This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: [PATCH] Indicate dependency on personality routines for ARM EHABI- take 2
- From: Julian Brown <julian at codesourcery dot com>
- To: Paul Brook <paul at codesourcery dot com>
- Cc: binutils at sources dot redhat dot com, julian at codesourcery dot com
- Date: Mon, 07 Mar 2005 15:35:55 +0000
- Subject: Re: [PATCH] Indicate dependency on personality routines for ARM EHABI- take 2
- References: <422792FC.1020000@codesourcery.com> <200503032331.38745.paul@codesourcery.com>
Paul Brook wrote:
On Thursday 03 March 2005 22:43, Julian Brown wrote:
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.
Is one per file sufficient? I'd expect one per section would be needed to
prevent bad things happening with partial linking.
Yes, you are probably right. This version should fix that: it resets the
bitmap of relocations which have been output when the section is changed
to one of type SHT_ARM_EXIDX.
Tested with cross to arm-none-eabi, and natively with all targets on
i686-pc-unknown-none.
OK to apply?
ChangeLog:
* gas/config/tc-arm.c (marked_pr_dependency): New static global
(bitmask).
(arm_elf_change_section): Reset bitmap of dependencies which have
been output when a new EXIDX section is seen.
(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.
? 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 4 Mar 2005 18:54:20 -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
*************** arm_elf_change_section (void)
*** 1376,1385 ****
{
flagword flags;
! /* Link an unlinked unwind index table section to the .text section. */
! if (elf_section_type (now_seg) == SHT_ARM_EXIDX
! && elf_linked_to_section (now_seg) == NULL)
! elf_linked_to_section (now_seg) = text_section;
if (!SEG_NORMAL (now_seg))
return;
--- 1381,1394 ----
{
flagword flags;
! if (elf_section_type (now_seg) == SHT_ARM_EXIDX)
! {
! /* Link an unlinked unwind index table section to the .text section. */
! if (elf_linked_to_section (now_seg) == NULL)
! elf_linked_to_section (now_seg) = text_section;
!
! marked_pr_dependency = 0;
! }
if (!SEG_NORMAL (now_seg))
return;
*************** 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;
--- 13911,13916 ----
*************** 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:
--- 13924,13936 ----
/* 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 ****
--- 14039,14059 ----
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 4 Mar 2005 18:54:22 -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