summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoritohy <itohy@NetBSD.org>1999-01-05 10:02:20 +0000
committeritohy <itohy@NetBSD.org>1999-01-05 10:02:20 +0000
commit85da239ef8ed87de75fa466e694b13bbd4c9639a (patch)
tree31f33b3e1d510a880867c876013ab0e9a3d9d2e1
parent56d26266a5e6adf28141dc6e39c329157d14895d (diff)
Fix byte order swapping for cross linker.
-rw-r--r--gnu/usr.bin/ld/ld/rrs.c4
-rw-r--r--gnu/usr.bin/ld/ld/xbits.c19
-rw-r--r--libexec/ld.aout_so/arch/m68k/md.c8
-rw-r--r--libexec/ld.aout_so/arch/m68k/md.h6
4 files changed, 15 insertions, 22 deletions
diff --git a/gnu/usr.bin/ld/ld/rrs.c b/gnu/usr.bin/ld/ld/rrs.c
index 51270810350..2089aa6e17d 100644
--- a/gnu/usr.bin/ld/ld/rrs.c
+++ b/gnu/usr.bin/ld/ld/rrs.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rrs.c,v 1.27 1998/12/17 14:34:51 pk Exp $ */
+/* $NetBSD: rrs.c,v 1.28 1999/01/05 10:02:20 itohy Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -1189,7 +1189,7 @@ write_rrs_text()
/* Write the symbol table */
if (rrs_symbol_size == sizeof(struct nlist))
- md_swapout_symbols(rrs_symbols, number_of_rrs_symbols);
+ md_swapout_symbols((struct nlist *) rrs_symbols, number_of_rrs_symbols);
else
md_swapout_zsymbols(rrs_symbols, number_of_rrs_symbols);
mywrite(rrs_symbols, symsize, 1, outstream);
diff --git a/gnu/usr.bin/ld/ld/xbits.c b/gnu/usr.bin/ld/ld/xbits.c
index 7cea2fbc6ed..ca824408351 100644
--- a/gnu/usr.bin/ld/ld/xbits.c
+++ b/gnu/usr.bin/ld/ld/xbits.c
@@ -1,4 +1,4 @@
-/* $NetBSD: xbits.c,v 1.7 1998/12/17 14:34:52 pk Exp $ */
+/* $NetBSD: xbits.c,v 1.8 1999/01/05 10:02:21 itohy Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -133,8 +133,10 @@ swapin_sod(sodp, n)
sodp->sod_major = md_swap_short(sodp->sod_major);
sodp->sod_minor = md_swap_short(sodp->sod_minor);
sodp->sod_next = md_swap_long(sodp->sod_next);
- bits = ((unsigned long *)sodp)[1];
- sodp->sod_library = ((bits >> 24) & 1);
+ /* swap sod_library flag */
+ bits = ((unsigned char *)sodp)[4];
+ ((u_int *)sodp)[1] = 0; /* clear reserved bits */
+ ((unsigned char *)sodp)[4] = ((bits & 1) << 7) | (bits>>7 & 1);
}
}
@@ -143,16 +145,7 @@ swapout_sod(sodp, n)
struct sod *sodp;
int n;
{
- unsigned long bits;
-
- for (; n; n--, sodp++) {
- sodp->sod_name = md_swap_long(sodp->sod_name);
- sodp->sod_major = md_swap_short(sodp->sod_major);
- sodp->sod_minor = md_swap_short(sodp->sod_minor);
- sodp->sod_next = md_swap_long(sodp->sod_next);
- bits = (unsigned long)(sodp->sod_library) << 24;
- ((unsigned long *)sodp)[1] = bits;
- }
+ swapin_sod(sodp, n);
}
void
diff --git a/libexec/ld.aout_so/arch/m68k/md.c b/libexec/ld.aout_so/arch/m68k/md.c
index 7b14d5b2c01..93cae324c8d 100644
--- a/libexec/ld.aout_so/arch/m68k/md.c
+++ b/libexec/ld.aout_so/arch/m68k/md.c
@@ -1,4 +1,4 @@
-/* $NetBSD: md.c,v 1.14 1998/12/20 17:43:37 veego Exp $ */
+/* $NetBSD: md.c,v 1.15 1999/01/05 10:02:21 itohy Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -329,8 +329,8 @@ md_swapin_reloc(r, n)
for (; n; n--, r++) {
r->r_address = md_swap_long(r->r_address);
bits = ((int *)r)[1];
- r->r_symbolnum = md_swap_long(bits) & 0x00ffffff;
- bits = ((unsigned char *)r)[7];
+ r->r_symbolnum = md_swap_long(bits) >> 8;
+ bits >>= 24;
r->r_pcrel = (bits >> 7) & 1;
r->r_length = (bits >> 5) & 3;
r->r_extern = (bits >> 4) & 1;
@@ -352,7 +352,6 @@ md_swapout_reloc(r, n)
for (; n; n--, r++) {
r->r_address = md_swap_long(r->r_address);
- ((int *)r)[1] = md_swap_long(r->r_symbolnum) & 0xffffff00;
bits = (r->r_pcrel & 1) << 7;
bits |= (r->r_length & 3) << 5;
bits |= (r->r_extern & 1) << 4;
@@ -362,6 +361,7 @@ md_swapout_reloc(r, n)
#ifdef N_SIZE
bits |= (r->r_copy & 1);
#endif
+ ((int *)r)[1] = md_swap_long(r->r_symbolnum) >> 8;
((unsigned char *)r)[7] = bits;
}
}
diff --git a/libexec/ld.aout_so/arch/m68k/md.h b/libexec/ld.aout_so/arch/m68k/md.h
index 65dcfefeeec..1055100a7ce 100644
--- a/libexec/ld.aout_so/arch/m68k/md.h
+++ b/libexec/ld.aout_so/arch/m68k/md.h
@@ -1,4 +1,4 @@
-/* $NetBSD: md.h,v 1.7 1998/12/21 12:16:16 is Exp $ */
+/* $NetBSD: md.h,v 1.8 1999/01/05 10:02:21 itohy Exp $ */
/*
* - m68k dependent definitions
@@ -141,8 +141,8 @@ void md_swapout_jmpslot __P((jmpslot_t *, int));
#define md_swapout_so_debug(d) swap_so_debug(d)
#define md_swapin_rrs_hash(f,n) swap_rrs_hash(f,n)
#define md_swapout_rrs_hash(f,n) swap_rrs_hash(f,n)
-#define md_swapin_sod(l,n) swapin_link_object(l,n)
-#define md_swapout_sod(l,n) swapout_link_object(l,n)
+#define md_swapin_sod(l,n) swapin_sod(l,n)
+#define md_swapout_sod(l,n) swapout_sod(l,n)
#define md_swapout_got(g,n) swap_longs((long*)(g),n)
#define md_swapin_ranlib_hdr(h,n) swap_ranlib_hdr(h,n)
#define md_swapout_ranlib_hdr(h,n) swap_ranlib_hdr(h,n)