I am trying to use GNU asas a universal assembler that is used as nasm. I create the template source as follows:
.section .text
.globl _start
.intel_syntax noprefix
_start:
call 0xb77431c0 # the instruction I want to assemble
And then I run the build command as follows:
as --32 -o test.o test.s
ld -m elf_i386 -Ttext 0xb77431d9 --oformat binary -o test.bin test.o
Everything works well with binutils 2.24. But it seems that asfrom binutils 2.22 (the one in Ubuntu Precise) aligns the partition .textto a 4-byte border, so instead of the expected disassembly, I get the wrong results:
$ ndisasm -b 32 -o 0xb77431d9 test.bin
B77431D9 E8E2FFFFFF call dword 0xb77431c0
$ ndisasm -b 32 -o 0xb77431d9 test.bin
B77431D9 90 nop
B77431DA 90 nop
B77431DB 90 nop
B77431DC E8DFFFFFFF call dword 0xb77431c0
The problem is the command as(i.e. not ld): readelf -Sgives me the following as2.22 results :
$ readelf -S test.o | grep ' \.text'
[ 1] .text PROGBITS 00000000 000034 000005 00 AX 0 0 4
And for 2.24 I have
$ readelf -S test.o | grep ' \.text'
[ 1] .text PROGBITS 00000000 000034 000005 00 AX 0 0 1
, .text. .align 0 .align 1 , .
, : ELF GNU?