21.12.2011 0:22, Walter Bright пишет:
First off, dmd most definitely puts 0 initialized static data into the
BSS segment. So what's going on here?

1. char data is not initialized to 0, it is initialized to 0xFF.
Non-zero data cannot be put in BSS.
Sorry, it was because of copying C code in my post. ubyte array was tested in D.

2. Static data goes, by default, into thread local storage. BSS data is
not thread local. To put it in global data, it has to be declared with
__gshared.
I completely forgot about TLS.

So,

__gshared byte arr[1024 * 1024 *10];

will go into BSS.

There is pretty much no reason to have such huge arrays in static data.
Instead, dynamically allocate them.
Of course, it was just an example of a huge executable.


Now I see that dmd uses BSS , thank you for the explanation!

I still think that zero-filled TLS arrays can occupy no size in the executable, but it should be done with compiler and D run-time system support and surely it is not worth the time it will take to implement.

I apologize for the unfair accusation.

Reply via email to