[PATCH] D62364: llvm-objcopy: Implement --extract-partition and --extract-main-partition.

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 23 20:07:36 PDT 2019


pcc created this revision.
pcc added reviewers: rupprecht, alexshap, jakehehrlich, jhenderson.
Herald added subscribers: MaskRay, arichardson, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.

This implements the functionality described in Partitions.rst in D60242 <https://reviews.llvm.org/D60242>
(eventually https://lld.llvm.org/Partitions.html). It works as follows:

- Reads the section headers using the ELF header at file offset 0;
- If extracting a loadable partition:
  - Finds the section containing the required partition ELF header by looking it up in the section table;
  - Reads the ELF and program headers from the section.
- If extracting the main partition:
  - Reads the ELF and program headers from file offset 0.
- Filters the section table according to which sections are in the program headers that it read:
  - If ParentSegment != nullptr or section is not SHF_ALLOC, then it goes in.
  - Sections containing partition ELF headers or program headers are excluded as there are no headers for these in ordinary ELF files.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62364

Files:
  llvm/test/tools/llvm-objcopy/ELF/Inputs/partitions.elf
  llvm/test/tools/llvm-objcopy/ELF/Inputs/partitions.elf.test
  llvm/test/tools/llvm-objcopy/ELF/partitions.test
  llvm/tools/llvm-objcopy/CopyConfig.cpp
  llvm/tools/llvm-objcopy/CopyConfig.h
  llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp
  llvm/tools/llvm-objcopy/ELF/Object.cpp
  llvm/tools/llvm-objcopy/ELF/Object.h
  llvm/tools/llvm-objcopy/ObjcopyOpts.td

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62364.201118.patch
Type: text/x-patch
Size: 25358 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190524/d6a85210/attachment.bin>


More information about the llvm-commits mailing list