Skip to contentSkip to conversation

selftests/bpf: suppress readelf stderr when probing for BTF support

PATCH Superseded Stanislav Fomichev 3 participants 4 messages Jan 23, 2019 – Jan 24, 2019

Subsystems (5)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/bpf: suppress readelf stderr when probing for BTF support

Before:

$ make -s -C tools/testing/selftests/bpf
readelf: Error: Missing knowledge of 32-bit reloc types used in DWARF
sections of machine number 247
readelf: Warning: unable to apply unsupported reloc type 10 to section
.debug_info
readelf: Warning: unable to apply unsupported reloc type 1 to section
.debug_info
readelf: Warning: unable to apply unsupported reloc type 10 to section
.debug_info

After:

$ make -s -C tools/testing/selftests/bpf
---
 tools/testing/selftests/bpf/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/Makefile +1 -1
index 70229de510f5..ff3cab5525c1 100644
@@ -131,7 +131,7 @@ BTF_PAHOLE_PROBE := $(shell $(BTF_PAHOLE) --help 2>&1 | grep BTF)
 BTF_OBJCOPY_PROBE := $(shell $(LLVM_OBJCOPY) --help 2>&1 | grep -i 'usage.*llvm')
 BTF_LLVM_PROBE := $(shell echo "int main() { return 0; }" | \
 			  $(CLANG) -target bpf -O2 -g -c -x c - -o ./llvm_btf_verify.o; \
-			  readelf -S ./llvm_btf_verify.o | grep BTF; \
+			  readelf -S ./llvm_btf_verify.o 2>/dev/null | grep BTF; \
 			  /bin/rm -f ./llvm_btf_verify.o)
 
 ifneq ($(BTF_LLVM_PROBE),)
Signature · 1 line
2.20.1.321.g9e740568ce-goog
#1 lore raw
Quoted 24 lines · Stanislav Fomichev

Before:

$ make -s -C tools/testing/selftests/bpf
readelf: Error: Missing knowledge of 32-bit reloc types used in DWARF
sections of machine number 247
readelf: Warning: unable to apply unsupported reloc type 10 to section
.debug_info
readelf: Warning: unable to apply unsupported reloc type 1 to section
.debug_info
readelf: Warning: unable to apply unsupported reloc type 10 to section
.debug_info

After:

$ make -s -C tools/testing/selftests/bpf
---
 tools/testing/selftests/bpf/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/Makefile +0 -0
index 70229de510f5..ff3cab5525c1 100644

tools/testing/selftests/bpf/Makefile BTF_PAHOLE_PROBE := $(shell $(BTF_PAHOLE) --help 2>&1 | grep BTF) · line 135

Quoted 6 lines
tools/testing/selftests/bpf/Makefile +1 -1
@@ -131,7 +131,7 @@ BTF_PAHOLE_PROBE := $(shell $(BTF_PAHOLE) --help 2>&1 | grep BTF)
 BTF_OBJCOPY_PROBE := $(shell $(LLVM_OBJCOPY) --help 2>&1 | grep -i 'usage.*llvm')
 BTF_LLVM_PROBE := $(shell echo "int main() { return 0; }" | \
 			  $(CLANG) -target bpf -O2 -g -c -x c - -o ./llvm_btf_verify.o; \
-			  readelf -S ./llvm_btf_verify.o | grep BTF; \
+			  readelf -S ./llvm_btf_verify.o 2>/dev/null | grep BTF; \
 			  /bin/rm -f ./llvm_btf_verify.o)

Silencing the warning may hide real issue later.
I'd rather fix whatever is necessary in readelf.
Does it use bfd? if so bpf support for bfd was practically complete.

#2 lore raw
Quoted 20 lines · Alexei Starovoitov
Quoted 19 lines · Stanislav Fomichev

Before:

$ make -s -C tools/testing/selftests/bpf
readelf: Error: Missing knowledge of 32-bit reloc types used in DWARF
sections of machine number 247
readelf: Warning: unable to apply unsupported reloc type 10 to section
.debug_info
readelf: Warning: unable to apply unsupported reloc type 1 to section
.debug_info
readelf: Warning: unable to apply unsupported reloc type 10 to section
.debug_info

After:

$ make -s -C tools/testing/selftests/bpf
---
 tools/testing/selftests/bpf/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines

tools/testing/selftests/bpf/Makefile BTF_PAHOLE_PROBE := $(shell $(BTF_PAHOLE) --help 2>&1 | grep BTF) · line 135

Quoted 11 lines
tools/testing/selftests/bpf/Makefile +1 -1
index 70229de510f5..ff3cab5525c1 100644
@@ -131,7 +131,7 @@ BTF_PAHOLE_PROBE := $(shell $(BTF_PAHOLE) --help 2>&1 | grep BTF)
 BTF_OBJCOPY_PROBE := $(shell $(LLVM_OBJCOPY) --help 2>&1 | grep -i 'usage.*llvm')
 BTF_LLVM_PROBE := $(shell echo "int main() { return 0; }" | \
 			  $(CLANG) -target bpf -O2 -g -c -x c - -o ./llvm_btf_verify.o; \
-			  readelf -S ./llvm_btf_verify.o | grep BTF; \
+			  readelf -S ./llvm_btf_verify.o 2>/dev/null | grep BTF; \
 			  /bin/rm -f ./llvm_btf_verify.o)

Silencing the warning may hide real issue later.
I'd rather fix whatever is necessary in readelf.
Does it use bfd? if so bpf support for bfd was practically complete.

Are you concerned about the situation where llvm has btf support, but readelf (binutils) is unaware of it? In this case, we should probably use llvm's readelf (llvm-readelf binary). We already have a precedent of using llvm's tools with LLVM_OBJCOPY. Let me try it out tomorrow.

#3 lore raw
Quoted 36 lines · Stanislav Fomichev
Quoted 20 lines · Alexei Starovoitov
Quoted 19 lines · Stanislav Fomichev

Before:

$ make -s -C tools/testing/selftests/bpf
readelf: Error: Missing knowledge of 32-bit reloc types used in DWARF
sections of machine number 247
readelf: Warning: unable to apply unsupported reloc type 10 to section
.debug_info
readelf: Warning: unable to apply unsupported reloc type 1 to section
.debug_info
readelf: Warning: unable to apply unsupported reloc type 10 to section
.debug_info

After:

$ make -s -C tools/testing/selftests/bpf
---
 tools/testing/selftests/bpf/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines

tools/testing/selftests/bpf/Makefile BTF_PAHOLE_PROBE := $(shell $(BTF_PAHOLE) --help 2>&1 | grep BTF) · line 135

Quoted 11 lines
tools/testing/selftests/bpf/Makefile +1 -1
index 70229de510f5..ff3cab5525c1 100644
@@ -131,7 +131,7 @@ BTF_PAHOLE_PROBE := $(shell $(BTF_PAHOLE) --help 2>&1 | grep BTF)
 BTF_OBJCOPY_PROBE := $(shell $(LLVM_OBJCOPY) --help 2>&1 | grep -i 'usage.*llvm')
 BTF_LLVM_PROBE := $(shell echo "int main() { return 0; }" | \
 			  $(CLANG) -target bpf -O2 -g -c -x c - -o ./llvm_btf_verify.o; \
-			  readelf -S ./llvm_btf_verify.o | grep BTF; \
+			  readelf -S ./llvm_btf_verify.o 2>/dev/null | grep BTF; \
 			  /bin/rm -f ./llvm_btf_verify.o)

Silencing the warning may hide real issue later.
I'd rather fix whatever is necessary in readelf.
Does it use bfd? if so bpf support for bfd was practically complete.

Quoted 4 lines

Are you concerned about the situation where llvm has btf support, but readelf (binutils) is unaware of it? In this case, we should probably use llvm's readelf (llvm-readelf binary). We already have a precedent of using llvm's tools with LLVM_OBJCOPY. Let me try it out tomorrow.

llvm-readelf or llvm-objdump are fine options too.