These initializers force-unwrap _fileSliceForLinkEditData / _readLinkEditData, which return nil when the range is not inside __LINKEDIT or the file:
| Reader |
Location |
Symbols64 / Symbols |
MachOFile+Symbols.swift:76, :81, :222, :227 |
ExportTrie |
MachOFile+ExportTrie.swift:119 |
FunctionStarts |
MachOFile+FunctionStarts.swift:37 |
Reproduce
symbols64 on any MH_OBJECT (clang -c): relocatable objects have LC_SYMTAB but no __LINKEDIT segment.
- A truncated binary, or a
symoff / stroff / dataoff pointing past EOF.
Suggestion
Return nil from symbols64 / symbols32 / exportTrie / functionStarts when the slice cannot be created. For objects, fall back to reading symoff / stroff relative to the file (they are plain file offsets there).
These initializers force-unwrap
_fileSliceForLinkEditData/_readLinkEditData, which returnnilwhen the range is not inside__LINKEDITor the file:Symbols64/SymbolsMachOFile+Symbols.swift:76,:81,:222,:227ExportTrieMachOFile+ExportTrie.swift:119FunctionStartsMachOFile+FunctionStarts.swift:37Reproduce
symbols64on anyMH_OBJECT(clang -c): relocatable objects haveLC_SYMTABbut no__LINKEDITsegment.symoff/stroff/dataoffpointing past EOF.Suggestion
Return
nilfromsymbols64/symbols32/exportTrie/functionStartswhen the slice cannot be created. For objects, fall back to readingsymoff/stroffrelative to the file (they are plain file offsets there).