ANNOUNCE: pahole v1.20 (gcc11 DWARF5's default, lots of ELF sections, BTF)
Subsystems (3)
Hi,
The v1.20 release of pahole and its friends is out, mostly
addressing problems related to gcc 11 defaulting to DWARF5 for -g, available at the usual places:
Main git repo:
git://git.kernel.org/pub/scm/devel/pahole/pahole.git
Mirror git repo:
https://github.com/acmel/dwarves.git
tarball + gpg signature:
https://fedorapeople.org/~acme/dwarves/dwarves-1.20.tar.xz
https://fedorapeople.org/~acme/dwarves/dwarves-1.20.tar.bz2
https://fedorapeople.org/~acme/dwarves/dwarves-1.20.tar.sign
Best Regards,
- Arnaldo
v1.20:
BTF encoder:
- Improve ELF error reporting using elf_errmsg(elf_errno()).
- Improve objcopy error handling.
- Fix handling of 'restrict' qualifier, that was being treated as a 'const'.
- Support SHN_XINDEX in st_shndx symbol indexes, to handle ELF objects with more than 65534 sections, for instance, which happens with kernels built with 'KCFLAGS="-ffunction-sections -fdata-sections", Other cases may include when using FG-ASLR, LTO.
- Cope with functions without a name, as seen sometimes when building kernel images with some versions of clang, when a SEGFAULT was taking place.
- Fix BTF variable generation for kernel modules, not skipping variables at offset zero.
- Fix address size to match what is in the ELF file being processed, to fix using a 64-bit pahole binary to generate BTF for a 32-bit vmlinux image.
- Use kernel module ftrace addresses when finding which functions to encode, which increases the number of functions encoded.
libbpf:
- Allow use of packaged version, for distros wanting to dynamically link with the system's libbpf package instead of using the libbpf git submodule shipped in pahole's source code.
DWARF loader:
- Support DW_AT_data_bit_offset
This appeared in DWARF4 but is supported only in gcc's -gdwarf-5, support it in a way that makes the output be the same for both cases.
$ gcc -gdwarf-5 -c examples/dwarf5/bf.c
$ pahole bf.o
struct pea {
long int a:1; /* 0: 0 8 */
long int b:1; /* 0: 1 8 */
long int c:1; /* 0: 2 8 */
/* XXX 29 bits hole, try to pack */ /* Bitfield combined with next fields */
int after_bitfield; /* 4 4 */
/* size: 8, cachelines: 1, members: 4 */
/* sum members: 4 */
/* sum bitfield members: 3 bits, bit holes: 1, sum bit holes: 29 bits */ /* last cacheline: 8 bytes */
};
- DW_FORM_implicit_const in attr_numeric() and attr_offset()
- Support DW_TAG_GNU_call_site, its the standardized rename of the previously supported DW_TAG_GNU_call_site.
build:
- Fix compilation on 32-bit architectures.
Quoted 7 lines · Arnaldo Carvalho de Melo
Hi,
The v1.20 release of pahole and its friends is out, mostly
addressing problems related to gcc 11 defaulting to DWARF5 for -g, available at the usual places:
Congrats and thanks for v1.20 and to all involved folks.
- Sedat -
Quoted 86 lines
Main git repo:
git://git.kernel.org/pub/scm/devel/pahole/pahole.gitMirror git repo:
https://github.com/acmel/dwarves.git
tarball + gpg signature:
https://fedorapeople.org/~acme/dwarves/dwarves-1.20.tar.xz https://fedorapeople.org/~acme/dwarves/dwarves-1.20.tar.bz2 https://fedorapeople.org/~acme/dwarves/dwarves-1.20.tar.signBest Regards,
- Arnaldo
v1.20:
BTF encoder:
- Improve ELF error reporting using elf_errmsg(elf_errno()).
- Improve objcopy error handling.
- Fix handling of 'restrict' qualifier, that was being treated as a 'const'.
- Support
SHN_XINDEXinst_shndxsymbol indexes, to handle ELF objects with more than 65534 sections, for instance, which happens with kernels built with 'KCFLAGS="-ffunction-sections -fdata-sections", Other cases may include when using FG-ASLR, LTO.- Cope with functions without a name, as seen sometimes when building kernel images with some versions of clang, when a SEGFAULT was taking place.
- Fix BTF variable generation for kernel modules, not skipping variables at offset zero.
- Fix address size to match what is in the ELF file being processed, to fix using a 64-bit pahole binary to generate BTF for a 32-bit vmlinux image.
- Use kernel module ftrace addresses when finding which functions to encode, which increases the number of functions encoded.
libbpf:
- Allow use of packaged version, for distros wanting to dynamically link with the system's libbpf package instead of using the libbpf git submodule shipped in pahole's source code.
DWARF loader:
- Support
DW_AT_data_bit_offsetThis appeared in DWARF4 but is supported only in gcc's -gdwarf-5, support it in a way that makes the output be the same for both cases.
$ gcc -gdwarf-5 -c
examples/dwarf5/bf.c
$ pahole bf.o
struct pea {
long int a:1; /* 0: 0 8 */
long int b:1; /* 0: 1 8 */
long int c:1; /* 0: 2 8 *//* XXX 29 bits hole, try to pack */ /* Bitfield combined with next fields */
int
after_bitfield; /* 4 4 *//* size: 8, cachelines: 1, members: 4 */
/* sum members: 4 */
/* sum bitfield members: 3 bits, bit holes: 1, sum bit holes: 29 bits */ /* last cacheline: 8 bytes */
};-
DW_FORM_implicit_constinattr_numeric()andattr_offset()- Support
DW_TAG_GNU_call_site, its the standardized rename of the previously supportedDW_TAG_GNU_call_site.build:
- Fix compilation on 32-bit architectures.
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
Quoted 6 lines · Arnaldo Carvalho de Melo
Hi,
The v1.20 release of pahole and its friends is out, mostly
addressing problems related to gcc 11 defaulting to DWARF5 for -g, available at the usual places:
Great, thanks, Arnaldo! Do you plan to build RPMs soon as well?
Quoted 19 lines
Main git repo:
git://git.kernel.org/pub/scm/devel/pahole/pahole.gitMirror git repo:
https://github.com/acmel/dwarves.git
tarball + gpg signature:
https://fedorapeople.org/~acme/dwarves/dwarves-1.20.tar.xz https://fedorapeople.org/~acme/dwarves/dwarves-1.20.tar.bz2 https://fedorapeople.org/~acme/dwarves/dwarves-1.20.tar.signBest Regards,
- Arnaldo
[...]
Quoted 6 lines · Andrii Nakryiko
Quoted 3 lines · On Thu, Feb 4, 2021 at 2:09 PM Arnaldo Carvalho de Melo><[email protected]> wrote:
The v1.20 release of pahole and its friends is out, mostly
addressing problems related to gcc 11 defaulting to DWARF5 for -g, available at the usual places:Great, thanks, Arnaldo! Do you plan to build RPMs soon as well?
It's in rawhide already, I'll do it for f33, f32 later,
- Arnaldo
Signature · 1 line
Sent from my Android device with K-9 Mail. Please excuse my brevity.
Quoted 4 lines · Arnaldo Carvalho de Melo
On February 4, 2021 9:01:51 PM GMT-03:00, Andrii Nakryiko <[email protected]> wrote:
Quoted 9 lines
Quoted 6 lines · On Thu, Feb 4, 2021 at 2:09 PM Arnaldo Carvalho de Melo><[email protected]> wrote:
Quoted 3 lines
The v1.20 release of pahole and its friends is out, mostly
addressing problems related to gcc 11 defaulting to DWARF5 for -g, available at the usual places:Great, thanks, Arnaldo! Do you plan to build RPMs soon as well?
It's in rawhide already, I'll do it for f33, f32 later,
Do you have a link? I tried to find it, but only see 1.19 so far.
Quoted 4 lines
- Arnaldo
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
Quoted 13 lines · Andrii Nakryiko
Quoted 4 lines · Arnaldo Carvalho de Melo
On February 4, 2021 9:01:51 PM GMT-03:00, Andrii Nakryiko
Quoted 1 line · <[email protected]> wrote:
Quoted 1 line
On Thu, Feb 4, 2021 at 2:09 PM Arnaldo Carvalho de
Quoted 4 lines · Melo><[email protected]> wrote:
Quoted 4 lines
Quoted 3 lines
The v1.20 release of pahole and its friends is out, mostly
addressing problems related to gcc 11 defaulting to DWARF5 for -g, available at the usual places:
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Great, thanks, Arnaldo! Do you plan to build RPMs soon as well?
It's in rawhide already, I'll do it for f33, f32 later,
Do you have a link? I tried to find it, but only see 1.19 so far.
https://koji.fedoraproject.org/koji/buildinfo?buildID=1703678
- Arnaldo
Signature · 1 line
Sent from my Android device with K-9 Mail. Please excuse my brevity.
Em Fri, Feb 05, 2021 at 06:33:43AM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 10 lines · Andrii Nakryiko
Quoted 8 lines · On Thu, Feb 4, 2021 at 8:34 PM Arnaldo Carvalho de Melo…
Quoted 1 line
On February 4, 2021 9:01:51 PM GMT-03:00, Andrii Nakryiko
Quoted 1 line · <[email protected]> wrote:
Quoted 1 line
On Thu, Feb 4, 2021 at 2:09 PM Arnaldo Carvalho de
Quoted 3 lines · Melo><[email protected]> wrote:
Quoted 3 lines
Quoted 3 lines
The v1.20 release of pahole and its friends is out, mostly
addressing problems related to gcc 11 defaulting to DWARF5 for -g, available at the usual places:
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Great, thanks, Arnaldo! Do you plan to build RPMs soon as well?
It's in rawhide already, I'll do it for f33, f32 later,
Do you have a link? I tried to find it, but only see 1.19 so far.
https://koji.fedoraproject.org/koji/buildinfo?buildID=1703678
And now for Fedora 33, waiting for karma bumps at:
https://bodhi.fedoraproject.org/updates/FEDORA-2021-804e7a572c
fedpkg buidling for f32 now.
- Arnaldo
Quoted 20 lines · Arnaldo Carvalho de Melo
Em Fri, Feb 05, 2021 at 06:33:43AM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 10 lines · Andrii Nakryiko
Quoted 8 lines · On Thu, Feb 4, 2021 at 8:34 PM Arnaldo Carvalho de Melo…
Quoted 1 line
On February 4, 2021 9:01:51 PM GMT-03:00, Andrii Nakryiko
Quoted 1 line · <[email protected]> wrote:
Quoted 1 line
On Thu, Feb 4, 2021 at 2:09 PM Arnaldo Carvalho de
Quoted 3 lines · Melo><[email protected]> wrote:
Quoted 3 lines
Quoted 3 lines
The v1.20 release of pahole and its friends is out, mostly
addressing problems related to gcc 11 defaulting to DWARF5 for -g, available at the usual places:Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Great, thanks, Arnaldo! Do you plan to build RPMs soon as well?
It's in rawhide already, I'll do it for f33, f32 later,
Do you have a link? I tried to find it, but only see 1.19 so far.
https://koji.fedoraproject.org/koji/buildinfo?buildID=1703678
Quoted 7 lines
And now for Fedora 33, waiting for karma bumps at:
https://bodhi.fedoraproject.org/updates/FEDORA-2021-804e7a572c
fedpkg buidling for f32 now.
- Arnaldo
Ok, imported dwarves-1.20. Had to fix two dates in changelog (in spec), day of week didn't match the date, tooling complained about that. Also had to undo cmake_build and cmake_install fanciness, because apparently we don't have them or the support for it is not great. But otherwise everything else looks to be ok.
Em Fri, Feb 05, 2021 at 02:11:44PM -0800, Andrii Nakryiko escreveu:
Quoted 26 lines
Quoted 24 lines · Arnaldo Carvalho de Melo
Em Fri, Feb 05, 2021 at 06:33:43AM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 10 lines · Andrii Nakryiko
Quoted 8 lines · On Thu, Feb 4, 2021 at 8:34 PM Arnaldo Carvalho de Melo…
Quoted 1 line
On February 4, 2021 9:01:51 PM GMT-03:00, Andrii Nakryiko
Quoted 1 line · <[email protected]> wrote:
Quoted 1 line
On Thu, Feb 4, 2021 at 2:09 PM Arnaldo Carvalho de
Quoted 3 lines · Melo><[email protected]> wrote:
Quoted 3 lines
Quoted 3 lines
The v1.20 release of pahole and its friends is out, mostly
addressing problems related to gcc 11 defaulting to DWARF5 for -g, available at the usual places:Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Great, thanks, Arnaldo! Do you plan to build RPMs soon as well?
It's in rawhide already, I'll do it for f33, f32 later,
Do you have a link? I tried to find it, but only see 1.19 so far.
https://koji.fedoraproject.org/koji/buildinfo?buildID=1703678
And now for Fedora 33, waiting for karma bumps at:
https://bodhi.fedoraproject.org/updates/FEDORA-2021-804e7a572c
Quoted 7 lines
Quoted 1 line
fedpkg buidling for f32 now.
Ok, imported dwarves-1.20. Had to fix two dates in changelog (in spec), day of week didn't match the date, tooling complained about that. Also had to undo
cmake_buildandcmake_installfanciness, because apparently we don't have them or the support for it is not great. But otherwise everything else looks to be ok.
Send patch please, I wasn't expecting this, if you could do some more and send me tooling bits to help me in the release process, if that is possible, I'd love to get it, otherwise I'll write it, don't want to go thru this one more time, sigh :-(
- Arnaldo
Quoted 36 lines · Arnaldo Carvalho de Melo
Em Fri, Feb 05, 2021 at 02:11:44PM -0800, Andrii Nakryiko escreveu:
Quoted 26 lines
Quoted 24 lines · Arnaldo Carvalho de Melo
Em Fri, Feb 05, 2021 at 06:33:43AM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 10 lines · Andrii Nakryiko
Quoted 8 lines · On Thu, Feb 4, 2021 at 8:34 PM Arnaldo Carvalho de Melo…
Quoted 1 line
On February 4, 2021 9:01:51 PM GMT-03:00, Andrii Nakryiko
Quoted 1 line · <[email protected]> wrote:
Quoted 1 line
On Thu, Feb 4, 2021 at 2:09 PM Arnaldo Carvalho de
Quoted 3 lines · Melo><[email protected]> wrote:
Quoted 3 lines
Quoted 3 lines
The v1.20 release of pahole and its friends is out, mostly
addressing problems related to gcc 11 defaulting to DWARF5 for -g, available at the usual places:Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Great, thanks, Arnaldo! Do you plan to build RPMs soon as well?
It's in rawhide already, I'll do it for f33, f32 later,
Do you have a link? I tried to find it, but only see 1.19 so far.
https://koji.fedoraproject.org/koji/buildinfo?buildID=1703678
And now for Fedora 33, waiting for karma bumps at:
https://bodhi.fedoraproject.org/updates/FEDORA-2021-804e7a572c
Quoted 7 lines
Quoted 1 line
fedpkg buidling for f32 now.
Ok, imported dwarves-1.20. Had to fix two dates in changelog (in spec), day of week didn't match the date, tooling complained about that. Also had to undo
cmake_buildandcmake_installfanciness, because apparently we don't have them or the support for it is not great. But otherwise everything else looks to be ok.
Quoted 5 lines
Send patch please, I wasn't expecting this, if you could do some more and send me tooling bits to help me in the release process, if that is possible, I'd love to get it, otherwise I'll write it, don't want to go thru this one more time, sigh :-(
I just "reverted" some bits of spec file to what it used to be pre-1.19, I think. There is also a work-around for lack of ldconfig_scriptlets support in our platform, so I have to work around that. Here's full diff:
dwarves.spec 2021-02-05 13:26:52.502859609 -0800 renamed from git/rpm/SPECS/dwarves.spec 2021-02-05 11:19:54.364938716 -0800 +7 -5
@@ -3,12 +3,14 @@ Name: dwarves Version: 1.20 -Release: 1%{?dist} +Release: 1fb1%{?dist} License: GPLv2 Summary: Debugging Information Manipulation Tools (pahole & friends) URL: http://acmel.wordpress.com Source: http://fedorapeople.org/~acme/dwarves/%{name}-%{version}.tar.xz Requires: %{libname}%{libver} = %{version}-%{release} +Requires(post): /sbin/ldconfig +Requires(postun): /sbin/ldconfig BuildRequires: gcc BuildRequires: cmake >= 2.8.12 BuildRequires: zlib-devel
@@ -68,13 +70,14 @@ %build %cmake -DCMAKE_BUILD_TYPE=Release . -%cmake_build +make VERBOSE=1 %{?_smp_mflags} %install rm -Rf %{buildroot} -%cmake_install +make install DESTDIR=%{buildroot} -%ldconfig_scriptlets -n %{libname}%{libver} +%post -p /sbin/ldconfig +%postun -p /sbin/ldconfig %files %doc README.ctracer
@@ -295,7 +298,7 @@ * Sat Nov 20 2010 Arnaldo Carvalho de Melo <[email protected]> - 1.9-1 - New release -* Tue Feb 08 2010 Fedora Release Engineering
<[email protected]> - 1.8-2
+* Mon Feb 08 2010 Fedora Release Engineering <[email protected]> - 1.8-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
* Fri Dec 4 2009 Arnaldo Carvalho de Melo <[email protected]> - 1.8-1
@@ -446,7 +449,7 @@
- Fix emission of arrays of structs, unions, etc
- use sysconf for the default cacheline size
-* Wed Jan 18 2007 Arnaldo Carvalho de Melo <[email protected]> +* Thu Jan 18 2007 Arnaldo Carvalho de Melo <[email protected]>
- fab0db03ea9046893ca110bb2b7d71b764f61033
- pdwtags added
Quoted 2 lines
- Arnaldo
ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
In reply to Arnaldo Carvalho de MeloHi,
when building with pahole v1.20 and binutils v2.35.2 plus Clang v12.0.0-rc1 and DWARF-v5 I see:
...
+ info BTF .btf.vmlinux.bin.o
+ [ != silent_ ]
+ printf %-7s %s\n BTF .btf.vmlinux.bin.o
BTF .btf.vmlinux.bin.o
+ LLVM_OBJCOPY=/opt/binutils/bin/objcopy /opt/pahole/bin/pahole -J .tmp_vmlinux.btf
[115] INT DW_ATE_unsigned_1 Error emitting BTF type Encountered error while encoding BTF.
+ /opt/binutils/bin/objcopy --only-section=.BTF --set-section-flags .BTF=alloc,readonly --strip-all .tmp_vmlinux.btf .btf.vmlinux.bin.o
+ printf \1
+ dd of=.btf.vmlinux.bin.o conv=notrunc bs=1 seek=16 status=none
+ kallsymso=
...
+ info BTFIDS vmlinux
+ [ != silent_ ]
+ printf %-7s %s\n BTFIDS vmlinux
BTFIDS vmlinux
+ ./tools/bpf/resolve_btfids/resolve_btfids vmlinux
FAILED: load BTF from vmlinux: No such file or directory
+ on_exit
+ [ 255 -ne 0 ]
+ cleanup
+ rm -f .btf.vmlinux.bin.o
+ rm -f .tmp_System.map
+ rm -f .tmp_vmlinux.btf .tmp_vmlinux.kallsyms1 .tmp_vmlinux.kallsyms1.S .tmp_vmlinux.kallsyms1.o .tmp_vmlinux.kallsyms2 .tmp_vmlinux.kallsyms2.S .tmp_vmlinux.kallsyms 2.o
+ rm -f System.map
+ rm -f vmlinux
+ rm -f vmlinux.o
make[3]: *** [Makefile:1166: vmlinux] Error 255
Looks like it does not matter to use LLVM_OBJCOPY=/opt/llvm-toolchain/bin/llvm-objcopy:
+ info BTF .btf.vmlinux.bin.o
+ [ != silent_ ]
+ printf %-7s %s\n BTF .btf.vmlinux.bin.o
BTF .btf.vmlinux.bin.o
+ LLVM_OBJCOPY=/opt/llvm-toolchain/bin/llvm-objcopy /opt/pahole/bin/pahole -J .tmp_vmlinux.btf
[115] INT DW_ATE_unsigned_1 Error emitting BTF type Encountered error while encoding BTF.
My make-line looks like this:
make V=1 -j4 HOSTCC=clang HOSTCXX=clang++ HOSTLD=/opt/binutils/bin/ld.bfd HOSTAR=/opt/binutils/bin/ar CC=clang LD=/opt/binutils/bin/ld.
bfd AR=/opt/binutils/bin/ar NM=/opt/binutils/bin/nm STRIP=/opt/binutils/bin/strip OBJCOPY=/opt/binutils/bin/objcopy OBJDUMP=/opt/binutils/bin/objdump READELF=/opt/binu tils/bin/readelf PAHOLE=/opt/pahole/bin/pahole LOCALVERSION=-11-amd64-clang12-bfd KBUILD_VERBOSE=1 KBUILD_BUILD_HOST=iniza [email protected] KBUILD_BUILD_TIMESTAMP=2021-02-05 bindeb-pkg KDEB_PKGVERSION=5.11.0~rc6-11~bullseye+dileks1
My kernel-config is attached.
If you need further informations, please let me know.
Thanks.
Regards,
- Sedat -
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
Quoted 14 lines · Sedat Dilek
Hi,
when building with pahole v1.20 and binutils v2.35.2 plus Clang v12.0.0-rc1 and DWARF-v5 I see:
...
+ info BTF .btf.vmlinux.bin.o
+ [ !=silent_]
+ printf %-7s %s\n BTF .btf.vmlinux.bin.o
BTF .btf.vmlinux.bin.o
+ LLVM_OBJCOPY=/opt/binutils/bin/objcopy/opt/pahole/bin/pahole-J .tmp_vmlinux.btf
[115] INTDW_ATE_unsigned_1Error emitting BTF type Encountered error while encoding BTF.
Grepping the pahole sources:
$ git grep DW_ATE dwarf_loader.c: bt->is_bool = encoding == DW_ATE_boolean; dwarf_loader.c: bt->is_signed = encoding == DW_ATE_signed;
Missing DW_ATE_unsigned encoding?
- Sedat -
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
Quoted 17 lines · Sedat Dilek
Quoted 14 lines · Sedat Dilek
Hi,
when building with pahole v1.20 and binutils v2.35.2 plus Clang v12.0.0-rc1 and DWARF-v5 I see:
...
+ info BTF .btf.vmlinux.bin.o
+ [ !=silent_]
+ printf %-7s %s\n BTF .btf.vmlinux.bin.o
BTF .btf.vmlinux.bin.o
+ LLVM_OBJCOPY=/opt/binutils/bin/objcopy/opt/pahole/bin/pahole-J .tmp_vmlinux.btf
[115] INTDW_ATE_unsigned_1Error emitting BTF type Encountered error while encoding BTF.
Quoted 8 lines
Grepping the pahole sources:
$ git grep DW_ATE dwarf_loader.c: bt->is_bool = encoding == DW_ATE_boolean; dwarf_loader.c: bt->is_signed = encoding == DW_ATE_signed;Missing
DW_ATE_unsignedencoding?
Checked the LLVM sources:
clang/lib/CodeGen/CGDebugInfo.cpp: Encoding =llvm::dwarf::DW_ATE_unsigned_char;
clang/lib/CodeGen/CGDebugInfo.cpp: Encoding = llvm::dwarf::DW_ATE_unsigned;
clang/lib/CodeGen/CGDebugInfo.cpp: Encoding =llvm::dwarf::DW_ATE_unsigned_fixed;
clang/lib/CodeGen/CGDebugInfo.cpp:
? llvm::dwarf::DW_ATE_unsigned
...
lld/test/wasm/debuginfo.test:CHECK-NEXT: DW_AT_encoding
(DW_ATE_unsigned)
So, I will switch from GNU ld.bfd v2.35.2 to LLD-12.
- Sedat -
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
Em Fri, Feb 05, 2021 at 04:23:59PM +0100, Sedat Dilek escreveu:
Quoted 40 lines · Sedat Dilek
Quoted 17 lines · Sedat Dilek
Quoted 14 lines
Hi,
when building with pahole v1.20 and binutils v2.35.2 plus Clang v12.0.0-rc1 and DWARF-v5 I see:
...
+ info BTF .btf.vmlinux.bin.o
+ [ !=silent_]
+ printf %-7s %s\n BTF .btf.vmlinux.bin.o
BTF .btf.vmlinux.bin.o
+ LLVM_OBJCOPY=/opt/binutils/bin/objcopy/opt/pahole/bin/pahole-J .tmp_vmlinux.btf
[115] INTDW_ATE_unsigned_1Error emitting BTF type Encountered error while encoding BTF.Quoted 8 lines
Grepping the pahole sources:
$ git grep DW_ATE dwarf_loader.c: bt->is_bool = encoding == DW_ATE_boolean; dwarf_loader.c: bt->is_signed = encoding == DW_ATE_signed;Missing
DW_ATE_unsignedencoding?Checked the LLVM sources:
clang/lib/CodeGen/CGDebugInfo.cpp: Encoding =
llvm::dwarf::DW_ATE_unsigned_char;
clang/lib/CodeGen/CGDebugInfo.cpp: Encoding =llvm::dwarf::DW_ATE_unsigned;
clang/lib/CodeGen/CGDebugInfo.cpp: Encoding =llvm::dwarf::DW_ATE_unsigned_fixed;
clang/lib/CodeGen/CGDebugInfo.cpp:
?llvm::dwarf::DW_ATE_unsigned
...
lld/test/wasm/debuginfo.test:CHECK-NEXT:DW_AT_encoding
(DW_ATE_unsigned)
Quoted 1 line
So, I will switch from GNU ld.bfd v2.35.2 to LLD-12.
Thanks for the research, probably your conclusion is correct, can you go the next step and add that part and check if the end result is the expected one?
- Arnaldo
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
Quoted 42 lines · Arnaldo Carvalho de Melo
Em Fri, Feb 05, 2021 at 04:23:59PM +0100, Sedat Dilek escreveu:
Quoted 40 lines · Sedat Dilek
Quoted 17 lines · Sedat Dilek
Quoted 14 lines
Hi,
when building with pahole v1.20 and binutils v2.35.2 plus Clang v12.0.0-rc1 and DWARF-v5 I see:
...
+ info BTF .btf.vmlinux.bin.o
+ [ !=silent_]
+ printf %-7s %s\n BTF .btf.vmlinux.bin.o
BTF .btf.vmlinux.bin.o
+ LLVM_OBJCOPY=/opt/binutils/bin/objcopy/opt/pahole/bin/pahole-J .tmp_vmlinux.btf
[115] INTDW_ATE_unsigned_1Error emitting BTF type Encountered error while encoding BTF.Quoted 8 lines
Grepping the pahole sources:
$ git grep DW_ATE dwarf_loader.c: bt->is_bool = encoding == DW_ATE_boolean; dwarf_loader.c: bt->is_signed = encoding == DW_ATE_signed;Missing
DW_ATE_unsignedencoding?Checked the LLVM sources:
clang/lib/CodeGen/CGDebugInfo.cpp: Encoding =
llvm::dwarf::DW_ATE_unsigned_char;
clang/lib/CodeGen/CGDebugInfo.cpp: Encoding =llvm::dwarf::DW_ATE_unsigned;
clang/lib/CodeGen/CGDebugInfo.cpp: Encoding =llvm::dwarf::DW_ATE_unsigned_fixed;
clang/lib/CodeGen/CGDebugInfo.cpp:
?llvm::dwarf::DW_ATE_unsigned
...
lld/test/wasm/debuginfo.test:CHECK-NEXT:DW_AT_encoding
(DW_ATE_unsigned)
Quoted 6 lines
Quoted 1 line
So, I will switch from GNU ld.bfd v2.35.2 to LLD-12.
Thanks for the research, probably your conclusion is correct, can you go the next step and add that part and check if the end result is the expected one?
Still building...
Can you give me a hand on what has to be changed in dwarves/pahole?
I guess switching from ld.bfd to ld.lld will show the same ERROR.
- Sedat -
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
Quoted 52 lines · Sedat Dilek
Quoted 42 lines · Arnaldo Carvalho de Melo
Em Fri, Feb 05, 2021 at 04:23:59PM +0100, Sedat Dilek escreveu:
Quoted 40 lines · Sedat Dilek
Quoted 17 lines · Sedat Dilek
Quoted 14 lines
Hi,
when building with pahole v1.20 and binutils v2.35.2 plus Clang v12.0.0-rc1 and DWARF-v5 I see:
...
+ info BTF .btf.vmlinux.bin.o
+ [ !=silent_]
+ printf %-7s %s\n BTF .btf.vmlinux.bin.o
BTF .btf.vmlinux.bin.o
+ LLVM_OBJCOPY=/opt/binutils/bin/objcopy/opt/pahole/bin/pahole-J .tmp_vmlinux.btf
[115] INTDW_ATE_unsigned_1Error emitting BTF type Encountered error while encoding BTF.Quoted 8 lines
Grepping the pahole sources:
$ git grep DW_ATE dwarf_loader.c: bt->is_bool = encoding == DW_ATE_boolean; dwarf_loader.c: bt->is_signed = encoding == DW_ATE_signed;Missing
DW_ATE_unsignedencoding?Checked the LLVM sources:
clang/lib/CodeGen/CGDebugInfo.cpp: Encoding =
llvm::dwarf::DW_ATE_unsigned_char;
clang/lib/CodeGen/CGDebugInfo.cpp: Encoding =llvm::dwarf::DW_ATE_unsigned;
clang/lib/CodeGen/CGDebugInfo.cpp: Encoding =llvm::dwarf::DW_ATE_unsigned_fixed;
clang/lib/CodeGen/CGDebugInfo.cpp:
?llvm::dwarf::DW_ATE_unsigned
...
lld/test/wasm/debuginfo.test:CHECK-NEXT:DW_AT_encoding
(DW_ATE_unsigned)Quoted 6 lines
Quoted 1 line
So, I will switch from GNU ld.bfd v2.35.2 to LLD-12.
Thanks for the research, probably your conclusion is correct, can you go the next step and add that part and check if the end result is the expected one?
Quoted 6 lines
Still building...
Can you give me a hand on what has to be changed in dwarves/pahole?
I guess switching from ld.bfd to ld.lld will show the same ERROR.
This builds successfully - untested:
$ git diff
btf_loader.c +0 -0
@@ -107,6 +107,7 @@ static struct base_type *base_type__new(strings_t
name, uint32_t attrs,
bt->bit_size = size;
bt->is_signed = attrs & BTF_INT_SIGNED;
bt->is_bool = attrs & BTF_INT_BOOL;
+ bt->is_unsigned = attrs & BTF_INT_UNSIGNED;
bt->name_has_encoding = false;
bt->float_type = float_type;
}ctf.h +0 -0
@@ -100,6 +100,7 @@ struct ctf_full_type {
#define CTF_TYPE_INT_CHAR 0x2 #define CTF_TYPE_INT_BOOL 0x4 #define CTF_TYPE_INT_VARARGS 0x8
+#define CTF_TYPE_INT_UNSIGNED 0x16
#define CTF_TYPE_FP_ATTRS(VAL) ((VAL) >> 24)
#define CTF_TYPE_FP_OFFSET(VAL) (((VAL) >> 16) & 0xff)
dwarf_loader.c +0 -0
@@ -473,6 +473,7 @@ static struct base_type *base_type__new(Dwarf_Die
*die, struct cu *cu)
bt->is_bool = encoding == DW_ATE_boolean;
bt->is_signed = encoding == DW_ATE_signed;
bt->is_varargs = false;
+ bt->is_unsigned = encoding == DW_ATE_unsigned;
bt->name_has_encoding = true;
}dwarves.h +1 -0
@@ -1261,6 +1261,7 @@ struct base_type { uint8_t is_signed:1; uint8_t is_bool:1; uint8_t is_varargs:1; + uint8_t is_unsigned:1; uint8_t float_type:4;
};
lib/bpf +1 -1
@@ -1 +1 @@ -Subproject commit 5af3d86b5a2c5fecdc3ab83822d083edd32b4396 +Subproject commit 5af3d86b5a2c5fecdc3ab83822d083edd32b4396-dirty
libbtf.c +0 -0
@@ -247,6 +247,8 @@ static const char *
btf_elf__int_encoding_str(uint8_t encoding)
return "CHAR";
else if (encoding == BTF_INT_BOOL)
return "BOOL";
+ else if (encoding == BTF_INT_UNSIGNED)
+ return "UNSIGNED";
else
return "UNKN";
}
@@ -379,6 +381,8 @@ int32_t btf_elf__add_base_type(struct btf_elf
*btfe, const struct base_type *bt,
encoding = BTF_INT_SIGNED;
} else if (bt->is_bool) {
encoding = BTF_INT_BOOL;
+ } else if (bt->is_unsigned) {
+ encoding = BTF_INT_UNSIGNED;
} else if (bt->float_type) {
fprintf(stderr, "float_type is not supported\n");
return -1;Additionally - I cannot see it with git diff:
[ lib/bpf/include/uapi/linux/btf.h ]
/* Attributes stored in the BTF_INT_ENCODING */
#define BTF_INT_SIGNED (1 << 0)
#define BTF_INT_CHAR (1 << 1)
#define BTF_INT_BOOL (1 << 2)
#define BTF_INT_UNSIGNED (1 << 3)
Comments?
- Sedat -
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
Quoted 149 lines · Sedat Dilek
Quoted 52 lines · Sedat Dilek
Quoted 42 lines · Arnaldo Carvalho de Melo
Em Fri, Feb 05, 2021 at 04:23:59PM +0100, Sedat Dilek escreveu:
Quoted 40 lines · Sedat Dilek
Quoted 17 lines · Sedat Dilek
Quoted 14 lines
Hi,
when building with pahole v1.20 and binutils v2.35.2 plus Clang v12.0.0-rc1 and DWARF-v5 I see:
...
+ info BTF .btf.vmlinux.bin.o
+ [ !=silent_]
+ printf %-7s %s\n BTF .btf.vmlinux.bin.o
BTF .btf.vmlinux.bin.o
+ LLVM_OBJCOPY=/opt/binutils/bin/objcopy/opt/pahole/bin/pahole-J .tmp_vmlinux.btf
[115] INTDW_ATE_unsigned_1Error emitting BTF type Encountered error while encoding BTF.Quoted 8 lines
Grepping the pahole sources:
$ git grep DW_ATE dwarf_loader.c: bt->is_bool = encoding == DW_ATE_boolean; dwarf_loader.c: bt->is_signed = encoding == DW_ATE_signed;Missing
DW_ATE_unsignedencoding?Checked the LLVM sources:
clang/lib/CodeGen/CGDebugInfo.cpp: Encoding =
llvm::dwarf::DW_ATE_unsigned_char;
clang/lib/CodeGen/CGDebugInfo.cpp: Encoding =llvm::dwarf::DW_ATE_unsigned;
clang/lib/CodeGen/CGDebugInfo.cpp: Encoding =llvm::dwarf::DW_ATE_unsigned_fixed;
clang/lib/CodeGen/CGDebugInfo.cpp:
?llvm::dwarf::DW_ATE_unsigned
...
lld/test/wasm/debuginfo.test:CHECK-NEXT:DW_AT_encoding
(DW_ATE_unsigned)Quoted 6 lines
Quoted 1 line
So, I will switch from GNU ld.bfd v2.35.2 to LLD-12.
Thanks for the research, probably your conclusion is correct, can you go the next step and add that part and check if the end result is the expected one?
Quoted 6 lines
Still building...
Can you give me a hand on what has to be changed in dwarves/pahole?
I guess switching from ld.bfd to ld.lld will show the same ERROR.
This builds successfully - untested:
$ git diffbtf_loader.c +1
-0@@ -107,6 +107,7 @@ static struct base_type *base_type__new(strings_t name, uint32_t attrs, bt->bit_size = size; bt->is_signed = attrs &BTF_INT_SIGNED ; bt->is_bool = attrs &BTF_INT_BOOL ; + bt->is_unsigned = attrs &BTF_INT_UNSIGNED ; bt->name_has_encoding = false; bt->float_type = float_type;}ctf.h +1
-0@@ -100,6 +100,7 @@ struct ctf_full_type {#define CTF_TYPE_INT_CHAR 0x2#define CTF_TYPE_INT_BOOL 0x4#define CTF_TYPE_INT_VARARGS 0x8 +#define CTF_TYPE_INT_UNSIGNED 0x16#define CTF_TYPE_FP_ATTRS (VAL ) ((VAL) >> 24)#define CTF_TYPE_FP_OFFSET (VAL ) (((VAL) >> 16) & 0xff)dwarf_loader.c +1
-0@@ -473,6 +473,7 @@ static struct base_type *base_type__new(Dwarf_Die *die, struct cu *cu) bt->is_bool = encoding == DW_ATE_boolean; bt->is_signed = encoding == DW_ATE_signed; bt->is_varargs = false; + bt->is_unsigned = encoding == DW_ATE_unsigned; bt->name_has_encoding = true; }dwarves.h +1
-0@@ -1261,6 +1261,7 @@ struct base_type { uint8_t is_signed:1; uint8_t is_bool:1; uint8_t is_varargs:1; + uint8_t is_unsigned:1; uint8_t float_type:4; };lib/bpf +1
-1@@ -1 +1 @@ -Subproject commit 5af3d86b5a2c5fecdc3ab83822d083edd32b4396 +Subproject commit 5af3d86b5a2c5fecdc3ab83822d083edd32b4396-dirtylibbtf.c +2
-0@@ -247,6 +247,8 @@ static const char * btf_elf__int_encoding_str(uint8_t encoding) return "CHAR"; else if (encoding == BTF_INT_BOOL) return "BOOL"; + else if (encoding == BTF_INT_UNSIGNED) + return "UNSIGNED"; else return "UNKN";}
libbtf.c +2
-0@@ -379,6 +381,8 @@ int32_t btf_elf__add_base_type(struct btf_elf *btfe, const struct base_type *bt, encoding =BTF_INT_SIGNED ; }else if (bt->is_bool) { encoding =BTF_INT_BOOL ; + }else if (bt->is_unsigned) { + encoding =BTF_INT_UNSIGNED ; }else if (bt->float_type) {fprintf (stderr,"float_type is not supported\n" );return -1;Additionally - I cannot see it with
git diff:[
lib/bpf/include/uapi/linux/btf.h]
Quoted 8 lines
/* Attributes stored in the
BTF_INT_ENCODING*/
#defineBTF_INT_SIGNED(1 << 0)
#defineBTF_INT_CHAR(1 << 1)
#defineBTF_INT_BOOL(1 << 2)
#defineBTF_INT_UNSIGNED(1 << 3)Comments?
Hmmm...
+ info BTF .btf.vmlinux.bin.o
+ [ != silent_ ]
+ printf %-7s %s\n BTF .btf.vmlinux.bin.o
BTF .btf.vmlinux.bin.o
+ LLVM_OBJCOPY=llvm-objcopy /opt/pahole/bin/pahole -J .tmp_vmlinux.btf
[2] INT long unsigned int Error emitting BTF type Encountered error while encoding BTF.
+ llvm-objcopy --only-section=.BTF --set-section-flags .BTF=alloc,readonly --strip-all .tmp_vmlinux.btf .btf.vmlinux.bin.o
...
+ info BTFIDS vmlinux
+ [ != silent_ ]
+ printf %-7s %s\n BTFIDS vmlinux
BTFIDS vmlinux
+ ./tools/bpf/resolve_btfids/resolve_btfids vmlinux
FAILED: load BTF from vmlinux: Invalid argument
+ on_exit
+ [ 255 -ne 0 ]
+ cleanup
+ rm -f .btf.vmlinux.bin.o
+ rm -f .tmp_System.map
+ rm -f .tmp_vmlinux.btf .tmp_vmlinux.kallsyms1 .tmp_vmlinux.kallsyms1.S .tmp_vmlinux.kallsyms1.o .tmp_vmlinux.kallsyms2 .tmp_vmlinux.kallsyms2.S .tmp_vmlinux.kallsyms 2.o
+ rm -f System.map
+ rm -f vmlinux
+ rm -f vmlinux.o
make[3]: *** [Makefile:1166: vmlinux] Error 255
Grepping through linux.git/tools I guess some BTF tools/libs need to know what BTF_INT_UNSIGNED is?
- Sedat -
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
Quoted 191 lines · Sedat Dilek
Quoted 149 lines · Sedat Dilek
Quoted 52 lines · Sedat Dilek
Quoted 42 lines · Arnaldo Carvalho de Melo
Em Fri, Feb 05, 2021 at 04:23:59PM +0100, Sedat Dilek escreveu:
Quoted 40 lines · Sedat Dilek
Quoted 17 lines · Sedat Dilek
Quoted 14 lines
Hi,
when building with pahole v1.20 and binutils v2.35.2 plus Clang v12.0.0-rc1 and DWARF-v5 I see:
...
+ info BTF .btf.vmlinux.bin.o
+ [ !=silent_]
+ printf %-7s %s\n BTF .btf.vmlinux.bin.o
BTF .btf.vmlinux.bin.o
+ LLVM_OBJCOPY=/opt/binutils/bin/objcopy/opt/pahole/bin/pahole-J .tmp_vmlinux.btf
[115] INTDW_ATE_unsigned_1Error emitting BTF type Encountered error while encoding BTF.Quoted 8 lines
Grepping the pahole sources:
$ git grep DW_ATE dwarf_loader.c: bt->is_bool = encoding == DW_ATE_boolean; dwarf_loader.c: bt->is_signed = encoding == DW_ATE_signed;Missing
DW_ATE_unsignedencoding?Checked the LLVM sources:
clang/lib/CodeGen/CGDebugInfo.cpp: Encoding =
llvm::dwarf::DW_ATE_unsigned_char;
clang/lib/CodeGen/CGDebugInfo.cpp: Encoding =llvm::dwarf::DW_ATE_unsigned;
clang/lib/CodeGen/CGDebugInfo.cpp: Encoding =llvm::dwarf::DW_ATE_unsigned_fixed;
clang/lib/CodeGen/CGDebugInfo.cpp:
?llvm::dwarf::DW_ATE_unsigned
...
lld/test/wasm/debuginfo.test:CHECK-NEXT:DW_AT_encoding
(DW_ATE_unsigned)Quoted 6 lines
Quoted 1 line
So, I will switch from GNU ld.bfd v2.35.2 to LLD-12.
Thanks for the research, probably your conclusion is correct, can you go the next step and add that part and check if the end result is the expected one?
Quoted 6 lines
Still building...
Can you give me a hand on what has to be changed in dwarves/pahole?
I guess switching from ld.bfd to ld.lld will show the same ERROR.
This builds successfully - untested:
$ git diffbtf_loader.c +1
-0@@ -107,6 +107,7 @@ static struct base_type *base_type__new(strings_t name, uint32_t attrs, bt->bit_size = size; bt->is_signed = attrs &BTF_INT_SIGNED ; bt->is_bool = attrs &BTF_INT_BOOL ; + bt->is_unsigned = attrs &BTF_INT_UNSIGNED ; bt->name_has_encoding = false; bt->float_type = float_type;}ctf.h +1
-0@@ -100,6 +100,7 @@ struct ctf_full_type {#define CTF_TYPE_INT_CHAR 0x2#define CTF_TYPE_INT_BOOL 0x4#define CTF_TYPE_INT_VARARGS 0x8 +#define CTF_TYPE_INT_UNSIGNED 0x16#define CTF_TYPE_FP_ATTRS (VAL ) ((VAL) >> 24)#define CTF_TYPE_FP_OFFSET (VAL ) (((VAL) >> 16) & 0xff)dwarf_loader.c +1
-0@@ -473,6 +473,7 @@ static struct base_type *base_type__new(Dwarf_Die *die, struct cu *cu) bt->is_bool = encoding == DW_ATE_boolean; bt->is_signed = encoding == DW_ATE_signed; bt->is_varargs = false; + bt->is_unsigned = encoding == DW_ATE_unsigned; bt->name_has_encoding = true; }dwarves.h +1
-0@@ -1261,6 +1261,7 @@ struct base_type { uint8_t is_signed:1; uint8_t is_bool:1; uint8_t is_varargs:1; + uint8_t is_unsigned:1; uint8_t float_type:4; };lib/bpf +1
-1@@ -1 +1 @@ -Subproject commit 5af3d86b5a2c5fecdc3ab83822d083edd32b4396 +Subproject commit 5af3d86b5a2c5fecdc3ab83822d083edd32b4396-dirtylibbtf.c +2
-0@@ -247,6 +247,8 @@ static const char * btf_elf__int_encoding_str(uint8_t encoding) return "CHAR"; else if (encoding == BTF_INT_BOOL) return "BOOL"; + else if (encoding == BTF_INT_UNSIGNED) + return "UNSIGNED"; else return "UNKN";}
libbtf.c +2
-0@@ -379,6 +381,8 @@ int32_t btf_elf__add_base_type(struct btf_elf *btfe, const struct base_type *bt, encoding =BTF_INT_SIGNED ; }else if (bt->is_bool) { encoding =BTF_INT_BOOL ; + }else if (bt->is_unsigned) { + encoding =BTF_INT_UNSIGNED ; }else if (bt->float_type) {fprintf (stderr,"float_type is not supported\n" );return -1;Additionally - I cannot see it with
git diff:[
lib/bpf/include/uapi/linux/btf.h]Quoted 8 lines
/* Attributes stored in the
BTF_INT_ENCODING*/
#defineBTF_INT_SIGNED(1 << 0)
#defineBTF_INT_CHAR(1 << 1)
#defineBTF_INT_BOOL(1 << 2)
#defineBTF_INT_UNSIGNED(1 << 3)Comments?
Hmmm...
+ info BTF .btf.vmlinux.bin.o
+ [ !=silent_]
+ printf %-7s %s\n BTF .btf.vmlinux.bin.o
BTF .btf.vmlinux.bin.o
+ LLVM_OBJCOPY=llvm-objcopy/opt/pahole/bin/pahole-J .tmp_vmlinux.btf
[2] INT long unsigned int Error emitting BTF type Encountered error while encoding BTF.
+ llvm-objcopy --only-section=.BTF --set-section-flags .BTF=alloc,readonly --strip-all .tmp_vmlinux.btf .btf.vmlinux.bin.o
...
+ info BTFIDS vmlinux
+ [ !=silent_]
+ printf %-7s %s\n BTFIDS vmlinux
BTFIDS vmlinux
+./tools/bpf/resolve_btfids/resolve_btfidsvmlinux
FAILED: load BTF from vmlinux: Invalid argument
+on_exit
+ [ 255 -ne 0 ]
+ cleanup
+ rm -f .btf.vmlinux.bin.o
+ rm -f .tmp_System.map
+ rm -f .tmp_vmlinux.btf .tmp_vmlinux.kallsyms1.tmp_vmlinux.kallsyms1.S.tmp_vmlinux.kallsyms1.o .tmp_vmlinux.kallsyms2.tmp_vmlinux.kallsyms2.S.tmp_vmlinux.kallsyms 2.o
+ rm -f System.map
+ rm -f vmlinux
+ rm -f vmlinux.o
make[3]: *** [Makefile:1166: vmlinux] Error 255
Quoted 2 lines
Grepping through linux.git/tools I guess some BTF
tools/libsneed to know whatBTF_INT_UNSIGNEDis?
BTF_INT_UNSIGNED needs kernel support. Maybe to teach pahole to ignore this for now until kernel infrastructure is ready. Not sure whether this information will be useful or not for BTF. This needs to be discussed separately.
Quoted 3 lines
- Sedat -
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
Quoted 195 lines · Yonghong Song
Quoted 191 lines · Sedat Dilek
Quoted 149 lines · Sedat Dilek
Quoted 52 lines · Sedat Dilek
Quoted 42 lines · Arnaldo Carvalho de Melo
Em Fri, Feb 05, 2021 at 04:23:59PM +0100, Sedat Dilek escreveu:
Quoted 40 lines · Sedat Dilek
Quoted 17 lines · Sedat Dilek
Quoted 14 lines
Hi,
when building with pahole v1.20 and binutils v2.35.2 plus Clang v12.0.0-rc1 and DWARF-v5 I see:
...
+ info BTF .btf.vmlinux.bin.o
+ [ !=silent_]
+ printf %-7s %s\n BTF .btf.vmlinux.bin.o
BTF .btf.vmlinux.bin.o
+ LLVM_OBJCOPY=/opt/binutils/bin/objcopy/opt/pahole/bin/pahole-J .tmp_vmlinux.btf
[115] INTDW_ATE_unsigned_1Error emitting BTF type Encountered error while encoding BTF.Quoted 8 lines
Grepping the pahole sources:
$ git grep DW_ATE dwarf_loader.c: bt->is_bool = encoding == DW_ATE_boolean; dwarf_loader.c: bt->is_signed = encoding == DW_ATE_signed;Missing
DW_ATE_unsignedencoding?Checked the LLVM sources:
clang/lib/CodeGen/CGDebugInfo.cpp: Encoding =
llvm::dwarf::DW_ATE_unsigned_char;
clang/lib/CodeGen/CGDebugInfo.cpp: Encoding =llvm::dwarf::DW_ATE_unsigned;
clang/lib/CodeGen/CGDebugInfo.cpp: Encoding =llvm::dwarf::DW_ATE_unsigned_fixed;
clang/lib/CodeGen/CGDebugInfo.cpp:
?llvm::dwarf::DW_ATE_unsigned
...
lld/test/wasm/debuginfo.test:CHECK-NEXT:DW_AT_encoding
(DW_ATE_unsigned)Quoted 6 lines
Quoted 1 line
So, I will switch from GNU ld.bfd v2.35.2 to LLD-12.
Thanks for the research, probably your conclusion is correct, can you go the next step and add that part and check if the end result is the expected one?
Quoted 6 lines
Still building...
Can you give me a hand on what has to be changed in dwarves/pahole?
I guess switching from ld.bfd to ld.lld will show the same ERROR.
This builds successfully - untested:
$ git diffbtf_loader.c +1
-0@@ -107,6 +107,7 @@ static struct base_type *base_type__new(strings_t name, uint32_t attrs, bt->bit_size = size; bt->is_signed = attrs &BTF_INT_SIGNED ; bt->is_bool = attrs &BTF_INT_BOOL ; + bt->is_unsigned = attrs &BTF_INT_UNSIGNED ; bt->name_has_encoding = false; bt->float_type = float_type;}ctf.h +1
-0@@ -100,6 +100,7 @@ struct ctf_full_type {#define CTF_TYPE_INT_CHAR 0x2#define CTF_TYPE_INT_BOOL 0x4#define CTF_TYPE_INT_VARARGS 0x8 +#define CTF_TYPE_INT_UNSIGNED 0x16#define CTF_TYPE_FP_ATTRS (VAL ) ((VAL) >> 24)#define CTF_TYPE_FP_OFFSET (VAL ) (((VAL) >> 16) & 0xff)dwarf_loader.c +1
-0@@ -473,6 +473,7 @@ static struct base_type *base_type__new(Dwarf_Die *die, struct cu *cu) bt->is_bool = encoding == DW_ATE_boolean; bt->is_signed = encoding == DW_ATE_signed; bt->is_varargs = false; + bt->is_unsigned = encoding == DW_ATE_unsigned; bt->name_has_encoding = true; }dwarves.h +1
-0@@ -1261,6 +1261,7 @@ struct base_type { uint8_t is_signed:1; uint8_t is_bool:1; uint8_t is_varargs:1; + uint8_t is_unsigned:1; uint8_t float_type:4; };lib/bpf +1
-1@@ -1 +1 @@ -Subproject commit 5af3d86b5a2c5fecdc3ab83822d083edd32b4396 +Subproject commit 5af3d86b5a2c5fecdc3ab83822d083edd32b4396-dirtylibbtf.c +2
-0@@ -247,6 +247,8 @@ static const char * btf_elf__int_encoding_str(uint8_t encoding) return "CHAR"; else if (encoding == BTF_INT_BOOL) return "BOOL"; + else if (encoding == BTF_INT_UNSIGNED) + return "UNSIGNED"; else return "UNKN";}
libbtf.c +2
-0@@ -379,6 +381,8 @@ int32_t btf_elf__add_base_type(struct btf_elf *btfe, const struct base_type *bt, encoding =BTF_INT_SIGNED ; }else if (bt->is_bool) { encoding =BTF_INT_BOOL ; + }else if (bt->is_unsigned) { + encoding =BTF_INT_UNSIGNED ; }else if (bt->float_type) {fprintf (stderr,"float_type is not supported\n" );return -1;Additionally - I cannot see it with
git diff:[
lib/bpf/include/uapi/linux/btf.h]Quoted 8 lines
/* Attributes stored in the
BTF_INT_ENCODING*/
#defineBTF_INT_SIGNED(1 << 0)
#defineBTF_INT_CHAR(1 << 1)
#defineBTF_INT_BOOL(1 << 2)
#defineBTF_INT_UNSIGNED(1 << 3)Comments?
Hmmm...
+ info BTF .btf.vmlinux.bin.o
+ [ !=silent_]
+ printf %-7s %s\n BTF .btf.vmlinux.bin.o
BTF .btf.vmlinux.bin.o
+ LLVM_OBJCOPY=llvm-objcopy/opt/pahole/bin/pahole-J .tmp_vmlinux.btf
[2] INT long unsigned int Error emitting BTF type Encountered error while encoding BTF.
+ llvm-objcopy --only-section=.BTF --set-section-flags .BTF=alloc,readonly --strip-all .tmp_vmlinux.btf .btf.vmlinux.bin.o
...
+ info BTFIDS vmlinux
+ [ !=silent_]
+ printf %-7s %s\n BTFIDS vmlinux
BTFIDS vmlinux
+./tools/bpf/resolve_btfids/resolve_btfidsvmlinux
FAILED: load BTF from vmlinux: Invalid argument
+on_exit
+ [ 255 -ne 0 ]
+ cleanup
+ rm -f .btf.vmlinux.bin.o
+ rm -f .tmp_System.map
+ rm -f .tmp_vmlinux.btf .tmp_vmlinux.kallsyms1.tmp_vmlinux.kallsyms1.S.tmp_vmlinux.kallsyms1.o .tmp_vmlinux.kallsyms2.tmp_vmlinux.kallsyms2.S.tmp_vmlinux.kallsyms 2.o
+ rm -f System.map
+ rm -f vmlinux
+ rm -f vmlinux.o
make[3]: *** [Makefile:1166: vmlinux] Error 255
Quoted 8 lines
Quoted 2 lines
Grepping through linux.git/tools I guess some BTF
tools/libsneed to know whatBTF_INT_UNSIGNEDis?
BTF_INT_UNSIGNEDneeds kernel support. Maybe to teach pahole to ignore this for now until kernel infrastructure is ready. Not sure whether this information will be useful or not for BTF. This needs to be discussed separately.
[ CC Fangrui ]
How can I teach pahole to ignore BTF_INT_UNSIGNED?
Another tryout might be to use "-fbinutils-version=..." which is available for LLVM-12 according to Fangrui?
Fangrui, which binutils versions can I pass and how?
Thanks.
- Sedat -
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
Quoted 206 lines · Sedat Dilek
Quoted 195 lines · Yonghong Song
Quoted 191 lines · Sedat Dilek
Quoted 149 lines · Sedat Dilek
Quoted 52 lines · Sedat Dilek
Quoted 42 lines · Arnaldo Carvalho de Melo
Em Fri, Feb 05, 2021 at 04:23:59PM +0100, Sedat Dilek escreveu:
Quoted 40 lines · Sedat Dilek
Quoted 17 lines · Sedat Dilek
Quoted 14 lines
Hi,
when building with pahole v1.20 and binutils v2.35.2 plus Clang v12.0.0-rc1 and DWARF-v5 I see:
...
+ info BTF .btf.vmlinux.bin.o
+ [ !=silent_]
+ printf %-7s %s\n BTF .btf.vmlinux.bin.o
BTF .btf.vmlinux.bin.o
+ LLVM_OBJCOPY=/opt/binutils/bin/objcopy/opt/pahole/bin/pahole-J .tmp_vmlinux.btf
[115] INTDW_ATE_unsigned_1Error emitting BTF type Encountered error while encoding BTF.Quoted 8 lines
Grepping the pahole sources:
$ git grep DW_ATE dwarf_loader.c: bt->is_bool = encoding == DW_ATE_boolean; dwarf_loader.c: bt->is_signed = encoding == DW_ATE_signed;Missing
DW_ATE_unsignedencoding?Checked the LLVM sources:
clang/lib/CodeGen/CGDebugInfo.cpp: Encoding =
llvm::dwarf::DW_ATE_unsigned_char;
clang/lib/CodeGen/CGDebugInfo.cpp: Encoding =llvm::dwarf::DW_ATE_unsigned;
clang/lib/CodeGen/CGDebugInfo.cpp: Encoding =llvm::dwarf::DW_ATE_unsigned_fixed;
clang/lib/CodeGen/CGDebugInfo.cpp:
?llvm::dwarf::DW_ATE_unsigned
...
lld/test/wasm/debuginfo.test:CHECK-NEXT:DW_AT_encoding
(DW_ATE_unsigned)Quoted 6 lines
Quoted 1 line
So, I will switch from GNU ld.bfd v2.35.2 to LLD-12.
Thanks for the research, probably your conclusion is correct, can you go the next step and add that part and check if the end result is the expected one?
Quoted 6 lines
Still building...
Can you give me a hand on what has to be changed in dwarves/pahole?
I guess switching from ld.bfd to ld.lld will show the same ERROR.
This builds successfully - untested:
$ git diffbtf_loader.c +1
-0@@ -107,6 +107,7 @@ static struct base_type *base_type__new(strings_t name, uint32_t attrs, bt->bit_size = size; bt->is_signed = attrs &BTF_INT_SIGNED ; bt->is_bool = attrs &BTF_INT_BOOL ; + bt->is_unsigned = attrs &BTF_INT_UNSIGNED ; bt->name_has_encoding = false; bt->float_type = float_type;}ctf.h +1
-0@@ -100,6 +100,7 @@ struct ctf_full_type {#define CTF_TYPE_INT_CHAR 0x2#define CTF_TYPE_INT_BOOL 0x4#define CTF_TYPE_INT_VARARGS 0x8 +#define CTF_TYPE_INT_UNSIGNED 0x16#define CTF_TYPE_FP_ATTRS (VAL ) ((VAL) >> 24)#define CTF_TYPE_FP_OFFSET (VAL ) (((VAL) >> 16) & 0xff)dwarf_loader.c +1
-0@@ -473,6 +473,7 @@ static struct base_type *base_type__new(Dwarf_Die *die, struct cu *cu) bt->is_bool = encoding == DW_ATE_boolean; bt->is_signed = encoding == DW_ATE_signed; bt->is_varargs = false; + bt->is_unsigned = encoding == DW_ATE_unsigned; bt->name_has_encoding = true; }dwarves.h +1
-0@@ -1261,6 +1261,7 @@ struct base_type { uint8_t is_signed:1; uint8_t is_bool:1; uint8_t is_varargs:1; + uint8_t is_unsigned:1; uint8_t float_type:4; };lib/bpf +1
-1@@ -1 +1 @@ -Subproject commit 5af3d86b5a2c5fecdc3ab83822d083edd32b4396 +Subproject commit 5af3d86b5a2c5fecdc3ab83822d083edd32b4396-dirtylibbtf.c +2
-0@@ -247,6 +247,8 @@ static const char * btf_elf__int_encoding_str(uint8_t encoding) return "CHAR"; else if (encoding == BTF_INT_BOOL) return "BOOL"; + else if (encoding == BTF_INT_UNSIGNED) + return "UNSIGNED"; else return "UNKN";}
libbtf.c +2
-0@@ -379,6 +381,8 @@ int32_t btf_elf__add_base_type(struct btf_elf *btfe, const struct base_type *bt, encoding =BTF_INT_SIGNED ; }else if (bt->is_bool) { encoding =BTF_INT_BOOL ; + }else if (bt->is_unsigned) { + encoding =BTF_INT_UNSIGNED ; }else if (bt->float_type) {fprintf (stderr,"float_type is not supported\n" );return -1;Additionally - I cannot see it with
git diff:[
lib/bpf/include/uapi/linux/btf.h]Quoted 8 lines
/* Attributes stored in the
BTF_INT_ENCODING*/
#defineBTF_INT_SIGNED(1 << 0)
#defineBTF_INT_CHAR(1 << 1)
#defineBTF_INT_BOOL(1 << 2)
#defineBTF_INT_UNSIGNED(1 << 3)Comments?
Hmmm...
+ info BTF .btf.vmlinux.bin.o
+ [ !=silent_]
+ printf %-7s %s\n BTF .btf.vmlinux.bin.o
BTF .btf.vmlinux.bin.o
+ LLVM_OBJCOPY=llvm-objcopy/opt/pahole/bin/pahole-J .tmp_vmlinux.btf
[2] INT long unsigned int Error emitting BTF type Encountered error while encoding BTF.
+ llvm-objcopy --only-section=.BTF --set-section-flags .BTF=alloc,readonly --strip-all .tmp_vmlinux.btf .btf.vmlinux.bin.o
...
+ info BTFIDS vmlinux
+ [ !=silent_]
+ printf %-7s %s\n BTFIDS vmlinux
BTFIDS vmlinux
+./tools/bpf/resolve_btfids/resolve_btfidsvmlinux
FAILED: load BTF from vmlinux: Invalid argument
+on_exit
+ [ 255 -ne 0 ]
+ cleanup
+ rm -f .btf.vmlinux.bin.o
+ rm -f .tmp_System.map
+ rm -f .tmp_vmlinux.btf .tmp_vmlinux.kallsyms1.tmp_vmlinux.kallsyms1.S.tmp_vmlinux.kallsyms1.o .tmp_vmlinux.kallsyms2.tmp_vmlinux.kallsyms2.S.tmp_vmlinux.kallsyms 2.o
+ rm -f System.map
+ rm -f vmlinux
+ rm -f vmlinux.o
make[3]: *** [Makefile:1166: vmlinux] Error 255Quoted 8 lines
Quoted 2 lines
Grepping through linux.git/tools I guess some BTF
tools/libsneed to know whatBTF_INT_UNSIGNEDis?
BTF_INT_UNSIGNEDneeds kernel support. Maybe to teach pahole to ignore this for now until kernel infrastructure is ready. Not sure whether this information will be useful or not for BTF. This needs to be discussed separately.
Quoted 8 lines
[ CC Fangrui ]
How can I teach pahole to ignore
BTF_INT_UNSIGNED?Another tryout might be to use "-fbinutils-version=..." which is available for LLVM-12 according to Fangrui?
Fangrui, which binutils versions can I pass and how?
OK, I checked LLVM-12 sources:
clang/docs/ReleaseNotes.rst:101:- New option ``-fbinutils-version=`` specifies the targeted binutils version. clang/docs/ReleaseNotes.rst:102: For example, ``-fbinutils-version=2.35`` means compatibility with GNU as/ld clang/docs/ReleaseNotes.rst-103- before 2.35 is not needed: new features can be used and there is no need to clang/docs/ReleaseNotes.rst-104- work around old GNU as/ld bugs.
Can I pass (also patchlevel) like 2.35.2? Here I have Debian's v2.35.1 and a selfmade v2.35.2?
- Sedat -
- Sedat -
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
Quoted 227 lines · Sedat Dilek
Quoted 206 lines · Sedat Dilek
Quoted 195 lines · Yonghong Song
Quoted 191 lines · Sedat Dilek
Quoted 149 lines · Sedat Dilek
Quoted 52 lines · Sedat Dilek
Quoted 42 lines · Arnaldo Carvalho de Melo
Em Fri, Feb 05, 2021 at 04:23:59PM +0100, Sedat Dilek escreveu:
Quoted 40 lines · Sedat Dilek
Quoted 17 lines · Sedat Dilek
Quoted 14 lines
Hi,
when building with pahole v1.20 and binutils v2.35.2 plus Clang v12.0.0-rc1 and DWARF-v5 I see:
...
+ info BTF .btf.vmlinux.bin.o
+ [ !=silent_]
+ printf %-7s %s\n BTF .btf.vmlinux.bin.o
BTF .btf.vmlinux.bin.o
+ LLVM_OBJCOPY=/opt/binutils/bin/objcopy/opt/pahole/bin/pahole-J .tmp_vmlinux.btf
[115] INTDW_ATE_unsigned_1Error emitting BTF type Encountered error while encoding BTF.Quoted 8 lines
Grepping the pahole sources:
$ git grep DW_ATE dwarf_loader.c: bt->is_bool = encoding == DW_ATE_boolean; dwarf_loader.c: bt->is_signed = encoding == DW_ATE_signed;Missing
DW_ATE_unsignedencoding?Checked the LLVM sources:
clang/lib/CodeGen/CGDebugInfo.cpp: Encoding =
llvm::dwarf::DW_ATE_unsigned_char;
clang/lib/CodeGen/CGDebugInfo.cpp: Encoding =llvm::dwarf::DW_ATE_unsigned;
clang/lib/CodeGen/CGDebugInfo.cpp: Encoding =llvm::dwarf::DW_ATE_unsigned_fixed;
clang/lib/CodeGen/CGDebugInfo.cpp:
?llvm::dwarf::DW_ATE_unsigned
...
lld/test/wasm/debuginfo.test:CHECK-NEXT:DW_AT_encoding
(DW_ATE_unsigned)Quoted 6 lines
Quoted 1 line
So, I will switch from GNU ld.bfd v2.35.2 to LLD-12.
Thanks for the research, probably your conclusion is correct, can you go the next step and add that part and check if the end result is the expected one?
Quoted 6 lines
Still building...
Can you give me a hand on what has to be changed in dwarves/pahole?
I guess switching from ld.bfd to ld.lld will show the same ERROR.
This builds successfully - untested:
$ git diffbtf_loader.c +1
-0@@ -107,6 +107,7 @@ static struct base_type *base_type__new(strings_t name, uint32_t attrs, bt->bit_size = size; bt->is_signed = attrs &BTF_INT_SIGNED ; bt->is_bool = attrs &BTF_INT_BOOL ; + bt->is_unsigned = attrs &BTF_INT_UNSIGNED ; bt->name_has_encoding = false; bt->float_type = float_type;}ctf.h +1
-0@@ -100,6 +100,7 @@ struct ctf_full_type {#define CTF_TYPE_INT_CHAR 0x2#define CTF_TYPE_INT_BOOL 0x4#define CTF_TYPE_INT_VARARGS 0x8 +#define CTF_TYPE_INT_UNSIGNED 0x16#define CTF_TYPE_FP_ATTRS (VAL ) ((VAL) >> 24)#define CTF_TYPE_FP_OFFSET (VAL ) (((VAL) >> 16) & 0xff)dwarf_loader.c +1
-0@@ -473,6 +473,7 @@ static struct base_type *base_type__new(Dwarf_Die *die, struct cu *cu) bt->is_bool = encoding == DW_ATE_boolean; bt->is_signed = encoding == DW_ATE_signed; bt->is_varargs = false; + bt->is_unsigned = encoding == DW_ATE_unsigned; bt->name_has_encoding = true; }dwarves.h +1
-0@@ -1261,6 +1261,7 @@ struct base_type { uint8_t is_signed:1; uint8_t is_bool:1; uint8_t is_varargs:1; + uint8_t is_unsigned:1; uint8_t float_type:4; };lib/bpf +1
-1@@ -1 +1 @@ -Subproject commit 5af3d86b5a2c5fecdc3ab83822d083edd32b4396 +Subproject commit 5af3d86b5a2c5fecdc3ab83822d083edd32b4396-dirtylibbtf.c +2
-0@@ -247,6 +247,8 @@ static const char * btf_elf__int_encoding_str(uint8_t encoding) return "CHAR"; else if (encoding == BTF_INT_BOOL) return "BOOL"; + else if (encoding == BTF_INT_UNSIGNED) + return "UNSIGNED"; else return "UNKN";}
libbtf.c +2
-0@@ -379,6 +381,8 @@ int32_t btf_elf__add_base_type(struct btf_elf *btfe, const struct base_type *bt, encoding =BTF_INT_SIGNED ; }else if (bt->is_bool) { encoding =BTF_INT_BOOL ; + }else if (bt->is_unsigned) { + encoding =BTF_INT_UNSIGNED ; }else if (bt->float_type) {fprintf (stderr,"float_type is not supported\n" );return -1;Additionally - I cannot see it with
git diff:[
lib/bpf/include/uapi/linux/btf.h]Quoted 8 lines
/* Attributes stored in the
BTF_INT_ENCODING*/
#defineBTF_INT_SIGNED(1 << 0)
#defineBTF_INT_CHAR(1 << 1)
#defineBTF_INT_BOOL(1 << 2)
#defineBTF_INT_UNSIGNED(1 << 3)Comments?
Hmmm...
+ info BTF .btf.vmlinux.bin.o
+ [ !=silent_]
+ printf %-7s %s\n BTF .btf.vmlinux.bin.o
BTF .btf.vmlinux.bin.o
+ LLVM_OBJCOPY=llvm-objcopy/opt/pahole/bin/pahole-J .tmp_vmlinux.btf
[2] INT long unsigned int Error emitting BTF type Encountered error while encoding BTF.
+ llvm-objcopy --only-section=.BTF --set-section-flags .BTF=alloc,readonly --strip-all .tmp_vmlinux.btf .btf.vmlinux.bin.o
...
+ info BTFIDS vmlinux
+ [ !=silent_]
+ printf %-7s %s\n BTFIDS vmlinux
BTFIDS vmlinux
+./tools/bpf/resolve_btfids/resolve_btfidsvmlinux
FAILED: load BTF from vmlinux: Invalid argument
+on_exit
+ [ 255 -ne 0 ]
+ cleanup
+ rm -f .btf.vmlinux.bin.o
+ rm -f .tmp_System.map
+ rm -f .tmp_vmlinux.btf .tmp_vmlinux.kallsyms1.tmp_vmlinux.kallsyms1.S.tmp_vmlinux.kallsyms1.o .tmp_vmlinux.kallsyms2.tmp_vmlinux.kallsyms2.S.tmp_vmlinux.kallsyms 2.o
+ rm -f System.map
+ rm -f vmlinux
+ rm -f vmlinux.o
make[3]: *** [Makefile:1166: vmlinux] Error 255Quoted 8 lines
Quoted 2 lines
Grepping through linux.git/tools I guess some BTF
tools/libsneed to know whatBTF_INT_UNSIGNEDis?
BTF_INT_UNSIGNEDneeds kernel support. Maybe to teach pahole to ignore this for now until kernel infrastructure is ready. Not sure whether this information will be useful or not for BTF. This needs to be discussed separately.Quoted 8 lines
[ CC Fangrui ]
How can I teach pahole to ignore
BTF_INT_UNSIGNED?Another tryout might be to use "-fbinutils-version=..." which is available for LLVM-12 according to Fangrui?
Fangrui, which binutils versions can I pass and how?OK, I checked LLVM-12 sources:
clang/docs/ReleaseNotes.rst:101:- New option ``-fbinutils-version=`` specifies the targeted binutils version.
clang/docs/ReleaseNotes.rst:102: For example, ``-fbinutils-version=2.35`` means compatibility with GNU as/ld clang/docs/ReleaseNotes.rst-103- before 2.35 is not needed: new features can be used and there is no need to clang/docs/ReleaseNotes.rst-104- work around old GNU as/ld bugs.
Quoted 6 lines
Can I pass (also patchlevel) like 2.35.2? Here I have Debian's v2.35.1 and a selfmade v2.35.2?
- Sedat -
- Sedat -
Answering specifically this question:
clang -help displays:
...
-fbinutils-version=<major.minor>
Produced object files can use all ELF
features supported by this binutils version and newer. If -fno-integrated-as is specified, the generated assembly will consider GNU as support. 'none' means that all ELF features can be used, regardless of binutils support. Defaults to 2.26.
The option was introduced in https://reviews.llvm.org/D85474
major.minor.patch is not supported. In reality, very few features are gated by this option, currently just SHF_MERGE and a pending SHF_LINK_ORDER PGO patch.
I think we will be conservative. If a 2.37 fix is back ported to 2.35.2 and 2.36.1, we will ignore that and will use the feature only if -fbinutils-version=2.37 or above is specified.
Signature · 1 line
宋方睿
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
Quoted 247 lines · Fāng-ruì Sòng
Quoted 227 lines · Sedat Dilek
Quoted 206 lines · Sedat Dilek
Quoted 195 lines · Yonghong Song
Quoted 191 lines · Sedat Dilek
Quoted 149 lines · Sedat Dilek
Quoted 52 lines · Sedat Dilek
Quoted 42 lines · Arnaldo Carvalho de Melo
Em Fri, Feb 05, 2021 at 04:23:59PM +0100, Sedat Dilek escreveu:
Quoted 40 lines · Sedat Dilek
Quoted 17 lines · Sedat Dilek
Quoted 14 lines
Hi,
when building with pahole v1.20 and binutils v2.35.2 plus Clang v12.0.0-rc1 and DWARF-v5 I see:
...
+ info BTF .btf.vmlinux.bin.o
+ [ !=silent_]
+ printf %-7s %s\n BTF .btf.vmlinux.bin.o
BTF .btf.vmlinux.bin.o
+ LLVM_OBJCOPY=/opt/binutils/bin/objcopy/opt/pahole/bin/pahole-J .tmp_vmlinux.btf
[115] INTDW_ATE_unsigned_1Error emitting BTF type Encountered error while encoding BTF.Quoted 8 lines
Grepping the pahole sources:
$ git grep DW_ATE dwarf_loader.c: bt->is_bool = encoding == DW_ATE_boolean; dwarf_loader.c: bt->is_signed = encoding == DW_ATE_signed;Missing
DW_ATE_unsignedencoding?Checked the LLVM sources:
clang/lib/CodeGen/CGDebugInfo.cpp: Encoding =
llvm::dwarf::DW_ATE_unsigned_char;
clang/lib/CodeGen/CGDebugInfo.cpp: Encoding =llvm::dwarf::DW_ATE_unsigned;
clang/lib/CodeGen/CGDebugInfo.cpp: Encoding =llvm::dwarf::DW_ATE_unsigned_fixed;
clang/lib/CodeGen/CGDebugInfo.cpp:
?llvm::dwarf::DW_ATE_unsigned
...
lld/test/wasm/debuginfo.test:CHECK-NEXT:DW_AT_encoding
(DW_ATE_unsigned)Quoted 6 lines
Quoted 1 line
So, I will switch from GNU ld.bfd v2.35.2 to LLD-12.
Thanks for the research, probably your conclusion is correct, can you go the next step and add that part and check if the end result is the expected one?
Quoted 6 lines
Still building...
Can you give me a hand on what has to be changed in dwarves/pahole?
I guess switching from ld.bfd to ld.lld will show the same ERROR.
This builds successfully - untested:
$ git diffbtf_loader.c +1
-0@@ -107,6 +107,7 @@ static struct base_type *base_type__new(strings_t name, uint32_t attrs, bt->bit_size = size; bt->is_signed = attrs &BTF_INT_SIGNED ; bt->is_bool = attrs &BTF_INT_BOOL ; + bt->is_unsigned = attrs &BTF_INT_UNSIGNED ; bt->name_has_encoding = false; bt->float_type = float_type;}ctf.h +1
-0@@ -100,6 +100,7 @@ struct ctf_full_type {#define CTF_TYPE_INT_CHAR 0x2#define CTF_TYPE_INT_BOOL 0x4#define CTF_TYPE_INT_VARARGS 0x8 +#define CTF_TYPE_INT_UNSIGNED 0x16#define CTF_TYPE_FP_ATTRS (VAL ) ((VAL) >> 24)#define CTF_TYPE_FP_OFFSET (VAL ) (((VAL) >> 16) & 0xff)dwarf_loader.c +1
-0@@ -473,6 +473,7 @@ static struct base_type *base_type__new(Dwarf_Die *die, struct cu *cu) bt->is_bool = encoding == DW_ATE_boolean; bt->is_signed = encoding == DW_ATE_signed; bt->is_varargs = false; + bt->is_unsigned = encoding == DW_ATE_unsigned; bt->name_has_encoding = true; }dwarves.h +1
-0@@ -1261,6 +1261,7 @@ struct base_type { uint8_t is_signed:1; uint8_t is_bool:1; uint8_t is_varargs:1; + uint8_t is_unsigned:1; uint8_t float_type:4; };lib/bpf +1
-1@@ -1 +1 @@ -Subproject commit 5af3d86b5a2c5fecdc3ab83822d083edd32b4396 +Subproject commit 5af3d86b5a2c5fecdc3ab83822d083edd32b4396-dirtylibbtf.c +2
-0@@ -247,6 +247,8 @@ static const char * btf_elf__int_encoding_str(uint8_t encoding) return "CHAR"; else if (encoding == BTF_INT_BOOL) return "BOOL"; + else if (encoding == BTF_INT_UNSIGNED) + return "UNSIGNED"; else return "UNKN";}
libbtf.c +2
-0@@ -379,6 +381,8 @@ int32_t btf_elf__add_base_type(struct btf_elf *btfe, const struct base_type *bt, encoding =BTF_INT_SIGNED ; }else if (bt->is_bool) { encoding =BTF_INT_BOOL ; + }else if (bt->is_unsigned) { + encoding =BTF_INT_UNSIGNED ; }else if (bt->float_type) {fprintf (stderr,"float_type is not supported\n" );return -1;Additionally - I cannot see it with
git diff:[
lib/bpf/include/uapi/linux/btf.h]Quoted 8 lines
/* Attributes stored in the
BTF_INT_ENCODING*/
#defineBTF_INT_SIGNED(1 << 0)
#defineBTF_INT_CHAR(1 << 1)
#defineBTF_INT_BOOL(1 << 2)
#defineBTF_INT_UNSIGNED(1 << 3)Comments?
Hmmm...
+ info BTF .btf.vmlinux.bin.o
+ [ !=silent_]
+ printf %-7s %s\n BTF .btf.vmlinux.bin.o
BTF .btf.vmlinux.bin.o
+ LLVM_OBJCOPY=llvm-objcopy/opt/pahole/bin/pahole-J .tmp_vmlinux.btf
[2] INT long unsigned int Error emitting BTF type Encountered error while encoding BTF.
+ llvm-objcopy --only-section=.BTF --set-section-flags .BTF=alloc,readonly --strip-all .tmp_vmlinux.btf .btf.vmlinux.bin.o
...
+ info BTFIDS vmlinux
+ [ !=silent_]
+ printf %-7s %s\n BTFIDS vmlinux
BTFIDS vmlinux
+./tools/bpf/resolve_btfids/resolve_btfidsvmlinux
FAILED: load BTF from vmlinux: Invalid argument
+on_exit
+ [ 255 -ne 0 ]
+ cleanup
+ rm -f .btf.vmlinux.bin.o
+ rm -f .tmp_System.map
+ rm -f .tmp_vmlinux.btf .tmp_vmlinux.kallsyms1.tmp_vmlinux.kallsyms1.S.tmp_vmlinux.kallsyms1.o .tmp_vmlinux.kallsyms2.tmp_vmlinux.kallsyms2.S.tmp_vmlinux.kallsyms 2.o
+ rm -f System.map
+ rm -f vmlinux
+ rm -f vmlinux.o
make[3]: *** [Makefile:1166: vmlinux] Error 255Quoted 8 lines
Quoted 2 lines
Grepping through linux.git/tools I guess some BTF
tools/libsneed to know whatBTF_INT_UNSIGNEDis?
BTF_INT_UNSIGNEDneeds kernel support. Maybe to teach pahole to ignore this for now until kernel infrastructure is ready. Not sure whether this information will be useful or not for BTF. This needs to be discussed separately.Quoted 8 lines
[ CC Fangrui ]
How can I teach pahole to ignore
BTF_INT_UNSIGNED?Another tryout might be to use "-fbinutils-version=..." which is available for LLVM-12 according to Fangrui?
Fangrui, which binutils versions can I pass and how?OK, I checked LLVM-12 sources:
clang/docs/ReleaseNotes.rst:101:- New option ``-fbinutils-version=`` specifies the targeted binutils version.
clang/docs/ReleaseNotes.rst:102: For example, ``-fbinutils-version=2.35`` means compatibility with GNU as/ld clang/docs/ReleaseNotes.rst-103- before 2.35 is not needed: new features can be used and there is no need to clang/docs/ReleaseNotes.rst-104- work around old GNU as/ld bugs.Quoted 6 lines
Can I pass (also patchlevel) like 2.35.2? Here I have Debian's v2.35.1 and a selfmade v2.35.2?
- Sedat -
- Sedat -
Answering specifically this question:
clang -help displays:
...
-fbinutils-version=<major.minor>
Produced object files can use all ELF
features supported by this binutils version and newer. If -fno-integrated-as is specified, the generated assembly will consider GNU as support. 'none' means that all ELF features can be used, regardless of binutils support. Defaults to 2.26.
Quoted 8 lines
The option was introduced in https://reviews.llvm.org/D85474
major.minor.patch is not supported. In reality, very few features are gated by this option, currently justSHF_MERGEand a pendingSHF_LINK_ORDERPGO patch.
I think we will be conservative. If a 2.37 fix is back ported to 2.35.2 and 2.36.1, we will ignore that and will use the feature only if -fbinutils-version=2.37 or above is specified.
Binutils v2.35.2 has DWARF-5 fixes which are not in vanilla v2.36 - I might be wrong, please correct me.
So what shall I pass now to -fbinutils-version= ?
- Sedat -
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
In reply to Sedat DilekQuoted 205 lines · Sedat Dilek
Quoted 195 lines · Yonghong Song
Quoted 191 lines · Sedat Dilek
Quoted 149 lines · Sedat Dilek
Quoted 52 lines · Sedat Dilek
Quoted 42 lines · Arnaldo Carvalho de Melo
Em Fri, Feb 05, 2021 at 04:23:59PM +0100, Sedat Dilek escreveu:
Quoted 40 lines · Sedat Dilek
Quoted 17 lines · Sedat Dilek
Quoted 14 lines
Hi,
when building with pahole v1.20 and binutils v2.35.2 plus Clang v12.0.0-rc1 and DWARF-v5 I see:
...
+ info BTF .btf.vmlinux.bin.o
+ [ !=silent_]
+ printf %-7s %s\n BTF .btf.vmlinux.bin.o
BTF .btf.vmlinux.bin.o
+ LLVM_OBJCOPY=/opt/binutils/bin/objcopy/opt/pahole/bin/pahole-J .tmp_vmlinux.btf
[115] INTDW_ATE_unsigned_1Error emitting BTF type Encountered error while encoding BTF.Quoted 8 lines
Grepping the pahole sources:
$ git grep DW_ATE dwarf_loader.c: bt->is_bool = encoding == DW_ATE_boolean; dwarf_loader.c: bt->is_signed = encoding == DW_ATE_signed;Missing
DW_ATE_unsignedencoding?Checked the LLVM sources:
clang/lib/CodeGen/CGDebugInfo.cpp: Encoding =
llvm::dwarf::DW_ATE_unsigned_char;
clang/lib/CodeGen/CGDebugInfo.cpp: Encoding =llvm::dwarf::DW_ATE_unsigned;
clang/lib/CodeGen/CGDebugInfo.cpp: Encoding =llvm::dwarf::DW_ATE_unsigned_fixed;
clang/lib/CodeGen/CGDebugInfo.cpp:
?llvm::dwarf::DW_ATE_unsigned
...
lld/test/wasm/debuginfo.test:CHECK-NEXT:DW_AT_encoding
(DW_ATE_unsigned)Quoted 6 lines
Quoted 1 line
So, I will switch from GNU ld.bfd v2.35.2 to LLD-12.
Thanks for the research, probably your conclusion is correct, can you go the next step and add that part and check if the end result is the expected one?
Quoted 6 lines
Still building...
Can you give me a hand on what has to be changed in dwarves/pahole?
I guess switching from ld.bfd to ld.lld will show the same ERROR.
This builds successfully - untested:
$ git diffbtf_loader.c +1
-0@@ -107,6 +107,7 @@ static struct base_type *base_type__new(strings_t name, uint32_t attrs, bt->bit_size = size; bt->is_signed = attrs &BTF_INT_SIGNED ; bt->is_bool = attrs &BTF_INT_BOOL ; + bt->is_unsigned = attrs &BTF_INT_UNSIGNED ; bt->name_has_encoding = false; bt->float_type = float_type;}ctf.h +1
-0@@ -100,6 +100,7 @@ struct ctf_full_type {#define CTF_TYPE_INT_CHAR 0x2#define CTF_TYPE_INT_BOOL 0x4#define CTF_TYPE_INT_VARARGS 0x8 +#define CTF_TYPE_INT_UNSIGNED 0x16#define CTF_TYPE_FP_ATTRS (VAL ) ((VAL) >> 24)#define CTF_TYPE_FP_OFFSET (VAL ) (((VAL) >> 16) & 0xff)dwarf_loader.c +1
-0@@ -473,6 +473,7 @@ static struct base_type *base_type__new(Dwarf_Die *die, struct cu *cu) bt->is_bool = encoding == DW_ATE_boolean; bt->is_signed = encoding == DW_ATE_signed; bt->is_varargs = false; + bt->is_unsigned = encoding == DW_ATE_unsigned; bt->name_has_encoding = true; }dwarves.h +1
-0@@ -1261,6 +1261,7 @@ struct base_type { uint8_t is_signed:1; uint8_t is_bool:1; uint8_t is_varargs:1; + uint8_t is_unsigned:1; uint8_t float_type:4; };lib/bpf +1
-1@@ -1 +1 @@ -Subproject commit 5af3d86b5a2c5fecdc3ab83822d083edd32b4396 +Subproject commit 5af3d86b5a2c5fecdc3ab83822d083edd32b4396-dirtylibbtf.c +2
-0@@ -247,6 +247,8 @@ static const char * btf_elf__int_encoding_str(uint8_t encoding) return "CHAR"; else if (encoding == BTF_INT_BOOL) return "BOOL"; + else if (encoding == BTF_INT_UNSIGNED) + return "UNSIGNED"; else return "UNKN";}
libbtf.c +2
-0@@ -379,6 +381,8 @@ int32_t btf_elf__add_base_type(struct btf_elf *btfe, const struct base_type *bt, encoding =BTF_INT_SIGNED ; }else if (bt->is_bool) { encoding =BTF_INT_BOOL ; + }else if (bt->is_unsigned) { + encoding =BTF_INT_UNSIGNED ; }else if (bt->float_type) {fprintf (stderr,"float_type is not supported\n" );return -1;Additionally - I cannot see it with
git diff:[
lib/bpf/include/uapi/linux/btf.h]Quoted 8 lines
/* Attributes stored in the
BTF_INT_ENCODING*/
#defineBTF_INT_SIGNED(1 << 0)
#defineBTF_INT_CHAR(1 << 1)
#defineBTF_INT_BOOL(1 << 2)
#defineBTF_INT_UNSIGNED(1 << 3)Comments?
Hmmm...
+ info BTF .btf.vmlinux.bin.o
+ [ !=silent_]
+ printf %-7s %s\n BTF .btf.vmlinux.bin.o
BTF .btf.vmlinux.bin.o
+ LLVM_OBJCOPY=llvm-objcopy/opt/pahole/bin/pahole-J .tmp_vmlinux.btf
[2] INT long unsigned int Error emitting BTF type Encountered error while encoding BTF.
+ llvm-objcopy --only-section=.BTF --set-section-flags .BTF=alloc,readonly --strip-all .tmp_vmlinux.btf .btf.vmlinux.bin.o
...
+ info BTFIDS vmlinux
+ [ !=silent_]
+ printf %-7s %s\n BTFIDS vmlinux
BTFIDS vmlinux
+./tools/bpf/resolve_btfids/resolve_btfidsvmlinux
FAILED: load BTF from vmlinux: Invalid argument
+on_exit
+ [ 255 -ne 0 ]
+ cleanup
+ rm -f .btf.vmlinux.bin.o
+ rm -f .tmp_System.map
+ rm -f .tmp_vmlinux.btf .tmp_vmlinux.kallsyms1.tmp_vmlinux.kallsyms1.S.tmp_vmlinux.kallsyms1.o .tmp_vmlinux.kallsyms2.tmp_vmlinux.kallsyms2.S.tmp_vmlinux.kallsyms 2.o
+ rm -f System.map
+ rm -f vmlinux
+ rm -f vmlinux.o
make[3]: *** [Makefile:1166: vmlinux] Error 255Quoted 8 lines
Quoted 2 lines
Grepping through linux.git/tools I guess some BTF
tools/libsneed to know whatBTF_INT_UNSIGNEDis?
BTF_INT_UNSIGNEDneeds kernel support. Maybe to teach pahole to ignore this for now until kernel infrastructure is ready. Not sure whether this information will be useful or not for BTF. This needs to be discussed separately.
Quoted 3 lines
[ CC Fangrui ]
How can I teach pahole to ignore
BTF_INT_UNSIGNED?
i mean for the following:
@@ -379,6 +381,8 @@ int32_t btf_elf__add_base_type(struct btf_elf *btfe, const struct base_type *bt,
encoding = BTF_INT_SIGNED;
} else if (bt->is_bool) {
encoding = BTF_INT_BOOL;
+ } else if (bt->is_unsigned) {
+ encoding = BTF_INT_UNSIGNED;
} else if (bt->float_type) {
fprintf(stderr, "float_type is not supported\n");
return -1;You can do
@@ -379,6 +381,8 @@ int32_t btf_elf__add_base_type(struct btf_elf *btfe, const struct base_type *bt,
encoding = BTF_INT_SIGNED;
} else if (bt->is_bool) {
encoding = BTF_INT_BOOL;
+ } else if (bt->is_unsigned) {
+ ; /* ignored for now */
} else if (bt->float_type) {
fprintf(stderr, "float_type is not supported\n");
return -1;The default encoding is 0 which indicates an unsigned int.
Quoted 10 lines
Another tryout might be to use "-fbinutils-version=..." which is available for LLVM-12 according to Fangrui?
Fangrui, which binutils versions can I pass and how?Thanks.
- Sedat -
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
Quoted 239 lines · Yonghong Song
Quoted 205 lines · Sedat Dilek
Quoted 195 lines · Yonghong Song
Quoted 191 lines · Sedat Dilek
Quoted 149 lines · Sedat Dilek
Quoted 52 lines · Sedat Dilek
Quoted 42 lines · Arnaldo Carvalho de Melo
Em Fri, Feb 05, 2021 at 04:23:59PM +0100, Sedat Dilek escreveu:
Quoted 40 lines · Sedat Dilek
Quoted 17 lines · Sedat Dilek
Quoted 14 lines
Hi,
when building with pahole v1.20 and binutils v2.35.2 plus Clang v12.0.0-rc1 and DWARF-v5 I see:
...
+ info BTF .btf.vmlinux.bin.o
+ [ !=silent_]
+ printf %-7s %s\n BTF .btf.vmlinux.bin.o
BTF .btf.vmlinux.bin.o
+ LLVM_OBJCOPY=/opt/binutils/bin/objcopy/opt/pahole/bin/pahole-J .tmp_vmlinux.btf
[115] INTDW_ATE_unsigned_1Error emitting BTF type Encountered error while encoding BTF.Quoted 8 lines
Grepping the pahole sources:
$ git grep DW_ATE dwarf_loader.c: bt->is_bool = encoding == DW_ATE_boolean; dwarf_loader.c: bt->is_signed = encoding == DW_ATE_signed;Missing
DW_ATE_unsignedencoding?Checked the LLVM sources:
clang/lib/CodeGen/CGDebugInfo.cpp: Encoding =
llvm::dwarf::DW_ATE_unsigned_char;
clang/lib/CodeGen/CGDebugInfo.cpp: Encoding =llvm::dwarf::DW_ATE_unsigned;
clang/lib/CodeGen/CGDebugInfo.cpp: Encoding =llvm::dwarf::DW_ATE_unsigned_fixed;
clang/lib/CodeGen/CGDebugInfo.cpp:
?llvm::dwarf::DW_ATE_unsigned
...
lld/test/wasm/debuginfo.test:CHECK-NEXT:DW_AT_encoding
(DW_ATE_unsigned)Quoted 6 lines
Quoted 1 line
So, I will switch from GNU ld.bfd v2.35.2 to LLD-12.
Thanks for the research, probably your conclusion is correct, can you go the next step and add that part and check if the end result is the expected one?
Quoted 6 lines
Still building...
Can you give me a hand on what has to be changed in dwarves/pahole?
I guess switching from ld.bfd to ld.lld will show the same ERROR.
This builds successfully - untested:
$ git diffbtf_loader.c +1
-0@@ -107,6 +107,7 @@ static struct base_type *base_type__new(strings_t name, uint32_t attrs, bt->bit_size = size; bt->is_signed = attrs &BTF_INT_SIGNED ; bt->is_bool = attrs &BTF_INT_BOOL ; + bt->is_unsigned = attrs &BTF_INT_UNSIGNED ; bt->name_has_encoding = false; bt->float_type = float_type;}ctf.h +1
-0@@ -100,6 +100,7 @@ struct ctf_full_type {#define CTF_TYPE_INT_CHAR 0x2#define CTF_TYPE_INT_BOOL 0x4#define CTF_TYPE_INT_VARARGS 0x8 +#define CTF_TYPE_INT_UNSIGNED 0x16#define CTF_TYPE_FP_ATTRS (VAL ) ((VAL) >> 24)#define CTF_TYPE_FP_OFFSET (VAL ) (((VAL) >> 16) & 0xff)dwarf_loader.c +1
-0@@ -473,6 +473,7 @@ static struct base_type *base_type__new(Dwarf_Die *die, struct cu *cu) bt->is_bool = encoding == DW_ATE_boolean; bt->is_signed = encoding == DW_ATE_signed; bt->is_varargs = false; + bt->is_unsigned = encoding == DW_ATE_unsigned; bt->name_has_encoding = true; }dwarves.h +1
-0@@ -1261,6 +1261,7 @@ struct base_type { uint8_t is_signed:1; uint8_t is_bool:1; uint8_t is_varargs:1; + uint8_t is_unsigned:1; uint8_t float_type:4; };lib/bpf +1
-1@@ -1 +1 @@ -Subproject commit 5af3d86b5a2c5fecdc3ab83822d083edd32b4396 +Subproject commit 5af3d86b5a2c5fecdc3ab83822d083edd32b4396-dirtylibbtf.c +2
-0@@ -247,6 +247,8 @@ static const char * btf_elf__int_encoding_str(uint8_t encoding) return "CHAR"; else if (encoding == BTF_INT_BOOL) return "BOOL"; + else if (encoding == BTF_INT_UNSIGNED) + return "UNSIGNED"; else return "UNKN";}
libbtf.c +2
-0@@ -379,6 +381,8 @@ int32_t btf_elf__add_base_type(struct btf_elf *btfe, const struct base_type *bt, encoding =BTF_INT_SIGNED ; }else if (bt->is_bool) { encoding =BTF_INT_BOOL ; + }else if (bt->is_unsigned) { + encoding =BTF_INT_UNSIGNED ; }else if (bt->float_type) {fprintf (stderr,"float_type is not supported\n" );return -1;Additionally - I cannot see it with
git diff:[
lib/bpf/include/uapi/linux/btf.h]Quoted 8 lines
/* Attributes stored in the
BTF_INT_ENCODING*/
#defineBTF_INT_SIGNED(1 << 0)
#defineBTF_INT_CHAR(1 << 1)
#defineBTF_INT_BOOL(1 << 2)
#defineBTF_INT_UNSIGNED(1 << 3)Comments?
Hmmm...
+ info BTF .btf.vmlinux.bin.o
+ [ !=silent_]
+ printf %-7s %s\n BTF .btf.vmlinux.bin.o
BTF .btf.vmlinux.bin.o
+ LLVM_OBJCOPY=llvm-objcopy/opt/pahole/bin/pahole-J .tmp_vmlinux.btf
[2] INT long unsigned int Error emitting BTF type Encountered error while encoding BTF.
+ llvm-objcopy --only-section=.BTF --set-section-flags .BTF=alloc,readonly --strip-all .tmp_vmlinux.btf .btf.vmlinux.bin.o
...
+ info BTFIDS vmlinux
+ [ !=silent_]
+ printf %-7s %s\n BTFIDS vmlinux
BTFIDS vmlinux
+./tools/bpf/resolve_btfids/resolve_btfidsvmlinux
FAILED: load BTF from vmlinux: Invalid argument
+on_exit
+ [ 255 -ne 0 ]
+ cleanup
+ rm -f .btf.vmlinux.bin.o
+ rm -f .tmp_System.map
+ rm -f .tmp_vmlinux.btf .tmp_vmlinux.kallsyms1.tmp_vmlinux.kallsyms1.S.tmp_vmlinux.kallsyms1.o .tmp_vmlinux.kallsyms2.tmp_vmlinux.kallsyms2.S.tmp_vmlinux.kallsyms 2.o
+ rm -f System.map
+ rm -f vmlinux
+ rm -f vmlinux.o
make[3]: *** [Makefile:1166: vmlinux] Error 255Quoted 8 lines
Quoted 2 lines
Grepping through linux.git/tools I guess some BTF
tools/libsneed to know whatBTF_INT_UNSIGNEDis?
BTF_INT_UNSIGNEDneeds kernel support. Maybe to teach pahole to ignore this for now until kernel infrastructure is ready. Not sure whether this information will be useful or not for BTF. This needs to be discussed separately.Quoted 3 lines
[ CC Fangrui ]
How can I teach pahole to ignore
BTF_INT_UNSIGNED?i mean for the following:
(quoted diff) +2
-0@@ -379,6 +381,8 @@ int32_t btf_elf__add_base_type(struct btf_elf *btfe, const struct base_type *bt, encoding = BTF_INT_SIGNED; } else if (bt->is_bool) { encoding = BTF_INT_BOOL; + } else if (bt->is_unsigned) { + encoding = BTF_INT_UNSIGNED; } else if (bt->float_type) { fprintf(stderr, "float_type is not supported\n");return -1;You can do
(quoted diff) +2
-0@@ -379,6 +381,8 @@ int32_t btf_elf__add_base_type(struct btf_elf *btfe, const struct base_type *bt, encoding = BTF_INT_SIGNED; } else if (bt->is_bool) { encoding = BTF_INT_BOOL; + } else if (bt->is_unsigned) { + ; /* ignored for now */ } else if (bt->float_type) { fprintf(stderr, "float_type is not supported\n");return -1;
Quoted 2 lines
The default encoding is 0 which indicates an unsigned int.
So my diff looks good to you (I have no glue about BTF/pahole)?
I will try with that snippet you gave me.
Thanks.
- Sedat -
Quoted 10 lines
Quoted 10 lines
Another tryout might be to use "-fbinutils-version=..." which is available for LLVM-12 according to Fangrui?
Fangrui, which binutils versions can I pass and how?Thanks.
- Sedat -
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
In reply to Yonghong SongQuoted 239 lines · Yonghong Song
Quoted 205 lines · Sedat Dilek
Quoted 195 lines · Yonghong Song
Quoted 191 lines · Sedat Dilek
Quoted 149 lines · Sedat Dilek
Quoted 52 lines · Sedat Dilek
Quoted 42 lines · Arnaldo Carvalho de Melo
Em Fri, Feb 05, 2021 at 04:23:59PM +0100, Sedat Dilek escreveu:
Quoted 40 lines · Sedat Dilek
Quoted 17 lines · Sedat Dilek
Quoted 14 lines
Hi,
when building with pahole v1.20 and binutils v2.35.2 plus Clang v12.0.0-rc1 and DWARF-v5 I see:
...
+ info BTF .btf.vmlinux.bin.o
+ [ !=silent_]
+ printf %-7s %s\n BTF .btf.vmlinux.bin.o
BTF .btf.vmlinux.bin.o
+ LLVM_OBJCOPY=/opt/binutils/bin/objcopy/opt/pahole/bin/pahole-J .tmp_vmlinux.btf
[115] INTDW_ATE_unsigned_1Error emitting BTF type Encountered error while encoding BTF.Quoted 8 lines
Grepping the pahole sources:
$ git grep DW_ATE dwarf_loader.c: bt->is_bool = encoding == DW_ATE_boolean; dwarf_loader.c: bt->is_signed = encoding == DW_ATE_signed;Missing
DW_ATE_unsignedencoding?Checked the LLVM sources:
clang/lib/CodeGen/CGDebugInfo.cpp: Encoding =
llvm::dwarf::DW_ATE_unsigned_char;
clang/lib/CodeGen/CGDebugInfo.cpp: Encoding =llvm::dwarf::DW_ATE_unsigned;
clang/lib/CodeGen/CGDebugInfo.cpp: Encoding =llvm::dwarf::DW_ATE_unsigned_fixed;
clang/lib/CodeGen/CGDebugInfo.cpp:
?llvm::dwarf::DW_ATE_unsigned
...
lld/test/wasm/debuginfo.test:CHECK-NEXT:DW_AT_encoding
(DW_ATE_unsigned)Quoted 6 lines
Quoted 1 line
So, I will switch from GNU ld.bfd v2.35.2 to LLD-12.
Thanks for the research, probably your conclusion is correct, can you go the next step and add that part and check if the end result is the expected one?
Quoted 6 lines
Still building...
Can you give me a hand on what has to be changed in dwarves/pahole?
I guess switching from ld.bfd to ld.lld will show the same ERROR.
This builds successfully - untested:
$ git diffbtf_loader.c +1
-0@@ -107,6 +107,7 @@ static struct base_type *base_type__new(strings_t name, uint32_t attrs, bt->bit_size = size; bt->is_signed = attrs &BTF_INT_SIGNED ; bt->is_bool = attrs &BTF_INT_BOOL ; + bt->is_unsigned = attrs &BTF_INT_UNSIGNED ; bt->name_has_encoding = false; bt->float_type = float_type;}ctf.h +1
-0@@ -100,6 +100,7 @@ struct ctf_full_type {#define CTF_TYPE_INT_CHAR 0x2#define CTF_TYPE_INT_BOOL 0x4#define CTF_TYPE_INT_VARARGS 0x8 +#define CTF_TYPE_INT_UNSIGNED 0x16#define CTF_TYPE_FP_ATTRS (VAL ) ((VAL) >> 24)#define CTF_TYPE_FP_OFFSET (VAL ) (((VAL) >> 16) & 0xff)dwarf_loader.c +1
-0@@ -473,6 +473,7 @@ static struct base_type *base_type__new(Dwarf_Die *die, struct cu *cu) bt->is_bool = encoding == DW_ATE_boolean; bt->is_signed = encoding == DW_ATE_signed; bt->is_varargs = false; + bt->is_unsigned = encoding == DW_ATE_unsigned; bt->name_has_encoding = true; }dwarves.h +1
-0@@ -1261,6 +1261,7 @@ struct base_type { uint8_t is_signed:1; uint8_t is_bool:1; uint8_t is_varargs:1; + uint8_t is_unsigned:1; uint8_t float_type:4; };lib/bpf +1
-1@@ -1 +1 @@ -Subproject commit 5af3d86b5a2c5fecdc3ab83822d083edd32b4396 +Subproject commit 5af3d86b5a2c5fecdc3ab83822d083edd32b4396-dirtylibbtf.c +2
-0@@ -247,6 +247,8 @@ static const char * btf_elf__int_encoding_str(uint8_t encoding) return "CHAR"; else if (encoding == BTF_INT_BOOL) return "BOOL"; + else if (encoding == BTF_INT_UNSIGNED) + return "UNSIGNED"; else return "UNKN";}
libbtf.c +2
-0@@ -379,6 +381,8 @@ int32_t btf_elf__add_base_type(struct btf_elf *btfe, const struct base_type *bt, encoding =BTF_INT_SIGNED ; }else if (bt->is_bool) { encoding =BTF_INT_BOOL ; + }else if (bt->is_unsigned) { + encoding =BTF_INT_UNSIGNED ; }else if (bt->float_type) {fprintf (stderr,"float_type is not supported\n" );return -1;Additionally - I cannot see it with
git diff:[
lib/bpf/include/uapi/linux/btf.h]Quoted 8 lines
/* Attributes stored in the
BTF_INT_ENCODING*/
#defineBTF_INT_SIGNED(1 << 0)
#defineBTF_INT_CHAR(1 << 1)
#defineBTF_INT_BOOL(1 << 2)
#defineBTF_INT_UNSIGNED(1 << 3)Comments?
Hmmm...
+ info BTF .btf.vmlinux.bin.o
+ [ !=silent_]
+ printf %-7s %s\n BTF .btf.vmlinux.bin.o
BTF .btf.vmlinux.bin.o
+ LLVM_OBJCOPY=llvm-objcopy/opt/pahole/bin/pahole-J .tmp_vmlinux.btf
[2] INT long unsigned int Error emitting BTF type Encountered error while encoding BTF.
+ llvm-objcopy --only-section=.BTF --set-section-flags .BTF=alloc,readonly --strip-all .tmp_vmlinux.btf .btf.vmlinux.bin.o
...
+ info BTFIDS vmlinux
+ [ !=silent_]
+ printf %-7s %s\n BTFIDS vmlinux
BTFIDS vmlinux
+./tools/bpf/resolve_btfids/resolve_btfidsvmlinux
FAILED: load BTF from vmlinux: Invalid argument
+on_exit
+ [ 255 -ne 0 ]
+ cleanup
+ rm -f .btf.vmlinux.bin.o
+ rm -f .tmp_System.map
+ rm -f .tmp_vmlinux.btf .tmp_vmlinux.kallsyms1.tmp_vmlinux.kallsyms1.S.tmp_vmlinux.kallsyms1.o .tmp_vmlinux.kallsyms2.tmp_vmlinux.kallsyms2.S.tmp_vmlinux.kallsyms 2.o
+ rm -f System.map
+ rm -f vmlinux
+ rm -f vmlinux.o
make[3]: *** [Makefile:1166: vmlinux] Error 255Quoted 8 lines
Quoted 2 lines
Grepping through linux.git/tools I guess some BTF
tools/libsneed to know whatBTF_INT_UNSIGNEDis?
BTF_INT_UNSIGNEDneeds kernel support. Maybe to teach pahole to ignore this for now until kernel infrastructure is ready. Not sure whether this information will be useful or not for BTF. This needs to be discussed separately.Quoted 3 lines
[ CC Fangrui ]
How can I teach pahole to ignore
BTF_INT_UNSIGNED?i mean for the following:
(quoted diff) +2
-0@@ -379,6 +381,8 @@ int32_t btf_elf__add_base_type(struct btf_elf *btfe, const struct base_type *bt, encoding = BTF_INT_SIGNED; } else if (bt->is_bool) { encoding = BTF_INT_BOOL; + } else if (bt->is_unsigned) { + encoding = BTF_INT_UNSIGNED; } else if (bt->float_type) { fprintf(stderr, "float_type is not supported\n");return -1;You can do
(quoted diff) +2
-0@@ -379,6 +381,8 @@ int32_t btf_elf__add_base_type(struct btf_elf *btfe, const struct base_type *bt, encoding = BTF_INT_SIGNED; } else if (bt->is_bool) { encoding = BTF_INT_BOOL; + } else if (bt->is_unsigned) { + ; /* ignored for now */ } else if (bt->float_type) { fprintf(stderr, "float_type is not supported\n");return -1;
Quoted 2 lines
The default encoding is 0 which indicates an unsigned int.
With the attached diff I get again:
+ info BTF .btf.vmlinux.bin.o
+ [ != silent_ ]
+ printf %-7s %s\n BTF .btf.vmlinux.bin.o
BTF .btf.vmlinux.bin.o
+ LLVM_OBJCOPY=llvm-objcopy /opt/pahole/bin/pahole -J .tmp_vmlinux.btf
[115] INT DW_ATE_unsigned_1 Error emitting BTF type Encountered error while encoding BTF.
+ llvm-objcopy --only-section=.BTF --set-section-flags .BTF=alloc,readonly --strip-all .tmp_vmlinux.btf .btf.vmlinux.bin.o
...
+ info BTFIDS vmlinux
+ [ != silent_ ]
+ printf %-7s %s\n BTFIDS vmlinux
BTFIDS vmlinux
+ ./tools/bpf/resolve_btfids/resolve_btfids vmlinux
FAILED: load BTF from vmlinux: Invalid argument
+ on_exit
Can someone please look at the attached diff?
Thanks.
- Sedat -
Quoted 10 lines
Quoted 10 lines
Another tryout might be to use "-fbinutils-version=..." which is available for LLVM-12 according to Fangrui?
Fangrui, which binutils versions can I pass and how?Thanks.
- Sedat -
btf_loader.c +1 -0
@@ -107,6 +107,7 @@ static struct base_type *base_type__new(strings_t name, uint32_t attrs, bt->bit_size = size; bt->is_signed = attrs &BTF_INT_SIGNED ; bt->is_bool = attrs &BTF_INT_BOOL ; + bt->is_unsigned = attrs &BTF_INT_UNSIGNED ; bt->name_has_encoding = false; bt->float_type = float_type; }
ctf.h +1 -0
@@ -100,6 +100,7 @@ struct ctf_full_type {#define CTF_TYPE_INT_CHAR 0x2#define CTF_TYPE_INT_BOOL 0x4#define CTF_TYPE_INT_VARARGS 0x8 +#define CTF_TYPE_INT_UNSIGNED 0x16#define CTF_TYPE_FP_ATTRS (VAL ) ((VAL) >> 24)#define CTF_TYPE_FP_OFFSET (VAL ) (((VAL) >> 16) & 0xff)
dwarf_loader.c +1 -0
@@ -473,6 +473,7 @@ static struct base_type *base_type__new(Dwarf_Die *die, struct cu *cu) bt->is_bool = encoding == DW_ATE_boolean; bt->is_signed = encoding == DW_ATE_signed; bt->is_varargs = false; + bt->is_unsigned = encoding == DW_ATE_unsigned; bt->name_has_encoding = true; }
dwarves.h +1 -0
@@ -1261,6 +1261,7 @@ struct base_type { uint8_t is_signed:1; uint8_t is_bool:1; uint8_t is_varargs:1; + uint8_t is_unsigned:1; uint8_t float_type:4; };
lib/bpf +1 -1
@@ -1 +1 @@ -Subproject commit 5af3d86b5a2c5fecdc3ab83822d083edd32b4396 +Subproject commit 5af3d86b5a2c5fecdc3ab83822d083edd32b4396-dirty
libbtf.c +4 -0
@@ -247,6 +247,8 @@ static const char * btf_elf__int_encoding_str(uint8_t encoding)return "CHAR" ; else if (encoding == BTF_INT_BOOL) return "BOOL"; + else if (encoding == BTF_INT_UNSIGNED) + return "UNSIGNED"; else return "UNKN"; }
@@ -379,6 +381,8 @@ int32_t btf_elf__add_base_type(struct btf_elf *btfe, const struct base_type *bt, encoding =BTF_INT_SIGNED ; }else if (bt->is_bool) { encoding =BTF_INT_BOOL ; + }else if (bt->is_unsigned) { + ;/* ignored for now */ }else if (bt->float_type) {fprintf (stderr,"float_type is not supported\n" );return -1 ;
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
In reply to Yonghong SongEm Fri, Feb 05, 2021 at 11:10:08AM -0800, Yonghong Song escreveu:
Quoted 7 lines · Sedat Dilek
Quoted 3 lines · Sedat Dilek
Grepping through linux.git/tools I guess some BTF
tools/libsneed to know whatBTF_INT_UNSIGNEDis?
BTF_INT_UNSIGNEDneeds kernel support. Maybe to teach pahole to ignore this for now until kernel infrastructure is ready.
Yeah, I thought about doing that.
Quoted 2 lines
Not sure whether this information will be useful or not for BTF. This needs to be discussed separately.
Maybe search for the rationale for its introduction in DWARF.
- ARnaldo
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
Quoted 9 lines · Arnaldo Carvalho de Melo
Em Fri, Feb 05, 2021 at 11:10:08AM -0800, Yonghong Song escreveu:
Quoted 7 lines · Sedat Dilek
Quoted 3 lines · Sedat Dilek
Grepping through linux.git/tools I guess some BTF
tools/libsneed to know whatBTF_INT_UNSIGNEDis?
BTF_INT_UNSIGNEDneeds kernel support. Maybe to teach pahole to ignore this for now until kernel infrastructure is ready.
Quoted 6 lines
Yeah, I thought about doing that.
Quoted 2 lines
Not sure whether this information will be useful or not for BTF. This needs to be discussed separately.
Maybe search for the rationale for its introduction in DWARF.
In LLVM, we have:
uint8_t BTFEncoding;
switch (Encoding) {
case dwarf::DW_ATE_boolean:
BTFEncoding = BTF::INT_BOOL;
break;
case dwarf::DW_ATE_signed:
case dwarf::DW_ATE_signed_char:
BTFEncoding = BTF::INT_SIGNED;
break;
case dwarf::DW_ATE_unsigned:
case dwarf::DW_ATE_unsigned_char:
BTFEncoding = 0;
break;I think DW_ATE_unsigned can be ignored in pahole since the default encoding = 0. A simple comment is enough.
Quoted 3 lines
- ARnaldo
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
Quoted 35 lines · Yonghong Song
Quoted 9 lines · Arnaldo Carvalho de Melo
Em Fri, Feb 05, 2021 at 11:10:08AM -0800, Yonghong Song escreveu:
Quoted 7 lines · Sedat Dilek
Quoted 3 lines · Sedat Dilek
Grepping through linux.git/tools I guess some BTF
tools/libsneed to know whatBTF_INT_UNSIGNEDis?
BTF_INT_UNSIGNEDneeds kernel support. Maybe to teach pahole to ignore this for now until kernel infrastructure is ready.Quoted 6 lines
Yeah, I thought about doing that.
Quoted 2 lines
Not sure whether this information will be useful or not for BTF. This needs to be discussed separately.
Maybe search for the rationale for its introduction in DWARF.
In LLVM, we have:
uint8_t BTFEncoding; switch (Encoding) { case dwarf::DW_ATE_boolean: BTFEncoding = BTF::INT_BOOL; break; case dwarf::DW_ATE_signed: case dwarf::DW_ATE_signed_char: BTFEncoding = BTF::INT_SIGNED; break; case dwarf::DW_ATE_unsigned: case dwarf::DW_ATE_unsigned_char: BTFEncoding = 0; break;
Quoted 3 lines
I think
DW_ATE_unsignedcan be ignored in pahole since the default encoding = 0. A simple comment is enough.
Yonghong Son, do you have a patch/diff for me?
Thanks.
- Sedat -
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
Quoted 36 lines · Sedat Dilek
Quoted 35 lines · Yonghong Song
Quoted 9 lines · Arnaldo Carvalho de Melo
Em Fri, Feb 05, 2021 at 11:10:08AM -0800, Yonghong Song escreveu:
Quoted 7 lines · Sedat Dilek
Quoted 3 lines · Sedat Dilek
Grepping through linux.git/tools I guess some BTF
tools/libsneed to know whatBTF_INT_UNSIGNEDis?
BTF_INT_UNSIGNEDneeds kernel support. Maybe to teach pahole to ignore this for now until kernel infrastructure is ready.Quoted 6 lines
Yeah, I thought about doing that.
Quoted 2 lines
Not sure whether this information will be useful or not for BTF. This needs to be discussed separately.
Maybe search for the rationale for its introduction in DWARF.
In LLVM, we have:
uint8_t BTFEncoding; switch (Encoding) { case dwarf::DW_ATE_boolean: BTFEncoding = BTF::INT_BOOL; break; case dwarf::DW_ATE_signed: case dwarf::DW_ATE_signed_char: BTFEncoding = BTF::INT_SIGNED; break; case dwarf::DW_ATE_unsigned: case dwarf::DW_ATE_unsigned_char: BTFEncoding = 0; break;
Quoted 5 lines
Quoted 3 lines
I think
DW_ATE_unsignedcan be ignored in pahole since the default encoding = 0. A simple comment is enough.Yonghong Son, do you have a patch/diff for me?
Looking at error message from log:
LLVM_OBJCOPY=/opt/binutils/bin/objcopy /opt/pahole/bin/pahole -J
.tmp_vmlinux.btf
[115] INT DW_ATE_unsigned_1 Error emitting BTF type Encountered error while encoding BTF.
Not exactly what is the root cause. Maybe bt->bit_size is not encoded correctly. Could you put vmlinux (in the above it is .tmp_vmlinux.btf) somewhere, I or somebody else can investigate and provide a proper fix.
Quoted 4 lines
Thanks.
- Sedat -
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
Quoted 53 lines · Yonghong Song
Quoted 36 lines · Sedat Dilek
Quoted 35 lines · Yonghong Song
Quoted 9 lines · Arnaldo Carvalho de Melo
Em Fri, Feb 05, 2021 at 11:10:08AM -0800, Yonghong Song escreveu:
Quoted 7 lines · Sedat Dilek
Quoted 3 lines · Sedat Dilek
Grepping through linux.git/tools I guess some BTF
tools/libsneed to know whatBTF_INT_UNSIGNEDis?
BTF_INT_UNSIGNEDneeds kernel support. Maybe to teach pahole to ignore this for now until kernel infrastructure is ready.Quoted 6 lines
Yeah, I thought about doing that.
Quoted 2 lines
Not sure whether this information will be useful or not for BTF. This needs to be discussed separately.
Maybe search for the rationale for its introduction in DWARF.
In LLVM, we have:
uint8_t BTFEncoding; switch (Encoding) { case dwarf::DW_ATE_boolean: BTFEncoding = BTF::INT_BOOL; break; case dwarf::DW_ATE_signed: case dwarf::DW_ATE_signed_char: BTFEncoding = BTF::INT_SIGNED; break; case dwarf::DW_ATE_unsigned: case dwarf::DW_ATE_unsigned_char: BTFEncoding = 0; break;Quoted 5 lines
Quoted 3 lines
I think
DW_ATE_unsignedcan be ignored in pahole since the default encoding = 0. A simple comment is enough.Yonghong Son, do you have a patch/diff for me?
Looking at error message from log:
LLVM_OBJCOPY=/opt/binutils/bin/objcopy
/opt/pahole/bin/pahole-J
.tmp_vmlinux.btf
[115] INTDW_ATE_unsigned_1Error emitting BTF type Encountered error while encoding BTF.
Quoted 5 lines
Not exactly what is the root cause. Maybe
bt->bit_sizeis not encoded correctly. Could you put vmlinux (in the above it is .tmp_vmlinux.btf) somewhere, I or somebody else can investigate and provide a proper fix.
[ TO: Masahiro ]
Thanks for taking care Yonghong - hope this is your first name, if not I am sorry.
In case of mixing my first and last name you will make me female - Dilek is a Turkish female first name :-).
So, in some cultures you need to be careful.
Anyway... back to business and facts.
Out of frustration I killed my last build via make distclean. The whole day I tested diverse combination of GCC-10 and LLVM-12 together with BTF Kconfigs, selfmade pahole, etc.
I will do ne run with some little changes:
#1: Pass LLVM_IAS=1 to make (means use Clang's Integrated ASsembler - as per Nick this leads to the same error - should be unrelated) #2: I did: DEBUG_INFO_COMPRESSED y -> n
#2 I did in case you need vmlinux and I have to upload - I will compress the resulting vmlinux with ZSTD.
You need vmlinux or .tmp_vmlinux.btf file?
Nick was not allowed from his company to download from a Dropbox link. So, as an alternative I can offer GoogleDrive...
...or bomb into your INBOX :-).
Now, why I CCed Masahiro:
In case of ERRORs when running scripts/link-vmlinux.sh above files will be removed.
Last, I found a hack to bypass this - means to keep these files (I need to check old emails).
Masahiro, you see a possibility to have a way to keep these files in case of ERRORs without doing hackery?
From a previous post in this thread:
+ info BTF .btf.vmlinux.bin.o
+ [ != silent_ ]
+ printf %-7s %s\n BTF .btf.vmlinux.bin.o
BTF .btf.vmlinux.bin.o
+ LLVM_OBJCOPY=llvm-objcopy /opt/pahole/bin/pahole -J .tmp_vmlinux.btf
[2] INT long unsigned int Error emitting BTF type Encountered error while encoding BTF.
+ llvm-objcopy --only-section=.BTF --set-section-flags .BTF=alloc,readonly --strip-all .tmp_vmlinux.btf .btf.vmlinux.bin.o
...
+ info BTFIDS vmlinux
+ [ != silent_ ]
+ printf %-7s %s\n BTFIDS vmlinux
BTFIDS vmlinux
+ ./tools/bpf/resolve_btfids/resolve_btfids vmlinux
FAILED: load BTF from vmlinux: Invalid argument
+ on_exit
+ [ 255 -ne 0 ]
+ cleanup
+ rm -f .btf.vmlinux.bin.o
+ rm -f .tmp_System.map
+ rm -f .tmp_vmlinux.btf .tmp_vmlinux.kallsyms1 .tmp_vmlinux.kallsyms1.S .tmp_vmlinux.kallsyms1.o .tmp_vmlinux.kallsyms2 .tmp_vmlinux.kallsyms2.S .tmp_vmlinux.kallsyms 2.o
+ rm -f System.map
+ rm -f vmlinux
+ rm -f vmlinux.o
make[3]: *** [Makefile:1166: vmlinux] Error 255
^^^ Look here.
Thanks.
Regards,
- Sedat -
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
Quoted 131 lines · Sedat Dilek
Quoted 53 lines · Yonghong Song
Quoted 36 lines · Sedat Dilek
Quoted 35 lines · Yonghong Song
Quoted 9 lines · Arnaldo Carvalho de Melo
Em Fri, Feb 05, 2021 at 11:10:08AM -0800, Yonghong Song escreveu:
Quoted 7 lines · Sedat Dilek
Quoted 3 lines · Sedat Dilek
Grepping through linux.git/tools I guess some BTF
tools/libsneed to know whatBTF_INT_UNSIGNEDis?
BTF_INT_UNSIGNEDneeds kernel support. Maybe to teach pahole to ignore this for now until kernel infrastructure is ready.Quoted 6 lines
Yeah, I thought about doing that.
Quoted 2 lines
Not sure whether this information will be useful or not for BTF. This needs to be discussed separately.
Maybe search for the rationale for its introduction in DWARF.
In LLVM, we have:
uint8_t BTFEncoding; switch (Encoding) { case dwarf::DW_ATE_boolean: BTFEncoding = BTF::INT_BOOL; break; case dwarf::DW_ATE_signed: case dwarf::DW_ATE_signed_char: BTFEncoding = BTF::INT_SIGNED; break; case dwarf::DW_ATE_unsigned: case dwarf::DW_ATE_unsigned_char: BTFEncoding = 0; break;Quoted 5 lines
Quoted 3 lines
I think
DW_ATE_unsignedcan be ignored in pahole since the default encoding = 0. A simple comment is enough.Yonghong Son, do you have a patch/diff for me?
Looking at error message from log:
LLVM_OBJCOPY=/opt/binutils/bin/objcopy
/opt/pahole/bin/pahole-J
.tmp_vmlinux.btf
[115] INTDW_ATE_unsigned_1Error emitting BTF type Encountered error while encoding BTF.Quoted 5 lines
Not exactly what is the root cause. Maybe
bt->bit_sizeis not encoded correctly. Could you put vmlinux (in the above it is .tmp_vmlinux.btf) somewhere, I or somebody else can investigate and provide a proper fix.[ TO: Masahiro ]
Thanks for taking care Yonghong - hope this is your first name, if not I am sorry.
In case of mixing my first and last name you will make me female - Dilek is a Turkish female first name :-).
So, in some cultures you need to be careful.Anyway... back to business and facts.
Out of frustration I killed my last build via
make distclean. The whole day I tested diverse combination of GCC-10 and LLVM-12 together with BTF Kconfigs, selfmade pahole, etc.I will do ne run with some little changes:
#1: Pass LLVM_IAS=1 to make (means use Clang's Integrated ASsembler - as per Nick this leads to the same error - should be unrelated) #2: I did:
DEBUG_INFO_COMPRESSEDy -> n#2 I did in case you need vmlinux and I have to upload - I will compress the resulting vmlinux with ZSTD.
You need vmlinux or .tmp_vmlinux.btf file?
Nick was not allowed from his company to download from a Dropbox link. So, as an alternative I can offer GoogleDrive...
...or bomb into your INBOX :-).Now, why I CCed Masahiro:
In case of ERRORs when running
scripts/link-vmlinux.shabove files will be removed.Last, I found a hack to bypass this - means to keep these files (I need to check old emails).
Masahiro, you see a possibility to have a way to keep these files in case of ERRORs without doing hackery?
From a previous post in this thread:
+ info BTF .btf.vmlinux.bin.o
+ [ !=silent_]
+ printf %-7s %s\n BTF .btf.vmlinux.bin.o
BTF .btf.vmlinux.bin.o
+ LLVM_OBJCOPY=llvm-objcopy/opt/pahole/bin/pahole-J .tmp_vmlinux.btf
[2] INT long unsigned int Error emitting BTF type Encountered error while encoding BTF.
+ llvm-objcopy --only-section=.BTF --set-section-flags .BTF=alloc,readonly --strip-all .tmp_vmlinux.btf .btf.vmlinux.bin.o
...
+ info BTFIDS vmlinux
+ [ !=silent_]
+ printf %-7s %s\n BTFIDS vmlinux
BTFIDS vmlinux
+./tools/bpf/resolve_btfids/resolve_btfidsvmlinux
FAILED: load BTF from vmlinux: Invalid argument
+on_exit
+ [ 255 -ne 0 ]
+ cleanup
+ rm -f .btf.vmlinux.bin.o
+ rm -f .tmp_System.map
+ rm -f .tmp_vmlinux.btf .tmp_vmlinux.kallsyms1.tmp_vmlinux.kallsyms1.S.tmp_vmlinux.kallsyms1.o .tmp_vmlinux.kallsyms2.tmp_vmlinux.kallsyms2.S.tmp_vmlinux.kallsyms 2.o
+ rm -f System.map
+ rm -f vmlinux
+ rm -f vmlinux.o
make[3]: *** [Makefile:1166: vmlinux] Error 255
Quoted 2 lines
^^^ Look here.
With this diff:
$ git diff scripts/link-vmlinux.sh
scripts/link-vmlinux.sh +0 -0
@@ -330,7 +330,7 @@ vmlinux_link vmlinux "${kallsymso}" ${btf_vmlinux_bin_o}
# fill in BTF IDs
if [ -n "${CONFIG_DEBUG_INFO_BTF}" -a -n "${CONFIG_BPF}" ]; then
info BTFIDS vmlinux
- ${RESOLVE_BTFIDS} vmlinux
+ ##${RESOLVE_BTFIDS} vmlinux
fiif [ -n "${CONFIG_BUILDTIME_TABLE_SORT}" ]; then
This files are kept - not removed:
$ LC_ALL=C ll .*btf* vmlinux vmlinux.o -rwxr-xr-x 1 dileks dileks 31M Feb 6 06:37 .btf.vmlinux.bin.o -rwxr-xr-x 1 dileks dileks 348M Feb 6 06:37 .tmp_vmlinux.btf -rwxr-xr-x 1 dileks dileks 348M Feb 6 06:37 vmlinux -rw-r--r-- 1 dileks dileks 344M Feb 6 06:37 vmlinux.o
Pleas let me know where to upload - Dropbox or GoogleDrive or elsewhere and give me a link.
Thanks.
- Sedat -
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
Quoted 161 lines · Sedat Dilek
Quoted 131 lines · Sedat Dilek
Quoted 53 lines · Yonghong Song
Quoted 36 lines · Sedat Dilek
Quoted 35 lines · Yonghong Song
Quoted 9 lines · Arnaldo Carvalho de Melo
Em Fri, Feb 05, 2021 at 11:10:08AM -0800, Yonghong Song escreveu:
Quoted 7 lines · Sedat Dilek
Quoted 3 lines · Sedat Dilek
Grepping through linux.git/tools I guess some BTF
tools/libsneed to know whatBTF_INT_UNSIGNEDis?
BTF_INT_UNSIGNEDneeds kernel support. Maybe to teach pahole to ignore this for now until kernel infrastructure is ready.Quoted 6 lines
Yeah, I thought about doing that.
Quoted 2 lines
Not sure whether this information will be useful or not for BTF. This needs to be discussed separately.
Maybe search for the rationale for its introduction in DWARF.
In LLVM, we have:
uint8_t BTFEncoding; switch (Encoding) { case dwarf::DW_ATE_boolean: BTFEncoding = BTF::INT_BOOL; break; case dwarf::DW_ATE_signed: case dwarf::DW_ATE_signed_char: BTFEncoding = BTF::INT_SIGNED; break; case dwarf::DW_ATE_unsigned: case dwarf::DW_ATE_unsigned_char: BTFEncoding = 0; break;Quoted 5 lines
Quoted 3 lines
I think
DW_ATE_unsignedcan be ignored in pahole since the default encoding = 0. A simple comment is enough.Yonghong Son, do you have a patch/diff for me?
Looking at error message from log:
LLVM_OBJCOPY=/opt/binutils/bin/objcopy
/opt/pahole/bin/pahole-J
.tmp_vmlinux.btf
[115] INTDW_ATE_unsigned_1Error emitting BTF type Encountered error while encoding BTF.Quoted 5 lines
Not exactly what is the root cause. Maybe
bt->bit_sizeis not encoded correctly. Could you put vmlinux (in the above it is .tmp_vmlinux.btf) somewhere, I or somebody else can investigate and provide a proper fix.[ TO: Masahiro ]
Thanks for taking care Yonghong - hope this is your first name, if not I am sorry.
In case of mixing my first and last name you will make me female - Dilek is a Turkish female first name :-).
So, in some cultures you need to be careful.Anyway... back to business and facts.
Out of frustration I killed my last build via
make distclean. The whole day I tested diverse combination of GCC-10 and LLVM-12 together with BTF Kconfigs, selfmade pahole, etc.I will do ne run with some little changes:
#1: Pass LLVM_IAS=1 to make (means use Clang's Integrated ASsembler - as per Nick this leads to the same error - should be unrelated) #2: I did:
DEBUG_INFO_COMPRESSEDy -> n#2 I did in case you need vmlinux and I have to upload - I will compress the resulting vmlinux with ZSTD.
You need vmlinux or .tmp_vmlinux.btf file?
Nick was not allowed from his company to download from a Dropbox link. So, as an alternative I can offer GoogleDrive...
...or bomb into your INBOX :-).Now, why I CCed Masahiro:
In case of ERRORs when running
scripts/link-vmlinux.shabove files will be removed.Last, I found a hack to bypass this - means to keep these files (I need to check old emails).
Masahiro, you see a possibility to have a way to keep these files in case of ERRORs without doing hackery?
From a previous post in this thread:
+ info BTF .btf.vmlinux.bin.o
+ [ !=silent_]
+ printf %-7s %s\n BTF .btf.vmlinux.bin.o
BTF .btf.vmlinux.bin.o
+ LLVM_OBJCOPY=llvm-objcopy/opt/pahole/bin/pahole-J .tmp_vmlinux.btf
[2] INT long unsigned int Error emitting BTF type Encountered error while encoding BTF.
+ llvm-objcopy --only-section=.BTF --set-section-flags .BTF=alloc,readonly --strip-all .tmp_vmlinux.btf .btf.vmlinux.bin.o
...
+ info BTFIDS vmlinux
+ [ !=silent_]
+ printf %-7s %s\n BTFIDS vmlinux
BTFIDS vmlinux
+./tools/bpf/resolve_btfids/resolve_btfidsvmlinux
FAILED: load BTF from vmlinux: Invalid argument
+on_exit
+ [ 255 -ne 0 ]
+ cleanup
+ rm -f .btf.vmlinux.bin.o
+ rm -f .tmp_System.map
+ rm -f .tmp_vmlinux.btf .tmp_vmlinux.kallsyms1.tmp_vmlinux.kallsyms1.S.tmp_vmlinux.kallsyms1.o .tmp_vmlinux.kallsyms2.tmp_vmlinux.kallsyms2.S.tmp_vmlinux.kallsyms 2.o
+ rm -f System.map
+ rm -f vmlinux
+ rm -f vmlinux.o
make[3]: *** [Makefile:1166: vmlinux] Error 255Quoted 2 lines
^^^ Look here.
With this diff:
$ git diff scripts/link-vmlinux.shscripts/link-vmlinux.sh +0
-0@@ -330,7 +330,7 @@ vmlinux_link vmlinux "${kallsymso}" ${btf_vmlinux_bin_o} # fill in BTF IDsif [ -n "${CONFIG_DEBUG_INFO_BTF}" -a -n "${CONFIG_BPF}" ]; then
info BTFIDS vmlinuxscripts/link-vmlinux.sh +1
-1- ${RESOLVE_BTFIDS} vmlinux + ##${RESOLVE_BTFIDS} vmlinuxfi
if [ -n "${CONFIG_BUILDTIME_TABLE_SORT}" ]; then
This files are kept - not removed:
$ LC_ALL=C ll .*btf* vmlinux vmlinux.oscripts/link-vmlinux.sh +0
-4-rwxr-xr-x 1 dileks dileks 31M Feb 6 06:37 .btf.vmlinux.bin.o -rwxr-xr-x 1 dileks dileks 348M Feb 6 06:37 .tmp_vmlinux.btf -rwxr-xr-x 1 dileks dileks 348M Feb 6 06:37 vmlinux -rw-r--r-- 1 dileks dileks 344M Feb 6 06:37 vmlinux.o
Quoted 3 lines
Pleas let me know where to upload - Dropbox or GoogleDrive or elsewhere and give me a link.
WOW, ZSTD is great :-).
$ zstd -19 -T0 -v vmlinux *** zstd command line interface 64-bits v1.4.8, by Yann Collet *** Note: 2 physical core(s) detected vmlinux : 22.71% (364466016 => 82784801 bytes, vmlinux.zst)
$ du -m vmlinux* 348 vmlinux 79 vmlinux.zst
- Sedat -
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
Quoted 170 lines · Sedat Dilek
Quoted 161 lines · Sedat Dilek
Quoted 131 lines · Sedat Dilek
Quoted 53 lines · Yonghong Song
Quoted 36 lines · Sedat Dilek
Quoted 35 lines · Yonghong Song
Quoted 9 lines · Arnaldo Carvalho de Melo
Em Fri, Feb 05, 2021 at 11:10:08AM -0800, Yonghong Song escreveu:
Quoted 7 lines · Sedat Dilek
Quoted 3 lines · Sedat Dilek
Grepping through linux.git/tools I guess some BTF
tools/libsneed to know whatBTF_INT_UNSIGNEDis?
BTF_INT_UNSIGNEDneeds kernel support. Maybe to teach pahole to ignore this for now until kernel infrastructure is ready.Quoted 6 lines
Yeah, I thought about doing that.
Quoted 2 lines
Not sure whether this information will be useful or not for BTF. This needs to be discussed separately.
Maybe search for the rationale for its introduction in DWARF.
In LLVM, we have:
uint8_t BTFEncoding; switch (Encoding) { case dwarf::DW_ATE_boolean: BTFEncoding = BTF::INT_BOOL; break; case dwarf::DW_ATE_signed: case dwarf::DW_ATE_signed_char: BTFEncoding = BTF::INT_SIGNED; break; case dwarf::DW_ATE_unsigned: case dwarf::DW_ATE_unsigned_char: BTFEncoding = 0; break;Quoted 5 lines
Quoted 3 lines
I think
DW_ATE_unsignedcan be ignored in pahole since the default encoding = 0. A simple comment is enough.Yonghong Son, do you have a patch/diff for me?
Looking at error message from log:
LLVM_OBJCOPY=/opt/binutils/bin/objcopy
/opt/pahole/bin/pahole-J
.tmp_vmlinux.btf
[115] INTDW_ATE_unsigned_1Error emitting BTF type Encountered error while encoding BTF.Quoted 5 lines
Not exactly what is the root cause. Maybe
bt->bit_sizeis not encoded correctly. Could you put vmlinux (in the above it is .tmp_vmlinux.btf) somewhere, I or somebody else can investigate and provide a proper fix.[ TO: Masahiro ]
Thanks for taking care Yonghong - hope this is your first name, if not I am sorry.
In case of mixing my first and last name you will make me female - Dilek is a Turkish female first name :-).
So, in some cultures you need to be careful.Anyway... back to business and facts.
Out of frustration I killed my last build via
make distclean. The whole day I tested diverse combination of GCC-10 and LLVM-12 together with BTF Kconfigs, selfmade pahole, etc.I will do ne run with some little changes:
#1: Pass LLVM_IAS=1 to make (means use Clang's Integrated ASsembler - as per Nick this leads to the same error - should be unrelated) #2: I did:
DEBUG_INFO_COMPRESSEDy -> n#2 I did in case you need vmlinux and I have to upload - I will compress the resulting vmlinux with ZSTD.
You need vmlinux or .tmp_vmlinux.btf file?
Nick was not allowed from his company to download from a Dropbox link. So, as an alternative I can offer GoogleDrive...
...or bomb into your INBOX :-).Now, why I CCed Masahiro:
In case of ERRORs when running
scripts/link-vmlinux.shabove files will be removed.Last, I found a hack to bypass this - means to keep these files (I need to check old emails).
Masahiro, you see a possibility to have a way to keep these files in case of ERRORs without doing hackery?
From a previous post in this thread:
+ info BTF .btf.vmlinux.bin.o
+ [ !=silent_]
+ printf %-7s %s\n BTF .btf.vmlinux.bin.o
BTF .btf.vmlinux.bin.o
+ LLVM_OBJCOPY=llvm-objcopy/opt/pahole/bin/pahole-J .tmp_vmlinux.btf
[2] INT long unsigned int Error emitting BTF type Encountered error while encoding BTF.
+ llvm-objcopy --only-section=.BTF --set-section-flags .BTF=alloc,readonly --strip-all .tmp_vmlinux.btf .btf.vmlinux.bin.o
...
+ info BTFIDS vmlinux
+ [ !=silent_]
+ printf %-7s %s\n BTFIDS vmlinux
BTFIDS vmlinux
+./tools/bpf/resolve_btfids/resolve_btfidsvmlinux
FAILED: load BTF from vmlinux: Invalid argument
+on_exit
+ [ 255 -ne 0 ]
+ cleanup
+ rm -f .btf.vmlinux.bin.o
+ rm -f .tmp_System.map
+ rm -f .tmp_vmlinux.btf .tmp_vmlinux.kallsyms1.tmp_vmlinux.kallsyms1.S.tmp_vmlinux.kallsyms1.o .tmp_vmlinux.kallsyms2.tmp_vmlinux.kallsyms2.S.tmp_vmlinux.kallsyms 2.o
+ rm -f System.map
+ rm -f vmlinux
+ rm -f vmlinux.o
make[3]: *** [Makefile:1166: vmlinux] Error 255Quoted 2 lines
^^^ Look here.
With this diff:
$ git diff scripts/link-vmlinux.shscripts/link-vmlinux.sh +0
-0@@ -330,7 +330,7 @@ vmlinux_link vmlinux "${kallsymso}" ${btf_vmlinux_bin_o} # fill in BTF IDsif [ -n "${CONFIG_DEBUG_INFO_BTF}" -a -n "${CONFIG_BPF}" ]; then
info BTFIDS vmlinuxscripts/link-vmlinux.sh +1
-1- ${RESOLVE_BTFIDS} vmlinux + ##${RESOLVE_BTFIDS} vmlinuxfi
if [ -n "${CONFIG_BUILDTIME_TABLE_SORT}" ]; then
This files are kept - not removed:
$ LC_ALL=C ll .*btf* vmlinux vmlinux.oscripts/link-vmlinux.sh +0
-4-rwxr-xr-x 1 dileks dileks 31M Feb 6 06:37 .btf.vmlinux.bin.o -rwxr-xr-x 1 dileks dileks 348M Feb 6 06:37 .tmp_vmlinux.btf -rwxr-xr-x 1 dileks dileks 348M Feb 6 06:37 vmlinux -rw-r--r-- 1 dileks dileks 344M Feb 6 06:37 vmlinux.oQuoted 3 lines
Pleas let me know where to upload - Dropbox or GoogleDrive or elsewhere and give me a link.
WOW, ZSTD is great :-).
Quoted 9 lines
$ zstd -19 -T0 -v vmlinux *** zstd command line interface 64-bits v1.4.8, by Yann Collet *** Note: 2 physical core(s) detected vmlinux : 22.71% (364466016 => 82784801 bytes, vmlinux.zst)$ du -m vmlinux* 348 vmlinux 79 vmlinux.zst
Dropbox link:
https://www.dropbox.com/sh/kvyh8ps7na0r1h5/AABfyNfDZ2bESse_bo4h05fFa?dl=0
I hope this is public available.
- Sedat -
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
Quoted 182 lines · Sedat Dilek
Quoted 170 lines · Sedat Dilek
Quoted 161 lines · Sedat Dilek
Quoted 131 lines · Sedat Dilek
Quoted 53 lines · Yonghong Song
Quoted 36 lines · Sedat Dilek
Quoted 35 lines · Yonghong Song
Quoted 9 lines · Arnaldo Carvalho de Melo
Em Fri, Feb 05, 2021 at 11:10:08AM -0800, Yonghong Song escreveu:
Quoted 7 lines · Sedat Dilek
Quoted 3 lines · Sedat Dilek
Grepping through linux.git/tools I guess some BTF
tools/libsneed to know whatBTF_INT_UNSIGNEDis?
BTF_INT_UNSIGNEDneeds kernel support. Maybe to teach pahole to ignore this for now until kernel infrastructure is ready.Quoted 6 lines
Yeah, I thought about doing that.
Quoted 2 lines
Not sure whether this information will be useful or not for BTF. This needs to be discussed separately.
Maybe search for the rationale for its introduction in DWARF.
In LLVM, we have:
uint8_t BTFEncoding; switch (Encoding) { case dwarf::DW_ATE_boolean: BTFEncoding = BTF::INT_BOOL; break; case dwarf::DW_ATE_signed: case dwarf::DW_ATE_signed_char: BTFEncoding = BTF::INT_SIGNED; break; case dwarf::DW_ATE_unsigned: case dwarf::DW_ATE_unsigned_char: BTFEncoding = 0; break;Quoted 5 lines
Quoted 3 lines
I think
DW_ATE_unsignedcan be ignored in pahole since the default encoding = 0. A simple comment is enough.Yonghong Son, do you have a patch/diff for me?
Looking at error message from log:
LLVM_OBJCOPY=/opt/binutils/bin/objcopy
/opt/pahole/bin/pahole-J
.tmp_vmlinux.btf
[115] INTDW_ATE_unsigned_1Error emitting BTF type Encountered error while encoding BTF.Quoted 5 lines
Not exactly what is the root cause. Maybe
bt->bit_sizeis not encoded correctly. Could you put vmlinux (in the above it is .tmp_vmlinux.btf) somewhere, I or somebody else can investigate and provide a proper fix.[ TO: Masahiro ]
Thanks for taking care Yonghong - hope this is your first name, if not I am sorry.
In case of mixing my first and last name you will make me female - Dilek is a Turkish female first name :-).
So, in some cultures you need to be careful.Anyway... back to business and facts.
Out of frustration I killed my last build via
make distclean. The whole day I tested diverse combination of GCC-10 and LLVM-12 together with BTF Kconfigs, selfmade pahole, etc.I will do ne run with some little changes:
#1: Pass LLVM_IAS=1 to make (means use Clang's Integrated ASsembler - as per Nick this leads to the same error - should be unrelated) #2: I did:
DEBUG_INFO_COMPRESSEDy -> n#2 I did in case you need vmlinux and I have to upload - I will compress the resulting vmlinux with ZSTD.
You need vmlinux or .tmp_vmlinux.btf file?
Nick was not allowed from his company to download from a Dropbox link. So, as an alternative I can offer GoogleDrive...
...or bomb into your INBOX :-).Now, why I CCed Masahiro:
In case of ERRORs when running
scripts/link-vmlinux.shabove files will be removed.Last, I found a hack to bypass this - means to keep these files (I need to check old emails).
Masahiro, you see a possibility to have a way to keep these files in case of ERRORs without doing hackery?
From a previous post in this thread:
+ info BTF .btf.vmlinux.bin.o
+ [ !=silent_]
+ printf %-7s %s\n BTF .btf.vmlinux.bin.o
BTF .btf.vmlinux.bin.o
+ LLVM_OBJCOPY=llvm-objcopy/opt/pahole/bin/pahole-J .tmp_vmlinux.btf
[2] INT long unsigned int Error emitting BTF type Encountered error while encoding BTF.
+ llvm-objcopy --only-section=.BTF --set-section-flags .BTF=alloc,readonly --strip-all .tmp_vmlinux.btf .btf.vmlinux.bin.o
...
+ info BTFIDS vmlinux
+ [ !=silent_]
+ printf %-7s %s\n BTFIDS vmlinux
BTFIDS vmlinux
+./tools/bpf/resolve_btfids/resolve_btfidsvmlinux
FAILED: load BTF from vmlinux: Invalid argument
+on_exit
+ [ 255 -ne 0 ]
+ cleanup
+ rm -f .btf.vmlinux.bin.o
+ rm -f .tmp_System.map
+ rm -f .tmp_vmlinux.btf .tmp_vmlinux.kallsyms1.tmp_vmlinux.kallsyms1.S.tmp_vmlinux.kallsyms1.o .tmp_vmlinux.kallsyms2.tmp_vmlinux.kallsyms2.S.tmp_vmlinux.kallsyms 2.o
+ rm -f System.map
+ rm -f vmlinux
+ rm -f vmlinux.o
make[3]: *** [Makefile:1166: vmlinux] Error 255Quoted 2 lines
^^^ Look here.
With this diff:
$ git diff scripts/link-vmlinux.shscripts/link-vmlinux.sh +0
-0@@ -330,7 +330,7 @@ vmlinux_link vmlinux "${kallsymso}" ${btf_vmlinux_bin_o} # fill in BTF IDsif [ -n "${CONFIG_DEBUG_INFO_BTF}" -a -n "${CONFIG_BPF}" ]; then
info BTFIDS vmlinuxscripts/link-vmlinux.sh +1
-1- ${RESOLVE_BTFIDS} vmlinux + ##${RESOLVE_BTFIDS} vmlinuxfi
if [ -n "${CONFIG_BUILDTIME_TABLE_SORT}" ]; then
This files are kept - not removed:
$ LC_ALL=C ll .*btf* vmlinux vmlinux.oscripts/link-vmlinux.sh +0
-4-rwxr-xr-x 1 dileks dileks 31M Feb 6 06:37 .btf.vmlinux.bin.o -rwxr-xr-x 1 dileks dileks 348M Feb 6 06:37 .tmp_vmlinux.btf -rwxr-xr-x 1 dileks dileks 348M Feb 6 06:37 vmlinux -rw-r--r-- 1 dileks dileks 344M Feb 6 06:37 vmlinux.oQuoted 3 lines
Pleas let me know where to upload - Dropbox or GoogleDrive or elsewhere and give me a link.
WOW, ZSTD is great :-).
Quoted 9 lines
$ zstd -19 -T0 -v vmlinux *** zstd command line interface 64-bits v1.4.8, by Yann Collet *** Note: 2 physical core(s) detected vmlinux : 22.71% (364466016 => 82784801 bytes, vmlinux.zst)$ du -m vmlinux* 348 vmlinux 79 vmlinux.zst
Quoted 5 lines
Dropbox link:
https://www.dropbox.com/sh/kvyh8ps7na0r1h5/AABfyNfDZ2bESse_bo4h05fFa?dl=0I hope this is public available.
Inspecting vmlinux with llvm-dwarf:
$ /opt/llvm-toolchain/bin/llvm-dwarfdump vmlinux | grep DW_AT_name |
grep DW_ATE_ | sort | uniq
DW_AT_name ("DW_ATE_signed_1")
DW_AT_name ("DW_ATE_signed_16")
DW_AT_name ("DW_ATE_signed_32")
DW_AT_name ("DW_ATE_signed_64")
DW_AT_name ("DW_ATE_signed_8")
DW_AT_name ("DW_ATE_unsigned_1")
DW_AT_name ("DW_ATE_unsigned_128")
DW_AT_name ("DW_ATE_unsigned_16")
DW_AT_name ("DW_ATE_unsigned_24")
DW_AT_name ("DW_ATE_unsigned_32")
DW_AT_name ("DW_ATE_unsigned_40")
DW_AT_name ("DW_ATE_unsigned_64")
DW_AT_name ("DW_ATE_unsigned_8")- Sedat -
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
Quoted 207 lines · Sedat Dilek
Quoted 182 lines · Sedat Dilek
Quoted 170 lines · Sedat Dilek
Quoted 161 lines · Sedat Dilek
Quoted 131 lines · Sedat Dilek
Quoted 53 lines · Yonghong Song
Quoted 36 lines · Sedat Dilek
Quoted 35 lines · Yonghong Song
Quoted 9 lines · Arnaldo Carvalho de Melo
Em Fri, Feb 05, 2021 at 11:10:08AM -0800, Yonghong Song escreveu:
Quoted 7 lines · Sedat Dilek
Quoted 3 lines · Sedat Dilek
Grepping through linux.git/tools I guess some BTF
tools/libsneed to know whatBTF_INT_UNSIGNEDis?
BTF_INT_UNSIGNEDneeds kernel support. Maybe to teach pahole to ignore this for now until kernel infrastructure is ready.Quoted 6 lines
Yeah, I thought about doing that.
Quoted 2 lines
Not sure whether this information will be useful or not for BTF. This needs to be discussed separately.
Maybe search for the rationale for its introduction in DWARF.
In LLVM, we have:
uint8_t BTFEncoding; switch (Encoding) { case dwarf::DW_ATE_boolean: BTFEncoding = BTF::INT_BOOL; break; case dwarf::DW_ATE_signed: case dwarf::DW_ATE_signed_char: BTFEncoding = BTF::INT_SIGNED; break; case dwarf::DW_ATE_unsigned: case dwarf::DW_ATE_unsigned_char: BTFEncoding = 0; break;Quoted 5 lines
Quoted 3 lines
I think
DW_ATE_unsignedcan be ignored in pahole since the default encoding = 0. A simple comment is enough.Yonghong Son, do you have a patch/diff for me?
Looking at error message from log:
LLVM_OBJCOPY=/opt/binutils/bin/objcopy
/opt/pahole/bin/pahole-J
.tmp_vmlinux.btf
[115] INTDW_ATE_unsigned_1Error emitting BTF type Encountered error while encoding BTF.Quoted 5 lines
Not exactly what is the root cause. Maybe
bt->bit_sizeis not encoded correctly. Could you put vmlinux (in the above it is .tmp_vmlinux.btf) somewhere, I or somebody else can investigate and provide a proper fix.[ TO: Masahiro ]
Thanks for taking care Yonghong - hope this is your first name, if not I am sorry.
In case of mixing my first and last name you will make me female - Dilek is a Turkish female first name :-).
So, in some cultures you need to be careful.Anyway... back to business and facts.
Out of frustration I killed my last build via
make distclean. The whole day I tested diverse combination of GCC-10 and LLVM-12 together with BTF Kconfigs, selfmade pahole, etc.I will do ne run with some little changes:
#1: Pass LLVM_IAS=1 to make (means use Clang's Integrated ASsembler - as per Nick this leads to the same error - should be unrelated) #2: I did:
DEBUG_INFO_COMPRESSEDy -> n#2 I did in case you need vmlinux and I have to upload - I will compress the resulting vmlinux with ZSTD.
You need vmlinux or .tmp_vmlinux.btf file?
Nick was not allowed from his company to download from a Dropbox link. So, as an alternative I can offer GoogleDrive...
...or bomb into your INBOX :-).Now, why I CCed Masahiro:
In case of ERRORs when running
scripts/link-vmlinux.shabove files will be removed.Last, I found a hack to bypass this - means to keep these files (I need to check old emails).
Masahiro, you see a possibility to have a way to keep these files in case of ERRORs without doing hackery?
From a previous post in this thread:
+ info BTF .btf.vmlinux.bin.o
+ [ !=silent_]
+ printf %-7s %s\n BTF .btf.vmlinux.bin.o
BTF .btf.vmlinux.bin.o
+ LLVM_OBJCOPY=llvm-objcopy/opt/pahole/bin/pahole-J .tmp_vmlinux.btf
[2] INT long unsigned int Error emitting BTF type Encountered error while encoding BTF.
+ llvm-objcopy --only-section=.BTF --set-section-flags .BTF=alloc,readonly --strip-all .tmp_vmlinux.btf .btf.vmlinux.bin.o
...
+ info BTFIDS vmlinux
+ [ !=silent_]
+ printf %-7s %s\n BTFIDS vmlinux
BTFIDS vmlinux
+./tools/bpf/resolve_btfids/resolve_btfidsvmlinux
FAILED: load BTF from vmlinux: Invalid argument
+on_exit
+ [ 255 -ne 0 ]
+ cleanup
+ rm -f .btf.vmlinux.bin.o
+ rm -f .tmp_System.map
+ rm -f .tmp_vmlinux.btf .tmp_vmlinux.kallsyms1.tmp_vmlinux.kallsyms1.S.tmp_vmlinux.kallsyms1.o .tmp_vmlinux.kallsyms2.tmp_vmlinux.kallsyms2.S.tmp_vmlinux.kallsyms 2.o
+ rm -f System.map
+ rm -f vmlinux
+ rm -f vmlinux.o
make[3]: *** [Makefile:1166: vmlinux] Error 255Quoted 2 lines
^^^ Look here.
With this diff:
$ git diff scripts/link-vmlinux.shscripts/link-vmlinux.sh +0
-0@@ -330,7 +330,7 @@ vmlinux_link vmlinux "${kallsymso}" ${btf_vmlinux_bin_o} # fill in BTF IDsif [ -n "${CONFIG_DEBUG_INFO_BTF}" -a -n "${CONFIG_BPF}" ]; then
info BTFIDS vmlinuxscripts/link-vmlinux.sh +1
-1- ${RESOLVE_BTFIDS} vmlinux + ##${RESOLVE_BTFIDS} vmlinuxfi
if [ -n "${CONFIG_BUILDTIME_TABLE_SORT}" ]; then
This files are kept - not removed:
$ LC_ALL=C ll .*btf* vmlinux vmlinux.oscripts/link-vmlinux.sh +0
-4-rwxr-xr-x 1 dileks dileks 31M Feb 6 06:37 .btf.vmlinux.bin.o -rwxr-xr-x 1 dileks dileks 348M Feb 6 06:37 .tmp_vmlinux.btf -rwxr-xr-x 1 dileks dileks 348M Feb 6 06:37 vmlinux -rw-r--r-- 1 dileks dileks 344M Feb 6 06:37 vmlinux.oQuoted 3 lines
Pleas let me know where to upload - Dropbox or GoogleDrive or elsewhere and give me a link.
WOW, ZSTD is great :-).
Quoted 9 lines
$ zstd -19 -T0 -v vmlinux *** zstd command line interface 64-bits v1.4.8, by Yann Collet *** Note: 2 physical core(s) detected vmlinux : 22.71% (364466016 => 82784801 bytes, vmlinux.zst)$ du -m vmlinux* 348 vmlinux 79 vmlinux.zstQuoted 5 lines
Dropbox link:
https://www.dropbox.com/sh/kvyh8ps7na0r1h5/AABfyNfDZ2bESse_bo4h05fFa?dl=0I hope this is public available.
Inspecting vmlinux with llvm-dwarf:
$ /opt/llvm-toolchain/bin/llvm-dwarfdump vmlinux | grep DW_AT_name | grep DW_ATE_ | sort | uniq DW_AT_name ("DW_ATE_signed_1") DW_AT_name ("DW_ATE_signed_16") DW_AT_name ("DW_ATE_signed_32") DW_AT_name ("DW_ATE_signed_64") DW_AT_name ("DW_ATE_signed_8") DW_AT_name ("DW_ATE_unsigned_1") DW_AT_name ("DW_ATE_unsigned_128") DW_AT_name ("DW_ATE_unsigned_16") DW_AT_name ("DW_ATE_unsigned_24") DW_AT_name ("DW_ATE_unsigned_32") DW_AT_name ("DW_ATE_unsigned_40") DW_AT_name ("DW_ATE_unsigned_64") DW_AT_name ("DW_ATE_unsigned_8")
Quoted 1 line
- Sedat -
Thanks for the above dropbot link, I am able to reproduce the issue.
I tried to use latest llvm + Nick's patch + latest pahole + dwarf5 config option to compile kernel with LLVM=1 LLVM_IAS=1, somehow I did not hit the issue. It complained like
MODPOST vmlinux.symvers
WARNING: modpost: vmlinux.o(.text+0x6ce73): Section mismatch in reference from the function __nodes _weight() to the variable .init.data:numa_nodes_parsed
The function __nodes_weight() references
the variable __initdata numa_nodes_parsed.
This is often because __nodes_weight lacks a __initdata
annotation or the annotation of numa_nodes_parsed is wrong.
but otherwise compilation is fine.
With the above vmlinux, the issue appears to be handling DW_ATE_signed_1, DW_ATE_unsigned_{1,24,40}.
The following patch should fix the issue:
-bash-4.4$ git diff
dwarf_loader.c +0 -0
index b73d786..0341b5e 100644
--- a/dwarf_loader.c
+++ b/dwarf_loader.c
@@ -467,8 +467,16 @@ static struct base_type *base_type__new(Dwarf_Die *die, struct cu *cu)
if (bt != NULL) {
tag__init(&bt->tag, cu, die); - bt->name = strings__add(strings, attr_string(die, DW_AT_name));
- bt->bit_size = attr_numeric(die, DW_AT_byte_size) * 8;
+ const char *name = attr_string(die, DW_AT_name);
+ bt->name = strings__add(strings, name);
+ /* DW_ATE_unsigned_1 has DW_AT_byte_size == 0.
+ * specially process it.
+ */
+ if (strcmp(name, "DW_ATE_unsigned_1") == 0)
+ bt->bit_size = 1;
+ else
+ bt->bit_size = attr_numeric(die, DW_AT_byte_size) * 8;
+
uint64_t encoding = attr_numeric(die, DW_AT_encoding);
bt->is_bool = encoding == DW_ATE_boolean;
bt->is_signed = encoding == DW_ATE_signed;libbtf.c +19 -0
@@ -367,13 +367,32 @@ static void btf_log_func_param(const struct btf_elf *btfe, } } +/* btf requires power-of-2 bytes, yet dwarf may have something like +* DW_ATE_unsigned_24 which encodes as 24 bits (3 bytes). +*/ +static int bits_to_int_bytes (uint16_t bit_size) +{ +if (bit_size <=8 ) +return 1 ; +if (bit_size <=16 ) +return 2 ; +if (bit_size <=32 ) +return 4 ; +if (bit_size <=64 ) +return 8 ; +if (bit_size <=128 ) +return 16 ; +/* BTF supports upto 16byte int (__int128). */ +return -1 ; +} + int32_t btf_elf__add_base_type(struct btf_elf *btfe, const struct
base_type *bt,
const char *name)
{
struct btf *btf = btfe->btf;
const struct btf_type *t;
uint8_t encoding = 0;- int32_t id;
+ int32_t id, nbytes;
if (bt->is_signed) {
encoding = BTF_INT_SIGNED;
@@ -384,7 +403,13 @@ int32_t btf_elf__add_base_type(struct btf_elf *btfe, const struct base_type *b
t,
return -1;
}
- id = btf__add_int(btf, name, BITS_ROUNDUP_BYTES(bt->bit_size), encoding);
+ nbytes = bits_to_int_bytes(bt->bit_size);
+ if (nbytes < 0) {+ fprintf(stderr, "not supported bit_size %hu\n", bt->bit_size);
+ return -1;
+ }
+
+ id = btf__add_int(btf, name, nbytes, encoding);
if (id < 0) {
btf_elf__log_err(btfe, BTF_KIND_INT, name, true, "Error
emitting BTF type");
} else {-bash-4.4$
Please help do a test. I can submit a formal patch tomorrow.
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
Quoted 339 lines · Yonghong Song
Quoted 207 lines · Sedat Dilek
Quoted 182 lines · Sedat Dilek
Quoted 170 lines · Sedat Dilek
Quoted 161 lines · Sedat Dilek
Quoted 131 lines · Sedat Dilek
Quoted 53 lines · Yonghong Song
Quoted 36 lines · Sedat Dilek
Quoted 35 lines · Yonghong Song
Quoted 9 lines · Arnaldo Carvalho de Melo
Em Fri, Feb 05, 2021 at 11:10:08AM -0800, Yonghong Song escreveu:
Quoted 7 lines · Sedat Dilek
Quoted 3 lines · Sedat Dilek
Grepping through linux.git/tools I guess some BTF
tools/libsneed to know whatBTF_INT_UNSIGNEDis?
BTF_INT_UNSIGNEDneeds kernel support. Maybe to teach pahole to ignore this for now until kernel infrastructure is ready.Quoted 6 lines
Yeah, I thought about doing that.
Quoted 2 lines
Not sure whether this information will be useful or not for BTF. This needs to be discussed separately.
Maybe search for the rationale for its introduction in DWARF.
In LLVM, we have:
uint8_t BTFEncoding; switch (Encoding) { case dwarf::DW_ATE_boolean: BTFEncoding = BTF::INT_BOOL; break; case dwarf::DW_ATE_signed: case dwarf::DW_ATE_signed_char: BTFEncoding = BTF::INT_SIGNED; break; case dwarf::DW_ATE_unsigned: case dwarf::DW_ATE_unsigned_char: BTFEncoding = 0; break;Quoted 5 lines
Quoted 3 lines
I think
DW_ATE_unsignedcan be ignored in pahole since the default encoding = 0. A simple comment is enough.Yonghong Son, do you have a patch/diff for me?
Looking at error message from log:
LLVM_OBJCOPY=/opt/binutils/bin/objcopy
/opt/pahole/bin/pahole-J
.tmp_vmlinux.btf
[115] INTDW_ATE_unsigned_1Error emitting BTF type Encountered error while encoding BTF.Quoted 5 lines
Not exactly what is the root cause. Maybe
bt->bit_sizeis not encoded correctly. Could you put vmlinux (in the above it is .tmp_vmlinux.btf) somewhere, I or somebody else can investigate and provide a proper fix.[ TO: Masahiro ]
Thanks for taking care Yonghong - hope this is your first name, if not I am sorry.
In case of mixing my first and last name you will make me female - Dilek is a Turkish female first name :-).
So, in some cultures you need to be careful.Anyway... back to business and facts.
Out of frustration I killed my last build via
make distclean. The whole day I tested diverse combination of GCC-10 and LLVM-12 together with BTF Kconfigs, selfmade pahole, etc.I will do ne run with some little changes:
#1: Pass LLVM_IAS=1 to make (means use Clang's Integrated ASsembler - as per Nick this leads to the same error - should be unrelated) #2: I did:
DEBUG_INFO_COMPRESSEDy -> n#2 I did in case you need vmlinux and I have to upload - I will compress the resulting vmlinux with ZSTD.
You need vmlinux or .tmp_vmlinux.btf file?
Nick was not allowed from his company to download from a Dropbox link. So, as an alternative I can offer GoogleDrive...
...or bomb into your INBOX :-).Now, why I CCed Masahiro:
In case of ERRORs when running
scripts/link-vmlinux.shabove files will be removed.Last, I found a hack to bypass this - means to keep these files (I need to check old emails).
Masahiro, you see a possibility to have a way to keep these files in case of ERRORs without doing hackery?
From a previous post in this thread:
+ info BTF .btf.vmlinux.bin.o
+ [ !=silent_]
+ printf %-7s %s\n BTF .btf.vmlinux.bin.o
BTF .btf.vmlinux.bin.o
+ LLVM_OBJCOPY=llvm-objcopy/opt/pahole/bin/pahole-J .tmp_vmlinux.btf
[2] INT long unsigned int Error emitting BTF type Encountered error while encoding BTF.
+ llvm-objcopy --only-section=.BTF --set-section-flags .BTF=alloc,readonly --strip-all .tmp_vmlinux.btf .btf.vmlinux.bin.o
...
+ info BTFIDS vmlinux
+ [ !=silent_]
+ printf %-7s %s\n BTFIDS vmlinux
BTFIDS vmlinux
+./tools/bpf/resolve_btfids/resolve_btfidsvmlinux
FAILED: load BTF from vmlinux: Invalid argument
+on_exit
+ [ 255 -ne 0 ]
+ cleanup
+ rm -f .btf.vmlinux.bin.o
+ rm -f .tmp_System.map
+ rm -f .tmp_vmlinux.btf .tmp_vmlinux.kallsyms1.tmp_vmlinux.kallsyms1.S.tmp_vmlinux.kallsyms1.o .tmp_vmlinux.kallsyms2.tmp_vmlinux.kallsyms2.S.tmp_vmlinux.kallsyms 2.o
+ rm -f System.map
+ rm -f vmlinux
+ rm -f vmlinux.o
make[3]: *** [Makefile:1166: vmlinux] Error 255Quoted 2 lines
^^^ Look here.
With this diff:
$ git diff scripts/link-vmlinux.shscripts/link-vmlinux.sh +0
-0@@ -330,7 +330,7 @@ vmlinux_link vmlinux "${kallsymso}" ${btf_vmlinux_bin_o} # fill in BTF IDsif [ -n "${CONFIG_DEBUG_INFO_BTF}" -a -n "${CONFIG_BPF}" ]; then
info BTFIDS vmlinuxscripts/link-vmlinux.sh +1
-1- ${RESOLVE_BTFIDS} vmlinux + ##${RESOLVE_BTFIDS} vmlinuxfi
if [ -n "${CONFIG_BUILDTIME_TABLE_SORT}" ]; then
This files are kept - not removed:
$ LC_ALL=C ll .*btf* vmlinux vmlinux.oscripts/link-vmlinux.sh +0
-4-rwxr-xr-x 1 dileks dileks 31M Feb 6 06:37 .btf.vmlinux.bin.o -rwxr-xr-x 1 dileks dileks 348M Feb 6 06:37 .tmp_vmlinux.btf -rwxr-xr-x 1 dileks dileks 348M Feb 6 06:37 vmlinux -rw-r--r-- 1 dileks dileks 344M Feb 6 06:37 vmlinux.oQuoted 3 lines
Pleas let me know where to upload - Dropbox or GoogleDrive or elsewhere and give me a link.
WOW, ZSTD is great :-).
Quoted 9 lines
$ zstd -19 -T0 -v vmlinux *** zstd command line interface 64-bits v1.4.8, by Yann Collet *** Note: 2 physical core(s) detected vmlinux : 22.71% (364466016 => 82784801 bytes, vmlinux.zst)$ du -m vmlinux* 348 vmlinux 79 vmlinux.zstQuoted 5 lines
Dropbox link:
https://www.dropbox.com/sh/kvyh8ps7na0r1h5/AABfyNfDZ2bESse_bo4h05fFa?dl=0I hope this is public available.
Inspecting vmlinux with llvm-dwarf:
$ /opt/llvm-toolchain/bin/llvm-dwarfdump vmlinux | grep DW_AT_name | grep DW_ATE_ | sort | uniq DW_AT_name ("DW_ATE_signed_1") DW_AT_name ("DW_ATE_signed_16") DW_AT_name ("DW_ATE_signed_32") DW_AT_name ("DW_ATE_signed_64") DW_AT_name ("DW_ATE_signed_8") DW_AT_name ("DW_ATE_unsigned_1") DW_AT_name ("DW_ATE_unsigned_128") DW_AT_name ("DW_ATE_unsigned_16") DW_AT_name ("DW_ATE_unsigned_24") DW_AT_name ("DW_ATE_unsigned_32") DW_AT_name ("DW_ATE_unsigned_40") DW_AT_name ("DW_ATE_unsigned_64") DW_AT_name ("DW_ATE_unsigned_8")Quoted 1 line
- Sedat -
Thanks for the above dropbot link, I am able to reproduce the issue.
I tried to use latest llvm + Nick's patch + latest pahole + dwarf5 config option to compile kernel with LLVM=1 LLVM_IAS=1, somehow I did not hit the issue. It complained like
MODPOST vmlinux.symvers
WARNING: modpost:vmlinux.o(.text+0x6ce73): Section mismatch in reference from the function__nodes_weight()to the variable .init.data:numa_nodes_parsed The function__nodes_weight()references
the variable__initdatanuma_nodes_parsed.
This is often because__nodes_weightlacks a__initdataannotation or the annotation ofnuma_nodes_parsedis wrong.but otherwise compilation is fine.
With the above vmlinux, the issue appears to be handling
DW_ATE_signed_1, DW_ATE_unsigned_{1,24,40}.The following patch should fix the issue:
(quoted diff) +0
-1-bash-4.4$ git diffdwarf_loader.c +0
-0index b73d786..0341b5e 100644
---
a/dwarf_loader.c+++
b/dwarf_loader.cdwarf_loader.c +0
-1@@ -467,8 +467,16 @@ static struct base_type *base_type__new(Dwarf_Die *die, struct cu *cu)if (bt !=NULL ) {tag__init (&bt->tag, cu, die); - bt->name = strings__add(strings, attr_string(die,
DW_AT_name));dwarf_loader.c +9
-1- bt->bit_size =attr_numeric (die, DW_AT_byte_size) *8 ; +const char *name =attr_string (die, DW_AT_name); + bt->name =strings__add (strings, name); +/* DW_ATE_unsigned_1 has DW_AT_byte_size == 0. +* specially process it. +*/ +if (strcmp (name,"DW_ATE_unsigned_1" ) ==0 ) + bt->bit_size =1 ; +else + bt->bit_size = attr_numeric(die,
DW_AT_byte_size) * 8;dwarf_loader.c +1
-0+uint64_t encoding =attr_numeric (die, DW_AT_encoding); bt->is_bool = encoding == DW_ATE_boolean; bt->is_signed = encoding == DW_ATE_signed;libbtf.c +27
-2@@ -367,13 +367,32 @@ static void btf_log_func_param(const struct btf_elf *btfe, } } +/* btf requires power-of-2 bytes, yet dwarf may have something like +* DW_ATE_unsigned_24 which encodes as 24 bits (3 bytes). +*/ +static int bits_to_int_bytes (uint16_t bit_size) +{ +if (bit_size <=8 ) +return 1 ; +if (bit_size <=16 ) +return 2 ; +if (bit_size <=32 ) +return 4 ; +if (bit_size <=64 ) +return 8 ; +if (bit_size <=128 ) +return 16 ; +/* BTF supports upto 16byte int (__int128). */ +return -1 ; +} +int32_t btf_elf__add_base_type (struct btf_elf *btfe,const struct base_type *bt,const char *name) {struct btf *btf = btfe->btf;const struct btf_type *t;uint8_t encoding =0 ; -int32_t id; +int32_t id, nbytes;if (bt->is_signed) { encoding =BTF_INT_SIGNED ;@@ -384,7 +403,13 @@ int32_t btf_elf__add_base_type(struct btf_elf *btfe, const struct base_type *b t, return -1 ; } - id =btf__add_int (btf, name,BITS_ROUNDUP_BYTES (bt->bit_size), encoding); + nbytes =bits_to_int_bytes (bt->bit_size); +if (nbytes <0 ) { +fprintf (stderr,"not supported bit_size %hu\n" , bt->bit_size); +return -1 ; + } + + id =btf__add_int (btf, name, nbytes, encoding);if (id < 0) {
btf_elf__log_err(btfe,BTF_KIND_INT, name, true, "Error
Quoted 5 lines
emitting BTF type"); } else {-bash-4.4$
Please help do a test. I can submit a formal patch tomorrow.
Thanks for the patch.
Can you attach the diff as Gmail has totally truncated/malformed it?
For the Linux breakage - you will need some additional Clang specific patches. Is this Linux 5.11-rcX?
The "Blocking bugs" are listed in the first post of "Linux 5.11 release cycle". Hope this helps.
This is cool co-working :-).
- Sedat -
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
Quoted 356 lines · Sedat Dilek
Quoted 339 lines · Yonghong Song
Quoted 207 lines · Sedat Dilek
Quoted 182 lines · Sedat Dilek
Quoted 170 lines · Sedat Dilek
Quoted 161 lines · Sedat Dilek
Quoted 131 lines · Sedat Dilek
Quoted 53 lines · Yonghong Song
Quoted 36 lines · Sedat Dilek
Quoted 35 lines · Yonghong Song
Quoted 9 lines · Arnaldo Carvalho de Melo
Em Fri, Feb 05, 2021 at 11:10:08AM -0800, Yonghong Song escreveu:
Quoted 7 lines · Sedat Dilek
Quoted 3 lines · Sedat Dilek
Grepping through linux.git/tools I guess some BTF tools/libs need to
know what BTF_INT_UNSIGNED is?
BTF_INT_UNSIGNEDneeds kernel support. Maybe to teach pahole to ignore this for now until kernel infrastructure is ready.Quoted 6 lines
Yeah, I thought about doing that.
Quoted 2 lines
Not sure whether this information will be useful or not for BTF. This needs to be discussed separately.
Maybe search for the rationale for its introduction in DWARF.
In LLVM, we have:
uint8_t BTFEncoding; switch (Encoding) { case dwarf::DW_ATE_boolean: BTFEncoding = BTF::INT_BOOL; break; case dwarf::DW_ATE_signed: case dwarf::DW_ATE_signed_char: BTFEncoding = BTF::INT_SIGNED; break; case dwarf::DW_ATE_unsigned: case dwarf::DW_ATE_unsigned_char: BTFEncoding = 0; break;Quoted 5 lines
Quoted 3 lines
I think
DW_ATE_unsignedcan be ignored in pahole since the default encoding = 0. A simple comment is enough.Yonghong Son, do you have a patch/diff for me?
Looking at error message from log:
LLVM_OBJCOPY=/opt/binutils/bin/objcopy
/opt/pahole/bin/pahole-J
.tmp_vmlinux.btf
[115] INTDW_ATE_unsigned_1Error emitting BTF type Encountered error while encoding BTF.Quoted 5 lines
Not exactly what is the root cause. Maybe
bt->bit_sizeis not encoded correctly. Could you put vmlinux (in the above it is .tmp_vmlinux.btf) somewhere, I or somebody else can investigate and provide a proper fix.[ TO: Masahiro ]
Thanks for taking care Yonghong - hope this is your first name, if not I am sorry.
In case of mixing my first and last name you will make me female - Dilek is a Turkish female first name :-).
So, in some cultures you need to be careful.Anyway... back to business and facts.
Out of frustration I killed my last build via
make distclean. The whole day I tested diverse combination of GCC-10 and LLVM-12 together with BTF Kconfigs, selfmade pahole, etc.I will do ne run with some little changes:
#1: Pass LLVM_IAS=1 to make (means use Clang's Integrated ASsembler - as per Nick this leads to the same error - should be unrelated) #2: I did:
DEBUG_INFO_COMPRESSEDy -> n#2 I did in case you need vmlinux and I have to upload - I will compress the resulting vmlinux with ZSTD.
You need vmlinux or .tmp_vmlinux.btf file?
Nick was not allowed from his company to download from a Dropbox link. So, as an alternative I can offer GoogleDrive...
...or bomb into your INBOX :-).Now, why I CCed Masahiro:
In case of ERRORs when running
scripts/link-vmlinux.shabove files will be removed.Last, I found a hack to bypass this - means to keep these files (I need to check old emails).
Masahiro, you see a possibility to have a way to keep these files in case of ERRORs without doing hackery?
From a previous post in this thread:
+ info BTF .btf.vmlinux.bin.o
+ [ !=silent_]
+ printf %-7s %s\n BTF .btf.vmlinux.bin.o
BTF .btf.vmlinux.bin.o
+ LLVM_OBJCOPY=llvm-objcopy/opt/pahole/bin/pahole-J .tmp_vmlinux.btf
[2] INT long unsigned int Error emitting BTF type Encountered error while encoding BTF.
+ llvm-objcopy --only-section=.BTF --set-section-flags .BTF=alloc,readonly --strip-all .tmp_vmlinux.btf .btf.vmlinux.bin.o
...
+ info BTFIDS vmlinux
+ [ !=silent_]
+ printf %-7s %s\n BTFIDS vmlinux
BTFIDS vmlinux
+./tools/bpf/resolve_btfids/resolve_btfidsvmlinux
FAILED: load BTF from vmlinux: Invalid argument
+on_exit
+ [ 255 -ne 0 ]
+ cleanup
+ rm -f .btf.vmlinux.bin.o
+ rm -f .tmp_System.map
+ rm -f .tmp_vmlinux.btf .tmp_vmlinux.kallsyms1.tmp_vmlinux.kallsyms1.S.tmp_vmlinux.kallsyms1.o .tmp_vmlinux.kallsyms2.tmp_vmlinux.kallsyms2.S.tmp_vmlinux.kallsyms 2.o
+ rm -f System.map
+ rm -f vmlinux
+ rm -f vmlinux.o
make[3]: *** [Makefile:1166: vmlinux] Error 255Quoted 2 lines
^^^ Look here.
With this diff:
$ git diff scripts/link-vmlinux.shscripts/link-vmlinux.sh +0
-0@@ -330,7 +330,7 @@ vmlinux_link vmlinux "${kallsymso}" ${btf_vmlinux_bin_o} # fill in BTF IDsif [ -n "${CONFIG_DEBUG_INFO_BTF}" -a -n "${CONFIG_BPF}" ]; then
info BTFIDS vmlinuxscripts/link-vmlinux.sh +1
-1- ${RESOLVE_BTFIDS} vmlinux + ##${RESOLVE_BTFIDS} vmlinuxfi
if [ -n "${CONFIG_BUILDTIME_TABLE_SORT}" ]; then
This files are kept - not removed:
$ LC_ALL=C ll .*btf* vmlinux vmlinux.oscripts/link-vmlinux.sh +0
-4-rwxr-xr-x 1 dileks dileks 31M Feb 6 06:37 .btf.vmlinux.bin.o -rwxr-xr-x 1 dileks dileks 348M Feb 6 06:37 .tmp_vmlinux.btf -rwxr-xr-x 1 dileks dileks 348M Feb 6 06:37 vmlinux -rw-r--r-- 1 dileks dileks 344M Feb 6 06:37 vmlinux.oQuoted 3 lines
Pleas let me know where to upload - Dropbox or GoogleDrive or elsewhere and give me a link.
WOW, ZSTD is great :-).
Quoted 9 lines
$ zstd -19 -T0 -v vmlinux *** zstd command line interface 64-bits v1.4.8, by Yann Collet *** Note: 2 physical core(s) detected vmlinux : 22.71% (364466016 => 82784801 bytes, vmlinux.zst)$ du -m vmlinux* 348 vmlinux 79 vmlinux.zstQuoted 5 lines
Dropbox link:
https://www.dropbox.com/sh/kvyh8ps7na0r1h5/AABfyNfDZ2bESse_bo4h05fFa?dl=0I hope this is public available.
Inspecting vmlinux with llvm-dwarf:
$ /opt/llvm-toolchain/bin/llvm-dwarfdump vmlinux | grep DW_AT_name | grep DW_ATE_ | sort | uniq DW_AT_name ("DW_ATE_signed_1") DW_AT_name ("DW_ATE_signed_16") DW_AT_name ("DW_ATE_signed_32") DW_AT_name ("DW_ATE_signed_64") DW_AT_name ("DW_ATE_signed_8") DW_AT_name ("DW_ATE_unsigned_1") DW_AT_name ("DW_ATE_unsigned_128") DW_AT_name ("DW_ATE_unsigned_16") DW_AT_name ("DW_ATE_unsigned_24") DW_AT_name ("DW_ATE_unsigned_32") DW_AT_name ("DW_ATE_unsigned_40") DW_AT_name ("DW_ATE_unsigned_64") DW_AT_name ("DW_ATE_unsigned_8")Quoted 1 line
- Sedat -
Thanks for the above dropbot link, I am able to reproduce the issue.
I tried to use latest llvm + Nick's patch + latest pahole + dwarf5 config option to compile kernel with LLVM=1 LLVM_IAS=1, somehow I did not hit the issue. It complained like
MODPOST vmlinux.symvers
WARNING: modpost:vmlinux.o(.text+0x6ce73): Section mismatch in reference from the function__nodes_weight()to the variable .init.data:numa_nodes_parsed The function__nodes_weight()references
the variable__initdatanuma_nodes_parsed.
This is often because__nodes_weightlacks a__initdataannotation or the annotation ofnuma_nodes_parsedis wrong.but otherwise compilation is fine.
With the above vmlinux, the issue appears to be handling
DW_ATE_signed_1, DW_ATE_unsigned_{1,24,40}.The following patch should fix the issue:
(quoted diff) +0
-1-bash-4.4$ git diffdwarf_loader.c +0
-0index b73d786..0341b5e 100644
---
a/dwarf_loader.c+++
b/dwarf_loader.cdwarf_loader.c +0
-1@@ -467,8 +467,16 @@ static struct base_type *base_type__new(Dwarf_Die *die, struct cu *cu)if (bt !=NULL ) {tag__init (&bt->tag, cu, die); - bt->name = strings__add(strings, attr_string(die,
DW_AT_name));dwarf_loader.c +9
-1- bt->bit_size =attr_numeric (die, DW_AT_byte_size) *8 ; +const char *name =attr_string (die, DW_AT_name); + bt->name =strings__add (strings, name); +/* DW_ATE_unsigned_1 has DW_AT_byte_size == 0. +* specially process it. +*/ +if (strcmp (name,"DW_ATE_unsigned_1" ) ==0 ) + bt->bit_size =1 ; +else + bt->bit_size = attr_numeric(die,
DW_AT_byte_size) * 8;dwarf_loader.c +1
-0+uint64_t encoding =attr_numeric (die, DW_AT_encoding); bt->is_bool = encoding == DW_ATE_boolean; bt->is_signed = encoding == DW_ATE_signed;libbtf.c +27
-2@@ -367,13 +367,32 @@ static void btf_log_func_param(const struct btf_elf *btfe, } } +/* btf requires power-of-2 bytes, yet dwarf may have something like +* DW_ATE_unsigned_24 which encodes as 24 bits (3 bytes). +*/ +static int bits_to_int_bytes (uint16_t bit_size) +{ +if (bit_size <=8 ) +return 1 ; +if (bit_size <=16 ) +return 2 ; +if (bit_size <=32 ) +return 4 ; +if (bit_size <=64 ) +return 8 ; +if (bit_size <=128 ) +return 16 ; +/* BTF supports upto 16byte int (__int128). */ +return -1 ; +} +int32_t btf_elf__add_base_type (struct btf_elf *btfe,const struct base_type *bt,const char *name) {struct btf *btf = btfe->btf;const struct btf_type *t;uint8_t encoding =0 ; -int32_t id; +int32_t id, nbytes;if (bt->is_signed) { encoding =BTF_INT_SIGNED ;@@ -384,7 +403,13 @@ int32_t btf_elf__add_base_type(struct btf_elf *btfe, const struct base_type *b t, return -1 ; } - id =btf__add_int (btf, name,BITS_ROUNDUP_BYTES (bt->bit_size), encoding); + nbytes =bits_to_int_bytes (bt->bit_size); +if (nbytes <0 ) { +fprintf (stderr,"not supported bit_size %hu\n" , bt->bit_size); +return -1 ; + } + + id =btf__add_int (btf, name, nbytes, encoding);if (id < 0) {
btf_elf__log_err(btfe,BTF_KIND_INT, name, true, "ErrorQuoted 5 lines
emitting BTF type"); } else {-bash-4.4$
Please help do a test. I can submit a formal patch tomorrow.
Thanks for the patch.
Can you attach the diff as Gmail has totally truncated/malformed it?
For the Linux breakage - you will need some additional Clang specific patches. Is this Linux 5.11-rcX?
The "Blocking bugs" are listed in the first post of "Linux 5.11 release cycle". Hope this helps.
Quoted 5 lines
This is cool co-working :-).
- Sedat -
With the attached diff and new selfmade pahole looks good here.
Passed (see line-numbers):
11090:+ info LD .tmp_vmlinux.btf
11099:+ info BTF .btf.vmlinux.bin.o
11103:+ LLVM_OBJCOPY=llvm-objcopy /opt/pahole/bin/pahole -J .tmp_vmlinux.btf 11121:+ info LD .tmp_vmlinux.kallsyms1
11139:+ info KSYMS .tmp_vmlinux.kallsyms1.S
11145:+ info AS .tmp_vmlinux.kallsyms1.S
11160:+ info LD .tmp_vmlinux.kallsyms2
11178:+ info KSYMS .tmp_vmlinux.kallsyms2.S
11184:+ info AS .tmp_vmlinux.kallsyms2.S
11200:+ info LD vmlinux
11210:+ info BTFIDS vmlinux
11216:+ info SORTTAB vmlinux
Still building linux-kernel...
Will report later if I was able to boot on bare metal.
- Sedat -
dwarf_loader.c +9 -2
@@ -467,8 +467,15 @@ static struct base_type *base_type__new(Dwarf_Die *die, struct cu *cu)if (bt !=NULL ) {tag__init (&bt->tag, cu, die); - bt->name =strings__add (strings,attr_string (die, DW_AT_name)); - bt->bit_size =attr_numeric (die, DW_AT_byte_size) *8 ; +const char *name =attr_string (die, DW_AT_name); + bt->name =strings__add (strings, name); +/* DW_ATE_unsigned_1 has DW_AT_byte_size == 0. +* specially process it. +*/ +if (strcmp (name,"DW_ATE_unsigned_1" ) ==0 ) + bt->bit_size =1 ; +else + bt->bit_size =attr_numeric (die, DW_AT_byte_size) *8 ;uint64_t encoding =attr_numeric (die, DW_AT_encoding); bt->is_bool = encoding == DW_ATE_boolean; bt->is_signed = encoding == DW_ATE_signed;
libbtf.c +27 -2
@@ -367,13 +367,32 @@ static void btf_log_func_param(const struct btf_elf *btfe, } } +/* btf requires power-of-2 bytes, yet dwarf may have something like +* DW_ATE_unsigned_24 which encodes as 24 bits (3 bytes). +*/ +static int bits_to_int_bytes (uint16_t bit_size) +{ +if (bit_size <=8 ) +return 1 ; +if (bit_size <=16 ) +return 2 ; +if (bit_size <=32 ) +return 4 ; +if (bit_size <=64 ) +return 8 ; +if (bit_size <=128 ) +return 16 ; +/* BTF supports upto 16byte int (__int128). */ +return -1 ; +} +int32_t btf_elf__add_base_type (struct btf_elf *btfe,const struct base_type *bt,const char *name) {struct btf *btf = btfe->btf;const struct btf_type *t;uint8_t encoding =0 ; -int32_t id; +int32_t id, nbytes;if (bt->is_signed) { encoding =BTF_INT_SIGNED ;
@@ -384,7 +403,13 @@ int32_t btf_elf__add_base_type(struct btf_elf *btfe, const struct base_type *bt,return -1 ; } - id =btf__add_int (btf, name,BITS_ROUNDUP_BYTES (bt->bit_size), encoding); + nbytes =bits_to_int_bytes (bt->bit_size); +if (nbytes <0 ) { +fprintf (stderr,"not supported bit_size %hu\n" , bt->bit_size); +return -1 ; + } + + id =btf__add_int (btf, name, nbytes, encoding);if (id <0 ) {btf_elf__log_err (btfe,BTF_KIND_INT , name, true,"Error emitting BTF type" ); }else {
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
Quoted 381 lines · Sedat Dilek
Quoted 356 lines · Sedat Dilek
Quoted 339 lines · Yonghong Song
Quoted 207 lines · Sedat Dilek
Quoted 182 lines · Sedat Dilek
Quoted 170 lines · Sedat Dilek
Quoted 161 lines · Sedat Dilek
Quoted 131 lines · Sedat Dilek
Quoted 53 lines · Yonghong Song
Quoted 36 lines · Sedat Dilek
Quoted 35 lines · Yonghong Song
Quoted 9 lines · Arnaldo Carvalho de Melo
Em Fri, Feb 05, 2021 at 11:10:08AM -0800, Yonghong Song escreveu:
Quoted 7 lines · Sedat Dilek
On Fri, Feb 5, 2021 at 7:53 PM Sedat Dilek <[email protected]> wrote:
Grepping through linux.git/tools I guess some BTF tools/libs need to
know what BTF_INT_UNSIGNED is?BTF_INT_UNSIGNED needs kernel support. Maybe to teach pahole to
ignore this for now until kernel infrastructure is ready.Quoted 6 lines
Yeah, I thought about doing that.
Quoted 2 lines
Not sure whether this information will be useful or not
for BTF. This needs to be discussed separately.Maybe search for the rationale for its introduction in DWARF.
In LLVM, we have:
uint8_t BTFEncoding; switch (Encoding) { case dwarf::DW_ATE_boolean: BTFEncoding = BTF::INT_BOOL; break; case dwarf::DW_ATE_signed: case dwarf::DW_ATE_signed_char: BTFEncoding = BTF::INT_SIGNED; break; case dwarf::DW_ATE_unsigned: case dwarf::DW_ATE_unsigned_char: BTFEncoding = 0; break;Quoted 5 lines
Quoted 3 lines
I think
DW_ATE_unsignedcan be ignored in pahole since the default encoding = 0. A simple comment is enough.Yonghong Son, do you have a patch/diff for me?
Looking at error message from log:
LLVM_OBJCOPY=/opt/binutils/bin/objcopy
/opt/pahole/bin/pahole-J
.tmp_vmlinux.btf
[115] INTDW_ATE_unsigned_1Error emitting BTF type Encountered error while encoding BTF.Quoted 5 lines
Not exactly what is the root cause. Maybe
bt->bit_sizeis not encoded correctly. Could you put vmlinux (in the above it is .tmp_vmlinux.btf) somewhere, I or somebody else can investigate and provide a proper fix.[ TO: Masahiro ]
Thanks for taking care Yonghong - hope this is your first name, if not I am sorry.
In case of mixing my first and last name you will make me female - Dilek is a Turkish female first name :-).
So, in some cultures you need to be careful.Anyway... back to business and facts.
Out of frustration I killed my last build via
make distclean. The whole day I tested diverse combination of GCC-10 and LLVM-12 together with BTF Kconfigs, selfmade pahole, etc.I will do ne run with some little changes:
#1: Pass LLVM_IAS=1 to make (means use Clang's Integrated ASsembler - as per Nick this leads to the same error - should be unrelated) #2: I did:
DEBUG_INFO_COMPRESSEDy -> n#2 I did in case you need vmlinux and I have to upload - I will compress the resulting vmlinux with ZSTD.
You need vmlinux or .tmp_vmlinux.btf file?
Nick was not allowed from his company to download from a Dropbox link. So, as an alternative I can offer GoogleDrive...
...or bomb into your INBOX :-).Now, why I CCed Masahiro:
In case of ERRORs when running
scripts/link-vmlinux.shabove files will be removed.Last, I found a hack to bypass this - means to keep these files (I need to check old emails).
Masahiro, you see a possibility to have a way to keep these files in case of ERRORs without doing hackery?
From a previous post in this thread:
+ info BTF .btf.vmlinux.bin.o
+ [ !=silent_]
+ printf %-7s %s\n BTF .btf.vmlinux.bin.o
BTF .btf.vmlinux.bin.o
+ LLVM_OBJCOPY=llvm-objcopy/opt/pahole/bin/pahole-J .tmp_vmlinux.btf
[2] INT long unsigned int Error emitting BTF type Encountered error while encoding BTF.
+ llvm-objcopy --only-section=.BTF --set-section-flags .BTF=alloc,readonly --strip-all .tmp_vmlinux.btf .btf.vmlinux.bin.o
...
+ info BTFIDS vmlinux
+ [ !=silent_]
+ printf %-7s %s\n BTFIDS vmlinux
BTFIDS vmlinux
+./tools/bpf/resolve_btfids/resolve_btfidsvmlinux
FAILED: load BTF from vmlinux: Invalid argument
+on_exit
+ [ 255 -ne 0 ]
+ cleanup
+ rm -f .btf.vmlinux.bin.o
+ rm -f .tmp_System.map
+ rm -f .tmp_vmlinux.btf .tmp_vmlinux.kallsyms1.tmp_vmlinux.kallsyms1.S.tmp_vmlinux.kallsyms1.o .tmp_vmlinux.kallsyms2.tmp_vmlinux.kallsyms2.S.tmp_vmlinux.kallsyms 2.o
+ rm -f System.map
+ rm -f vmlinux
+ rm -f vmlinux.o
make[3]: *** [Makefile:1166: vmlinux] Error 255Quoted 2 lines
^^^ Look here.
With this diff:
$ git diff scripts/link-vmlinux.shscripts/link-vmlinux.sh +0
-0@@ -330,7 +330,7 @@ vmlinux_link vmlinux "${kallsymso}" ${btf_vmlinux_bin_o} # fill in BTF IDsif [ -n "${CONFIG_DEBUG_INFO_BTF}" -a -n "${CONFIG_BPF}" ]; then
info BTFIDS vmlinuxscripts/link-vmlinux.sh +1
-1- ${RESOLVE_BTFIDS} vmlinux + ##${RESOLVE_BTFIDS} vmlinuxfi
if [ -n "${CONFIG_BUILDTIME_TABLE_SORT}" ]; then
This files are kept - not removed:
$ LC_ALL=C ll .*btf* vmlinux vmlinux.oscripts/link-vmlinux.sh +0
-4-rwxr-xr-x 1 dileks dileks 31M Feb 6 06:37 .btf.vmlinux.bin.o -rwxr-xr-x 1 dileks dileks 348M Feb 6 06:37 .tmp_vmlinux.btf -rwxr-xr-x 1 dileks dileks 348M Feb 6 06:37 vmlinux -rw-r--r-- 1 dileks dileks 344M Feb 6 06:37 vmlinux.oQuoted 3 lines
Pleas let me know where to upload - Dropbox or GoogleDrive or elsewhere and give me a link.
WOW, ZSTD is great :-).
Quoted 9 lines
$ zstd -19 -T0 -v vmlinux *** zstd command line interface 64-bits v1.4.8, by Yann Collet *** Note: 2 physical core(s) detected vmlinux : 22.71% (364466016 => 82784801 bytes, vmlinux.zst)$ du -m vmlinux* 348 vmlinux 79 vmlinux.zstQuoted 5 lines
Dropbox link:
https://www.dropbox.com/sh/kvyh8ps7na0r1h5/AABfyNfDZ2bESse_bo4h05fFa?dl=0I hope this is public available.
Inspecting vmlinux with llvm-dwarf:
$ /opt/llvm-toolchain/bin/llvm-dwarfdump vmlinux | grep DW_AT_name | grep DW_ATE_ | sort | uniq DW_AT_name ("DW_ATE_signed_1") DW_AT_name ("DW_ATE_signed_16") DW_AT_name ("DW_ATE_signed_32") DW_AT_name ("DW_ATE_signed_64") DW_AT_name ("DW_ATE_signed_8") DW_AT_name ("DW_ATE_unsigned_1") DW_AT_name ("DW_ATE_unsigned_128") DW_AT_name ("DW_ATE_unsigned_16") DW_AT_name ("DW_ATE_unsigned_24") DW_AT_name ("DW_ATE_unsigned_32") DW_AT_name ("DW_ATE_unsigned_40") DW_AT_name ("DW_ATE_unsigned_64") DW_AT_name ("DW_ATE_unsigned_8")Quoted 1 line
- Sedat -
Thanks for the above dropbot link, I am able to reproduce the issue.
I tried to use latest llvm + Nick's patch + latest pahole + dwarf5 config option to compile kernel with LLVM=1 LLVM_IAS=1, somehow I did not hit the issue. It complained like
MODPOST vmlinux.symvers
WARNING: modpost:vmlinux.o(.text+0x6ce73): Section mismatch in reference from the function__nodes_weight()to the variable .init.data:numa_nodes_parsed The function__nodes_weight()references
the variable__initdatanuma_nodes_parsed.
This is often because__nodes_weightlacks a__initdataannotation or the annotation ofnuma_nodes_parsedis wrong.but otherwise compilation is fine.
With the above vmlinux, the issue appears to be handling
DW_ATE_signed_1, DW_ATE_unsigned_{1,24,40}.The following patch should fix the issue:
(quoted diff) +0
-1-bash-4.4$ git diffdwarf_loader.c +0
-0index b73d786..0341b5e 100644
---
a/dwarf_loader.c+++
b/dwarf_loader.cdwarf_loader.c +0
-1@@ -467,8 +467,16 @@ static struct base_type *base_type__new(Dwarf_Die *die, struct cu *cu)if (bt !=NULL ) {tag__init (&bt->tag, cu, die); - bt->name = strings__add(strings, attr_string(die,
DW_AT_name));dwarf_loader.c +9
-1- bt->bit_size =attr_numeric (die, DW_AT_byte_size) *8 ; +const char *name =attr_string (die, DW_AT_name); + bt->name =strings__add (strings, name); +/* DW_ATE_unsigned_1 has DW_AT_byte_size == 0. +* specially process it. +*/ +if (strcmp (name,"DW_ATE_unsigned_1" ) ==0 ) + bt->bit_size =1 ; +else + bt->bit_size = attr_numeric(die,
DW_AT_byte_size) * 8;dwarf_loader.c +1
-0+uint64_t encoding =attr_numeric (die, DW_AT_encoding); bt->is_bool = encoding == DW_ATE_boolean; bt->is_signed = encoding == DW_ATE_signed;libbtf.c +27
-2@@ -367,13 +367,32 @@ static void btf_log_func_param(const struct btf_elf *btfe, } } +/* btf requires power-of-2 bytes, yet dwarf may have something like +* DW_ATE_unsigned_24 which encodes as 24 bits (3 bytes). +*/ +static int bits_to_int_bytes (uint16_t bit_size) +{ +if (bit_size <=8 ) +return 1 ; +if (bit_size <=16 ) +return 2 ; +if (bit_size <=32 ) +return 4 ; +if (bit_size <=64 ) +return 8 ; +if (bit_size <=128 ) +return 16 ; +/* BTF supports upto 16byte int (__int128). */ +return -1 ; +} +int32_t btf_elf__add_base_type (struct btf_elf *btfe,const struct base_type *bt,const char *name) {struct btf *btf = btfe->btf;const struct btf_type *t;uint8_t encoding =0 ; -int32_t id; +int32_t id, nbytes;if (bt->is_signed) { encoding =BTF_INT_SIGNED ;@@ -384,7 +403,13 @@ int32_t btf_elf__add_base_type(struct btf_elf *btfe, const struct base_type *b t, return -1 ; } - id =btf__add_int (btf, name,BITS_ROUNDUP_BYTES (bt->bit_size), encoding); + nbytes =bits_to_int_bytes (bt->bit_size); +if (nbytes <0 ) { +fprintf (stderr,"not supported bit_size %hu\n" , bt->bit_size); +return -1 ; + } + + id =btf__add_int (btf, name, nbytes, encoding);if (id < 0) {
btf_elf__log_err(btfe,BTF_KIND_INT, name, true, "ErrorQuoted 5 lines
emitting BTF type"); } else {-bash-4.4$
Please help do a test. I can submit a formal patch tomorrow.
Thanks for the patch.
Can you attach the diff as Gmail has totally truncated/malformed it?
For the Linux breakage - you will need some additional Clang specific patches. Is this Linux 5.11-rcX?
The "Blocking bugs" are listed in the first post of "Linux 5.11 release cycle". Hope this helps.Quoted 5 lines
This is cool co-working :-).
- Sedat -
With the attached diff and new selfmade pahole looks good here.
Passed (see line-numbers):
11090:+ info LD .tmp_vmlinux.btf
11099:+ info BTF .btf.vmlinux.bin.o
11103:+ LLVM_OBJCOPY=llvm-objcopy/opt/pahole/bin/pahole-J .tmp_vmlinux.btf 11121:+ info LD .tmp_vmlinux.kallsyms1
11139:+ info KSYMS.tmp_vmlinux.kallsyms1.S
11145:+ info AS.tmp_vmlinux.kallsyms1.S
11160:+ info LD .tmp_vmlinux.kallsyms2
11178:+ info KSYMS.tmp_vmlinux.kallsyms2.S
11184:+ info AS.tmp_vmlinux.kallsyms2.S
11200:+ info LD vmlinux
11210:+ info BTFIDS vmlinux
11216:+ info SORTTAB vmlinux
Quoted 4 lines
Still building linux-kernel...
Will report later if I was able to boot on bare metal.
I uploaded the diff.
Dropbox link:
https://www.dropbox.com/sh/kvyh8ps7na0r1h5/AABfyNfDZ2bESse_bo4h05fFa?dl=0
- Sedat -
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
In reply to Sedat DilekQuoted 381 lines · Sedat Dilek
Quoted 356 lines · Sedat Dilek
Quoted 339 lines · Yonghong Song
Quoted 207 lines · Sedat Dilek
Quoted 182 lines · Sedat Dilek
Quoted 170 lines · Sedat Dilek
Quoted 161 lines · Sedat Dilek
Quoted 131 lines · Sedat Dilek
Quoted 53 lines · Yonghong Song
Quoted 36 lines · Sedat Dilek
Quoted 35 lines · Yonghong Song
Quoted 9 lines · Arnaldo Carvalho de Melo
Em Fri, Feb 05, 2021 at 11:10:08AM -0800, Yonghong Song escreveu:
Quoted 7 lines · Sedat Dilek
On Fri, Feb 5, 2021 at 7:53 PM Sedat Dilek <[email protected]> wrote:
Grepping through linux.git/tools I guess some BTF tools/libs need to
know what BTF_INT_UNSIGNED is?BTF_INT_UNSIGNED needs kernel support. Maybe to teach pahole to
ignore this for now until kernel infrastructure is ready.Quoted 6 lines
Yeah, I thought about doing that.
Quoted 2 lines
Not sure whether this information will be useful or not
for BTF. This needs to be discussed separately.Maybe search for the rationale for its introduction in DWARF.
In LLVM, we have:
uint8_t BTFEncoding; switch (Encoding) { case dwarf::DW_ATE_boolean: BTFEncoding = BTF::INT_BOOL; break; case dwarf::DW_ATE_signed: case dwarf::DW_ATE_signed_char: BTFEncoding = BTF::INT_SIGNED; break; case dwarf::DW_ATE_unsigned: case dwarf::DW_ATE_unsigned_char: BTFEncoding = 0; break;Quoted 5 lines
Quoted 3 lines
I think
DW_ATE_unsignedcan be ignored in pahole since the default encoding = 0. A simple comment is enough.Yonghong Son, do you have a patch/diff for me?
Looking at error message from log:
LLVM_OBJCOPY=/opt/binutils/bin/objcopy
/opt/pahole/bin/pahole-J
.tmp_vmlinux.btf
[115] INTDW_ATE_unsigned_1Error emitting BTF type Encountered error while encoding BTF.Quoted 5 lines
Not exactly what is the root cause. Maybe
bt->bit_sizeis not encoded correctly. Could you put vmlinux (in the above it is .tmp_vmlinux.btf) somewhere, I or somebody else can investigate and provide a proper fix.[ TO: Masahiro ]
Thanks for taking care Yonghong - hope this is your first name, if not I am sorry.
In case of mixing my first and last name you will make me female - Dilek is a Turkish female first name :-).
So, in some cultures you need to be careful.Anyway... back to business and facts.
Out of frustration I killed my last build via
make distclean. The whole day I tested diverse combination of GCC-10 and LLVM-12 together with BTF Kconfigs, selfmade pahole, etc.I will do ne run with some little changes:
#1: Pass LLVM_IAS=1 to make (means use Clang's Integrated ASsembler - as per Nick this leads to the same error - should be unrelated) #2: I did:
DEBUG_INFO_COMPRESSEDy -> n#2 I did in case you need vmlinux and I have to upload - I will compress the resulting vmlinux with ZSTD.
You need vmlinux or .tmp_vmlinux.btf file?
Nick was not allowed from his company to download from a Dropbox link. So, as an alternative I can offer GoogleDrive...
...or bomb into your INBOX :-).Now, why I CCed Masahiro:
In case of ERRORs when running
scripts/link-vmlinux.shabove files will be removed.Last, I found a hack to bypass this - means to keep these files (I need to check old emails).
Masahiro, you see a possibility to have a way to keep these files in case of ERRORs without doing hackery?
From a previous post in this thread:
+ info BTF .btf.vmlinux.bin.o
+ [ !=silent_]
+ printf %-7s %s\n BTF .btf.vmlinux.bin.o
BTF .btf.vmlinux.bin.o
+ LLVM_OBJCOPY=llvm-objcopy/opt/pahole/bin/pahole-J .tmp_vmlinux.btf
[2] INT long unsigned int Error emitting BTF type Encountered error while encoding BTF.
+ llvm-objcopy --only-section=.BTF --set-section-flags .BTF=alloc,readonly --strip-all .tmp_vmlinux.btf .btf.vmlinux.bin.o
...
+ info BTFIDS vmlinux
+ [ !=silent_]
+ printf %-7s %s\n BTFIDS vmlinux
BTFIDS vmlinux
+./tools/bpf/resolve_btfids/resolve_btfidsvmlinux
FAILED: load BTF from vmlinux: Invalid argument
+on_exit
+ [ 255 -ne 0 ]
+ cleanup
+ rm -f .btf.vmlinux.bin.o
+ rm -f .tmp_System.map
+ rm -f .tmp_vmlinux.btf .tmp_vmlinux.kallsyms1.tmp_vmlinux.kallsyms1.S.tmp_vmlinux.kallsyms1.o .tmp_vmlinux.kallsyms2.tmp_vmlinux.kallsyms2.S.tmp_vmlinux.kallsyms 2.o
+ rm -f System.map
+ rm -f vmlinux
+ rm -f vmlinux.o
make[3]: *** [Makefile:1166: vmlinux] Error 255Quoted 2 lines
^^^ Look here.
With this diff:
$ git diff scripts/link-vmlinux.shscripts/link-vmlinux.sh +0
-0@@ -330,7 +330,7 @@ vmlinux_link vmlinux "${kallsymso}" ${btf_vmlinux_bin_o} # fill in BTF IDsif [ -n "${CONFIG_DEBUG_INFO_BTF}" -a -n "${CONFIG_BPF}" ]; then
info BTFIDS vmlinuxscripts/link-vmlinux.sh +1
-1- ${RESOLVE_BTFIDS} vmlinux + ##${RESOLVE_BTFIDS} vmlinuxfi
if [ -n "${CONFIG_BUILDTIME_TABLE_SORT}" ]; then
This files are kept - not removed:
$ LC_ALL=C ll .*btf* vmlinux vmlinux.oscripts/link-vmlinux.sh +0
-4-rwxr-xr-x 1 dileks dileks 31M Feb 6 06:37 .btf.vmlinux.bin.o -rwxr-xr-x 1 dileks dileks 348M Feb 6 06:37 .tmp_vmlinux.btf -rwxr-xr-x 1 dileks dileks 348M Feb 6 06:37 vmlinux -rw-r--r-- 1 dileks dileks 344M Feb 6 06:37 vmlinux.oQuoted 3 lines
Pleas let me know where to upload - Dropbox or GoogleDrive or elsewhere and give me a link.
WOW, ZSTD is great :-).
Quoted 9 lines
$ zstd -19 -T0 -v vmlinux *** zstd command line interface 64-bits v1.4.8, by Yann Collet *** Note: 2 physical core(s) detected vmlinux : 22.71% (364466016 => 82784801 bytes, vmlinux.zst)$ du -m vmlinux* 348 vmlinux 79 vmlinux.zstQuoted 5 lines
Dropbox link:
https://www.dropbox.com/sh/kvyh8ps7na0r1h5/AABfyNfDZ2bESse_bo4h05fFa?dl=0I hope this is public available.
Inspecting vmlinux with llvm-dwarf:
$ /opt/llvm-toolchain/bin/llvm-dwarfdump vmlinux | grep DW_AT_name | grep DW_ATE_ | sort | uniq DW_AT_name ("DW_ATE_signed_1") DW_AT_name ("DW_ATE_signed_16") DW_AT_name ("DW_ATE_signed_32") DW_AT_name ("DW_ATE_signed_64") DW_AT_name ("DW_ATE_signed_8") DW_AT_name ("DW_ATE_unsigned_1") DW_AT_name ("DW_ATE_unsigned_128") DW_AT_name ("DW_ATE_unsigned_16") DW_AT_name ("DW_ATE_unsigned_24") DW_AT_name ("DW_ATE_unsigned_32") DW_AT_name ("DW_ATE_unsigned_40") DW_AT_name ("DW_ATE_unsigned_64") DW_AT_name ("DW_ATE_unsigned_8")Quoted 1 line
- Sedat -
Thanks for the above dropbot link, I am able to reproduce the issue.
I tried to use latest llvm + Nick's patch + latest pahole + dwarf5 config option to compile kernel with LLVM=1 LLVM_IAS=1, somehow I did not hit the issue. It complained like
MODPOST vmlinux.symvers
WARNING: modpost:vmlinux.o(.text+0x6ce73): Section mismatch in reference from the function__nodes_weight()to the variable .init.data:numa_nodes_parsed The function__nodes_weight()references
the variable__initdatanuma_nodes_parsed.
This is often because__nodes_weightlacks a__initdataannotation or the annotation ofnuma_nodes_parsedis wrong.but otherwise compilation is fine.
With the above vmlinux, the issue appears to be handling
DW_ATE_signed_1, DW_ATE_unsigned_{1,24,40}.The following patch should fix the issue:
(quoted diff) +0
-1-bash-4.4$ git diffdwarf_loader.c +0
-0index b73d786..0341b5e 100644
---
a/dwarf_loader.c+++
b/dwarf_loader.cdwarf_loader.c +0
-1@@ -467,8 +467,16 @@ static struct base_type *base_type__new(Dwarf_Die *die, struct cu *cu)if (bt !=NULL ) {tag__init (&bt->tag, cu, die); - bt->name = strings__add(strings, attr_string(die,
DW_AT_name));dwarf_loader.c +9
-1- bt->bit_size =attr_numeric (die, DW_AT_byte_size) *8 ; +const char *name =attr_string (die, DW_AT_name); + bt->name =strings__add (strings, name); +/* DW_ATE_unsigned_1 has DW_AT_byte_size == 0. +* specially process it. +*/ +if (strcmp (name,"DW_ATE_unsigned_1" ) ==0 ) + bt->bit_size =1 ; +else + bt->bit_size = attr_numeric(die,
DW_AT_byte_size) * 8;dwarf_loader.c +1
-0+uint64_t encoding =attr_numeric (die, DW_AT_encoding); bt->is_bool = encoding == DW_ATE_boolean; bt->is_signed = encoding == DW_ATE_signed;libbtf.c +27
-2@@ -367,13 +367,32 @@ static void btf_log_func_param(const struct btf_elf *btfe, } } +/* btf requires power-of-2 bytes, yet dwarf may have something like +* DW_ATE_unsigned_24 which encodes as 24 bits (3 bytes). +*/ +static int bits_to_int_bytes (uint16_t bit_size) +{ +if (bit_size <=8 ) +return 1 ; +if (bit_size <=16 ) +return 2 ; +if (bit_size <=32 ) +return 4 ; +if (bit_size <=64 ) +return 8 ; +if (bit_size <=128 ) +return 16 ; +/* BTF supports upto 16byte int (__int128). */ +return -1 ; +} +int32_t btf_elf__add_base_type (struct btf_elf *btfe,const struct base_type *bt,const char *name) {struct btf *btf = btfe->btf;const struct btf_type *t;uint8_t encoding =0 ; -int32_t id; +int32_t id, nbytes;if (bt->is_signed) { encoding =BTF_INT_SIGNED ;@@ -384,7 +403,13 @@ int32_t btf_elf__add_base_type(struct btf_elf *btfe, const struct base_type *b t, return -1 ; } - id =btf__add_int (btf, name,BITS_ROUNDUP_BYTES (bt->bit_size), encoding); + nbytes =bits_to_int_bytes (bt->bit_size); +if (nbytes <0 ) { +fprintf (stderr,"not supported bit_size %hu\n" , bt->bit_size); +return -1 ; + } + + id =btf__add_int (btf, name, nbytes, encoding);if (id < 0) {
btf_elf__log_err(btfe,BTF_KIND_INT, name, true, "ErrorQuoted 5 lines
emitting BTF type"); } else {-bash-4.4$
Please help do a test. I can submit a formal patch tomorrow.
Thanks for the patch.
Can you attach the diff as Gmail has totally truncated/malformed it?
For the Linux breakage - you will need some additional Clang specific patches. Is this Linux 5.11-rcX?
The "Blocking bugs" are listed in the first post of "Linux 5.11 release cycle". Hope this helps.Quoted 5 lines
This is cool co-working :-).
- Sedat -
With the attached diff and new selfmade pahole looks good here.
Passed (see line-numbers):
11090:+ info LD .tmp_vmlinux.btf
11099:+ info BTF .btf.vmlinux.bin.o
11103:+ LLVM_OBJCOPY=llvm-objcopy/opt/pahole/bin/pahole-J .tmp_vmlinux.btf 11121:+ info LD .tmp_vmlinux.kallsyms1
11139:+ info KSYMS.tmp_vmlinux.kallsyms1.S
11145:+ info AS.tmp_vmlinux.kallsyms1.S
11160:+ info LD .tmp_vmlinux.kallsyms2
11178:+ info KSYMS.tmp_vmlinux.kallsyms2.S
11184:+ info AS.tmp_vmlinux.kallsyms2.S
11200:+ info LD vmlinux
11210:+ info BTFIDS vmlinux
11216:+ info SORTTAB vmlinux
Quoted 4 lines
Still building linux-kernel...
Will report later if I was able to boot on bare metal.
When running scripts/Makefile.modfinal:
...
not supported bit_size 160
Encountered error while encoding BTF.
...
make[5]: *** [scripts/Makefile.modfinal:59:drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.ko] Error 1 make[5]: *** Deleting file 'drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.ko'
- Sedat -
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
Quoted 390 lines · Sedat Dilek
Quoted 381 lines · Sedat Dilek
Quoted 356 lines · Sedat Dilek
Quoted 339 lines · Yonghong Song
Quoted 207 lines · Sedat Dilek
Quoted 182 lines · Sedat Dilek
Quoted 170 lines · Sedat Dilek
Quoted 161 lines · Sedat Dilek
Quoted 131 lines · Sedat Dilek
Quoted 53 lines · Yonghong Song
Quoted 36 lines · Sedat Dilek
Quoted 35 lines · Yonghong Song
Quoted 15 lines · Arnaldo Carvalho de Melo
Em Fri, Feb 05, 2021 at 11:10:08AM -0800, Yonghong Song escreveu:
On 2/5/21 11:06 AM, Sedat Dilek wrote:
On Fri, Feb 5, 2021 at 7:53 PM Sedat Dilek <[email protected]> wrote:
Grepping through linux.git/tools I guess some BTF tools/libs need to
know what BTF_INT_UNSIGNED is?BTF_INT_UNSIGNED needs kernel support. Maybe to teach pahole to
ignore this for now until kernel infrastructure is ready.Yeah, I thought about doing that.
Not sure whether this information will be useful or not
for BTF. This needs to be discussed separately.Maybe search for the rationale for its introduction in DWARF.
In LLVM, we have:
uint8_t BTFEncoding; switch (Encoding) { case dwarf::DW_ATE_boolean: BTFEncoding = BTF::INT_BOOL; break; case dwarf::DW_ATE_signed: case dwarf::DW_ATE_signed_char: BTFEncoding = BTF::INT_SIGNED; break; case dwarf::DW_ATE_unsigned: case dwarf::DW_ATE_unsigned_char: BTFEncoding = 0; break;Quoted 5 lines
Quoted 3 lines
I think
DW_ATE_unsignedcan be ignored in pahole since the default encoding = 0. A simple comment is enough.Yonghong Son, do you have a patch/diff for me?
Looking at error message from log:
LLVM_OBJCOPY=/opt/binutils/bin/objcopy
/opt/pahole/bin/pahole-J
.tmp_vmlinux.btf
[115] INTDW_ATE_unsigned_1Error emitting BTF type Encountered error while encoding BTF.Quoted 5 lines
Not exactly what is the root cause. Maybe
bt->bit_sizeis not encoded correctly. Could you put vmlinux (in the above it is .tmp_vmlinux.btf) somewhere, I or somebody else can investigate and provide a proper fix.[ TO: Masahiro ]
Thanks for taking care Yonghong - hope this is your first name, if not I am sorry.
In case of mixing my first and last name you will make me female - Dilek is a Turkish female first name :-).
So, in some cultures you need to be careful.Anyway... back to business and facts.
Out of frustration I killed my last build via
make distclean. The whole day I tested diverse combination of GCC-10 and LLVM-12 together with BTF Kconfigs, selfmade pahole, etc.I will do ne run with some little changes:
#1: Pass LLVM_IAS=1 to make (means use Clang's Integrated ASsembler - as per Nick this leads to the same error - should be unrelated) #2: I did:
DEBUG_INFO_COMPRESSEDy -> n#2 I did in case you need vmlinux and I have to upload - I will compress the resulting vmlinux with ZSTD.
You need vmlinux or .tmp_vmlinux.btf file?
Nick was not allowed from his company to download from a Dropbox link. So, as an alternative I can offer GoogleDrive...
...or bomb into your INBOX :-).Now, why I CCed Masahiro:
In case of ERRORs when running
scripts/link-vmlinux.shabove files will be removed.Last, I found a hack to bypass this - means to keep these files (I need to check old emails).
Masahiro, you see a possibility to have a way to keep these files in case of ERRORs without doing hackery?
From a previous post in this thread:
+ info BTF .btf.vmlinux.bin.o
+ [ !=silent_]
+ printf %-7s %s\n BTF .btf.vmlinux.bin.o
BTF .btf.vmlinux.bin.o
+ LLVM_OBJCOPY=llvm-objcopy/opt/pahole/bin/pahole-J .tmp_vmlinux.btf
[2] INT long unsigned int Error emitting BTF type Encountered error while encoding BTF.
+ llvm-objcopy --only-section=.BTF --set-section-flags .BTF=alloc,readonly --strip-all .tmp_vmlinux.btf .btf.vmlinux.bin.o
...
+ info BTFIDS vmlinux
+ [ !=silent_]
+ printf %-7s %s\n BTFIDS vmlinux
BTFIDS vmlinux
+./tools/bpf/resolve_btfids/resolve_btfidsvmlinux
FAILED: load BTF from vmlinux: Invalid argument
+on_exit
+ [ 255 -ne 0 ]
+ cleanup
+ rm -f .btf.vmlinux.bin.o
+ rm -f .tmp_System.map
+ rm -f .tmp_vmlinux.btf .tmp_vmlinux.kallsyms1.tmp_vmlinux.kallsyms1.S.tmp_vmlinux.kallsyms1.o .tmp_vmlinux.kallsyms2.tmp_vmlinux.kallsyms2.S.tmp_vmlinux.kallsyms 2.o
+ rm -f System.map
+ rm -f vmlinux
+ rm -f vmlinux.o
make[3]: *** [Makefile:1166: vmlinux] Error 255Quoted 2 lines
^^^ Look here.
With this diff:
$ git diff scripts/link-vmlinux.shscripts/link-vmlinux.sh +0
-0@@ -330,7 +330,7 @@ vmlinux_link vmlinux "${kallsymso}" ${btf_vmlinux_bin_o} # fill in BTF IDsif [ -n "${CONFIG_DEBUG_INFO_BTF}" -a -n "${CONFIG_BPF}" ]; then
info BTFIDS vmlinuxscripts/link-vmlinux.sh +1
-1- ${RESOLVE_BTFIDS} vmlinux + ##${RESOLVE_BTFIDS} vmlinuxfi
if [ -n "${CONFIG_BUILDTIME_TABLE_SORT}" ]; then
This files are kept - not removed:
$ LC_ALL=C ll .*btf* vmlinux vmlinux.oscripts/link-vmlinux.sh +0
-4-rwxr-xr-x 1 dileks dileks 31M Feb 6 06:37 .btf.vmlinux.bin.o -rwxr-xr-x 1 dileks dileks 348M Feb 6 06:37 .tmp_vmlinux.btf -rwxr-xr-x 1 dileks dileks 348M Feb 6 06:37 vmlinux -rw-r--r-- 1 dileks dileks 344M Feb 6 06:37 vmlinux.oQuoted 3 lines
Pleas let me know where to upload - Dropbox or GoogleDrive or elsewhere and give me a link.
WOW, ZSTD is great :-).
Quoted 9 lines
$ zstd -19 -T0 -v vmlinux *** zstd command line interface 64-bits v1.4.8, by Yann Collet *** Note: 2 physical core(s) detected vmlinux : 22.71% (364466016 => 82784801 bytes, vmlinux.zst)$ du -m vmlinux* 348 vmlinux 79 vmlinux.zstQuoted 5 lines
Dropbox link:
https://www.dropbox.com/sh/kvyh8ps7na0r1h5/AABfyNfDZ2bESse_bo4h05fFa?dl=0I hope this is public available.
Inspecting vmlinux with llvm-dwarf:
$ /opt/llvm-toolchain/bin/llvm-dwarfdump vmlinux | grep DW_AT_name | grep DW_ATE_ | sort | uniq DW_AT_name ("DW_ATE_signed_1") DW_AT_name ("DW_ATE_signed_16") DW_AT_name ("DW_ATE_signed_32") DW_AT_name ("DW_ATE_signed_64") DW_AT_name ("DW_ATE_signed_8") DW_AT_name ("DW_ATE_unsigned_1") DW_AT_name ("DW_ATE_unsigned_128") DW_AT_name ("DW_ATE_unsigned_16") DW_AT_name ("DW_ATE_unsigned_24") DW_AT_name ("DW_ATE_unsigned_32") DW_AT_name ("DW_ATE_unsigned_40") DW_AT_name ("DW_ATE_unsigned_64") DW_AT_name ("DW_ATE_unsigned_8")Quoted 1 line
- Sedat -
Thanks for the above dropbot link, I am able to reproduce the issue.
I tried to use latest llvm + Nick's patch + latest pahole + dwarf5 config option to compile kernel with LLVM=1 LLVM_IAS=1, somehow I did not hit the issue. It complained like
MODPOST vmlinux.symvers
WARNING: modpost:vmlinux.o(.text+0x6ce73): Section mismatch in reference from the function__nodes_weight()to the variable .init.data:numa_nodes_parsed The function__nodes_weight()references
the variable__initdatanuma_nodes_parsed.
This is often because__nodes_weightlacks a__initdataannotation or the annotation ofnuma_nodes_parsedis wrong.but otherwise compilation is fine.
With the above vmlinux, the issue appears to be handling
DW_ATE_signed_1, DW_ATE_unsigned_{1,24,40}.The following patch should fix the issue:
(quoted diff) +0
-1-bash-4.4$ git diffdwarf_loader.c +0
-0index b73d786..0341b5e 100644
---
a/dwarf_loader.c+++
b/dwarf_loader.cdwarf_loader.c +0
-1@@ -467,8 +467,16 @@ static struct base_type *base_type__new(Dwarf_Die *die, struct cu *cu)if (bt !=NULL ) {tag__init (&bt->tag, cu, die); - bt->name = strings__add(strings, attr_string(die,
DW_AT_name));dwarf_loader.c +9
-1- bt->bit_size =attr_numeric (die, DW_AT_byte_size) *8 ; +const char *name =attr_string (die, DW_AT_name); + bt->name =strings__add (strings, name); +/* DW_ATE_unsigned_1 has DW_AT_byte_size == 0. +* specially process it. +*/ +if (strcmp (name,"DW_ATE_unsigned_1" ) ==0 ) + bt->bit_size =1 ; +else + bt->bit_size = attr_numeric(die,
DW_AT_byte_size) * 8;dwarf_loader.c +1
-0+uint64_t encoding =attr_numeric (die, DW_AT_encoding); bt->is_bool = encoding == DW_ATE_boolean; bt->is_signed = encoding == DW_ATE_signed;libbtf.c +27
-2@@ -367,13 +367,32 @@ static void btf_log_func_param(const struct btf_elf *btfe, } } +/* btf requires power-of-2 bytes, yet dwarf may have something like +* DW_ATE_unsigned_24 which encodes as 24 bits (3 bytes). +*/ +static int bits_to_int_bytes (uint16_t bit_size) +{ +if (bit_size <=8 ) +return 1 ; +if (bit_size <=16 ) +return 2 ; +if (bit_size <=32 ) +return 4 ; +if (bit_size <=64 ) +return 8 ; +if (bit_size <=128 ) +return 16 ; +/* BTF supports upto 16byte int (__int128). */ +return -1 ; +} +int32_t btf_elf__add_base_type (struct btf_elf *btfe,const struct base_type *bt,const char *name) {struct btf *btf = btfe->btf;const struct btf_type *t;uint8_t encoding =0 ; -int32_t id; +int32_t id, nbytes;if (bt->is_signed) { encoding =BTF_INT_SIGNED ;@@ -384,7 +403,13 @@ int32_t btf_elf__add_base_type(struct btf_elf *btfe, const struct base_type *b t, return -1 ; } - id =btf__add_int (btf, name,BITS_ROUNDUP_BYTES (bt->bit_size), encoding); + nbytes =bits_to_int_bytes (bt->bit_size); +if (nbytes <0 ) { +fprintf (stderr,"not supported bit_size %hu\n" , bt->bit_size); +return -1 ; + } + + id =btf__add_int (btf, name, nbytes, encoding);if (id < 0) {
btf_elf__log_err(btfe,BTF_KIND_INT, name, true, "ErrorQuoted 5 lines
emitting BTF type"); } else {-bash-4.4$
Please help do a test. I can submit a formal patch tomorrow.
Thanks for the patch.
Can you attach the diff as Gmail has totally truncated/malformed it?
For the Linux breakage - you will need some additional Clang specific patches. Is this Linux 5.11-rcX?
The "Blocking bugs" are listed in the first post of "Linux 5.11 release cycle". Hope this helps.Quoted 5 lines
This is cool co-working :-).
- Sedat -
With the attached diff and new selfmade pahole looks good here.
Passed (see line-numbers):
11090:+ info LD .tmp_vmlinux.btf
11099:+ info BTF .btf.vmlinux.bin.o
11103:+ LLVM_OBJCOPY=llvm-objcopy/opt/pahole/bin/pahole-J .tmp_vmlinux.btf 11121:+ info LD .tmp_vmlinux.kallsyms1
11139:+ info KSYMS.tmp_vmlinux.kallsyms1.S
11145:+ info AS.tmp_vmlinux.kallsyms1.S
11160:+ info LD .tmp_vmlinux.kallsyms2
11178:+ info KSYMS.tmp_vmlinux.kallsyms2.S
11184:+ info AS.tmp_vmlinux.kallsyms2.S
11200:+ info LD vmlinux
11210:+ info BTFIDS vmlinux
11216:+ info SORTTAB vmlinuxQuoted 4 lines
Still building linux-kernel...
Will report later if I was able to boot on bare metal.
When running
scripts/Makefile.modfinal:
Quoted 9 lines
...
not supportedbit_size160
Encountered error while encoding BTF.
...
make[5]: *** [scripts/Makefile.modfinal:59:drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.ko] Error 1 make[5]: *** Deleting file 'drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.ko'
I added "bit_size 160" to libbtf.c:
static int bits_to_int_bytes(uint16_t bit_size)
{
if (bit_size <= 8)
return 1;
if (bit_size <= 16)
return 2;
if (bit_size <= 32)
return 4;
if (bit_size <= 64)
return 8;
if (bit_size <= 128)
return 16;
if (bit_size <= 160)
return 20;
/* BTF supports upto 16byte int (__int128). */
return -1;
}It still breaks with:
[521367] INT DW_ATE_unsigned_160 Error emitting BTF type Encountered error while encoding BTF.
make[5]: *** [scripts/Makefile.modfinal:58:drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.ko] Error 1 make[5]: *** Deleting file 'drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.ko'
Comments?
- Sedat -
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
[ SNIP ]
Quoted 73 lines
Quoted 41 lines
Quoted 34 lines
Quoted 11 lines
Quoted 1 line
Please help do a test. I can submit a formal patch tomorrow.
Thanks for the patch.
Can you attach the diff as Gmail has totally truncated/malformed it?
For the Linux breakage - you will need some additional Clang specific patches. Is this Linux 5.11-rcX?
The "Blocking bugs" are listed in the first post of "Linux 5.11 release cycle". Hope this helps.Quoted 5 lines
This is cool co-working :-).
- Sedat -
With the attached diff and new selfmade pahole looks good here.
Passed (see line-numbers):
11090:+ info LD .tmp_vmlinux.btf
11099:+ info BTF .btf.vmlinux.bin.o
11103:+ LLVM_OBJCOPY=llvm-objcopy/opt/pahole/bin/pahole-J .tmp_vmlinux.btf 11121:+ info LD .tmp_vmlinux.kallsyms1
11139:+ info KSYMS.tmp_vmlinux.kallsyms1.S
11145:+ info AS.tmp_vmlinux.kallsyms1.S
11160:+ info LD .tmp_vmlinux.kallsyms2
11178:+ info KSYMS.tmp_vmlinux.kallsyms2.S
11184:+ info AS.tmp_vmlinux.kallsyms2.S
11200:+ info LD vmlinux
11210:+ info BTFIDS vmlinux
11216:+ info SORTTAB vmlinuxQuoted 4 lines
Still building linux-kernel...
Will report later if I was able to boot on bare metal.
When running
scripts/Makefile.modfinal:Quoted 9 lines
...
not supportedbit_size160
Encountered error while encoding BTF.
...
make[5]: *** [scripts/Makefile.modfinal:59:drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.ko] Error 1 make[5]: *** Deleting file 'drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.ko'I added "
bit_size160" tolibbtf.c:static int
bits_to_int_bytes(uint16_t bit_size){ if (bit_size <= 8) return 1; if (bit_size <= 16) return 2; if (bit_size <= 32) return 4; if (bit_size <= 64) return 8; if (bit_size <= 128) return 16; if (bit_size <= 160) return 20; /* BTF supports upto 16byte int (__int128). */ return -1; }It still breaks with:
Quoted 9 lines
[521367] INT
DW_ATE_unsigned_160Error emitting BTF type Encountered error while encoding BTF.
make[5]: *** [scripts/Makefile.modfinal:58:drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.ko] Error 1 make[5]: *** Deleting file 'drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.ko'Comments?
Indeed there is DW_ATE_unsigned_160:
$ /opt/llvm-toolchain/bin/llvm-dwarfdump
drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.o | grep DW_AT_name
| grep DW_ATE_ | sort -u
DW_AT_name ("DW_ATE_signed_32")
DW_AT_name ("DW_ATE_signed_64")
DW_AT_name ("DW_ATE_unsigned_1")
DW_AT_name ("DW_ATE_unsigned_128")
DW_AT_name ("DW_ATE_unsigned_16")
DW_AT_name ("DW_ATE_unsigned_160")
DW_AT_name ("DW_ATE_unsigned_32")
DW_AT_name ("DW_ATE_unsigned_64")
DW_AT_name ("DW_ATE_unsigned_8")Attached is diff v2 with the "bit_size 160" fix.
- Sedat -
dwarf_loader.c +9 -2
@@ -467,8 +467,15 @@ static struct base_type *base_type__new(Dwarf_Die *die, struct cu *cu)if (bt !=NULL ) {tag__init (&bt->tag, cu, die); - bt->name =strings__add (strings,attr_string (die, DW_AT_name)); - bt->bit_size =attr_numeric (die, DW_AT_byte_size) *8 ; +const char *name =attr_string (die, DW_AT_name); + bt->name =strings__add (strings, name); +/* DW_ATE_unsigned_1 has DW_AT_byte_size == 0. +* specially process it. +*/ +if (strcmp (name,"DW_ATE_unsigned_1" ) ==0 ) + bt->bit_size =1 ; +else + bt->bit_size =attr_numeric (die, DW_AT_byte_size) *8 ;uint64_t encoding =attr_numeric (die, DW_AT_encoding); bt->is_bool = encoding == DW_ATE_boolean; bt->is_signed = encoding == DW_ATE_signed;
libbtf.c +29 -2
@@ -367,13 +367,34 @@ static void btf_log_func_param(const struct btf_elf *btfe, } } +/* btf requires power-of-2 bytes, yet dwarf may have something like +* DW_ATE_unsigned_24 which encodes as 24 bits (3 bytes). +*/ +static int bits_to_int_bytes (uint16_t bit_size) +{ +if (bit_size <=8 ) +return 1 ; +if (bit_size <=16 ) +return 2 ; +if (bit_size <=32 ) +return 4 ; +if (bit_size <=64 ) +return 8 ; +if (bit_size <=128 ) +return 16 ; +if (bit_size <=160 ) +return 20 ; +/* BTF supports upto 16byte int (__int128). */ +return -1 ; +} +int32_t btf_elf__add_base_type (struct btf_elf *btfe,const struct base_type *bt,const char *name) {struct btf *btf = btfe->btf;const struct btf_type *t;uint8_t encoding =0 ; -int32_t id; +int32_t id, nbytes;if (bt->is_signed) { encoding =BTF_INT_SIGNED ;
@@ -384,7 +405,13 @@ int32_t btf_elf__add_base_type(struct btf_elf *btfe, const struct base_type *bt,return -1 ; } - id =btf__add_int (btf, name,BITS_ROUNDUP_BYTES (bt->bit_size), encoding); + nbytes =bits_to_int_bytes (bt->bit_size); +if (nbytes <0 ) { +fprintf (stderr,"not supported bit_size %hu\n" , bt->bit_size); +return -1 ; + } + + id =btf__add_int (btf, name, nbytes, encoding);if (id <0 ) {btf_elf__log_err (btfe,BTF_KIND_INT , name, true,"Error emitting BTF type" ); }else {
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
Quoted 101 lines · Sedat Dilek
[ SNIP ]
Quoted 73 lines
Quoted 41 lines
Quoted 34 lines
Quoted 11 lines
Quoted 1 line
Please help do a test. I can submit a formal patch tomorrow.
Thanks for the patch.
Can you attach the diff as Gmail has totally truncated/malformed it?
For the Linux breakage - you will need some additional Clang specific patches. Is this Linux 5.11-rcX?
The "Blocking bugs" are listed in the first post of "Linux 5.11 release cycle". Hope this helps.Quoted 5 lines
This is cool co-working :-).
- Sedat -
With the attached diff and new selfmade pahole looks good here.
Passed (see line-numbers):
11090:+ info LD .tmp_vmlinux.btf
11099:+ info BTF .btf.vmlinux.bin.o
11103:+ LLVM_OBJCOPY=llvm-objcopy/opt/pahole/bin/pahole-J .tmp_vmlinux.btf 11121:+ info LD .tmp_vmlinux.kallsyms1
11139:+ info KSYMS.tmp_vmlinux.kallsyms1.S
11145:+ info AS.tmp_vmlinux.kallsyms1.S
11160:+ info LD .tmp_vmlinux.kallsyms2
11178:+ info KSYMS.tmp_vmlinux.kallsyms2.S
11184:+ info AS.tmp_vmlinux.kallsyms2.S
11200:+ info LD vmlinux
11210:+ info BTFIDS vmlinux
11216:+ info SORTTAB vmlinuxQuoted 4 lines
Still building linux-kernel...
Will report later if I was able to boot on bare metal.
When running
scripts/Makefile.modfinal:Quoted 9 lines
...
not supportedbit_size160
Encountered error while encoding BTF.
...
make[5]: *** [scripts/Makefile.modfinal:59:drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.ko] Error 1 make[5]: *** Deleting file 'drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.ko'I added "
bit_size160" tolibbtf.c:static int
bits_to_int_bytes(uint16_t bit_size){ if (bit_size <= 8) return 1; if (bit_size <= 16) return 2; if (bit_size <= 32) return 4; if (bit_size <= 64) return 8; if (bit_size <= 128) return 16; if (bit_size <= 160) return 20; /* BTF supports upto 16byte int (__int128). */ return -1; }It still breaks with:
Quoted 9 lines
[521367] INT
DW_ATE_unsigned_160Error emitting BTF type Encountered error while encoding BTF.
make[5]: *** [scripts/Makefile.modfinal:58:drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.ko] Error 1 make[5]: *** Deleting file 'drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.ko'Comments?
Indeed there is
DW_ATE_unsigned_160:$ /opt/llvm-toolchain/bin/llvm-dwarfdump drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.o | grep DW_AT_name | grep DW_ATE_ | sort -u DW_AT_name ("DW_ATE_signed_32") DW_AT_name ("DW_ATE_signed_64") DW_AT_name ("DW_ATE_unsigned_1") DW_AT_name ("DW_ATE_unsigned_128") DW_AT_name ("DW_ATE_unsigned_16") DW_AT_name ("DW_ATE_unsigned_160") DW_AT_name ("DW_ATE_unsigned_32") DW_AT_name ("DW_ATE_unsigned_64") DW_AT_name ("DW_ATE_unsigned_8")
Quoted 2 lines
Attached is diff v2 with the "
bit_size160" fix.
With attached diff v4 I was able to build and boot into bare metal.
$ cat /proc/version Linux version 5.11.0-rc6-14-amd64-clang12-ias ([email protected]@iniza) (dileks clang version 12.0.0 (https://github.com/llvm/llvm-project.git 8364f5369eeeb2da8db2 bae7716c549930d8df93), LLD 12.0.0 (https://github.com/llvm/llvm-project.git 8364f5369eeeb2da8db2bae7716c549930d8df93)) #14~bullseye+dileks1 SMP 2021-02-06
This is the diffconfig to my previous build:
$ scripts/diffconfig /boot/config-5.11.0-rc6-10-amd64-clang12-bfd .config BUILD_SALT "5.11.0-rc6-10-amd64-clang12-bfd" -> "5.11.0-rc6-14-amd64-clang12-ias" DEBUG_INFO_COMPRESSED y -> n DEBUG_INFO_DWARF4 y -> n LD_VERSION 235020000 -> 0 LLD_VERSION 0 -> 120000 +DEBUG_INFO_DWARF5 y +LD_IS_LLD y +TOOLS_SUPPORT_RELR y
Attached is also my linux-config.
Thanks to all involved people.
- Sedat -
dwarf_loader.c +12 -2
@@ -467,8 +467,18 @@ static struct base_type *base_type__new(Dwarf_Die *die, struct cu *cu)if (bt !=NULL ) {tag__init (&bt->tag, cu, die); - bt->name =strings__add (strings,attr_string (die, DW_AT_name)); - bt->bit_size =attr_numeric (die, DW_AT_byte_size) *8 ; +const char *name =attr_string (die, DW_AT_name); + bt->name =strings__add (strings, name); +/* DW_ATE_unsigned_1 has DW_AT_byte_size == 0. +* specially process it. +* Process DW_ATE_unsigned_160 the same way. +*/ +if (strcmp (name,"DW_ATE_unsigned_1" ) ==0 ) + bt->bit_size =1 ; +if (strcmp (name,"DW_ATE_unsigned_160" ) ==0 ) + bt->bit_size =20 ; +else + bt->bit_size =attr_numeric (die, DW_AT_byte_size) *8 ;uint64_t encoding =attr_numeric (die, DW_AT_encoding); bt->is_bool = encoding == DW_ATE_boolean; bt->is_signed = encoding == DW_ATE_signed;
libbtf.c +27 -2
@@ -367,13 +367,32 @@ static void btf_log_func_param(const struct btf_elf *btfe, } } +/* btf requires power-of-2 bytes, yet dwarf may have something like +* DW_ATE_unsigned_24 which encodes as 24 bits (3 bytes). +*/ +static int bits_to_int_bytes (uint16_t bit_size) +{ +if (bit_size <=8 ) +return 1 ; +if (bit_size <=16 ) +return 2 ; +if (bit_size <=32 ) +return 4 ; +if (bit_size <=64 ) +return 8 ; +if (bit_size <=128 ) +return 16 ; +/* BTF supports upto 16byte int (__int128). */ +return -1 ; +} +int32_t btf_elf__add_base_type (struct btf_elf *btfe,const struct base_type *bt,const char *name) {struct btf *btf = btfe->btf;const struct btf_type *t;uint8_t encoding =0 ; -int32_t id; +int32_t id, nbytes;if (bt->is_signed) { encoding =BTF_INT_SIGNED ;
@@ -384,7 +403,13 @@ int32_t btf_elf__add_base_type(struct btf_elf *btfe, const struct base_type *bt,return -1 ; } - id =btf__add_int (btf, name,BITS_ROUNDUP_BYTES (bt->bit_size), encoding); + nbytes =bits_to_int_bytes (bt->bit_size); +if (nbytes <0 ) { +fprintf (stderr,"not supported bit_size %hu\n" , bt->bit_size); +return -1 ; + } + + id =btf__add_int (btf, name, nbytes, encoding);if (id <0 ) {btf_elf__log_err (btfe,BTF_KIND_INT , name, true,"Error emitting BTF type" ); }else {
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
Some post-mortem:
LLVM_DWARF_BIN="/opt/llvm-toolchain/bin/llvm-dwarfdump"
module="drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.ko"
Module has DW_ATE_unsigned_160 and DW_ATE_unsigned_1:
$LLVM_DWARF_BIN $module | grep DW_AT_name | grep DW_ATE_ | sort -u
DW_AT_name ("DW_ATE_signed_32")
DW_AT_name ("DW_ATE_signed_64")
DW_AT_name ("DW_ATE_unsigned_1")
DW_AT_name ("DW_ATE_unsigned_128")
DW_AT_name ("DW_ATE_unsigned_16")
DW_AT_name ("DW_ATE_unsigned_160")
DW_AT_name ("DW_ATE_unsigned_32")
DW_AT_name ("DW_ATE_unsigned_64")vmlinux has only DW_ATE_unsigned_1:
$ $LLVM_DWARF_BIN vmlinux | grep DW_AT_name | grep DW_ATE_ | sort -u
DW_AT_name ("DW_ATE_signed_1")
DW_AT_name ("DW_ATE_signed_16")
DW_AT_name ("DW_ATE_signed_32")
DW_AT_name ("DW_ATE_signed_64")
DW_AT_name ("DW_ATE_signed_8")
DW_AT_name ("DW_ATE_unsigned_1")
DW_AT_name ("DW_ATE_unsigned_128")
DW_AT_name ("DW_ATE_unsigned_16")
DW_AT_name ("DW_ATE_unsigned_24")
DW_AT_name ("DW_ATE_unsigned_32")
DW_AT_name ("DW_ATE_unsigned_40")
DW_AT_name ("DW_ATE_unsigned_64")
DW_AT_name ("DW_ATE_unsigned_8")- Sedat -
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
In reply to Yonghong SongHi,
Quoted 4 lines · Yonghong Song
With the above vmlinux, the issue appears to be handling
DW_ATE_signed_1, DW_ATE_unsigned_{1,24,40}.The following patch should fix the issue:
That doesn't really make sense to me. Why is the compiler emitting a DW_TAG_base_type that needs to be interpreted according to the DW_AT_name attribute?
If the issue is that the size of the base type cannot be expressed in bytes then the DWARF spec provides the following option:
If the value of an object of the given type does not fully occupy the storage described by a byte size attribute, the base type entry may also have a DW_AT_bit_size and a DW_AT_data_bit_offset attribute, both of whose values are integer constant values (see Section 2.19 on page 55). The bit size attribute describes the actual size in bits used to represent values of the given type. The data bit offset attribute is the offset in bits from the beginning of the containing storage to the beginning of the value. Bits that are part of the offset are padding. If this attribute is omitted a default data bit offset of zero is assumed.
Would it be possible to use that encoding of those special types? If not, can we try to come up with some extension that doesn't require consumers to match magic names?
Thanks,
Mark
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
Quoted 26 lines · Mark Wieelard
Hi,
Quoted 4 lines · Yonghong Song
With the above vmlinux, the issue appears to be handling
DW_ATE_signed_1, DW_ATE_unsigned_{1,24,40}.The following patch should fix the issue:
That doesn't really make sense to me. Why is the compiler emitting a
DW_TAG_base_typethat needs to be interpreted according to theDW_AT_nameattribute?If the issue is that the size of the base type cannot be expressed in bytes then the DWARF spec provides the following option:
If the value of an object of the given type does not fully occupy the storage described by a byte size attribute, the base type entry may also have a
DW_AT_bit_sizeand aDW_AT_data_bit_offsetattribute, both of whose values are integer constant values (see Section 2.19 on page 55). The bit size attribute describes the actual size in bits used to represent values of the given type. The data bit offset attribute is the offset in bits from the beginning of the containing storage to the beginning of the value. Bits that are part of the offset are padding. If this attribute is omitted a default data bit offset of zero is assumed.
Quoted 1 line
Would it be possible to use that encoding of those special types? If
I agree with you. I do not like comparing me as well. Unfortunately, there is no enough information in dwarf to find out actual information. The following is the dwarf dump with vmlinux (Sedat provided) forDW_ATE_unsigned_1.
0x000e97e9: DW_TAG_base_type
DW_AT_name ("DW_ATE_unsigned_1")
DW_AT_encoding (DW_ATE_unsigned)
DW_AT_byte_size (0x00)There is no DW_AT_bit_size and DW_AT_bit_offset for base type. AFAIK, these two attributes typically appear in struct/union members together with DW_AT_byte_size.
Maybe compilers (clang in this case) can emit DW_AT_bit_size = 1 and DW_AT_bit_offset = 0/7 (depending on big/little endian) and this case, we just test and get DW_AT_bit_size and it should work.
But I think BTF does not need this (DW_ATE_unsigned_1) for now. I checked dwarf dump and it is mostly used for some arith operation encoded in dump (in this case, e.g., shift by 1 bit)
0x000015cf: DW_TAG_base_type
DW_AT_name ("DW_ATE_unsigned_1")
DW_AT_encoding (DW_ATE_unsigned)
DW_AT_byte_size (0x00)0x00010ed9: DW_TAG_formal_parameter
DW_AT_location (DW_OP_lit0, DW_OP_not,DW_OP_convert (0x000015cf) "DW_ATE_unsigned_1", DW_OP_convert (0x000015d4) "DW_ATE_unsigned_8", DW_OP_stack_value)
DW_AT_abstract_origin (0x00013984 "branch")
Look at clang frontend, only the following types are encoded with unsigned dwarf type.
case BuiltinType::UShort:
case BuiltinType::UInt:
case BuiltinType::UInt128:
case BuiltinType::ULong:
case BuiltinType::WChar_U:
case BuiltinType::ULongLong:
Encoding = llvm::dwarf::DW_ATE_unsigned;
break;Quoted 7 lines
not, can we try to come up with some extension that doesn't require consumers to match magic names?
Thanks,
Mark
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
Quoted 68 lines · Yonghong Song
Quoted 26 lines · Mark Wieelard
Hi,
Quoted 4 lines · Yonghong Song
With the above vmlinux, the issue appears to be handling
DW_ATE_signed_1, DW_ATE_unsigned_{1,24,40}.The following patch should fix the issue:
That doesn't really make sense to me. Why is the compiler emitting a
DW_TAG_base_typethat needs to be interpreted according to theDW_AT_nameattribute?If the issue is that the size of the base type cannot be expressed in bytes then the DWARF spec provides the following option:
If the value of an object of the given type does not fully occupy the storage described by a byte size attribute, the base type entry may also have a
DW_AT_bit_sizeand aDW_AT_data_bit_offsetattribute, both of whose values are integer constant values (see Section 2.19 on page 55). The bit size attribute describes the actual size in bits used to represent values of the given type. The data bit offset attribute is the offset in bits from the beginning of the containing storage to the beginning of the value. Bits that are part of the offset are padding. If this attribute is omitted a default data bit offset of zero is assumed.Quoted 1 line
Would it be possible to use that encoding of those special types? If
I agree with you. I do not like comparing me as well. Unfortunately, there is no enough information in dwarf to find out actual information. The following is the dwarf dump with vmlinux (Sedat provided) for
DW_ATE_unsigned_1.
0x000e97e9:DW_TAG_base_typeDW_AT_name ("DW_ATE_unsigned_1") DW_AT_encoding (DW_ATE_unsigned) DW_AT_byte_size (0x00)There is no
DW_AT_bit_sizeandDW_AT_bit_offsetfor base type. AFAIK, these two attributes typically appear in struct/union members together withDW_AT_byte_size.Maybe compilers (clang in this case) can emit
DW_AT_bit_size= 1 andDW_AT_bit_offset= 0/7 (depending on big/little endian) and this case, we just test and getDW_AT_bit_sizeand it should work.But I think BTF does not need this (
DW_ATE_unsigned_1) for now. I checked dwarf dump and it is mostly used for some arith operation encoded in dump (in this case, e.g., shift by 1 bit)
0x000015cf:DW_TAG_base_typeDW_AT_name ("DW_ATE_unsigned_1") DW_AT_encoding (DW_ATE_unsigned) DW_AT_byte_size (0x00)
0x00010ed9:DW_TAG_formal_parameter
DW_AT_location(DW_OP_lit0,DW_OP_not,DW_OP_convert(0x000015cf) "DW_ATE_unsigned_1",DW_OP_convert(0x000015d4) "DW_ATE_unsigned_8",DW_OP_stack_value)DW_AT_abstract_origin (0x00013984 "branch")Look at clang frontend, only the following types are encoded with unsigned dwarf type.
Quoted 13 lines
case BuiltinType::UShort: case BuiltinType::UInt: case BuiltinType::UInt128: case BuiltinType::ULong: case BuiltinType::WChar_U: case BuiltinType::ULongLong: Encoding = llvm::dwarf::DW_ATE_unsigned; break;Quoted 3 lines
not, can we try to come up with some extension that doesn't require consumers to match magic names?
You want me to upload mlx5_core.ko?
When looking with llvm-dwarf for DW_ATE_unsigned_160:
0x00d65616: DW_TAG_base_type
DW_AT_name ("DW_ATE_unsigned_160")
DW_AT_encoding (DW_ATE_unsigned)
DW_AT_byte_size (0x14)If you need further information, please let me know.
Thanks.
- Sedat -
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
Quoted 79 lines · Sedat Dilek
Quoted 78 lines · Yonghong Song
Quoted 26 lines · Mark Wieelard
Hi,
Quoted 4 lines · Yonghong Song
With the above vmlinux, the issue appears to be handling
DW_ATE_signed_1, DW_ATE_unsigned_{1,24,40}.The following patch should fix the issue:
That doesn't really make sense to me. Why is the compiler emitting a
DW_TAG_base_typethat needs to be interpreted according to theDW_AT_nameattribute?If the issue is that the size of the base type cannot be expressed in bytes then the DWARF spec provides the following option:
If the value of an object of the given type does not fully occupy the storage described by a byte size attribute, the base type entry may also have a
DW_AT_bit_sizeand aDW_AT_data_bit_offsetattribute, both of whose values are integer constant values (see Section 2.19 on page 55). The bit size attribute describes the actual size in bits used to represent values of the given type. The data bit offset attribute is the offset in bits from the beginning of the containing storage to the beginning of the value. Bits that are part of the offset are padding. If this attribute is omitted a default data bit offset of zero is assumed.Quoted 1 line
Would it be possible to use that encoding of those special types? If
I agree with you. I do not like comparing me as well. Unfortunately, there is no enough information in dwarf to find out actual information. The following is the dwarf dump with vmlinux (Sedat provided) for
DW_ATE_unsigned_1.
0x000e97e9:DW_TAG_base_typeDW_AT_name ("DW_ATE_unsigned_1") DW_AT_encoding (DW_ATE_unsigned) DW_AT_byte_size (0x00)There is no
DW_AT_bit_sizeandDW_AT_bit_offsetfor base type. AFAIK, these two attributes typically appear in struct/union members together withDW_AT_byte_size.Maybe compilers (clang in this case) can emit
DW_AT_bit_size= 1 andDW_AT_bit_offset= 0/7 (depending on big/little endian) and this case, we just test and getDW_AT_bit_sizeand it should work.But I think BTF does not need this (
DW_ATE_unsigned_1) for now. I checked dwarf dump and it is mostly used for some arith operation encoded in dump (in this case, e.g., shift by 1 bit)
0x000015cf:DW_TAG_base_typeDW_AT_name ("DW_ATE_unsigned_1") DW_AT_encoding (DW_ATE_unsigned) DW_AT_byte_size (0x00)
0x00010ed9:DW_TAG_formal_parameter
DW_AT_location(DW_OP_lit0,DW_OP_not,DW_OP_convert(0x000015cf) "DW_ATE_unsigned_1",DW_OP_convert(0x000015d4) "DW_ATE_unsigned_8",DW_OP_stack_value)DW_AT_abstract_origin (0x00013984 "branch")Look at clang frontend, only the following types are encoded with unsigned dwarf type.
case BuiltinType::UShort: case BuiltinType::UInt: case BuiltinType::UInt128: case BuiltinType::ULong: case BuiltinType::WChar_U: case BuiltinType::ULongLong: Encoding = llvm::dwarf::DW_ATE_unsigned; break;
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
not, can we try to come up with some extension that doesn't require consumers to match magic names?
You want me to upload mlx5_core.ko?
I just sent out a patch. You are cc'ed. I also attached in this email. Yes, it would be great if you can upload mlx5_core.ko so I can double check with this DW_ATE_unsigned_160 which is really usual.
Quoted 8 lines
When looking with llvm-dwarf for
DW_ATE_unsigned_160:
0x00d65616:DW_TAG_base_typeDW_AT_name ("DW_ATE_unsigned_160") DW_AT_encoding (DW_ATE_unsigned) DW_AT_byte_size (0x14)
Quoted 6 lines
If you need further information, please let me know.
Thanks.
- Sedat -
From 239c797090abbdc5253d0ff1e9e657c5006fbbee Mon Sep 17 00:00:00 2001
From: Yonghong Song <[email protected]>
Date: Sat, 6 Feb 2021 10:21:45 -0800
Subject: [PATCH dwarves] btf_encoder: sanitize non-regular int base type
clang with dwarf5 may generate non-regular int base type, i.e., not a signed/unsigned char/short/int/longlong/__int128. Such base types are often used to describe
how an actual parameter or variable is generated. For example,
0x000015cf: DW_TAG_base_type
DW_AT_name ("DW_ATE_unsigned_1")
DW_AT_encoding (DW_ATE_unsigned)
DW_AT_byte_size (0x00)0x00010ed9: DW_TAG_formal_parameter
DW_AT_location (DW_OP_lit0,
DW_OP_not,
DW_OP_convert (0x000015cf) "DW_ATE_unsigned_1",
DW_OP_convert (0x000015d4) "DW_ATE_unsigned_8",
DW_OP_stack_value)
DW_AT_abstract_origin (0x00013984 "branch")What it does is with a literal "0", did a "not" operation, and the converted to one-bit unsigned int and then 8-bit unsigned int.
Another example,
0x000e97e4: DW_TAG_base_type
DW_AT_name ("DW_ATE_unsigned_24")
DW_AT_encoding (DW_ATE_unsigned)
DW_AT_byte_size (0x03)0x000f88f8: DW_TAG_variable
DW_AT_location (indexed (0x3c) loclist = 0x00008fb0:
[0xffffffff82808812, 0xffffffff82808817):
DW_OP_breg0 RAX+0,
DW_OP_convert (0x000e97d5) "DW_ATE_unsigned_64",
DW_OP_convert (0x000e97df) "DW_ATE_unsigned_8",
DW_OP_stack_value,
DW_OP_piece 0x1,
DW_OP_breg0 RAX+0,
DW_OP_convert (0x000e97d5) "DW_ATE_unsigned_64",
DW_OP_convert (0x000e97da) "DW_ATE_unsigned_32",
DW_OP_lit8,
DW_OP_shr,
DW_OP_convert (0x000e97da) "DW_ATE_unsigned_32",
DW_OP_convert (0x000e97e4) "DW_ATE_unsigned_24",
DW_OP_stack_value,
DW_OP_piece 0x3
......At one point, a right shift by 8 happens and the result is converted to 32-bit unsigned int and then to 24-bit unsigned int.
BTF does not need any of these DW_OP_* information and such non-regular int types will cause libbpf to emit errors.
Let us sanitize them to generate BTF acceptable to libbpf and kernel.
--- libbtf.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-)
libbtf.c +38 -1
@@ -373,6 +373,7 @@ int32_t btf_elf__add_base_type(struct btf_elf *btfe, const struct base_type *bt,struct btf *btf = btfe->btf;const struct btf_type *t;uint8_t encoding =0 ; +uint16_t byte_sz;int32_t id;if (bt->is_signed) {
@@ -384,7 +385,43 @@ int32_t btf_elf__add_base_type(struct btf_elf *btfe, const struct base_type *bt,return -1 ; } - id =btf__add_int (btf, name,BITS_ROUNDUP_BYTES (bt->bit_size), encoding); +/* dwarf5 may emit DW_ATE_[un]signed_{num} base types where +* {num} is not power of 2 and may exceed 128. Such attributes +* are mostly used to record operation for an actual parameter +* or variable. +* For example, +* DW_AT_location (indexed (0x3c) loclist = 0x00008fb0: +* [0xffffffff82808812, 0xffffffff82808817): +* DW_OP_breg0 RAX+0, +* DW_OP_convert (0x000e97d5) "DW_ATE_unsigned_64", +* DW_OP_convert (0x000e97df) "DW_ATE_unsigned_8", +* DW_OP_stack_value, +* DW_OP_piece 0x1, +* DW_OP_breg0 RAX+0, +* DW_OP_convert (0x000e97d5) "DW_ATE_unsigned_64", +* DW_OP_convert (0x000e97da) "DW_ATE_unsigned_32", +* DW_OP_lit8, +* DW_OP_shr, +* DW_OP_convert (0x000e97da) "DW_ATE_unsigned_32", +* DW_OP_convert (0x000e97e4) "DW_ATE_unsigned_24", +* DW_OP_stack_value, DW_OP_piece 0x3 +* DW_AT_name ("ebx") +* DW_AT_decl_file ("/linux/arch/x86/events/intel/core.c") +* +* In the above example, at some point, one unsigned_32 value +* is right shifted by 8 and the result is converted to unsigned_32 +* and then unsigned_24. +* +* BTF does not need such DW_OP_* information so let us sanitize +* these non-regular int types to avoid libbpf/kernel complaints. +*/ + byte_sz =BITS_ROUNDUP_BYTES (bt->bit_size); +if (!byte_sz || (byte_sz & (byte_sz -1 ))) { + name ="sanitized_int" ; + byte_sz =4 ; + } + + id =btf__add_int (btf, name, byte_sz, encoding);if (id <0 ) {btf_elf__log_err (btfe,BTF_KIND_INT , name, true,"Error emitting BTF type" ); }else {
Signature · 1 line
2.24.1
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
Quoted 87 lines · Yonghong Song
Quoted 83 lines · Sedat Dilek
Quoted 81 lines · Yonghong Song
Quoted 26 lines · Mark Wieelard
Hi,
Quoted 4 lines · Yonghong Song
With the above vmlinux, the issue appears to be handling
DW_ATE_signed_1, DW_ATE_unsigned_{1,24,40}.The following patch should fix the issue:
That doesn't really make sense to me. Why is the compiler emitting a
DW_TAG_base_typethat needs to be interpreted according to theDW_AT_nameattribute?If the issue is that the size of the base type cannot be expressed in bytes then the DWARF spec provides the following option:
If the value of an object of the given type does not fully occupy the storage described by a byte size attribute, the base type entry may also have a
DW_AT_bit_sizeand aDW_AT_data_bit_offsetattribute, both of whose values are integer constant values (see Section 2.19 on page 55). The bit size attribute describes the actual size in bits used to represent values of the given type. The data bit offset attribute is the offset in bits from the beginning of the containing storage to the beginning of the value. Bits that are part of the offset are padding. If this attribute is omitted a default data bit offset of zero is assumed.Quoted 1 line
Would it be possible to use that encoding of those special types? If
I agree with you. I do not like comparing me as well. Unfortunately, there is no enough information in dwarf to find out actual information. The following is the dwarf dump with vmlinux (Sedat provided) for
DW_ATE_unsigned_1.
0x000e97e9:DW_TAG_base_typeDW_AT_name ("DW_ATE_unsigned_1") DW_AT_encoding (DW_ATE_unsigned) DW_AT_byte_size (0x00)There is no
DW_AT_bit_sizeandDW_AT_bit_offsetfor base type. AFAIK, these two attributes typically appear in struct/union members together withDW_AT_byte_size.Maybe compilers (clang in this case) can emit
DW_AT_bit_size= 1 andDW_AT_bit_offset= 0/7 (depending on big/little endian) and this case, we just test and getDW_AT_bit_sizeand it should work.But I think BTF does not need this (
DW_ATE_unsigned_1) for now. I checked dwarf dump and it is mostly used for some arith operation encoded in dump (in this case, e.g., shift by 1 bit)
0x000015cf:DW_TAG_base_typeDW_AT_name ("DW_ATE_unsigned_1") DW_AT_encoding (DW_ATE_unsigned) DW_AT_byte_size (0x00)
0x00010ed9:DW_TAG_formal_parameter
DW_AT_location(DW_OP_lit0,DW_OP_not,DW_OP_convert(0x000015cf) "DW_ATE_unsigned_1",DW_OP_convert(0x000015d4) "DW_ATE_unsigned_8",DW_OP_stack_value)DW_AT_abstract_origin (0x00013984 "branch")Look at clang frontend, only the following types are encoded with unsigned dwarf type.
case BuiltinType::UShort: case BuiltinType::UInt: case BuiltinType::UInt128: case BuiltinType::ULong: case BuiltinType::WChar_U: case BuiltinType::ULongLong: Encoding = llvm::dwarf::DW_ATE_unsigned; break;Quoted 3 lines
not, can we try to come up with some extension that doesn't require consumers to match magic names?
Quoted 6 lines
Quoted 1 line
You want me to upload mlx5_core.ko?
I just sent out a patch. You are cc'ed. I also attached in this email. Yes, it would be great if you can upload mlx5_core.ko so I can double check with this
DW_ATE_unsigned_160which is really usual.
Yupp, just built a new pahole :-).
Re-building linux-kernel...
Will upload mlx5_core.ko - need zstd-ed it before.
- Sedat -
Quoted 14 lines
Quoted 14 lines
When looking with llvm-dwarf for
DW_ATE_unsigned_160:
0x00d65616:DW_TAG_base_typeDW_AT_name ("DW_ATE_unsigned_160") DW_AT_encoding (DW_ATE_unsigned) DW_AT_byte_size (0x14)If you need further information, please let me know.
Thanks.
- Sedat -
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
Quoted 96 lines · Sedat Dilek
Quoted 87 lines · Yonghong Song
Quoted 83 lines · Sedat Dilek
Quoted 81 lines · Yonghong Song
Quoted 26 lines · Mark Wieelard
Hi,
Quoted 4 lines · Yonghong Song
With the above vmlinux, the issue appears to be handling
DW_ATE_signed_1, DW_ATE_unsigned_{1,24,40}.The following patch should fix the issue:
That doesn't really make sense to me. Why is the compiler emitting a
DW_TAG_base_typethat needs to be interpreted according to theDW_AT_nameattribute?If the issue is that the size of the base type cannot be expressed in bytes then the DWARF spec provides the following option:
If the value of an object of the given type does not fully occupy the storage described by a byte size attribute, the base type entry may also have a
DW_AT_bit_sizeand aDW_AT_data_bit_offsetattribute, both of whose values are integer constant values (see Section 2.19 on page 55). The bit size attribute describes the actual size in bits used to represent values of the given type. The data bit offset attribute is the offset in bits from the beginning of the containing storage to the beginning of the value. Bits that are part of the offset are padding. If this attribute is omitted a default data bit offset of zero is assumed.Quoted 1 line
Would it be possible to use that encoding of those special types? If
I agree with you. I do not like comparing me as well. Unfortunately, there is no enough information in dwarf to find out actual information. The following is the dwarf dump with vmlinux (Sedat provided) for
DW_ATE_unsigned_1.
0x000e97e9:DW_TAG_base_typeDW_AT_name ("DW_ATE_unsigned_1") DW_AT_encoding (DW_ATE_unsigned) DW_AT_byte_size (0x00)There is no
DW_AT_bit_sizeandDW_AT_bit_offsetfor base type. AFAIK, these two attributes typically appear in struct/union members together withDW_AT_byte_size.Maybe compilers (clang in this case) can emit
DW_AT_bit_size= 1 andDW_AT_bit_offset= 0/7 (depending on big/little endian) and this case, we just test and getDW_AT_bit_sizeand it should work.But I think BTF does not need this (
DW_ATE_unsigned_1) for now. I checked dwarf dump and it is mostly used for some arith operation encoded in dump (in this case, e.g., shift by 1 bit)
0x000015cf:DW_TAG_base_typeDW_AT_name ("DW_ATE_unsigned_1") DW_AT_encoding (DW_ATE_unsigned) DW_AT_byte_size (0x00)
0x00010ed9:DW_TAG_formal_parameter
DW_AT_location(DW_OP_lit0,DW_OP_not,DW_OP_convert(0x000015cf) "DW_ATE_unsigned_1",DW_OP_convert(0x000015d4) "DW_ATE_unsigned_8",DW_OP_stack_value)DW_AT_abstract_origin (0x00013984 "branch")Look at clang frontend, only the following types are encoded with unsigned dwarf type.
case BuiltinType::UShort: case BuiltinType::UInt: case BuiltinType::UInt128: case BuiltinType::ULong: case BuiltinType::WChar_U: case BuiltinType::ULongLong: Encoding = llvm::dwarf::DW_ATE_unsigned; break;Quoted 3 lines
not, can we try to come up with some extension that doesn't require consumers to match magic names?
Quoted 6 lines
Quoted 1 line
You want me to upload mlx5_core.ko?
I just sent out a patch. You are cc'ed. I also attached in this email. Yes, it would be great if you can upload mlx5_core.ko so I can double check with this
DW_ATE_unsigned_160which is really usual.
Quoted 5 lines
Yupp, just built a new pahole :-).
Re-building linux-kernel...Will upload mlx5_core.ko - need zstd-ed it before.
Hmm, I guess you want a mlx5_core.ko with your patch applied-to-pahole-1.20 :-)?
Quoted 16 lines
- Sedat -
Quoted 14 lines
Quoted 14 lines
When looking with llvm-dwarf for
DW_ATE_unsigned_160:
0x00d65616:DW_TAG_base_typeDW_AT_name ("DW_ATE_unsigned_160") DW_AT_encoding (DW_ATE_unsigned) DW_AT_byte_size (0x14)If you need further information, please let me know.
Thanks.
- Sedat -
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
Quoted 97 lines · Sedat Dilek
Quoted 96 lines · Sedat Dilek
Quoted 93 lines · Yonghong Song
Quoted 79 lines · Sedat Dilek
Quoted 78 lines · Yonghong Song
Quoted 26 lines · Mark Wieelard
Hi,
Quoted 4 lines · Yonghong Song
With the above vmlinux, the issue appears to be handling
DW_ATE_signed_1, DW_ATE_unsigned_{1,24,40}.The following patch should fix the issue:
That doesn't really make sense to me. Why is the compiler emitting a
DW_TAG_base_typethat needs to be interpreted according to theDW_AT_nameattribute?If the issue is that the size of the base type cannot be expressed in bytes then the DWARF spec provides the following option:
If the value of an object of the given type does not fully occupy the storage described by a byte size attribute, the base type entry may also have a
DW_AT_bit_sizeand aDW_AT_data_bit_offsetattribute, both of whose values are integer constant values (see Section 2.19 on page 55). The bit size attribute describes the actual size in bits used to represent values of the given type. The data bit offset attribute is the offset in bits from the beginning of the containing storage to the beginning of the value. Bits that are part of the offset are padding. If this attribute is omitted a default data bit offset of zero is assumed.Quoted 1 line
Would it be possible to use that encoding of those special types? If
I agree with you. I do not like comparing me as well. Unfortunately, there is no enough information in dwarf to find out actual information. The following is the dwarf dump with vmlinux (Sedat provided) for
DW_ATE_unsigned_1.
0x000e97e9:DW_TAG_base_typeDW_AT_name ("DW_ATE_unsigned_1") DW_AT_encoding (DW_ATE_unsigned) DW_AT_byte_size (0x00)There is no
DW_AT_bit_sizeandDW_AT_bit_offsetfor base type. AFAIK, these two attributes typically appear in struct/union members together withDW_AT_byte_size.Maybe compilers (clang in this case) can emit
DW_AT_bit_size= 1 andDW_AT_bit_offset= 0/7 (depending on big/little endian) and this case, we just test and getDW_AT_bit_sizeand it should work.But I think BTF does not need this (
DW_ATE_unsigned_1) for now. I checked dwarf dump and it is mostly used for some arith operation encoded in dump (in this case, e.g., shift by 1 bit)
0x000015cf:DW_TAG_base_typeDW_AT_name ("DW_ATE_unsigned_1") DW_AT_encoding (DW_ATE_unsigned) DW_AT_byte_size (0x00)
0x00010ed9:DW_TAG_formal_parameter
DW_AT_location(DW_OP_lit0,DW_OP_not,DW_OP_convert(0x000015cf) "DW_ATE_unsigned_1",DW_OP_convert(0x000015d4) "DW_ATE_unsigned_8",DW_OP_stack_value)DW_AT_abstract_origin (0x00013984 "branch")Look at clang frontend, only the following types are encoded with unsigned dwarf type.
case BuiltinType::UShort: case BuiltinType::UInt: case BuiltinType::UInt128: case BuiltinType::ULong: case BuiltinType::WChar_U: case BuiltinType::ULongLong: Encoding = llvm::dwarf::DW_ATE_unsigned; break;Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
not, can we try to come up with some extension that doesn't require consumers to match magic names?
You want me to upload mlx5_core.ko?
I just sent out a patch. You are cc'ed. I also attached in this email. Yes, it would be great if you can upload mlx5_core.ko so I can double check with this
DW_ATE_unsigned_160which is really usual.
Quoted 7 lines
Quoted 5 lines
Yupp, just built a new pahole :-).
Re-building linux-kernel...Will upload mlx5_core.ko - need zstd-ed it before.
Hmm, I guess you want a mlx5_core.ko with your patch applied-to-pahole-1.20 :-)?
this should work too. I want to check dwarf data. My patch won't impact dwarf generation.
Quoted 17 lines
Quoted 17 lines
- Sedat -
Quoted 14 lines
Quoted 14 lines
When looking with llvm-dwarf for
DW_ATE_unsigned_160:
0x00d65616:DW_TAG_base_typeDW_AT_name ("DW_ATE_unsigned_160") DW_AT_encoding (DW_ATE_unsigned) DW_AT_byte_size (0x14)If you need further information, please let me know.
Thanks.
- Sedat -
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
Quoted 104 lines · Yonghong Song
Quoted 100 lines · Sedat Dilek
Quoted 99 lines · Sedat Dilek
Quoted 87 lines · Yonghong Song
Quoted 83 lines · Sedat Dilek
Quoted 81 lines · Yonghong Song
Quoted 26 lines · Mark Wieelard
Hi,
Quoted 4 lines · Yonghong Song
With the above vmlinux, the issue appears to be handling
DW_ATE_signed_1, DW_ATE_unsigned_{1,24,40}.The following patch should fix the issue:
That doesn't really make sense to me. Why is the compiler emitting a
DW_TAG_base_typethat needs to be interpreted according to theDW_AT_nameattribute?If the issue is that the size of the base type cannot be expressed in bytes then the DWARF spec provides the following option:
If the value of an object of the given type does not fully occupy the storage described by a byte size attribute, the base type entry may also have a
DW_AT_bit_sizeand aDW_AT_data_bit_offsetattribute, both of whose values are integer constant values (see Section 2.19 on page 55). The bit size attribute describes the actual size in bits used to represent values of the given type. The data bit offset attribute is the offset in bits from the beginning of the containing storage to the beginning of the value. Bits that are part of the offset are padding. If this attribute is omitted a default data bit offset of zero is assumed.Quoted 1 line
Would it be possible to use that encoding of those special types? If
I agree with you. I do not like comparing me as well. Unfortunately, there is no enough information in dwarf to find out actual information. The following is the dwarf dump with vmlinux (Sedat provided) for
DW_ATE_unsigned_1.
0x000e97e9:DW_TAG_base_typeDW_AT_name ("DW_ATE_unsigned_1") DW_AT_encoding (DW_ATE_unsigned) DW_AT_byte_size (0x00)There is no
DW_AT_bit_sizeandDW_AT_bit_offsetfor base type. AFAIK, these two attributes typically appear in struct/union members together withDW_AT_byte_size.Maybe compilers (clang in this case) can emit
DW_AT_bit_size= 1 andDW_AT_bit_offset= 0/7 (depending on big/little endian) and this case, we just test and getDW_AT_bit_sizeand it should work.But I think BTF does not need this (
DW_ATE_unsigned_1) for now. I checked dwarf dump and it is mostly used for some arith operation encoded in dump (in this case, e.g., shift by 1 bit)
0x000015cf:DW_TAG_base_typeDW_AT_name ("DW_ATE_unsigned_1") DW_AT_encoding (DW_ATE_unsigned) DW_AT_byte_size (0x00)
0x00010ed9:DW_TAG_formal_parameter
DW_AT_location(DW_OP_lit0,DW_OP_not,DW_OP_convert(0x000015cf) "DW_ATE_unsigned_1",DW_OP_convert(0x000015d4) "DW_ATE_unsigned_8",DW_OP_stack_value)DW_AT_abstract_origin (0x00013984 "branch")Look at clang frontend, only the following types are encoded with unsigned dwarf type.
case BuiltinType::UShort: case BuiltinType::UInt: case BuiltinType::UInt128: case BuiltinType::ULong: case BuiltinType::WChar_U: case BuiltinType::ULongLong: Encoding = llvm::dwarf::DW_ATE_unsigned; break;Quoted 3 lines
not, can we try to come up with some extension that doesn't require consumers to match magic names?
Quoted 6 lines
Quoted 1 line
You want me to upload mlx5_core.ko?
I just sent out a patch. You are cc'ed. I also attached in this email. Yes, it would be great if you can upload mlx5_core.ko so I can double check with this
DW_ATE_unsigned_160which is really usual.Yupp, just built a new pahole :-).
Re-building linux-kernel...
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Will upload mlx5_core.ko - need zstd-ed it before.
Hmm, I guess you want a mlx5_core.ko with your patch applied-to-pahole-1.20 :-)?
this should work too. I want to check dwarf data. My patch won't impact dwarf generation.
Usual Dropbox-Link:
https://www.dropbox.com/sh/kvyh8ps7na0r1h5/AABfyNfDZ2bESse_bo4h05fFa?dl=0
See "for-yhs" directory:
1. mlx5-module_yhs-v1 ("[PATCH dwarves] btf_encoder: sanitize non-regular int base type")
2. mlx5-module_yhs-dileks-v4 (with the last diff-v4 I tried successfully)
- Sedat -
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
- Sedat -
Quoted 14 lines
Quoted 14 lines
When looking with llvm-dwarf for
DW_ATE_unsigned_160:
0x00d65616:DW_TAG_base_typeDW_AT_name ("DW_ATE_unsigned_160") DW_AT_encoding (DW_ATE_unsigned) DW_AT_byte_size (0x14)If you need further information, please let me know.
Thanks.
- Sedat -
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
Quoted 116 lines · Sedat Dilek
Quoted 104 lines · Yonghong Song
Quoted 100 lines · Sedat Dilek
Quoted 99 lines · Sedat Dilek
Quoted 87 lines · Yonghong Song
Quoted 83 lines · Sedat Dilek
Quoted 81 lines · Yonghong Song
Quoted 26 lines · Mark Wieelard
Hi,
Quoted 4 lines · Yonghong Song
With the above vmlinux, the issue appears to be handling
DW_ATE_signed_1, DW_ATE_unsigned_{1,24,40}.The following patch should fix the issue:
That doesn't really make sense to me. Why is the compiler emitting a
DW_TAG_base_typethat needs to be interpreted according to theDW_AT_nameattribute?If the issue is that the size of the base type cannot be expressed in bytes then the DWARF spec provides the following option:
If the value of an object of the given type does not fully occupy the storage described by a byte size attribute, the base type entry may also have a
DW_AT_bit_sizeand aDW_AT_data_bit_offsetattribute, both of whose values are integer constant values (see Section 2.19 on page 55). The bit size attribute describes the actual size in bits used to represent values of the given type. The data bit offset attribute is the offset in bits from the beginning of the containing storage to the beginning of the value. Bits that are part of the offset are padding. If this attribute is omitted a default data bit offset of zero is assumed.Quoted 1 line
Would it be possible to use that encoding of those special types? If
I agree with you. I do not like comparing me as well. Unfortunately, there is no enough information in dwarf to find out actual information. The following is the dwarf dump with vmlinux (Sedat provided) for
DW_ATE_unsigned_1.
0x000e97e9:DW_TAG_base_typeDW_AT_name ("DW_ATE_unsigned_1") DW_AT_encoding (DW_ATE_unsigned) DW_AT_byte_size (0x00)There is no
DW_AT_bit_sizeandDW_AT_bit_offsetfor base type. AFAIK, these two attributes typically appear in struct/union members together withDW_AT_byte_size.Maybe compilers (clang in this case) can emit
DW_AT_bit_size= 1 andDW_AT_bit_offset= 0/7 (depending on big/little endian) and this case, we just test and getDW_AT_bit_sizeand it should work.But I think BTF does not need this (
DW_ATE_unsigned_1) for now. I checked dwarf dump and it is mostly used for some arith operation encoded in dump (in this case, e.g., shift by 1 bit)
0x000015cf:DW_TAG_base_typeDW_AT_name ("DW_ATE_unsigned_1") DW_AT_encoding (DW_ATE_unsigned) DW_AT_byte_size (0x00)
0x00010ed9:DW_TAG_formal_parameter
DW_AT_location(DW_OP_lit0,DW_OP_not,DW_OP_convert(0x000015cf) "DW_ATE_unsigned_1",DW_OP_convert(0x000015d4) "DW_ATE_unsigned_8",DW_OP_stack_value)DW_AT_abstract_origin (0x00013984 "branch")Look at clang frontend, only the following types are encoded with unsigned dwarf type.
case BuiltinType::UShort: case BuiltinType::UInt: case BuiltinType::UInt128: case BuiltinType::ULong: case BuiltinType::WChar_U: case BuiltinType::ULongLong: Encoding = llvm::dwarf::DW_ATE_unsigned; break;Quoted 3 lines
not, can we try to come up with some extension that doesn't require consumers to match magic names?
Quoted 6 lines
Quoted 1 line
You want me to upload mlx5_core.ko?
I just sent out a patch. You are cc'ed. I also attached in this email. Yes, it would be great if you can upload mlx5_core.ko so I can double check with this
DW_ATE_unsigned_160which is really usual.Yupp, just built a new pahole :-).
Re-building linux-kernel...Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Will upload mlx5_core.ko - need zstd-ed it before.
Hmm, I guess you want a mlx5_core.ko with your patch applied-to-pahole-1.20 :-)?
this should work too. I want to check dwarf data. My patch won't impact dwarf generation.
Usual Dropbox-Link:
Quoted 7 lines
https://www.dropbox.com/sh/kvyh8ps7na0r1h5/AABfyNfDZ2bESse_bo4h05fFa?dl=0
See "for-yhs" directory:
1. mlx5-module_yhs-v1 ("[PATCH dwarves]
btf_encoder: sanitize non-regular int base type")
2. mlx5-module_yhs-dileks-v4 (with the last diff-v4 I tried successfully)
Thanks, with llvm-dwarfdump, I can see
0x00d65616: DW_TAG_base_type
DW_AT_name ("DW_ATE_unsigned_160")
DW_AT_encoding (DW_ATE_unsigned)
DW_AT_byte_size (0x14)0x00d88e81: DW_TAG_variable
DW_AT_location (indexed (0xad) loclist =
0x0005df42:
[0x0000000000088c8e, 0x0000000000088c97):
DW_OP_breg9 R9+0, DW_OP_convert (0x00d65616) "DW_ATE_unsigned_160", DW_OP_convert (0x00d65607) "DW_ATE_unsigned_32", DW_OP_stack_value, DW_OP_piece 0x4)
DW_AT_abstract_origin (0x00d88d37 "_v")0x00d88d37: DW_TAG_variable
DW_AT_name ("_v")
DW_AT_decl_file
("/home/dileks/src/linux-kernel/git/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste.c")
DW_AT_decl_line (1198)
DW_AT_type (0x00d68835 "u32")The source code at line 1198.
1198 DR_STE_SET_MASK_V(eth_l3_ipv4_5_tuple, bit_mask,
1199 source_port, mask, udp_sport);
This is for struct mlx5dr_match_spec.
struct mlx5dr_match_spec {
u32 smac_47_16; /* Source MAC address of incoming packet */
/* Incoming packet Ethertype - this is the Ethertype
* following the last VLAN tag of the packet
*/
u32 ethertype:16;
u32 smac_15_0:16;
...
u32 tcp_dport:16;
/* TCP source port.;tcp and udp sport/dport are mutually
exclusive */
u32 tcp_sport:16;
u32 ttl_hoplimit:8;
u32 reserved:24;
/* UDP destination port.;tcp and udp sport/dport are mutually
exclusive */
u32 udp_dport:16;
/* UDP source port.;tcp and udp sport/dport are mutually
exclusive */
u32 udp_sport:16;
/* IPv6 source address of incoming packets
* For IPv4 address use bits 31:0 (rest of the bits are reserved)
* This field should be qualified by an appropriate ethertype
*/
u32 src_ip_127_96;...
}
which includes a bunch of bit fields and non-bit fields.
I have no idea why clang will generate
DW_OP_convert (0x00d65616) "DW_ATE_unsigned_160"
and possibly try to capture more semantic information? But BTF should be able to safely ignore this as described in my patch.
Thanks.
Quoted 20 lines
- Sedat -
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
- Sedat -
Quoted 14 lines
Quoted 14 lines
When looking with llvm-dwarf for
DW_ATE_unsigned_160:
0x00d65616:DW_TAG_base_typeDW_AT_name ("DW_ATE_unsigned_160") DW_AT_encoding (DW_ATE_unsigned) DW_AT_byte_size (0x14)If you need further information, please let me know.
Thanks.
- Sedat -
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
Quoted 188 lines · Yonghong Song
Quoted 116 lines · Sedat Dilek
Quoted 104 lines · Yonghong Song
Quoted 100 lines · Sedat Dilek
Quoted 99 lines · Sedat Dilek
Quoted 87 lines · Yonghong Song
Quoted 83 lines · Sedat Dilek
Quoted 81 lines · Yonghong Song
Quoted 26 lines · Mark Wieelard
Hi,
Quoted 4 lines · Yonghong Song
With the above vmlinux, the issue appears to be handling
DW_ATE_signed_1, DW_ATE_unsigned_{1,24,40}.The following patch should fix the issue:
That doesn't really make sense to me. Why is the compiler emitting a
DW_TAG_base_typethat needs to be interpreted according to theDW_AT_nameattribute?If the issue is that the size of the base type cannot be expressed in bytes then the DWARF spec provides the following option:
If the value of an object of the given type does not fully occupy the storage described by a byte size attribute, the base type entry may also have a
DW_AT_bit_sizeand aDW_AT_data_bit_offsetattribute, both of whose values are integer constant values (see Section 2.19 on page 55). The bit size attribute describes the actual size in bits used to represent values of the given type. The data bit offset attribute is the offset in bits from the beginning of the containing storage to the beginning of the value. Bits that are part of the offset are padding. If this attribute is omitted a default data bit offset of zero is assumed.Quoted 1 line
Would it be possible to use that encoding of those special types? If
I agree with you. I do not like comparing me as well. Unfortunately, there is no enough information in dwarf to find out actual information. The following is the dwarf dump with vmlinux (Sedat provided) for
DW_ATE_unsigned_1.
0x000e97e9:DW_TAG_base_typeDW_AT_name ("DW_ATE_unsigned_1") DW_AT_encoding (DW_ATE_unsigned) DW_AT_byte_size (0x00)There is no
DW_AT_bit_sizeandDW_AT_bit_offsetfor base type. AFAIK, these two attributes typically appear in struct/union members together withDW_AT_byte_size.Maybe compilers (clang in this case) can emit
DW_AT_bit_size= 1 andDW_AT_bit_offset= 0/7 (depending on big/little endian) and this case, we just test and getDW_AT_bit_sizeand it should work.But I think BTF does not need this (
DW_ATE_unsigned_1) for now. I checked dwarf dump and it is mostly used for some arith operation encoded in dump (in this case, e.g., shift by 1 bit)
0x000015cf:DW_TAG_base_typeDW_AT_name ("DW_ATE_unsigned_1") DW_AT_encoding (DW_ATE_unsigned) DW_AT_byte_size (0x00)
0x00010ed9:DW_TAG_formal_parameter
DW_AT_location(DW_OP_lit0,DW_OP_not,DW_OP_convert(0x000015cf) "DW_ATE_unsigned_1",DW_OP_convert(0x000015d4) "DW_ATE_unsigned_8",DW_OP_stack_value)DW_AT_abstract_origin (0x00013984 "branch")Look at clang frontend, only the following types are encoded with unsigned dwarf type.
case BuiltinType::UShort: case BuiltinType::UInt: case BuiltinType::UInt128: case BuiltinType::ULong: case BuiltinType::WChar_U: case BuiltinType::ULongLong: Encoding = llvm::dwarf::DW_ATE_unsigned; break;Quoted 3 lines
not, can we try to come up with some extension that doesn't require consumers to match magic names?
Quoted 6 lines
Quoted 1 line
You want me to upload mlx5_core.ko?
I just sent out a patch. You are cc'ed. I also attached in this email. Yes, it would be great if you can upload mlx5_core.ko so I can double check with this
DW_ATE_unsigned_160which is really usual.Yupp, just built a new pahole :-).
Re-building linux-kernel...Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Will upload mlx5_core.ko - need zstd-ed it before.
Hmm, I guess you want a mlx5_core.ko with your patch applied-to-pahole-1.20 :-)?
this should work too. I want to check dwarf data. My patch won't impact dwarf generation.
Usual Dropbox-Link:
Quoted 7 lines
https://www.dropbox.com/sh/kvyh8ps7na0r1h5/AABfyNfDZ2bESse_bo4h05fFa?dl=0
See "for-yhs" directory:
1. mlx5-module_yhs-v1 ("[PATCH dwarves]
btf_encoder: sanitize non-regular int base type")
2. mlx5-module_yhs-dileks-v4 (with the last diff-v4 I tried successfully)Thanks, with llvm-dwarfdump, I can see
0x00d65616:DW_TAG_base_typeDW_AT_name ("DW_ATE_unsigned_160") DW_AT_encoding (DW_ATE_unsigned) DW_AT_byte_size (0x14)
0x00d88e81:DW_TAG_variableDW_AT_location (indexed (0xad) loclist = 0x0005df42: [0x0000000000088c8e, 0x0000000000088c97): DW_OP_breg9 R9+0, DW_OP_convert (0x00d65616) "DW_ATE_unsigned_160", DW_OP_convert (0x00d65607) "DW_ATE_unsigned_32", DW_OP_stack_value, DW_OP_piece 0x4) DW_AT_abstract_origin (0x00d88d37 "_v")
0x00d88d37:DW_TAG_variableDW_AT_name ("_v") DW_AT_decl_file ("/home/dileks/src/linux-kernel/git/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste.c") DW_AT_decl_line (1198) DW_AT_type (0x00d68835 "u32")The source code at line 1198.
1198 DR_STE_SET_MASK_V(eth_l3_ipv4_5_tuple,bit_mask,
1199source_port, mask,udp_sport);This is for struct
mlx5dr_match_spec.struct mlx5dr_match_spec { u32 smac_47_16; /* Source MAC address of incoming packet */ /* Incoming packet Ethertype - this is the Ethertype * following the last VLAN tag of the packet */ u32 ethertype:16; u32 smac_15_0:16; ... u32 tcp_dport:16; /* TCP source port.;tcp and udp sport/dport are mutually exclusive */ u32 tcp_sport:16; u32 ttl_hoplimit:8; u32 reserved:24; /* UDP destination port.;tcp and udp sport/dport are mutually exclusive */ u32 udp_dport:16; /* UDP source port.;tcp and udp sport/dport are mutually exclusive */ u32 udp_sport:16; /* IPv6 source address of incoming packets * For IPv4 address use bits 31:0 (rest of the bits are reserved) * This field should be qualified by an appropriate ethertype */ u32 src_ip_127_96;...
}which includes a bunch of bit fields and non-bit fields.
Quoted 8 lines
I have no idea why clang will generate
DW_OP_convert (0x00d65616) "DW_ATE_unsigned_160"and possibly try to capture more semantic information? But BTF should be able to safely ignore this as described in my patch.
Thanks.
[ CC Fangrui - the only guy I know who might comment on this ]
Fangrui, feel free to comment?
Get the patch "[PATCH dwarves] btf_encoder: sanitize non-regular int base type" from Yonghong Son:
link="https://lore.kernel.org/r/[email protected]" b4 -d am $link
I commented the success in the other thread.
Sorry for cross-posting.
Big Thank-You Yonghong!
- Sedat -
- Sedat -
Quoted 20 lines
Quoted 20 lines
- Sedat -
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
- Sedat -
Quoted 14 lines
Quoted 14 lines
When looking with llvm-dwarf for
DW_ATE_unsigned_160:
0x00d65616:DW_TAG_base_typeDW_AT_name ("DW_ATE_unsigned_160") DW_AT_encoding (DW_ATE_unsigned) DW_AT_byte_size (0x14)If you need further information, please let me know.
Thanks.
- Sedat -
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
In reply to Yonghong SongQuoted 35 lines · Yonghong Song
Quoted 9 lines · Arnaldo Carvalho de Melo
Em Fri, Feb 05, 2021 at 11:10:08AM -0800, Yonghong Song escreveu:
Quoted 7 lines · Sedat Dilek
Quoted 3 lines · Sedat Dilek
Grepping through linux.git/tools I guess some BTF
tools/libsneed to know whatBTF_INT_UNSIGNEDis?
BTF_INT_UNSIGNEDneeds kernel support. Maybe to teach pahole to ignore this for now until kernel infrastructure is ready.Quoted 6 lines
Yeah, I thought about doing that.
Quoted 2 lines
Not sure whether this information will be useful or not for BTF. This needs to be discussed separately.
Maybe search for the rationale for its introduction in DWARF.
In LLVM, we have:
uint8_t BTFEncoding; switch (Encoding) { case dwarf::DW_ATE_boolean: BTFEncoding = BTF::INT_BOOL; break; case dwarf::DW_ATE_signed: case dwarf::DW_ATE_signed_char: BTFEncoding = BTF::INT_SIGNED; break; case dwarf::DW_ATE_unsigned: case dwarf::DW_ATE_unsigned_char: BTFEncoding = 0; break;
Quoted 3 lines
I think
DW_ATE_unsignedcan be ignored in pahole since the default encoding = 0. A simple comment is enough.
For the followers (here: LLVM v12.0.0-rc1):
[ llvm/lib/Target/BPF/BTFDebug.cpp ]
BTFTypeInt::BTFTypeInt(uint32_t Encoding, uint32_t SizeInBits,
uint32_t OffsetInBits, StringRef TypeName)
: Name(TypeName) {
// Translate IR int encoding to BTF int encoding. uint8_t BTFEncoding;
switch (Encoding) {
case dwarf::DW_ATE_boolean:
BTFEncoding = BTF::INT_BOOL;
break;
case dwarf::DW_ATE_signed:
case dwarf::DW_ATE_signed_char:
BTFEncoding = BTF::INT_SIGNED;
break;
case dwarf::DW_ATE_unsigned:
case dwarf::DW_ATE_unsigned_char:
BTFEncoding = 0;
break;
default:
llvm_unreachable("Unknown BTFTypeInt Encoding");}
- Sedat -
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
In reply to Arnaldo Carvalho de MeloQuoted 42 lines · Arnaldo Carvalho de Melo
Em Fri, Feb 05, 2021 at 04:23:59PM +0100, Sedat Dilek escreveu:
Quoted 40 lines · Sedat Dilek
Quoted 17 lines · Sedat Dilek
Quoted 14 lines
Hi,
when building with pahole v1.20 and binutils v2.35.2 plus Clang v12.0.0-rc1 and DWARF-v5 I see:
...
+ info BTF .btf.vmlinux.bin.o
+ [ !=silent_]
+ printf %-7s %s\n BTF .btf.vmlinux.bin.o
BTF .btf.vmlinux.bin.o
+ LLVM_OBJCOPY=/opt/binutils/bin/objcopy/opt/pahole/bin/pahole-J .tmp_vmlinux.btf
[115] INTDW_ATE_unsigned_1Error emitting BTF type Encountered error while encoding BTF.Quoted 8 lines
Grepping the pahole sources:
$ git grep DW_ATE dwarf_loader.c: bt->is_bool = encoding == DW_ATE_boolean; dwarf_loader.c: bt->is_signed = encoding == DW_ATE_signed;Missing
DW_ATE_unsignedencoding?Checked the LLVM sources:
clang/lib/CodeGen/CGDebugInfo.cpp: Encoding =
llvm::dwarf::DW_ATE_unsigned_char;
clang/lib/CodeGen/CGDebugInfo.cpp: Encoding =llvm::dwarf::DW_ATE_unsigned;
clang/lib/CodeGen/CGDebugInfo.cpp: Encoding =llvm::dwarf::DW_ATE_unsigned_fixed;
clang/lib/CodeGen/CGDebugInfo.cpp:
?llvm::dwarf::DW_ATE_unsigned
...
lld/test/wasm/debuginfo.test:CHECK-NEXT:DW_AT_encoding
(DW_ATE_unsigned)
Quoted 6 lines
Quoted 1 line
So, I will switch from GNU ld.bfd v2.35.2 to LLD-12.
Thanks for the research, probably your conclusion is correct, can you go the next step and add that part and check if the end result is the expected one?
Started a new build:
$ ps -ef | grep p[e]rf dileks 529807 529775 0 16:32 pts/1 00:00:00 /usr/bin/perf_5.10 stat make V=1 -j4 LLVM=1 PAHOLE=/opt/pahole/bin/pahole LOCALVERSION=-12-amd64-clang12-llvm KBUIL D_VERBOSE=1 KBUILD_BUILD_HOST=iniza [email protected] KBUILD_BUILD_TIMESTAMP=2021-02-05 bindeb-pkg KDEB_PKGVERSION=5.11.0~rc6-12~bullseye+dileks1
$ scripts/diffconfig /boot/config-5.11.0-rc6-10-amd64-clang12-bfd .config BUILD_SALT "5.11.0-rc6-10-amd64-clang12-bfd" -> "5.11.0-rc6-11-amd64-clang12-llvm" DEBUG_INFO_DWARF4 y -> n LD_VERSION 235020000 -> 0 LLD_VERSION 0 -> 120000 +DEBUG_INFO_DWARF5 y +LD_IS_LLD y +TOOLS_SUPPORT_RELR y
Will take approx. 03:15 [hh:mm] and report later.
- Sedat -
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
In reply to Sedat DilekQuoted 13 lines
Hi,
when building with pahole v1.20 and binutils v2.35.2 plus Clang v12.0.0-rc1 and DWARF-v5 I see:
...
+ info BTF .btf.vmlinux.bin.o
+ [ !=silent_]
+ printf %-7s %s\n BTF .btf.vmlinux.bin.o
BTF .btf.vmlinux.bin.o
+ LLVM_OBJCOPY=/opt/binutils/bin/objcopy/opt/pahole/bin/pahole-J .tmp_vmlinux.btf
[115] INTDW_ATE_unsigned_1Error emitting BTF type Encountered error while encoding BTF.
Yes, I observe this error, too.
https://gist.github.com/nickdesaulniers/ae8c9efbe4da69b1cf0dce138c1d2781
via v9 of my DWARF v5 series, which should help make this easier to reproduce:
https://lore.kernel.org/lkml/CA+icZUW3sg_PkbmKSFMs6EqwQV7=hvKuAgZSsbg=Qr6gTs7RbQ@mail.gmail.com/T/#m45ec7e6df4c4b5e9da034b95d7dfc8e2a0c81dac
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
Quoted 15 lines · Nick Desaulniers
Quoted 14 lines
Hi,
when building with pahole v1.20 and binutils v2.35.2 plus Clang v12.0.0-rc1 and DWARF-v5 I see:
...
+ info BTF .btf.vmlinux.bin.o
+ [ !=silent_]
+ printf %-7s %s\n BTF .btf.vmlinux.bin.o
BTF .btf.vmlinux.bin.o
+ LLVM_OBJCOPY=/opt/binutils/bin/objcopy/opt/pahole/bin/pahole-J .tmp_vmlinux.btf
[115] INTDW_ATE_unsigned_1Error emitting BTF type Encountered error while encoding BTF.
Quoted 7 lines
Yes, I observe this error, too.
https://gist.github.com/nickdesaulniers/ae8c9efbe4da69b1cf0dce138c1d2781
via v9 of my DWARF v5 series, which should help make this easier to reproduce:
https://lore.kernel.org/lkml/CA+icZUW3sg_PkbmKSFMs6EqwQV7=hvKuAgZSsbg=Qr6gTs7RbQ@mail.gmail.com/T/#m45ec7e6df4c4b5e9da034b95d7dfc8e2a0c81dac
Thanks Nick for confirming the error.
Ah, I see you passed:
make LLVM=1 LLVM_IAS=1 ...
Can you by chance try with KCFLAGS="-fbinutils-version=2.35"?
- Sedat -
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
Quoted 26 lines · Sedat Dilek
Quoted 15 lines · Nick Desaulniers
Quoted 14 lines
Hi,
when building with pahole v1.20 and binutils v2.35.2 plus Clang v12.0.0-rc1 and DWARF-v5 I see:
...
+ info BTF .btf.vmlinux.bin.o
+ [ !=silent_]
+ printf %-7s %s\n BTF .btf.vmlinux.bin.o
BTF .btf.vmlinux.bin.o
+ LLVM_OBJCOPY=/opt/binutils/bin/objcopy/opt/pahole/bin/pahole-J .tmp_vmlinux.btf
[115] INTDW_ATE_unsigned_1Error emitting BTF type Encountered error while encoding BTF.Quoted 7 lines
Yes, I observe this error, too.
https://gist.github.com/nickdesaulniers/ae8c9efbe4da69b1cf0dce138c1d2781
via v9 of my DWARF v5 series, which should help make this easier to reproduce:
https://lore.kernel.org/lkml/CA+icZUW3sg_PkbmKSFMs6EqwQV7=hvKuAgZSsbg=Qr6gTs7RbQ@mail.gmail.com/T/#m45ec7e6df4c4b5e9da034b95d7dfc8e2a0c81dac
Quoted 7 lines
Thanks Nick for confirming the error.
Ah, I see you passed:
make LLVM=1 LLVM_IAS=1 ...
Can you by chance try with KCFLAGS="-fbinutils-version=2.35"?
$ PATH=/path/to/tot/pahole/build:$PATH make LLVM=1 LLVM_IAS=1 -j72 KCFLAGS="-fbinutils-version=2.35" ... BTF .btf.vmlinux.bin.o [12919] INT DW_ATE_unsigned_1 Error emitting BTF type Encountered error while encoding BTF. ... LD vmlinux BTFIDS vmlinux FAILED: load BTF from vmlinux: Invalid argument
Signature · 2 lines
Thanks, ~Nick Desaulniers
Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
Quoted 36 lines · Nick Desaulniers
Quoted 26 lines · Sedat Dilek
Quoted 15 lines · Nick Desaulniers
Quoted 14 lines
Hi,
when building with pahole v1.20 and binutils v2.35.2 plus Clang v12.0.0-rc1 and DWARF-v5 I see:
...
+ info BTF .btf.vmlinux.bin.o
+ [ !=silent_]
+ printf %-7s %s\n BTF .btf.vmlinux.bin.o
BTF .btf.vmlinux.bin.o
+ LLVM_OBJCOPY=/opt/binutils/bin/objcopy/opt/pahole/bin/pahole-J .tmp_vmlinux.btf
[115] INTDW_ATE_unsigned_1Error emitting BTF type Encountered error while encoding BTF.Quoted 7 lines
Yes, I observe this error, too.
https://gist.github.com/nickdesaulniers/ae8c9efbe4da69b1cf0dce138c1d2781
via v9 of my DWARF v5 series, which should help make this easier to reproduce:
https://lore.kernel.org/lkml/CA+icZUW3sg_PkbmKSFMs6EqwQV7=hvKuAgZSsbg=Qr6gTs7RbQ@mail.gmail.com/T/#m45ec7e6df4c4b5e9da034b95d7dfc8e2a0c81dacQuoted 7 lines
Thanks Nick for confirming the error.
Ah, I see you passed:
make LLVM=1 LLVM_IAS=1 ...
Can you by chance try with KCFLAGS="-fbinutils-version=2.35"?
Quoted 11 lines
$ PATH=/path/to/tot/pahole/build:$PATH make LLVM=1 LLVM_IAS=1 -j72 KCFLAGS="-fbinutils-version=2.35" ... BTF .btf.vmlinux.bin.o [12919] INT DW_ATE_unsigned_1 Error emitting BTF type Encountered error while encoding BTF. ... LD vmlinux BTFIDS vmlinux FAILED: load BTF from vmlinux: Invalid argument
OK, thanks.
I stopped my build:
/usr/bin/perf_5.10 stat make V=1 -j4 LLVM=1 LLVM_IAS=1 PAHOLE=/opt/pahole/bin/pahole KCFLAGS=-fbinutils-version=2.3 5 LOCALVERSION=-13-amd64-clang12-llvm KBUILD_VERBOSE=1 KBUILD_BUILD_HOST=iniza [email protected] KBUILD_BUILD_TIMESTAMP=2021-02-05 bindeb-pkg KDE B_PKGVERSION=5.11.0~rc6-13~bullseye+dileks1
Enjoy weekend.
- Sedat -
Quoted 13 lines · Arnaldo Carvalho de Melo
Hi,
The v1.20 release of pahole and its friends is out, mostly
addressing problems related to gcc 11 defaulting to DWARF5 for -g, available at the usual places:Main git repo:
git://git.kernel.org/pub/scm/devel/pahole/pahole.gitMirror git repo:
Quoted 8 lines
https://github.com/acmel/dwarves.git
tarball + gpg signature:
https://fedorapeople.org/~acme/dwarves/dwarves-1.20.tar.xz https://fedorapeople.org/~acme/dwarves/dwarves-1.20.tar.bz2 https://fedorapeople.org/~acme/dwarves/dwarves-1.20.tar.sign
FYI:
Debian now ships dwarves package version 1.20-1 in unstable.
Just a small nit to this release and its tagging:
You did:
commit 0d415f68c468b77c5bf8e71965cd08c6efd25fc4 ("pahole: Prep 1.20")
Is this new?
The release before:
commit dd15aa4b0a6421295cbb7c3913429142fef8abe0 ("dwarves: Prep v1.19")
- Sedat -
Quoted 72 lines
Best Regards,
- Arnaldo
v1.20:
BTF encoder:
- Improve ELF error reporting using elf_errmsg(elf_errno()).
- Improve objcopy error handling.
- Fix handling of 'restrict' qualifier, that was being treated as a 'const'.
- Support
SHN_XINDEXinst_shndxsymbol indexes, to handle ELF objects with more than 65534 sections, for instance, which happens with kernels built with 'KCFLAGS="-ffunction-sections -fdata-sections", Other cases may include when using FG-ASLR, LTO.- Cope with functions without a name, as seen sometimes when building kernel images with some versions of clang, when a SEGFAULT was taking place.
- Fix BTF variable generation for kernel modules, not skipping variables at offset zero.
- Fix address size to match what is in the ELF file being processed, to fix using a 64-bit pahole binary to generate BTF for a 32-bit vmlinux image.
- Use kernel module ftrace addresses when finding which functions to encode, which increases the number of functions encoded.
libbpf:
- Allow use of packaged version, for distros wanting to dynamically link with the system's libbpf package instead of using the libbpf git submodule shipped in pahole's source code.
DWARF loader:
- Support
DW_AT_data_bit_offsetThis appeared in DWARF4 but is supported only in gcc's -gdwarf-5, support it in a way that makes the output be the same for both cases.
$ gcc -gdwarf-5 -c
examples/dwarf5/bf.c
$ pahole bf.o
struct pea {
long int a:1; /* 0: 0 8 */
long int b:1; /* 0: 1 8 */
long int c:1; /* 0: 2 8 *//* XXX 29 bits hole, try to pack */ /* Bitfield combined with next fields */
int
after_bitfield; /* 4 4 *//* size: 8, cachelines: 1, members: 4 */
/* sum members: 4 */
/* sum bitfield members: 3 bits, bit holes: 1, sum bit holes: 29 bits */ /* last cacheline: 8 bytes */
};-
DW_FORM_implicit_constinattr_numeric()andattr_offset()- Support
DW_TAG_GNU_call_site, its the standardized rename of the previously supportedDW_TAG_GNU_call_site.build:
- Fix compilation on 32-bit architectures.
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
Em Mon, Feb 08, 2021 at 03:44:54AM +0100, Sedat Dilek escreveu:
Quoted 29 lines
Quoted 13 lines · Arnaldo Carvalho de Melo
Hi,
The v1.20 release of pahole and its friends is out, mostly
addressing problems related to gcc 11 defaulting to DWARF5 for -g, available at the usual places:Main git repo:
git://git.kernel.org/pub/scm/devel/pahole/pahole.gitMirror git repo:
Quoted 8 lines
https://github.com/acmel/dwarves.git
tarball + gpg signature:
https://fedorapeople.org/~acme/dwarves/dwarves-1.20.tar.xz https://fedorapeople.org/~acme/dwarves/dwarves-1.20.tar.bz2 https://fedorapeople.org/~acme/dwarves/dwarves-1.20.tar.signFYI:
Debian now ships dwarves package version 1.20-1 in unstable.Just a small nit to this release and its tagging:
Quoted 7 lines
You did:
commit0d415f68c468b77c5bf8e71965cd08c6efd25fc4("pahole: Prep 1.20")Is this new?
The release before:
commitdd15aa4b0a6421295cbb7c3913429142fef8abe0("dwarves: Prep v1.19")
Its minor but intentional, pahole is by far the most well known tool in dwarves, so using that name more frequently (the git repo is pahole.git , for instance) may help more quickly associate with the tool needed for BTF encoding, data analysis, etc. And since its not about only DWARF, perhaps transitioning to using 'pahole' more widely is interesting.
- Arnaldo
Quoted 74 lines
- Sedat -
Quoted 72 lines
Best Regards,
- Arnaldo
v1.20:
BTF encoder:
- Improve ELF error reporting using elf_errmsg(elf_errno()).
- Improve objcopy error handling.
- Fix handling of 'restrict' qualifier, that was being treated as a 'const'.
- Support
SHN_XINDEXinst_shndxsymbol indexes, to handle ELF objects with more than 65534 sections, for instance, which happens with kernels built with 'KCFLAGS="-ffunction-sections -fdata-sections", Other cases may include when using FG-ASLR, LTO.- Cope with functions without a name, as seen sometimes when building kernel images with some versions of clang, when a SEGFAULT was taking place.
- Fix BTF variable generation for kernel modules, not skipping variables at offset zero.
- Fix address size to match what is in the ELF file being processed, to fix using a 64-bit pahole binary to generate BTF for a 32-bit vmlinux image.
- Use kernel module ftrace addresses when finding which functions to encode, which increases the number of functions encoded.
libbpf:
- Allow use of packaged version, for distros wanting to dynamically link with the system's libbpf package instead of using the libbpf git submodule shipped in pahole's source code.
DWARF loader:
- Support
DW_AT_data_bit_offsetThis appeared in DWARF4 but is supported only in gcc's -gdwarf-5, support it in a way that makes the output be the same for both cases.
$ gcc -gdwarf-5 -c
examples/dwarf5/bf.c
$ pahole bf.o
struct pea {
long int a:1; /* 0: 0 8 */
long int b:1; /* 0: 1 8 */
long int c:1; /* 0: 2 8 *//* XXX 29 bits hole, try to pack */ /* Bitfield combined with next fields */
int
after_bitfield; /* 4 4 *//* size: 8, cachelines: 1, members: 4 */
/* sum members: 4 */
/* sum bitfield members: 3 bits, bit holes: 1, sum bit holes: 29 bits */ /* last cacheline: 8 bytes */
};-
DW_FORM_implicit_constinattr_numeric()andattr_offset()- Support
DW_TAG_GNU_call_site, its the standardized rename of the previously supportedDW_TAG_GNU_call_site.build:
- Fix compilation on 32-bit architectures.
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
Signature · 1 line
- Arnaldo
Quoted 36 lines · Arnaldo Carvalho de Melo
Em Mon, Feb 08, 2021 at 03:44:54AM +0100, Sedat Dilek escreveu:
Quoted 34 lines
Quoted 13 lines · Arnaldo Carvalho de Melo
Hi,
The v1.20 release of pahole and its friends is out, mostly
addressing problems related to gcc 11 defaulting to DWARF5 for -g, available at the usual places:Main git repo:
git://git.kernel.org/pub/scm/devel/pahole/pahole.gitMirror git repo:
Quoted 8 lines
https://github.com/acmel/dwarves.git
tarball + gpg signature:
https://fedorapeople.org/~acme/dwarves/dwarves-1.20.tar.xz https://fedorapeople.org/~acme/dwarves/dwarves-1.20.tar.bz2 https://fedorapeople.org/~acme/dwarves/dwarves-1.20.tar.signFYI:
Debian now ships dwarves package version 1.20-1 in unstable.Just a small nit to this release and its tagging:
You did:
commit0d415f68c468b77c5bf8e71965cd08c6efd25fc4("pahole: Prep 1.20")Is this new?
Quoted 9 lines
Quoted 2 lines
The release before:
commitdd15aa4b0a6421295cbb7c3913429142fef8abe0("dwarves: Prep v1.19")Its minor but intentional, pahole is by far the most well known tool in dwarves, so using that name more frequently (the git repo is pahole.git , for instance) may help more quickly associate with the tool needed for BTF encoding, data analysis, etc. And since its not about only DWARF, perhaps transitioning to using 'pahole' more widely is interesting.
I am fine with that, Arnaldo.
The Git tree is called "pahole" Git, so that makes sense to me.
- Sedat -
Quoted 80 lines
- Arnaldo
Quoted 74 lines
- Sedat -
Quoted 72 lines
Best Regards,
- Arnaldo
v1.20:
BTF encoder:
- Improve ELF error reporting using elf_errmsg(elf_errno()).
- Improve objcopy error handling.
- Fix handling of 'restrict' qualifier, that was being treated as a 'const'.
- Support
SHN_XINDEXinst_shndxsymbol indexes, to handle ELF objects with more than 65534 sections, for instance, which happens with kernels built with 'KCFLAGS="-ffunction-sections -fdata-sections", Other cases may include when using FG-ASLR, LTO.- Cope with functions without a name, as seen sometimes when building kernel images with some versions of clang, when a SEGFAULT was taking place.
- Fix BTF variable generation for kernel modules, not skipping variables at offset zero.
- Fix address size to match what is in the ELF file being processed, to fix using a 64-bit pahole binary to generate BTF for a 32-bit vmlinux image.
- Use kernel module ftrace addresses when finding which functions to encode, which increases the number of functions encoded.
libbpf:
- Allow use of packaged version, for distros wanting to dynamically link with the system's libbpf package instead of using the libbpf git submodule shipped in pahole's source code.
DWARF loader:
- Support
DW_AT_data_bit_offsetThis appeared in DWARF4 but is supported only in gcc's -gdwarf-5, support it in a way that makes the output be the same for both cases.
$ gcc -gdwarf-5 -c
examples/dwarf5/bf.c
$ pahole bf.o
struct pea {
long int a:1; /* 0: 0 8 */
long int b:1; /* 0: 1 8 */
long int c:1; /* 0: 2 8 *//* XXX 29 bits hole, try to pack */ /* Bitfield combined with next fields */
int
after_bitfield; /* 4 4 *//* size: 8, cachelines: 1, members: 4 */
/* sum members: 4 */
/* sum bitfield members: 3 bits, bit holes: 1, sum bit holes: 29 bits */ /* last cacheline: 8 bytes */
};-
DW_FORM_implicit_constinattr_numeric()andattr_offset()- Support
DW_TAG_GNU_call_site, its the standardized rename of the previously supportedDW_TAG_GNU_call_site.build:
- Fix compilation on 32-bit architectures.
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>--
- Arnaldo
Quoted 35 lines · Arnaldo Carvalho de Melo
Em Mon, Feb 08, 2021 at 03:44:54AM +0100, Sedat Dilek escreveu:
Quoted 34 lines
Quoted 13 lines · Arnaldo Carvalho de Melo
Hi,
The v1.20 release of pahole and its friends is out, mostly
addressing problems related to gcc 11 defaulting to DWARF5 for -g, available at the usual places:Main git repo:
git://git.kernel.org/pub/scm/devel/pahole/pahole.gitMirror git repo:
Quoted 8 lines
https://github.com/acmel/dwarves.git
tarball + gpg signature:
https://fedorapeople.org/~acme/dwarves/dwarves-1.20.tar.xz https://fedorapeople.org/~acme/dwarves/dwarves-1.20.tar.bz2 https://fedorapeople.org/~acme/dwarves/dwarves-1.20.tar.signFYI:
Debian now ships dwarves package version 1.20-1 in unstable.Just a small nit to this release and its tagging:
You did:
commit0d415f68c468b77c5bf8e71965cd08c6efd25fc4("pahole: Prep 1.20")Is this new?
Quoted 8 lines
Quoted 2 lines
The release before:
commitdd15aa4b0a6421295cbb7c3913429142fef8abe0("dwarves: Prep v1.19")Its minor but intentional, pahole is by far the most well known tool in dwarves, so using that name more frequently (the git repo is pahole.git , for instance) may help more quickly associate with the tool needed for BTF encoding, data analysis, etc. And since its not about only DWARF, perhaps transitioning to using 'pahole' more widely is interesting.
Any plan to switch also the release tarball name?
We are planning to rename the Debian package once the Bullseye is released, currently it's dwarves-dfsg for legacy/unclear reasons.
Would it be a good idea to switch directly to pahole then?
Dom
Quoted 81 lines
- Arnaldo
Quoted 74 lines
- Sedat -
Quoted 72 lines
Best Regards,
- Arnaldo
v1.20:
BTF encoder:
- Improve ELF error reporting using elf_errmsg(elf_errno()).
- Improve objcopy error handling.
- Fix handling of 'restrict' qualifier, that was being treated as a 'const'.
- Support
SHN_XINDEXinst_shndxsymbol indexes, to handle ELF objects with more than 65534 sections, for instance, which happens with kernels built with 'KCFLAGS="-ffunction-sections -fdata-sections", Other cases may include when using FG-ASLR, LTO.- Cope with functions without a name, as seen sometimes when building kernel images with some versions of clang, when a SEGFAULT was taking place.
- Fix BTF variable generation for kernel modules, not skipping variables at offset zero.
- Fix address size to match what is in the ELF file being processed, to fix using a 64-bit pahole binary to generate BTF for a 32-bit vmlinux image.
- Use kernel module ftrace addresses when finding which functions to encode, which increases the number of functions encoded.
libbpf:
- Allow use of packaged version, for distros wanting to dynamically link with the system's libbpf package instead of using the libbpf git submodule shipped in pahole's source code.
DWARF loader:
- Support
DW_AT_data_bit_offsetThis appeared in DWARF4 but is supported only in gcc's -gdwarf-5, support it in a way that makes the output be the same for both cases.
$ gcc -gdwarf-5 -c
examples/dwarf5/bf.c
$ pahole bf.o
struct pea {
long int a:1; /* 0: 0 8 */
long int b:1; /* 0: 1 8 */
long int c:1; /* 0: 2 8 *//* XXX 29 bits hole, try to pack */ /* Bitfield combined with next fields */
int
after_bitfield; /* 4 4 *//* size: 8, cachelines: 1, members: 4 */
/* sum members: 4 */
/* sum bitfield members: 3 bits, bit holes: 1, sum bit holes: 29 bits */ /* last cacheline: 8 bytes */
};-
DW_FORM_implicit_constinattr_numeric()andattr_offset()- Support
DW_TAG_GNU_call_site, its the standardized rename of the previously supportedDW_TAG_GNU_call_site.build:
- Fix compilation on 32-bit architectures.
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>Signature · 1 line
- Arnaldo
Signature · 2 lines
rsa4096: 3B10 0CA1 8674 ACBA B4FE FCD2 CE5B CF17 9960 DE13 ed25519: FFB4 0CC3 7F2E 091D F7DA 356E CC79 2832 ED38 CB05
Em Wed, Feb 17, 2021 at 01:08:23PM +0100, Domenico Andreoli escreveu:
Quoted 45 lines · Arnaldo Carvalho de Melo
Quoted 35 lines
Em Mon, Feb 08, 2021 at 03:44:54AM +0100, Sedat Dilek escreveu:
Quoted 34 lines
Quoted 13 lines · Arnaldo Carvalho de Melo
Hi,
The v1.20 release of pahole and its friends is out, mostly
addressing problems related to gcc 11 defaulting to DWARF5 for -g, available at the usual places:Main git repo:
git://git.kernel.org/pub/scm/devel/pahole/pahole.gitMirror git repo:
Quoted 8 lines
https://github.com/acmel/dwarves.git
tarball + gpg signature:
https://fedorapeople.org/~acme/dwarves/dwarves-1.20.tar.xz https://fedorapeople.org/~acme/dwarves/dwarves-1.20.tar.bz2 https://fedorapeople.org/~acme/dwarves/dwarves-1.20.tar.signFYI:
Debian now ships dwarves package version 1.20-1 in unstable.Just a small nit to this release and its tagging:
You did:
commit0d415f68c468b77c5bf8e71965cd08c6efd25fc4("pahole: Prep 1.20")Is this new?
Quoted 8 lines
Quoted 2 lines
The release before:
commitdd15aa4b0a6421295cbb7c3913429142fef8abe0("dwarves: Prep v1.19")Its minor but intentional, pahole is by far the most well known tool in dwarves, so using that name more frequently (the git repo is pahole.git , for instance) may help more quickly associate with the tool needed for BTF encoding, data analysis, etc. And since its not about only DWARF, perhaps transitioning to using 'pahole' more widely is interesting.
Quoted 6 lines
Any plan to switch also the release tarball name?
We are planning to rename the Debian package once the Bullseye is released, currently it's dwarves-dfsg for legacy/unclear reasons.
Would it be a good idea to switch directly to pahole then?
Yeah, I think it is, I'll check what are the bureaucratic steps to do that rename on Fedora and RHEL, but then, no need for all distros to do it at once if that is something that requires long term planning or whatever.
- Arnaldo
Quoted 87 lines
Dom
Quoted 81 lines
- Arnaldo
Quoted 74 lines
- Sedat -
Quoted 72 lines
Best Regards,
- Arnaldo
v1.20:
BTF encoder:
- Improve ELF error reporting using elf_errmsg(elf_errno()).
- Improve objcopy error handling.
- Fix handling of 'restrict' qualifier, that was being treated as a 'const'.
- Support
SHN_XINDEXinst_shndxsymbol indexes, to handle ELF objects with more than 65534 sections, for instance, which happens with kernels built with 'KCFLAGS="-ffunction-sections -fdata-sections", Other cases may include when using FG-ASLR, LTO.- Cope with functions without a name, as seen sometimes when building kernel images with some versions of clang, when a SEGFAULT was taking place.
- Fix BTF variable generation for kernel modules, not skipping variables at offset zero.
- Fix address size to match what is in the ELF file being processed, to fix using a 64-bit pahole binary to generate BTF for a 32-bit vmlinux image.
- Use kernel module ftrace addresses when finding which functions to encode, which increases the number of functions encoded.
libbpf:
- Allow use of packaged version, for distros wanting to dynamically link with the system's libbpf package instead of using the libbpf git submodule shipped in pahole's source code.
DWARF loader:
- Support
DW_AT_data_bit_offsetThis appeared in DWARF4 but is supported only in gcc's -gdwarf-5, support it in a way that makes the output be the same for both cases.
$ gcc -gdwarf-5 -c
examples/dwarf5/bf.c
$ pahole bf.o
struct pea {
long int a:1; /* 0: 0 8 */
long int b:1; /* 0: 1 8 */
long int c:1; /* 0: 2 8 *//* XXX 29 bits hole, try to pack */ /* Bitfield combined with next fields */
int
after_bitfield; /* 4 4 *//* size: 8, cachelines: 1, members: 4 */
/* sum members: 4 */
/* sum bitfield members: 3 bits, bit holes: 1, sum bit holes: 29 bits */ /* last cacheline: 8 bytes */
};-
DW_FORM_implicit_constinattr_numeric()andattr_offset()- Support
DW_TAG_GNU_call_site, its the standardized rename of the previously supportedDW_TAG_GNU_call_site.build:
- Fix compilation on 32-bit architectures.
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>Signature · 1 line
- ArnaldoSignature · 2 lines
rsa4096: 3B10 0CA1 8674 ACBA B4FE FCD2 CE5B CF17 9960 DE13 ed25519: FFB4 0CC3 7F2E 091D F7DA 356E CC79 2832 ED38 CB05
Signature · 1 line
- Arnaldo