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: Hiding symbols in a static library


On Sep 28, 2009, at 03:58, Erik de Castro Lopo wrote:
Ian Lance Taylor wrote:

If it's OK to use ld -r instead of building an archive, then it may
work to use ld -r with --retain-symbols-file.

I've tried a couple of different versions of this:


   ld -r --retain-symbols-file=Symbols.static \
       libA.a libB.a libC.a libD.a -o output.o

The four archives are all > 40kbytes, but the output file is always
257 bytes in size. Regardless of what I try, there are never any
warning or error messages.

Right, there's nothing to cause any of the objects to get pulled in from the archive libraries; "--retain-symbols-file" is just about trimming the symbol table. Add "-u symbol" options for specific symbols, or "--whole-archive" to just suck in everything.


I've also tried using object files instead of archives, but that creates
an object file still seems to export all the symbols that should be hidden.

Hm, that ought to work, I think... Check closely -- is it exporting them as global symbols, or retaining them after converting to local symbols so that they can still be used in relocations within the output file? I haven't looked at the mechanism of --retain-symbols- file in a lot of years, but I think it ought to be doing the latter.


Ken


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