Marvee Amasi
Marvee Amasi
DIIDevHeads IoT Integration Server
Created by Marvee Amasi on 7/21/2024 in #code-review
Segmentation Fault in Assembly Program Using AT&T Syntax and GNU Assembler
I assemble and link the program with GCC using the following command:
gcc -o main main.s
gcc -o main main.s
So when I run the program using ./main, I get a segmentation fault . Debugging with gdb reveals that printf is not found. I've tried using .extern printf without success. Someone suggested I should store the stack pointer before calling printf and restore it before RET. Right now I'm unsure how to implement this in AT&T syntax. I'm not including any specific linker flags with GCC. Can anyone help me understand why I'm getting the segmentation fault and how to fix it? Also, if storing the stack pointer is necessary, how would I do that in AT&T syntax?
2 replies