GNU ld, inflating binary
Posted: Wed Mar 14, 2012 1:31 pm
Hi,
I have a problem and searching has gotten me nowhere this afternoon. Basically my 16 bit code is being assembled and linked fine to the constraints of 512bytes (for a bootloader). However as soon as I add an instruction the file is inflated with zero bytes.
This code is fine and stays 512bytes in size:
This code does not and I have only added a single instruction
Am assembling with "as file -o file.o" and linking with "ld --oformat binary --Ttext 0x7c00 -o boot.bin boot.o"
Any ideas?
Thanks,
Jim
I have a problem and searching has gotten me nowhere this afternoon. Basically my 16 bit code is being assembled and linked fine to the constraints of 512bytes (for a bootloader). However as soon as I add an instruction the file is inflated with zero bytes.
This code is fine and stays 512bytes in size:
Code: Select all
.code16
.text
.global _start
_start:
/*
* Starting code for bootloader
* IN:
* OUT:
* DESCRIPTION:
*/
.bootloader_begin:
/*
* DATA USED BY PROGRAM
*
*/
.data
#STRINGS
kernel_filename: .ascii "KERNEL BIN"
disk_error: .asciz "Floppy disk error..."
file_not_found: .asciz "KERNEL.BIN not found"
reboot_message: .asciz "Press any key to reboot..."
#PADDING
.org (510 - ($$ - $)),0x00
#MAGIC NUMBER FOR BOOT
.byte 0x55, 0xAA
.buffer:
Code: Select all
.code16
.text
.global _start
_start:
/*
* Starting code for bootloader
* IN:
* OUT:
* DESCRIPTION:
*/
.bootloader_begin:
movw 0x07C0, %ax
/*
* DATA USED BY PROGRAM
*
*/
.data
#STRINGS
kernel_filename: .ascii "KERNEL BIN"
disk_error: .asciz "Floppy disk error..."
file_not_found: .asciz "KERNEL.BIN not found"
reboot_message: .asciz "Press any key to reboot..."
#PADDING
.org (510 - ($$ - $)),0x00
#MAGIC NUMBER FOR BOOT
.byte 0x55, 0xAA
.buffer:
Any ideas?
Thanks,
Jim