Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 4 additions & 16 deletions libwild/src/elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use object::LittleEndian;
use object::read::elf::CompressionHeader;
use object::read::elf::Crel;
use object::read::elf::CrelIterator;
use object::read::elf::Dyn;
use object::read::elf::FileHeader as _;
use object::read::elf::RelocationSections;
use object::read::elf::SectionHeader as _;
Expand Down Expand Up @@ -66,8 +65,8 @@ pub(crate) struct File<'data> {
/// An iterator over the version definitions and the corresponding linked string table index.
pub(crate) verdef: Option<(VerdefIterator<'data>, object::SectionIndex)>,

/// Number of verdef versions according to the dynamic table.
pub(crate) verdefnum: u64,
/// Number of verdef versions according to `sh_info` of `.gnu._version_d` section.
pub(crate) verdefnum: u32,

/// e_flags from the header.
pub(crate) eflags: u32,
Expand Down Expand Up @@ -144,10 +143,9 @@ impl<'data> File<'data> {
let mut symbols = SymbolTable::default();
let mut versym: &[Versym] = &[];
let mut verdef = None;
let mut dynamic = None;
let mut verdefnum = 0;

// Find all the sections that we're interested in in a single scan of the section table so
// Find all the sections that we're interested in a single scan of the section table so
// as to avoid multiple scans.
for (section_index, section) in sections.enumerate() {
match SectionType::from_header(section) {
Expand All @@ -162,22 +160,12 @@ impl<'data> File<'data> {
}
sht::GNU_VERDEF => {
verdef = section.gnu_verdef(endian, data)?;
}
sht::DYNAMIC => {
dynamic = section.dynamic(endian, data)?;
verdefnum = section.sh_info(endian);
}
_ => {}
}
}

if let Some((dynamic, _)) = dynamic {
for dy in dynamic {
if dy.d_tag(endian) == u64::from(object::elf::DT_VERDEFNUM) {
verdefnum = dy.d_val(endian);
}
}
}

Ok(Self {
arch: architecture,
data,
Expand Down
4 changes: 2 additions & 2 deletions libwild/src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5392,9 +5392,9 @@ impl<'data> DynamicLayoutState<'data> {
resources: &GraphResources<'data, '_>,
queue: &mut LocalWorkQueue,
) -> Result {
let dt_info = DynamicTagValues::read(self.object)?;
self.symbol_versions_needed = vec![false; dt_info.verdefnum as usize];
self.symbol_versions_needed = vec![false; self.object.verdefnum as usize];

let dt_info = DynamicTagValues::read(self.object)?;
if let Some(soname) = dt_info.soname {
self.lib_name = soname;
}
Expand Down