Skip to contentSkip to conversation

dwarf_loader: Sync with LINUX_ELFNOTE_LTO_INFO macro from kernel

PATCH In review Sedat Dilek 2 participants 2 messages Jan 20, 2023 BPF

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dwarf_loader: Sync with LINUX_ELFNOTE_LTO_INFO macro from kernel

As long as I am using CONFIG_DEBUG_INFO_BTF=y with LLVM/Clang I have noticed the below macros where defined unconsistently.

See here pahole latest Git...

[ pahole:dwarf_loader ]

/* Match the define in linux:include/linux/elfnote.h */
#define LINUX_ELFNOTE_BUILD_LTO 0x101

...and latest Linus v6.2-rc4+ Git:

[ linux:include/linux/elfnote-lto.h ]

#define LINUX_ELFNOTE_LTO_INFO 0x101

Yonghong Song says:

Quoted 3 lines

Ya, LINUX_ELFNOTE_BUILD_LTO is initially proposed macro name but later the formal kernel patch used LINUX_ELFNOTE_LTO_INFO. Could you submit a pahole for this so it is consistent with kernel? Thanks!

Fix this by syncing the pahole macro with the one from linux-kernel.

---
 dwarf_loader.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
dwarf_loader.c +3 -3
index 5a74035c5708..96ce5db4f5bc 100644
@@ -2808,8 +2808,8 @@ static int __cus__load_debug_types(struct conf_load *conf, Dwfl_Module *mod, Dwa
 	return 0;
 }
 
-/* Match the define in linux:include/linux/elfnote.h */
-#define LINUX_ELFNOTE_BUILD_LTO		0x101
+/* Match the define in linux:include/linux/elfnote-lto.h */
+#define LINUX_ELFNOTE_LTO_INFO		0x101
 
 static bool cus__merging_cu(Dwarf *dw, Elf *elf)
 {
@@ -2827,7 +2827,7 @@ static bool cus__merging_cu(Dwarf *dw, Elf *elf)
 			size_t name_off, desc_off, offset = 0;
 			GElf_Nhdr hdr;
 			while ((offset = gelf_getnote(data, offset, &hdr, &name_off, &desc_off)) != 0) {
-				if (hdr.n_type != LINUX_ELFNOTE_BUILD_LTO)
+				if (hdr.n_type != LINUX_ELFNOTE_LTO_INFO)
 					continue;
 
 				/* owner is Linux */
Signature · 1 line
2.39.0
Acked-by on v1 1/1
#1 lore raw
Quoted 17 lines · Sedat Dilek

As long as I am using CONFIG_DEBUG_INFO_BTF=y with LLVM/Clang I have noticed the below macros where defined unconsistently.

See here pahole latest Git...

[ pahole:dwarf_loader ]

/* Match the define in linux:include/linux/elfnote.h */
#define LINUX_ELFNOTE_BUILD_LTO 0x101

...and latest Linus v6.2-rc4+ Git:

[ linux:include/linux/elfnote-lto.h ]

#define LINUX_ELFNOTE_LTO_INFO 0x101

Yonghong Song says:

Quoted 8 lines
Quoted 3 lines

Ya, LINUX_ELFNOTE_BUILD_LTO is initially proposed macro name but later the formal kernel patch used LINUX_ELFNOTE_LTO_INFO. Could you submit a pahole for this so it is consistent with kernel? Thanks!

Fix this by syncing the pahole macro with the one from linux-kernel.

Thanks!