OcMachoLib: Update MachoGetMetaclassSymbolFromSmcpSymbol64() to use the new public APIs. Removes MachoGetCxxSymbolByExternRelocation64().

This commit is contained in:
Download-Fritz 2018-10-21 14:53:01 +02:00
parent 48ea3b19f1
commit bcdddbd9ae
3 changed files with 9 additions and 67 deletions

View File

@ -292,21 +292,6 @@ MachoRelocateSymbol64 (
IN OUT MACH_NLIST_64 *Symbol
);
/**
Retrieves a C++ symbol by the Relocation it is referenced by.
@param[in,out] Context Context of the Mach-O.
@param[in] Relocation The Relocation to evaluate.
@retval NULL NULL is returned on failure.
**/
CONST MACH_NLIST_64 *
MachoGetCxxSymbolByExternRelocation64 (
IN OUT VOID *Context,
IN CONST MACH_RELOCATION_INFO *Relocation
);
/**
Returns whether Name is pure virtual.

View File

@ -561,17 +561,22 @@ MachoGetMetaclassSymbolFromSmcpSymbol64 (
IN CONST MACH_NLIST_64 *Smcp
)
{
CONST MACH_RELOCATION_INFO *Relocation;
BOOLEAN Result;
MACH_NLIST_64 *Symbol;
ASSERT (Context != NULL);
ASSERT (Smcp != NULL);
Relocation = MachoGetExternalRelocationByOffset (Context, Smcp->Value);
if (Relocation == NULL) {
Result = MachoGetSymbolByExternRelocationOffset64 (
Context,
Smcp->Value,
&Symbol
);
if (!Result) {
return NULL;
}
return MachoGetCxxSymbolByExternRelocation64 (Context, Relocation);
return Symbol;
}
/**

View File

@ -383,51 +383,3 @@ MachoRelocateSymbol64 (
return TRUE;
}
/**
Retrieves a C++ symbol by the extern Relocation it is referenced by.
@param[in,out] Context Context of the Mach-O.
@param[in] Relocation The extern Relocation to evaluate.
@retval NULL NULL is returned on failure.
**/
CONST MACH_NLIST_64 *
MachoGetCxxSymbolByExternRelocation64 (
IN OUT VOID *Context,
IN CONST MACH_RELOCATION_INFO *Relocation
)
{
OC_MACHO_CONTEXT *MachoContext;
CONST MACH_NLIST_64 *SymbolTable;
CONST CHAR8 *StringTable;
CONST MACH_NLIST_64 *Symbol;
ASSERT (Context != NULL);
ASSERT (Relocation != NULL);
ASSERT (Relocation->Extern != 0);
MachoContext = (OC_MACHO_CONTEXT *)Context;
if ((MachoContext->SymbolTable == NULL)
&& !InternalRetrieveSymtabs64 (MachoContext)) {
return NULL;
}
SymbolTable = MachoContext->SymbolTable;
StringTable = MachoContext->StringTable;
ASSERT (SymbolTable != NULL);
ASSERT (StringTable != NULL);
//
// Scattered Relocations are only supported by i386.
//
ASSERT (((UINT32)Relocation->Address & MACH_RELOC_SCATTERED) == 0);
Symbol = &SymbolTable[Relocation->SymbolNumber];
if (InternalSymbolIsSane (MachoContext, Symbol)) {
return Symbol;
}
return NULL;
}