From 2585b7a5ce5830e60a089aa2316a329558902f0c Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Sun, 19 Jul 2020 06:51:19 -0700 Subject: x86: Change PLT32 reloc against section to PC32 Commit 292676c1 resolved PLT32 reloc aganst local symbol to section. Since PLT32 relocation must be against symbols, turn such PLT32 relocation into PC32 relocation. gas/ PR gas/26263 * config/tc-i386.c (i386_validate_fix): Change PLT32 reloc against section to PC32 reloc. * testsuite/gas/i386/relax-5.d: Updated. * testsuite/gas/i386/x86-64-relax-4.d: Likewise. ld/ PR gas/26263 * testsuite/ld-i386/i386.exp: Run PR gas/26263 test. * testsuite/ld-x86-64/x86-64.exp: Likewise. * testsuite/ld-i386/pr26263.d: New file. * testsuite/ld-x86-64/pr26263.d: Likewise. * testsuite/ld-x86-64/pr26263.s: Likewise. --- gas/config/tc-i386.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'gas/config/tc-i386.c') diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index 192c5e1..a9c79f1 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -13849,11 +13849,22 @@ i386_validate_fix (fixS *fixp) } } #if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) - else if (!object_64bit) + else { - if (fixp->fx_r_type == BFD_RELOC_386_GOT32 - && fixp->fx_tcbit2) - fixp->fx_r_type = BFD_RELOC_386_GOT32X; + /* NB: Commit 292676c1 resolved PLT32 reloc aganst local symbol + to section. Since PLT32 relocation must be against symbols, + turn such PLT32 relocation into PC32 relocation. */ + if (fixp->fx_addsy + && (fixp->fx_r_type == BFD_RELOC_386_PLT32 + || fixp->fx_r_type == BFD_RELOC_X86_64_PLT32) + && symbol_section_p (fixp->fx_addsy)) + fixp->fx_r_type = BFD_RELOC_32_PCREL; + if (!object_64bit) + { + if (fixp->fx_r_type == BFD_RELOC_386_GOT32 + && fixp->fx_tcbit2) + fixp->fx_r_type = BFD_RELOC_386_GOT32X; + } } #endif } -- cgit v1.1