Freepascal and binary files? (Developers)
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:
- Freepascal and binary files? - Laaca, 20.05.2020, 23:15 (Developers)
![Open in board view [Board]](img/board_d.gif)
![Open in mix view [Mix]](img/mix_d.gif)
- Freepascal and binary files? - RayeR, 21.05.2020, 01:46
- Freepascal and binary files? - Laaca, 21.05.2020, 10:36
- Freepascal and binary files? - Rugxulo, 21.05.2020, 02:27
- Freepascal and binary files? - marcov, 21.05.2020, 12:25
- Freepascal and binary files? - Laaca, 21.05.2020, 17:30
- Freepascal and binary files? - marcov, 22.05.2020, 13:17
- Freepascal and binary files? - Laaca, 21.05.2020, 17:30
- Freepascal and binary files? - Rugxulo, 31.05.2020, 18:50
- Freepascal and binary files? - CandyMan, 11.06.2020, 12:29
- Freepascal and binary files? - Laaca, 12.06.2020, 07:37
- Freepascal and binary files? - Laaca, 29.10.2021, 00:17
- Freepascal and binary files? - tkchia, 30.10.2021, 07:33
- Freepascal and binary files? - Laaca, 30.10.2021, 12:29
- Freepascal and binary files? - tkchia, 30.10.2021, 19:01
- Freepascal and binary files? - Rugxulo, 28.08.2022, 23:21
- Freepascal and binary files? - tkchia, 30.10.2021, 19:01
- Freepascal and binary files? - Laaca, 30.10.2021, 12:29
- Freepascal and binary files? - tkchia, 30.10.2021, 07:33
- Freepascal and binary files? - RayeR, 21.05.2020, 01:46
Mix view