Skip to content

Commit 1ffdc8a

Browse files
Remove dladdr fallback and implementation (rust-lang#317)
* Remove dladdr fallback and implementation This has been present for a very long time but I believe this has never actually been that necessary. Non-MSVC platforms all use libbacktrace by default, and libbacktrace will consult symbol tables of object files to do what `dladdr` does, just inside of libbacktrace. Additionally gimli implements the same logic. I believe that this means that `dladdr` isn't necessary for resolving any symbols since our other strategies should already be doing everything for us. This commit makes the feature defunkt and otherwise removes the various forms of fallback to dladdr. * Switch to the `object` crate for object parsing This commit switches the gimli feature from the `goblin` crate to the `object` crate for parsing object files. The main motivation here is trimming the dependencies of the `gimli-symbolize` feature to a bare minimum. The `object` crate itself has no dependencies now and should be a relatively easy drop-in replacement for the `goblin` crate. * Parse fat libraries on macOS This commit updates the object parsing code for macOS to support fat libraries. This enables gimli to symbolize addresses coming from system libraries which are currently installed frequently as fat libraries. Closes rust-lang#319 * Fix macOS symbolication of system libraries This commit fixes an issue where symbolication of system libraries didn't work on macOS. Symbolication through the symbol table was always off by a slide amount for the library. It's not entirely clear why this kept happening or what was going on, but some poking in LLDB's source revealed a way we can differentiate and figure out what addresses need to be looked up in the symbol table. Some more information is contained in the comments of the commit itself. Closes rust-lang#318 Co-authored-by: Philip Craig <philipjcraig@gmail.com>
1 parent df444be commit 1ffdc8a

File tree

8 files changed

+387
-455
lines changed

8 files changed

+387
-455
lines changed

Cargo.toml

+9-7
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@ cpp_demangle = { default-features = false, version = "0.2.3", optional = true }
3535

3636
# Optional dependencies enabled through the `gimli-symbolize` feature
3737
addr2line = { version = "0.11.0", optional = true, default-features = false, features = ['std'] }
38-
goblin = { version = "0.2", optional = true, default-features = false, features = ['elf32', 'elf64', 'mach32', 'mach64', 'pe32', 'pe64', 'std'] }
38+
39+
[dependencies.object]
40+
version = "0.19"
41+
optional = true
42+
default-features = false
43+
features = ['read_core', 'elf', 'macho', 'pe']
3944

4045
[target.'cfg(windows)'.dependencies]
4146
winapi = { version = "0.3.3", optional = true }
@@ -49,7 +54,7 @@ winapi = { version = "0.3.3", optional = true }
4954
# Note that not all features are available on all platforms, so even though a
5055
# feature is enabled some other feature may be used instead.
5156
[features]
52-
default = ["std", "libunwind", "libbacktrace", "dladdr", "dbghelp"]
57+
default = ["std", "libunwind", "libbacktrace", "dbghelp"]
5358

5459
# Include std support.
5560
std = []
@@ -81,17 +86,13 @@ kernel32 = []
8186
# can also provide filename/line number information if debuginfo is
8287
# compiled in. This library currently only primarily works on unixes that
8388
# are not OSX, however.
84-
# - dladdr: this feature uses the dladdr(3) function (a glibc extension) to
85-
# resolve symbol names. This is fairly unreliable on linux, but works well
86-
# enough on OSX.
8789
# - gimli-symbolize: use the `gimli-rs/addr2line` crate to symbolicate
8890
# addresses into file, line, and name using DWARF debug information. At
8991
# the moment, this is only possible when targetting Linux, since macOS
9092
# splits DWARF out into a separate object file. Enabling this feature
9193
# means one less C dependency.
9294
libbacktrace = ["backtrace-sys/backtrace-sys"]
93-
dladdr = []
94-
gimli-symbolize = ["addr2line", "goblin"]
95+
gimli-symbolize = ["addr2line", "object"]
9596

9697
#=======================================
9798
# Methods of serialization
@@ -105,6 +106,7 @@ serialize-serde = ["serde"]
105106
#
106107
# Only here for backwards compatibility purposes, they do nothing now.
107108
coresymbolication = []
109+
dladdr = []
108110

109111
#=======================================
110112
# Internal features for testing and such.

crates/without_debuginfo/Cargo.toml

-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ features = [
1212
'libunwind',
1313
'dbghelp',
1414

15-
# Allow fallback to dladdr
16-
'dladdr',
17-
1815
# Yes, we have `std`
1916
'std',
2017
]

src/symbolize/dladdr.rs

-112
This file was deleted.

src/symbolize/dladdr_resolve.rs

-50
This file was deleted.

0 commit comments

Comments
 (0)