This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: R_SPARC_RELATIVE vs R_SPARC_UA32 & unaligned unwind tables - again
On Wed, Dec 19, 2001 at 02:18:57PM +0100, Jakub Jelinek wrote:
>
> 2) glibc code matches what does Solaris 8 ld.so and what Solaris ld creates:
> relocs against STB_LOCAL symbols have addend which is relative to
> library VMA, not the actual STB_LOCAL symbol value
ie. behave as a reloc against STN_UNDEF. Sounds like your idea of
avoiding any section symbol relocs is the cure.
DJ, try this patch:
Index: bfd/elf32-sparc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-sparc.c,v
retrieving revision 1.34
diff -u -p -r1.34 elf32-sparc.c
--- elf32-sparc.c 2001/12/17 00:52:35 1.34
+++ elf32-sparc.c 2001/12/19 13:50:25
@@ -1415,6 +1415,7 @@ elf32_sparc_relocate_section (output_bfd
{
Elf_Internal_Rela outrel;
boolean skip;
+ boolean relocate;
/* When generating a shared object, these relocations
are copied into the output file to be resolved at run
@@ -1449,6 +1450,7 @@ elf32_sparc_relocate_section (output_bfd
skip = true;
outrel.r_offset += (input_section->output_section->vma
+ input_section->output_offset);
+ outrel.r_addend = rel->r_addend;
/* Optimize unaligned reloc usage now that we know where
it finally resides. */
@@ -1472,6 +1474,7 @@ elf32_sparc_relocate_section (output_bfd
break;
}
+ relocate = false;
if (skip)
memset (&outrel, 0, sizeof outrel);
/* h->dynindx may be -1 if the symbol was marked to
@@ -1483,57 +1486,27 @@ elf32_sparc_relocate_section (output_bfd
{
BFD_ASSERT (h->dynindx != -1);
outrel.r_info = ELF32_R_INFO (h->dynindx, r_type);
- outrel.r_addend = rel->r_addend;
}
else
{
+ relocate = true;
+ outrel.r_addend += relocation;
+
if (r_type == R_SPARC_32)
{
outrel.r_info = ELF32_R_INFO (0, R_SPARC_RELATIVE);
- outrel.r_addend = relocation + rel->r_addend;
}
else
{
- long indx;
-
- if (h == NULL)
- sec = local_sections[r_symndx];
- else
- {
- BFD_ASSERT (h->root.type == bfd_link_hash_defined
- || (h->root.type
- == bfd_link_hash_defweak));
- sec = h->root.u.def.section;
- }
- if (sec != NULL && bfd_is_abs_section (sec))
- indx = 0;
- else if (sec == NULL || sec->owner == NULL)
- {
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
- else
- {
- asection *osec;
-
- osec = sec->output_section;
- indx = elf_section_data (osec)->dynindx;
-
- /* FIXME: we really should be able to link non-pic
- shared libraries. */
- if (indx == 0)
- {
- BFD_FAIL ();
- (*_bfd_error_handler)
- (_("%s: probably compiled without -fPIC?"),
- bfd_archive_filename (input_bfd));
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
- }
+ /* Normally we would turn some cases of this reloc
+ against a local sym into one against the relevant
+ section symbol, but the Solaris 8 (and earlier)
+ dynamic linkers ignore the symbol value. ie.
+ behave as if the reloc was against index 0,
+ STN_UNDEF for all local syms. So avoid confusing
+ the issue with ignored section syms. */
- outrel.r_info = ELF32_R_INFO (indx, r_type);
- outrel.r_addend = relocation + rel->r_addend;
+ outrel.r_info = ELF32_R_INFO (0, r_type);
}
}
@@ -1544,8 +1517,11 @@ elf32_sparc_relocate_section (output_bfd
++sreloc->reloc_count;
/* This reloc will be computed at runtime, so there's no
- need to do anything now. */
- continue;
+ need to do anything now. Sigh, except that the Solaris
+ 2.5.1 and 2.6 dynamic linker use the section contents when
+ resolving dynamic relocs against local symbols. */
+ if (!relocate)
+ continue;
}
break;