This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
[PATCH] Indicate dependency on personality routines for ARM EHABI- take 2
- From: Julian Brown <julian at codesourcery dot com>
- To: binutils at sources dot redhat dot com
- Date: Thu, 03 Mar 2005 22:43:08 +0000
- Subject: [PATCH] Indicate dependency on personality routines for ARM EHABI- take 2
Hi,
This is a second attempt at a patch to make gas emit dependencies on
exception-handling personality routines (__aeabi_unwind_cpp_pr[012]) in
accordance with the ARM EHABI, using relocations of type R_ARM_NONE.
The previous patch is here:
http://sourceware.org/ml/binutils/2005-02/msg00172.html
This version fixes some missing cases in the previous patch (eg, where
there is a .personalityindex directive in an assembly source file but
nothing is written to an .extab section), and outputs only one
relocation for each personality routine per-file to save unnecessary bloat.
I'm not sure if the way this is implemented is good enough though: a
global variable is initialised at load-time to indicate that no PR
dependencies have been output yet. Are there any situations where gas
processes more than one file consecutively, or is there any other reason
why this might break?
Tested with no regressions with cross to arm-none-eabi, and natively on
i686-pc-linux-gnu with all targets enabled.
OK to apply?
ChangeLog:
* gas/config/tc-arm.c (marked_pr_dependency): New static global
(bitmask).
(create_unwind_entry): Don't output dependencies on PR routines
here.
(s_arm_unwind_fnend): Output dependency on unwinding routines, if it
hasn't been done already.
* gas/testsuite/arm/unwind.d: Update expected output.
--
Julian Brown
CodeSourcery, LLC
? bfd/doc/bfd.info
? bfd/doc/bfd.info-1
? gas/doc/as.info
? gas/doc/as.info-1
? gprof/gprof.info
? gprof/gprof.info-1
Index: gas/config/tc-arm.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-arm.c,v
retrieving revision 1.193
diff -c -p -r1.193 tc-arm.c
*** gas/config/tc-arm.c 23 Feb 2005 12:28:03 -0000 1.193
--- gas/config/tc-arm.c 3 Mar 2005 22:18:25 -0000
*************** static struct
*** 83,88 ****
--- 83,93 ----
unsigned sp_restored:1;
} unwind;
+ /* Bit N indicates that an R_ARM_NONE relocation has been output for
+ __aeabi_unwind_cpp_prN already if set. This enables dependencies to be
+ emitted only once per file, to save unnecessary bloat. */
+ static unsigned int marked_pr_dependency = 0;
+
#endif /* OBJ_ELF */
enum arm_float_abi
*************** create_unwind_entry (int have_data)
*** 13902,13914 ****
fix_new (frag_now, where, 4, unwind.personality_routine, 0, 1,
BFD_RELOC_ARM_PREL31);
- /* Indicate dependency to linker. */
- {
- char *name = "__aeabi_unwind_cpp_pr0";
- symbolS *pr = symbol_find_or_make (name);
- fix_new (frag_now, where, 4, pr, 0, 1, BFD_RELOC_NONE);
- }
-
where += 4;
ptr += 4;
--- 13907,13912 ----
*************** create_unwind_entry (int have_data)
*** 13922,13945 ****
/* Three opcodes bytes are packed into the first word. */
data = 0x80;
n = 3;
! goto emit_reloc;
case 1:
case 2:
/* The size and first two opcode bytes go in the first word. */
data = ((0x80 + unwind.personality_index) << 8) | size;
n = 2;
- goto emit_reloc;
-
- emit_reloc:
- {
- /* Indicate dependency to linker. */
- char *name[] = { "__aeabi_unwind_cpp_pr0",
- "__aeabi_unwind_cpp_pr1",
- "__aeabi_unwind_cpp_pr2" };
- symbolS *pr = symbol_find_or_make (name[unwind.personality_index]);
- fix_new (frag_now, where, 4, pr, 0, 1, BFD_RELOC_NONE);
- }
break;
default:
--- 13920,13932 ----
/* Three opcodes bytes are packed into the first word. */
data = 0x80;
n = 3;
! break;
case 1:
case 2:
/* The size and first two opcode bytes go in the first word. */
data = ((0x80 + unwind.personality_index) << 8) | size;
n = 2;
break;
default:
*************** s_arm_unwind_fnend (int ignored ATTRIBUT
*** 14048,14053 ****
--- 14035,14055 ----
fix_new (frag_now, where, 4, unwind.proc_start, 0, 1,
BFD_RELOC_ARM_PREL31);
+ /* Indicate dependency on EHABI-defined personality routines to the
+ linker, if it hasn't been done already. */
+ if (unwind.personality_index >= 0 && unwind.personality_index < 3)
+ {
+ char *name[] = { "__aeabi_unwind_cpp_pr0",
+ "__aeabi_unwind_cpp_pr1",
+ "__aeabi_unwind_cpp_pr2" };
+ if (!(marked_pr_dependency & (1 << unwind.personality_index)))
+ {
+ symbolS *pr = symbol_find_or_make (name[unwind.personality_index]);
+ fix_new (frag_now, where, 0, pr, 0, 1, BFD_RELOC_NONE);
+ marked_pr_dependency |= 1 << unwind.personality_index;
+ }
+ }
+
if (val)
/* Inline exception table entry. */
md_number_to_chars (ptr + 4, val, 4);
Index: gas/testsuite/gas/arm/unwind.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/arm/unwind.d,v
retrieving revision 1.4
diff -c -p -r1.4 unwind.d
*** gas/testsuite/gas/arm/unwind.d 10 Feb 2005 12:39:17 -0000 1.4
--- gas/testsuite/gas/arm/unwind.d 3 Mar 2005 22:18:30 -0000
***************
*** 5,20 ****
RELOCATION RECORDS FOR \[.ARM.extab\]:
OFFSET TYPE VALUE
- 00000000 R_ARM_NONE __aeabi_unwind_cpp_pr1
0000000c R_ARM_PREL31 .text
- 0000000c R_ARM_NONE __aeabi_unwind_cpp_pr0
- 0000001c R_ARM_NONE __aeabi_unwind_cpp_pr1
RELOCATION RECORDS FOR \[.ARM.exidx\]:
OFFSET TYPE VALUE
00000000 R_ARM_PREL31 .text
00000008 R_ARM_PREL31 .text
0000000c R_ARM_PREL31 .ARM.extab
00000010 R_ARM_PREL31 .text
00000014 R_ARM_PREL31 .ARM.extab
--- 5,19 ----
RELOCATION RECORDS FOR \[.ARM.extab\]:
OFFSET TYPE VALUE
0000000c R_ARM_PREL31 .text
RELOCATION RECORDS FOR \[.ARM.exidx\]:
OFFSET TYPE VALUE
00000000 R_ARM_PREL31 .text
+ 00000000 R_ARM_NONE __aeabi_unwind_cpp_pr0
00000008 R_ARM_PREL31 .text
+ 00000008 R_ARM_NONE __aeabi_unwind_cpp_pr1
0000000c R_ARM_PREL31 .ARM.extab
00000010 R_ARM_PREL31 .text
00000014 R_ARM_PREL31 .ARM.extab