2006-05-02 Paul Brook <paul@codesourcery.com>
authorPaul Brook <paul@codesourcery.com>
Tue, 2 May 2006 13:09:18 +0000 (13:09 +0000)
committerPaul Brook <paul@codesourcery.com>
Tue, 2 May 2006 13:09:18 +0000 (13:09 +0000)
bfd/
* elf32-arm.c (elf32_arm_final_link_relocate): Set thumb funciton bit
for R_ARM_REL32.
gas/
* config/tc-arm.c (arm_optimize_expr): New function.
* config/tc-arm.h (md_optimize_expr): Define
(arm_optimize_expr): Add prototype.
(TC_FORCE_RELOCATION_SUB_SAME): Define.
ld/testsuite/
* ld-arm/arm-elf.exp: Add thumb-rel32.
* ld-arm/thumb-rel32.d: New test.
* ld-arm/thumb-rel32.s: New test.

bfd/ChangeLog
bfd/elf32-arm.c
gas/ChangeLog
gas/config/tc-arm.c
gas/config/tc-arm.h
ld/testsuite/ChangeLog
ld/testsuite/ld-arm/arm-elf.exp
ld/testsuite/ld-arm/thumb-rel32.d [new file with mode: 0644]
ld/testsuite/ld-arm/thumb-rel32.s [new file with mode: 0644]

index 9381660c843aa334a79ff1dd5f6edcd151c33550..e3d371f5922b9663f2252a0a9d638fd5bf97b7db 100644 (file)
@@ -1,3 +1,8 @@
+2006-05-02  Paul Brook  <paul@codesourcery.com>
+
+       * elf32-arm.c (elf32_arm_final_link_relocate): Set thumb funciton bit
+       for R_ARM_REL32.
+
 2006-05-02  Ben Elliston  <bje@au.ibm.com>
 
        * archive.c (bfd_generic_archive_p): Remove unused local variable
index bd3c4e3356b1e0c386e48ae99bc1475689548a40..eb7723b49422499b8d7d2413ee2aa058dcc258ff 100644 (file)
@@ -3274,9 +3274,11 @@ elf32_arm_final_link_relocate (reloc_howto_type *           howto,
          break;
 
        case R_ARM_REL32:
+         value += addend;
+         if (sym_flags == STT_ARM_TFUNC)
+           value |= 1;
          value -= (input_section->output_section->vma
                    + input_section->output_offset + rel->r_offset);
-         value += addend;
          break;
 
        case R_ARM_PREL31:
index 718197b973097c174ebc88e9cfda4ea774eae6fe..8ab4b75fae835e89cdc0e39348f3881fc1c18598 100644 (file)
@@ -1,3 +1,10 @@
+2006-05-02  Paul Brook  <paul@codesourcery.com>
+
+       * config/tc-arm.c (arm_optimize_expr): New function.
+       * config/tc-arm.h (md_optimize_expr): Define
+       (arm_optimize_expr): Add prototype.
+       (TC_FORCE_RELOCATION_SUB_SAME): Define.
+
 2006-05-02  Ben Elliston  <bje@au.ibm.com>
 
        * config/obj-elf.h (ELF_TARGET_SYMBOL_FIELDS): Make single bit
index ff66a1d4ba0457f927ee1a05df890205a71ed60c..3b588ace9bb6ac3ed6280a1be7ec01ec9c13a08f 100644 (file)
@@ -15811,6 +15811,29 @@ get_thumb32_insn (char * buf)
   return insn;
 }
 
+
+/* We usually want to set the low bit on the address of thumb function
+   symbols.  In particular .word foo - . should have the low bit set.
+   Generic code tries to fold the difference of two symbols to
+   a constant.  Prevent this and force a relocation when the first symbols
+   is a thumb function.  */
+int
+arm_optimize_expr (expressionS *l, operatorT op, expressionS *r)
+{
+  if (op == O_subtract
+      && l->X_op == O_symbol
+      && r->X_op == O_symbol
+      && THUMB_IS_FUNC (l->X_add_symbol))
+    {
+      l->X_op = O_subtract;
+      l->X_op_symbol = r->X_add_symbol;
+      l->X_add_number -= r->X_add_number;
+      return 1;
+    }
+  /* Process as normal.  */
+  return 0;
+}
+
 void
 md_apply_fix (fixS *   fixP,
               valueT * valP,
index 3b33324053d55e9e780c8adb723741d972a6f77e..f2615770c47df9f4ad1aa50cc45b1bfa16c7ec41 100644 (file)
@@ -83,6 +83,9 @@ struct fix;
   arm_relax_frag(segment, fragp, stretch)
 extern int arm_relax_frag (asection *, struct frag *, long);
 
+#define md_optimize_expr(l,o,r)                arm_optimize_expr (l, o, r)
+extern int arm_optimize_expr (expressionS *, operatorT, expressionS *);
+
 #define md_cleanup() arm_cleanup ()
 
 #define md_start_line_hook() arm_start_line_hook ()
@@ -148,6 +151,12 @@ extern void arm_md_end (void);
    || (FIX)->fx_r_type == BFD_RELOC_32                 \
    || TC_FORCE_RELOCATION (FIX))
 
+/* Force output of R_ARM_REL32 relocations against thumb function symbols.
+   This is needed to ensure the low bit is handled correctly.  */
+#define TC_FORCE_RELOCATION_SUB_SAME(FIX, SEG) \
+  (THUMB_IS_FUNC ((FIX)->fx_addsy)             \
+   || !SEG_NORMAL (SEG))
+
 #define TC_CONS_FIX_NEW cons_fix_new_arm
 
 #define MAX_MEM_FOR_RS_ALIGN_CODE 31
index 76fdb74735585164ea918a0d313d50667a1d6422..dc5cfecedfd4e115bd6823058462a68cb9b3ab44 100644 (file)
@@ -1,3 +1,9 @@
+2006-05-02  Paul Brook  <paul@codesourcery.com>
+
+       * ld-arm/arm-elf.exp: Add thumb-rel32.
+       * ld-arm/thumb-rel32.d: New test.
+       * ld-arm/thumb-rel32.s: New test.
+
 2006-04-29  H.J. Lu  <hongjiu.lu@intel.com>
 
        * ld-elfvers/vers.exp: Xfail vers7a, vers7, vers23a, vers23b,
index 1cb231faf1460cb9f18d4e1fade4127d359ae1ee..1a9fc00aeb8c0fd83e6fd8783787716bfd3a6c9a 100644 (file)
@@ -119,6 +119,9 @@ set armelftests {
     {"Thumb entry point" "-T arm.ld" "" {thumb-entry.s}
      {{readelf -h thumb-entry.d}}
      "thumb-entry"}
+    {"thumb-rel32" "-static -T arm.ld" "" {thumb-rel32.s}
+     {{objdump -s thumb-rel32.d}}
+     "thumb-rel32"}
 }
 
 run_ld_link_tests $armelftests
diff --git a/ld/testsuite/ld-arm/thumb-rel32.d b/ld/testsuite/ld-arm/thumb-rel32.d
new file mode 100644 (file)
index 0000000..34cde4d
--- /dev/null
@@ -0,0 +1,7 @@
+
+.*:     file format.*
+
+Contents of section .text:
+ 8000 (00000011 fffffffd 00ffffff f8000000|11000000 fdffffff 00f8ffff ff000000) .*
+# Ignore .ARM.attributes section
+#...
diff --git a/ld/testsuite/ld-arm/thumb-rel32.s b/ld/testsuite/ld-arm/thumb-rel32.s
new file mode 100644 (file)
index 0000000..83eb0e5
--- /dev/null
@@ -0,0 +1,18 @@
+       .text
+       .arch armv4t
+       .global _start
+       .type   _start, %function
+       .thumb_func
+_start:
+       .word bar - .
+       .word _start - .
+       .byte 0
+       .4byte (_start - .) + 1
+       .byte 0, 0, 0
+       .section .after, "ax", %progbits
+       .global bar
+       .type bar, %function
+       .thumb_func
+bar:
+       .word 0
+       .ident  "GCC: (GNU) 4.1.0 (CodeSourcery ARM)"
This page took 0.044592 seconds and 4 git commands to generate.