From 2e93abb858ae4ff2b8605b4a94988068869c0ff1 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Tue, 9 Jan 2024 06:30:28 -0800 Subject: x86: Don't check R_386_NONE nor R_X86_64_NONE Update x86 ELF linker to skip R_386_NONE/R_X86_64_NONE when scanning relocations. bfd/ * PR ld/31047 * elf32-i386.c (elf_i386_scan_relocs): Don't check R_386_NONE. * elf64-x86-64.c (elf_x86_64_scan_relocs): Don't check R_X86_64_NONE. ld/ * PR ld/31047 * testsuite/ld-i386/i386.exp: Run PR ld/31047 test. * testsuite/ld-x86-64/x86-64.exp: Likewise. * testsuite/ld-i386/pr31047.d: New file. * testsuite/ld-x86-64/pr31047-x32.d: Likewise. * testsuite/ld-x86-64/pr31047.d: Likewise. * testsuite/ld-x86-64/pr31047a.s: Likewise. * testsuite/ld-x86-64/pr31047b.s: Likewise. --- bfd/elf32-i386.c | 4 ++++ bfd/elf64-x86-64.c | 4 ++++ 2 files changed, 8 insertions(+) (limited to 'bfd') diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index 5fc6855..e2f88a1 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -1525,6 +1525,10 @@ elf_i386_scan_relocs (bfd *abfd, r_symndx = ELF32_R_SYM (rel->r_info); r_type = ELF32_R_TYPE (rel->r_info); + /* Don't check R_386_NONE. */ + if (r_type == R_386_NONE) + continue; + if (r_symndx >= NUM_SHDR_ENTRIES (symtab_hdr)) { /* xgettext:c-format */ diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index ec00159..f8905fb 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -2040,6 +2040,10 @@ elf_x86_64_scan_relocs (bfd *abfd, struct bfd_link_info *info, r_symndx = htab->r_sym (rel->r_info); r_type = ELF32_R_TYPE (rel->r_info); + /* Don't check R_X86_64_NONE. */ + if (r_type == R_X86_64_NONE) + continue; + if (r_symndx >= NUM_SHDR_ENTRIES (symtab_hdr)) { /* xgettext:c-format */ -- cgit v1.1