[PATCH] D67090: [llvm-objcopy] Add a new file offset assignment algorithm and support --only-keep-debug

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 3 06:05:50 PDT 2019


jhenderson added a comment.

> preserve-segment-contents.test I'm not sure how to test this. They new layout algorithm no longer leaves holes in the file (the behavior matches GNU objcopy).

I don't see any update to this test. What are you planning on doing with it? We have deliberately decided to deviate from GNU objcopy's behaviour here, because there are many cases where we want to preserve the contents of data within a segment that aren't covered by sections. A good example is 0xcc padding introduced to conform to alignment rules, or linker script modifications. Another example is when --strip-sections has been run on an object, there are no more sections to cover the data, so the bytes need to be preserved.

A fairly major deliberate decision we've agreed on previously in llvm-objcopy is that the layout of sections within a segment is immutable, as is the majority of a program header's fields (p_offset being the only exception I can think of currently). The only thing that can be done is explicitly removing a section, which will cause the resultant hole to be filled with null bytes instead of the old data content. This is because it is impossible to fix up address references etc without effectively relinking the entire program, should sections be compacted within a segment.

I haven't yet looked at the detail of this change, but I wanted to make sure you are aware of these points. I think we can make exceptions to specific aspects of the rules outlined above to ensure certain switches function well, but I'd be reluctant to completely redo the layout algorithm to support such situations, unless the above rules are preserved.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D67090





More information about the llvm-commits mailing list