From 7de7a5ecf43a5c41b5170d0cb70cb744fdf9de9f Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Tue, 26 Nov 2024 11:36:41 +0100 Subject: pkg/compiler: allow manual consts to override auto-extracted consts Currently if const values in 2 .const files have different value, the compiler produces an error. This is problematic for auto-extacted consts since we extract them for only 1 arch now. So if a const has different values for different arches, auto-extacted consts may not reflect that, and we can get a mismatch with manual descriptions that has correct values for all arches. So if both manual and auto-extacted consts have different values, silently prefer the manual ones. I've tried to do some whitelisting of consts during auto-extaction, but the list is large and changing over time. This solution is not perfect since the manual descriptions may have a bug, and the mismatch is actually pointing to that bug. Maybe in future we could extract for all arches separately, or do something else. But let's do this for now. --- pkg/compiler/testdata/auto.txt | 4 ++++ pkg/compiler/testdata/auto.txt.const | 6 ++++++ pkg/compiler/testdata/auto0.txt | 4 ++++ pkg/compiler/testdata/auto0.txt.const | 6 ++++++ 4 files changed, 20 insertions(+) create mode 100644 pkg/compiler/testdata/auto.txt create mode 100644 pkg/compiler/testdata/auto.txt.const create mode 100644 pkg/compiler/testdata/auto0.txt create mode 100644 pkg/compiler/testdata/auto0.txt.const (limited to 'pkg/compiler/testdata') diff --git a/pkg/compiler/testdata/auto.txt b/pkg/compiler/testdata/auto.txt new file mode 100644 index 000000000..1e64e0a95 --- /dev/null +++ b/pkg/compiler/testdata/auto.txt @@ -0,0 +1,4 @@ +# Copyright 2024 syzkaller project authors. All rights reserved. +# Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. + +foo(a const[FOO]) diff --git a/pkg/compiler/testdata/auto.txt.const b/pkg/compiler/testdata/auto.txt.const new file mode 100644 index 000000000..388aa936f --- /dev/null +++ b/pkg/compiler/testdata/auto.txt.const @@ -0,0 +1,6 @@ +# Copyright 2024 syzkaller project authors. All rights reserved. +# Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. + +arches = 64 +SYS_foo = 11 +FOO = 22 diff --git a/pkg/compiler/testdata/auto0.txt b/pkg/compiler/testdata/auto0.txt new file mode 100644 index 000000000..9c3608caf --- /dev/null +++ b/pkg/compiler/testdata/auto0.txt @@ -0,0 +1,4 @@ +# Copyright 2024 syzkaller project authors. All rights reserved. +# Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. + +foo$auto(a const[FOO]) diff --git a/pkg/compiler/testdata/auto0.txt.const b/pkg/compiler/testdata/auto0.txt.const new file mode 100644 index 000000000..4ba494b07 --- /dev/null +++ b/pkg/compiler/testdata/auto0.txt.const @@ -0,0 +1,6 @@ +# Copyright 2024 syzkaller project authors. All rights reserved. +# Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. + +arches = 64 +SYS_foo = 1 +FOO = 2 -- cgit mrf-deployment