[llvm] r238513 - Don't special case undefined symbol when deciding the symbol order.
Rafael Espindola
rafael.espindola at gmail.com
Thu May 28 14:59:34 PDT 2015
Author: rafael
Date: Thu May 28 16:59:34 2015
New Revision: 238513
URL: http://llvm.org/viewvc/llvm-project?rev=238513&view=rev
Log:
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.
Modified:
llvm/trunk/lib/MC/ELFObjectWriter.cpp
llvm/trunk/test/MC/ARM/arm-elf-symver.s
llvm/trunk/test/MC/ARM/elf-movt.s
llvm/trunk/test/MC/ELF/alias.s
llvm/trunk/test/MC/ELF/strtab-suffix-opt.s
llvm/trunk/test/MC/ELF/symver.s
Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=238513&r1=238512&r2=238513&view=diff
==============================================================================
--- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Thu May 28 16:59:34 2015
@@ -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.
@@ -952,12 +950,6 @@ void ELFObjectWriter::computeSymbolTable
unsigned StringIndex = StrTabBuilder.getOffset(MSD.Name);
MSD.Symbol->setIndex(Index++);
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);
}
Modified: llvm/trunk/test/MC/ARM/arm-elf-symver.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/arm-elf-symver.s?rev=238513&r1=238512&r2=238513&view=diff
==============================================================================
--- llvm/trunk/test/MC/ARM/arm-elf-symver.s (original)
+++ llvm/trunk/test/MC/ARM/arm-elf-symver.s Thu May 28 16:59:34 2015
@@ -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 at 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 at 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 at 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 at 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: ]
Modified: llvm/trunk/test/MC/ARM/elf-movt.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/elf-movt.s?rev=238513&r1=238512&r2=238513&view=diff
==============================================================================
--- llvm/trunk/test/MC/ARM/elf-movt.s (original)
+++ llvm/trunk/test/MC/ARM/elf-movt.s Thu May 28 16:59:34 2015
@@ -53,6 +53,6 @@ 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: }
Modified: llvm/trunk/test/MC/ELF/alias.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/alias.s?rev=238513&r1=238512&r2=238513&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/alias.s (original)
+++ llvm/trunk/test/MC/ELF/alias.s Thu May 28 16:59:34 2015
@@ -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: ]
Modified: llvm/trunk/test/MC/ELF/strtab-suffix-opt.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/strtab-suffix-opt.s?rev=238513&r1=238512&r2=238513&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/strtab-suffix-opt.s (original)
+++ llvm/trunk/test/MC/ELF/strtab-suffix-opt.s Thu May 28 16:59:34 2015
@@ -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)
Modified: llvm/trunk/test/MC/ELF/symver.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/symver.s?rev=238513&r1=238512&r2=238513&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/symver.s (original)
+++ llvm/trunk/test/MC/ELF/symver.s Thu May 28 16:59:34 2015
@@ -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 at 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 at 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 at 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 at 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: ]
More information about the llvm-commits
mailing list