[llvm] [llvm-objcopy] Add --gap-fill and --pad-to options (PR #65515)

via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 6 12:30:54 PDT 2023


quic-akaryaki wrote:

This is an implementation of section padding with a more limited scope than was attempted in https://reviews.llvm.org/D67689.
Only binary outputs are supported, but ELF and IHEX are not. The main motivation for taking this approach was to support the clear use case of building padded ROM images without figuring all the murky details of the general ELF case. 
After reviewing https://reviews.llvm.org/D67689, it seems the main problem was with how the section content is updated for padding. The SectionBase::OriginalData was modified, which is incorrect. However, I think the bigger problem is that there are multiple section types that represent their data differently (SectionBase::OriginalData, OwnedDataSection::Data, compressed sections, etc). In binutils, sections are represented uniformly and resizing them in one location is sufficient. I don't know if a similar simple solution is possible in llvm-objdump. Therefore, I think it would make sense to handle padding in the output stage. 
I think which approach is better going forward ultimately depends on whether section padding is a valuable use case for ELF and IHEX outputs. I am not aware of such use cases, but suggestions are welcome. Talking about ROM images, it is possible in some platforms to directly flash an ihex. However, since ihex contains addresses, it supports gaps naturally and does not have to store all the padding bytes. During the flashing, the gaps are skipped.



https://github.com/llvm/llvm-project/pull/65515


More information about the llvm-commits mailing list