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 /bfd/elfnn-aarch64.c | |
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 'bfd/elfnn-aarch64.c')
-rw-r--r-- | bfd/elfnn-aarch64.c | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c index 85cf856..c98987b 100644 --- a/bfd/elfnn-aarch64.c +++ b/bfd/elfnn-aarch64.c @@ -4801,16 +4801,36 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto, signed_addend, weak_undef_p); break; + case BFD_RELOC_AARCH64_ADR_LO21_PCREL: + case BFD_RELOC_AARCH64_ADR_HI21_PCREL: + case BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL: + case BFD_RELOC_AARCH64_LD_LO19_PCREL: + case BFD_RELOC_AARCH64_16_PCREL: + case BFD_RELOC_AARCH64_32_PCREL: + case BFD_RELOC_AARCH64_64_PCREL: + if (info->shared + && (input_section->flags & SEC_ALLOC) != 0 + && (input_section->flags & SEC_READONLY) != 0 + && h != NULL + && !h->def_regular) + { + int howto_index = bfd_r_type - BFD_RELOC_AARCH64_RELOC_START; + + (*_bfd_error_handler) + (_("%B: relocation %s against external symbol `%s' can not be used" + " when making a shared object; recompile with -fPIC"), + input_bfd, elfNN_aarch64_howto_table[howto_index].name, + h->root.root.string); + bfd_set_error (bfd_error_bad_value); + return FALSE; + } + case BFD_RELOC_AARCH64_16: #if ARCH_SIZE == 64 case BFD_RELOC_AARCH64_32: #endif case BFD_RELOC_AARCH64_ADD_LO12: - case BFD_RELOC_AARCH64_ADR_LO21_PCREL: - case BFD_RELOC_AARCH64_ADR_HI21_PCREL: - case BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL: case BFD_RELOC_AARCH64_BRANCH19: - case BFD_RELOC_AARCH64_LD_LO19_PCREL: case BFD_RELOC_AARCH64_LDST8_LO12: case BFD_RELOC_AARCH64_LDST16_LO12: case BFD_RELOC_AARCH64_LDST32_LO12: @@ -4826,9 +4846,6 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto, case BFD_RELOC_AARCH64_MOVW_G2: case BFD_RELOC_AARCH64_MOVW_G2_NC: case BFD_RELOC_AARCH64_MOVW_G3: - case BFD_RELOC_AARCH64_16_PCREL: - case BFD_RELOC_AARCH64_32_PCREL: - case BFD_RELOC_AARCH64_64_PCREL: case BFD_RELOC_AARCH64_TSTBR14: value = _bfd_aarch64_elf_resolve_relocation (bfd_r_type, place, value, signed_addend, weak_undef_p); |