summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2016-10-05 22:36:07 +0000
committerReid Kleckner <rnk@google.com>2016-10-05 22:36:07 +0000
commitbb96df602ebf7357b24cba5bf4fb09750d467be7 (patch)
tree971fe03560ba0c08423831a8db5a913f81365a47 /llvm/lib/MC
parent5aa02480594f861efc332650188eef6b2986a269 (diff)
downloadbcm5719-llvm-bb96df602ebf7357b24cba5bf4fb09750d467be7.tar.gz
bcm5719-llvm-bb96df602ebf7357b24cba5bf4fb09750d467be7.zip
[codeview] Truncate records to maximum record size near 64KB
If we don't truncate, LLVM asserts when the label difference doesn't fit in a 16 bit field. This patch truncates two kinds of data: trailing null terminated names in symbol records, and inline line tables. The inline line table test that I have is too large (many MB), so I'm not checking it in. Hopefully fixes PR28264. llvm-svn: 283403
Diffstat (limited to 'llvm/lib/MC')
-rw-r--r--llvm/lib/MC/MCCodeView.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCCodeView.cpp b/llvm/lib/MC/MCCodeView.cpp
index ec5dc20a13e..ac1acc08b0c 100644
--- a/llvm/lib/MC/MCCodeView.cpp
+++ b/llvm/lib/MC/MCCodeView.cpp
@@ -358,6 +358,13 @@ void CodeViewContext::encodeInlineLineTable(MCAsmLayout &Layout,
SmallVectorImpl<char> &Buffer = Frag.getContents();
Buffer.clear(); // Clear old contents if we went through relaxation.
for (const MCCVLineEntry &Loc : Locs) {
+ // Exit early if our line table would produce an oversized InlineSiteSym
+ // record. Account for the ChangeCodeLength annotation emitted after the
+ // loop ends.
+ size_t MaxBufferSize = MaxRecordLength - sizeof(InlineSiteSym::Hdr) - 8;
+ if (Buffer.size() >= MaxBufferSize)
+ break;
+
if (Loc.getFunctionId() == Frag.SiteFuncId) {
CurSourceLoc.File = Loc.getFileNum();
CurSourceLoc.Line = Loc.getLine();
OpenPOWER on IntegriCloud