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 0D21C1A682A; Thu, 2 Jul 2026 16:38:37 +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=1783010318; cv=none; b=S0dm7a1a7CwCKT6LwR33uXISck/HKDg02s7z0ulNshhjPMr/SKCLrYJEQAY2ViPihkFpMw63vqTVJWCTtZpHCM5zUkElAW9Ax2ZmQn8uUG0GebExyjjhQIVAoajEQqSNMe7yWHIAdL2IRuj7T30txw7ChamGE+niv/WkmGG4c+Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783010318; c=relaxed/simple; bh=bjgGAsjIuiYpP9OrMd2wZ+aoHB4Hzt6uH5estsnUJ2Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PGtjFhJyrar54ZXZc9ivohJRnjT93vCMSG+EWiyikGKV40c4FYAQ1Npq+2QoswgidIVRX0A3iPyoD/H+YFalEe1vv+h44mBrYJuL/EEX72Ae+oH6muuxCeF3OetZaiL8U/vBpjpuaLcgei4IQKDvC/PY4J44iMu/XFO2ek4dQQs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=M1yPPQBN; 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="M1yPPQBN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 47F2F1F000E9; Thu, 2 Jul 2026 16:38:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1783010316; bh=hDj8aR8LUtVPUSvZWloW7mOKVQX/J7y8/2Hth3sz0p4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=M1yPPQBNxf0L8EL3NgQeF/6kfRBn00sz9vVg87vMX7PKXRORrgg3ePcAmoVdXD9wj MYPMzvhN7CGwzZ1AGOQPlvrAc1mpO0M8hAb4nlD/rZQn7bzQBfbj+BRJSVT/X/vk4Z P90p4kCrCLMmGV17+q1EZ+gdb/7bQGjDD+E9urWk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, bpf , Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Peter Zijlstra , Linus Torvalds , Masahiro Yamada , Nathan Chancellor , Nicolas Schier , Zheng Yejian , Martin Kelly , Christophe Leroy , Josh Poimboeuf , "Steven Rostedt (Google)" , Andrey Grodzovsky Subject: [PATCH 6.12 061/204] scripts/sorttable: Make compare_extable() into two functions Date: Thu, 2 Jul 2026 18:18:38 +0200 Message-ID: <20260702155119.941511339@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260702155118.667618796@linuxfoundation.org> References: <20260702155118.667618796@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Steven Rostedt [ Upstream commit 7ffc0d0819f438779ed592e2e2e3576f43ce14f0 ] Instead of having the compare_extable() part of the sorttable.h header where it get's defined twice, since it is a very simple function, just define it twice in sorttable.c, and then it can use the proper read functions for the word size and endianess and the Elf_Addr macro can be removed from sorttable.h. Also add a micro optimization. Instead of: if (a < b) return -1; if (a > b) return 1; return 0; That can be shorten to: if (a < b) return -1; return a > b; Cc: bpf Cc: Masami Hiramatsu Cc: Mark Rutland Cc: Mathieu Desnoyers Cc: Andrew Morton Cc: Peter Zijlstra Cc: Linus Torvalds Cc: Masahiro Yamada Cc: Nathan Chancellor Cc: Nicolas Schier Cc: Zheng Yejian Cc: Martin Kelly Cc: Christophe Leroy Cc: Josh Poimboeuf Link: https://lore.kernel.org/20250105162344.945299671@goodmis.org Signed-off-by: Steven Rostedt (Google) Signed-off-by: Andrey Grodzovsky Signed-off-by: Greg Kroah-Hartman --- scripts/sorttable.c | 20 ++++++++++++++++++++ scripts/sorttable.h | 14 -------------- 2 files changed, 20 insertions(+), 14 deletions(-) --- a/scripts/sorttable.c +++ b/scripts/sorttable.c @@ -173,6 +173,26 @@ static inline unsigned int get_secindex( return r(&symtab_shndx_start[sym_offs]); } +static int compare_extable_32(const void *a, const void *b) +{ + Elf32_Addr av = r(a); + Elf32_Addr bv = r(b); + + if (av < bv) + return -1; + return av > bv; +} + +static int compare_extable_64(const void *a, const void *b) +{ + Elf64_Addr av = r8(a); + Elf64_Addr bv = r8(b); + + if (av < bv) + return -1; + return av > bv; +} + /* 32 bit and 64 bit are very similar */ #include "sorttable.h" #define SORTTABLE_64 --- a/scripts/sorttable.h +++ b/scripts/sorttable.h @@ -23,7 +23,6 @@ #undef sort_mcount_loc #undef elf_mcount_loc #undef do_sort -#undef Elf_Addr #undef Elf_Ehdr #undef Elf_Shdr #undef Elf_Sym @@ -38,7 +37,6 @@ # define sort_mcount_loc sort_mcount_loc_64 # define elf_mcount_loc elf_mcount_loc_64 # define do_sort do_sort_64 -# define Elf_Addr Elf64_Addr # define Elf_Ehdr Elf64_Ehdr # define Elf_Shdr Elf64_Shdr # define Elf_Sym Elf64_Sym @@ -52,7 +50,6 @@ # define sort_mcount_loc sort_mcount_loc_32 # define elf_mcount_loc elf_mcount_loc_32 # define do_sort do_sort_32 -# define Elf_Addr Elf32_Addr # define Elf_Ehdr Elf32_Ehdr # define Elf_Shdr Elf32_Shdr # define Elf_Sym Elf32_Sym @@ -160,17 +157,6 @@ static void *sort_orctable(void *arg) } #endif -static int compare_extable(const void *a, const void *b) -{ - Elf_Addr av = _r(a); - Elf_Addr bv = _r(b); - - if (av < bv) - return -1; - if (av > bv) - return 1; - return 0; -} #ifdef MCOUNT_SORT_ENABLED pthread_t mcount_sort_thread;