Skip to content

Commit 7b24b30

Browse files
committed
Avoid usage of Error::last_os_error on AIX
1 parent a069957 commit 7b24b30

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/symbolize/gimli/libs_aix.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11
use super::mystd::env;
22
use super::mystd::ffi::OsStr;
3-
use super::mystd::io::Error;
43
use super::mystd::os::unix::ffi::OsStrExt;
54
use super::xcoff;
65
use super::{Library, LibrarySegment, Vec};
76
use alloc::borrow::ToOwned;
87
use alloc::vec;
9-
use core::ffi::CStr;
8+
use core::ffi::{c_int, CStr};
109
use core::mem;
1110

1211
const EXE_IMAGE_BASE: u64 = 0x100000000;
1312

13+
extern "C" {
14+
#[link_name = "_Errno"]
15+
fn errno_location() -> *mut c_int;
16+
}
17+
18+
fn errno() -> i32 {
19+
unsafe { (*errno_location()) as i32 }
20+
}
21+
1422
/// On AIX, we use `loadquery` with `L_GETINFO` flag to query libraries mmapped.
1523
/// See https://www.ibm.com/docs/en/aix/7.2?topic=l-loadquery-subroutine for
1624
/// detailed information of `loadquery`.
@@ -27,15 +35,14 @@ pub(super) fn native_libraries() -> Vec<Library> {
2735
{
2836
break;
2937
} else {
30-
match Error::last_os_error().raw_os_error() {
31-
Some(libc::ENOMEM) => {
38+
match errno() {
39+
libc::ENOMEM => {
3240
buffer.resize(buffer.len() * 2, mem::zeroed::<libc::ld_info>());
3341
}
34-
Some(_) => {
42+
_ => {
3543
// If other error occurs, return empty libraries.
3644
return Vec::new();
3745
}
38-
_ => unreachable!(),
3946
}
4047
}
4148
}

0 commit comments

Comments
 (0)