File: fix-file-cache-test-for-32bit.diff

package info (click to toggle)
libkdumpfile 0.5.4-3
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 3,800 kB
  • sloc: ansic: 34,639; sh: 3,853; python: 1,490; makefile: 755
file content (66 lines) | stat: -rw-r--r-- 2,165 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
Description: Fix file cache test for 32-bit architectures
 If 64-bit file offsets are selected with _FILE_OFFSET_BITS on a 32-bit
 architecture, the default mmap() call takes a 64-bit off_t, but dlsym()
 returns a pointer to a function that takes a 32-bit off_t.
 .
 To fix it:
 .
 - always call original mmap64() if it is available,
 - use XSTRINGIFY(mmap) instead of "mmap".
 .
 The latter is needed, because some systems define mmap as a macro which
 expands to another identifier.
Author: Petr Tesarik <petr@tesarici.cz>
Origin: https://github.com/ptesarik/libkdumpfile/commit/16c73b83a78c1bfb55f3e9823b09fce549c8ec11
Bug: https://github.com/ptesarik/libkdumpfile/issues/80
Applied-Upstream: https://github.com/ptesarik/libkdumpfile/commit/16c73b83a78c1bfb55f3e9823b09fce549c8ec11 
Last-Update: 2024-05-28
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
diff --git a/configure.ac b/configure.ac
index 04d1c6fa..93ebb39d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -61,6 +61,8 @@ AC_CHECK_SIZEOF(long)
 AC_CHECK_SIZEOF(off_t)
 AC_SUBST(SIZEOF_OFF_T, $ac_cv_sizeof_off_t)
 
+AC_CHECK_FUNCS(mmap64)
+
 dnl This makes sure pkg.m4 is available.
 m4_pattern_forbid([^_?PKG_[A-Z_]+$],[*** pkg.m4 missing, please install pkg-config])
 
diff --git a/src/kdumpfile/test-fcache.c b/src/kdumpfile/test-fcache.c
index 1ed57447..604ed540 100644
--- a/src/kdumpfile/test-fcache.c
+++ b/src/kdumpfile/test-fcache.c
@@ -64,9 +64,20 @@ static char *mmapbuf;
 
 static int failmmap;
 
+#ifdef HAVE_MMAP64
+
+#define STR_MMAP	XSTRINGIFY(mmap64)
+static void* (*orig_mmap)(void *addr, size_t length, int prot, int flags,
+			  int fd, off64_t offset);
+
+#else
+
+#define STR_MMAP	XSTRINGIFY(mmap)
 static void* (*orig_mmap)(void *addr, size_t length, int prot, int flags,
 			  int fd, off_t offset);
 
+#endif
+
 void *
 mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset)
 {
@@ -445,7 +456,7 @@ main(int argc, char **argv)
 		return TEST_ERR;
 	}
 
-	orig_mmap = dlsym(RTLD_NEXT, "mmap");
+	orig_mmap = dlsym(RTLD_NEXT, STR_MMAP);
 	if (!orig_mmap) {
 		fprintf(stderr, "Cannot get original mmap() address: %s\n",
 			dlerror());