Symbian platform (C++)
SDK native APIs, runtime and tooling
Loading...
Searching...
No Matches
e32.h
Go to the documentation of this file.
1#ifndef SYMBIAN_E32_E32_H_
2#define SYMBIAN_E32_E32_H_
3
4#include <cstdint>
5#include <string>
6#include <string_view>
7#include <vector>
8
9#include <absl/status/statusor.h>
10
11namespace symbian::e32 {
12
13struct ImportSlot {
14 uint32_t code_offset = 0;
15 uint32_t ordinal = 0;
16};
17
19 std::string dll;
20 std::vector<ImportSlot> slots;
21};
22
23struct ExportSlot {
24 uint32_t ordinal = 0;
25 uint32_t address = 0;
26 bool absent = false;
27};
28
29// Metadata for the narrow, uncompressed experimental profiles.
30// Successful inspection does not prove acceptance by a device loader.
31struct ImageInfo {
32 std::string kernel = "eka2";
33 uint32_t uid3 = 0;
34 uint32_t header_crc = 0;
35 uint32_t flags = 0;
36 std::string architecture;
37 uint32_t code_size = 0;
38 uint32_t code_base = 0;
39 uint32_t data_size = 0;
40 uint32_t bss_size = 0;
41 uint32_t data_base = 0;
42 uint32_t entry_offset = 0;
43 uint32_t secure_id = 0;
44 uint32_t capabilities = 0;
45 bool dll = false;
46 uint32_t header_size = 0;
47 // Code-relative offset of the verified Symbian EHABI descriptor, or zero.
49 std::vector<ImportBlock> imports;
50 std::vector<ExportSlot> exports;
51 std::vector<uint32_t> code_relocations;
52 std::vector<uint32_t> code_data_relocations;
53 std::vector<uint32_t> data_relocations;
54 std::vector<uint32_t> data_data_relocations;
55};
56
57// Accepts ARM EABI5 ET_EXEC linked with --emit-relocs: one RX PT_LOAD,
58// one optional bounded RW mapping with initialized data and zero-filled BSS,
59// internal relative references and resolved ABS32 pointers into code/data,
60// EKA2 ARM entry, no imports/exports/TLS. Bounded constructor arrays require
61// an SDK startup that calls the guest runtime after thread-heap setup.
62// Named .data.rel.ro tables are placed in the read-only code mapping.
63// One .got table (at most 1024 words) supports retained R_ARM_GOT_PREL to
64// defined code/constant/data/BSS symbols. Every slot matches a referenced symbol;
65// slot addresses receive typed text/data fixups, preserving Thumb state.
66// Code and data mappings relocate independently. Direct PC-relative references
67// across them are rejected. Writable EXE storage is capped at 1 MiB.
68// Input must come from a trusted link retaining ALL relocations. This cannot
69// detect stripped relocations or absolute addresses hand-written in code.
70// UID3 must be in the experimental unprotected 0xe0000000..0xefffffff range.
71absl::StatusOr<std::string> ConvertPicExecutable(std::string_view elf,
72 uint32_t uid3,
73 uint32_t capabilities = 0);
74
75// Opt-in EKA1 no-UI process profile: ARMv5T EABI input, an ARM callable
76// entry that returns an integer, one read-only PIC mapping, no writable
77// data/BSS, pointer fixups, lifecycle or unwinding. Optional proxies enable
78// one EUSER DLL with a final contiguous PE IAT, not EKA2 ELF imports.
79// The legacy E32 header has no security/CRC fields. EABI input does not
80// establish compatibility with the general EKA1 C++ ABI.
81// Execution currently depends on EKA2L1's existing EKA1 bootstrap.
82absl::StatusOr<std::string> ConvertEka1Executable(
83 std::string_view elf, uint32_t uid3,
84 const std::vector<std::string>& proxies = {});
85
86// Eager function imports from validated ordinal proxies, retained call relocs,
87// one RX load containing GOT/PLT and dynamic metadata; optional bounded RW
88// data/BSS as above. Bounded constructor arrays require the SDK startup;
89// TLS and general DLL unload/lifetime are not established by conversion.
90// Link with --emit-relocs and the import layout; all imports have zero addends.
91absl::StatusOr<std::string> ConvertImportedExecutable(
92 std::string_view elf, const std::vector<std::string>& proxies,
93 uint32_t uid3, uint32_t capabilities = 0);
94
95// Frozen function exports from a trusted retained-relocation EKA2 PIC image.
96// Emits count word, complete ordinal table, absence bitmap and code relocations
97// for every slot.
98// Optional eager function imports use the same profile as the executable path.
99absl::StatusOr<std::string> ConvertDll(std::string_view elf,
100 std::string_view definition,
101 const std::vector<std::string>& proxies,
102 uint32_t uid3,
103 uint32_t capabilities = 0);
104
105// Checks bounds, UID checksum, header CRC and this supported profile only.
106// Other E32 profiles return Unimplemented, not a general validity verdict.
107absl::StatusOr<ImageInfo> InspectImage(std::string_view bytes);
108
109} // namespace symbian::e32
110
111#endif // SYMBIAN_E32_E32_H_
Definition e32.cc:21
absl::StatusOr< std::string > ConvertPicExecutable(std::string_view elf, uint32_t uid3, uint32_t capabilities)
Definition e32.cc:981
absl::StatusOr< std::string > ConvertDll(std::string_view elf, std::string_view definition, const std::vector< std::string > &proxies, uint32_t uid3, uint32_t capabilities)
Definition e32.cc:1092
absl::StatusOr< std::string > ConvertImportedExecutable(std::string_view elf, const std::vector< std::string > &proxies, uint32_t uid3, uint32_t capabilities)
Definition e32.cc:1086
absl::StatusOr< std::string > ConvertEka1Executable(std::string_view elf, uint32_t uid3, const std::vector< std::string > &proxies)
Definition e32.cc:987
absl::StatusOr< ImageInfo > InspectImage(std::string_view bytes)
Definition e32.cc:1100
std::string_view bytes
Definition exports.cc:74
Definition e32.h:23
uint32_t ordinal
Definition e32.h:24
uint32_t address
Definition e32.h:25
bool absent
Definition e32.h:26
Definition e32.h:31
uint32_t code_size
Definition e32.h:37
uint32_t data_base
Definition e32.h:41
uint32_t header_crc
Definition e32.h:34
uint32_t secure_id
Definition e32.h:43
uint32_t flags
Definition e32.h:35
std::string architecture
Definition e32.h:36
std::vector< uint32_t > code_relocations
Definition e32.h:51
uint32_t code_base
Definition e32.h:38
uint32_t exception_descriptor_offset
Definition e32.h:48
std::vector< ExportSlot > exports
Definition e32.h:50
uint32_t data_size
Definition e32.h:39
uint32_t bss_size
Definition e32.h:40
std::vector< uint32_t > code_data_relocations
Definition e32.h:52
uint32_t capabilities
Definition e32.h:44
std::vector< ImportBlock > imports
Definition e32.h:49
uint32_t entry_offset
Definition e32.h:42
bool dll
Definition e32.h:45
uint32_t header_size
Definition e32.h:46
std::vector< uint32_t > data_data_relocations
Definition e32.h:54
uint32_t uid3
Definition e32.h:33
std::string kernel
Definition e32.h:32
std::vector< uint32_t > data_relocations
Definition e32.h:53
Definition e32.h:18
std::string dll
Definition e32.h:19
std::vector< ImportSlot > slots
Definition e32.h:20
Definition e32.h:13
uint32_t ordinal
Definition e32.h:15
uint32_t code_offset
Definition e32.h:14