From 2f391d26a29ed7be975f29edba3a9349e8a84b77 Mon Sep 17 00:00:00 2001 From: Zhao Hang Date: Tue, 5 Dec 2023 14:20:56 +0800 Subject: [PATCH 1/2] update to dwarves-1.25-1.src.rpm Signed-off-by: Zhao Hang --- ...tialize-struct-cu-in-cu__new-to-prev.patch | 93 ------------------- dist | 1 + download | 2 +- dwarves.spec | 29 +++--- 4 files changed, 20 insertions(+), 105 deletions(-) delete mode 100644 0001-dwarves-Zero-initialize-struct-cu-in-cu__new-to-prev.patch create mode 100644 dist diff --git a/0001-dwarves-Zero-initialize-struct-cu-in-cu__new-to-prev.patch b/0001-dwarves-Zero-initialize-struct-cu-in-cu__new-to-prev.patch deleted file mode 100644 index 5d90d12..0000000 --- a/0001-dwarves-Zero-initialize-struct-cu-in-cu__new-to-prev.patch +++ /dev/null @@ -1,93 +0,0 @@ -From b72f5188856df0abf45e1a707856bb4e4e86153c Mon Sep 17 00:00:00 2001 -From: Alan Maguire -Date: Fri, 21 Oct 2022 16:02:03 +0100 -Subject: [PATCH] dwarves: Zero-initialize struct cu in cu__new() to prevent - incorrect BTF types - -BTF deduplication was throwing some strange results, where core kernel -data types were failing to deduplicate due to the return values -of function type members being void (0) instead of the actual type -(unsigned int). An example of this can be seen below, where -"struct dst_ops" was failing to deduplicate between kernel and -module: - -struct dst_ops { - short unsigned int family; - unsigned int gc_thresh; - int (*gc)(struct dst_ops *); - struct dst_entry * (*check)(struct dst_entry *, __u32); - unsigned int (*default_advmss)(const struct dst_entry *); - unsigned int (*mtu)(const struct dst_entry *); -... - -struct dst_ops___2 { - short unsigned int family; - unsigned int gc_thresh; - int (*gc)(struct dst_ops___2 *); - struct dst_entry___2 * (*check)(struct dst_entry___2 *, __u32); - void (*default_advmss)(const struct dst_entry___2 *); - void (*mtu)(const struct dst_entry___2 *); -... - -This was seen with - -bcc648a10cbc ("btf_encoder: Encode DW_TAG_unspecified_type returning routines as void") - -...which rewrites the return value as 0 (void) when it is marked -as matching DW_TAG_unspecified_type: - -static int32_t btf_encoder__tag_type(struct btf_encoder *encoder, uint32_t type_id_off, uint32_t tag_type) -{ - if (tag_type == 0) - return 0; - - if (encoder->cu->unspecified_type.tag && tag_type == encoder->cu->unspecified_type.type) { - // No provision for encoding this, turn it into void. - return 0; - } - - return type_id_off + tag_type; -} - -However the odd thing was that on further examination, the unspecified type -was not being set, so why was this logic being tripped? Futher debugging -showed that the encoder->cu->unspecified_type.tag value was garbage, and -the type id happened to collide with "unsigned int"; as a result we -were replacing unsigned ints with void return values, and since this -was being done to function type members in structs, it triggered a -type mismatch which failed deduplication between kernel and module. - -The fix is simply to calloc() the cu in cu__new() instead. - -Committer notes: - -We have zalloc(size) as an alias to calloc(1, size), use it instead. - -Fixes: bcc648a10cbcd0b9 ("btf_encoder: Encode DW_TAG_unspecified_type returning routines as void") -Signed-off-by: Alan Maguire -Acked-by: Andrii Nakryiko -Acked-by: Jiri Olsa -Cc: bpf@vger.kernel.org -Cc: dwarves@vger.kernel.org -Link: https://lore.kernel.org/r/1666364523-9648-1-git-send-email-alan.maguire@oracle.com -Signed-off-by: Arnaldo Carvalho de Melo ---- - dwarves.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/dwarves.c b/dwarves.c -index fbebc1d..95a3bac 100644 ---- a/dwarves.c -+++ b/dwarves.c -@@ -626,7 +626,7 @@ struct cu *cu__new(const char *name, uint8_t addr_size, - const unsigned char *build_id, int build_id_len, - const char *filename, bool use_obstack) - { -- struct cu *cu = malloc(sizeof(*cu) + build_id_len); -+ struct cu *cu = zalloc(sizeof(*cu) + build_id_len); - - if (cu != NULL) { - uint32_t void_id; --- -2.38.1 - diff --git a/dist b/dist new file mode 100644 index 0000000..89c1faf --- /dev/null +++ b/dist @@ -0,0 +1 @@ +an9 diff --git a/download b/download index 021fb96..7beeb19 100644 --- a/download +++ b/download @@ -1 +1 @@ -c2a2e771a50df28911310a071e410581 dwarves-1.24.tar.xz +0ebeb58a81f6e9cb491fd7305910f42d dwarves-1.25.tar.xz diff --git a/dwarves.spec b/dwarves.spec index b14bf84..994d10d 100644 --- a/dwarves.spec +++ b/dwarves.spec @@ -1,21 +1,19 @@ -%define anolis_release .0.1 %define libname libdwarves %define libver 1 Name: dwarves -Version: 1.24 -Release: 2%{anolis_release}%{?dist} +Version: 1.25 +Release: 1%{?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} -Patch1: 0001-dwarves-Zero-initialize-struct-cu-in-cu__new-to-prev.patch BuildRequires: gcc BuildRequires: cmake >= 2.8.12 BuildRequires: zlib-devel BuildRequires: elfutils-devel >= 0.130 -BuildRequires: python3 +BuildRequires: libbpf-devel %description dwarves is a set of tools that use the debugging information inserted in @@ -68,10 +66,9 @@ Debugging information processing library development files. %prep %setup -q -%patch1 -p1 %build -%cmake -DCMAKE_BUILD_TYPE=Release . +%cmake -DCMAKE_BUILD_TYPE=Release -DLIBBPF_EMBEDDED=Off . %cmake_build %install @@ -83,8 +80,7 @@ rm -Rf %{buildroot} %files %doc README.ctracer %doc README.btf -%doc changes-v1.23 -%doc changes-v1.24 +%doc changes-v1.25 %doc NEWS %{_bindir}/btfdiff %{_bindir}/codiff @@ -136,8 +132,19 @@ rm -Rf %{buildroot} %{_libdir}/%{libname}_reorganize.so %changelog -* Fri Dec 23 2022 Chang Gao - 1.24-2.0.1 -- Add Buildrequires python3 +* Wed Jun 14 2023 Viktor Malik - 1.25-1 +- Resolves: rhbz#2190484 +- Build with system libbpf +- New release: v1.25 +- Support for DW_TAG_unspecified_type more generally. +- Make sure struct member offsets are in ascending order. Rust BTF needs this. +- Support C atomic types (DW_TAG_atomic_type). +- Initial support for DW_TAG_LLVM_annotation, used for BTF type tags, for __rcu, __user, etc +- Exclude functions with the same name (static functions in different CUs), inconsistent prototypes or not following calling convention. +- Allow generation of BTF for optimized functions, those that end with a .isra*, .constprop*. +- Support 'pahole --lang=/--lang_exclude=asm' +- Support --compile from DWARF in addition to from BTF. +- Exclude RUST CUs in 'btfdiff', as those are not yet being BTF encoded. * Wed Nov 16 2022 Viktor Malik - 1.24-2 - Backport BTF fix needed for kernel kfuncs -- Gitee From 351c61bff6ec63a7202ace9f11540fb7e91d84d4 Mon Sep 17 00:00:00 2001 From: "taifu.gc" Date: Fri, 23 Dec 2022 19:20:26 +0800 Subject: [PATCH 2/2] Add buildrequires --- dwarves.spec | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dwarves.spec b/dwarves.spec index 994d10d..d432cea 100644 --- a/dwarves.spec +++ b/dwarves.spec @@ -1,9 +1,10 @@ +%define anolis_release .0.1 %define libname libdwarves %define libver 1 Name: dwarves Version: 1.25 -Release: 1%{?dist} +Release: 1%{anolis_release}%{?dist} License: GPLv2 Summary: Debugging Information Manipulation Tools (pahole & friends) URL: http://acmel.wordpress.com @@ -14,6 +15,7 @@ BuildRequires: cmake >= 2.8.12 BuildRequires: zlib-devel BuildRequires: elfutils-devel >= 0.130 BuildRequires: libbpf-devel +BuildRequires: python3 %description dwarves is a set of tools that use the debugging information inserted in @@ -132,6 +134,9 @@ rm -Rf %{buildroot} %{_libdir}/%{libname}_reorganize.so %changelog +* Wed Dec 06 2023 Chang Gao - 1.25-1.0.1 +- Add Buildrequires python3 + * Wed Jun 14 2023 Viktor Malik - 1.25-1 - Resolves: rhbz#2190484 - Build with system libbpf -- Gitee