Skip to content

Commit 92593ff

Browse files
committed
fix check for unset xref from symbol's group
1 parent f0e3ef2 commit 92593ff

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

src/lib/internal_functions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ static bool CompareOOVPAToAddress(iXbSymbolContext* pContext, OOVPA* Oovpa, memp
110110
// Return if the given (XRef'erenced) is not set yet.
111111
static inline bool internal_IsXRefUnset(uint16_t XRef)
112112
{
113-
return (XRef == (uint16_t)XREF_ADDR_UNDETERMINED) || (XRef == XREF_ADDR_DERIVE);
113+
return (XRef == XREF_UNDETERMINED) || (XRef <= XREF_KT_COUNT);
114114
}
115115

116116
// Return if the given (XRef'erenced) address is not set yet.

src/lib/internal_tests.h

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,12 @@ static unsigned int SymbolDatabaseVerifyContext_VerifyEntry(SymbolDatabaseVerify
250250
context->main.revision_index = revision_index;
251251

252252
error_count += SymbolDatabaseVerifyContext_VerifyXRefJmp(context, table, symbol_index, revision_index);
253+
254+
// For safety check purpose
255+
if (internal_IsXRefUnset(table[symbol_index].xref)) {
256+
output_message_format(&context->output, XB_OUTPUT_MESSAGE_ERROR, "%s cannot have unset xref.", table[symbol_index].szFuncName);
257+
error_count++;
258+
}
253259
}
254260
else {
255261
context->against.symbol_index = symbol_index;
@@ -276,15 +282,6 @@ static unsigned int SymbolDatabaseVerifyContext_VerifyDatabase(SymbolDatabaseVer
276282

277283
// Verify each entry in data's symbol table.
278284
for (uint32_t s = 0; s < data->SymbolsTableCount; s++) {
279-
// We only need to check from main, not against.
280-
if (context->against.data == NULL) {
281-
// For safety check purpose
282-
if (internal_IsXRefUnset(data->SymbolsTable[s].xref)) {
283-
output_message_format(&context->output, XB_OUTPUT_MESSAGE_ERROR, "%s cannot have unset xref.", data->SymbolsTable[s].szFuncName);
284-
error_count++;
285-
}
286-
}
287-
288285
// Check each revision entry in a symbol.
289286
for (uint32_t r = 0; r < data->SymbolsTable[s].count; r++) {
290287
error_count += SymbolDatabaseVerifyContext_VerifyEntry(context, data->SymbolsTable, s, r);

src/xref/list_xref.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,8 @@ typedef enum _XRefDatabaseOffset {
418418
#include "xonline.def"
419419
#undef XREF_SYMBOL
420420

421-
XREF_COUNT // XREF_COUNT must always be last.
421+
XREF_COUNT, // XREF_COUNT must always be last.
422+
XREF_UNDETERMINED = (uint16_t)-1
422423
// Also, if XREF_COUNT > sizeof(uint16), enlarge struct OOVPA.XRefSaveIndex (and Value somehow)
423424
} XRefDatabaseOffset;
424425

0 commit comments

Comments
 (0)