[PATCH] D132541: [llvm-objcopy] Introduce 'ihex-flat' output format.

Simon Tatham via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 24 02:45:06 PDT 2022


simon_tatham created this revision.
simon_tatham added reviewers: evgeny777, rupprecht, jhenderson.
Herald added subscribers: pengfei, abrachet, hiraditya, emaste.
Herald added a reviewer: alexander-shaposhnikov.
Herald added a project: All.
simon_tatham requested review of this revision.
Herald added subscribers: llvm-commits, MaskRay.
Herald added a project: LLVM.

Currently, if you use llvm-objcopy to translate an ELF image into
'ihex' format, the input ELF file's entry point address will be
converted into x86-16 segment:offset style if it's less than 1MB, and
the same happens to addresses of data records. The separate record
types for a flat 32-bit address space are not used unless an address
is too big for the segment:offset style.

This is awkward for users consuming the file, who may find they need
to understand both formats of start address and both formats of data
address record. And it doesn't have any relevance to any of LLVM's
target architectures, since we support x86-32 but not x86-16. So users
wanting to write the simplest possible ihex consumer would prefer the
producer to emit the 32-bit record types unconditionally.

I haven't changed the existing format in this commit, on the
assumption that exactly matching the behavior of GNU objdump is a
useful property. Instead, I've added a new format name "ihex-flat"
alongside the existing "ihex", and made the format changes conditional
on that.

(For symmetry, the new name is also accepted on input, but it's
treated exactly like "ihex", because there's no reason not to accept
both types of address record.)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D132541

Files:
  llvm/include/llvm/ObjCopy/CommonConfig.h
  llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp
  llvm/lib/ObjCopy/ELF/ELFObject.cpp
  llvm/lib/ObjCopy/ELF/ELFObject.h
  llvm/test/tools/llvm-objcopy/ELF/ihex-reader.test
  llvm/test/tools/llvm-objcopy/ELF/ihex-writer.test
  llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
  llvm/tools/llvm-objcopy/llvm-objcopy.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132541.455117.patch
Type: text/x-patch
Size: 11358 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220824/f72a7206/attachment.bin>


More information about the llvm-commits mailing list