[PATCH] D101332: [llvm-objcopy] Exclude empty sections in IHexWriter output

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 12 12:50:47 PDT 2021


MaskRay added inline comments.


================
Comment at: llvm/tools/llvm-objcopy/ELF/Object.cpp:180
+namespace internal {
+bool SectionCompare::operator()(const SectionBase *Lhs,
+                                const SectionBase *Rhs) const {
----------------
mciantyre wrote:
> evgeny777 wrote:
> > mciantyre wrote:
> > > evgeny777 wrote:
> > > > With this change you start using section offset/index instead of address for IHexWriter. Why? Is this something GNU objcopy does?
> > > I didn't consider the address- vs offset-ordering implications of this change. My goal was to share code, and I was hopeful that if it works for `Segment`, it might work here. See the discussion around James' previous remarks for ways to undo this.
> > > 
> > > I've so far treated GNU objcopy as a black box, and I'm not sure how it's generating HEX outputs.
> > Given that GNU objcopy creates ihex segments in sorted (by physical address) order, I have concerns about this change. ELF segment has designated `p_paddr` field, so section physical addresses can be of different order than section offsets. I don't know if (and how often) this happens in reality though.
> Reverted the comparator change. IHex sections are still ordered by physical address.
Unordered `p_paddr` can happen with `AT(addr)` in a linker script. I agree that GNU objcopy sorts sections by physical address for -O binary and -O ihex output.

Created D104186 for simplification.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101332/new/

https://reviews.llvm.org/D101332



More information about the llvm-commits mailing list