Skip to content

Commit bb5aa64

Browse files
committed
Enable gimli on all platforms
This commit updates `#[cfg]` and organization to ensure that the gimli-symbolize feature compiles on all platforms. The main thing to implement will be loading native libraries which currently doesn't have an implementation for platforms like FreeBSD.
1 parent 67ccecb commit bb5aa64

File tree

3 files changed

+25
-13
lines changed

3 files changed

+25
-13
lines changed

src/symbolize/gimli.rs

+15-1
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,10 @@ cfg_if::cfg_if! {
267267
bias: slide,
268268
})
269269
}
270-
} else {
270+
} else if #[cfg(any(
271+
target_os = "linux",
272+
target_os = "fuchsia",
273+
))] {
271274
// Other Unix (e.g. Linux) platforms use ELF as an object file format
272275
// and typically implement an API called `dl_iterate_phdr` to load
273276
// native libraries.
@@ -279,6 +282,7 @@ cfg_if::cfg_if! {
279282
use self::elf::Object;
280283

281284
fn native_libraries() -> Vec<Library> {
285+
wut();
282286
let mut ret = Vec::new();
283287
unsafe {
284288
libc::dl_iterate_phdr(Some(callback), &mut ret as *mut _ as *mut _);
@@ -316,6 +320,16 @@ cfg_if::cfg_if! {
316320
});
317321
0
318322
}
323+
} else {
324+
// Everything else should use ELF, but doesn't know how to load native
325+
// libraries.
326+
327+
mod elf;
328+
use self::elf::Object;
329+
330+
fn native_libraries() -> Vec<Library> {
331+
Vec::new()
332+
}
319333
}
320334
}
321335

src/symbolize/gimli/elf.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ impl<'a> Object<'a> {
6767
// symbolicating with locally defined functions.
6868
.filter(|sym| sym.st_shndx(endian) != object::elf::SHN_UNDEF)
6969
.map(|sym| {
70-
let address = sym.st_value(endian);
71-
let size = sym.st_size(endian);
70+
let address = sym.st_value(endian).into();
71+
let size = sym.st_size(endian).into();
7272
let name = sym.st_name(endian);
7373
ParsedSym {
7474
address,

src/symbolize/mod.rs

+8-10
Original file line numberDiff line numberDiff line change
@@ -463,21 +463,19 @@ cfg_if::cfg_if! {
463463
unsafe fn clear_symbol_cache_imp() {}
464464
} else if #[cfg(all(
465465
feature = "gimli-symbolize",
466-
any(
467-
target_os = "linux",
468-
target_os = "macos",
469-
windows,
470-
),
466+
not(target_os = "emscripten"),
471467
))] {
472468
mod gimli;
473469
use self::gimli::resolve as resolve_imp;
474470
use self::gimli::Symbol as SymbolImp;
475471
use self::gimli::clear_symbol_cache as clear_symbol_cache_imp;
476-
} else if #[cfg(all(feature = "libbacktrace",
477-
any(unix, all(windows, not(target_vendor = "uwp"), target_env = "gnu")),
478-
not(target_os = "fuchsia"),
479-
not(target_os = "emscripten"),
480-
not(target_env = "uclibc")))] {
472+
} else if #[cfg(all(
473+
feature = "libbacktrace",
474+
any(unix, all(windows, not(target_vendor = "uwp"), target_env = "gnu")),
475+
not(target_os = "fuchsia"),
476+
not(target_os = "emscripten"),
477+
not(target_env = "uclibc"),
478+
))] {
481479
mod libbacktrace;
482480
use self::libbacktrace::resolve as resolve_imp;
483481
use self::libbacktrace::Symbol as SymbolImp;

0 commit comments

Comments
 (0)