diff --git a/src/cc/libbpf.c b/src/cc/libbpf.c index f72a1249a831..cd2dee45af6d 100644 --- a/src/cc/libbpf.c +++ b/src/cc/libbpf.c @@ -344,6 +344,14 @@ static void bpf_print_hints(int ret, char *log) "you'll need to be explicit.\n\n"); } + // referencing global/static variables or read only data + if (strstr(log, "unknown opcode") != NULL) { + fprintf(stderr, "HINT: The 'unknown opcode' can happen if you reference" + "a global or static variable, or data in read only section. For example," + "'char *p = \"hello\"' will result in p referencing a read only section," + " and 'char p[] = \"hello\"' will have \"hello\" stored on the stack.\n\n"); + } + // helper function not found in kernel char *helper_str = strstr(log, "invalid func "); if (helper_str != NULL) {