@isopodlabs/binary_libs 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/elf.js DELETED
@@ -1,791 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.ELFFile = void 0;
27
- const binary = __importStar(require("@isopodlabs/binary"));
28
- //-------------------- FILE HEADER
29
- var CLASS;
30
- (function (CLASS) {
31
- CLASS[CLASS["CLASSNONE"] = 0] = "CLASSNONE";
32
- CLASS[CLASS["CLASS32"] = 1] = "CLASS32";
33
- CLASS[CLASS["CLASS64"] = 2] = "CLASS64";
34
- })(CLASS || (CLASS = {}));
35
- var DATA;
36
- (function (DATA) {
37
- DATA[DATA["NONE"] = 0] = "NONE";
38
- DATA[DATA["LSB"] = 1] = "LSB";
39
- DATA[DATA["MSB"] = 2] = "MSB";
40
- })(DATA || (DATA = {}));
41
- var OSABI;
42
- (function (OSABI) {
43
- OSABI[OSABI["SYSV"] = 0] = "SYSV";
44
- OSABI[OSABI["HPUX"] = 1] = "HPUX";
45
- OSABI[OSABI["STANDALONE"] = 255] = "STANDALONE";
46
- })(OSABI || (OSABI = {}));
47
- const Ident = {
48
- //enum {MAGIC = '\177ELF'};
49
- magic: binary.UINT32_LE,
50
- file_class: binary.as(binary.UINT8, binary.Enum(CLASS)),
51
- encoding: binary.as(binary.UINT8, binary.Enum(DATA)),
52
- version: binary.UINT8,
53
- //64 bit only
54
- osabi: binary.as(binary.UINT8, binary.Enum(OSABI)),
55
- abiversion: binary.UINT8,
56
- pad: binary.ArrayType(7, binary.UINT8),
57
- };
58
- var ET;
59
- (function (ET) {
60
- ET[ET["NONE"] = 0] = "NONE";
61
- ET[ET["REL"] = 1] = "REL";
62
- ET[ET["EXEC"] = 2] = "EXEC";
63
- ET[ET["DYN"] = 3] = "DYN";
64
- ET[ET["CORE"] = 4] = "CORE";
65
- ET[ET["LOOS"] = 65024] = "LOOS";
66
- ET[ET["HIOS"] = 65279] = "HIOS";
67
- ET[ET["LOPROC"] = 65280] = "LOPROC";
68
- ET[ET["HIPROC"] = 65535] = "HIPROC";
69
- })(ET || (ET = {}));
70
- const EM = {
71
- NONE: 0,
72
- M32: 1,
73
- SPARC: 2,
74
- '386': 3,
75
- '68K': 4,
76
- '88K': 5,
77
- '486': 6,
78
- '860': 7,
79
- MIPS: 8,
80
- S370: 9,
81
- MIPS_RS3_LE: 10,
82
- RS6000: 11,
83
- UNKNOWN12: 12,
84
- UNKNOWN13: 13,
85
- UNKNOWN14: 14,
86
- PA_RISC: 15,
87
- nCUBE: 16,
88
- VPP500: 17,
89
- SPARC32PLUS: 18,
90
- '960': 19,
91
- PPC: 20,
92
- PPC64: 21,
93
- S390: 22,
94
- SPE: 23,
95
- UNKNOWN24: 24,
96
- UNKNOWN25: 25,
97
- UNKNOWN26: 26,
98
- UNKNOWN27: 27,
99
- UNKNOWN28: 28,
100
- UNKNOWN29: 29,
101
- UNKNOWN30: 30,
102
- UNKNOWN31: 31,
103
- UNKNOWN32: 32,
104
- UNKNOWN33: 33,
105
- UNKNOWN34: 34,
106
- UNKNOWN35: 35,
107
- V800: 36,
108
- FR20: 37,
109
- RH32: 38,
110
- RCE: 39,
111
- ARM: 40,
112
- ALPHA: 41,
113
- SH: 42,
114
- SPARCV9: 43,
115
- TRICORE: 44,
116
- ARC: 45,
117
- H8_300: 46,
118
- H8_300H: 47,
119
- H8S: 48,
120
- H8_500: 49,
121
- IA_64: 50,
122
- MIPS_X: 51,
123
- COLDFIRE: 52,
124
- '68HC12': 53,
125
- MMA: 54,
126
- PCP: 55,
127
- NCPU: 56,
128
- NDR1: 57,
129
- STARCORE: 58,
130
- ME16: 59,
131
- ST100: 60,
132
- TINYJ: 61,
133
- AMD64: 62,
134
- PDSP: 63,
135
- UNKNOWN64: 64,
136
- UNKNOWN65: 65,
137
- FX66: 66,
138
- ST9PLUS: 67,
139
- ST7: 68,
140
- '68HC16': 69,
141
- '68HC11': 70,
142
- '68HC08': 71,
143
- '68HC05': 72,
144
- SVX: 73,
145
- ST19: 74,
146
- VAX: 75,
147
- CRIS: 76,
148
- JAVELIN: 77,
149
- FIREPATH: 78,
150
- ZSP: 79,
151
- MMIX: 80,
152
- HUANY: 81,
153
- PRISM: 82,
154
- AVR: 83,
155
- FR30: 84,
156
- D10V: 85,
157
- D30V: 86,
158
- V850: 87,
159
- M32R: 88,
160
- MN10300: 89,
161
- MN10200: 90,
162
- PJ: 91,
163
- OPENRISC: 92,
164
- ARC_A5: 93,
165
- XTENSA: 94, // Tensilica Xtensa architecture
166
- };
167
- var EV;
168
- (function (EV) {
169
- EV[EV["NONE"] = 0] = "NONE";
170
- EV[EV["CURRENT"] = 1] = "CURRENT";
171
- })(EV || (EV = {}));
172
- //-------------------- PROGRAM HEADER
173
- var PT;
174
- (function (PT) {
175
- PT[PT["NULL"] = 0] = "NULL";
176
- PT[PT["LOAD"] = 1] = "LOAD";
177
- PT[PT["DYNAMIC"] = 2] = "DYNAMIC";
178
- PT[PT["INTERP"] = 3] = "INTERP";
179
- PT[PT["NOTE"] = 4] = "NOTE";
180
- PT[PT["SHLIB"] = 5] = "SHLIB";
181
- PT[PT["PHDR"] = 6] = "PHDR";
182
- PT[PT["TLS"] = 7] = "TLS";
183
- //OS-specific semantics.
184
- PT[PT["LOOS"] = 1610612736] = "LOOS";
185
- PT[PT["UNWIND"] = 1684333904] = "UNWIND";
186
- PT[PT["EH_FRAME"] = 1685382480] = "EH_FRAME";
187
- PT[PT["GNU_STACK"] = 1685382481] = "GNU_STACK";
188
- PT[PT["GNU_RELRO"] = 1685382482] = "GNU_RELRO";
189
- PT[PT["OS_SCE"] = 1879047936] = "OS_SCE";
190
- PT[PT["HIOS"] = 1879048191] = "HIOS";
191
- //processor-specific semantics.
192
- PT[PT["LOPROC"] = 1879048192] = "LOPROC";
193
- PT[PT["HIPROC"] = 2147483647] = "HIPROC";
194
- })(PT || (PT = {}));
195
- var PF;
196
- (function (PF) {
197
- PF[PF["X"] = 1] = "X";
198
- PF[PF["W"] = 2] = "W";
199
- PF[PF["R"] = 4] = "R";
200
- PF[PF["MASKPROC"] = 4026531840] = "MASKPROC";
201
- })(PF || (PF = {}));
202
- //-------------------- SECTIONS
203
- var SHN;
204
- (function (SHN) {
205
- SHN[SHN["UNDEF"] = 0] = "UNDEF";
206
- // LORESERVE = 0xff00, //lower bound of the range of reserved indexes
207
- SHN[SHN["LOPROC"] = 65280] = "LOPROC";
208
- SHN[SHN["HIPROC"] = 65311] = "HIPROC";
209
- SHN[SHN["LOOS"] = 65312] = "LOOS";
210
- SHN[SHN["HIOS"] = 65343] = "HIOS";
211
- SHN[SHN["ABS"] = 65521] = "ABS";
212
- SHN[SHN["COMMON"] = 65522] = "COMMON";
213
- SHN[SHN["HIRESERVE"] = 65535] = "HIRESERVE";
214
- })(SHN || (SHN = {}));
215
- var SHT;
216
- (function (SHT) {
217
- SHT[SHT["NULL"] = 0] = "NULL";
218
- SHT[SHT["PROGBITS"] = 1] = "PROGBITS";
219
- SHT[SHT["SYMTAB"] = 2] = "SYMTAB";
220
- SHT[SHT["STRTAB"] = 3] = "STRTAB";
221
- SHT[SHT["RELA"] = 4] = "RELA";
222
- SHT[SHT["HASH"] = 5] = "HASH";
223
- SHT[SHT["DYNAMIC"] = 6] = "DYNAMIC";
224
- SHT[SHT["NOTE"] = 7] = "NOTE";
225
- SHT[SHT["NOBITS"] = 8] = "NOBITS";
226
- SHT[SHT["REL"] = 9] = "REL";
227
- SHT[SHT["SHLIB"] = 10] = "SHLIB";
228
- SHT[SHT["DYNSYM"] = 11] = "DYNSYM";
229
- SHT[SHT["LOOS"] = 1610612736] = "LOOS";
230
- SHT[SHT["HIOS"] = 1879048191] = "HIOS";
231
- SHT[SHT["LOPROC"] = 1879048192] = "LOPROC";
232
- SHT[SHT["HIPROC"] = 2147483647] = "HIPROC";
233
- SHT[SHT["LOUSER"] = 2147483648] = "LOUSER";
234
- SHT[SHT["HIUSER"] = 4294967295] = "HIUSER";
235
- SHT[SHT["PS3_RELA"] = 1879048356] = "PS3_RELA";
236
- })(SHT || (SHT = {}));
237
- var SHF;
238
- (function (SHF) {
239
- SHF[SHF["WRITE"] = 1] = "WRITE";
240
- SHF[SHF["ALLOC"] = 2] = "ALLOC";
241
- SHF[SHF["EXECINSTR"] = 4] = "EXECINSTR";
242
- SHF[SHF["MASKOS"] = 251658240] = "MASKOS";
243
- SHF[SHF["MASKPROC"] = 4026531840] = "MASKPROC";
244
- })(SHF || (SHF = {}));
245
- //-------------------- SYMBOLS
246
- const ST_INFO = binary.BitFields({
247
- type: [4, binary.Enum({
248
- NOTYPE: 0,
249
- OBJECT: 1,
250
- FUNC: 2,
251
- SECTION: 3,
252
- FILE: 4,
253
- LOOS: 10,
254
- HIOS: 12,
255
- LOPROC: 13,
256
- HIPROC: 15,
257
- })],
258
- binding: [4, binary.Enum({
259
- LOCAL: 0,
260
- GLOBAL: 1,
261
- WEAK: 2,
262
- LOOS: 10,
263
- HIOS: 12,
264
- LOPROC: 13,
265
- HIPROC: 15,
266
- })],
267
- });
268
- const ST_OTHER = binary.BitFields({
269
- visibility: [2, binary.Enum({
270
- DEFAULT: 0,
271
- HIDDEN: 1,
272
- PROTECTED: 2,
273
- })],
274
- other: 6,
275
- });
276
- //-------------------- DYNAMIC
277
- var DT_TAG;
278
- (function (DT_TAG) {
279
- //Name Value d_un Executable Shared Object
280
- DT_TAG[DT_TAG["DT_NULL"] = 0] = "DT_NULL";
281
- DT_TAG[DT_TAG["DT_NEEDED"] = 1] = "DT_NEEDED";
282
- DT_TAG[DT_TAG["DT_PLTRELSZ"] = 2] = "DT_PLTRELSZ";
283
- DT_TAG[DT_TAG["DT_PLTGOT"] = 3] = "DT_PLTGOT";
284
- DT_TAG[DT_TAG["DT_HASH"] = 4] = "DT_HASH";
285
- DT_TAG[DT_TAG["DT_STRTAB"] = 5] = "DT_STRTAB";
286
- DT_TAG[DT_TAG["DT_SYMTAB"] = 6] = "DT_SYMTAB";
287
- DT_TAG[DT_TAG["DT_RELA"] = 7] = "DT_RELA";
288
- DT_TAG[DT_TAG["DT_RELASZ"] = 8] = "DT_RELASZ";
289
- DT_TAG[DT_TAG["DT_RELAENT"] = 9] = "DT_RELAENT";
290
- DT_TAG[DT_TAG["DT_STRSZ"] = 10] = "DT_STRSZ";
291
- DT_TAG[DT_TAG["DT_SYMENT"] = 11] = "DT_SYMENT";
292
- DT_TAG[DT_TAG["DT_INIT"] = 12] = "DT_INIT";
293
- DT_TAG[DT_TAG["DT_FINI"] = 13] = "DT_FINI";
294
- DT_TAG[DT_TAG["DT_SONAME"] = 14] = "DT_SONAME";
295
- DT_TAG[DT_TAG["DT_RPATH"] = 15] = "DT_RPATH";
296
- DT_TAG[DT_TAG["DT_SYMBOLIC"] = 16] = "DT_SYMBOLIC";
297
- DT_TAG[DT_TAG["DT_REL"] = 17] = "DT_REL";
298
- DT_TAG[DT_TAG["DT_RELSZ"] = 18] = "DT_RELSZ";
299
- DT_TAG[DT_TAG["DT_RELENT"] = 19] = "DT_RELENT";
300
- DT_TAG[DT_TAG["DT_PLTREL"] = 20] = "DT_PLTREL";
301
- DT_TAG[DT_TAG["DT_DEBUG"] = 21] = "DT_DEBUG";
302
- DT_TAG[DT_TAG["DT_TEXTREL"] = 22] = "DT_TEXTREL";
303
- DT_TAG[DT_TAG["DT_JMPREL"] = 23] = "DT_JMPREL";
304
- DT_TAG[DT_TAG["DT_BIND_NOW"] = 24] = "DT_BIND_NOW";
305
- DT_TAG[DT_TAG["DT_INIT_ARRAY"] = 25] = "DT_INIT_ARRAY";
306
- DT_TAG[DT_TAG["DT_FINI_ARRAY"] = 26] = "DT_FINI_ARRAY";
307
- DT_TAG[DT_TAG["DT_INIT_ARRAYSZ"] = 27] = "DT_INIT_ARRAYSZ";
308
- DT_TAG[DT_TAG["DT_FINI_ARRAYSZ"] = 28] = "DT_FINI_ARRAYSZ";
309
- DT_TAG[DT_TAG["DT_RUNPATH"] = 29] = "DT_RUNPATH";
310
- DT_TAG[DT_TAG["DT_FLAGS"] = 30] = "DT_FLAGS";
311
- DT_TAG[DT_TAG["DT_ENCODING"] = 32] = "DT_ENCODING";
312
- // DT_PREINIT_ARRAY = 32, //d_ptr optional ignored
313
- DT_TAG[DT_TAG["DT_PREINIT_ARRAYSZ"] = 33] = "DT_PREINIT_ARRAYSZ";
314
- DT_TAG[DT_TAG["DT_LOOS"] = 1610612749] = "DT_LOOS";
315
- DT_TAG[DT_TAG["DT_HIOS"] = 1879044096] = "DT_HIOS";
316
- DT_TAG[DT_TAG["DT_LOPROC"] = 1879048192] = "DT_LOPROC";
317
- DT_TAG[DT_TAG["DT_HIPROC"] = 2147483647] = "DT_HIPROC";
318
- })(DT_TAG || (DT_TAG = {}));
319
- var DT_FLAGS;
320
- (function (DT_FLAGS) {
321
- DT_FLAGS[DT_FLAGS["DF_ORIGIN"] = 1] = "DF_ORIGIN";
322
- DT_FLAGS[DT_FLAGS["DF_SYMBOLIC"] = 2] = "DF_SYMBOLIC";
323
- DT_FLAGS[DT_FLAGS["DF_TEXTREL"] = 4] = "DF_TEXTREL";
324
- DT_FLAGS[DT_FLAGS["DF_BIND_NOW"] = 8] = "DF_BIND_NOW";
325
- DT_FLAGS[DT_FLAGS["DF_STATIC_TLS"] = 16] = "DF_STATIC_TLS";
326
- })(DT_FLAGS || (DT_FLAGS = {}));
327
- //-------------------- RELOC
328
- var RELOC_386;
329
- (function (RELOC_386) {
330
- RELOC_386[RELOC_386["R_386_NONE"] = 0] = "R_386_NONE";
331
- RELOC_386[RELOC_386["R_386_32"] = 1] = "R_386_32";
332
- RELOC_386[RELOC_386["R_386_PC32"] = 2] = "R_386_PC32";
333
- RELOC_386[RELOC_386["R_386_GOT32"] = 3] = "R_386_GOT32";
334
- RELOC_386[RELOC_386["R_386_PLT32"] = 4] = "R_386_PLT32";
335
- RELOC_386[RELOC_386["R_386_COPY"] = 5] = "R_386_COPY";
336
- RELOC_386[RELOC_386["R_386_GLOB_DAT"] = 6] = "R_386_GLOB_DAT";
337
- RELOC_386[RELOC_386["R_386_JMP_SLOT"] = 7] = "R_386_JMP_SLOT";
338
- RELOC_386[RELOC_386["R_386_RELATIVE"] = 8] = "R_386_RELATIVE";
339
- RELOC_386[RELOC_386["R_386_GOTOFF"] = 9] = "R_386_GOTOFF";
340
- RELOC_386[RELOC_386["R_386_GOTPC"] = 10] = "R_386_GOTPC";
341
- RELOC_386[RELOC_386["R_386_32PLT"] = 11] = "R_386_32PLT";
342
- RELOC_386[RELOC_386["R_386_TLS_GD_PLT"] = 12] = "R_386_TLS_GD_PLT";
343
- RELOC_386[RELOC_386["R_386_TLS_LDM_PLT"] = 13] = "R_386_TLS_LDM_PLT";
344
- RELOC_386[RELOC_386["R_386_TLS_TPOFF"] = 14] = "R_386_TLS_TPOFF";
345
- RELOC_386[RELOC_386["R_386_TLS_IE"] = 15] = "R_386_TLS_IE";
346
- RELOC_386[RELOC_386["R_386_TLS_GOTIE"] = 16] = "R_386_TLS_GOTIE";
347
- RELOC_386[RELOC_386["R_386_TLS_LE"] = 17] = "R_386_TLS_LE";
348
- RELOC_386[RELOC_386["R_386_TLS_GD"] = 18] = "R_386_TLS_GD";
349
- RELOC_386[RELOC_386["R_386_TLS_LDM"] = 19] = "R_386_TLS_LDM";
350
- RELOC_386[RELOC_386["R_386_16"] = 20] = "R_386_16";
351
- RELOC_386[RELOC_386["R_386_PC16"] = 21] = "R_386_PC16";
352
- RELOC_386[RELOC_386["R_386_8"] = 22] = "R_386_8";
353
- RELOC_386[RELOC_386["R_386_PC8"] = 23] = "R_386_PC8";
354
- RELOC_386[RELOC_386["R_386_UNKNOWN24"] = 24] = "R_386_UNKNOWN24";
355
- RELOC_386[RELOC_386["R_386_UNKNOWN25"] = 25] = "R_386_UNKNOWN25";
356
- RELOC_386[RELOC_386["R_386_UNKNOWN26"] = 26] = "R_386_UNKNOWN26";
357
- RELOC_386[RELOC_386["R_386_UNKNOWN27"] = 27] = "R_386_UNKNOWN27";
358
- RELOC_386[RELOC_386["R_386_UNKNOWN28"] = 28] = "R_386_UNKNOWN28";
359
- RELOC_386[RELOC_386["R_386_UNKNOWN29"] = 29] = "R_386_UNKNOWN29";
360
- RELOC_386[RELOC_386["R_386_UNKNOWN30"] = 30] = "R_386_UNKNOWN30";
361
- RELOC_386[RELOC_386["R_386_UNKNOWN31"] = 31] = "R_386_UNKNOWN31";
362
- RELOC_386[RELOC_386["R_386_TLS_LDO_32"] = 32] = "R_386_TLS_LDO_32";
363
- RELOC_386[RELOC_386["R_386_UNKNOWN33"] = 33] = "R_386_UNKNOWN33";
364
- RELOC_386[RELOC_386["R_386_UNKNOWN34"] = 34] = "R_386_UNKNOWN34";
365
- RELOC_386[RELOC_386["R_386_TLS_DTPMOD32"] = 35] = "R_386_TLS_DTPMOD32";
366
- RELOC_386[RELOC_386["R_386_TLS_DTPOFF32"] = 36] = "R_386_TLS_DTPOFF32";
367
- RELOC_386[RELOC_386["R_386_UNKNOWN37"] = 37] = "R_386_UNKNOWN37";
368
- RELOC_386[RELOC_386["R_386_SIZE32"] = 38] = "R_386_SIZE32";
369
- RELOC_386[RELOC_386["R_386_NUM"] = 39] = "R_386_NUM";
370
- })(RELOC_386 || (RELOC_386 = {}));
371
- var RELOC_PPC;
372
- (function (RELOC_PPC) {
373
- RELOC_PPC[RELOC_PPC["R_PPC_NONE"] = 0] = "R_PPC_NONE";
374
- RELOC_PPC[RELOC_PPC["R_PPC_ADDR32"] = 1] = "R_PPC_ADDR32";
375
- RELOC_PPC[RELOC_PPC["R_PPC_ADDR24"] = 2] = "R_PPC_ADDR24";
376
- RELOC_PPC[RELOC_PPC["R_PPC_ADDR16"] = 3] = "R_PPC_ADDR16";
377
- RELOC_PPC[RELOC_PPC["R_PPC_ADDR16_LO"] = 4] = "R_PPC_ADDR16_LO";
378
- RELOC_PPC[RELOC_PPC["R_PPC_ADDR16_HI"] = 5] = "R_PPC_ADDR16_HI";
379
- RELOC_PPC[RELOC_PPC["R_PPC_ADDR16_HA"] = 6] = "R_PPC_ADDR16_HA";
380
- RELOC_PPC[RELOC_PPC["R_PPC_ADDR14"] = 7] = "R_PPC_ADDR14";
381
- RELOC_PPC[RELOC_PPC["R_PPC_ADDR14_BRTAKEN"] = 8] = "R_PPC_ADDR14_BRTAKEN";
382
- RELOC_PPC[RELOC_PPC["R_PPC_ADDR14_BRNTAKEN"] = 9] = "R_PPC_ADDR14_BRNTAKEN";
383
- RELOC_PPC[RELOC_PPC["R_PPC_REL24"] = 10] = "R_PPC_REL24";
384
- RELOC_PPC[RELOC_PPC["R_PPC_REL14"] = 11] = "R_PPC_REL14";
385
- RELOC_PPC[RELOC_PPC["R_PPC_REL14_BRTAKEN"] = 12] = "R_PPC_REL14_BRTAKEN";
386
- RELOC_PPC[RELOC_PPC["R_PPC_REL14_BRNTAKEN"] = 13] = "R_PPC_REL14_BRNTAKEN";
387
- RELOC_PPC[RELOC_PPC["R_PPC_GOT16"] = 14] = "R_PPC_GOT16";
388
- RELOC_PPC[RELOC_PPC["R_PPC_GOT16_LO"] = 15] = "R_PPC_GOT16_LO";
389
- RELOC_PPC[RELOC_PPC["R_PPC_GOT16_HI"] = 16] = "R_PPC_GOT16_HI";
390
- RELOC_PPC[RELOC_PPC["R_PPC_GOT16_HA"] = 17] = "R_PPC_GOT16_HA";
391
- RELOC_PPC[RELOC_PPC["R_PPC_PLTREL24"] = 18] = "R_PPC_PLTREL24";
392
- RELOC_PPC[RELOC_PPC["R_PPC_COPY"] = 19] = "R_PPC_COPY";
393
- RELOC_PPC[RELOC_PPC["R_PPC_GLOB_DAT"] = 20] = "R_PPC_GLOB_DAT";
394
- RELOC_PPC[RELOC_PPC["R_PPC_JMP_SLOT"] = 21] = "R_PPC_JMP_SLOT";
395
- RELOC_PPC[RELOC_PPC["R_PPC_RELATIVE"] = 22] = "R_PPC_RELATIVE";
396
- RELOC_PPC[RELOC_PPC["R_PPC_LOCAL24PC"] = 23] = "R_PPC_LOCAL24PC";
397
- RELOC_PPC[RELOC_PPC["R_PPC_UADDR32"] = 24] = "R_PPC_UADDR32";
398
- RELOC_PPC[RELOC_PPC["R_PPC_UADDR16"] = 25] = "R_PPC_UADDR16";
399
- RELOC_PPC[RELOC_PPC["R_PPC_REL32"] = 26] = "R_PPC_REL32";
400
- RELOC_PPC[RELOC_PPC["R_PPC_PLT32"] = 27] = "R_PPC_PLT32";
401
- RELOC_PPC[RELOC_PPC["R_PPC_PLTREL32"] = 28] = "R_PPC_PLTREL32";
402
- RELOC_PPC[RELOC_PPC["R_PPC_PLT16_LO"] = 29] = "R_PPC_PLT16_LO";
403
- RELOC_PPC[RELOC_PPC["R_PPC_PLT16_HI"] = 30] = "R_PPC_PLT16_HI";
404
- RELOC_PPC[RELOC_PPC["R_PPC_PLT16_HA"] = 31] = "R_PPC_PLT16_HA";
405
- RELOC_PPC[RELOC_PPC["R_PPC_SDAREL16"] = 32] = "R_PPC_SDAREL16";
406
- RELOC_PPC[RELOC_PPC["R_PPC_SECTOFF"] = 33] = "R_PPC_SECTOFF";
407
- RELOC_PPC[RELOC_PPC["R_PPC_SECTOFF_LO"] = 34] = "R_PPC_SECTOFF_LO";
408
- RELOC_PPC[RELOC_PPC["R_PPC_SECTOFF_HI"] = 35] = "R_PPC_SECTOFF_HI";
409
- RELOC_PPC[RELOC_PPC["R_PPC_SECTOFF_HA"] = 36] = "R_PPC_SECTOFF_HA";
410
- RELOC_PPC[RELOC_PPC["R_PPC_ADDR30"] = 37] = "R_PPC_ADDR30";
411
- // Relocs added to support TLS.
412
- RELOC_PPC[RELOC_PPC["R_PPC_TLS"] = 67] = "R_PPC_TLS";
413
- RELOC_PPC[RELOC_PPC["R_PPC_DTPMOD32"] = 68] = "R_PPC_DTPMOD32";
414
- RELOC_PPC[RELOC_PPC["R_PPC_TPREL16"] = 69] = "R_PPC_TPREL16";
415
- RELOC_PPC[RELOC_PPC["R_PPC_TPREL16_LO"] = 70] = "R_PPC_TPREL16_LO";
416
- RELOC_PPC[RELOC_PPC["R_PPC_TPREL16_HI"] = 71] = "R_PPC_TPREL16_HI";
417
- RELOC_PPC[RELOC_PPC["R_PPC_TPREL16_HA"] = 72] = "R_PPC_TPREL16_HA";
418
- RELOC_PPC[RELOC_PPC["R_PPC_TPREL32"] = 73] = "R_PPC_TPREL32";
419
- RELOC_PPC[RELOC_PPC["R_PPC_DTPREL16"] = 74] = "R_PPC_DTPREL16";
420
- RELOC_PPC[RELOC_PPC["R_PPC_DTPREL16_LO"] = 75] = "R_PPC_DTPREL16_LO";
421
- RELOC_PPC[RELOC_PPC["R_PPC_DTPREL16_HI"] = 76] = "R_PPC_DTPREL16_HI";
422
- RELOC_PPC[RELOC_PPC["R_PPC_DTPREL16_HA"] = 77] = "R_PPC_DTPREL16_HA";
423
- RELOC_PPC[RELOC_PPC["R_PPC_DTPREL32"] = 78] = "R_PPC_DTPREL32";
424
- RELOC_PPC[RELOC_PPC["R_PPC_GOT_TLSGD16"] = 79] = "R_PPC_GOT_TLSGD16";
425
- RELOC_PPC[RELOC_PPC["R_PPC_GOT_TLSGD16_LO"] = 80] = "R_PPC_GOT_TLSGD16_LO";
426
- RELOC_PPC[RELOC_PPC["R_PPC_GOT_TLSGD16_HI"] = 81] = "R_PPC_GOT_TLSGD16_HI";
427
- RELOC_PPC[RELOC_PPC["R_PPC_GOT_TLSGD16_HA"] = 82] = "R_PPC_GOT_TLSGD16_HA";
428
- RELOC_PPC[RELOC_PPC["R_PPC_GOT_TLSLD16"] = 83] = "R_PPC_GOT_TLSLD16";
429
- RELOC_PPC[RELOC_PPC["R_PPC_GOT_TLSLD16_LO"] = 84] = "R_PPC_GOT_TLSLD16_LO";
430
- RELOC_PPC[RELOC_PPC["R_PPC_GOT_TLSLD16_HI"] = 85] = "R_PPC_GOT_TLSLD16_HI";
431
- RELOC_PPC[RELOC_PPC["R_PPC_GOT_TLSLD16_HA"] = 86] = "R_PPC_GOT_TLSLD16_HA";
432
- RELOC_PPC[RELOC_PPC["R_PPC_GOT_TPREL16"] = 87] = "R_PPC_GOT_TPREL16";
433
- RELOC_PPC[RELOC_PPC["R_PPC_GOT_TPREL16_LO"] = 88] = "R_PPC_GOT_TPREL16_LO";
434
- RELOC_PPC[RELOC_PPC["R_PPC_GOT_TPREL16_HI"] = 89] = "R_PPC_GOT_TPREL16_HI";
435
- RELOC_PPC[RELOC_PPC["R_PPC_GOT_TPREL16_HA"] = 90] = "R_PPC_GOT_TPREL16_HA";
436
- RELOC_PPC[RELOC_PPC["R_PPC_GOT_DTPREL16"] = 91] = "R_PPC_GOT_DTPREL16";
437
- RELOC_PPC[RELOC_PPC["R_PPC_GOT_DTPREL16_LO"] = 92] = "R_PPC_GOT_DTPREL16_LO";
438
- RELOC_PPC[RELOC_PPC["R_PPC_GOT_DTPREL16_HI"] = 93] = "R_PPC_GOT_DTPREL16_HI";
439
- RELOC_PPC[RELOC_PPC["R_PPC_GOT_DTPREL16_HA"] = 94] = "R_PPC_GOT_DTPREL16_HA";
440
- // The remaining relocs are from the Embedded ELF ABI and are not in the SVR4 ELF ABI
441
- RELOC_PPC[RELOC_PPC["R_PPC_EMB_NADDR32"] = 101] = "R_PPC_EMB_NADDR32";
442
- RELOC_PPC[RELOC_PPC["R_PPC_EMB_NADDR16"] = 102] = "R_PPC_EMB_NADDR16";
443
- RELOC_PPC[RELOC_PPC["R_PPC_EMB_NADDR16_LO"] = 103] = "R_PPC_EMB_NADDR16_LO";
444
- RELOC_PPC[RELOC_PPC["R_PPC_EMB_NADDR16_HI"] = 104] = "R_PPC_EMB_NADDR16_HI";
445
- RELOC_PPC[RELOC_PPC["R_PPC_EMB_NADDR16_HA"] = 105] = "R_PPC_EMB_NADDR16_HA";
446
- RELOC_PPC[RELOC_PPC["R_PPC_EMB_SDAI16"] = 106] = "R_PPC_EMB_SDAI16";
447
- RELOC_PPC[RELOC_PPC["R_PPC_EMB_SDA2I16"] = 107] = "R_PPC_EMB_SDA2I16";
448
- RELOC_PPC[RELOC_PPC["R_PPC_EMB_SDA2REL"] = 108] = "R_PPC_EMB_SDA2REL";
449
- RELOC_PPC[RELOC_PPC["R_PPC_EMB_SDA21"] = 109] = "R_PPC_EMB_SDA21";
450
- RELOC_PPC[RELOC_PPC["R_PPC_EMB_MRKREF"] = 110] = "R_PPC_EMB_MRKREF";
451
- RELOC_PPC[RELOC_PPC["R_PPC_EMB_RELSEC16"] = 111] = "R_PPC_EMB_RELSEC16";
452
- RELOC_PPC[RELOC_PPC["R_PPC_EMB_RELST_LO"] = 112] = "R_PPC_EMB_RELST_LO";
453
- RELOC_PPC[RELOC_PPC["R_PPC_EMB_RELST_HI"] = 113] = "R_PPC_EMB_RELST_HI";
454
- RELOC_PPC[RELOC_PPC["R_PPC_EMB_RELST_HA"] = 114] = "R_PPC_EMB_RELST_HA";
455
- RELOC_PPC[RELOC_PPC["R_PPC_EMB_BIT_FLD"] = 115] = "R_PPC_EMB_BIT_FLD";
456
- RELOC_PPC[RELOC_PPC["R_PPC_EMB_RELSDA"] = 116] = "R_PPC_EMB_RELSDA";
457
- })(RELOC_PPC || (RELOC_PPC = {}));
458
- var RELOC_PPC64;
459
- (function (RELOC_PPC64) {
460
- RELOC_PPC64[RELOC_PPC64["R_PPC64_NONE"] = 0] = "R_PPC64_NONE";
461
- RELOC_PPC64[RELOC_PPC64["R_PPC64_ADDR32"] = 1] = "R_PPC64_ADDR32";
462
- RELOC_PPC64[RELOC_PPC64["R_PPC64_ADDR24"] = 2] = "R_PPC64_ADDR24";
463
- RELOC_PPC64[RELOC_PPC64["R_PPC64_ADDR16"] = 3] = "R_PPC64_ADDR16";
464
- RELOC_PPC64[RELOC_PPC64["R_PPC64_ADDR16_LO"] = 4] = "R_PPC64_ADDR16_LO";
465
- RELOC_PPC64[RELOC_PPC64["R_PPC64_ADDR16_HI"] = 5] = "R_PPC64_ADDR16_HI";
466
- RELOC_PPC64[RELOC_PPC64["R_PPC64_ADDR16_HA"] = 6] = "R_PPC64_ADDR16_HA";
467
- RELOC_PPC64[RELOC_PPC64["R_PPC64_ADDR14"] = 7] = "R_PPC64_ADDR14";
468
- RELOC_PPC64[RELOC_PPC64["R_PPC64_ADDR14_BRTAKEN"] = 8] = "R_PPC64_ADDR14_BRTAKEN";
469
- RELOC_PPC64[RELOC_PPC64["R_PPC64_ADDR14_BRNTAKEN"] = 9] = "R_PPC64_ADDR14_BRNTAKEN";
470
- RELOC_PPC64[RELOC_PPC64["R_PPC64_REL24"] = 10] = "R_PPC64_REL24";
471
- RELOC_PPC64[RELOC_PPC64["R_PPC64_REL14"] = 11] = "R_PPC64_REL14";
472
- RELOC_PPC64[RELOC_PPC64["R_PPC64_REL14_BRTAKEN"] = 12] = "R_PPC64_REL14_BRTAKEN";
473
- RELOC_PPC64[RELOC_PPC64["R_PPC64_REL14_BRNTAKEN"] = 13] = "R_PPC64_REL14_BRNTAKEN";
474
- RELOC_PPC64[RELOC_PPC64["R_PPC64_GOT16"] = 14] = "R_PPC64_GOT16";
475
- RELOC_PPC64[RELOC_PPC64["R_PPC64_GOT16_LO"] = 15] = "R_PPC64_GOT16_LO";
476
- RELOC_PPC64[RELOC_PPC64["R_PPC64_GOT16_HI"] = 16] = "R_PPC64_GOT16_HI";
477
- RELOC_PPC64[RELOC_PPC64["R_PPC64_GOT16_HA"] = 17] = "R_PPC64_GOT16_HA";
478
- // 18 unused. = 32-bit reloc is R_PPC_PLTREL24.
479
- RELOC_PPC64[RELOC_PPC64["R_PPC64_COPY"] = 19] = "R_PPC64_COPY";
480
- RELOC_PPC64[RELOC_PPC64["R_PPC64_GLOB_DAT"] = 20] = "R_PPC64_GLOB_DAT";
481
- RELOC_PPC64[RELOC_PPC64["R_PPC64_JMP_SLOT"] = 21] = "R_PPC64_JMP_SLOT";
482
- RELOC_PPC64[RELOC_PPC64["R_PPC64_RELATIVE"] = 22] = "R_PPC64_RELATIVE";
483
- // 23 unused. = 32-bit reloc is R_PPC_LOCAL24PC.
484
- RELOC_PPC64[RELOC_PPC64["R_PPC64_UADDR32"] = 24] = "R_PPC64_UADDR32";
485
- RELOC_PPC64[RELOC_PPC64["R_PPC64_UADDR16"] = 25] = "R_PPC64_UADDR16";
486
- RELOC_PPC64[RELOC_PPC64["R_PPC64_REL32"] = 26] = "R_PPC64_REL32";
487
- RELOC_PPC64[RELOC_PPC64["R_PPC64_PLT32"] = 27] = "R_PPC64_PLT32";
488
- RELOC_PPC64[RELOC_PPC64["R_PPC64_PLTREL32"] = 28] = "R_PPC64_PLTREL32";
489
- RELOC_PPC64[RELOC_PPC64["R_PPC64_PLT16_LO"] = 29] = "R_PPC64_PLT16_LO";
490
- RELOC_PPC64[RELOC_PPC64["R_PPC64_PLT16_HI"] = 30] = "R_PPC64_PLT16_HI";
491
- RELOC_PPC64[RELOC_PPC64["R_PPC64_PLT16_HA"] = 31] = "R_PPC64_PLT16_HA";
492
- // 32 unused. = 32-bit reloc is R_PPC_SDAREL16.
493
- RELOC_PPC64[RELOC_PPC64["R_PPC64_SECTOFF"] = 33] = "R_PPC64_SECTOFF";
494
- RELOC_PPC64[RELOC_PPC64["R_PPC64_SECTOFF_LO"] = 34] = "R_PPC64_SECTOFF_LO";
495
- RELOC_PPC64[RELOC_PPC64["R_PPC64_SECTOFF_HI"] = 35] = "R_PPC64_SECTOFF_HI";
496
- RELOC_PPC64[RELOC_PPC64["R_PPC64_SECTOFF_HA"] = 36] = "R_PPC64_SECTOFF_HA";
497
- RELOC_PPC64[RELOC_PPC64["R_PPC64_REL30"] = 37] = "R_PPC64_REL30";
498
- RELOC_PPC64[RELOC_PPC64["R_PPC64_ADDR64"] = 38] = "R_PPC64_ADDR64";
499
- RELOC_PPC64[RELOC_PPC64["R_PPC64_ADDR16_HIGHER"] = 39] = "R_PPC64_ADDR16_HIGHER";
500
- RELOC_PPC64[RELOC_PPC64["R_PPC64_ADDR16_HIGHERA"] = 40] = "R_PPC64_ADDR16_HIGHERA";
501
- RELOC_PPC64[RELOC_PPC64["R_PPC64_ADDR16_HIGHEST"] = 41] = "R_PPC64_ADDR16_HIGHEST";
502
- RELOC_PPC64[RELOC_PPC64["R_PPC64_ADDR16_HIGHESTA"] = 42] = "R_PPC64_ADDR16_HIGHESTA";
503
- RELOC_PPC64[RELOC_PPC64["R_PPC64_UADDR64"] = 43] = "R_PPC64_UADDR64";
504
- RELOC_PPC64[RELOC_PPC64["R_PPC64_REL64"] = 44] = "R_PPC64_REL64";
505
- RELOC_PPC64[RELOC_PPC64["R_PPC64_PLT64"] = 45] = "R_PPC64_PLT64";
506
- RELOC_PPC64[RELOC_PPC64["R_PPC64_PLTREL64"] = 46] = "R_PPC64_PLTREL64";
507
- RELOC_PPC64[RELOC_PPC64["R_PPC64_TOC16"] = 47] = "R_PPC64_TOC16";
508
- RELOC_PPC64[RELOC_PPC64["R_PPC64_TOC16_LO"] = 48] = "R_PPC64_TOC16_LO";
509
- RELOC_PPC64[RELOC_PPC64["R_PPC64_TOC16_HI"] = 49] = "R_PPC64_TOC16_HI";
510
- RELOC_PPC64[RELOC_PPC64["R_PPC64_TOC16_HA"] = 50] = "R_PPC64_TOC16_HA";
511
- RELOC_PPC64[RELOC_PPC64["R_PPC64_TOC"] = 51] = "R_PPC64_TOC";
512
- RELOC_PPC64[RELOC_PPC64["R_PPC64_PLTGOT16"] = 52] = "R_PPC64_PLTGOT16";
513
- RELOC_PPC64[RELOC_PPC64["R_PPC64_PLTGOT16_LO"] = 53] = "R_PPC64_PLTGOT16_LO";
514
- RELOC_PPC64[RELOC_PPC64["R_PPC64_PLTGOT16_HI"] = 54] = "R_PPC64_PLTGOT16_HI";
515
- RELOC_PPC64[RELOC_PPC64["R_PPC64_PLTGOT16_HA"] = 55] = "R_PPC64_PLTGOT16_HA";
516
- // The following relocs were added in the 64-bit PowerPC ELF ABI revision 1.2.
517
- RELOC_PPC64[RELOC_PPC64["R_PPC64_ADDR16_DS"] = 56] = "R_PPC64_ADDR16_DS";
518
- RELOC_PPC64[RELOC_PPC64["R_PPC64_ADDR16_LO_DS"] = 57] = "R_PPC64_ADDR16_LO_DS";
519
- RELOC_PPC64[RELOC_PPC64["R_PPC64_GOT16_DS"] = 58] = "R_PPC64_GOT16_DS";
520
- RELOC_PPC64[RELOC_PPC64["R_PPC64_GOT16_LO_DS"] = 59] = "R_PPC64_GOT16_LO_DS";
521
- RELOC_PPC64[RELOC_PPC64["R_PPC64_PLT16_LO_DS"] = 60] = "R_PPC64_PLT16_LO_DS";
522
- RELOC_PPC64[RELOC_PPC64["R_PPC64_SECTOFF_DS"] = 61] = "R_PPC64_SECTOFF_DS";
523
- RELOC_PPC64[RELOC_PPC64["R_PPC64_SECTOFF_LO_DS"] = 62] = "R_PPC64_SECTOFF_LO_DS";
524
- RELOC_PPC64[RELOC_PPC64["R_PPC64_TOC16_DS"] = 63] = "R_PPC64_TOC16_DS";
525
- RELOC_PPC64[RELOC_PPC64["R_PPC64_TOC16_LO_DS"] = 64] = "R_PPC64_TOC16_LO_DS";
526
- RELOC_PPC64[RELOC_PPC64["R_PPC64_PLTGOT16_DS"] = 65] = "R_PPC64_PLTGOT16_DS";
527
- RELOC_PPC64[RELOC_PPC64["R_PPC64_PLTGOT16_LO_DS"] = 66] = "R_PPC64_PLTGOT16_LO_DS";
528
- // Relocs added to support TLS. PowerPC64 ELF ABI revision 1.5.
529
- RELOC_PPC64[RELOC_PPC64["R_PPC64_TLS"] = 67] = "R_PPC64_TLS";
530
- RELOC_PPC64[RELOC_PPC64["R_PPC64_DTPMOD64"] = 68] = "R_PPC64_DTPMOD64";
531
- RELOC_PPC64[RELOC_PPC64["R_PPC64_TPREL16"] = 69] = "R_PPC64_TPREL16";
532
- RELOC_PPC64[RELOC_PPC64["R_PPC64_TPREL16_LO"] = 70] = "R_PPC64_TPREL16_LO";
533
- RELOC_PPC64[RELOC_PPC64["R_PPC64_TPREL16_HI"] = 71] = "R_PPC64_TPREL16_HI";
534
- RELOC_PPC64[RELOC_PPC64["R_PPC64_TPREL16_HA"] = 72] = "R_PPC64_TPREL16_HA";
535
- RELOC_PPC64[RELOC_PPC64["R_PPC64_TPREL64"] = 73] = "R_PPC64_TPREL64";
536
- RELOC_PPC64[RELOC_PPC64["R_PPC64_DTPREL16"] = 74] = "R_PPC64_DTPREL16";
537
- RELOC_PPC64[RELOC_PPC64["R_PPC64_DTPREL16_LO"] = 75] = "R_PPC64_DTPREL16_LO";
538
- RELOC_PPC64[RELOC_PPC64["R_PPC64_DTPREL16_HI"] = 76] = "R_PPC64_DTPREL16_HI";
539
- RELOC_PPC64[RELOC_PPC64["R_PPC64_DTPREL16_HA"] = 77] = "R_PPC64_DTPREL16_HA";
540
- RELOC_PPC64[RELOC_PPC64["R_PPC64_DTPREL64"] = 78] = "R_PPC64_DTPREL64";
541
- RELOC_PPC64[RELOC_PPC64["R_PPC64_GOT_TLSGD16"] = 79] = "R_PPC64_GOT_TLSGD16";
542
- RELOC_PPC64[RELOC_PPC64["R_PPC64_GOT_TLSGD16_LO"] = 80] = "R_PPC64_GOT_TLSGD16_LO";
543
- RELOC_PPC64[RELOC_PPC64["R_PPC64_GOT_TLSGD16_HI"] = 81] = "R_PPC64_GOT_TLSGD16_HI";
544
- RELOC_PPC64[RELOC_PPC64["R_PPC64_GOT_TLSGD16_HA"] = 82] = "R_PPC64_GOT_TLSGD16_HA";
545
- RELOC_PPC64[RELOC_PPC64["R_PPC64_GOT_TLSLD16"] = 83] = "R_PPC64_GOT_TLSLD16";
546
- RELOC_PPC64[RELOC_PPC64["R_PPC64_GOT_TLSLD16_LO"] = 84] = "R_PPC64_GOT_TLSLD16_LO";
547
- RELOC_PPC64[RELOC_PPC64["R_PPC64_GOT_TLSLD16_HI"] = 85] = "R_PPC64_GOT_TLSLD16_HI";
548
- RELOC_PPC64[RELOC_PPC64["R_PPC64_GOT_TLSLD16_HA"] = 86] = "R_PPC64_GOT_TLSLD16_HA";
549
- RELOC_PPC64[RELOC_PPC64["R_PPC64_GOT_TPREL16_DS"] = 87] = "R_PPC64_GOT_TPREL16_DS";
550
- RELOC_PPC64[RELOC_PPC64["R_PPC64_GOT_TPREL16_LO_DS"] = 88] = "R_PPC64_GOT_TPREL16_LO_DS";
551
- RELOC_PPC64[RELOC_PPC64["R_PPC64_GOT_TPREL16_HI"] = 89] = "R_PPC64_GOT_TPREL16_HI";
552
- RELOC_PPC64[RELOC_PPC64["R_PPC64_GOT_TPREL16_HA"] = 90] = "R_PPC64_GOT_TPREL16_HA";
553
- RELOC_PPC64[RELOC_PPC64["R_PPC64_GOT_DTPREL16_DS"] = 91] = "R_PPC64_GOT_DTPREL16_DS";
554
- RELOC_PPC64[RELOC_PPC64["R_PPC64_GOT_DTPREL16_LO_DS"] = 92] = "R_PPC64_GOT_DTPREL16_LO_DS";
555
- RELOC_PPC64[RELOC_PPC64["R_PPC64_GOT_DTPREL16_HI"] = 93] = "R_PPC64_GOT_DTPREL16_HI";
556
- RELOC_PPC64[RELOC_PPC64["R_PPC64_GOT_DTPREL16_HA"] = 94] = "R_PPC64_GOT_DTPREL16_HA";
557
- RELOC_PPC64[RELOC_PPC64["R_PPC64_TPREL16_DS"] = 95] = "R_PPC64_TPREL16_DS";
558
- RELOC_PPC64[RELOC_PPC64["R_PPC64_TPREL16_LO_DS"] = 96] = "R_PPC64_TPREL16_LO_DS";
559
- RELOC_PPC64[RELOC_PPC64["R_PPC64_TPREL16_HIGHER"] = 97] = "R_PPC64_TPREL16_HIGHER";
560
- RELOC_PPC64[RELOC_PPC64["R_PPC64_TPREL16_HIGHERA"] = 98] = "R_PPC64_TPREL16_HIGHERA";
561
- RELOC_PPC64[RELOC_PPC64["R_PPC64_TPREL16_HIGHEST"] = 99] = "R_PPC64_TPREL16_HIGHEST";
562
- RELOC_PPC64[RELOC_PPC64["R_PPC64_TPREL16_HIGHESTA"] = 100] = "R_PPC64_TPREL16_HIGHESTA";
563
- RELOC_PPC64[RELOC_PPC64["R_PPC64_DTPREL16_DS"] = 101] = "R_PPC64_DTPREL16_DS";
564
- RELOC_PPC64[RELOC_PPC64["R_PPC64_DTPREL16_LO_DS"] = 102] = "R_PPC64_DTPREL16_LO_DS";
565
- RELOC_PPC64[RELOC_PPC64["R_PPC64_DTPREL16_HIGHER"] = 103] = "R_PPC64_DTPREL16_HIGHER";
566
- RELOC_PPC64[RELOC_PPC64["R_PPC64_DTPREL16_HIGHERA"] = 104] = "R_PPC64_DTPREL16_HIGHERA";
567
- RELOC_PPC64[RELOC_PPC64["R_PPC64_DTPREL16_HIGHEST"] = 105] = "R_PPC64_DTPREL16_HIGHEST";
568
- RELOC_PPC64[RELOC_PPC64["R_PPC64_DTPREL16_HIGHESTA"] = 106] = "R_PPC64_DTPREL16_HIGHESTA";
569
- // These are GNU extensions to enable C++ vtable garbage collection.
570
- RELOC_PPC64[RELOC_PPC64["R_PPC64_GNU_VTINHERIT"] = 253] = "R_PPC64_GNU_VTINHERIT";
571
- RELOC_PPC64[RELOC_PPC64["R_PPC64_GNU_VTENTRY"] = 254] = "R_PPC64_GNU_VTENTRY";
572
- })(RELOC_PPC64 || (RELOC_PPC64 = {}));
573
- var RELOC_AMD64;
574
- (function (RELOC_AMD64) {
575
- RELOC_AMD64[RELOC_AMD64["R_AMD64_NONE"] = 0] = "R_AMD64_NONE";
576
- RELOC_AMD64[RELOC_AMD64["R_AMD64_64"] = 1] = "R_AMD64_64";
577
- RELOC_AMD64[RELOC_AMD64["R_AMD64_PC32"] = 2] = "R_AMD64_PC32";
578
- RELOC_AMD64[RELOC_AMD64["R_AMD64_GOT32"] = 3] = "R_AMD64_GOT32";
579
- RELOC_AMD64[RELOC_AMD64["R_AMD64_PLT32"] = 4] = "R_AMD64_PLT32";
580
- RELOC_AMD64[RELOC_AMD64["R_AMD64_COPY"] = 5] = "R_AMD64_COPY";
581
- RELOC_AMD64[RELOC_AMD64["R_AMD64_GLOB_DAT"] = 6] = "R_AMD64_GLOB_DAT";
582
- RELOC_AMD64[RELOC_AMD64["R_AMD64_JUMP_SLOT"] = 7] = "R_AMD64_JUMP_SLOT";
583
- RELOC_AMD64[RELOC_AMD64["R_AMD64_RELATIVE"] = 8] = "R_AMD64_RELATIVE";
584
- RELOC_AMD64[RELOC_AMD64["R_AMD64_GOTPCREL"] = 9] = "R_AMD64_GOTPCREL";
585
- RELOC_AMD64[RELOC_AMD64["R_AMD64_32"] = 10] = "R_AMD64_32";
586
- RELOC_AMD64[RELOC_AMD64["R_AMD64_32S"] = 11] = "R_AMD64_32S";
587
- RELOC_AMD64[RELOC_AMD64["R_AMD64_16"] = 12] = "R_AMD64_16";
588
- RELOC_AMD64[RELOC_AMD64["R_AMD64_PC16"] = 13] = "R_AMD64_PC16";
589
- RELOC_AMD64[RELOC_AMD64["R_AMD64_8"] = 14] = "R_AMD64_8";
590
- RELOC_AMD64[RELOC_AMD64["R_AMD64_PC8"] = 15] = "R_AMD64_PC8";
591
- // TLS relocations
592
- RELOC_AMD64[RELOC_AMD64["R_AMD64_DTPMOD64"] = 16] = "R_AMD64_DTPMOD64";
593
- RELOC_AMD64[RELOC_AMD64["R_AMD64_DTPOFF64"] = 17] = "R_AMD64_DTPOFF64";
594
- RELOC_AMD64[RELOC_AMD64["R_AMD64_TPOFF64"] = 18] = "R_AMD64_TPOFF64";
595
- RELOC_AMD64[RELOC_AMD64["R_AMD64_TLSGD"] = 19] = "R_AMD64_TLSGD";
596
- RELOC_AMD64[RELOC_AMD64["R_AMD64_TLSLD"] = 20] = "R_AMD64_TLSLD";
597
- RELOC_AMD64[RELOC_AMD64["R_AMD64_DTPOFF32"] = 21] = "R_AMD64_DTPOFF32";
598
- RELOC_AMD64[RELOC_AMD64["R_AMD64_GOTTPOFF"] = 22] = "R_AMD64_GOTTPOFF";
599
- RELOC_AMD64[RELOC_AMD64["R_AMD64_TPOFF32"] = 23] = "R_AMD64_TPOFF32";
600
- RELOC_AMD64[RELOC_AMD64["R_AMD64_PC64"] = 24] = "R_AMD64_PC64";
601
- RELOC_AMD64[RELOC_AMD64["R_AMD64_GOTOFF64"] = 25] = "R_AMD64_GOTOFF64";
602
- RELOC_AMD64[RELOC_AMD64["R_AMD64_GOTPC32"] = 26] = "R_AMD64_GOTPC32";
603
- RELOC_AMD64[RELOC_AMD64["R_AMD64_GOT64"] = 27] = "R_AMD64_GOT64";
604
- RELOC_AMD64[RELOC_AMD64["R_AMD64_GOTPCREL64"] = 28] = "R_AMD64_GOTPCREL64";
605
- RELOC_AMD64[RELOC_AMD64["R_AMD64_GOTPC64"] = 29] = "R_AMD64_GOTPC64";
606
- RELOC_AMD64[RELOC_AMD64["R_AMD64_GOTPLT64"] = 30] = "R_AMD64_GOTPLT64";
607
- RELOC_AMD64[RELOC_AMD64["R_AMD64_PLTOFF64"] = 31] = "R_AMD64_PLTOFF64";
608
- RELOC_AMD64[RELOC_AMD64["R_AMD64_SIZE32"] = 32] = "R_AMD64_SIZE32";
609
- RELOC_AMD64[RELOC_AMD64["R_AMD64_SIZE64"] = 33] = "R_AMD64_SIZE64";
610
- RELOC_AMD64[RELOC_AMD64["R_AMD64_GOTPC32_TLSDESC"] = 34] = "R_AMD64_GOTPC32_TLSDESC";
611
- RELOC_AMD64[RELOC_AMD64["R_AMD64_TLSDESC_CALL"] = 35] = "R_AMD64_TLSDESC_CALL";
612
- RELOC_AMD64[RELOC_AMD64["R_AMD64_TLSDESC"] = 36] = "R_AMD64_TLSDESC";
613
- RELOC_AMD64[RELOC_AMD64["R_AMD64_IRELATIVE"] = 37] = "R_AMD64_IRELATIVE";
614
- // GNU vtable garbage collection extensions.
615
- RELOC_AMD64[RELOC_AMD64["R_AMD64_GNU_VTINHERIT"] = 250] = "R_AMD64_GNU_VTINHERIT";
616
- RELOC_AMD64[RELOC_AMD64["R_AMD64_GNU_VTENTRY"] = 251] = "R_AMD64_GNU_VTENTRY";
617
- })(RELOC_AMD64 || (RELOC_AMD64 = {}));
618
- //-----------------------------------------------------------------------------
619
- // ELF
620
- //-----------------------------------------------------------------------------
621
- class ELFFile {
622
- segments = [];
623
- sections = [];
624
- symbols;
625
- dynamic_symbols;
626
- header;
627
- static check(data) {
628
- const x = binary.utils.decodeText(data.subarray(0, 4), 'utf8');
629
- return x == '\x7fELF';
630
- }
631
- constructor(data) {
632
- const s = new binary.stream(data);
633
- const ident = binary.read(s, Ident);
634
- if (ident.magic != binary.utils.stringCode("\x7fELF"))
635
- throw new Error('Not an ELF file');
636
- const be = ident.encoding == 'MSB';
637
- const bits = ident.file_class == 'CLASS32' ? 32 : 64;
638
- const Addr = binary.as(binary.UINT(bits, be), binary.hex);
639
- const Off = binary.UINT(bits, be);
640
- const Half = binary.UINT(16, be);
641
- const Sword = binary.INT(32, be);
642
- const Word = binary.UINT(32, be);
643
- const Xword = binary.INT(bits, be);
644
- const Sxword = binary.UINT(bits, be);
645
- const PairHalf = binary.UINT(bits == 32 ? 8 : 32, be);
646
- const Pair = be ? { top: PairHalf, bottom: PairHalf } : { bottom: PairHalf, top: PairHalf };
647
- const Ehdr = {
648
- e_type: binary.asEnum(Half, ET),
649
- e_machine: binary.asEnum(Half, EM),
650
- e_version: binary.asEnum(Word, EV),
651
- e_entry: Addr,
652
- e_phoff: Off,
653
- e_shoff: Off,
654
- e_flags: Word,
655
- e_ehsize: Half,
656
- e_phentsize: Half,
657
- e_phnum: Half,
658
- e_shentsize: Half,
659
- e_shnum: Half,
660
- e_shstrndx: Half, //section header table index of section name string table
661
- };
662
- class Phdr extends binary.ReadStruct(bits == 32 ? {
663
- p_type: binary.asEnum(Word, PT),
664
- p_offset: Off,
665
- p_vaddr: Addr,
666
- p_paddr: Addr,
667
- p_filesz: Word,
668
- p_memsz: Word,
669
- p_flags: binary.asFlags(Word, PF),
670
- p_align: Word,
671
- } : {
672
- p_type: binary.asEnum(Word, PT),
673
- p_flags: binary.asFlags(Word, PF),
674
- p_offset: Off,
675
- p_vaddr: Addr,
676
- p_paddr: Addr,
677
- p_filesz: Xword,
678
- p_memsz: Xword,
679
- p_align: Xword,
680
- }) {
681
- data;
682
- constructor(s) {
683
- super(s);
684
- const flags = (this.p_flags.R ? 1 /* binary.utils.MEM.READ */ : 0)
685
- | (this.p_flags.W ? 2 /* binary.utils.MEM.WRITE */ : 0)
686
- | (this.p_flags.X ? 4 /* binary.utils.MEM.EXECUTE */ : 0);
687
- this.data = new binary.utils.MappedMemory(s.buffer_at(Number(this.p_offset), Number(this.p_filesz)), +this.p_vaddr, flags);
688
- }
689
- }
690
- class Shdr extends binary.ReadStruct({
691
- sh_name: Word,
692
- sh_type: binary.asEnum(Word, SHT),
693
- sh_flags: binary.asFlags(Xword, SHF),
694
- sh_addr: Addr,
695
- sh_offset: Off,
696
- sh_size: Off,
697
- sh_link: Word,
698
- sh_info: Word,
699
- sh_addralign: Off,
700
- sh_entsize: Off, //size in bytes of each entry (when appropriate)
701
- }) {
702
- data;
703
- constructor(s) {
704
- super(s);
705
- const flags = 1 /* binary.utils.MEM.READ */
706
- | (this.sh_flags.WRITE ? 2 /* binary.utils.MEM.WRITE */ : 0)
707
- | (this.sh_flags.EXECINSTR ? 4 /* binary.utils.MEM.EXECUTE */ : 0);
708
- this.data = new binary.utils.MappedMemory(s.buffer_at(Number(this.sh_offset), Number(this.sh_size)), +this.sh_addr, flags);
709
- }
710
- }
711
- const Sym = bits === 32 ? {
712
- st_name: Word,
713
- st_value: Addr,
714
- st_size: Word,
715
- st_info: binary.as(binary.UINT8, ST_INFO),
716
- st_other: binary.as(binary.UINT8, ST_OTHER),
717
- st_shndx: binary.asEnum(Half, SHN), //section header table index
718
- } : {
719
- st_name: Word,
720
- st_info: binary.as(binary.UINT8, ST_INFO),
721
- st_other: binary.as(binary.UINT8, ST_OTHER),
722
- st_shndx: binary.asEnum(Half, SHN),
723
- st_value: Addr,
724
- st_size: Off,
725
- };
726
- const Dyn = {
727
- d_tag: Sxword,
728
- //union {
729
- d_val: Xword,
730
- // d_ptr: Addr,
731
- //} d_un;
732
- };
733
- const Rel = {
734
- r_offset: Addr,
735
- r_info: Pair,
736
- };
737
- const Rela = {
738
- ...Rel,
739
- r_addend: Sxword,
740
- };
741
- const h = binary.read(s, Ehdr);
742
- this.header = h;
743
- s.seek(Number(h.e_phoff));
744
- const ph = Array.from({ length: h.e_phnum }, () => new Phdr(s));
745
- s.seek(Number(h.e_shoff));
746
- const sh = Array.from({ length: h.e_shnum }, () => new Shdr(s));
747
- //set segment names
748
- for (const i of ph)
749
- this.segments.push([`${i.p_type} @ 0x${i.p_offset.toString(16)}`, i]);
750
- //set section names
751
- const shnames = sh[h.e_shstrndx].data.data;
752
- for (const i of sh) {
753
- const name = binary.utils.decodeTextTo0(shnames.subarray(i.sh_name), 'utf8');
754
- this.sections.push([name, i]);
755
- }
756
- for (const i of sh) {
757
- switch (i.sh_type) {
758
- case 'SYMTAB':
759
- this.symbols = this.getSymbols(Sym, i.data.data, sh[i.sh_link].data.data);
760
- break;
761
- case 'DYNSYM':
762
- this.dynamic_symbols = this.getSymbols(Sym, i.data.data, sh[i.sh_link].data.data);
763
- break;
764
- }
765
- }
766
- }
767
- getSymbols(type, data, names) {
768
- const syms = binary.RemainingArrayType(type).get(new binary.stream(data));
769
- return syms.filter(sym => sym.st_name).map(sym => {
770
- if (+sym.st_shndx) {
771
- const section = this.sections[+sym.st_shndx][1];
772
- const offset = sym.st_value - section.sh_addr;
773
- const flags = sym.st_info.type === 'FUNC' ? section.data.flags : section.data.flags & ~4 /* binary.utils.MEM.EXECUTE */;
774
- sym.data = new binary.utils.MappedMemory(section.data.data.subarray(offset, offset + sym.st_size), sym.st_value, flags);
775
- }
776
- return [binary.utils.decodeTextTo0(names.subarray(sym.st_name), 'utf8'), sym];
777
- });
778
- }
779
- }
780
- exports.ELFFile = ELFFile;
781
- /*
782
- export function load(data: Uint8Array) {
783
- const s = new binary.stream(data);
784
- const ident = binary.read(s, Ident);
785
- if (ident.magic == utils.stringCode("\x7fELF")) {
786
- const be = ident.encoding == 'MSB';
787
- const bits = ident.file_class == 'CLASS32' ? 32 : 64;
788
- return new ELFFile(data, bits, be);
789
- }
790
- }
791
- */