Sha256: 0a0d4b37145e898f7068cadacccf362d8216e463e7026af2ce38d75ebfd74bea

Contents?: true

Size: 1.69 KB

Versions: 31

Compression:

Stored size: 1.69 KB

Contents

// Haiku implements the image_info struct and the get_next_image_info()
// functions to iterate through the loaded executable images. The
// image_info struct contains a pointer to the start of the .text
// section within the virtual address space, as well as the size of
// that section. All the read-only segments of the ELF-binary are in
// that part of the address space.

use super::mystd::borrow::ToOwned;
use super::mystd::ffi::{CStr, OsStr};
use super::mystd::mem::MaybeUninit;
use super::mystd::os::unix::prelude::*;
use super::{Library, LibrarySegment, Vec};

pub(super) fn native_libraries() -> Vec<Library> {
    let mut libraries: Vec<Library> = Vec::new();

    unsafe {
        let mut info = MaybeUninit::<libc::image_info>::zeroed();
        let mut cookie: i32 = 0;
        // Load the first image to get a valid info struct
        let mut status =
            libc::get_next_image_info(libc::B_CURRENT_TEAM, &mut cookie, info.as_mut_ptr());
        if status != libc::B_OK {
            return libraries;
        }
        let mut info = info.assume_init();

        while status == libc::B_OK {
            let mut segments = Vec::new();
            segments.push(LibrarySegment {
                stated_virtual_memory_address: 0,
                len: info.text_size as usize,
            });

            let bytes = CStr::from_ptr(info.name.as_ptr()).to_bytes();
            let name = OsStr::from_bytes(bytes).to_owned();
            libraries.push(Library {
                name: name,
                segments: segments,
                bias: info.text as usize,
            });

            status = libc::get_next_image_info(libc::B_CURRENT_TEAM, &mut cookie, &mut info);
        }
    }

    libraries
}

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
wasmtime-30.0.2 ./ext/cargo-vendor/backtrace-0.3.74/src/symbolize/gimli/libs_haiku.rs
wasmtime-29.0.0 ./ext/cargo-vendor/backtrace-0.3.74/src/symbolize/gimli/libs_haiku.rs
wasmtime-28.0.0 ./ext/cargo-vendor/backtrace-0.3.74/src/symbolize/gimli/libs_haiku.rs
wasmtime-27.0.0 ./ext/cargo-vendor/backtrace-0.3.74/src/symbolize/gimli/libs_haiku.rs
wasmtime-26.0.0 ./ext/cargo-vendor/backtrace-0.3.74/src/symbolize/gimli/libs_haiku.rs
wasmtime-25.0.2 ./ext/cargo-vendor/backtrace-0.3.73/src/symbolize/gimli/libs_haiku.rs
wasmtime-25.0.1 ./ext/cargo-vendor/backtrace-0.3.73/src/symbolize/gimli/libs_haiku.rs
wasmtime-25.0.0 ./ext/cargo-vendor/backtrace-0.3.73/src/symbolize/gimli/libs_haiku.rs
wasmtime-24.0.0 ./ext/cargo-vendor/backtrace-0.3.73/src/symbolize/gimli/libs_haiku.rs
wasmtime-23.0.2 ./ext/cargo-vendor/backtrace-0.3.69/src/symbolize/gimli/libs_haiku.rs
wasmtime-22.0.0 ./ext/cargo-vendor/backtrace-0.3.69/src/symbolize/gimli/libs_haiku.rs
wasmtime-21.0.1 ./ext/cargo-vendor/backtrace-0.3.69/src/symbolize/gimli/libs_haiku.rs
wasmtime-20.0.2 ./ext/cargo-vendor/backtrace-0.3.69/src/symbolize/gimli/libs_haiku.rs
wasmtime-20.0.0 ./ext/cargo-vendor/backtrace-0.3.69/src/symbolize/gimli/libs_haiku.rs
wasmtime-18.0.3 ./ext/cargo-vendor/backtrace-0.3.69/src/symbolize/gimli/libs_haiku.rs
wasmtime-17.0.1 ./ext/cargo-vendor/backtrace-0.3.69/src/symbolize/gimli/libs_haiku.rs
wasmtime-17.0.0 ./ext/cargo-vendor/backtrace-0.3.69/src/symbolize/gimli/libs_haiku.rs
wasmtime-16.0.0 ./ext/cargo-vendor/backtrace-0.3.69/src/symbolize/gimli/libs_haiku.rs
wasmtime-15.0.1 ./ext/cargo-vendor/backtrace-0.3.69/src/symbolize/gimli/libs_haiku.rs
wasmtime-15.0.0 ./ext/cargo-vendor/backtrace-0.3.69/src/symbolize/gimli/libs_haiku.rs