mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-21 20:40:05 +00:00
* elf/Makefile ($(objpfx)$(rtld-installed-name)): New target to make
link to ld.so if that is not the installed name. (lib-noranlib): Depend on the installed name in the build directory instead of on ld.so. * Makeconfig (link-libc): Include $(elfobjdir)/$(rtld-installed-name) between libc.so and libc.a, because with libc.so's DT_NEEDED for ld.so ld searches libc.a before ld.so (is that an ld bug?). Add $(elfobjdir) to -rpath-link. * Makerules (elfobjdir): Define as . when $(subdir) is elf. * sysdeps/i386/dl-machine.h (elf_machine_rel): In R_386_32 case when relocating _dl_rtld_map, subtract SYM's value from final reloc value, but don't change *RELOC_ADDR before calling *RESOLVE, because it might call the function we are relocating!
This commit is contained in:
parent
6ba3531662
commit
852fc4b91e
17
ChangeLog
17
ChangeLog
@ -1,5 +1,22 @@
|
||||
Tue Jun 11 15:09:15 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
|
||||
|
||||
* elf/Makefile ($(objpfx)$(rtld-installed-name)): New target to make
|
||||
link to ld.so if that is not the installed name.
|
||||
(lib-noranlib): Depend on the installed name in the build directory
|
||||
instead of on ld.so.
|
||||
|
||||
* Makeconfig (link-libc): Include $(elfobjdir)/$(rtld-installed-name)
|
||||
between libc.so and libc.a, because with libc.so's DT_NEEDED for ld.so
|
||||
ld searches libc.a before ld.so (is that an ld bug?).
|
||||
Add $(elfobjdir) to -rpath-link.
|
||||
|
||||
* Makerules (elfobjdir): Define as . when $(subdir) is elf.
|
||||
|
||||
* sysdeps/i386/dl-machine.h (elf_machine_rel): In R_386_32 case when
|
||||
relocating _dl_rtld_map, subtract SYM's value from final reloc value,
|
||||
but don't change *RELOC_ADDR before calling *RESOLVE, because it might
|
||||
call the function we are relocating!
|
||||
|
||||
* string/basename.c: New file.
|
||||
* string/Makefile (routines): Add basename.
|
||||
|
||||
|
@ -312,8 +312,9 @@ ifeq (yes,$(build-shared))
|
||||
# We need the versioned name of libc.so in the deps of $(others) et al
|
||||
# so that the symlink to libc.so is created before anything tries to
|
||||
# run the linked programs.
|
||||
link-libc = -Wl,-rpath-link=$(common-objdir) \
|
||||
link-libc = -Wl,-rpath-link=$(common-objdir):$(elfobjdir) \
|
||||
$(common-objpfx)libc.so$(libc.so-version) \
|
||||
$(elfobjdir)/$(rtld-installed-name) \
|
||||
$(common-objpfx)libc.a $(gnulib)
|
||||
# Choose the default search path for the dynamic linker based on
|
||||
# where we will install libraries.
|
||||
|
@ -493,7 +493,11 @@ LDFLAGS-c.so = -nostdlib -nostartfiles
|
||||
# Give libc.so an entry point and make it directly runnable itself.
|
||||
LDFLAGS-c.so += -e __libc_print_version
|
||||
# Use our own special initializer and finalizer files for libc.so.
|
||||
ifeq (elf, $(subdir))
|
||||
elfobjdir := .
|
||||
else
|
||||
elfobjdir := $(firstword $(objdir) $(..)elf)
|
||||
endif
|
||||
$(common-objpfx)libc.so: $(elfobjdir)/soinit.so \
|
||||
$(common-objpfx)libc_pic.a \
|
||||
$(elfobjdir)/sofini.so $(elfobjdir)/ld.so
|
||||
|
11
elf/Makefile
11
elf/Makefile
@ -53,7 +53,8 @@ install-bin = ldd
|
||||
|
||||
# Make sure these things are built in the `make lib' pass so they can be used
|
||||
# to run programs during the `make others' pass.
|
||||
lib-noranlib: $(objpfx)ld.so $(addprefix $(objpfx),$(extra-objs))
|
||||
lib-noranlib: $(objpfx)$(rtld-installed-name) \
|
||||
$(addprefix $(objpfx),$(extra-objs))
|
||||
|
||||
ifneq (,$(filter linux% linux,$(config-os)))
|
||||
extra-objs += linux-compat.so
|
||||
@ -92,6 +93,14 @@ endef
|
||||
# The dl code in the static libc needs a default library path.
|
||||
CFLAGS-dl-support.c = -D'DEFAULT_RPATH="$(default-rpath)"'
|
||||
|
||||
ifneq (ld.so, $(rtld-installed-name))
|
||||
# Make sure ld-gnu.so.1 exists in the build directory so we can link
|
||||
# against it.
|
||||
$(objpfx)$(rtld-installed-name): $(objpfx)ld.so
|
||||
rm -f $@
|
||||
ln $< $@
|
||||
endif
|
||||
|
||||
# The Linux-compatible dynamic linker shared object is just the same
|
||||
# with one object file of compatibility initialization code added.
|
||||
$(objpfx)ld-linux.so.1: $(objpfx)linux-compat.so
|
||||
|
@ -35,7 +35,7 @@ routines := strcat strchr strcmp strcoll strcpy strcspn strdup \
|
||||
swab strfry memfrob memmem \
|
||||
$(addprefix argz-,append count create ctsep next \
|
||||
delete extract insert stringify) \
|
||||
envz
|
||||
envz basename
|
||||
|
||||
tests := tester testcopy test-ffs tst-strlen
|
||||
distribute := memcopy.h pagecopy.h
|
||||
|
27
string/basename.c
Normal file
27
string/basename.c
Normal file
@ -0,0 +1,27 @@
|
||||
/* basename -- return the name-within-directory of a file name.
|
||||
Copyright (C) 1996 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 Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If
|
||||
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
||||
Cambridge, MA 02139, USA. */
|
||||
|
||||
#include <string.h>
|
||||
|
||||
char *
|
||||
basename (const char *filename)
|
||||
{
|
||||
char *p = strrchr (filename, '/');
|
||||
return p ? p + 1 : filename;
|
||||
}
|
@ -79,7 +79,7 @@ elf_machine_rel (struct link_map *map,
|
||||
int noplt))
|
||||
{
|
||||
Elf32_Addr *const reloc_addr = (void *) (map->l_addr + reloc->r_offset);
|
||||
Elf32_Addr loadbase;
|
||||
Elf32_Addr loadbase, undo;
|
||||
|
||||
switch (ELF32_R_TYPE (reloc->r_info))
|
||||
{
|
||||
@ -101,20 +101,17 @@ elf_machine_rel (struct link_map *map,
|
||||
break;
|
||||
case R_386_32:
|
||||
if (resolve && map == &_dl_rtld_map)
|
||||
{
|
||||
/* Undo the relocation done here during bootstrapping. Now we will
|
||||
relocate it anew, possibly using a binding found in the user
|
||||
program or a loaded library rather than the dynamic linker's
|
||||
built-in definitions used while loading those libraries. */
|
||||
const Elf32_Sym *const dlsymtab
|
||||
= (void *) (map->l_addr + map->l_info[DT_SYMTAB]->d_un.d_ptr);
|
||||
*reloc_addr -= (map->l_addr +
|
||||
dlsymtab[ELF32_R_SYM (reloc->r_info)].st_value);
|
||||
}
|
||||
/* Undo the relocation done here during bootstrapping. Now we will
|
||||
relocate it anew, possibly using a binding found in the user
|
||||
program or a loaded library rather than the dynamic linker's
|
||||
built-in definitions used while loading those libraries. */
|
||||
undo = map->l_addr + sym->st_value;
|
||||
else
|
||||
undo = 0;
|
||||
loadbase = (resolve ? (*resolve) (&sym, (Elf32_Addr) reloc_addr, 0) :
|
||||
/* RESOLVE is null during bootstrap relocation. */
|
||||
map->l_addr);
|
||||
*reloc_addr += sym ? (loadbase + sym->st_value) : 0;
|
||||
*reloc_addr += (sym ? (loadbase + sym->st_value) : 0) - undo;
|
||||
break;
|
||||
case R_386_RELATIVE:
|
||||
if (!resolve || map != &_dl_rtld_map) /* Already done in rtld itself. */
|
||||
|
Loading…
Reference in New Issue
Block a user