Skip to content
Merged
Changes from 1 commit
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
40 changes: 40 additions & 0 deletions src/symbol/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ pub enum SymbolData<'t> {
EnvBlock(EnvBlockSymbol<'t>),
/// A COFF section in a PE executable.
Section(SectionSymbol<'t>),
/// A COFF group.
CoffGroup(CoffGroupSymbol<'t>),
}

impl<'t> SymbolData<'t> {
Expand Down Expand Up @@ -272,6 +274,7 @@ impl<'t> SymbolData<'t> {
Self::OEM(_) => None,
Self::EnvBlock(_) => None,
Self::Section(data) => Some(data.name),
Self::CoffGroup(data) => Some(data.name),
}
}
}
Expand Down Expand Up @@ -331,6 +334,7 @@ impl<'t> TryFromCtx<'t> for SymbolData<'t> {
S_OEM => SymbolData::OEM(buf.parse_with(kind)?),
S_ENVBLOCK => SymbolData::EnvBlock(buf.parse_with(kind)?),
S_SECTION => SymbolData::Section(buf.parse_with(kind)?),
S_COFFGROUP => SymbolData::CoffGroup(buf.parse_with(kind)?),
other => return Err(Error::UnimplementedSymbolKind(other)),
};

Expand Down Expand Up @@ -1759,6 +1763,42 @@ impl<'t> TryFromCtx<'t, SymbolKind> for SectionSymbol <'t> {
}
}

/// A COFF section in a PE executable.
///
/// Symbol kind `S_SECTION`.
Comment thread
DanielT marked this conversation as resolved.
Outdated
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct CoffGroupSymbol<'t> {
/// COFF group's CB.
pub cb: u32,
/// COFF group characteristics.
pub characteristics: u32,
/// Symbol offset.
pub offset: PdbInternalSectionOffset,
/// Symbol segment.
pub segment: u16,
Comment thread
DanielT marked this conversation as resolved.
Outdated
/// COFF group name.
pub name: RawString<'t>

}

impl<'t> TryFromCtx<'t, SymbolKind> for CoffGroupSymbol <'t> {
type Error = Error;

fn try_from_ctx(this: &'t [u8], kind: SymbolKind) -> Result<(Self, usize)> {
let mut buf = ParseBuffer::from(this);

let symbol = CoffGroupSymbol {
cb: buf.parse()?,
characteristics: buf.parse()?,
offset: buf.parse()?,
segment: buf.parse()?,
name: parse_symbol_name(&mut buf, kind)?
};

Ok((symbol, buf.pos()))
}
}

/// PDB symbol tables contain names, locations, and metadata about functions, global/static data,
/// constants, data types, and more.
///
Expand Down