Home | History | Annotate | Download | only in bcc
      1 /*
      2  * Copyright 2010, 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_CACHE_H
     18 #define BCC_CACHE_H
     19 
     20 #include <stdint.h>
     21 #include <sys/types.h>
     22 
     23 /* BCC Cache File Magic Word */
     24 #define OBCC_MAGIC "\0bcc"
     25 
     26 /* BCC Cache File Version, encoded in 4 bytes of ASCII */
     27 #define OBCC_VERSION "001\0"
     28 
     29 /* BCC Cache Header Structure */
     30 struct OBCC_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   /* export variable list section */
     54   off_t export_var_list_offset;
     55   size_t export_var_list_size;
     56 
     57   /* export function list section */
     58   off_t export_func_list_offset;
     59   size_t export_func_list_size;
     60 
     61   /* pragma list section */
     62   off_t pragma_list_offset;
     63   size_t pragma_list_size;
     64 
     65   /* function table */
     66   off_t func_table_offset;
     67   size_t func_table_size;
     68 
     69   /* function table */
     70   off_t object_slot_list_offset;
     71   size_t object_slot_list_size;
     72 
     73   /* context section */
     74   char *context_cached_addr;
     75   uint32_t context_parity_checksum;
     76 
     77   /* dirty hack for libRS */
     78   /* TODO: This should be removed in the future */
     79   uint32_t libRS_threadable;
     80 };
     81 
     82 struct OBCC_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 OBCC_StringPool {
     88   size_t count;
     89   struct OBCC_String list[];
     90 };
     91 
     92 enum OBCC_ResourceType {
     93   BCC_APK_RESOURCE = 0,
     94   BCC_FILE_RESOURCE = 1,
     95 };
     96 
     97 struct OBCC_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 OBCC_DependencyTable {
    104   size_t count;
    105   struct OBCC_Dependency table[];
    106 };
    107 
    108 struct OBCC_RelocationTable {
    109 /* TODO: Implement relocation table. */
    110 };
    111 
    112 struct OBCC_ExportVarList {
    113   size_t count;
    114   void *cached_addr_list[];
    115 };
    116 
    117 struct OBCC_ExportFuncList {
    118   size_t count;
    119   void *cached_addr_list[];
    120 };
    121 
    122 struct OBCC_Pragma {
    123   size_t key_strp_index;
    124   size_t value_strp_index;
    125 };
    126 
    127 struct OBCC_PragmaList {
    128   size_t count;
    129   struct OBCC_Pragma list[];
    130 };
    131 
    132 struct OBCC_ObjectSlotList {
    133   size_t count;
    134   uint32_t object_slot_list[];
    135 };
    136 
    137 struct OBCC_FuncInfo {
    138   size_t name_strp_index;
    139   void *cached_addr;
    140   size_t size;
    141 };
    142 
    143 struct OBCC_FuncTable {
    144   size_t count;
    145   struct OBCC_FuncInfo table[];
    146 };
    147 
    148 struct OBCC_String_Ptr {
    149   size_t count;
    150   size_t strp_indexs[];
    151 };
    152 
    153 
    154 #endif /* BCC_CACHE_H */
    155