summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorMasahiro Yamada <masahiroy@kernel.org>2023-03-08 20:52:41 +0900
committerMasahiro Yamada <masahiroy@kernel.org>2023-04-17 11:03:56 +0900
commit404bad70fcf7cb1a36198581e6904637f3c36846 (patch)
tree99f0b306ccaa4be01100043e14b727394b537aba /scripts
parent320e7c9d4494f7a6f046871678f582a3392235f8 (diff)
downloadlinux-404bad70fcf7cb1a36198581e6904637f3c36846.tar.gz
scripts/kallsyms: change the output order
Currently, this tool outputs symbol data in the following order. (1) kallsyms_addressed / kallsyms_offsets (2) kallsyms_relative_base (3) kallsyms_num_syms (4) kallsyms_names (5) kallsyms_markers (6) kallsyms_seq_of_names (7) kallsyms_token_table (8) kallsyms_token_index This commit changes the order as follows: (1) kallsyms_num_syms (2) kallsyms_names (3) kallsyms_markers (4) kallsyms_token_table (5) kallsyms_token_index (6) kallsyms_addressed / kallsyms_offsets (7) kallsyms_relative_base (8) kallsyms_seq_of_names The motivation is to decrease the number of function calls to expand_symbol() and cleanup_symbol_name(). The compressed names are only required for writing 'kallsyms_names'. If you do this first, we can restore the original symbol names. You do not need to repeat the same operation over again. The actual refactoring will happen in the next commit. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/kallsyms.c118
1 files changed, 59 insertions, 59 deletions
diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c
index 97d514c0fc8f..5996f1e61bcf 100644
--- a/scripts/kallsyms.c
+++ b/scripts/kallsyms.c
@@ -412,56 +412,6 @@ static void write_src(void)
printf("\t.section .rodata, \"a\"\n");
- if (!base_relative)
- output_label("kallsyms_addresses");
- else
- output_label("kallsyms_offsets");
-
- for (i = 0; i < table_cnt; i++) {
- if (base_relative) {
- /*
- * Use the offset relative to the lowest value
- * encountered of all relative symbols, and emit
- * non-relocatable fixed offsets that will be fixed
- * up at runtime.
- */
-
- long long offset;
- int overflow;
-
- if (!absolute_percpu) {
- offset = table[i]->addr - relative_base;
- overflow = (offset < 0 || offset > UINT_MAX);
- } else if (symbol_absolute(table[i])) {
- offset = table[i]->addr;
- overflow = (offset < 0 || offset > INT_MAX);
- } else {
- offset = relative_base - table[i]->addr - 1;
- overflow = (offset < INT_MIN || offset >= 0);
- }
- if (overflow) {
- fprintf(stderr, "kallsyms failure: "
- "%s symbol value %#llx out of range in relative mode\n",
- symbol_absolute(table[i]) ? "absolute" : "relative",
- table[i]->addr);
- exit(EXIT_FAILURE);
- }
- expand_symbol(table[i]->sym, table[i]->len, buf);
- printf("\t.long\t%#x /* %s */\n", (int)offset, buf);
- } else if (!symbol_absolute(table[i])) {
- output_address(table[i]->addr);
- } else {
- printf("\tPTR\t%#llx\n", table[i]->addr);
- }
- }
- printf("\n");
-
- if (base_relative) {
- output_label("kallsyms_relative_base");
- output_address(relative_base);
- printf("\n");
- }
-
output_label("kallsyms_num_syms");
printf("\t.long\t%u\n", table_cnt);
printf("\n");
@@ -521,15 +471,6 @@ static void write_src(void)
free(markers);
- sort_symbols_by_name();
- output_label("kallsyms_seqs_of_names");
- for (i = 0; i < table_cnt; i++)
- printf("\t.byte 0x%02x, 0x%02x, 0x%02x\n",
- (unsigned char)(table[i]->seq >> 16),
- (unsigned char)(table[i]->seq >> 8),
- (unsigned char)(table[i]->seq >> 0));
- printf("\n");
-
output_label("kallsyms_token_table");
off = 0;
for (i = 0; i < 256; i++) {
@@ -544,6 +485,65 @@ static void write_src(void)
for (i = 0; i < 256; i++)
printf("\t.short\t%d\n", best_idx[i]);
printf("\n");
+
+ if (!base_relative)
+ output_label("kallsyms_addresses");
+ else
+ output_label("kallsyms_offsets");
+
+ for (i = 0; i < table_cnt; i++) {
+ if (base_relative) {
+ /*
+ * Use the offset relative to the lowest value
+ * encountered of all relative symbols, and emit
+ * non-relocatable fixed offsets that will be fixed
+ * up at runtime.
+ */
+
+ long long offset;
+ int overflow;
+
+ if (!absolute_percpu) {
+ offset = table[i]->addr - relative_base;
+ overflow = (offset < 0 || offset > UINT_MAX);
+ } else if (symbol_absolute(table[i])) {
+ offset = table[i]->addr;
+ overflow = (offset < 0 || offset > INT_MAX);
+ } else {
+ offset = relative_base - table[i]->addr - 1;
+ overflow = (offset < INT_MIN || offset >= 0);
+ }
+ if (overflow) {
+ fprintf(stderr, "kallsyms failure: "
+ "%s symbol value %#llx out of range in relative mode\n",
+ symbol_absolute(table[i]) ? "absolute" : "relative",
+ table[i]->addr);
+ exit(EXIT_FAILURE);
+ }
+ expand_symbol(table[i]->sym, table[i]->len, buf);
+ printf("\t.long\t%#x /* %s */\n", (int)offset, buf);
+ } else if (!symbol_absolute(table[i])) {
+ output_address(table[i]->addr);
+ } else {
+ printf("\tPTR\t%#llx\n", table[i]->addr);
+ }
+ }
+ printf("\n");
+
+ if (base_relative) {
+ output_label("kallsyms_relative_base");
+ output_address(relative_base);
+ printf("\n");
+ }
+
+ sort_symbols_by_name();
+ output_label("kallsyms_seqs_of_names");
+ for (i = 0; i < table_cnt; i++)
+ printf("\t.byte 0x%02x, 0x%02x, 0x%02x\n",
+ (unsigned char)(table[i]->seq >> 16),
+ (unsigned char)(table[i]->seq >> 8),
+ (unsigned char)(table[i]->seq >> 0));
+ printf("\n");
}