public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Indicate dependency on personality routines for ARM EHABI - take 2
@ 2005-03-03 22:43 Julian Brown
  2005-03-03 23:31 ` Paul Brook
  0 siblings, 1 reply; 11+ messages in thread
From: Julian Brown @ 2005-03-03 22:43 UTC (permalink / raw)
  To: binutils

[-- Attachment #1: Type: text/plain, Size: 1406 bytes --]

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

[-- Attachment #2: patch-10 --]
[-- Type: text/plain, Size: 4754 bytes --]

? 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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Indicate dependency on personality routines for ARM EHABI - take 2
  2005-03-03 22:43 [PATCH] Indicate dependency on personality routines for ARM EHABI - take 2 Julian Brown
@ 2005-03-03 23:31 ` Paul Brook
  2005-03-07 15:36   ` Julian Brown
  0 siblings, 1 reply; 11+ messages in thread
From: Paul Brook @ 2005-03-03 23:31 UTC (permalink / raw)
  To: binutils; +Cc: Julian Brown

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.

Paul

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Indicate dependency on personality routines for ARM EHABI - take 2
  2005-03-03 23:31 ` Paul Brook
@ 2005-03-07 15:36   ` Julian Brown
  2005-03-07 16:08     ` Paul Brook
  0 siblings, 1 reply; 11+ messages in thread
From: Julian Brown @ 2005-03-07 15:36 UTC (permalink / raw)
  To: Paul Brook; +Cc: binutils, julian

[-- Attachment #1: Type: text/plain, Size: 1575 bytes --]

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.

[-- Attachment #2: patch-11 --]
[-- Type: text/plain, Size: 5514 bytes --]

? 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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Indicate dependency on personality routines for ARM EHABI - take 2
  2005-03-07 15:36   ` Julian Brown
@ 2005-03-07 16:08     ` Paul Brook
  2005-03-07 18:40       ` Julian Brown
  0 siblings, 1 reply; 11+ messages in thread
From: Paul Brook @ 2005-03-07 16:08 UTC (permalink / raw)
  To: Julian Brown; +Cc: binutils

> > 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.

Paul

$ cat test.s
        .text
        .fnstart
        .global foo
foo:
        bx lr
        .fnend
        .fnstart
        .global bar
bar:
        bx lr
        .fnend
        .section        .text.other,"ax",%progbits
        .fnstart
        .global other
other:
        bx lr
        .fnend

$ arm-unknown-eabi-as test.s -o test.o
$ arm-unknown-eabi-objdump -r test.o

test.o:     file format elf32-littlearm

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


RELOCATION RECORDS FOR [.ARM.exidx.text.other]:
OFFSET   TYPE              VALUE
00000000 R_ARM_PREL31      .text.other

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Indicate dependency on personality routines for ARM EHABI - take 2
  2005-03-07 16:08     ` Paul Brook
@ 2005-03-07 18:40       ` Julian Brown
  2005-03-09 12:57         ` Nick Clifton
  2005-03-09 15:26         ` Richard Earnshaw
  0 siblings, 2 replies; 11+ messages in thread
From: Julian Brown @ 2005-03-07 18:40 UTC (permalink / raw)
  To: Paul Brook; +Cc: binutils, julian

[-- Attachment #1: Type: text/plain, Size: 1107 bytes --]

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.

[-- Attachment #2: patch-12 --]
[-- Type: text/plain, Size: 5082 bytes --]

? 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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Indicate dependency on personality routines for ARM EHABI - take 2
  2005-03-07 18:40       ` Julian Brown
@ 2005-03-09 12:57         ` Nick Clifton
  2005-03-09 15:13           ` Richard Earnshaw
  2005-03-09 15:26         ` Richard Earnshaw
  1 sibling, 1 reply; 11+ messages in thread
From: Nick Clifton @ 2005-03-09 12:57 UTC (permalink / raw)
  To: Julian Brown; +Cc: Paul Brook, binutils

Hi Julian,

> 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.

I have only be vaguely following this thread but one thing does occur to 
me.  Will your patch work if the programmer uses sub-segments and/or the 
.pushsection/.popsection pseudo ops ?  If so, then please consider this 
patch approved for the mainline only, not the 2.16 branch.

Cheers
   Nick

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Indicate dependency on personality routines for ARM EHABI - take 2
  2005-03-09 12:57         ` Nick Clifton
@ 2005-03-09 15:13           ` Richard Earnshaw
  0 siblings, 0 replies; 11+ messages in thread
From: Richard Earnshaw @ 2005-03-09 15:13 UTC (permalink / raw)
  To: Nick Clifton; +Cc: Julian Brown, Paul Brook, binutils

On Wed, 2005-03-09 at 13:09, Nick Clifton wrote:
> Hi Julian,
> 
> > 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.
> 
> I have only be vaguely following this thread but one thing does occur to 
> me.  Will your patch work if the programmer uses sub-segments and/or the 
> .pushsection/.popsection pseudo ops ?  If so, then please consider this 
> patch approved for the mainline only, not the 2.16 branch.

A quick look at the code suggests that most of the unwinding code in the
assembler will probably break horribly if we try to nest building
partial unwind descriptions in multiple sections.  So I don't think it
would be reasonable to expect that to be fixed here first.

R. 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Indicate dependency on personality routines for ARM EHABI - take 2
  2005-03-07 18:40       ` Julian Brown
  2005-03-09 12:57         ` Nick Clifton
@ 2005-03-09 15:26         ` Richard Earnshaw
  2005-03-29  6:42           ` [PATCH] Indicate dependency on personality routines for ARM EHABI - take 3 Julian Brown
  1 sibling, 1 reply; 11+ messages in thread
From: Richard Earnshaw @ 2005-03-09 15:26 UTC (permalink / raw)
  To: Julian Brown; +Cc: Paul Brook, binutils

On Mon, 2005-03-07 at 18:40, Julian Brown wrote:
> 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?

I fear we aren't there yet.  Consider emitting unwind sections for a
real C++ application that goes something like

.text
.text.foo (eg a common function definition)
.text

We'll get two references added to the .text section.  That's not
necessarily fatal, but it is indicative of a design flaw.

Nick's point about making push/pop section work correctly made me think
about this for a moment.  I think the correct way to handle this is to
rework the TC_SEGMENT_INFO_TYPE code (and hence the mapping symbol code)
so that it is a structure rather than a single datum type.  You could
then add marked_pr_dependency to that type and all segment
pushing/popping should just work magically, solving both Nick's question
and the case above once and for all.

R.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH] Indicate dependency on personality routines for ARM EHABI - take 3
  2005-03-09 15:26         ` Richard Earnshaw
@ 2005-03-29  6:42           ` Julian Brown
  2005-03-29 17:38             ` Richard Earnshaw
  0 siblings, 1 reply; 11+ messages in thread
From: Julian Brown @ 2005-03-29  6:42 UTC (permalink / raw)
  To: Richard Earnshaw; +Cc: Paul Brook, binutils

[-- Attachment #1: Type: text/plain, Size: 1169 bytes --]

Hi,

This patch fixes output of dependencies on ARM EABI personality routines 
for stack unwinding, using R_ARM_NONE relocations. It should output only 
one dependency per-section, and should handle .pushsection/.popsection 
correctly. These are the previous version of the patch:

   http://sourceware.org/ml/binutils/2005-03/msg00126.html
   http://sourceware.org/ml/binutils/2005-02/msg00172.html

Tested on arm-none-eabi and i686-pc-linux-gnu with all targets.

OK to apply?

ChangeLog:

   * gas/config/tc-arm.c (marked_pr_dependency): New bitmap, bit N
   indicates whether personality routine index N has been output for this
   section.
   (mapping_state): tc_segment_info_data now struct not enum.
   (arm_elf_change_section): Likewise, and marked_pr_dependency is now
   handled on section change.
   (create_unwind_entry): Previous code to output dependency removed.
   (s_arm_unwind_fnend): Output dependency if it hasn't been done
   already for this section.
   * gas/config/tc-arm.h (TC_SEGMENT_INFO_TYPE): Redefined as struct
   arm_segment_info_type.
   (arm_segment_info_type): New struct.
   * gas/testsuite/gas/arm/unwind.d: Update expected output.

[-- Attachment #2: patch-13 --]
[-- Type: text/plain, Size: 7241 bytes --]

? 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.197
diff -c -p -r1.197 tc-arm.c
*** gas/config/tc-arm.c	23 Mar 2005 15:49:02 -0000	1.197
--- gas/config/tc-arm.c	28 Mar 2005 23:31:26 -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 section, to save unnecessary bloat.  */
+ static unsigned int marked_pr_dependency = 0;
+ 
  #endif /* OBJ_ELF */
  
  enum arm_float_abi
*************** mapping_state (enum mstate state)
*** 1347,1353 ****
        abort ();
      }
  
!   seg_info (now_seg)->tc_segment_info_data = state;
  
    symbolP = symbol_new (symname, now_seg, (valueT) frag_now_fix (), frag_now);
    symbol_table_insert (symbolP);
--- 1352,1358 ----
        abort ();
      }
  
!   seg_info (now_seg)->tc_segment_info_data.mapstate = state;
  
    symbolP = symbol_new (symname, now_seg, (valueT) frag_now_fix (), frag_now);
    symbol_table_insert (symbolP);
*************** void
*** 1379,1384 ****
--- 1384,1390 ----
  arm_elf_change_section (void)
  {
    flagword flags;
+   segment_info_type *seginfo;
  
    /* Link an unlinked unwind index table section to the .text section.  */
    if (elf_section_type (now_seg) == SHT_ARM_EXIDX
*************** arm_elf_change_section (void)
*** 1394,1400 ****
    if ((flags & SEC_ALLOC) == 0)
      return;
  
!   mapstate = seg_info (now_seg)->tc_segment_info_data;
  }
  
  int
--- 1400,1408 ----
    if ((flags & SEC_ALLOC) == 0)
      return;
  
!   seginfo = seg_info (now_seg);
!   mapstate = seginfo->tc_segment_info_data.mapstate;
!   marked_pr_dependency = seginfo->tc_segment_info_data.marked_pr_dependency;
  }
  
  int
*************** create_unwind_entry (int have_data)
*** 14303,14315 ****
        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;
  
--- 14311,14316 ----
*************** create_unwind_entry (int have_data)
*** 14323,14346 ****
        /* 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:
--- 14324,14336 ----
        /* 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
*** 14449,14454 ****
--- 14439,14461 ----
    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;
+ 	  seg_info (now_seg)->tc_segment_info_data.marked_pr_dependency
+ 	    = marked_pr_dependency;
+         }
+     }
+ 
    if (val)
      /* Inline exception table entry.  */
      md_number_to_chars (ptr + 4, val, 4);
Index: gas/config/tc-arm.h
===================================================================
RCS file: /cvs/src/src/gas/config/tc-arm.h,v
retrieving revision 1.25
diff -c -p -r1.25 tc-arm.h
*** gas/config/tc-arm.h	3 Mar 2005 11:47:49 -0000	1.25
--- gas/config/tc-arm.h	28 Mar 2005 23:31:26 -0000
*************** struct fix;
*** 170,176 ****
  # define md_elf_section_type(str, len)	arm_elf_section_type (str, len)
  # define GLOBAL_OFFSET_TABLE_NAME	"_GLOBAL_OFFSET_TABLE_"
  # define LOCAL_LABEL_PREFIX 		'.'
! # define TC_SEGMENT_INFO_TYPE 		enum mstate
  
  enum mstate
  {
--- 170,176 ----
  # define md_elf_section_type(str, len)	arm_elf_section_type (str, len)
  # define GLOBAL_OFFSET_TABLE_NAME	"_GLOBAL_OFFSET_TABLE_"
  # define LOCAL_LABEL_PREFIX 		'.'
! # define TC_SEGMENT_INFO_TYPE 		struct arm_segment_info_type
  
  enum mstate
  {
*************** enum mstate
*** 180,185 ****
--- 180,191 ----
    MAP_THUMB
  };
  
+ struct arm_segment_info_type
+ {
+   enum mstate mapstate;
+   unsigned int marked_pr_dependency;
+ };
+ 
  /* We want .cfi_* pseudo-ops for generating unwind info.  */
  #define TARGET_USE_CFIPOP              1
  
Index: gas/testsuite/gas/arm/unwind.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/arm/unwind.d,v
retrieving revision 1.5
diff -c -p -r1.5 unwind.d
*** gas/testsuite/gas/arm/unwind.d	4 Mar 2005 15:28:36 -0000	1.5
--- gas/testsuite/gas/arm/unwind.d	28 Mar 2005 23:31:26 -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.*

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Indicate dependency on personality routines for ARM EHABI - take 3
  2005-03-29  6:42           ` [PATCH] Indicate dependency on personality routines for ARM EHABI - take 3 Julian Brown
@ 2005-03-29 17:38             ` Richard Earnshaw
  2005-03-29 20:00               ` Julian Brown
  0 siblings, 1 reply; 11+ messages in thread
From: Richard Earnshaw @ 2005-03-29 17:38 UTC (permalink / raw)
  To: Julian Brown; +Cc: Paul Brook, binutils

On Tue, 2005-03-29 at 01:02, Julian Brown wrote:
> Hi,
> 
> This patch fixes output of dependencies on ARM EABI personality routines 
> for stack unwinding, using R_ARM_NONE relocations. It should output only 
> one dependency per-section, and should handle .pushsection/.popsection 
> correctly. These are the previous version of the patch:
> 
>    http://sourceware.org/ml/binutils/2005-03/msg00126.html
>    http://sourceware.org/ml/binutils/2005-02/msg00172.html
> 
> Tested on arm-none-eabi and i686-pc-linux-gnu with all targets.
> 
> OK to apply?
> 
> ChangeLog:
> 
>    * gas/config/tc-arm.c (marked_pr_dependency): New bitmap, bit N
>    indicates whether personality routine index N has been output for this
>    section.
>    (mapping_state): tc_segment_info_data now struct not enum.
>    (arm_elf_change_section): Likewise, and marked_pr_dependency is now
>    handled on section change.
>    (create_unwind_entry): Previous code to output dependency removed.
>    (s_arm_unwind_fnend): Output dependency if it hasn't been done
>    already for this section.
>    * gas/config/tc-arm.h (TC_SEGMENT_INFO_TYPE): Redefined as struct
>    arm_segment_info_type.
>    (arm_segment_info_type): New struct.
>    * gas/testsuite/gas/arm/unwind.d: Update expected output.
> 
> ______________________________________________________________________
OK.

R.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Indicate dependency on personality routines for ARM EHABI - take 3
  2005-03-29 17:38             ` Richard Earnshaw
@ 2005-03-29 20:00               ` Julian Brown
  0 siblings, 0 replies; 11+ messages in thread
From: Julian Brown @ 2005-03-29 20:00 UTC (permalink / raw)
  To: Richard Earnshaw; +Cc: Paul Brook, binutils, Julian Brown

Richard Earnshaw wrote:
> On Tue, 2005-03-29 at 01:02, Julian Brown wrote:
> 
>>Hi,
>>
>>This patch fixes output of dependencies on ARM EABI personality routines 
>>for stack unwinding, using R_ARM_NONE relocations. It should output only 
>>one dependency per-section, and should handle .pushsection/.popsection 
>>correctly. These are the previous version of the patch:
>>
>>   http://sourceware.org/ml/binutils/2005-03/msg00126.html
>>   http://sourceware.org/ml/binutils/2005-02/msg00172.html
>>
>>Tested on arm-none-eabi and i686-pc-linux-gnu with all targets.
>>
>>OK to apply?
>>
>>ChangeLog:
>>
>>   * gas/config/tc-arm.c (marked_pr_dependency): New bitmap, bit N
>>   indicates whether personality routine index N has been output for this
>>   section.
>>   (mapping_state): tc_segment_info_data now struct not enum.
>>   (arm_elf_change_section): Likewise, and marked_pr_dependency is now
>>   handled on section change.
>>   (create_unwind_entry): Previous code to output dependency removed.
>>   (s_arm_unwind_fnend): Output dependency if it hasn't been done
>>   already for this section.
>>   * gas/config/tc-arm.h (TC_SEGMENT_INFO_TYPE): Redefined as struct
>>   arm_segment_info_type.
>>   (arm_segment_info_type): New struct.
>>   * gas/testsuite/gas/arm/unwind.d: Update expected output.
>>
>>______________________________________________________________________
> 
> OK.

Applied on mainline and binutils-csl-arm-2005q1-branch.

Julian

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2005-03-29 16:38 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-03 22:43 [PATCH] Indicate dependency on personality routines for ARM EHABI - take 2 Julian Brown
2005-03-03 23:31 ` Paul Brook
2005-03-07 15:36   ` Julian Brown
2005-03-07 16:08     ` Paul Brook
2005-03-07 18:40       ` Julian Brown
2005-03-09 12:57         ` Nick Clifton
2005-03-09 15:13           ` Richard Earnshaw
2005-03-09 15:26         ` Richard Earnshaw
2005-03-29  6:42           ` [PATCH] Indicate dependency on personality routines for ARM EHABI - take 3 Julian Brown
2005-03-29 17:38             ` Richard Earnshaw
2005-03-29 20:00               ` Julian Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).