[llvm] 991df73 - [Object][MachO] Handle end iterator in getSymbolType()
Steven Wu via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 17 15:06:59 PDT 2021
Author: Steven Wu
Date: 2021-03-17T15:06:45-07:00
New Revision: 991df7333d4a6c9904dec17f53b4c531cfb40d49
URL: https://github.com/llvm/llvm-project/commit/991df7333d4a6c9904dec17f53b4c531cfb40d49
DIFF: https://github.com/llvm/llvm-project/commit/991df7333d4a6c9904dec17f53b4c531cfb40d49.diff
LOG: [Object][MachO] Handle end iterator in getSymbolType()
Fix a bug in MachOObjectFile::getSymbolType() that it is not checking if
the iterator is end() before deference the iterator. Instead, return
`Other` type, which aligns with the behavior of `llvm-nm`.
rdar://75291638
Reviewed By: davide, ab
Differential Revision: https://reviews.llvm.org/D98739
Added:
Modified:
llvm/lib/Object/MachOObjectFile.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp
index 302255926289..498e99bdb828 100644
--- a/llvm/lib/Object/MachOObjectFile.cpp
+++ b/llvm/lib/Object/MachOObjectFile.cpp
@@ -1836,6 +1836,8 @@ MachOObjectFile::getSymbolType(DataRefImpl Symb) const {
if (!SecOrError)
return SecOrError.takeError();
section_iterator Sec = *SecOrError;
+ if (Sec == section_end())
+ return SymbolRef::ST_Other;
if (Sec->isData() || Sec->isBSS())
return SymbolRef::ST_Data;
return SymbolRef::ST_Function;
More information about the llvm-commits
mailing list