This is the mail archive of the
mailing list for the binutils project.
strip --strip-unneeded adds back section symbols
- From: Andrei Borzenkov <arvidjaar at gmail dot com>
- To: binutils at sourceware dot org, The development of GNU GRUB <grub-devel at gnu dot org>
- Date: Fri, 29 Jan 2016 09:13:48 +0300
- Subject: strip --strip-unneeded adds back section symbols
- Authentication-results: sourceware.org; auth=none
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 ). Recently we added
build-time module verifier to catch possible problems in toolchains
output. After that we got bug report from FreeBSD user  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  got empty table after strip. According to
user, this happened with both
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
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.