[PATCH] D39021: [llvm-objcopy] Add support for --only-keep and the special way it interacts with -O binary

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 31 06:05:53 PDT 2017


jhenderson added a comment.

Without thinking about it too much, the way I'd expect -j and -O binary to work is for it to be identical to -O binary with --remove-section for every other section, complete with padding being used to preserve alignment and relative positions etc (quick experiments shows this to be the case with GNU objcopy). That being said, I see that GNU objcopy has some unexpected behaviour when emitting binary output - the second of a pair of kept sections was neither aligned as it was in the input, nor positioned at the same relative distance to the first section, even though it was in the same segment.

Tangentially related, I also see that we don't have any tests for what happens when you combine --remove-section etc with -O binary, and I doubt from my initial observation of GNU's behaviour that we match its behaviour. My initial instinct is therefore that the problem is with our binary output format, and that ultimately, we should be using the BinaryObject class in this case, after we've fixed it to match GNU's behaviour.



================
Comment at: test/tools/llvm-objcopy/basic-only-keep.test:2
+# RUN: yaml2obj %s > %t
+# RUN: llvm-objcopy -j=.test %t %t2
+# RUN: llvm-readobj -file-headers -sections %t2 | FileCheck %s
----------------
I've probably been inconsistent in requesting this for other switches in the past, but we should really test both aliases explicitly. A simple diff of the output when using -j and --only-keep would suffice for this.


Repository:
  rL LLVM

https://reviews.llvm.org/D39021





More information about the llvm-commits mailing list