From 40102eb27f294b81c967b19943a020525febfbf6 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 17 Sep 2015 18:26:25 +0000 Subject: [PATCH] Use a MapVector to output symbols in a deterministic order. We used to sort the symbols at the very end, but we need to know the order earlier so that we can create reference to them in the dynamic relocations. Thanks to Igor Kudrin for pointing out the problem. llvm-svn: 247911 --- lld/ELF/SymbolTable.h | 14 +- lld/ELF/Writer.cpp | 10 - lld/test/elf2/common.s | 29 +-- lld/test/elf2/dynamic-reloc-index.s | 21 ++ lld/test/elf2/resolution.s | 388 ++++++++++++++-------------- lld/test/elf2/symbols.s | 44 ++-- 6 files changed, 261 insertions(+), 245 deletions(-) create mode 100644 lld/test/elf2/dynamic-reloc-index.s diff --git a/lld/ELF/SymbolTable.h b/lld/ELF/SymbolTable.h index 7c4ac815aa76..be7c32483b6c 100644 --- a/lld/ELF/SymbolTable.h +++ b/lld/ELF/SymbolTable.h @@ -11,8 +11,7 @@ #define LLD_ELF_SYMBOL_TABLE_H #include "InputFiles.h" -#include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/DenseMapInfo.h" +#include "llvm/ADT/MapVector.h" namespace lld { namespace elf2 { @@ -44,7 +43,7 @@ public: bool shouldUseRela() const; - const llvm::DenseMap &getSymbols() const { + const llvm::MapVector &getSymbols() const { return Symtab; } @@ -74,7 +73,14 @@ private: std::vector> ArchiveFiles; - llvm::DenseMap Symtab; + // The order the global symbols are in is not defined. We can use an arbitrary + // order, but it has to be reproducible. That is true even when cross linking. + // The default hashing of StringRef produces different results on 32 and 64 + // bit systems so we use a MapVector. That is arbitrary, deterministic but + // a bit inefficient. + // FIXME: Experiment with passing in a custom hashing or sorting the symbols + // once symbol resolution is finished. + llvm::MapVector Symtab; llvm::BumpPtrAllocator Alloc; // The writer needs to infer the machine type from the object files. diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 7c9e7cf7a40a..460c1a2ea248 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -699,8 +699,6 @@ template void SymbolTableSection::writeTo(uint8_t *Buf) { } } - uint8_t *GlobalStart = Buf; - for (auto &P : Table.getSymbols()) { StringRef Name = P.first; Symbol *Sym = P.second; @@ -755,14 +753,6 @@ template void SymbolTableSection::writeTo(uint8_t *Buf) { Buf += sizeof(Elf_Sym); } - - // The order the global symbols are in is not defined. We can use an arbitrary - // order, but it has to be reproducible. That is true even when cross linking. - // The default hashing of StringRef produces different results on 32 and 64 - // bit systems so we sort by st_name. That is arbitrary but deterministic. - // FIXME: Experiment with passing in a custom hashing instead. - auto *Syms = reinterpret_cast(GlobalStart); - array_pod_sort(Syms, Syms + NumVisible - NumLocals, compareSym); } template diff --git a/lld/test/elf2/common.s b/lld/test/elf2/common.s index 6c19e4e8bffe..f455c2be4625 100644 --- a/lld/test/elf2/common.s +++ b/lld/test/elf2/common.s @@ -14,18 +14,9 @@ // CHECK-NEXT: Offset: // CHECK-NEXT: Size: 22 - -// CHECK: Name: sym4 -// CHECK-NEXT: Value: 0x11000 -// CHECK-NEXT: Size: 4 -// CHECK-NEXT: Binding: Global -// CHECK-NEXT: Type: Object -// CHECK-NEXT: Other: 0 -// CHECK-NEXT: Section: .bss - -// CHECK: Name: sym3 -// CHECK-NEXT: Value: 0x11014 -// CHECK-NEXT: Size: 2 +// CHECK: Name: sym1 +// CHECK-NEXT: Value: 0x11004 +// CHECK-NEXT: Size: 8 // CHECK-NEXT: Binding: Global // CHECK-NEXT: Type: Object // CHECK-NEXT: Other: 0 @@ -39,9 +30,17 @@ // CHECK-NEXT: Other: 0 // CHECK-NEXT: Section: .bss -// CHECK: Name: sym1 -// CHECK-NEXT: Value: 0x11004 -// CHECK-NEXT: Size: 8 +// CHECK: Name: sym3 +// CHECK-NEXT: Value: 0x11014 +// CHECK-NEXT: Size: 2 +// CHECK-NEXT: Binding: Global +// CHECK-NEXT: Type: Object +// CHECK-NEXT: Other: 0 +// CHECK-NEXT: Section: .bss + +// CHECK: Name: sym4 +// CHECK-NEXT: Value: 0x11000 +// CHECK-NEXT: Size: 4 // CHECK-NEXT: Binding: Global // CHECK-NEXT: Type: Object // CHECK-NEXT: Other: 0 diff --git a/lld/test/elf2/dynamic-reloc-index.s b/lld/test/elf2/dynamic-reloc-index.s new file mode 100644 index 000000000000..294595b9fb95 --- /dev/null +++ b/lld/test/elf2/dynamic-reloc-index.s @@ -0,0 +1,21 @@ +// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o +// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/shared.s -o %t2.o +// RUN: lld -flavor gnu2 -shared %t2.o -o %t2.so +// RUN: lld -flavor gnu2 %t.o %t2.so -o %t +// RUN: llvm-readobj -r %t | FileCheck %s + +// We used to record the wrong symbol index for this test + +// CHECK: Relocations [ +// CHECK-NEXT: Section ({{.*}}) .rela.dyn { +// CHECK-NEXT: 0x11000 R_X86_64_64 bar 0x0 +// CHECK-NEXT: } +// CHECK-NEXT: ] + + .global foobar +foobar: + .global zedx +zedx: + .global _start +_start: +.quad bar diff --git a/lld/test/elf2/resolution.s b/lld/test/elf2/resolution.s index 526aceea1e46..6a095966d774 100644 --- a/lld/test/elf2/resolution.s +++ b/lld/test/elf2/resolution.s @@ -28,36 +28,27 @@ // CHECK-NEXT: Section: .text // CHECK-NEXT: } // CHECK-NEXT: Symbol { -// CHECK-NEXT: Name: RegularWeak_with_RegularWeak +// CHECK-NEXT: Name: CommonStrong_with_CommonStrong // CHECK-NEXT: Value: -// CHECK-NEXT: Size: 0 -// CHECK-NEXT: Binding: Weak -// CHECK-NEXT: Type: None -// CHECK-NEXT: Other: 0 -// CHECK-NEXT: Section: .text -// CHECK-NEXT: } -// CHECK-NEXT: Symbol { -// CHECK-NEXT: Name: CommonWeak_with_RegularWeak -// CHECK-NEXT: Value: -// CHECK-NEXT: Size: 20 -// CHECK-NEXT: Binding: Weak +// CHECK-NEXT: Size: 63 +// CHECK-NEXT: Binding: Global // CHECK-NEXT: Type: Object // CHECK-NEXT: Other: 0 // CHECK-NEXT: Section: // CHECK-NEXT: } // CHECK-NEXT: Symbol { -// CHECK-NEXT: Name: UndefWeak_with_RegularWeak +// CHECK-NEXT: Name: CommonStrong_with_CommonWeak // CHECK-NEXT: Value: -// CHECK-NEXT: Size: 43 -// CHECK-NEXT: Binding: Weak -// CHECK-NEXT: Type: None +// CHECK-NEXT: Size: 30 +// CHECK-NEXT: Binding: Global +// CHECK-NEXT: Type: Object // CHECK-NEXT: Other: 0 -// CHECK-NEXT: Section: .text +// CHECK-NEXT: Section: // CHECK-NEXT: } // CHECK-NEXT: Symbol { -// CHECK-NEXT: Name: RegularStrong_with_RegularWeak +// CHECK-NEXT: Name: CommonStrong_with_RegularStrong // CHECK-NEXT: Value: -// CHECK-NEXT: Size: 2 +// CHECK-NEXT: Size: 55 // CHECK-NEXT: Binding: Global // CHECK-NEXT: Type: None // CHECK-NEXT: Other: 0 @@ -73,105 +64,15 @@ // CHECK-NEXT: Section: // CHECK-NEXT: } // CHECK-NEXT: Symbol { -// CHECK-NEXT: Name: UndefStrong_with_RegularWeak +// CHECK-NEXT: Name: CommonStrong_with_UndefStrong // CHECK-NEXT: Value: -// CHECK-NEXT: Size: 45 -// CHECK-NEXT: Binding: Weak -// CHECK-NEXT: Type: None -// CHECK-NEXT: Other: 0 -// CHECK-NEXT: Section: .text -// CHECK-NEXT: } -// CHECK-NEXT: Symbol { -// CHECK-NEXT: Name: RegularWeak_with_CommonWeak -// CHECK-NEXT: Value: -// CHECK-NEXT: Size: 7 -// CHECK-NEXT: Binding: Weak -// CHECK-NEXT: Type: None -// CHECK-NEXT: Other: 0 -// CHECK-NEXT: Section: .text -// CHECK-NEXT: } -// CHECK-NEXT: Symbol { -// CHECK-NEXT: Name: CommonWeak_with_CommonWeak -// CHECK-NEXT: Value: -// CHECK-NEXT: Size: 28 -// CHECK-NEXT: Binding: Weak -// CHECK-NEXT: Type: Object -// CHECK-NEXT: Other: 0 -// CHECK-NEXT: Section: -// CHECK-NEXT: } -// CHECK-NEXT: Symbol { -// CHECK-NEXT: Name: UndefWeak_with_CommonWeak -// CHECK-NEXT: Value: -// CHECK-NEXT: Size: 48 -// CHECK-NEXT: Binding: Weak -// CHECK-NEXT: Type: Object -// CHECK-NEXT: Other: 0 -// CHECK-NEXT: Section: -// CHECK-NEXT: } -// CHECK-NEXT: Symbol { -// CHECK-NEXT: Name: RegularStrong_with_CommonWeak -// CHECK-NEXT: Value: -// CHECK-NEXT: Size: 9 -// CHECK-NEXT: Binding: Global -// CHECK-NEXT: Type: None -// CHECK-NEXT: Other: 0 -// CHECK-NEXT: Section: .text -// CHECK-NEXT: } -// CHECK-NEXT: Symbol { -// CHECK-NEXT: Name: CommonStrong_with_CommonWeak -// CHECK-NEXT: Value: -// CHECK-NEXT: Size: 30 +// CHECK-NEXT: Size: 27 // CHECK-NEXT: Binding: Global // CHECK-NEXT: Type: Object // CHECK-NEXT: Other: 0 // CHECK-NEXT: Section: // CHECK-NEXT: } // CHECK-NEXT: Symbol { -// CHECK-NEXT: Name: UndefStrong_with_CommonWeak -// CHECK-NEXT: Value: -// CHECK-NEXT: Size: 50 -// CHECK-NEXT: Binding: Weak -// CHECK-NEXT: Type: Object -// CHECK-NEXT: Other: 0 -// CHECK-NEXT: Section: -// CHECK-NEXT: } -// CHECK-NEXT: Symbol { -// CHECK-NEXT: Name: RegularWeak_with_UndefWeak -// CHECK-NEXT: Value: -// CHECK-NEXT: Size: 3 -// CHECK-NEXT: Binding: Weak -// CHECK-NEXT: Type: None -// CHECK-NEXT: Other: 0 -// CHECK-NEXT: Section: .text -// CHECK-NEXT: } -// CHECK-NEXT: Symbol { -// CHECK-NEXT: Name: CommonWeak_with_UndefWeak -// CHECK-NEXT: Value: -// CHECK-NEXT: Size: 24 -// CHECK-NEXT: Binding: Weak -// CHECK-NEXT: Type: Object -// CHECK-NEXT: Other: 0 -// CHECK-NEXT: Section: -// CHECK-NEXT: } -// CHECK-NEXT: Symbol { -// CHECK-NEXT: Name: UndefWeak_with_UndefWeak -// CHECK-NEXT: Value: 0x0 -// CHECK-NEXT: Size: 15 -// CHECK-NEXT: Binding: Weak -// CHECK-NEXT: Type: None -// CHECK-NEXT: Other: 0 -// CHECK-NEXT: Section: Undefined -// CHECK-NEXT: } -// CHECK-NEXT: Symbol { -// CHECK-NEXT: Name: RegularStrong_with_UndefWeak -// CHECK-NEXT: Value: -// CHECK-NEXT: Size: 5 -// CHECK-NEXT: Binding: Global -// CHECK-NEXT: Type: None -// CHECK-NEXT: Other: 0 -// CHECK-NEXT: Section: .text -// CHECK-NEXT: } -// CHECK-NEXT: Symbol { // CHECK-NEXT: Name: CommonStrong_with_UndefWeak // CHECK-NEXT: Value: // CHECK-NEXT: Size: 26 @@ -181,60 +82,6 @@ // CHECK-NEXT: Section: // CHECK-NEXT: } // CHECK-NEXT: Symbol { -// CHECK-NEXT: Name: RegularWeak_with_RegularStrong -// CHECK-NEXT: Value: -// CHECK-NEXT: Size: 33 -// CHECK-NEXT: Binding: Global -// CHECK-NEXT: Type: None -// CHECK-NEXT: Other: 0 -// CHECK-NEXT: Section: .text -// CHECK-NEXT: } -// CHECK-NEXT: Symbol { -// CHECK-NEXT: Name: CommonWeak_with_RegularStrong -// CHECK-NEXT: Value: -// CHECK-NEXT: Size: 53 -// CHECK-NEXT: Binding: Global -// CHECK-NEXT: Type: None -// CHECK-NEXT: Other: 0 -// CHECK-NEXT: Section: .text -// CHECK-NEXT: } -// CHECK-NEXT: Symbol { -// CHECK-NEXT: Name: UndefWeak_with_RegularStrong -// CHECK-NEXT: Value: -// CHECK-NEXT: Size: 44 -// CHECK-NEXT: Binding: Global -// CHECK-NEXT: Type: None -// CHECK-NEXT: Other: 0 -// CHECK-NEXT: Section: .text -// CHECK-NEXT: } -// CHECK-NEXT: Symbol { -// CHECK-NEXT: Name: CommonStrong_with_RegularStrong -// CHECK-NEXT: Value: -// CHECK-NEXT: Size: 55 -// CHECK-NEXT: Binding: Global -// CHECK-NEXT: Type: None -// CHECK-NEXT: Other: 0 -// CHECK-NEXT: Section: .text -// CHECK-NEXT: } -// CHECK-NEXT: Symbol { -// CHECK-NEXT: Name: UndefStrong_with_RegularStrong -// CHECK-NEXT: Value: -// CHECK-NEXT: Size: 46 -// CHECK-NEXT: Binding: Global -// CHECK-NEXT: Type: None -// CHECK-NEXT: Other: 0 -// CHECK-NEXT: Section: .text -// CHECK-NEXT: } -// CHECK-NEXT: Symbol { -// CHECK-NEXT: Name: RegularWeak_with_CommonStrong -// CHECK-NEXT: Value: -// CHECK-NEXT: Size: 40 -// CHECK-NEXT: Binding: Global -// CHECK-NEXT: Type: Object -// CHECK-NEXT: Other: 0 -// CHECK-NEXT: Section: -// CHECK-NEXT: } -// CHECK-NEXT: Symbol { // CHECK-NEXT: Name: CommonWeak_with_CommonStrong // CHECK-NEXT: Value: // CHECK-NEXT: Size: 61 @@ -244,10 +91,46 @@ // CHECK-NEXT: Section: // CHECK-NEXT: } // CHECK-NEXT: Symbol { -// CHECK-NEXT: Name: UndefWeak_with_CommonStrong +// CHECK-NEXT: Name: CommonWeak_with_CommonWeak // CHECK-NEXT: Value: -// CHECK-NEXT: Size: 49 +// CHECK-NEXT: Size: 28 +// CHECK-NEXT: Binding: Weak +// CHECK-NEXT: Type: Object +// CHECK-NEXT: Other: 0 +// CHECK-NEXT: Section: +// CHECK-NEXT: } +// CHECK-NEXT: Symbol { +// CHECK-NEXT: Name: CommonWeak_with_RegularStrong +// CHECK-NEXT: Value: +// CHECK-NEXT: Size: 53 // CHECK-NEXT: Binding: Global +// CHECK-NEXT: Type: None +// CHECK-NEXT: Other: 0 +// CHECK-NEXT: Section: .text +// CHECK-NEXT: } +// CHECK-NEXT: Symbol { +// CHECK-NEXT: Name: CommonWeak_with_RegularWeak +// CHECK-NEXT: Value: +// CHECK-NEXT: Size: 20 +// CHECK-NEXT: Binding: Weak +// CHECK-NEXT: Type: Object +// CHECK-NEXT: Other: 0 +// CHECK-NEXT: Section: +// CHECK-NEXT: } +// CHECK-NEXT: Symbol { +// CHECK-NEXT: Name: CommonWeak_with_UndefStrong +// CHECK-NEXT: Value: +// CHECK-NEXT: Size: 25 +// CHECK-NEXT: Binding: Weak +// CHECK-NEXT: Type: Object +// CHECK-NEXT: Other: 0 +// CHECK-NEXT: Section: +// CHECK-NEXT: } +// CHECK-NEXT: Symbol { +// CHECK-NEXT: Name: CommonWeak_with_UndefWeak +// CHECK-NEXT: Value: +// CHECK-NEXT: Size: 24 +// CHECK-NEXT: Binding: Weak // CHECK-NEXT: Type: Object // CHECK-NEXT: Other: 0 // CHECK-NEXT: Section: @@ -262,40 +145,22 @@ // CHECK-NEXT: Section: .text // CHECK-NEXT: } // CHECK-NEXT: Symbol { -// CHECK-NEXT: Name: CommonStrong_with_CommonStrong +// CHECK-NEXT: Name: RegularStrong_with_CommonWeak // CHECK-NEXT: Value: -// CHECK-NEXT: Size: 63 +// CHECK-NEXT: Size: 9 // CHECK-NEXT: Binding: Global -// CHECK-NEXT: Type: Object -// CHECK-NEXT: Other: 0 -// CHECK-NEXT: Section: -// CHECK-NEXT: } -// CHECK-NEXT: Symbol { -// CHECK-NEXT: Name: UndefStrong_with_CommonStrong -// CHECK-NEXT: Value: -// CHECK-NEXT: Size: 51 -// CHECK-NEXT: Binding: Global -// CHECK-NEXT: Type: Object -// CHECK-NEXT: Other: 0 -// CHECK-NEXT: Section: -// CHECK-NEXT: } -// CHECK-NEXT: Symbol { -// CHECK-NEXT: Name: RegularWeak_with_UndefStrong -// CHECK-NEXT: Value: -// CHECK-NEXT: Size: 4 -// CHECK-NEXT: Binding: Weak // CHECK-NEXT: Type: None // CHECK-NEXT: Other: 0 // CHECK-NEXT: Section: .text // CHECK-NEXT: } // CHECK-NEXT: Symbol { -// CHECK-NEXT: Name: CommonWeak_with_UndefStrong +// CHECK-NEXT: Name: RegularStrong_with_RegularWeak // CHECK-NEXT: Value: -// CHECK-NEXT: Size: 25 -// CHECK-NEXT: Binding: Weak -// CHECK-NEXT: Type: Object +// CHECK-NEXT: Size: 2 +// CHECK-NEXT: Binding: Global +// CHECK-NEXT: Type: None // CHECK-NEXT: Other: 0 -// CHECK-NEXT: Section: +// CHECK-NEXT: Section: .text // CHECK-NEXT: } // CHECK-NEXT: Symbol { // CHECK-NEXT: Name: RegularStrong_with_UndefStrong @@ -307,14 +172,149 @@ // CHECK-NEXT: Section: .text // CHECK-NEXT: } // CHECK-NEXT: Symbol { -// CHECK-NEXT: Name: CommonStrong_with_UndefStrong +// CHECK-NEXT: Name: RegularStrong_with_UndefWeak // CHECK-NEXT: Value: -// CHECK-NEXT: Size: 27 +// CHECK-NEXT: Size: 5 +// CHECK-NEXT: Binding: Global +// CHECK-NEXT: Type: None +// CHECK-NEXT: Other: 0 +// CHECK-NEXT: Section: .text +// CHECK-NEXT: } +// CHECK-NEXT: Symbol { +// CHECK-NEXT: Name: RegularWeak_with_CommonStrong +// CHECK-NEXT: Value: +// CHECK-NEXT: Size: 40 // CHECK-NEXT: Binding: Global // CHECK-NEXT: Type: Object // CHECK-NEXT: Other: 0 // CHECK-NEXT: Section: // CHECK-NEXT: } +// CHECK-NEXT: Symbol { +// CHECK-NEXT: Name: RegularWeak_with_CommonWeak +// CHECK-NEXT: Value: +// CHECK-NEXT: Size: 7 +// CHECK-NEXT: Binding: Weak +// CHECK-NEXT: Type: None +// CHECK-NEXT: Other: 0 +// CHECK-NEXT: Section: .text +// CHECK-NEXT: } +// CHECK-NEXT: Symbol { +// CHECK-NEXT: Name: RegularWeak_with_RegularStrong +// CHECK-NEXT: Value: +// CHECK-NEXT: Size: 33 +// CHECK-NEXT: Binding: Global +// CHECK-NEXT: Type: None +// CHECK-NEXT: Other: 0 +// CHECK-NEXT: Section: .text +// CHECK-NEXT: } +// CHECK-NEXT: Symbol { +// CHECK-NEXT: Name: RegularWeak_with_RegularWeak +// CHECK-NEXT: Value: +// CHECK-NEXT: Size: 0 +// CHECK-NEXT: Binding: Weak +// CHECK-NEXT: Type: None +// CHECK-NEXT: Other: 0 +// CHECK-NEXT: Section: .text +// CHECK-NEXT: } +// CHECK-NEXT: Symbol { +// CHECK-NEXT: Name: RegularWeak_with_UndefStrong +// CHECK-NEXT: Value: +// CHECK-NEXT: Size: 4 +// CHECK-NEXT: Binding: Weak +// CHECK-NEXT: Type: None +// CHECK-NEXT: Other: 0 +// CHECK-NEXT: Section: .text +// CHECK-NEXT: } +// CHECK-NEXT: Symbol { +// CHECK-NEXT: Name: RegularWeak_with_UndefWeak +// CHECK-NEXT: Value: +// CHECK-NEXT: Size: 3 +// CHECK-NEXT: Binding: Weak +// CHECK-NEXT: Type: None +// CHECK-NEXT: Other: 0 +// CHECK-NEXT: Section: .text +// CHECK-NEXT: } +// CHECK-NEXT: Symbol { +// CHECK-NEXT: Name: UndefStrong_with_CommonStrong +// CHECK-NEXT: Value: +// CHECK-NEXT: Size: 51 +// CHECK-NEXT: Binding: Global +// CHECK-NEXT: Type: Object +// CHECK-NEXT: Other: 0 +// CHECK-NEXT: Section: +// CHECK-NEXT: } +// CHECK-NEXT: Symbol { +// CHECK-NEXT: Name: UndefStrong_with_CommonWeak +// CHECK-NEXT: Value: +// CHECK-NEXT: Size: 50 +// CHECK-NEXT: Binding: Weak +// CHECK-NEXT: Type: Object +// CHECK-NEXT: Other: 0 +// CHECK-NEXT: Section: +// CHECK-NEXT: } +// CHECK-NEXT: Symbol { +// CHECK-NEXT: Name: UndefStrong_with_RegularStrong +// CHECK-NEXT: Value: +// CHECK-NEXT: Size: 46 +// CHECK-NEXT: Binding: Global +// CHECK-NEXT: Type: None +// CHECK-NEXT: Other: 0 +// CHECK-NEXT: Section: .text +// CHECK-NEXT: } +// CHECK-NEXT: Symbol { +// CHECK-NEXT: Name: UndefStrong_with_RegularWeak +// CHECK-NEXT: Value: +// CHECK-NEXT: Size: 45 +// CHECK-NEXT: Binding: Weak +// CHECK-NEXT: Type: None +// CHECK-NEXT: Other: 0 +// CHECK-NEXT: Section: .text +// CHECK-NEXT: } +// CHECK-NEXT: Symbol { +// CHECK-NEXT: Name: UndefWeak_with_CommonStrong +// CHECK-NEXT: Value: +// CHECK-NEXT: Size: 49 +// CHECK-NEXT: Binding: Global +// CHECK-NEXT: Type: Object +// CHECK-NEXT: Other: 0 +// CHECK-NEXT: Section: +// CHECK-NEXT: } +// CHECK-NEXT: Symbol { +// CHECK-NEXT: Name: UndefWeak_with_CommonWeak +// CHECK-NEXT: Value: +// CHECK-NEXT: Size: 48 +// CHECK-NEXT: Binding: Weak +// CHECK-NEXT: Type: Object +// CHECK-NEXT: Other: 0 +// CHECK-NEXT: Section: +// CHECK-NEXT: } +// CHECK-NEXT: Symbol { +// CHECK-NEXT: Name: UndefWeak_with_RegularStrong +// CHECK-NEXT: Value: +// CHECK-NEXT: Size: 44 +// CHECK-NEXT: Binding: Global +// CHECK-NEXT: Type: None +// CHECK-NEXT: Other: 0 +// CHECK-NEXT: Section: .text +// CHECK-NEXT: } +// CHECK-NEXT: Symbol { +// CHECK-NEXT: Name: UndefWeak_with_RegularWeak +// CHECK-NEXT: Value: +// CHECK-NEXT: Size: 43 +// CHECK-NEXT: Binding: Weak +// CHECK-NEXT: Type: None +// CHECK-NEXT: Other: 0 +// CHECK-NEXT: Section: .text +// CHECK-NEXT: } +// CHECK-NEXT: Symbol { +// CHECK-NEXT: Name: UndefWeak_with_UndefWeak +// CHECK-NEXT: Value: 0x0 +// CHECK-NEXT: Size: 15 +// CHECK-NEXT: Binding: Weak +// CHECK-NEXT: Type: None +// CHECK-NEXT: Other: 0 +// CHECK-NEXT: Section: Undefined +// CHECK-NEXT: } // CHECK-NEXT: ] .globl _start diff --git a/lld/test/elf2/symbols.s b/lld/test/elf2/symbols.s index 892a37919ee3..d1572ac48887 100644 --- a/lld/test/elf2/symbols.s +++ b/lld/test/elf2/symbols.s @@ -108,6 +108,15 @@ internal: // CHECK-NEXT: Section: Undefined (0x0) // CHECK-NEXT: } // CHECK-NEXT: Symbol { +// CHECK-NEXT: Name: common +// CHECK-NEXT: Value: 0x12000 +// CHECK-NEXT: Size: 4 +// CHECK-NEXT: Binding: Global +// CHECK-NEXT: Type: Object +// CHECK-NEXT: Other: 0 +// CHECK-NEXT: Section: .bss +// CHECK-NEXT: } +// CHECK-NEXT: Symbol { // CHECK-NEXT: Name: foo // CHECK-NEXT: Value: 0x11000 // CHECK-NEXT: Size: 0 @@ -117,24 +126,6 @@ internal: // CHECK-NEXT: Section: .text // CHECK-NEXT: } // CHECK-NEXT: Symbol { -// CHECK-NEXT: Name: common (34) -// CHECK-NEXT: Value: 0x12000 -// CHECK-NEXT: Size: 4 -// CHECK-NEXT: Binding: Global (0x1) -// CHECK-NEXT: Type: Object (0x1) -// CHECK-NEXT: Other: 0 -// CHECK-NEXT: Section: .bss -// CHECK-NEXT: } -// CHECK-NEXT: Symbol { -// CHECK-NEXT: Name: zed -// CHECK-NEXT: Value: 0x13000 -// CHECK-NEXT: Size: 0 -// CHECK-NEXT: Binding: Global (0x1) -// CHECK-NEXT: Type: None -// CHECK-NEXT: Other: 0 -// CHECK-NEXT: Section: foobar -// CHECK-NEXT: } -// CHECK-NEXT: Symbol { // CHECK-NEXT: Name: protected // CHECK-NEXT: Value: 0x13008 // CHECK-NEXT: Size: 0 @@ -144,10 +135,10 @@ internal: // CHECK-NEXT: Section: foobar // CHECK-NEXT: } // CHECK-NEXT: Symbol { -// CHECK-NEXT: Name: zed3 -// CHECK-NEXT: Value: 0x13008 -// CHECK-NEXT: Size: 4 -// CHECK-NEXT: Binding: Global +// CHECK-NEXT: Name: zed +// CHECK-NEXT: Value: 0x13000 +// CHECK-NEXT: Size: 0 +// CHECK-NEXT: Binding: Global (0x1) // CHECK-NEXT: Type: None // CHECK-NEXT: Other: 0 // CHECK-NEXT: Section: foobar @@ -161,4 +152,13 @@ internal: // CHECK-NEXT: Other: 0 // CHECK-NEXT: Section: foobar // CHECK-NEXT: } +// CHECK-NEXT: Symbol { +// CHECK-NEXT: Name: zed3 +// CHECK-NEXT: Value: 0x13008 +// CHECK-NEXT: Size: 4 +// CHECK-NEXT: Binding: Global +// CHECK-NEXT: Type: None +// CHECK-NEXT: Other: 0 +// CHECK-NEXT: Section: foobar +// CHECK-NEXT: } // CHECK-NEXT: ]