From eb043451b1652de2a6746d75603467e9cf955718 Mon Sep 17 00:00:00 2001 From: Paul Brook Date: Fri, 17 Sep 2004 12:35:00 +0000 Subject: bfd/ * bfd-in.h (bfd_elf32_arm_set_target_relocs): Add prototype. (bfd_elf32_arm_process_before_allocation): Update prototype. * bfd-in2.h: Regenerate. * bfd/elf32-arm.h (elf32_arm_link_hash_table): Add target2_reloc. (elf32_arm_link_hash_table_create): Set it. (bfd_elf32_arm_process_before_allocation): Remove target1_is_rel. (bfd_elf32_arm_set_target_relocs): New function. (arm_real_reloc_type): New function. (elf32_arm_final_link_relocate): Use it. Handle R_ARM_PREL31 and R_ARM_GOT_PREL. Remove R_ARM_TARGET1. (elf32_arm_gc_sweep_hook): Ditto. (elf32_arm_check_relocs): Ditto. (elf32_arm_relocate_section): Handle R_ARM_GOT_PREL. * elfarm-nabi.c (elf32_arm_howto_table): Add R_ARM_PREL31 and R_ARM_GOT_TARGET2. (elf32_arm_got_prel): New variable. (elf32_arm_howto_from_type): New function. (elf32_arm_info_to_howto): Use it. (elf32_arm_reloc_map): Add BFD_RELOC_ARM_PREL31 and BFD_RELOC_ARM_TARGET2. * libbfd.h: Regenerate. * reloc.c: Add BFD_RELOC_ARM_TARGET2 and BFD_RELOC_ARM_PREL31. gas/ * config/tc-arm.c (s_arm_rel31): New funciton. (md_pseudo_table): Add .rel31. (md_apply_fix3): Handle BFD_RELOC_ARM_TARGET2, BFD_RELOC_32_PCREL and BFD_RELOC_ARM_PREL31. (tc_gen_reloc): Handle BFD_RELOC_ARM_PREL31 and BFD_RELOC_ARM_TARGET2. (arm_fix_adjustable): Return 0 for BFD_RELOC_ARM_TARGET2. (arm_parse_reloc): Add (target2). gas/testsuite/ * gas/arm/pic.s: Add (target2). * gas/arm/pic.d: Ditto. include/ * elf/arm.h: Remove R_ARM_STKCHK and R_ARM_THM_STKCHK. Add R_ARM_TARGET2, R_ARM_PREL31, R_ARM_GOT_ABS, R_ARM_GOT_PREL, R_ARM_GOT_BREL12, R_ARM_GOTOFF12 and R_ARM_GOTRELAX. ld/ * ld.texinfo: Rename arm-specific section. Document --target* * emulparams/armelf_fbsd.sh: Set TARGET2_TYPE. * emulparams/armelf_linux.sh: Ditto. * emulparams/armelf_nbsd.sh: Ditto. * emultempl/armelf.em: Set default for TARGET2_TYPE. (target2_type): New variable. (arm_elf_before_allocation): Don't pass target1_type. (arm_elf_create_output_section_statements): New function. (PARSE_AND_LIST_PROLOGUE): Add OPTION_TARGET2. (PARSE_AND_LIST_LONGOPTS, PARSE_AND_LIST_OPTIONS): Add --target=. (PARSE_AND_LIST_ARGS_CASES): Handle OPTION_TARGET2. (LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS): Set. * emultempl/armelf_oabi.em (_before_allocation): Remove extra argument to bfd_elf32_arm_process_before_allocation. ld/testsuite/ * ld-arm/arm-target1-{abs,rel}.d}: New files. * ld-arm/arm-target1.s: New file. * ld-arm/arm-target2-{,got-}rel.d: New files. * ld-arm/arm-target2.s: New file. * ld-arm/arm-rel31.d: New files. * ld-arm/arm-rel31.s: New files. * ld-arm/arm.ld: New file. * ld-arm/arm-elf.exp: Add new tests. --- gas/ChangeLog | 10 +++++++ gas/config/tc-arm.c | 68 ++++++++++++++++++++++++++++++++++++++++++++- gas/testsuite/ChangeLog | 5 ++++ gas/testsuite/gas/arm/pic.d | 1 + gas/testsuite/gas/arm/pic.s | 1 + 5 files changed, 84 insertions(+), 1 deletion(-) (limited to 'gas') diff --git a/gas/ChangeLog b/gas/ChangeLog index 2ccb27c..2a4f37f 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,13 @@ +2004-09-17 Paul Brook + + * config/tc-arm.c (s_arm_rel31): New funciton. + (md_pseudo_table): Add .rel31. + (md_apply_fix3): Handle BFD_RELOC_ARM_TARGET2, + BFD_RELOC_32_PCREL and BFD_RELOC_ARM_PREL31. + (tc_gen_reloc): Handle BFD_RELOC_ARM_PREL31 and BFD_RELOC_ARM_TARGET2. + (arm_fix_adjustable): Return 0 for BFD_RELOC_ARM_TARGET2. + (arm_parse_reloc): Add (target2). + 2004-09-17 Alan Modra * Makefile.am: Run "make dep-am". diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c index faa628b..b0dbff7 100644 --- a/gas/config/tc-arm.c +++ b/gas/config/tc-arm.c @@ -2445,6 +2445,7 @@ static void s_thumb_func PARAMS ((int)); static void s_thumb_set PARAMS ((int)); #ifdef OBJ_ELF static void s_arm_elf_cons PARAMS ((int)); +static void s_arm_rel31 (int nbytes); #endif static int my_get_expression PARAMS ((expressionS *, char **)); @@ -2468,6 +2469,7 @@ const pseudo_typeS md_pseudo_table[] = #ifdef OBJ_ELF { "word", s_arm_elf_cons, 4 }, { "long", s_arm_elf_cons, 4 }, + { "rel31", s_arm_rel31, 0 }, #else { "word", cons, 4}, #endif @@ -12481,6 +12483,7 @@ md_apply_fix3 (fixP, valP, seg) #ifdef OBJ_ELF case BFD_RELOC_ARM_GOT32: case BFD_RELOC_ARM_GOTOFF: + case BFD_RELOC_ARM_TARGET2: md_number_to_chars (buf, 0, 4); break; #endif @@ -12490,6 +12493,7 @@ md_apply_fix3 (fixP, valP, seg) case BFD_RELOC_ARM_TARGET1: case BFD_RELOC_ARM_ROSEGREL32: case BFD_RELOC_ARM_SBREL32: + case BFD_RELOC_32_PCREL: if (fixP->fx_done || fixP->fx_pcrel) md_number_to_chars (buf, value, 4); #ifdef OBJ_ELF @@ -12502,6 +12506,20 @@ md_apply_fix3 (fixP, valP, seg) break; #ifdef OBJ_ELF + case BFD_RELOC_ARM_PREL31: + if (fixP->fx_done || fixP->fx_pcrel) + { + newval = md_chars_to_number (buf, 4) & 0x80000000; + if ((value ^ (value >> 1)) & 0x40000000) + { + as_bad_where (fixP->fx_file, fixP->fx_line, + _("rel31 relocation overflow")); + } + newval |= value & 0x7fffffff; + md_number_to_chars (buf, newval, 4); + } + break; + case BFD_RELOC_ARM_PLT32: /* It appears the instruction is fully prepared at this point. */ break; @@ -12780,6 +12798,8 @@ tc_gen_reloc (section, fixp) case BFD_RELOC_ARM_TARGET1: case BFD_RELOC_ARM_ROSEGREL32: case BFD_RELOC_ARM_SBREL32: + case BFD_RELOC_ARM_PREL31: + case BFD_RELOC_ARM_TARGET2: code = fixp->fx_r_type; break; #endif @@ -14090,7 +14110,8 @@ arm_fix_adjustable (fixP) /* Don't allow symbols to be discarded on GOT related relocs. */ if (fixP->fx_r_type == BFD_RELOC_ARM_PLT32 || fixP->fx_r_type == BFD_RELOC_ARM_GOT32 - || fixP->fx_r_type == BFD_RELOC_ARM_GOTOFF) + || fixP->fx_r_type == BFD_RELOC_ARM_GOTOFF + || fixP->fx_r_type == BFD_RELOC_ARM_TARGET2) return 0; return 1; @@ -14151,6 +14172,7 @@ arm_parse_reloc () MAP ("(plt)", BFD_RELOC_ARM_PLT32), MAP ("(target1)", BFD_RELOC_ARM_TARGET1), MAP ("(sbrel)", BFD_RELOC_ARM_SBREL32), + MAP ("(target2)", BFD_RELOC_ARM_TARGET2), { NULL, 0, BFD_RELOC_UNUSED } #undef MAP }; @@ -14225,6 +14247,50 @@ s_arm_elf_cons (nbytes) demand_empty_rest_of_line (); } + +/* Parse a .rel31 directive. */ + +static void +s_arm_rel31 (int ignored ATTRIBUTE_UNUSED) +{ + expressionS exp; + char *p; + valueT highbit; + + SKIP_WHITESPACE (); + + highbit = 0; + if (*input_line_pointer == '1') + highbit = 0x80000000; + else if (*input_line_pointer != '0') + as_bad (_("expected 0 or 1")); + + input_line_pointer++; + SKIP_WHITESPACE (); + if (*input_line_pointer != ',') + as_bad (_("missing comma")); + input_line_pointer++; + +#ifdef md_flush_pending_output + md_flush_pending_output (); +#endif + +#ifdef md_cons_align + md_cons_align (4); +#endif + + mapping_state (MAP_DATA); + + expression (&exp); + + p = frag_more (4); + md_number_to_chars (p, highbit, 4); + fix_new_arm (frag_now, p - frag_now->fr_literal, 4, &exp, 1, + BFD_RELOC_ARM_PREL31); + + demand_empty_rest_of_line (); +} + #endif /* OBJ_ELF */ /* This is called from HANDLE_ALIGN in write.c. Fill in the contents diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog index c2e4663..2d5d234 100644 --- a/gas/testsuite/ChangeLog +++ b/gas/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-09-17 Paul Brook + + * gas/arm/pic.s: Add (target2). + * gas/arm/pic.d: Ditto. + 2004-09-13 Paul Brook * gas/arm/pic.d: Rename RELABS to TARGET1. diff --git a/gas/testsuite/gas/arm/pic.d b/gas/testsuite/gas/arm/pic.d index ff536ad..2697136 100644 --- a/gas/testsuite/gas/arm/pic.d +++ b/gas/testsuite/gas/arm/pic.d @@ -17,3 +17,4 @@ Disassembly of section .text: 14: R_ARM_GOTPC _GLOBAL_OFFSET_TABLE_ 18: R_ARM_TARGET1 foo2 1c: R_ARM_SBREL32 foo3 + 20: R_ARM_TARGET2 foo4 diff --git a/gas/testsuite/gas/arm/pic.s b/gas/testsuite/gas/arm/pic.s index 7a26750..3c3c329 100644 --- a/gas/testsuite/gas/arm/pic.s +++ b/gas/testsuite/gas/arm/pic.s @@ -11,3 +11,4 @@ .word _GLOBAL_OFFSET_TABLE_ - 1b .word foo2(TARGET1) .word foo3(SBREL) + .word foo4(TARGET2) -- cgit v1.1