[Bug target/80013] New: [ms_abi-windows x86-64] A Pointer Size 64-bit Wide or 32-bit Wide?
rudyy.id at gmail dot com
gcc-bugzilla@gcc.gnu.org
Sun Mar 12 10:55:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80013
Bug ID: 80013
Summary: [ms_abi-windows x86-64] A Pointer Size 64-bit Wide or
32-bit Wide?
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: rudyy.id at gmail dot com
Target Milestone: ---
This is a log from a c source I'm compile using -O2 (The weird stuff start on
line 790 and so on):
614 .p2align 3,,7
615 .def _arc4random_buf.part.2; .scl 3;
.type 32; .endef
616 .seh_proc _arc4random_buf.part.2
617 _arc4random_buf.part.2:
618 0888 4157 push r15
619 .seh_pushreg r15
620 088a 4156 push r14
621 .seh_pushreg r14
622 088c 4155 push r13
623 .seh_pushreg r13
624 088e 4154 push r12
625 .seh_pushreg r12
626 0890 55 push rbp
627 .seh_pushreg rbp
628 0891 57 push rdi
629 .seh_pushreg rdi
630 0892 56 push rsi
631 .seh_pushreg rsi
632 0893 53 push rbx
633 .seh_pushreg rbx
634 0894 4883EC38 sub rsp, 56
635 .seh_stackalloc 56
636 .seh_endprologue
637 0898 488B0500 mov rax, QWORD PTR Arc4Rand_Mutex[rip]
637 000000
638 089f 4989CE mov r14, rcx
639 08a2 4889D5 mov rbp, rdx
640 08a5 4885C0 test rax, rax
641 08a8 0F84BF01 je .L94
.......................................................
/* CreateMutexA(void* pMutexSecurity, int bOwner, char* pName) */
/* CreateMutexW(void* pMutexSecurity, int bOwner, wchar_t* pName) */
/* InterlockedCompareExchangePointer, basically this is just cmpxchg with a
lock */
789 .L94:
790 0a6d 31C9 xor ecx, ecx /* Since the 1st argument is a
pointer type, Isn't this suppose to be rcx? */
791 0a6f 4531C0 xor r8d, r8d /* Since the 3rd argument is a
pointer type, Isn't this suppose to be r8? */
792 0a72 31D2 xor edx, edx /* This is correct, since the
2nd argument is a BOOL (32-bit wide) */
GAS LISTING D:\Documents\GCC-MinGW\_Temp\ccwQlMZr.s page 20
793 0a74 FF150000 call [QWORD PTR __imp_CreateMutexW[rip]]
793 0000
794 0a7a 4889C1 mov rcx, rax
795 0a7d 4885C0 test rax, rax
796 0a80 743D je .L105
797 .L47:
798 0a82 31C0 xor eax, eax /* Isn't this suppose to be
rax? */
799 0a84 F0480FB1 lock cmpxchg QWORD PTR Arc4Rand_Mutex[rip],
rcx
799 0D000000
799 00
800 0a8d 4885C0 test rax, rax /* Hey its rax, but the
comparand is eax? */
801 0a90 0F8418FE je .L46
Using GNUC 6.3.0 + Binutils 2.28 + mingw64 header and libs 2017. Build by
msys2.
Using GNUC 7.x + Binutils 2.28 + mingw64 header and libs 2017. Build by someone
from x265 developer.
Both compiler show the same result but 7.x had better optimization than 6.x :)
Both compiler also show the same result if I'm using ATT silent option (no log
output except error stuff).
Disassembler ms dll and take a look inside for CreateMutexW:
test edx,edx /* 2nd argument from the caller */
mov rax,r8 /* 3rd argument is r8 from the caller but gnuc using
r8d? */
jnz .
xor r8d,r8d / 3rd Argument for CreateMutexExW ; its int/DWORD */
mov r9d,0001F0001 /* Access Method ; 4rd argument for
CreateMutexExW ; its int/DWORD */
mov rdx,rax /* 2nd Argument for CreateMutexExW , taken from 3rd
argument of the caller */
jmp CreateMutexExW
nop
nop
More information about the Gcc-bugs
mailing list