diff options
| author | Florent Revest <revest@chromium.org> | 2024-11-28 01:49:47 +0100 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2024-12-09 18:35:48 +0000 |
| commit | 07e46fbc2bd7ff8782c975596672e4e3d3891865 (patch) | |
| tree | e5b5faf3f3225f930127716f3242b31b667dd36d /pkg/compiler/gen.go | |
| parent | 9ac0fdc66500475f1914254ef369b32d51adbff9 (diff) | |
pkg/compiler: handle string syscall attributes
Diffstat (limited to 'pkg/compiler/gen.go')
| -rw-r--r-- | pkg/compiler/gen.go | 15 |
1 files changed, 12 insertions, 3 deletions
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) |
