Skip to content

Commit

Permalink
Update to Rust nightly-2024-04-21. (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunfishcode committed Apr 22, 2024
1 parent 2c5bcef commit 115adf5
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Expand Up @@ -27,7 +27,7 @@ rustix-futex-sync = { version = "0.2.1", optional = true }
# before `origin_main` is called.

# Enable `env_logger`; eg. recognizing `RUST_LOG=trace`. This requires `std`.
env_logger = { version = "0.10.0", optional = true, default-features = false }
env_logger = { version = "0.11.0", optional = true, default-features = false }

# Enable `atomic-dbg`'s simple logger. This doesn't require `std`.
atomic-dbg = { version = "0.1", default-features = false, optional = true }
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2024-02-26"
channel = "nightly-2024-04-21"
components = ["rustc", "cargo", "rust-std", "rust-src", "rustfmt"]
12 changes: 6 additions & 6 deletions src/relocate.rs
Expand Up @@ -30,7 +30,7 @@ use crate::arch::{
dynamic_table_addr, relocation_load, relocation_mprotect_readonly, relocation_store,
};
use core::ffi::c_void;
use core::ptr::{from_exposed_addr, null, null_mut};
use core::ptr::{with_exposed_provenance, null, null_mut};
use linux_raw_sys::elf::*;
use linux_raw_sys::general::{AT_BASE, AT_ENTRY, AT_NULL, AT_PAGESZ};

Expand Down Expand Up @@ -148,14 +148,14 @@ pub(super) unsafe fn relocate(envp: *mut *mut u8) {

match *d_tag {
// We found a rela table. As above, model this as
// `from_exposed_addr`.
DT_RELA => rela_ptr = from_exposed_addr(d_un.d_ptr.wrapping_add(offset)),
// `with_exposed_provenance`.
DT_RELA => rela_ptr = with_exposed_provenance(d_un.d_ptr.wrapping_add(offset)),
DT_RELASZ => rela_total_size = d_un.d_val as usize,
DT_RELAENT => rela_entry_size = d_un.d_val as usize,

// We found a rel table. As above, model this as
// `from_exposed_addr`.
DT_REL => rel_ptr = from_exposed_addr(d_un.d_ptr.wrapping_add(offset)),
// `with_exposed_provenance`.
DT_REL => rel_ptr = with_exposed_provenance(d_un.d_ptr.wrapping_add(offset)),
DT_RELSZ => rel_total_size = d_un.d_val as usize,
DT_RELENT => rel_entry_size = d_un.d_val as usize,

Expand Down Expand Up @@ -245,7 +245,7 @@ pub(super) unsafe fn relocate(envp: *mut *mut u8) {
let mut relro_size = 0;

let phentsize = EHDR.e_phentsize as usize;
let mut current_phdr = from_exposed_addr::<Elf_Phdr>(offset + EHDR.e_phoff);
let mut current_phdr = with_exposed_provenance::<Elf_Phdr>(offset + EHDR.e_phoff);
let phdrs_end = current_phdr
.cast::<u8>()
.add(EHDR.e_phnum as usize * phentsize)
Expand Down
6 changes: 3 additions & 3 deletions src/thread/libc.rs
Expand Up @@ -3,7 +3,7 @@
use alloc::boxed::Box;
use core::ffi::{c_int, c_void};
use core::mem::{size_of, transmute, zeroed};
use core::ptr::{from_exposed_addr_mut, null_mut, without_provenance_mut, NonNull};
use core::ptr::{with_exposed_provenance_mut, null_mut, without_provenance_mut, NonNull};
use core::slice;
use rustix::io;

Expand Down Expand Up @@ -39,7 +39,7 @@ impl Thread {
/// `Thread::to_raw`.
#[inline]
pub fn from_raw(raw: *mut c_void) -> Self {
Self(raw.expose_addr() as libc::pthread_t)
Self(raw.expose_provenance() as libc::pthread_t)
}

/// Convert to `Self` from a raw non-null pointer that was returned from
Expand All @@ -56,7 +56,7 @@ impl Thread {
/// threads.
#[inline]
pub fn to_raw(self) -> *mut c_void {
from_exposed_addr_mut(self.0 as usize)
with_exposed_provenance_mut(self.0 as usize)
}

/// Convert to a raw non-null pointer from a `Self`.
Expand Down
2 changes: 0 additions & 2 deletions tests/example_crates.rs
@@ -1,8 +1,6 @@
//! Run the programs in the `example-crates` directory and compare their
//! outputs with expected outputs.

#![feature(cfg_target_abi)]

mod utils;

use utils::{COMMON_STDERR, NO_ALLOC_STDERR};
Expand Down
2 changes: 0 additions & 2 deletions tests/test_crates.rs
@@ -1,8 +1,6 @@
//! Run the programs in the `test-crates` directory and compare their
//! outputs with expected outputs.

#![feature(cfg_target_abi)]

mod utils;

fn test_crate(
Expand Down

0 comments on commit 115adf5

Please sign in to comment.