This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] LD: Always make a SEGMENT_START expression section-relative
- From: Alan Modra <amodra at gmail dot com>
- To: "Maciej W. Rozycki" <macro at mips dot com>
- Cc: binutils at sourceware dot org
- Date: Mon, 23 Jul 2018 10:56:58 +0930
- Subject: Re: [PATCH] LD: Always make a SEGMENT_START expression section-relative
- References: <alpine.DEB.2.00.1807191525430.30992@tp.orcam.me.uk>
On Thu, Jul 19, 2018 at 04:40:56PM +0100, Maciej W. Rozycki wrote:
> 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.
The above is OK, but since you're changing this code it would be good
to avoid the divide by zero exposed by your override testcase on
non-ELF targets. Please add a "config.maxpagesize != 0" test before
we try to calculate "seg->value % config.maxpagesize".
> * 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.
I'm inclined to think these tests should only be run on ELF targets.
Some formats don't support changing the text segment address.
OK with those changes.
--
Alan Modra
Australia Development Lab, IBM