aboutsummaryrefslogtreecommitdiff
path: root/ld/ldexp.h
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2015-09-18 09:14:25 +0930
committerAlan Modra <amodra@gmail.com>2015-09-18 12:39:16 +0930
commit975f8a9e3144e4d3d3f391e907c8bf94b23dc8b6 (patch)
tree1e0766556406a33ec0f6fcd83b270087ae88897f /ld/ldexp.h
parentb29b8669ad250df649a0f02c5575e7163a2cd9e4 (diff)
downloadgdb-975f8a9e3144e4d3d3f391e907c8bf94b23dc8b6.zip
gdb-975f8a9e3144e4d3d3f391e907c8bf94b23dc8b6.tar.gz
gdb-975f8a9e3144e4d3d3f391e907c8bf94b23dc8b6.tar.bz2
Delay converting linker script defined symbols from absolute
Giving linker script symbols defined outside of output sections a section-relative value early, leads to them being used in expressions as if they were defined inside an output section. This can mean loss of the section VMA, and wrong results. ld/ PR ld/18963 * ldexp.h (struct ldexp_control): Add rel_from_abs. (ldexp_finalize_syms): Declare. * ldexp.c (new_rel_from_abs): Keep absolute for expressions outside of output section statements. Set rel_from_abs. (make_abs, exp_fold_tree, exp_fold_tree_no_dot): Clear rel_from_abs. (struct definedness_hash_entry): Add final_sec, and comment. (update_definedness): Set final_sec. (set_sym_sections, ldexp_finalize_syms): New functions. * ldlang.c (lang_process): Call ldexp_finalize_syms. ld/testsuite PR ld/18963 * ld-scripts/pr18963.d, * ld-scripts/pr18963.t: New test. * ld-scripts/expr.exp: Run it. * ld-elf/provide-hidden-2.ld: Explicitly make "dot" absolute. * ld-mips-elf/gp-hidden.sd: Don't care about _gp section. * ld-mips-elf/no-shared-1-n32.d: Don't care about symbol shown at start of .data section. * ld-mips-elf/no-shared-1-n64.d: Likewise. * ld-mips-elf/no-shared-1-o32.d: Likewise.
Diffstat (limited to 'ld/ldexp.h')
-rw-r--r--ld/ldexp.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/ld/ldexp.h b/ld/ldexp.h
index f61df6b..bea8045 100644
--- a/ld/ldexp.h
+++ b/ld/ldexp.h
@@ -138,6 +138,14 @@ struct ldexp_control {
/* Principally used for diagnostics. */
bfd_boolean assigning_to_dot;
+
+ /* Set if the current expression used "dot", SEGMENT_START or
+ ORIGIN, but not ABSOLUTE or combined symbols in a way that forces
+ an absolute result. Used in tracking symbols assigned from dot
+ outside of output section statements, in order to later convert
+ them from absolute. */
+ bfd_boolean rel_from_abs;
+
/* If evaluating an assignment, the destination. Cleared if an
etree_name NAME matches this, to signal a self-assignment.
Note that an etree_name DEFINED does not clear this field, nor
@@ -222,6 +230,7 @@ fill_type *exp_get_fill
bfd_vma exp_get_abs_int
(etree_type *, int, char *);
void ldexp_init (void);
+void ldexp_finalize_syms (void);
void ldexp_finish (void);
#endif