diff options
author | Alan Modra <amodra@bigpond.net.au> | 2001-10-06 07:25:40 +0000 |
---|---|---|
committer | Alan Modra <amodra@bigpond.net.au> | 2001-10-06 07:25:40 +0000 |
commit | 03239bf605d618058a13938e65a077e8bee14f10 (patch) | |
tree | 40249df0b7f0dcfbb4c4dd39b70f96470aeae6d5 /bfd/elflink.h | |
parent | 6b94604903ddea66670735932c15a15a58f6a2cd (diff) | |
download | gdb-03239bf605d618058a13938e65a077e8bee14f10.tar.gz |
* elflink.h (elf_link_input_bfd): Don't zero discarded link-once
section sym values. Instead replace any relocs against them with
relocs against STN_UNDEF, which has a zero value.
Diffstat (limited to 'bfd/elflink.h')
-rw-r--r-- | bfd/elflink.h | 62 |
1 files changed, 48 insertions, 14 deletions
diff --git a/bfd/elflink.h b/bfd/elflink.h index 3879dbcaa94..a8ffb0b85d9 100644 --- a/bfd/elflink.h +++ b/bfd/elflink.h @@ -5993,20 +5993,6 @@ elf_link_input_bfd (finfo, input_bfd) if (ELF_ST_TYPE (isym->st_info) == STT_SECTION) { - /* If this is a discarded link-once section symbol, set its - value to 0. We should really undefine it, and complain - if anything in the final link tries to use it, but - DWARF-based exception handling might have an entry in - .eh_frame to describe a routine in the linkonce section, - and it turns out to be hard to remove the .eh_frame entry - too. FIXME. */ - if (isec != NULL - && (bfd_get_section_flags (input_bfd, isec) & SEC_LINK_ONCE) != 0 - && bfd_is_abs_section (isec->output_section)) - { - isym->st_value = 0; - } - /* We never output section symbols. Instead, we use the section symbol of the corresponding section in the output file. */ @@ -6130,6 +6116,54 @@ elf_link_input_bfd (finfo, input_bfd) && o->reloc_count > 0) return false; +#if BFD_VERSION_DATE < 20031005 + { + Elf_Internal_Rela *rel, *relend; + /* Run through the relocs looking for any against section + symbols from removed link-once sections. Set any such + relocs to be against 0. We should really complain if + anything in the final link tries to use it, but + DWARF-based exception handling might have an entry in + .eh_frame to describe a routine in the linkonce section, + and it turns out to be hard to remove the .eh_frame entry + too. FIXME. */ + rel = internal_relocs; + relend = rel + o->reloc_count * bed->s->int_rels_per_ext_rel; + for ( ; rel < relend; rel++) + { + unsigned long r_symndx = ELF_R_SYM (rel->r_info); + + if (r_symndx < locsymcount + && (!elf_bad_symtab (input_bfd) + || finfo->sections[r_symndx] != NULL)) + { + isym = finfo->internal_syms + r_symndx; + if (ELF_ST_TYPE (isym->st_info) == STT_SECTION) + { + asection *sec = finfo->sections[r_symndx]; + + if (sec != NULL + && (sec->flags & SEC_LINK_ONCE) != 0 + && bfd_is_abs_section (sec->output_section)) + { + long r_type = ELF_R_TYPE (rel->r_info); + rel->r_info = ELF_R_INFO (0, r_type); + +#if BFD_VERSION_DATE > 20021005 + (*finfo->info->callbacks->warning) + (finfo->info, + _("warning: relocation against removed section; zeroing"), + NULL, input_bfd, o, rel->r_offset); +#endif + } + } + } + } + } +#else +#error "This kludge ought to be fixed properly in gcc by now" +#endif + /* Relocate the section by invoking a back end routine. The back end routine is responsible for adjusting the |