Товарищи, есть .s файл такого вида:
.section .rodata
.LC0:
.string «Hi!»
.text
.globl _start
.type main, @function
_start:
pushl %ebp
movl %esp, %ebp
andl $-16, %esp
subl $16, %esp
movl $.LC0, (%esp)
call puts
movl $0, %eax
leave
ret
.size main, .-main
.section .note.GNU-stack,"",@progbits
Далее делаю следующее:
1. > as hello.s -o hello.o
2. > ld -lc -s -o hello hello.o
3. > ./hello
./hello: Command not found.
В чём я не прав? Самое интересное:
strace ./hello
execve("./hello", ["./hello"], [/* 24 vars */]) = -1 ENOEXEC (Exec format error)
dup(2) = 3
fcntl64(3, F_GETFL) = 0x8002 (flags O_RDWR|O_LARGEFILE)
fstat64(3, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 5), ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb78ac000
_llseek(3, 0, 0xbf9fe944, SEEK_CUR) = -1 ESPIPE (Illegal seek)
write(3, «strace: exec: Exec format error\n», 32strace: exec: Exec format error
) = 32
close(3) = 0
munmap(0xb78ac000, 4096) = 0
exit_group(1) = ?