diff --git a/include/eld/Config/LinkerConfig.h b/include/eld/Config/LinkerConfig.h index 3d18459b6..4a8222cd6 100644 --- a/include/eld/Config/LinkerConfig.h +++ b/include/eld/Config/LinkerConfig.h @@ -60,6 +60,10 @@ class LinkerConfig { Unset ///< Undetermine code position mode }; + // FIXME: ARM/RISCV/X86 disable multithreading in ScanRelocations and + // ApplyRelocations by default, likely to avoid non-determinism. With + // dynsym order now fixed, revisit those defaults and whether per phase + // granularity is still needed. enum EnableThreadsOpt { NoThreads = 0, AssignOutputSections = 0x1, diff --git a/lib/Core/Module.cpp b/lib/Core/Module.cpp index 057328218..f29ad865f 100644 --- a/lib/Core/Module.cpp +++ b/lib/Core/Module.cpp @@ -378,28 +378,32 @@ bool Module::sortCommonSymbols() { } bool Module::sortSymbols() { - std::stable_sort(Symbols.begin(), Symbols.end(), - static_cast( - [](ResolveInfo *A, ResolveInfo *B) -> bool { - // Section symbols always appear first. - if (A->type() == ResolveInfo::Section && - (B->type() != ResolveInfo::Section)) - return true; - if (A->type() != ResolveInfo::Section && - (B->type() == ResolveInfo::Section)) - return false; - if (A->isLocal() && !B->isLocal()) - return true; - if (!A->isLocal() && B->isLocal()) - return false; - // All undefs appear after sections. - if (A->isUndef() && !B->isUndef()) - return true; - if (!A->isUndef() && B->isUndef()) - return false; - return A->outSymbol()->value() < - B->outSymbol()->value(); - })); + auto Cmp = [](ResolveInfo *A, ResolveInfo *B) -> bool { + // Section symbols always appear first. + if (A->type() == ResolveInfo::Section && + (B->type() != ResolveInfo::Section)) + return true; + if (A->type() != ResolveInfo::Section && + (B->type() == ResolveInfo::Section)) + return false; + // ELF requires all locals before all globals. + if (A->isLocal() != B->isLocal()) + return A->isLocal(); + // Deterministic order: by (input ordinal, input .symtab index). + auto OrdA = A->resolvedOrigin()->getInput()->getInputOrdinal(); + auto OrdB = B->resolvedOrigin()->getInput()->getInputOrdinal(); + if (OrdA != OrdB) + return OrdA < OrdB; + if (A->outSymbol()->getSymbolIndex() != B->outSymbol()->getSymbolIndex()) + return A->outSymbol()->getSymbolIndex() < + B->outSymbol()->getSymbolIndex(); + // Linker-created symbols share an input and carry no input .symtab index; + // break ties by final address then name to keep the order total. + if (A->outSymbol()->value() != B->outSymbol()->value()) + return A->outSymbol()->value() < B->outSymbol()->value(); + return A->getName() < B->getName(); + }; + llvm::stable_sort(Symbols, Cmp); return true; } diff --git a/lib/Target/GNULDBackend.cpp b/lib/Target/GNULDBackend.cpp index 8953bdfeb..038c5744c 100644 --- a/lib/Target/GNULDBackend.cpp +++ b/lib/Target/GNULDBackend.cpp @@ -818,6 +818,25 @@ void GNULDBackend::sizeDynNamePools() { // Copy all the DynamicSymbols. std::copy(PartitionBegin, RVect.end(), std::back_inserter(DynamicSymbols)); + + // Deterministic .dynsym order: undefined symbols first, then defined; + // within each group by (input ordinal, input .symtab index). + auto Cmp = [](const ResolveInfo *A, const ResolveInfo *B) -> bool { + bool UndA = A->isUndef() || A->isDyn(); + bool UndB = B->isUndef() || B->isDyn(); + if (UndA != UndB) + return UndA; + auto OrdA = A->resolvedOrigin()->getInput()->getInputOrdinal(); + auto OrdB = B->resolvedOrigin()->getInput()->getInputOrdinal(); + if (OrdA != OrdB) + return OrdA < OrdB; + return A->outSymbol()->getSymbolIndex() < + B->outSymbol()->getSymbolIndex(); + }; + // Skip the null symbol at index 0. + llvm::stable_sort( + llvm::make_range(DynamicSymbols.begin() + 1, DynamicSymbols.end()), + Cmp); } { diff --git a/test/AArch64/standalone/KeepCommonSymbols/KeepCommonSymbols.test b/test/AArch64/standalone/KeepCommonSymbols/KeepCommonSymbols.test index 202b0ab27..7c8d68d7c 100644 --- a/test/AArch64/standalone/KeepCommonSymbols/KeepCommonSymbols.test +++ b/test/AArch64/standalone/KeepCommonSymbols/KeepCommonSymbols.test @@ -8,9 +8,9 @@ RUN: %clang %clangopts -fcommon -c %p/Inputs/1.c -o %t1.1.o RUN: %link %linkopts -o %t1.1.out %t1.1.o --gc-sections -e main -T %p/Inputs/1.script RUN: %readelf -s %t1.1.out | %filecheck %s #END_TEST -#CHECK: b_common #CHECK: a_common #CHECK: f_common +#CHECK: b_common #CHECK-NOT: c_common #CHECK-NOT: d_common #CHECK-NOT: e_common diff --git a/test/AArch64/standalone/Reloc_gotpage_lo15/R_AARCH64_LD64_GOTPAGE_LO15.test b/test/AArch64/standalone/Reloc_gotpage_lo15/R_AARCH64_LD64_GOTPAGE_LO15.test index cad70aaf2..c858568de 100644 --- a/test/AArch64/standalone/Reloc_gotpage_lo15/R_AARCH64_LD64_GOTPAGE_LO15.test +++ b/test/AArch64/standalone/Reloc_gotpage_lo15/R_AARCH64_LD64_GOTPAGE_LO15.test @@ -6,8 +6,8 @@ RUN: %clang %clangopts -c %p/Inputs/a.s -fPIC -o %t1.1.o -target aarch64 RUN: %link %linkopts %t1.1.o -shared -o %t1.so -march aarch64 RUN: %objdump -d --dynamic-reloc %t1.so | %filecheck %s -#CHECK-DAG: 00000000000010f0 R_AARCH64_GLOB_DAT first -#CHECK-DAG: 00000000000010f8 R_AARCH64_GLOB_DAT second +#CHECK: 00000000000010f0 R_AARCH64_GLOB_DAT first +#CHECK-NEXT: 00000000000010f8 R_AARCH64_GLOB_DAT second #CHECK: 1b8: b0000000 adrp x0, 0x1000 #CHECK: 1bc: 9103c000 add x0, x0, #0xf0 diff --git a/test/AArch64/standalone/linkerscript/excludeFile/excludeFiles.test b/test/AArch64/standalone/linkerscript/excludeFile/excludeFiles.test index bd6da8792..4a2176b4b 100644 --- a/test/AArch64/standalone/linkerscript/excludeFile/excludeFiles.test +++ b/test/AArch64/standalone/linkerscript/excludeFile/excludeFiles.test @@ -9,8 +9,8 @@ RUN: %readelf -S -s %t.out | %filecheck %s CHECK: .section1 PROGBITS CHECK: .others PROGBITS -CHECK: FUNC GLOBAL DEFAULT 1 main_4 +CHECK: FUNC GLOBAL DEFAULT 2 main_1 CHECK: FUNC GLOBAL DEFAULT 1 main_5 CHECK: OBJECT GLOBAL DEFAULT 1 a5 -CHECK: FUNC GLOBAL DEFAULT 2 main_1 +CHECK: FUNC GLOBAL DEFAULT 1 main_4 CHECK: OBJECT GLOBAL DEFAULT 2 a4 diff --git a/test/ARM/standalone/KeepCommonSymbols/KeepCommonSymbols.test b/test/ARM/standalone/KeepCommonSymbols/KeepCommonSymbols.test index 202b0ab27..7c8d68d7c 100644 --- a/test/ARM/standalone/KeepCommonSymbols/KeepCommonSymbols.test +++ b/test/ARM/standalone/KeepCommonSymbols/KeepCommonSymbols.test @@ -8,9 +8,9 @@ RUN: %clang %clangopts -fcommon -c %p/Inputs/1.c -o %t1.1.o RUN: %link %linkopts -o %t1.1.out %t1.1.o --gc-sections -e main -T %p/Inputs/1.script RUN: %readelf -s %t1.1.out | %filecheck %s #END_TEST -#CHECK: b_common #CHECK: a_common #CHECK: f_common +#CHECK: b_common #CHECK-NOT: c_common #CHECK-NOT: d_common #CHECK-NOT: e_common diff --git a/test/ARM/standalone/linkerscript/excludeFile/excludeFiles.test b/test/ARM/standalone/linkerscript/excludeFile/excludeFiles.test index e2783bde3..431789eb2 100644 --- a/test/ARM/standalone/linkerscript/excludeFile/excludeFiles.test +++ b/test/ARM/standalone/linkerscript/excludeFile/excludeFiles.test @@ -9,9 +9,9 @@ RUN: %readelf -S -s %t.out | %filecheck %s CHECK: .section1 PROGBITS CHECK: .others PROGBITS -CHECK: FUNC GLOBAL DEFAULT 1 main_4 +CHECK: FUNC GLOBAL DEFAULT 2 main_1 CHECK: FUNC GLOBAL DEFAULT 1 main_5 CHECK: OBJECT GLOBAL DEFAULT 1 a5 -CHECK: FUNC GLOBAL DEFAULT 2 main_1 +CHECK: FUNC GLOBAL DEFAULT 1 main_4 CHECK: OBJECT GLOBAL DEFAULT 2 a4 diff --git a/test/Common/standalone/DeterministicDynsym/DeterministicDynsym.test b/test/Common/standalone/DeterministicDynsym/DeterministicDynsym.test new file mode 100644 index 000000000..22c755e9e --- /dev/null +++ b/test/Common/standalone/DeterministicDynsym/DeterministicDynsym.test @@ -0,0 +1,64 @@ +## Repeated links of the same inputs into a shared library must produce +## identical output, even with multithreaded scanning. + +# UNSUPPORTED: x86 + +# RUN: rm -rf %t && split-file %s %t +# RUN: %clang %clangopts -c -fPIC -ffunction-sections -fdata-sections %t/a.c -o %t/a.o +# RUN: %clang %clangopts -c -fPIC -ffunction-sections -fdata-sections %t/b.c -o %t/b.o +# RUN: %clang %clangopts -c -fPIC -ffunction-sections -fdata-sections %t/c.c -o %t/c.o + +# RUN: %link %linkopts -shared --threads --enable-threads=all %t/a.o %t/b.o %t/c.o -o %t1.so +# RUN: %link %linkopts -shared --threads --enable-threads=all %t/a.o %t/b.o %t/c.o -o %t2.so +# RUN: %link %linkopts -shared --threads --enable-threads=all %t/a.o %t/b.o %t/c.o -o %t3.so +# RUN: %link %linkopts -shared --threads --enable-threads=all %t/a.o %t/b.o %t/c.o -o %t4.so +# RUN: %link %linkopts -shared --threads --enable-threads=all %t/a.o %t/b.o %t/c.o -o %t5.so +# RUN: %link %linkopts -shared --threads --enable-threads=all %t/a.o %t/b.o %t/c.o -o %t6.so +# RUN: %link %linkopts -shared --threads --enable-threads=all %t/a.o %t/b.o %t/c.o -o %t7.so +# RUN: %link %linkopts -shared --threads --enable-threads=all %t/a.o %t/b.o %t/c.o -o %t8.so + +# RUN: %readelf -a %t1.so > %t1.dump +# RUN: %readelf -a %t2.so > %t2.dump +# RUN: %readelf -a %t3.so > %t3.dump +# RUN: %readelf -a %t4.so > %t4.dump +# RUN: %readelf -a %t5.so > %t5.dump +# RUN: %readelf -a %t6.so > %t6.dump +# RUN: %readelf -a %t7.so > %t7.dump +# RUN: %readelf -a %t8.so > %t8.dump +# RUN: %diff %t1.dump %t2.dump +# RUN: %diff %t1.dump %t3.dump +# RUN: %diff %t1.dump %t4.dump +# RUN: %diff %t1.dump %t5.dump +# RUN: %diff %t1.dump %t6.dump +# RUN: %diff %t1.dump %t7.dump +# RUN: %diff %t1.dump %t8.dump + +#--- a.c +extern int va1, va2, va3, va4, va5, va6, va7, va8; +extern void fa1(void), fa2(void), fa3(void), fa4(void); +int sum_a(void) { + return va1 + va2 + va3 + va4 + va5 + va6 + va7 + va8; +} +void call_a(void) { fa1(); fa2(); fa3(); fa4(); } +int da1 = 1, da2 = 2, da3 = 3, da4 = 4; +const char sa1[] = "a1", sa2[] = "a2"; + +#--- b.c +extern int vb1, vb2, vb3, vb4, vb5, vb6, vb7, vb8; +extern void fb1(void), fb2(void), fb3(void), fb4(void); +int sum_b(void) { + return vb1 + vb2 + vb3 + vb4 + vb5 + vb6 + vb7 + vb8; +} +void call_b(void) { fb1(); fb2(); fb3(); fb4(); } +int db1 = 1, db2 = 2, db3 = 3, db4 = 4; +const char sb1[] = "b1", sb2[] = "b2"; + +#--- c.c +extern int vc1, vc2, vc3, vc4, vc5, vc6, vc7, vc8; +extern void fc1(void), fc2(void), fc3(void), fc4(void); +int sum_c(void) { + return vc1 + vc2 + vc3 + vc4 + vc5 + vc6 + vc7 + vc8; +} +void call_c(void) { fc1(); fc2(); fc3(); fc4(); } +int dc1 = 1, dc2 = 2, dc3 = 3, dc4 = 4; +const char sc1[] = "c1", sc2[] = "c2"; diff --git a/test/Common/standalone/DynsymSortOrder/DynsymSortOrder.test b/test/Common/standalone/DynsymSortOrder/DynsymSortOrder.test new file mode 100644 index 000000000..71c839c44 --- /dev/null +++ b/test/Common/standalone/DynsymSortOrder/DynsymSortOrder.test @@ -0,0 +1,34 @@ +## Sort .dynsym: undefined symbols first, then defined symbols, and within +## each group by input ordinal, input .symtab index. + +# RUN: rm -rf %t && split-file %s %t +# RUN: %clang %clangopts -c -fPIC %t/a.c -o %t/a.o +# RUN: %clang %clangopts -c -fPIC %t/b.c -o %t/b.o + +# RUN: %link %linkopts -shared %t/a.o %t/b.o -o %t.ab.so +# RUN: %readelf --dyn-syms %t.ab.so | %filecheck --check-prefix=AB %s + +# AB: OBJECT GLOBAL DEFAULT {{.*}} a_z +# AB-NEXT: OBJECT GLOBAL DEFAULT {{.*}} a_b +# AB-NEXT: OBJECT GLOBAL DEFAULT {{.*}} a_alpha +# AB-NEXT: OBJECT GLOBAL DEFAULT {{.*}} b_m +# AB-NEXT: OBJECT GLOBAL DEFAULT {{.*}} b_n + +## Reverse the input order and the dynsym blocks follow. +# RUN: %link %linkopts -shared %t/b.o %t/a.o -o %t.ba.so +# RUN: %readelf --dyn-syms %t.ba.so | %filecheck --check-prefix=BA %s + +# BA: OBJECT GLOBAL DEFAULT {{.*}} b_m +# BA-NEXT: OBJECT GLOBAL DEFAULT {{.*}} b_n +# BA-NEXT: OBJECT GLOBAL DEFAULT {{.*}} a_z +# BA-NEXT: OBJECT GLOBAL DEFAULT {{.*}} a_b +# BA-NEXT: OBJECT GLOBAL DEFAULT {{.*}} a_alpha + +#--- a.c +int a_z = 1; +int a_b = 2; +int a_alpha = 3; + +#--- b.c +int b_m = 4; +int b_n = 5; diff --git a/test/Common/standalone/Patching/PatchPLT/PatchPLT.riscv32.test b/test/Common/standalone/Patching/PatchPLT/PatchPLT.riscv32.test index 360c47506..c1d1bb3ff 100644 --- a/test/Common/standalone/Patching/PatchPLT/PatchPLT.riscv32.test +++ b/test/Common/standalone/Patching/PatchPLT/PatchPLT.riscv32.test @@ -26,8 +26,8 @@ ELF: [ {{[[:digit:]]+}}] .rela.pgot RELA {{[[:xdigit:]]+}} ELF: Relocation section '.rela.pgot' at offset 0x{{[[:xdigit:]]+}} contains 1 entries: ELF: [[#PGOT]] {{[[:xdigit:]]+}} R_RISCV_32 {{0*}}[[#%x,0x2000]] f + 0 -ELF: 00001000 {{[[:xdigit:]]+}} NOTYPE GLOBAL DEFAULT {{[[:digit:]]+}} __llvm_patchable_f ELF: 00002000 {{[[:xdigit:]]+}} FUNC GLOBAL DEFAULT {{[[:digit:]]+}} f +ELF: 00001000 {{[[:xdigit:]]+}} NOTYPE GLOBAL DEFAULT {{[[:digit:]]+}} __llvm_patchable_f OD: Disassembly of section .plt: diff --git a/test/Common/standalone/Patching/PatchPLT/PatchPLT.riscv64.test b/test/Common/standalone/Patching/PatchPLT/PatchPLT.riscv64.test index 7792c1c8a..519fa7848 100644 --- a/test/Common/standalone/Patching/PatchPLT/PatchPLT.riscv64.test +++ b/test/Common/standalone/Patching/PatchPLT/PatchPLT.riscv64.test @@ -26,8 +26,8 @@ ELF: [ {{[[:digit:]]+}}] .rela.pgot RELA {{[[:xdigit:]]+}} ELF: Relocation section '.rela.pgot' at offset 0x{{[[:xdigit:]]+}} contains 1 entries: ELF: [[#PGOT]] {{[[:xdigit:]]+}} R_RISCV_64 {{0*}}[[#%x,0x2000]] f + 0 -ELF: 00001000 {{[[:xdigit:]]+}} NOTYPE GLOBAL DEFAULT {{[[:digit:]]+}} __llvm_patchable_f ELF: 00002000 {{[[:xdigit:]]+}} FUNC GLOBAL DEFAULT {{[[:digit:]]+}} f +ELF: 00001000 {{[[:xdigit:]]+}} NOTYPE GLOBAL DEFAULT {{[[:digit:]]+}} __llvm_patchable_f OD: Disassembly of section .plt: diff --git a/test/Common/standalone/SymbolVersioning/VersionOfUndefSymbol/VersionOfUndefSymbol.test b/test/Common/standalone/SymbolVersioning/VersionOfUndefSymbol/VersionOfUndefSymbol.test index 92d68e058..44cba7653 100644 --- a/test/Common/standalone/SymbolVersioning/VersionOfUndefSymbol/VersionOfUndefSymbol.test +++ b/test/Common/standalone/SymbolVersioning/VersionOfUndefSymbol/VersionOfUndefSymbol.test @@ -10,5 +10,5 @@ RUN: %link %linkopts -o %t1.lib1.so %t1.1.o -shared --version-script %p/Inputs/v RUN: %readelf --dyn-syms --version-info %t1.lib1.so | %filecheck %s #END_TEST -CHECK-DAG: UND foo{{$}} -CHECK-DAG: {{[0-9]+}} bar@@V1 +CHECK: UND foo{{$}} +CHECK-NEXT: {{[0-9]+}} bar@@V1 diff --git a/test/Common/standalone/SymtabSortOrder/SymtabSortOrder.test b/test/Common/standalone/SymtabSortOrder/SymtabSortOrder.test new file mode 100644 index 000000000..aefc52779 --- /dev/null +++ b/test/Common/standalone/SymtabSortOrder/SymtabSortOrder.test @@ -0,0 +1,47 @@ +## Sort .symtab: section symbols first, locals before globals; within each +## block, by input ordinal, input .symtab index. + +# RUN: rm -rf %t && split-file %s %t +# RUN: %clang %clangopts -c -fPIC %t/a.c -o %t/a.o +# RUN: %clang %clangopts -c -fPIC %t/b.c -o %t/b.o + +# RUN: %link %linkopts -shared %t/a.o %t/b.o -o %t.ab.so +# RUN: %readelf -s %t.ab.so | %filecheck --check-prefix=AB %s + +## Each input's locals appear contiguously in input .symtab order. Inputs +## appear in command-line order: a.c (a_z, a_b, a_alpha) then b.c (b_m, b_n). +# AB: FILE LOCAL DEFAULT ABS a.c +# AB: OBJECT LOCAL DEFAULT {{.*}} a_z +# AB-NEXT: OBJECT LOCAL DEFAULT {{.*}} a_b +# AB-NEXT: OBJECT LOCAL DEFAULT {{.*}} a_alpha +# AB: FILE LOCAL DEFAULT ABS b.c +# AB: OBJECT LOCAL DEFAULT {{.*}} b_m +# AB-NEXT: OBJECT LOCAL DEFAULT {{.*}} b_n +## Globals (after all locals, also in input order). +# AB: FUNC GLOBAL DEFAULT {{.*}} get_a +# AB-NEXT: FUNC GLOBAL DEFAULT {{.*}} get_b + +## Reverse the input order and the symtab blocks follow. +# RUN: %link %linkopts -shared %t/b.o %t/a.o -o %t.ba.so +# RUN: %readelf -s %t.ba.so | %filecheck --check-prefix=BA %s + +# BA: FILE LOCAL DEFAULT ABS b.c +# BA: OBJECT LOCAL DEFAULT {{.*}} b_m +# BA-NEXT: OBJECT LOCAL DEFAULT {{.*}} b_n +# BA: FILE LOCAL DEFAULT ABS a.c +# BA: OBJECT LOCAL DEFAULT {{.*}} a_z +# BA-NEXT: OBJECT LOCAL DEFAULT {{.*}} a_b +# BA-NEXT: OBJECT LOCAL DEFAULT {{.*}} a_alpha +# BA: FUNC GLOBAL DEFAULT {{.*}} get_b +# BA-NEXT: FUNC GLOBAL DEFAULT {{.*}} get_a + +#--- a.c +static int a_z = 1; +static int a_b = 2; +static int a_alpha = 3; +int get_a(void) { return a_z + a_b + a_alpha; } + +#--- b.c +static int b_m = 4; +static int b_n = 5; +int get_b(void) { return b_m + b_n; } diff --git a/test/Common/standalone/VersionScriptAnonymousTagMerge/VersionScriptAnonymousTagMerge.test b/test/Common/standalone/VersionScriptAnonymousTagMerge/VersionScriptAnonymousTagMerge.test index 458ec3950..9810fc5c7 100644 --- a/test/Common/standalone/VersionScriptAnonymousTagMerge/VersionScriptAnonymousTagMerge.test +++ b/test/Common/standalone/VersionScriptAnonymousTagMerge/VersionScriptAnonymousTagMerge.test @@ -9,5 +9,5 @@ RUN: %clang %clangopts -c -fpic -O2 %p/Inputs/1.c -o %t1.o -ffunction-sections RUN: %link %linkopts -shared -o %t1.so %t1.o --version-script=%p/Inputs/vs1 --version-script=%p/Inputs/vs2 RUN: %readelf --dyn-syms %t1.so | %filecheck %s -CHECK-DAG: main -CHECK-DAG: bar +CHECK: main +CHECK-NEXT: bar diff --git a/test/Common/standalone/linkerscript/excludeFile/excludeFiles.test b/test/Common/standalone/linkerscript/excludeFile/excludeFiles.test index 5863b1f6d..584dd2bfa 100644 --- a/test/Common/standalone/linkerscript/excludeFile/excludeFiles.test +++ b/test/Common/standalone/linkerscript/excludeFile/excludeFiles.test @@ -8,10 +8,10 @@ RUN: %ar cr %aropts %tlib24.a %t2.o %t4.o RUN: %link %linkopts -T %p/Inputs/exclude.t %t1.o --whole-archive %tlib24.a --no-whole-archive %t3.o %t5.o -o %t.out 2>&1 RUN: %readelf -S -s %t.out | %filecheck %s -CHECK: .section1 PROGBITS -CHECK: .others PROGBITS -CHECK: FUNC GLOBAL DEFAULT 1 main_4 -CHECK: FUNC GLOBAL DEFAULT 1 main_5 -CHECK: OBJECT GLOBAL DEFAULT 1 a5 -CHECK: FUNC GLOBAL DEFAULT 2 main_1 -CHECK: OBJECT GLOBAL DEFAULT 2 a4 +CHECK: .section1 PROGBITS +CHECK: .others PROGBITS +CHECK: FUNC GLOBAL DEFAULT 2 main_1 +CHECK: FUNC GLOBAL DEFAULT 1 main_5 +CHECK: OBJECT GLOBAL DEFAULT 1 a5 +CHECK: FUNC GLOBAL DEFAULT 1 main_4 +CHECK: OBJECT GLOBAL DEFAULT 2 a4 diff --git a/test/Hexagon/Plugin/GetAllSymbols/getallsymbols.test b/test/Hexagon/Plugin/GetAllSymbols/getallsymbols.test index 4880c448c..e0fff4fd5 100644 --- a/test/Hexagon/Plugin/GetAllSymbols/getallsymbols.test +++ b/test/Hexagon/Plugin/GetAllSymbols/getallsymbols.test @@ -19,13 +19,14 @@ LINK-DAG: trampoline_for_far_from_.text.bar_{{[0-9]+}} # the extra entry is the null symbol SYMTAB: Symbol table '.symtab' contains 12 entries: -SYMTAB: .text SYMTAB: .comment +SYMTAB: .hexagon.attributes +SYMTAB: .text SYMTAB: .text.far SYMTAB: .text.foo SYMTAB: trampoline_for_far_from_.text.bar_{{[0-9]+}} SYMTAB: local -SYMTAB: bar -SYMTAB: far +SYMTAB: ___end SYMTAB: foo -SYMTAB: __end \ No newline at end of file +SYMTAB: far +SYMTAB: bar \ No newline at end of file diff --git a/test/Hexagon/TLS/TPREL/tprel.test b/test/Hexagon/TLS/TPREL/tprel.test index f53d09a06..8f61cb86d 100644 --- a/test/Hexagon/TLS/TPREL/tprel.test +++ b/test/Hexagon/TLS/TPREL/tprel.test @@ -10,6 +10,6 @@ RUN: %readelf -l -S -s -W %t.out | %filecheck %s #ERR: recompile with -fPIC # CHECK: .tdata PROGBITS {{[x0-9a-z]+}} {{[x0-9a-z]+}} 000008 00 WAT # CHECK: .tbss NOBITS {{[x0-9a-z]+}} {{[x0-9a-z]+}} 000004 00 WAT +# CHECK: 00000008 4 TLS GLOBAL DEFAULT {{[0-9]}} dst # CHECK: 00000000 4 TLS GLOBAL DEFAULT {{[0-9]}} src1 # CHECK: 00000004 4 TLS GLOBAL DEFAULT {{[0-9]}} src2 -# CHECK: 00000008 4 TLS GLOBAL DEFAULT {{[0-9]}} dst diff --git a/test/Hexagon/TLS/headers/headers.test b/test/Hexagon/TLS/headers/headers.test index 55259ce95..18f9a348f 100644 --- a/test/Hexagon/TLS/headers/headers.test +++ b/test/Hexagon/TLS/headers/headers.test @@ -25,8 +25,8 @@ RUN: %readelf -l -S -s -W %t6.out | %filecheck %s --check-prefix="TBSSDATA" #ALL: TLS {{[x0-9a-f]+}} {{[x0-9a-f]+}} {{[x0-9a-f]+}} 0x00008 0x00010 R 0x8 #ALL: 01 .tdata .data .bss #ALL: 02 .tdata .tbss -#ALL: 00000000 8 TLS GLOBAL DEFAULT {{[0-9]}} a -#ALL: 00000008 4 TLS GLOBAL DEFAULT {{[0-9]}} b +#ALL-DAG: 00000000 8 TLS GLOBAL DEFAULT {{[0-9]}} a +#ALL-DAG: 00000008 4 TLS GLOBAL DEFAULT {{[0-9]}} b #TBSSTDATA: LOAD {{[x0-9a-z]+}} {{[x0-9a-z]+}} {{[x0-9a-z]+}} 0x00004 0x00004 RW 0x1000 #TBSSTDATA: TLS {{[x0-9a-z]+}} {{[x0-9a-z]+}} {{[x0-9a-z]+}} 0x00004 0x00008 R 0x8 #TBSS: TLS {{[x0-9a-z]+}} {{[x0-9a-z]+}} {{[x0-9a-z]+}} 0x00000 0x00008 R 0x8 diff --git a/test/Hexagon/linux/ExportFromExe/ExportFromExe.test b/test/Hexagon/linux/ExportFromExe/ExportFromExe.test index f94e650ce..ca927178e 100644 --- a/test/Hexagon/linux/ExportFromExe/ExportFromExe.test +++ b/test/Hexagon/linux/ExportFromExe/ExportFromExe.test @@ -10,7 +10,7 @@ RUN: %link %linkopts -Bdynamic %t2.o %t.dso.so -o %t.out RUN: %readelf --dyn-syms %t.out | %filecheck %s #CHECK-NOT: COM -#CHECK-DAG: common_in_program -#CHECK-DAG: data_in_program -#CHECK-DAG: func_in_program -#CHECK-DAG: variable_in_program +#CHECK: func_in_program +#CHECK-NEXT: variable_in_program +#CHECK-NEXT: data_in_program +#CHECK-NEXT: common_in_program diff --git a/test/Hexagon/linux/MoveCommonsToBSS/movecommon-to-bss.test b/test/Hexagon/linux/MoveCommonsToBSS/movecommon-to-bss.test index 40879d621..45e0222e2 100644 --- a/test/Hexagon/linux/MoveCommonsToBSS/movecommon-to-bss.test +++ b/test/Hexagon/linux/MoveCommonsToBSS/movecommon-to-bss.test @@ -5,6 +5,6 @@ RUN: %clang %clangg0opts -fcommon -c %p/Inputs/2.c -o %t2.o RUN: %link %linkg0opts %t1.o %t2.o -o %t.out 2>&1 RUN: %readelf -s %t.out | %filecheck %s -#CHECK: {{[0-9]+}}: {{[x0-9a-z]+}} 4 OBJECT GLOBAL DEFAULT 1 bss #CHECK: {{[0-9]+}}: {{[x0-9a-z]+}} 4000 OBJECT GLOBAL DEFAULT 1 common1 +#CHECK: {{[0-9]+}}: {{[x0-9a-z]+}} 4 OBJECT GLOBAL DEFAULT 1 bss diff --git a/test/Hexagon/linux/TLS/IE/ie.test b/test/Hexagon/linux/TLS/IE/ie.test index bbec9a6d0..fd9882bc9 100644 --- a/test/Hexagon/linux/TLS/IE/ie.test +++ b/test/Hexagon/linux/TLS/IE/ie.test @@ -6,7 +6,7 @@ RUN: %link %linkopts -G0 -dy %t1.o %t2.so -o %t.out RUN: %readelf -l -r -S -s -W %t.out | %filecheck %s # CHECK: TLS {{[x0-9a-z]+}} {{[x0-9a-z]+}} {{[x0-9a-z]+}} 0x00004 0x00008 R 0x8 -# CHECK-DAG: R_HEX_TPREL_32 00000000 src1 + 0 -# CHECK-DAG: R_HEX_TPREL_32 00000000 src2 + 0 +# CHECK: R_HEX_TPREL_32 00000000 src1 + 0 +# CHECK-NEXT: R_HEX_TPREL_32 00000000 src2 + 0 # CHECK: 00000000 4 TLS GLOBAL DEFAULT {{[0-9]}} dst diff --git a/test/Hexagon/linux/TLS/TPREL/tprel.test b/test/Hexagon/linux/TLS/TPREL/tprel.test index f53d09a06..8f61cb86d 100644 --- a/test/Hexagon/linux/TLS/TPREL/tprel.test +++ b/test/Hexagon/linux/TLS/TPREL/tprel.test @@ -10,6 +10,6 @@ RUN: %readelf -l -S -s -W %t.out | %filecheck %s #ERR: recompile with -fPIC # CHECK: .tdata PROGBITS {{[x0-9a-z]+}} {{[x0-9a-z]+}} 000008 00 WAT # CHECK: .tbss NOBITS {{[x0-9a-z]+}} {{[x0-9a-z]+}} 000004 00 WAT +# CHECK: 00000008 4 TLS GLOBAL DEFAULT {{[0-9]}} dst # CHECK: 00000000 4 TLS GLOBAL DEFAULT {{[0-9]}} src1 # CHECK: 00000004 4 TLS GLOBAL DEFAULT {{[0-9]}} src2 -# CHECK: 00000008 4 TLS GLOBAL DEFAULT {{[0-9]}} dst diff --git a/test/Hexagon/linux/TLS/headers/headers.test b/test/Hexagon/linux/TLS/headers/headers.test index 690d1e5c7..734f9045c 100644 --- a/test/Hexagon/linux/TLS/headers/headers.test +++ b/test/Hexagon/linux/TLS/headers/headers.test @@ -29,8 +29,8 @@ RUN: %readelf -l -S -s -W %t6.out | %filecheck %s --check-prefix="TBSSDATA" #ALL: TLS {{[x0-9a-f]+}} {{[x0-9a-f]+}} {{[x0-9a-f]+}} 0x00008 0x00010 R 0x8 #ALL: 01 .tdata .data .bss #ALL: 02 .tdata .tbss -#ALL: 00000000 8 TLS GLOBAL DEFAULT {{[0-9]}} a -#ALL: 00000008 4 TLS GLOBAL DEFAULT {{[0-9]}} b +#ALL-DAG: 00000000 8 TLS GLOBAL DEFAULT {{[0-9]}} a +#ALL-DAG: 00000008 4 TLS GLOBAL DEFAULT {{[0-9]}} b #TBSSTDATA: LOAD {{[x0-9a-z]+}} {{[x0-9a-z]+}} {{[x0-9a-z]+}} 0x00004 0x00004 RW 0x10000 #TBSSTDATA: TLS {{[x0-9a-z]+}} {{[x0-9a-z]+}} {{[x0-9a-z]+}} 0x00004 0x00008 R 0x8 #TBSS: TLS {{[x0-9a-z]+}} {{[x0-9a-z]+}} {{[x0-9a-z]+}} 0x00000 0x00008 R 0x8 diff --git a/test/Hexagon/linux/linkerscript/excludeFile/excludeFiles.test b/test/Hexagon/linux/linkerscript/excludeFile/excludeFiles.test index c86c3308f..2d079dac9 100644 --- a/test/Hexagon/linux/linkerscript/excludeFile/excludeFiles.test +++ b/test/Hexagon/linux/linkerscript/excludeFile/excludeFiles.test @@ -9,8 +9,8 @@ RUN: %readelf -S -s %t.out | %filecheck %s CHECK: .section1 PROGBITS CHECK: .others PROGBITS -CHECK: FUNC GLOBAL DEFAULT 1 main_4 +CHECK: FUNC GLOBAL DEFAULT 2 main_1 CHECK: FUNC GLOBAL DEFAULT 1 main_5 CHECK: OBJECT GLOBAL DEFAULT 1 a5 -CHECK: FUNC GLOBAL DEFAULT 2 main_1 +CHECK: FUNC GLOBAL DEFAULT 1 main_4 CHECK: OBJECT GLOBAL DEFAULT 2 a4 diff --git a/test/RISCV/FromLLD/riscv-tbljal-syms.s b/test/RISCV/FromLLD/riscv-tbljal-syms.s index 0c083fb09..264b986d5 100644 --- a/test/RISCV/FromLLD/riscv-tbljal-syms.s +++ b/test/RISCV/FromLLD/riscv-tbljal-syms.s @@ -9,18 +9,16 @@ # CHECK4-NEXT: 00100000 0 NOTYPE LOCAL DEFAULT 1 $x # CHECK4-NEXT: 00100004 2 NOTYPE LOCAL DEFAULT 1 c # CHECK4-NEXT: 00100004 6 NOTYPE LOCAL DEFAULT 1 d -# CHECK4-NEXT: {{.*}} 0 NOTYPE LOCAL DEFAULT {{.*}} $d -# CHECK4-NEXT: 00100000 10 NOTYPE GLOBAL DEFAULT 1 _start -# CHECK4: NOTYPE GLOBAL HIDDEN {{.*}} __jvt_base$ +# CHECK4-DAG: 00100000 10 NOTYPE GLOBAL DEFAULT 1 _start +# CHECK4-DAG: NOTYPE GLOBAL HIDDEN {{.*}} __jvt_base$ # # CHECK8: 00100000 4 NOTYPE LOCAL DEFAULT 1 a # CHECK8-NEXT: 00100000 8 NOTYPE LOCAL DEFAULT 1 b # CHECK8-NEXT: 00100000 0 NOTYPE LOCAL DEFAULT 1 $x # CHECK8-NEXT: 00100004 4 NOTYPE LOCAL DEFAULT 1 c # CHECK8-NEXT: 00100004 8 NOTYPE LOCAL DEFAULT 1 d -# CHECK8-NEXT: {{.*}} 0 NOTYPE LOCAL DEFAULT {{.*}} $d -# CHECK8-NEXT: 00100000 12 NOTYPE GLOBAL DEFAULT 1 _start -# CHECK8: NOTYPE GLOBAL HIDDEN {{.*}} __jvt_base$ +# CHECK8-DAG: 00100000 12 NOTYPE GLOBAL DEFAULT 1 _start +# CHECK8-DAG: NOTYPE GLOBAL HIDDEN {{.*}} __jvt_base$ .global _start _start: diff --git a/test/RISCV/standalone/KeepCommonSymbols/KeepCommonSymbols.test b/test/RISCV/standalone/KeepCommonSymbols/KeepCommonSymbols.test index 202b0ab27..7c8d68d7c 100644 --- a/test/RISCV/standalone/KeepCommonSymbols/KeepCommonSymbols.test +++ b/test/RISCV/standalone/KeepCommonSymbols/KeepCommonSymbols.test @@ -8,9 +8,9 @@ RUN: %clang %clangopts -fcommon -c %p/Inputs/1.c -o %t1.1.o RUN: %link %linkopts -o %t1.1.out %t1.1.o --gc-sections -e main -T %p/Inputs/1.script RUN: %readelf -s %t1.1.out | %filecheck %s #END_TEST -#CHECK: b_common #CHECK: a_common #CHECK: f_common +#CHECK: b_common #CHECK-NOT: c_common #CHECK-NOT: d_common #CHECK-NOT: e_common diff --git a/test/RISCV/standalone/Relocs/R_RISCV_QC_ABS20_U/R_RISCV_QC_ABS20_U.test b/test/RISCV/standalone/Relocs/R_RISCV_QC_ABS20_U/R_RISCV_QC_ABS20_U.test index 02656aa6c..03b62ab14 100644 --- a/test/RISCV/standalone/Relocs/R_RISCV_QC_ABS20_U/R_RISCV_QC_ABS20_U.test +++ b/test/RISCV/standalone/Relocs/R_RISCV_QC_ABS20_U/R_RISCV_QC_ABS20_U.test @@ -16,8 +16,8 @@ CHECK-LABEL: SYMBOL TABLE: CHECK: 00000000 l *ABS* 00000000 test_zero CHECK: 0007ffff l *ABS* 00000000 test_hi CHECK: fff80000 l *ABS* 00000000 test_lo -CHECK: fffabcde l *ABS* 00000000 test_distinct CHECK: ffffffff l *ABS* 00000000 test_minus_one +CHECK: fffabcde l *ABS* 00000000 test_distinct CHECK-LABEL: 00000074 : CHECK: 0000029b qc.li t0, 0 diff --git a/test/RISCV/standalone/Relocs/R_RISCV_QC_E_32/R_RISCV_QC_E_32.test b/test/RISCV/standalone/Relocs/R_RISCV_QC_E_32/R_RISCV_QC_E_32.test index b9f77e577..ced82b8a0 100644 --- a/test/RISCV/standalone/Relocs/R_RISCV_QC_E_32/R_RISCV_QC_E_32.test +++ b/test/RISCV/standalone/Relocs/R_RISCV_QC_E_32/R_RISCV_QC_E_32.test @@ -14,9 +14,9 @@ RUN: %objdump -dt %t1.out | %filecheck %s CHECK-LABEL: SYMBOL TABLE: CHECK: 00000000 l *ABS* 00000000 test_zero -CHECK: 0000007a l .text 00000000 test2 -CHECK: 89abcdef l *ABS* 00000000 test_distinct CHECK: ffffffff l *ABS* 00000000 test_ffff +CHECK: 89abcdef l *ABS* 00000000 test_distinct +CHECK: 0000007a l .text 00000000 test2 CHECK-LABEL: 00000074 : CHECK: 029f 0000 0000 qc.e.li t0, 0 diff --git a/test/RISCV/standalone/Relocs/R_RISCV_QC_E_CALL_PLT/R_RISCV_QC_E_CALL_PLT.test b/test/RISCV/standalone/Relocs/R_RISCV_QC_E_CALL_PLT/R_RISCV_QC_E_CALL_PLT.test index 5d4f49c3b..0e860eb65 100644 --- a/test/RISCV/standalone/Relocs/R_RISCV_QC_E_CALL_PLT/R_RISCV_QC_E_CALL_PLT.test +++ b/test/RISCV/standalone/Relocs/R_RISCV_QC_E_CALL_PLT/R_RISCV_QC_E_CALL_PLT.test @@ -15,6 +15,8 @@ RUN: %objdump -dt %t1.out | %filecheck %s CHECK-LABEL: SYMBOL TABLE: CHECK: 00000000 l *ABS* 00000000 test_zero +CHECK: abcdef78 l *ABS* 00000000 test_distinct +CHECK: fffffffe l *ABS* 00000000 test_fffe CHECK: 00000074 l .text 00000000 test_j_1 CHECK: 0000007a l .text 00000000 test_j_2 CHECK: 00000080 l .text 00000000 test_j_3 @@ -31,8 +33,6 @@ CHECK: 000000bc l .text 00000000 test_jal_5 CHECK: 000000c2 l .text 00000000 test_jal_6 CHECK: 000000c8 l .text 00000000 test_jal_7 CHECK: 000000ce l .text 00000000 test_jal_8 -CHECK: abcdef78 l *ABS* 00000000 test_distinct -CHECK: fffffffe l *ABS* 00000000 test_fffe CHECK: 000000d4 g F .text 00000002 test_vis_default CHECK: 000000d6 g F .text 00000002 .hidden test_vis_hidden CHECK: 000000da g F .text 00000002 .protected test_vis_protected