gnu-assembler

Can't compile asm hello world with gcc

纵然是瞬间 提交于 2020-11-29 09:45:31
问题 This is the code in hello.s .data hello_str: .string "Hello, world!\n" .set hello_str_length, . - hello_str - 1 .text .globl main .type main, @function main: movl $4, %eax movl $1, %ebx movl $hello_str, %ecx movl $hello_str_length, %edx int $0x80 movl $1, %eax movl $0, %ebx int $0x80 .size main, . - main I run gcc hello.s -o hello and get this error: /usr/bin/ld: /tmp/cc6ILJpd.o: relocation R_X86_64_32 against '.data' can not be used when making a shared object; recompile with -fPIC /usr/bin