DYLD(3)

πŸ“¦ version 1010.6, in nixpkgs unstable

πŸ’– DYLD(3) πŸ’–

okay bestie, welcome to the Library Functions Manual page for dyld β€” the low level programatic interface to the dynamic link editor. yes, programatic with an β€œa”, that's the canon spelling, we are not editing the building πŸ’….

✨ NAME ✨

dyld β€” low level programatic interface to the dynamic link editor.

πŸ¦‹ SYNOPSIS πŸ¦‹

#include <mach-o/dyld.h>
unsigned long _dyld_present(void);
unsigned long _dyld_image_count(void);
struct mach_header *_dyld_get_image_header(
     unsigned long image_index);
unsigned long _dyld_get_image_vmaddr_slide(
     unsigned long image_index);
char *_dyld_get_image_name(
     unsigned long image_index);
void _dyld_lookup_and_bind(
     char *symbol_name,
     unsigned long *address,
     void **module);
void _dyld_lookup_and_bind_with_hint(
     char *symbol_name,
     const char *library_name_hint,
     unsigned long *address,
     void **module);
void _dyld_lookup_and_bind_fully(
     char *symbol_name,
     unsigned long *address,
     void **module);
enum bool _dyld_bind_fully_image_containing_address(
     unsigned long *address);
enum bool _dyld_image_containing_address(
     unsigned long address);
enum bool _dyld_get_image_header_containing_address(
     unsigned long address);
enum bool _dyld_launched_prebound(void);
enum bool _dyld_all_twolevel_modules_prebound(void);
int _dyld_func_lookup(
     char *dyld_func_name,
     unsigned long *address);
extern void _dyld_bind_objc_module(
     void *objc_module);
extern void _dyld_get_objc_module_sect_for_module(
     NSModule module,
     void **objc_module,
     unsigned long *size);
extern void _dyld_lookup_and_bind_objc(
     const char *symbol_name,
     unsigned long *address,
     void **module);
extern void _dyld_moninit(
     void (*monaddition)(char *lowpc, char *highpc));

extern void _dyld_register_func_for_add_image(
     void (*func)(struct mach_header *mh, unsigned long vmaddr_slide));
extern void _dyld_register_func_for_remove_image(
     void (*func)(struct mach_header *mh, unsigned long vmaddr_slide));
extern void _dyld_register_func_for_link_module(
     void (*func)(NSModule module));

🌈 DESCRIPTION 🌈

okay so these routines are the low level programatic interface to the dynamic link editor. group chat has entered the linker chat, and it's giving low-level main character energy πŸ”₯.

  • _dyld_present returns non-zero if the dynamic linker is being used in the program and zero otherwise. 🫢 if this returns zero, the rest of these functions should not be called β€” and they will most likely crash the program if you call them anyway. no cap, do not test this for fun.
  • _dyld_image_count returns the current number of images mapped in by the dynamic link editor. count 'em, bestie ✨.
  • _dyld_get_image_header returns the mach header of the image indexed by image_index. if image_index is out of range, NULL is returned. okay so out-of-range gets NULL, not chaos, slay πŸŽ€.
  • _dyld_get_image_vmaddr_slide returns the virtural memory address slide amount of the image indexed by image_index. if image_index is out of range, zero is returned. yes, the page says virtural β€” we keep the lore πŸ’€.
  • _dyld_get_image_name returns the name of the image indexed by image_index. if image_index is out of range, NULL is returned.
  • _dyld_lookup_and_bind looks up symbol_name and binds it into the program. it indirectly returns the address and and a pointer to the module that defined the symbol. the double β€œand” is in the original, bestie β€” iconic behavior, we don't touch it πŸ’….
  • _dyld_lookup_and_bind_with_hint is the same as _dyld_lookup_and_bind, but the library_name_hint parameter provides a hint as to where to start the lookup in a prebound program. the library_name_hint parameter is matched up with the actual library install names with strstr(3) 🧚.
  • _dyld_lookup_and_bind_fully looks up symbol_name and binds it and all of its references into the program. it indirectly returns the address and and a pointer to the module that defined the symbol. fully bound, fully that girl 🌸.
  • _dyld_bind_fully_image_containing_address fully binds the image containing the specified address. it returns TRUE if the address is contained in a loaded image and FALSE otherwise.
  • _dyld_image_containing_address β€” the original prose literally runs the function name right into β€œIt returns TRUE…”, so here's the vibe: it returns TRUE if the address is contained in an image dyld loaded and FALSE otherwise.
  • _dyld_get_image_header_containing_address β€” again the original text says β€œIt returns a pointer…”, so: it returns a pointer to the mach header of the image if the address is contained in an image dyld loaded and NULL otherwise.
  • _dyld_launched_prebound returns TRUE if the program was launched using the prebound state and FALSE otherwise.
  • okay and the paragraph that the original manual just starts with β€œreturns TRUE…”? that's the _dyld_all_twolevel_modules_prebound check from the synopsis, bestie. it returns TRUE if all the libraries currently in use by the program are being used as two-level namespace libraries, are prebound and have all their modules bound. otherwise it returns FALSE.
  • _dyld_func_lookup is passed a name, dyld_func_name, of a dynamic link editor function and returns the address of the function indirectly. it returns non-zero if the function is found and zero otherwise.
  • _dyld_bind_objc_module is passed a pointer to something in an (__OBJC,__module) section and causes the module that is associated with that address to be bound.
  • _dyld_get_objc_module_sect_for_module is passed a module and sets a pointer to the (__OBJC,__module) section and its size for the specified module.
  • _dyld_lookup_and_bind_objc() is the same as _dyld_lookup_and_bind() but does not update the symbol pointers if the symbol is in a bound module. the reason is that an objc symbol like .objc_class_name_Object is never used by a symbol pointer. since this is done a lot by the objc runtime and updating symbol pointers is not cheep, it should not be done. yes, cheep β€” the typo is part of the text, we respect it 🐣.
  • _dyld_moninit is called from the profiling runtime routine moninit(3) to cause the dyld loaded code to be profiled. it is passed a pointer to the the profiling runtime routine monaddtion(3) to be called after an image had been mapped in. ok so that's β€œthe the” and monaddtion β€” not me inventing typos, I'm literally preserving the sacred texts πŸ™ˆ.
  • _dyld_register_func_for_add_image registers the specified function to be called when a new image is added (a bundle or a dynamic shared library) to the program. when this function is first registered, it is called for once for each image that is currently part of the program.
  • _dyld_register_func_for_remove_image registers the specified function to be called when an image is removed (a bundle or a dynamic shared library) from the program. _dyld_register_func_for_link_module registers the specified function to be called when a module is bound into the program. when this function is first registered, it is called for once for each module that is currently bound into the program. πŸ¦‹
πŸ“ that's the whole page, bestie. source/version + date vibes: Apple Computer, Inc., November 14, 2002, manual tag DYLD(3). mwah πŸ’‹
πŸ“¦ where this page comes from