summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
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/CodeGen/AsmPrinter/CodeViewDebug.cpp
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/CodeGen/AsmPrinter/CodeViewDebug.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
index 1850a30a5d1..a305e3d3ab9 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -432,10 +432,13 @@ void CodeViewDebug::endModule() {
}
static void emitNullTerminatedSymbolName(MCStreamer &OS, StringRef S) {
- // Microsoft's linker seems to have trouble with symbol names longer than
- // 0xffd8 bytes.
- S = S.substr(0, 0xffd8);
- SmallString<32> NullTerminatedString(S);
+ // The maximum CV record length is 0xFF00. Most of the strings we emit appear
+ // after a fixed length portion of the record. The fixed length portion should
+ // always be less than 0xF00 (3840) bytes, so truncate the string so that the
+ // overall record size is less than the maximum allowed.
+ unsigned MaxFixedRecordLength = 0xF00;
+ SmallString<32> NullTerminatedString(
+ S.take_front(MaxRecordLength - MaxFixedRecordLength - 1));
NullTerminatedString.push_back('\0');
OS.EmitBytes(NullTerminatedString);
}
OpenPOWER on IntegriCloud