Logan | aae8f2c | 2010-11-26 23:28:37 +0800 | [diff] [blame] | 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 | |
| 21 | /* BCC Cache File Magic Word */ |
| 22 | #define OBCC_MAGIC "bcc\n" |
| 23 | |
| 24 | /* BCC Cache File Version, encoded in 4 bytes of ASCII */ |
Shih-wei Liao | be65a48 | 2010-12-21 14:18:44 -0800 | [diff] [blame] | 25 | #define OBCC_MAGIC_VERS "002\0" |
Logan | aae8f2c | 2010-11-26 23:28:37 +0800 | [diff] [blame] | 26 | |
| 27 | /* BCC Cache Header Structure */ |
| 28 | struct oBCCHeader { |
| 29 | uint8_t magic[4]; /* includes version number */ |
| 30 | uint8_t magicVersion[4]; |
| 31 | |
Logan | b9b0416 | 2010-12-20 16:36:57 +0800 | [diff] [blame] | 32 | long sourceWhen; |
| 33 | long sourceCRC32; |
| 34 | |
Logan | aae8f2c | 2010-11-26 23:28:37 +0800 | [diff] [blame] | 35 | uint32_t rslibWhen; |
| 36 | uint32_t libRSWhen; |
| 37 | uint32_t libbccWhen; |
| 38 | |
Logan | 8b77a77 | 2010-12-21 09:11:01 +0800 | [diff] [blame] | 39 | unsigned char sourceSHA1[20]; |
| 40 | |
Logan | aae8f2c | 2010-11-26 23:28:37 +0800 | [diff] [blame] | 41 | uint32_t cachedCodeDataAddr; |
| 42 | uint32_t rootAddr; |
| 43 | uint32_t initAddr; |
| 44 | |
Logan | b9b0416 | 2010-12-20 16:36:57 +0800 | [diff] [blame] | 45 | uint32_t libRSThreadable; /* TODO: This is an hack. Should be fixed |
| 46 | in the long term. */ |
| 47 | |
Logan | aae8f2c | 2010-11-26 23:28:37 +0800 | [diff] [blame] | 48 | uint32_t relocOffset; /* offset of reloc table. */ |
| 49 | uint32_t relocCount; |
| 50 | uint32_t exportVarsOffset; /* offset of export var table */ |
| 51 | uint32_t exportVarsCount; |
| 52 | uint32_t exportFuncsOffset; /* offset of export func table */ |
| 53 | uint32_t exportFuncsCount; |
| 54 | uint32_t exportPragmasOffset; /* offset of export pragma table */ |
| 55 | uint32_t exportPragmasCount; |
Logan | 7cc1baf | 2010-11-28 23:46:11 +0800 | [diff] [blame] | 56 | uint32_t exportPragmasSize; /* size of export pragma table (in bytes) */ |
Logan | aae8f2c | 2010-11-26 23:28:37 +0800 | [diff] [blame] | 57 | |
| 58 | uint32_t codeOffset; /* offset of code: 64-bit alignment */ |
| 59 | uint32_t codeSize; |
| 60 | uint32_t dataOffset; /* offset of data section */ |
| 61 | uint32_t dataSize; |
| 62 | |
| 63 | /* uint32_t flags; */ /* some info flags */ |
| 64 | uint32_t checksum; /* adler32 checksum covering deps/opt */ |
| 65 | }; |
| 66 | |
| 67 | |
| 68 | /* BCC Cache Relocation Entry */ |
| 69 | struct oBCCRelocEntry { |
| 70 | uint32_t relocType; /* target instruction relocation type */ |
| 71 | uint32_t relocOffset; /* offset of hole (holeAddr - codeAddr) */ |
| 72 | uint32_t cachedResultAddr; /* address resolved at compile time */ |
| 73 | |
| 74 | oBCCRelocEntry(uint32_t ty, uintptr_t off, void *addr) |
| 75 | : relocType(ty), |
| 76 | relocOffset(static_cast<uint32_t>(off)), |
| 77 | cachedResultAddr(reinterpret_cast<uint32_t>(addr)) { |
| 78 | } |
| 79 | }; |
| 80 | |
| 81 | |
Logan | 7cc1baf | 2010-11-28 23:46:11 +0800 | [diff] [blame] | 82 | /* BCC Cache Pragma Entry */ |
| 83 | struct oBCCPragmaEntry { |
| 84 | uint32_t pragmaNameOffset; |
| 85 | uint32_t pragmaNameSize; |
| 86 | uint32_t pragmaValueOffset; |
| 87 | uint32_t pragmaValueSize; |
| 88 | }; |
| 89 | |
| 90 | |
Logan | aae8f2c | 2010-11-26 23:28:37 +0800 | [diff] [blame] | 91 | /* BCC Cache Header Offset Table */ |
| 92 | /* TODO(logan): Deprecated. Will remove this. */ |
| 93 | #define k_magic offsetof(oBCCHeader, magic) |
| 94 | #define k_magicVersion offsetof(oBCCHeader, magicVersion) |
| 95 | #define k_sourceWhen offsetof(oBCCHeader, sourceWhen) |
| 96 | #define k_rslibWhen offsetof(oBCCHeader, rslibWhen) |
| 97 | #define k_libRSWhen offsetof(oBCCHeader, libRSWhen) |
| 98 | #define k_libbccWhen offsetof(oBCCHeader, libbccWhen) |
| 99 | #define k_cachedCodeDataAddr offsetof(oBCCHeader, cachedCodeDataAddr) |
| 100 | #define k_rootAddr offsetof(oBCCHeader, rootAddr) |
| 101 | #define k_initAddr offsetof(oBCCHeader, initAddr) |
| 102 | #define k_relocOffset offsetof(oBCCHeader, relocOffset) |
| 103 | #define k_relocCount offsetof(oBCCHeader, relocCount) |
| 104 | #define k_exportVarsOffset offsetof(oBCCHeader, exportVarsOffset) |
| 105 | #define k_exportVarsCount offsetof(oBCCHeader, exportVarsCount) |
| 106 | #define k_exportFuncsOffset offsetof(oBCCHeader, exportFuncsOffset) |
| 107 | #define k_exportFuncsCount offsetof(oBCCHeader, exportFuncsCount) |
| 108 | #define k_exportPragmasOffset offsetof(oBCCHeader, exportPragmasOffset) |
| 109 | #define k_exportPragmasCount offsetof(oBCCHeader, exportPragmasCount) |
| 110 | #define k_codeOffset offsetof(oBCCHeader, codeOffset) |
| 111 | #define k_codeSize offsetof(oBCCHeader, codeSize) |
| 112 | #define k_dataOffset offsetof(oBCCHeader, dataOffset) |
| 113 | #define k_dataSize offsetof(oBCCHeader, dataSize) |
| 114 | #define k_checksum offsetof(oBCCHeader, checksum) |
| 115 | |
| 116 | |
| 117 | #endif /* BCC_CACHE_H */ |