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

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 19 09:46:32 PDT 2019


pcc added inline comments.


================
Comment at: tools/llvm-objcopy/ELF/Object.cpp:783
+         Segment.Offset <= Section.OriginalOffset &&
+         Segment.Offset + Segment.MemSize >= Section.OriginalOffset + SecSize;
 }
----------------
evgeny777 wrote:
> jakehehrlich wrote:
> > We need to be *very* careful here. Can you explain why you did this?
> This patch introduces segment fixup procedure which works incorrectly without this change
> Besides that this change has some sense, because:
> 
> - Non-allocatable section can't be in segment
> - Using MemSize instead of FileSize seems correct, because some allocatable sections (like .bss) have file size of 0.
For sections such as bss, sh_offset can have an arbitrary value (because there is no file data), so this can end up returning the wrong result. To properly classify bss sections, sh_addr must be used as in D58426.


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

https://reviews.llvm.org/D59351





More information about the llvm-commits mailing list