summaryrefslogtreecommitdiff
path: root/bfd/elflink.h
diff options
context:
space:
mode:
authorAlan Modra <amodra@bigpond.net.au>2000-10-12 03:44:50 +0000
committerAlan Modra <amodra@bigpond.net.au>2000-10-12 03:44:50 +0000
commit133b1ea791aa9650899ba7964d85613d893515a5 (patch)
tree55a647db127095bc2018982aefbb55f1b999e344 /bfd/elflink.h
parent791bfbc893992ba4c53644d1c6ffa05e1b5e5707 (diff)
downloadgdb-133b1ea791aa9650899ba7964d85613d893515a5.tar.gz
Another try at correcting relocations against discarded
link-once section symbols.
Diffstat (limited to 'bfd/elflink.h')
-rw-r--r--bfd/elflink.h39
1 files changed, 32 insertions, 7 deletions
diff --git a/bfd/elflink.h b/bfd/elflink.h
index 9e543a7c8d0..9a0f49a182d 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