public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Nick Clifton <nickc@redhat.com>
To: Tao Zhang <zhangtao@cc.gatech.edu>
Cc: binutils@sources.redhat.com
Subject: Re: A simple linker script question
Date: Mon, 21 Jun 2004 14:33:00 -0000	[thread overview]
Message-ID: <40D6F34E.7060001@redhat.com> (raw)
In-Reply-To: <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


  reply	other threads:[~2004-06-21 14:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-18 13:39 Tao Zhang
2004-06-21 14:33 ` Nick Clifton [this message]
2004-06-21 14:54   ` Tao Zhang
2004-06-25 16:53     ` Nick Clifton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=40D6F34E.7060001@redhat.com \
    --to=nickc@redhat.com \
    --cc=binutils@sources.redhat.com \
    --cc=zhangtao@cc.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).