This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: A relocation problem in shared objects for SH
On Sep 16, 2000, Alexandre Oliva <aoliva@redhat.com> wrote:
> On Sep 16, 2000, kaz Kojima <kkojima@rr.iij4u.or.jp> wrote:
>> One point of this bug may be that it's exposed in the case of the
>> relocateable object which is generated form several objects by ld -r
>> command.
> Right on the nail! Indeed, this causes the bug to show up.
>> So I think that our ugly patch for elf32-sh.c (or something else) is
>> still needed.
> Yep. I'll keep looking for something else for a while :-)
Here's the ``something else'' I've come up with. It fixes the
relocatable link, so that it doesn't generate relocations with both
an in-place value and an addend. I've tried to relocate a lot of PIC
and non-PIC object files, and it always did The Right Thing (TM), so I
guess this is the way to go. Ok to install?
Index: bfd/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* elf32-sh.c (sh_elf_relocate_section): Use
_bfd_final_link_relocate to apply the relocation against a section
symbol, when doing relocatable links.
Index: bfd/elf32-sh.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-sh.c,v
retrieving revision 1.19
diff -u -p -r1.19 elf32-sh.c
--- bfd/elf32-sh.c 2000/09/14 04:59:14 1.19
+++ bfd/elf32-sh.c 2000/09/16 17:16:14
@@ -2897,25 +2897,6 @@ sh_elf_relocate_section (output_bfd, inf
r_symndx = ELF32_R_SYM (rel->r_info);
- if (info->relocateable)
- {
- /* This is a relocateable link. We don't have to change
- anything, unless the reloc is against a section symbol,
- in which case we have to adjust according to where the
- section symbol winds up in the output section. */
- if (r_symndx < symtab_hdr->sh_info)
- {
- sym = local_syms + r_symndx;
- if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
- {
- sec = local_sections[r_symndx];
- rel->r_addend += sec->output_offset + sym->st_value;
- }
- }
-
- continue;
- }
-
r_type = ELF32_R_TYPE (rel->r_info);
/* Many of the relocs are only used for relaxing, and are
@@ -2948,9 +2929,28 @@ sh_elf_relocate_section (output_bfd, inf
relocation = (sec->output_section->vma
+ sec->output_offset
+ sym->st_value);
+
+ if (info->relocateable)
+ {
+ /* This is a relocateable link. We don't have to change
+ anything, unless the reloc is against a section symbol,
+ in which case we have to adjust according to where the
+ section symbol winds up in the output section. */
+ sym = local_syms + r_symndx;
+ if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
+ goto final_link_relocate;
+
+ continue;
+ }
}
else
{
+ /* Section symbol are never (?) placed in the hash table, so
+ we can just ignore hash relocations when creating a
+ relocateable object file. */
+ if (info->relocateable)
+ continue;
+
h = sym_hashes[r_symndx - symtab_hdr->sh_info];
while (h->root.type == bfd_link_hash_indirect
|| h->root.type == bfd_link_hash_warning)
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist *Please* write to mailing lists, not to me