Skip to content

Commit a745792

Browse files
authored
read/macho: Add support for parsing N_STSYM from the Mach-O symbol table (gimli-rs#764)
1 parent bc8ae31 commit a745792

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/read/macho/symbol.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ impl<'data, Mach: MachHeader, R: ReadRef<'data>> SymbolTable<'data, Mach, R> {
104104
if n_type & macho::N_STAB == 0 {
105105
continue;
106106
}
107-
// TODO: includes variables too (N_GSYM, N_STSYM). These may need to get their
107+
// TODO: includes global symbols too (N_GSYM). These may need to get their
108108
// address from regular symbols though.
109109
match n_type {
110110
macho::N_SO => {
@@ -148,6 +148,20 @@ impl<'data, Mach: MachHeader, R: ReadRef<'data>> SymbolTable<'data, Mach, R> {
148148
}
149149
}
150150
}
151+
macho::N_STSYM => {
152+
// Static symbols have a single entry with the address of the symbol
153+
// but no size
154+
if let Ok(name) = nlist.name(endian, self.strings) {
155+
if let Some(object) = object {
156+
symbols.push(ObjectMapEntry {
157+
address: nlist.n_value(endian).into(),
158+
size: 0,
159+
name,
160+
object,
161+
})
162+
}
163+
}
164+
}
151165
_ => {}
152166
}
153167
}

0 commit comments

Comments
 (0)