diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2015-05-28 21:59:34 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2015-05-28 21:59:34 +0000 |
commit | fb48de619e2bac3f4fe3aeda06a7b1c08fc4d623 (patch) | |
tree | 3cb40a0234dba4e42f288cfec2c06b19d411be63 | |
parent | 6882d57ef2f8eb56e7682b99a84746054785e2d2 (diff) |
Don't special case undefined symbol when deciding the symbol order.
ELF has no restrictions on where undefined symbols go relative to other defined
symbols. In fact, gas just sorts them together. Do the same.
This was there since r111174 probably just because the MachO writer has it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238513 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/MC/ELFObjectWriter.cpp | 10 | ||||
-rw-r--r-- | test/MC/ARM/arm-elf-symver.s | 24 | ||||
-rw-r--r-- | test/MC/ARM/elf-movt.s | 2 | ||||
-rw-r--r-- | test/MC/ELF/alias.s | 8 | ||||
-rw-r--r-- | test/MC/ELF/strtab-suffix-opt.s | 2 | ||||
-rw-r--r-- | test/MC/ELF/symver.s | 24 |
6 files changed, 31 insertions, 39 deletions
diff --git a/lib/MC/ELFObjectWriter.cpp b/lib/MC/ELFObjectWriter.cpp index 39efaf16cf1..9bfe679b449 100644 --- a/lib/MC/ELFObjectWriter.cpp +++ b/lib/MC/ELFObjectWriter.cpp @@ -805,7 +805,6 @@ void ELFObjectWriter::computeSymbolTable( std::vector<ELFSymbolData> LocalSymbolData; std::vector<ELFSymbolData> ExternalSymbolData; - std::vector<ELFSymbolData> UndefinedSymbolData; // Add the data for the symbols. bool HasLargeSectionIndex = false; @@ -902,7 +901,7 @@ void ELFObjectWriter::computeSymbolTable( MSD.Name = StrTabBuilder.add(Name); if (MSD.SectionIndex == ELF::SHN_UNDEF) - UndefinedSymbolData.push_back(MSD); + ExternalSymbolData.push_back(MSD); else if (Local) LocalSymbolData.push_back(MSD); else @@ -930,7 +929,6 @@ void ELFObjectWriter::computeSymbolTable( // Symbols are required to be in lexicographic order. array_pod_sort(LocalSymbolData.begin(), LocalSymbolData.end()); array_pod_sort(ExternalSymbolData.begin(), ExternalSymbolData.end()); - array_pod_sort(UndefinedSymbolData.begin(), UndefinedSymbolData.end()); // Set the symbol indices. Local symbols must come before all other // symbols with non-local bindings. @@ -954,12 +952,6 @@ void ELFObjectWriter::computeSymbolTable( writeSymbol(Writer, StringIndex, MSD, Layout); assert(MCELF::GetBinding(MSD.Symbol->getData()) != ELF::STB_LOCAL); } - for (ELFSymbolData &MSD : UndefinedSymbolData) { - unsigned StringIndex = StrTabBuilder.getOffset(MSD.Name); - MSD.Symbol->setIndex(Index++); - writeSymbol(Writer, StringIndex, MSD, Layout); - assert(MCELF::GetBinding(MSD.Symbol->getData()) != ELF::STB_LOCAL); - } uint64_t SecEnd = OS.tell(); SectionOffsets[SymtabSection] = std::make_pair(SecStart, SecEnd); diff --git a/test/MC/ARM/arm-elf-symver.s b/test/MC/ARM/arm-elf-symver.s index 4303540e82a..b39197080bd 100644 --- a/test/MC/ARM/arm-elf-symver.s +++ b/test/MC/ARM/arm-elf-symver.s @@ -105,39 +105,39 @@ global1: @ CHECK-NEXT: Section: .bss @ CHECK-NEXT: } @ CHECK-NEXT: Symbol { -@ CHECK-NEXT: Name: g1@@zed -@ CHECK-NEXT: Value: 0x14 +@ CHECK-NEXT: Name: bar2@zed +@ CHECK-NEXT: Value: 0x0 @ CHECK-NEXT: Size: 0 @ CHECK-NEXT: Binding: Global (0x1) @ CHECK-NEXT: Type: None (0x0) @ CHECK-NEXT: Other: 0 -@ CHECK-NEXT: Section: .text +@ CHECK-NEXT: Section: Undefined (0x0) @ CHECK-NEXT: } @ CHECK-NEXT: Symbol { -@ CHECK-NEXT: Name: global1 -@ CHECK-NEXT: Value: 0x14 +@ CHECK-NEXT: Name: bar6@zed +@ CHECK-NEXT: Value: 0x0 @ CHECK-NEXT: Size: 0 @ CHECK-NEXT: Binding: Global (0x1) @ CHECK-NEXT: Type: None (0x0) @ CHECK-NEXT: Other: 0 -@ CHECK-NEXT: Section: .text +@ CHECK-NEXT: Section: Undefined (0x0) @ CHECK-NEXT: } @ CHECK-NEXT: Symbol { -@ CHECK-NEXT: Name: bar2@zed -@ CHECK-NEXT: Value: 0x0 +@ CHECK-NEXT: Name: g1@@zed +@ CHECK-NEXT: Value: 0x14 @ CHECK-NEXT: Size: 0 @ CHECK-NEXT: Binding: Global (0x1) @ CHECK-NEXT: Type: None (0x0) @ CHECK-NEXT: Other: 0 -@ CHECK-NEXT: Section: Undefined (0x0) +@ CHECK-NEXT: Section: .text @ CHECK-NEXT: } @ CHECK-NEXT: Symbol { -@ CHECK-NEXT: Name: bar6@zed -@ CHECK-NEXT: Value: 0x0 +@ CHECK-NEXT: Name: global1 +@ CHECK-NEXT: Value: 0x14 @ CHECK-NEXT: Size: 0 @ CHECK-NEXT: Binding: Global (0x1) @ CHECK-NEXT: Type: None (0x0) @ CHECK-NEXT: Other: 0 -@ CHECK-NEXT: Section: Undefined (0x0) +@ CHECK-NEXT: Section: .text @ CHECK-NEXT: } @ CHECK-NEXT: ] diff --git a/test/MC/ARM/elf-movt.s b/test/MC/ARM/elf-movt.s index 0fd77754795..4fcd63c4a9d 100644 --- a/test/MC/ARM/elf-movt.s +++ b/test/MC/ARM/elf-movt.s @@ -53,6 +53,6 @@ barf: @ @barf @ OBJ-NEXT: 0x4 R_ARM_MOVT_PREL @ OBJ-NEXT: ] @ OBJ-NEXT: SectionData ( -@ OBJ-NEXT: 0000: 00000000 2D060000 04000000 2E060000 |....-...........| +@ OBJ-NEXT: 0000: 00000000 2D050000 04000000 2E050000 |....-...........| @ OBJ-NEXT: ) @ OBJ-NEXT: } diff --git a/test/MC/ELF/alias.s b/test/MC/ELF/alias.s index 0ab6dd4b5b8..92621bc660a 100644 --- a/test/MC/ELF/alias.s +++ b/test/MC/ELF/alias.s @@ -119,21 +119,21 @@ leaq .Llocal1(%rip), %rdi // CHECK-NOT: Symbol { // CHECK: } // CHECK-NEXT: Symbol { -// CHECK-NEXT: Name: bar3 +// CHECK-NEXT: Name: bar2 // CHECK-NEXT: Value: 0x0 // CHECK-NEXT: Size: 0 // CHECK-NEXT: Binding: Global // CHECK-NEXT: Type: None // CHECK-NEXT: Other: 0 -// CHECK-NEXT: Section: .text +// CHECK-NEXT: Section: Undefined (0x0) // CHECK-NEXT: } // CHECK-NEXT: Symbol { -// CHECK-NEXT: Name: bar2 +// CHECK-NEXT: Name: bar3 // CHECK-NEXT: Value: 0x0 // CHECK-NEXT: Size: 0 // CHECK-NEXT: Binding: Global // CHECK-NEXT: Type: None // CHECK-NEXT: Other: 0 -// CHECK-NEXT: Section: Undefined (0x0) +// CHECK-NEXT: Section: .text // CHECK-NEXT: } // CHECK-NEXT: ] diff --git a/test/MC/ELF/strtab-suffix-opt.s b/test/MC/ELF/strtab-suffix-opt.s index 05246564460..96d15005c61 100644 --- a/test/MC/ELF/strtab-suffix-opt.s +++ b/test/MC/ELF/strtab-suffix-opt.s @@ -16,6 +16,6 @@ foobar: .Ltmp3: .size foobar, .Ltmp3-foobar -// CHECK: Name: foobar (16) // CHECK: Name: bar (19) // CHECK: Name: foo (23) +// CHECK: Name: foobar (16) diff --git a/test/MC/ELF/symver.s b/test/MC/ELF/symver.s index 80d71fd0e06..178c0ff3cb7 100644 --- a/test/MC/ELF/symver.s +++ b/test/MC/ELF/symver.s @@ -104,39 +104,39 @@ global1: // CHECK-NEXT: Section: .bss // CHECK-NEXT: } // CHECK-NEXT: Symbol { -// CHECK-NEXT: Name: g1@@zed -// CHECK-NEXT: Value: 0x14 +// CHECK-NEXT: Name: bar2@zed +// CHECK-NEXT: Value: 0x0 // CHECK-NEXT: Size: 0 // CHECK-NEXT: Binding: Global // CHECK-NEXT: Type: None // CHECK-NEXT: Other: 0 -// CHECK-NEXT: Section: .text +// CHECK-NEXT: Section: Undefined // CHECK-NEXT: } // CHECK-NEXT: Symbol { -// CHECK-NEXT: Name: global1 -// CHECK-NEXT: Value: 0x14 +// CHECK-NEXT: Name: bar6@zed +// CHECK-NEXT: Value: 0x0 // CHECK-NEXT: Size: 0 // CHECK-NEXT: Binding: Global // CHECK-NEXT: Type: None // CHECK-NEXT: Other: 0 -// CHECK-NEXT: Section: .text +// CHECK-NEXT: Section: Undefined // CHECK-NEXT: } // CHECK-NEXT: Symbol { -// CHECK-NEXT: Name: bar2@zed -// CHECK-NEXT: Value: 0x0 +// CHECK-NEXT: Name: g1@@zed +// CHECK-NEXT: Value: 0x14 // CHECK-NEXT: Size: 0 // CHECK-NEXT: Binding: Global // CHECK-NEXT: Type: None // CHECK-NEXT: Other: 0 -// CHECK-NEXT: Section: Undefined +// CHECK-NEXT: Section: .text // CHECK-NEXT: } // CHECK-NEXT: Symbol { -// CHECK-NEXT: Name: bar6@zed -// CHECK-NEXT: Value: 0x0 +// CHECK-NEXT: Name: global1 +// CHECK-NEXT: Value: 0x14 // CHECK-NEXT: Size: 0 // CHECK-NEXT: Binding: Global // CHECK-NEXT: Type: None // CHECK-NEXT: Other: 0 -// CHECK-NEXT: Section: Undefined +// CHECK-NEXT: Section: .text // CHECK-NEXT: } // CHECK-NEXT: ] |