[klibc] [PATCH v2 2/5] Kbuild: support clang's lld

Ben Hutchings ben at decadent.org.uk
Sat Mar 28 08:40:07 PDT 2020


On Fri, 2020-03-27 at 15:29 -0700, Bill Wendling wrote:
> From: Stanislav Fomichev <sdf at google.com>
> 
> Clang's lld prefers the use of "-image-base" instead of
> "-Ttext-segment".
> 
> Signed-off-by: Stanislav Fomichev <sdf at google.com>
> Signed-off-by: Bill Wendling <morbo at google.com>
> ---
>  Makefile                       | 3 +++
>  usr/klibc/arch/i386/MCONFIG    | 2 +-
>  usr/klibc/arch/mips64/MCONFIG  | 2 +-
>  usr/klibc/arch/ppc/MCONFIG     | 2 +-
>  usr/klibc/arch/ppc64/MCONFIG   | 2 +-
>  usr/klibc/arch/riscv64/MCONFIG | 2 +-
>  usr/klibc/arch/sparc64/MCONFIG | 2 +-
>  usr/klibc/arch/x86_64/MCONFIG  | 2 +-
>  8 files changed, 10 insertions(+), 7 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index c99b962fd2a3..52d7cd2cf791 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -27,6 +27,9 @@ export NM	:= $(KLIBCROSS)nm
>  export OBJCOPY  := $(KLIBCROSS)objcopy
>  export OBJDUMP  := $(KLIBCROSS)objdump
>  
> +LLD := $(shell $(LD) --version 2>&1 | grep LLD)
> +export IMAGE_BASE=$(if $(LLD),--image-base,-Ttext-segment)

This isn't a great variable name.  I think something like
LD_IMAGE_BASE_OPT would be clearer.

[...]
> --- a/usr/klibc/arch/mips64/MCONFIG
> +++ b/usr/klibc/arch/mips64/MCONFIG
> @@ -20,4 +20,4 @@ KLIBCBITSIZE  = 64
>  # load address, use the very top of the 256M region (minus 2MB)
>  #
>  # Use -Ttext-segment so that the special .MIPS* sections are moved as well.

This comment line should be updated or deleted.

Ben.

> -KLIBCSHAREDFLAGS     = -Ttext-segment 0x12FE00000
> +KLIBCSHAREDFLAGS     = $(IMAGE_BASE) 0x12FE00000
[...]

-- 
Ben Hutchings
This sentence contradicts itself - no actually it doesn't.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <https://lists.zytor.com/archives/klibc/attachments/20200328/423611b7/attachment.sig>


More information about the klibc mailing list