diff options
author | Jiong Wang <jiong.wang@arm.com> | 2017-06-16 14:20:38 +0100 |
---|---|---|
committer | Jiong Wang <jiong.wang@arm.com> | 2017-06-16 14:20:38 +0100 |
commit | d68f19767dfbb33c1813563d5a4af0731a1855c5 (patch) | |
tree | 27afb23abad3e0ebaa2121a63a8d7cf191eeef39 /ld | |
parent | a87dc45adc983a8e6ec3db8d18cd31c35abd2048 (diff) | |
download | gdb-d68f19767dfbb33c1813563d5a4af0731a1855c5.zip gdb-d68f19767dfbb33c1813563d5a4af0731a1855c5.tar.gz gdb-d68f19767dfbb33c1813563d5a4af0731a1855c5.tar.bz2 |
[AArch64] Use SYMBOL_REFERENCES_LOCAL in one symbol check
For some pc-relative relocations we want to allow them under PIC mode while
a normal global symbol defined in the same dynamic object can still bind
externally through copy relocation. So, we should not allow pc-relative
relocation against such symbol.
SYMBOL_REFERENCES_LOCAL should be used and is more accurate than the original
individual checks.
bfd/
* elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Use
SYMBOL_REFERENCES_LOCAL.
ld/
* testsuite/ld-aarch64/aarch64-elf.exp: Update test name
* testsuite/ld-aarch64/pcrel.s: Add new testcases.
* testsuite/ld-aarch64/pcrel_pic_undefined.d: Update the expected
warnings.
* testsuite/ld-aarch64/pcrel_pic_defined_local.d: Rename ...
* testsuite/ld-aarch64/pcrel_pic_defined.d: ... to this.
Update expected warnings.
Diffstat (limited to 'ld')
-rw-r--r-- | ld/ChangeLog | 10 | ||||
-rw-r--r-- | ld/testsuite/ld-aarch64/aarch64-elf.exp | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-aarch64/pcrel.s | 6 | ||||
-rw-r--r-- | ld/testsuite/ld-aarch64/pcrel_pic_defined.d | 10 | ||||
-rw-r--r-- | ld/testsuite/ld-aarch64/pcrel_pic_defined_local.d | 5 | ||||
-rw-r--r-- | ld/testsuite/ld-aarch64/pcrel_pic_undefined.d | 16 |
6 files changed, 35 insertions, 14 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index 7791c03..751699d 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,13 @@ +2017-06-16 Jiong Wang <jiong.wang@arm.com> + + * testsuite/ld-aarch64/aarch64-elf.exp: Update test name + * testsuite/ld-aarch64/pcrel.s: Add new testcases. + * testsuite/ld-aarch64/pcrel_pic_undefined.d: Update the expected + warnings. + * testsuite/ld-aarch64/pcrel_pic_defined_local.d: Rename ... + * testsuite/ld-aarch64/pcrel_pic_defined.d: ... to this. + Update expected warnings. + 2017-06-15 H.J. Lu <hongjiu.lu@intel.com> * exsup.c (elf_shlib_list_options): Display "-z stack-size=SIZE" diff --git a/ld/testsuite/ld-aarch64/aarch64-elf.exp b/ld/testsuite/ld-aarch64/aarch64-elf.exp index f171f6f..b9c9885 100644 --- a/ld/testsuite/ld-aarch64/aarch64-elf.exp +++ b/ld/testsuite/ld-aarch64/aarch64-elf.exp @@ -195,7 +195,7 @@ run_dump_test_lp64 "local-addend-r" # test error handling on pcrel relocation for shared libraries. run_dump_test_lp64 "pcrel_pic_undefined" -run_dump_test_lp64 "pcrel_pic_defined_local" +run_dump_test_lp64 "pcrel_pic_defined" run_dump_test "limit-b" run_dump_test "limit-bl" diff --git a/ld/testsuite/ld-aarch64/pcrel.s b/ld/testsuite/ld-aarch64/pcrel.s index df542ef..c5e18d0 100644 --- a/ld/testsuite/ld-aarch64/pcrel.s +++ b/ld/testsuite/ld-aarch64/pcrel.s @@ -1,3 +1,4 @@ + .hidden global_b .text .align 2 main: @@ -18,3 +19,8 @@ main: .word global_a - . .xword global_a - . + # Defined global symbol may bind externally because of copy relocation, + # while defined hidden symbol binds locally. LD should be able to + # differenciate this. + adrp x0, :pg_hi21:global_b + .xword global_b - . diff --git a/ld/testsuite/ld-aarch64/pcrel_pic_defined.d b/ld/testsuite/ld-aarch64/pcrel_pic_defined.d new file mode 100644 index 0000000..743e810 --- /dev/null +++ b/ld/testsuite/ld-aarch64/pcrel_pic_defined.d @@ -0,0 +1,10 @@ +#name: PC-Rel relocation against defined +#source: pcrel.s +#ld: -shared -e0 -defsym global_a=0x1000 -defsym global_b=0x2000 +#warning: .*: relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `global_a.*bind externally.*fPIC.* +#warning: .*: relocation R_AARCH64_ADR_PREL_PG_HI21_NC against symbol `global_a.*bind externally.*fPIC.* +#warning: .*: relocation R_AARCH64_ADR_PREL_LO21 against symbol `global_a.*bind externally.*fPIC.* +#warning: .*: relocation R_AARCH64_LD_PREL_LO19 against symbol `global_a.*bind externally.*fPIC.* +#warning: .*: relocation R_AARCH64_PREL16 against symbol `global_a.*bind externally.*fPIC.* +#warning: .*: relocation R_AARCH64_PREL32 against symbol `global_a.*bind externally.*fPIC.* +#warning: .*: relocation R_AARCH64_PREL64 against symbol `global_a.*bind externally.*fPIC.* diff --git a/ld/testsuite/ld-aarch64/pcrel_pic_defined_local.d b/ld/testsuite/ld-aarch64/pcrel_pic_defined_local.d deleted file mode 100644 index 832652f..0000000 --- a/ld/testsuite/ld-aarch64/pcrel_pic_defined_local.d +++ /dev/null @@ -1,5 +0,0 @@ -#name: PC-Rel relocation against defined -#source: pcrel.s -#objdump: -r -#ld: -shared -e0 -defsym global_a=0x1000 -#... diff --git a/ld/testsuite/ld-aarch64/pcrel_pic_undefined.d b/ld/testsuite/ld-aarch64/pcrel_pic_undefined.d index de7f020..f7f048d 100644 --- a/ld/testsuite/ld-aarch64/pcrel_pic_undefined.d +++ b/ld/testsuite/ld-aarch64/pcrel_pic_undefined.d @@ -1,10 +1,10 @@ #name: PC-Rel relocation against undefined #source: pcrel.s -#ld: -shared -e0 -#warning: .*: relocation R_AARCH64_ADR_PREL_PG_HI21 against external symbol.*fPIC.* -#warning: .*: relocation R_AARCH64_ADR_PREL_PG_HI21_NC against external symbol.*fPIC.* -#warning: .*: relocation R_AARCH64_ADR_PREL_LO21 against external symbol.*fPIC.* -#warning: .*: relocation R_AARCH64_LD_PREL_LO19 against external symbol.*fPIC.* -#warning: .*: relocation R_AARCH64_PREL16 against external symbol.*fPIC.* -#warning: .*: relocation R_AARCH64_PREL32 against external symbol.*fPIC.* -#warning: .*: relocation R_AARCH64_PREL64 against external symbol.*fPIC.* +#ld: -shared -e0 -defsym global_b=0x2000 +#warning: .*: relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `global_a.*bind externally.*fPIC.* +#warning: .*: relocation R_AARCH64_ADR_PREL_PG_HI21_NC against symbol `global_a.*bind externally.*fPIC.* +#warning: .*: relocation R_AARCH64_ADR_PREL_LO21 against symbol `global_a.*bind externally.*fPIC.* +#warning: .*: relocation R_AARCH64_LD_PREL_LO19 against symbol `global_a.*bind externally.*fPIC.* +#warning: .*: relocation R_AARCH64_PREL16 against symbol `global_a.*bind externally.*fPIC.* +#warning: .*: relocation R_AARCH64_PREL32 against symbol `global_a.*bind externally.*fPIC.* +#warning: .*: relocation R_AARCH64_PREL64 against symbol `global_a.*bind externally.*fPIC.* |