This option prevent from removing file symbols while removing symbols.
This patch relies on this one (not merged yet) : https://reviews.llvm.org/D46819
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Other than explicitly stripping the file symbol, is there any way of actually removing such symbols currently? It seems like adding a switch just to prevent you doing something you asked for is a bit superfluous.
Do you have a specific use-case at the moment?
test/tools/llvm-objcopy/keep-file-symbols-remove-section.test | ||
---|---|---|
1 ↗ | (On Diff #146592) | I don't think you need this test, since the file symbol is by definition not in a section. |
Well, --strip-unneeded can trigger the file symbols removal. Anyway, for the moment, I stopped implementing it because I have some problems with the error messages we are issuing for the symbol removal.
In all cases, I truly think that this way is the way to prevent from file symbol removal (particularly for the --strip-unneeded option). Maybe I can just remove the section removal test and land it like this, waiting for someone (maybe me) to implement --strip-unneeded and to add a better test case ?
What do you think about it ?
Code change looks fine, but could you add a test to show that --keep-file-symbols trumps --strip-symbol, assuming that is the desired behaviour (double-check against GNU, I suggest here).
Added test for --strip-symbol and --keep-file-symbols.
This follows the same behavior as GNU objcopy
LGTM, with the suggested test change. The bug needs fixing separately.
test/tools/llvm-objcopy/keep-file-symbols.test | ||
---|---|---|
28–35 ↗ | (On Diff #148598) | You only need two symbols - one file symbol and one non-file symbol. |
37–48 ↗ | (On Diff #148598) | Wait, shouldn't there be a null symbol here? Null symbols are required... That's probably a bug unrelated to your change, but should be fixed ASAP. |
test/tools/llvm-objcopy/keep-file-symbols.test | ||
---|---|---|
28–35 ↗ | (On Diff #148598) | You're totally right. I'll remove those :) |
37–48 ↗ | (On Diff #148598) | Well, yes, I added a TODO for this in my previous patch, about this dummy symbol. We shouldn't pass it to the removeSymbols function as @jakehehrlich stated :) |
test/tools/llvm-objcopy/keep-file-symbols.test | ||
---|---|---|
37–48 ↗ | (On Diff #148598) | If you don't mind. What we currently generate is actually illegal ELF. I was under the impression that the TODO was for coming up with a better way for handling the null symbol, and I assumed that it wasn't being stripped (unless the whole table was), hence why I didn't comment on it before. |
Added James' suggestions.
test/tools/llvm-objcopy/keep-file-symbols.test | ||
---|---|---|
37–48 ↗ | (On Diff #148598) | Well, you're actually right. The TODO was for this reason, definitely. But if we handle it the way we planned to handle it, this will also fix this issue :) |