[PATCH] D56554: [ELF] Add '-z nognustack' opt to suppress emitting PT_GNU_STACK
Rui Ueyama via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 10 15:56:16 PST 2019
ruiu added a comment.
In D56554#1353527 <https://reviews.llvm.org/D56554#1353527>, @krytarowski wrote:
> In D56554#1353513 <https://reviews.llvm.org/D56554#1353513>, @ruiu wrote:
>
> > In D56554#1353487 <https://reviews.llvm.org/D56554#1353487>, @krytarowski wrote:
> >
> > > In D56554#1353368 <https://reviews.llvm.org/D56554#1353368>, @ruiu wrote:
> > >
> > > > The absence of PT_GNU_STACK segment makes stack area executable on systems that recognizes PT_GNU_STACK segment. So, I think if `-z execstack` is specified, we should omit PT_GNU_STACK segment rather than adding it, which I think you guys want. If we do that, it seems `-z nognustack` is a redundant option. That option name is unfortunate (you don't really mean you want an executable stack area), but that's I think still better than adding an option that is very similar to an existing feature.
> > >
> > >
> > > If we are going to change the meaning of `-z execstack`, can we rename the option in lld? Probably to `-z gnustack` vs `-z nognustack`, probably there is no other use-case than RWX->RW protection change.
> >
> >
> > Both `-z execstack` and `-z noexecstack` are supported by GNU linkers, so we can't simply rename them. We might be able to define aliases to the options. But I'm not sure if we want it if the only reason to do so is aesthetic reason.
>
>
> For compat with GNU linkers we could disable it by default, and emit GNU stack only on demand.
>
> The current approach to enable GNU STACK is to inline a new segment definition in assembly. It's done this way in llvm projects too.
Right. In terms of which is the default, lld is not compatible with GNU. lld by default tries to disable executable stack (which is definitely a good thing to do today). GNU linkers tries to do something smarter which doesn't make much sense and more error-prone today. I think changing the default makes sense.
Defining an alias to `-z execstack` as `-z nognustack` is a different story. I'm not totally against doing it, and I see that the option name is somewhat confusing, but I'm actually curious if the alias is what you really want. If you pass `-z noexecstack` to lld, your command line still works for both lld and GNU ld. But if you define `-z nognustack` and pass that option to lld, your command line is no longer compatible with GNU. You would no longer be able to copy all arguments to lld to run it again with GNU ld by just copy-n-pasting, for example. Are you happy with that?
Repository:
rLLD LLVM Linker
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D56554/new/
https://reviews.llvm.org/D56554
More information about the cfe-commits
mailing list