aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Object/MachOObjectFile.cpp
diff options
context:
space:
mode:
authorSteven Wu <stevenwu@apple.com>2021-03-17 15:05:51 -0700
committerSteven Wu <stevenwu@apple.com>2021-03-17 15:06:45 -0700
commit991df7333d4a6c9904dec17f53b4c531cfb40d49 (patch)
treeb6da47788ba32868b0505a98d81f77fd8451a6d8 /llvm/lib/Object/MachOObjectFile.cpp
parent48ab9674b21be2c6206ccc04602d4a3e4c812953 (diff)
downloadllvm-991df7333d4a6c9904dec17f53b4c531cfb40d49.zip
llvm-991df7333d4a6c9904dec17f53b4c531cfb40d49.tar.gz
llvm-991df7333d4a6c9904dec17f53b4c531cfb40d49.tar.bz2
[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
Diffstat (limited to 'llvm/lib/Object/MachOObjectFile.cpp')
-rw-r--r--llvm/lib/Object/MachOObjectFile.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp
index 3022559..498e99b 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;