[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Stripping ELF .note and .comment sections?

ELF objects may contain sections .note and .comment, which are not needed.
Gcc puts compiler version to .comment and "01.01" to .note section. The
sections may be examined like this:

$ objdump --section=.note --full-contents /bin/cp

/bin/cp:     file format elf32-i386

Contents of section .note:
 0190 08000000 00000000 01000000 30312e30  ............01.0
 01a0 31000000 08000000 00000000 01000000  1...............
 01b0 30312e30 31000000 08000000 00000000  01.01...........

Same for .comment:
 0000 00474343 3a202847 4e552920 322e372e  .GCC: (GNU) 2.7.
 0010 322e3100 00474343 3a202847 4e552920  2.1..GCC: (GNU) 
 0020 322e372e 322e3300 00474343 3a202847 (G

These sections just take up disk space. They can be stripped with

$ objcopy --remove-section=.comment --remove-section=.note /usr/X11R6/bin/XF86_SVGA xf
$ du /usr/X11R6/bin/XF86_SVGA xf
2652    /usr/X11R6/bin/XF86_SVGA
2623    xf

29k disk space saved (1%). Savings depend on size of compile-time *.o files
vs their number, for example for cp that is 4%.

Compiler version information could be useful (to detect old compiler
output), but that is already in /usr/doc/foo/buildinfo.Debian and the
version in .comment does not specify entire Debian version.

BugReportWarning: If this is added to Policy (section 3.3.1?), inspecting
ELF sections is trivial to add to lintian. ;-)


To UNSUBSCRIBE, email to debian-policy-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org

Reply to: