Open zzdmfk opened 1 year ago
Please provide the compiler output
Compiler outputs:
george@george-ubuntu:~/Desktop/gitcompiler/PeachCompiler$ ./main
section .data
section .text
extern printf
global set_dog
; set_dog function
set_dog:
push ebp
mov ebp, esp
push dword [ebp+12]
lea ebx, [ebp+8]
push ebx
pop ebx
mov ebx, [ebx]
add ebx, 4
push ebx
pop edx
pop eax
mov dword [edx], eax
pop ebp
ret
section .data
section .rodata
everything compiled file
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/11/../../../../lib32/Scrt1.o: in function _start': (.text+0x22): undefined reference to
main'
collect2: error: ld returned 1 exit status
nasm -f elf32 ./test -o ./test.o && gcc -m32 ./test.o -o ./test
And I debugged it, found the function 'main' can not be parsed correctly in 'parse_function'.
Thanks for reporting the problem
C code: int printf(const char* str, ...);
struct dog { int a; int b; };
void set_dog(struct dog* d, int x) { d->b = x; }
int main() { struct dog d; set_dog(&d, 70); //printf("hello world %i\r\n", d.b); printf("hello world %i\r\n" d.b); //I forget a comma return 0; }