linker scripts and linker sections

Matthew J Fletcher
Mon Oct 28 07:25:00 GMT 2002

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 vairables 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).

i have had most sucess using a linker script to move the sections like
this,... (note i am using x86 ELF linux)

	. = 0x08048000 + SIZEOF_HEADERS;

	.outvar :{
		__outvar_start = . ;


		__outvar_stop = . ;

	// other section stuff snipped

in C code i then,..

memset((void*)&__outvar_start,0,(&__outvar_stop - &__outvar_start));

(gdb) p &__outvar_start
$2 = 0x808a8a0 ""
(gdb) p &__outvar_stop
$3 = 0x808c0f4 <Address 0x808c0f4 out of bounds>

what does this mean ?


Matthew J Fletcher
Serck Controls Ltd
Phone (UK Direct) 02476 515089

Serck Controls Ltd, Rowley Drive, Coventry, CV3 4FH, UK
Tel: 44 (0) 24 7630 5050   Fax: 44 (0) 24 7630 2437
Web:  Admin:
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the above.  Any views or opinions presented are solely those of the
author and do not necessarily represent those of Serck Controls Ltd.
Please note that Serck Controls Ltd is able to, and reserves the right
to, monitor e-mail communications passing through its network.
This email has been checked for viruses.  Serck Controls Ltd shall not
be responsible for damage caused by any undetected virus.
Serck Controls Ltd is a subsidiary of Hunter Watertech Pty.
Registered in England No. 4353634.

This message has been checked for all known viruses by MessageLabs

Want more information?  See the CrossGCC FAQ,
Want to unsubscribe? Send a note to

More information about the crossgcc mailing list