Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
strategy:
matrix:
build: [ubuntu, i686-linux, aarch64-linux, riscv64-linux]
rust: [1.78, nightly-2025-03-05]
rust: [1.84, nightly-2025-03-05]
include:
- build: ubuntu
os: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ edition = "2021"
keywords = ["linux"]
categories = ["no-std"]
include = ["src", "Cargo.toml", "COPYRIGHT", "LICENSE*", "/*.md"]
rust-version = "1.78"
rust-version = "1.84"

[dependencies]
linux-raw-sys = { version = "0.9.2", default-features = false, features = ["general", "no_std", "elf"] }
Expand Down
5 changes: 0 additions & 5 deletions src/arch/x86.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
//! Architecture-specific assembly code.

#[cfg(feature = "take-charge")]
#[cfg(feature = "thread")]
#[cfg(not(feature = "nightly"))]
use crate::ptr::{without_provenance_mut, Polyfill as _};
#[cfg(any(
feature = "take-charge",
all(not(feature = "unwinding"), feature = "panic-handler-trap")
))]
use core::arch::asm;
#[cfg(feature = "take-charge")]
#[cfg(feature = "thread")]
#[cfg(feature = "nightly")]
use core::ptr::without_provenance_mut;
#[cfg(all(feature = "experimental-relocate", feature = "origin-start"))]
#[cfg(relocation_model = "pic")]
Expand Down
3 changes: 0 additions & 3 deletions src/getauxval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
//!
//! This may be needed to satisfy `compiler_builtins` or other low-level code.

#[cfg(not(feature = "nightly"))]
use crate::ptr::without_provenance_mut;
use core::ffi::{c_ulong, c_void};
#[cfg(feature = "nightly")]
use core::ptr::without_provenance_mut;

// `getauxval` usually returns `unsigned long`, but we make it a pointer type
Expand Down
8 changes: 0 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,10 @@
all(debug_assertions, feature = "nightly"),
feature(link_llvm_intrinsics)
)]
// Allow our polyfills to polyfill nightly features.
#![cfg_attr(not(feature = "nightly"), allow(unstable_name_collisions))]
// Allow `Polyfill` imports to be unused for now.
#![cfg_attr(not(feature = "nightly"), allow(unused_imports))]

#[cfg(all(feature = "alloc", not(feature = "rustc-dep-of-std")))]
extern crate alloc;

// Strict-provenance API polyfill.
#[cfg(not(feature = "nightly"))]
pub(crate) mod ptr;

// Wrapper/polyfill for `#[naked]`.
#[macro_use]
pub(crate) mod naked;
Expand Down
3 changes: 0 additions & 3 deletions src/mem/fast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
//!
//! [compiler_builtins library]: https://github.com/rust-lang/compiler-builtins

#[cfg(not(feature = "nightly"))]
use crate::ptr::Polyfill as _;

// memcpy/memmove/memset have optimized implementations on some architectures
#[cfg_attr(target_arch = "x86_64", path = "x86_64.rs")]
#[cfg_attr(not(target_arch = "x86_64"), path = "impls.rs")]
Expand Down
3 changes: 0 additions & 3 deletions src/mem/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
//!
//! [compiler_builtins library]: https://github.com/rust-lang/compiler-builtins

#[cfg(not(feature = "nightly"))]
use crate::ptr::Polyfill as _;

const WORD_SIZE: usize = core::mem::size_of::<usize>();
const WORD_MASK: usize = WORD_SIZE - 1;

Expand Down
2 changes: 0 additions & 2 deletions src/mem/small.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
//! This code uses `core::arch::asm!("")` to try to discourage optimizers from
//! vectorizing or pattern-matching these loops.

#[cfg(not(feature = "nightly"))]
use crate::ptr::Polyfill as _;
use core::ffi::{c_char, c_int, c_void};

#[no_mangle]
Expand Down
2 changes: 0 additions & 2 deletions src/mem/x86_64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
// feature is present at compile-time. We don't bother detecting other features.
// Note that ERMSB does not enhance the backwards (DF=1) "rep movsb".

#[cfg(not(feature = "nightly"))]
use crate::ptr::Polyfill as _;
use core::arch::asm;
use core::mem;

Expand Down
3 changes: 0 additions & 3 deletions src/program/linux_raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ pub(super) unsafe extern "C" fn entry(mem: *mut usize) -> ! {
#[cfg(debug_assertions)]
#[cfg(feature = "origin-start")]
{
#[cfg(not(feature = "nightly"))]
use crate::ptr::Polyfill;

// Check that `mem` is where we expect it to be.
debug_assert_ne!(mem, core::ptr::null_mut());
debug_assert_eq!(mem.addr() & 0xf, 0);
Expand Down
87 changes: 0 additions & 87 deletions src/ptr.rs

This file was deleted.

20 changes: 5 additions & 15 deletions src/relocate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,12 @@ use crate::arch::{
dynamic_table_addr, ehdr_addr, relocation_load, relocation_mprotect_readonly, relocation_store,
trap,
};
#[cfg(not(feature = "nightly"))]
use crate::ptr::addr;
use core::ffi::c_void;
use core::mem;
use core::ptr::{null, null_mut};
use linux_raw_sys::elf::*;
use linux_raw_sys::general::{AT_BASE, AT_ENTRY, AT_NULL, AT_PAGESZ};

/// Wrapper around `.addr()` for pointers, because we can't use the polyfill
/// in the relocation code because that might emit calls to things that aren't
/// relocated yet.
#[cfg(feature = "nightly")]
fn addr<T>(addr: *const T) -> usize {
addr.addr()
}

// The Linux UAPI headers don't define the .relr types and consts yet.
#[allow(non_camel_case_types)]
type Elf_Relr = usize;
Expand Down Expand Up @@ -105,7 +95,7 @@ pub(super) unsafe fn relocate(envp: *mut *mut u8) {

match a_type as _ {
AT_BASE => auxv_base = a_val,
AT_PAGESZ => auxv_page_size = addr(a_val),
AT_PAGESZ => auxv_page_size = a_val.addr(),
AT_ENTRY => auxv_entry = a_val,
AT_NULL => break,
_ => (),
Expand All @@ -129,7 +119,7 @@ pub(super) unsafe fn relocate(envp: *mut *mut u8) {
// program headers and `AT_ENTRY` doesn't point to our own entry point.
// `AT_BASE` contains our own relocation offset.

if load_static_start() == addr(auxv_entry) {
if load_static_start() == auxv_entry.addr() {
// This is case 1) or case 3). If `AT_BASE` doesn't exist, then we are
// already loaded at our static address despite the lack of any dynamic
// linker. As such it would be case 1). If `AT_BASE` does exist, we have
Expand All @@ -154,7 +144,7 @@ pub(super) unsafe fn relocate(envp: *mut *mut u8) {
// `AT_BASE` contains the relocation offset of the dynamic linker.
auxv_base
};
let offset = addr(base);
let offset = base.addr();

// This is case 2) or 4). We need to do all `R_RELATIVE` relocations.
// There should be no other kind of relocation because we are either a
Expand Down Expand Up @@ -326,7 +316,7 @@ pub(super) unsafe fn relocate(envp: *mut *mut u8) {
// entry point when AT_BASE is not zero and thus a dynamic linker is in
// use. In this case the assertion would fail.
if auxv_base == null_mut() {
debug_assert_eq!(load_static_start(), addr(auxv_entry));
debug_assert_eq!(load_static_start(), auxv_entry.addr());
}

// Finally, look through the static segment headers (phdrs) to find the
Expand Down Expand Up @@ -397,5 +387,5 @@ fn load_static_start() -> usize {
// Use `relocation_load` to do the load because the optimizer won't have
// any idea what we're up to.
let static_start_addr: *const *const c_void = &STATIC_START.0;
unsafe { relocation_load(addr(static_start_addr)) }
unsafe { relocation_load(static_start_addr.addr()) }
}
6 changes: 1 addition & 5 deletions src/thread/libc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,11 @@
//! more control when creating efficient higher-level abstractions like
//! pthreads or `std::thread::Thread`.

#[cfg(not(feature = "nightly"))]
use crate::ptr::{with_exposed_provenance_mut, without_provenance_mut, Polyfill as _};
#[cfg(feature = "thread-at-exit")]
use alloc::boxed::Box;
use core::ffi::{c_int, c_void};
use core::mem::{size_of, transmute, zeroed};
use core::ptr::{null_mut, NonNull};
#[cfg(feature = "nightly")]
use core::ptr::{with_exposed_provenance_mut, without_provenance_mut};
use core::ptr::{null_mut, with_exposed_provenance_mut, without_provenance_mut, NonNull};
use core::slice;
use rustix::io;

Expand Down
2 changes: 0 additions & 2 deletions src/thread/linux_raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
use crate::arch::{
clone, munmap_and_exit_thread, set_thread_pointer, thread_pointer, STACK_ALIGNMENT, TLS_OFFSET,
};
#[cfg(not(feature = "nightly"))]
use crate::ptr::Polyfill as _;
#[cfg(feature = "thread-at-exit")]
use alloc::boxed::Box;
#[cfg(feature = "unstable-errno")]
Expand Down