Bug 2104638 - strip --strip-unneeded doesn't remove the build-id
Summary: strip --strip-unneeded doesn't remove the build-id
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: binutils
Version: 8.2
Hardware: All
OS: Linux
unspecified
medium
Target Milestone: rc
: ---
Assignee: Nick Clifton
QA Contact: qe-baseos-tools-bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-07-06 18:45 UTC by Paulo Andrade
Modified: 2023-07-18 14:19 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-07-25 08:05:10 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-127137 0 None None None 2022-07-06 18:48:19 UTC

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.


Note You need to log in before you can comment on or make changes to this bug.