The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/libkern/kxld/kxld_sym.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * Copyright (c) 2008 Apple Inc. All rights reserved.
    3  *
    4  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
    5  * 
    6  * This file contains Original Code and/or Modifications of Original Code
    7  * as defined in and that are subject to the Apple Public Source License
    8  * Version 2.0 (the 'License'). You may not use this file except in
    9  * compliance with the License. The rights granted to you under the License
   10  * may not be used to create, or enable the creation or redistribution of,
   11  * unlawful or unlicensed copies of an Apple operating system, or to
   12  * circumvent, violate, or enable the circumvention or violation of, any
   13  * terms of an Apple operating system software license agreement.
   14  * 
   15  * Please obtain a copy of the License at
   16  * http://www.opensource.apple.com/apsl/ and read it before using this file.
   17  * 
   18  * The Original Code and all software distributed under the License are
   19  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
   20  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
   21  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
   22  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
   23  * Please see the License for the specific language governing rights and
   24  * limitations under the License.
   25  * 
   26  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
   27  */
   28 #ifndef _KXLD_SYMBOL_H_
   29 #define _KXLD_SYMBOL_H_
   30 
   31 #include <mach/machine.h>
   32 #include <sys/types.h>
   33 #if KERNEL
   34     #include <libkern/kxld_types.h>
   35 #else
   36     #include "kxld_types.h"
   37 #endif
   38 
   39 struct kxld_sect;
   40 struct nlist;
   41 struct nlist_64;
   42 typedef struct kxld_sym KXLDSym;
   43 typedef boolean_t (*KXLDSymPredicateTest)(const KXLDSym *sym);
   44 
   45 struct kxld_sym {
   46     char *name;                       // The symbol's name
   47     char *alias;                      // The indirect symbol's alias name
   48     kxld_addr_t base_addr;            // The symbol's base address
   49     kxld_addr_t link_addr;            // The relocated address
   50     kxld_addr_t got_addr;             // The address of this symbol's GOT entry
   51     uint8_t type;
   52     uint8_t sectnum;                  // The symbol's section number
   53     uint8_t relocated_sectnum;
   54     uint16_t desc;
   55     struct {
   56         u_int is_absolute:1,          // Set for absolute symbols
   57         is_section:1,                 // Set for section symbols
   58         is_undefined:1,               // Set for undefined symbols
   59         is_indirect:1,                // Set for indirect symbols
   60         is_common:1,                  // Set for common symbols
   61         is_external:1,                // Set for external symbols
   62         is_stab:1,                    // Set for stab symbols
   63         is_weak:1,                    // Set for weak definition symbols
   64         is_resolved:1,                // For symbols that have been resolved
   65                                       // externally and should not be exported
   66         is_obsolete:1,                // For symbols marked as obsolete
   67         is_replaced:1,                // Set for symbols replaced by patching
   68         is_got:1,                     // Has an entry in the GOT
   69         is_cxx:1,                     // Set for C++ symbols
   70         is_pure_virtual:1,            // Set for pure virtual symbols
   71         is_class_vtable:1,            // Set for vtable symbols of classes
   72         is_meta_vtable:1,             // Set for vtable symbols of MetaClasses
   73         is_padslot:1,                 // Set for pad slot symbols
   74         is_metaclass:1,               // Set for metaclass symbols
   75         is_super_metaclass_pointer:1, // Set for super metaclass pointer syms
   76         is_thumb:1;                   // Set for thumb symbols (ARM only)
   77     } predicates;
   78 };
   79 
   80 /*******************************************************************************
   81 * Constructors and destructors
   82 *******************************************************************************/
   83 
   84 #if KXLD_USER_OR_ILP32
   85 kern_return_t kxld_sym_init_from_macho32(KXLDSym *sym, char *strtab, 
   86     const struct nlist *src) __attribute__((nonnull, visibility("hidden")));
   87 #endif
   88 
   89 #if KXLD_USER_OR_LP64
   90 kern_return_t kxld_sym_init_from_macho64(KXLDSym *sym, char *strtab, 
   91     const struct nlist_64 *src) __attribute__((nonnull, visibility("hidden")));
   92 #endif
   93 
   94 void kxld_sym_init_absolute(KXLDSym *sym, char *name, kxld_addr_t link_addr)
   95     __attribute__((nonnull, visibility("hidden")));
   96 
   97 void kxld_sym_deinit(KXLDSym *sym)
   98     __attribute__((nonnull, visibility("hidden")));
   99 
  100 void kxld_sym_destroy(KXLDSym *sym)
  101     __attribute__((nonnull, visibility("hidden")));
  102 
  103 /*******************************************************************************
  104 * Accessors
  105 *******************************************************************************/
  106 
  107 boolean_t kxld_sym_is_absolute(const KXLDSym *sym)
  108     __attribute__((pure, nonnull, visibility("hidden")));
  109 
  110 boolean_t kxld_sym_is_section(const KXLDSym *sym) 
  111     __attribute__((pure, nonnull, visibility("hidden")));
  112 
  113 boolean_t kxld_sym_is_defined(const KXLDSym *sym)
  114     __attribute__((pure, nonnull, visibility("hidden")));
  115 
  116 boolean_t kxld_sym_is_defined_locally(const KXLDSym *sym)
  117     __attribute__((pure, nonnull, visibility("hidden")));
  118 
  119 boolean_t kxld_sym_is_external(const KXLDSym *sym)
  120     __attribute__((pure, nonnull, visibility("hidden")));
  121 
  122 boolean_t kxld_sym_is_exported(const KXLDSym *sym)
  123     __attribute__((pure, nonnull, visibility("hidden")));
  124 
  125 boolean_t kxld_sym_is_undefined(const KXLDSym *sym)
  126     __attribute__((pure, nonnull, visibility("hidden")));
  127 
  128 boolean_t kxld_sym_is_indirect(const KXLDSym *sym)
  129     __attribute__((pure, nonnull, visibility("hidden")));
  130 
  131 /* We don't wrap this in KXLD_USER_OR_COMMON because even though common symbols
  132  * aren't always supported, we always need to be able to detect them.
  133  */
  134 boolean_t kxld_sym_is_common(const KXLDSym *sym)
  135     __attribute__((pure, nonnull, visibility("hidden")));
  136 
  137 boolean_t kxld_sym_is_unresolved(const KXLDSym *sym)
  138     __attribute__((pure, nonnull, visibility("hidden")));
  139 
  140 boolean_t kxld_sym_is_obsolete(const KXLDSym *sym)
  141     __attribute__((pure, nonnull, visibility("hidden")));
  142 
  143 #if KXLD_USER_OR_GOT
  144 boolean_t kxld_sym_is_got(const KXLDSym *sym)
  145     __attribute__((pure, nonnull, visibility("hidden")));
  146 #endif /* KXLD_USER_OR_GOT */
  147 
  148 boolean_t kxld_sym_is_stab(const KXLDSym *sym)
  149     __attribute__((pure, nonnull, visibility("hidden")));
  150 
  151 boolean_t kxld_sym_is_weak(const KXLDSym *sym)
  152     __attribute__((pure, nonnull, visibility("hidden")));
  153 
  154 boolean_t kxld_sym_is_cxx(const KXLDSym *sym)
  155     __attribute__((pure, nonnull, visibility("hidden")));
  156 
  157 boolean_t kxld_sym_is_pure_virtual(const KXLDSym *sym)
  158     __attribute__((pure, nonnull, visibility("hidden")));
  159 
  160 boolean_t kxld_sym_is_vtable(const KXLDSym *sym)
  161     __attribute__((pure, nonnull, visibility("hidden")));
  162 
  163 boolean_t kxld_sym_is_class_vtable(const KXLDSym *sym)
  164     __attribute__((pure, nonnull, visibility("hidden")));
  165 
  166 boolean_t kxld_sym_is_metaclass_vtable(const KXLDSym *sym)
  167     __attribute__((pure, nonnull, visibility("hidden")));
  168 
  169 boolean_t kxld_sym_is_padslot(const KXLDSym *sym)
  170     __attribute__((pure, nonnull, visibility("hidden")));
  171 
  172 boolean_t kxld_sym_is_metaclass(const KXLDSym *sym)
  173     __attribute__((pure, nonnull, visibility("hidden")));
  174 
  175 boolean_t kxld_sym_is_super_metaclass_pointer(const KXLDSym *sym)
  176     __attribute__((pure, nonnull, visibility("hidden")));
  177 
  178 boolean_t kxld_sym_name_is_padslot(const char *name)
  179     __attribute__((pure, nonnull, visibility("hidden")));
  180 
  181 u_int kxld_sym_get_section_offset(const KXLDSym *sym, 
  182     const struct kxld_sect *sect)
  183     __attribute__((pure, nonnull, visibility("hidden")));
  184 
  185 #if KXLD_USER_OR_COMMON
  186 kxld_size_t kxld_sym_get_common_size(const KXLDSym *sym)
  187     __attribute__((pure, nonnull, visibility("hidden")));
  188 
  189 u_int kxld_sym_get_common_align(const KXLDSym *sym)
  190     __attribute__((pure, nonnull, visibility("hidden")));
  191 #endif /* KXLD_USER_OR_COMMON */
  192 
  193 kern_return_t kxld_sym_get_class_name_from_metaclass(const KXLDSym *sym,
  194     char class_name[], u_long class_name_len)
  195     __attribute__((nonnull, visibility("hidden")));
  196 
  197 kern_return_t kxld_sym_get_class_name_from_super_metaclass_pointer(
  198     const KXLDSym *sym, char class_name[], u_long class_name_len)
  199     __attribute__((nonnull, visibility("hidden")));
  200 
  201 kern_return_t kxld_sym_get_class_name_from_vtable(const KXLDSym *sym,
  202     char class_name[], u_long class_name_len)
  203     __attribute__((nonnull, visibility("hidden")));
  204 
  205 kern_return_t kxld_sym_get_class_name_from_vtable_name(const char *vtable_name,
  206     char class_name[], u_long class_name_len)
  207     __attribute__((nonnull, visibility("hidden")));
  208 
  209 kern_return_t kxld_sym_get_vtable_name_from_class_name(const char *class_name, 
  210     char vtable_name[], u_long vtable_name_len)
  211     __attribute__((nonnull, visibility("hidden")));
  212 
  213 kern_return_t kxld_sym_get_meta_vtable_name_from_class_name(const char *class_name, 
  214     char meta_vtable_name[], u_long meta_vtable_name_len)
  215     __attribute__((nonnull, visibility("hidden")));
  216 
  217 kern_return_t kxld_sym_get_final_sym_name_from_class_name(const char *class_name, 
  218     char final_sym_name[], u_long final_sym_name_len)
  219     __attribute__((nonnull, visibility("hidden")));
  220 
  221 u_long kxld_sym_get_function_prefix_from_class_name(const char *class_name,
  222     char function_prefix[], u_long function_prefix_len)
  223     __attribute__((nonnull, visibility("hidden")));
  224 
  225 #if KXLD_USER_OR_ILP32
  226 kern_return_t kxld_sym_export_macho_32(const KXLDSym *sym, u_char *nl, 
  227     char *strtab, u_long *stroff, u_long strsize, boolean_t is_link_state)
  228     __attribute__((nonnull, visibility("hidden")));
  229 #endif
  230 
  231 #if KXLD_USER_OR_LP64
  232 kern_return_t kxld_sym_export_macho_64(const KXLDSym *sym, u_char *nl, 
  233     char *strtab, u_long *stroff, u_long strsize, boolean_t is_link_state)
  234     __attribute__((nonnull, visibility("hidden")));
  235 #endif
  236 
  237 /*******************************************************************************
  238 * Mutators
  239 *******************************************************************************/
  240 
  241 void kxld_sym_relocate(KXLDSym *sym, const struct kxld_sect *sect)
  242     __attribute__((nonnull, visibility("hidden")));
  243 
  244 #if KXLD_USER_OR_GOT
  245 void kxld_sym_set_got(KXLDSym *sym)
  246     __attribute__((nonnull, visibility("hidden")));
  247 #endif /* KXLD_USER_OR_GOT */
  248 
  249 kern_return_t kxld_sym_resolve(KXLDSym *sym, const kxld_addr_t addr,
  250     boolean_t export_sym)
  251     __attribute__((nonnull, visibility("hidden")));
  252 
  253 #if KXLD_USER_OR_COMMON
  254 kern_return_t kxld_sym_resolve_common(KXLDSym *sym, u_int sectnum, 
  255     kxld_addr_t base_addr)
  256     __attribute__((nonnull, visibility("hidden")));
  257 #endif /* KXLD_USER_OR_COMMON */
  258 
  259 void kxld_sym_delete(KXLDSym *sym)
  260     __attribute__((nonnull, visibility("hidden")));
  261     
  262 void kxld_sym_patch(KXLDSym *sym)
  263     __attribute__((nonnull, visibility("hidden")));
  264 
  265 void kxld_sym_mark_private(KXLDSym *sym)
  266     __attribute__((nonnull, visibility("hidden")));
  267 
  268 #endif /* _KXLD_SYMBOL_H_ */
  269 

Cache object: 7f21af1c98913f2ce60822bf7e0bc007


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.