<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Clan7.0.1 does not apply -D_FORTIFY_SOURCE=2"
   href="https://bugs.llvm.org/show_bug.cgi?id=43114">43114</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clan7.0.1 does not apply -D_FORTIFY_SOURCE=2
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>7.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Other
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>release blocker
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>Vikas.Pandey2@harman.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>echo $CC
aarch64-poky-linux-musl-clang -mlittle-endian
--sysroot=/data/home/user-name/work/toolchain/install_clang/sysroots/aarch64-poky-linux-musl


main.c file content:
---------------------
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[]) {
    char buffer[8];
    strcpy(buffer, argv[0]);
    puts(buffer);
    return 0;
}


$CC -O2 -D_FORTIFY_SOURCE=2  main.c -o main.o
./checksec.sh -f main.o
RELRO              STACK CANARY      NX                         PIE            
RPATH             RUNPATH      FORTIFY     Fortified     Fortifiable     FILE
Partial RELRO   Canary found      NX enabled    PIE enabled     No RPATH   No
RUNPATH   Yes              0                    2                 main.o

root@b1:~/usb_drive# ./main.o
./main.o
Segmentation fault


Expected : ---
./main.o
*** buffer overflow detected ***: ./main.o terminated
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x7320f)[0x7f630b4a120f]
/lib/x86_64-linux-gnu/libc.so.6(__fortify_fail+0x37)[0x7f630b5244e7]
/lib/x86_64-linux-gnu/libc.so.6(+0xf4700)[0x7f630b522700]
./fortify_example[0x4005ba]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5)[0x7f630b44fb45]
./fortify_example[0x4004c9]
======= Memory map: ========
00400000-00401000 r-xp 00000000 fb:01 391109                            
/tmp/main.o
[... blah blah blah ...]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                 
[vsyscall]</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>