mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
Merge remote-tracking branch 'origin/GP-3175_dev747368_dwarf_apple_silicon_kdk'
This commit is contained in:
commit
9594431f09
8 changed files with 57 additions and 5 deletions
|
@ -431,6 +431,27 @@ public class DIEAggregate {
|
||||||
return getRef(DWARFAttribute.DW_AT_type);
|
return getRef(DWARFAttribute.DW_AT_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the name of the source file this item was declared in (DW_AT_decl_file)
|
||||||
|
*
|
||||||
|
* @return name of file this item was declared in, or null if info not available
|
||||||
|
*/
|
||||||
|
public String getSourceFile() {
|
||||||
|
AttrInfo attrInfo = findAttribute(DWARFAttribute.DW_AT_decl_file);
|
||||||
|
if (attrInfo == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
DWARFNumericAttribute attr = attrInfo.getValue(DWARFNumericAttribute.class);
|
||||||
|
if (attr == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
int fileNum = (int) attr.getUnsignedValue();
|
||||||
|
DWARFCompileUnit dcu = attrInfo.die.getCompilationUnit().getCompileUnit();
|
||||||
|
return dcu.isValidFileIndex(fileNum)
|
||||||
|
? dcu.getFileByIndex(fileNum)
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a list of children that are of a specific DWARF type.
|
* Return a list of children that are of a specific DWARF type.
|
||||||
* <p>
|
* <p>
|
||||||
|
|
|
@ -144,6 +144,16 @@ public class DWARFCompileUnit {
|
||||||
return this.line.getFile(index, this.comp_dir);
|
return this.line.getFile(index, this.comp_dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks validity of a file index number.
|
||||||
|
*
|
||||||
|
* @param index file number, 1..N
|
||||||
|
* @return boolean true if index is a valid file number, false otherwise
|
||||||
|
*/
|
||||||
|
public boolean isValidFileIndex(int index) {
|
||||||
|
return line.isValidFileIndex(index);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the producer of the compile unit
|
* Get the producer of the compile unit
|
||||||
* @return the producer of the compile unit
|
* @return the producer of the compile unit
|
||||||
|
|
|
@ -190,6 +190,17 @@ public class DWARFLine {
|
||||||
"Negative file index was given: " + Integer.toString(index));
|
"Negative file index was given: " + Integer.toString(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if file exists.
|
||||||
|
*
|
||||||
|
* @param index file number, excluding 0
|
||||||
|
* @return boolean true if file exists
|
||||||
|
*/
|
||||||
|
public boolean isValidFileIndex(int index) {
|
||||||
|
index--;
|
||||||
|
return 0 <= index && index < file_names.size();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
|
|
@ -157,6 +157,14 @@ public final class DWARFAttribute {
|
||||||
public static final int DW_AT_GNU_pubtypes = 0x2135;
|
public static final int DW_AT_GNU_pubtypes = 0x2135;
|
||||||
// end GNU DebugFission
|
// end GNU DebugFission
|
||||||
|
|
||||||
|
// Apple proprietary tags
|
||||||
|
public static final int DW_AT_APPLE_ptrauth_key = 0x3e04;
|
||||||
|
public static final int DW_AT_APPLE_ptrauth_address_discriminated = 0x3e05;
|
||||||
|
public static final int DW_AT_APPLE_ptrauth_extra_discriminator = 0x3e06;
|
||||||
|
public static final int DW_AT_APPLE_omit_frame_ptr = 0x3fe7;
|
||||||
|
public static final int DW_AT_APPLE_optimized = 0x3fe1;
|
||||||
|
// end Apple proprietary tags
|
||||||
|
|
||||||
public static String toString(long value) {
|
public static String toString(long value) {
|
||||||
return DWARFUtil.toString(DWARFAttribute.class, value);
|
return DWARFUtil.toString(DWARFAttribute.class, value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,4 +98,6 @@ public final class DWARFTag
|
||||||
public static final int DW_TAG_gnu_call_site_parameter = 0x410a;
|
public static final int DW_TAG_gnu_call_site_parameter = 0x410a;
|
||||||
public static final int DW_TAG_hi_user = 0xffff;
|
public static final int DW_TAG_hi_user = 0xffff;
|
||||||
|
|
||||||
|
public static final int DW_TAG_APPLE_ptrauth_type = 0x4300; // Apple proprietary
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,6 +175,7 @@ public class DWARFDataTypeImporter {
|
||||||
case DWARFTag.DW_TAG_volatile_type:
|
case DWARFTag.DW_TAG_volatile_type:
|
||||||
case DWARFTag.DW_TAG_restrict_type:
|
case DWARFTag.DW_TAG_restrict_type:
|
||||||
case DWARFTag.DW_TAG_shared_type:
|
case DWARFTag.DW_TAG_shared_type:
|
||||||
|
case DWARFTag.DW_TAG_APPLE_ptrauth_type:
|
||||||
result = makeDataTypeForConst(diea);
|
result = makeDataTypeForConst(diea);
|
||||||
break;
|
break;
|
||||||
case DWARFTag.DW_TAG_enumeration_type:
|
case DWARFTag.DW_TAG_enumeration_type:
|
||||||
|
|
|
@ -34,12 +34,11 @@ public class DWARFSourceInfo {
|
||||||
* @return new {@link DWARFSourceInfo} with filename:linenum info, or null if no info present in DIEA.
|
* @return new {@link DWARFSourceInfo} with filename:linenum info, or null if no info present in DIEA.
|
||||||
*/
|
*/
|
||||||
public static DWARFSourceInfo create(DIEAggregate diea) {
|
public static DWARFSourceInfo create(DIEAggregate diea) {
|
||||||
int fileNum = (int) diea.getUnsignedLong(DWARFAttribute.DW_AT_decl_file, -1);
|
String file = diea.getSourceFile();
|
||||||
int lineNum = (int) diea.getUnsignedLong(DWARFAttribute.DW_AT_decl_line, -1);
|
int lineNum = (int) diea.getUnsignedLong(DWARFAttribute.DW_AT_decl_line, -1);
|
||||||
|
|
||||||
return (fileNum != -1 && lineNum != -1)
|
return (file != null && lineNum != -1)
|
||||||
? new DWARFSourceInfo(
|
? new DWARFSourceInfo(file, lineNum)
|
||||||
diea.getCompilationUnit().getCompileUnit().getFileByIndex(fileNum), lineNum)
|
|
||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -285,7 +285,7 @@ public class DataTypeUtilities {
|
||||||
DataType dataType2) {
|
DataType dataType2) {
|
||||||
if (dataType1 instanceof BuiltIn) {
|
if (dataType1 instanceof BuiltIn) {
|
||||||
// Same kind if both types share a common BuiltIn implementation
|
// Same kind if both types share a common BuiltIn implementation
|
||||||
Class<?> baseClass = dataType1.getClass().getSuperclass();
|
Class<?> baseClass = dataType1.getClass();
|
||||||
Class<?> superClass;
|
Class<?> superClass;
|
||||||
while ((superClass = baseClass.getSuperclass()) != BuiltIn.class) {
|
while ((superClass = baseClass.getSuperclass()) != BuiltIn.class) {
|
||||||
baseClass = superClass;
|
baseClass = superClass;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue