2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-25 03:18:36 +00:00
criu/scripts/feature-tests.mak
Dmitry Safonov 585dda236c ia32: Get rid of R_X86_64_32S relocation
Distributions starts to supply GCC that is configured to compile
-pie and -fPIC code by default due to security reasons.

CONFIG_COMPAT was unfriendy to -pie by the reason of R_X86_64_32S
relocation in call32.S helper:
  LINK     criu/criu
/usr/bin/ld: criu/arch/x86/crtools.built-in.o: relocation R_X86_64_32S against `.text' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
make[1]: *** [criu/Makefile:92: criu/criu] Error 1
make: *** [Makefile:225: criu] Error 2

Use %rip-relative addressing to avoid ld errors for shared binary linking.
Puff, all needs to be done with bare hands!

Now CONFIG_COMPAT can be used with -pie binaries and all should
also work for debian toolchain (#315).

Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-23 20:23:23 +03:00

139 lines
2.2 KiB
Makefile

define FEATURE_TEST_TCP_REPAIR
#include <netinet/tcp.h>
int main(void)
{
struct tcp_repair_opt opts;
opts.opt_code = TCP_NO_QUEUE;
opts.opt_val = 0;
return opts.opt_val;
}
endef
define FEATURE_TEST_TCP_REPAIR_WINDOW
#include <netinet/tcp.h>
int main(void)
{
struct tcp_repair_window opts;
opts.snd_wl1 = 0;
return opts.snd_wl1;
}
endef
define FEATURE_TEST_LIBBSD_DEV
#include <bsd/string.h>
int main(void)
{
return 0;
}
endef
define FEATURE_TEST_STRLCPY
#include <string.h>
#ifdef CONFIG_HAS_LIBBSD
# include <bsd/string.h>
#endif
int main(void)
{
return strlcpy(NULL, NULL, 0);
}
endef
define FEATURE_TEST_STRLCAT
#include <string.h>
#ifdef CONFIG_HAS_LIBBSD
# include <bsd/string.h>
#endif
int main(void)
{
return strlcat(NULL, NULL, 0);
}
endef
define FEATURE_TEST_PTRACE_PEEKSIGINFO
#include <sys/ptrace.h>
int main(void)
{
struct ptrace_peeksiginfo_args args = {};
return 0;
}
endef
define FEATURE_TEST_SETPROCTITLE_INIT
#include <bsd/unistd.h>
int main(int argc, char *argv[], char *envp[])
{
setproctitle_init(argc, argv, envp);
return 0;
}
endef
define FEATURE_TEST_X86_COMPAT
#define __ALIGN .align 4, 0x90
#define ENTRY(name) \
.globl name; \
.type name, @function; \
__ALIGN; \
name:
#define END(sym) \
.size sym, . - sym
#define __USER32_CS 0x23
#define __USER_CS 0x33
.text
ENTRY(call32_from_64)
/* Push return address and 64-bit segment descriptor */
sub \$$4, %rsp
movl \$$__USER_CS,(%rsp)
sub \$$4, %rsp
/* Using rip-relative addressing to get rid of R_X86_64_32S relocs */
leaq 2f(%rip),%r12
movl %r12d,(%rsp)
/* Switch into compatibility mode */
pushq \$$__USER32_CS
/* Using rip-relative addressing to get rid of R_X86_64_32S relocs */
leaq 1f(%rip), %r12
pushq %r12
lretq
1: .code32
/* Run function and switch back */
call *%esi
lret
2: .code64
/* Restore the stack */
mov (%rsp),%rsp
add \$$8, %rdi
END(call32_from_64)
ENTRY(main)
nop
END(main)
endef