aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock21
-rw-r--r--Cargo.toml4
-rw-r--r--src/main.rs30
3 files changed, 38 insertions, 17 deletions
diff --git a/Cargo.lock b/Cargo.lock
index faacac6..2837cd3 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -10,8 +10,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "goblin"
-version = "0.4.2"
-source = "git+https://github.com/johannst/goblin?branch=elf-gnu-symbol-versioning-utils#4893886664718b7627a572578b69de65a9f88e24"
+version = "0.4.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "32401e89c6446dcd28185931a01b1093726d0356820ac744023e6850689bf926"
dependencies = [
"log",
"plain",
@@ -20,9 +21,9 @@ dependencies = [
[[package]]
name = "libc"
-version = "0.2.102"
+version = "0.2.108"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a2a5ac8f984bfcf3a823267e5fde638acc3325f6496633a5da6bb6eb2171e103"
+checksum = "8521a1b57e76b1ec69af7599e75e38e7b7fad6610f037db8c79b127201b5d119"
[[package]]
name = "log"
@@ -41,18 +42,18 @@ checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6"
[[package]]
name = "proc-macro2"
-version = "1.0.29"
+version = "1.0.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b9f5105d4fdaab20335ca9565e106a5d9b82b6219b5ba735731124ac6711d23d"
+checksum = "ba508cc11742c0dc5c1659771673afbab7a0efab23aa17e854cbab0837ed0b43"
dependencies = [
"unicode-xid",
]
[[package]]
name = "quote"
-version = "1.0.9"
+version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7"
+checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05"
dependencies = [
"proc-macro2",
]
@@ -79,9 +80,9 @@ dependencies = [
[[package]]
name = "syn"
-version = "1.0.76"
+version = "1.0.81"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c6f107db402c2c2055242dbf4d2af0e69197202e9faacbef9571bbe47f5a1b84"
+checksum = "f2afee18b8beb5a596ecb4a2dce128c719b4ba399d34126b9e4396e3f9860966"
dependencies = [
"proc-macro2",
"quote",
diff --git a/Cargo.toml b/Cargo.toml
index a8975b2..f2cc248 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -8,8 +8,6 @@ edition = "2018"
libc = "0.2"
[dependencies.goblin]
-#version = "0.4"
-git = "https://github.com/johannst/goblin"
-branch = "elf-gnu-symbol-versioning-utils"
+version = "0.4"
default-features = false
features = ["std", "elf32", "elf64", "endian_fd"]
diff --git a/src/main.rs b/src/main.rs
index 08cf086..ca0e47e 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -88,8 +88,10 @@ unsafe fn get_vdso_sym(
)
.ok_or(Error::SymbolNotFound(symbol_name.0.into()))?;
- let found_symbol_version = elf
+ // Get the corresponding ElfVersym entry.
+ let versym = elf
.versym
+ .as_ref()
.ok_or(Error::SymbolVersionError(
"Missing ELF section Versym".into(),
))?
@@ -97,8 +99,24 @@ unsafe fn get_vdso_sym(
.ok_or(Error::SymbolVersionError(format!(
"No Versym entry for symbol with idx {} found",
idx
- )))?
- .find_version(&elf.verdef, &elf.verneed, &elf.dynstrtab)
+ )))?;
+
+ // Get the defined symbol version for the ElfVersym entry from the ElfVerdef section.
+ let found_symbol_version = elf
+ .verdef
+ .as_ref()
+ .ok_or(Error::SymbolVersionError(
+ "Missing ELF section Verdef".into(),
+ ))?
+ .iter()
+ .find_map(|vd| {
+ if !versym.is_local() && !versym.is_global() && vd.vd_ndx == versym.version() {
+ let vda0 = vd.iter().next()?;
+ elf.dynstrtab.get_at(vda0.vda_name)
+ } else {
+ None
+ }
+ })
.ok_or(Error::SymbolVersionError(format!(
"No symbol version string found for symbol with idx {}",
idx
@@ -136,7 +154,11 @@ fn main() -> Result<(), Error> {
// SAFETY: orig_vdso describes a valid memory region as we got it from /proc/self/maps.
let orig = get_vdso_sym(&orig_vdso, Sym("__vdso_gettimeofday"), Symver("LINUX_2.6"))?;
// SAFETY: copy_vdso describes a valid and owned memory allocation.
- let copy = get_vdso_sym(&copy_vdso.as_ref(), Sym("__vdso_gettimeofday"), Symver("LINUX_2.6"))?;
+ let copy = get_vdso_sym(
+ &copy_vdso.as_ref(),
+ Sym("__vdso_gettimeofday"),
+ Symver("LINUX_2.6"),
+ )?;
(orig, copy)
};