[PATCH] D49870: [llvm-objcopy] Add support for --rename-section flags from gnu objcopy

Jordan Rupprecht via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 30 14:40:01 PDT 2018


rupprecht marked 10 inline comments as done.
rupprecht added a comment.

In https://reviews.llvm.org/D49870#1179887, @jhenderson wrote:

> My main concern is still the interaction between these switches and existing flags. Specifically, I'm worried about what will happen if this is used on a section with lots of flags that cannot be controlled via this switch. A quick look at the spec shows that this will clear the following flags unconditionally: SHF_INFO_LINK, SHF_GROUP, SHF_TLS, SHF_COMPRESSED, and any OS/processor-specific flags. I haven't checked what GNU objcopy does, but in basically all of those, changing the flags could be bad, and have a negative impact on the ability to link the resultant object. Could you investigate what GNU does in each of these cases, and write tests to show the behaviour, please.


Here's what I've found from some basic testing of gnu objcopy:

- `SHF_ALLOC, SHF_WRITE, SHF_EXECINSTR, SHF_MERGE, SHF_STRINGS:` covered already, appear to always be cleared
- `SHF_INFO_LINK, SHF_OS_NONCONFORMING, SHF_TLS:` appear to be always cleared
- `SHF_COMPRESSED, SHF_EXCLUDE, SHF_GROUP, SHF_LINK_ORDER:` appear to be preserved
- CPU/processor dependent flags (e.g. `SHF_X86_64_LARGE`) are preserved

I added a mask so that preserved flags are never changed. It works for the current test cases, but I do plan to do more thorough testing (once this patch, and others, land) to see if this is really good enough.

> Also, I feel like we should have two versions of the basic test: one with a section with no flags, and the other with a section with all the flags, if possible, to show which get set, which get unset, and which get ignored. Perhaps this would be best achieved with two sections, one each of the two different flag sets outlined in the previous sentence, and the main test just runs objcopy/readobj/FileCheck twice or similar.

Done -- I couldn't figure out how to get the prefixes configured to have it all in one test case, so I split off the all-flags test into a separate test file.


Repository:
  rL LLVM

https://reviews.llvm.org/D49870





More information about the llvm-commits mailing list