From patchwork Tue Oct 26 20:03:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 46672 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EC94E385800A for ; Tue, 26 Oct 2021 20:06:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EC94E385800A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1635278785; bh=SM2Banl76FDsfLoMDCQtKXjxL+CvKsvONf55XXgLJig=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=wiCeVOvwhyt53lT/TC62gcnUp2UvguAcoFn8m/2j0gn1nhuX7M/AHPZXQl89sp17G 5g6/h8+dT1iAnwh/RRiEY6FpGXrVDOmPOs+gqZN349Zq9YBQWw2U7LaDFqhFrdhXNw UGgUOpSUt9YIACfhG3iamQMM5kHXNK03GowC5l0A= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oi1-x234.google.com (mail-oi1-x234.google.com [IPv6:2607:f8b0:4864:20::234]) by sourceware.org (Postfix) with ESMTPS id 245763858036 for ; Tue, 26 Oct 2021 20:03:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 245763858036 Received: by mail-oi1-x234.google.com with SMTP id t4so260112oie.5 for ; Tue, 26 Oct 2021 13:03:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=SM2Banl76FDsfLoMDCQtKXjxL+CvKsvONf55XXgLJig=; b=sadOlMttbqtvtVh/ANzmDKTztRYmKTVZBBl7YGN4FlLiOxFbysKjXino87d0/+e8xh EoiHFyFfsWe2hDEVtps512+kt6ywit8hDCmTEYGqlm0sDcoBpGhQWixIcuG8aAHSXX47 oW+l5G1ya1gyoN312sOt9XkEkpD24NnB5T/6oOQC7C71nflS9kgKPujNPDyMLiN6krJV QWT1+gPD246JaCGAADSekJ2U1iaZPckW9X+F/URIMg68o0uEnwKIvE+FG5qcbCyK/Dlu ifwO9RkwETacvljJ1S7I+ZSHW4Jok/SFvjojD68KYrNS9ZDlWf3r0MqZviafvR0i1c05 QGMg== X-Gm-Message-State: AOAM533MzQq+05nilSQSMApNzPb5CgA+zwjyIc4GXzHcdQEy6m50dQvI B0owUCwFL+eRFtReph4yX5LTTx7B2cIZbw== X-Google-Smtp-Source: ABdhPJySzOQ6wC2TsIfwUJipgPoVc+eye7/JuO+gC/GcGqUlt8a6841LRmxY+4cwBpDfInSXTT2LfA== X-Received: by 2002:aca:5d07:: with SMTP id r7mr684097oib.138.1635278630292; Tue, 26 Oct 2021 13:03:50 -0700 (PDT) Received: from birita.. ([2804:431:c7cb:6672:308c:d549:2f1f:5bb6]) by smtp.gmail.com with ESMTPSA id l3sm2689062otu.6.2021.10.26.13.03.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Oct 2021 13:03:49 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 0/3] Improve lld support and current status Date: Tue, 26 Oct 2021 17:03:43 -0300 Message-Id: <20211026200346.3371750-1-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_BLACK autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Ths patch allows x86_64, i686, aarch64, powerpc64le, powerpc64, and powerpc to build, including the tests, with LLD packed in LLVM 13 [1]. For x86_64 and aarch64 there is no regression in testssuite. On i686 there is only one: FAIL: elf/ifuncmain6pie Which segfaults calling the 'foo' functions: Program received signal SIGSEGV, Segmentation fault. 0xfb010101 in ?? () (gdb) bt #0 0xfb010101 in ?? () #1 0xf7fba620 in call_foo () at ifuncmod6.c:18 #2 0xf7fc0857 in ?? () #3 0xf7e1b195 in __libc_start_call_main (main=main@entry=0xf7fc0830, argc=argc@entry=2, argv=argv@entry=0xffffc610) at ../sysdeps/nptl/libc_start_call_main.h:58 #4 0xf7e1b286 in __libc_start_main_impl (main=0xf7fc0830, argc=2, argv=0xffffc610, init=0x0, fini=0x0, rtld_fini=0xf7fe79b0 <_dl_fini>, stack_end=0xffffc60c) at ../csu/libc-start.c:409 #5 0xf7fc06d7 in ?? () The powerpc64le fails at libc.so start: (gdb) bt #0 0x00007ffff7f2a980 in __gep_setup___vmx__sigjmp_save () from /home/azanella/glibc/build/powerpc64le-linux-gnu-power9-lld/libc.so.6 #1 0x00007ffff7d7ac5c in __libc_start_call_main () from /home/azanella/glibc/build/powerpc64le-linux-gnu-power9-lld/libc.so.6 #2 0x00007ffff7d7ae90 in __libc_start_main_impl () from /home/azanella/glibc/build/powerpc64le-linux-gnu-power9-lld/libc.so.6 #3 0x0000000000000000 in ?? () (gdb) disas Dump of assembler code for function __gep_setup___vmx__sigjmp_save: => 0x00007ffff7f2a980 <+0>: .long 0x613ffe6 0x00007ffff7f2a984 <+4>: li r12,-1280 0x00007ffff7f2a988 <+8>: mtctr r12 0x00007ffff7f2a98c <+12>: bctr And powerpc64-linux-gnu fails on dynamic loaders start: (gdb) bt #0 0x00007ffff7ffa9a8 in _start () (gdb) disas Dump of assembler code for function _start: => 0x00007ffff7ffa9a8 <+0>: .long 0x0 0x00007ffff7ffa9ac <+4>: .long 0x0 0x00007ffff7ffa9b0 <+8>: .long 0x0 0x00007ffff7ffa9b4 <+12>: .long 0x0 The arm, sparcv9, mips, and riscv fail to build due different issues. On arm the loader fails to build: ld.so fails with ld.lld: error: relocation R_ARM_GOTOFF32 cannot be used against symbol _dl_argv; recompile with -fPIC >>> defined in >>> /home/azanella/Projects/glibc/build/arm-linux-gnueabihf-lld/elf/librtld.os >>> referenced by rtld.c:164 >>> /home/azanella/Projects/glibc/build/arm-linux-gnueabihf-lld/elf/librtld.os:(.text+0xA8) On sparcv9, lld handles --relax option different than ld.bfd: it throws an error instead of silent ignoring it: $ sparc64-glibc-linux-gnu-gcc -mcpu=niagara -fuse-ld=lld -Bclang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04/bin -g -O2 -fPIC -shared -fno-stack-protector -o conftest.so conftest.c -nostdlib -nostartfiles -Wl,-z,combreloc ld.lld: error: unknown argument '-relax' And even when -mno-relax is explicit add, lld does not support some relocations generated by GCC: $ sparc64-glibc-linux-gnu-readelf -Wr elf/librtld.os | grep _dl_skip_args | head -n2 00000000000000a0 0000012200000052 R_SPARC_GOTDATA_OP_HIX22 0000000000000058 _dl_skip_args + 0 00000000000000a4 0000012200000053 R_SPARC_GOTDATA_OP_LOX10 0000000000000058 _dl_skip_args + 0 The mips/mipsel also fails to build the loader: ld.lld: error: can't create dynamic relocation R_MIPS_32 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output >>> defined in >>> /home/azanella/Projects/glibc/build/mips-linux-gnu-lld/elf/librtld.os >>> referenced by /home/azanella/toolchain/src/gcc/libgcc/libgcc2.c >>> /home/azanella/Projects/glibc/build/mips-linux-gnu-lld/elf/librtld.os:(.eh_frame+0x1C) ld.lld: error: can't create dynamic relocation R_MIPS_32 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output >>> defined in >>> /home/azanella/Projects/glibc/build/mips-linux-gnu-lld/elf/librtld.os >>> referenced by /home/azanella/toolchain/src/gcc/libgcc/libgcc2.c >>> /home/azanella/Projects/glibc/build/mips-linux-gnu-lld/elf/librtld.os:(.eh_frame+0x54) Similar to mips64/mips64el: ld.lld: warning: ../sysdeps/unix/sysv/linux/setitimer.c:(function _dl_runtime_resolve: .text+0x18954): found R_MIPS_JALR relocation against non-function symbol . This is invalid and most likely a compiler bug. ld.lld: error: can't create dynamic relocation R_MIPS_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output >>> defined in >>> /home/azanella/Projects/glibc/build/mips64-linux-gnu-lld/elf/librtld.os >>> referenced by ../sysdeps/unix/sysv/linux/setitimer.c >>> /home/azanella/Projects/glibc/build/mips64-linux-gnu-lld/elf/librtld.os:(.eh_frame+0x20) The riscv32/riscv64 fails to the loader, but it is due missing support to relaxation: ld.lld: error: /home/azanella/Projects/glibc/glibc-git/elf/rtld.c:2584:(.text+0xEC84): relocation R_RISCV_ALIGN requires unimplemented linker relaxation; recompile with -mno-relax ld.lld: error: /home/azanella/Projects/glibc/glibc-git/elf/rtld.c:2589:(.text+0x13DEC): relocation R_RISCV_ALIGN requires unimplemented linker relaxation; recompile with -mno-relax ld.lld: error: /home/azanella/Projects/glibc/glibc-git/elf/rtld.c:2589:(.text+0x13DEE): relocation R_RISCV_ALIGN requires unimplemented linker relaxation; recompile with -mno-rela Adding -mno-relax to sysdep-CFLAGS seems to be ineffective. [1] https://releases.llvm.org/download.html#13.0.0 Adhemerval Zanella (3): elf: Disable ifuncmain{1,5,5pic,5pie} when using LLD Fix LIBC_PROG_BINUTILS for -fuse-ld=lld Check if linker also support -mtls-dialect=gnu2 aclocal.m4 | 6 +++++- configure | 10 +++++++--- configure.ac | 4 ++-- elf/Makefile | 17 +++++++++++++---- 4 files changed, 27 insertions(+), 10 deletions(-)