public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v4 0/7] ELF: Strip section header in ELF objects
@ 2023-06-06 17:58 H.J. Lu
  2023-06-06 17:58 ` [PATCH v4 1/7] " H.J. Lu
                   ` (6 more replies)
  0 siblings, 7 replies; 17+ messages in thread
From: H.J. Lu @ 2023-06-06 17:58 UTC (permalink / raw)
  To: binutils; +Cc: Alan Modra, Florian Weimer, Kaylee Blake

Changes in v4:

1. Disallow -r with -z nosectionheader.
2. Add return after fail in no-section-header.exp.
3. Call free without checking null pointer.
4. Remove dead code.
5. Remove excess parentheses.

Changes in v3:

1. Fix indentation.
2. Update tests to allow extra symbols.
3. Limit ld-elf/hash-2.d to targets with shared library support.

Changes in v2:

1. Rename the objcopy and strip option to --strip-section-headers.
2. Also strip non-alloc sections.

Section header isn't mandatory on ELF executable nor shared library.
This patch set adds a new linker option, -z nosectionheader, to omit ELF
section header, a new objcopy and strip option, --strip-section-headers,
to remove ELF section header.

H.J. Lu (5):
  ELF: Discard non-alloc sections without section header
  bfd: Improve nm and objdump without section header
  binutils: Add a --strip-section-headers test
  ld: Add tests for -z nosectionheader and --strip-section-headers
  ld: Add -z nosectionheader test to bootstrap.exp

Kaylee Blake (2):
  ELF: Strip section header in ELF objects
  ld: Add simple tests for -z nosectionheader

 bfd/bfd-in2.h                                 |   6 +-
 bfd/bfd.c                                     |   6 +-
 bfd/elf-bfd.h                                 |  15 +
 bfd/elf.c                                     | 742 ++++++++++++++++--
 bfd/elfcode.h                                 |  91 ++-
 bfd/elflink.c                                 |  12 +
 bfd/elfxx-target.h                            |   4 +-
 binutils/NEWS                                 |   5 +-
 binutils/doc/binutils.texi                    |  10 +
 binutils/objcopy.c                            |  38 +-
 binutils/testsuite/binutils-all/objcopy.exp   |   5 +
 .../binutils-all/strip-section-headers-1.d    |   5 +
 ld/NEWS                                       |   3 +
 ld/emultempl/elf.em                           |   4 +
 ld/ld.h                                       |   3 +
 ld/ld.texi                                    |   5 +
 ld/ldlang.c                                   |   8 +
 ld/lexsup.c                                   |  13 +
 ld/testsuite/ld-bootstrap/bootstrap.exp       |  10 +-
 ld/testsuite/ld-elf/hash-2.d                  |  11 +
 ld/testsuite/ld-elf/no-section-header.exp     | 371 +++++++++
 ld/testsuite/ld-elf/nosectionheader-1.d       |  14 +
 ld/testsuite/ld-elf/nosectionheader-2.d       |   4 +
 ld/testsuite/ld-elf/pr25617-1-no-sec-hdr.nd   |   3 +
 ld/testsuite/ld-elf/pr25617-1-no-sec-hdr.rd   |  20 +
 .../ld-elf/pr25617-1-static-no-sec-hdr.rd     |  12 +
 ld/testsuite/ld-elf/pr25617-1a-no-sec-hdr.nd  |   3 +
 ld/testsuite/ld-elf/pr25617-1a-no-sec-hdr.rd  |  20 +
 ld/testsuite/ld-elf/pr25617-1a-sec-hdr.rd     |  19 +
 ld/testsuite/ld-elf/pr25617-1a.c              |  11 +
 ld/testsuite/ld-elf/pr25617-1b.c              |  15 +
 ld/testsuite/ld-elf/start-noheader.rd         |  11 +
 .../ld-elf/start-shared-noheader-gnu.rd       |  26 +
 .../ld-elf/start-shared-noheader-sysv.rd      |  26 +
 ld/testsuite/ld-elf/start-shared-noheader.nd  |  11 +
 35 files changed, 1475 insertions(+), 87 deletions(-)
 create mode 100644 binutils/testsuite/binutils-all/strip-section-headers-1.d
 create mode 100644 ld/testsuite/ld-elf/hash-2.d
 create mode 100644 ld/testsuite/ld-elf/no-section-header.exp
 create mode 100644 ld/testsuite/ld-elf/nosectionheader-1.d
 create mode 100644 ld/testsuite/ld-elf/nosectionheader-2.d
 create mode 100644 ld/testsuite/ld-elf/pr25617-1-no-sec-hdr.nd
 create mode 100644 ld/testsuite/ld-elf/pr25617-1-no-sec-hdr.rd
 create mode 100644 ld/testsuite/ld-elf/pr25617-1-static-no-sec-hdr.rd
 create mode 100644 ld/testsuite/ld-elf/pr25617-1a-no-sec-hdr.nd
 create mode 100644 ld/testsuite/ld-elf/pr25617-1a-no-sec-hdr.rd
 create mode 100644 ld/testsuite/ld-elf/pr25617-1a-sec-hdr.rd
 create mode 100644 ld/testsuite/ld-elf/pr25617-1a.c
 create mode 100644 ld/testsuite/ld-elf/pr25617-1b.c
 create mode 100644 ld/testsuite/ld-elf/start-noheader.rd
 create mode 100644 ld/testsuite/ld-elf/start-shared-noheader-gnu.rd
 create mode 100644 ld/testsuite/ld-elf/start-shared-noheader-sysv.rd
 create mode 100644 ld/testsuite/ld-elf/start-shared-noheader.nd

-- 
2.40.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2023-07-19  6:21 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-06 17:58 [PATCH v4 0/7] ELF: Strip section header in ELF objects H.J. Lu
2023-06-06 17:58 ` [PATCH v4 1/7] " H.J. Lu
2023-06-06 17:58 ` [PATCH v4 2/7] ELF: Discard non-alloc sections without section header H.J. Lu
2023-06-06 17:58 ` [PATCH v4 3/7] bfd: Improve nm and objdump " H.J. Lu
2023-07-01  2:12   ` Simon Marchi
2023-07-07 15:26     ` H.J. Lu
2023-07-10  3:30       ` Simon Marchi
2023-07-13  5:02         ` Alan Modra
2023-07-13  5:34           ` Fangrui Song
2023-07-13 21:58           ` Mark Wielaard
2023-07-19  6:21             ` Alan Modra
2023-06-06 17:58 ` [PATCH v4 4/7] ld: Add simple tests for -z nosectionheader H.J. Lu
2023-06-06 17:58 ` [PATCH v4 5/7] binutils: Add a --strip-section-headers test H.J. Lu
2023-06-06 17:58 ` [PATCH v4 6/7] ld: Add tests for -z nosectionheader and --strip-section-headers H.J. Lu
2023-06-29 20:56   ` H.J. Lu
2023-07-06  1:27     ` Alan Modra
2023-06-06 17:58 ` [PATCH v4 7/7] ld: Add -z nosectionheader test to bootstrap.exp H.J. Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).