Skip to content

Commit 37483ce

Browse files
committed
Solve issues linux release.
1 parent 6101978 commit 37483ce

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

CMakeLists.txt

+30
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,36 @@ project(MetaCallPoC VERSION 1.0)
44
set(CMAKE_C_STANDARD 99)
55
set(CMAKE_CXX_STANDARD 11)
66
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
7+
set(CMAKE_VERBOSE_MAKEFILE ON)
8+
9+
# TODO: -O3 generates a segmentation fault on Linux
10+
#
11+
# METACALL load from normal executable
12+
# should_not_call_init constructor has been called and it should not
13+
# NORMAL EXECUTABLE enum symbols node_loader (1): fflush -> 0x4864018
14+
# ...
15+
# NORMAL EXECUTABLE enum symbols node_loader (11): __cxa_finalize -> 0x4863ff8
16+
# INSIDE NODE LOADER (before string_function call): (nil)
17+
# ==12635== Jump to the invalid address stated on the next line
18+
# ==12635== at 0x0: ???
19+
# ==12635== by 0x4861188: node_loader (in /metacall-plthook-poc/build/libnode_loader.so)
20+
# ==12635== by 0x4856638: load_normal_executable (in /metacall-plthook-poc/build/libmetacall.so)
21+
# ==12635== by 0x4896564: (below main) (libc-start.c:332)
22+
# ==12635== Address 0x0 is not stack'd, malloc'd or (recently) free'd
23+
# ==12635==
24+
# ==12635== Process terminating with default action of signal 11 (SIGSEGV)
25+
# ==12635== Bad permissions for mapped region at address 0x0
26+
# ==12635== at 0x0: ???
27+
# ==12635== by 0x4861188: node_loader (in /metacall-plthook-poc/build/libnode_loader.so)
28+
# ==12635== by 0x4856638: load_normal_executable (in /metacall-plthook-poc/build/libmetacall.so)
29+
# ==12635== by 0x4896564: (below main) (libc-start.c:332)
30+
string(REGEX MATCH "Linux" PROJECT_OS_LINUX ${CMAKE_SYSTEM_NAME})
31+
32+
if(PROJECT_OS_LINUX)
33+
# Use -O2 by now until we can find why string_function is NULL
34+
set(CMAKE_C_FLAGS_RELEASE "-O2")
35+
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
36+
endif()
737

838
# Default build type
939
if(NOT CMAKE_BUILD_TYPE)

source/node_loader.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
#include "libnode2.h"
55

66
char *node_loader() {
7+
printf("INSIDE NODE LOADER (before string_function call): %p\n", string_function);
8+
fflush(stdout);
79
char *str = string_function();
8-
printf("INSIDE NODE LOADER: %s\n", str);
10+
printf("INSIDE NODE LOADER (after): %s\n", str);
11+
fflush(stdout);
912
return str;
1013
}

0 commit comments

Comments
 (0)