Skip to content

Commit 8f2d98c

Browse files
committed
Avoid usage of Error::last_os_error on AIX
1 parent 4d7906b commit 8f2d98c

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/symbolize/gimli/libs_aix.rs

+13-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
use super::mystd::env;
22
use super::mystd::ffi::OsStr;
3-
use super::mystd::io::Error;
43
use super::mystd::os::unix::prelude::*;
54
use super::xcoff;
65
use super::{Library, LibrarySegment};
76
use alloc::borrow::ToOwned;
87
use alloc::vec;
98
use alloc::vec::Vec;
10-
use core::ffi::CStr;
9+
use core::ffi::{c_int, CStr};
1110
use core::mem;
1211

1312
const EXE_IMAGE_BASE: u64 = 0x100000000;
1413

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

0 commit comments

Comments
 (0)