Re: Preliminary questions for sponsoring a compiler
On 07/25/2016 02:51 PM, Albert van der Horst wrote:
> The problem is: ld is not stable w.r.t. linking pure assembler files.
How so?
$ cat write.s
.text
.global _start
.type _start, @function
_start:
mov $1, %rax
mov %rax, %rdi
lea str, %rsi
mov strsize, %rdx
syscall
xor %rdi, %rdi
mov $60, %rax
syscall
.data
str:
.string "Hello World!\n"
strsize:
.quad .-str
$ gcc -Wall -c -o write.o write.s && ld -o write write.o
$ ./write
Hello World!
$ strace ./write
execve("./write", ["./write"], [/* 58 vars */]) = 0
write(1, "Hello World!\n\0", 14Hello World!
) = 14
_exit(0) = ?
+++ exited with 0 +++
$ cat write-nasm.s
section .text
global _start
_start:
mov rax, 0x1
mov rdi, rax
lea rsi, [hello]
mov rdx, length
syscall
xor edi, edi
mov rax, 60
syscall
section .data
hello db 'Hello World!', 10, 0
length equ $ - hello
$ nasm -f elf64 -o write-nasm.o write-nasm.s
$ ld -o write-nasm write-nasm.o
$ ./write-nasm
Hello World!
$ strace ./write-nasm
execve("./write-nasm", ["./write-nasm"], [/* 58 vars */]) = 0
write(1, "Hello World!\n\0", 14Hello World!
) = 14
_exit(0) = ?
+++ exited with 0 +++
I don't quite get what you mean, I never had any problem with
that.
Regards,
Christian
Reply to: