[llvm-objcopy] Make ihex writer similar to binary writer
authorFangrui Song <i@maskray.me>
Wed, 16 Jun 2021 17:08:20 +0000 (10:08 -0700)
committerFangrui Song <i@maskray.me>
Wed, 16 Jun 2021 17:08:20 +0000 (10:08 -0700)
commit1de18ad8d79eb328ad410fa60209e5dfa19752c8
treedb67bfd7889ee7824e56a7594e4b7efb16c993ec
parent2193347e72fad6a78ce4a96c8d89f9a43a028e79
[llvm-objcopy] Make ihex writer similar to binary writer

There is no need to differentiate whether `UseSegments` is true or
false. Unifying the cases makes the behavior closer to BinaryWriter.

This improves compatibility with objcopy because SHF_ALLOC sections not in
a PT_LOAD will not be skipped. Such cases are usually erroneous input, though.

Reviewed By: jhenderson

Differential Revision: https://reviews.llvm.org/D104186
llvm/test/tools/llvm-objcopy/ELF/Inputs/ihex-elf-segments.yaml
llvm/test/tools/llvm-objcopy/ELF/ihex-writer.test
llvm/tools/llvm-objcopy/ELF/Object.cpp