detect and error out on PDB linked with /DEBUG:FASTLINK

This commit is contained in:
Nikita Smith
2025-02-25 14:42:10 -08:00
parent 6c5d2a05cb
commit a06f576161
4 changed files with 47 additions and 27 deletions
+18 -2
View File
@@ -74,12 +74,14 @@ pdb_info_from_data(Arena *arena, String8 data){
// table layout: epilogue // table layout: epilogue
U32 epilogue_base_off = deleted_words_array_off + num_deleted_words*sizeof(U32); U32 epilogue_base_off = deleted_words_array_off + num_deleted_words*sizeof(U32);
if (epilogue_base_off <= data.size){
U64 record_off = epilogue_base_off;
// read table // read table
if (hash_table_count > 0 && epilogue_base_off <= data.size){ if (hash_table_count > 0) {
PDB_InfoNode *first = 0; PDB_InfoNode *first = 0;
PDB_InfoNode *last = 0; PDB_InfoNode *last = 0;
U32 record_off = epilogue_base_off;
for (U32 i = 0; i < hash_table_count; i += 1, record_off += 8){ for (U32 i = 0; i < hash_table_count; i += 1, record_off += 8){
U32 *record = (U32*)(data.str + record_off); U32 *record = (U32*)(data.str + record_off);
U32 relative_name_off = record[0]; U32 relative_name_off = record[0];
@@ -102,6 +104,20 @@ pdb_info_from_data(Arena *arena, String8 data){
result->auth_guid = *auth_guid; result->auth_guid = *auth_guid;
} }
// read PDB features
PDB_FeatureFlags features = 0;
for (; record_off + sizeof(PDB_FeatureSig) <= data.size; ) {
PDB_FeatureSig sig = 0;
record_off += str8_deserial_read_struct(data, record_off, &sig);
switch (sig) {
case PDB_FeatureSig_NULL: break;
case PDB_FeatureSig_VC140: features |= PDB_FeatureFlag_HAS_ID_STREAM; break;
case PDB_FeatureSig_NO_TYPE_MERGE: features |= PDB_FeatureFlag_NO_TYPE_MERGE; break;
case PDB_FeatureSig_MINIMAL_DEBUG_INFO: features |= PDB_FeatureFlag_MINIMAL_DBG_INFO; break;
}
}
result->features = features;
}
} }
} }
+1
View File
@@ -45,6 +45,7 @@ typedef struct PDB_Info
PDB_InfoNode *first; PDB_InfoNode *first;
PDB_InfoNode *last; PDB_InfoNode *last;
Guid auth_guid; Guid auth_guid;
PDB_FeatureFlags features;
} PDB_Info; } PDB_Info;
typedef struct PDB_InfoHeader typedef struct PDB_InfoHeader
@@ -27,7 +27,6 @@
#include "coff/coff_parse.h" #include "coff/coff_parse.h"
#include "codeview/codeview.h" #include "codeview/codeview.h"
#include "codeview/codeview_parse.h" #include "codeview/codeview_parse.h"
#include "codeview/codeview_enum.h"
#include "msf/msf.h" #include "msf/msf.h"
#include "msf/msf_parse.h" #include "msf/msf_parse.h"
#include "pdb/pdb.h" #include "pdb/pdb.h"
@@ -44,7 +43,6 @@
#include "coff/coff_parse.c" #include "coff/coff_parse.c"
#include "codeview/codeview.c" #include "codeview/codeview.c"
#include "codeview/codeview_parse.c" #include "codeview/codeview_parse.c"
#include "codeview/codeview_enum.c"
#include "msf/msf.c" #include "msf/msf.c"
#include "msf/msf_parse.c" #include "msf/msf_parse.c"
#include "pdb/pdb.c" #include "pdb/pdb.c"
+5
View File
@@ -2957,6 +2957,11 @@ p2r_convert(Arena *arena, P2R_User2Convert *in)
named_streams = pdb_named_stream_table_from_info(arena, info); named_streams = pdb_named_stream_table_from_info(arena, info);
MemoryCopyStruct(&auth_guid, &info->auth_guid); MemoryCopyStruct(&auth_guid, &info->auth_guid);
scratch_end(scratch); scratch_end(scratch);
if (info->features & PDB_FeatureFlag_MINIMAL_DBG_INFO) {
fprintf(stderr, "ERROR: PDB was linked with /DEBUG:FASTLINK (partial debug info is not supported). Please relink using /DEBUG:FULL.");
os_abort(1);
}
} }
////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////