How to create an image file with a specific size from a linked absolute code

ali hagigat hagigatali@gmail.com
Mon May 16 06:39:00 GMT 2011


I am using two assembly files and a linker script like what follows:

asm2.s:

#comment1
.comm dovom, 10
.byte 12,15,28
aval:
movl %edx, 32(%edi)

asm3.s:

.section .text
.comm dovom, 10
aval:
movl $26, %eax

asm2.ld:
SECTIONS
{
	section5 0 :
	{
		*(.data);
		*(.bss);
	} = 0xffffffff

	.text 0x400000 :
	{
		*(.text);
		BYTE(0x57);
		BYTE(0x58);
		BYTE(0x59);
	} = 0xffffffff
}

It means that between between section5 and .text there is a huge gap!
Then I compile with:
ld asm2.o asm3.o -T asm2.ld -o asm2
objcopy -O binary asm2 asm2.img

I want my final image, means asm2.img, becomes 4 mega bytes and the
space between section5 and .text gets filled by 0xff.
I wonder if anybody knows how to do.
Thank you.



More information about the Binutils mailing list