diff options
author | Fangrui Song <i@maskray.me> | 2021-07-26 09:05:18 -0700 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2021-07-26 09:05:18 -0700 |
commit | 792c206e2b63c16075d759d3abc3eb5399ed74fe (patch) | |
tree | d196b238e5a1846ddcc986a221f726b4cecdec82 /llvm/tools/llvm-objcopy/ELF/Object.cpp | |
parent | c0da287c30c9f511ccb07fdd42c997be2caea9ec (diff) | |
download | llvm-792c206e2b63c16075d759d3abc3eb5399ed74fe.zip llvm-792c206e2b63c16075d759d3abc3eb5399ed74fe.tar.gz llvm-792c206e2b63c16075d759d3abc3eb5399ed74fe.tar.bz2 |
[llvm-objcopy] Drop GRP_COMDAT if the group signature is localized
See [GRP_COMDAT group with STB_LOCAL signature](https://groups.google.com/g/generic-abi/c/2X6mR-s2zoc)
objcopy PR: https://sourceware.org/bugzilla/show_bug.cgi?id=27931
GRP_COMDAT deduplication is purely based on the signature symbol name in
ld.lld/GNU ld/gold. The local/global status is not part of the equation.
If the signature symbol is localized by --localize-hidden or
--keep-global-symbol, the intention is likely to make the group fully
localized. Drop GRP_COMDAT to suppress deduplication.
Reviewed By: jhenderson
Differential Revision: https://reviews.llvm.org/D106782
Diffstat (limited to 'llvm/tools/llvm-objcopy/ELF/Object.cpp')
-rw-r--r-- | llvm/tools/llvm-objcopy/ELF/Object.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/tools/llvm-objcopy/ELF/Object.cpp b/llvm/tools/llvm-objcopy/ELF/Object.cpp index 0255fda..91a73f21 100644 --- a/llvm/tools/llvm-objcopy/ELF/Object.cpp +++ b/llvm/tools/llvm-objcopy/ELF/Object.cpp @@ -1069,6 +1069,12 @@ Error Section::removeSectionReferences( void GroupSection::finalize() { this->Info = Sym ? Sym->Index : 0; this->Link = SymTab ? SymTab->Index : 0; + // Linker deduplication for GRP_COMDAT is based on Sym->Name. The local/global + // status is not part of the equation. If Sym is localized, the intention is + // likely to make the group fully localized. Drop GRP_COMDAT to suppress + // deduplication. See https://groups.google.com/g/generic-abi/c/2X6mR-s2zoc + if ((FlagWord & GRP_COMDAT) && Sym && Sym->Binding == STB_LOCAL) + this->FlagWord &= ~GRP_COMDAT; } Error GroupSection::removeSectionReferences( |