66 * of the GNU General Public License, incorporated herein by reference.
77 *
88 * Usage: kallsyms [--all-symbols] [--absolute-percpu]
9- * [--base-relative] [-- lto-clang] in.map > out.S
9+ * [--lto-clang] in.map > out.S
1010 *
1111 * Table compression uses all the unused char codes on the symbols and
1212 * maps these to the most used substrings (tokens). For instance, it might
@@ -63,7 +63,6 @@ static struct sym_entry **table;
6363static unsigned int table_size , table_cnt ;
6464static int all_symbols ;
6565static int absolute_percpu ;
66- static int base_relative ;
6766static int lto_clang ;
6867
6968static int token_profit [0x10000 ];
@@ -76,7 +75,7 @@ static unsigned char best_table_len[256];
7675static void usage (void )
7776{
7877 fprintf (stderr , "Usage: kallsyms [--all-symbols] [--absolute-percpu] "
79- "[--base-relative] [-- lto-clang] in.map > out.S\n" );
78+ "[--lto-clang] in.map > out.S\n" );
8079 exit (1 );
8180}
8281
@@ -491,54 +490,43 @@ static void write_src(void)
491490 printf ("\t.short\t%d\n" , best_idx [i ]);
492491 printf ("\n" );
493492
494- if (!base_relative )
495- output_label ("kallsyms_addresses" );
496- else
497- output_label ("kallsyms_offsets" );
493+ output_label ("kallsyms_offsets" );
498494
499495 for (i = 0 ; i < table_cnt ; i ++ ) {
500- if (base_relative ) {
501- /*
502- * Use the offset relative to the lowest value
503- * encountered of all relative symbols, and emit
504- * non-relocatable fixed offsets that will be fixed
505- * up at runtime.
506- */
496+ /*
497+ * Use the offset relative to the lowest value
498+ * encountered of all relative symbols, and emit
499+ * non-relocatable fixed offsets that will be fixed
500+ * up at runtime.
501+ */
507502
508- long long offset ;
509- int overflow ;
510-
511- if (!absolute_percpu ) {
512- offset = table [i ]-> addr - relative_base ;
513- overflow = (offset < 0 || offset > UINT_MAX );
514- } else if (symbol_absolute (table [i ])) {
515- offset = table [i ]-> addr ;
516- overflow = (offset < 0 || offset > INT_MAX );
517- } else {
518- offset = relative_base - table [i ]-> addr - 1 ;
519- overflow = (offset < INT_MIN || offset >= 0 );
520- }
521- if (overflow ) {
522- fprintf (stderr , "kallsyms failure: "
523- "%s symbol value %#llx out of range in relative mode\n" ,
524- symbol_absolute (table [i ]) ? "absolute" : "relative" ,
525- table [i ]-> addr );
526- exit (EXIT_FAILURE );
527- }
528- printf ("\t.long\t%#x /* %s */\n" , (int )offset , table [i ]-> sym );
529- } else if (!symbol_absolute (table [i ])) {
530- output_address (table [i ]-> addr );
503+ long long offset ;
504+ int overflow ;
505+
506+ if (!absolute_percpu ) {
507+ offset = table [i ]-> addr - relative_base ;
508+ overflow = (offset < 0 || offset > UINT_MAX );
509+ } else if (symbol_absolute (table [i ])) {
510+ offset = table [i ]-> addr ;
511+ overflow = (offset < 0 || offset > INT_MAX );
531512 } else {
532- printf ("\tPTR\t%#llx\n" , table [i ]-> addr );
513+ offset = relative_base - table [i ]-> addr - 1 ;
514+ overflow = (offset < INT_MIN || offset >= 0 );
515+ }
516+ if (overflow ) {
517+ fprintf (stderr , "kallsyms failure: "
518+ "%s symbol value %#llx out of range in relative mode\n" ,
519+ symbol_absolute (table [i ]) ? "absolute" : "relative" ,
520+ table [i ]-> addr );
521+ exit (EXIT_FAILURE );
533522 }
523+ printf ("\t.long\t%#x /* %s */\n" , (int )offset , table [i ]-> sym );
534524 }
535525 printf ("\n" );
536526
537- if (base_relative ) {
538- output_label ("kallsyms_relative_base" );
539- output_address (relative_base );
540- printf ("\n" );
541- }
527+ output_label ("kallsyms_relative_base" );
528+ output_address (relative_base );
529+ printf ("\n" );
542530
543531 if (lto_clang )
544532 for (i = 0 ; i < table_cnt ; i ++ )
@@ -820,7 +808,6 @@ int main(int argc, char **argv)
820808 static const struct option long_options [] = {
821809 {"all-symbols" , no_argument , & all_symbols , 1 },
822810 {"absolute-percpu" , no_argument , & absolute_percpu , 1 },
823- {"base-relative" , no_argument , & base_relative , 1 },
824811 {"lto-clang" , no_argument , & lto_clang , 1 },
825812 {},
826813 };
@@ -841,8 +828,7 @@ int main(int argc, char **argv)
841828 if (absolute_percpu )
842829 make_percpus_absolute ();
843830 sort_symbols ();
844- if (base_relative )
845- record_relative_base ();
831+ record_relative_base ();
846832 optimize_token_table ();
847833 write_src ();
848834
0 commit comments