[AArch64, ILP32] 3/6 Support for ELF32 relocs and refactor reloc handling

bfd/

	* bfd-in2.h: Re-generated.
	* elfnn-aarch64.c (HOWTO64, HOWTO32): New define.
	(IS_AARCH64_TLS_RELOC): Change to be based on the
	bfd reloc enumerators.
	(IS_AARCH64_TLSDESC_RELOC): Likewise.
	(PG, PG_OFFSET): Cast literal to bfd_vma.
	(elf64_aarch64_howto_table): Removed.
	(elf64_aarch64_howto_dynrelocs): Removed.
	(elf64_aarch64_tls_howto_table): Removed.
	(elf64_aarch64_tlsdesc_howto_table): Removed.
	(elfNN_aarch64_howto_table): New table to host all howto entires..
	(R_AARCH64_*): Replaced by AARCH64_R (*) and AARCH64_R_STR (*).
	(elfNN_aarch64_bfd_reloc_from_howto): New function.
	(elfNN_aarch64_bfd_reloc_from_type): Ditto.
	(struct elf_aarch64_reloc_map): New.
	(elf_aarch64_reloc_map): New table.
	(elfNN_aarch64_howto_from_bfd_reloc): New function.
	(elfNN_aarch64_howto_from_type): Update to look up the new table
	elfNN_aarch64_howto_table.
	(struct elf64_aarch64_reloc_map): Remove.
	(elf64_aarch64_reloc_map): Remove.
	(elfNN_aarch64_reloc_type_lookup): Change to call
	elfNN_aarch64_howto_from_bfd_reloc.
	(elfNN_aarch64_reloc_name_lookup): Change to look up the new table
	elfNN_aarch64_howto_table.
	(aarch64_resolve_relocation): Refactor to switch on the bfd
	reloc enumerators.
	(bfd_elf_aarch64_put_addend): Likewise.
	(elfNN_aarch64_final_link_relocate): Likewise.
	(aarch64_tls_transition_without_check): Likewise.
	(aarch64_reloc_got_type): Likewise.
	(aarch64_can_relax_tls): Likewise.
	(aarch64_tls_transition): Likewise.
	(elfNN_aarch64_tls_relax): Likewise.
	(elfNN_aarch64_final_link_relocate): Likewise.
	(elfNN_aarch64_relocate_section): Likewise.
	(elfNN_aarch64_gc_sweep_hook): Likewise.
	(elfNN_aarch64_check_relocs): Likewise.
	(aarch64_tls_transition): Change to return a bfd reloc enumerator.
	* libbfd.h: Re-generated.
	* reloc.c: Re-order the AArch64 bfd reloc enumerators.
	(BFD_RELOC_AARCH64_RELOC_START)
	(BFD_RELOC_AARCH64_RELOC_END)
	(BFD_RELOC_AARCH64_LD_GOT_LO12_NC)
	(BFD_RELOC_AARCH64_LD32_GOT_LO12_NC)
	(BFD_RELOC_AARCH64_TLSDESC_LD_LO12_NC)
	(BFD_RELOC_AARCH64_TLSDESC_LD32_LO12_NC)
	(BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_LO12_NC)
	(BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC)
	(BFD_RELOC_AARCH64_IRELATIVE): New relocs.

gas/

	* config/tc-aarch64.c (reloc_table): Replace
	BFD_RELOC_AARCH64_LD64_GOT_LO12_NC with
	BFD_RELOC_AARCH64_LD_GOT_LO12_NC; likewise to
	BFD_RELOC_AARCH64_TLSDESC_LD64_LO12_NC and
	BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_LO12_NC.
	(md_apply_fix): Handle BFD_RELOC_AARCH64_LD_GOT_LO12_NC,
	BFD_RELOC_AARCH64_LD32_GOT_LO12_NC,
	BFD_RELOC_AARCH64_TLSDESC_LD_LO12_NC,
	BFD_RELOC_AARCH64_TLSDESC_LD32_LO12_NC,
	BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_LO12_NC and
	BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC.
	(aarch64_force_relocation): Likewise.

gas/testsuite/

	* gas/aarch64/ilp32-basic.d: New file.
	* gas/aarch64/ilp32-basic.s: New file.

include/elf/

	* aarch64.h: Add ELF32 reloc codes and remove fake ELF64 ones.
	(R_AARCH64_IRELATIVE): New reloc.
This commit is contained in:
Yufeng Zhang 2013-06-26 10:47:06 +00:00
parent aa688bddb4
commit bce06a5f2f
2 changed files with 128 additions and 12 deletions

View File

@ -1,3 +1,7 @@
2013-06-26 Yufeng Zhang <yufeng.zhang@arm.com>
* aarch64.h: Add ELF32 reloc codes and remove fake ELF64 ones.
2013-06-24 Maciej W. Rozycki <macro@codesourcery.com>
* mips.h (ELF_ST_IS_MIPS_PLT): Respect STO_MIPS16 setting.

View File

@ -43,7 +43,126 @@ START_RELOC_NUMBERS (elf_aarch64_reloc_type)
/* Null relocations. */
RELOC_NUMBER (R_AARCH64_NONE, 0) /* No reloc */
FAKE_RELOC (R_AARCH64_static_min, 256)
/* Basic data relocations. */
/* .word: (S+A) */
RELOC_NUMBER (R_AARCH64_P32_ABS32, 1)
/* .half: (S+A) */
RELOC_NUMBER (R_AARCH64_P32_ABS16, 2)
/* .word: (S+A-P) */
RELOC_NUMBER (R_AARCH64_P32_PREL32, 3)
/* .half: (S+A-P) */
RELOC_NUMBER (R_AARCH64_P32_PREL16, 4)
/* Group relocations to create a 16, 32, 48 or 64 bit
unsigned data or abs address inline. */
/* MOV[ZK]: ((S+A) >> 0) & 0xffff */
RELOC_NUMBER (R_AARCH64_P32_MOVW_UABS_G0, 5)
/* MOV[ZK]: ((S+A) >> 0) & 0xffff */
RELOC_NUMBER (R_AARCH64_P32_MOVW_UABS_G0_NC, 6)
/* MOV[ZK]: ((S+A) >> 16) & 0xffff */
RELOC_NUMBER (R_AARCH64_P32_MOVW_UABS_G1, 7)
/* Group relocations to create high part of a 16, 32, 48 or 64 bit
signed data or abs address inline. Will change instruction
to MOVN or MOVZ depending on sign of calculated value. */
/* MOV[ZN]: ((S+A) >> 0) & 0xffff */
RELOC_NUMBER (R_AARCH64_P32_MOVW_SABS_G0, 8)
/* Relocations to generate 19, 21 and 33 bit PC-relative load/store
addresses: PG(x) is (x & ~0xfff). */
/* LD-lit: ((S+A-P) >> 2) & 0x7ffff */
RELOC_NUMBER (R_AARCH64_P32_LD_PREL_LO19, 9)
/* ADR: (S+A-P) & 0x1fffff */
RELOC_NUMBER (R_AARCH64_P32_ADR_PREL_LO21, 10)
/* ADRH: ((PG(S+A)-PG(P)) >> 12) & 0x1fffff */
RELOC_NUMBER (R_AARCH64_P32_ADR_PREL_PG_HI21, 11)
/* ADD: (S+A) & 0xfff */
RELOC_NUMBER (R_AARCH64_P32_ADD_ABS_LO12_NC, 12)
/* LD/ST8: (S+A) & 0xfff */
RELOC_NUMBER (R_AARCH64_P32_LDST8_ABS_LO12_NC, 13)
/* LD/ST16: (S+A) & 0xffe */
RELOC_NUMBER (R_AARCH64_P32_LDST16_ABS_LO12_NC, 14)
/* LD/ST32: (S+A) & 0xffc */
RELOC_NUMBER (R_AARCH64_P32_LDST32_ABS_LO12_NC, 15)
/* LD/ST64: (S+A) & 0xff8 */
RELOC_NUMBER (R_AARCH64_P32_LDST64_ABS_LO12_NC, 16)
/* LD/ST128: (S+A) & 0xff0 */
RELOC_NUMBER (R_AARCH64_P32_LDST128_ABS_LO12_NC, 17)
/* Relocations for control-flow instructions. */
/* TBZ/NZ: ((S+A-P) >> 2) & 0x3fff. */
RELOC_NUMBER (R_AARCH64_P32_TSTBR14, 18)
/* B.cond: ((S+A-P) >> 2) & 0x7ffff. */
RELOC_NUMBER (R_AARCH64_P32_CONDBR19, 19)
/* B: ((S+A-P) >> 2) & 0x3ffffff. */
RELOC_NUMBER (R_AARCH64_P32_JUMP26, 20)
/* BL: ((S+A-P) >> 2) & 0x3ffffff. */
RELOC_NUMBER (R_AARCH64_P32_CALL26, 21)
RELOC_NUMBER (R_AARCH64_P32_GOT_LD_PREL19, 25)
RELOC_NUMBER (R_AARCH64_P32_ADR_GOT_PAGE, 26)
RELOC_NUMBER (R_AARCH64_P32_LD32_GOT_LO12_NC, 27)
RELOC_NUMBER (R_AARCH64_P32_TLSGD_ADR_PAGE21, 81)
RELOC_NUMBER (R_AARCH64_P32_TLSGD_ADD_LO12_NC, 82)
RELOC_NUMBER (R_AARCH64_P32_TLSIE_ADR_GOTTPREL_PAGE21, 103)
RELOC_NUMBER (R_AARCH64_P32_TLSIE_LD32_GOTTPREL_LO12_NC, 104)
RELOC_NUMBER (R_AARCH64_P32_TLSIE_LD_GOTTPREL_PREL19, 105)
RELOC_NUMBER (R_AARCH64_P32_TLSLE_MOVW_TPREL_G1, 106)
RELOC_NUMBER (R_AARCH64_P32_TLSLE_MOVW_TPREL_G0, 107)
RELOC_NUMBER (R_AARCH64_P32_TLSLE_MOVW_TPREL_G0_NC, 108)
RELOC_NUMBER (R_AARCH64_P32_TLSLE_ADD_TPREL_HI12, 109)
RELOC_NUMBER (R_AARCH64_P32_TLSLE_ADD_TPREL_LO12, 110)
RELOC_NUMBER (R_AARCH64_P32_TLSLE_ADD_TPREL_LO12_NC, 111)
RELOC_NUMBER (R_AARCH64_P32_TLSDESC_LD_PREL19, 122)
RELOC_NUMBER (R_AARCH64_P32_TLSDESC_ADR_PREL21, 123)
RELOC_NUMBER (R_AARCH64_P32_TLSDESC_ADR_PAGE21, 124)
RELOC_NUMBER (R_AARCH64_P32_TLSDESC_LD32_LO12_NC, 125)
RELOC_NUMBER (R_AARCH64_P32_TLSDESC_ADD_LO12_NC, 126)
RELOC_NUMBER (R_AARCH64_P32_TLSDESC_CALL, 127)
/* Dynamic relocations */
/* Copy symbol at runtime. */
RELOC_NUMBER (R_AARCH64_P32_COPY, 180)
/* Create GOT entry. */
RELOC_NUMBER (R_AARCH64_P32_GLOB_DAT, 181)
/* Create PLT entry. */
RELOC_NUMBER (R_AARCH64_P32_JUMP_SLOT, 182)
/* Adjust by program base. */
RELOC_NUMBER (R_AARCH64_P32_RELATIVE, 183)
RELOC_NUMBER (R_AARCH64_P32_TLS_DTPMOD, 184)
RELOC_NUMBER (R_AARCH64_P32_TLS_DTPREL, 185)
RELOC_NUMBER (R_AARCH64_P32_TLS_TPREL, 186)
RELOC_NUMBER (R_AARCH64_P32_TLSDESC, 187)
RELOC_NUMBER (R_AARCH64_P32_IRELATIVE, 188)
RELOC_NUMBER (R_AARCH64_NULL, 256) /* No reloc */
@ -157,9 +276,6 @@ RELOC_NUMBER (R_AARCH64_GOT_LD_PREL19, 309)
RELOC_NUMBER (R_AARCH64_ADR_GOT_PAGE, 311)
RELOC_NUMBER (R_AARCH64_LD64_GOT_LO12_NC, 312)
FAKE_RELOC (R_AARCH64_static_max, 313)
FAKE_RELOC (R_AARCH64_tls_min, 512)
RELOC_NUMBER (R_AARCH64_TLSGD_ADR_PAGE21, 513)
RELOC_NUMBER (R_AARCH64_TLSGD_ADD_LO12_NC, 514)
RELOC_NUMBER (R_AARCH64_TLSIE_MOVW_GOTTPREL_G1, 539)
@ -175,9 +291,7 @@ RELOC_NUMBER (R_AARCH64_TLSLE_MOVW_TPREL_G0_NC, 548)
RELOC_NUMBER (R_AARCH64_TLSLE_ADD_TPREL_HI12, 549)
RELOC_NUMBER (R_AARCH64_TLSLE_ADD_TPREL_LO12, 550)
RELOC_NUMBER (R_AARCH64_TLSLE_ADD_TPREL_LO12_NC, 551)
FAKE_RELOC (R_AARCH64_tls_max, 552)
FAKE_RELOC (R_AARCH64_tlsdesc_min, 560)
RELOC_NUMBER (R_AARCH64_TLSDESC_LD_PREL19, 560)
RELOC_NUMBER (R_AARCH64_TLSDESC_ADR_PREL21, 561)
RELOC_NUMBER (R_AARCH64_TLSDESC_ADR_PAGE21, 562)
@ -188,10 +302,8 @@ RELOC_NUMBER (R_AARCH64_TLSDESC_OFF_G0_NC, 566)
RELOC_NUMBER (R_AARCH64_TLSDESC_LDR, 567)
RELOC_NUMBER (R_AARCH64_TLSDESC_ADD, 568)
RELOC_NUMBER (R_AARCH64_TLSDESC_CALL, 569)
FAKE_RELOC (R_AARCH64_tlsdesc_max, 570)
/* Dynamic relocations */
FAKE_RELOC (R_AARCH64_dyn_min, 1024)
/* Copy symbol at runtime. */
RELOC_NUMBER (R_AARCH64_COPY, 1024)
@ -204,11 +316,11 @@ RELOC_NUMBER (R_AARCH64_JUMP_SLOT, 1026)
/* Adjust by program base. */
RELOC_NUMBER (R_AARCH64_RELATIVE, 1027)
RELOC_NUMBER (R_AARCH64_TLS_DTPMOD64, 1028)
RELOC_NUMBER (R_AARCH64_TLS_DTPREL64, 1029)
RELOC_NUMBER (R_AARCH64_TLS_TPREL64, 1030)
RELOC_NUMBER (R_AARCH64_TLS_DTPMOD, 1028)
RELOC_NUMBER (R_AARCH64_TLS_DTPREL, 1029)
RELOC_NUMBER (R_AARCH64_TLS_TPREL, 1030)
RELOC_NUMBER (R_AARCH64_TLSDESC, 1031)
FAKE_RELOC (R_AARCH64_dyn_max, 1032)
RELOC_NUMBER (R_AARCH64_IRELATIVE, 1032)
END_RELOC_NUMBERS (R_AARCH64_end)