// If the local symbol belongs to a section we are discarding,
// and that section is a debug section, try to find the
// corresponding kept section and map this symbol to its
- // counterpart in the kept section.
+ // counterpart in the kept section. The symbol must not
+ // correspond to a section we are folding.
bool is_ordinary;
unsigned int shndx = psymval->input_shndx(&is_ordinary);
if (is_ordinary
&& shndx != elfcpp::SHN_UNDEF
- && !object->is_section_included(shndx))
+ && !object->is_section_included(shndx)
+ && !(relinfo->symtab->is_section_folded(object, shndx)))
{
if (comdat_behavior == CB_UNDETERMINED)
{
psymval = &symval;
}
- if (!relocate.relocate(relinfo, target, i, reloc, r_type, sym, psymval,
- view + offset, view_address + offset, view_size))
+ if (!relocate.relocate(relinfo, target, output_section, i, reloc,
+ r_type, sym, psymval, view + offset,
+ view_address + offset, view_size))
continue;
if (offset < 0 || static_cast<section_size_type>(offset) >= view_size)
&& !target->is_defined_by_abi(sym)
&& (!parameters->options().shared() // -shared
|| parameters->options().defs())) // -z defs
- gold_undefined_symbol(sym, relinfo, i, offset);
+ gold_undefined_symbol_at_location(sym, relinfo, i, offset);
if (sym != NULL && sym->has_warning())
relinfo->symtab->issue_warning(sym, relinfo, i, offset);
// Return the strategy to use for a local symbol which is not a
// section symbol, given the relocation type.
inline Relocatable_relocs::Reloc_strategy
- local_non_section_strategy(unsigned int r_type, Relobj*)
+ local_non_section_strategy(unsigned int r_type, Relobj*, unsigned int r_sym)
{
// We assume that relocation type 0 is NONE. Targets which are
// different must override.
- if (r_type == 0)
+ if (r_type == 0 && r_sym == 0)
return Relocatable_relocs::RELOC_DISCARD;
return Relocatable_relocs::RELOC_COPY;
}
inline Relocatable_relocs::Reloc_strategy
local_section_strategy(unsigned int r_type, Relobj* object)
{
- // We assume that relocation type 0 is NONE. Targets which are
- // different must override.
- if (r_type == 0)
- return Relocatable_relocs::RELOC_DISCARD;
if (sh_type == elfcpp::SHT_RELA)
return Relocatable_relocs::RELOC_ADJUST_FOR_SECTION_RELA;
else
// Return the strategy to use for a global symbol, given the
// relocation type, the object, and the symbol index.
inline Relocatable_relocs::Reloc_strategy
- global_strategy(unsigned int r_type, Relobj*, unsigned int)
- {
- // We assume that relocation type 0 is NONE. Targets which are
- // different must override.
- if (r_type == 0)
- return Relocatable_relocs::RELOC_DISCARD;
- return Relocatable_relocs::RELOC_COPY;
- }
+ global_strategy(unsigned int, Relobj*, unsigned int)
+ { return Relocatable_relocs::RELOC_COPY; }
};
// Scan relocs during a relocatable link. This is a default
strategy = Relocatable_relocs::RELOC_DISCARD;
}
else if (lsym.get_st_type() != elfcpp::STT_SECTION)
- strategy = scan.local_non_section_strategy(r_type, object);
+ strategy = scan.local_non_section_strategy(r_type, object,
+ r_sym);
else
{
strategy = scan.local_section_strategy(r_type, object);