-
Notifications
You must be signed in to change notification settings - Fork 2
/
1349-COFF-i960.patch
383 lines (342 loc) · 17 KB
/
1349-COFF-i960.patch
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: mumbel <22204578+mumbel@users.noreply.github.com>
Date: Mon, 16 Dec 2019 19:12:40 -0600
Subject: [PATCH] 1349: COFF i960
Revert "COFF i960"
Initial factory for COFF
---
.../formats/CoffBinaryAnalysisCommand.java | 6 +++---
.../util/bin/format/coff/CoffConstants.java | 4 ++++
.../util/bin/format/coff/CoffFileHeader.java | 8 ++++++++
.../util/bin/format/coff/CoffLineNumber.java | 8 +++++---
.../bin/format/coff/CoffSectionHeader.java | 8 ++++++++
.../app/util/bin/format/coff/CoffSymbol.java | 19 +++++++++++--------
.../bin/format/coff/CoffSymbolAuxArray.java | 19 +++++++++++--------
.../coff/CoffSymbolAuxBeginningOfBlock.java | 13 ++++++++-----
.../bin/format/coff/CoffSymbolAuxDefault.java | 5 ++++-
.../format/coff/CoffSymbolAuxEndOfBlock.java | 9 ++++++---
.../format/coff/CoffSymbolAuxEndOfStruct.java | 11 +++++++----
.../format/coff/CoffSymbolAuxFilename.java | 7 +++++--
.../format/coff/CoffSymbolAuxFunction.java | 13 ++++++++-----
.../bin/format/coff/CoffSymbolAuxName.java | 11 +++++++----
.../bin/format/coff/CoffSymbolAuxSection.java | 11 +++++++----
.../bin/format/coff/CoffSymbolAuxTagName.java | 13 ++++++++-----
16 files changed, 110 insertions(+), 55 deletions(-)
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/formats/CoffBinaryAnalysisCommand.java b/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/formats/CoffBinaryAnalysisCommand.java
index c6208604bc..29d4db5cc6 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/formats/CoffBinaryAnalysisCommand.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/formats/CoffBinaryAnalysisCommand.java
@@ -147,7 +147,7 @@ public class CoffBinaryAnalysisCommand extends FlatProgramAPI
private void processStrings(CoffFileHeader header) throws Exception {
monitor.setMessage("Processing strings...");
Address start = toAddr(header.getSymbolTablePointer() +
- (header.getSymbolTableEntries() * CoffConstants.SYMBOL_SIZEOF));
+ header.getSymbolTableLength());
Address address = start;
createData(address, new DWordDataType());
createLabel(address, "Number_of_strings", true);
@@ -165,7 +165,7 @@ public class CoffBinaryAnalysisCommand extends FlatProgramAPI
private void processSymbols(CoffFileHeader header) throws Exception {
monitor.setMessage("Processing symbols...");
Address start = toAddr(header.getSymbolTablePointer());
- long length = header.getSymbolTableEntries() * CoffConstants.SYMBOL_SIZEOF;
+ long length = header.getSymbolTableLength();
Address address = start;
List<CoffSymbol> symbols = header.getSymbols();
for (int i = 0; i < symbols.size(); ++i) {
@@ -226,7 +226,7 @@ public class CoffBinaryAnalysisCommand extends FlatProgramAPI
return;
}
Address start = toAddr(section.getPointerToLineNumbers());
- long length = section.getLineNumberCount() * CoffLineNumber.SIZEOF;
+ long length = section.getLineNumberLength();
Address address = start;
List<CoffLineNumber> lineNumbers = section.getLineNumbers();
for (CoffLineNumber lineNumber : lineNumbers) {
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffConstants.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffConstants.java
index 6b2de0598e..b8ce54487d 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffConstants.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffConstants.java
@@ -38,4 +38,8 @@ public class CoffConstants {
* Number of dimensions of a symbol's auxiliary array.
*/
public final static int AUXILIARY_ARRAY_DIMENSION = 4;
+ /**
+ * Length (in bytes0 of a Line Number
+ */
+ public final static int LINENO_SIZEOF = 6;
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffFileHeader.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffFileHeader.java
index 166a22f32a..32b581c866 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffFileHeader.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffFileHeader.java
@@ -105,6 +105,14 @@ public class CoffFileHeader implements StructConverter {
return f_nsyms;
}
+ /**
+ * Returns the length of symbols in the symbol table.
+ * @return the length of symbols in the symbol table
+ */
+ public int getSymbolTableLength() {
+ return f_nsyms * CoffConstants.SYMBOL_SIZEOF;
+ }
+
/**
* Returns the size in bytes of the optional header.
* The optional header immediately follows the file header
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffLineNumber.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffLineNumber.java
index 9f5d36e3de..2a4ad0de4c 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffLineNumber.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffLineNumber.java
@@ -23,10 +23,12 @@ import ghidra.util.exception.DuplicateNameException;
import java.io.IOException;
public class CoffLineNumber implements StructConverter {
- public final static int SIZEOF = 4 + 2;
- private int l_addr; // address of line number
- private short l_lnno; // line number
+ protected int l_addr; // address of line number
+ protected short l_lnno; // line number
+
+ protected CoffLineNumber() {
+ }
CoffLineNumber(BinaryReader reader) throws IOException {
l_addr = reader.readNextInt();
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSectionHeader.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSectionHeader.java
index fb00d9b5c2..a4c69b0b44 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSectionHeader.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSectionHeader.java
@@ -212,6 +212,14 @@ public class CoffSectionHeader implements StructConverter {
return s_nlnno;
}
+ /**
+ * Returns the length of line number entries for this section.
+ * @return the length of line number entries for this section
+ */
+ public int getLineNumberLength() {
+ return s_nlnno * CoffConstants.LINENO_SIZEOF;
+ }
+
/**
* Returns the flags for this section.
* @return the flags for this section
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSymbol.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSymbol.java
index f0196a1eb3..e1919e8dae 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSymbol.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSymbol.java
@@ -24,14 +24,17 @@ import java.util.ArrayList;
import java.util.List;
public class CoffSymbol implements StructConverter {
- private String e_name;
- private int e_value;
- private short e_scnum;
- private short e_type;
- private byte e_sclass;
- private byte e_numaux;
-
- private List<CoffSymbolAux> _auxiliarySymbols = new ArrayList<CoffSymbolAux>();
+ protected String e_name;
+ protected int e_value;
+ protected short e_scnum;
+ protected int e_type;
+ protected byte e_sclass;
+ protected byte e_numaux;
+
+ protected List<CoffSymbolAux> _auxiliarySymbols = new ArrayList<CoffSymbolAux>();
+
+ protected CoffSymbol() {
+ }
CoffSymbol(BinaryReader reader, CoffFileHeader header) throws IOException {
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSymbolAuxArray.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSymbolAuxArray.java
index af12322318..ca38a160b1 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSymbolAuxArray.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSymbolAuxArray.java
@@ -25,14 +25,17 @@ import java.io.IOException;
public class CoffSymbolAuxArray implements CoffSymbolAux {
- private int tagIndex;
- private short lineNumber;
- private short arraySize;
- private short firstDimension;
- private short secondDimension;
- private short thirdDimension;
- private short fourthDimension;
- private byte [] unused;
+ protected int tagIndex;
+ protected short lineNumber;
+ protected short arraySize;
+ protected short firstDimension;
+ protected short secondDimension;
+ protected short thirdDimension;
+ protected short fourthDimension;
+ protected byte [] unused;
+
+ protected CoffSymbolAuxArray() {
+ }
CoffSymbolAuxArray(BinaryReader reader) throws IOException {
tagIndex = reader.readNextInt();
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSymbolAuxBeginningOfBlock.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSymbolAuxBeginningOfBlock.java
index 0e5508687f..b6faf0d86f 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSymbolAuxBeginningOfBlock.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSymbolAuxBeginningOfBlock.java
@@ -24,11 +24,14 @@ import ghidra.util.exception.DuplicateNameException;
public class CoffSymbolAuxBeginningOfBlock implements CoffSymbolAux {
- private byte [] unused1;
- private short sourceLineNumber;
- private byte [] unused2;
- private int nextEntryIndex;
- private byte [] unused3;
+ protected byte [] unused1;
+ protected short sourceLineNumber;
+ protected byte [] unused2;
+ protected int nextEntryIndex;
+ protected byte [] unused3;
+
+ protected CoffSymbolAuxBeginningOfBlock() {
+ }
CoffSymbolAuxBeginningOfBlock(BinaryReader reader) throws IOException {
unused1 = reader.readNextByteArray(4);
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSymbolAuxDefault.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSymbolAuxDefault.java
index f15761f234..05e0b87150 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSymbolAuxDefault.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSymbolAuxDefault.java
@@ -25,7 +25,10 @@ import java.io.IOException;
class CoffSymbolAuxDefault implements CoffSymbolAux {
- private byte [] bytes;
+ protected byte [] bytes;
+
+ protected CoffSymbolAuxDefault() {
+ }
CoffSymbolAuxDefault(BinaryReader reader) throws IOException {
bytes = reader.readNextByteArray(CoffConstants.SYMBOL_SIZEOF);
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSymbolAuxEndOfBlock.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSymbolAuxEndOfBlock.java
index 9d33401651..bdb302c201 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSymbolAuxEndOfBlock.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSymbolAuxEndOfBlock.java
@@ -25,9 +25,12 @@ import java.io.IOException;
public class CoffSymbolAuxEndOfBlock implements CoffSymbolAux {
- private byte [] unused1;
- private short sourceLineNumber;
- private byte [] unused2;
+ protected byte [] unused1;
+ protected short sourceLineNumber;
+ protected byte [] unused2;
+
+ protected CoffSymbolAuxEndOfBlock() {
+ }
CoffSymbolAuxEndOfBlock(BinaryReader reader) throws IOException {
unused1 = reader.readNextByteArray(4);
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSymbolAuxEndOfStruct.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSymbolAuxEndOfStruct.java
index db00e61ca5..be4ce8dde6 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSymbolAuxEndOfStruct.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSymbolAuxEndOfStruct.java
@@ -25,10 +25,13 @@ import java.io.IOException;
public class CoffSymbolAuxEndOfStruct implements CoffSymbolAux {
- private int tagIndex;
- private byte [] unused1;
- private short size; //of structure, union, or enumeration
- private byte [] unused2;
+ protected int tagIndex;
+ protected byte [] unused1;
+ protected short size; //of structure, union, or enumeration
+ protected byte [] unused2;
+
+ protected CoffSymbolAuxEndOfStruct() {
+ }
CoffSymbolAuxEndOfStruct(BinaryReader reader) throws IOException {
tagIndex = reader.readNextInt();
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSymbolAuxFilename.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSymbolAuxFilename.java
index f9979f11bd..2e1061db9c 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSymbolAuxFilename.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSymbolAuxFilename.java
@@ -25,8 +25,11 @@ import ghidra.util.exception.DuplicateNameException;
public class CoffSymbolAuxFilename implements CoffSymbolAux {
- private byte [] filename;
- private byte [] unused;
+ protected byte [] filename;
+ protected byte [] unused;
+
+ protected CoffSymbolAuxFilename() {
+ }
CoffSymbolAuxFilename(BinaryReader reader) throws IOException {
filename = reader.readNextByteArray(CoffConstants.FILE_NAME_LENGTH);
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSymbolAuxFunction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSymbolAuxFunction.java
index 31c3dda098..4e3aa24de9 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSymbolAuxFunction.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSymbolAuxFunction.java
@@ -25,11 +25,14 @@ import java.io.IOException;
public class CoffSymbolAuxFunction implements CoffSymbolAux {
- private int tagIndex;
- private int size;
- private int filePointerToLineNumber;
- private int nextEntryIndex;
- private byte [] unused;
+ protected int tagIndex;
+ protected int size;
+ protected int filePointerToLineNumber;
+ protected int nextEntryIndex;
+ protected byte [] unused;
+
+ protected CoffSymbolAuxFunction() {
+ }
CoffSymbolAuxFunction(BinaryReader reader) throws IOException {
tagIndex = reader.readNextInt();
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSymbolAuxName.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSymbolAuxName.java
index 9dbe2b928b..6576c7b031 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSymbolAuxName.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSymbolAuxName.java
@@ -25,10 +25,13 @@ import java.io.IOException;
public class CoffSymbolAuxName implements CoffSymbolAux {
- private int tagIndex;
- private byte [] unused1;
- private short size;
- private byte [] unused2;
+ protected int tagIndex;
+ protected byte [] unused1;
+ protected short size;
+ protected byte [] unused2;
+
+ protected CoffSymbolAuxName() {
+ }
CoffSymbolAuxName(BinaryReader reader) throws IOException {
tagIndex = reader.readNextInt();
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSymbolAuxSection.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSymbolAuxSection.java
index 441b381a3e..8f9681af27 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSymbolAuxSection.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSymbolAuxSection.java
@@ -25,10 +25,13 @@ import java.io.IOException;
public class CoffSymbolAuxSection implements CoffSymbolAux {
- private int sectionLength;
- private short relocationCount;
- private short lineNumberCount;
- private byte [] unused;
+ protected int sectionLength;
+ protected short relocationCount;
+ protected short lineNumberCount;
+ protected byte [] unused;
+
+ protected CoffSymbolAuxSection() {
+ }
CoffSymbolAuxSection(BinaryReader reader) throws IOException {
sectionLength = reader.readNextInt();
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSymbolAuxTagName.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSymbolAuxTagName.java
index f9bac67a3e..2a972ed644 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSymbolAuxTagName.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSymbolAuxTagName.java
@@ -25,11 +25,14 @@ import java.io.IOException;
public class CoffSymbolAuxTagName implements CoffSymbolAux {
- private byte [] unused1;
- private short size;
- private byte [] unused2;
- private int nextEntryIndex;
- private byte [] unused3;
+ protected byte [] unused1;
+ protected short size;
+ protected byte [] unused2;
+ protected int nextEntryIndex;
+ protected byte [] unused3;
+
+ protected CoffSymbolAuxTagName() {
+ }
CoffSymbolAuxTagName(BinaryReader reader) throws IOException {
unused1 = reader.readNextByteArray(6);
--
2.45.1