00db10
commit 02657da2cf4457804ed938ee08b8316249126444
00db10
Author: Siddhesh Poyarekar <siddhesh@redhat.com>
00db10
Date:   Tue Sep 16 22:19:22 2014 +0530
00db10
00db10
    Include .interp section only for libc.so
00db10
    
00db10
    Barring libc.so and libdl.so, none of the libraries have any entry
00db10
    points, so it is pointless to add a .interp section for them.  The
00db10
    libdl.so entry point (in dlfcn/eval.c) is also defunct, so remove that
00db10
    file as well.
00db10
    
00db10
    Build tested for x86_64, ppc64 and s390x.  I have not moved
00db10
    CFLAGS-interp.c to CPPFLAGS-interp.c isnce I'll be removing it
00db10
    completely in a follow-up patch.
00db10
    
00db10
    Siddhesh
00db10
    
00db10
    	* Makerules (lib%.so): Don't include $(+interp) in
00db10
    	prerequisites.
00db10
    	* elf/Makefile (CFLAGS-interp.c): Don't define NOT_IN_libc.
00db10
    	* dlfcn/eval.c: Remove file.
00db10
00db10
Index: glibc-2.17-c758a686/Makerules
00db10
===================================================================
00db10
--- glibc-2.17-c758a686.orig/Makerules
00db10
+++ glibc-2.17-c758a686/Makerules
00db10
@@ -461,7 +461,7 @@ link-libc-deps = $(common-objpfx)libc.so
00db10
 # build shared libraries in place from the installed *_pic.a files.
00db10
 # $(LDLIBS-%.so) may contain -l switches to generate run-time dependencies
00db10
 # on other shared objects.
00db10
-lib%.so: lib%_pic.a $(+preinit) $(+postinit) $(+interp)
00db10
+lib%.so: lib%_pic.a $(+preinit) $(+postinit)
00db10
 	$(build-shlib)
00db10
 
00db10
 define build-shlib-helper
00db10
Index: glibc-2.17-c758a686/dlfcn/eval.c
00db10
===================================================================
00db10
--- glibc-2.17-c758a686.orig/dlfcn/eval.c
00db10
+++ /dev/null
00db10
@@ -1,200 +0,0 @@
00db10
-/* You don't really want to know what this hack is for.
00db10
-   Copyright (C) 1996, 1997, 2000, 2001 Free Software Foundation, Inc.
00db10
-   This file is part of the GNU C Library.
00db10
-
00db10
-   The GNU C Library is free software; you can redistribute it and/or
00db10
-   modify it under the terms of the GNU Lesser General Public
00db10
-   License as published by the Free Software Foundation; either
00db10
-   version 2.1 of the License, or (at your option) any later version.
00db10
-
00db10
-   The GNU C Library is distributed in the hope that it will be useful,
00db10
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
00db10
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00db10
-   Lesser General Public License for more details.
00db10
-
00db10
-   You should have received a copy of the GNU Lesser General Public
00db10
-   License along with the GNU C Library; if not, see
00db10
-   <http://www.gnu.org/licenses/>.  */
00db10
-
00db10
-#include <assert.h>
00db10
-#include <ctype.h>
00db10
-#include <dlfcn.h>
00db10
-#include <errno.h>
00db10
-#include <limits.h>
00db10
-#include <stdio.h>
00db10
-#include <stdlib.h>
00db10
-#include <string.h>
00db10
-#include <unistd.h>
00db10
-
00db10
-static void *funcall (char **stringp) __attribute_noinline__;
00db10
-static void *eval (char **stringp);
00db10
-
00db10
-
00db10
-long int weak_function
00db10
-__strtol_internal (const char *nptr, char **endptr, int base, int group)
00db10
-{
00db10
-  unsigned long int result = 0;
00db10
-  long int sign = 1;
00db10
-
00db10
-  while (*nptr == ' ' || *nptr == '\t')
00db10
-    ++nptr;
00db10
-
00db10
-  if (*nptr == '-')
00db10
-    {
00db10
-      sign = -1;
00db10
-      ++nptr;
00db10
-    }
00db10
-  else if (*nptr == '+')
00db10
-    ++nptr;
00db10
-
00db10
-  if (*nptr < '0' || *nptr > '9')
00db10
-    {
00db10
-      if (endptr != NULL)
00db10
-	*endptr = (char *) nptr;
00db10
-      return 0L;
00db10
-    }
00db10
-
00db10
-  assert (base == 0);
00db10
-  base = 10;
00db10
-  if (*nptr == '0')
00db10
-    {
00db10
-      if (nptr[1] == 'x' || nptr[1] == 'X')
00db10
-	{
00db10
-	  base = 16;
00db10
-	  nptr += 2;
00db10
-	}
00db10
-      else
00db10
-	base = 8;
00db10
-    }
00db10
-
00db10
-  while (*nptr >= '0' && *nptr <= '9')
00db10
-    {
00db10
-      unsigned long int digval = *nptr - '0';
00db10
-      if (result > LONG_MAX / 10
00db10
-	  || (sign > 0 ? result == LONG_MAX / 10 && digval > LONG_MAX % 10
00db10
-	      : (result == ((unsigned long int) LONG_MAX + 1) / 10
00db10
-		 && digval > ((unsigned long int) LONG_MAX + 1) % 10)))
00db10
-	{
00db10
-	  errno = ERANGE;
00db10
-	  return sign > 0 ? LONG_MAX : LONG_MIN;
00db10
-	}
00db10
-      result *= base;
00db10
-      result += digval;
00db10
-      ++nptr;
00db10
-    }
00db10
-
00db10
-  return (long int) result * sign;
00db10
-}
00db10
-
00db10
-
00db10
-static void *
00db10
-funcall (char **stringp)
00db10
-{
00db10
-  void *args[strlen (*stringp)], **ap = args;
00db10
-  void *argcookie = &args[1];
00db10
-
00db10
-  do
00db10
-    {
00db10
-      /* Evaluate the next token.  */
00db10
-      *ap++ = eval (stringp);
00db10
-
00db10
-      /* Whitespace is irrelevant.  */
00db10
-      while (isspace (**stringp))
00db10
-	++*stringp;
00db10
-
00db10
-      /* Terminate at closing paren or end of line.  */
00db10
-    } while (**stringp != '\0' && **stringp != ')');
00db10
-  if (**stringp != '\0')
00db10
-    /* Swallow closing paren.  */
00db10
-    ++*stringp;
00db10
-
00db10
-  if (args[0] == NULL)
00db10
-    {
00db10
-      static const char unknown[] = "Unknown function\n";
00db10
-      write (1, unknown, sizeof unknown - 1);
00db10
-      return NULL;
00db10
-    }
00db10
-
00db10
-  /* Do it to it.  */
00db10
-  __builtin_return (__builtin_apply (args[0],
00db10
-				     &argcookie,
00db10
-				     (char *) ap - (char *) &args[1]));
00db10
-}
00db10
-
00db10
-static void *
00db10
-eval (char **stringp)
00db10
-{
00db10
-  void *value;
00db10
-  char *p = *stringp, c;
00db10
-
00db10
-  /* Whitespace is irrelevant.  */
00db10
-  while (isspace (*p))
00db10
-    ++p;
00db10
-
00db10
-  switch (*p)
00db10
-    {
00db10
-    case '"':
00db10
-      /* String constant.  */
00db10
-      value = ++p;
00db10
-      do
00db10
-	if (*p == '\\')
00db10
-	  {
00db10
-	    switch (*strcpy (p, p + 1))
00db10
-	      {
00db10
-	      case 't':
00db10
-		*p = '\t';
00db10
-		break;
00db10
-	      case 'n':
00db10
-		*p = '\n';
00db10
-		break;
00db10
-	      }
00db10
-	    ++p;
00db10
-	  }
00db10
-      while (*p != '\0' && *p++ != '"');
00db10
-      if (p[-1] == '"')
00db10
-	p[-1] = '\0';
00db10
-      break;
00db10
-
00db10
-    case '(':
00db10
-      *stringp = ++p;
00db10
-      return funcall (stringp);
00db10
-
00db10
-    default:
00db10
-      /* Try to parse it as a number.  */
00db10
-      value = (void *) __strtol_internal (p, stringp, 0, 0);
00db10
-      if (*stringp != p)
00db10
-	return value;
00db10
-
00db10
-      /* Anything else is a symbol that produces its address.  */
00db10
-      value = p;
00db10
-      do
00db10
-	++p;
00db10
-      while (*p != '\0' && !isspace (*p) && (!ispunct (*p) || *p == '_'));
00db10
-      c = *p;
00db10
-      *p = '\0';
00db10
-      value = dlsym (NULL, value);
00db10
-      *p = c;
00db10
-      break;
00db10
-    }
00db10
-
00db10
-  *stringp = p;
00db10
-  return value;
00db10
-}
00db10
-
00db10
-
00db10
-extern void _start (void) __attribute__ ((noreturn));
00db10
-void
00db10
-__attribute__ ((noreturn))
00db10
-_start (void)
00db10
-{
00db10
-  char *buf = NULL;
00db10
-  size_t bufsz = 0;
00db10
-
00db10
-  while (__getdelim (&buf, &bufsz, '\n', stdin) > 0)
00db10
-    {
00db10
-      char *p = buf;
00db10
-      eval (&p);
00db10
-    }
00db10
-
00db10
-  exit (0);
00db10
-}
00db10
Index: glibc-2.17-c758a686/elf/Makefile
00db10
===================================================================
00db10
--- glibc-2.17-c758a686.orig/elf/Makefile
00db10
+++ glibc-2.17-c758a686/elf/Makefile
00db10
@@ -345,8 +345,7 @@ $(objpfx)ld.so: $(objpfx)librtld.os $(ld
00db10
 	  | $(AWK) '($$7 ~ /^UND(|EF)$$/ && $$1 != "0:" && $$4 != "REGISTER") { print; p=1 } END { exit p != 0 }'
00db10
 
00db10
 # interp.c exists just to get this string into the libraries.
00db10
-CFLAGS-interp.c = -D'RUNTIME_LINKER="$(rtlddir)/$(rtld-installed-name)"' \
00db10
-		  -DNOT_IN_libc=1
00db10
+CFLAGS-interp.c = -D'RUNTIME_LINKER="$(rtlddir)/$(rtld-installed-name)"'
00db10
 $(objpfx)interp.os: $(common-objpfx)config.make
00db10
 
00db10
 ifneq (ld.so,$(rtld-installed-name))