Browse Source

[GLIBC] Move syscalldb implementation to a separate patch

Chia-Che Tsai 5 years ago
parent
commit
05a65c6188
2 changed files with 110 additions and 9 deletions
  1. 2 9
      LibOS/Makefile
  2. 108 0
      LibOS/glibc-syscalldb-api.patch

+ 2 - 9
LibOS/Makefile

@@ -41,15 +41,7 @@ ifeq ($(findstring x86_64,$(SYS))$(findstring linux,$(SYS)),x86_64linux)
 
 .SECONDARY: $(BUILD_DIR)/Build.success
 
-GLIBC_ADDED_FILES = \
-        $(GLIBC_SRC)/syscallas.S \
-        $(GLIBC_SRC)/syscalldb.c \
-        $(GLIBC_SRC)/syscalldb.h \
-        $(GLIBC_SRC)/elf/syscalldb.c \
-        $(GLIBC_SRC)/elf/syscallas.S \
-        $(GLIBC_SRC)/sysdeps/unix/sysv/linux/x86_64/syscalldb.h
-
-$(BUILD_DIR)/Build.success: $(BUILD_DIR)/Makefile $(GLIBC_ADDED_FILES)
+$(BUILD_DIR)/Build.success: $(BUILD_DIR)/Makefile
 	@echo "Building glibc, may take a while to finish. Warning messages may show up. If this process terminates with failures, see \"$(BUILD_DIR)/build.log\" for more information."
 	($(MAKE) -C $(BUILD_DIR) 2>&1 >> build.log) && touch $@
 #  2>&1 | tee -a build.log)
@@ -77,6 +69,7 @@ GLIBC_MIRRORS ?= https://ftp.gnu.org/gnu/ \
 ifeq ($(shell git ls-files $(GLIBC_SRC)/configure),)
 GLIBC_PATCHES = \
 	$(GLIBC_SRC).patch \
+	glibc-syscalldb-api.patch \
 	glibc-fix-warning.patch \
 	glibc-no-pie.patch \
 	glibc-liblibos.patch

+ 108 - 0
LibOS/glibc-syscalldb-api.patch

@@ -0,0 +1,108 @@
+diff --git a/elf/syscallas.S b/elf/syscallas.S
+new file mode 120000
+index 0000000..107bd13
+--- /dev/null
++++ b/elf/syscallas.S
+@@ -0,0 +1 @@
++../syscallas.S
+\ No newline at end of file
+diff --git a/elf/syscalldb.c b/elf/syscalldb.c
+new file mode 120000
+index 0000000..61dca52
+--- /dev/null
++++ b/elf/syscalldb.c
+@@ -0,0 +1 @@
++../syscalldb.c
+\ No newline at end of file
+diff --git a/syscallas.S b/syscallas.S
+new file mode 100644
+index 0000000..07c6ffc
+--- /dev/null
++++ b/syscallas.S
+@@ -0,0 +1,11 @@
++#include <syscalldb.h>
++
++.weak syscalldb
++.type syscalldb,@function
++
++syscalldb:
++	.cfi_startproc
++	syscall
++	retq
++	.cfi_endproc
++	.size syscalldb,.-syscalldb
+diff --git a/syscalldb.c b/syscalldb.c
+new file mode 100644
+index 0000000..7a56162
+--- /dev/null
++++ b/syscalldb.c
+@@ -0,0 +1,16 @@
++#include "syscalldb.h"
++#include <stdarg.h>
++#include <errno.h>
++
++int register_library (const char * name, unsigned long load_address)
++	__attribute__((weak));
++
++int register_library (const char * name, unsigned long load_address)
++{
++	return 0;
++}
++
++long int glibc_option (const char * opt)
++{
++	return -EINVAL;
++}
+diff --git a/syscalldb.h b/syscalldb.h
+new file mode 100644
+index 0000000..2833def
+--- /dev/null
++++ b/syscalldb.h
+@@ -0,0 +1,39 @@
++#ifndef _SYSCALLDB_H_
++#define _SYSCALLDB_H_
++
++#ifdef __ASSEMBLER__
++.weak syscalldb
++.type syscalldb, @function
++
++# if defined(PSEUDO) && defined(SYSCALL_NAME) && defined(SYSCALL_SYMBOL)
++#  define SYSCALLDB                     \
++    subq $128, %rsp;                    \
++    callq *syscalldb@GOTPCREL(%rip);    \
++    addq $128, %rsp
++# else
++#  define SYSCALLDB                             \
++    callq *syscalldb@GOTPCREL(%rip)
++# endif
++
++#else /* !__ASSEMBLER__ */
++asm (
++".weak syscalldb\r\n"
++".type syscalldb, @function\r\n");
++
++#define SYSCALLDB                           \
++    "subq $128, %%rsp\n\t"                  \
++    "callq *syscalldb@GOTPCREL(%%rip)\n\t"  \
++    "addq $128, %%rsp\n\t"
++
++#define SYSCALLDB_ASM                       \
++    "callq *syscalldb@GOTPCREL(%rip)\n\t"
++
++long int glibc_option (const char * opt);
++
++asm (
++".weak glibc_option\r\n"
++".type glibc_option, @function\r\n");
++
++#endif /* Assembler */
++
++#endif /* _SYSCALLDB_H */
+diff --git a/sysdeps/unix/sysv/linux/x86_64/syscalldb.h b/sysdeps/unix/sysv/linux/x86_64/syscalldb.h
+new file mode 120000
+index 0000000..55ab305
+--- /dev/null
++++ b/sysdeps/unix/sysv/linux/x86_64/syscalldb.h
+@@ -0,0 +1 @@
++../../../../../syscalldb.h
+\ No newline at end of file