Skip to contentSkip to conversation

tools/resolve_btfids: Fix build error with older host toolchains

PATCH Applied Kun-Chuan Hsieh 3 participants 3 messages Feb 24, 2021

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

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

Older libelf.h and glibc elf.h might not yet define the ELF compression types.

Checking and defining SHF_COMPRESSED fix the build error when compiling with older toolchains. Also, the tool resolve_btfids is compiled with host toolchain. The host toolchain is more likely to be older than the cross compile toolchain.

---
 tools/bpf/resolve_btfids/main.c | 5 +++++
 1 file changed, 5 insertions(+)
tools/bpf/resolve_btfids/main.c +5 -0
index 7409d7860aa6..80d966cfcaa1 100644
@@ -260,6 +260,11 @@ static struct btf_id *add_symbol(struct rb_root *root, char *name, size_t size)
 	return btf_id__add(root, id, false);
 }
 
+/* Older libelf.h and glibc elf.h might not yet define the ELF compression types. */
+#ifndef SHF_COMPRESSED
+#define SHF_COMPRESSED (1 << 11) /* Section with compressed data. */
+#endif
+
 /*
  * The data of compressed section should be aligned to 4
  * (for 32bit) or 8 (for 64 bit) bytes. The binutils ld
Signature · 1 line
2.25.1
Acked-by on v2 1/1
#1 lore raw
Quoted 11 lines · Kun-Chuan Hsieh

Older libelf.h and glibc elf.h might not yet define the ELF compression types.

Checking and defining SHF_COMPRESSED fix the build error when compiling with older toolchains. Also, the tool resolve_btfids is compiled with host toolchain. The host toolchain is more likely to be older than the cross compile toolchain.

thanks,
jirka

Quoted 23 lines
---
 tools/bpf/resolve_btfids/main.c | 5 +++++
 1 file changed, 5 insertions(+)
tools/bpf/resolve_btfids/main.c +5 -0
index 7409d7860aa6..80d966cfcaa1 100644
@@ -260,6 +260,11 @@ static struct btf_id *add_symbol(struct rb_root *root, char *name, size_t size)
 	return btf_id__add(root, id, false);
 }
 
+/* Older libelf.h and glibc elf.h might not yet define the ELF compression types. */
+#ifndef SHF_COMPRESSED
+#define SHF_COMPRESSED (1 << 11) /* Section with compressed data. */
+#endif
+
 /*
  * The data of compressed section should be aligned to 4
  * (for 32bit) or 8 (for 64 bit) bytes. The binutils ld
Signature · 1 line
2.25.1
#2 lore raw
In reply to Kun-Chuan Hsieh
This patch was applied to bpf/bpf.git (refs/heads/master):

Hello:

This patch was applied to bpf/bpf.git (refs/heads/master):

Quoted 9 lines · On Wed, 24 Feb 2021 05:27:52 +0000 you wrote:

Older libelf.h and glibc elf.h might not yet define the ELF compression types.

Checking and defining SHF_COMPRESSED fix the build error when compiling with older toolchains. Also, the tool resolve_btfids is compiled with host toolchain. The host toolchain is more likely to be older than the cross compile toolchain.

[...]

Here is the summary with links:
- [v2] tools/resolve_btfids: Fix build error with older host toolchains

    https://git.kernel.org/bpf/bpf/c/b8592e231fb8

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html