summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/ld/sparc/md.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1995-12-30 08:13:59 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1995-12-30 08:13:59 +0000
commitddc76b57bb0c7f468cf3ad262f525f689f085edb (patch)
treed8e3a430711090f7e54ca31a28d377ab9c3706c9 /gnu/usr.bin/ld/sparc/md.c
parent4c46e0a04250f144ff46485011251bd2e1800e35 (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/usr.bin/ld/sparc/md.c')
-rw-r--r--gnu/usr.bin/ld/sparc/md.c74
1 files changed, 30 insertions, 44 deletions
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