-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathVpuImage.h
50 lines (39 loc) · 992 Bytes
/
VpuImage.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#pragma once
#include "Vpu.h"
#include <vector>
#include <assert.h>
#include <sstream>
struct VpuImageHeader
{
uint64_t m_codeSize;
uint64_t m_entryOffset;
uint64_t m_tlsSize;
uint16_t m_relocationCount;
uint64_t GetSerializationSize(void)
{
return sizeof(VpuImageHeader) + (m_relocationCount * sizeof(VpuRelocation)) + m_codeSize;
}
uint64_t GetTlsOffset(void)
{
return AlignUp(m_codeSize, kVpuImageCodeAlignment);
}
uint64_t GetImageSize()
{
return AlignUp(m_codeSize, kVpuImageCodeAlignment) +
AlignUp(m_tlsSize, kVpuImagekDataAlignment);
}
uint64_t GetEntryOffset()
{
return m_entryOffset;
}
bool Load(uint8_t * base, uint64_t size);
bool ApplyRelocation(uint8_t * base, VpuRelocation * reolocation);
private:
static const uint32_t kVpuImageCodeAlignment = 4096;
static const uint32_t kVpuImagekDataAlignment = 4096;
uint64_t AlignUp(uint64_t value, uint64_t alignment)
{
uint64_t mask = alignment - 1;
return (value + mask) & ~mask;
}
};