From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DC020C32771 for ; Mon, 26 Sep 2022 20:47:50 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 14AC584DD8; Mon, 26 Sep 2022 22:47:49 +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="lArQ4kTt"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 26E1184840; Mon, 26 Sep 2022 22:47:47 +0200 (CEST) Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) (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 2504D84E17 for ; Mon, 26 Sep 2022 22:47: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=37g8yYwYKBvUXabisXdlldib.Zljr-Yllqifpqp.abku.ab@flex--adelva.bounces.google.com Received: by mail-pl1-x649.google.com with SMTP id d7-20020a170903230700b00177f6dd8472so5035914plh.6 for ; Mon, 26 Sep 2022 13:47:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date; bh=NGNAbGCfKYZGU1LbprRsZ04x87nOQAU1j5nrJj/frns=; b=lArQ4kTtRgKuatjnLi/ZPyCBGu5+chrY9ljuL/jwmXu5F6pnuTjmNVQl+BZvzG4VRZ RtLI7V6zyE6oLeg6p3lYolNxTwiQR0ANmhFCjuJhtA12FfdYaH5PW83TtxPZKLVEPtIf BKOWOpLIfUNcnuPHhxDZRqY2Ogit4n4L3uUOnhC2mtN51WcpcX3kb+Qaf6SWWUasVrZR 4wZ2B6X6HRcgTQ0MMCbD1ARWzwwz6/3f9J4AGfeYhQsoWU0cgZdwbRvvrbIk2hBq9VI1 HWOoApJ2zSVKs9O+6mlAyyMdPPoB/8xbvoI3AAxsZMYVErmqiCiPpT2yvNW2rZOtTFiG NWmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date; bh=NGNAbGCfKYZGU1LbprRsZ04x87nOQAU1j5nrJj/frns=; b=e6iUpy3O+fMZQodQCuU9W+bkCaxdUwN05BJcaVnZYkmz7qKGdFmEoMYi/1WjWyXGpr ym0tVQztawVdW7ZinSPaYxFOI2j5lEpRbdO7hEuJOSKaz7cloniQNa68JM+0s5caMhnY +Wf8wBOB/J8jZHyo+qE4QQI4orHgySlPmjt8dNl8gg2Q3ITBqy3owBpdKEZmZweQAxTc WEn4I5SwxXVpZXlc3gz3Asb2+RN9goVDLSLtTKax1XfUnFb+2oea1tI2ECdmVwFXGZcI mdZC8qLuqBhofDrrF5pykrmuE53AoTDJ/fIxadAzpg14LirIoBiCzIjYmXTxE4VwzzUz 8cFA== X-Gm-Message-State: ACrzQf2E5/f3COL/D07/clOC8VAsP+vY978VZOCnh3ySssjzrxUdn67E pMz9DhCtpcnJrqgSVMBlq2ul/siKRnxoSvlV0wk2tHklLZb36b9lnMRgZFGvawnRCU65XRNR6OK IFSLrGw1umr7gp470yJmf6aMGf4C6RuiBPPC/33N7vDYgcEJW8exBYfofCSQ= X-Google-Smtp-Source: AMsMyM5k612xG28oru++lW+y8fdoCbcjrA3ObekLFu53HGb2pvgrhpSpoG+xWoCLAHTyA8I9690hEFJniLU= X-Received: from adelva.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:47a8]) (user=adelva job=sendgmr) by 2002:a17:903:230b:b0:177:e667:7862 with SMTP id d11-20020a170903230b00b00177e6677862mr24041870plh.154.1664225262207; Mon, 26 Sep 2022 13:47:42 -0700 (PDT) Date: Mon, 26 Sep 2022 20:47:40 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.37.3.998.g577e59143f-goog Message-ID: <20220926204740.861969-1-adelva@google.com> Subject: [PATCH] Makefile: apply dynamic relocations for LLD From: Alistair Delva To: u-boot@lists.denx.de Cc: Fangrui Song , Nick Desaulniers , Simon Glass , Tom Rini Content-Type: text/plain; charset="UTF-8" X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.6 at phobos.denx.de X-Virus-Status: Clean From: Nick Desaulniers It seems that for aarch64, unless we apply dynamic relocations to the location being relocated, we fail to boot. As Fangrui notes: For dynamic relocations using the RELA format (readelf -Wr), GNU ld sets the initial content to r_addend; ld.lld doesn't do that by default (needs --apply-dynamic-relocs). Otherwise .rodata appears to be full of NUL-bytes before relocation, causing crashes when trying to invoke the function pointers in init_sequence_f from initcall_run_list(). Link: https://reviews.llvm.org/D42797 Suggested-by: Fangrui Song Signed-off-by: Nick Desaulniers Signed-off-by: Alistair Delva Cc: Simon Glass Cc: Tom Rini Cc: Nick Desaulniers --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 010ace9d7c..af06b7aa19 100644 --- a/Makefile +++ b/Makefile @@ -1022,7 +1022,7 @@ LDFLAGS_u-boot += $(LDFLAGS_FINAL) LDFLAGS_u-boot += $(call ld-option, --no-dynamic-linker) # ld.lld support -LDFLAGS_u-boot += -z notext +LDFLAGS_u-boot += -z notext $(call ld-option,--apply-dynamic-relocs) LDFLAGS_u-boot += --build-id=none -- 2.30.2