I want to call printf in assembly and link it using gcc -l option with standard library, But it says:
Symbol `printf' causes overflow in R_X86_64_PC32 relocation
Segmentation fault (core dumped)
this is How i compile:
gcc mod.s -l:libc.so -o mod
when I replace libc.so with libc.a, It still shows Sementation fault
.file "mod.c"
.text
.section .rodata
.LC0:
.string "%d"
.text
.globl main
.type main, @function
main:
pushq %rbp
movq %rsp, %rbp
subq $16, %rsp
movl $3, -8(%rbp)
movl $2, -4(%rbp)
movl -8(%rbp), %eax
cltd
idivl -4(%rbp)
movl %edx, -4(%rbp)
movl -4(%rbp), %eax
movl %eax, %esi
leaq .LC0(%rip), %rdi
movl $0, %eax
call printf
movl $0, %eax
leave
ret
.size main, .-main
.ident "GCC: (Ubuntu 7.4.0-1ubuntu1~18.04) 7.4.0"
.section .note.GNU-stack,"",@progbits
When I add @PLT after printf it goes right, But I just want to use -l in gcc