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