The FreeRADIUS server $Id: f3670dba8951ca10eb4948feb3dc3db9423a334f $
Loading...
Searching...
No Matches
Data Structures | Macros | Functions | Variables
macho.c File Reference
#include "config.h"
#include <sys/types.h>
#include <dirent.h>
#include <stdlib.h>
#include <string.h>
#include "backtrace.h"
#include "internal.h"
+ Include dependency graph for macho.c:

Go to the source code of this file.

Data Structures

struct  macho_fat_arch
 
struct  macho_fat_arch_64
 
struct  macho_header_32
 
struct  macho_header_64
 
struct  macho_header_fat
 
struct  macho_load_command
 
struct  macho_nlist
 
struct  macho_nlist_64
 
struct  macho_section
 
struct  macho_section_64
 
struct  macho_segment_64_command
 
struct  macho_segment_command
 
struct  macho_symbol
 
struct  macho_syminfo_data
 
struct  macho_symtab_command
 
struct  macho_uuid_command
 

Macros

#define MACH_O_CPU_ARCH_ABI64   0x01000000
 
#define MACH_O_CPU_TYPE_ARM   12
 
#define MACH_O_CPU_TYPE_ARM64   (MACH_O_CPU_TYPE_ARM | MACH_O_CPU_ARCH_ABI64)
 
#define MACH_O_CPU_TYPE_PPC   18
 
#define MACH_O_CPU_TYPE_PPC64   (MACH_O_CPU_TYPE_PPC | MACH_O_CPU_ARCH_ABI64)
 
#define MACH_O_CPU_TYPE_X86   7
 
#define MACH_O_CPU_TYPE_X86_64   (MACH_O_CPU_TYPE_X86 | MACH_O_CPU_ARCH_ABI64)
 
#define MACH_O_LC_SEGMENT   0x01
 
#define MACH_O_LC_SEGMENT_64   0x19
 
#define MACH_O_LC_SYMTAB   0x02
 
#define MACH_O_LC_UUID   0x1b
 
#define MACH_O_MH_CIGAM_FAT   0xbebafeca
 
#define MACH_O_MH_CIGAM_FAT_64   0xbfbafeca
 
#define MACH_O_MH_DSYM   0x0a
 
#define MACH_O_MH_DYLIB   0x06
 
#define MACH_O_MH_EXECUTE   0x02
 
#define MACH_O_MH_MAGIC_32   0xfeedface
 
#define MACH_O_MH_MAGIC_64   0xfeedfacf
 
#define MACH_O_MH_MAGIC_FAT   0xcafebabe
 
#define MACH_O_MH_MAGIC_FAT_64   0xcafebabf
 
#define MACH_O_N_ABS   0x02 /* Absolute symbol */
 
#define MACH_O_N_SECT   0x0e /* Defined in section from n_sect field */
 
#define MACH_O_N_STAB   0xe0 /* Stabs debugging symbol */
 
#define MACH_O_N_TYPE   0x0e /* Mask for type bits */
 
#define MACH_O_N_UNDF   0x00 /* Undefined symbol */
 
#define MACH_O_NAMELEN   (16)
 
#define MACH_O_UUID_LEN   (16)
 

Functions

int backtrace_initialize (struct backtrace_state *state, const char *filename, int descriptor, backtrace_error_callback error_callback, void *data, fileline *fileline_fn)
 
static int macho_add (struct backtrace_state *, const char *, int, off_t, const unsigned char *, struct libbacktrace_base_address, int, backtrace_error_callback, void *, fileline *, int *)
 
static int macho_add_dsym (struct backtrace_state *state, const char *filename, struct libbacktrace_base_address base_address, const unsigned char *uuid, backtrace_error_callback error_callback, void *data, fileline *fileline_fn)
 
static int macho_add_dwarf_section (struct backtrace_state *state, int descriptor, const char *sectname, uint32_t offset, uint64_t size, backtrace_error_callback error_callback, void *data, struct dwarf_sections *dwarf_sections)
 
static int macho_add_dwarf_segment (struct backtrace_state *state, int descriptor, off_t offset, unsigned int cmd, const char *psecs, size_t sizesecs, unsigned int nsects, backtrace_error_callback error_callback, void *data, struct dwarf_sections *dwarf_sections)
 
static int macho_add_fat (struct backtrace_state *state, const char *filename, int descriptor, int swapped, off_t offset, const unsigned char *match_uuid, struct libbacktrace_base_address base_address, int skip_symtab, uint32_t nfat_arch, int is_64, backtrace_error_callback error_callback, void *data, fileline *fileline_fn, int *found_sym)
 
static int macho_add_symtab (struct backtrace_state *state, int descriptor, struct libbacktrace_base_address base_address, int is_64, off_t symoff, unsigned int nsyms, off_t stroff, unsigned int strsize, backtrace_error_callback error_callback, void *data)
 
static int macho_defined_symbol (uint8_t type)
 
static int macho_nodebug (struct backtrace_state *state ATTRIBUTE_UNUSED, uintptr_t pc ATTRIBUTE_UNUSED, backtrace_full_callback callback ATTRIBUTE_UNUSED, backtrace_error_callback error_callback, void *data)
 
static void macho_nosyms (struct backtrace_state *state ATTRIBUTE_UNUSED, uintptr_t addr ATTRIBUTE_UNUSED, backtrace_syminfo_callback callback ATTRIBUTE_UNUSED, backtrace_error_callback error_callback, void *data)
 
static int macho_symbol_compare (const void *v1, const void *v2)
 
static int macho_symbol_search (const void *vkey, const void *ventry)
 
static void macho_syminfo (struct backtrace_state *state, uintptr_t addr, backtrace_syminfo_callback callback, backtrace_error_callback error_callback ATTRIBUTE_UNUSED, void *data)
 

Variables

static const char *const dwarf_section_names [DEBUG_MAX]
 

Data Structure Documentation

◆ macho_fat_arch

struct macho_fat_arch

Definition at line 101 of file macho.c.

Data Fields
uint32_t align
uint32_t cpusubtype
uint32_t cputype
uint32_t offset
uint32_t size

◆ macho_fat_arch_64

struct macho_fat_arch_64

Definition at line 114 of file macho.c.

Data Fields
uint32_t align
uint32_t cpusubtype
uint32_t cputype
uint64_t offset
uint32_t reserved
uint64_t size

◆ macho_header_32

struct macho_header_32

Definition at line 49 of file macho.c.

Data Fields
uint32_t cpusubtype
uint32_t cputype
uint32_t filetype
uint32_t flags
uint32_t magic
uint32_t ncmds
uint32_t sizeofcmds

◆ macho_header_64

struct macho_header_64

Definition at line 62 of file macho.c.

Data Fields
uint32_t cpusubtype
uint32_t cputype
uint32_t filetype
uint32_t flags
uint32_t magic
uint32_t ncmds
uint32_t reserved
uint32_t sizeofcmds

◆ macho_header_fat

struct macho_header_fat

Definition at line 76 of file macho.c.

Data Fields
uint32_t magic
uint32_t nfat_arch

◆ macho_load_command

struct macho_load_command

Definition at line 139 of file macho.c.

Data Fields
uint32_t cmd
uint32_t cmdsize

◆ macho_nlist

struct macho_nlist

Definition at line 252 of file macho.c.

Data Fields
uint16_t n_desc
uint8_t n_sect
uint32_t n_strx
uint8_t n_type
uint32_t n_value

◆ macho_nlist_64

struct macho_nlist_64

Definition at line 263 of file macho.c.

Data Fields
uint16_t n_desc
uint8_t n_sect
uint32_t n_strx
uint8_t n_type
uint64_t n_value

◆ macho_section

struct macho_section

Definition at line 217 of file macho.c.

Data Fields
uint32_t addr
uint32_t align
uint32_t flags
uint32_t nreloc
uint32_t offset
uint32_t reloff
uint32_t reserved1
uint32_t reserved2
char sectname[MACH_O_NAMELEN]
char segment[MACH_O_NAMELEN]
uint32_t size

◆ macho_section_64

struct macho_section_64

Definition at line 234 of file macho.c.

Data Fields
uint64_t addr
uint32_t align
uint32_t flags
uint32_t nreloc
uint32_t offset
uint32_t reloff
uint32_t reserved1
uint32_t reserved2
uint32_t reserved3
char sectname[MACH_O_NAMELEN]
char segment[MACH_O_NAMELEN]
uint64_t size

◆ macho_segment_64_command

struct macho_segment_64_command

Definition at line 175 of file macho.c.

Data Fields
uint32_t cmd
uint32_t cmdsize
uint64_t fileoff
uint64_t filesize
uint32_t flags
uint32_t initprot
uint32_t maxprot
uint32_t nsects
char segname[MACH_O_NAMELEN]
uint64_t vmaddr
uint64_t vmsize

◆ macho_segment_command

struct macho_segment_command

Definition at line 158 of file macho.c.

Data Fields
uint32_t cmd
uint32_t cmdsize
uint32_t fileoff
uint32_t filesize
uint32_t flags
uint32_t initprot
uint32_t maxprot
uint32_t nsects
char segname[MACH_O_NAMELEN]
uint32_t vmaddr
uint32_t vmsize

◆ macho_symbol

struct macho_symbol

Definition at line 285 of file macho.c.

Data Fields
uintptr_t address
const char * name

◆ macho_syminfo_data

struct macho_syminfo_data

Definition at line 293 of file macho.c.

+ Collaboration diagram for macho_syminfo_data:
Data Fields
size_t count
struct macho_syminfo_data * next
struct macho_symbol * symbols

◆ macho_symtab_command

struct macho_symtab_command

Definition at line 192 of file macho.c.

Data Fields
uint32_t cmd
uint32_t cmdsize
uint32_t nsyms
uint32_t stroff
uint32_t strsize
uint32_t symoff

◆ macho_uuid_command

struct macho_uuid_command

Definition at line 208 of file macho.c.

Data Fields
uint32_t cmd
uint32_t cmdsize
unsigned char uuid[MACH_O_UUID_LEN]

Macro Definition Documentation

◆ MACH_O_CPU_ARCH_ABI64

#define MACH_O_CPU_ARCH_ABI64   0x01000000

Definition at line 127 of file macho.c.

◆ MACH_O_CPU_TYPE_ARM

#define MACH_O_CPU_TYPE_ARM   12

Definition at line 130 of file macho.c.

◆ MACH_O_CPU_TYPE_ARM64

#define MACH_O_CPU_TYPE_ARM64   (MACH_O_CPU_TYPE_ARM | MACH_O_CPU_ARCH_ABI64)

Definition at line 134 of file macho.c.

◆ MACH_O_CPU_TYPE_PPC

#define MACH_O_CPU_TYPE_PPC   18

Definition at line 131 of file macho.c.

◆ MACH_O_CPU_TYPE_PPC64

#define MACH_O_CPU_TYPE_PPC64   (MACH_O_CPU_TYPE_PPC | MACH_O_CPU_ARCH_ABI64)

Definition at line 135 of file macho.c.

◆ MACH_O_CPU_TYPE_X86

#define MACH_O_CPU_TYPE_X86   7

Definition at line 129 of file macho.c.

◆ MACH_O_CPU_TYPE_X86_64

#define MACH_O_CPU_TYPE_X86_64   (MACH_O_CPU_TYPE_X86 | MACH_O_CPU_ARCH_ABI64)

Definition at line 133 of file macho.c.

◆ MACH_O_LC_SEGMENT

#define MACH_O_LC_SEGMENT   0x01

Definition at line 147 of file macho.c.

◆ MACH_O_LC_SEGMENT_64

#define MACH_O_LC_SEGMENT_64   0x19

Definition at line 149 of file macho.c.

◆ MACH_O_LC_SYMTAB

#define MACH_O_LC_SYMTAB   0x02

Definition at line 148 of file macho.c.

◆ MACH_O_LC_UUID

#define MACH_O_LC_UUID   0x1b

Definition at line 150 of file macho.c.

◆ MACH_O_MH_CIGAM_FAT

#define MACH_O_MH_CIGAM_FAT   0xbebafeca

Definition at line 87 of file macho.c.

◆ MACH_O_MH_CIGAM_FAT_64

#define MACH_O_MH_CIGAM_FAT_64   0xbfbafeca

Definition at line 89 of file macho.c.

◆ MACH_O_MH_DSYM

#define MACH_O_MH_DSYM   0x0a

Definition at line 95 of file macho.c.

◆ MACH_O_MH_DYLIB

#define MACH_O_MH_DYLIB   0x06

Definition at line 94 of file macho.c.

◆ MACH_O_MH_EXECUTE

#define MACH_O_MH_EXECUTE   0x02

Definition at line 93 of file macho.c.

◆ MACH_O_MH_MAGIC_32

#define MACH_O_MH_MAGIC_32   0xfeedface

Definition at line 84 of file macho.c.

◆ MACH_O_MH_MAGIC_64

#define MACH_O_MH_MAGIC_64   0xfeedfacf

Definition at line 85 of file macho.c.

◆ MACH_O_MH_MAGIC_FAT

#define MACH_O_MH_MAGIC_FAT   0xcafebabe

Definition at line 86 of file macho.c.

◆ MACH_O_MH_MAGIC_FAT_64

#define MACH_O_MH_MAGIC_FAT_64   0xcafebabf

Definition at line 88 of file macho.c.

◆ MACH_O_N_ABS

#define MACH_O_N_ABS   0x02 /* Absolute symbol */

Definition at line 279 of file macho.c.

◆ MACH_O_N_SECT

#define MACH_O_N_SECT   0x0e /* Defined in section from n_sect field */

Definition at line 280 of file macho.c.

◆ MACH_O_N_STAB

#define MACH_O_N_STAB   0xe0 /* Stabs debugging symbol */

Definition at line 274 of file macho.c.

◆ MACH_O_N_TYPE

#define MACH_O_N_TYPE   0x0e /* Mask for type bits */

Definition at line 275 of file macho.c.

◆ MACH_O_N_UNDF

#define MACH_O_N_UNDF   0x00 /* Undefined symbol */

Definition at line 278 of file macho.c.

◆ MACH_O_NAMELEN

#define MACH_O_NAMELEN   (16)

Definition at line 154 of file macho.c.

◆ MACH_O_UUID_LEN

#define MACH_O_UUID_LEN   (16)

Definition at line 204 of file macho.c.

Function Documentation

◆ backtrace_initialize()

int backtrace_initialize ( struct backtrace_state state,
const char *  filename,
int  descriptor,
backtrace_error_callback  error_callback,
void *  data,
fileline fileline_fn 
)

Definition at line 1320 of file macho.c.

+ Here is the call graph for this function:

◆ macho_add()

static int macho_add ( struct backtrace_state state,
const char *  filename,
int  descriptor,
off_t  offset,
const unsigned char *  match_uuid,
struct libbacktrace_base_address  base_address,
int  skip_symtab,
backtrace_error_callback  error_callback,
void *  data,
fileline fileline_fn,
int *  found_sym 
)
static

Definition at line 982 of file macho.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ macho_add_dsym()

static int macho_add_dsym ( struct backtrace_state state,
const char *  filename,
struct libbacktrace_base_address  base_address,
const unsigned char *  uuid,
backtrace_error_callback  error_callback,
void *  data,
fileline fileline_fn 
)
static

Definition at line 864 of file macho.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ macho_add_dwarf_section()

static int macho_add_dwarf_section ( struct backtrace_state state,
int  descriptor,
const char *  sectname,
uint32_t  offset,
uint64_t  size,
backtrace_error_callback  error_callback,
void *  data,
struct dwarf_sections dwarf_sections 
)
static

Definition at line 350 of file macho.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ macho_add_dwarf_segment()

static int macho_add_dwarf_segment ( struct backtrace_state state,
int  descriptor,
off_t  offset,
unsigned int  cmd,
const char *  psecs,
size_t  sizesecs,
unsigned int  nsects,
backtrace_error_callback  error_callback,
void *  data,
struct dwarf_sections dwarf_sections 
)
static

Definition at line 383 of file macho.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ macho_add_fat()

static int macho_add_fat ( struct backtrace_state state,
const char *  filename,
int  descriptor,
int  swapped,
off_t  offset,
const unsigned char *  match_uuid,
struct libbacktrace_base_address  base_address,
int  skip_symtab,
uint32_t  nfat_arch,
int  is_64,
backtrace_error_callback  error_callback,
void *  data,
fileline fileline_fn,
int *  found_sym 
)
static

Definition at line 760 of file macho.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ macho_add_symtab()

static int macho_add_symtab ( struct backtrace_state state,
int  descriptor,
struct libbacktrace_base_address  base_address,
int  is_64,
off_t  symoff,
unsigned int  nsyms,
off_t  stroff,
unsigned int  strsize,
backtrace_error_callback  error_callback,
void *  data 
)
static

Definition at line 514 of file macho.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ macho_defined_symbol()

static int macho_defined_symbol ( uint8_t  type)
static

Definition at line 494 of file macho.c.

+ Here is the caller graph for this function:

◆ macho_nodebug()

static int macho_nodebug ( struct backtrace_state *state  ATTRIBUTE_UNUSED,
uintptr_t pc  ATTRIBUTE_UNUSED,
backtrace_full_callback callback  ATTRIBUTE_UNUSED,
backtrace_error_callback  error_callback,
void *  data 
)
static

Definition at line 325 of file macho.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ macho_nosyms()

static void macho_nosyms ( struct backtrace_state *state  ATTRIBUTE_UNUSED,
uintptr_t addr  ATTRIBUTE_UNUSED,
backtrace_syminfo_callback callback  ATTRIBUTE_UNUSED,
backtrace_error_callback  error_callback,
void *  data 
)
static

Definition at line 338 of file macho.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ macho_symbol_compare()

static int macho_symbol_compare ( const void *  v1,
const void *  v2 
)
static

Definition at line 451 of file macho.c.

+ Here is the caller graph for this function:

◆ macho_symbol_search()

static int macho_symbol_search ( const void *  vkey,
const void *  ventry 
)
static

Definition at line 469 of file macho.c.

+ Here is the caller graph for this function:

◆ macho_syminfo()

static void macho_syminfo ( struct backtrace_state state,
uintptr_t  addr,
backtrace_syminfo_callback  callback,
backtrace_error_callback error_callback  ATTRIBUTE_UNUSED,
void *  data 
)
static

Definition at line 707 of file macho.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ dwarf_section_names

const char* const dwarf_section_names[DEBUG_MAX]
static
Initial value:
=
{
"__debug_info",
"__debug_line",
"__debug_abbrev",
"__debug_ranges",
"__debug_str",
"__debug_addr",
"__debug_str_offs",
"__debug_line_str",
"__debug_rnglists"
}

Definition at line 302 of file macho.c.