Page MenuHomePhabricator

Always add a .note.GNU-stack section if -r.
ClosedPublic

Authored by ruiu on Aug 28 2018, 8:48 PM.

Details

Summary

With this patch, lld creates a .note.GNU_stack and adds it to an
output file if it is creating a re-linkable object file (i.e. if -r
is given). If we don't do this, and if you use GNU linkers as a final
linker, they create an executable whose stack area is executable,
which is considered pretty bad these days.

Diff Detail

Repository
rL LLVM

Event Timeline

ruiu created this revision.Aug 28 2018, 8:48 PM
rprichard added inline comments.Aug 28 2018, 9:03 PM
lld/ELF/SyntheticSections.h
142 ↗(On Diff #163008)

I think we want to pass SHF_EXECINSTR as the first SyntheticSection param if Config->ZExecstack is set?

ruiu added a comment.Aug 28 2018, 10:30 PM

It's intentionally omitted, as I think if you want an exectuable stack, you should explicitly pass -z execstack to the final linker.

rprichard accepted this revision.Aug 29 2018, 12:15 AM

It's intentionally omitted, as I think if you want an exectuable stack, you should explicitly pass -z execstack to the final linker.

Ok, that sounds reasonable.

The change looks OK to me.

This revision is now accepted and ready to land.Aug 29 2018, 12:15 AM
This revision was automatically updated to reflect the committed changes.