Browse Source

add vsdo support

lordrasmus 2 years ago
parent
commit
de0cfd949a
6 changed files with 34 additions and 3 deletions
  1. 17 0
      extra/Configs/Config.in
  2. 1 0
      extra/Configs/Config.mips
  3. 7 0
      ldso/include/ldso.h
  4. 3 2
      ldso/ldso/Makefile.in
  5. 3 0
      ldso/ldso/dl-startup.c
  6. 3 1
      ldso/ldso/ldso.c

+ 17 - 0
extra/Configs/Config.in

@@ -455,6 +455,22 @@ config LDSO_PRELINK_SUPPORT
 	  time. It also is able to load and handle prelinked libraries and
 	  time. It also is able to load and handle prelinked libraries and
 	  binaries at runtime.
 	  binaries at runtime.
 
 
+config ARCH_VDSO_SUPPORT
+	bool
+	
+config VDSO_SUPPORT
+	bool "Dynamic linker vDSO support"
+	depends on ARCH_VDSO_SUPPORT
+	help
+	  Enable this option to support vDSO loading
+
+	  vDSO provides access to some kernel function without a systemcall
+	  if provided by the kernel
+
+	  most archs support gettimeofday() and clock_gettime()
+
+	  vDSO loading can be disabled via VDSO_DISABLE environment variable
+
 config UCLIBC_STATIC_LDCONFIG
 config UCLIBC_STATIC_LDCONFIG
 	bool "Link ldconfig statically"
 	bool "Link ldconfig statically"
 	depends on HAVE_SHARED
 	depends on HAVE_SHARED
@@ -2321,6 +2337,7 @@ config SUPPORT_LD_DEBUG
 	    nofixups      never fixes up jump relocations
 	    nofixups      never fixes up jump relocations
 	    bindings      displays the resolve processing (function calls);
 	    bindings      displays the resolve processing (function calls);
 	                  detail shows the relocation patch
 	                  detail shows the relocation patch
+	    vdso          display vdso symbol table processing
 	    all           Enable everything!
 	    all           Enable everything!
 
 
 	  The additional environment variable:
 	  The additional environment variable:

+ 1 - 0
extra/Configs/Config.mips

@@ -13,6 +13,7 @@ config FORCE_OPTIONS_FOR_ARCH
 	select ARCH_ANY_ENDIAN
 	select ARCH_ANY_ENDIAN
 	select ARCH_HAS_UCONTEXT
 	select ARCH_HAS_UCONTEXT
 	select ARCH_HAS_DEPRECATED_SYSCALLS
 	select ARCH_HAS_DEPRECATED_SYSCALLS
+	select ARCH_VDSO_SUPPORT
 
 
 choice
 choice
 	prompt "Target ABI"
 	prompt "Target ABI"

+ 7 - 0
ldso/include/ldso.h

@@ -109,6 +109,7 @@ extern char *_dl_debug_reloc;
 extern char *_dl_debug_detail;
 extern char *_dl_debug_detail;
 extern char *_dl_debug_nofixups;
 extern char *_dl_debug_nofixups;
 extern char *_dl_debug_bindings;
 extern char *_dl_debug_bindings;
+extern char *_dl_debug_vdso;
 extern int   _dl_debug_file;
 extern int   _dl_debug_file;
 # define __dl_debug_dprint(fmt, args...) \
 # define __dl_debug_dprint(fmt, args...) \
 	_dl_dprintf(_dl_debug_file, "%s:%i: " fmt, __func__, __LINE__, ## args);
 	_dl_dprintf(_dl_debug_file, "%s:%i: " fmt, __func__, __LINE__, ## args);
@@ -193,4 +194,10 @@ extern void *_dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE loa
 #define AUX_MAX_AT_ID 40
 #define AUX_MAX_AT_ID 40
 extern ElfW(auxv_t) _dl_auxvt[AUX_MAX_AT_ID];
 extern ElfW(auxv_t) _dl_auxvt[AUX_MAX_AT_ID];
 
 
+void load_vdso( uint32_t sys_info_ehdr, char **envp );
+
+#ifdef __VDSO_SUPPORT__
+extern void* _dl__vdso_gettimeofday;
+#endif
+
 #endif /* _LDSO_H */
 #endif /* _LDSO_H */

+ 3 - 2
ldso/ldso/Makefile.in

@@ -63,14 +63,15 @@ ldso_FULL_NAME := $(UCLIBC_LDSO_NAME)-$(VERSION).so
 $(UCLIBC_LDSO_NAME)_DIR := $(top_srcdir)ldso/ldso
 $(UCLIBC_LDSO_NAME)_DIR := $(top_srcdir)ldso/ldso
 $(UCLIBC_LDSO_NAME)_OUT := $(top_builddir)ldso/ldso
 $(UCLIBC_LDSO_NAME)_OUT := $(top_builddir)ldso/ldso
 
 
-$(UCLIBC_LDSO_NAME)_CSRC := $($(UCLIBC_LDSO_NAME)_DIR)/ldso.c
+$(UCLIBC_LDSO_NAME)_CSRC := $($(UCLIBC_LDSO_NAME)_DIR)/ldso.c $($(UCLIBC_LDSO_NAME)_DIR)/dl-vdso.c
 # prerequesites
 # prerequesites
 $($(UCLIBC_LDSO_NAME)_OUT)/ldso.o $($(UCLIBC_LDSO_NAME)_OUT)/ldso.oS: \
 $($(UCLIBC_LDSO_NAME)_OUT)/ldso.o $($(UCLIBC_LDSO_NAME)_OUT)/ldso.oS: \
 	$($(UCLIBC_LDSO_NAME)_DIR)/dl-debug.c \
 	$($(UCLIBC_LDSO_NAME)_DIR)/dl-debug.c \
 	$($(UCLIBC_LDSO_NAME)_DIR)/dl-startup.c \
 	$($(UCLIBC_LDSO_NAME)_DIR)/dl-startup.c \
 	$($(UCLIBC_LDSO_NAME)_DIR)/dl-array.c \
 	$($(UCLIBC_LDSO_NAME)_DIR)/dl-array.c \
 	$($(UCLIBC_LDSO_NAME)_DIR)/dl-hash.c \
 	$($(UCLIBC_LDSO_NAME)_DIR)/dl-hash.c \
-	$($(UCLIBC_LDSO_NAME)_DIR)/dl-elf.c
+	$($(UCLIBC_LDSO_NAME)_DIR)/dl-elf.c \
+	$($(UCLIBC_LDSO_NAME)_DIR)/dl-vdso.c
 $(UCLIBC_LDSO_NAME)_COBJ := $(patsubst $($(UCLIBC_LDSO_NAME)_DIR)/%.c,$($(UCLIBC_LDSO_NAME)_OUT)/%.o,$($(UCLIBC_LDSO_NAME)_CSRC))
 $(UCLIBC_LDSO_NAME)_COBJ := $(patsubst $($(UCLIBC_LDSO_NAME)_DIR)/%.c,$($(UCLIBC_LDSO_NAME)_OUT)/%.o,$($(UCLIBC_LDSO_NAME)_CSRC))
 
 
 $(UCLIBC_LDSO_NAME)_SSRC := $(wildcard $($(UCLIBC_LDSO_NAME)_DIR)/$(TARGET_ARCH)/*.S)
 $(UCLIBC_LDSO_NAME)_SSRC := $(wildcard $($(UCLIBC_LDSO_NAME)_DIR)/$(TARGET_ARCH)/*.S)

+ 3 - 0
ldso/ldso/dl-startup.c

@@ -367,6 +367,9 @@ DL_START(unsigned long args)
 			_dl_get_ready_to_run(tpnt, load_addr, envp, argv
 			_dl_get_ready_to_run(tpnt, load_addr, envp, argv
 					     DL_GET_READY_TO_RUN_EXTRA_ARGS);
 					     DL_GET_READY_TO_RUN_EXTRA_ARGS);
 
 
+
+	load_vdso(_dl_auxvt[AT_SYSINFO_EHDR].a_un.a_val, envp);
+
 	/* Transfer control to the application.  */
 	/* Transfer control to the application.  */
 	SEND_STDERR_DEBUG("transfering control to application @ ");
 	SEND_STDERR_DEBUG("transfering control to application @ ");
 	SEND_ADDRESS_STDERR_DEBUG(_dl_elf_main, 1);
 	SEND_ADDRESS_STDERR_DEBUG(_dl_elf_main, 1);

+ 3 - 1
ldso/ldso/ldso.c

@@ -73,6 +73,7 @@ char *_dl_debug_reloc     = NULL;
 char *_dl_debug_detail    = NULL;
 char *_dl_debug_detail    = NULL;
 char *_dl_debug_nofixups  = NULL;
 char *_dl_debug_nofixups  = NULL;
 char *_dl_debug_bindings  = NULL;
 char *_dl_debug_bindings  = NULL;
+char *_dl_debug_vdso      = NULL;
 int   _dl_debug_file      = 2;
 int   _dl_debug_file      = 2;
 #endif
 #endif
 
 
@@ -791,7 +792,7 @@ of this helper program; chances are you did not intend to run this program.\n\
 	if (_dl_debug) {
 	if (_dl_debug) {
 		if (_dl_strstr(_dl_debug, "all")) {
 		if (_dl_strstr(_dl_debug, "all")) {
 			_dl_debug_detail = _dl_debug_move = _dl_debug_symbols
 			_dl_debug_detail = _dl_debug_move = _dl_debug_symbols
-				= _dl_debug_reloc = _dl_debug_bindings = _dl_debug_nofixups = (void*)1;
+				= _dl_debug_reloc = _dl_debug_bindings = _dl_debug_nofixups = _dl_debug_vdso = (void*)1;
 		} else {
 		} else {
 			_dl_debug_detail   = _dl_strstr(_dl_debug, "detail");
 			_dl_debug_detail   = _dl_strstr(_dl_debug, "detail");
 			_dl_debug_move     = _dl_strstr(_dl_debug, "move");
 			_dl_debug_move     = _dl_strstr(_dl_debug, "move");
@@ -799,6 +800,7 @@ of this helper program; chances are you did not intend to run this program.\n\
 			_dl_debug_reloc    = _dl_strstr(_dl_debug, "reloc");
 			_dl_debug_reloc    = _dl_strstr(_dl_debug, "reloc");
 			_dl_debug_nofixups = _dl_strstr(_dl_debug, "nofix");
 			_dl_debug_nofixups = _dl_strstr(_dl_debug, "nofix");
 			_dl_debug_bindings = _dl_strstr(_dl_debug, "bind");
 			_dl_debug_bindings = _dl_strstr(_dl_debug, "bind");
+			_dl_debug_vdso     = _dl_strstr(_dl_debug, "vdso");
 		}
 		}
 	}
 	}