diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1995-12-30 08:13:59 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1995-12-30 08:13:59 +0000 |
commit | ddc76b57bb0c7f468cf3ad262f525f689f085edb (patch) | |
tree | d8e3a430711090f7e54ca31a28d377ab9c3706c9 /gnu | |
parent | 4c46e0a04250f144ff46485011251bd2e1800e35 (diff) |
from netbsd:
Simplify update of r_addend field in relocation record if `-r' is on.
The old quirky code did strange things.
Diffstat (limited to 'gnu')
-rw-r--r-- | gnu/usr.bin/ld/ld.c | 21 | ||||
-rw-r--r-- | gnu/usr.bin/ld/sparc/md.c | 74 |
2 files changed, 34 insertions, 61 deletions
diff --git a/gnu/usr.bin/ld/ld.c b/gnu/usr.bin/ld/ld.c index ea4e5f2a23e..be17bcb6314 100644 --- a/gnu/usr.bin/ld/ld.c +++ b/gnu/usr.bin/ld/ld.c @@ -32,7 +32,7 @@ static char sccsid[] = "@(#)ld.c 6.10 (Berkeley) 5/22/91"; Set, indirect, and warning symbol features added by Randy Smith. */ /* - * $Id: ld.c,v 1.1 1995/10/18 08:40:55 deraadt Exp $ + * $Id: ld.c,v 1.2 1995/12/30 08:13:47 deraadt Exp $ */ /* Define how to initialize system-dependent header fields. */ @@ -2734,7 +2734,6 @@ copy_data(entry) * relocation info, in core. NRELOC says how many there are. */ -/* HACK: md.c may need access to this */ int pc_relocation; void @@ -2754,9 +2753,9 @@ perform_relocation(data, data_size, reloc, nreloc, entry, dataseg) int data_relocation = entry->data_start_address - entry->header.a_text; int bss_relocation = entry->bss_start_address - entry->header.a_text - entry->header.a_data; - pc_relocation = dataseg? - entry->data_start_address - entry->header.a_text: - entry->text_start_address; + pc_relocation = dataseg + ? entry->data_start_address - entry->header.a_text + : entry->text_start_address; for (; r < end; r++) { int addr = RELOC_ADDRESS(r); @@ -3120,18 +3119,6 @@ coptxtrel(entry) RELOC_SYMBOL(r) = (sp->defined & N_TYPE); } else RELOC_SYMBOL(r) = sp->symbolnum; -#ifdef RELOC_ADD_EXTRA - /* - * If we aren't going to be adding in the - * value in memory on the next pass of the - * loader, then we need to add it in from the - * relocation entry, unless the symbol remains - * external in our output. Otherwise the work we - * did in this pass is lost. - */ - if (!RELOC_MEMORY_ADD_P(r) && !RELOC_EXTERN_P(r)) - RELOC_ADD_EXTRA(r) += sp->value; -#endif } else /* * Global symbols come first. diff --git a/gnu/usr.bin/ld/sparc/md.c b/gnu/usr.bin/ld/sparc/md.c index 39f03f68054..77ed9905236 100644 --- a/gnu/usr.bin/ld/sparc/md.c +++ b/gnu/usr.bin/ld/sparc/md.c @@ -27,7 +27,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: md.c,v 1.2 1995/12/14 03:40:55 deraadt Exp $ + * $Id: md.c,v 1.3 1995/12/30 08:13:58 deraadt Exp $ */ #include <sys/param.h> @@ -103,43 +103,29 @@ iflush(sp) */ long md_get_addend(r, addr) -struct relocation_info *r; -unsigned char *addr; + struct relocation_info *r; + unsigned char *addr; { return r->r_addend; } void md_relocate(r, relocation, addr, relocatable_output) -struct relocation_info *r; -long relocation; -unsigned char *addr; -int relocatable_output; + struct relocation_info *r; + long relocation; + unsigned char *addr; + int relocatable_output; { register unsigned long mask; -#ifndef RTLD if (relocatable_output) { /* - * Non-PC relative relocations which are absolute or - * which have become non-external now have fixed - * relocations. Set the ADD_EXTRA of this relocation - * to be the relocation we have now determined. + * Store relocation where the next link-edit run + * will look for it. */ - if (!RELOC_PCREL_P(r)) { - if ((int) r->r_type <= RELOC_32 - || RELOC_EXTERN_P(r) == 0) - RELOC_ADD_EXTRA(r) = relocation; - } else if (RELOC_EXTERN_P(r)) - /* - * External PC-relative relocations continue - * to move around; update their relocations - * by the amount they have moved so far. - */ - RELOC_ADD_EXTRA(r) -= pc_relocation; + r->r_addend = relocation; return; } -#endif relocation >>= RELOC_VALUE_RIGHTSHIFT(r); @@ -186,8 +172,8 @@ int relocatable_output; */ int md_make_reloc(rp, r, type) -struct relocation_info *rp, *r; -int type; + struct relocation_info *rp, *r; + int type; { r->r_type = rp->r_type; r->r_addend = rp->r_addend; @@ -218,9 +204,9 @@ int type; */ void md_make_jmpslot(sp, offset, index) -jmpslot_t *sp; -long offset; -long index; + jmpslot_t *sp; + long offset; + long index; { u_long fudge = (u_long) -(sizeof(sp->opcode1) + offset); sp->opcode1 = SAVE; @@ -241,9 +227,9 @@ long index; */ void md_fix_jmpslot(sp, offset, addr) -jmpslot_t *sp; -long offset; -u_long addr; + jmpslot_t *sp; + long offset; + u_long addr; { /* * Here comes a RELOC_{LO10,HI22} relocation pair @@ -263,8 +249,8 @@ u_long addr; */ void md_make_jmpreloc(rp, r, type) -struct relocation_info *rp, *r; -int type; + struct relocation_info *rp, *r; + int type; { if (type & RELTYPE_RELATIVE) r->r_type = RELOC_RELATIVE; @@ -279,8 +265,8 @@ int type; */ void md_make_gotreloc(rp, r, type) -struct relocation_info *rp, *r; -int type; + struct relocation_info *rp, *r; + int type; { /* * GOT value resolved (symbolic or entry point): R_32 @@ -301,7 +287,7 @@ int type; */ void md_make_cpyreloc(rp, r) -struct relocation_info *rp, *r; + struct relocation_info *rp, *r; { r->r_type = RELOC_COPY_DAT; r->r_addend = 0; @@ -309,8 +295,8 @@ struct relocation_info *rp, *r; void md_set_breakpoint(where, savep) -long where; -long *savep; + long where; + long *savep; { *savep = *(long *)where; *(long *)where = TRAP; @@ -323,10 +309,10 @@ long *savep; */ void md_init_header(hp, magic, flags) -struct exec *hp; -int magic, flags; + struct exec *hp; + int magic, flags; { -#ifdef NetBSD +#ifdef __NetBSD__ N_SETMAGIC((*hp), magic, MID_MACHINE, flags); /* TEXT_START depends on the value of outheader.a_entry. */ @@ -349,9 +335,9 @@ int magic, flags; */ int md_midcompat(hp) -struct exec *hp; + struct exec *hp; { -#ifdef NetBSD +#ifdef __NetBSD__ #define SUN_M_SPARC 3 return (((md_swap_long(hp->a_midmag)&0x00ff0000) >> 16) == SUN_M_SPARC); #else |