danial27@castor:~$ ./task1 need exactly one command-line argument danial27@castor:~$ ./task1 the dog need exactly one command-line argument danial27@castor:~$ ./task1 hi hello, hi! ---------------------------------------------------------------------------------- danial27@castor:~$ xxd task1 00000000: 7f45 4c46 0201 0100 0000 0000 0000 0000 .ELF............ 00000010: 0200 b700 0100 0000 c000 4000 0000 0000 ..........@..... 00000020: 4000 0000 0000 0000 5001 0000 0000 0000 @.......P....... 00000030: 0000 0000 4000 3800 0100 4000 0300 0200 ....@.8...@..... 00000040: 0100 0000 0500 0000 0000 0000 0000 0000 ................ 00000050: 0000 4000 0000 0000 0000 4000 0000 0000 ..@.......@..... 00000060: 3801 0000 0000 0000 3801 0000 0000 0000 8.......8....... 00000070: 0000 0100 0000 0000 0200 8092 4204 0091 ............B... 00000080: 0114 4038 c1ff ff35 e003 02aa c003 5fd6 ..@8...5......_. 00000090: ff43 00d1 fe07 00f9 e003 00f9 f7ff ff97 .C.............. 000000a0: e203 00aa 2000 80d2 e103 40f9 0808 80d2 .... .....@..... 000000b0: 0100 00d4 fe07 40f9 ff43 0091 c003 5fd6 ......@..C...._. 000000c0: e003 40f9 1f08 00f1 a000 0054 e001 0070 ..@........T...p 000000d0: f0ff ff97 2000 80d2 0800 0014 2001 0010 .... ....... ... 000000e0: ecff ff97 e00b 40f9 eaff ff97 e000 0010 ......@......... 000000f0: e8ff ff97 0000 80d2 a80b 80d2 0100 00d4 ................ 00000100: 6865 6c6c 6f2c 2000 210a 006e 6565 6420 hello, .!..need 00000110: 6578 6163 746c 7920 6f6e 6520 636f 6d6d exactly one comm 00000120: 616e 642d 6c69 6e65 2061 7267 756d 656e and-line argumen 00000130: 740a 0000 1f20 03d5 002e 7368 7374 7274 t.... ....shstrt 00000140: 6162 002e 7465 7874 0000 0000 0000 0000 ab..text........ 00000150: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 00000160: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 00000170: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 00000180: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 00000190: 0b00 0000 0100 0000 0600 0000 0000 0000 ................ 000001a0: 7800 4000 0000 0000 7800 0000 0000 0000 x.@.....x....... 000001b0: c000 0000 0000 0000 0000 0000 0000 0000 ................ 000001c0: 0800 0000 0000 0000 0000 0000 0000 0000 ................ 000001d0: 0100 0000 0300 0000 0000 0000 0000 0000 ................ 000001e0: 0000 0000 0000 0000 3801 0000 0000 0000 ........8....... 000001f0: 1100 0000 0000 0000 0000 0000 0000 0000 ................ 00000200: 0100 0000 0000 0000 0000 0000 0000 0000 ................ ---------------------------------------------------------------------------------- danial27@castor:~$ objdump -d task1 task1: file format elf64-littleaarch64 Disassembly of section .text: 0000000000400078 <.text>: 400078: 92800002 mov x2, #0xffffffffffffffff // #-1 // func 1 40007c: 91000442 add x2, x2, #0x1 400080: 38401401 ldrb w1, [x0], #1 400084: 35ffffc1 cbnz w1, 0x40007c 400088: aa0203e0 mov x0, x2 40008c: d65f03c0 ret 400090: d10043ff sub sp, sp, #0x10 // func 2 400094: f90007fe str x30, [sp, #8] // lr 400098: f90003e0 str x0, [sp] 40009c: 97fffff7 bl 0x400078 4000a0: aa0003e2 mov x2, x0 4000a4: d2800020 mov x0, #0x1 // #1 4000a8: f94003e1 ldr x1, [sp] 4000ac: d2800808 mov x8, #0x40 // #64 4000b0: d4000001 svc #0x0 4000b4: f94007fe ldr x30, [sp, #8] 4000b8: 910043ff add sp, sp, #0x10 4000bc: d65f03c0 ret 4000c0: f94003e0 ldr x0, [sp] // _start // loading the CLI-argument from stack to x0 4000c4: f100081f cmp x0, #0x2 4000c8: 540000a0 b.eq 0x4000dc // b.none 4000cc: 700001e0 adr x0, 0x40010b 4000d0: 97fffff0 bl 0x400090 4000d4: d2800020 mov x0, #0x1 // #1 4000d8: 14000008 b 0x4000f8 4000dc: 10000120 adr x0, 0x400100 4000e0: 97ffffec bl 0x400090 4000e4: f9400be0 ldr x0, [sp, #16] 4000e8: 97ffffea bl 0x400090 4000ec: 100000e0 adr x0, 0x400108 4000f0: 97ffffe8 bl 0x400090 4000f4: d2800000 mov x0, #0x0 // #0 4000f8: d2800ba8 mov x8, #0x5d // #93 4000fc: d4000001 svc #0x0 400100: 6c6c6568 ldnp d8, d25, [x11, #-320] 400104: 00202c6f .inst 0x00202c6f ; NYI 400108: 6e000a21 ext v1.16b, v17.16b, v0.16b, #1 40010c: 20646565 .inst 0x20646565 ; undefined 400110: 63617865 .inst 0x63617865 ; undefined 400114: 20796c74 .inst 0x20796c74 ; undefined 400118: 20656e6f .inst 0x20656e6f ; undefined 40011c: 6d6d6f63 ldp d3, d27, [x27, #-304] 400120: 2d646e61 ldp s1, s27, [x19, #-224] 400124: 656e696c fnmls z12.h, p2/m, z11.h, z14.h 400128: 67726120 .inst 0x67726120 ; undefined 40012c: 6e656d75 umin v21.8h, v11.8h, v5.8h 400130: 00000a74 .inst 0x00000a74 ; undefined 400134: d503201f nop ---------------------------------------------------------------------------------- danial27@castor:~$ gdb --args task1 someargument GNU gdb (Ubuntu 9.2-0ubuntu1~20.04.1) 9.2 Copyright (C) 2020 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "aarch64-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: . Find the GDB manual and other documentation resources online at: . For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from task1... (No debugging symbols found in task1) ---------------------------------------------------------------------------------- (gdb) starti Starting program: /ubc/ece/home/ugrads/d/danial27/task1 someargument Program stopped. 0x00000000004000c0 in ?? () (gdb) disas $pc, +16 Dump of assembler code from 0x4000c0 to 0x4000d0: => 0x00000000004000c0: ldr x0, [sp] 0x00000000004000c4: cmp x0, #0x2 0x00000000004000c8: b.eq 0x4000dc // b.none 0x00000000004000cc: adr x0, 0x40010b End of assembler dump. ---------------------------------------------------------------------------------- (gdb) si 0x00000000004000c4 in ?? () (gdb) p/x $sp $1 = 0xfffffffff450 (gdb) p/x $x0 $2 = 0x2 (gdb) x/8xg sp No symbol table is loaded. Use the "file" command. (gdb) display/x {$pc, $sp, $x0} 1: /x {$pc, $sp, $x0} = {0x4000c4, 0xfffffffff450, 0x2} ---------------------------------------------------------------------------------- (gdb) layout asm (gdb) layout regs (gdb) focus regs (gdb) focus asm (gdb) focus cmd ----------------------------------------------------------------------------------