@@ -473,33 +473,31 @@ static void write_src(void)
473
473
if ((i & 0xFF ) == 0 )
474
474
markers [i >> 8 ] = off ;
475
475
476
- /*
477
- * There cannot be any symbol of length zero -- we use that
478
- * to mark a "big" symbol (and it doesn't make sense anyway).
479
- */
476
+ /* There cannot be any symbol of length zero. */
480
477
if (table [i ]-> len == 0 ) {
481
478
fprintf (stderr , "kallsyms failure: "
482
479
"unexpected zero symbol length\n" );
483
480
exit (EXIT_FAILURE );
484
481
}
485
482
486
- /* Only lengths that fit in up to two bytes are supported. */
487
- if (table [i ]-> len > 0xFFFF ) {
483
+ /* Only lengths that fit in up-to- two-byte ULEB128 are supported. */
484
+ if (table [i ]-> len > 0x3FFF ) {
488
485
fprintf (stderr , "kallsyms failure: "
489
486
"unexpected huge symbol length\n" );
490
487
exit (EXIT_FAILURE );
491
488
}
492
489
493
- if (table [i ]-> len <= 0xFF ) {
490
+ /* Encode length with ULEB128. */
491
+ if (table [i ]-> len <= 0x7F ) {
494
492
/* Most symbols use a single byte for the length. */
495
493
printf ("\t.byte 0x%02x" , table [i ]-> len );
496
494
off += table [i ]-> len + 1 ;
497
495
} else {
498
- /* "Big" symbols use a zero and then two bytes. */
499
- printf ("\t.byte 0x00, 0x%02x, 0x%02x" ,
500
- (table [i ]-> len >> 8 ) & 0xFF ,
501
- table [i ]-> len & 0xFF );
502
- off += table [i ]-> len + 3 ;
496
+ /* "Big" symbols use two bytes. */
497
+ printf ("\t.byte 0x%02x, 0x%02x" ,
498
+ (table [i ]-> len & 0x7F ) | 0x80 ,
499
+ ( table [i ]-> len >> 7 ) & 0x7F );
500
+ off += table [i ]-> len + 2 ;
503
501
}
504
502
for (k = 0 ; k < table [i ]-> len ; k ++ )
505
503
printf (", 0x%02x" , table [i ]-> sym [k ]);
0 commit comments