Issue 124238
Summary ASan breaks __seg_gs
Labels new issue
Assignees
Reporter glandium
    Take this source:
```
#include <cstdint>
void test(uintptr_t addr) {
    __builtin_memcpy((void __seg_gs*)addr, "x", 1);
}
```
It compiles to
```
test(unsigned long):
        push    rbp
        mov     rbp, rsp
        mov     qword ptr [rbp - 8], rdi
        mov     rax, qword ptr [rbp - 8]
        mov byte ptr gs:[rax], 120
        pop     rbp
        ret
```
Or even
```
test(unsigned long):
        mov     byte ptr gs:[rdi], 120
 ret
```
Without ASan, but with ASan:
```
test(unsigned long):
 push    rbp
        mov     rbp, rsp
        sub     rsp, 16
        mov qword ptr [rbp - 8], rdi
        mov     rdi, qword ptr [rbp - 8]
 lea     rsi, [rip + .str]
        mov     edx, 1
        call __asan_memcpy@PLT
        add     rsp, 16
        pop     rbp
 ret
```

The `gs:` addressing is gone.

Funnily enough, with `-O` + ASan, it compiles to the same thing as without ASan.

Obligatory godbolt link: https://godbolt.org/z/8hWGxdc3P
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to