strip --strip-unneeded adds back section symbols

Andrei Borzenkov arvidjaar@gmail.com
Fri Jan 29 06:13:00 GMT 2016


GRUB builds most of its code as loadable ELF modules. To reduce
run-time size they are passed through "strip --strip-unneeded" (we
also do some more mangling, full code is here [3]). Recently we added
build-time module verifier to catch possible problems in toolchains
output. After that we got bug report from FreeBSD user [1] that GRUB
build started to fail. It was traced to module verifier reporting
error for one specific module. One of checks is for non-empty symbol
table and this module [2] got empty table after strip. According to
user, this happened with both

elftoolchain r3223M
GNU binutils 2.17.50 [FreeBSD] 2007-07-03

This module is actually empty placeholder that does not have any code
and data and exists only for the custom section that lists module
dependencies.

I could verify this behavior after building 2.17 (binutils-2_17 tag) from GIT.

It appears that recent binutils (earliest version I have is 2.24)
unconditionally add back section symbols when copying sections. I
verified that filter_symbols() in strip actually removes everything
from source module, and symbol table reappears deep in call chain
initiated by copy_section(), where STT_SECTION is unconditionally
added for every present section.

Was this change intentional? Is there any standard that requires
presence of these symbols in every ELF object? Note that these symbols
passed filter as unneeded and as GRUB developer I would rather welcome
2.17 behavior that allows us to further reduce run-time image size.

Thank you!


[1] https://savannah.gnu.org/bugs/?46986
[2] https://savannah.gnu.org/bugs/download.php?file_id=36182
[3] http://git.savannah.gnu.org/cgit/grub.git/tree/grub-core/genmod.sh.in



More information about the Binutils mailing list