x86: Properly handle PLT expression in directive
authorH.J. Lu <hjl.tools@gmail.com>
Wed, 19 Dec 2018 20:21:56 +0000 (12:21 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Wed, 19 Dec 2018 20:22:12 +0000 (12:22 -0800)
commitb9519cfe9828b9ee5a73e74b4be83d46f33e6886
treeaecea8a8890eb3cc814a80abdf7c0a976a889f01
parentfc999e8020ffe8e1136da70f275bceafaa62a588
x86: Properly handle PLT expression in directive

For PLT expressions, we should subtract the PLT relocation size only for
jump instructions.  Since PLT relocations are PC relative, we only allow
"symbol@PLT" in PLT expression.

gas/

PR gas/23997
* config/tc-i386.c (x86_cons): Check for invalid PLT expression.
(md_apply_fix): Subtract the PLT relocation size only for jump
instructions.
* testsuite/gas/i386/reloc32.s: Add test for invalid PLT
expression.
* testsuite/gas/i386/reloc64.s: Likewise.
* testsuite/gas/i386/ilp32/reloc64.s: Likewise.
* testsuite/gas/i386/reloc32.l: Updated.
* testsuite/gas/i386/reloc64.l: Likewise.
* testsuite/gas/i386/ilp32/reloc64.l: Likewise.

ld/

PR gas/23997
* testsuite/ld-i386/i386.exp: Run PR gas/23997 test.
* testsuite/ld-x86-64/x86-64.exp: Likewise.
* testsuite/ld-x86-64/pr23997a.s: New file.
* testsuite/ld-x86-64/pr23997b.c: Likewise.
* testsuite/ld-x86-64/pr23997c.c: Likewise.
14 files changed:
gas/ChangeLog
gas/config/tc-i386.c
gas/testsuite/gas/i386/ilp32/reloc64.l
gas/testsuite/gas/i386/ilp32/reloc64.s
gas/testsuite/gas/i386/reloc32.l
gas/testsuite/gas/i386/reloc32.s
gas/testsuite/gas/i386/reloc64.l
gas/testsuite/gas/i386/reloc64.s
ld/ChangeLog
ld/testsuite/ld-i386/i386.exp
ld/testsuite/ld-x86-64/pr23997a.s [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr23997b.c [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr23997c.c [new file with mode: 0644]
ld/testsuite/ld-x86-64/x86-64.exp