Skip to content

Commit 433fd0a

Browse files
Support version 10.1
1 parent e77446f commit 433fd0a

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

src/main/java/golanganalyzerextension/FunctionModifier.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import ghidra.program.model.address.Address;
99
import ghidra.program.model.data.DataType;
1010
import ghidra.program.model.data.PointerDataType;
11+
import ghidra.program.model.data.VoidDataType;
1112
import ghidra.program.model.lang.Register;
1213
import ghidra.program.model.listing.Function;
1314
import ghidra.program.model.listing.Instruction;
@@ -543,7 +544,7 @@ void modify_func_param(GolangFunction gofunc) {
543544

544545
try {
545546
func.updateFunction(null, null, new_params, FunctionUpdateType.CUSTOM_STORAGE, true, SourceType.USER_DEFINED);
546-
func.setReturnType(DataType.VOID, SourceType.USER_DEFINED);
547+
func.setReturnType(new VoidDataType(), SourceType.USER_DEFINED);
547548
}catch(Exception e) {
548549
append_message(String.format("Failed to set function parameters: %s", e.getMessage()));
549550
}

src/main/java/golanganalyzerextension/StructureManager.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class ChanTypeInfo extends BasicTypeInfo {
129129
public DataType get_datatype() {
130130
// runtime/chan.go
131131
StructureDataType hchan_datatype=new StructureDataType(name, 0);
132-
hchan_datatype.setMinimumAlignment(pointer_size);
132+
hchan_datatype.setExplicitMinimumAlignment(pointer_size);
133133
hchan_datatype.add(get_datatype_by_name("uint"), "qcount", "");
134134
hchan_datatype.add(get_datatype_by_name("uint"), "dataqsiz", "");
135135
hchan_datatype.add(get_datatype_by_name("unsafe.Pointer"), "buf", "");
@@ -171,7 +171,7 @@ class InterfaceTypeInfo extends BasicTypeInfo {
171171
public DataType get_datatype() {
172172
// runtime/iface.go
173173
StructureDataType interface_datatype=new StructureDataType(name, 0);
174-
interface_datatype.setMinimumAlignment(pointer_size);
174+
interface_datatype.setExplicitMinimumAlignment(pointer_size);
175175
interface_datatype.add(new PointerDataType(get_datatype_by_name("_type")), "tab", "");
176176
interface_datatype.add(new PointerDataType(), "data", "");
177177
return interface_datatype;
@@ -188,7 +188,7 @@ class MapTypeInfo extends BasicTypeInfo {
188188
public DataType get_datatype() {
189189
// runtime/map.go
190190
StructureDataType hmap_datatype=new StructureDataType(name, 0);
191-
hmap_datatype.setMinimumAlignment(pointer_size);
191+
hmap_datatype.setExplicitMinimumAlignment(pointer_size);
192192
hmap_datatype.add(get_datatype_by_name("int"), "count", "");
193193
hmap_datatype.add(get_datatype_by_name("uint8"), "flags", "");
194194
hmap_datatype.add(get_datatype_by_name("uint8"), "B", "");
@@ -242,7 +242,7 @@ public DataType get_datatype(boolean once) {
242242
}
243243
// cmd/cgo/out.go
244244
StructureDataType slice_datatype=new StructureDataType(name, 0);
245-
slice_datatype.setMinimumAlignment(pointer_size);
245+
slice_datatype.setExplicitMinimumAlignment(pointer_size);
246246
slice_datatype.add(new PointerDataType(inner_datatype, pointer_size), "__values", null);
247247
slice_datatype.add(get_datatype_by_name("uintptr"), "__count", null);
248248
slice_datatype.add(get_datatype_by_name("uintptr"), "__capacity", null);
@@ -263,7 +263,7 @@ class StructTypeInfo extends BasicTypeInfo {
263263
}
264264
public DataType get_datatype() {
265265
StructureDataType structure_datatype=new StructureDataType(name, 0);
266-
structure_datatype.setMinimumAlignment(field_alignment);
266+
structure_datatype.setExplicitMinimumAlignment(field_alignment);
267267
for(int i=0;i<field_name_list.size();i++) {
268268
long field_key=field_type_key_list.get(i);
269269
DataType field_datatype=new PointerDataType(new VoidDataType(), field_alignment);
@@ -353,7 +353,7 @@ DataType get_datatype_by_name(String name) {
353353
boolean init_basig_golang_hardcode_datatype() {
354354
// reflect/type.go
355355
StructureDataType _type_datatype=new StructureDataType("_type", 0);
356-
_type_datatype.setMinimumAlignment(pointer_size);
356+
_type_datatype.setExplicitMinimumAlignment(pointer_size);
357357
_type_datatype.add(new PointerDataType(), "size", "");
358358
_type_datatype.add(new PointerDataType(), "ptrdata", "");
359359
_type_datatype.add(new UnsignedIntegerDataType(), "hash", "");
@@ -369,14 +369,14 @@ boolean init_basig_golang_hardcode_datatype() {
369369

370370
// runtime/chan.go
371371
StructureDataType waitq_datatype=new StructureDataType("waitq", 0);
372-
waitq_datatype.setMinimumAlignment(pointer_size);
372+
waitq_datatype.setExplicitMinimumAlignment(pointer_size);
373373
waitq_datatype.add(new PointerDataType(), "first", "");
374374
waitq_datatype.add(new PointerDataType(), "last", "");
375375
hardcode_datatype_map.put("waitq", waitq_datatype);
376376

377377
// runtime/runtime2.go
378378
StructureDataType mutex_datatype=new StructureDataType("mutex", 0);
379-
mutex_datatype.setMinimumAlignment(pointer_size);
379+
mutex_datatype.setExplicitMinimumAlignment(pointer_size);
380380
// lockRankStruct
381381
mutex_datatype.add(new PointerDataType(), "key", "");
382382
hardcode_datatype_map.put("mutex", mutex_datatype);
@@ -638,13 +638,13 @@ boolean analyze_type(Address type_base_addr, long offset, boolean is_go16) {
638638
basic_type_info_map.replace(offset, new OtherTypeInfo(basic_info, new Float8DataType()));
639639
}else if(basic_info.kind==Kind.Complex64) {
640640
StructureDataType complex64_datatype=new StructureDataType("complex64", 0);
641-
complex64_datatype.setMinimumAlignment(basic_info.align);
641+
complex64_datatype.setExplicitMinimumAlignment(basic_info.align);
642642
complex64_datatype.add(new Float4DataType(), "re", null);
643643
complex64_datatype.add(new Float4DataType(), "im", null);
644644
basic_type_info_map.replace(offset, new OtherTypeInfo(basic_info, complex64_datatype));
645645
}else if(basic_info.kind==Kind.Complex128) {
646646
StructureDataType complex128_datatype=new StructureDataType("complex128", 0);
647-
complex128_datatype.setMinimumAlignment(basic_info.align);
647+
complex128_datatype.setExplicitMinimumAlignment(basic_info.align);
648648
complex128_datatype.add(new Float8DataType(), "re", null);
649649
complex128_datatype.add(new Float8DataType(), "im", null);
650650
basic_type_info_map.replace(offset, new OtherTypeInfo(basic_info, complex128_datatype));
@@ -736,7 +736,7 @@ boolean analyze_type(Address type_base_addr, long offset, boolean is_go16) {
736736
basic_type_info_map.replace(offset, new SliceTypeInfo(basic_info, elem_addr_value-type_base_addr.getOffset()));
737737
}else if(basic_info.kind==Kind.String) {
738738
StructureDataType string_datatype=new StructureDataType("string", 0);
739-
string_datatype.setMinimumAlignment(basic_info.align);
739+
string_datatype.setExplicitMinimumAlignment(basic_info.align);
740740
string_datatype.add(new PointerDataType(new StringDataType(), pointer_size), "__data", null);
741741
string_datatype.add(new IntegerDataType(), "__length", null);
742742
basic_type_info_map.replace(offset, new OtherTypeInfo(basic_info, string_datatype));

0 commit comments

Comments
 (0)