flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > High Level Languages > A problem with the linker

Goto page 1, 2  Next
Author
Thread Post new topic Reply to topic
timryazthunder



Joined: 18 Jan 2014
Posts: 44
A problem with the linker
When I type ld -t link.ld -o kernel.bin ks.o kernel.o it gives me this: ks.o: File not recognized: File format not recognized. I'm using GCC, NASM and LD within CodeBlocks. Help me.

_________________
Enigma is for programmers! | Making DL-DOS 1.10 together! 1%
Post 09 Mar 2014, 15:11
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 15238
Location: 1I/╩╗Oumuamua
Moving to High Level Languages. Doesn't seem to be related to fasm or assembly.
Post 09 Mar 2014, 15:25
View user's profile Send private message Visit poster's website Reply with quote
sid123



Joined: 30 Jul 2013
Posts: 340
Location: Asia, Singapore
Hi,
You need to use a cross-compiler. The one you download for Windows/Unix will produce executables for Windows/Unix which will ccompile PE32/PE64/ELF32/ELF64 along with Windows/Unix libraries. From your posts you seem to be developing an operating system, remember that at the OS level there is no such libraries/runtime/framework or whatever the only thing below you is the firmware, SMM (System Management Mode) there is one thing to note that even if the OS is running the SMM code will still run, it handles things like PS/2 Emulation etc. more on that later. You need to use a cross-compiler i.e. a compiler that runs on a specific platform but emits binaries for another platform. I would recommend i586 or i686. You can view the instructions on building a cross compiler here: http://wiki.osdev.org/GCC_Cross-Compiler
(It's assumed that you're on a Unix-like platform if not use Cygwin under Windows). As for using an IDE like CodeBlocks I am doubtful about that, I guess that you would need some experience with the command line,
However you may wish to edit the sources in the IDE.
-sid123
Post 09 Mar 2014, 15:50
View user's profile Send private message Reply with quote
timryazthunder



Joined: 18 Jan 2014
Posts: 44
I tried doing that, it failed.
Post 09 Mar 2014, 16:07
View user's profile Send private message Reply with quote
sid123



Joined: 30 Jul 2013
Posts: 340
Location: Asia, Singapore
What message do you get?
If you can't even make a cross compiler, give up system programming </flamebait>
Post 09 Mar 2014, 23:42
View user's profile Send private message Reply with quote
timryazthunder



Joined: 18 Jan 2014
Posts: 44
When I type ld -t link.ld -o kernel.bin ks.o kernel.o it gives me this: ks.o: File not recognized: File format not recognized.
Post 10 Mar 2014, 06:32
View user's profile Send private message Reply with quote
timryazthunder



Joined: 18 Jan 2014
Posts: 44
I was using MinGW and Cygwin, they both failed. *facepalm*
Post 10 Mar 2014, 06:33
View user's profile Send private message Reply with quote
sid123



Joined: 30 Jul 2013
Posts: 340
Location: Asia, Singapore
What the ...? BUILD A CROSS COMPILER! And then compile your code with a cross compiler!
Post 10 Mar 2014, 08:32
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 15238
Location: 1I/╩╗Oumuamua
sid123: Somehow I think you are using the term "cross-assembler" in a way that is not the normal usage. Usually a cross-assembler assembles for a different CPU architecture and has nothing to do with the OS being used.
Post 10 Mar 2014, 08:38
View user's profile Send private message Visit poster's website Reply with quote
sid123



Joined: 30 Jul 2013
Posts: 340
Location: Asia, Singapore
@revolution Ah, I see what you mean there maybe I should've made the meaning of platform more clear, by platform I meant the OS, not the architecture. Or Did I misunderstand your point?

_________________
"Those who can make you believe in absurdities can make you commit atrocities" -- Voltaire https://github.com/Benderx2/R3X
XD
Post 10 Mar 2014, 10:23
View user's profile Send private message Reply with quote
timryazthunder



Joined: 18 Jan 2014
Posts: 44
I used all instructions from OSDev Wiki. Now I get this: kernel.o:kernel.c:(.text+0x16): undefined reference to `_outb'
kernel.o:kernel.c:(.text+0x2a): undefined reference to `_outb'
kernel.o:kernel.c:(.text+0x3d): undefined reference to `_outb'
kernel.o:kernel.c:(.text+0x50): undefined reference to `_outb'
kernel.o:kernel.c:(.text+0x64): undefined reference to `_outb'
kernel.o:kernel.c:(.text+0x78): more undefined references to `_outb' follow
kernel.o:kernel.c:(.text+0xf7): undefined reference to `_k_printf'
c:/djgpp/bin/ld.exe: kernel.bin(.eh_frame): relocation ".text+0x140 (type DISP32
)" goes out of range
c:/djgpp/bin/ld.exe: final link failed: Invalid operation.
Now I'm using DJGPP, other problems fixed.
Post 10 Mar 2014, 10:28
View user's profile Send private message Reply with quote
sid123



Joined: 30 Jul 2013
Posts: 340
Location: Asia, Singapore
This shows that you have NULL experience in C, and you're attempting to write a kernel.
They mean that, those functions are not being found when you're linking your kernel, you haven't written them and are trying to access or reference them.
And ALWAYS use a cross compiler! Will save you a lot of trouble. I recommend reading
some simple books that teach you about C, I myself learnt C from the book 'The C programming Language' by Dennis M Ritchie.
Post 10 Mar 2014, 10:54
View user's profile Send private message Reply with quote
timryazthunder



Joined: 18 Jan 2014
Posts: 44
Thanks, I'm reading that on my tablet.
Post 10 Mar 2014, 11:53
View user's profile Send private message Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 616
As this is a link stage error, I'm going to assume the compiler set up is correct and did something to produce the .o files. Those errors can still occur for a number of reasons:

- You have defined the function but not declared the function either in C (extern) or ASM (extrn/public[+as]) where it is used/defined
- You have have conflicting declarations due to architecture/call convention or type encoding e.g. cdecl might be '_outb' but fastcall might be 'outb' OR you have different architectures being linked [16/32/64]
- Missing C libraries (to be honest I never use ld directly and get gcc to do it for me but you might need add the C standard libraries for the printf reference or try gcc to see if helps)
Post 10 Mar 2014, 13:18
View user's profile Send private message Reply with quote
timryazthunder



Joined: 18 Jan 2014
Posts: 44
I programmed the PIC, that's why it gives me this error.
Post 10 Mar 2014, 15:02
View user's profile Send private message Reply with quote
timryazthunder



Joined: 18 Jan 2014
Posts: 44
But it won't help me. I made a cross-compiler but in the making it gives errors.
Post 10 Mar 2014, 15:29
View user's profile Send private message Reply with quote
sid123



Joined: 30 Jul 2013
Posts: 340
Location: Asia, Singapore
What error?
Programming the PICs are a crucial step for IRQs to work. If you can't get them working, you would never be able to write a keyboard or a floppy driver.
Post 11 Mar 2014, 00:07
View user's profile Send private message Reply with quote
timryazthunder



Joined: 18 Jan 2014
Posts: 44
The same one. I think of trying, I watched a tutorial on Cygwin, it didn't work.
Post 11 Mar 2014, 07:33
View user's profile Send private message Reply with quote
timryazthunder



Joined: 18 Jan 2014
Posts: 44
I use a virtual machine running Windows XP and I need tutorials on the cross-compiler for WINDOWS.
Post 12 Mar 2014, 11:45
View user's profile Send private message Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 616
If you can post source code, command lines and compiler/OS details, it would be easier to work out the problem.
Post 12 Mar 2014, 17:31
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  Next

< Last Thread | Next Thread >

Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.