[PATCH] D22116: [ELF] Support for setting the base address
Ed Maste via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 8 13:43:59 PDT 2016
On 8 July 2016 at 15:05, Rafael Espíndola <rafael.espindola at gmail.com> wrote:
> Ed, do you know if the uses of -Ttext is FreeBSD are trying to set the
> address of the text segment or just control the the lowest address in
> the binary (i.e., set the address of the first segment)?
As far as I know it's not used in FreeBSD base at all -- all of the
cases where we need this functionality use linker scripts. This is in
part because GNU ld's -Ttext option is basically useless while
-Ttext-segment has the desired behaviour but does not exist in
FreeBSD's ancient GNU ld. Gold implemented -Ttext and made it
equivalent to -Ttext-segment, and later added an alias so it treats
both of them the same.
I'm aware of several uses of this option in the ports tree on FreeBSD,
and all of them use it just to locate the binary at a different
address so that it is out of the way. QEMU and Valgrind are two
examples. Thus, I think address of the first segment is the desired
I think -image-base is a more representative name. The option is used
rarely enough that it probably won't be onerous to address this in
individual third-party software ports.
I'm unfortunately familiar with these options :(
AFAIK it is not used in FreeBSD.
this is not used in FreeBSD, because the
> On 8 July 2016 at 15:01, Rafael Espíndola <rafael.espindola at gmail.com> wrote:
>> On 8 July 2016 at 14:33, Petr Hosek via llvm-commits
>> <llvm-commits at lists.llvm.org> wrote:
>>> phosek added a comment.
>>> There are two issues here. The first is correctness, and you're right that for lld `-Trodata-segment` as an option for setting the start address would be better since lld puts rodata segment at the beginning. The other is compatibility, as large number of existing build scripts use `-Ttext-segment` as an option for setting the start address, irrespective of which linker is being used.
>> I see, so what you base is an option to set the smallest used virtual address.
>>> In our use case, we would like to have an option to set the start address in lld. Would it be fine with you if I rename the option to `-image-base`? This option is already supported by BFD ld, even though it's only used for PE targets, and OS X ld also has a similar option `-image_base`. Alternatively we could use a completely different name.
>> Rui, is there something like that for COFF? image-base is a COFF term, no?
>> Another option name would be -Tbase, or -Tfirst_segment since the
>> other options are -Txyz.
>> Taking a look a the patch itself.
More information about the llvm-commits