GETSECTBYNAME(3)

πŸ“¦ version 1010.6, in nixpkgs unstable

okay bestie, welcome to GETSECTBYNAME(3) from the Library Functions Manual πŸ’… this one's all about grabbing section info by name, and yes, it's lowkey iconic.

πŸ’– NAME πŸ’–

getsectbyname, getsectdata β€” get the section information for the named section.

✨ SYNOPSIS ✨

#include <mach-o/getsect.h>

const struct section *getsectbynamefromheader(
const struct mach_header *mhp,
const char *segname,
const char *sectname)
const struct section *getsectbyname(
const char *segname,
const char *sectname)
char *getsectdatafromheader(
const struct mach_header *mhp,
const char *segname,
const char *sectname,
unsigned long *size)
char *getsectdata(
const char *segname,
const char *sectname,
unsigned long *size)
char *getsectdatafromFramework(
const char *FrameworkName,
const char *segname,
const char *sectname,
unsigned long *size)

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so here's the group chat rundown, bestie: these functions are your little section-finders. they look for the named section inside the named segment, and the vibes depend on which header you're working with. 🫢

  • getsectbynamefromheader β€” returns the section structure for the named section in the named segment if it exists in the specified Mach header; otherwise it returns NULL. If the specified Mach header comes from a dynamic library as returned by _dyld_get_image_header(3), the addr field in the section structure will have to have _dyld_get_image_vmaddr_slide(3) added to it to make it a valid pointer. like, that slide addition is not optional, bestie.
  • getsectbyname β€” the same as getsectbynamefromheader, but its first argument is the link editor defined symbol _mh_execute_header. easy peasy. ✨
  • getsectdatafromheader β€” returns the address to the data for the named section in the named segment if it exists in the specified Mach header. Also, it returns the size of the section data indirectly through the pointer size. Otherwise it returns NULL for the pointer and zero for the size. If the specified Mach header comes from a dynamic library as returned by _dyld_get_image_header(3), the address to the data returned will have to have _dyld_get_image_vmaddr_slide(3) added to it to make it a valid pointer. no cap, same slide situation as above.
  • getsectdata β€” the same as getsectdatafromheader, but its first argument is the link editor defined symbol _mh_execute_header. periodt. πŸ’…
  • getsectdatafromFramework β€” used to get the named section data from the named Framework. for example, the framework name Appkit would be used for /System/Library/Frameworks/Appkit.framework/Versions/C/Appkit. If that Framework isn't being used by the program, then it returns NULL for the pointer and zero for the size. iykyk, framework hunting has consequences. πŸ¦‹
real talk: when the Mach header came from a dynamic library (as returned by _dyld_get_image_header(3)), the slide from _dyld_get_image_vmaddr_slide(3) has to be added to make the addr field or the returned data address a valid pointer. the manual is very clear on that, and we do not argue with the manual. 😭

🌈 SEE ALSO 🌈


mwah πŸ’‹ this cutie was brought to you by Apple Computer, Inc., dated April 10, 1998, under the GETSECTBYNAME(3) banner β€” and that's the whole manual page, bestie. slay. πŸ‘‘

πŸ“¦ where this page comes from