This is the mail archive of the binutils@sourceware.org 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: how to link a section in specific .o inside .a via linker script?


Hi Mat,

I am creating a linker script to place sections at exactly the
addresses I want them.

However, I want a specific section from a specific .o file that is
inside a specific .a file.

The problem here is that the purpose of libraries is to allow the linker to choose which, if any, of the object files it contains should be included in the final output. If you know in advance that you are definitely going to need a particular object file that is normally held in a library then the "proper" way of doing things would be to extract it from the library first, and then include it on the linker command line.


> I've been playing around with an experimental patch to fix this, where
there is a new (admittedly ugly) MEMBER operator in the linker script
that lets you specify a pair of a .a and .o file, that you can use in
place of any normal (possibly wildcarded) filename, e.g in my case:

    /* Only get .text section from bar.o inside foo.a */
    .text : { MEMBER(foo.a , bar.o)(.text) }

Interesting. Would this syntax mean that .text section from bar.o *has* to be included in the linker's output at this point, or that it *might* be included in the output, but only if the linker decides that bar.o is needed ?


Cheers
  Nick


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