[PATCH] D44285: Fix computeSymbolSizes SEGFAULT on invalid file
Teng Qin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 28 15:39:23 PDT 2018
palmtenor updated this revision to Diff 140149.
palmtenor added a comment.
@aprantl Updated with the test file committed:)
https://reviews.llvm.org/D44285
Files:
lib/Object/SymbolSize.cpp
test/tools/llvm-symbolizer/Inputs/zero_file
test/tools/llvm-symbolizer/sym.test
Index: test/tools/llvm-symbolizer/sym.test
===================================================================
--- test/tools/llvm-symbolizer/sym.test
+++ test/tools/llvm-symbolizer/sym.test
@@ -19,6 +19,8 @@
RUN: llvm-symbolizer -print-address -obj=%p/Inputs/addr.exe < %p/Inputs/addr.inp | FileCheck %s
RUN: llvm-symbolizer -inlining -print-address -pretty-print -obj=%p/Inputs/addr.exe < %p/Inputs/addr.inp | FileCheck --check-prefix="PRETTY" %s
+RUN: echo "0x1" > %t.input
+RUN: llvm-symbolizer -obj=%p/Inputs/zero_file < %t.input
#CHECK: some text
#CHECK: 0x40054d
Index: lib/Object/SymbolSize.cpp
===================================================================
--- lib/Object/SymbolSize.cpp
+++ lib/Object/SymbolSize.cpp
@@ -66,6 +66,10 @@
Addresses.push_back(
{O.symbol_end(), Address + Size, 0, getSectionID(O, Sec)});
}
+
+ if (Addresses.empty())
+ return Ret;
+
array_pod_sort(Addresses.begin(), Addresses.end(), compareAddress);
// Compute the size as the gap to the next symbol
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44285.140149.patch
Type: text/x-patch
Size: 1032 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180328/12ee9895/attachment.bin>
More information about the llvm-commits
mailing list