Add external symbol for __PROCEDURE_LINKAGE_TABLE_. Modify arguments
to md_make_gotreloc for VAX'es sake.
This commit is contained in:
parent
df94d3f4f5
commit
4da3f7cfd8
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: md.c,v 1.5 1998/08/05 04:25:03 mycroft Exp $ */
|
||||
/* $NetBSD: md.c,v 1.6 1998/08/26 14:37:40 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1997 Mark Brinicombe
|
||||
@ -293,9 +293,10 @@ int type;
|
||||
* Set relocation type for a RRS GOT relocation.
|
||||
*/
|
||||
void
|
||||
md_make_gotreloc(rp, r, type)
|
||||
md_make_gotreloc(rp, r, type, gotp)
|
||||
struct relocation_info *rp, *r;
|
||||
int type;
|
||||
got_t *gotp;
|
||||
{
|
||||
r->r_pcrel = 0;
|
||||
r->r_length = 2;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: md.c,v 1.13 1998/07/27 07:48:21 mycroft Exp $ */
|
||||
/* $NetBSD: md.c,v 1.14 1998/08/26 14:37:40 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993 Paul Kranenburg
|
||||
@ -197,9 +197,10 @@ int type;
|
||||
* Set relocation type for a RRS GOT relocation.
|
||||
*/
|
||||
void
|
||||
md_make_gotreloc(rp, r, type)
|
||||
md_make_gotreloc(rp, r, type, gotp)
|
||||
struct relocation_info *rp, *r;
|
||||
int type;
|
||||
got_t *gotp;
|
||||
{
|
||||
r->r_baserel = 1;
|
||||
if (type & RELTYPE_RELATIVE)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: md.c,v 1.8 1998/01/05 22:00:39 cgd Exp $ */
|
||||
/* $NetBSD: md.c,v 1.9 1998/08/26 14:37:40 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993 Paul Kranenburg
|
||||
@ -195,9 +195,10 @@ int type;
|
||||
* Set relocation type for a RRS GOT relocation.
|
||||
*/
|
||||
void
|
||||
md_make_gotreloc(rp, r, type)
|
||||
md_make_gotreloc(rp, r, type, gotp)
|
||||
struct relocation_info *rp, *r;
|
||||
int type;
|
||||
got_t *gotp;
|
||||
{
|
||||
r->r_baserel = 1;
|
||||
if (type & RELTYPE_RELATIVE)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: md.c,v 1.7 1998/01/05 22:00:42 cgd Exp $ */
|
||||
/* $NetBSD: md.c,v 1.8 1998/08/26 14:37:40 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993 Paul Kranenburg
|
||||
@ -360,9 +360,10 @@ int type;
|
||||
* Set relocation type for a RRS GOT relocation.
|
||||
*/
|
||||
void
|
||||
md_make_gotreloc(rp, r, type)
|
||||
md_make_gotreloc(rp, r, type, gotp)
|
||||
struct relocation_info *rp, *r;
|
||||
int type;
|
||||
got_t *gotp;
|
||||
{
|
||||
r->r_baserel = 1;
|
||||
if (type & RELTYPE_RELATIVE)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: md.c,v 1.1 1996/11/03 18:06:50 ws Exp $ */
|
||||
/* $NetBSD: md.c,v 1.2 1998/08/26 14:37:41 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993 Paul Kranenburg
|
||||
@ -195,9 +195,10 @@ md_make_jmpreloc(rp, r, type)
|
||||
* Set relocation type for a RRS GOT relocation.
|
||||
*/
|
||||
void
|
||||
md_make_gotreloc(rp, r, type)
|
||||
md_make_gotreloc(rp, r, type, gotp)
|
||||
struct relocation_info *rp, *r;
|
||||
int type;
|
||||
got_t *gotp;
|
||||
{
|
||||
errx(1, "md_make_gotreloc unimplemented");
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: md.c,v 1.14 1998/01/05 22:00:45 cgd Exp $ */
|
||||
/* $NetBSD: md.c,v 1.15 1998/08/26 14:37:41 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993 Paul Kranenburg
|
||||
@ -266,9 +266,10 @@ md_make_jmpreloc(rp, r, type)
|
||||
* Set relocation type for a GOT RRS relocation.
|
||||
*/
|
||||
void
|
||||
md_make_gotreloc(rp, r, type)
|
||||
md_make_gotreloc(rp, r, type, gotp)
|
||||
struct relocation_info *rp, *r;
|
||||
int type;
|
||||
got_t *gotp;
|
||||
{
|
||||
/*
|
||||
* GOT value resolved (symbolic or entry point): R_32
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: md.c,v 1.6 1998/08/21 01:03:48 matt Exp $ */
|
||||
/* $NetBSD: md.c,v 1.7 1998/08/26 14:37:41 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993 Paul Kranenburg
|
||||
@ -75,6 +75,12 @@ long relocation;
|
||||
unsigned char *addr;
|
||||
int relocatable_output;
|
||||
{
|
||||
/*
|
||||
*
|
||||
*/
|
||||
if (rp->r_baserel && rp->r_pcrel && !relocatable_output)
|
||||
relocation += got_symbol->value - (rp->r_address + 4);
|
||||
|
||||
switch (RELOC_TARGET_SIZE(rp)) {
|
||||
case 0:
|
||||
put_byte(addr, relocation);
|
||||
@ -129,12 +135,19 @@ long index;
|
||||
* On VAX a branch offset given in immediate mode is relative to
|
||||
* the end of the address itself.
|
||||
*/
|
||||
u_long fudge = - (offsetof(jmpslot_t, reloc_index) + offset);
|
||||
u_long fudge = -(offset + 8 - 2 /* skip mask */);
|
||||
|
||||
sp->mask = 0; /* save no registers */
|
||||
sp->opcode = JSB_PCREL;
|
||||
sp->offset[0] = fudge & 0xffff;
|
||||
sp->offset[1] = fudge >> 16;
|
||||
if (offset == 0) {
|
||||
sp->mask = 0x0101; /* NOP NOP */
|
||||
} else {
|
||||
sp->mask - 0x0000;
|
||||
}
|
||||
sp->insn[0] = 0x16; /* jsb */
|
||||
sp->insn[1] = 0xef; /* L^(pc) */
|
||||
sp->insn[2] = (fudge >> 0) & 0xff;
|
||||
sp->insn[3] = (fudge >> 8) & 0xff;
|
||||
sp->insn[4] = (fudge >> 16) & 0xff;
|
||||
sp->insn[5] = (fudge >> 24) & 0xff;
|
||||
sp->reloc_index = index;
|
||||
}
|
||||
|
||||
@ -142,7 +155,7 @@ long index;
|
||||
* Set up a "direct" transfer (ie. not through the run-time binder) from
|
||||
* jmpslot at OFFSET to ADDR. Used by `ld' when the SYMBOLIC flag is on,
|
||||
* and by `ld.so' after resolving the symbol.
|
||||
* On the VAX, we use the JMP instruction which is PC relative, so no
|
||||
* On the VAX, we use a PC relative JMP instruction, so no
|
||||
* further RRS relocations will be necessary for such a jmpslot.
|
||||
*/
|
||||
void
|
||||
@ -151,15 +164,22 @@ jmpslot_t *sp;
|
||||
long offset;
|
||||
u_long addr;
|
||||
{
|
||||
u_long fudge = addr - (offsetof(jmpslot_t, reloc_index) + offset);
|
||||
u_long fudge = addr - (offset + 9);
|
||||
|
||||
sp->mask = *(u_short *) addr; /* store the procedure entry mask */
|
||||
sp->opcode = JMP_PCREL; /* jmp to procedure + 2 */
|
||||
sp->offset[0] = (fudge + 2) & 0xffff; /* skipping entry mask */
|
||||
sp->offset[1] = (fudge + 2) >> 16;
|
||||
#if 0
|
||||
sp->reloc_index = 0;
|
||||
#endif
|
||||
if (offset == 0) {
|
||||
sp->mask = 0x0101; /* NOP NOP */
|
||||
sp->insn[0] = 0x01; /* nop */
|
||||
sp->insn[1] = 0x17; /* jmp */
|
||||
} else {
|
||||
sp->mask - 0x0000;
|
||||
sp->insn[0] = 0xfa; /* callg */
|
||||
sp->insn[1] = 0x6c; /* (ap) */
|
||||
}
|
||||
sp->insn[2] = 0xef; /* L^(pc) */
|
||||
sp->insn[2] = (fudge >> 0) & 0xff;
|
||||
sp->insn[3] = (fudge >> 8) & 0xff;
|
||||
sp->insn[4] = (fudge >> 16) & 0xff;
|
||||
sp->insn[5] = (fudge >> 24) & 0xff;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -185,17 +205,28 @@ int type;
|
||||
r->r_jmptable = 1;
|
||||
if (type & RELTYPE_RELATIVE)
|
||||
r->r_relative = 1;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Set relocation type for a RRS GOT relocation.
|
||||
*/
|
||||
void
|
||||
md_make_gotreloc(rp, r, type)
|
||||
md_make_gotreloc(rp, r, type, gotp)
|
||||
struct relocation_info *rp, *r;
|
||||
int type;
|
||||
got_t *gotp;
|
||||
{
|
||||
/*
|
||||
* this is a fixup from text space.
|
||||
* consider that addend is really -pc_offset + addend.
|
||||
* so remove -pc_offset from addend (which is stored in
|
||||
* the got).
|
||||
* movl l^datum+4, r0 --> movl @_datum@GOT, r0
|
||||
* _datum@GOT: .long 4
|
||||
*/
|
||||
if (rp->r_baserel && rp->r_pcrel)
|
||||
*gotp += (rp->r_address + 4);
|
||||
|
||||
r->r_baserel = 1;
|
||||
if (type & RELTYPE_RELATIVE)
|
||||
r->r_relative = 1;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: md.h,v 1.4 1998/08/21 01:03:48 matt Exp $ */
|
||||
/* $NetBSD: md.h,v 1.5 1998/08/26 14:37:41 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993 Paul Kranenburg
|
||||
@ -87,14 +87,15 @@
|
||||
|
||||
#define RELOC_STATICS_THROUGH_GOT_P(r) (1)
|
||||
#define JMPSLOT_NEEDS_RELOC (1)
|
||||
#define JMPSLOT_NEEDS_GOT (1)
|
||||
|
||||
#define md_got_reloc(r) (0)
|
||||
|
||||
#define md_get_rt_segment_addend(r,a) md_get_addend(r,a)
|
||||
|
||||
/* Width of a Global Offset Table entry */
|
||||
#define GOT_ENTRY_SIZE 4
|
||||
typedef long got_t;
|
||||
#define GOT_ENTRY_SIZE 4
|
||||
typedef int32_t got_t;
|
||||
|
||||
/*
|
||||
* .word ^M<reg-mask>
|
||||
@ -102,20 +103,14 @@ typedef long got_t;
|
||||
*/
|
||||
typedef struct jmpslot {
|
||||
u_short mask;
|
||||
u_short opcode;
|
||||
u_short offset[2];
|
||||
#define JMPSLOT_RELOC_MASK 0xffff
|
||||
u_short addr[2];
|
||||
u_char insn[8];
|
||||
u_short reloc_index;
|
||||
u_short filler;
|
||||
} jmpslot_t;
|
||||
|
||||
/*
|
||||
* following defines are untested since VAX doesn't support PIC (yet?)
|
||||
*/
|
||||
#define JSB_PCREL 0x8F16 /* JSB + immediate mode for displacement */
|
||||
#define JMP_PCREL 0x8F17 /* JMP + immediate mode for displacement */
|
||||
#define TRAP 0x00BC /* how to trap ??? CHMK ??? */
|
||||
#define BPT 0x0003 /* Set a breakpoint */
|
||||
|
||||
/*
|
||||
* Byte swap defs for cross linking
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ld.h,v 1.20 1998/01/05 22:00:53 cgd Exp $ */
|
||||
/* $NetBSD: ld.h,v 1.21 1998/08/26 14:37:41 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* This code is derived from software copyrighted by the Free Software
|
||||
@ -467,6 +467,7 @@ extern symbol *edata_symbol; /* the symbol _edata */
|
||||
extern symbol *etext_symbol; /* the symbol _etext */
|
||||
extern symbol *end_symbol; /* the symbol _end */
|
||||
extern symbol *got_symbol; /* the symbol __GLOBAL_OFFSET_TABLE_ */
|
||||
extern symbol *plt_symbol; /* the symbol __PROCEDURE_LINKAGE_TABLE_ */
|
||||
extern symbol *dynamic_symbol; /* the symbol __DYNAMIC */
|
||||
|
||||
/*
|
||||
@ -688,7 +689,7 @@ void md_make_jmpslot __P((jmpslot_t *, long, long));
|
||||
void md_fix_jmpslot __P((jmpslot_t *, long, u_long));
|
||||
int md_make_reloc __P((struct relocation_info *, struct relocation_info *, int));
|
||||
void md_make_jmpreloc __P((struct relocation_info *, struct relocation_info *, int));
|
||||
void md_make_gotreloc __P((struct relocation_info *, struct relocation_info *, int));
|
||||
void md_make_gotreloc __P((struct relocation_info *, struct relocation_info *, int, got_t *));
|
||||
void md_make_copyreloc __P((struct relocation_info *, struct relocation_info *));
|
||||
void md_set_breakpoint __P((long, long *));
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ld.c,v 1.54 1998/08/13 07:34:05 mycroft Exp $ */
|
||||
/* $NetBSD: ld.c,v 1.55 1998/08/26 14:37:41 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* This code is derived from software copyrighted by the Free Software
|
||||
@ -1509,7 +1509,7 @@ enter_global_ref(lsp, name, entry)
|
||||
|
||||
sp->flags |= GS_REFERENCED;
|
||||
|
||||
if (sp == dynamic_symbol || sp == got_symbol) {
|
||||
if (sp == dynamic_symbol || sp == got_symbol || sp == plt_symbol) {
|
||||
if (type != (N_UNDF | N_EXT) && !(entry->flags & E_JUST_SYMS))
|
||||
errx(1,"Linker reserved symbol %s defined as type %x ",
|
||||
name, type);
|
||||
@ -1840,6 +1840,9 @@ printf("set_sect_start = %#x, set_sect_size = %#x\n",
|
||||
if (got_symbol->flags & GS_REFERENCED)
|
||||
global_sym_count++;
|
||||
|
||||
if (plt_symbol->flags & GS_REFERENCED)
|
||||
global_sym_count++;
|
||||
|
||||
if (relocatable_output || building_shared_object) {
|
||||
/* For each alias we write out two struct nlists */
|
||||
global_sym_count += global_alias_count;
|
||||
@ -1906,7 +1909,7 @@ digest_pass1()
|
||||
/* Already examined; must have been an alias */
|
||||
continue;
|
||||
|
||||
if (sp == got_symbol || sp == dynamic_symbol)
|
||||
if (sp == got_symbol || sp == dynamic_symbol || sp == plt_symbol)
|
||||
continue;
|
||||
|
||||
for (lsp = sp->refs; lsp; lsp = lsp->next) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: rrs.c,v 1.20 1998/08/13 07:34:06 mycroft Exp $ */
|
||||
/* $NetBSD: rrs.c,v 1.21 1998/08/26 14:37:42 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993 Paul Kranenburg
|
||||
@ -497,7 +497,7 @@ printf("claim_rrs_gotslot: %s(%d,%#x) slot offset %#x, addend %#x\n",
|
||||
r->r_address = got_symbol->value + sp->gotslot_offset;
|
||||
RELOC_SYMBOL(r) = sp->rrs_symbolnum;
|
||||
RELOC_EXTERN_P(r) = !(reloc_type == RELTYPE_RELATIVE);
|
||||
md_make_gotreloc(rp, r, reloc_type);
|
||||
md_make_gotreloc(rp, r, reloc_type, GOTP(sp->gotslot_offset));
|
||||
|
||||
return sp->gotslot_offset;
|
||||
}
|
||||
@ -565,7 +565,7 @@ printf("claim_rrs_internal_gotslot: %s: slot offset %#x, addend = %#x\n",
|
||||
r = rrs_next_reloc();
|
||||
r->r_address = got_symbol->value + lsp->gotslot_offset;
|
||||
RELOC_EXTERN_P(r) = 0;
|
||||
md_make_gotreloc(rp, r, RELTYPE_RELATIVE);
|
||||
md_make_gotreloc(rp, r, RELTYPE_RELATIVE, GOTP(lsp->gotslot_offset));
|
||||
return lsp->gotslot_offset;
|
||||
}
|
||||
|
||||
@ -725,6 +725,9 @@ consider_rrs_section_lengths()
|
||||
if (number_of_gotslots > 1)
|
||||
got_symbol->flags |= GS_REFERENCED;
|
||||
|
||||
if (number_of_jmpslots > 1)
|
||||
plt_symbol->flags |= GS_REFERENCED;
|
||||
|
||||
|
||||
/* Next, allocate relocs, got and plt */
|
||||
n = reserved_rrs_relocs * sizeof(struct relocation_info);
|
||||
@ -880,6 +883,7 @@ relocate_rrs_addresses()
|
||||
got_symbol->value = rrs_sdt.sdt_got + got_origin;
|
||||
rrs_sdt.sdt_plt = rrs_sdt.sdt_got +
|
||||
number_of_gotslots * sizeof(got_t);
|
||||
got_symbol->value = rrs_sdt.sdt_plt;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -932,6 +936,7 @@ relocate_rrs_addresses()
|
||||
* The value `&__DYNAMIC' is in the GOT table at offset 0.
|
||||
*/
|
||||
got_symbol->value = rrs_sdt.sdt_got + got_origin;
|
||||
plt_symbol->value = rrs_sdt.sdt_plt;
|
||||
*GOTP(0) = dynamic_symbol->value = rrs_data_start;
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: md.c,v 1.5 1998/08/05 04:25:03 mycroft Exp $ */
|
||||
/* $NetBSD: md.c,v 1.6 1998/08/26 14:37:40 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1997 Mark Brinicombe
|
||||
@ -293,9 +293,10 @@ int type;
|
||||
* Set relocation type for a RRS GOT relocation.
|
||||
*/
|
||||
void
|
||||
md_make_gotreloc(rp, r, type)
|
||||
md_make_gotreloc(rp, r, type, gotp)
|
||||
struct relocation_info *rp, *r;
|
||||
int type;
|
||||
got_t *gotp;
|
||||
{
|
||||
r->r_pcrel = 0;
|
||||
r->r_length = 2;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: md.c,v 1.13 1998/07/27 07:48:21 mycroft Exp $ */
|
||||
/* $NetBSD: md.c,v 1.14 1998/08/26 14:37:40 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993 Paul Kranenburg
|
||||
@ -197,9 +197,10 @@ int type;
|
||||
* Set relocation type for a RRS GOT relocation.
|
||||
*/
|
||||
void
|
||||
md_make_gotreloc(rp, r, type)
|
||||
md_make_gotreloc(rp, r, type, gotp)
|
||||
struct relocation_info *rp, *r;
|
||||
int type;
|
||||
got_t *gotp;
|
||||
{
|
||||
r->r_baserel = 1;
|
||||
if (type & RELTYPE_RELATIVE)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: md.c,v 1.8 1998/01/05 22:00:39 cgd Exp $ */
|
||||
/* $NetBSD: md.c,v 1.9 1998/08/26 14:37:40 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993 Paul Kranenburg
|
||||
@ -195,9 +195,10 @@ int type;
|
||||
* Set relocation type for a RRS GOT relocation.
|
||||
*/
|
||||
void
|
||||
md_make_gotreloc(rp, r, type)
|
||||
md_make_gotreloc(rp, r, type, gotp)
|
||||
struct relocation_info *rp, *r;
|
||||
int type;
|
||||
got_t *gotp;
|
||||
{
|
||||
r->r_baserel = 1;
|
||||
if (type & RELTYPE_RELATIVE)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: md.c,v 1.7 1998/01/05 22:00:42 cgd Exp $ */
|
||||
/* $NetBSD: md.c,v 1.8 1998/08/26 14:37:40 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993 Paul Kranenburg
|
||||
@ -360,9 +360,10 @@ int type;
|
||||
* Set relocation type for a RRS GOT relocation.
|
||||
*/
|
||||
void
|
||||
md_make_gotreloc(rp, r, type)
|
||||
md_make_gotreloc(rp, r, type, gotp)
|
||||
struct relocation_info *rp, *r;
|
||||
int type;
|
||||
got_t *gotp;
|
||||
{
|
||||
r->r_baserel = 1;
|
||||
if (type & RELTYPE_RELATIVE)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: md.c,v 1.1 1996/11/03 18:06:50 ws Exp $ */
|
||||
/* $NetBSD: md.c,v 1.2 1998/08/26 14:37:41 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993 Paul Kranenburg
|
||||
@ -195,9 +195,10 @@ md_make_jmpreloc(rp, r, type)
|
||||
* Set relocation type for a RRS GOT relocation.
|
||||
*/
|
||||
void
|
||||
md_make_gotreloc(rp, r, type)
|
||||
md_make_gotreloc(rp, r, type, gotp)
|
||||
struct relocation_info *rp, *r;
|
||||
int type;
|
||||
got_t *gotp;
|
||||
{
|
||||
errx(1, "md_make_gotreloc unimplemented");
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: md.c,v 1.14 1998/01/05 22:00:45 cgd Exp $ */
|
||||
/* $NetBSD: md.c,v 1.15 1998/08/26 14:37:41 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993 Paul Kranenburg
|
||||
@ -266,9 +266,10 @@ md_make_jmpreloc(rp, r, type)
|
||||
* Set relocation type for a GOT RRS relocation.
|
||||
*/
|
||||
void
|
||||
md_make_gotreloc(rp, r, type)
|
||||
md_make_gotreloc(rp, r, type, gotp)
|
||||
struct relocation_info *rp, *r;
|
||||
int type;
|
||||
got_t *gotp;
|
||||
{
|
||||
/*
|
||||
* GOT value resolved (symbolic or entry point): R_32
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: md.c,v 1.6 1998/08/21 01:03:48 matt Exp $ */
|
||||
/* $NetBSD: md.c,v 1.7 1998/08/26 14:37:41 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993 Paul Kranenburg
|
||||
@ -75,6 +75,12 @@ long relocation;
|
||||
unsigned char *addr;
|
||||
int relocatable_output;
|
||||
{
|
||||
/*
|
||||
*
|
||||
*/
|
||||
if (rp->r_baserel && rp->r_pcrel && !relocatable_output)
|
||||
relocation += got_symbol->value - (rp->r_address + 4);
|
||||
|
||||
switch (RELOC_TARGET_SIZE(rp)) {
|
||||
case 0:
|
||||
put_byte(addr, relocation);
|
||||
@ -129,12 +135,19 @@ long index;
|
||||
* On VAX a branch offset given in immediate mode is relative to
|
||||
* the end of the address itself.
|
||||
*/
|
||||
u_long fudge = - (offsetof(jmpslot_t, reloc_index) + offset);
|
||||
u_long fudge = -(offset + 8 - 2 /* skip mask */);
|
||||
|
||||
sp->mask = 0; /* save no registers */
|
||||
sp->opcode = JSB_PCREL;
|
||||
sp->offset[0] = fudge & 0xffff;
|
||||
sp->offset[1] = fudge >> 16;
|
||||
if (offset == 0) {
|
||||
sp->mask = 0x0101; /* NOP NOP */
|
||||
} else {
|
||||
sp->mask - 0x0000;
|
||||
}
|
||||
sp->insn[0] = 0x16; /* jsb */
|
||||
sp->insn[1] = 0xef; /* L^(pc) */
|
||||
sp->insn[2] = (fudge >> 0) & 0xff;
|
||||
sp->insn[3] = (fudge >> 8) & 0xff;
|
||||
sp->insn[4] = (fudge >> 16) & 0xff;
|
||||
sp->insn[5] = (fudge >> 24) & 0xff;
|
||||
sp->reloc_index = index;
|
||||
}
|
||||
|
||||
@ -142,7 +155,7 @@ long index;
|
||||
* Set up a "direct" transfer (ie. not through the run-time binder) from
|
||||
* jmpslot at OFFSET to ADDR. Used by `ld' when the SYMBOLIC flag is on,
|
||||
* and by `ld.so' after resolving the symbol.
|
||||
* On the VAX, we use the JMP instruction which is PC relative, so no
|
||||
* On the VAX, we use a PC relative JMP instruction, so no
|
||||
* further RRS relocations will be necessary for such a jmpslot.
|
||||
*/
|
||||
void
|
||||
@ -151,15 +164,22 @@ jmpslot_t *sp;
|
||||
long offset;
|
||||
u_long addr;
|
||||
{
|
||||
u_long fudge = addr - (offsetof(jmpslot_t, reloc_index) + offset);
|
||||
u_long fudge = addr - (offset + 9);
|
||||
|
||||
sp->mask = *(u_short *) addr; /* store the procedure entry mask */
|
||||
sp->opcode = JMP_PCREL; /* jmp to procedure + 2 */
|
||||
sp->offset[0] = (fudge + 2) & 0xffff; /* skipping entry mask */
|
||||
sp->offset[1] = (fudge + 2) >> 16;
|
||||
#if 0
|
||||
sp->reloc_index = 0;
|
||||
#endif
|
||||
if (offset == 0) {
|
||||
sp->mask = 0x0101; /* NOP NOP */
|
||||
sp->insn[0] = 0x01; /* nop */
|
||||
sp->insn[1] = 0x17; /* jmp */
|
||||
} else {
|
||||
sp->mask - 0x0000;
|
||||
sp->insn[0] = 0xfa; /* callg */
|
||||
sp->insn[1] = 0x6c; /* (ap) */
|
||||
}
|
||||
sp->insn[2] = 0xef; /* L^(pc) */
|
||||
sp->insn[2] = (fudge >> 0) & 0xff;
|
||||
sp->insn[3] = (fudge >> 8) & 0xff;
|
||||
sp->insn[4] = (fudge >> 16) & 0xff;
|
||||
sp->insn[5] = (fudge >> 24) & 0xff;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -185,17 +205,28 @@ int type;
|
||||
r->r_jmptable = 1;
|
||||
if (type & RELTYPE_RELATIVE)
|
||||
r->r_relative = 1;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Set relocation type for a RRS GOT relocation.
|
||||
*/
|
||||
void
|
||||
md_make_gotreloc(rp, r, type)
|
||||
md_make_gotreloc(rp, r, type, gotp)
|
||||
struct relocation_info *rp, *r;
|
||||
int type;
|
||||
got_t *gotp;
|
||||
{
|
||||
/*
|
||||
* this is a fixup from text space.
|
||||
* consider that addend is really -pc_offset + addend.
|
||||
* so remove -pc_offset from addend (which is stored in
|
||||
* the got).
|
||||
* movl l^datum+4, r0 --> movl @_datum@GOT, r0
|
||||
* _datum@GOT: .long 4
|
||||
*/
|
||||
if (rp->r_baserel && rp->r_pcrel)
|
||||
*gotp += (rp->r_address + 4);
|
||||
|
||||
r->r_baserel = 1;
|
||||
if (type & RELTYPE_RELATIVE)
|
||||
r->r_relative = 1;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: md.h,v 1.4 1998/08/21 01:03:48 matt Exp $ */
|
||||
/* $NetBSD: md.h,v 1.5 1998/08/26 14:37:41 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993 Paul Kranenburg
|
||||
@ -87,14 +87,15 @@
|
||||
|
||||
#define RELOC_STATICS_THROUGH_GOT_P(r) (1)
|
||||
#define JMPSLOT_NEEDS_RELOC (1)
|
||||
#define JMPSLOT_NEEDS_GOT (1)
|
||||
|
||||
#define md_got_reloc(r) (0)
|
||||
|
||||
#define md_get_rt_segment_addend(r,a) md_get_addend(r,a)
|
||||
|
||||
/* Width of a Global Offset Table entry */
|
||||
#define GOT_ENTRY_SIZE 4
|
||||
typedef long got_t;
|
||||
#define GOT_ENTRY_SIZE 4
|
||||
typedef int32_t got_t;
|
||||
|
||||
/*
|
||||
* .word ^M<reg-mask>
|
||||
@ -102,20 +103,14 @@ typedef long got_t;
|
||||
*/
|
||||
typedef struct jmpslot {
|
||||
u_short mask;
|
||||
u_short opcode;
|
||||
u_short offset[2];
|
||||
#define JMPSLOT_RELOC_MASK 0xffff
|
||||
u_short addr[2];
|
||||
u_char insn[8];
|
||||
u_short reloc_index;
|
||||
u_short filler;
|
||||
} jmpslot_t;
|
||||
|
||||
/*
|
||||
* following defines are untested since VAX doesn't support PIC (yet?)
|
||||
*/
|
||||
#define JSB_PCREL 0x8F16 /* JSB + immediate mode for displacement */
|
||||
#define JMP_PCREL 0x8F17 /* JMP + immediate mode for displacement */
|
||||
#define TRAP 0x00BC /* how to trap ??? CHMK ??? */
|
||||
#define BPT 0x0003 /* Set a breakpoint */
|
||||
|
||||
/*
|
||||
* Byte swap defs for cross linking
|
||||
|
Loading…
Reference in New Issue
Block a user