gas, sparc, dwarf2, and R_SPARC_(UA)64

Nick Clifton nickc@redhat.com
Fri Jul 9 15:52:00 GMT 2004


Hi DJ,

> The dwarf2 code in sparc's gas seems to want to emit R_SPARC_64
> relocs, but these occasionally end up unaligned and the linker
> complains.  A simple patch to detect an unaligned frac and convert it
> got most but not all of the alignment issues; there were still a few
> R_SPARC_64 cases that ended up unaligned.  Is there any reason why we
> don't just use R_SPARC_UA64 all the time for dwarf2 info?  There
> doesn't seem to be a hook for that vs other cons expressions, though.
> 
> My current naive patch follows, a previous one also tested the
> alignment of the reloc itself.
> 
> *** orig/binutils-2.14/gas/config/tc-sparc.c	Fri Jan 24 18:44:44 2003
> --- binutils-2.14/gas/config/tc-sparc.c	Thu Jun 24 10:32:30 2004
> ***************
> *** 4442,4447 ****
> --- 4442,4457 ----
>          (nbytes == 2 ? BFD_RELOC_16 :
>   	(nbytes == 4 ? BFD_RELOC_32 : BFD_RELOC_64)));
>   
> +   if (!sparc_no_align_cons)
> +     {
> +       /* This happens when gas's dwarf2 debug ops emit .debug_line
> + 	 entries.  */
> +       sparc_no_align_cons = 1;
> +       cons_fix_new_sparc (frag, where, nbytes, exp);
> +       sparc_no_align_cons = 0;
> +       return;
> +     }
> + 
>     if (target_little_endian_data
>         && nbytes == 4
>         && now_seg->flags & SEC_ALLOC)

I have not seen any adverse comments to this patch and it certainly 
makes sense to me, but I think that it might be tidied up slightly.  How 
about this version instead ?

gas/ChangeLog
2004-07-09  Nick Clifton  <nickc@redhat.com>

	* config/tc-sparc.c (cons_fix_new_sparc): Always use unaligned
	versions of the relocs

Index: gas/config/tc-sparc.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-sparc.c,v
retrieving revision 1.51
diff -c -3 -p -r1.51 tc-sparc.c
*** gas/config/tc-sparc.c	18 Jan 2004 23:47:03 -0000	1.51
--- gas/config/tc-sparc.c	9 Jul 2004 15:50:48 -0000
*************** cons_fix_new_sparc (frag, where, nbytes,
*** 4448,4456 ****
   {
     bfd_reloc_code_real_type r;

!   r = (nbytes == 1 ? BFD_RELOC_8 :
!        (nbytes == 2 ? BFD_RELOC_16 :
! 	(nbytes == 4 ? BFD_RELOC_32 : BFD_RELOC_64)));

     if (target_little_endian_data
         && nbytes == 4
--- 4448,4463 ----
   {
     bfd_reloc_code_real_type r;

!   /* Always use unaligned relocs as there are circumstances where they are
!      needed, eg when gas's dwarf2 debug ops emit .debug_line entries.  */
!   switch (nbytes)
!     {
!     case 1: r = BFD_RELOC_8; break;
!     case 2: r = BFD_RELOC_SPARC_UA16; break;
!     case 4: r = BFD_RELOC_SPARC_UA32; break;
!     case 8: r = BFD_RELOC_SPARC_UA64; break;
!     default: abort ();
!     }

     if (target_little_endian_data
         && nbytes == 4
*************** cons_fix_new_sparc (frag, where, nbytes,
*** 4481,4496 ****
   	  case 8: r = BFD_RELOC_SPARC_TLS_DTPOFF64; break;
   	  }
       }
-   else if (sparc_no_align_cons)
-     {
-       switch (nbytes)
- 	{
- 	case 2: r = BFD_RELOC_SPARC_UA16; break;
- 	case 4: r = BFD_RELOC_SPARC_UA32; break;
- 	case 8: r = BFD_RELOC_SPARC_UA64; break;
- 	default: abort ();
- 	}
-    }

     fix_new_exp (frag, where, (int) nbytes, exp, 0, r);
     sparc_cons_special_reloc = NULL;
--- 4488,4493 ----



Cheers
   Nick



More information about the Binutils mailing list