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

    <tr>
        <th>Summary</th>
        <td>
            Sample code segfaults in clang, but not in gcc
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

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

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

<pre>
    Consider following `1.c`:

```c
__attribute__((noreturn, naked))
void _start() {
 asm volatile(
        "mov $60, %%rax\n"
        "mov $42, %%rdi\n"
        "syscall"
        ::: "%rax", "%rdi"
 );
}
```

Compiling it under `gcc` has the program work as intended, but not with `clang`:

```
> rm a ; gcc 1.c -o a -s -nostdlib -static -fno-ident -fno-asynchronous-unwind-tables -Wl,--build-id=none -z max-page-size=0x4 ; ./a ; echo $?
42
> rm a ; clang 1.c -o a -s -nostdlib -static -fno-ident -fno-asynchronous-unwind-tables -Wl,--build-id=none -z max-page-size=0x4 ; ./a ; echo $?
Segmentation fault
139
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzMU8GO4yoQ_Jr2pUWEG9tjH3zwZF5-YA_vGGEgNm8xRIAzM_v1TySRdrSaD1irJSO7uqguCpmSXbwxI7Sv0L5Vcs9riKMWIsu1moP-HI_BJ6tNxEtwLrxbvyB0vD4o6DiICfi9Ov4oBXw6n2XO0c57NuczUA_U-xBN3qMHOqKXP40GGkrx6RasxnPKMuY7dEB4eQU-oUwb3oKT2TpT_vAJnw8QbeGGQE3HCyFQC9RG-QHt0QPRt9CGvkC1_RaaPpOSzv3xXUyPKojnPvQkoyfZo6EMJIp2eHn76snDomPYrtYV-2zG3RdHoeOLKj7iKhPm1eA1hiXKDd9D_IkyofXZeF3sOuK8Z_Qh47vNa2lVTvrl20Moa_EPxg0lgnjFRSmsDwpZQIksIfMhZe3sjCxlma1CdvGBWW18fixl-vRqjcGHPbHdv1uvWZazMwnZvw7oyNi8W6eZ1SDefPAG2S_c5Ae7ysWwZH8ZEG_8o7nvfwA6PZQYtYZyGiBOwKeG_lR6n-mv1PrDLJvxRUHweJG7y8CnWgxffa_0KPQgBlmZsX5peN0MnIZqHfXQ6f5ihlmrWg0D79qalH6ZiYuuv3SmsiNxajlRXTeNaIaDbJRo6r67aNG3F5LQcLNJ6w7O3bZDiEtlU9rNWFNf97xycjYu3W8x0SMYROVCx7E0sHlfEjTc2ZTTb4psszPjD7ldnUEVtMFklvtsJXn45PmdPOtLlKo9unHN-ZpK8ugEdFpsXvf5oMIGdCr0zxe7xvCfURnodJebgE5PxbeR_g8AAP__9N5STQ">