OcMachoLib: Update GetSymbolByRelocOffset interface to report Relocation existance.

This commit is contained in:
Download-Fritz 2019-03-23 11:48:02 +01:00
parent eda77537cc
commit 0ce7e1ec99
3 changed files with 28 additions and 10 deletions

View File

@ -322,14 +322,18 @@ MachoIsSymbolValueInRange64 (
@param[in,out] Context Context of the Mach-O.
@param[in] Address Address to search for.
@param[out] Symbol Buffer to output the symbol referenced by the
Relocation into. The output is undefined when FALSE
is returned. May be NULL.
@returns NULL NULL is returned on failure.
@returns Whether the Relocation exists.
**/
MACH_NLIST_64 *
BOOLEAN
MachoGetSymbolByExternRelocationOffset64 (
IN OUT OC_MACHO_CONTEXT *Context,
IN UINT64 Address
IN UINT64 Address,
OUT MACH_NLIST_64 **Symbol
);
/**

View File

@ -569,6 +569,9 @@ MachoGetMetaclassSymbolFromSmcpSymbol64 (
IN CONST MACH_NLIST_64 *Smcp
)
{
MACH_NLIST_64 *Symbol;
BOOLEAN Result;
ASSERT (Context != NULL);
ASSERT (Smcp != NULL);
@ -576,10 +579,16 @@ MachoGetMetaclassSymbolFromSmcpSymbol64 (
return NULL;
}
return MachoGetSymbolByExternRelocationOffset64 (
Result = MachoGetSymbolByExternRelocationOffset64 (
Context,
Smcp->Value
Smcp->Value,
&Symbol
);
if (Result) {
return Symbol;
}
return NULL;
}
/**

View File

@ -297,14 +297,18 @@ MachoGetIndirectSymbolName64 (
@param[in,out] Context Context of the Mach-O.
@param[in] Address Address to search for.
@param[out] Symbol Buffer to output the symbol referenced by the
Relocation into. The output is undefined when FALSE
is returned. May be NULL.
@returns NULL NULL is returned on failure.
@returns Whether the Relocation exists.
**/
MACH_NLIST_64 *
BOOLEAN
MachoGetSymbolByExternRelocationOffset64 (
IN OUT OC_MACHO_CONTEXT *Context,
IN UINT64 Address
IN UINT64 Address,
OUT MACH_NLIST_64 **Symbol
)
{
CONST MACH_RELOCATION_INFO *Relocation;
@ -313,10 +317,11 @@ MachoGetSymbolByExternRelocationOffset64 (
Relocation = InternalGetExternalRelocationByOffset (Context, Address);
if (Relocation != NULL) {
return MachoGetSymbolByIndex64 (Context, Relocation->SymbolNumber);
*Symbol = MachoGetSymbolByIndex64 (Context, Relocation->SymbolNumber);
return TRUE;
}
return NULL;
return FALSE;
}
/**