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: Include archive member section with ld script (+ somewhat RFC)


On Wed, Jun 11, 2003 at 05:59:10PM +0200, Vincent Rubiolo wrote:
> how to include a given section of an 
> archive member in an ld script

See info node "Input Section Basics".  You want filename(section),
where "filename" is the archive member.  Note the last paragraph though!
ld will try to open "filename" if it doesn't contain a wildcard char.

You might use something like

SECTIONS {
.
.
  .foocode : { foo.?(.text) }
.
.
}

to put ".text" from archive member "foo.o" into output section
".foocode".  Note how I've sneakily used a wildcard to match "foo.o", so
that the linker doesn't try to find file "foo.o".

This example doesn't force the linker to actually include foo.o in
the link.  For that, you need to specify your library on the command
line (or via an INPUT command in the script), and arrange for foo.o
to be extracted.  ie. normal archive search rules apply, and members
will be included to satisfy some non-weak undefined symbol or if
--whole-archive is used.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


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