Skip to content

Stop unnecessarily removing sections from the kernel binary#27

Open
pcc wants to merge 1 commit into
telent:mainfrom
pcc:fix-strip
Open

Stop unnecessarily removing sections from the kernel binary#27
pcc wants to merge 1 commit into
telent:mainfrom
pcc:fix-strip

Conversation

@pcc
Copy link
Copy Markdown
Contributor

@pcc pcc commented May 18, 2026

We just need -S here which removes non-SHF_ALLOC sections. SHF_ALLOC sections are generally required to be in the kernel image, and can't be removed (in the sense of shrinking the binary) by a tool like objcopy because that would alter the section layout which is fixed by the linker. objcopy was "removing" these sections by replacing them with zeros, so this wasn't reducing the size of the kernel anyway.

In particular, this command was removing the .notes section containing the build ID which is readable from userspace via /sys/kernel/notes and may be used for symbolization on the host.

We just need -S here which removes non-SHF_ALLOC sections. SHF_ALLOC
sections are generally required to be in the kernel image, and can't be
removed (in the sense of shrinking the binary) by a tool like objcopy
because that would alter the section layout which is fixed by the
linker. objcopy was "removing" these sections by replacing them with
zeros, so this wasn't reducing the size of the kernel anyway.

In particular, this command was removing the .notes section containing
the build ID which is readable from userspace via /sys/kernel/notes and
may be used for symbolization on the host.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant