From patchwork Wed Sep 11 21:04:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaku Yamahata X-Patchwork-Id: 34504 Received: (qmail 94865 invoked by alias); 11 Sep 2019 21:05:15 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 94723 invoked by uid 89); 11 Sep 2019 21:05:14 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=Signal, H*r:sk:mail-pf, HX-HELO:sk:mail-pf X-HELO: mail-pf1-f195.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=7Cxs8bmthjfuLnkG6N92r6l8HW4AVr5Q4jaMMgCez7c=; b=ElVmfQLVhrSeOizE9KfU9Y2Hn2Enu+cgAUmcZEFdomAK3eyIIYpZVUAvekKaMGMbx8 TLDRhI4DBWrmo8gIuCq3S5Mt/Yb22hcbxSKu5FCcZR59teOPyi3m5GQ3dktPpmYuE6RY gBfDXUSxqdHSmCoWbO5kCiU/VUiLDjmrQNw3CCLu+aAiYLMX8iWHY6xuXXcV70VdeYz0 iZa13Ysvai8SHewZWVlDA8pjLRjStXDiLXXEDprHRQ33M/qK8wRP9Mb/8Y+rqTLu7j1v E3+2FRF0DXARxXX9QCyD+JBbNfE9V4Sq+ekkuytgSBq094F0d4kU/7GPXYWcYyBFgmil 1q4w== Return-Path: From: Isaku Yamahata To: libc-alpha@sourceware.org Cc: isaku.yamahata@intel.com, Isaku Yamahata Subject: [RFC PATCH 05/11] elf: add hook, __libos_map_library to dl-open.c Date: Wed, 11 Sep 2019 14:04:03 -0700 Message-Id: <59087b506dde76e07ea9fba069d0d0a12c842881.1568219399.git.isaku.yamahata@gmail.com> In-Reply-To: References: In-Reply-To: References: 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 --- 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 #include #include +#include #include #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; }