Linker exposing private symbols
Michael Matz
matz@suse.de
Mon Aug 27 14:49:00 GMT 2018
More information about the Binutils mailing list
Mon Aug 27 14:49:00 GMT 2018
- Previous message (by thread): Linker exposing private symbols
- Next message (by thread): Linker exposing private symbols
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi, On Mon, 27 Aug 2018, Jeffrey Walton wrote: > I feel like the toolchain is misbehaving because I asked for 2 symbols > to be exported but that did not happen. > > There's nothing special about me. Others have encountered the same, > like https://stackoverflow.com/q/2222162/608639 and That one is confusing compiling and linking. > https://stackoverflow.com/q/37934388/608639 . And that one is misreading output of nm. > I'll have to think about things some more. Maybe the complaint is, we > asked GCC to ensure 2 symbols were exported (and the rest private) but > GCC did not fulfill the request when it drove link. I may be splitting > too many hairs, though. But you don't need to ask only the compiler, you also need to ask the link editor if foreign object files are involved (where the compiler didn't have a chance to mark symbols as hidden). What you effectively did was: (assume no hidden attributes in sources) % gcc -c file1.c % gcc -c -fvisibility=hidden file2.c % gcc -fvisibility=hidden -shared -o result.so file1.o file2.o and now expect that the symbols from file1 are hidden even though you didn't compile that file for this. (In your case the cryptopp.a file is a collection of files similar to file1.o) Well, as -fvisibility=hidden is a compile-only option it's ignored for the linking step. > >> Second, why is ALL case sensitive (and without a diagnostic)? Command line options and file names are generally case sensitive. > > Seems good to me. You asked ld to exclude All.a symbols. > > Just to play devils advocate... I don't have a library ALL.a either. To cite: --exclude-libs lib,lib,... Specifies a list of archive libraries from which symbols should not be automatically exported. The library names may be delimited by commas or colons. Specifying "--exclude-libs ALL" excludes symbols in all archive libraries from automatic export. This option is available only for the i386 PE targeted port of the linker and for ELF targeted ports. For i386 PE, symbols explicitly listed in a .def file are still exported, regardless of this option. For ELF targeted ports, symbols affected by this option will be treated as hidden. All working as documented and designed. (And yes, this means this won't work if you have in fact a static archive named ALL.a, tough luck). Ciao, Michael.
- Previous message (by thread): Linker exposing private symbols
- Next message (by thread): Linker exposing private symbols
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Binutils mailing list