Skip to content

Commit

Permalink
Avoid usage of Error::last_os_error on AIX
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorn3 committed Sep 18, 2024
1 parent a069957 commit 7b24b30
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/symbolize/gimli/libs_aix.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
use super::mystd::env;
use super::mystd::ffi::OsStr;
use super::mystd::io::Error;
use super::mystd::os::unix::ffi::OsStrExt;
use super::xcoff;
use super::{Library, LibrarySegment, Vec};
use alloc::borrow::ToOwned;
use alloc::vec;
use core::ffi::CStr;
use core::ffi::{c_int, CStr};
use core::mem;

const EXE_IMAGE_BASE: u64 = 0x100000000;

extern "C" {
#[link_name = "_Errno"]
fn errno_location() -> *mut c_int;
}

fn errno() -> i32 {
unsafe { (*errno_location()) as i32 }
}

/// On AIX, we use `loadquery` with `L_GETINFO` flag to query libraries mmapped.
/// See https://www.ibm.com/docs/en/aix/7.2?topic=l-loadquery-subroutine for
/// detailed information of `loadquery`.
Expand All @@ -27,15 +35,14 @@ pub(super) fn native_libraries() -> Vec<Library> {
{
break;
} else {
match Error::last_os_error().raw_os_error() {
Some(libc::ENOMEM) => {
match errno() {
libc::ENOMEM => {
buffer.resize(buffer.len() * 2, mem::zeroed::<libc::ld_info>());
}
Some(_) => {
_ => {
// If other error occurs, return empty libraries.
return Vec::new();
}
_ => unreachable!(),
}
}
}
Expand Down

0 comments on commit 7b24b30

Please sign in to comment.