This option removes non-global symbols from the binary.
I tried to follow GNU Binutils behavior as much as I could.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
| test/tools/llvm-objcopy/discard-all.test | ||
|---|---|---|
| 3 | Could you extend this test to check that -x works the same as --discard-all, please. | |
| 26 | Please define this symbol in a section. | |
| tools/llvm-objcopy/Opts.td | ||
| 76 | I know this is what gnu objcopy says, but non-global means not STB_GLOBAL to me, but it doesn't affect some other symbol types either (i.e. STB_WEAK, STT_FILE, STT_SECTION). Could you change the help text to match what it actually does, please. | |
Added various fixes.
| tools/llvm-objcopy/Opts.td | ||
|---|---|---|
| 76 | Yes, I know, this is a really bad help text. But I was out of ideas, as the real behavior of this option is really tricky... Any thoughts about it guys ? | |
| tools/llvm-objcopy/llvm-objcopy.cpp | ||
| 344 | Actually, as there is other options that will use this removeSymbols function, this choice was made to make it clearer. I was thinking about something like : if (Config.DiscardAll && Blabla...)
return true;
if (Config.DiscardLocals && Blabla..)
return true;
return false;I personally find it easier to read, even if this is not the most optimized way for doing it. What do you think ? | |
| tools/llvm-objcopy/Opts.td | ||
|---|---|---|
| 76 | How about "remove all local symbols except file and section symbols"? Similar to yours but feels a little less clunky. | |
Changed the option help text to make it more descriptive
| tools/llvm-objcopy/Opts.td | ||
|---|---|---|
| 76 | I like this one :) | |
| tools/llvm-objcopy/Opts.td | ||
|---|---|---|
| 76 | clang-format? | |
| tools/llvm-objcopy/Opts.td | ||
|---|---|---|
| 76 | Hmm.. Just ran it again, and it doesn't seem I missed indent :) | |
| tools/llvm-objcopy/Opts.td | ||
|---|---|---|
| 76 | Oh, wait, didn't realise this was Options.td! Sorry, never mind :) | |
| tools/llvm-objcopy/llvm-objcopy.cpp | ||
|---|---|---|
| 344 | i think having if (expression which evaluates to bool)
return true;
return falseis kinda strange because "if" and the second "return" can be eliminated (there is no actual branching here), thus i would prefer the less verbose form, clang-format (don't forget -style=llvm) will format the long expression in a nice way, so it's not a big issue. That's my preference, but i don't really insist. | |
| tools/llvm-objcopy/llvm-objcopy.cpp | ||
|---|---|---|
| 344 | Sure, I understand that we can eliminate the condition, of course. My point was more that I find it "nicer", and, as I mentioned, there will be other conditions for other options, and I truly think that it might be ugly to have only one big return statement. | |
Could you extend this test to check that -x works the same as --discard-all, please.