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: A simple linker script question


Hi, Nick

Thanks a lot for your reply. I am working on a weird problem and I need
to play with the program binary layout a little bit.

I understand the piece of linker script you wrote in your email, it will
place non-user code and data before user code and data. What if I want
more fine grained control?  Say I want to place libfoo.a before libbar.a,
I need to do some patten matching. That's my current problem. I think the
names of the input libraries have full path with them, for example,
/usr/lib/libfoo.a(foo1.o). I don't know how to pattern match those '/' and
'(' and ')' in linker script. I tried single and double quote and it looks
not working. Could anybody give some help?

Thanks so much

Tao



			-Tao Zhang (zhangtao@cc.gatech.edu)

On Mon, 21 Jun 2004, Nick Clifton wrote:

> 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
>
>
>


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