public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* A simple linker script question
@ 2004-06-18 13:39 Tao Zhang
  2004-06-21 14:33 ` Nick Clifton
  0 siblings, 1 reply; 4+ messages in thread
From: Tao Zhang @ 2004-06-18 13:39 UTC (permalink / raw)
  To: binutils

Hi,

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?

Thanks a lot

Tao


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: A simple linker script question
  2004-06-18 13:39 A simple linker script question Tao Zhang
@ 2004-06-21 14:33 ` Nick Clifton
  2004-06-21 14:54   ` Tao Zhang
  0 siblings, 1 reply; 4+ messages in thread
From: Nick Clifton @ 2004-06-21 14:33 UTC (permalink / raw)
  To: Tao Zhang; +Cc: binutils

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: A simple linker script question
  2004-06-21 14:33 ` Nick Clifton
@ 2004-06-21 14:54   ` Tao Zhang
  2004-06-25 16:53     ` Nick Clifton
  0 siblings, 1 reply; 4+ messages in thread
From: Tao Zhang @ 2004-06-21 14:54 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: A simple linker script question
  2004-06-21 14:54   ` Tao Zhang
@ 2004-06-25 16:53     ` Nick Clifton
  0 siblings, 0 replies; 4+ messages in thread
From: Nick Clifton @ 2004-06-25 16:53 UTC (permalink / raw)
  To: Tao Zhang; +Cc: binutils

Hi Tao,

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

I am sorry, but I just do not think that this is possible with the 
current implementation of the linker.  Can you give us more information 
about what you are trying to do ?  Perhaps there is a different way that 
the same results can be achieved.

Cheers
   Nick


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-06-25 16:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-18 13:39 A simple linker script question Tao Zhang
2004-06-21 14:33 ` Nick Clifton
2004-06-21 14:54   ` Tao Zhang
2004-06-25 16:53     ` Nick Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).