8sa1-binutils-gdb/include/elf
H.J. Lu 02a866936d Add R_386_GOT32X support to gas and ld
This patch adds support for the R_386_GOT32X relocation proposed in

https://groups.google.com/forum/#!topic/ia32-abi/GbJJskkid4I

to gas and ld.  It updates gas to generate R_386_GOT32X relocation for
memory operand, foo@GOT[(%reg)].  We must encode "mov foo@GOT, %eax"
with the 0x8b opcode, instead of the 0xb8 opcode, so that it can be
transformed to "lea foo, %eax".  With the locally defined symbol, foo,
we convert

   mov foo@GOT[(%reg1)], %reg2
to
   lea foo[@GOTOFF(%reg1)], %reg2

and convert

   call/jmp *foo@GOT[(%reg)]
to

   nop call foo/jmp foo nop

When PIC is false, convert

   test %reg1, foo@GOT[(%reg2)]
to
   test $foo, %reg1

and convert

binop foo@GOT[(%reg1)], %reg2

to

binop $foo, %reg2

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

bfd/

	* elf32-i386.c: Include opcode/i386.h.
	(elf_howto_table): Add R_386_GOT32X.
	(R_386_ext2): Replace R_386_IRELATIVE with R_386_GOT32X.
	(elf_i386_reloc_type_lookup): Handle BFD_RELOC_386_GOT32X.
	(need_convert_mov_to_lea): Renamed to ...
	(need_convert_load): This.
	(elf_i386_check_relocs): Handle R_386_GOT32X.  Replace
	need_convert_mov_to_lea with need_convert_load.
	(elf_i386_gc_sweep_hook): Handle R_386_GOT32X.
	(elf_i386_size_dynamic_sections): Likewise.
	(elf_i386_relocate_section): Likewise.
	(elf_i386_convert_mov_to_lea): Renamed to ...
	(elf_i386_convert_load): This.  Replace need_convert_mov_to_lea
	with need_convert_load.  Support R_386_GOT32X transformations.
	* reloc.c (BFD_RELOC_386_GOT32X): New.
	* bfd-in2.h: Regenerated.
	* libbfd.h: Likewise.

gas/

	* config/tc-i386.c (tc_i386_fix_adjustable): Handle
	BFD_RELOC_386_GOT32X.
	(tc_gen_reloc): Likewise.
	(match_template): Force 0x8b encoding for "mov foo@GOT, %eax".
	(output_disp): Check for "call/jmp *mem", "mov mem, %reg",
	"test %reg, mem" and "binop mem, %reg" where binop is one of
	adc, add, and, cmp, or, sbb, sub, xor instructions.  Set
	fx_tcbit if the REX prefix is generated.  Set fx_tcbit2 if
	BFD_RELOC_386_GOT32X should be generated.
	(i386_validate_fix): Generate BFD_RELOC_386_GOT32X if fx_tcbit2
	is set.

gas/testsuite/

	* gas/i386/got.d: New file.
	* gas/i386/got.s: Likewise.
	* gas/i386/i386.exp: Run got.
	* gas/i386/localpic.d: Replace R_386_GOT32 with R_386_GOT32X.
	* gas/i386/mixed-mode-reloc32.d: Likewise.
	* gas/i386/reloc32.d: Likewise.

include/elf/

	* i386.h (R_386_GOT32X): New relocation.

ld/testsuite/

	* ld-i386/branch1.d: New file.
	* ld-i386/branch1.s: Likewise.
	* ld-i386/call1.d: Likewise.
	* ld-i386/call1.s: Likewise.
	* ld-i386/call2.d: Likewise.
	* ld-i386/call2.s: Likewise.
	* ld-i386/got1.dd: Likewise.
	* ld-i386/got1.out: Likewise.
	* ld-i386/got1a.S: Likewise.
	* ld-i386/got1b.c: Likewise.
	* ld-i386/got1c.c: Likewise.
	* ld-i386/got1d.S: Likewise.
	* ld-i386/jmp1.d: Likewise.
	* ld-i386/jmp1.s: Likewise.
	* ld-i386/jmp2.d: Likewise.
	* ld-i386/jmp2.s: Likewise.
	* ld-i386/load1.d: Likewise.
	* ld-i386/load1.s: Likewise.
	* ld-i386/load2.d: Likewise.
	* ld-i386/load2.s: Likewise.
	* ld-i386/load3.d: Likewise.
	* ld-i386/load3.s: Likewise.
	* ld-i386/load4.s: Likewise.
	* ld-i386/load4a.d: Likewise.
	* ld-i386/load4b.d: Likewise.
	* ld-i386/load5.s: Likewise.
	* ld-i386/load5a.d: Likewise.
	* ld-i386/load5b.d: Likewise.
	* ld-i386/load6.d: Likewise.
	* ld-i386/load6.s: Likewise.
	* ld-i386/i386.exp: Run branch1, call1, call2, jmp1, jmp2,
	load1, load2, load3, load4a, load4b, load5a, load5b and load6
	tests.  Run got1 test.
2015-10-22 04:47:07 -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_386_GOT32X support to gas and ld 2015-10-22 04:47:07 -07:00
ChangeLog-9103 Add copyright notices 2012-12-10 12:48:03 +00:00
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 ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
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