@@ -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;
}
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(-)