[PATCH] D33964: [LLVM][llvm-objcopy] Added basic plumbing to get things started

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 10 02:30:12 PDT 2017


jhenderson added a comment.

Could you construct a test case that confirms the behaviour of nested segments, please? Something with a memory image like:

  | Segment 1                                                        |
  | Segment 2                               |
  | Progbits Section | gap | NOBITS section | gap | Progbits section |  



================
Comment at: test/tools/llvm-objcopy/hello-world.s:2
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+# RUN: ld.lld %t.o -o %t
+# RUN: llvm-objcopy %t %t2
----------------
I don't think this will work for many people, as LLD is not part of LLVM's main source code body, so people will be unable to run this test. That being said, I'm not sure how to work around this. Can yaml2obj help us here? (I'm not particularly familiar with that tool yet).


================
Comment at: tools/llvm-objcopy/Object.cpp:185
+      // We should respect interstitial gaps of allocated sections. We *must*
+      // maintain the memory image. This ensures that the current segment's
+      // memory image and file image match with the exception of NOBITS sections
----------------
I'd suggest changing the second and third sentence to something like:

"We *must* maintain the memory image so that addresses are preserved. As, with the exception of SHT_NOBITS sections at the end of segments, the memory image is a copy of the file image, we preserve the file image as well."

It explains why the file and memory image need to match, which may not be obvious to those who are unfamiliar with ELF.


Repository:
  rL LLVM

https://reviews.llvm.org/D33964





More information about the llvm-commits mailing list