From patchwork Mon Sep 15 08:19:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 389236 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 E10591400A3 for ; Mon, 15 Sep 2014 18:19:34 +1000 (EST) 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; q=dns; s=default; b=TnVCCgDQPZWGTGTSKVH9yGHdE6r9hC0 mKQGJf/EbSP413OhwVaKswUbeh13UGFL0p1PJBnNejvyp55L8YVfHSQOY6lxV0ui zzspwPStTxcLFnR/bPNq6uhb/YjIEo4XZ/LNqi6KWspzF46yBReqTbvDJY5FNT5/ nLWmPPiVT2ZA= 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; s=default; bh=e/OWvIEN44wUHcorjggsY93w3GE=; b=ctYRo Y85/nSsFhQWgBslYeIhABFChM/IcU0As53jfL/W6RRVq6KkUmbfyUbfC4cSLyr+d QsLTffbUKxo5c57k9eCpQIPSQlYmM5eHMFt3tRVroJkME1dLn5iz02dxW/IklbOy woA7f42gKpIn1LMeT20sKS6TCdgXGeItryt7qk= Received: (qmail 2296 invoked by alias); 15 Sep 2014 08:19:28 -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 2272 invoked by uid 89); 15 Sep 2014 08:19:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.7 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com From: Siddhesh Poyarekar To: libc-alpha@sourceware.org Cc: Roland McGrath , Siddhesh Poyarekar Subject: [PATCH] Include .interp section only for libc.so Date: Mon, 15 Sep 2014 13:49:09 +0530 Message-Id: <1410769149-24314-1-git-send-email-siddhesh@redhat.com> In-Reply-To: <20140905225447.97A952C3984@topped-with-meat.com> References: <20140905225447.97A952C3984@topped-with-meat.com> Barring libc.so and libdl.so, none of the libraries have any entry points, so it is pointless to add a .interp section for them. The libdl.so entry point (in dlfcn/eval.c) is also defunct, so remove that file as well. Build tested for x86_64, ppc64 and s390x. I have not moved CFLAGS-interp.c to CPPFLAGS-interp.c isnce I'll be removing it completely in a follow-up patch. Siddhesh * Makerules (lib%.so): Don't include $(+interp) in prerequisites. * elf/Makefile (CFLAGS-interp.c): Don't define NOT_IN_libc. * dlfcn/eval.c: Remove file. --- Makerules | 2 +- dlfcn/eval.c | 200 ----------------------------------------------------------- elf/Makefile | 3 +- 3 files changed, 2 insertions(+), 203 deletions(-) delete mode 100644 dlfcn/eval.c diff --git a/Makerules b/Makerules index 6b30e8c..695c9ab 100644 --- a/Makerules +++ b/Makerules @@ -436,7 +436,7 @@ link-libc-deps = $(common-objpfx)libc.so $(common-objpfx)linkobj/libc.so \ # $(LDLIBS-%.so) may contain -l switches to generate run-time dependencies # on other shared objects. The linking with libc and ld.so is intended # to be as similar as possible to a default link with an installed libc. -lib%.so: lib%_pic.a $(+preinit) $(+postinit) $(+interp) $(link-libc-deps) +lib%.so: lib%_pic.a $(+preinit) $(+postinit) $(link-libc-deps) $(build-shlib) $(link-libc-args) define build-shlib-helper diff --git a/dlfcn/eval.c b/dlfcn/eval.c deleted file mode 100644 index 9cc307a..0000000 --- a/dlfcn/eval.c +++ /dev/null @@ -1,200 +0,0 @@ -/* You don't really want to know what this hack is for. - Copyright (C) 1996-2014 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static void *funcall (char **stringp) __attribute_noinline__; -static void *eval (char **stringp); - - -long int weak_function -__strtol_internal (const char *nptr, char **endptr, int base, int group) -{ - unsigned long int result = 0; - long int sign = 1; - - while (*nptr == ' ' || *nptr == '\t') - ++nptr; - - if (*nptr == '-') - { - sign = -1; - ++nptr; - } - else if (*nptr == '+') - ++nptr; - - if (*nptr < '0' || *nptr > '9') - { - if (endptr != NULL) - *endptr = (char *) nptr; - return 0L; - } - - assert (base == 0); - base = 10; - if (*nptr == '0') - { - if (nptr[1] == 'x' || nptr[1] == 'X') - { - base = 16; - nptr += 2; - } - else - base = 8; - } - - while (*nptr >= '0' && *nptr <= '9') - { - unsigned long int digval = *nptr - '0'; - if (result > LONG_MAX / 10 - || (sign > 0 ? result == LONG_MAX / 10 && digval > LONG_MAX % 10 - : (result == ((unsigned long int) LONG_MAX + 1) / 10 - && digval > ((unsigned long int) LONG_MAX + 1) % 10))) - { - errno = ERANGE; - return sign > 0 ? LONG_MAX : LONG_MIN; - } - result *= base; - result += digval; - ++nptr; - } - - return (long int) result * sign; -} - - -static void * -funcall (char **stringp) -{ - void *args[strlen (*stringp)], **ap = args; - void *argcookie = &args[1]; - - do - { - /* Evaluate the next token. */ - *ap++ = eval (stringp); - - /* Whitespace is irrelevant. */ - while (isspace (**stringp)) - ++*stringp; - - /* Terminate at closing paren or end of line. */ - } while (**stringp != '\0' && **stringp != ')'); - if (**stringp != '\0') - /* Swallow closing paren. */ - ++*stringp; - - if (args[0] == NULL) - { - static const char unknown[] = "Unknown function\n"; - write (1, unknown, sizeof unknown - 1); - return NULL; - } - - /* Do it to it. */ - __builtin_return (__builtin_apply (args[0], - &argcookie, - (char *) ap - (char *) &args[1])); -} - -static void * -eval (char **stringp) -{ - void *value; - char *p = *stringp, c; - - /* Whitespace is irrelevant. */ - while (isspace (*p)) - ++p; - - switch (*p) - { - case '"': - /* String constant. */ - value = ++p; - do - if (*p == '\\') - { - switch (*strcpy (p, p + 1)) - { - case 't': - *p = '\t'; - break; - case 'n': - *p = '\n'; - break; - } - ++p; - } - while (*p != '\0' && *p++ != '"'); - if (p[-1] == '"') - p[-1] = '\0'; - break; - - case '(': - *stringp = ++p; - return funcall (stringp); - - default: - /* Try to parse it as a number. */ - value = (void *) __strtol_internal (p, stringp, 0, 0); - if (*stringp != p) - return value; - - /* Anything else is a symbol that produces its address. */ - value = p; - do - ++p; - while (*p != '\0' && !isspace (*p) && (!ispunct (*p) || *p == '_')); - c = *p; - *p = '\0'; - value = dlsym (NULL, value); - *p = c; - break; - } - - *stringp = p; - return value; -} - - -extern void _start (void) __attribute__ ((noreturn)); -void -__attribute__ ((noreturn)) -_start (void) -{ - char *buf = NULL; - size_t bufsz = 0; - - while (__getdelim (&buf, &bufsz, '\n', stdin) > 0) - { - char *p = buf; - eval (&p); - } - - exit (0); -} diff --git a/elf/Makefile b/elf/Makefile index 25012cc..e3bd692 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -354,8 +354,7 @@ $(objpfx)ld.so: $(objpfx)librtld.os $(ld-map) mv -f $@.new $@ # interp.c exists just to get this string into the libraries. -CFLAGS-interp.c = -D'RUNTIME_LINKER="$(rtlddir)/$(rtld-installed-name)"' \ - -DNOT_IN_libc=1 +CFLAGS-interp.c = -D'RUNTIME_LINKER="$(rtlddir)/$(rtld-installed-name)"' $(objpfx)interp.os: $(common-objpfx)config.make ifneq (ld.so,$(rtld-installed-name))