[PATCH] D112116: [llvm-objcopy] Add --update-section

Leonard Chan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 20 11:18:56 PDT 2021


leonardchan added a comment.

In D112116#3074501 <https://reviews.llvm.org/D112116#3074501>, @jhenderson wrote:

> High-level question: does GNU objcopy change the section size for sections that are updated?

Looks like it does. It will change the section size to whatever the size of the file was. If the section happens to be part of a segment, then that segment (FileSize/MemSize) will increase/decrease by however much larger/smaller the file is compared to the original section size. (Example: given an 8 byte section, then using a 6 byte file will decrease the section size to 6 and reduce the segment size by 2. Given a 10 byte file, the section size increases to 10 and the segment size increases by 2).

For this implementation, we just want to avoid the hassle of resizing a segment. Currently this patch throws an error for a file larger than the section, but kinda just "accepts" files smaller than the section (effectively doing a short memcpy only overwriting part of the section without resizing). If in the future, there's a demand for resizing sections/segments, then maybe it would be more desirable to update this patch such that it will only work on same-size files and throw an error if the file is smaller. This way, the behavior can still be defined down the line rather than saying it's just a short memcpy for now. Thoughts?

In the meantime, I'll address code comments that aren't too crucial to design.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112116/new/

https://reviews.llvm.org/D112116



More information about the llvm-commits mailing list