This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: A simple linker script question
- From: Nick Clifton <nickc at redhat dot com>
- To: Tao Zhang <zhangtao at cc dot gatech dot edu>
- Cc: binutils at sources dot redhat dot com
- Date: Mon, 21 Jun 2004 15:40:14 +0100
- Subject: Re: A simple linker script question
- References: <Pine.GSO.4.58.0406180936330.22766@gaia.cc.gatech.edu>
Hi Tao,
I am new to linker script. I just want to write one to place all system
library code before the user code. Could anybody give me some hint on
that?
First of all - why do you need to do this ?
Secondly do you mean that you want to put the contents of the sections
in the system libraries before similarly named sections in the user
code, or do you want to put the entire contents of the system libraries
before the user code ?
For example given a system library sys.a containing a .text section and
a .data section and a user file user.o also containing a .text and a
.data section, how do you want the final executable to appear ? Should
it have one .text section containing the contents of the .text section
from sys.a and then the contents of the .text section from user.o, and
followed by a single .data section containing the contents of the .data
sections from sys.a and user.o. Or, should the output file have two
.text sections, one from sys.a and one from user.o, with the one from
sys.a occurring first in the memory map, and similarly two .data sections ?
Assuming you want a single .text section and a single .data section then
you can do something like this in your linker script:
SECTIONS {
.text : { *(EXCLUDE_FILE (user.o).text)
*(.text) }
.data : { *(EXCLUDE_FILE (user.o).data)
*(.data) }
}
Cheers
Nick