Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #############################################3
- #% as -o argc.o argc.s && ld -o argc argc.o
- #% ./argc 3 4 5
- #4
- #
- #% as -o argc.o argc.s && ld -o argc argc.o -lc
- #% ./argc 4 5 6
- #zsh: no such file or directory: ./argc
- #
- #% gcc -m64 -o argc argc.s -nostdlib
- #% ./argc 3 4 5
- #4
- #
- #% gcc -m64 -o argc argc.s
- #/tmp/ccfN2MUC.o: In function `_start':
- #(.text+0x0): multiple definition of `_start'
- #/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/../../../../lib64/crt1.o:(.text+0x0): first defined here
- #/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/../../../../lib64/crt1.o: In function `_start':
- #(.text+0x20): undefined reference to `main'
- #collect2: ld returned 1 exit status
- #
- ### Меняем `_start:' на `main:'
- #
- #% gcc -m64 -o argc argc.s
- #% ./argc 3 4 5
- #=���
- #
- ### Код:
- .globl _start
- .data
- newline: .ascii "\n"
- .set newline_len, . - newline
- .bss
- argc: .space 8
- .text
- _start:
- movq $1, %rax
- movq $1, %rdi
- movq (%rsp), %rbx
- movq %rbx, argc
- addq $48, argc
- movq $argc, %rsi
- movq $8, %rdx
- syscall
- movq $1, %rax
- movq $1, %rdi
- movq $newline, %rsi
- movq $newline_len, %rdx
- syscall
- movq $60, %rax
- xorq %rdi, %rdi
- syscall
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement