-
static volatile const struct config CFG;
#define cfg (&CFG)
// 将配置写入到 bpf 程序中
if err := bpfSpecClone.RewriteConstants(map[string]interface{}{
"CFG": traceConfig,
}); err != nil {
log.Fatalf("Failed to rewrite config: %v", err)
}
F1205 17:36:24.336716 215397 log.go:130] Failed to rewrite config: rewrite constants: some constants are missing from .rodata: CFG
cd ./cmd;CGO_ENABLED=1 GOOS=linux GOARCH=amd64 CGO_LDFLAGS='-g -lcapstone -static' go build -gcflags "all=-N -l" -v -o nfs-trace |
Beta Was this translation helpful? Give feedback.
Answered by
ti-mo
Dec 10, 2024
Replies: 1 comment
-
I understand this may be a breaking change, but this was unavoidable as RewriteConstants didn't take object visibility into account in the past (it allowed rewriting local vars). With VariableSpec in fhe picture, we now follow the same rules as libbpf. Please see https://ebpf-go.dev/concepts/global-variables/#static-global-variables for more info. Also, in the future, please create issues for reporting regressions, Discussions are more for Q&A. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
ti-mo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I understand this may be a breaking change, but this was unavoidable as RewriteConstants didn't take object visibility into account in the past (it allowed rewriting local vars). With VariableSpec in fhe picture, we now follow the same rules as libbpf.
Please see https://ebpf-go.dev/concepts/global-variables/#static-global-variables for more info.
Also, in the future, please create issues for reporting regressions, Discussions are more for Q&A.