delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2020/04/22/16:19:05

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Received: by 2002:a05:620a:1202:: with SMTP id u2mr29486802qkj.285.1587585619142;
Wed, 22 Apr 2020 13:00:19 -0700 (PDT)
X-Received: by 2002:a25:cc48:: with SMTP id l69mr866113ybf.459.1587585618817;
Wed, 22 Apr 2020 13:00:18 -0700 (PDT)
Newsgroups: comp.os.msdos.djgpp
Date: Wed, 22 Apr 2020 13:00:18 -0700 (PDT)
In-Reply-To: <b73af67e-9b17-40c7-9b8d-dcb6d70b2944@googlegroups.com>
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
References: <b73af67e-9b17-40c7-9b8d-dcb6d70b2944 AT googlegroups DOT com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <304921f6-fb52-4388-85ec-0ab5ed773417@googlegroups.com>
Subject: Re: 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 20:00:19 +0000
Bytes: 3095
Lines: 31
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 03MKFJWT001711
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Wednesday, April 22, 2020 at 3:31:44 AM UTC-4, nona DOT  DOT  DOT  AT gmail DOT com wrote:
> 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.

Here's an update. I told LLVM to generate code using the “large” code model, which made it avoid relative CALL instructions, but things still break down when trying to pass pointers between functions.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019