<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/121234>121234</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            lld silently ignores .note.GNU-stack section that requests exectuable stack
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            lld
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          emaste
      </td>
    </tr>
</table>

<pre>
    lld contains the comment
```
    // The GNU linker uses .note.GNU-stack section as a marker indicating
    // that the code in the object file does not expect that the stack is
    // executable (in terms of NX bit). If all input files have the marker,
    // the GNU linker adds a PT_GNU_STACK segment to tells the loader to
    // make the stack non-executable. Most object files have this section as
    // of 2017.
```

This is not entirely correct -- the presence of .note.GNU-stack does not necessarily indicate that the object file is compatible with non-exec stack. That is indeed the most common case, but the note actually indicates the object's expected stack protection -- it may have an X flag to indicate an object file that requires executable stack. See https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=278939 for the FreeBSD issue that prompted this.

```
Section Headers:
  [Nr] Name Type            Address          Off    Size   ES Flg Lk Inf Al
...
  [14] .note.GNU-stack   PROGBITS        0000000000000000 0077d8 000000 00   X  0 0  1
```

Executable stacks **should** be exceedingly rare and I have no issue with requiring an explicit `-z execstack`, but I think we should at least produce an error if there's a .note.GNU-stack that specifies exec stack and `-z execstack` is not specified. We should not silently produce broken output.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJx8VV9vqzYU_zTOy1EQMaQkD3lI25uu2pZ7taRa3yqDD-DF2MzHtE0__WSgaZJKQ5WgFP_O759rQaQqg7hi81s2v5-IztfWrbAR5HGSW3lcaS2hsMYLZQh8jVDYpkHjWbxmN_H4E68BABjfML6BfY3wsH0CrcwBHXSEBJGxHqOH7dOUvCgOQFh4ZQ0IAgGNcOFDZaQqhFemusTztfDjZImgTP9s83-w8FAqjSAtEhjrAd_b8PK0YJil6B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