summaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2024-01-09 06:30:28 -0800
committerH.J. Lu <hjl.tools@gmail.com>2024-01-09 06:39:42 -0800
commit2e93abb858ae4ff2b8605b4a94988068869c0ff1 (patch)
tree019a40ce778e4afa7f2dc1d287405f6e21db6d73 /bfd
parent862180a2d10963494356ec089a16b808bab736bd (diff)
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.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/elf32-i386.c4
-rw-r--r--bfd/elf64-x86-64.c4
2 files changed, 8 insertions, 0 deletions
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index 5fc68551e95..e2f88a11487 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 ec001599cc1..f8905fbd4d4 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 */