mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-30 14:41:07 +08:00
Merge remote-tracking branch 'origin/GP-3197_dev747368_markup_elfnotes_fix--SQUASHED'
This commit is contained in:
+4
-3
@@ -23,8 +23,9 @@ import java.io.IOException;
|
|||||||
import ghidra.app.util.bin.BinaryReader;
|
import ghidra.app.util.bin.BinaryReader;
|
||||||
import ghidra.framework.options.Options;
|
import ghidra.framework.options.Options;
|
||||||
import ghidra.program.model.address.Address;
|
import ghidra.program.model.address.Address;
|
||||||
|
import ghidra.program.model.data.DataUtilities;
|
||||||
|
import ghidra.program.model.data.DataUtilities.ClearDataMode;
|
||||||
import ghidra.program.model.data.StringUTF8DataType;
|
import ghidra.program.model.data.StringUTF8DataType;
|
||||||
import ghidra.program.model.listing.Listing;
|
|
||||||
import ghidra.program.model.listing.Program;
|
import ghidra.program.model.listing.Program;
|
||||||
import ghidra.program.model.symbol.SourceType;
|
import ghidra.program.model.symbol.SourceType;
|
||||||
import ghidra.program.model.symbol.SymbolTable;
|
import ghidra.program.model.symbol.SymbolTable;
|
||||||
@@ -93,7 +94,6 @@ public class ElfComment implements ElfInfoItem {
|
|||||||
public void markupProgram(Program program, Address address) {
|
public void markupProgram(Program program, Address address) {
|
||||||
try {
|
try {
|
||||||
Options progInfo = program.getOptions(Program.PROGRAM_INFO);
|
Options progInfo = program.getOptions(Program.PROGRAM_INFO);
|
||||||
Listing listing = program.getListing();
|
|
||||||
SymbolTable symTable = program.getSymbolTable();
|
SymbolTable symTable = program.getSymbolTable();
|
||||||
|
|
||||||
for (int commentNum = 0; commentNum < commentStrings.size(); commentNum++) {
|
for (int commentNum = 0; commentNum < commentStrings.size(); commentNum++) {
|
||||||
@@ -103,7 +103,8 @@ public class ElfComment implements ElfInfoItem {
|
|||||||
progInfo.setString("Elf Comment[%d]".formatted(commentNum), commentStr);
|
progInfo.setString("Elf Comment[%d]".formatted(commentNum), commentStr);
|
||||||
symTable.createLabel(address, "ElfComment[%d]".formatted(commentNum),
|
symTable.createLabel(address, "ElfComment[%d]".formatted(commentNum),
|
||||||
SourceType.IMPORTED);
|
SourceType.IMPORTED);
|
||||||
listing.createData(address, StringUTF8DataType.dataType, strLen);
|
DataUtilities.createData(program, address, StringUTF8DataType.dataType, strLen,
|
||||||
|
false, ClearDataMode.CLEAR_ALL_UNDEFINED_CONFLICT_DATA);
|
||||||
address = address.addWrap(strLen); // need to allow wrap so we don't error when hitting end-of-section
|
address = address.addWrap(strLen); // need to allow wrap so we don't error when hitting end-of-section
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import ghidra.app.util.bin.*;
|
|||||||
import ghidra.framework.options.Options;
|
import ghidra.framework.options.Options;
|
||||||
import ghidra.program.model.address.Address;
|
import ghidra.program.model.address.Address;
|
||||||
import ghidra.program.model.data.*;
|
import ghidra.program.model.data.*;
|
||||||
|
import ghidra.program.model.data.DataUtilities.ClearDataMode;
|
||||||
import ghidra.program.model.listing.Program;
|
import ghidra.program.model.listing.Program;
|
||||||
import ghidra.program.model.util.CodeUnitInsertionException;
|
import ghidra.program.model.util.CodeUnitInsertionException;
|
||||||
import ghidra.util.Msg;
|
import ghidra.util.Msg;
|
||||||
@@ -240,7 +241,8 @@ public class ElfNote implements ElfInfoItem {
|
|||||||
StructureDataType dt = toStructure(program.getDataTypeManager());
|
StructureDataType dt = toStructure(program.getDataTypeManager());
|
||||||
if (dt != null) {
|
if (dt != null) {
|
||||||
try {
|
try {
|
||||||
program.getListing().createData(address, dt);
|
DataUtilities.createData(program, address, dt, -1, false,
|
||||||
|
ClearDataMode.CLEAR_ALL_UNDEFINED_CONFLICT_DATA);
|
||||||
}
|
}
|
||||||
catch (CodeUnitInsertionException e) {
|
catch (CodeUnitInsertionException e) {
|
||||||
Msg.error(this, "Failed to markup Elf Note at %s: %s".formatted(address, this), e);
|
Msg.error(this, "Failed to markup Elf Note at %s: %s".formatted(address, this), e);
|
||||||
|
|||||||
+3
-1
@@ -22,6 +22,7 @@ import java.io.IOException;
|
|||||||
import ghidra.app.util.bin.BinaryReader;
|
import ghidra.app.util.bin.BinaryReader;
|
||||||
import ghidra.program.model.address.Address;
|
import ghidra.program.model.address.Address;
|
||||||
import ghidra.program.model.data.*;
|
import ghidra.program.model.data.*;
|
||||||
|
import ghidra.program.model.data.DataUtilities.ClearDataMode;
|
||||||
import ghidra.program.model.listing.Program;
|
import ghidra.program.model.listing.Program;
|
||||||
import ghidra.program.model.util.CodeUnitInsertionException;
|
import ghidra.program.model.util.CodeUnitInsertionException;
|
||||||
import ghidra.util.Msg;
|
import ghidra.util.Msg;
|
||||||
@@ -98,7 +99,8 @@ public class GnuDebugLink implements ElfInfoItem {
|
|||||||
try {
|
try {
|
||||||
StructureDataType struct = toStructure(program.getDataTypeManager());
|
StructureDataType struct = toStructure(program.getDataTypeManager());
|
||||||
if (struct != null) {
|
if (struct != null) {
|
||||||
program.getListing().createData(address, struct);
|
DataUtilities.createData(program, address, struct, -1, false,
|
||||||
|
ClearDataMode.CLEAR_ALL_UNDEFINED_CONFLICT_DATA);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (CodeUnitInsertionException e) {
|
catch (CodeUnitInsertionException e) {
|
||||||
|
|||||||
+5
-2
@@ -25,6 +25,7 @@ import ghidra.app.util.bin.StructConverter;
|
|||||||
import ghidra.framework.options.Options;
|
import ghidra.framework.options.Options;
|
||||||
import ghidra.program.model.address.Address;
|
import ghidra.program.model.address.Address;
|
||||||
import ghidra.program.model.data.*;
|
import ghidra.program.model.data.*;
|
||||||
|
import ghidra.program.model.data.DataUtilities.ClearDataMode;
|
||||||
import ghidra.program.model.listing.*;
|
import ghidra.program.model.listing.*;
|
||||||
import ghidra.program.model.util.CodeUnitInsertionException;
|
import ghidra.program.model.util.CodeUnitInsertionException;
|
||||||
import ghidra.util.Msg;
|
import ghidra.util.Msg;
|
||||||
@@ -180,12 +181,14 @@ public class NoteGnuProperty extends ElfNote {
|
|||||||
StructureDataType struct =
|
StructureDataType struct =
|
||||||
createNoteStructure(null, "NoteGnuProperty_%d".formatted(getNameLen()), false,
|
createNoteStructure(null, "NoteGnuProperty_%d".formatted(getNameLen()), false,
|
||||||
getNameLen(), 0, program.getDataTypeManager());
|
getNameLen(), 0, program.getDataTypeManager());
|
||||||
Data propData = listing.createData(address, struct);
|
Data propData = DataUtilities.createData(program, address, struct, -1, false,
|
||||||
|
ClearDataMode.CLEAR_ALL_UNDEFINED_CONFLICT_DATA);
|
||||||
address = propData.getMaxAddress().next();
|
address = propData.getMaxAddress().next();
|
||||||
|
|
||||||
for (NotePropertyElement element : elements) {
|
for (NotePropertyElement element : elements) {
|
||||||
DataType elementDT = getElementDataType(dtm, element);
|
DataType elementDT = getElementDataType(dtm, element);
|
||||||
Data elementData = listing.createData(address, elementDT);
|
Data elementData = DataUtilities.createData(program, address, elementDT, -1, false,
|
||||||
|
ClearDataMode.CLEAR_ALL_UNDEFINED_CONFLICT_DATA);
|
||||||
listing.setComment(address, CodeUnit.EOL_COMMENT,
|
listing.setComment(address, CodeUnit.EOL_COMMENT,
|
||||||
element.typeName() + "=" + element.value());
|
element.typeName() + "=" + element.value());
|
||||||
address = elementData.getMaxAddress().next();
|
address = elementData.getMaxAddress().next();
|
||||||
|
|||||||
+4
-3
@@ -24,8 +24,8 @@ import ghidra.app.util.bin.*;
|
|||||||
import ghidra.app.util.bin.format.elf.*;
|
import ghidra.app.util.bin.format.elf.*;
|
||||||
import ghidra.app.util.bin.format.elf.info.ElfInfoItem.ReaderFunc;
|
import ghidra.app.util.bin.format.elf.info.ElfInfoItem.ReaderFunc;
|
||||||
import ghidra.program.model.address.Address;
|
import ghidra.program.model.address.Address;
|
||||||
import ghidra.program.model.data.CategoryPath;
|
import ghidra.program.model.data.*;
|
||||||
import ghidra.program.model.data.StructureDataType;
|
import ghidra.program.model.data.DataUtilities.ClearDataMode;
|
||||||
import ghidra.program.model.listing.CodeUnit;
|
import ghidra.program.model.listing.CodeUnit;
|
||||||
import ghidra.program.model.listing.Program;
|
import ghidra.program.model.listing.Program;
|
||||||
import ghidra.program.model.mem.Memory;
|
import ghidra.program.model.mem.Memory;
|
||||||
@@ -107,7 +107,8 @@ public class StandardElfInfoProducer implements ElfInfoProducer {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
StructureDataType struct = note.toStructure(program.getDataTypeManager());
|
StructureDataType struct = note.toStructure(program.getDataTypeManager());
|
||||||
program.getListing().createData(addr, struct);
|
DataUtilities.createData(program, addr, struct, -1, false,
|
||||||
|
ClearDataMode.CLEAR_ALL_UNDEFINED_CONFLICT_DATA);
|
||||||
String comment =
|
String comment =
|
||||||
"ELF Note \"%s\", %xh".formatted(note.getName(), note.getVendorType());
|
"ELF Note \"%s\", %xh".formatted(note.getName(), note.getVendorType());
|
||||||
program.getListing().setComment(addr, CodeUnit.EOL_COMMENT, comment);
|
program.getListing().setComment(addr, CodeUnit.EOL_COMMENT, comment);
|
||||||
|
|||||||
Reference in New Issue
Block a user