Bug 1579425 - Part 1: Update goblin and object. r=froydnj

Differential Revision: https://phabricator.services.mozilla.com/D45046

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Bastien Orivel 2019-09-06 17:49:51 +00:00
Родитель c377fd351d
Коммит 3799c3a86f
4 изменённых файлов: 25 добавлений и 19 удалений

18
Cargo.lock сгенерированный
Просмотреть файл

@ -1319,7 +1319,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "goblin"
version = "0.0.17"
version = "0.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2121,12 +2121,13 @@ dependencies = [
[[package]]
name = "object"
version = "0.10.0"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"goblin 0.0.17 (registry+https://github.com/rust-lang/crates.io-index)",
"goblin 0.0.24 (registry+https://github.com/rust-lang/crates.io-index)",
"scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
"uuid 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -2320,11 +2321,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
name = "profiler_helper"
version = "0.1.0"
dependencies = [
"goblin 0.0.17 (registry+https://github.com/rust-lang/crates.io-index)",
"goblin 0.0.24 (registry+https://github.com/rust-lang/crates.io-index)",
"memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
"object 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"object 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-demangle 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"thin-vec 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -3978,7 +3980,7 @@ dependencies = [
"checksum gl_generator 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "39a23d5e872a275135d66895d954269cf5e8661d234eb1c2480f4ce0d586acbd"
"checksum gleam 0.6.17 (registry+https://github.com/rust-lang/crates.io-index)" = "7f46fd8874e043ffac0d638ed1567a2584f7814f6d72b4db37ab1689004a26c4"
"checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb"
"checksum goblin 0.0.17 (registry+https://github.com/rust-lang/crates.io-index)" = "5911d7df7b8f65ab676c5327b50acea29d3c6a1a4ad05e444cf5dce321b26db2"
"checksum goblin 0.0.24 (registry+https://github.com/rust-lang/crates.io-index)" = "e3fa261d919c1ae9d1e4533c4a2f99e10938603c4208d56c05bec7a872b661b0"
"checksum guid_win 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "87261686cc5e35b6584f4c2a430c2b153d8a92ab1ef820c16be34c1df8f5f58b"
"checksum h2 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "a27e7ed946e8335bdf9a191bc1b9b14a03ba822d013d2f58437f4fabcbd7fc2c"
"checksum headers 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dc6e2e51d356081258ef05ff4c648138b5d3fe64b7300aaad3b820554a2b7fb6"
@ -4044,7 +4046,7 @@ dependencies = [
"checksum num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31"
"checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1"
"checksum num_cpus 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "514f0d73e64be53ff320680ca671b64fe3fb91da01e1ae2ddc99eb51d453b20d"
"checksum object 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6cca6ad89d0801138cb4ef606908ae12d83edc4c790ef5178fc7b4c72d959e90"
"checksum object 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d89ec45bc6b810c6ee998e22953fbf387a40fcbf5014dcbb9e5ba9a09a81ee15"
"checksum opaque-debug 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "51ecbcb821e1bd256d456fe858aaa7f380b63863eab2eb86eee1bd9f33dd6682"
"checksum ordered-float 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2f0015e9e8e28ee20c581cfbfe47c650cedeb9ed0721090e0b7ebb10b9cdbcc2"
"checksum owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49a4b8ea2179e6a2e27411d3bca09ca6dd630821cf6894c6c7c8467a8ee7ef13"

Просмотреть файл

@ -6,18 +6,19 @@ authors = ["Markus Stange <mstange@themasta.com>"]
[dependencies]
memmap = "0.6.2"
rustc-demangle = "0.1"
uuid = "0.7"
[dependencies.object]
version = "0.10.0"
version = "0.13.0"
optional = true
default-features = false
features = ["std"]
features = ["std", "read"]
[dependencies.goblin]
optional = true
# The version and features of goblin need to match what's in object's Cargo.toml,
# because we really want object's goblin and not another instance of goblin.
version = "0.0.17"
version = "0.0.24"
features = ["endian_fd", "elf32", "elf64", "mach32", "mach64", "pe32", "pe64", "archive"]
default-features = false

Просмотреть файл

@ -4,9 +4,11 @@
use compact_symbol_table::CompactSymbolTable;
use goblin::elf;
use object::{ElfFile, Object, SymbolKind, Uuid};
use object::SymbolKind;
use object::read::{ElfFile, Object};
use std::cmp;
use std::collections::HashMap;
use uuid::Uuid;
const UUID_SIZE: usize = 16;
const PAGE_SIZE: usize = 4096;
@ -18,8 +20,8 @@ where
object_file
.dynamic_symbols()
.chain(object_file.symbols())
.filter(|symbol| symbol.kind() == SymbolKind::Text)
.filter_map(|symbol| symbol.name().map(|name| (symbol.address() as u32, name)))
.filter(|(_, symbol)| symbol.kind() == SymbolKind::Text)
.filter_map(|(_, symbol)| symbol.name().map(|name| (symbol.address() as u32, name)))
.collect()
}
@ -29,13 +31,13 @@ pub fn get_compact_symbol_table(
) -> Option<CompactSymbolTable> {
let elf_file = ElfFile::parse(buffer).ok()?;
let elf_id = get_elf_id(&elf_file, buffer)?;
if !breakpad_id.map_or(true, |id| id == format!("{:X}0", elf_id.simple())) {
if !breakpad_id.map_or(true, |id| id == format!("{:X}0", elf_id.to_simple_ref())) {
return None;
}
return Some(CompactSymbolTable::from_map(get_symbol_map(&elf_file)));
}
fn create_elf_id(identifier: &[u8], little_endian: bool) -> Option<Uuid> {
fn create_elf_id(identifier: &[u8], little_endian: bool) -> Uuid {
// Make sure that we have exactly UUID_SIZE bytes available
let mut data = [0 as u8; UUID_SIZE];
let len = cmp::min(identifier.len(), UUID_SIZE);
@ -50,7 +52,7 @@ fn create_elf_id(identifier: &[u8], little_endian: bool) -> Option<Uuid> {
data[6..8].reverse(); // uuid field 3
}
Uuid::from_bytes(&data).ok()
Uuid::from_bytes(data)
}
/// Tries to obtain the object identifier of an ELF object.
@ -67,7 +69,7 @@ fn create_elf_id(identifier: &[u8], little_endian: bool) -> Option<Uuid> {
/// If all of the above fails, this function will return `None`.
pub fn get_elf_id(elf_file: &ElfFile, data: &[u8]) -> Option<Uuid> {
if let Some(identifier) = elf_file.build_id() {
return create_elf_id(identifier, elf_file.elf().little_endian);
return Some(create_elf_id(identifier, elf_file.elf().little_endian));
}
// We were not able to locate the build ID, so fall back to hashing the
@ -79,7 +81,7 @@ pub fn get_elf_id(elf_file: &ElfFile, data: &[u8]) -> Option<Uuid> {
hash[i % UUID_SIZE] ^= section_data[i];
}
return create_elf_id(&hash, elf_file.elf().little_endian);
return Some(create_elf_id(&hash, elf_file.elf().little_endian));
}
None

Просмотреть файл

@ -5,6 +5,7 @@
extern crate memmap;
extern crate rustc_demangle;
extern crate thin_vec;
extern crate uuid;
#[cfg(feature = "parse_elf")]
extern crate goblin;