Skip to content

Commit 6b546dc

Browse files
committed
test/64bit_child: determine bitness at compile-time
The test binary for 64bit_child determines the bitness of the process by searching the memory map for either 'librrpage.so' or 'librrpage_32.so'. This commit makes the test independent of the SONAME of librrpage, instead relying on predefined architecture macros since these should reflect the eventual process image bitness.
1 parent 7228160 commit 6b546dc

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

src/test/64bit_child.c

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,16 @@
22

33
#include "util.h"
44

5-
void callback(uint64_t env, char *name, __attribute__((unused)) map_properties_t* props) {
6-
const char search[] = "librrpage.so";
7-
if (strlen(name) > strlen(search)) {
8-
if (sizeof(void*) == 4 &&
9-
strcmp(name + strlen(name) - strlen(search), search) == 0)
10-
{
11-
int* rr_is_32bit = (int*)(uintptr_t)env;
12-
*rr_is_32bit = 1;
13-
}
14-
}
15-
}
16-
175
static void skip_if_rr_32_bit_under_kernel_64_bit(void) {
18-
FILE* maps_file = fopen("/proc/self/maps", "r");
19-
int rr_is_32bit = 0;
20-
iterate_maps((uintptr_t)&rr_is_32bit, callback, maps_file);
6+
int rr_is_32bit;
7+
8+
#ifdef __i386__
9+
rr_is_32bit = 1;
10+
#elif defined(__x86_64__) || defined(__aarch64__)
11+
rr_is_32bit = 0;
12+
#else
13+
# error "With what bitness are we compiling?"
14+
#endif
2115

2216
struct utsname buf;
2317
if (uname(&buf) != 0)

0 commit comments

Comments
 (0)