Skip to content

Commit 83dbb5d

Browse files
author
Name1e5s
authored
Update dependencies, clean up code and bump version (gimli-rs#75)
1 parent abf06be commit 83dbb5d

File tree

4 files changed

+16
-38
lines changed

4 files changed

+16
-38
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "findshlibs"
3-
version = "0.10.1"
3+
version = "0.10.2"
44
description = "Find the set of shared libraries loaded in the current process with a cross platform API"
55
documentation = "https://docs.rs/findshlibs"
66
edition = "2018"
@@ -10,7 +10,7 @@ readme = "./README.md"
1010
repository = "https://github.com/gimli-rs/findshlibs"
1111

1212
[dependencies]
13-
libc = "0.2.98"
13+
libc = "0.2.104"
1414

1515
[build-dependencies]
1616
# Only needed for Android, but cannot be target dependent

src/linux/mod.rs

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,6 @@ type Phdr = libc::Elf32_Phdr;
2727
type Phdr = libc::Elf64_Phdr;
2828

2929
const NT_GNU_BUILD_ID: u32 = 3;
30-
const PT_NULL: u32 = 0;
31-
const PT_LOAD: u32 = 1;
32-
const PT_DYNAMIC: u32 = 2;
33-
const PT_INTERP: u32 = 3;
34-
const PT_NOTE: u32 = 4;
35-
const PT_SHLIB: u32 = 5;
36-
const PT_PHDR: u32 = 6;
37-
const PT_TLS: u32 = 7;
38-
const PT_NUM: u32 = 8;
39-
const PT_LOOS: u32 = 0x60000000;
40-
const PT_GNU_EH_FRAME: u32 = 0x6474e550;
41-
const PT_GNU_STACK: u32 = 0x6474e551;
42-
const PT_GNU_RELRO: u32 = 0x6474e552;
4330

4431
// Normally we would use `Elf32_Nhdr` on 32-bit platforms and `Elf64_Nhdr` on
4532
// 64-bit platforms. However, in practice it seems that only `Elf32_Nhdr` is
@@ -72,7 +59,7 @@ impl<'a> Segment<'a> {
7259
}
7360

7461
fn is_note(&self) -> bool {
75-
self.phdr().p_type == PT_NOTE
62+
self.phdr().p_type == libc::PT_NOTE
7663
}
7764

7865
/// Parse the contents of a `PT_NOTE` segment.
@@ -157,19 +144,17 @@ impl<'a> SegmentTrait for Segment<'a> {
157144
fn name(&self) -> &str {
158145
unsafe {
159146
match self.phdr.as_ref().unwrap().p_type {
160-
PT_NULL => "NULL",
161-
PT_LOAD => "LOAD",
162-
PT_DYNAMIC => "DYNAMIC",
163-
PT_INTERP => "INTERP",
164-
PT_NOTE => "NOTE",
165-
PT_SHLIB => "SHLI",
166-
PT_PHDR => "PHDR",
167-
PT_TLS => "TLS",
168-
PT_NUM => "NUM",
169-
PT_LOOS => "LOOS",
170-
PT_GNU_EH_FRAME => "GNU_EH_FRAME",
171-
PT_GNU_STACK => "GNU_STACK",
172-
PT_GNU_RELRO => "GNU_RELRO",
147+
libc::PT_NULL => "NULL",
148+
libc::PT_LOAD => "LOAD",
149+
libc::PT_DYNAMIC => "DYNAMIC",
150+
libc::PT_INTERP => "INTERP",
151+
libc::PT_NOTE => "NOTE",
152+
libc::PT_SHLIB => "SHLIB",
153+
libc::PT_PHDR => "PHDR",
154+
libc::PT_TLS => "TLS",
155+
libc::PT_GNU_EH_FRAME => "GNU_EH_FRAME",
156+
libc::PT_GNU_STACK => "GNU_STACK",
157+
libc::PT_GNU_RELRO => "GNU_RELRO",
173158
_ => "(unknown segment type)",
174159
}
175160
}
@@ -179,12 +164,12 @@ impl<'a> SegmentTrait for Segment<'a> {
179164
fn is_code(&self) -> bool {
180165
let hdr = self.phdr();
181166
// 0x1 is PT_X for executable
182-
hdr.p_type == PT_LOAD && (hdr.p_flags & 0x1) != 0
167+
hdr.p_type == libc::PT_LOAD && (hdr.p_flags & 0x1) != 0
183168
}
184169

185170
#[inline]
186171
fn is_load(&self) -> bool {
187-
self.phdr().p_type == PT_LOAD
172+
self.phdr().p_type == libc::PT_LOAD
188173
}
189174

190175
#[inline]

src/macos/bindings.h

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/macos/bindings.rs

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)