diff options
author | Alan Modra <amodra@gmail.com> | 2000-10-12 03:44:51 +0000 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2000-10-12 03:44:51 +0000 |
commit | 24376d1b58f62660beb3e5f9c2a7c135513ce27d (patch) | |
tree | 684628a3f6e7b7ffe80bfb966007ad2179aeee00 /bfd/elflink.h | |
parent | 74bcd5294fa6894905a705d18c229cbe5ea42b59 (diff) | |
download | gdb-24376d1b58f62660beb3e5f9c2a7c135513ce27d.zip gdb-24376d1b58f62660beb3e5f9c2a7c135513ce27d.tar.gz gdb-24376d1b58f62660beb3e5f9c2a7c135513ce27d.tar.bz2 |
Another try at correcting relocations against discarded
link-once section symbols.
Diffstat (limited to 'bfd/elflink.h')
-rw-r--r-- | bfd/elflink.h | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/bfd/elflink.h b/bfd/elflink.h index 9e543a7..9a0f49a 100644 --- a/bfd/elflink.h +++ b/bfd/elflink.h @@ -1371,8 +1371,6 @@ elf_link_add_object_symbols (abfd, info) if (sym.st_shndx != SHN_UNDEF && sym.st_shndx != SHN_COMMON) flags = BSF_GLOBAL; - else - flags = 0; } else if (bind == STB_WEAK) flags = BSF_WEAK; @@ -5536,16 +5534,43 @@ elf_link_input_bfd (finfo, input_bfd) if (esym == external_syms) continue; + if (ELF_ST_TYPE (isym->st_info) == STT_SECTION) + { + asection *ksec; + + /* Save away all section symbol values. */ + if (isec != NULL) + isec->symbol->value = isym->st_value; + + /* If this is a discarded link-once section symbol, update + it's value to that of the kept section symbol. The + linker will keep the first of any matching link-once + sections, so we should have already seen it's section + symbol. I trust no-one will have the bright idea of + re-ordering the bfd list... */ + if (isec != NULL + && (bfd_get_section_flags (input_bfd, isec) & SEC_LINK_ONCE) != 0 + && (ksec = isec->kept_section) != NULL) + { + isym->st_value = ksec->symbol->value; + + /* That put the value right, but the section info is all + wrong. I hope this works. */ + isec->output_offset = ksec->output_offset; + isec->output_section = ksec->output_section; + } + + /* We never output section symbols. Instead, we use the + section symbol of the corresponding section in the output + file. */ + continue; + } + /* If we are stripping all symbols, we don't want to output this one. */ if (finfo->info->strip == strip_all) continue; - /* We never output section symbols. Instead, we use the section - symbol of the corresponding section in the output file. */ - if (ELF_ST_TYPE (isym->st_info) == STT_SECTION) - continue; - /* If we are discarding all local symbols, we don't want to output this one. If we are generating a relocateable output file, then some of the local symbols may be required by |