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
Paul Brook wrote:
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.
I still only get one R_ARM_NONE relocation for the example below.
> [snipped example]
This version fixes that example, and my previous tests - it now tests
for the section being changed to one of type SHT_PROGBITS, rather than
SHT_ARM_EXIDX.
Tests have been re-run.
OK to apply?
ChangeLog:
* gas/config/tc-arm.c (marked_pr_dependency): New static global
(bitmap).
(arm_elf_change_section): Reset bitmap of dependencies which have
been output when a new section with type SHT_PROGBITS 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 7 Mar 2005 18:13:31 -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)
*** 1381,1386 ****
--- 1386,1394 ----
&& elf_linked_to_section (now_seg) == NULL)
elf_linked_to_section (now_seg) = text_section;
+ if (elf_section_type (now_seg) == SHT_PROGBITS)
+ 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;
--- 13910,13915 ----
*************** 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:
--- 13923,13935 ----
/* 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 ****
--- 14038,14058 ----
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 7 Mar 2005 18:13:34 -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