mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-09-28 17:11:11 -09:00
Merge remote-tracking branch 'origin/patch'
This commit is contained in:
@@ -4,9 +4,9 @@
|
|||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
@@ -181,7 +181,8 @@ public class ElfRelocationContext<H extends ElfRelocationHandler> {
|
|||||||
* Get a relocation context for a specfic Elf image and relocation table
|
* Get a relocation context for a specfic Elf image and relocation table
|
||||||
* @param loadHelper Elf load helper
|
* @param loadHelper Elf load helper
|
||||||
* @param symbolMap Elf symbol placement map
|
* @param symbolMap Elf symbol placement map
|
||||||
* @return relocation context object
|
* @return relocation context object. A generic context will be returned if a custom one
|
||||||
|
* is not defined.
|
||||||
*/
|
*/
|
||||||
public static ElfRelocationContext<?> getRelocationContext(ElfLoadHelper loadHelper,
|
public static ElfRelocationContext<?> getRelocationContext(ElfLoadHelper loadHelper,
|
||||||
Map<ElfSymbol, Address> symbolMap) {
|
Map<ElfSymbol, Address> symbolMap) {
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
@@ -164,7 +164,7 @@ public class PEx64UnwindInfoDataType extends DynamicDataType {
|
|||||||
|
|
||||||
private static EnumDataType unwindInfoFlagsEnum;
|
private static EnumDataType unwindInfoFlagsEnum;
|
||||||
|
|
||||||
private EnumDataType defineUnwindInfoFlags() {
|
private synchronized EnumDataType defineUnwindInfoFlags() {
|
||||||
if (unwindInfoFlagsEnum == null) {
|
if (unwindInfoFlagsEnum == null) {
|
||||||
unwindInfoFlagsEnum = new EnumDataType("UNW_FLAGS", 1);
|
unwindInfoFlagsEnum = new EnumDataType("UNW_FLAGS", 1);
|
||||||
unwindInfoFlagsEnum.add("UNW_FLAG_NHANDLER", PEx64UnwindInfo.UNW_FLAG_NHANDLER);
|
unwindInfoFlagsEnum.add("UNW_FLAG_NHANDLER", PEx64UnwindInfo.UNW_FLAG_NHANDLER);
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
@@ -879,7 +879,8 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {
|
|||||||
}
|
}
|
||||||
monitor.initialize(totalCount);
|
monitor.initialize(totalCount);
|
||||||
|
|
||||||
ElfRelocationContext<?> context = ElfRelocationContext.getRelocationContext(this, symbolMap);
|
ElfRelocationContext<?> context =
|
||||||
|
ElfRelocationContext.getRelocationContext(this, symbolMap);
|
||||||
try {
|
try {
|
||||||
for (ElfRelocationTable relocationTable : relocationTables) {
|
for (ElfRelocationTable relocationTable : relocationTables) {
|
||||||
monitor.checkCancelled();
|
monitor.checkCancelled();
|
||||||
@@ -887,9 +888,7 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
if (context != null) {
|
context.dispose();
|
||||||
context.dispose();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -956,9 +955,9 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {
|
|||||||
ElfRelocationContext<?> context, AddressSpace relocationSpace, long baseWordOffset,
|
ElfRelocationContext<?> context, AddressSpace relocationSpace, long baseWordOffset,
|
||||||
TaskMonitor monitor) throws CancelledException {
|
TaskMonitor monitor) throws CancelledException {
|
||||||
|
|
||||||
if (context != null) {
|
boolean processRelocations = ElfLoaderOptionsFactory.performRelocations(options);
|
||||||
context.startRelocationTableProcessing(relocationTable);
|
|
||||||
}
|
context.startRelocationTableProcessing(relocationTable);
|
||||||
|
|
||||||
ElfSymbolTable symbolTable = relocationTable.getAssociatedSymbolTable();
|
ElfSymbolTable symbolTable = relocationTable.getAssociatedSymbolTable();
|
||||||
ElfRelocation[] relocs = relocationTable.getRelocations();
|
ElfRelocation[] relocs = relocationTable.getRelocations();
|
||||||
@@ -977,7 +976,7 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {
|
|||||||
|
|
||||||
boolean relrTypeUnknown = false;
|
boolean relrTypeUnknown = false;
|
||||||
int relrRelocationType = 0;
|
int relrRelocationType = 0;
|
||||||
if (relocationTable.isRelrTable() && context != null) {
|
if (relocationTable.isRelrTable()) {
|
||||||
relrRelocationType = context.getRelrRelocationType();
|
relrRelocationType = context.getRelrRelocationType();
|
||||||
if (relrRelocationType == 0) {
|
if (relrRelocationType == 0) {
|
||||||
relrTypeUnknown = true;
|
relrTypeUnknown = true;
|
||||||
@@ -991,8 +990,8 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {
|
|||||||
monitor.incrementProgress(1);
|
monitor.incrementProgress(1);
|
||||||
|
|
||||||
int type = reloc.getType();
|
int type = reloc.getType();
|
||||||
if (type == 0) {
|
if (type == 0 && !relocationTable.isRelrTable()) {
|
||||||
continue; // ignore relocation type 0 (i.e., ..._NONE)
|
continue; // ignore relocation type 0 if not a RELR table (i.e., ..._NONE)
|
||||||
}
|
}
|
||||||
|
|
||||||
int symbolIndex = reloc.getSymbolIndex();
|
int symbolIndex = reloc.getSymbolIndex();
|
||||||
@@ -1004,9 +1003,7 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {
|
|||||||
Address baseAddress = relocationSpace.getTruncatedAddress(baseWordOffset, true);
|
Address baseAddress = relocationSpace.getTruncatedAddress(baseWordOffset, true);
|
||||||
|
|
||||||
// relocation offset (r_offset) is defined to be a byte offset (assume byte size is 1)
|
// relocation offset (r_offset) is defined to be a byte offset (assume byte size is 1)
|
||||||
Address relocAddr =
|
Address relocAddr = context.getRelocationAddress(baseAddress, reloc.getOffset());
|
||||||
context != null ? context.getRelocationAddress(baseAddress, reloc.getOffset())
|
|
||||||
: baseAddress.addWrap(reloc.getOffset());
|
|
||||||
|
|
||||||
long[] values = new long[] { reloc.getSymbolIndex() };
|
long[] values = new long[] { reloc.getSymbolIndex() };
|
||||||
|
|
||||||
@@ -1018,6 +1015,11 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {
|
|||||||
Status status = Status.SKIPPED;
|
Status status = Status.SKIPPED;
|
||||||
int byteLength = 0;
|
int byteLength = 0;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
if (!processRelocations) {
|
||||||
|
continue; // skip and record relocation
|
||||||
|
}
|
||||||
|
|
||||||
if (unableToApplyRelocs) {
|
if (unableToApplyRelocs) {
|
||||||
status = Status.FAILURE;
|
status = Status.FAILURE;
|
||||||
context.markRelocationError(relocAddr, type, symbolIndex, symbolName,
|
context.markRelocationError(relocAddr, type, symbolIndex, symbolName,
|
||||||
@@ -1044,17 +1046,15 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context != null) {
|
if (relrTypeUnknown) {
|
||||||
if (relrTypeUnknown) {
|
status = Status.UNSUPPORTED;
|
||||||
status = Status.UNSUPPORTED;
|
ElfRelocationHandler.bookmarkUnsupportedRelr(program, relocAddr, symbolIndex,
|
||||||
ElfRelocationHandler.bookmarkUnsupportedRelr(program, relocAddr,
|
symbolName);
|
||||||
symbolIndex, symbolName);
|
}
|
||||||
}
|
else {
|
||||||
else {
|
RelocationResult result = context.processRelocation(reloc, relocAddr);
|
||||||
RelocationResult result = context.processRelocation(reloc, relocAddr);
|
byteLength = result.byteLength();
|
||||||
byteLength = result.byteLength();
|
status = result.status();
|
||||||
status = result.status();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (MemoryAccessException e) {
|
catch (MemoryAccessException e) {
|
||||||
@@ -1072,9 +1072,7 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context != null) {
|
context.endRelocationTableProcessing();
|
||||||
context.endRelocationTableProcessing();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
@@ -130,6 +130,7 @@ public class EnumDataType extends GenericDataType implements Enum {
|
|||||||
List<String> names = new ArrayList<>();
|
List<String> names = new ArrayList<>();
|
||||||
Collection<List<String>> values = valueMap.values();
|
Collection<List<String>> values = valueMap.values();
|
||||||
for (List<String> list : values) {
|
for (List<String> list : values) {
|
||||||
|
list = new ArrayList<>(list);
|
||||||
Collections.sort(list);
|
Collections.sort(list);
|
||||||
names.addAll(list);
|
names.addAll(list);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user