[PATCH] Re: binutils: "unexpected reloc type 0x17" on sparc
Jakub Jelinek
jakub@redhat.com
Fri Jun 29 03:24:00 GMT 2001
On Fri, Jun 29, 2001 at 03:05:10PM +0930, Alan Modra wrote:
> On Fri, Jun 29, 2001 at 07:16:48AM +0200, Jakub Jelinek wrote:
> > On Thu, Jun 28, 2001 at 03:42:52PM -0700, David S. Miller wrote:
> > > Actually, it is even more confusing now, because things worked
> > > perfectly fine under Linux previously as far as we know right?
> > > It was emitting R_SPARC_32 and not R_SPARC_UA32.
> > >
> > > I mean, I'll tool around in the gcc-3.0 and cvs binutils sources
> > > to try and figure this out, but someone here can probably dig into
> > > it more quickly than I at the moment.
> >
> > That's why I asked for the library in question, so that it is clear whether
> > glibc's dl-machine.h needs to be changed or binutils fixed.
> >
>
> One thing you might like to consider doing is to massage the reloc type
> depending on its offset, before calling bfd_elf32_swap_reloca_out
> (elf32-sparc.c:1531). That way, you'll only get the UA relocs when you
> really need them.
That's what elf64-sparc.c is already doing, wonder why it was missing in
elf32-sparc.c.
Tomasz, does the following patch help?
While writing it, I've noticed someone added support for R_SPARC_UA64 into
elf32-sparc.c. That does not make sense to me in the light that sparc32 is
not supporting R_SPARC_64 either. Simply putting anything but assembly time
constant into .xword, .uaxword or .8byte is bad assembly on SPARC 32bit.
As far as glibc is concerned, if you show me a real-world DSO which really
needs R_SPARC_UA16 or R_SPARC_UA32, then I'll happily add those relocs to
sparc/sparc32/dl-machine.h, but the libstdc++ Artur mailed me had just
R_SPARC_UA32 with all r_offsets divisible by 4.
2001-06-29 Jakub Jelinek <jakub@redhat.com>
* elf32-sparc.c (_bfd_sparc_elf_howto_table): Remove support for
R_SPARC_UA64.
(elf32_sparc_check_relocs): Likewise.
(elf32_sparc_relocate_section): Likewise.
Optimize unaligned reloc usage.
--- bfd/elf32-sparc.c.jj Fri Jun 29 11:58:58 2001
+++ bfd/elf32-sparc.c Fri Jun 29 12:24:17 2001
@@ -120,7 +120,7 @@ reloc_howto_type _bfd_sparc_elf_howto_ta
HOWTO(R_SPARC_NONE, 0,0, 0,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_NONE", false,0,0x00000000,true),
HOWTO(R_SPARC_NONE, 0,0, 0,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_NONE", false,0,0x00000000,true),
HOWTO(R_SPARC_NONE, 0,0, 0,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_NONE", false,0,0x00000000,true),
- HOWTO(R_SPARC_UA64, 0,4,64,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_UA64", false,0,(~ (bfd_vma)0), true),
+ HOWTO(R_SPARC_UA64, 0,0, 0,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_UA64", false,0,0x00000000,true),
HOWTO(R_SPARC_UA16, 0,1,16,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_UA16", false,0,0x0000ffff,true),
HOWTO(R_SPARC_REV32, 0,2,32,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_REV32", false,0,0xffffffff,true),
};
@@ -554,7 +554,6 @@ elf32_sparc_check_relocs (abfd, info, se
case R_SPARC_LO10:
case R_SPARC_UA16:
case R_SPARC_UA32:
- case R_SPARC_UA64:
if (h != NULL)
h->elf_link_hash_flags |= ELF_LINK_NON_GOT_REF;
@@ -1223,7 +1222,6 @@ elf32_sparc_relocate_section (output_bfd
|| r_type == R_SPARC_LO10
|| r_type == R_SPARC_UA16
|| r_type == R_SPARC_UA32
- || r_type == R_SPARC_UA64
|| ((r_type == R_SPARC_PC10
|| r_type == R_SPARC_PC22)
&& strcmp (h->root.root.string,
@@ -1412,7 +1410,6 @@ elf32_sparc_relocate_section (output_bfd
case R_SPARC_LO10:
case R_SPARC_UA16:
case R_SPARC_UA32:
- case R_SPARC_UA64:
if (info->shared)
{
Elf_Internal_Rela outrel;
@@ -1463,6 +1460,24 @@ elf32_sparc_relocate_section (output_bfd
outrel.r_offset += (input_section->output_section->vma
+ input_section->output_offset);
+ /* Optimize unaligned reloc usage now that we know where
+ it finally resides. */
+ switch (r_type)
+ {
+ case R_SPARC_16:
+ if (outrel.r_offset & 1) r_type = R_SPARC_UA16;
+ break;
+ case R_SPARC_UA16:
+ if (!(outrel.r_offset & 1)) r_type = R_SPARC_16;
+ break;
+ case R_SPARC_32:
+ if (outrel.r_offset & 3) r_type = R_SPARC_UA32;
+ break;
+ case R_SPARC_UA32:
+ if (!(outrel.r_offset & 3)) r_type = R_SPARC_32;
+ break;
+ }
+
if (skip)
memset (&outrel, 0, sizeof outrel);
/* h->dynindx may be -1 if the symbol was marked to
@@ -2024,7 +2039,7 @@ elf32_sparc_object_p (abfd)
}
else if (elf_elfheader (abfd)->e_flags & EF_SPARC_LEDATA)
return bfd_default_set_arch_mach (abfd, bfd_arch_sparc,
- bfd_mach_sparc_sparclite_le);
+ bfd_mach_sparc_sparclite_le);
else
return bfd_default_set_arch_mach (abfd, bfd_arch_sparc, bfd_mach_sparc);
}
Jakub
More information about the Libc-alpha
mailing list