mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-13 06:29:59 +00:00
[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
This commit is contained in:
parent
989b264cc2
commit
9abb223622
@ -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);
|
||||
}
|
||||
|
@ -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();
|
||||
|
43
test/DebugInfo/COFF/long-name.ll
Normal file
43
test/DebugInfo/COFF/long-name.ll
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user