[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] configure: Use lld --image-base for --disable-pie user mode
Re: [PATCH] configure: Use lld --image-base for --disable-pie user mode binaries
Sun, 1 Dec 2019 13:48:08 -0800
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.1
On 11/27/19 6:36 PM, Fangrui Song wrote:
> On 2019-11-20, Fangrui Song wrote:
>> On 2019-11-15, Fangrui Song wrote:
>>> For lld, --image-base is the preferred way to set the base address.
>>> lld does not actually implement -Ttext-segment, but treats it as an alias
>>> -Ttext. -Ttext-segment=0x60000000 combined with --no-rosegment can
>>> create a 1.6GB executable.
>>> Fix the problem by using --image-base for lld. GNU ld and gold will
>>> still get -Ttext-segment. Also delete the ld --verbose fallback introduced
>>> in 2013, which is no longer relevant or correct (the default linker
>>> script has changed).
>>> Signed-off-by: Fangrui Song <address@hidden>
>>> configure | 33 ++++++++++++---------------------
>>> 1 file changed, 12 insertions(+), 21 deletions(-)
>>> diff --git a/configure b/configure
>>> index 6099be1d84..2d45af0d09 100755
>>> --- a/configure
>>> +++ b/configure
>>> @@ -6336,43 +6336,34 @@ fi
>>> # Probe for the need for relocating the user-only binary.
>>> if ( [ "$linux_user" = yes ] || [ "$bsd_user" = yes ] ) && [ "$pie" = no ];
>>> - textseg_addr=
>>> + image_base=
>>> case "$cpu" in
>>> arm | i386 | ppc* | s390* | sparc* | x86_64 | x32)
>>> - # ??? Rationale for choosing this address
>>> - textseg_addr=0x60000000
>>> + # An arbitrary address that makes it unlikely to collide with user
>>> + # programs.
Please don't replace this ??? with an arbitrary rationale, which clearly
doesn't apply to all of these hosts.
>>> + image_base=0x60000000
>>> # A 256M aligned address, high in the address space, with enough
>>> # room for the code_gen_buffer above it before the stack.
This is the only one with a proper rationale.
That said, I'm not sure that the proper way to handle this issue with lld is to
drop this code entirely.
The best way to handle the underlying issue -- address conflict between
interpreter and guest binary -- is PIE, for which this code is skipped.
After that, we go to some pain to choose a guest_base address that allows the
guest binary to load around the interpreter's reserved addresses.
So what's left that this messing about with link addresses buys us?
- Re: [PATCH] configure: Use lld --image-base for --disable-pie user mode binaries,
Richard Henderson <=