From 07e46fbc2bd7ff8782c975596672e4e3d3891865 Mon Sep 17 00:00:00 2001 From: Florent Revest Date: Thu, 28 Nov 2024 01:49:47 +0100 Subject: pkg/compiler: handle string syscall attributes --- pkg/compiler/gen.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'pkg/compiler/gen.go') diff --git a/pkg/compiler/gen.go b/pkg/compiler/gen.go index a6fd938a9..fb803875a 100644 --- a/pkg/compiler/gen.go +++ b/pkg/compiler/gen.go @@ -132,8 +132,8 @@ func (comp *compiler) genSyscall(n *ast.Call, argSizes []uint64) *prog.Syscall { ret = comp.genType(n.Ret, comp.ptrSize) } var attrs prog.SyscallAttrs - descAttrs := comp.parseIntAttrs(callAttrs, n, n.Attrs) - for desc, val := range descAttrs { + intAttrs, _, stringAttrs := comp.parseAttrs(callAttrs, n, n.Attrs) + for desc, val := range intAttrs { fld := reflect.ValueOf(&attrs).Elem().FieldByName(desc.Name) switch desc.Type { case intAttr: @@ -144,6 +144,15 @@ func (comp *compiler) genSyscall(n *ast.Call, argSizes []uint64) *prog.Syscall { panic(fmt.Sprintf("unexpected attrDesc type: %q", desc.Type)) } } + for desc, val := range stringAttrs { + fld := reflect.ValueOf(&attrs).Elem().FieldByName(desc.Name) + switch desc.Type { + case stringAttr: + fld.SetString(val) + default: + panic(fmt.Sprintf("unexpected attrDesc type: %q", desc.Type)) + } + } fields, _ := comp.genFieldArray(n.Args, argSizes) return &prog.Syscall{ Name: n.Name.Name, @@ -513,7 +522,7 @@ func (comp *compiler) genFieldDir(attrs map[*attrDesc]uint64) (prog.Dir, bool) { } func (comp *compiler) genField(f *ast.Field, argSize uint64, overlayDir prog.Dir) prog.Field { - intAttrs, exprAttrs := comp.parseAttrs(structFieldAttrs, f, f.Attrs) + intAttrs, exprAttrs, _ := comp.parseAttrs(structFieldAttrs, f, f.Attrs) dir, hasDir := overlayDir, true if overlayDir == prog.DirInOut { dir, hasDir = comp.genFieldDir(intAttrs) -- cgit mrf-deployment