我正在和nasm打交道,在没有问题地做了hello world之后,我想我应该试着做一些c集成。
我正在使用c打开一个文件,然后我想使用为打开的文件返回的指针来处理文本。然而,当我在rdi中使用指针调用fgetc时,我得到一个“没有这样的文件或目录”,后面跟着一个segfault。
我做错了什么?
int64_t asmFunc(FILE* a, char* b);
int main()
{
int num;
FILE *fptr;
size_t line_buf_size = 0;
char *ret = malloc(100);
fptr = fopen("./test.txt","r");
if(fptr == NULL)
{
printf("Error!");
exit(1);
}
printf("%ld", asmFunc(fptr, ret));
return 0;
}
global asmFunc
section .text
extern fgetc
asmFunc:
call fgetc ; segfault occurs here.
(...)
ret
https://stackoverflow.com/questions/55882234
复制相似问题