I've compile 32bit nasm source code using
Code: Select all
nasm start.asm -f aout -f start.o
Code: Select all
ld -T link.ld -o kernel start.o
Code: Select all
OUTPUT_FORMAT("binary")
ENTRY(start)
phys = 0x00100000;
SECTIONS
{
.text phys : AT(phys)
{
code = .;
*(.text)
*(.rodata)
. = ALIGN(4096);
}
.data : AT(phys + (data - code))
{
data = .;
*(.data)
. = ALIGN(4096);
}
.bss : AT(phys + (bss - code))
{
bss = .;
*(.bss)
. = ALIGN(4096);
}
end = .;
}
Code: Select all
[color=#FF0000]ld: i386 architecture of input file `start.o' is incompatible with i386:x86-64 output[/color]
Code: Select all
GNU ld (GNU Binutils for Ubuntu) 2.23.52.20130913
Supported emulations:
elf_x86_64
elf32_x86_64
elf_i386
i386linux
elf_l1om
elf_k1om
i386pep
i386pe
Question: how can I use ld to link 32 bit output with flat format using 32 bit input?