ld -s -o out out.o error
Opened this issue · 2 comments
Deleted user commented
ld -s -o out out.o
creates these warnings:
ld: warning: option -s is obsolete and being ignored
ld: warning: -macosx_version_min not specified, assuming 10.10
ld: warning: object file (out.o) was built for newer OSX version (10.11) than being linked (10.10)
Undefined symbols for architecture x86_64:
"start", referenced from:
implicit entry/start for main executable
(maybe you meant: _start)
ld: symbol(s) not found for inferred architecture x86_64
Warnings aren't inherently bad, but the next step: ./out
fails with ./out: No such file or directory
Deleted user commented
out.s:
.text
.global _start
_start:
movl $0, %ebx
movl $1, %eax
int $0x80
Deleted user commented
The compiler emits 32-bit code (i386), not code for x86-64 . You must be explicit on the type of generated format.
$ as --32 -g -o out.o out.s
$ ld -m elf_i386 -e _start -g -o a.out out.o
$ file ./a.out
a.out: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, not stripped