[Object] Also treat STB_GNU_UNIQUE symbols as exported to other DSO

All of STB_GLOBAL/STB_WEAK/STB_GNU_UNIQUE are treated as export symbols, see:

glibc/elf/dl-lookup.c:do_lookup_x
musl/ldso/dynlink.c OK_BINDS

Though ld.so does not read binding, the currently used STV_DEFAULT or STV_PROTECTED is a good emulation of linker behavior.

llvm-svn: 347481
This commit is contained in:
Fangrui Song 2018-11-23 01:33:19 +00:00
parent 46acc72cf4
commit 32ebd73127
1 changed files with 4 additions and 3 deletions

View File

@ -333,9 +333,10 @@ protected:
// A symbol is exported if its binding is either GLOBAL or WEAK, and its
// visibility is either DEFAULT or PROTECTED. All other symbols are not
// exported.
return ((Binding == ELF::STB_GLOBAL || Binding == ELF::STB_WEAK) &&
(Visibility == ELF::STV_DEFAULT ||
Visibility == ELF::STV_PROTECTED));
return (
(Binding == ELF::STB_GLOBAL || Binding == ELF::STB_WEAK ||
Binding == ELF::STB_GNU_UNIQUE) &&
(Visibility == ELF::STV_DEFAULT || Visibility == ELF::STV_PROTECTED));
}
// This flag is used for classof, to distinguish ELFObjectFile from