From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BB11B34C155; Thu, 2 Jul 2026 16:47:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783010869; cv=none; b=DS2tFoqqlXrF1qPBOZP9KUs24e/AyTY9fWSKI5ALcR12bBJWysTlKPytAFSsU5xDoOVWM932XkgX1KarnorcvgTrhuEoy4ZB1kp1DhD3JGVj9QvQNWnV0E9mAS7ZtLCRqycOwKeK0+YZS984253E5GOTrah7UiBuEOxyNpUcNaw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783010869; c=relaxed/simple; bh=9Lu25dw4DWT6jYkzprVkzMMddIQ5TaiaiHeuqe6uXnI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=k88nzUWME8Ze45ubg2oIcuYvMiFJQeE5/vLxHq3aYF3V/Ve2SD14ubb/x47yDVci5a/jOMQAGScroYLVgYr7SwvZjakG7XwzX/weCq3HxYtbkX9BXKyIH+VRHna2yI6cfD2yfSuusoOIQTzoeibhClbSF8nh9yvXmxpXwYAmY60= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=0qPuHQLQ; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="0qPuHQLQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 328221F000E9; Thu, 2 Jul 2026 16:47:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1783010868; bh=SOlCjJeUFNHQRXmsyiuJTu9J3iA6MSDBIogCcOv6eVo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=0qPuHQLQrkwSLSIqXX3C2a3gmNj5wZFjEpP/8cmcY4r6m+Spmv2PuZr18c4wd0vUI JqIVlfbIshBF+JWdDPUyMIukWRyoNavoWbL2rTZMK4CJgBQudpxj5Fax0GLQC6CNz7 VI0w78kGXfaXD49b/7JfJwkSg9EESoBzMcL3hfcg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Masahiro Yamada , Catalin Marinas , Will Deacon , Mark Brown , "Arnd Bergmann" , Nathan Chancellor , "Steven Rostedt (Google)" , Andrey Grodzovsky Subject: [PATCH 6.6 068/175] scripts/sorttable: Use normal sort if theres no relocs in the mcount section Date: Thu, 2 Jul 2026 18:19:29 +0200 Message-ID: <20260702155117.225506612@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260702155115.766838875@linuxfoundation.org> References: <20260702155115.766838875@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Steven Rostedt [ Upstream commit 46514b3c2c17c67cefe84b0c1a59e0aaf6093131 ] When ARM 64 is compiled with gcc, the mcount_loc section will be filled with zeros and the addresses will be located in the Elf_Rela sections. To sort the mcount_loc section, the addresses from the Elf_Rela need to be placed into an array and that is sorted. But when ARM 64 is compiled with clang, it does it the same way as other architectures and leaves the addresses as is in the mcount_loc section. To handle both cases, ARM 64 will first try to sort the Elf_Rela section, and if it doesn't find any functions, it will then fall back to the sorting of the addresses in the mcount_loc section itself. Cc: Masami Hiramatsu Cc: Mark Rutland Cc: Mathieu Desnoyers Cc: Andrew Morton Cc: Masahiro Yamada Cc: Catalin Marinas Cc: Will Deacon Cc: Mark Brown Link: https://lore.kernel.org/20250225182054.648398403@goodmis.org Fixes: b3d09d06e052 ("arm64: scripts/sorttable: Implement sorting mcount_loc at boot for arm64") Reported-by: "Arnd Bergmann" Tested-by: Nathan Chancellor Closes: https://lore.kernel.org/all/893cd8f1-8585-4d25-bf0f-4197bf872465@app.fastmail.com/ Signed-off-by: Steven Rostedt (Google) Signed-off-by: Andrey Grodzovsky Signed-off-by: Greg Kroah-Hartman --- scripts/sorttable.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) --- a/scripts/sorttable.c +++ b/scripts/sorttable.c @@ -827,9 +827,14 @@ static void *sort_mcount_loc(void *arg) pthread_exit(m_err); } - if (sort_reloc) + if (sort_reloc) { count = fill_relocs(vals, size, ehdr, emloc->start_mcount_loc); - else + /* gcc may use relocs to save the addresses, but clang does not. */ + if (!count) { + count = fill_addrs(vals, size, start_loc); + sort_reloc = 0; + } + } else count = fill_addrs(vals, size, start_loc); if (count < 0) {