return NULL;
 }
 
-static void codegen_btf_dump_printf(void *ct, const char *fmt, va_list args)
+static void codegen_btf_dump_printf(void *ctx, const char *fmt, va_list args)
 {
        vprintf(fmt, args);
 }
        int i, err, off = 0, pad_cnt = 0, vlen = btf_vlen(sec);
        const char *sec_ident;
        char var_ident[256];
+       bool strip_mods = false;
 
-       if (strcmp(sec_name, ".data") == 0)
+       if (strcmp(sec_name, ".data") == 0) {
                sec_ident = "data";
-       else if (strcmp(sec_name, ".bss") == 0)
+       } else if (strcmp(sec_name, ".bss") == 0) {
                sec_ident = "bss";
-       else if (strcmp(sec_name, ".rodata") == 0)
+       } else if (strcmp(sec_name, ".rodata") == 0) {
                sec_ident = "rodata";
-       else if (strcmp(sec_name, ".kconfig") == 0)
+               strip_mods = true;
+       } else if (strcmp(sec_name, ".kconfig") == 0) {
                sec_ident = "kconfig";
-       else
+       } else {
                return 0;
+       }
 
        printf("        struct %s__%s {\n", obj_name, sec_ident);
        for (i = 0; i < vlen; i++, sec_var++) {
                DECLARE_LIBBPF_OPTS(btf_dump_emit_type_decl_opts, opts,
                        .field_name = var_ident,
                        .indent_level = 2,
+                       .strip_mods = strip_mods,
                );
                int need_off = sec_var->offset, align_off, align;
                __u32 var_type_id = var->type;
-               const struct btf_type *t;
-
-               t = btf__type_by_id(btf, var_type_id);
-               while (btf_is_mod(t)) {
-                       var_type_id = t->type;
-                       t = btf__type_by_id(btf, var_type_id);
-               }
 
                if (off > need_off) {
                        p_err("Something is wrong for %s's variable #%d: need offset %d, already at %d.\n",
 
        /* strip all the const/volatile/restrict mods */
        bool strip_mods;
 };
-#define btf_dump_emit_type_decl_opts__last_field indent_level
+#define btf_dump_emit_type_decl_opts__last_field strip_mods
 
 LIBBPF_API int
 btf_dump__emit_type_decl(struct btf_dump *d, __u32 id,
 
        CHECK(bss->in4 != 0, "in4", "got %lld != exp %lld\n", bss->in4, 0LL);
        CHECK(bss->out4 != 0, "out4", "got %lld != exp %lld\n", bss->out4, 0LL);
 
-       CHECK(rodata->in6 != 0, "in6", "got %d != exp %d\n", rodata->in6, 0);
+       CHECK(rodata->in.in6 != 0, "in6", "got %d != exp %d\n", rodata->in.in6, 0);
        CHECK(bss->out6 != 0, "out6", "got %d != exp %d\n", bss->out6, 0);
 
        /* validate we can pre-setup global variables, even in .bss */
        data->in2 = 11;
        bss->in3 = 12;
        bss->in4 = 13;
-       rodata->in6 = 14;
+       rodata->in.in6 = 14;
 
        err = test_skeleton__load(skel);
        if (CHECK(err, "skel_load", "failed to load skeleton: %d\n", err))
        CHECK(data->in2 != 11, "in2", "got %lld != exp %lld\n", data->in2, 11LL);
        CHECK(bss->in3 != 12, "in3", "got %d != exp %d\n", bss->in3, 12);
        CHECK(bss->in4 != 13, "in4", "got %lld != exp %lld\n", bss->in4, 13LL);
-       CHECK(rodata->in6 != 14, "in6", "got %d != exp %d\n", rodata->in6, 14);
+       CHECK(rodata->in.in6 != 14, "in6", "got %d != exp %d\n", rodata->in.in6, 14);
 
        /* now set new values and attach to get them into outX variables */
        data->in1 = 1;
 
 struct s in5 = {};
 
 /* .rodata section */
-const volatile int in6 = 0;
+const volatile struct {
+       const int in6;
+} in = {};
 
 /* .data section */
 int out1 = -1;
        out3 = in3;
        out4 = in4;
        out5 = in5;
-       out6 = in6;
+       out6 = in.in6;
 
        bpf_syscall = CONFIG_BPF_SYSCALL;
        kern_ver = LINUX_KERNEL_VERSION;