@@ -744,6 +744,14 @@ static int btf_elf__write(const char *filename, struct btf *btf)
goto out;
}
+ /*
+ * We'll align .BTF to 8 bytes to cater for all architectures. It'd be
+ * nice if we could fetch this value from somewhere. The BTF
+ * specification does not discuss alignment and its trailing string
+ * table is not currently padded to any particular alignment.
+ */
+ const size_t btf_alignment = 8;
+
/*
* First we check if there is already a .BTF section present.
*/
@@ -821,6 +829,7 @@ static int btf_elf__write(const char *filename, struct btf *btf)
elf_error("elf_getshdr(btf_scn) failed");
goto out;
}
+ btf_shdr.sh_addralign = btf_alignment;
btf_shdr.sh_entsize = 0;
btf_shdr.sh_flags = 0;
if (dot_btf_offset)