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

Paul Semel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 16 07:43:53 PDT 2018


paulsemel added a comment.

In https://reviews.llvm.org/D46896#1101231, @jhenderson wrote:

> In https://reviews.llvm.org/D46896#1101102, @paulsemel wrote:
>
> > In https://reviews.llvm.org/D46896#1101079, @jhenderson wrote:
> >
> > > In https://reviews.llvm.org/D46896#1100897, @paulsemel wrote:
> > >
> > > > I'm sorry guys, but I think I am missing something. Indeed, if I used the ELF type and not something else, it's because objcopy is keeping global and weak symbols (except for undefined ones) for relocatable files.
> > > >  This is actually done even if the symbol is not referenced by a relocation. That's why I don't really see what I can do with `SHF_ALLOC`.
> > > >  Can you elaborate on this one ?
> > >
> > >
> > > Sorry, I probably wasn't clear enough. You have a check for the object type in the change you are proposing. My point was that it is unnecessary. There shouldn't be a difference in llvm-objcopy's behaviour in this case. The code to mark a symbol as needed is only called for instances of `RelocationSection`, which deals with static relocations. Such relocations only appear typically in ET_REL inputs, but it should be harmless to modify them regardless of input type.
> >
> >
> > No it's ok :)
> >  The fact is that `objcopy` cares about those "static relocations". Or at least it was the case when I tested for those ones.
> >  So what you say is that we should just strip those symbols ? It's really weird, because it would lead to a broken relocatable file..
>
>
> No, I didn't say that at all, sorry. --strip-unneeded should, by my understanding, remove symbols that are not the target of a static relocation (this is what you have implemented). I don't think you need to check the file type.


Ok, so for this one, we do not follow `objcopy` behavior ?


Repository:
  rL LLVM

https://reviews.llvm.org/D46896





More information about the llvm-commits mailing list