[PATCH] D56683: [llvm-objcopy] [COFF] Add support for removing sections
Martin Storsjö via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 14 14:47:37 PST 2019
mstorsjo created this revision.
mstorsjo added reviewers: jhenderson, alexshap, jakehehrlich, rnk, rupprecht.
This is designed similarly to removing symbols; each section gets a unique id, which is used to map symbols to sections through removals/additions, which is then mapped back to proper sequential indices when writing out.
Compared to removal of symbols, section definition symbols add a bit of extra code, as they contain section numbers in the section aux data as well. For associative comdat symbols, that needs to be updated just like the normal section number.
I've tried to keep the removal behaviour sensible, that is: When removing a section, all symbols pointing to that section is removed. (This matches GNU objcopy.) If there were relocations against those symbols in a section that is kept, writing errors out. (GNU objcopy on the other hand will just leave the relocation pointing at any random symbol that is left, but I prefer erroring out in this case.)
If the target section of a associative comdat is removed, the associative comdat can also be removed automatically (as nothing would include it). Nothing that really is used in the wild I guess, but makes the case of manually removing a specific section more convenient.
Repository:
rL LLVM
https://reviews.llvm.org/D56683
Files:
test/tools/llvm-objcopy/COFF/remove-section.yaml
tools/llvm-objcopy/COFF/COFFObjcopy.cpp
tools/llvm-objcopy/COFF/Object.cpp
tools/llvm-objcopy/COFF/Object.h
tools/llvm-objcopy/COFF/Reader.cpp
tools/llvm-objcopy/COFF/Writer.cpp
tools/llvm-objcopy/COFF/Writer.h
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56683.181654.patch
Type: text/x-patch
Size: 24531 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190114/c3c0da84/attachment.bin>
More information about the llvm-commits
mailing list