objcopy -O binary only outputting 16 bit data
Posted: Sun Aug 24, 2014 4:35 am
So, here is my c_test.c
Now i compile and link
Doing an 'objdump -d boot.bin1' results in
Note 8006: its using the 32-bit value 0xb80a0.
Next, I 'objcopy -O binary boot.bin1 boot.bin
Next, a 'ndisasm boot.bin' results in
Now, at offset 6, its only moving the 16-bit value 0x80a0, removing the 0x000b that should be in front of it.
Anyone have an idea why objcopy is using only a 16-bit value when transforming boot.bin1 to boot.bin?
Code: Select all
void entry()
{
unsigned *p = (unsigned *)(0xb8000 + 160);
p[0] = 0x0f42;
}
Code: Select all
gcc -nostdlib -m32 -c -o c_test.o c_test.c
ld -Ttext 0x8000 -melf_i386 -o boot.bin1 c_test.o
Code: Select all
00008000 <entry>:
8000: 55 push %ebp
8001: 89 e5 mov %esp,%ebp
8003: 83 ec 10 sub $0x10,%esp
8006: c7 45 fc a0 80 0b 00 movl $0xb80a0,-0x4(%ebp)
800d: 8b 45 fc mov -0x4(%ebp),%eax
8010: c7 00 42 0f 00 00 movl $0xf42,(%eax)
8016: c9 leave
8017: c3 ret
Next, I 'objcopy -O binary boot.bin1 boot.bin
Next, a 'ndisasm boot.bin' results in
Code: Select all
00000000 55 push bp
00000001 89E5 mov bp,sp
00000003 83EC10 sub sp,byte +0x10
00000006 C745FCA080 mov word [di-0x4],0x80a0
0000000B 0B00 or ax,[bx+si]
0000000D 8B45FC mov ax,[di-0x4]
00000010 C700420F mov word [bx+si],0xf42
00000014 0000 add [bx+si],al
00000016 C9 leave
00000017 C3 ret
Anyone have an idea why objcopy is using only a 16-bit value when transforming boot.bin1 to boot.bin?