OSDN Git Service

Do not look up symbol names when n_strx == 0
authorMichael Trent <mtrent@apple.com>
Wed, 3 Jan 2018 23:28:32 +0000 (23:28 +0000)
committerMichael Trent <mtrent@apple.com>
Wed, 3 Jan 2018 23:28:32 +0000 (23:28 +0000)
commitcb27e1d0da7f30562ea6c1c4f01393afbf112620
tree32993636d54eb352c9aa5e3c9851530cab67a98e
parentfed80828328eb9a957bb0221a8f2545dad6562ad
Do not look up symbol names when n_strx == 0

Summary:
Historical tools for working with mach-o binaries verify the nlist field
n_strx has a non-zero value before using that value to retrieve symbol names.
Under some cirumstances, llvm-nm will attempt to display the symbol name at
position 0, even though symbol names at that position are not well defined.
This change addresses this problem by returning an empty string when n_strx
is zero.

rdar://problem/35750548

Reviewers: enderby, davide

Reviewed By: enderby, davide

Subscribers: davide, llvm-commits, JDevlieghere

Differential Revision: https://reviews.llvm.org/D41657

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@321773 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Object/MachOObjectFile.cpp
test/tools/llvm-nm/X86/Inputs/macho-dwarf-x86_64 [new file with mode: 0755]
test/tools/llvm-nm/X86/macho-dwarf.test [new file with mode: 0644]