From patchwork Wed Sep 11 21:04:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaku Yamahata X-Patchwork-Id: 1161280 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-105150-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="OhiUbcc0"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="XVvreSeJ"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46TDvj1zyvz9s00 for ; Thu, 12 Sep 2019 07:05:53 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; q=dns; s=default; b=aBDWdikL cpLgMJcWAUXqeguhXP86/+h1VIYMnaQc57PQ5B09qZOLmDxnXCs9EehiRGBpruYQ FChqhaGBeSXfWzDvgv1pGDouGl8fEaEcbvuNaKkH6zrXYW+FLw5Gm1A3pdfHtevb d2KkAzDXP64C2YQetywmqLkpeJxjvBzS9f0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; s=default; bh=+cswMMFl8QEgSm XCh3R0yFrDKLg=; b=OhiUbcc0mXEnQO3dscrQaIOzkngt5/sZ86+shdPBPOoaBX lxC+w73Ad3WNnumdZh0+NEzwDWsE6Q9Qo+t5S+thRKzS5kbHJoCnEL1kCQEpl2BQ bqtnXZblKXH2SyVh37sNM3N5b5B37jnH4s9pBBgurMntyZsY8AVLgW0IhwlDg= Received: (qmail 94687 invoked by alias); 11 Sep 2019 21:05:14 -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 94581 invoked by uid 89); 11 Sep 2019 21:05:13 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.0 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=HX-Spam-Relays-External:209.85.210.193, H*RU:209.85.210.193 X-HELO: mail-pf1-f193.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=zYS1xkpt88xvoHbXkweX8cw1kSyJ2mW6TT8o5M41YTA=; b=XVvreSeJrrVMrcR8aZPHvqQQxzLurj13o5fNlJzIoHNEuC7plxzO1UnSgPgvxa/XzB RlbNTooQZ/XRAWp0eF6YoNYk6DZ8VpkVR+oiaGvz9gi7+l0H9Mef+7/sDakFUwybkyE2 +78XFab42Tn4KgUCeP2a2xE53QR5I4qKiubdanBF0ev5ql4J8DGiKpvDrkdGukdKI0vO EQZW/5MQKbLyKOwssLzaHLfsG4ebT0w+8dnTJOvdDRovS5id6hwJq+/oEowGsB5Au4av TmCRrfqsny1DFGaeMM0hOIBPyPNSYNWNrCMnQUdMg9XQI09T17t91sN3wBBGy0y8335D +7EQ== From: Isaku Yamahata To: libc-alpha@sourceware.org Cc: isaku.yamahata@intel.com, Isaku Yamahata Subject: [RFC PATCH 04/11] elf: add stub functions for LibOS support Date: Wed, 11 Sep 2019 14:04:02 -0700 Message-Id: <5fd525684f6fa6b3cd73dd2d26f5531a32925291.1568219399.git.isaku.yamahata@gmail.com> In-Reply-To: References: In-Reply-To: References: This patch add a stub function for LibOS support which will be used by later patch. This impact on traditional run-time is single stub function as weak symbol so that LibOS can inject the function at runtime. As statically linked case, dynamic symbol interposing isn't usable. For such case, the symbol address is recored in note section and nop instructions are added so that LibOS can overwrite jump instruction. Signed-off-by: Isaku Yamahata --- elf/Versions | 2 ++ elf/libos.c | 10 ++++++++++ elf/libos.h | 14 ++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/elf/Versions b/elf/Versions index b9b4ae168a..619676afef 100644 --- a/elf/Versions +++ b/elf/Versions @@ -81,5 +81,7 @@ ld { # libos __libos_release; __libos_version; __libos_abi; + # stub symbols for libos support + __libos_map_library; } } diff --git a/elf/libos.c b/elf/libos.c index 8fe3df4944..8f6036283f 100644 --- a/elf/libos.c +++ b/elf/libos.c @@ -15,6 +15,8 @@ License along with the GNU C Library; if not, see . */ +#include + #include #include "../version.h" @@ -24,3 +26,11 @@ const uint64_t __libos_abi = 0; LIBOS_NOTES("versions", LIBOS_NOTE_VERSION, __libos_release, __WORDSIZE / 8, "release"); LIBOS_NOTES("versions", LIBOS_NOTE_VERSION, __libos_version, __WORDSIZE / 8, "version"); LIBOS_NOTES("versions", LIBOS_NOTE_VERSION, __libos_abi, 8, "abi"); + +int __attribute__((weak)) __libos_map_library (int fd, const char * name, + unsigned long load_address) +{ + NOP_FILL; + return 0; +} +LIBOS_NOTES("functions", LIBOS_NOTE_FUNCTION, __libos_map_library, 0, "__libos_map_library"); diff --git a/elf/libos.h b/elf/libos.h index 0610c212ff..6624e8d3a7 100644 --- a/elf/libos.h +++ b/elf/libos.h @@ -81,4 +81,18 @@ struct libos_note_desc { " .popsection\n") #endif +#ifdef __x86_64__ + /* 16 bytes space for 8 bytes offset jump */ +# define NOP_FILL \ + do { \ + /* ".nops 16, 1" requires relatively recent gas */ \ + __asm__ volatile ("nop;nop;nop;nop;nop;nop;nop;nop;\n"); \ + __asm__ volatile ("nop;nop;nop;nop;nop;nop;nop;nop;\n"); \ + } while (0) +#else +# define NOP_FILL /* nothing */ +#endif + +extern int __libos_map_library (int fd, const char * name, unsigned long load_address); + #endif /* libos.h */