This is needed to add a yaml test for D67689 to test 'llvm-objcopy --gap-fill'.
This has the following changes:
- 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.
- 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.
- Add a unit test for obj2yaml.