This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH v2][AArch64] Fix PR18841 ifunc relocation ordering
- From: Szabolcs Nagy <szabolcs dot nagy at arm dot com>
- To: Nick Clifton <nickc at redhat dot com>, Binutils <binutils at sourceware dot org>
- Cc: nd at arm dot com
- Date: Wed, 19 Jul 2017 14:00:11 +0100
- Subject: [PATCH v2][AArch64] Fix PR18841 ifunc relocation ordering
- Authentication-results: sourceware.org; auth=none
- Authentication-results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=arm.com;
- Nodisclaimer: True
- References: <59637E45.8060206@arm.com> <7ab6987e-ac06-7899-7a76-e8bac2fe40d5@redhat.com> <596F246C.5010804@arm.com>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
On 19/07/17 10:20, Szabolcs Nagy wrote:
> On 18/07/17 17:23, Nick Clifton wrote:
>> I strongly dislike calls to abort() inside a library. Corrupt input
>> files can trigger them, and they are of no help to the user. So please
>> replace this with a call to bfd_error_message(). (It would be nice if
>> there was a reloc_class_unknown so that you could return that value, but
>> that would be too big of a change).
>
> thanks for the review.
>
> i don't see bfd_error_message.
> do you mean bfd_perror (printing last bfd error)
> or bfd_assert (aborting with an error message)
> or bfd_error_handler (printing a custom message) ?
>
> i can return some random reloc class, but i don't
> know if continuing in such state is valid.
>
using _bfd_error_handler (with an existing error
message from elf.c) is this OK?:
In order to get the ifunc relocs properly sorted the correct class
needs to be returned. The code mimics what has been done for x86.
Fixes
FAIL: Run pr18841 with libpr18841c.so
bfd/
2017-07-19 Szabolcs Nagy <szabolcs.nagy@arm.com>
PR ld/18841
* elfnn-aarch64.c (elfNN_aarch64_reloc_type_class): Return
reloc_class_ifunc for ifunc symbols.
diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
index de7b627004..be2f89cfc3 100644
--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -7634,8 +7634,39 @@ elfNN_aarch64_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSE
const asection *rel_sec ATTRIBUTE_UNUSED,
const Elf_Internal_Rela *rela)
{
+ struct elf_aarch64_link_hash_table *htab = elf_aarch64_hash_table (info);
+
+ if (htab->root.dynsym != NULL
+ && htab->root.dynsym->contents != NULL)
+ {
+ /* Check relocation against STT_GNU_IFUNC symbol if there are
+ dynamic symbols. */
+ bfd *abfd = info->output_bfd;
+ const struct elf_backend_data *bed = get_elf_backend_data (abfd);
+ unsigned long r_symndx = ELFNN_R_SYM (rela->r_info);
+ if (r_symndx != STN_UNDEF)
+ {
+ Elf_Internal_Sym sym;
+ if (!bed->s->swap_symbol_in (abfd,
+ (htab->root.dynsym->contents
+ + r_symndx * bed->s->sizeof_sym),
+ 0, &sym))
+ {
+ /* xgettext:c-format */
+ _bfd_error_handler (_("%B symbol number %lu references"
+ " nonexistent SHT_SYMTAB_SHNDX section"),
+ abfd, r_symndx);
+ /* Ideally an error class should be returned here. */
+ }
+ else if (ELF_ST_TYPE (sym.st_info) == STT_GNU_IFUNC)
+ return reloc_class_ifunc;
+ }
+ }
+
switch ((int) ELFNN_R_TYPE (rela->r_info))
{
+ case AARCH64_R (IRELATIVE):
+ return reloc_class_ifunc;
case AARCH64_R (RELATIVE):
return reloc_class_relative;
case AARCH64_R (JUMP_SLOT):