objcopy/strip of IR files and is_strip_input

H.J. Lu hjl.tools@gmail.com
Tue Aug 12 12:24:40 GMT 2025


On Mon, Aug 11, 2025 at 11:11 PM Alan Modra <amodra@gmail.com> wrote:
>
> On Mon, Aug 11, 2025 at 06:11:42PM -0700, H.J. Lu wrote:
> > On Mon, Aug 11, 2025 at 5:39 PM Alan Modra <amodra@gmail.com> wrote:
> > > Yes, I can see your comment are with commit c2729c37f10a
> > >   /* NB: Must keep .gnu.debuglto_* sections unless all GCC LTO sections
> > >      will be removed to avoid undefined references to symbols in GCC LTO
> > >      debug sections.  */
> > >   if (!lto_sections_removed)
> > >     find_section_list (".gnu.debuglto_*", true, SECTION_CONTEXT_KEEP);
> > >
> > > That doesn't make a great deal of sense to me.  Usually it is the
> > > other way around.  ie. symbols in a non-debug section are referenced
> > > by a debug section.  What symbols are being referenced in the
> > > .gnu.debuglto sections and from where?
> >
> > There are cross references between GCC code IR and GCC debug IR.
> > If GCC debug IR is removed while GCC code IR is kept, we get undefined
> > references to debug IR from code IR.
>
> Isn't that a gcc bug?  Particularly since older versions of strip and

A GCC feature?  Since LLVM puts all IR in a single section in fat IR
object, .llvm.lto, we can't only strip debug IR either.  IR removal should
all or nothing.

> objcopy will remove .gnu.debuglto_.debug_* with --strip-debug.
>

-- 
H.J.


More information about the Binutils mailing list