Bug 2104638

Summary: strip --strip-unneeded doesn't remove the build-id
Product: Red Hat Enterprise Linux 8 Reporter: Paulo Andrade <pandrade>
Component: binutilsAssignee: Nick Clifton <nickc>
binutils sub component: system-version QA Contact: qe-baseos-tools-bugs
Status: CLOSED NOTABUG Docs Contact:
Severity: medium    
Priority: unspecified CC: fweimer, mprchlik, ohudlick, sipoyare
Version: 8.2   
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-07-25 08:05:10 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Paulo Andrade 2022-07-06 18:45:17 UTC
From my understanding, this is due to ld merging comment sections,
and workarounds should be either pass --build-id=none to the linker,
or --remove-section=.note.gnu.build-id to strip.

  Can you please clarify if my assumption is incorrect, and the
build-id is expected to not be removed by strip-unneeded.

Comment 1 Nick Clifton 2022-07-07 10:49:52 UTC
(In reply to Paulo Andrade from comment #0)
Hi Paulo,

> From my understanding, this is due to ld merging comment sections,
> and workarounds should be either pass --build-id=none to the linker,
> or --remove-section=.note.gnu.build-id to strip.
> 
>   Can you please clarify if my assumption is incorrect, and the
> build-id is expected to not be removed by strip-unneeded.

It is not expected to be removed by strip-unneeded.  That option is 
intended to remove unneeded *symbols* as well as debug sections.  It
is not intended to remove sections which might be considered to be
of no use, eg because they are not loaded at runtime.  In particular
the option does not remove any ELF format NOTE sections, such as the
.note.gnu.build-id.

(The linker's merging of comment sections is unrelated to this issue).

Also, it is worth mentionining that the .note.gnu.build-id section
*is* needed in an executable binary.  At least in one where the debug
information has been moved into a separate debuginfo file.  In this
sceanario the build-id is also copied to the debuginfo file and it
can be used by tools which consume the debug information, eg gdb, to
verify that the debug info does indeeed apply to the binary to which
it is linked.  (And that the binary has not changed version since
the debug info was created).

The workarounds you mention should be effective, although I do wonder
why you want to use them.  The build-ids are small and do not impeed
the execution of a program, so why remove them ?

Does this explanation help ?

Cheers
  Nick

Comment 2 Nick Clifton 2022-07-25 08:05:10 UTC
I am going to close this BZ as I believe that I have answered the questions raised.  If there are any further points that need to be reviewed or considered, please reopen this BZ.

Comment 3 Paulo Andrade 2022-07-25 12:08:11 UTC
Thanks. The related customer support case had also been closed after your response.