delorie.com/archives/browse.cgi | search |
X-Authentication-Warning: | delorie.com: mail set sender to djgpp-bounces using -f |
X-Received: | by 2002:ac8:5216:: with SMTP id r22mr2118689qtn.266.1587540703622; |
Wed, 22 Apr 2020 00:31:43 -0700 (PDT) | |
X-Received: | by 2002:a25:e010:: with SMTP id x16mr938137ybg.384.1587540703294; |
Wed, 22 Apr 2020 00:31:43 -0700 (PDT) | |
Newsgroups: | comp.os.msdos.djgpp |
Date: | Wed, 22 Apr 2020 00:31:43 -0700 (PDT) |
Complaints-To: | groups-abuse AT google DOT com |
Injection-Info: | google-groups.googlegroups.com; posting-host=45.58.213.126; posting-account=DTw6mgoAAABVKmwnaJ8FE6P8zb_HY_u- |
NNTP-Posting-Host: | 45.58.213.126 |
User-Agent: | G2/1.0 |
MIME-Version: | 1.0 |
Message-ID: | <b73af67e-9b17-40c7-9b8d-dcb6d70b2944@googlegroups.com> |
Subject: | Issues using DJGPP with Rust |
From: | "noname422 AT gmail DOT com [via djgpp AT delorie DOT com]" <djgpp AT delorie DOT com> |
Injection-Date: | Wed, 22 Apr 2020 07:31:43 +0000 |
Bytes: | 2619 |
Lines: | 26 |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
X-MIME-Autoconverted: | from quoted-printable to 8bit by delorie.com id 03M7jHI8017476 |
Reply-To: | djgpp AT delorie DOT com |
Hi everyone! 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 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 to be related to the linking stage and to the combination of Rust with DJGPP. 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 (opcode E8). 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 to reflect the changing distance to the target. The more functions a function calls, the more out of sync the offset seems to become, and eventually CALL instructions might even point to the middle of the wrong function altogether. 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.
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |