[PATCH 1/6] ELF: Strip section header in ELF objects

H.J. Lu hjl.tools@gmail.com
Wed May 31 17:15:58 GMT 2023


On Tue, May 30, 2023 at 6:38 PM Alan Modra <amodra@gmail.com> wrote:
>
> On Tue, May 30, 2023 at 10:12:47AM -0700, H.J. Lu via Binutils wrote:
> > +@item --strip-sections
> > +Strip section header   This option is specific to ELF files.
> > +Implies @option{--strip-all} and @option{--merge-notes}.
>
> Debug info is inaccessible without section headers, and also
> non-dynamic relocs (ld --emit-relocs).  Should the section data be
> removed too?  Perhaps all non-alloc sections?

According to objcopy manual:

‘-S’
‘--strip-all’
     Do not copy relocation and symbol information from the source file.
     Also deletes debug sections.

It keeps:

  [24] .comment          PROGBITS        0000000000000000 003004
00005c 01  MS  0   0  1
  [25] .gnu.build.attributes NOTE            0000000000406008 003060
001724 00   L 12   0  4
  [26] .symtab           SYMTAB          0000000000000000 004788
0005a0 18     27  45  8
  [27] .strtab           STRTAB          0000000000000000 004d28
0004ed 00      0   0  1
  [28] .shstrtab         STRTAB          0000000000000000 005215
000122 00      0   0  1

I guess these sections can also be removed.

-- 
H.J.


More information about the Binutils mailing list