Skip to content

Commit

Permalink
read/archive: add symbol iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
philipc committed Apr 1, 2024
1 parent d65bc75 commit e7520e0
Show file tree
Hide file tree
Showing 8 changed files with 3,698 additions and 17 deletions.
16 changes: 15 additions & 1 deletion crates/examples/src/readobj/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,14 +323,28 @@ fn print_archive(p: &mut Printer<'_>, data: &[u8]) {
for member in archive.members() {
if let Some(member) = member.print_err(p) {
p.blank();
p.field("Member", String::from_utf8_lossy(member.name()));
p.field_inline_string("Member", member.name());
if member.is_thin() {
p.field("Size", member.size());
} else if let Some(data) = member.data(data).print_err(p) {
print_object(p, data);
}
}
}
if let Some(symbols) = archive.symbols().print_err(p).flatten() {
p.blank();
for symbol in symbols {
if let Some(symbol) = symbol.print_err(p) {
p.group("Symbol", |p| {
p.field_inline_string("Name", symbol.name());
let offset = symbol.offset();
if let Some(member) = archive.member(offset).print_err(p) {
p.field_inline_string("Member", member.name());
}
});
}
}
}
}
}

Expand Down
Loading

0 comments on commit e7520e0

Please sign in to comment.