我想用 Debian 在 Windows Subsystem for Linux (WLS) 中编译“Hello World”。
.text
.global _start
_start:
movl $len,%edx
movl $msg,%ecx
movl $1,%ebx
movl $4,%eax
int $0x80
movl $0,%ebx
movl $1,%eax
int $0x80
.data
msg:
.ascii "Hello, world!\n"
len = . - msg
如果我在 Debian 服务器中编译
gcc -nostdlib -o hello hello.s
它可以工作,但在 WLS 中返回错误
/usr/bin/ld: /tmp/cciVVddg.o: relocation R_X86_64_32 against `.data' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output collect2: error: ld returned 1 exit status
我也试过
gcc -fPIC -nostdlib -o hello hello.s