diff options
author | Jiong Wang <jiong.wang@arm.com> | 2015-04-24 22:35:04 +0100 |
---|---|---|
committer | Jiong Wang <jiong.wang@arm.com> | 2015-04-24 22:35:04 +0100 |
commit | dcbd20eb1499db937785881aca2f9584a330723c (patch) | |
tree | b2038cdd2a8884c24cd830f8b0eb5f625912953b /ld | |
parent | d9e88e902134b6febeef7156ecb6341a593b8c54 (diff) | |
download | gdb-dcbd20eb1499db937785881aca2f9584a330723c.zip gdb-dcbd20eb1499db937785881aca2f9584a330723c.tar.gz gdb-dcbd20eb1499db937785881aca2f9584a330723c.tar.bz2 |
[AArch64] Improve PC-relative relocation check for shared library
2015-04-24 Jiong. Wang <jiong.wang@arm.com>
bfd/
* elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Reject
PC-relative relocation for external symbol.
ld/testsuite/
* ld-aarch64/pcrel.s: New testcase.
* ld-aarch64/pcrel_pic_defiend_local.d: New expect file.
* ld-aarch64/pcrel_pic_undefined.d: Ditto.
* ld-aarch64/aarch64-elf.exp: Run them.
Diffstat (limited to 'ld')
-rw-r--r-- | ld/testsuite/ld-aarch64/aarch64-elf.exp | 4 | ||||
-rw-r--r-- | ld/testsuite/ld-aarch64/pcrel.s | 20 | ||||
-rw-r--r-- | ld/testsuite/ld-aarch64/pcrel_pic_defined_local.d | 5 | ||||
-rw-r--r-- | ld/testsuite/ld-aarch64/pcrel_pic_undefined.d | 10 |
4 files changed, 39 insertions, 0 deletions
diff --git a/ld/testsuite/ld-aarch64/aarch64-elf.exp b/ld/testsuite/ld-aarch64/aarch64-elf.exp index 895b1b2..bfbbe24 100644 --- a/ld/testsuite/ld-aarch64/aarch64-elf.exp +++ b/ld/testsuite/ld-aarch64/aarch64-elf.exp @@ -105,6 +105,10 @@ run_dump_test "emit-relocs-local-addend" # test addend correctness when -r specified. run_dump_test "local-addend-r" +# test error handling on pcrel relocation for shared libraries. +run_dump_test "pcrel_pic_undefined" +run_dump_test "pcrel_pic_defined_local" + run_dump_test "limit-b" run_dump_test "limit-bl" run_dump_test "farcall-section" diff --git a/ld/testsuite/ld-aarch64/pcrel.s b/ld/testsuite/ld-aarch64/pcrel.s new file mode 100644 index 0000000..df542ef --- /dev/null +++ b/ld/testsuite/ld-aarch64/pcrel.s @@ -0,0 +1,20 @@ + .text + .align 2 +main: + # R_AARCH64_ADR_PREL_PG_HI21 + # R_AARCH64_ADR_PREL_PG_HI21_NC + # R_AARCH64_ADR_LO_21 + adrp x0, :pg_hi21:global_a + adrp x1, :pg_hi21_nc:global_a + adr x2, global_a + + #R_AARCH64_LD_PREL_LO19 + ldr x3, global_a + + # R_AARCH64_PREL16 + # R_AARCH64_PREL32 + # R_AARCH64_PREL64 + .hword global_a - . + .word global_a - . + .xword global_a - . + diff --git a/ld/testsuite/ld-aarch64/pcrel_pic_defined_local.d b/ld/testsuite/ld-aarch64/pcrel_pic_defined_local.d new file mode 100644 index 0000000..832652f --- /dev/null +++ b/ld/testsuite/ld-aarch64/pcrel_pic_defined_local.d @@ -0,0 +1,5 @@ +#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 new file mode 100644 index 0000000..de7f020 --- /dev/null +++ b/ld/testsuite/ld-aarch64/pcrel_pic_undefined.d @@ -0,0 +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.* |