Add the RHEL 211.21.1..211.22.1 backports (1288-1351) from centos-stream-10 and upstream stable, on top of 211.20.1. Bump pkgrelease and specrelease to 211.22.1. (The redhat/ automotive rebuild-changelog tooling change is omitted: it patches redhat/scripts not present in this build base and does not affect the kernel.)
197 lines
6.1 KiB
Diff
197 lines
6.1 KiB
Diff
From 0e6fd4e629cfcaf1a4f04e2c9e39e8b5776890a2 Mon Sep 17 00:00:00 2001
|
|
From: Jerome Marchand <jmarchan@redhat.com>
|
|
Date: Mon, 1 Jun 2026 15:36:32 +0200
|
|
Subject: [PATCH] scripts/sorttable: Get start/stop_mcount_loc from ELF file
|
|
directly
|
|
|
|
JIRA: https://redhat.atlassian.net/browse/RHEL-180193
|
|
|
|
commit 4acda8edefa1ce66d3de845f1c12745721cd14c3
|
|
Author: Steven Rostedt <rostedt@goodmis.org>
|
|
Date: Sun Jan 5 11:22:25 2025 -0500
|
|
|
|
scripts/sorttable: Get start/stop_mcount_loc from ELF file directly
|
|
|
|
The get_mcount_loc() does a cheesy trick to find the start_mcount_loc and
|
|
stop_mcount_loc values. That trick is:
|
|
|
|
file_start = popen(" grep start_mcount System.map | awk '{print $1}' ", "r");
|
|
|
|
and
|
|
|
|
file_stop = popen(" grep stop_mcount System.map | awk '{print $1}' ", "r");
|
|
|
|
Those values are stored in the Elf symbol table. Use that to capture those
|
|
values. Using the symbol table is more efficient and more robust. The
|
|
above could fail if another variable had "start_mcount" or "stop_mcount"
|
|
as part of its name.
|
|
|
|
Cc: bpf <bpf@vger.kernel.org>
|
|
Cc: Masami Hiramatsu <mhiramat@kernel.org>
|
|
Cc: Mark Rutland <mark.rutland@arm.com>
|
|
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
|
|
Cc: Andrew Morton <akpm@linux-foundation.org>
|
|
Cc: Peter Zijlstra <peterz@infradead.org>
|
|
Cc: Linus Torvalds <torvalds@linux-foundation.org>
|
|
Cc: Masahiro Yamada <masahiroy@kernel.org>
|
|
Cc: Nathan Chancellor <nathan@kernel.org>
|
|
Cc: Nicolas Schier <nicolas@fjasle.eu>
|
|
Cc: Zheng Yejian <zhengyejian1@huawei.com>
|
|
Cc: Martin Kelly <martin.kelly@crowdstrike.com>
|
|
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
|
|
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
|
|
Link: https://lore.kernel.org/20250105162346.817157047@goodmis.org
|
|
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
|
|
|
|
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
|
|
|
|
diff --git a/scripts/sorttable.c b/scripts/sorttable.c
|
|
index ff9b60fc0dd8..656c1e9b5ad9 100644
|
|
--- a/scripts/sorttable.c
|
|
+++ b/scripts/sorttable.c
|
|
@@ -472,42 +472,41 @@ static void *sort_mcount_loc(void *arg)
|
|
}
|
|
|
|
/* Get the address of __start_mcount_loc and __stop_mcount_loc in System.map */
|
|
-static void get_mcount_loc(uint64_t *_start, uint64_t *_stop)
|
|
+static void get_mcount_loc(struct elf_mcount_loc *emloc, Elf_Shdr *symtab_sec,
|
|
+ const char *strtab)
|
|
{
|
|
- FILE *file_start, *file_stop;
|
|
- char start_buff[20];
|
|
- char stop_buff[20];
|
|
- int len = 0;
|
|
+ Elf_Sym *sym, *end_sym;
|
|
+ int symentsize = shdr_entsize(symtab_sec);
|
|
+ int found = 0;
|
|
+
|
|
+ sym = (void *)emloc->ehdr + shdr_offset(symtab_sec);
|
|
+ end_sym = (void *)sym + shdr_size(symtab_sec);
|
|
+
|
|
+ while (sym < end_sym) {
|
|
+ if (!strcmp(strtab + sym_name(sym), "__start_mcount_loc")) {
|
|
+ emloc->start_mcount_loc = sym_value(sym);
|
|
+ if (++found == 2)
|
|
+ break;
|
|
+ } else if (!strcmp(strtab + sym_name(sym), "__stop_mcount_loc")) {
|
|
+ emloc->stop_mcount_loc = sym_value(sym);
|
|
+ if (++found == 2)
|
|
+ break;
|
|
+ }
|
|
+ sym = (void *)sym + symentsize;
|
|
+ }
|
|
|
|
- file_start = popen(" grep start_mcount System.map | awk '{print $1}' ", "r");
|
|
- if (!file_start) {
|
|
+ if (!emloc->start_mcount_loc) {
|
|
fprintf(stderr, "get start_mcount_loc error!");
|
|
return;
|
|
}
|
|
|
|
- file_stop = popen(" grep stop_mcount System.map | awk '{print $1}' ", "r");
|
|
- if (!file_stop) {
|
|
+ if (!emloc->stop_mcount_loc) {
|
|
fprintf(stderr, "get stop_mcount_loc error!");
|
|
- pclose(file_start);
|
|
return;
|
|
}
|
|
-
|
|
- while (fgets(start_buff, sizeof(start_buff), file_start) != NULL) {
|
|
- len = strlen(start_buff);
|
|
- start_buff[len - 1] = '\0';
|
|
- }
|
|
- *_start = strtoul(start_buff, NULL, 16);
|
|
-
|
|
- while (fgets(stop_buff, sizeof(stop_buff), file_stop) != NULL) {
|
|
- len = strlen(stop_buff);
|
|
- stop_buff[len - 1] = '\0';
|
|
- }
|
|
- *_stop = strtoul(stop_buff, NULL, 16);
|
|
-
|
|
- pclose(file_start);
|
|
- pclose(file_stop);
|
|
}
|
|
#endif
|
|
+
|
|
static int do_sort(Elf_Ehdr *ehdr,
|
|
char const *const fname,
|
|
table_sort_t custom_sort)
|
|
@@ -538,8 +537,6 @@ static int do_sort(Elf_Ehdr *ehdr,
|
|
unsigned int shstrndx;
|
|
#ifdef MCOUNT_SORT_ENABLED
|
|
struct elf_mcount_loc mstruct = {0};
|
|
- uint64_t _start_mcount_loc = 0;
|
|
- uint64_t _stop_mcount_loc = 0;
|
|
#endif
|
|
#ifdef UNWINDER_ORC_ENABLED
|
|
unsigned int orc_ip_size = 0;
|
|
@@ -577,13 +574,8 @@ static int do_sort(Elf_Ehdr *ehdr,
|
|
|
|
#ifdef MCOUNT_SORT_ENABLED
|
|
/* locate the .init.data section in vmlinux */
|
|
- if (!strcmp(secstrings + idx, ".init.data")) {
|
|
- get_mcount_loc(&_start_mcount_loc, &_stop_mcount_loc);
|
|
- mstruct.ehdr = ehdr;
|
|
+ if (!strcmp(secstrings + idx, ".init.data"))
|
|
mstruct.init_data_sec = shdr;
|
|
- mstruct.start_mcount_loc = _start_mcount_loc;
|
|
- mstruct.stop_mcount_loc = _stop_mcount_loc;
|
|
- }
|
|
#endif
|
|
|
|
#ifdef UNWINDER_ORC_ENABLED
|
|
@@ -627,23 +619,6 @@ static int do_sort(Elf_Ehdr *ehdr,
|
|
goto out;
|
|
}
|
|
#endif
|
|
-
|
|
-#ifdef MCOUNT_SORT_ENABLED
|
|
- if (!mstruct.init_data_sec || !_start_mcount_loc || !_stop_mcount_loc) {
|
|
- fprintf(stderr,
|
|
- "incomplete mcount's sort in file: %s\n",
|
|
- fname);
|
|
- goto out;
|
|
- }
|
|
-
|
|
- /* create thread to sort mcount_loc concurrently */
|
|
- if (pthread_create(&mcount_sort_thread, NULL, &sort_mcount_loc, &mstruct)) {
|
|
- fprintf(stderr,
|
|
- "pthread_create mcount_sort_thread failed '%s': %s\n",
|
|
- strerror(errno), fname);
|
|
- goto out;
|
|
- }
|
|
-#endif
|
|
if (!extab_sec) {
|
|
fprintf(stderr, "no __ex_table in file: %s\n", fname);
|
|
goto out;
|
|
@@ -663,6 +638,26 @@ static int do_sort(Elf_Ehdr *ehdr,
|
|
strtab = (const char *)ehdr + shdr_offset(strtab_sec);
|
|
symtab = (const Elf_Sym *)((const char *)ehdr + shdr_offset(symtab_sec));
|
|
|
|
+#ifdef MCOUNT_SORT_ENABLED
|
|
+ mstruct.ehdr = ehdr;
|
|
+ get_mcount_loc(&mstruct, symtab_sec, strtab);
|
|
+
|
|
+ if (!mstruct.init_data_sec || !mstruct.start_mcount_loc || !mstruct.stop_mcount_loc) {
|
|
+ fprintf(stderr,
|
|
+ "incomplete mcount's sort in file: %s\n",
|
|
+ fname);
|
|
+ goto out;
|
|
+ }
|
|
+
|
|
+ /* create thread to sort mcount_loc concurrently */
|
|
+ if (pthread_create(&mcount_sort_thread, NULL, &sort_mcount_loc, &mstruct)) {
|
|
+ fprintf(stderr,
|
|
+ "pthread_create mcount_sort_thread failed '%s': %s\n",
|
|
+ strerror(errno), fname);
|
|
+ goto out;
|
|
+ }
|
|
+#endif
|
|
+
|
|
if (custom_sort) {
|
|
custom_sort(extab_image, shdr_size(extab_sec));
|
|
} else {
|
|
--
|
|
2.50.1 (Apple Git-155)
|
|
|