Re: [PATCH v2 03/21] kallsyms: output binary data to speed output and kallsyms assembly

From: Markus Elfring

Date: Mon Sep 14 2026 - 16:19:25 EST



> +++ b/scripts/kallsyms.c

> @@ -413,26 +438,24 @@ static void write_src(void)
> /* Encode length with ULEB128. */
> if (table[i]->len <= 0x7F) {
> /* Most symbols use a single byte for the length. */
> - printf("\t.byte 0x%02x", table[i]->len);
> + fputc(table[i]->len, out_bin_file);
> off += table[i]->len + 1;
> } else {
> /* "Big" symbols use two bytes. */
> - printf("\t.byte 0x%02x, 0x%02x",
> - (table[i]->len & 0x7F) | 0x80,
> - (table[i]->len >> 7) & 0x7F);
> + fputc((table[i]->len & 0x7F) | 0x80, out_bin_file);
> + fputc((table[i]->len >> 7) & 0x7F, out_bin_file);
> off += table[i]->len + 2;
> }
> - for (k = 0; k < table[i]->len; k++)
> - printf(", 0x%02x", table[i]->sym[k]);
> + fwrite(table[i]->sym, 1, table[i]->len, out_bin_file);
>
> /*
> * Now that we wrote out the compressed symbol name, restore the
> - * original name and print it in the comment.
> + * original name for the comments below.
> */
> expand_symbol(table[i]->sym, table[i]->len, buf);
> strcpy((char *)table[i]->sym, buf);
> - printf("\t/* %s */\n", table[i]->sym);
> }
> + write_incbin(out_bin_name, bin_start, bin_pos(out_bin_file));
> printf(".size kallsyms_names, . - kallsyms_names\n");
> printf("\n");
>


I suggest to avoid return value ignorance a bit more.
https://cmu-sei.github.io/secure-coding-standards/sei-cert-c-coding-standard/rules/error-handling-err/err33-c/
https://cwe.mitre.org/data/definitions/252.html

Regards,
Markus