Index: lib/ReaderWriter/ELF/AArch64/AArch64RelocationPass.cpp =================================================================== --- lib/ReaderWriter/ELF/AArch64/AArch64RelocationPass.cpp +++ lib/ReaderWriter/ELF/AArch64/AArch64RelocationPass.cpp @@ -432,7 +432,7 @@ pa->addReferenceELF_AArch64(R_AARCH64_NONE, 12, getPLT0(), 0); // Set the starting address of the got entry to the first instruction in // the plt0 entry. - ga->addReferenceELF_AArch64(R_AARCH64_ABS32, 0, pa, 0); + ga->addReferenceELF_AArch64(R_AARCH64_ABS32, 0, getPLT0(), 0); #ifndef NDEBUG ga->_name = "__got_"; ga->_name += a->name(); Index: test/elf/AArch64/Inputs/largebss.c =================================================================== --- /dev/null +++ test/elf/AArch64/Inputs/largebss.c @@ -0,0 +1,3 @@ +int largebss[1000] = { 0 }; +int largecommon[1000]; +__thread int largetbss[1000] = { 0 }; Index: test/elf/AArch64/Inputs/layoutpass/1.c =================================================================== --- /dev/null +++ test/elf/AArch64/Inputs/layoutpass/1.c @@ -0,0 +1,8 @@ +int main() { + a(); + return 0; +} + +int b() { + return 0; +} Index: test/elf/AArch64/Inputs/layoutpass/2.c =================================================================== --- /dev/null +++ test/elf/AArch64/Inputs/layoutpass/2.c @@ -0,0 +1,7 @@ +int a() { + return 0; +} + +int c() { + return 0; +} Index: test/elf/AArch64/Inputs/layoutpass/3.c =================================================================== --- /dev/null +++ test/elf/AArch64/Inputs/layoutpass/3.c @@ -0,0 +1,3 @@ +int d() { + return 0; +} Index: test/elf/AArch64/Inputs/multi-ovrd.c =================================================================== --- /dev/null +++ test/elf/AArch64/Inputs/multi-ovrd.c @@ -0,0 +1,10 @@ +#include +void f(void) +{ + printf("overridden f!\n"); +} + +void g(void) +{ + printf("overridden g!\n"); +} Index: test/elf/AArch64/Inputs/multi-weak.c =================================================================== --- /dev/null +++ test/elf/AArch64/Inputs/multi-weak.c @@ -0,0 +1,21 @@ +#include +int fn() +{ + return 0; +} + +void __attribute__((weak)) f() +{ + printf("original f..\n"); +} + +void __attribute__((weak)) g() +{ + printf("original f..\n"); +} + +int main(void) +{ + f(); + return 0; +} Index: test/elf/AArch64/largebss.test =================================================================== --- /dev/null +++ test/elf/AArch64/largebss.test @@ -0,0 +1,21 @@ +# This tests the functionality of handling BSS symbols +# BSS symbols don't occupy file content and are associated with typeZeroFill +# Any typeZeroFill content wouldn't have space reserved in the file to store +# its content + +RUN: lld -flavor gnu -target aarch64--linux-gnu %p/Inputs/largebss.o \ +RUN: --output-filetype=yaml --noinhibit-exec | FileCheck %s + +CHECK: - name: largecommon +CHECK: scope: global +CHECK: type: zero-fill +CHECK: size: 4000 +CHECK: merge: as-tentative +CHECK: - name: largebss +CHECK: scope: global +CHECK: type: zero-fill +CHECK: size: 4000 +CHECK: - name: largetbss +CHECK: scope: global +CHECK: type: thread-zero-fill +CHECK: size: 4000 Index: test/elf/AArch64/layoutpass-order.test =================================================================== --- /dev/null +++ test/elf/AArch64/layoutpass-order.test @@ -0,0 +1,14 @@ +# This test checks that we follow the command line order of layouting +# symbols in the output file + +RUN: lld -flavor gnu -target aarch64--linux-gnu %p/Inputs/layoutpass/1.o \ +RUN: %p/Inputs/layoutpass/lib2.a %p/Inputs/layoutpass/3.o -o %t \ +RUN: --noinhibit-exec -static + +RUN: llvm-nm -n %t | FileCheck -check-prefix=SYMBOLSORDER %s + +SYMBOLSORDER: {{[A-Fa-f0-9]+}} T main +SYMBOLSORDER: {{[A-Fa-f0-9]+}} T b +SYMBOLSORDER: {{[A-Fa-f0-9]+}} T a +SYMBOLSORDER: {{[A-Fa-f0-9]+}} T c +SYMBOLSORDER: {{[A-Fa-f0-9]+}} T d Index: test/elf/AArch64/multi-weak-override.test =================================================================== --- /dev/null +++ test/elf/AArch64/multi-weak-override.test @@ -0,0 +1,16 @@ +# Test for weak symbol getting overridden +RUN: lld -flavor gnu -target aarch64--linux-gnu %p/Inputs/multi-weak.o \ +RUN: %p/Inputs/multi-ovrd.o -o %t -e main --noinhibit-exec +RUN: llvm-nm -n %t | FileCheck -check-prefix=WEAKORDER %s +RUN: lld -flavor gnu -target aarch64--linux-gnu %p/Inputs/multi-weak.o \ +RUN: %p/Inputs/multi-ovrd.o --output-filetype=yaml -o %t2 --noinhibit-exec +RUN: FileCheck -check-prefix=WEAKATOMSORDER %s < %t2 + +WEAKORDER: {{[0-9a-f]+}} T f +WEAKORDER: {{[0-9a-f]+}} T g + +WEAKATOMSORDER: - ref-name: {{[A-Z0-9]+}} +WEAKATOMSORDER: - ref-name: {{[A-Z0-9]+}} +WEAKATOMSORDER: - name: f +WEAKATOMSORDER: - name: g +