- if (gsym->source() != Symbol::FROM_OBJECT)
- continue;
- bool is_ordinary;
- dst_obj = gsym->object();
- dst_indx = gsym->shndx(&is_ordinary);
- if (!is_ordinary)
- continue;
- Section_id dst_id(dst_obj, dst_indx);
+
+ dst_obj = NULL;
+ dst_indx = 0;
+ bool is_ordinary = false;
+ if (gsym->source() == Symbol::FROM_OBJECT
+ && !gsym->object()->is_dynamic())
+ {
+ dst_obj = static_cast<Relobj*>(gsym->object());
+ dst_indx = gsym->shndx(&is_ordinary);
+ }
+ dst_off = static_cast<const Sized_symbol<size>*>(gsym)->value();
+ dst_off += addend;
+
+ // When doing safe folding, check to see if this relocation is that
+ // of a function pointer being taken.
+ if (gsym->source() == Symbol::FROM_OBJECT
+ && gsym->type() == elfcpp::STT_FUNC
+ && check_section_for_function_pointers
+ && dst_obj != NULL
+ && (!is_ordinary
+ || scan.global_reloc_may_be_function_pointer(
+ symtab, NULL, target, src_obj, src_indx, NULL, reloc,
+ r_type, gsym)))
+ symtab->icf()->set_section_has_function_pointers(dst_obj, dst_indx);
+
+ // If the symbol name matches '__start_XXX' then the section with
+ // the C identifier like name 'XXX' should not be garbage collected.
+ // A similar treatment to symbols with the name '__stop_XXX'.
+ if (is_prefix_of(cident_section_start_prefix, gsym->name()))
+ {
+ cident_section_name = (gsym->name()
+ + strlen(cident_section_start_prefix));
+ }
+ else if (is_prefix_of(cident_section_stop_prefix, gsym->name()))
+ {
+ cident_section_name = (gsym->name()
+ + strlen(cident_section_stop_prefix));
+ }