diff options
| author | mycroft <mycroft@NetBSD.org> | 2002-09-06 13:20:29 +0000 |
|---|---|---|
| committer | mycroft <mycroft@NetBSD.org> | 2002-09-06 13:20:29 +0000 |
| commit | 0df8d181005d4dd20006b532cb500ea0e5ee3b8d (patch) | |
| tree | b89571a942775a8e9b620036bb566352eab2767f /libexec | |
| parent | 77a6b82b27fa24d81a68a73afb1c4158bfb664ba (diff) | |
Introduce a new flag, `isdynamic', which is used to remember whether the
executable was of type ET_DYN. Use this instead of `mainprog' to determine
whether we need to do base-relative fixups of the PLT. (This allows loading
non-relocatable objects, should we desire to do that at some point...)
Diffstat (limited to 'libexec')
| -rw-r--r-- | libexec/ld.elf_so/arch/alpha/alpha_reloc.c | 6 | ||||
| -rw-r--r-- | libexec/ld.elf_so/arch/arm/mdreloc.c | 4 | ||||
| -rw-r--r-- | libexec/ld.elf_so/arch/hppa/hppa_reloc.c | 4 | ||||
| -rw-r--r-- | libexec/ld.elf_so/arch/i386/mdreloc.c | 4 | ||||
| -rw-r--r-- | libexec/ld.elf_so/arch/m68k/mdreloc.c | 4 | ||||
| -rw-r--r-- | libexec/ld.elf_so/arch/mips/mips_reloc.c | 6 | ||||
| -rw-r--r-- | libexec/ld.elf_so/arch/powerpc/ppc_reloc.c | 4 | ||||
| -rw-r--r-- | libexec/ld.elf_so/arch/sh3/mdreloc.c | 4 | ||||
| -rw-r--r-- | libexec/ld.elf_so/arch/vax/mdreloc.c | 4 | ||||
| -rw-r--r-- | libexec/ld.elf_so/arch/x86_64/mdreloc.c | 4 | ||||
| -rw-r--r-- | libexec/ld.elf_so/map_object.c | 3 | ||||
| -rw-r--r-- | libexec/ld.elf_so/reloc.c | 4 | ||||
| -rw-r--r-- | libexec/ld.elf_so/rtld.h | 5 |
13 files changed, 29 insertions, 27 deletions
diff --git a/libexec/ld.elf_so/arch/alpha/alpha_reloc.c b/libexec/ld.elf_so/arch/alpha/alpha_reloc.c index cc8596aafb5..daf3c3113c7 100644 --- a/libexec/ld.elf_so/arch/alpha/alpha_reloc.c +++ b/libexec/ld.elf_so/arch/alpha/alpha_reloc.c @@ -1,4 +1,4 @@ -/* $NetBSD: alpha_reloc.c,v 1.11 2002/09/06 03:12:05 mycroft Exp $ */ +/* $NetBSD: alpha_reloc.c,v 1.12 2002/09/06 13:20:31 mycroft Exp $ */ /* * Copyright (c) 2001 Wasabi Systems, Inc. @@ -182,7 +182,7 @@ _rtld_relocate_nonplt_objects(obj, dodebug) * COPY relocation is not in a shared library. They * are allowed only in executable files. */ - if (!obj->mainprog) { + if (obj->isdynamic) { _rtld_error( "%s: Unexpected R_COPY relocation in shared library", obj->path); @@ -214,7 +214,7 @@ _rtld_relocate_plt_lazy(obj, dodebug) { const Elf_Rela *rela; - if (obj->mainprog) + if (!obj->isdynamic) return 0; for (rela = obj->pltrela; rela < obj->pltrelalim; rela++) { diff --git a/libexec/ld.elf_so/arch/arm/mdreloc.c b/libexec/ld.elf_so/arch/arm/mdreloc.c index 72f19606d54..bc3d95368e0 100644 --- a/libexec/ld.elf_so/arch/arm/mdreloc.c +++ b/libexec/ld.elf_so/arch/arm/mdreloc.c @@ -100,7 +100,7 @@ _rtld_relocate_nonplt_objects(obj, dodebug) * COPY relocation is not in a shared library. They * are allowed only in executable files. */ - if (!obj->mainprog) { + if (obj->isdynamic) { _rtld_error( "%s: Unexpected R_COPY relocation in shared library", obj->path); @@ -131,7 +131,7 @@ _rtld_relocate_plt_lazy(obj, dodebug) { const Elf_Rel *rel; - if (obj->mainprog) + if (!obj->isdynamic) return 0; for (rel = obj->pltrel; rel < obj->pltrellim; rel++) { diff --git a/libexec/ld.elf_so/arch/hppa/hppa_reloc.c b/libexec/ld.elf_so/arch/hppa/hppa_reloc.c index dde1529b3bc..e6d8855e159 100644 --- a/libexec/ld.elf_so/arch/hppa/hppa_reloc.c +++ b/libexec/ld.elf_so/arch/hppa/hppa_reloc.c @@ -1,4 +1,4 @@ -/* $NetBSD: hppa_reloc.c,v 1.9 2002/09/06 03:12:06 mycroft Exp $ */ +/* $NetBSD: hppa_reloc.c,v 1.10 2002/09/06 13:20:32 mycroft Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -443,7 +443,7 @@ _rtld_relocate_nonplt_objects(obj, dodebug) * COPY relocation is not in a shared library. They * are allowed only in executable files. */ - if (!obj->mainprog) { + if (obj->isdynamic) { _rtld_error( "%s: Unexpected R_COPY relocation in shared library", obj->path); diff --git a/libexec/ld.elf_so/arch/i386/mdreloc.c b/libexec/ld.elf_so/arch/i386/mdreloc.c index bfbe9130416..6af534d85fc 100644 --- a/libexec/ld.elf_so/arch/i386/mdreloc.c +++ b/libexec/ld.elf_so/arch/i386/mdreloc.c @@ -98,7 +98,7 @@ _rtld_relocate_nonplt_objects(obj, dodebug) * COPY relocation is not in a shared library. They * are allowed only in executable files. */ - if (!obj->mainprog) { + if (obj->isdynamic) { _rtld_error( "%s: Unexpected R_COPY relocation in shared library", obj->path); @@ -129,7 +129,7 @@ _rtld_relocate_plt_lazy(obj, dodebug) { const Elf_Rel *rel; - if (obj->mainprog) + if (!obj->isdynamic) return 0; for (rel = obj->pltrel; rel < obj->pltrellim; rel++) { diff --git a/libexec/ld.elf_so/arch/m68k/mdreloc.c b/libexec/ld.elf_so/arch/m68k/mdreloc.c index 0475e1d113e..7767ccba28c 100644 --- a/libexec/ld.elf_so/arch/m68k/mdreloc.c +++ b/libexec/ld.elf_so/arch/m68k/mdreloc.c @@ -77,7 +77,7 @@ _rtld_relocate_nonplt_objects(obj, dodebug) * COPY relocation is not in a shared library. They * are allowed only in executable files. */ - if (!obj->mainprog) { + if (obj->isdynamic) { _rtld_error( "%s: Unexpected R_COPY relocation in shared library", obj->path); @@ -109,7 +109,7 @@ _rtld_relocate_plt_lazy(obj, dodebug) { const Elf_Rela *rela; - if (obj->mainprog) + if (!obj->isdynamic) return 0; for (rela = obj->pltrela; rela < obj->pltrelalim; rela++) { diff --git a/libexec/ld.elf_so/arch/mips/mips_reloc.c b/libexec/ld.elf_so/arch/mips/mips_reloc.c index 10c7ea9eda9..b0fc19b6b2e 100644 --- a/libexec/ld.elf_so/arch/mips/mips_reloc.c +++ b/libexec/ld.elf_so/arch/mips/mips_reloc.c @@ -1,4 +1,4 @@ -/* $NetBSD: mips_reloc.c,v 1.14 2002/09/06 12:00:41 mycroft Exp $ */ +/* $NetBSD: mips_reloc.c,v 1.15 2002/09/06 13:20:33 mycroft Exp $ */ /* * Copyright 1997 Michael L. Hitch <mhitch@montana.edu> @@ -225,7 +225,7 @@ _rtld_relocate_plt_lazy(obj, dodebug) { const Elf_Rel *rel; - if (obj->mainprog) + if (!obj->isdynamic) return 0; for (rel = obj->pltrel; rel < obj->pltrellim; rel++) { @@ -252,7 +252,7 @@ _rtld_relocate_plt_object(obj, rela, addrp, dodebug) /* Fully resolve procedure addresses now */ - if (!obj->mainprog) { + if (obj->isdynamic) { /* Just relocate the GOT slots pointing into the PLT */ new_value = *where + (Elf_Addr)(obj->relocbase); rdbg(dodebug, ("fixup !main in %s --> %p", obj->path, diff --git a/libexec/ld.elf_so/arch/powerpc/ppc_reloc.c b/libexec/ld.elf_so/arch/powerpc/ppc_reloc.c index 3546c7a4b49..3c4db8c15ed 100644 --- a/libexec/ld.elf_so/arch/powerpc/ppc_reloc.c +++ b/libexec/ld.elf_so/arch/powerpc/ppc_reloc.c @@ -1,4 +1,4 @@ -/* $NetBSD: ppc_reloc.c,v 1.19 2002/09/06 12:00:41 mycroft Exp $ */ +/* $NetBSD: ppc_reloc.c,v 1.20 2002/09/06 13:20:33 mycroft Exp $ */ /*- * Copyright (C) 1998 Tsubai Masanari @@ -207,7 +207,7 @@ _rtld_relocate_nonplt_objects(obj, dodebug) * COPY relocation is not in a shared library. They * are allowed only in executable files. */ - if (!obj->mainprog) { + if (obj->isdynamic) { _rtld_error( "%s: Unexpected R_COPY relocation in shared library", obj->path); diff --git a/libexec/ld.elf_so/arch/sh3/mdreloc.c b/libexec/ld.elf_so/arch/sh3/mdreloc.c index 68e01cfb2dc..ff0745aa90f 100644 --- a/libexec/ld.elf_so/arch/sh3/mdreloc.c +++ b/libexec/ld.elf_so/arch/sh3/mdreloc.c @@ -102,7 +102,7 @@ _rtld_relocate_nonplt_objects(obj, dodebug) * COPY relocation is not in a shared library. They * are allowed only in executable files. */ - if (!obj->mainprog) { + if (obj->isdynamic) { _rtld_error( "%s: Unexpected R_COPY relocation in shared library", obj->path); @@ -134,7 +134,7 @@ _rtld_relocate_plt_lazy(obj, dodebug) { const Elf_Rela *rela; - if (obj->mainprog) + if (!obj->isdynamic) return 0; for (rela = obj->pltrela; rela < obj->pltrelalim; rela++) { diff --git a/libexec/ld.elf_so/arch/vax/mdreloc.c b/libexec/ld.elf_so/arch/vax/mdreloc.c index 44cfc0cd24e..09914f13e7f 100644 --- a/libexec/ld.elf_so/arch/vax/mdreloc.c +++ b/libexec/ld.elf_so/arch/vax/mdreloc.c @@ -63,7 +63,7 @@ _rtld_relocate_nonplt_objects(obj, dodebug) * COPY relocation is not in a shared library. They * are allowed only in executable files. */ - if (!obj->mainprog) { + if (obj->isdynamic) { _rtld_error( "%s: Unexpected R_COPY relocation in shared library", obj->path); @@ -95,7 +95,7 @@ _rtld_relocate_plt_lazy(obj, dodebug) { const Elf_Rela *rela; - if (obj->mainprog) + if (!obj->isdynamic) return 0; for (rela = obj->pltrela; rela < obj->pltrelalim; rela++) { diff --git a/libexec/ld.elf_so/arch/x86_64/mdreloc.c b/libexec/ld.elf_so/arch/x86_64/mdreloc.c index a429d038d00..0c73d76c8d8 100644 --- a/libexec/ld.elf_so/arch/x86_64/mdreloc.c +++ b/libexec/ld.elf_so/arch/x86_64/mdreloc.c @@ -1,4 +1,4 @@ -/* $NetBSD: mdreloc.c,v 1.13 2002/09/06 03:12:08 mycroft Exp $ */ +/* $NetBSD: mdreloc.c,v 1.14 2002/09/06 13:20:35 mycroft Exp $ */ /* * Copyright (c) 2001 Wasabi Systems, Inc. @@ -202,7 +202,7 @@ _rtld_relocate_plt_lazy(obj, dodebug) { const Elf_Rela *rela; - if (obj->mainprog) + if (!obj->isdynamic) return 0; for (rela = obj->pltrela; rela < obj->pltrelalim; rela++) { diff --git a/libexec/ld.elf_so/map_object.c b/libexec/ld.elf_so/map_object.c index 3b488bb183a..3e3e571a15c 100644 --- a/libexec/ld.elf_so/map_object.c +++ b/libexec/ld.elf_so/map_object.c @@ -1,4 +1,4 @@ -/* $NetBSD: map_object.c,v 1.13 2002/06/01 23:50:53 lukem Exp $ */ +/* $NetBSD: map_object.c,v 1.14 2002/09/06 13:20:29 mycroft Exp $ */ /* * Copyright 1996 John D. Polstra. @@ -273,6 +273,7 @@ _rtld_map_object(path, fd, sb) } if (phinterp != NULL) obj->interp = (const char *) (obj->relocbase + phinterp->p_vaddr); + obj->isdynamic = u.hdr.e_type == ET_DYN; return obj; } diff --git a/libexec/ld.elf_so/reloc.c b/libexec/ld.elf_so/reloc.c index 5e2ca7145b7..d8514e3c0cb 100644 --- a/libexec/ld.elf_so/reloc.c +++ b/libexec/ld.elf_so/reloc.c @@ -1,4 +1,4 @@ -/* $NetBSD: reloc.c,v 1.63 2002/09/06 12:00:40 mycroft Exp $ */ +/* $NetBSD: reloc.c,v 1.64 2002/09/06 13:20:30 mycroft Exp $ */ /* * Copyright 1996 John D. Polstra. @@ -115,7 +115,7 @@ _rtld_do_copy_relocations(dstobj, dodebug) #ifndef RTLD_INHIBIT_COPY_RELOCS /* COPY relocations are invalid elsewhere */ - assert(dstobj->mainprog); + assert(!dstobj->isdynamic); if (dstobj->rel != NULL) { const Elf_Rel *rel; diff --git a/libexec/ld.elf_so/rtld.h b/libexec/ld.elf_so/rtld.h index 327aa932754..a62a287d80b 100644 --- a/libexec/ld.elf_so/rtld.h +++ b/libexec/ld.elf_so/rtld.h @@ -1,4 +1,4 @@ -/* $NetBSD: rtld.h,v 1.43 2002/09/06 12:00:40 mycroft Exp $ */ +/* $NetBSD: rtld.h,v 1.44 2002/09/06 13:20:30 mycroft Exp $ */ /* * Copyright 1996 John D. Polstra. @@ -203,7 +203,8 @@ typedef struct Struct_Obj_Entry { * text seg */ symbolic:1, /* True if generated with * "-Bsymbolic" */ - printed:1; /* True if ldd has printed it */ + printed:1, /* True if ldd has printed it */ + isdynamic:1; /* True if this is a pure PIC object */ struct link_map linkmap; /* for GDB */ |
