From 6e7ce2cdd34f7e3ad720e1d43a19635d79ce17b4 Mon Sep 17 00:00:00 2001 From: Paul Brook Date: Tue, 31 May 2011 13:40:04 +0000 Subject: [PATCH] 2011-05-31 Paul Brook Nathan Sidwell gas/ * config/tc-arm.c (fix_new_arm): Create an absolute symbol for pc-relative fixes to constants. * config/tc-arm.h (TC_FORCE_RELOCATATION_ABS): Define. ld/testsuite/ * ld-arm/abs-call-1.d: New. * ld-arm/abs-call-1.s: New. * ld-arm/arm-elf.exp: Add it. --- gas/ChangeLog | 7 +++++++ gas/config/tc-arm.c | 23 +++++++++++++++++++++++ gas/config/tc-arm.h | 6 ++++++ ld/testsuite/ChangeLog | 7 +++++++ ld/testsuite/ld-arm/abs-call-1.d | 9 +++++++++ ld/testsuite/ld-arm/abs-call-1.s | 8 ++++++++ ld/testsuite/ld-arm/arm-elf.exp | 3 +++ 7 files changed, 63 insertions(+) create mode 100644 ld/testsuite/ld-arm/abs-call-1.d create mode 100644 ld/testsuite/ld-arm/abs-call-1.s diff --git a/gas/ChangeLog b/gas/ChangeLog index cd4546c2c78..456f14a6290 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,10 @@ +2011-05-31 Paul Brook + Nathan Sidwell + + * config/tc-arm.c (fix_new_arm): Create an absolute symbol for + pc-relative fixes to constants. + * config/tc-arm.h (TC_FORCE_RELOCATATION_ABS): Define. + 2011-05-27 Nick Clifton * config/tc-s390.c (md_begin): Remove unused variable dup_insn. diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c index a9839cd9342..375ff82d3fc 100644 --- a/gas/config/tc-arm.c +++ b/gas/config/tc-arm.c @@ -15434,6 +15434,29 @@ fix_new_arm (fragS * frag, switch (exp->X_op) { case O_constant: + if (pc_rel) + { + /* Create an absolute valued symbol, so we have something to + refer to in the object file. Unfortunately for us, gas's + generic expression parsing will already have folded out + any use of .set foo/.type foo %function that may have + been used to set type information of the target location, + that's being specified symbolically. We have to presume + the user knows what they are doing. */ + char name[16 + 8]; + symbolS *symbol; + + sprintf (name, "*ABS*0x%lx", (unsigned long)exp->X_add_number); + + symbol = symbol_find_or_make (name); + S_SET_SEGMENT (symbol, absolute_section); + symbol_set_frag (symbol, &zero_address_frag); + S_SET_VALUE (symbol, exp->X_add_number); + exp->X_op = O_symbol; + exp->X_add_symbol = symbol; + exp->X_add_number = 0; + } + /* FALLTHROUGH */ case O_symbol: case O_add: case O_subtract: diff --git a/gas/config/tc-arm.h b/gas/config/tc-arm.h index 702e4053b02..2916ae19a32 100644 --- a/gas/config/tc-arm.h +++ b/gas/config/tc-arm.h @@ -192,6 +192,12 @@ void arm_copy_symbol_attributes (symbolS *, symbolS *); (THUMB_IS_FUNC ((FIX)->fx_addsy) \ || !SEG_NORMAL (SEG)) +#define TC_FORCE_RELOCATION_ABS(FIX) \ + (((FIX)->fx_pcrel \ + && (FIX)->fx_r_type != BFD_RELOC_32 \ + && (FIX)->fx_r_type != BFD_RELOC_ARM_GOT32) \ + || TC_FORCE_RELOCATION(FIX)) + #define TC_CONS_FIX_NEW cons_fix_new_arm #define MAX_MEM_ALIGNMENT_BYTES 6 diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index a652cdeee08..586356e5c43 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2011-05-31 Paul Brook + Nathan Sidwell + + * ld-arm/abs-call-1.d: New. + * ld-arm/abs-call-1.s: New. + * ld-arm/arm-elf.exp: Add it. + 2011-05-31 Paul Brook * ld-arm/tls-longplt.d: Update expected output. diff --git a/ld/testsuite/ld-arm/abs-call-1.d b/ld/testsuite/ld-arm/abs-call-1.d new file mode 100644 index 00000000000..4482beba529 --- /dev/null +++ b/ld/testsuite/ld-arm/abs-call-1.d @@ -0,0 +1,9 @@ +.*: file format elf32-.* + + +Disassembly of section .text: + +00008000 : + 8000: eb03dffe bl 100000 + 8004: ea03dffd b 100000 + 8008: eb03dffc bl 100000 diff --git a/ld/testsuite/ld-arm/abs-call-1.s b/ld/testsuite/ld-arm/abs-call-1.s new file mode 100644 index 00000000000..c0a66b46740 --- /dev/null +++ b/ld/testsuite/ld-arm/abs-call-1.s @@ -0,0 +1,8 @@ + + .type foo, %function + .set foo, 0x100000 + +arm: bl 0x100000 + b 0x100000 + bl foo + diff --git a/ld/testsuite/ld-arm/arm-elf.exp b/ld/testsuite/ld-arm/arm-elf.exp index 95959f8b351..a8c51c25cf6 100644 --- a/ld/testsuite/ld-arm/arm-elf.exp +++ b/ld/testsuite/ld-arm/arm-elf.exp @@ -413,6 +413,9 @@ set armelftests { {objdump {-s -j.data -j.got} ifunc-16.gd} {readelf -r ifunc-16.rd}} "ifunc-16"} + {"abs call" "-T arm.ld" "" {abs-call-1.s} + {{objdump -d abs-call-1.d}} + "abs-call-1"} } run_ld_link_tests $armelftests -- 2.30.2