public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Julian Brown <julian@codesourcery.com>
To: Richard Earnshaw <rearnsha@gcc.gnu.org>
Cc: Paul Brook <paul@codesourcery.com>,  binutils@sources.redhat.com
Subject: [PATCH] Indicate dependency on personality routines for ARM EHABI - take 3
Date: Tue, 29 Mar 2005 06:42:00 -0000	[thread overview]
Message-ID: <42489B0F.5070809@codesourcery.com> (raw)
In-Reply-To: <1110381746.14453.61.camel@pc960.cambridge.arm.com>

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

  reply	other threads:[~2005-03-29  0:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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           ` Julian Brown [this message]
2005-03-29 17:38             ` [PATCH] Indicate dependency on personality routines for ARM EHABI - take 3 Richard Earnshaw
2005-03-29 20:00               ` Julian Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=42489B0F.5070809@codesourcery.com \
    --to=julian@codesourcery.com \
    --cc=binutils@sources.redhat.com \
    --cc=paul@codesourcery.com \
    --cc=rearnsha@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).