Re: [OT] text,data and bss
On Sun, 16 Nov 2008 22:27:37 +0000, Richard Tobin wrote:
Oh, sure, initialised to whatever random bytes the compiler happened to
have in memory when laying out the .data section or equivalent is
effectively uninitialised to me.
But depending on the number of bytes, it may be a waste of space to store
them all when there's no need to do so. To use an extreme example:
union {
double d;
char a[1000000];
} u;
Is there a benefit in filling a[sizeof(double)] through a[999999] in the
generated object or at startup? The drawback seems obvious to me.
Especially if u.d needs to be filled in the startup code anyway (let's say
because the system doesn't have a .data section or equivalent), I can
imagine the rest of a being semi-random.
On Sun, 16 Nov 2008 22:27:37 +0000, Richard Tobin wrote:
In article <gfprf1$kof$1@n ews.motzarella. org>, Harald van Dijk
<truedfx@gmail. comwrote:
>
>
>
>
Quite so. Is there some reason you think I'm disputing that?
>
If 0.0 is all zeros, then a zero-initialised section can be used for it.
If it's not, then you need something like .data that can be initialised
to any value. Neither case suggests a .bss that is not initialised at
all.
<truedfx@gmail. comwrote:
>>>>But "unitialise d" static variables are implicitly initialised to
>>>>zero. There are no really-uninitialised static variables in C.
>>>>zero. There are no really-uninitialised static variables in C.
>>>>What about the bytes of a union that are not part of the initialised
>>>>sub- object?
>>>>sub- object?
>>I suppose so. But you could hardly put them in a different section
>>from the initialised bytes of the union, so there's still no use for a
>>really-uninitialised section.
>>from the initialised bytes of the union, so there's still no use for a
>>really-uninitialised section.
>>On systems where pointer types or floating-point types are not
>>initialised to all-bits zero (which are admittedly uncommon, but real),
>>and the initialised member of the union is of pointer or floating-point
>>type, it doesn't make sense to put the union in a zero-initialised
>>section.
>>initialised to all-bits zero (which are admittedly uncommon, but real),
>>and the initialised member of the union is of pointer or floating-point
>>type, it doesn't make sense to put the union in a zero-initialised
>>section.
Quite so. Is there some reason you think I'm disputing that?
>
If 0.0 is all zeros, then a zero-initialised section can be used for it.
If it's not, then you need something like .data that can be initialised
to any value. Neither case suggests a .bss that is not initialised at
all.
have in memory when laying out the .data section or equivalent is
effectively uninitialised to me.
But depending on the number of bytes, it may be a waste of space to store
them all when there's no need to do so. To use an extreme example:
union {
double d;
char a[1000000];
} u;
Is there a benefit in filling a[sizeof(double)] through a[999999] in the
generated object or at startup? The drawback seems obvious to me.
Especially if u.d needs to be filled in the startup code anyway (let's say
because the system doesn't have a .data section or equivalent), I can
imagine the rest of a being semi-random.
Comment