title: ld.exe: unrecognized option '-z'
body: <p>I followed this <a href="https://dhavalkapil.com/blogs/Buffer-Overflow-Exploit/" rel="nofollow noreferrer">Buffer Overflow Exploit tutorial</a> and wrote a small application to compile with gcc in my <code>mingw32.exe</code>. However, when I did, I got the following errors:</p>
  <pre><code>Liu.D.H@DESKTOP-KA8TQF4 MINGW32 ~
  $ gcc vuln.c -o vuln -fno-stack-protector -m32 -z execstack
  C:/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/7.3.0/../../../../i686-w64-mingw32/bin/ld.exe: unrecognized option '-z'
  C:/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/7.3.0/../../../../i686-w64-mingw32/bin/ld.exe: use the --help option for usage information
  collect2.exe: error: ld returned 1 exit status
  
  Liu.D.H@DESKTOP-KA8TQF4 MINGW32 ~
  $ gcc -c vuln.c -o vuln -fno-stack-protector -m32 -z execstack
  
  Liu.D.H@DESKTOP-KA8TQF4 MINGW32 ~
  $ ld -z execstack vuln.o -o vuln
  C:\msys32\mingw32\bin\ld.exe: unrecognized option '-z'
  C:\msys32\mingw32\bin\ld.exe: use the --help option for usage information
  
  Liu.D.H@DESKTOP-KA8TQF4 MINGW32 ~
  $ ld -v
  GNU ld (GNU Binutils) 2.30
  
  Liu.D.H@DESKTOP-KA8TQF4 MINGW32 ~
  $ C:/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/7.3.0/../../../../i686-w64-mingw32/bin/ld.exe -v
  GNU ld (GNU Binutils) 2.30
  
  Liu.D.H@DESKTOP-KA8TQF4 MINGW32 ~
  $
  
  </code></pre>
  <p>I could find the <code>execstack</code> options in <code>man ld</code> and the version matched above.</p>