Skip to content

Commit 2663fd6

Browse files
committed
PIX: dxcpdbutils: Don't set default entry name in lib case (#4929)
In the lib case, m_EntryPoint will be non-null but empty, but shouldn't be set anyway. (Also, not clearing m_EntryPoint first can result in an assert in CComPtr that the poiner is non-null, and then the pointer is overwritten, resulting in a small memory leak.)
1 parent f85a8c3 commit 2663fd6

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

tools/clang/tools/dxcompiler/dxcpdbutils.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -947,9 +947,14 @@ struct DxcPdbUtils : public IDxcPdbUtils2, public IDxcPixDxilDebugInfoFactory
947947
HRESULT SetEntryPointToDefaultIfEmpty() {
948948
// Entry point might have been omitted. Set it to main by default.
949949
// Don't set entry point if this instance is non-debug DXIL and has no arguments at all.
950-
// TODO: Check to see that this DxilContainer is not a library before setting the entry point.
951950
if ((!m_EntryPoint || m_EntryPoint->GetStringLength() == 0) && !m_ArgPairs.empty()) {
952-
IFR(Utf8ToBlobWide("main", &m_EntryPoint));
951+
// Don't set the name if the target is a lib
952+
if (!m_TargetProfile ||
953+
m_TargetProfile->GetStringLength() < 3 ||
954+
0 != wcsncmp(m_TargetProfile->GetStringPointer(), L"lib", 3)) {
955+
m_EntryPoint = nullptr;
956+
IFR(Utf8ToBlobWide("main", &m_EntryPoint));
957+
}
953958
}
954959
return S_OK;
955960
}

0 commit comments

Comments
 (0)