private Section <T> GetSectionFromSectionHeader(SectionHeader header) { Section <T> returned; switch (header.Type) { case SectionType.Null: goto default; case SectionType.ProgBits: returned = new ProgBitsSection <T>(header, readerSource); break; case SectionType.SymbolTable: returned = new SymbolTable <T>(header, readerSource, objectsStringTable, this); break; case SectionType.StringTable: returned = new StringTable <T>(header, readerSource); break; case SectionType.RelocationAddends: goto default; case SectionType.HashTable: goto default; case SectionType.Dynamic: returned = new DynamicSection <T>(header, Class, readerSource); break; case SectionType.Note: returned = new NoteSection <T>(header, Class, readerSource); break; case SectionType.NoBits: goto default; case SectionType.Relocation: goto default; case SectionType.Shlib: goto default; case SectionType.DynamicSymbolTable: returned = new SymbolTable <T>(header, readerSource, dynamicStringTable, this); break; default: returned = new Section <T>(header, readerSource); break; } return(returned); }
/// <summary> /// Returns the address of a module export symbol if found /// </summary> /// <param name="symbolName">symbol name (without the module name prepended)</param> /// <param name="offset">symbol offset returned</param> /// <returns>true if found</returns> public bool TryGetExportSymbol(string symbolName, out ulong offset) { try { if (DynamicSection is not null && DynamicSection.TryLookupSymbol(symbolName, out ElfSymbol? symbol) && symbol is not null) { offset = (ulong)symbol.Value; return(true); } } catch (Exception ex) when(ex is IOException || ex is InvalidDataException) { } offset = 0; return(false); }