From 279b2f94168ee91e02ccd070d27c983fc001fe12 Mon Sep 17 00:00:00 2001 From: Renlin Li Date: Sat, 3 Feb 2018 13:18:17 +0000 Subject: [PR22764][LD][AARCH64]Allow R_AARCH64_ABS16 and R_AARCH64_ABS32 against absolution symbol or undefine symbol in shared object. The assumption that R_AARCH64_ABS16 and R_AARCH64_ABS32 relocation in LP64 abi will be used to generate an address does not hold for absolute symbol. In this case, it is a value fixed at static linking time. The condition to check the relocations is relax to allow absolute symbol and undefined symbol case. bfd/ 2018-02-05 Renlin Li PR ld/22764 * elfnn-aarch64.c (elfNN_aarch64_check_relocs): Relax the R_AARCH64_ABS32 and R_AARCH64_ABS16 for absolute symbol. Apply the check for writeable section as well. ld/ 2018-02-05 Renlin Li PR ld/22764 * testsuite/ld-aarch64/emit-relocs-258.s: Define symbol as an address. * testsuite/ld-aarch64/emit-relocs-259.s: Likewise. * testsuite/ld-aarch64/aarch64-elf.exp: Run new test. * testsuite/ld-aarch64/pr22764.s: New. * testsuite/ld-aarch64/pr22764.d: New. --- bfd/elfnn-aarch64.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'bfd/elfnn-aarch64.c') diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c index af448f9..2737773 100644 --- a/bfd/elfnn-aarch64.c +++ b/bfd/elfnn-aarch64.c @@ -7189,10 +7189,19 @@ elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info, #if ARCH_SIZE == 64 case BFD_RELOC_AARCH64_32: #endif - if (bfd_link_pic (info) - && (sec->flags & SEC_ALLOC) != 0 - && (sec->flags & SEC_READONLY) != 0) + if (bfd_link_pic (info) && (sec->flags & SEC_ALLOC) != 0) { + if (h != NULL + /* This is an absolute symbol. It represents a value instead + of an address. */ + && ((h->root.type == bfd_link_hash_defined + && bfd_is_abs_section (h->root.u.def.section)) + /* This is an undefined symbol. */ + || h->root.type == bfd_link_hash_undefined)) + break; + + /* For local symbols, defined global symbols in a non-ABS section, + it is assumed that the value is an address. */ int howto_index = bfd_r_type - BFD_RELOC_AARCH64_RELOC_START; _bfd_error_handler /* xgettext:c-format */ -- cgit v1.1