ftp.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2020/04/24/14:34:28

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Recipient: djgpp AT delorie DOT com
X-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20161025;
h=subject:to:references:cc:from:message-id:date:user-agent
:mime-version:in-reply-to:content-language:content-transfer-encoding;
bh=1NlGkhHF9f7h2/HJP4L0EyyT9MPTX6GI+PZvWTwhzHQ=;
b=sRu5KdVgDj4X5i1vauFDNm+AtRo/H1Tsf9E6FKGbAEwsPglz7pLw/PPdPiAsxVfY/G
qC67q/Q0kGOlqJOxsbIOYZG/E0Oz8ri6aEAiPRA++BMHTGNmDnfd4+nPzzorxVj/Ecwu
hYwcTJfx/x+EQ6S+Byo+lHWW/MqWDLyp2C72YrsBE8/Voz6Xb8ioxg8fMDgrBsemEl1w
nuyuDip21yxNnTZH6m6SIuZtJhpKHlbfpAvFiLWEXEGaeMdkilX2y4M1Lmt7jKb5TxG+
Pgq0gInPCQcdNahF8DOZpbLi5Vi3bz1lCVCrMt3mLKSXgHdtt13MLuSTu7hPtA+h75Py
4rIw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20161025;
h=x-gm-message-state:subject:to:references:cc:from:message-id:date
:user-agent:mime-version:in-reply-to:content-language
:content-transfer-encoding;
bh=1NlGkhHF9f7h2/HJP4L0EyyT9MPTX6GI+PZvWTwhzHQ=;
b=RedtdpoXYsueSDxBqIh1yQmTYN+mkn6eylUr+HCvIXa199a+MIzBCRxgzz0HO4XNLk
p7QQ7gCuf/FynqzA7GNdalOvGKR6JGwhBMfhdqqjpAv3J49rfUwBXzJARfvkQAZXBCr2
Rk8Pvny9JB2Sfmap8cfmillJmUu5+KG06zlVVxMBm0DlhNBLkEIk9vBJIxWz+LX+UoOH
qj+EaftjVbZ1Jvs98J44tKNYqg0WEIg4NMTU+kLeOxJExMqeIrwx17ggOXMDreRke0Ln
3XEQQiG8tEJ6kVbh5Om2LGddv7q+p15m7vQNVnI0Rv92PNYNndwEKCnnhLzpugWtTw2y
Cn+Q==
X-Gm-Message-State: AGi0PuaaQJJYVG0f1p5wTGFXdyee+mAAOszB2mYjxbZX0USElB4Z5PWu
gOAylIu4a4V3S2Hu0NQQ9cPS1lXT
X-Google-Smtp-Source: APiQypJoHDG0/bEr8pGYbhRsK1F0f9zxmc0s4o9423nEoCftI6HKH1rqHMBoPe+Hv+wCclJZgEWofQ==
X-Received: by 2002:adf:f844:: with SMTP id d4mr12381860wrq.362.1587752996404;
Fri, 24 Apr 2020 11:29:56 -0700 (PDT)
Subject: Re: Issues using DJGPP with Rust
To: noname422 AT gmail DOT com
References: <b73af67e-9b17-40c7-9b8d-dcb6d70b2944 AT googlegroups DOT com>
Cc: djgpp AT delorie DOT com
From: "J.W. Jagersma (jwjagersma AT gmail DOT com) [via djgpp AT delorie DOT com]" <djgpp AT delorie DOT com>
Message-ID: <8af0ebdd-acea-a7be-3388-d295af50bfc7@gmail.com>
Date: Fri, 24 Apr 2020 20:29:53 +0200
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:68.0) Gecko/20100101
Thunderbird/68.7.0
MIME-Version: 1.0
In-Reply-To: <b73af67e-9b17-40c7-9b8d-dcb6d70b2944@googlegroups.com>
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 2020-04-22 09:31, noname422 AT gmail DOT com [via djgpp AT delorie 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.

Hey, I like this idea, maybe I can help look into this.

Could you provide some more information on how to reproduce the
problem?  What does your build environment look like, I suppose you're
using ld from binutils?  How do you invoke the compiler and linker?

Also some example code or compiled object files would be useful for
those not familiar with Rust (like myself).

- Raw text -


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