Home | History | Annotate | Download | only in bcc
      1 /*
      2  * Copyright 2010-2012, The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *     http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #ifndef BCC_MCCACHE_H
     18 #define BCC_MCCACHE_H
     19 
     20 #include <stdint.h>
     21 #include <sys/types.h>
     22 
     23 /* BCC Cache File Magic Word */
     24 #define MCO_MAGIC "\0bcc"
     25 
     26 /* BCC Cache File Version, encoded in 4 bytes of ASCII */
     27 #define MCO_VERSION "001\0"
     28 
     29 /* BCC Cache Header Structure */
     30 struct MCO_Header {
     31   /* magic and version */
     32   uint8_t magic[4];
     33   uint8_t version[4];
     34 
     35   /* machine-dependent integer type size */
     36   uint8_t endianness;
     37   uint8_t sizeof_off_t;
     38   uint8_t sizeof_size_t;
     39   uint8_t sizeof_ptr_t;
     40 
     41   /* string pool section */
     42   off_t str_pool_offset;
     43   size_t str_pool_size;
     44 
     45   /* dependancy table */
     46   off_t depend_tab_offset;
     47   size_t depend_tab_size;
     48 
     49   /* relocation table section */
     50   off_t reloc_tab_offset;
     51   size_t reloc_tab_size;
     52 
     53   /* pragma list section */
     54   off_t pragma_list_offset;
     55   size_t pragma_list_size;
     56 
     57   /* function table */
     58   off_t func_table_offset;
     59   size_t func_table_size;
     60 
     61   /* function table */
     62   off_t object_slot_list_offset;
     63   size_t object_slot_list_size;
     64 
     65   /* export variable name list section */
     66   off_t export_var_name_list_offset;
     67   size_t export_var_name_list_size;
     68 
     69   /* export function name list section */
     70   off_t export_func_name_list_offset;
     71   size_t export_func_name_list_size;
     72 
     73   /* dirty hack for libRS */
     74   /* TODO: This should be removed in the future */
     75   uint32_t libRS_threadable;
     76 
     77   /* export foreach list section */
     78   off_t export_foreach_name_list_offset;
     79   size_t export_foreach_name_list_size;
     80 };
     81 
     82 struct MCO_String {
     83   size_t length; /* String length, without ending '\0' */
     84   off_t offset; /* Note: Offset related to string_pool_offset. */
     85 };
     86 
     87 struct MCO_StringPool {
     88   size_t count;
     89   struct MCO_String list[];
     90 };
     91 
     92 enum MCO_ResourceType {
     93   BCC_APK_RESOURCE = 0,
     94   BCC_FILE_RESOURCE = 1,
     95 };
     96 
     97 struct MCO_Dependency {
     98   size_t res_name_strp_index;
     99   uint32_t res_type; /* BCC_APK_RESOURCE or BCC_FILE_RESOURCE */
    100   unsigned char sha1[20];
    101 };
    102 
    103 struct MCO_DependencyTable {
    104   size_t count;
    105   struct MCO_Dependency table[];
    106 };
    107 
    108 struct MCO_ExportVarList {
    109   size_t count;
    110   void *cached_addr_list[];
    111 };
    112 
    113 struct MCO_ExportFuncList {
    114   size_t count;
    115   void *cached_addr_list[];
    116 };
    117 
    118 struct MCO_ExportForEachList {
    119   size_t count;
    120   void *cached_addr_list[];
    121 };
    122 
    123 struct MCO_Pragma {
    124   size_t key_strp_index;
    125   size_t value_strp_index;
    126 };
    127 
    128 struct MCO_PragmaList {
    129   size_t count;
    130   struct MCO_Pragma list[];
    131 };
    132 
    133 struct MCO_ObjectSlotList {
    134   size_t count;
    135   uint32_t object_slot_list[];
    136 };
    137 
    138 struct MCO_FuncInfo {
    139   size_t name_strp_index;
    140   void *cached_addr;
    141   size_t size;
    142 };
    143 
    144 struct MCO_FuncTable {
    145   size_t count;
    146   struct MCO_FuncInfo table[];
    147 };
    148 
    149 struct MCO_String_Ptr {
    150   size_t count;
    151   size_t strp_indexs[];
    152 };
    153 
    154 
    155 #endif /* BCC_MCCACHE_H */
    156