Object file questions

Timo Sintonen via D.gnu d.gnu at puremagic.com
Sat Aug 16 01:39:04 PDT 2014


On Saturday, 16 August 2014 at 07:36:07 UTC, Johannes Pfau wrote:

> Iain recently pushed a commit to put zero initializers into 
> bss, so
> that's intentional:
> http://bugzilla.gdcproject.org/show_bug.cgi?id=139
> But I understand your point that it should be in rodata 
> instead, you'll
> have to discuss this with Iain.

It is true that bss does not take place in the executable. But in 
small processors, even there is nowadays plenty of rom there is 
not enough ram. It is also a question of safety: in the long run, 
data area may be corrupted by buggy program or electrical distort 
while rodata in rom cannot be changed.
At least in my setup, gold maps bss to executable anyway while ld 
does not.

I noticed your comment in the bug report. I was just thinking the 
same: one big block of zeros that is used by all.
Another that I was thinking is that memset might be used for 
these types. Then there would be no block of zeros at all. But 
that would require an extra flag in typeinfo to separate these 
types from others...
>

> Regarding __Class: Can you post a short example?

Some lines from mapfile. Seems to be one for every type in the 
program:

  .data          0x0000000020001074      0x720 
minlibd/libdruntime/libdruntime.a(object_.o)
                 0x0000000020001074                
_D9Exception7__ClassZ
                 0x00000000200010c0                
_D8TypeInfo7__ClassZ
                 0x000000002000110c                
_D17TypeInfo_Function7__ClassZ
                 0x0000000020001158                
_D17TypeInfo_Delegate7__ClassZ
                 0x00000000200011a4                
_D14TypeInfo_Class7__ClassZ
                 0x00000000200011f0                
_D18TypeInfo_Interface7__ClassZ
                 0x000000002000123c                
_D15TypeInfo_Struct7__ClassZ
                 0x0000000020001288                
_D16TypeInfo_Typedef7__ClassZ

>
>> 
>> In my application there will be several large structs. I never 
>> create anything of these types. Instead I use them to point to 
>> hardware registers and maybe on top of existing byte arrays 
>> like message buffers. There will still be initial values for 
>> these structs wasting memory. Is there any way to omit them?
>> 
>
> See
> https://github.com/D-Programming-GDC/GDC/pull/82
> @attribute("noinit")

Yes this will solve the problem.



More information about the D.gnu mailing list