ld skipping incompatible object on amd64

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
carbonBased
Member
Member
Posts: 382
Joined: Sat Nov 20, 2004 12:00 am
Location: Wellesley, Ontario, Canada
Contact:

ld skipping incompatible object on amd64

Post by carbonBased »

Hey everyone,

Been a while sense I've been able to check this site, as work's been crazy-busy.

I did, however, just manage to build myself a new AMD64 system, but I'm having difficulties building my OS now!

I've changed my ant build scripts to force gcc to compile 32-bit code (appended the -m32 -oformat=elf32-i386 params).

ld, however, refuses to accept my nasm build start.obj file. I don't understand this. I've checked all my objects and they are correctly elf32-i386 format (objdump --file-headers). ld doesn't complain about any other nasm built objects, either.

The only thing that's different about this particular object is the exact code in it, as far as I can tell.

Can anybody suggest to me why ld doesn't like this file?

I've provided the source, in case anybody would like to look at it.

Thanks,
Jeff
Attachments
start.asm
start.asm source code
(6.3 KiB) Downloaded 70 times
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

1: could you please give the error message?
2: i hope your includes contain no code
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
carbonBased
Member
Member
Posts: 382
Joined: Sat Nov 20, 2004 12:00 am
Location: Wellesley, Ontario, Canada
Contact:

Post by carbonBased »

Yes, of course! Sorry :)

Below is the verbose output. And yes, the include file is merely a bunch of build-time generated %define statements.

--Jeff

link:
[ld] Creating linker script: built/bin/ldscript
[ld] ld -nostdlib -nostartfiles -b elf32-i386 --oformat elf32-i386 --verbose -T built/bin/ldscript -o built/bin/ndk.i386.kernel
[null] ld: skipping incompatible built/obj/arch/i386/start.o when searching for built/obj/arch/i386/start.o
[null] ld: cannot find built/obj/arch/i386/start.o
[null] GNU ld version 2.17.50.0.5 20060927 (SUSE Linux)
[null] Supported emulations:
[null] elf_x86_64
[null] elf_i386
[null] i386linux
[null] elf64alpha
[null] alpha
[null] armelf_linux
[null] armelf
[null] hppalinux
[null] elf64_ia64
[null] m68kelf
[null] m68klinux
[null] elf32ppclinux
[null] elf32ppc
[null] elf32ppcsim
[null] elf64ppc
[null] elf_s390
[null] elf64_s390
[null] elf32_sparc
[null] sparclinux
[null] elf64_sparc
[null] sun4
[null] i386pe
[null] opened script file built/bin/ldscript
[null] using external linker script:
[null] ==================================================
[null] INPUT(built/obj/arch/i386/start.o)
[null] INPUT(built/obj/arch/i386/arch.o)
[null] INPUT(built/obj/arch/i386/console.o)
[null] INPUT(built/obj/arch/i386/descgate.o)
[null] INPUT(built/obj/arch/i386/gdt.o)
[null] INPUT(built/obj/arch/i386/idt.o)
[null] INPUT(built/obj/arch/i386/io.o)
[null] INPUT(built/obj/arch/i386/isr.o)
[null] INPUT(built/obj/arch/i386/memory.o)
[null] INPUT(built/obj/arch/i386/multiboot.o)
[null] INPUT(built/obj/arch/i386/pager.o)
[null] INPUT(built/obj/arch/i386/pic.o)
[null] INPUT(built/obj/arch/i386/pmode.o)
[null] INPUT(built/obj/arch/i386/system.o)
[null] INPUT(built/obj/arch/i386/task.o)
[null] INPUT(built/obj/arch/i386/timer.o)
[null] INPUT(built/obj/arch/i386/vm86.o)
[null] INPUT(built/obj/arch/i386/vm86asm.o)
[null] INPUT(built/obj/appInterface.o)
[null] INPUT(built/obj/array.o)
[null] INPUT(built/obj/binaryTree.o)
[null] INPUT(built/obj/debug.o)
[null] INPUT(built/obj/driver.o)
[null] INPUT(built/obj/expandingQueue.o)
[null] INPUT(built/obj/hashTable.o)
[null] INPUT(built/obj/list.o)
[null] INPUT(built/obj/messageQueue.o)
[null] INPUT(built/obj/mutex.o)
[null] INPUT(built/obj/ndk.o)
[null] INPUT(built/obj/object.o)
[null] INPUT(built/obj/objectKernel.o)
[null] INPUT(built/obj/objectRDOFF2.o)
[null] INPUT(built/obj/queue.o)
[null] INPUT(built/obj/rZero.o)
[null] INPUT(built/obj/semaphore.o)
[null] INPUT(built/obj/stack.o)
[null] INPUT(built/obj/tests/tests.o)
[null] INPUT(built/obj/tests/testsBTree.o)
[null] INPUT(built/obj/tests/testsDriverManager.o)
[null] INPUT(built/obj/tests/testsMutex.o)
[null] INPUT(built/obj/klibc/assert.o)
[null] INPUT(built/obj/klibc/ctype.o)
[null] INPUT(built/obj/klibc/errno.o)
[null] INPUT(built/obj/klibc/fprintf.o)
[null] INPUT(built/obj/klibc/malloc.o)
[null] INPUT(built/obj/klibc/printf.o)
[null] INPUT(built/obj/klibc/sbrk.o)
[null] INPUT(built/obj/klibc/string.o)
[null] INPUT(built/obj/klibc/sysconf.o)
[null] SECTIONS {
[null] .text 0x00100000 :{
[null] *(.text)
[null] }
[null] textEnd = .;

[null] .data :{
[null] *(.data)
[null] *(.rodata)
[null] }
[null] dataEnd = .;

[null] .bss :{
[null] *(.common)
[null] *(.bss)
[null] }
[null] bssEnd = .;
[null] }
[null] ==================================================
[null] attempt to open built/obj/arch/i386/start.o succeeded

BUILD FAILED
/home/dcipher/osDev/ndk/build.xml:355: null returned: 1
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

CarbonBased wrote:start.obj
ld wrote:ld: cannot find (...)/start.o
typo?
[null] GNU ld version 2.17.50.0.5 20060927 (SUSE Linux)
you are trying to force 32-bit apps out of a 64-bit toolchain? elf32-i386 is NOT listed and it might be that it chokes on the first file in the list then quits before even trying the rest...
If you are indeed running a 64 bit linux, you should definately get a crosscompiler as you are essentially targeting a different architecture.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
carbonBased
Member
Member
Posts: 382
Joined: Sat Nov 20, 2004 12:00 am
Location: Wellesley, Ontario, Canada
Contact:

Post by carbonBased »

Combuster wrote:
CarbonBased wrote:start.obj
ld wrote:ld: cannot find (...)/start.o
typo?
Yeah, the obj was a typo -- you've got good eyes! :)
Combuster wrote:
[null] GNU ld version 2.17.50.0.5 20060927 (SUSE Linux)
you are trying to force 32-bit apps out of a 64-bit toolchain? elf32-i386 is NOT listed and it might be that it chokes on the first file in the list then quits before even trying the rest...
Hmm... yes, you're right. I re-ordered the objects and now another one fails. Should've thought of that first.

I made an assumption that elf_i386 would be compatible with elf32-i386. It appears as though it's not the case. I'm curious as to what the distinction between the two formats is (?).
Combuster wrote: If you are indeed running a 64 bit linux, you should definately get a crosscompiler as you are essentially targeting a different architecture.
Fair enough, will do.

EDIT: Done, worked like a charm, of course.
For those that might be interested, Buenos hosts a good quick tutorial on writting cross compilers. I've used it in the past to build several:

http://www.niksula.hut.fi/~buenos/cross-compiler.html

Only thing I've changed is the addition of --disable-libssp when configuring GCC.

Thanks,
Jeff
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Post by Solar »

carbonBased wrote:For those that might be interested, Buenos hosts a good quick tutorial on writting cross compilers. I've used it in the past to build several:
Basically the same we have in http://www.osdev.org/wiki/GCC_Cross-Compiler, but we also have http://www.osdev.org/wiki/GCC_Cross-Compiler_for_x86_64 and http://www.osdev.org/wiki/GCC_Cross-Compiler_on_Linux. If you find an "integrated" way of adding a cross-compiler to a SuSE setup, you're very welcome to edit the last from that list. ;)
Every good solution is obvious once you've found it.
Post Reply