History

kallsyms: support "big" kernel symbols

Rust symbols can become quite long due to namespacing introduced by modules, types, traits, generics, etc. Increasing to 255 is not enough in some cases, therefore introduce longer lengths to the symbol table. In order to avoid increasing all lengths to 2 bytes (since most of them are small, including many Rust ones), use ULEB128 to keep smaller symbols in 1 byte, with the rest in 2 bytes.

Miguel Ojeda committed 5 years ago

Commit 73bbb941 parent 6e8c5bb2 files · +48 −7Browse files

Showing the changes to scripts (1 of 2 files). Show all

Unified · Split

scripts/kallsyms.c+26−3
@@ -487,12 +487,35 @@ static void write_src(void) · 486 unmodified lines
487487 if ((i & 0xFF) == 0)
488488 markers[i >> 8] = off;
489489
490− printf("\t.byte 0x%02x", table[i]->len);
490+ /* There cannot be any symbol of length zero. */
491+ if (table[i]->len == 0) {
492+ fprintf(stderr, "kallsyms failure: "
493+ "unexpected zero symbol length\n");
494+ exit(EXIT_FAILURE);
495+ }
496+
497+ /* Only lengths that fit in up-to-two-byte ULEB128 are supported. */
498+ if (table[i]->len > 0x3FFF) {
499+ fprintf(stderr, "kallsyms failure: "
500+ "unexpected huge symbol length\n");
501+ exit(EXIT_FAILURE);
502+ }
503+
504+ /* Encode length with ULEB128. */
505+ if (table[i]->len <= 0x7F) {
506+ /* Most symbols use a single byte for the length. */
507+ printf("\t.byte 0x%02x", table[i]->len);
508+ off += table[i]->len + 1;
509+ } else {
510+ /* "Big" symbols use two bytes. */
511+ printf("\t.byte 0x%02x, 0x%02x",
512+ (table[i]->len & 0x7F) | 0x80,
513+ (table[i]->len >> 7) & 0x7F);
514+ off += table[i]->len + 2;
515+ }
491516 for (k = 0; k < table[i]->len; k++)
492517 printf(", 0x%02x", table[i]->sym[k]);
493518 printf("\n");
494−
495− off += table[i]->len + 1;
496519 }
497520 printf("\n");
498521

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t