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...)
This commit is contained in:
mycroft 2002-09-06 13:20:29 +00:00
parent 77a6b82b27
commit 0df8d18100
13 changed files with 29 additions and 27 deletions

View File

@ -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++) {

View File

@ -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++) {

View File

@ -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);

View File

@ -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++) {

View File

@ -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++) {

View File

@ -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,

View File

@ -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);

View File

@ -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++) {

View File

@ -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++) {

View File

@ -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++) {

View File

@ -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;
}

View File

@ -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;

View File

@ -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 */