This is an archive of the discontinued LLVM Phabricator instance.

[obj2yaml] Dump ELF program headers
AbandonedPublic

Authored by asmith on Mar 20 2020, 7:09 PM.

Details

Summary

This is needed to add a yaml test for D67689 to test 'llvm-objcopy --gap-fill'.

This has the following changes:

  1. Introduce isSectionWithinPhdr in ELF.h. This extracts similar functionality from llvm-readobj/ELFDumper and is intended to work for llvm-readobj, obj2yaml and llvm-objcopy (to replace its sectionWithinSegement function). A major change is that we check the offset OR VMA to determine if a section is within the range of a program header. This is different from ELFDumper that checks both. All tests pass with this change.
  1. Dump elf program headers. The program header fields: offset/filesz/memsz are not optional. However for objects via yaml2obj that lack a section to segment mapping these fields are not dumped.
  1. Add a unit test for obj2yaml.

Diff Detail

Event Timeline

asmith created this revision.Mar 20 2020, 7:09 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 20 2020, 7:09 PM
asmith edited the summary of this revision. (Show Details)Mar 20 2020, 7:10 PM

@grimar put up a patch for review D75342

isSectionWithinPhdr in this patch is more complex. I don't think we need so many checks. (binutils-gdb BFD does have many checks but I suspect many are years of legacy cruft. We can simplify that a lot starting from scratch.)

asmith abandoned this revision.Mar 31 2020, 7:58 PM