; ; +-------------------------------------------------------------------------+ ; | This file was generated by The Interactive Disassembler (IDA) | ; | Copyright (c) 2021 Hex-Rays, <[email protected]> | ; | Freeware version | ; +-------------------------------------------------------------------------+ ; ; Input SHA256 : C5B0D9E18E087435633CDBDC148AA7D0C7491A8FDFC428A36F6D079B45CB9D72 ; Input MD5 : 342992E2FD4444A0D16539BD997B6307 ; Input CRC32 : 2A63251E ; File Name : C:\_Tsukasa_Yamazaki\CpawCTF\questions\exec_me ; Format : ELF64 for x86-64 (Executable) ; Imagebase : 400000 ; Interpreter '/lib64/ld-linux-x86-64.so.2' ; Needed Library 'libc.so.6' ; ; Source File : 'crtstuff.c' ; Source File : 'exec_me.c' ; Source File : 'crtstuff.c' .686p .mmx .model flat .intel_syntax noprefix ; Segment type: Pure code ; Segment permissions: Read/Execute LOAD segment byte public 'CODE' use64 assume cs:LOAD ;org 400000h assume es:nothing, ss:nothing, ds:_data, fs:nothing, gs:nothing dword_400000 dd 464C457Fh ; File format: \x7FELF db 2 ; File class: 64-bit db 1 ; Data encoding: little-endian db 1 ; File version db 0 ; OS/ABI: UNIX System V ABI db 0 ; ABI Version db 7 dup(0) ; Padding dw 2 ; File type: Executable dw 3Eh ; Machine: x86-64 dd 1 ; File version dq offset _start ; Entry point dq 40h ; PHT file offset dq 1198h ; SHT file offset dd 0 ; Processor-specific flags dw 40h ; ELF header size dw 38h ; PHT entry size dw 9 ; Number of entries in PHT dw 40h ; SHT entry size dw 1Eh ; Number of entries in SHT dw 1Bh ; SHT entry index for string table ; ELF64 Program Header ; PHT Entry 0 dword_400040 dd 6 ; Type: PHDR dd 5 ; Flags dq 40h ; File offset dq offset dword_400040 ; Virtual address dq 400040h ; Physical address dq 1F8h ; Size in file image dq 1F8h ; Size in memory image dq 8 ; Alignment ; PHT Entry 1 dd 3 ; Type: INTERP dd 4 ; Flags dq 238h ; File offset dq offset aLib64LdLinuxX8 ; Virtual address dq 400238h ; Physical address dq 1Ch ; Size in file image dq 1Ch ; Size in memory image dq 1 ; Alignment ; PHT Entry 2 dd 1 ; Type: LOAD dd 5 ; Flags dq 0 ; File offset dq offset dword_400000 ; Virtual address dq 400000h ; Physical address dq 7ECh ; Size in file image dq 7ECh ; Size in memory image dq 200000h ; Alignment ; PHT Entry 3 dd 1 ; Type: LOAD dd 6 ; Flags dq 0E10h ; File offset dq offset __frame_dummy_init_array_entry ; Virtual address dq 600E10h ; Physical address dq 230h ; Size in file image dq 238h ; Size in memory image dq 200000h ; Alignment ; PHT Entry 4 dd 2 ; Type: DYNAMIC dd 6 ; Flags dq 0E28h ; File offset dq offset _DYNAMIC ; Virtual address dq 600E28h ; Physical address dq 1D0h ; Size in file image dq 1D0h ; Size in memory image dq 8 ; Alignment ; PHT Entry 5 dd 4 ; Type: NOTE dd 4 ; Flags dq 254h ; File offset dq offset dword_400254 ; Virtual address dq 400254h ; Physical address dq 44h ; Size in file image dq 44h ; Size in memory image dq 4 ; Alignment ; PHT Entry 6 dd 6474E550h ; Type: EH_FRAME dd 4 ; Flags dq 6C4h ; File offset dq offset unk_4006C4 ; Virtual address dq 4006C4h ; Physical address dq 34h ; Size in file image dq 34h ; Size in memory image dq 4 ; Alignment ; PHT Entry 7 dd 6474E551h ; Type: STACK dd 6 ; Flags dq 0 ; File offset dq 0 ; Virtual address dq 0 ; Physical address dq 0 ; Size in file image dq 0 ; Size in memory image dq 10h ; Alignment ; PHT Entry 8 dd 6474E552h ; Type: RO-AFTER dd 4 ; Flags dq 0E10h ; File offset dq offset __frame_dummy_init_array_entry ; Virtual address dq 600E10h ; Physical address dq 1F0h ; Size in file image dq 1F0h ; Size in memory image dq 1 ; Alignment aLib64LdLinuxX8 db '/lib64/ld-linux-x86-64.so.2',0 ; ELF Note Entry dword_400254 dd 4 ; Name Size dd 10h ; Desc Size dd 1 ; Type: NT_GNU_ABI_TAG aGnu db 'GNU',0 ; Name dd 0, 2, 6, 18h ; ABI: Linux 2.6.24 ; ELF Note Entry dd 4 ; Name Size dd 14h ; Desc Size dd 3 ; Type: NT_GNU_BUILD_ID aGnu_0 db 'GNU',0 ; Name db 66h, 3Ah, 3Eh, 0Eh, 5Ah, 7, 9Fh, 0DDh ; Desc db 0D0h, 0DEh, 92h, 47h, 46h, 88h, 0CDh db 68h, 12h, 0D3h, 0B5h, 50h ; ELF GNU Hash Table elf_gnu_hash_nbuckets dd 1 elf_gnu_hash_symbias dd 1 elf_gnu_hash_bitmask_nwords dd 1 elf_gnu_hash_shift dd 0 elf_gnu_hash_indexes dq 0 elf_gnu_hash_bucket dd 0 elf_gnu_hash_chain dd 0 ; ELF Symbol Table Elf64_Sym <0> Elf64_Sym <offset aPutchar - offset byte_400318,\ ; "putchar" 12h, 0, 0, 0, 0> Elf64_Sym <offset aLibcStartMain - offset byte_400318,\ ; "__libc_start_main" 12h, 0, 0, 0, 0> Elf64_Sym <offset aGmonStart - offset byte_400318,\ ; "__gmon_start__" 20h, 0, 0, 0, 0> ; ELF String Table byte_400318 db 0 aLibcSo6 db 'libc.so.6',0 aPutchar db 'putchar',0 aLibcStartMain db '__libc_start_main',0 aGmonStart db '__gmon_start__',0 aGlibc225 db 'GLIBC_2.2.5',0 ; ELF GNU Symbol Version Table dw 0 dw 2 ; putchar@@GLIBC_2.2.5 dw 2 ; __libc_start_main@@GLIBC_2.2.5 dw 0 ; local symbol: __gmon_start__ ; ELF GNU Symbol Version Requirements Elf64_Verneed <1, 1, \ ; "libc.so.6" offset aLibcSo6 - offset byte_400318,\ 10h, 0> Elf64_Vernaux <9691A75h, 0, 2, \ ; "GLIBC_2.2.5" offset aGlibc225 - offset byte_400318,\ 0> ; ELF RELA Relocation Table Elf64_Rela <600FF8h, 300000006h, 0> ; R_X86_64_GLOB_DAT __gmon_start__ ; ELF JMPREL Relocation Table Elf64_Rela <601018h, 100000007h, 0> ; R_X86_64_JUMP_SLOT putchar Elf64_Rela <601020h, 200000007h, 0> ; R_X86_64_JUMP_SLOT __libc_start_main Elf64_Rela <601028h, 300000007h, 0> ; R_X86_64_JUMP_SLOT __gmon_start__ LOAD ends ; Segment type: Pure code ; Segment permissions: Read/Execute _init segment dword public 'CODE' use64 assume cs:_init ;org 4003E0h assume es:nothing, ss:nothing, ds:_data, fs:nothing, gs:nothing public _init_proc _init_proc proc near sub rsp, 8 ; _init mov rax, cs:__gmon_start___ptr test rax, rax jz short loc_4003F5 call ___gmon_start__ loc_4003F5: add rsp, 8 retn _init_proc endp _init ends ; Segment type: Pure code ; Segment permissions: Read/Execute LOAD segment byte public 'CODE' use64 assume cs:LOAD ;org 4003FAh assume es:nothing, ss:nothing, ds:_data, fs:nothing, gs:nothing align 20h LOAD ends ; Segment type: Pure code ; Segment permissions: Read/Execute _plt segment para public 'CODE' use64 assume cs:_plt ;org 400400h assume es:nothing, ss:nothing, ds:_data, fs:nothing, gs:nothing sub_400400 proc near push cs:qword_601008 jmp cs:qword_601010 sub_400400 endp align 10h ; [00000006 BYTES: COLLAPSED FUNCTION _putchar. PRESS CTRL-NUMPAD+ TO EXPAND] push 0 jmp sub_400400 ; [00000006 BYTES: COLLAPSED FUNCTION ___libc_start_main. PRESS CTRL-NUMPAD+ TO EXPAND] push 1 jmp sub_400400 ; [00000006 BYTES: COLLAPSED FUNCTION ___gmon_start__. PRESS CTRL-NUMPAD+ TO EXPAND] push 2 jmp sub_400400 _plt ends ; Segment type: Pure code ; Segment permissions: Read/Execute _text segment para public 'CODE' use64 assume cs:_text ;org 400440h assume es:nothing, ss:nothing, ds:_data, fs:nothing, gs:nothing ; Attributes: noreturn fuzzy-sp public _start _start proc near xor ebp, ebp mov r9, rdx ; rtld_fini pop rsi ; argc mov rdx, rsp ; ubp_av and rsp, 0FFFFFFFFFFFFFFF0h push rax push rsp ; stack_end mov r8, offset __libc_csu_fini ; fini mov rcx, offset __libc_csu_init ; init mov rdi, offset main ; main call ___libc_start_main hlt _start endp align 10h ; Attributes: bp-based frame deregister_tm_clones proc near mov eax, offset unk_601047 push rbp sub rax, offset __bss_start cmp rax, 0Eh mov rbp, rsp ja short loc_400487 loc_400485: pop rbp retn loc_400487: mov eax, 0 test rax, rax jz short loc_400485 pop rbp mov edi, offset __bss_start jmp rax deregister_tm_clones endp align 20h ; Attributes: bp-based frame register_tm_clones proc near mov eax, offset __bss_start push rbp sub rax, offset __bss_start sar rax, 3 mov rbp, rsp mov rdx, rax shr rdx, 3Fh add rax, rdx sar rax, 1 jnz short loc_4004C4 loc_4004C2: pop rbp retn loc_4004C4: mov edx, 0 test rdx, rdx jz short loc_4004C2 pop rbp mov rsi, rax mov edi, offset __bss_start jmp rdx register_tm_clones endp align 20h __do_global_dtors_aux proc near cmp cs:__bss_start, 0 jnz short locret_4004FA push rbp mov rbp, rsp call deregister_tm_clones pop rbp mov cs:__bss_start, 1 locret_4004FA: rep retn __do_global_dtors_aux endp align 20h frame_dummy proc near cmp cs:__JCR_LIST__, 0 jz short loc_400528 mov eax, 0 test rax, rax jz short loc_400528 push rbp mov edi, offset __JCR_LIST__ mov rbp, rsp call rax pop rbp jmp register_tm_clones align 8 loc_400528: jmp register_tm_clones frame_dummy endp ; Attributes: bp-based frame ; int __cdecl main(int argc, const char **argv, const char **envp) public main main proc near var_75= byte ptr -75h var_74= dword ptr -74h var_70= dword ptr -70h var_6C= dword ptr -6Ch var_68= dword ptr -68h var_64= dword ptr -64h var_60= dword ptr -60h var_5C= dword ptr -5Ch var_58= dword ptr -58h var_54= dword ptr -54h var_50= dword ptr -50h var_4C= dword ptr -4Ch var_48= dword ptr -48h var_44= dword ptr -44h var_40= dword ptr -40h var_3C= dword ptr -3Ch var_38= dword ptr -38h var_34= dword ptr -34h var_30= dword ptr -30h var_2C= dword ptr -2Ch var_28= dword ptr -28h var_24= dword ptr -24h var_20= dword ptr -20h var_1C= dword ptr -1Ch var_18= dword ptr -18h var_14= dword ptr -14h var_10= dword ptr -10h var_C= dword ptr -0Ch var_8= dword ptr -8 push rbp mov rbp, rsp add rsp, 0FFFFFFFFFFFFFF80h mov [rbp+var_70], 4Dh ; 'M' mov [rbp+var_6C], 5Ah ; 'Z' mov [rbp+var_68], 4Bh ; 'K' mov [rbp+var_64], 61h ; 'a' mov [rbp+var_60], 65h ; 'e' mov [rbp+var_5C], 2Eh ; '.' mov [rbp+var_58], 59h ; 'Y' mov [rbp+var_54], 49h ; 'I' mov [rbp+var_50], 63h ; 'c' mov [rbp+var_4C], 59h ; 'Y' mov [rbp+var_48], 5Fh ; '_' mov [rbp+var_44], 49h ; 'I' mov [rbp+var_40], 55h ; 'U' mov [rbp+var_3C], 58h ; 'X' mov [rbp+var_38], 59h ; 'Y' mov [rbp+var_34], 61h ; 'a' mov [rbp+var_30], 49h ; 'I' mov [rbp+var_2C], 2Fh ; '/' mov [rbp+var_28], 36h ; '6' mov [rbp+var_24], 30h ; '0' mov [rbp+var_20], 49h ; 'I' mov [rbp+var_1C], 50h ; 'P' mov [rbp+var_18], 53h ; 'S' mov [rbp+var_14], 56h ; 'V' mov [rbp+var_10], 4Fh ; 'O' mov [rbp+var_C], 29h ; ')' mov [rbp+var_8], 67h ; 'g' mov [rbp+var_74], 0 mov [rbp+var_74], 0 jmp short loc_400620 loc_400602: mov eax, [rbp+var_74] cdqe mov eax, [rbp+rax*4+var_70] add eax, 16h mov [rbp+var_75], al movsx eax, [rbp+var_75] mov edi, eax ; c call _putchar add [rbp+var_74], 1 loc_400620: cmp [rbp+var_74], 1Ah jle short loc_400602 mov edi, 0Ah ; c call _putchar mov eax, 0 leave retn main endp align 20h ; void _libc_csu_init(void) public __libc_csu_init __libc_csu_init proc near push r15 mov r15d, edi push r14 mov r14, rsi push r13 mov r13, rdx push r12 lea r12, __frame_dummy_init_array_entry push rbp lea rbp, __do_global_dtors_aux_fini_array_entry push rbx sub rbp, r12 xor ebx, ebx sar rbp, 3 sub rsp, 8 call _init_proc test rbp, rbp jz short loc_400696 nop dword ptr [rax+rax+00000000h] loc_400680: mov rdx, r13 mov rsi, r14 mov edi, r15d call ds:(__frame_dummy_init_array_entry - 600E10h)[r12+rbx*8] add rbx, 1 cmp rbx, rbp jnz short loc_400680 loc_400696: add rsp, 8 pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn __libc_csu_init endp align 10h ; void _libc_csu_fini(void) public __libc_csu_fini __libc_csu_fini proc near rep retn __libc_csu_fini endp _text ends ; Segment type: Pure code ; Segment permissions: Read/Execute LOAD segment byte public 'CODE' use64 assume cs:LOAD ;org 4006B2h assume es:nothing, ss:nothing, ds:_data, fs:nothing, gs:nothing align 4 LOAD ends ; Segment type: Pure code ; Segment permissions: Read/Execute _fini segment dword public 'CODE' use64 assume cs:_fini ;org 4006B4h assume es:nothing, ss:nothing, ds:_data, fs:nothing, gs:nothing public _term_proc _term_proc proc near sub rsp, 8 ; _fini add rsp, 8 retn _term_proc endp _fini ends ; Segment type: Pure code ; Segment permissions: Read/Execute LOAD segment byte public 'CODE' use64 assume cs:LOAD ;org 4006BDh assume es:nothing, ss:nothing, ds:_data, fs:nothing, gs:nothing align 20h LOAD ends ; Segment type: Pure data ; Segment permissions: Read _rodata segment dword public 'CONST' use64 assume cs:_rodata ;org 4006C0h public _IO_stdin_used _IO_stdin_used db 1 db 0 db 2 db 0 _rodata ends ; Segment type: Pure data ; Segment permissions: Read _eh_frame_hdr segment dword public 'CONST' use64 assume cs:_eh_frame_hdr ;org 4006C4h unk_4006C4 db 1 db 1Bh db 3 db 3Bh ; ; db 30h ; 0 db 0 db 0 db 0 db 5 db 0 db 0 db 0 db 3Ch ; < db 0FDh db 0FFh db 0FFh db 7Ch ; | db 0 db 0 db 0 db 7Ch ; | db 0FDh db 0FFh db 0FFh db 4Ch ; L db 0 db 0 db 0 db 69h ; i db 0FEh db 0FFh db 0FFh db 0A4h db 0 db 0 db 0 db 7Ch ; | db 0FFh db 0FFh db 0FFh db 0C4h db 0 db 0 db 0 db 0ECh db 0FFh db 0FFh db 0FFh db 0Ch db 1 db 0 db 0 _eh_frame_hdr ends ; Segment type: Pure data ; Segment permissions: Read _eh_frame segment qword public 'CONST' use64 assume cs:_eh_frame ;org 4006F8h db 14h db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 1 db 7Ah ; z db 52h ; R db 0 db 1 db 78h ; x db 10h db 1 db 1Bh db 0Ch db 7 db 8 db 90h db 1 db 7 db 10h db 14h db 0 db 0 db 0 db 1Ch db 0 db 0 db 0 db 28h ; ( db 0FDh db 0FFh db 0FFh db 2Ah ; * db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 14h db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 1 db 7Ah ; z db 52h ; R db 0 db 1 db 78h ; x db 10h db 1 db 1Bh db 0Ch db 7 db 8 db 90h db 1 db 0 db 0 db 24h ; $ db 0 db 0 db 0 db 1Ch db 0 db 0 db 0 db 0B8h db 0FCh db 0FFh db 0FFh db 40h ; @ db 0 db 0 db 0 db 0 db 0Eh db 10h db 46h ; F db 0Eh db 18h db 4Ah ; J db 0Fh db 0Bh db 77h ; w db 8 db 80h db 0 db 3Fh ; ? db 1Ah db 3Bh ; ; db 2Ah ; * db 33h ; 3 db 24h ; $ db 22h ; " db 0 db 0 db 0 db 0 db 1Ch db 0 db 0 db 0 db 44h ; D db 0 db 0 db 0 db 0BDh db 0FDh db 0FFh db 0FFh db 0Ah db 1 db 0 db 0 db 0 db 41h ; A db 0Eh db 10h db 86h db 2 db 43h ; C db 0Dh db 6 db 3 db 5 db 1 db 0Ch db 7 db 8 db 0 db 44h ; D db 0 db 0 db 0 db 64h ; d db 0 db 0 db 0 db 0B0h db 0FEh db 0FFh db 0FFh db 65h ; e db 0 db 0 db 0 db 0 db 42h ; B db 0Eh db 10h db 8Fh db 2 db 45h ; E db 0Eh db 18h db 8Eh db 3 db 45h ; E db 0Eh db 20h db 8Dh db 4 db 45h ; E db 0Eh db 28h ; ( db 8Ch db 5 db 48h ; H db 0Eh db 30h ; 0 db 86h db 6 db 48h ; H db 0Eh db 38h ; 8 db 83h db 7 db 4Dh ; M db 0Eh db 40h ; @ db 6Ch ; l db 0Eh db 38h ; 8 db 41h ; A db 0Eh db 30h ; 0 db 41h ; A db 0Eh db 28h ; ( db 42h ; B db 0Eh db 20h db 42h ; B db 0Eh db 18h db 42h ; B db 0Eh db 10h db 42h ; B db 0Eh db 8 db 0 db 14h db 0 db 0 db 0 db 0ACh db 0 db 0 db 0 db 0D8h db 0FEh db 0FFh db 0FFh db 2 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 __FRAME_END__ db 0 db 0 db 0 db 0 _eh_frame ends ; ELF Initialization Function Table ; Segment type: Pure data ; Segment permissions: Read/Write _init_array segment qword public 'DATA' use64 assume cs:_init_array ;org 600E10h __frame_dummy_init_array_entry dq offset frame_dummy ; Alternative name is '__init_array_start' _init_array ends ; ELF Termination Function Table ; Segment type: Pure data ; Segment permissions: Read/Write _fini_array segment qword public 'DATA' use64 assume cs:_fini_array ;org 600E18h __do_global_dtors_aux_fini_array_entry dq offset __do_global_dtors_aux ; Alternative name is '__init_array_end' _fini_array ends ; Segment type: Pure data ; Segment permissions: Read/Write _jcr segment qword public 'DATA' use64 assume cs:_jcr ;org 600E20h __JCR_LIST__ dq 0 _jcr ends ; ELF Dynamic Information ; Segment type: Pure data ; Segment permissions: Read/Write LOAD segment byte public 'DATA' use64 assume cs:LOAD ;org 600E28h _DYNAMIC Elf64_Dyn <1, 1> ; DT_NEEDED libc.so.6 Elf64_Dyn <0Ch, 4003E0h> ; DT_INIT Elf64_Dyn <0Dh, 4006B4h> ; DT_FINI Elf64_Dyn <19h, 600E10h> ; DT_INIT_ARRAY Elf64_Dyn <1Bh, 8> ; DT_INIT_ARRAYSZ Elf64_Dyn <1Ah, 600E18h> ; DT_FINI_ARRAY Elf64_Dyn <1Ch, 8> ; DT_FINI_ARRAYSZ Elf64_Dyn <6FFFFEF5h, 400298h> ; DT_GNU_HASH Elf64_Dyn <5, 400318h> ; DT_STRTAB Elf64_Dyn <6, 4002B8h> ; DT_SYMTAB Elf64_Dyn <0Ah, 40h> ; DT_STRSZ Elf64_Dyn <0Bh, 18h> ; DT_SYMENT Elf64_Dyn <15h, 0> ; DT_DEBUG Elf64_Dyn <3, 601000h> ; DT_PLTGOT Elf64_Dyn <2, 48h> ; DT_PLTRELSZ Elf64_Dyn <14h, 7> ; DT_PLTREL Elf64_Dyn <17h, 400398h> ; DT_JMPREL Elf64_Dyn <7, 400380h> ; DT_RELA Elf64_Dyn <8, 18h> ; DT_RELASZ Elf64_Dyn <9, 18h> ; DT_RELAENT Elf64_Dyn <6FFFFFFEh, 400360h> ; DT_VERNEED Elf64_Dyn <6FFFFFFFh, 1> ; DT_VERNEEDNUM Elf64_Dyn <6FFFFFF0h, 400358h> ; DT_VERSYM Elf64_Dyn <0> ; DT_NULL db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 LOAD ends ; Segment type: Pure data ; Segment permissions: Read/Write _got segment qword public 'DATA' use64 assume cs:_got ;org 600FF8h __gmon_start___ptr dq offset __gmon_start__ _got ends ; Segment type: Pure data ; Segment permissions: Read/Write _got_plt segment qword public 'DATA' use64 assume cs:_got_plt ;org 601000h _GLOBAL_OFFSET_TABLE_ dq offset _DYNAMIC qword_601008 dq 0 qword_601010 dq 0 off_601018 dq offset putchar off_601020 dq offset __libc_start_main off_601028 dq offset __gmon_start__ _got_plt ends ; Segment type: Pure data ; Segment permissions: Read/Write _data segment qword public 'DATA' use64 assume cs:_data ;org 601030h public __data_start ; weak __data_start db 0 ; Alternative name is '__data_start' ; data_start db 0 db 0 db 0 db 0 db 0 db 0 db 0 public __dso_handle __dso_handle db 0 db 0 db 0 db 0 db 0 db 0 db 0 db 0 _data ends ; Segment type: Uninitialized ; Segment permissions: Read/Write _bss segment byte public 'BSS' use64 assume cs:_bss ;org 601040h assume es:nothing, ss:nothing, ds:_data, fs:nothing, gs:nothing public __bss_start __bss_start db ? ; Alternative name is '__TMC_END__' ; completed.6973 ; _edata db ? ; db ? ; db ? ; db ? ; db ? ; db ? ; unk_601047 db ? ; _bss ends ; Segment type: Zero-length _prgend segment byte public '' use64 _end label byte _prgend ends ; Segment type: Externs ; extern ; int putchar(int c) extrn putchar:near ; int __fastcall _libc_start_main(int (__fastcall *main)(int, char **, char **), int argc, char **ubp_av, void (*init)(void), void (*fini)(void), void (*rtld_fini)(void), void *stack_end) extrn __libc_start_main:near extrn __gmon_start__:near ; weak end _start
Write, Run & Share Assembly code online using OneCompiler's Assembly online compiler for free. It's one of the robust, feature-rich online compilers for Assembly language. Getting started with the OneCompiler's Assembly compiler is simple and pretty fast. The editor shows sample boilerplate code when you choose language as Assembly
and start coding.
Assembly language(asm) is a low-level programming language, where the language instructions will be more similar to machine code instructions.
Every assembler may have it's own assembly language designed for a specific computers or an operating system.
Assembly language requires less execution time and memory. It is more helful for direct hardware manipulation, real-time critical applications. It is used in device drivers, low-level embedded systems etc.
Assembly language usually consists of three sections,
Data section
To initialize variables and constants, buffer size these values doesn't change at runtime.
bss section
To declare variables
text section
_start
specifies the starting of this section where the actually code is written.
There are various define directives to allocate space for variables for both initialized and uninitialized data.
variable-name define-directive initial-value
Define Directive | Description | Allocated Space |
---|---|---|
DB | Define Byte | 1 byte |
DW | Define Word | 2 bytes |
DD | Define Doubleword | 4 bytes |
DQ | Define Quadword | 8 bytes |
DT | Define Ten Bytes | 10 bytes |
Define Directive | Description |
---|---|
RESB | Reserve a Byte |
RESW | Reserve a Word |
RESD | Reserve a Doubleword |
RESQ | Reserve a Quadword |
REST | Reserve a Ten Bytes |
Constants can be defined using
CONSTANT_NAME EQU regular-exp or value
%assign constant_name value
%define constant_name value
Loops are used to iterate a set of statements for a specific number of times.
mov ECX,n
L1:
;<loop body>
loop L1
where n specifies the no of times loops should iterate.
Procedure is a sub-routine which contains set of statements. Usually procedures are written when multiple calls are required to same set of statements which increases re-usuability and modularity.
procedure_name:
;procedure body
ret