MCPcopy Index your code
hub / github.com/encounter/objdiff / parse_symbols

Function parse_symbols

objdiff-core/src/obj/mdebug.rs:362–377  ·  view source on GitHub ↗
(data: &[u8], endianness: Endianness)

Source from the content-addressed store, hash-verified

360}
361
362fn parse_symbols(data: &[u8], endianness: Endianness) -> Result<Vec<SymbolEntry>> {
363 ensure!(data.len().is_multiple_of(SYMR_SIZE), "symbol table misaligned");
364 let mut symbols = Vec::with_capacity(data.len() / SYMR_SIZE);
365 let mut cursor = 0;
366 while cursor + SYMR_SIZE <= data.len() {
367 let _iss = read_u32(data, &mut cursor, endianness)?;
368 let value = read_u32(data, &mut cursor, endianness)?;
369 let bits = read_u32(data, &mut cursor, endianness)?;
370 let (st, index) = match endianness {
371 Endianness::Big => (((bits >> 26) & 0x3f) as u8, bits & 0x000f_ffff),
372 Endianness::Little => (((bits & 0x3f) as u8), (bits >> 12) & 0x000f_ffff),
373 };
374 symbols.push(SymbolEntry { value, st, index });
375 }
376 Ok(symbols)
377}
378
379fn read_u16(data: &[u8], cursor: &mut usize, endianness: Endianness) -> Result<u16> {
380 ensure!(*cursor + 2 <= data.len(), "unexpected EOF while reading u16");

Callers 1

parse_line_info_mdebugFunction · 0.85

Calls 2

pushMethod · 0.80
read_u32Function · 0.70

Tested by

no test coverage detected