Skip to content

Commit 549a0ef

Browse files
committed
Merge branch 'junghee/reorg-relocations-dl' into 'main'
Factor out elf_relocation_size per ISA See merge request rewriting/ddisasm!1247
2 parents 889bf59 + 8e55c51 commit 549a0ef

8 files changed

Lines changed: 564 additions & 385 deletions

File tree

src/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ set(DATALOG_BASE_SOURCES
137137
datalog/arch/arch.dl
138138
datalog/binary/elf/elf_binaries.dl
139139
datalog/binary/elf/exceptions.dl
140-
datalog/binary/elf/relocations.dl
141140
datalog/binary/elf/symbolization.dl
142141
datalog/binary/elf/tls.dl
143142
datalog/binary/pe/pe_binaries.dl
@@ -308,6 +307,7 @@ if(DDISASM_ARM_32)
308307
datalog/arch/arm32/jump_operations.dl
309308
datalog/arch/arm32/registers.dl
310309
datalog/arch/arm32/memory_access.dl
310+
datalog/arch/arm32/elf_relocations.dl
311311
datalog/arch/arm_binaries.dl
312312
datalog/arch/arm32_binaries.dl
313313
datalog/arch/arm32_code_inference.dl
@@ -335,6 +335,7 @@ if(DDISASM_ARM_64)
335335
datalog/arch/arm64/jump_operations.dl
336336
datalog/arch/arm64/registers.dl
337337
datalog/arch/arm64/memory_access.dl
338+
datalog/arch/arm64/elf_relocations.dl
338339
datalog/arch/arm_binaries.dl
339340
datalog/arch/arm64_symbolization.dl)
340341

@@ -358,6 +359,7 @@ if(DDISASM_MIPS_32)
358359
datalog/arch/mips32/jump_operations.dl
359360
datalog/arch/mips32/memory_access.dl
360361
datalog/arch/mips32/registers.dl
362+
datalog/arch/mips32/elf_relocations.dl
361363
datalog/arch/mips_symbolization.dl)
362364

363365
generate_arch_static_lib(
@@ -382,6 +384,7 @@ if(DDISASM_X86_32)
382384
datalog/arch/intel/registers_x86_32.dl
383385
datalog/arch/intel/arch_x86.dl
384386
datalog/arch/intel/memory_access.dl
387+
datalog/arch/intel/elf_relocations_x86_32.dl
385388
datalog/arch/x86_32_symbolization.dl)
386389

387390
generate_arch_static_lib(
@@ -406,6 +409,7 @@ if(DDISASM_X86_64)
406409
datalog/arch/intel/registers_x86_64.dl
407410
datalog/arch/intel/arch_x86.dl
408411
datalog/arch/intel/memory_access.dl
412+
datalog/arch/intel/elf_relocations_x86_64.dl
409413
datalog/arch/x86_64_symbolization.dl)
410414

411415
generate_arch_static_lib(
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
//===- relocations.dl ---------------------------------------*- datalog -*-===//
2+
//
3+
// Copyright (C) 2019-2022 GrammaTech, Inc.
4+
//
5+
// This code is licensed under the GNU Affero General Public License
6+
// as published by the Free Software Foundation, either version 3 of
7+
// the License, or (at your option) any later version. See the
8+
// LICENSE.txt file in the project root for license terms or visit
9+
// https://www.gnu.org/licenses/agpl.txt.
10+
//
11+
// This program is distributed in the hope that it will be useful,
12+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
// GNU Affero General Public License for more details.
15+
//
16+
// This project is sponsored by the Office of Naval Research, One Liberty
17+
// Center, 875 N. Randolph Street, Arlington, VA 22203 under contract #
18+
// N68335-17-C-0700. The content of the information does not necessarily
19+
// reflect the position or policy of the Government and no official
20+
// endorsement should be inferred.
21+
//
22+
//===----------------------------------------------------------------------===//
23+
24+
/**
25+
Table maps ARM32 ELF relocation types to a size in bits.
26+
*/
27+
28+
elf_relocation_size("ARM", "NONE", 0).
29+
elf_relocation_size("ARM", "PC24", 24).
30+
elf_relocation_size("ARM", "ABS32", 32).
31+
elf_relocation_size("ARM", "REL32", 32).
32+
elf_relocation_size("ARM", "LDR_PC_G0", 32).
33+
elf_relocation_size("ARM", "ABS16", 16).
34+
elf_relocation_size("ARM", "ABS12", 12).
35+
elf_relocation_size("ARM", "THM_ABS5", 5).
36+
elf_relocation_size("ARM", "ABS8", 8).
37+
elf_relocation_size("ARM", "SBREL32", 32).
38+
elf_relocation_size("ARM", "THM_CALL", 25).
39+
elf_relocation_size("ARM", "THM_PC8", 8).
40+
elf_relocation_size("ARM", "BREL_ADJ", 32).
41+
elf_relocation_size("ARM", "TLS_DESC", 0).
42+
elf_relocation_size("ARM", "THM_SWI8", 0).
43+
elf_relocation_size("ARM", "XPC25", 25).
44+
elf_relocation_size("ARM", "THM_XPC22", 22).
45+
elf_relocation_size("ARM", "TLS_DTPMOD32", 32).
46+
elf_relocation_size("ARM", "TLS_DTPOFF32", 32).
47+
elf_relocation_size("ARM", "TLS_TPOFF32", 32).
48+
elf_relocation_size("ARM", "COPY", 32).
49+
elf_relocation_size("ARM", "GLOB_DAT", 32).
50+
elf_relocation_size("ARM", "JUMP_SLOT", 32).
51+
elf_relocation_size("ARM", "RELATIVE", 32).
52+
elf_relocation_size("ARM", "GOTOFF32", 32).
53+
elf_relocation_size("ARM", "BASE_PREL", 32).
54+
elf_relocation_size("ARM", "GOT_BREL", 32).
55+
elf_relocation_size("ARM", "PLT32", 24).
56+
elf_relocation_size("ARM", "CALL", 24).
57+
elf_relocation_size("ARM", "JUMP24", 24).
58+
elf_relocation_size("ARM", "THM_JUMP24", 24).
59+
elf_relocation_size("ARM", "BASE_ABS", 21).
60+
elf_relocation_size("ARM", "ALU_PCREL_7_0", 12).
61+
elf_relocation_size("ARM", "ALU_PCREL_15_8", 12).
62+
elf_relocation_size("ARM", "ALU_PCREL_23_15", 12).
63+
elf_relocation_size("ARM", "LDR_SBREL_11_0_NC", 12).
64+
elf_relocation_size("ARM", "ALU_SBREL_19_12_NC", 8).
65+
elf_relocation_size("ARM", "ALU_SBREL_27_20_CK", 8).
66+
elf_relocation_size("ARM", "TARGET1", 32).
67+
elf_relocation_size("ARM", "SBREL31", 32).
68+
elf_relocation_size("ARM", "V4BX", 32).
69+
elf_relocation_size("ARM", "TARGET2", 32).
70+
elf_relocation_size("ARM", "PREL31", 31).
71+
elf_relocation_size("ARM", "MOVW_ABS_NC", 16).
72+
elf_relocation_size("ARM", "MOVT_ABS", 16).
73+
elf_relocation_size("ARM", "MOVW_PREL_NC", 16).
74+
elf_relocation_size("ARM", "MOVT_PREL", 16).
75+
elf_relocation_size("ARM", "THM_MOVW_ABS_NC", 16).
76+
elf_relocation_size("ARM", "THM_MOVT_ABS", 16).
77+
elf_relocation_size("ARM", "THM_MOVW_PREL_NC", 16).
78+
elf_relocation_size("ARM", "THM_MOVT_PREL", 16).
79+
elf_relocation_size("ARM", "THM_JUMP19", 19).
80+
elf_relocation_size("ARM", "THM_JUMP6", 6).
81+
elf_relocation_size("ARM", "THM_ALU_PREL_11_0", 13).
82+
elf_relocation_size("ARM", "THM_PC12", 13).
83+
elf_relocation_size("ARM", "ABS32_NOI", 32).
84+
elf_relocation_size("ARM", "REL32_NOI", 32).
85+
elf_relocation_size("ARM", "ALU_PC_G0_NC", 32).
86+
elf_relocation_size("ARM", "ALU_PC_G0", 32).
87+
elf_relocation_size("ARM", "ALU_PC_G1_NC", 32).
88+
elf_relocation_size("ARM", "ALU_PC_G1", 32).
89+
elf_relocation_size("ARM", "ALU_PC_G2", 32).
90+
elf_relocation_size("ARM", "LDR_PC_G1", 32).
91+
elf_relocation_size("ARM", "LDR_PC_G2", 32).
92+
elf_relocation_size("ARM", "LDRS_PC_G0", 32).
93+
elf_relocation_size("ARM", "LDRS_PC_G1", 32).
94+
elf_relocation_size("ARM", "LDRS_PC_G2", 32).
95+
elf_relocation_size("ARM", "LDC_PC_G0", 32).
96+
elf_relocation_size("ARM", "LDC_PC_G1", 32).
97+
elf_relocation_size("ARM", "LDC_PC_G2", 32).
98+
elf_relocation_size("ARM", "ALU_SB_G0_NC", 32).
99+
elf_relocation_size("ARM", "ALU_SB_G0", 32).
100+
elf_relocation_size("ARM", "ALU_SB_G1_NC", 32).
101+
elf_relocation_size("ARM", "ALU_SB_G1", 32).
102+
elf_relocation_size("ARM", "ALU_SB_G2", 32).
103+
elf_relocation_size("ARM", "LDR_SB_G0", 32).
104+
elf_relocation_size("ARM", "LDR_SB_G1", 32).
105+
elf_relocation_size("ARM", "LDR_SB_G2", 32).
106+
elf_relocation_size("ARM", "LDRS_SB_G0", 32).
107+
elf_relocation_size("ARM", "LDRS_SB_G1", 32).
108+
elf_relocation_size("ARM", "LDRS_SB_G2", 32).
109+
elf_relocation_size("ARM", "LDC_SB_G0", 32).
110+
elf_relocation_size("ARM", "LDC_SB_G1", 32).
111+
elf_relocation_size("ARM", "LDC_SB_G2", 32).
112+
elf_relocation_size("ARM", "MOVW_BREL_NC", 16).
113+
elf_relocation_size("ARM", "MOVT_BREL", 16).
114+
elf_relocation_size("ARM", "MOVW_BREL", 16).
115+
elf_relocation_size("ARM", "THM_MOVW_BREL_NC", 16).
116+
elf_relocation_size("ARM", "THM_MOVT_BREL", 16).
117+
elf_relocation_size("ARM", "THM_MOVW_BREL", 16).
118+
elf_relocation_size("ARM", "TLS_GOTDESC", 0).
119+
elf_relocation_size("ARM", "TLS_CALL", 0).
120+
elf_relocation_size("ARM", "TLS_DESCSEQ", 0).
121+
elf_relocation_size("ARM", "THM_TLS_CALL", 0).
122+
elf_relocation_size("ARM", "PLT32_ABS", 32).
123+
elf_relocation_size("ARM", "GOT_ABS", 32).
124+
elf_relocation_size("ARM", "GOT_PREL", 32).
125+
elf_relocation_size("ARM", "GOT_BREL12", 12).
126+
elf_relocation_size("ARM", "GOTOFF12", 12).
127+
elf_relocation_size("ARM", "GOTRELAX", 12).
128+
elf_relocation_size("ARM", "GNU_VTENTRY", 0).
129+
elf_relocation_size("ARM", "GNU_VTINHERIT", 0).
130+
elf_relocation_size("ARM", "THM_JUMP11", 11).
131+
elf_relocation_size("ARM", "THM_JUMP8", 8).
132+
elf_relocation_size("ARM", "TLS_GD32", 32).
133+
elf_relocation_size("ARM", "TLS_LDM32", 32).
134+
elf_relocation_size("ARM", "TLS_LDO32", 32).
135+
elf_relocation_size("ARM", "TLS_IE32", 32).
136+
elf_relocation_size("ARM", "TLS_LE32", 32).
137+
elf_relocation_size("ARM", "TLS_LDO12", 12).
138+
elf_relocation_size("ARM", "TLS_LE12", 12).
139+
elf_relocation_size("ARM", "TLS_IE12GP", 12).
140+
elf_relocation_size("ARM", "PRIVATE_0", 0).
141+
elf_relocation_size("ARM", "PRIVATE_1", 0).
142+
elf_relocation_size("ARM", "PRIVATE_2", 0).
143+
elf_relocation_size("ARM", "PRIVATE_3", 0).
144+
elf_relocation_size("ARM", "PRIVATE_4", 0).
145+
elf_relocation_size("ARM", "PRIVATE_5", 0).
146+
elf_relocation_size("ARM", "PRIVATE_6", 0).
147+
elf_relocation_size("ARM", "PRIVATE_7", 0).
148+
elf_relocation_size("ARM", "PRIVATE_8", 0).
149+
elf_relocation_size("ARM", "PRIVATE_9", 0).
150+
elf_relocation_size("ARM", "PRIVATE_10", 0).
151+
elf_relocation_size("ARM", "PRIVATE_11", 0).
152+
elf_relocation_size("ARM", "PRIVATE_12", 0).
153+
elf_relocation_size("ARM", "PRIVATE_13", 0).
154+
elf_relocation_size("ARM", "PRIVATE_14", 0).
155+
elf_relocation_size("ARM", "PRIVATE_15", 0).
156+
elf_relocation_size("ARM", "ME_TOO", 0).
157+
elf_relocation_size("ARM", "THM_TLS_DESCSEQ16", 0).
158+
elf_relocation_size("ARM", "THM_TLS_DESCSEQ32", 0).
159+
elf_relocation_size("ARM", "IRELATIVE", 0).
160+
elf_relocation_size("ARM", "RXPC25", 25).
161+
elf_relocation_size("ARM", "RSBREL32", 32).
162+
elf_relocation_size("ARM", "THM_RPC22", 22).
163+
elf_relocation_size("ARM", "RREL32", 32).
164+
elf_relocation_size("ARM", "RPC24", 24).
165+
elf_relocation_size("ARM", "RBASE", 0).

0 commit comments

Comments
 (0)