`There are two files in the following: program.s and functions.c
I build it with following command:
gcc -c -std=c99 functions.c
gcc -o program program.s functions.o
run it: ./program
but got segmentation fault error
if remove "pushq %rbx" "popq %rbx", segmentation fault disappear.
please help me analysis it ?
//program.s
.globl main
.align 16
main:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
call read_int@PLT
popq %rbx
popq %rbp
retq
//functions.c
#include <stdio.h>
#include <inttypes.h>
int64_t read_int() {
int64_t i;
scanf("%" SCNd64, &i);
return i;
}
look at the above, if remove "pushq %rbx" "popq %rbx", segmentation fault disappear.
`