NSObjectFileImage(3)
β¨ NAME β¨
okay so bestie, this page is NSObjectFileImage(3) from the Library Functions Manual, and it's literally the programmatic interface for working with Mach-O files. no cap. π
π¦ SYNOPSIS π¦
bestie, here's the exact include + declarations vibe, character for character:
#include <mach-o/dyld.h>
extern NSObjectFileImageReturnCode NSCreateObjectFileImageFromFile(
const char *pathName,
NSObjectFileImage *objectFileImage);
extern NSObjectFileImageReturnCode NSCreateObjectFileImageFromMemory(
void *address,
unsigned long size,
NSObjectFileImage *objectFileImage);
extern NSObjectFileImageReturnCode NSCreateCoreFileImageFromFile(
const char *pathName,
NSObjectFileImage *objectFileImage);
extern enum DYLD_BOOL NSDestroyObjectFileImage(
NSObjectFileImage objectFileImage);
extern unsigned long NSSymbolDefinitionCountInObjectFileImage(
NSObjectFileImage objectFileImage);
extern const char * NSSymbolDefinitionNameInObjectFileImage(
NSObjectFileImage objectFileImage,
unsigned long ordinal);
extern unsigned long NSSymbolReferenceCountInObjectFileImage(
NSObjectFileImage objectFileImage);
extern const char * NSSymbolReferenceNameInObjectFileImage(
NSObjectFileImage objectFileImage,
unsigned long ordinal,
enum DYLD_BOOL *tentative_definition); /* can be NULL */
extern enum DYLD_BOOL NSIsSymbolDefinedInObjectFileImage(
NSObjectFileImage objectFileImage,
const char *symbolName);
extern void * NSGetSectionDataInObjectFileImage(
NSObjectFileImage objectFileImage,
const char *segmentName,
const char *sectionName,
unsigned long* size); /* can be NULL */
extern enum DYLD_BOOL NSHasModInitObjectFileImage(
NSObjectFileImage objectFileImage);
π DESCRIPTION π
okay so these routines are the programmatic interface for working with Mach-O files. they bring the Mach-O file into memory, and the API lets the file be inspected or loaded into the program. when an object file image is created, it gets checked to make sure it's a valid format and compatible with the host machine's cpu architecture. slay. β¨
NSCreateObjectFileImageFromFileβ takes the parameterpathNameas the path name to the file name in the file system and creates and returns anNSObjectFileImage. currently onlyMH_BUNDLEfiles can be used withNSCreateObjectFileImageFromFile, which can then be loaded into the program usingNSLinkModule(3). if the file is valid, anNSObjectFileImageis returned and the return code isNSObjectFileImageSuccess. πNSCreateObjectFileImageFromMemoryβ does the same asNSCreateObjectFileImageFromFilebut takes two parametersaddressandsizefor the Mach-O file that is in memory. β¨NSCreateCoreFileImageFromFileβ takes the parameterpathNameas the path name to a core file in the file system and creates and returns anNSObjectFileImage. thisNSObjectFileImagecan then be loaded into a task with_dyld_debug_task_from_core(3)to determine what libraries were loaded and which modules were linked. π«ΆNSSymbolDefinitionCountInObjectFileImageβ returns the number of symbol definitions in theNSObjectFileImage. πNSSymbolDefinitionNameInObjectFileImageβ returns the name of thei'th symbol definitions in theNSObjectFileImage. the'C'string returned should not be freed. if the ordinal specified is outside the range[0..NSSymbolDefinitionCountInObjectFileImage],NULLwill be returned. βNSSymbolReferenceCountInObjectFileImageβ returns the number of references to undefined symbols theNSObjectFileImagehas. πΈNSSymbolReferenceNameInObjectFileImageβ returns the name of thei'th undefined symbol in theNSObjectFileImage. the'C'string returned should not be freed. if the ordinal specified is outside the range[0..NSSymbolReferenceCountInObjectFileImage],NULLwill be returned. π¦NSIsSymbolDefinedInObjectFileImageβ returnsTRUEif the specified symbol name has a definition in theNSObjectFileImage. π₯NSGetSectionDataInObjectFileImageβ returns the address of the data for the named section in the named segment in theNSObjectFileImage. if the parametersizeis notNULL, the size of the section is returned insize. if the section cannot be found or a zerofill section,NULLis returned and the size returned is zero. πNSHasModInitObjectFileImageβ returnsTRUEif theNSObjectFileImagehas any module initialization routines andFALSEotherwise. π
π RETURN CODES π
the API's that create NSObjectFileImage's return an NSObjectFileImageReturnCode with the following possible values, bestie:
NSObjectFileImageSuccessβ indicates the API was successful and it returned a validNSObjectFileImagefor the host machine's cpu architecture. βNSObjectFileImageFailureβ indicates the API failed and noNSObjectFileImagewas returned. if this is returned, an error message is printed onstderras to the reason for the failure. πNSObjectFileImageInappropriateFileβ indicates the API failed because the file passed to it was not an appropriate type of object file. πNSObjectFileImageArchβ indicates the API failed because the host machine's cpu architecture could not be found in the file. πNSObjectFileImageFormatβ indicates the API failed because the Mach-O format was malformed. if this is returned, an error message is printed onstderras to the format error. π¨NSObjectFileImageAccessβ indicates the API failed because the file could not be accessed. π
π ALSO SEE π
π cute sign-off tea: this page comes from Apple Computer, Inc., dated March 14, 2003, and it's the NSObjectFileImage(3) manual page β periodt. π«Ά
π¦ where this page comes from
- nixpkgs unstable: cctools 1010.6
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms