Skip to content

Commit ca2bc36

Browse files
committed
Add elfutils patch to wheels
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
1 parent 55d2f73 commit ca2bc36

3 files changed

Lines changed: 69 additions & 0 deletions

File tree

‎MANIFEST.in‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ include README.md
1414
include src/pystack/py.typed
1515
include .bumpversion.cfg
1616
include .pre-commit-config.yaml
17+
include build_scripts/elfutils_contiguous_segtments.diff
1718

1819
recursive-include src/pystack/_pystack *
1920
recursive-include src/pystack *.py
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c
2+
index 3ef62a7d..09ee37b3 100644
3+
--- a/libdwfl/dwfl_segment_report_module.c
4+
+++ b/libdwfl/dwfl_segment_report_module.c
5+
@@ -737,17 +737,34 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name,
6+
&& invalid_elf (module->elf, module->disk_file_has_build_id,
7+
&build_id))
8+
{
9+
- elf_end (module->elf);
10+
- close (module->fd);
11+
- module->elf = NULL;
12+
- module->fd = -1;
13+
+ /* If MODULE's build-id doesn't match the disk file's
14+
+ build-id, close ELF only if MODULE and ELF refer to
15+
+ different builds of files with the same name. This
16+
+ prevents premature closure of the correct ELF in cases
17+
+ where segments of a module are non-contiguous in memory. */
18+
+ if (name != NULL && module->name[0] != '\0'
19+
+ && strcmp (basename (module->name), basename (name)) == 0)
20+
+ {
21+
+ elf_end (module->elf);
22+
+ close (module->fd);
23+
+ module->elf = NULL;
24+
+ module->fd = -1;
25+
+ }
26+
}
27+
- if (module->elf != NULL)
28+
+ else if (module->elf != NULL)
29+
{
30+
- /* Ignore this found module if it would conflict in address
31+
- space with any already existing module of DWFL. */
32+
+ /* This module has already been reported. */
33+
skip_this_module = true;
34+
}
35+
+ else
36+
+ {
37+
+ /* Only report this module if we haven't already done so. */
38+
+ for (Dwfl_Module *mod = dwfl->modulelist; mod != NULL;
39+
+ mod = mod->next)
40+
+ if (mod->low_addr == module_start
41+
+ && mod->high_addr == module_end)
42+
+ skip_this_module = true;
43+
+ }
44+
}
45+
if (skip_this_module)
46+
goto out;
47+
@@ -781,10 +798,6 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name,
48+
}
49+
}
50+
51+
- /* Our return value now says to skip the segments contained
52+
- within the module. */
53+
- ndx = addr_segndx (dwfl, segment, module_end, true);
54+
-
55+
/* Examine its .dynamic section to get more interesting details.
56+
If it has DT_SONAME, we'll use that as the module name.
57+
If it has a DT_DEBUG, then it's actually a PIE rather than a DSO.
58+
@@ -929,6 +942,8 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name,
59+
ndx = -1;
60+
goto out;
61+
}
62+
+ else
63+
+ ndx++;
64+
65+
/* We have reported the module. Now let the caller decide whether we
66+
should read the whole thing in right now. */

‎pyproject.toml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ before-all = [
5656
"curl https://sourceware.org/elfutils/ftp/$VERS/elfutils-$VERS.tar.bz2 > ./elfutils.tar.bz2",
5757
"tar -xf elfutils.tar.bz2",
5858
"cd elfutils-$VERS",
59+
"patch libdwfl/dwfl_segment_report_module.c < {package}/build_scripts/elfutils_contiguous_segtments.diff",
5960
"CFLAGS='-w' ./configure --enable-libdebuginfod=dummy --disable-debuginfod --prefix=/usr --libdir=/usr/lib64",
6061
"make install"
6162
]
@@ -93,6 +94,7 @@ before-all = [
9394
"curl https://sourceware.org/elfutils/ftp/$VERS/elfutils-$VERS.tar.bz2 > ./elfutils.tar.bz2",
9495
"tar -xf elfutils.tar.bz2",
9596
"cd elfutils-$VERS",
97+
"patch libdwfl/dwfl_segment_report_module.c < {package}/build_scripts/elfutils_contiguous_segtments.diff",
9698
"CFLAGS='-w -DFNM_EXTMATCH=0' ./configure --prefix=/usr --disable-nls --disable-libdebuginfod --disable-debuginfod --with-zstd",
9799
"make install"
98100
]

0 commit comments

Comments
 (0)