From nobody Fri Jan 31 00:26:06 2025 Received: from mail-wr1-f74.google.com (mail-wr1-f74.google.com [209.85.221.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5288F1FF1B5 for ; Mon, 27 Jan 2025 11:43:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737978235; cv=none; b=CyCiqqzlFjwE9AGG73Mibe39JvG+isBfLHM6BfdfzhDFt0SKj8X8XmZLjmKUY1p0/iEynY5emyc1UL6XF0aX4MNsQDbBgmFHtP0PQSr/ihnGaC+UanK18gGeT2+TNP84Snk9+0Z6/Q9Ldvlj/MOAfgtwa1tFjOlrd6Y6L01xU6M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737978235; c=relaxed/simple; bh=Rw7G1h9Mm5m0Rqqtpv2pG1QAtAwmucAqwhcPdCjMHsE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=l2eG9FCVWCb889G5WsxN+dI/+LfgOoE1p99XrkN4YThy849vCq0tTuICCUgsIAzk/E+nS76jG0p4ifnoWau45bQErEGlxLNPlR41aB/qF9g4zZEtdxiUO7ABtoqldRQKiPmFJRM2secxBWiPpHJps5UdjCn6IZNK9KhMfdZmd1Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--ardb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=WyML4/sA; arc=none smtp.client-ip=209.85.221.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--ardb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="WyML4/sA" Received: by mail-wr1-f74.google.com with SMTP id ffacd0b85a97d-38c24ac3415so3477624f8f.2 for ; Mon, 27 Jan 2025 03:43:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1737978231; x=1738583031; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=g5TdEKj++12/9w4Rdmd4D/a0SZj89JUunTQfRarbp/8=; b=WyML4/sAoRPetc9uOAYxXu7wmSJnONS6SNcJmqOD+fAEe/egAMU7lFc4BJuvm2wfXL SUag+c1hUKvBtq0s+uaNCiccN4g50iLiassxZqRxc4RgzAV5nc9XSpy39rDpMqhd9TgF 8L142cQorqo4gDkh9H1zo1PvrGvYlGJJ4tJUD/GiwblDU1gWpXbVZtARckGPbDdrNGDa dcNGo+dfkwZPYX7XjI35JnWfcpZM8FNI8Goe41/+LmS1jjI2JRa3DJRtw8gX5IQ1z/vT SrXlT524avCmeRjQyAtUPaWSJFQjJ3vGhMqcW+djsWKBDqkmqL9d1fjxOmDIbx3g4doz +zpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737978231; x=1738583031; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=g5TdEKj++12/9w4Rdmd4D/a0SZj89JUunTQfRarbp/8=; b=Al6hEUYJmTlouEHDzVnXcPDneiCeRh1MXzOTtbH7EUxg4N7PyUC7mukWU+Ym284lZK eQIapMQEhpC1c2cuE6KGshomlHOeXRYlDg07BSbPHmJrw7bgmUHTeMIrqdISsQVDgs0A k0+C9JXJQz33+EiFzmFty/T7JfREEG8mOu1MFsBQOiIy1Q3M0HEPGQTt762J/n25VFQP ocWuwkep0LZ/q9hmXtpduzpicak+AVUZxcRoRQClwuZ8GfUNUbOU0iCHivIlJhjjhXEy XqPjYwbtwkcCsYwHb2cFRoI4uBZjNeDrsoi+HW/uYXhD9g2aiTuGcKUuw/2ZcKJiV568 sGog== X-Gm-Message-State: AOJu0YyGQr6gROvpy1xr2gzh5uWX+BXqvusPEhNo7gRm8XoFWboXNMWB XQkFMaJ9croxBjZ2VdJkK4Z/TI57sUg1IGFDcbf1hlSiQZu2Koy6Fhj6398APKuCjLuNdFO9q+A MiBXCVcKsPmWqgxRsmVvNqOHesS5Ip9deuTzvgbNxj2Q/4t1GH6Z5COrzQjmNY+gC5mrLq+dwS5 yVdl4IM+YEQsT85v0vqvb6sM3dfTQiHQ== X-Google-Smtp-Source: AGHT+IERjn9RVrdg5Y5Gh6f/IyNBTRjNV/8facnUvIPpUrZjkN2vxlaXMSdH3Y3bJ9TAz6s70/Abb1t7 X-Received: from wrbfu6.prod.google.com ([2002:a05:6000:25e6:b0:38c:3e26:5bd8]) (user=ardb job=prod-delivery.src-stubby-dispatcher) by 2002:a5d:5906:0:b0:386:43c9:3ac2 with SMTP id ffacd0b85a97d-38bf5659ce2mr31929016f8f.15.1737978231477; Mon, 27 Jan 2025 03:43:51 -0800 (PST) Date: Mon, 27 Jan 2025 12:43:36 +0100 In-Reply-To: <20250127114334.1045857-4-ardb+git@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250127114334.1045857-4-ardb+git@google.com> X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-Developer-Signature: v=1; a=openpgp-sha256; l=1710; i=ardb@kernel.org; h=from:subject; bh=+HpXnRUb1oZjeVZUHoeruZsA5gOTtAup4kLlcX8D2c0=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JIX16YZZ3aJT9Q98vJQLOx1785vg9L97LW1V8nrjaJi+1j BeZCxw7SlkYxDgYZMUUWQRm/3238/REqVrnWbIwc1iZQIYwcHEKwESWqjL8U968/oDNwXubZ/Rt 3P9u3nTjrU/zfZtTH57/tnel8YqmEj2Gf5q+zWJlnW6tN7q/fa1kPfk1yepqgvW7HQUCn/dXZP2 +zgoA X-Mailer: git-send-email 2.48.1.262.g85cc9f2d1e-goog Message-ID: <20250127114334.1045857-5-ardb+git@google.com> Subject: [RFC PATCH 1/2] x86/relocs: Improve diagnostic for rejected absolute references From: Ard Biesheuvel To: linux-kernel@vger.kernel.org Cc: x86@kernel.org, Ard Biesheuvel , Ingo Molnar , Linus Torvalds , Tom Lendacky , Nathan Chancellor Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Ard Biesheuvel Compiler emitted absolute references are often section-relative, as the objects in question sometimes don't even exist in the C code (e.g., jump tables) or have static linkage. Enhance the diagnostic that is printed when detecting absolute references in .head.text, but printing the addend of the symbol reference, and the location in vmlinux where the reference can be found. So instead of printing Absolute reference to symbol '.rodata' detected not permitted in .head.te= xt and failing the build, print the below but only as a warning. Absolute reference to symbol '.rodata+0x180' detected in .head.text (0xff= ffffff820cb4ba). This kernel may might not boot. Not failing the build also works around the issue that the file vmlinux will be deleted by make when an error occurs, which is not very helpful in trying to narrow down the problem. Reported-by: Linus Torvalds Signed-off-by: Ard Biesheuvel --- arch/x86/tools/relocs.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c index e937be979ec8..134cf5cfe7bd 100644 --- a/arch/x86/tools/relocs.c +++ b/arch/x86/tools/relocs.c @@ -901,9 +901,10 @@ static int do_reloc64(struct section *sec, Elf_Rel *re= l, ElfW(Sym) *sym, } =20 if (headtext) { - die("Absolute reference to symbol '%s' not permitted in .head.text\n", - symname); - break; + fprintf(stderr, + "Absolute reference to symbol '%s+0x%lx' detected in .head.text (0x%lx= ).\n" + "This kernel might not boot.\n", + symname, rel->r_addend, offset); } =20 /* --=20 2.48.1.262.g85cc9f2d1e-goog