Hi, Here's a possible bug in the compiler:
As can be seen from the objdump output, 64-bit arguments are passed in 32-bit registers
000000000040049c <main>: 40049c: 55 push rbp 40049d: 48 89 e5 mov rbp,rsp 4004a0: be 44 44 00 00 mov esi,0x4444 4004a5: bf 33 33 00 00 mov edi,0x3333 4004aa: e8 05 00 00 00 call 4004b4 <function> 4004af: 90 nop 4004b0: 5d pop rbp 4004b1: c3 ret 4004b2: 66 90 xchg ax,ax also the opcodes on line 4004AF and 4004B2 seem obsolete. Best Regards, Mischa.
./a.out: file format elf64-x86-64 Disassembly of section .init: 0000000000400358 <_init>: 400358: 48 83 ec 08 sub rsp,0x8 40035c: e8 5b 00 00 00 call 4003bc <call_gmon_start> 400361: 48 83 c4 08 add rsp,0x8 400365: c3 ret Disassembly of section .plt: 0000000000400370 <__libc_start_main@plt-0x10>: 400370: ff 35 ca 04 20 00 push QWORD PTR [rip+0x2004ca] # 600840 <_GLOBAL_OFFSET_TABLE_+0x8> 400376: ff 25 cc 04 20 00 jmp QWORD PTR [rip+0x2004cc] # 600848 <_GLOBAL_OFFSET_TABLE_+0x10> 40037c: 0f 1f 40 00 nop DWORD PTR [rax+0x0] 0000000000400380 <__libc_start_main@plt>: 400380: ff 25 ca 04 20 00 jmp QWORD PTR [rip+0x2004ca] # 600850 <_GLOBAL_OFFSET_TABLE_+0x18> 400386: 68 00 00 00 00 push 0x0 40038b: e9 e0 ff ff ff jmp 400370 <_init+0x18> Disassembly of section .text: 0000000000400390 <_start>: 400390: 31 ed xor ebp,ebp 400392: 49 89 d1 mov r9,rdx 400395: 5e pop rsi 400396: 48 89 e2 mov rdx,rsp 400399: 48 83 e4 f0 and rsp,0xfffffffffffffff0 40039d: 50 push rax 40039e: 54 push rsp 40039f: 49 c7 c0 50 05 40 00 mov r8,0x400550 4003a6: 48 c7 c1 c0 04 40 00 mov rcx,0x4004c0 4003ad: 48 c7 c7 9c 04 40 00 mov rdi,0x40049c 4003b4: e8 c7 ff ff ff call 400380 <__libc_start_main@plt> 4003b9: f4 hlt 4003ba: 66 90 xchg ax,ax 00000000004003bc <call_gmon_start>: 4003bc: 48 83 ec 08 sub rsp,0x8 4003c0: 48 8b 05 69 04 20 00 mov rax,QWORD PTR [rip+0x200469] # 600830 <_DYNAMIC+0x1d0> 4003c7: 48 85 c0 test rax,rax 4003ca: 74 02 je 4003ce <call_gmon_start+0x12> 4003cc: ff d0 call rax 4003ce: 48 83 c4 08 add rsp,0x8 4003d2: c3 ret 4003d3: 66 2e 0f 1f 84 00 00 nop WORD PTR cs:[rax+rax*1+0x0] 4003da: 00 00 00 4003dd: 0f 1f 00 nop DWORD PTR [rax] 00000000004003e0 <deregister_tm_clones>: 4003e0: b8 67 08 60 00 mov eax,0x600867 4003e5: 55 push rbp 4003e6: 48 2d 60 08 60 00 sub rax,0x600860 4003ec: 48 83 f8 0e cmp rax,0xe 4003f0: 48 89 e5 mov rbp,rsp 4003f3: 77 02 ja 4003f7 <deregister_tm_clones+0x17> 4003f5: 5d pop rbp 4003f6: c3 ret 4003f7: b8 00 00 00 00 mov eax,0x0 4003fc: 48 85 c0 test rax,rax 4003ff: 74 f4 je 4003f5 <deregister_tm_clones+0x15> 400401: 5d pop rbp 400402: bf 60 08 60 00 mov edi,0x600860 400407: ff e0 jmp rax 400409: 0f 1f 80 00 00 00 00 nop DWORD PTR [rax+0x0] 0000000000400410 <register_tm_clones>: 400410: b8 60 08 60 00 mov eax,0x600860 400415: 55 push rbp 400416: 48 2d 60 08 60 00 sub rax,0x600860 40041c: 48 c1 f8 03 sar rax,0x3 400420: 48 89 e5 mov rbp,rsp 400423: 48 89 c2 mov rdx,rax 400426: 48 c1 ea 3f shr rdx,0x3f 40042a: 48 01 d0 add rax,rdx 40042d: 48 89 c6 mov rsi,rax 400430: 48 d1 fe sar rsi,1 400433: 75 02 jne 400437 <register_tm_clones+0x27> 400435: 5d pop rbp 400436: c3 ret 400437: ba 00 00 00 00 mov edx,0x0 40043c: 48 85 d2 test rdx,rdx 40043f: 74 f4 je 400435 <register_tm_clones+0x25> 400441: 5d pop rbp 400442: bf 60 08 60 00 mov edi,0x600860 400447: ff e2 jmp rdx 400449: 0f 1f 80 00 00 00 00 nop DWORD PTR [rax+0x0] 0000000000400450 <__do_global_dtors_aux>: 400450: 80 3d 05 04 20 00 00 cmp BYTE PTR [rip+0x200405],0x0 # 60085c <__bss_start> 400457: 75 11 jne 40046a <__do_global_dtors_aux+0x1a> 400459: 55 push rbp 40045a: 48 89 e5 mov rbp,rsp 40045d: e8 7e ff ff ff call 4003e0 <deregister_tm_clones> 400462: 5d pop rbp 400463: c6 05 f2 03 20 00 01 mov BYTE PTR [rip+0x2003f2],0x1 # 60085c <__bss_start> 40046a: f3 c3 repz ret 40046c: 0f 1f 40 00 nop DWORD PTR [rax+0x0] 0000000000400470 <frame_dummy>: 400470: 48 83 3d e0 01 20 00 cmp QWORD PTR [rip+0x2001e0],0x0 # 600658 <__JCR_END__> 400477: 00 400478: 74 1b je 400495 <frame_dummy+0x25> 40047a: b8 00 00 00 00 mov eax,0x0 40047f: 48 85 c0 test rax,rax 400482: 74 11 je 400495 <frame_dummy+0x25> 400484: 55 push rbp 400485: bf 58 06 60 00 mov edi,0x600658 40048a: 48 89 e5 mov rbp,rsp 40048d: ff d0 call rax 40048f: 5d pop rbp 400490: e9 7b ff ff ff jmp 400410 <register_tm_clones> 400495: e9 76 ff ff ff jmp 400410 <register_tm_clones> 40049a: 66 90 xchg ax,ax 000000000040049c <main>: 40049c: 55 push rbp 40049d: 48 89 e5 mov rbp,rsp 4004a0: be 44 44 00 00 mov esi,0x4444 4004a5: bf 33 33 00 00 mov edi,0x3333 4004aa: e8 05 00 00 00 call 4004b4 <function> 4004af: 90 nop 4004b0: 5d pop rbp 4004b1: c3 ret 4004b2: 66 90 xchg ax,ax 00000000004004b4 <function>: 4004b4: c3 ret 4004b5: 66 2e 0f 1f 84 00 00 nop WORD PTR cs:[rax+rax*1+0x0] 4004bc: 00 00 00 4004bf: 90 nop 00000000004004c0 <__libc_csu_init>: 4004c0: 48 89 6c 24 d8 mov QWORD PTR [rsp-0x28],rbp 4004c5: 4c 89 64 24 e0 mov QWORD PTR [rsp-0x20],r12 4004ca: 48 8d 2d 7f 01 20 00 lea rbp,[rip+0x20017f] # 600650 <__init_array_end> 4004d1: 4c 8d 25 70 01 20 00 lea r12,[rip+0x200170] # 600648 <__frame_dummy_init_array_entry> 4004d8: 48 89 5c 24 d0 mov QWORD PTR [rsp-0x30],rbx 4004dd: 4c 89 6c 24 e8 mov QWORD PTR [rsp-0x18],r13 4004e2: 4c 89 74 24 f0 mov QWORD PTR [rsp-0x10],r14 4004e7: 4c 89 7c 24 f8 mov QWORD PTR [rsp-0x8],r15 4004ec: 48 83 ec 38 sub rsp,0x38 4004f0: 4c 29 e5 sub rbp,r12 4004f3: 41 89 ff mov r15d,edi 4004f6: 49 89 f6 mov r14,rsi 4004f9: 48 c1 fd 03 sar rbp,0x3 4004fd: 49 89 d5 mov r13,rdx 400500: 31 db xor ebx,ebx 400502: e8 51 fe ff ff call 400358 <_init> 400507: 48 85 ed test rbp,rbp 40050a: 74 1a je 400526 <__libc_csu_init+0x66> 40050c: 0f 1f 40 00 nop DWORD PTR [rax+0x0] 400510: 4c 89 ea mov rdx,r13 400513: 4c 89 f6 mov rsi,r14 400516: 44 89 ff mov edi,r15d 400519: 41 ff 14 dc call QWORD PTR [r12+rbx*8] 40051d: 48 83 c3 01 add rbx,0x1 400521: 48 39 eb cmp rbx,rbp 400524: 75 ea jne 400510 <__libc_csu_init+0x50> 400526: 48 8b 5c 24 08 mov rbx,QWORD PTR [rsp+0x8] 40052b: 48 8b 6c 24 10 mov rbp,QWORD PTR [rsp+0x10] 400530: 4c 8b 64 24 18 mov r12,QWORD PTR [rsp+0x18] 400535: 4c 8b 6c 24 20 mov r13,QWORD PTR [rsp+0x20] 40053a: 4c 8b 74 24 28 mov r14,QWORD PTR [rsp+0x28] 40053f: 4c 8b 7c 24 30 mov r15,QWORD PTR [rsp+0x30] 400544: 48 83 c4 38 add rsp,0x38 400548: c3 ret 400549: 0f 1f 80 00 00 00 00 nop DWORD PTR [rax+0x0] 0000000000400550 <__libc_csu_fini>: 400550: f3 c3 repz ret 400552: 66 90 xchg ax,ax Disassembly of section .fini: 0000000000400554 <_fini>: 400554: 48 83 ec 08 sub rsp,0x8 400558: 48 83 c4 08 add rsp,0x8 40055c: c3 ret
.intel_syntax noprefix .global function .code64 function: ret
#include <stdint.h> extern void function(uint64_t, uint64_t); int main() { function(0x3333, 0x4444); return; }