From eb3908448bfe295e49bc7bd8a88b90deaa1ba95f Mon Sep 17 00:00:00 2001 From: Cary Coutant Date: Wed, 21 Dec 2016 16:21:23 -0800 Subject: Make linker-created symbols relocatable where appropriate. Linker-created symbols like __ehdr_start, __etext, __edata, and end should be relocatable, not absolute. gold/ * output.cc (Output_segment::first_section): Return NULL if there are no sections in the segment. * output.h (Output_segment::first_section_load_address): Assert that first section is not NULL. * symtab.cc (Symbol_table::sized_write_globals): Attach linker-created segment-relative symbols to first section of the segment. --- gold/symtab.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'gold/symtab.cc') diff --git a/gold/symtab.cc b/gold/symtab.cc index 6865190..35989f0 100644 --- a/gold/symtab.cc +++ b/gold/symtab.cc @@ -3120,7 +3120,14 @@ Symbol_table::sized_write_globals(const Stringpool* sympool, break; case Symbol::IN_OUTPUT_SEGMENT: - shndx = elfcpp::SHN_ABS; + { + Output_segment* oseg = sym->output_segment(); + Output_section* osect = oseg->first_section(); + if (osect == NULL) + shndx = elfcpp::SHN_ABS; + else + shndx = osect->out_shndx(); + } break; case Symbol::IS_CONSTANT: -- cgit v1.1