This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: linker scripts and linker sections
- From: Nick Clifton <nickc at redhat dot com>
- To: mfletcher at serck-controls dot co dot uk
- Cc: binutils at sources dot redhat dot com
- Date: 04 Nov 2002 17:25:37 +0000
- Subject: Re: linker scripts and linker sections
- References: <NGBBJIAFBJAGPBMIINJJKEOJCAAA.mfletcher@serck-controls.co.uk>
Hi Matthew,
> may i ask if anybody on this list has attempted to or knows how to
> simule the microsoft VC++ #pragmas data_seg and bss_seg.
>
> these pragmas move variables into sections e.g
>
> #pragma bss_seg(.mybss)
> int one;
> bool two;
> float three;
> #pragma bss_seg()
>
> this is instead of using the gcc __attribute__ to do the same,.. as
> it would have to be added to every variable declaration (and i have
> many, many).
Have you tried compiling these source files with "-fno-common" ? This
should force uninitialised variables to be placed in the .bss
section. You could then use a linker script or objcopy's
--rename-section switch to move them into a section called .mybss.
Alternatively you could try adding support for the #pragma bss_seg to
GCC.
> SECTIONS {
> . = 0x08048000 + SIZEOF_HEADERS;
>
> .outvar :{
> __outvar_start = . ;
>
> ./osfiles/debug/*(.bss)
>
> __outvar_stop = . ;
> }
> (gdb) p &__outvar_start
> $2 = 0x808a8a0 ""
> (gdb) p &__outvar_stop
> $3 = 0x808c0f4 <Address 0x808c0f4 out of bounds>
>
> what does this mean ?
It means that the address of __outvar_stop is not in valid memory.
This is because the linker has assigned it the address immediately
*after* the last of the *(.bss) sections.
Cheers
Nick