Skip to content

Commit

Permalink
fix check for unset xref from symbol's group
Browse files Browse the repository at this point in the history
  • Loading branch information
RadWolfie committed Dec 20, 2021
1 parent 611a517 commit 862ea93
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/lib/internal_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ static bool CompareOOVPAToAddress(iXbSymbolContext* pContext, OOVPA* Oovpa, memp
// Return if the given (XRef'erenced) is not set yet.
static inline bool internal_IsXRefUnset(uint16_t XRef)
{
return (XRef == (uint16_t)XREF_ADDR_UNDETERMINED) || (XRef == XREF_ADDR_DERIVE);
return (XRef == XREF_UNDETERMINED) || (XRef <= XREF_KT_COUNT);
}

// Return if the given (XRef'erenced) address is not set yet.
Expand Down
15 changes: 6 additions & 9 deletions src/lib/internal_tests.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,12 @@ static unsigned int SymbolDatabaseVerifyContext_VerifyEntry(SymbolDatabaseVerify
context->main.revision_index = revision_index;

error_count += SymbolDatabaseVerifyContext_VerifyXRefJmp(context, table, symbol_index, revision_index);

// For safety check purpose
if (internal_IsXRefUnset(table[symbol_index].xref)) {
output_message_format(&context->output, XB_OUTPUT_MESSAGE_ERROR, "%s cannot have unset xref.", table[symbol_index].szFuncName);
error_count++;
}
}
else {
context->against.symbol_index = symbol_index;
Expand All @@ -276,15 +282,6 @@ static unsigned int SymbolDatabaseVerifyContext_VerifyDatabase(SymbolDatabaseVer

// Verify each entry in data's symbol table.
for (uint32_t s = 0; s < data->SymbolsTableCount; s++) {
// We only need to check from main, not against.
if (context->against.data == NULL) {
// For safety check purpose
if (internal_IsXRefUnset(data->SymbolsTable[s].xref)) {
output_message_format(&context->output, XB_OUTPUT_MESSAGE_ERROR, "%s cannot have unset xref.", data->SymbolsTable[s].szFuncName);
error_count++;
}
}

// Check each revision entry in a symbol.
for (uint32_t r = 0; r < data->SymbolsTable[s].count; r++) {
error_count += SymbolDatabaseVerifyContext_VerifyEntry(context, data->SymbolsTable, s, r);
Expand Down
3 changes: 2 additions & 1 deletion src/xref/list_xref.h
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,8 @@ typedef enum _XRefDatabaseOffset {
#include "xonline.def"
#undef XREF_SYMBOL

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

Expand Down

0 comments on commit 862ea93

Please sign in to comment.