Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-3517 fix golang rtti structure field logic for 1.19+

dev747368fbf99ebb6e16
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/golang/rtti/types/GoStructField.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/golang/rtti/types/GoStructField.java
index 1d6b21466d..7abd1c0198 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/golang/rtti/types/GoStructField.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/golang/rtti/types/GoStructField.java
@@ -39,8 +39,11 @@ public class GoStructField {
@MarkupReference("type")
private long typ; // direct ptr to GoType
- @FieldMapping(fieldName = { "offsetAnon" /* <=1.18*/, "offset" /* >=1.19 */ })
- private long offset; // offset >> 1 == actual offset, bit 0 = embedded
+ @FieldMapping(optional = true) //<=1.18
+ private long offsetAnon; // offsetAnon >> 1 == actual offset, bit 0 = embedded flag
+
+ @FieldMapping(optional = true) //>=1.19
+ private long offset;
@Markup
public GoName getName() throws IOException {
@@ -54,14 +57,19 @@ public class GoStructField {
return programContext.getGoType(typ);
}
- public long getOffset() {
- return offset >> 1;
+ public void setOffsetAnon(long offsetAnon) {
+ this.offsetAnon = offsetAnon;
+ this.offset = offsetAnon >> 1;
}
- public boolean isEmbedded() {
- return (offset & 0x1) != 0;
+ public long getOffset() {
+ return offset;
}
+// public boolean isEmbedded() {
+// return (offsetAnon & 0x1) != 0;
+// }
+
public String getNameString() throws IOException {
GoName n = getName();
return n != null ? n.getName() : null;