I am trying to study about assembly, compiler(LLVM) and lifter.
I can write just assembly code by nasm.(like this)
Below is my assembly code.
section .data
hello_string db "Hello World!", 0x0d, 0x0a
hello_string_len equ $ - hello_string
section .text
global _start
_start:
mov eax, 4 ; eax <- 4, syscall number (print) But, never execute.
mov ebx, 1 ; ebx <- 1, syscall argument1 (stdout) But, never execute.
mov ecx, hello_string ; ecx <- exit_string, syscall argument2 (string ptr) But, never execute.
mov edx, hello_string_len ; edx <- exit_string_len, syscall argument3 (string len) But, never execute.
int 0x80; ; syscall But, never execute.
mov eax, 1 ; eax <- 1, syscall number (exit) But, never execute.
mov ebx, 0 ; ebx <- 0, syscall argument1 (return value) But, never execute.
int 0x80; syscall But, never execute.
;nasm -felf32 hello.x86.s -o hello.o
;ld -m elf_i386 hello.o -o hello.out
And I check binary file.
Here, I can't find Function. and i agree with that call and ret instructions are something combined some instructions.
$readelf -s hello.o
Symbol table '.symtab' contains 7 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 00000000 0 NOTYPE LOCAL DEFAULT UND
1: 00000000 0 FILE LOCAL DEFAULT ABS hello.x86.s
2: 00000000 0 SECTION LOCAL DEFAULT 1
3: 00000000 0 SECTION LOCAL DEFAULT 2
4: 00000000 0 NOTYPE LOCAL DEFAULT 1 hello_string
5: 0000000e 0 NOTYPE LOCAL DEFAULT ABS hello_string_len
6: 00000000 0 NOTYPE GLOBAL DEFAULT 2 _start
But. If i compile c program and check that binary file by readelf. then i can find "function".
P.S
$readelf -s function.o | grep FUNC
3: 0000000000000000 18 FUNC GLOBAL DEFAULT 2 add
4: 0000000000000020 43 FUNC GLOBAL DEFAULT 2 main
here i can see what is function.
what is function different NOTYPE label?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…