aboutsummaryrefslogtreecommitdiff
path: root/ld/ldexp.c
diff options
context:
space:
mode:
authorJan Beulich <jbeulich@suse.com>2021-03-04 16:55:01 +0100
committerJan Beulich <jbeulich@suse.com>2021-03-04 16:55:01 +0100
commit6fa7408d72b3805536e3579ba46b48f07f2e780a (patch)
tree4bf2a749afaa5ad0866b5659d2f4f6534fad2d5d /ld/ldexp.c
parent1178743e4c05d9c0daad5a105277fbc42872c9ea (diff)
downloadgdb-6fa7408d72b3805536e3579ba46b48f07f2e780a.zip
gdb-6fa7408d72b3805536e3579ba46b48f07f2e780a.tar.gz
gdb-6fa7408d72b3805536e3579ba46b48f07f2e780a.tar.bz2
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.
Diffstat (limited to 'ld/ldexp.c')
-rw-r--r--ld/ldexp.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/ld/ldexp.c b/ld/ldexp.c
index 0167845..7a95e56 100644
--- a/ld/ldexp.c
+++ b/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)
{