diff options
Diffstat (limited to 'src/get.c')
-rw-r--r-- | src/get.c | 104 |
1 files changed, 27 insertions, 77 deletions
@@ -1,19 +1,8 @@ /* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007, 2009 Red Hat, Inc. Written by Jakub Jelinek <jakub@redhat.com>, 2001. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +* SPDX-License-Identifier: GPL-2.0-or-later +*/ #include <config.h> #include <assert.h> @@ -167,7 +156,7 @@ prelink_record_relocations (struct prelink_info *info, FILE *f, { struct stat64 st; - if (wrap_stat64 (filename, &st) < 0) + if (stat64 (filename, &st) < 0) { error (0, errno, "%s: Could not stat %s", info->ent->filename, filename); @@ -642,7 +631,7 @@ prelink_get_relocations (struct prelink_info *info) { FILE *f; DSO *dso = info->dso; - const char *argv[8]; + const char *argv[5]; const char *envp[5]; int i, j, ret, status; char *p; @@ -672,6 +661,13 @@ prelink_get_relocations (struct prelink_info *info) / info->symtab_entsize; info->symbols = calloc (sizeof (struct prelink_symbol), info->symbol_count); + i = 0; + argv[i++] = dl; + if (ld_library_path) + { + argv[i++] = "--library-path"; + argv[i++] = ld_library_path; + } if (strchr (info->ent->filename, '/') != NULL) ent_filename = info->ent->filename; else @@ -682,71 +678,25 @@ prelink_get_relocations (struct prelink_info *info) memcpy (p + 2, info->ent->filename, flen + 1); ent_filename = p; } - if (prelink_rtld == NULL) - { - i = 0; - argv[i++] = dl; - if (ld_library_path) - { - argv[i++] = "--library-path"; - argv[i++] = ld_library_path; - } - argv[i++] = ent_filename; - argv[i] = NULL; - - j = 0; - if(etype == ET_EXEC && ld_preload) - { - p = alloca (sizeof "LD_PRELOAD=" + strlen (ld_preload)); - strcpy (stpcpy (p, "LD_PRELOAD="), ld_preload); - envp[j++] = p; - } - envp[j++] = "LD_TRACE_LOADED_OBJECTS=1"; - envp[j++] = "LD_BIND_NOW=1"; - p = alloca (sizeof "LD_TRACE_PRELINKING=" + strlen (info->ent->filename)); - strcpy (stpcpy (p, "LD_TRACE_PRELINKING="), info->ent->filename); - envp[j++] = p; - envp[j] = NULL; + argv[i++] = ent_filename; + argv[i] = NULL; - ret = 2; - f = execve_open (dl, (char * const *)argv, (char * const *)envp); - } - else + j = 0; + if(etype == ET_EXEC && ld_preload) { - i = 0; - argv[i++] = prelink_rtld; - if (ld_library_path) - { - argv[i++] = "--library-path"; - argv[i++] = ld_library_path; - } - - if(etype == ET_EXEC && ld_preload) { - argv[i++] = "--ld-preload"; - argv[i++] = ld_preload; - } - - argv[i++] = "--target-paths"; - argv[i++] = ent_filename; - argv[i] = NULL; - p = alloca (sizeof "RTLD_TRACE_PRELINKING=" + strlen (info->ent->filename)); - strcpy (stpcpy (p, "RTLD_TRACE_PRELINKING="), info->ent->filename); - envp[0] = p; - p = alloca (sizeof "PATH=" + strlen (getenv ("PATH"))); - sprintf (p, "PATH=%s", getenv ("PATH")); - envp[1] = p; - envp[2] = NULL; - if (sysroot) - { - p = alloca (sizeof "PRELINK_SYSROOT=" + strlen (sysroot)); - sprintf (p, "PRELINK_SYSROOT=%s", sysroot); - envp[2] = p; - envp[3] = NULL; - } - ret = 2; - f = execve_open (prelink_rtld, (char * const *)argv, (char * const *)envp); + p = alloca (sizeof "LD_PRELOAD=" + strlen (ld_preload)); + strcpy (stpcpy (p, "LD_PRELOAD="), ld_preload); + envp[j++] = p; } - + envp[j++] = "LD_TRACE_LOADED_OBJECTS=1"; + envp[j++] = "LD_BIND_NOW=1"; + p = alloca (sizeof "LD_TRACE_PRELINKING=" + strlen (info->ent->filename)); + strcpy (stpcpy (p, "LD_TRACE_PRELINKING="), info->ent->filename); + envp[j++] = p; + envp[j] = NULL; + + ret = 2; + f = execve_open (dl, (char * const *)argv, (char * const *)envp); if (f == NULL) { error (0, errno, "%s: Could not trace symbol resolving", |