unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Isaku Yamahata <isaku.yamahata@gmail.com>
To: libc-alpha@sourceware.org
Cc: isaku.yamahata@intel.com, Isaku Yamahata <isaku.yamahata@gmail.com>
Subject: [RFC PATCH 05/11] elf: add hook, __libos_map_library to dl-open.c
Date: Wed, 11 Sep 2019 14:04:03 -0700	[thread overview]
Message-ID: <59087b506dde76e07ea9fba069d0d0a12c842881.1568219399.git.isaku.yamahata@gmail.com> (raw)
In-Reply-To: <cover.1568219399.git.isaku.yamahata@gmail.com>
In-Reply-To: <cover.1568219399.git.isaku.yamahata@gmail.com>

This patch adds a hook on loading shared library.
The impact on traditional run-time is stub function call.
LibOS can inject its own symbol and interact with debugger.

Signed-off-by: Isaku Yamahata <isaku.yamahata@gmail.com>
---
 elf/dl-load.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/elf/dl-load.c b/elf/dl-load.c
index 5abeb867f1..6a811f41e0 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -72,6 +72,7 @@ struct filebuf
 #include <dl-sysdep-open.h>
 #include <dl-prop.h>
 #include <not-cancel.h>
+#include <libos.h>
 
 #include <endian.h>
 #if BYTE_ORDER == BIG_ENDIAN
@@ -1293,15 +1294,6 @@ cannot enable executable stack as shared object requires");
   if (l->l_tls_initimage != NULL)
     l->l_tls_initimage = (char *) l->l_tls_initimage + l->l_addr;
 
-  /* We are done mapping in the file.  We no longer need the descriptor.  */
-  if (__glibc_unlikely (__close_nocancel (fd) != 0))
-    {
-      errstring = N_("cannot close file descriptor");
-      goto call_lose_errno;
-    }
-  /* Signal that we closed the file.  */
-  fd = -1;
-
   /* If this is ET_EXEC, we should have loaded it as lt_executable.  */
   assert (type != ET_EXEC || l->l_type == lt_executable);
 
@@ -1397,6 +1389,18 @@ cannot enable executable stack as shared object requires");
     }
 #endif
 
+  /* register the library to libos */
+  __libos_map_library(fd, l->l_name, l->l_addr);
+
+  /* We are done mapping in the file.  We no longer need the descriptor.  */
+  if (__glibc_unlikely (__close_nocancel (fd) != 0))
+    {
+      errstring = N_("cannot close file descriptor");
+      goto call_lose_errno;
+    }
+  /* Signal that we closed the file.  */
+  fd = -1;
+
   return l;
 }
 \f
-- 
2.17.1


  parent reply	other threads:[~2019-09-11 21:05 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-11 21:03 [RFC PATCH 00/11] Library OS support Isaku Yamahata
2019-09-11 21:03 ` [RFC PATCH 01/11] x86-64, elf: make elf_machine_lazy_rel() ignore R_X86_64_NONE Isaku Yamahata
2019-09-11 21:04 ` [RFC PATCH 02/11] elf: add macro to define note section for LibOS Isaku Yamahata
2019-09-11 21:04 ` [RFC PATCH 03/11] elf: " Isaku Yamahata
2019-09-11 21:04 ` [RFC PATCH 04/11] elf: add stub functions for LibOS support Isaku Yamahata
2019-09-11 21:04 ` Isaku Yamahata [this message]
2019-09-11 21:04 ` [RFC PATCH 06/11] elf/rtld: introduce runtime option to disable HP_TIMING_INLINE Isaku Yamahata
2019-09-11 21:04 ` [RFC PATCH 07/11] malloc: make arena size configurable on startup Isaku Yamahata
2019-09-12  1:03   ` DJ Delorie
2019-09-12 18:43     ` Isaku Yamahata
2019-09-11 21:04 ` [RFC PATCH 08/11] x86-64: replace syscall instruction with SYSCALL_INST macro Isaku Yamahata
2019-09-11 21:04 ` [RFC PATCH 09/11] x86-64: add nop instruction after syscall instrunction Isaku Yamahata
2019-09-11 21:04 ` [RFC PATCH 10/11] x86-64: make the number of nops after syscall configurable Isaku Yamahata
2019-09-11 21:04 ` [RFC PATCH 11/11] benchtests: simple benchmark to measure nop effects Isaku Yamahata
2019-09-11 21:35   ` Patrick McGehearty
2019-09-12  0:10 ` [RFC PATCH 00/11] Library OS support Joseph Myers
2019-09-12  1:13   ` Isaku Yamahata
2019-09-16 20:47     ` Joseph Myers
2019-09-17 17:46       ` Isaku Yamahata
2019-09-17 13:19 ` Adhemerval Zanella

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/libc/involved.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=59087b506dde76e07ea9fba069d0d0a12c842881.1568219399.git.isaku.yamahata@gmail.com \
    --to=isaku.yamahata@gmail.com \
    --cc=isaku.yamahata@intel.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).