This option removes non-global symbols from the binary.
I tried to follow GNU Binutils behavior as much as I could.
Could you extend this test to check that -x works the same as --discard-all, please.
Please define this symbol in a section.
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.
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 ?
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 ?
i think having
if (expression which evaluates to bool) return true; return false
is 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.
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.