This is an archive of the discontinued LLVM Phabricator instance.

objdump fails to parse Mach-O binaries with n_desc bearing stabs
ClosedPublic

Authored by mtrent on Feb 22 2019, 5:49 PM.

Details

Summary

The objdump Mach-O parser uses MachOObjectFile::checkSymbolTable() to
verify the symbol table is in a legal state before dereferencing the
offsets in the table. This routine missed a test for N_STAB symbols
when validating the two-level name space library ordinal for undefined
symbols. If the binary in question contained a value in the n_desc high
byte that is larger than the list of loaded dylibs, checkSymbolTable()
will flag the library ordinal as being out of range. Most of the time
the n_desc field is set to 0 or to small values, but old final linked
binaries exist with N_STAB symbols bearing non-trivial n_desc fields.

The change here is simply to verify a symbol is not an N_STAB symbol
before consulting the values of n_other or n_desc.

rdar://44977336

Diff Detail

Repository
rL LLVM

Event Timeline

mtrent created this revision.Feb 22 2019, 5:49 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 22 2019, 5:49 PM
Herald added a subscriber: rupprecht. · View Herald Transcript
pete accepted this revision.Feb 22 2019, 5:50 PM
This revision is now accepted and ready to land.Feb 22 2019, 5:50 PM
This revision was automatically updated to reflect the committed changes.