diff options
author | Yufeng Zhang <yufeng.zhang@arm.com> | 2013-06-26 10:47:06 +0000 |
---|---|---|
committer | Yufeng Zhang <yufeng.zhang@arm.com> | 2013-06-26 10:47:06 +0000 |
commit | a6bb11b2df1b69d79828a52a44eaf29ebc4d4955 (patch) | |
tree | ac8dfcd70bc509af34e0d0d4452e1c2c19860410 /gas | |
parent | cec5225bd81f750984856603755854f0f5796ab1 (diff) | |
download | binutils-a6bb11b2df1b69d79828a52a44eaf29ebc4d4955.tar.gz binutils-a6bb11b2df1b69d79828a52a44eaf29ebc4d4955.tar.bz2 binutils-a6bb11b2df1b69d79828a52a44eaf29ebc4d4955.zip |
[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.
Diffstat (limited to 'gas')
-rw-r--r-- | gas/ChangeLog | 15 | ||||
-rw-r--r-- | gas/config/tc-aarch64.c | 51 | ||||
-rw-r--r-- | gas/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gas/testsuite/gas/aarch64/ilp32-basic.d | 23 | ||||
-rw-r--r-- | gas/testsuite/gas/aarch64/ilp32-basic.s | 17 |
5 files changed, 108 insertions, 3 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog index 5270688921c..d998e3bad88 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,5 +1,20 @@ 2013-06-26 Yufeng Zhang <yufeng.zhang@arm.com> + * 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. + +2013-06-26 Yufeng Zhang <yufeng.zhang@arm.com> + * config/tc-aarch64.c (ilp32_p): New static variable. (elf64_aarch64_target_format): Return the target according to the value of 'ilp32_p'. diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c index 239b9eef614..52811ef3855 100644 --- a/gas/config/tc-aarch64.c +++ b/gas/config/tc-aarch64.c @@ -2377,7 +2377,7 @@ static struct reloc_table_entry reloc_table[] = { 0, 0, 0, - BFD_RELOC_AARCH64_LD64_GOT_LO12_NC}, + BFD_RELOC_AARCH64_LD_GOT_LO12_NC}, /* Get to the page containing GOT TLS entry for a symbol */ {"tlsgd", 0, @@ -2405,7 +2405,7 @@ static struct reloc_table_entry reloc_table[] = { 0, 0, BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC, - BFD_RELOC_AARCH64_TLSDESC_LD64_LO12_NC}, + BFD_RELOC_AARCH64_TLSDESC_LD_LO12_NC}, /* Get to the page containing GOT TLS entry for a symbol */ {"gottprel", 0, @@ -2419,7 +2419,7 @@ static struct reloc_table_entry reloc_table[] = { 0, 0, 0, - BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC}, + BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_LO12_NC}, /* Get tp offset for a symbol. */ {"tprel", 0, @@ -6506,10 +6506,33 @@ md_apply_fix (fixS * fixP, valueT * valP, segT seg) } break; + case BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_LO12_NC: + fixP->fx_r_type = (ilp32_p + ? BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC + : BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC); + S_SET_THREAD_LOCAL (fixP->fx_addsy); + /* Should always be exported to object file, see + aarch64_force_relocation(). */ + gas_assert (!fixP->fx_done); + gas_assert (seg->use_rela_p); + break; + + case BFD_RELOC_AARCH64_TLSDESC_LD_LO12_NC: + fixP->fx_r_type = (ilp32_p + ? BFD_RELOC_AARCH64_TLSDESC_LD32_LO12_NC + : BFD_RELOC_AARCH64_TLSDESC_LD64_LO12_NC); + S_SET_THREAD_LOCAL (fixP->fx_addsy); + /* Should always be exported to object file, see + aarch64_force_relocation(). */ + gas_assert (!fixP->fx_done); + gas_assert (seg->use_rela_p); + break; + case BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21: case BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC: case BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21: case BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC: + case BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC: case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12: case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12: case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12_NC: @@ -6521,6 +6544,7 @@ md_apply_fix (fixS * fixP, valueT * valP, segT seg) case BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21: case BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC: case BFD_RELOC_AARCH64_TLSDESC_LD64_LO12_NC: + case BFD_RELOC_AARCH64_TLSDESC_LD32_LO12_NC: S_SET_THREAD_LOCAL (fixP->fx_addsy); /* Should always be exported to object file, see aarch64_force_relocation(). */ @@ -6528,6 +6552,16 @@ md_apply_fix (fixS * fixP, valueT * valP, segT seg) gas_assert (seg->use_rela_p); break; + case BFD_RELOC_AARCH64_LD_GOT_LO12_NC: + /* Should always be exported to object file, see + aarch64_force_relocation(). */ + fixP->fx_r_type = (ilp32_p + ? BFD_RELOC_AARCH64_LD32_GOT_LO12_NC + : BFD_RELOC_AARCH64_LD64_GOT_LO12_NC); + gas_assert (!fixP->fx_done); + gas_assert (seg->use_rela_p); + break; + case BFD_RELOC_AARCH64_ADR_HI21_PCREL: case BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL: case BFD_RELOC_AARCH64_ADD_LO12: @@ -6539,6 +6573,7 @@ md_apply_fix (fixS * fixP, valueT * valP, segT seg) case BFD_RELOC_AARCH64_GOT_LD_PREL19: case BFD_RELOC_AARCH64_ADR_GOT_PAGE: case BFD_RELOC_AARCH64_LD64_GOT_LO12_NC: + case BFD_RELOC_AARCH64_LD32_GOT_LO12_NC: /* Should always be exported to object file, see aarch64_force_relocation(). */ gas_assert (!fixP->fx_done); @@ -6669,10 +6704,18 @@ aarch64_force_relocation (struct fix *fixp) even if the symbol is extern or weak. */ return 0; + case BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_LO12_NC: + case BFD_RELOC_AARCH64_TLSDESC_LD_LO12_NC: + case BFD_RELOC_AARCH64_LD_GOT_LO12_NC: + /* Pseudo relocs that need to be fixed up according to + ilp32_p. */ + return 0; + case BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21: case BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC: case BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21: case BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC: + case BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC: case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12: case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12: case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12_NC: @@ -6684,8 +6727,10 @@ aarch64_force_relocation (struct fix *fixp) case BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21: case BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC: case BFD_RELOC_AARCH64_TLSDESC_LD64_LO12_NC: + case BFD_RELOC_AARCH64_TLSDESC_LD32_LO12_NC: case BFD_RELOC_AARCH64_ADR_GOT_PAGE: case BFD_RELOC_AARCH64_LD64_GOT_LO12_NC: + case BFD_RELOC_AARCH64_LD32_GOT_LO12_NC: case BFD_RELOC_AARCH64_ADR_HI21_PCREL: case BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL: case BFD_RELOC_AARCH64_ADD_LO12: diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog index 6a31de76d8b..e309d0ea0ba 100644 --- a/gas/testsuite/ChangeLog +++ b/gas/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2013-06-26 Yufeng Zhang <yufeng.zhang@arm.com> + + * gas/aarch64/ilp32-basic.d: New file. + * gas/aarch64/ilp32-basic.s: New file. + 2013-06-25 Maciej W. Rozycki <macro@codesourcery.com> * gas/mips/micromips-insn32.d: New test. diff --git a/gas/testsuite/gas/aarch64/ilp32-basic.d b/gas/testsuite/gas/aarch64/ilp32-basic.d new file mode 100644 index 00000000000..b876c7aa432 --- /dev/null +++ b/gas/testsuite/gas/aarch64/ilp32-basic.d @@ -0,0 +1,23 @@ +#as: -milp32 +#objdump: -dr + +.*: file format elf32-.*aarch64 + + +Disassembly of section \.text: + +00000000 <.*>: + 0: 90000004 adrp x4, c <.*> + 0: R_AARCH64_P32_ADR_PREL_PG_HI21 ptrs + 4: 91000083 add x3, x4, #0x0 + 4: R_AARCH64_P32_ADD_ABS_LO12_NC ptrs + 8: b9000080 str w0, \[x4\] + 8: R_AARCH64_P32_LDST32_ABS_LO12_NC ptrs + c: b9000461 str w1, \[x3,#4\] + 10: b9000862 str w2, \[x3,#8\] + 14: 90000004 adrp x4, c <.*> + 14: R_AARCH64_P32_ADR_GOT_PAGE ptrs + 18: f9400083 ldr x3, \[x4\] + 18: R_AARCH64_P32_LD32_GOT_LO12_NC ptrs + 1c: 2a0403e0 mov w0, w4 + 20: d65f03c0 ret diff --git a/gas/testsuite/gas/aarch64/ilp32-basic.s b/gas/testsuite/gas/aarch64/ilp32-basic.s new file mode 100644 index 00000000000..790dcdf65c0 --- /dev/null +++ b/gas/testsuite/gas/aarch64/ilp32-basic.s @@ -0,0 +1,17 @@ + .cpu generic + .text + .align 2 + .global foo + .type foo, %function +foo: + adrp x4, ptrs + add x3, x4, :lo12:ptrs + str w0, [x4,#:lo12:ptrs] + str w1, [x3,4] + str w2, [x3,8] + adrp x4, :got:ptrs + ldr x3, [x4,#:got_lo12:ptrs] + mov w0, w4 + ret + .size foo, .-foo + .comm ptrs,12,8 |