From 502e8a84302cfcc70166bd60cc6465a3e913cb8c Mon Sep 17 00:00:00 2001 From: Cary Coutant Date: Mon, 15 Apr 2013 16:34:12 +0000 Subject: gold/ * symtab.cc (Symbol_table::sized_write_globals): Subtract section starting address for relocatable link. * testsuite/Makefile.am (script_test_11): New test. * testsuite/Makefile.in: Regenerate. * testsuite/script_test_11.c: New source file. * testsuite/script_test_11.t: New linker script. --- gold/symtab.cc | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'gold/symtab.cc') diff --git a/gold/symtab.cc b/gold/symtab.cc index 17a0f55..2e17529 100644 --- a/gold/symtab.cc +++ b/gold/symtab.cc @@ -2940,15 +2940,24 @@ Symbol_table::sized_write_globals(const Stringpool* sympool, break; case Symbol::IN_OUTPUT_DATA: - shndx = sym->output_data()->out_shndx(); - if (shndx >= elfcpp::SHN_LORESERVE) - { - if (sym_index != -1U) - symtab_xindex->add(sym_index, shndx); - if (dynsym_index != -1U) - dynsym_xindex->add(dynsym_index, shndx); - shndx = elfcpp::SHN_XINDEX; - } + { + Output_data* od = sym->output_data(); + + shndx = od->out_shndx(); + if (shndx >= elfcpp::SHN_LORESERVE) + { + if (sym_index != -1U) + symtab_xindex->add(sym_index, shndx); + if (dynsym_index != -1U) + dynsym_xindex->add(dynsym_index, shndx); + shndx = elfcpp::SHN_XINDEX; + } + + // In object files symbol values are section + // relative. + if (parameters->options().relocatable()) + sym_value -= od->address(); + } break; case Symbol::IN_OUTPUT_SEGMENT: -- cgit v1.1