mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
[llvm-objcopy] Don't apply --localize flags to common symbols
Summary: --localize-symbol and --localize-hidden will currently localize common symbols. GNU objcopy will not localize these symbols even when explicitly requested, which seems reasonable; common symbols should always be global so they can be merged during linking. See PR39461 Reviewers: jakehehrlich, jhenderson, alexshap, MaskRay, espindola Reviewed By: jakehehrlich, jhenderson, alexshap, MaskRay Subscribers: emaste, arichardson, alexshap, MaskRay, llvm-commits Differential Revision: https://reviews.llvm.org/D53782 llvm-svn: 345856
This commit is contained in:
parent
e7a610a737
commit
f78bbcd84a
@ -55,6 +55,12 @@ Symbols:
|
||||
Value: 0x2006
|
||||
Size: 2
|
||||
Visibility: STV_HIDDEN
|
||||
- Name: hiddenGlobalCommon
|
||||
Type: STT_OBJECT
|
||||
Index: SHN_COMMON
|
||||
Value: 0x2006
|
||||
Size: 2
|
||||
Visibility: STV_HIDDEN
|
||||
- Name: undefGlobal
|
||||
Type: STT_FUNC
|
||||
Size: 8
|
||||
@ -142,6 +148,17 @@ Symbols:
|
||||
#CHECK-NEXT: Section: .text
|
||||
#CHECK-NEXT: }
|
||||
#CHECK-NEXT: Symbol {
|
||||
#CHECK-NEXT: Name: hiddenGlobalCommon
|
||||
#CHECK-NEXT: Value: 0x2006
|
||||
#CHECK-NEXT: Size: 2
|
||||
#CHECK-NEXT: Binding: Global
|
||||
#CHECK-NEXT: Type: Object
|
||||
#CHECK-NEXT: Other [
|
||||
#CHECK-NEXT: STV_HIDDEN
|
||||
#CHECK-NEXT: ]
|
||||
#CHECK-NEXT: Section: Common (0xF
|
||||
#CHECK-NEXT: }
|
||||
#CHECK-NEXT: Symbol {
|
||||
#CHECK-NEXT: Name: undefGlobal
|
||||
#CHECK-NEXT: Value: 0x0
|
||||
#CHECK-NEXT: Size: 8
|
||||
|
@ -1,5 +1,10 @@
|
||||
# RUN: yaml2obj %s > %t
|
||||
# RUN: llvm-objcopy --localize-symbol Global -L Local -L Weak %t %t2
|
||||
# RUN: llvm-objcopy \
|
||||
# RUN: --localize-symbol Global \
|
||||
# RUN: -L Local \
|
||||
# RUN: -L Weak \
|
||||
# RUN: -L GlobalCommon \
|
||||
# RUN: %t %t2
|
||||
# RUN: llvm-readobj -symbols %t2 | FileCheck %s
|
||||
|
||||
!ELF
|
||||
@ -40,6 +45,11 @@ Symbols:
|
||||
Size: 8
|
||||
Section: .text
|
||||
Value: 0x1010
|
||||
- Name: GlobalCommon
|
||||
Type: STT_OBJECT
|
||||
Index: SHN_COMMON
|
||||
Value: 0x2006
|
||||
Size: 2
|
||||
|
||||
#CHECK: Symbols [
|
||||
#CHECK-NEXT: Symbol {
|
||||
@ -78,4 +88,13 @@ Symbols:
|
||||
#CHECK-NEXT: Other: 0
|
||||
#CHECK-NEXT: Section: .text
|
||||
#CHECK-NEXT: }
|
||||
#CHECK-NEXT: Symbol {
|
||||
#CHECK-NEXT: Name: GlobalCommon
|
||||
#CHECK-NEXT: Value: 0x2006
|
||||
#CHECK-NEXT: Size: 2
|
||||
#CHECK-NEXT: Binding: Global
|
||||
#CHECK-NEXT: Type: Object
|
||||
#CHECK-NEXT: Other: 0
|
||||
#CHECK-NEXT: Section: Common (0xF
|
||||
#CHECK-NEXT: }
|
||||
#CHECK-NEXT:]
|
||||
|
@ -213,10 +213,11 @@ static void handleArgs(const CopyConfig &Config, Object &Obj,
|
||||
// them.
|
||||
if (Obj.SymbolTable) {
|
||||
Obj.SymbolTable->updateSymbols([&](Symbol &Sym) {
|
||||
if ((Config.LocalizeHidden &&
|
||||
(Sym.Visibility == STV_HIDDEN || Sym.Visibility == STV_INTERNAL)) ||
|
||||
(!Config.SymbolsToLocalize.empty() &&
|
||||
is_contained(Config.SymbolsToLocalize, Sym.Name)))
|
||||
if (!Sym.isCommon() &&
|
||||
((Config.LocalizeHidden &&
|
||||
(Sym.Visibility == STV_HIDDEN || Sym.Visibility == STV_INTERNAL)) ||
|
||||
(!Config.SymbolsToLocalize.empty() &&
|
||||
is_contained(Config.SymbolsToLocalize, Sym.Name))))
|
||||
Sym.Binding = STB_LOCAL;
|
||||
|
||||
// Note: these two globalize flags have very similar names but different
|
||||
|
@ -332,6 +332,8 @@ uint16_t Symbol::getShndx() const {
|
||||
llvm_unreachable("Symbol with invalid ShndxType encountered");
|
||||
}
|
||||
|
||||
bool Symbol::isCommon() const { return getShndx() == SHN_COMMON; }
|
||||
|
||||
void SymbolTableSection::assignIndices() {
|
||||
uint32_t Index = 0;
|
||||
for (auto &Sym : Symbols)
|
||||
|
@ -415,6 +415,7 @@ struct Symbol {
|
||||
bool Referenced = false;
|
||||
|
||||
uint16_t getShndx() const;
|
||||
bool isCommon() const;
|
||||
};
|
||||
|
||||
class SectionIndexSection : public SectionBase {
|
||||
|
Loading…
Reference in New Issue
Block a user