diff options
Diffstat (limited to 'bfd/elf32-i386.c')
-rw-r--r-- | bfd/elf32-i386.c | 83 |
1 files changed, 25 insertions, 58 deletions
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index 7a83c73..05fe640 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -1,6 +1,6 @@ /* Intel 80386/80486-specific support for 32-bit ELF Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, - 2003, 2004, 2005, 2006 Free Software Foundation, Inc. + 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -2264,51 +2264,6 @@ elf_i386_relocate_section (bfd *output_bfd, howto = elf_howto_table + indx; r_symndx = ELF32_R_SYM (rel->r_info); - - if (info->relocatable) - { - bfd_vma val; - bfd_byte *where; - - /* This is a relocatable 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) - continue; - - sym = local_syms + r_symndx; - if (ELF_ST_TYPE (sym->st_info) != STT_SECTION) - continue; - - sec = local_sections[r_symndx]; - val = sec->output_offset; - if (val == 0) - continue; - - where = contents + rel->r_offset; - switch (howto->size) - { - /* FIXME: overflow checks. */ - case 0: - val += bfd_get_8 (input_bfd, where); - bfd_put_8 (input_bfd, val, where); - break; - case 1: - val += bfd_get_16 (input_bfd, where); - bfd_put_16 (input_bfd, val, where); - break; - case 2: - val += bfd_get_32 (input_bfd, where); - bfd_put_32 (input_bfd, val, where); - break; - default: - abort (); - } - continue; - } - - /* This is a final link. */ h = NULL; sym = NULL; sec = NULL; @@ -2320,10 +2275,12 @@ elf_i386_relocate_section (bfd *output_bfd, relocation = (sec->output_section->vma + sec->output_offset + sym->st_value); - if ((sec->flags & SEC_MERGE) - && ELF_ST_TYPE (sym->st_info) == STT_SECTION) + + if (ELF_ST_TYPE (sym->st_info) == STT_SECTION + && ((sec->flags & SEC_MERGE) != 0 + || (info->relocatable + && sec->output_offset != 0))) { - asection *msec; bfd_vma addend; bfd_byte *where = contents + rel->r_offset; @@ -2357,10 +2314,16 @@ elf_i386_relocate_section (bfd *output_bfd, abort (); } - msec = sec; - addend = _bfd_elf_rel_local_sym (output_bfd, sym, &msec, addend); - addend -= relocation; - addend += msec->output_section->vma + msec->output_offset; + if (info->relocatable) + addend += sec->output_offset; + else + { + asection *msec = sec; + addend = _bfd_elf_rel_local_sym (output_bfd, sym, &msec, + addend); + addend -= relocation; + addend += msec->output_section->vma + msec->output_offset; + } switch (howto->size) { @@ -2393,16 +2356,20 @@ elf_i386_relocate_section (bfd *output_bfd, unresolved_reloc, warned); } - if (r_symndx == 0) + if (sec != NULL && elf_discarded_section (sec)) { - /* r_symndx will be zero only for relocs against symbols from - removed linkonce sections, or sections discarded by a linker - script. For these relocs, we just want the section contents - zeroed. Avoid any special processing. */ + /* For relocs against symbols from removed linkonce sections, + or sections discarded by a linker script, we just want the + section contents zeroed. Avoid any special processing. */ _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset); + rel->r_info = 0; + rel->r_addend = 0; continue; } + if (info->relocatable) + continue; + switch (r_type) { case R_386_GOT32: |