aboutsummaryrefslogtreecommitdiff
path: root/ld/ldexp.c
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@mips.com>2018-09-14 20:22:56 +0100
committerMaciej W. Rozycki <macro@linux-mips.org>2018-09-14 20:22:56 +0100
commit6057dc97e4df5ca9692ddd948798eaa543c74cc7 (patch)
tree4ac5b59f61ba9a6cb89a0aca6b5a344e24de2550 /ld/ldexp.c
parenta000f8817b32eadd4aeadf9185634350a59e6649 (diff)
downloadgdb-6057dc97e4df5ca9692ddd948798eaa543c74cc7.zip
gdb-6057dc97e4df5ca9692ddd948798eaa543c74cc7.tar.gz
gdb-6057dc97e4df5ca9692ddd948798eaa543c74cc7.tar.bz2
LD: Always make a SEGMENT_START expression section-relative
Fix an issue with the SEGMENT_START builtin function where its result is absolute when taken from the default supplied, and section-relative when taken from a `-T' command-line override. This is against documentation, inconsistent and unexpected, and with PIE executables gives an incorrect result with the `__executable_start' symbol. Make the result of SEGMENT_START always section-relative then. ld/ * ldexp.c (fold_binary): Always make the result of SEGMENT_START section-relative. * testsuite/ld-scripts/segment-start.d: New test. * testsuite/ld-scripts/segment-start.ld: New test linker script. * testsuite/ld-scripts/segment-start.s: New test source. * testsuite/ld-scripts/script.exp: Run the new test.
Diffstat (limited to 'ld/ldexp.c')
-rw-r--r--ld/ldexp.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/ld/ldexp.c b/ld/ldexp.c
index 4b9676e..f6446dc 100644
--- a/ld/ldexp.c
+++ b/ld/ldexp.c
@@ -534,6 +534,7 @@ fold_binary (etree_type *tree)
operand, binary.rhs is first operand. */
if (expld.result.valid_p && tree->type.node_code == SEGMENT_START)
{
+ bfd_vma value = expld.result.value;
const char *segment_name;
segment_type *seg;
@@ -551,9 +552,10 @@ fold_binary (etree_type *tree)
"isn't multiple of maximum page size\n"),
segment_name);
seg->used = TRUE;
- new_rel_from_abs (seg->value);
+ value = seg->value;
break;
}
+ new_rel_from_abs (value);
return;
}