Skip to contentSkip to conversation

tools/resolve_btfids: Fix build error with older host toolchain

PATCH In review Kun-Chuan Hsieh 2 participants 2 messages Feb 20, 2021 – Feb 22, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/resolve_btfids: Fix build error with older host toolchain

Older verions of libelf cannot recognize the compressed section.

However, it's only required to fix the compressed section info when compiling with CONFIG_DEBUG_INFO_COMPRESSED flag is set. Only compile the compressed_section_fix function when necessary will make it easier to enable the BTF function. Since the tool resolve_btfids is compiled with host toolchain.
The host toolchain might be older than the cross compile toolchain.

Cc stable <[email protected]>
---
 tools/bpf/resolve_btfids/main.c | 4 ++++
 1 file changed, 4 insertions(+)
tools/bpf/resolve_btfids/main.c +4 -0
index 7409d7860aa6..ad40346c6631 100644
@@ -260,6 +260,7 @@ static struct btf_id *add_symbol(struct rb_root *root, char *name, size_t size)
 	return btf_id__add(root, id, false);
 }
 
+#ifdef CONFIG_DEBUG_INFO_COMPRESSED
 /*
  * The data of compressed section should be aligned to 4
  * (for 32bit) or 8 (for 64 bit) bytes. The binutils ld
@@ -292,6 +293,7 @@ static int compressed_section_fix(Elf *elf, Elf_Scn *scn, GElf_Shdr *sh)
 	}
 	return 0;
 }
+#endif
 
 static int elf_collect(struct object *obj)
 {
@@ -370,8 +372,10 @@ static int elf_collect(struct object *obj)
 			obj->efile.idlist_addr  = sh.sh_addr;
 		}
 
+#ifdef CONFIG_DEBUG_INFO_COMPRESSED
 		if (compressed_section_fix(elf, scn, &sh))
 			return -1;
+#endif
 	}
 
 	return 0;
Signature · 1 line
2.25.1
#1 lore raw
Quoted 2 lines · Kun-Chuan Hsieh

Older verions of libelf cannot recognize the compressed section.

typo above.

Please resend cc-ing bpf@vger, Jiri, Andrii.

Quoted 46 lines

However, it's only required to fix the compressed section info when compiling with CONFIG_DEBUG_INFO_COMPRESSED flag is set. Only compile the compressed_section_fix function when necessary will make it easier to enable the BTF function. Since the tool resolve_btfids is compiled with host toolchain.
The host toolchain might be older than the cross compile toolchain.

Cc stable <[email protected]>
---
 tools/bpf/resolve_btfids/main.c | 4 ++++
 1 file changed, 4 insertions(+)
tools/bpf/resolve_btfids/main.c +4 -1
index 7409d7860aa6..ad40346c6631 100644
@@ -260,6 +260,7 @@ static struct btf_id *add_symbol(struct rb_root *root, char *name, size_t size)
        return btf_id__add(root, id, false);
 }
 
+#ifdef CONFIG_DEBUG_INFO_COMPRESSED
 /*
  * The data of compressed section should be aligned to 4
  * (for 32bit) or 8 (for 64 bit) bytes. The binutils ld
@@ -292,6 +293,7 @@ static int compressed_section_fix(Elf *elf, Elf_Scn *scn, GElf_Shdr *sh)
        }
        return 0;
 }
+#endif
 
 static int elf_collect(struct object *obj)
 {
@@ -370,8 +372,10 @@ static int elf_collect(struct object *obj)
                        obj->efile.idlist_addr  = sh.sh_addr;
                }
 
+#ifdef CONFIG_DEBUG_INFO_COMPRESSED
                if (compressed_section_fix(elf, scn, &sh))
                        return -1;
+#endif
        }
 
        return 0;
--

2.25.1