This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: linker scripts and linker sections


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]