From patchwork Wed Oct 20 21:31:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Delva X-Patchwork-Id: 1544048 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20210112 header.b=EoBVtuz+; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HZPDw1JrFz9sR4 for ; Thu, 21 Oct 2021 08:41:04 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6B1A283488; Wed, 20 Oct 2021 23:40:25 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="EoBVtuz+"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F164183273; Wed, 20 Oct 2021 23:31:50 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x1049.google.com (mail-pj1-x1049.google.com [IPv6:2607:f8b0:4864:20::1049]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id EEC0F833D5 for ; Wed, 20 Oct 2021 23:31:44 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=3v4pwYQYKBqgILMTdIOWWOTM.KWUc-JWWbTQaba.LMVf.LM@flex--adelva.bounces.google.com Received: by mail-pj1-x1049.google.com with SMTP id mn23-20020a17090b189700b001a04f094a68so1055028pjb.2 for ; Wed, 20 Oct 2021 14:31:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=Ij3B7kSrLR7n7brheeRTL1+k83QiUgOKYXYfMqMXGLs=; b=EoBVtuz+vIomOrJq8MAznpg1/bEiCpG7Kv/yT4PIBd4U73UYFJxWyiMWxMPxR+IMH7 cBEWnQgAxs8/VvRawJhPpUsuFD1uh8KpSLmQ5HZhS1n9tjaKlu7cp2g4VL7xOwrUVb+p LfvqldJZ4ZgdU9h3W/ZgylhNYBdHPBvMbYUKDhOW0/BEeyJQEN+D4/ocNmnJ9k4YcRZE hSD7WGbmflzzWarXoYmAISuiFq8f6ZLX1JAmuS5vNk/GXCr2iefIuVeKoxvCL2U+bjNn GdM/cRkc1dSt10kSav2HxKI1TQKcSj/j+pSB85vPZ0bzKP5kKMe0F1oEaXaegWgOJMSg H3rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=Ij3B7kSrLR7n7brheeRTL1+k83QiUgOKYXYfMqMXGLs=; b=amFFv5NOwF3V04S8Ry95pd8al+v9w5D5EriM8aTylWfdMAwzDb92g1bleujzNVpU5z S36M/fEbnMO34GaK31E25febL+bRYAc+Dzukfq1lyK4BRyvp+xUYB5pLJ5PKQ3W5HzHG DOJrNkOYtdmMnInSPOIg5MjdU9RpvhMHpKMRV4h56zwEic/gXUjj0rbvpyWSR0tYiKNK fUEGLHfAlFz36tRWEkAmS3CAxYHlWwqEcY6fzdtJsmG2WjbhnA2oc5YVIBlJbslrX6Pz GuwBWKH9e+F/UP9Rzkr3gqJaDde3dRV0PhVsF4wJiRxaIZhddwjvx4c0tJD0rgR0j6NP R1Hg== X-Gm-Message-State: AOAM533rZupLUsXsO3AuMqNqzh0nM89YSheDzI7PhrjjOkN2NlLSPpWc ljsA/B1WJ9KkZlK+kJdz8POZHt/TkHQYl/7dfjz88E4lGJZSxfq82NFtKmnnyIaEj53SFE++TV6 VEMAdY4Dcd/bkCm/RdUkrZDFMGMggH8JkM8b/NrKMtwb1jnF3AP+kRyow7gg= X-Google-Smtp-Source: ABdhPJz9hVRhyv9hWl73hBC3z6rUapQM/t6aDQHlkarIBnuje3v4h/e6HDe+cByFnM4f2+ZLCa8zT3NYsdQ= X-Received: from adelva.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:b2b]) (user=adelva job=sendgmr) by 2002:a17:90a:39c5:: with SMTP id k5mr1678222pjf.211.1634765503287; Wed, 20 Oct 2021 14:31:43 -0700 (PDT) Date: Wed, 20 Oct 2021 21:31:33 +0000 In-Reply-To: <20211020213134.7534-1-adelva@google.com> Message-Id: <20211020213134.7534-5-adelva@google.com> Mime-Version: 1.0 References: <20211020213134.7534-1-adelva@google.com> X-Mailer: git-send-email 2.33.0.1079.g6e70778dc9-goog Subject: [PATCH] x86: Fix linking u-boot with ld.lld From: Alistair Delva To: u-boot@lists.denx.de Cc: Nick Desaulniers , Simon Glass , Bin Meng X-Mailman-Approved-At: Wed, 20 Oct 2021 23:39:55 +0200 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean When linking the final u-boot binary with LLD, the following link errors are seen: ld.lld: error: can't create dynamic relocation R_386_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 arch/x86/cpu/start.o >>> referenced by arch/x86/cpu/start.o:(.text.start+0x32) [...] >>> defined in arch/x86/cpu/start16.o >>> referenced by arch/x86/cpu/start16.o:(.start16+0x1C) According to Nick Desaulniers: "This is a known difference between GNU and LLVM linkers; the GNU linkers permit relocations in readonly segments (making them not read only), LLVM does not (by default)." Since U-Boot apparently seems to use relocations in readonly segments, change the global linker flags to permit them when linking with LLD by specifying '-z notext'. Signed-off-by: Alistair Delva Cc: Nick Desaulniers Cc: Simon Glass Cc: Bin Meng Reviewed-by: Simon Glass Reviewed-by: Simon Glass --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index 6f2474baeb..3488b83e14 100644 --- a/Makefile +++ b/Makefile @@ -997,6 +997,9 @@ LDFLAGS_u-boot += $(LDFLAGS_FINAL) # Avoid 'Not enough room for program headers' error on binutils 2.28 onwards. LDFLAGS_u-boot += $(call ld-option, --no-dynamic-linker) +# ld.lld support +LDFLAGS_u-boot += -z notext + LDFLAGS_u-boot += --build-id=none ifeq ($(CONFIG_ARC)$(CONFIG_NIOS2)$(CONFIG_X86)$(CONFIG_XTENSA),)