Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

Freepascal and binary files? (Developers)

posted by Laaca Homepage, Czech republic, 29.10.2021, 00:17

Sorry for exhuming this thread but I did some further investigation in this topic.
1) Create a file HELLO.TXT with content like that:
Hello world!<CR><LF>

2) Call this line: "LD -r -b binary -o HELLO.O HELLO.TXT"
(I tried the LD.EXE ver. 2.17 from FPC 3.2.0 and LD.EXE ver. 2.9.1 from FPC 1.0.10 -- both work)

3) Write this FPC code:

var start_ptr:pointer;external name '_binary_hello_txt_start';
    size_ptr:pointer;external name '_binary_hello_txt_size';
    {end_ptr:pointer;external name '_binary_hello_txt_end';}

    my_start:pointer;
    my_size:longint;
    p:pchar;

begin
{$L hello.o}
my_start:=@start_ptr;
my_size:=longint(@size_ptr);

p:=my_start;
p[my_size]:=#0;  {Yeah, I know, I am crippling the LF char}
write(p);
end.


4) Compile it and run.

__BUT__
It works perfectly with FPC 1.0.10 and with FPC 2.4.2
However it does NOT with FPC 3.2.0 and 3.0.4 !
Why???
The 3.x.y versions of FPC refuse to compile the source with this error message:
"Error - Failed reading coff file, invalid section index while reading hello.o"

Edit: Well, it does compile if I set the compile option "Call linker after".
But... Can I make it work even without this option?

---
DOS-u-akbar!

 

Complete thread:

Back to the forum
Board view  Mix view
22752 Postings in 2119 Threads, 402 registered users (1 online)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum