[PATCH] D46896: [llvm-objcopy] Add --strip-unneeded option

Paul Semel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 18 01:18:56 PDT 2018


paulsemel added a comment.

In https://reviews.llvm.org/D46896#1104127, @jakehehrlich wrote:

> In https://reviews.llvm.org/D46896#1102723, @jhenderson wrote:
>
> > I'm happy to defer to @jakehehrlich's preferences here, but FWIW, I think GNU objcopy's behaviour is actually the wrong way around regarding the Global/Weak symbols: if you strip a defined symbol from an ET_REL ELF that isn't referenced within that ELF, the file can still be used in a link, you just can't reference anything that wasn't already referenced by that object file. Stripping symbols from ET_DYN/EXEC is okay, as it should have zero impact on the runtime behaviour (although debugging etc might not be as trivial). Anything that requires symbols at runtime should be using dynamic relocations and dynamic symbols, which this behaviour won't touch.
> >
> > I think we need to be slightly wary of using ET_* types directly, because it will make it hard for vendors to add their own ET_* types to the list of things that should/should not be affected by some behaviour. If we do decide to go down the route of matching objcopy's behaviour here and therefore need to distinguish between relocatable and executable types, I'd suggest adding helper functions to wrap them, and call those instead of testing e_type directly.
>
>
> First off, I think I agree with you on ET_* and the more I think about it the more I agree. I think given a) You're preference for not using ET_ and b) my initial and now growing preference we should not use ET_. @paulsemel please do not use ET_* checks in this way (if at all really)
>
> Second. I think I disagree with removing defined symbols using --strip-uneeded. I interpret "uneeded" as "100% not needed in any possible link" not "uneeded to fully link this". For instance a library might define lots of functions that it doesn't call and are only meant to be used by other bits of code. Such symbols are quite common and shouldn't be removed by --strip-uneeded IMO. I'm happy for --strip-uneeded-symbol to behave the way you describe however.


Ok, so we should keep defined symbols in any way, regardless the ELF type ? That's sounds really weird for me, as there is plenty of way we want to remove them (especially in ET_EXEC), but we can go for it :)


Repository:
  rL LLVM

https://reviews.llvm.org/D46896





More information about the llvm-commits mailing list