[PATCH] D101332: [llvm-obcopy] Keep ihex sections with same address

Ian McIntyre via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 26 15:52:42 PDT 2021


mciantyre created this revision.
Herald added a subscriber: emaste.
Herald added a reviewer: alexshap.
Herald added a reviewer: rupprecht.
Herald added a reviewer: jhenderson.
mciantyre requested review of this revision.
Herald added subscribers: llvm-commits, MaskRay.
Herald added a project: LLVM.

IHexWriter was evaluating a section's physical address when deciding
if that section should be written to an output. This approach does
not account for a zero-sized section that has the same physical
address as a sized section. The behavior varies from GNU objcopy,
and may result in a HEX file that does not include all sections.

See the updated test for a demonstration. We'd expect that the HEX
file would contain .data3 and disregard the empty section. Before
this patch, the IHexWriter would not write .data3, since it evaluates
sections in order, and .data3 has the same physical address as .empty.

This patch recommends that we share the Segment class' comparator with
IHexWriter. That comparator accounts for zero-sized sections with the
same address. The writer will disregard the empty section when writing
the HEX file, and we're left with the sized section in the output.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101332

Files:
  llvm/test/tools/llvm-objcopy/ELF/Inputs/ihex-elf-segments.yaml
  llvm/tools/llvm-objcopy/ELF/Object.cpp
  llvm/tools/llvm-objcopy/ELF/Object.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101332.340677.patch
Type: text/x-patch
Size: 3762 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210426/fb328fab/attachment.bin>


More information about the llvm-commits mailing list