public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Indicate dependency on personality routines for ARM EHABI
@ 2005-02-09 17:06 Julian Brown
  2005-02-09 17:09 ` Ian Lance Taylor
  2005-02-09 17:12 ` Richard Earnshaw
  0 siblings, 2 replies; 15+ messages in thread
From: Julian Brown @ 2005-02-09 17:06 UTC (permalink / raw)
  To: binutils

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

Hi,

This patch causes gas to emit dependencies on personality routines 
(__aeabi_unwind_cpp_pr[012]) from a suitable run-time library when 
necessary, using an R_ARM_NONE relocation type.

Tested on i686-pc-linux-gnu and arm-none-eabi with no regressions 
(though the expected output for the .ARM.extab has changed for one of 
the tests.)

OK to apply?

ChangeLog:

     * bfd/bfd-in2.h (bfd_reloc_code_real): New relocation type
     (BFD_RELOC_ARM_NONE).
     * bfd/elf32-arm.c (elf32_arm_reloc_map): BFD_RELOC_ARM_NONE maps to
     R_ARM_NONE.
     * bfd/libbfd.h (bfd_reloc_code_): Add BFD_RELOC_ARM_NONE.
     * bfd/reloc.c (BFD_RELOC_ARM_NONE): Add.
     * gas/config/tc-arm.c (md_apply_fix3): Handle BFD_RELOC_ARM_NONE.
     (tc_gen_reloc): Handle BFD_RELOC_ARM_NONE.
     (create_unwind_entry): Output dependency on the unwinding routines.
     * gas/testsuite/gas/arm/unwind.d: Alter expected output to include
     dependency on __aeabi_unwind_cpp_pr[01].

-- 
Julian Brown
CodeSourcery, LLC

[-- Attachment #2: patch-5 --]
[-- Type: text/plain, Size: 6932 bytes --]

? bfd/doc/bfd.info
? bfd/doc/bfd.info-1
? gas/doc/as.info
? gas/doc/as.info-1
Index: bfd/bfd-in2.h
===================================================================
RCS file: /cvs/src/src/bfd/bfd-in2.h,v
retrieving revision 1.318
diff -c -p -r1.318 bfd-in2.h
*** bfd/bfd-in2.h	28 Jan 2005 17:24:38 -0000	1.318
--- bfd/bfd-in2.h	9 Feb 2005 15:50:19 -0000
*************** field in the instruction.  */
*** 2642,2647 ****
--- 2642,2648 ----
  
  /* These relocs are only used within the ARM assembler.  They are not
  (at present) written to any object files.  */
+   BFD_RELOC_ARM_NONE,
    BFD_RELOC_ARM_IMMEDIATE,
    BFD_RELOC_ARM_ADRL_IMMEDIATE,
    BFD_RELOC_ARM_OFFSET_IMM,
Index: bfd/elf32-arm.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-arm.c,v
retrieving revision 1.20
diff -c -p -r1.20 elf32-arm.c
*** bfd/elf32-arm.c	31 Jan 2005 17:50:20 -0000	1.20
--- bfd/elf32-arm.c	9 Feb 2005 15:50:21 -0000
*************** static const struct elf32_arm_reloc_map 
*** 867,872 ****
--- 867,873 ----
      {BFD_RELOC_ARM_OFFSET_IMM,       R_ARM_ABS12},
      {BFD_RELOC_ARM_THUMB_OFFSET,     R_ARM_THM_ABS5},
      {BFD_RELOC_THUMB_PCREL_BRANCH23, R_ARM_THM_PC22},
+     {BFD_RELOC_ARM_NONE,             R_ARM_NONE},
      {BFD_RELOC_ARM_COPY,             R_ARM_COPY},
      {BFD_RELOC_ARM_GLOB_DAT,         R_ARM_GLOB_DAT},
      {BFD_RELOC_ARM_JUMP_SLOT,        R_ARM_JUMP_SLOT},
Index: bfd/libbfd.h
===================================================================
RCS file: /cvs/src/src/bfd/libbfd.h,v
retrieving revision 1.134
diff -c -p -r1.134 libbfd.h
*** bfd/libbfd.h	25 Jan 2005 20:22:23 -0000	1.134
--- bfd/libbfd.h	9 Feb 2005 15:50:23 -0000
*************** static const char *const bfd_reloc_code_
*** 1125,1130 ****
--- 1125,1131 ----
    "BFD_RELOC_PPC64_DTPREL16_HIGHESTA",
    "BFD_RELOC_I370_D12",
    "BFD_RELOC_CTOR",
+   "BFD_RELOC_ARM_NONE",
    "BFD_RELOC_ARM_PCREL_BRANCH",
    "BFD_RELOC_ARM_PCREL_BLX",
    "BFD_RELOC_THUMB_PCREL_BLX",
Index: bfd/reloc.c
===================================================================
RCS file: /cvs/src/src/bfd/reloc.c,v
retrieving revision 1.121
diff -c -p -r1.121 reloc.c
*** bfd/reloc.c	31 Jan 2005 23:13:29 -0000	1.121
--- bfd/reloc.c	9 Feb 2005 15:50:26 -0000
*************** ENUMDOC
*** 2564,2569 ****
--- 2564,2573 ----
    It generally does map to one of the other relocation types.
  
  ENUM
+   BFD_RELOC_ARM_NONE
+ ENUMDOC
+   For when we really want to write R_ARM_NONE to the object file.
+ ENUM
    BFD_RELOC_ARM_PCREL_BRANCH
  ENUMDOC
    ARM 26 bit pc-relative branch.  The lowest two bits must be zero and are
Index: gas/config/tc-arm.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-arm.c,v
retrieving revision 1.190
diff -c -p -r1.190 tc-arm.c
*** gas/config/tc-arm.c	31 Jan 2005 23:18:25 -0000	1.190
--- gas/config/tc-arm.c	9 Feb 2005 15:50:30 -0000
*************** md_apply_fix3 (fixS *   fixP,
*** 11383,11388 ****
--- 11383,11393 ----
  
    switch (fixP->fx_r_type)
      {
+     case BFD_RELOC_ARM_NONE:
+       /* This will need to go into the object file.  */
+       fixP->fx_done = 0;
+       break;
+   
      case BFD_RELOC_ARM_IMMEDIATE:
        /* We claim that this fixup has been processed here,
  	 even if in fact we generate an error because we do
*************** tc_gen_reloc (asection * section ATTRIBU
*** 12106,12111 ****
--- 12111,12117 ----
  	  break;
  	}
  
+     case BFD_RELOC_ARM_NONE:
      case BFD_RELOC_ARM_PCREL_BRANCH:
      case BFD_RELOC_ARM_PCREL_BLX:
      case BFD_RELOC_RVA:
*************** tc_gen_reloc (asection * section ATTRIBU
*** 12170,12175 ****
--- 12176,12182 ----
  
  	switch (fixp->fx_r_type)
  	  {
+ 	  case BFD_RELOC_ARM_NONE:         type = "ARM_NONE";     break;
  	  case BFD_RELOC_ARM_OFFSET_IMM8:  type = "OFFSET_IMM8";  break;
  	  case BFD_RELOC_ARM_SHIFT_IMM:    type = "SHIFT_IMM";    break;
  	  case BFD_RELOC_ARM_SMI:          type = "SMI";          break;
*************** create_unwind_entry (int have_data)
*** 13893,13898 ****
--- 13900,13913 ----
        /* Custom personality routine.  */
        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_ARM_NONE);
+ 	}
+ 
        where += 4;
        ptr += 4;
  
*************** create_unwind_entry (int have_data)
*** 13902,13919 ****
        break;
  
      /* ABI defined personality routines.  */
-     /* TODO: Emit R_ARM_NONE to the personality routine.  */
      case 0:
        /* 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:
--- 13917,13944 ----
        break;
  
      /* ABI defined personality routines.  */
      case 0:
        /* 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_ARM_NONE);
+       }
        break;
  
      default:
Index: gas/testsuite/gas/arm/unwind.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/arm/unwind.d,v
retrieving revision 1.3
diff -c -p -r1.3 unwind.d
*** gas/testsuite/gas/arm/unwind.d	9 Dec 2004 20:25:24 -0000	1.3
--- gas/testsuite/gas/arm/unwind.d	9 Feb 2005 15:50:44 -0000
***************
*** 1,11 ****
  #objdump: -sr
  #name: Unwind table generation
  
! .*:     file format.*
  
  RELOCATION RECORDS FOR \[.ARM.extab\]:
  OFFSET   TYPE              VALUE 
  0000000c R_ARM_PREL31      .text
  
  
  RELOCATION RECORDS FOR \[.ARM.exidx\]:
--- 1,14 ----
  #objdump: -sr
  #name: Unwind table generation
  
! dump.o:     file format elf32-littlearm
  
  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\]:

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

* Re: [PATCH] Indicate dependency on personality routines for ARM EHABI
  2005-02-09 17:06 [PATCH] Indicate dependency on personality routines for ARM EHABI Julian Brown
@ 2005-02-09 17:09 ` Ian Lance Taylor
  2005-02-09 17:24   ` Paul Brook
                     ` (2 more replies)
  2005-02-09 17:12 ` Richard Earnshaw
  1 sibling, 3 replies; 15+ messages in thread
From: Ian Lance Taylor @ 2005-02-09 17:09 UTC (permalink / raw)
  To: Julian Brown; +Cc: binutils

Julian Brown <julian@codesourcery.com> writes:

>   /* These relocs are only used within the ARM assembler.  They are not
>   (at present) written to any object files.  */
> +   BFD_RELOC_ARM_NONE,

Why not just use BFD_RELOC_NONE here?

In general you should only create a target specific BFD_RELOC enum
constant for relocations which only arise on a particular target.  For
example, note that there is no BFD_ARM_RELOC_32.

More generally, I think it's kind of dubious to use a zero reloc to
mean anything at all.  And why do you need a relocation entry?  Why is
it not sufficient to enter the symbol in the symbol table as an
undefined symbol?  Is the use of a zero reloc mandated by the ARM ABI?

Ian

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

* Re: [PATCH] Indicate dependency on personality routines for ARM EHABI
  2005-02-09 17:06 [PATCH] Indicate dependency on personality routines for ARM EHABI Julian Brown
  2005-02-09 17:09 ` Ian Lance Taylor
@ 2005-02-09 17:12 ` Richard Earnshaw
  1 sibling, 0 replies; 15+ messages in thread
From: Richard Earnshaw @ 2005-02-09 17:12 UTC (permalink / raw)
  To: Julian Brown; +Cc: binutils

On Wed, 2005-02-09 at 16:22, Julian Brown wrote:
> Hi,
> 
> This patch causes gas to emit dependencies on personality routines 
> (__aeabi_unwind_cpp_pr[012]) from a suitable run-time library when 
> necessary, using an R_ARM_NONE relocation type.
> 
> Tested on i686-pc-linux-gnu and arm-none-eabi with no regressions 
> (though the expected output for the .ARM.extab has changed for one of 
> the tests.)
> 
> OK to apply?
>
> ChangeLog:
> 
>      * bfd/bfd-in2.h (bfd_reloc_code_real): New relocation type
>      (BFD_RELOC_ARM_NONE).
>      * bfd/elf32-arm.c (elf32_arm_reloc_map): BFD_RELOC_ARM_NONE maps to
>      R_ARM_NONE.
>      * bfd/libbfd.h (bfd_reloc_code_): Add BFD_RELOC_ARM_NONE.
>      * bfd/reloc.c (BFD_RELOC_ARM_NONE): Add.
>      * gas/config/tc-arm.c (md_apply_fix3): Handle BFD_RELOC_ARM_NONE.
>      (tc_gen_reloc): Handle BFD_RELOC_ARM_NONE.
>      (create_unwind_entry): Output dependency on the unwinding routines.
>      * gas/testsuite/gas/arm/unwind.d: Alter expected output to include
>      dependency on __aeabi_unwind_cpp_pr[01].


bfd-in2.h is a generated file.  Rather than your above ChangeLog entry
you should just log it as regenerated.

It's not necessary to include patches to generated files when sending a
changeset, just note that it has been rebuilt.

OK apart from that.

R.

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

* Re: [PATCH] Indicate dependency on personality routines for ARM EHABI
  2005-02-09 17:09 ` Ian Lance Taylor
@ 2005-02-09 17:24   ` Paul Brook
  2005-02-09 17:32     ` Ian Lance Taylor
  2005-02-09 19:43     ` Andreas Schwab
  2005-02-09 17:28   ` Richard Earnshaw
  2005-02-09 19:02   ` Julian Brown
  2 siblings, 2 replies; 15+ messages in thread
From: Paul Brook @ 2005-02-09 17:24 UTC (permalink / raw)
  To: binutils; +Cc: Ian Lance Taylor, Julian Brown

On Wednesday 09 February 2005 16:32, Ian Lance Taylor wrote:
> More generally, I think it's kind of dubious to use a zero reloc to
> mean anything at all.  And why do you need a relocation entry?  Why is
> it not sufficient to enter the symbol in the symbol table as an
> undefined symbol? 

Isn't a linker allowed to discard symbols if nothing uses them?

The symbols referenced by the relocation are only ever called via a weak 
reference from the unwinding library. The use of the routine is implicitly 
encoded in the unwinding tables.

> Is the use of a zero reloc mandated by the ARM ABI? 

Yes. The ABI defines and requires the use of a zero reloc (R_ARM_NONE).

Paul

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

* Re: [PATCH] Indicate dependency on personality routines for ARM EHABI
  2005-02-09 17:09 ` Ian Lance Taylor
  2005-02-09 17:24   ` Paul Brook
@ 2005-02-09 17:28   ` Richard Earnshaw
  2005-02-09 17:42     ` Ian Lance Taylor
  2005-02-09 19:02   ` Julian Brown
  2 siblings, 1 reply; 15+ messages in thread
From: Richard Earnshaw @ 2005-02-09 17:28 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: Julian Brown, binutils

On Wed, 2005-02-09 at 16:32, Ian Lance Taylor wrote:
> Julian Brown <julian@codesourcery.com> writes:
> 
> >   /* These relocs are only used within the ARM assembler.  They are not
> >   (at present) written to any object files.  */
> > +   BFD_RELOC_ARM_NONE,
> 
> Why not just use BFD_RELOC_NONE here?
> 

Ah!  Good point

> In general you should only create a target specific BFD_RELOC enum
> constant for relocations which only arise on a particular target.  For
> example, note that there is no BFD_ARM_RELOC_32.
> 
> More generally, I think it's kind of dubious to use a zero reloc to
> mean anything at all.  And why do you need a relocation entry?  Why is
> it not sufficient to enter the symbol in the symbol table as an
> undefined symbol?  Is the use of a zero reloc mandated by the ARM ABI?

Because the unwind module only weakly links to the personality modules
(but it is the one that ends up calling them).

The module that needs the unwinding has to provide the strong reference
to ensure that it gets included in the link set.

Doing it this way ensures that only personality modules that are needed
get included in the final image.

R.

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

* Re: [PATCH] Indicate dependency on personality routines for ARM EHABI
  2005-02-09 17:24   ` Paul Brook
@ 2005-02-09 17:32     ` Ian Lance Taylor
  2005-02-09 19:43     ` Andreas Schwab
  1 sibling, 0 replies; 15+ messages in thread
From: Ian Lance Taylor @ 2005-02-09 17:32 UTC (permalink / raw)
  To: Paul Brook; +Cc: binutils, Julian Brown

Paul Brook <paul@codesourcery.com> writes:

> On Wednesday 09 February 2005 16:32, Ian Lance Taylor wrote:
> > More generally, I think it's kind of dubious to use a zero reloc to
> > mean anything at all.  And why do you need a relocation entry?  Why is
> > it not sufficient to enter the symbol in the symbol table as an
> > undefined symbol? 
> 
> Isn't a linker allowed to discard symbols if nothing uses them?

An undefined symbol in the symbol table will normally be enough to
bring in an object from a static library.

> > Is the use of a zero reloc mandated by the ARM ABI? 
> 
> Yes. The ABI defines and requires the use of a zero reloc (R_ARM_NONE).

Then, this approach is fine in any case.  But it should still use
BFD_RELOC_NONE, I think.

Ian

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

* Re: [PATCH] Indicate dependency on personality routines for ARM EHABI
  2005-02-09 17:28   ` Richard Earnshaw
@ 2005-02-09 17:42     ` Ian Lance Taylor
  2005-02-09 18:26       ` Richard Earnshaw
  0 siblings, 1 reply; 15+ messages in thread
From: Ian Lance Taylor @ 2005-02-09 17:42 UTC (permalink / raw)
  To: Richard Earnshaw; +Cc: Julian Brown, binutils

Richard Earnshaw <rearnsha@gcc.gnu.org> writes:

> > More generally, I think it's kind of dubious to use a zero reloc to
> > mean anything at all.  And why do you need a relocation entry?  Why is
> > it not sufficient to enter the symbol in the symbol table as an
> > undefined symbol?  Is the use of a zero reloc mandated by the ARM ABI?
> 
> Because the unwind module only weakly links to the personality modules
> (but it is the one that ends up calling them).
> 
> The module that needs the unwinding has to provide the strong reference
> to ensure that it gets included in the link set.
> 
> Doing it this way ensures that only personality modules that are needed
> get included in the final image.

I would expect a strong undefined symbol would achieve the same effect
without the relocation entry.

But if the ABI requires the relocation entry, that is fine.

Ian

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

* Re: [PATCH] Indicate dependency on personality routines for ARM EHABI
  2005-02-09 17:42     ` Ian Lance Taylor
@ 2005-02-09 18:26       ` Richard Earnshaw
  0 siblings, 0 replies; 15+ messages in thread
From: Richard Earnshaw @ 2005-02-09 18:26 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: Julian Brown, binutils

On Wed, 2005-02-09 at 16:58, Ian Lance Taylor wrote:
> Richard Earnshaw <rearnsha@gcc.gnu.org> writes:
> 
> > > More generally, I think it's kind of dubious to use a zero reloc to
> > > mean anything at all.  And why do you need a relocation entry?  Why is
> > > it not sufficient to enter the symbol in the symbol table as an
> > > undefined symbol?  Is the use of a zero reloc mandated by the ARM ABI?
> > 
> > Because the unwind module only weakly links to the personality modules
> > (but it is the one that ends up calling them).
> > 
> > The module that needs the unwinding has to provide the strong reference
> > to ensure that it gets included in the link set.
> > 
> > Doing it this way ensures that only personality modules that are needed
> > get included in the final image.
> 
> I would expect a strong undefined symbol would achieve the same effect
> without the relocation entry.

I suspect that wouldn't work if you did unused section elimination.

> But if the ABI requires the relocation entry, that is fine.

It's the model that we chose to implement it, so yes, it's needed.

R.

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

* Re: [PATCH] Indicate dependency on personality routines for ARM EHABI
  2005-02-09 17:09 ` Ian Lance Taylor
  2005-02-09 17:24   ` Paul Brook
  2005-02-09 17:28   ` Richard Earnshaw
@ 2005-02-09 19:02   ` Julian Brown
  2005-02-09 20:27     ` Ian Lance Taylor
  2005-02-09 20:35     ` Richard Earnshaw
  2 siblings, 2 replies; 15+ messages in thread
From: Julian Brown @ 2005-02-09 19:02 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: binutils

Ian Lance Taylor wrote:
> Julian Brown <julian@codesourcery.com> writes:
> 
> 
>>  /* These relocs are only used within the ARM assembler.  They are not
>>  (at present) written to any object files.  */
>>+   BFD_RELOC_ARM_NONE,
> 
> 
> Why not just use BFD_RELOC_NONE here?
> 
> In general you should only create a target specific BFD_RELOC enum
> constant for relocations which only arise on a particular target.  For
> example, note that there is no BFD_ARM_RELOC_32.

Perhaps it should be, and I tried it with that initially. The reason it 
isn't is because elsewhere in tc-arm.c:md_apply_fix3 BFD_RELOC_NONE 
seems to be used as an error indicator:-

   case BFD_RELOC_NONE:
   default:
     as_bad_where (fixP->fx_file, fixP->fx_line,
                   _("bad relocation fixup type (%d)"), fixP->fx_r_type);

...which was being triggered when that relocation type was requested 
with fix_new(), I think. Is there another way around that?

Cheers,

Julian

-- 
Julian Brown
CodeSourcery, LLC

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

* Re: [PATCH] Indicate dependency on personality routines for ARM EHABI
  2005-02-09 17:24   ` Paul Brook
  2005-02-09 17:32     ` Ian Lance Taylor
@ 2005-02-09 19:43     ` Andreas Schwab
  1 sibling, 0 replies; 15+ messages in thread
From: Andreas Schwab @ 2005-02-09 19:43 UTC (permalink / raw)
  To: Paul Brook; +Cc: binutils, Ian Lance Taylor, Julian Brown

Paul Brook <paul@codesourcery.com> writes:

> Yes. The ABI defines and requires the use of a zero reloc (R_ARM_NONE).

In which way is it different from, say, R_68K_NONE?

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

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

* Re: [PATCH] Indicate dependency on personality routines for ARM EHABI
  2005-02-09 19:02   ` Julian Brown
@ 2005-02-09 20:27     ` Ian Lance Taylor
  2005-02-09 20:35     ` Richard Earnshaw
  1 sibling, 0 replies; 15+ messages in thread
From: Ian Lance Taylor @ 2005-02-09 20:27 UTC (permalink / raw)
  To: Julian Brown; +Cc: binutils

Julian Brown <julian@codesourcery.com> writes:

> Perhaps it should be, and I tried it with that initially. The reason
> it isn't is because elsewhere in tc-arm.c:md_apply_fix3 BFD_RELOC_NONE
> seems to be used as an error indicator:-
> 
>    case BFD_RELOC_NONE:
>    default:
>      as_bad_where (fixP->fx_file, fixP->fx_line,
>                    _("bad relocation fixup type (%d)"), fixP->fx_r_type);
> 
> ...which was being triggered when that relocation type was requested
> with fix_new(), I think. Is there another way around that?

That seems to be a use strictly internal to tc-arm.c, so I would
expect that it can be handled differently in that file.  For example,
perhaps you could use BFD_RELOC_UNUSED, or perhaps you could add a
field to the reloc field of struct arm_it.

Ian

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

* Re: [PATCH] Indicate dependency on personality routines for ARM EHABI
  2005-02-09 19:02   ` Julian Brown
  2005-02-09 20:27     ` Ian Lance Taylor
@ 2005-02-09 20:35     ` Richard Earnshaw
  2005-02-09 21:48       ` Julian Brown
  2005-02-09 22:21       ` Julian Brown
  1 sibling, 2 replies; 15+ messages in thread
From: Richard Earnshaw @ 2005-02-09 20:35 UTC (permalink / raw)
  To: Julian Brown; +Cc: Ian Lance Taylor, binutils

On Wed, 2005-02-09 at 17:09, Julian Brown wrote:
> Ian Lance Taylor wrote:
> > Julian Brown <julian@codesourcery.com> writes:
> > 
> > 
> >>  /* These relocs are only used within the ARM assembler.  They are not
> >>  (at present) written to any object files.  */
> >>+   BFD_RELOC_ARM_NONE,
> > 
> > 
> > Why not just use BFD_RELOC_NONE here?
> > 
> > In general you should only create a target specific BFD_RELOC enum
> > constant for relocations which only arise on a particular target.  For
> > example, note that there is no BFD_ARM_RELOC_32.
> 
> Perhaps it should be, and I tried it with that initially. The reason it 
> isn't is because elsewhere in tc-arm.c:md_apply_fix3 BFD_RELOC_NONE 
> seems to be used as an error indicator:-
> 
>    case BFD_RELOC_NONE:
>    default:
>      as_bad_where (fixP->fx_file, fixP->fx_line,
>                    _("bad relocation fixup type (%d)"), fixP->fx_r_type);
> 
> ...which was being triggered when that relocation type was requested 
> with fix_new(), I think. Is there another way around that?

Hmm, that's an abuse of RELOC_NONE.  It would probably be best to change
them to BFD_RELOC_UNUSED, then you could use BFD_RELOC_NONE for it's
proper purpose.

R.

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

* Re: [PATCH] Indicate dependency on personality routines for ARM EHABI
  2005-02-09 20:35     ` Richard Earnshaw
@ 2005-02-09 21:48       ` Julian Brown
  2005-02-09 22:21       ` Julian Brown
  1 sibling, 0 replies; 15+ messages in thread
From: Julian Brown @ 2005-02-09 21:48 UTC (permalink / raw)
  To: Richard Earnshaw; +Cc: Ian Lance Taylor, binutils

Richard Earnshaw wrote:
> On Wed, 2005-02-09 at 17:09, Julian Brown wrote:
> 
>>Perhaps it should be, and I tried it with that initially. The reason it 
>>isn't is because elsewhere in tc-arm.c:md_apply_fix3 BFD_RELOC_NONE 
>>seems to be used as an error indicator:-
>>
>>   case BFD_RELOC_NONE:
>>   default:
>>     as_bad_where (fixP->fx_file, fixP->fx_line,
>>                   _("bad relocation fixup type (%d)"), fixP->fx_r_type);
>>
>>...which was being triggered when that relocation type was requested 
>>with fix_new(), I think. Is there another way around that?
> 
> 
> Hmm, that's an abuse of RELOC_NONE.  It would probably be best to change
> them to BFD_RELOC_UNUSED, then you could use BFD_RELOC_NONE for it's
> proper purpose.

OK, thanks Richard & Ian! I'll rework it then re-send.

Cheers,

Julian

-- 
Julian Brown
CodeSourcery, LLC

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

* Re: [PATCH] Indicate dependency on personality routines for ARM EHABI
  2005-02-09 20:35     ` Richard Earnshaw
  2005-02-09 21:48       ` Julian Brown
@ 2005-02-09 22:21       ` Julian Brown
  2005-02-10 14:07         ` Richard Earnshaw
  1 sibling, 1 reply; 15+ messages in thread
From: Julian Brown @ 2005-02-09 22:21 UTC (permalink / raw)
  To: binutils

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

Hi,

This version of the patch uses BFD_RELOC_NONE instead of 
BFD_RELOC_ARM_NONE, and changes the existing use of BFD_RELOC_NONE in 
gas/config/tc-arm.c to use BFD_RELOC_UNUSED instead to prevent conflict.

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

OK?

ChangeLog:

     * gas/config/tc-arm.c (do_t_ldmstm): Change BFD_RELOC_NONE to
     BFD_RELOC_UNUSED.
     (do_t_push_pop): Likewise.
     (md_assemble): Likewise.
     (md_apply_fix3): Handle BFD_RELOC_NONE, make BFD_RELOC_UNUSED same
     as previous meaning of BFD_RELOC_NONE.
     (create_unwind_entry): Output dependency on the required personality
     routines.
     * gas/testsuite/gas/arm/unwind.d: Alter expected output to include
     dependency on __aeabi_unwind_cpp_pr[01].

-- 
Julian Brown
CodeSourcery, LLC

[-- Attachment #2: patch-6 --]
[-- Type: text/plain, Size: 7238 bytes --]

? bfd/doc/bfd.info
? bfd/doc/bfd.info-1
? gas/doc/as.info
? gas/doc/as.info-1
Index: gas/config/tc-arm.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-arm.c,v
retrieving revision 1.190
diff -c -p -r1.190 tc-arm.c
*** gas/config/tc-arm.c	31 Jan 2005 23:18:25 -0000	1.190
--- gas/config/tc-arm.c	9 Feb 2005 18:47:56 -0000
*************** do_t_ldmstm (char * str)
*** 9369,9378 ****
        return;
      }
  
!   if (inst.reloc.type != BFD_RELOC_NONE)
      {
        /* This really doesn't seem worth it.  */
!       inst.reloc.type = BFD_RELOC_NONE;
        inst.error = _("expression too complex");
        return;
      }
--- 9369,9378 ----
        return;
      }
  
!   if (inst.reloc.type != BFD_RELOC_UNUSED)
      {
        /* This really doesn't seem worth it.  */
!       inst.reloc.type = BFD_RELOC_UNUSED;
        inst.error = _("expression too complex");
        return;
      }
*************** do_t_push_pop (char * str)
*** 9461,9470 ****
        return;
      }
  
!   if (inst.reloc.type != BFD_RELOC_NONE)
      {
        /* This really doesn't seem worth it.  */
!       inst.reloc.type = BFD_RELOC_NONE;
        inst.error = _("expression too complex");
        return;
      }
--- 9461,9470 ----
        return;
      }
  
!   if (inst.reloc.type != BFD_RELOC_UNUSED)
      {
        /* This really doesn't seem worth it.  */
!       inst.reloc.type = BFD_RELOC_UNUSED;
        inst.error = _("expression too complex");
        return;
      }
*************** md_apply_fix3 (fixS *   fixP,
*** 11361,11367 ****
    char *         buf = fixP->fx_where + fixP->fx_frag->fr_literal;
    arm_fix_data * arm_data = (arm_fix_data *) fixP->tc_fix_data;
  
!   assert (fixP->fx_r_type < BFD_RELOC_UNUSED);
  
    /* Note whether this will delete the relocation.  */
    if (fixP->fx_addsy == 0 && !fixP->fx_pcrel)
--- 11361,11367 ----
    char *         buf = fixP->fx_where + fixP->fx_frag->fr_literal;
    arm_fix_data * arm_data = (arm_fix_data *) fixP->tc_fix_data;
  
!   assert (fixP->fx_r_type <= BFD_RELOC_UNUSED);
  
    /* Note whether this will delete the relocation.  */
    if (fixP->fx_addsy == 0 && !fixP->fx_pcrel)
*************** md_apply_fix3 (fixS *   fixP,
*** 11383,11388 ****
--- 11383,11393 ----
  
    switch (fixP->fx_r_type)
      {
+     case BFD_RELOC_NONE:
+       /* This will need to go in the object file.  */
+       fixP->fx_done = 0;
+       break;
+   
      case BFD_RELOC_ARM_IMMEDIATE:
        /* We claim that this fixup has been processed here,
  	 even if in fact we generate an error because we do
*************** md_apply_fix3 (fixS *   fixP,
*** 12050,12056 ****
        fixP->fx_done = 0;
        return;
  
!     case BFD_RELOC_NONE:
      default:
        as_bad_where (fixP->fx_file, fixP->fx_line,
  		    _("bad relocation fixup type (%d)"), fixP->fx_r_type);
--- 12055,12061 ----
        fixP->fx_done = 0;
        return;
  
!     case BFD_RELOC_UNUSED:
      default:
        as_bad_where (fixP->fx_file, fixP->fx_line,
  		    _("bad relocation fixup type (%d)"), fixP->fx_r_type);
*************** tc_gen_reloc (asection * section ATTRIBU
*** 12106,12111 ****
--- 12111,12117 ----
  	  break;
  	}
  
+     case BFD_RELOC_NONE:
      case BFD_RELOC_ARM_PCREL_BRANCH:
      case BFD_RELOC_ARM_PCREL_BLX:
      case BFD_RELOC_RVA:
*************** tc_gen_reloc (asection * section ATTRIBU
*** 12170,12175 ****
--- 12176,12182 ----
  
  	switch (fixp->fx_r_type)
  	  {
+ 	  case BFD_RELOC_NONE:		   type = "NONE";         break;
  	  case BFD_RELOC_ARM_OFFSET_IMM8:  type = "OFFSET_IMM8";  break;
  	  case BFD_RELOC_ARM_SHIFT_IMM:    type = "SHIFT_IMM";    break;
  	  case BFD_RELOC_ARM_SMI:          type = "SMI";          break;
*************** output_inst (const char * str)
*** 12293,12299 ****
    else
      md_number_to_chars (to, inst.instruction, inst.size);
  
!   if (inst.reloc.type != BFD_RELOC_NONE)
      fix_new_arm (frag_now, to - frag_now->fr_literal,
  		 inst.size, & inst.reloc.exp, inst.reloc.pc_rel,
  		 inst.reloc.type);
--- 12300,12306 ----
    else
      md_number_to_chars (to, inst.instruction, inst.size);
  
!   if (inst.reloc.type != BFD_RELOC_UNUSED)
      fix_new_arm (frag_now, to - frag_now->fr_literal,
  		 inst.size, & inst.reloc.exp, inst.reloc.pc_rel,
  		 inst.reloc.type);
*************** md_assemble (char * str)
*** 12319,12325 ****
      }
  
    memset (&inst, '\0', sizeof (inst));
!   inst.reloc.type = BFD_RELOC_NONE;
  
    skip_whitespace (str);
  
--- 12326,12332 ----
      }
  
    memset (&inst, '\0', sizeof (inst));
!   inst.reloc.type = BFD_RELOC_UNUSED;
  
    skip_whitespace (str);
  
*************** create_unwind_entry (int have_data)
*** 13893,13898 ****
--- 13900,13913 ----
        /* Custom personality routine.  */
        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;
  
*************** create_unwind_entry (int have_data)
*** 13902,13919 ****
        break;
  
      /* ABI defined personality routines.  */
-     /* TODO: Emit R_ARM_NONE to the personality routine.  */
      case 0:
        /* 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:
--- 13917,13944 ----
        break;
  
      /* ABI defined personality routines.  */
      case 0:
        /* 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:
Index: gas/testsuite/gas/arm/unwind.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/arm/unwind.d,v
retrieving revision 1.3
diff -c -p -r1.3 unwind.d
*** gas/testsuite/gas/arm/unwind.d	9 Dec 2004 20:25:24 -0000	1.3
--- gas/testsuite/gas/arm/unwind.d	9 Feb 2005 18:48:11 -0000
***************
*** 5,11 ****
--- 5,14 ----
  
  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\]:

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

* Re: [PATCH] Indicate dependency on personality routines for ARM EHABI
  2005-02-09 22:21       ` Julian Brown
@ 2005-02-10 14:07         ` Richard Earnshaw
  0 siblings, 0 replies; 15+ messages in thread
From: Richard Earnshaw @ 2005-02-10 14:07 UTC (permalink / raw)
  To: Julian Brown; +Cc: binutils

On Wed, 2005-02-09 at 19:43, Julian Brown wrote:
> Hi,
> 
> This version of the patch uses BFD_RELOC_NONE instead of 
> BFD_RELOC_ARM_NONE, and changes the existing use of BFD_RELOC_NONE in 
> gas/config/tc-arm.c to use BFD_RELOC_UNUSED instead to prevent conflict.
> 
> Tested on arm-none-eabi and i686-pc-linux-gnu.
> 
> OK?
> 
> ChangeLog:
> 
>      * gas/config/tc-arm.c (do_t_ldmstm): Change BFD_RELOC_NONE to
>      BFD_RELOC_UNUSED.
>      (do_t_push_pop): Likewise.
>      (md_assemble): Likewise.
>      (md_apply_fix3): Handle BFD_RELOC_NONE, make BFD_RELOC_UNUSED same
>      as previous meaning of BFD_RELOC_NONE.
>      (create_unwind_entry): Output dependency on the required personality
>      routines.
>      * gas/testsuite/gas/arm/unwind.d: Alter expected output to include
>      dependency on __aeabi_unwind_cpp_pr[01].

OK.

R.

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

end of thread, other threads:[~2005-02-10 10:47 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-09 17:06 [PATCH] Indicate dependency on personality routines for ARM EHABI Julian Brown
2005-02-09 17:09 ` Ian Lance Taylor
2005-02-09 17:24   ` Paul Brook
2005-02-09 17:32     ` Ian Lance Taylor
2005-02-09 19:43     ` Andreas Schwab
2005-02-09 17:28   ` Richard Earnshaw
2005-02-09 17:42     ` Ian Lance Taylor
2005-02-09 18:26       ` Richard Earnshaw
2005-02-09 19:02   ` Julian Brown
2005-02-09 20:27     ` Ian Lance Taylor
2005-02-09 20:35     ` Richard Earnshaw
2005-02-09 21:48       ` Julian Brown
2005-02-09 22:21       ` Julian Brown
2005-02-10 14:07         ` Richard Earnshaw
2005-02-09 17:12 ` Richard Earnshaw

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