mirror of https://gitee.com/Nocallback/glibc.git
Browse Source
Prelinked binaries and libraries still work, the dynamic tags DT_GNU_PRELINKED, DT_GNU_LIBLIST, DT_GNU_CONFLICT just ignored (meaning the process is reallocated as default). The loader environment variable TRACE_PRELINKING is also removed, since it used solely on prelink. Checked on x86_64-linux-gnu, i686-linux-gnu, and aarch64-linux-gnu. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>maskray/relr
25 changed files with 117 additions and 885 deletions
@ -1,77 +0,0 @@ |
|||
/* Resolve conflicts against already prelinked libraries.
|
|||
Copyright (C) 2001-2022 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; see the file COPYING.LIB. If |
|||
not, see <https://www.gnu.org/licenses/>. */
|
|||
|
|||
#include <assert.h> |
|||
#include <errno.h> |
|||
#include <libintl.h> |
|||
#include <stdlib.h> |
|||
#include <unistd.h> |
|||
#include <ldsodefs.h> |
|||
#include <sys/mman.h> |
|||
#include <sys/param.h> |
|||
#include <sys/types.h> |
|||
#include "dynamic-link.h" |
|||
|
|||
/* Used at loading time solely for prelink executable. It is not called
|
|||
concurrently so it is be safe to defined as static. */ |
|||
static struct link_map *resolve_conflict_map __attribute__ ((__unused__)); |
|||
|
|||
/* This macro is used as a callback from the ELF_DYNAMIC_RELOCATE code. */ |
|||
#define RESOLVE_MAP(map, scope, ref, version, flags) (*ref = NULL, NULL) |
|||
#define RESOLVE(ref, version, flags) (*ref = NULL, 0) |
|||
#define RESOLVE_CONFLICT_FIND_MAP(map, r_offset) \ |
|||
do { \ |
|||
while ((resolve_conflict_map->l_map_end < (ElfW(Addr)) (r_offset)) \ |
|||
|| (resolve_conflict_map->l_map_start > (ElfW(Addr)) (r_offset))) \ |
|||
resolve_conflict_map = resolve_conflict_map->l_next; \ |
|||
\ |
|||
(map) = resolve_conflict_map; \ |
|||
} while (0) |
|||
|
|||
#include "dynamic-link.h" |
|||
|
|||
void |
|||
_dl_resolve_conflicts (struct link_map *l, ElfW(Rela) *conflict, |
|||
ElfW(Rela) *conflictend) |
|||
{ |
|||
#if ! ELF_MACHINE_NO_RELA |
|||
if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_RELOC)) |
|||
_dl_debug_printf ("\nconflict processing: %s\n", DSO_FILENAME (l->l_name)); |
|||
|
|||
{ |
|||
/* Do the conflict relocation of the object and library GOT and other
|
|||
data. */ |
|||
|
|||
/* Prelinking makes no sense for anything but the main namespace. */ |
|||
assert (l->l_ns == LM_ID_BASE); |
|||
resolve_conflict_map = GL(dl_ns)[LM_ID_BASE]._ns_loaded; |
|||
|
|||
/* Override these, defined in dynamic-link.h. */ |
|||
#undef CHECK_STATIC_TLS |
|||
#define CHECK_STATIC_TLS(ref_map, sym_map) ((void) 0) |
|||
#undef TRY_STATIC_TLS |
|||
#define TRY_STATIC_TLS(ref_map, sym_map) (0) |
|||
|
|||
GL(dl_num_cache_relocations) += conflictend - conflict; |
|||
|
|||
for (; conflict < conflictend; ++conflict) |
|||
elf_machine_rela (l, NULL, conflict, NULL, NULL, |
|||
(void *) conflict->r_offset, 0); |
|||
} |
|||
#endif |
|||
} |
|||
@ -1,49 +0,0 @@ |
|||
/* Test the output from the environment variable, LD_TRACE_PRELINKING,
|
|||
for prelink. |
|||
Copyright (C) 2021-2022 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 |
|||
<https://www.gnu.org/licenses/>. */
|
|||
|
|||
#include <ldsodefs.h> |
|||
#include <support/check.h> |
|||
#include <support/xstdio.h> |
|||
#include <support/support.h> |
|||
#include <support/test-driver.h> |
|||
|
|||
static int |
|||
do_test (void) |
|||
{ |
|||
#ifndef DL_EXTERN_PROTECTED_DATA |
|||
return EXIT_UNSUPPORTED; |
|||
#else |
|||
char *src = xasprintf ("%s/elf/tst-prelink-conflict.out", |
|||
support_objdir_root); |
|||
FILE *f = xfopen (src,"r"); |
|||
size_t buffer_length = 0; |
|||
char *buffer = NULL; |
|||
|
|||
const char *expected = "/0 stdout\n"; |
|||
|
|||
xgetline (&buffer, &buffer_length, f); |
|||
TEST_COMPARE_STRING (expected, buffer); |
|||
|
|||
free (buffer); |
|||
xfclose (f); |
|||
return 0; |
|||
#endif |
|||
} |
|||
|
|||
#include <support/test-driver.c> |
|||
@ -1,29 +0,0 @@ |
|||
/* Test the output from the environment variable, LD_TRACE_PRELINKING,
|
|||
for prelink. |
|||
Copyright (C) 2015-2022 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 |
|||
<https://www.gnu.org/licenses/>. */
|
|||
|
|||
#include <stdio.h> |
|||
|
|||
static int |
|||
do_test (void) |
|||
{ |
|||
fprintf (stdout, "hello\n"); |
|||
return 0; |
|||
} |
|||
|
|||
#include <support/test-driver.c> |
|||
Loading…
Reference in new issue