This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] LD: Always make a SEGMENT_START expression section-relative


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]