Код: Выделить всё
as
¹: Их объектные файлы различаются только в разделах, не связанных с кодом, и побитовое идентично, если я удалю --strip-section-headers *.o, так что я считаю, что это справедливое предположение.
NASM (v2.16.1):
Код: Выделить всё
; tiny-nasm.asm
SECTION .text
GLOBAL _start
_start:
mov eax, 60 ; Select the _exit syscall (60 in Linux ABI)
mov edi, 42 ; Set the exit code argument for _exit
syscall ; Perform the selected syscall
Код: Выделить всё
# tiny-gas.S
.SECTION .text
.GLOBL _start
_start:
mov $60, %eax # Select the _exit syscall (60 in Linux ABI)
mov $42, %edi # Set the exit code argument for _exit
syscall # Perform the selected syscall
Код: Выделить всё
nasm -f elf64 tiny-nasm.asm && ld -no-pie -z noseparate-code tiny-nasm.o -o tiny-nasm.bin
as tiny-gas.S -o tiny-gas.o && ld -no-pie -z noseparate-code tiny-gas.o -o tiny-gas.bin
strip --strip-section-headers *.bin
wc -c *.bin
diff -u
Подробнее здесь: [url]https://stackoverflow.com/questions/79225538/why-gnu-ld-has-different-output-from-nasm-vs-gas-o-files-using-equivalent-s[/url]