How to make a bin file with FreePascal

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
Silenger

How to make a bin file with FreePascal

Post by Silenger »

You can make coff and elf files with FreePascal but how do you make flat binary's?

Can someone tell me how. I saw in an old post that you should use LD to do that but how?
Silenger

Re:How to make a bin file with FreePascal

Post by Silenger »

k I made the COFF files with free pascal then started ld with "ld.exe testos.o -o loader.bin -oformat binary" then i get the next thing:

testos.o(.text+0x7):testos.pas: undefined reference to `FPC_INITIALIZEUNITS'
testos.o(.text+0x15):testos.pas: undefined reference to `FPC_PUSHEXCEPTADDR'
testos.o(.text+0x1b):testos.pas: undefined reference to `FPC_SETJMP'
testos.o(.text+0x2c):testos.pas: undefined reference to `_SYSTEMV$$_WRITESTR$STR
ING'
testos.o(.text+0x31):testos.pas: undefined reference to `_SYSTEMV$$_READLN'
testos.o(.text+0x3b):testos.pas: undefined reference to `FPC_ANSISTR_DECR_REF'
testos.o(.text+0x48):testos.pas: undefined reference to `FPC_ANSISTR_DECR_REF'
testos.o(.text+0x51):testos.pas: undefined reference to `FPC_ANSISTR_DECR_REF'
testos.o(.text+0x56):testos.pas: undefined reference to `FPC_POPADDRSTACK'
testos.o(.text+0x60):testos.pas: undefined reference to `FPC_RERAISE'
testos.o(.text+0x65):testos.pas: undefined reference to `FPC_DO_EXIT'
testos.o(.data+0x34):testos.pas: undefined reference to `INIT$$SYSTEM'
testos.o(.data+0x3c):testos.pas: undefined reference to `INIT$$OBJPAS'
testos.o(.data+0x40):testos.pas: undefined reference to `FINALIZE$$OBJPAS'

Can't you use units? Like TESTOS.PAS -> is the program, SYSTEMV.PAS -> is the unit with the functions.
Silenger

Re:How to make a bin file with FreePascal

Post by Silenger »

[attachment deleted by admin]
Silenger

Re:How to make a bin file with FreePascal

Post by Silenger »

Is there a option in LD to use external functions ???
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:How to make a bin file with FreePascal

Post by Pype.Clicker »

You're missing the runtime support library for Pascal language. This library holds strings manipulations as well as environment setup/release for any Pascal program, and obviously some code to handle exceptions ...

You have to find out which libraries implement these (i.e. by grep "FPC_ANSI_STR_..." * -r in /usr/lib or wherever your libraries are installed) and then link statically with the library that provide the missing symbols

(i.e. if it is libfpc.a, ld testos.o libfpc.a -o loader.bin -oformat binary)
Silenger

Re:How to make a bin file with FreePascal

Post by Silenger »

Thx ;)
Silenger

Re:How to make a bin file with FreePascal

Post by Silenger »

Can you set the dir to use? Or you have to say every file you need.
Silenger

Re:How to make a bin file with FreePascal

Post by Silenger »

I found it:

C:\PasOSDev>C:\pp\bin\go32v2\ld.exe testos.o systemv.o -rpath-link C:\pp\units\g
o32v2\rtl\*.o C:\pp\units\go32v2\rtl\*.a -o loader.bin -oformat binary

You had to use the *.o files to. :D

But now i got a 231kb big binary file is this normal?
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:How to make a bin file with FreePascal

Post by Pype.Clicker »

for sure, RTL library needs a lot of space ... this is what you have to pay for a higher-level language :(
Now, maybe you can save some Kbs by not including *.a but only *really* mandatory files or by re-implementing a lightweight version of the library (in asm or C)
Silenger

Re:How to make a bin file with FreePascal

Post by Silenger »

k Thx
Piotr Sejfried

Re:How to make a bin file with FreePascal

Post by Piotr Sejfried »

Hi,

I know that it isn't reply for the topic but I see that somebody try to write OS in Free Pascal. FPC is similar to TMT Pascal in which I write my OS.

I'm interested in your OS and I'd like to talk about it with you. Could you tell me what is your e-mail address?

My is: [email protected]

I'm waiting for your reply

Best Regards
Peter
Silenger

Re:How to make a bin file with FreePascal

Post by Silenger »

I think i couldn't help much, i am a asm newbie and its only for fun. I'm just trying to make something that boots ;D

If you like my mail: [email protected]
Post Reply