blob: 30c234dc8cf1e6e58beb8fe4388e17cf668cbece [file] [log] [blame]
Loganaae8f2c2010-11-26 23:28:37 +08001/*
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 Liaobe65a482010-12-21 14:18:44 -080025#define OBCC_MAGIC_VERS "002\0"
Loganaae8f2c2010-11-26 23:28:37 +080026
27/* BCC Cache Header Structure */
28struct oBCCHeader {
29 uint8_t magic[4]; /* includes version number */
30 uint8_t magicVersion[4];
31
Loganb9b04162010-12-20 16:36:57 +080032 long sourceWhen;
33 long sourceCRC32;
34
Loganaae8f2c2010-11-26 23:28:37 +080035 uint32_t rslibWhen;
36 uint32_t libRSWhen;
37 uint32_t libbccWhen;
38
Logan8b77a772010-12-21 09:11:01 +080039 unsigned char sourceSHA1[20];
40
Loganaae8f2c2010-11-26 23:28:37 +080041 uint32_t cachedCodeDataAddr;
42 uint32_t rootAddr;
43 uint32_t initAddr;
44
Loganb9b04162010-12-20 16:36:57 +080045 uint32_t libRSThreadable; /* TODO: This is an hack. Should be fixed
46 in the long term. */
47
Loganaae8f2c2010-11-26 23:28:37 +080048 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;
Logan7cc1baf2010-11-28 23:46:11 +080056 uint32_t exportPragmasSize; /* size of export pragma table (in bytes) */
Loganaae8f2c2010-11-26 23:28:37 +080057
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 */
69struct 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
Logan7cc1baf2010-11-28 23:46:11 +080082/* BCC Cache Pragma Entry */
83struct oBCCPragmaEntry {
84 uint32_t pragmaNameOffset;
85 uint32_t pragmaNameSize;
86 uint32_t pragmaValueOffset;
87 uint32_t pragmaValueSize;
88};
89
90
Loganaae8f2c2010-11-26 23:28:37 +080091/* 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 */