tests: Add -mno-relax to link flags for server test 54/291354/2
authorŁukasz Stelmach <l.stelmach@samsung.com>
Fri, 7 Apr 2023 10:49:25 +0000 (12:49 +0200)
committerŁukasz Stelmach <l.stelmach@samsung.com>
Thu, 13 Apr 2023 19:30:59 +0000 (21:30 +0200)
The flag is required to prevent the test binary from using the gp register
on RISC-V to access global variables. RISC-V ABI assumes the value of the register
is assigned once at sartup (see load_gp() in sysdeps/riscv/start.S in
glibc sources). During tests this code is called for the second time when
app2sd-server-test uses dlopen() to load app2sd-server. Therefore with
relaxed linking enabled for both binaries, the value set at the start
of app2sd-server-test gets overwriten and the test process crashes in
semi-random places.

Change-Id: I6c5d550340c222bb53f8affd0d0c188cc5311765
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
packaging/app2sd.spec
unit-tests/CMakeLists.txt

index 8d23bed..d6bf656 100644 (file)
@@ -60,7 +60,7 @@ cp %{SOURCE3} .
 
 %build
 MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
-%cmake . -DUNITDIR=%{_unitdir} -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
+%cmake . -DUNITDIR=%{_unitdir} -DFULLVER=%{version} -DMAJORVER=${MAJORVER} -DARCH=%{_arch}
 
 make %{?jobs:-j%jobs}
 
index e134f28..7ae2bc8 100644 (file)
@@ -11,6 +11,10 @@ SET(TARGET_SERVER_TEST "app2sd-server-test")
 ADD_EXECUTABLE(${TARGET_LIB_TEST} ${TEST_LIB_SRCS})
 ADD_EXECUTABLE(${TARGET_SERVER_TEST} ${TEST_SERVER_SRCS})
 
+IF("${ARCH}" STREQUAL "riscv64")
+  TARGET_LINK_OPTIONS(${TARGET_SERVER_TEST} PUBLIC -mno-relax)
+ENDIF()
+
 APPLY_PKG_CONFIG(${TARGET_LIB_TEST} PUBLIC
   app2ext_libpkgs
   GMOCK_DEPS