OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
Symbols.c File Reference
#include <Uefi.h>
#include <IndustryStandard/AppleMachoImage.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/BaseOverflowLib.h>
#include <Library/DebugLib.h>
#include <Library/OcMachoLib.h>
#include "OcMachoLibInternal.h"

Go to the source code of this file.

Functions

BOOLEAN MachoSymbolIsDefined (IN OUT OC_MACHO_CONTEXT *Context, IN CONST MACH_NLIST_ANY *Symbol)
 
BOOLEAN MachoSymbolIsLocalDefined (IN OUT OC_MACHO_CONTEXT *Context, IN CONST MACH_NLIST_ANY *Symbol)
 
MACH_NLIST_ANYMachoGetLocalDefinedSymbolByName (IN OUT OC_MACHO_CONTEXT *Context, IN CONST CHAR8 *Name)
 
MACH_NLIST_ANYMachoGetSymbolByIndex (IN OUT OC_MACHO_CONTEXT *Context, IN UINT32 Index)
 
CONST CHAR8 * MachoGetSymbolName (IN OUT OC_MACHO_CONTEXT *Context, IN CONST MACH_NLIST_ANY *Symbol)
 
CONST CHAR8 * MachoGetIndirectSymbolName (IN OUT OC_MACHO_CONTEXT *Context, IN CONST MACH_NLIST_ANY *Symbol)
 
BOOLEAN MachoIsSymbolValueInRange (IN OUT OC_MACHO_CONTEXT *Context, IN CONST MACH_NLIST_ANY *Symbol)
 
BOOLEAN MachoGetSymbolByExternRelocationOffset (IN OUT OC_MACHO_CONTEXT *Context, IN UINT64 Address, OUT MACH_NLIST_ANY **Symbol)
 
BOOLEAN MachoRelocateSymbol (IN OUT OC_MACHO_CONTEXT *Context, IN UINT64 LinkAddress, IN OUT MACH_NLIST_ANY *Symbol)
 
BOOLEAN MachoSymbolGetFileOffset (IN OUT OC_MACHO_CONTEXT *Context, IN CONST MACH_NLIST_ANY *Symbol, OUT UINT32 *FileOffset, OUT UINT32 *MaxSize OPTIONAL)
 
BOOLEAN MachoSymbolGetDirectFileOffset (IN OUT OC_MACHO_CONTEXT *Context, IN UINT64 Address, OUT UINT32 *FileOffset, OUT UINT32 *MaxSize OPTIONAL)
 

Detailed Description

Provides services for symbols.

Copyright (c) 2018, Download-Fritz. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php.

THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

Definition in file Symbols.c.

Function Documentation

◆ MachoGetIndirectSymbolName()

CONST CHAR8 * MachoGetIndirectSymbolName ( IN OUT OC_MACHO_CONTEXT * Context,
IN CONST MACH_NLIST_ANY * Symbol )

Retrieves a Symbol's name.

Parameters
[in,out]ContextContext of the Mach-O.
[in]SymbolIndirect symbol to retrieve the name of.
Return values
NULLNULL is returned on failure.

Definition at line 93 of file Symbols.c.

◆ MachoGetLocalDefinedSymbolByName()

MACH_NLIST_ANY * MachoGetLocalDefinedSymbolByName ( IN OUT OC_MACHO_CONTEXT * Context,
IN CONST CHAR8 * Name )

Retrieves a locally defined symbol by its name.

Parameters
[in]ContextContext of the Mach-O.
[in]NameName of the symbol to locate.

Definition at line 54 of file Symbols.c.

◆ MachoGetSymbolByExternRelocationOffset()

BOOLEAN MachoGetSymbolByExternRelocationOffset ( IN OUT OC_MACHO_CONTEXT * Context,
IN UINT64 Address,
OUT MACH_NLIST_ANY ** Symbol )

Retrieves the symbol referenced by the extern Relocation targeting Address.

Parameters
[in,out]ContextContext of the Mach-O.
[in]AddressAddress to search for.
[out]SymbolBuffer to output the symbol referenced by the Relocation into. The output is undefined when FALSE is returned. May be NULL.
Returns
Whether the Relocation exists.

Definition at line 119 of file Symbols.c.

◆ MachoGetSymbolByIndex()

MACH_NLIST_ANY * MachoGetSymbolByIndex ( IN OUT OC_MACHO_CONTEXT * Context,
IN UINT32 Index )

Retrieves a symbol by its index.

Parameters
[in]ContextContext of the Mach-O.
[in]IndexIndex of the symbol to locate.
Return values
NULLNULL is returned on failure.

Definition at line 67 of file Symbols.c.

◆ MachoGetSymbolName()

CONST CHAR8 * MachoGetSymbolName ( IN OUT OC_MACHO_CONTEXT * Context,
IN CONST MACH_NLIST_ANY * Symbol )

Retrieves a Symbol's name.

Parameters
[in,out]ContextContext of the Mach-O.
[in]SymbolSymbol to retrieve the name of.
Return values
symbolname.

Definition at line 80 of file Symbols.c.

◆ MachoIsSymbolValueInRange()

BOOLEAN MachoIsSymbolValueInRange ( IN OUT OC_MACHO_CONTEXT * Context,
IN CONST MACH_NLIST_ANY * Symbol )

Returns whether the symbol's value is a valid address within the Mach-O referenced to by Context.

Parameters
[in,out]ContextContext of the Mach-O.
[in]SymbolSymbol to verify the value of.

Definition at line 106 of file Symbols.c.

◆ MachoRelocateSymbol()

BOOLEAN MachoRelocateSymbol ( IN OUT OC_MACHO_CONTEXT * Context,
IN UINT64 LinkAddress,
IN OUT MACH_NLIST_ANY * Symbol )

Relocate Symbol to be against LinkAddress.

Parameters
[in,out]ContextContext of the Mach-O.
[in]LinkAddressThe address to be linked against.
[in,out]SymbolThe symbol to be relocated.
Returns
Whether the operation has been completed successfully.

Definition at line 136 of file Symbols.c.

◆ MachoSymbolGetDirectFileOffset()

BOOLEAN MachoSymbolGetDirectFileOffset ( IN OUT OC_MACHO_CONTEXT * Context,
IN UINT64 Address,
OUT UINT32 * FileOffset,
OUT UINT32 *MaxSize OPTIONAL )

Retrieves the Mach-O file offset of the address pointed to by a Symbol.

Parameters
[in,out]ContextContext of the Mach-O.
[in]AddressVirtual address to retrieve the offset of.
[out]FileOffsetPointer the file offset is returned into. If FALSE is returned, the output is undefined.
[out]MaxSizeMaximum data safely available from FileOffset.
Return values
00 is returned on failure.

Definition at line 168 of file Symbols.c.

◆ MachoSymbolGetFileOffset()

BOOLEAN MachoSymbolGetFileOffset ( IN OUT OC_MACHO_CONTEXT * Context,
IN CONST MACH_NLIST_ANY * Symbol,
OUT UINT32 * FileOffset,
OUT UINT32 *MaxSize OPTIONAL )

Retrieves the Mach-O file offset of the address pointed to by a Symbol.

Parameters
[in,out]ContextContext of the Mach-O.
[in]SymbolSymbol to retrieve the offset of.
[out]FileOffsetPointer the file offset is returned into. If FALSE is returned, the output is undefined.
[out]MaxSizeMaximum data safely available from FileOffset.
Return values
00 is returned on failure.

Definition at line 153 of file Symbols.c.

◆ MachoSymbolIsDefined()

BOOLEAN MachoSymbolIsDefined ( IN OUT OC_MACHO_CONTEXT * Context,
IN CONST MACH_NLIST_ANY * Symbol )

Returns whether Symbol is defined.

Parameters
[in,out]ContextContext of the Mach-O.
[in]SymbolSymbol to evaluate.

Definition at line 28 of file Symbols.c.

◆ MachoSymbolIsLocalDefined()

BOOLEAN MachoSymbolIsLocalDefined ( IN OUT OC_MACHO_CONTEXT * Context,
IN CONST MACH_NLIST_ANY * Symbol )

Returns whether Symbol is defined locally.

Parameters
[in,out]ContextContext of the Mach-O.
[in]SymbolSymbol to evaluate.

Definition at line 41 of file Symbols.c.