Skip to content

Commit 82e4590

Browse files
committed
update platform-support.md
1 parent 349325d commit 82e4590

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

library/std/src/sys/pal/unix/process/process_unix.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ use libc::{c_int, pid_t};
2424
use libc::{gid_t, uid_t};
2525

2626
cfg_if::cfg_if! {
27-
if #[cfg(target_os = "nto")] {
27+
// This workaround is only needed for QNX 7.0 and 7.1. The bug should have been fixed in 8.0
28+
if #[cfg(any(target_env = "nto70", target_env = "nto71"))] {
2829
use crate::thread;
2930
use libc::{c_char, posix_spawn_file_actions_t, posix_spawnattr_t};
3031
use crate::time::Duration;
@@ -191,7 +192,12 @@ impl Command {
191192

192193
// Attempts to fork the process. If successful, returns Ok((0, -1))
193194
// in the child, and Ok((child_pid, -1)) in the parent.
194-
#[cfg(not(any(target_os = "watchos", target_os = "tvos", target_os = "nto")))]
195+
#[cfg(not(any(
196+
target_os = "watchos",
197+
target_os = "tvos",
198+
target_env = "nto70",
199+
target_env = "nto71"
200+
)))]
195201
unsafe fn do_fork(&mut self) -> Result<pid_t, io::Error> {
196202
cvt(libc::fork())
197203
}
@@ -200,7 +206,8 @@ impl Command {
200206
// or closed a file descriptor while the fork() was occurring".
201207
// Documentation says "... or try calling fork() again". This is what we do here.
202208
// See also https://www.qnx.com/developers/docs/7.1/#com.qnx.doc.neutrino.lib_ref/topic/f/fork.html
203-
#[cfg(target_os = "nto")]
209+
// This workaround is only needed for QNX 7.0 and 7.1. The bug should have been fixed in 8.0
210+
#[cfg(any(target_env = "nto70", target_env = "nto71"))]
204211
unsafe fn do_fork(&mut self) -> Result<pid_t, io::Error> {
205212
use crate::sys::os::errno;
206213

src/doc/rustc/src/platform-support.md

+1
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ target | std | host | notes
254254
[`aarch64-kmc-solid_asp3`](platform-support/kmc-solid.md) | ✓ | | ARM64 SOLID with TOPPERS/ASP3
255255
[`aarch64-nintendo-switch-freestanding`](platform-support/aarch64-nintendo-switch-freestanding.md) | * | | ARM64 Nintendo Switch, Horizon
256256
[`aarch64-unknown-teeos`](platform-support/aarch64-unknown-teeos.md) | ? | | ARM64 TEEOS |
257+
[`aarch64-unknown-nto-qnx700`](platform-support/nto-qnx.md) | ✓ | | ARM64 QNX Neutrino 7.0 RTOS |
257258
[`aarch64-unknown-nto-qnx710`](platform-support/nto-qnx.md) | ✓ | | ARM64 QNX Neutrino 7.1 RTOS |
258259
`aarch64-unknown-freebsd` | ✓ | ✓ | ARM64 FreeBSD
259260
[`aarch64-unknown-hermit`](platform-support/hermit.md) | ✓ | | ARM64 Hermit

src/doc/rustc/src/platform-support/nto-qnx.md

+18
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Currently, the following QNX Neutrino versions and compilation targets are suppo
2424
|----------------------|---------------------|:------------:|:----------------:|
2525
| 7.1 | AArch64 |||
2626
| 7.1 | x86_64 |||
27+
| 7.0 | AArch64 |||
2728
| 7.0 | x86 | ||
2829

2930
Adding other architectures that are supported by QNX Neutrino is possible.
@@ -43,6 +44,23 @@ When linking `no_std` applications, they must link against `libc.so` (see exampl
4344
required because applications always link against the `crt` library and `crt` depends on `libc.so`.
4445
This is done automatically when using the standard library.
4546

47+
### Disabling RELocation Read-Only (RELRO)
48+
49+
While not recommended by default, some QNX kernel setups may require the `RELRO` to be disabled with `-C relro_level=off`, e.g. by adding it to the `.cargo/config.toml` file:
50+
51+
```toml
52+
[target.aarch64-unknown-nto-qnx700]
53+
rustflags = ["-C", "relro_level=off"]
54+
```
55+
56+
If your QNX kernel does not allow it, and `relro` is not disabled, running compiled binary would fail with `syntax error: ... unexpected` or similar. This is due to kernel trying to interpret compiled binary with `/bin/sh`, and obviously failing. To verify that this is really the case, run your binary with the `DL_DEBUG=all` env var, and look for this output. If you see it, you should disable `relro` as described above.
57+
58+
```text
59+
Resolution scope for Executable->/bin/sh:
60+
Executable->/bin/sh
61+
libc.so.4->/usr/lib/ldqnx-64.so.2
62+
```
63+
4664
### Small example application
4765

4866
Small `no_std` example is shown below. Applications using the standard library work as well.

0 commit comments

Comments
 (0)