forked from Imagelibrary/binutils-gdb
ld: don't generate base relocations in PE output for absolute symbols
It is the very nature of absolute symbols that they don't change even if the loader decides to put the image at other than its link-time base address. Of the linker-defined (and PE-specific) symbols __image_base__ (and its alias) needs special casing, as it'll still appear to be absolute at this point. A new inquiry function in ldexp.c is needed because PE base relocations get generated before ldexp_finalize_syms() runs, yet whether a relocation is needed depends on the ultimate property of a symbol.
This commit is contained in:
22
ld/ldexp.c
22
ld/ldexp.c
@@ -1699,6 +1699,28 @@ ldexp_finalize_syms (void)
|
||||
bfd_hash_traverse (&definedness_table, set_sym_sections, NULL);
|
||||
}
|
||||
|
||||
/* Determine whether a symbol is going to remain absolute even after
|
||||
ldexp_finalize_syms() has run. */
|
||||
|
||||
bfd_boolean
|
||||
ldexp_is_final_sym_absolute (const struct bfd_link_hash_entry *h)
|
||||
{
|
||||
if (h->type == bfd_link_hash_defined
|
||||
&& h->u.def.section == bfd_abs_section_ptr)
|
||||
{
|
||||
const struct definedness_hash_entry *def;
|
||||
|
||||
if (!h->ldscript_def)
|
||||
return TRUE;
|
||||
|
||||
def = symbol_defined (h->root.string);
|
||||
if (def != NULL)
|
||||
return def->final_sec == bfd_abs_section_ptr;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
ldexp_finish (void)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user