binutils-gdb/include/elf
H.J. Lu 56ceb5b540 Add R_X86_64_[REX_]GOTPCRELX support to gas and ld
This patch adds support for the R_X86_64_GOTPCRELX and
R_X86_64_REX_GOTPCRELX relocations proposed in

https://groups.google.com/forum/#!topic/x86-64-abi/n9AWHogmVY0

to gas and ld.  It updates gas to generate R_X86_64_GOTPCRELX,
R_X86_64_REX_GOTPCRELX if there is a REX prefix, relocation for memory
operand, foo@GOTPCREL(%rip).  With the locally defined symbol, foo, we
convert

  mov foo@GOTPCREL(%rip), %reg

to

   lea foo(%rip), %reg

and convert

   call/jmp *foo@GOTPCREL(%rip)
to

   nop call foo/jmp foo nop

When PIC is false, convert

   test %reg, foo@GOTPCREL(%rip)
to

test $foo, %reg

and convert

   binop foo@GOTPCREL(%rip), %reg

to

   binop $foo, %reg

where binop is one of adc, add, and, cmp, or, sbb, sub, xor instructions.

bfd/

	* elf64-x86-64.c: Include opcode/i386.h.
	(x86_64_elf_howto_table): Add R_X86_64_GOTPCRELX and
	R_X86_64_REX_GOTPCRELX.
	(R_X86_64_standard): Replace R_X86_64_PLT32_BND with
	R_X86_64_REX_GOTPCRELX.
	(x86_64_reloc_map): Add BFD_RELOC_X86_64_GOTPCRELX and
	BFD_RELOC_X86_64_REX_GOTPCRELX.
	(need_convert_mov_to_lea): Renamed to ...
	(need_convert_load): This.
	(elf_x86_64_check_relocs): Handle R_X86_64_GOTPCRELX and
	R_X86_64_REX_GOTPCRELX.  Replace need_convert_mov_to_lea with
	need_convert_load.
	(elf_x86_64_gc_sweep_hook): Handle R_X86_64_GOTPCRELX and
	R_X86_64_REX_GOTPCRELX.
	(elf_x86_64_size_dynamic_sections): Likewise.
	(elf_x86_64_relocate_section): Likewise.
	(elf_x86_64_convert_mov_to_lea): Renamed to ...
	(elf_x86_64_convert_load): This.  Replace need_convert_mov_to_lea
	with need_convert_load.  Support R_X86_64_GOTPCRELX and
	R_X86_64_REX_GOTPCRELX transformations.
	* reloc.c (BFD_RELOC_X86_64_GOTPCRELX): New.
	(BFD_RELOC_X86_64_REX_GOTPCRELX): Likewise.
	* bfd-in2.h: Regenerated.
	* libbfd.h: Likewise.

gas/

	* config/tc-i386.c (tc_i386_fix_adjustable): Handle
	BFD_RELOC_X86_64_GOTPCRELX and BFD_RELOC_X86_64_REX_GOTPCRELX.
	(tc_gen_reloc): Likewise.
	(i386_validate_fix): Generate BFD_RELOC_X86_64_GOTPCRELX or
	BFD_RELOC_X86_64_REX_GOTPCRELX if fx_tcbit2 is set.
	* config/tc-i386.h (TC_FORCE_RELOCATION_LOCAL): Also return
	true for BFD_RELOC_X86_64_GOTPCRELX and
	BFD_RELOC_X86_64_REX_GOTPCRELX.

gas/testsuite/

	* gas/i386/i386.exp: Run x86-64-gotpcrel.
	* gas/i386/x86-64-gotpcrel.d: New file.
	* gas/i386/x86-64-gotpcrel.s: Likewise.
	* gas/i386/ilp32/x86-64-gotpcrel.d: Likewise.
	* gas/i386/x86-64-localpic.d: Replace R_X86_64_GOTPCREL with
	R_X86_64_REX_GOTPCRELX.
	* gas/i386/ilp32/x86-64-localpic.d: Likewise.

include/elf/

	* x86-64.h (R_X86_64_GOTPCRELX): New.
	(R_X86_64_REX_GOTPCRELX): Likewise.

ld/testsuite/

	* ld-ifunc/ifunc-5r-local-x86-64.d: Replace R_X86_64_GOTPCREL
	with R_X86_64_REX_GOTPCRELX.
	* ld-x86-64/plt-main1.rd: Likewise.
	* ld-x86-64/plt-main3.rd: Likewise.
	* ld-x86-64/plt-main4.rd: Likewise.
	* ld-x86-64/gotpcrel1.dd: New file.
	* ld-x86-64/gotpcrel1.out: Likewise.
	* ld-x86-64/gotpcrel1a.S: Likewise.
	* ld-x86-64/gotpcrel1b.c: Likewise.
	* ld-x86-64/gotpcrel1c.c: Likewise.
	* ld-x86-64/gotpcrel1d.S: Likewise.
	* ld-x86-64/load1.s: Likewise.
	* ld-x86-64/load1a.d: Likewise.
	* ld-x86-64/load1b.d: Likewise.
	* ld-x86-64/load1c.d: Likewise.
	* ld-x86-64/load1d.d: Likewise.
	* ld-x86-64/x86-64.exp: Run load1a, load1b, load1c and load1d
	tests.  Run gotpcrel1 test.
2015-10-22 04:49:38 -07:00
..
aarch64.h [AArch64][3/6] GAS support TLSLD move/add relocation types 2015-08-19 16:36:22 +01:00
alpha.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
arc-reloc.def New ARC implementation. 2015-10-07 14:20:19 +01:00
arc.h New ARC implementation. 2015-10-07 14:20:19 +01:00
arm.h [ARM] PR ld/16572: Remove EF_ARM_HASENTRY flag 2015-03-10 11:15:13 +00:00
avr.h Define DIFF_EXPR_OK for avr target to allow PC relative difference relocation. 2015-07-08 21:41:52 +03:00
bfin.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
ChangeLog Add R_X86_64_[REX_]GOTPCRELX support to gas and ld 2015-10-22 04:49:38 -07:00
ChangeLog-9103
common.h New ARC implementation. 2015-10-07 14:20:19 +01:00
cr16.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
cr16c.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
cris.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
crx.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
d10v.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
d30v.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
dlx.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
dwarf.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
epiphany.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
external.h Change ch_type in Elf64_External_Chdr to 4 bytes 2015-09-21 10:19:25 -07:00
fr30.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
frv.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
ft32.h FT32 initial support 2015-01-28 16:25:18 +10:30
h8.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
hppa.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
i370.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
i386.h Add R_386_GOT32X support to gas and ld 2015-10-22 04:47:07 -07:00
i860.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
i960.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
ia64.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
internal.h Non-alloc sections don't belong in PT_LOAD segments 2015-04-25 09:15:49 +09:30
ip2k.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
iq2000.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
lm32.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
m32c.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
m32r.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
m68hc11.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
m68k.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
mcore.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
mep.h Define SEC_MEP_VLIW in bfd/section.c 2015-04-24 05:40:23 -07:00
metag.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
microblaze.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
mips.h 2015-07-09 Catherine Moore <clm@codesourcery.com> 2015-07-09 08:26:10 -07:00
mmix.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
mn10200.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
mn10300.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
moxie.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
msp430.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
mt.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
nds32.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
nios2.h Relocations for Nios II R2 2015-07-01 16:02:09 -07:00
or1k.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
pj.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
ppc64.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
ppc.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
reloc-macros.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
rl78.h Add support for G13 and G14 flag bits in RL78 ELF binaries. 2015-03-19 15:37:43 +00:00
rx.h Add support to the RX toolchain to restrict the use of string instructions. 2015-04-09 12:48:37 +01:00
s390.h S/390: z13 use GNU attribute to indicate vector ABI 2015-04-27 10:32:23 +02:00
score.h Fixes a typo in the license notice in include/elf/score.h 2015-02-23 14:52:12 +00:00
sh.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
sparc.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
spu.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
tic6x-attrs.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
tic6x.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
tilegx.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
tilepro.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
v850.h Adds support for generating notes in V850 binaries. 2015-02-24 17:54:09 +00:00
vax.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
visium.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
vxworks.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
x86-64.h Add R_X86_64_[REX_]GOTPCRELX support to gas and ld 2015-10-22 04:49:38 -07:00
xc16x.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
xgate.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
xstormy16.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
xtensa.h ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30