Initial commit
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
# Ignore BPM archives and signatures
|
||||||
|
*.bpm
|
||||||
|
*.bpm.sig
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Git repository
|
||||||
|
REPO="https://git.kernel.org/pub/scm/devel/pahole/pahole.git"
|
||||||
|
|
||||||
|
# Get tag name using 'git ls-remote'
|
||||||
|
TAG_NAME=$(git ls-remote --exit-code --refs --tags --sort='v:refname' "$REPO" | tail -1 | cut -d'/' -f3)
|
||||||
|
|
||||||
|
# Trim prefix
|
||||||
|
VERSION=${TAG_NAME//v/}
|
||||||
|
|
||||||
|
echo "$VERSION"
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
name: pahole
|
||||||
|
description: Type info tools
|
||||||
|
version: "1.31"
|
||||||
|
revision: 1
|
||||||
|
url: https://git.kernel.org/pub/scm/devel/pahole/pahole.git
|
||||||
|
license: GPL-2.0-only
|
||||||
|
maintainers:
|
||||||
|
- [email protected]
|
||||||
|
architecture: any
|
||||||
|
type: source
|
||||||
|
depends:
|
||||||
|
- bash
|
||||||
|
- glibc
|
||||||
|
- libelf
|
||||||
|
- zlib
|
||||||
|
make_depends:
|
||||||
|
- cmake
|
||||||
|
downloads:
|
||||||
|
- url: https://git.kernel.org/pub/scm/devel/pahole/pahole.git/snapshot/pahole-${BPM_PKG_VERSION}.tar.gz
|
||||||
|
extract_to: ${BPM_SOURCE}
|
||||||
|
extract_strip_components: 1
|
||||||
|
checksum: a0b9d79bdb8d3028a87afd402a61d0ff5b05c982b15f6bab1be08ca1662cd0e9
|
||||||
|
- url: https://github.com/libbpf/libbpf/archive/refs/tags/v1.7.0.tar.gz
|
||||||
|
extract_to: ${BPM_SOURCE}/lib/bpf
|
||||||
|
extract_strip_components: 1
|
||||||
|
checksum: 7ab5feffbf78557f626f2e3e3204788528394494715a30fc2070fcddc2051b7b
|
||||||
@@ -0,0 +1,144 @@
|
|||||||
|
From ba31cfa08ffcfe6ff5757f325de5b03ca157cb78 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Damien Hourtoulle <[email protected]>
|
||||||
|
Date: Wed, 11 Mar 2026 15:09:39 +0100
|
||||||
|
Subject: pahole: Fix discarded-qualifiers for strchr/strstr.
|
||||||
|
|
||||||
|
Glibc 2.43 added C23 const-preserving overloads :
|
||||||
|
https://sourceware.org/glibc/wiki/Release/2.43.
|
||||||
|
|
||||||
|
For the function prototype__new, fix local variable declaration to use
|
||||||
|
the correct const char* type instead of char*, removing the need to
|
||||||
|
discard the const qualifier.
|
||||||
|
|
||||||
|
Also fix a pre-existing bug in type__find_type_enum: when iterating
|
||||||
|
over a '+'-concatenated list of enum names, after advancing to the next
|
||||||
|
segment the new separator was not nullified, causing "second+third" to
|
||||||
|
be passed to cu__find_enumeration_by_name instead of "second". Add a
|
||||||
|
null check before writing to sep_mutable to avoid a null dereference
|
||||||
|
when no further '+' is present.
|
||||||
|
|
||||||
|
Signed-off-by: Damien Hourtoulle <[email protected]>
|
||||||
|
Signed-off-by: Alan Maguire <[email protected]>
|
||||||
|
Link: https://lore.kernel.org/dwarves/[email protected]/
|
||||||
|
---
|
||||||
|
btf_encoder.c | 2 +-
|
||||||
|
pahole.c | 35 ++++++++++++++++++-----------------
|
||||||
|
2 files changed, 19 insertions(+), 18 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/btf_encoder.c b/btf_encoder.c
|
||||||
|
index aa7cd1c..d36984a 100644
|
||||||
|
--- a/btf_encoder.c
|
||||||
|
+++ b/btf_encoder.c
|
||||||
|
@@ -1218,7 +1218,7 @@ static bool str_contains_non_fn_suffix(const char *str) {
|
||||||
|
".cold",
|
||||||
|
".part"
|
||||||
|
};
|
||||||
|
- char *suffix = strchr(str, '.');
|
||||||
|
+ const char *suffix = strchr(str, '.');
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (!suffix)
|
||||||
|
diff --git a/pahole.c b/pahole.c
|
||||||
|
index 02a0d19..e4bfb69 100644
|
||||||
|
--- a/pahole.c
|
||||||
|
+++ b/pahole.c
|
||||||
|
@@ -2483,7 +2483,7 @@ static int64_t type_instance__int_value(struct type_instance *instance, const ch
|
||||||
|
int byte_offset = 0;
|
||||||
|
|
||||||
|
if (!member) {
|
||||||
|
- char *sep = strchr(member_name_orig, '.');
|
||||||
|
+ const char *sep = strchr(member_name_orig, '.');
|
||||||
|
|
||||||
|
if (!sep)
|
||||||
|
return -1;
|
||||||
|
@@ -2496,8 +2496,8 @@ static int64_t type_instance__int_value(struct type_instance *instance, const ch
|
||||||
|
char *member_name = member_name_alloc;
|
||||||
|
struct type *type = instance->type;
|
||||||
|
|
||||||
|
- sep = member_name_alloc + (sep - member_name_orig);
|
||||||
|
- *sep = 0;
|
||||||
|
+ char *sep_mutable = member_name_alloc + (sep - member_name_orig); // sep mutable for the copy
|
||||||
|
+ *sep_mutable = 0;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
member = type__find_member_by_name(type, member_name);
|
||||||
|
@@ -2510,9 +2510,9 @@ out_free_member_name:
|
||||||
|
type = tag__type(cu__type(cu, member->tag.type));
|
||||||
|
if (type == NULL)
|
||||||
|
goto out_free_member_name;
|
||||||
|
- member_name = sep + 1;
|
||||||
|
- sep = strchr(member_name, '.');
|
||||||
|
- if (!sep)
|
||||||
|
+ member_name = sep_mutable + 1;
|
||||||
|
+ sep_mutable = strchr(member_name, '.');
|
||||||
|
+ if (!sep_mutable)
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
@@ -2950,7 +2950,7 @@ static struct prototype *prototype__new(const char *expression)
|
||||||
|
|
||||||
|
strcpy(prototype->name, expression);
|
||||||
|
|
||||||
|
- const char *name = prototype->name;
|
||||||
|
+ char *name = prototype->name;
|
||||||
|
|
||||||
|
prototype->nr_args = 0;
|
||||||
|
|
||||||
|
@@ -2964,10 +2964,9 @@ static struct prototype *prototype__new(const char *expression)
|
||||||
|
if (args_close == NULL)
|
||||||
|
goto out_no_closing_parens;
|
||||||
|
|
||||||
|
+ *args_open++ = *args_close = '\0';
|
||||||
|
char *args = args_open;
|
||||||
|
|
||||||
|
- *args++ = *args_close = '\0';
|
||||||
|
-
|
||||||
|
while (isspace(*args))
|
||||||
|
++args;
|
||||||
|
|
||||||
|
@@ -3114,7 +3113,7 @@ static int type__find_type_enum(struct type *type, struct cu *cu, const char *ty
|
||||||
|
return type__add_type_enum(type, te, cu);
|
||||||
|
|
||||||
|
// Now look at a 'virtual enum', i.e. the concatenation of multiple enums
|
||||||
|
- char *sep = strchr(type_enum, '+');
|
||||||
|
+ const char *sep = strchr(type_enum, '+');
|
||||||
|
|
||||||
|
if (!sep)
|
||||||
|
return -1;
|
||||||
|
@@ -3126,13 +3125,13 @@ static int type__find_type_enum(struct type *type, struct cu *cu, const char *ty
|
||||||
|
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
|
- sep = type_enums + (sep - type_enum);
|
||||||
|
+ char *sep_mutable = type_enums + (sep - type_enum);
|
||||||
|
+ char *cur = type_enums;
|
||||||
|
|
||||||
|
- type_enum = type_enums;
|
||||||
|
- *sep = '\0';
|
||||||
|
+ *sep_mutable = '\0';
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
- te = cu__find_enumeration_by_name(cu, type_enum, NULL);
|
||||||
|
+ te = cu__find_enumeration_by_name(cu, cur, NULL);
|
||||||
|
|
||||||
|
if (!te)
|
||||||
|
goto out;
|
||||||
|
@@ -3141,10 +3140,12 @@ static int type__find_type_enum(struct type *type, struct cu *cu, const char *ty
|
||||||
|
if (ret)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
- if (sep == NULL)
|
||||||
|
+ if (sep_mutable == NULL)
|
||||||
|
break;
|
||||||
|
- type_enum = sep + 1;
|
||||||
|
- sep = strchr(type_enum, '+');
|
||||||
|
+ cur = sep_mutable + 1;
|
||||||
|
+ sep_mutable = strchr(cur, '+');
|
||||||
|
+ if (sep_mutable)
|
||||||
|
+ *sep_mutable = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
--
|
||||||
|
cgit 1.3-korg
|
||||||
|
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
# This is the source.sh script. It is executed by BPM in a temporary directory when compiling a source package
|
||||||
|
# BPM Expects the source code to be extracted into the automatically created 'source' directory which can be accessed using $BPM_SOURCE
|
||||||
|
# BPM Expects the output files to be present in the automatically created 'output' directory which can be accessed using $BPM_OUTPUT
|
||||||
|
|
||||||
|
# The prepare function is executed in the root of the temp directory
|
||||||
|
# This function is used for putting downloaded files to the correct location or applying patches
|
||||||
|
prepare() {
|
||||||
|
cd "$BPM_SOURCE"
|
||||||
|
patch -Np1 -i "$BPM_WORKDIR"/fix-discarded-qualifiers.patch
|
||||||
|
}
|
||||||
|
|
||||||
|
# The build function is executed in the source directory
|
||||||
|
# This function is used to compile the source code
|
||||||
|
build() {
|
||||||
|
cmake -B build -DCMAKE_INSTALL_PREFIX=/usr -DLIBBPF_EMBEDDED=ON
|
||||||
|
cmake --build build
|
||||||
|
}
|
||||||
|
|
||||||
|
# The check function is executed in the source directory
|
||||||
|
# This function is used to run tests to verify the package has been compiled correctly
|
||||||
|
check() {
|
||||||
|
ctest --test-dir build
|
||||||
|
}
|
||||||
|
|
||||||
|
# The package function is executed in the source directory
|
||||||
|
# This function is used to move the compiled files into the output directory
|
||||||
|
package() {
|
||||||
|
DESTDIR="$BPM_OUTPUT" cmake --install build
|
||||||
|
|
||||||
|
# Install package license
|
||||||
|
install -Dm644 "$BPM_SOURCE"/COPYING "$BPM_OUTPUT"/usr/share/licenses/pahole/COPYING
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user