Hi everyone!the 386 at a minimum anyway. So now I'm using DJGPP both for linking and to compile pieces of bootstrap C code. However, I've been running into issues with the linker generating incorrect addresses for function calls. I'm asking here because this seems
I've been trying to use Rust to write software for MS-DOS. At first I was compiling it to real mode code, but I quickly realized that protected mode was more practical, and didn't increase the system requirements since LLVM (which Rust uses) targets
C code seems to have no issues calling either other C functions or Rust functions. However, Rust code seems to be having issues calling both other Rust functions and C functions. Both C code and Rust code is using IP-relative CALL instructions (opcodeE8). However, calls made from Rust code end up with incorrect offsets and often point to the middle of the target function instead of the beginning. If a function calls another function repeatedly the offset will stay the same, when it should be changing
I've tried changing all sorts of things with both Rust and DJGPP, including the relocation model used for Rust code, and DJGPP linker flags relating to position-independent code.
Any help with this would be greatly appreciated.
Hi everyone!the 386 at a minimum anyway. So now I'm using DJGPP both for linking and to compile pieces of bootstrap C code. However, I've been running into issues with the linker generating incorrect addresses for function calls. I'm asking here because this seems
I've been trying to use Rust to write software for MS-DOS. At first I was compiling it to real mode code, but I quickly realized that protected mode was more practical, and didn't increase the system requirements since LLVM (which Rust uses) targets
C code seems to have no issues calling either other C functions or Rust functions. However, Rust code seems to be having issues calling both other Rust functions and C functions. Both C code and Rust code is using IP-relative CALL instructions (opcodeE8). However, calls made from Rust code end up with incorrect offsets and often point to the middle of the target function instead of the beginning. If a function calls another function repeatedly the offset will stay the same, when it should be changing
I've tried changing all sorts of things with both Rust and DJGPP, including the relocation model used for Rust code, and DJGPP linker flags relating to position-independent code.
Any help with this would be greatly appreciated.
Hi, nice idea.
I have read your conversation in github.
Can you post here the result of the file command applied to files you try to link?
Remember that djgpp use coff format, which is different from PE for Windows and different to elf to.
PE is descendent of coff, they have some common parts. Weird functions address can come from here.
On Monday, April 27, 2020 at 1:33:59 PM UTC-4, Sébastien GUILLAUME wrote:
Hi, nice idea.
I have read your conversation in github.
Can you post here the result of the file command applied to files you try to link?
Remember that djgpp use coff format, which is different from PE for Windows and different to elf to.
PE is descendent of coff, they have some common parts. Weird functions address can come from here.
I ran it on one of the object files for my program and this is what I got.
dos32-dcb1f62a4632e187.dos32.frqh9yy0-cgu.0.rcgu.o: Intel 80386 COFF object file,
not stripped, 4 sections, symbol offset=0x234, 15 symbols
Le lundi 27 avril 2020 21:02:22 UTC+2, nona...@gmail.com a écrit :
On Monday, April 27, 2020 at 1:33:59 PM UTC-4, Sébastien GUILLAUME wrote:
Hi, nice idea.
I have read your conversation in github.
Can you post here the result of the file command applied to files you try to link?
Remember that djgpp use coff format, which is different from PE for Windows and different to elf to.
PE is descendent of coff, they have some common parts. Weird functions address can come from here.
I ran it on one of the object files for my program and this is what I got.
dos32-dcb1f62a4632e187.dos32.frqh9yy0-cgu.0.rcgu.o: Intel 80386 COFF object file,
not stripped, 4 sections, symbol offset=0x234, 15 symbols
wich compiler made this files ?
I don't know how to switch to nightly rust, gentoo doesn't give rustup package, so I can't build the rust part.
This is what I gave when I try to compile startup.c with this command line : $ i586-pc-msdosdjgpp-gcc -c startup.c -o startup.o
$ file startup.o
startup.o: Intel 80386 COFF object file, no line number info, not stripped, 5 sections, symbol offset=0x19c, 16 symbols
$ i586-pc-msdosdjgpp-strings -tx startup.o
14 .text
3c .data
64 .bss
8c .comment
11c GCC: (GNU) 7.2.0
19c .file
1ae startup.c
1c0 .text
1e4 .data
208 .bss
22c .comment
274 _main
298 _exit
2c0 .eh_frame
2ca .eh_frame
2d4 ___djgpp_nearptr_enable
2ec _rust_main
We can see that we have different number of section and symbols. It can be something interesting.
What do you have with your tools?
To realise my test, I used :
- GNU Binutils 2.29
- GCC 7.2.0
- file-5.37
- rustc 1.41.1
- cargo 1.41.0
OK,
can you post an archive with object file used to link the exe?
The build directory with all temporary files, from rustc and djgpp.
I have read the new post github, the idea of converting files with objectcopy is interesting, I will build binutils to have the support of pecoff and coff-go32, it's easy with Gentoo.
On Tuesday, April 28, 2020 at 12:35:02 PM UTC-4, Sébastien GUILLAUME wrote:unfortunately.
OK,
can you post an archive with object file used to link the exe?
The build directory with all temporary files, from rustc and djgpp.
I have read the new post github, the idea of converting files with objectcopy is interesting, I will build binutils to have the support of pecoff and coff-go32, it's easy with Gentoo.
Unfortunately stopping a Cargo build in the middle is difficult. It deletes the object files when it's done linking, so I think it caches them in some other format for when you want to rebuild. It might be best to just install nightly Rust
On Tuesday, April 28, 2020 at 12:35:02 PM UTC-4, Sébastien GUILLAUME wrote:unfortunately.
OK,
can you post an archive with object file used to link the exe?
The build directory with all temporary files, from rustc and djgpp.
I have read the new post github, the idea of converting files with objectcopy is interesting, I will build binutils to have the support of pecoff and coff-go32, it's easy with Gentoo.
Unfortunately stopping a Cargo build in the middle is difficult. It deletes the object files when it's done linking, so I think it caches them in some other format for when you want to rebuild. It might be best to just install nightly Rust
I won't install nightly on my system, I don't want to break it and discover strange error message at the next firfox update.
Your idea is to call C from Rust in DOS and using DJGPP libc, that's right?
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 349 |
Nodes: | 16 (0 / 16) |
Uptime: | 142:47:40 |
Calls: | 7,613 |
Calls today: | 1 |
Files: | 12,790 |
Messages: | 5,684,507 |