aout and bout breakage
Alan Modra
amodra@bigpond.net.au
Tue Mar 1 00:35:00 GMT 2005
Portability fixes. The AOUT and BOUT support broke badly when compiled
on a 64-bit host. Buffer overruns and all sorts of fun. i960-bout was
particularly broken on big-endian hosts.
bfd/
* bout.c (b_out_write_object_contents): Don't use sizeof on host
structs to size on-disk structures.
(b_out_set_section_contents): Size the external struct, not the
internal one for on-disk size.
(b_out_sizeof_headers): Likewise.
gas/
* configure.in (AC_C_BIGENDIAN): Invoke.
* configure: Regenerate.
* write.c (write_object_file <!BFD_ASSEMBLER>): Don't use sizeof
host variable to set string header size.
* config/obj-aout.c (obj_header_append): Don't use host structs.
(obj_symbol_to_chars): Likewise.
(obj_emit_strings): Likewise. Use the passed in output pointer.
* config/obj-aout.h (H_GET_FILE_SIZE): Include H_GET_LINENO_SIZE.
* config/obj-bout.c (obj_emit_relocations): Use md_reloc_size,
not sizeof host struct.
(obj_header_append, obj_symbol_to_chars): Don't use host structs.
(obj_emit_strings): Likewise.
* config/obj-bout.h (EXEC_BYTES_SIZE): Define.
(N_TXTOFF, H_GET_FILE_SIZE, H_GET_HEADER_SIZE): Use instead of
sizeof host struct.
(H_SET_SYMBOL_TABLE_SIZE): Hard code sym size rather than using
sizeof host struct.
(host_number_to_chars): Define.
* config/obj-hp300.c (hp300_header_append): Don't use sizeof
host internal struct to set header sizes.
* config/tc-i960.c (md_number_to_field): Warning fix.
(md_ri_to_chars): Use host byte order.
(get_cdisp, md_apply_fix3): Warning fix.
Index: gas/configure.in
===================================================================
RCS file: /cvs/src/src/gas/configure.in,v
retrieving revision 1.168
diff -u -p -r1.168 configure.in
--- gas/configure.in 22 Dec 2004 15:29:25 -0000 1.168
+++ gas/configure.in 28 Feb 2005 22:45:23 -0000
@@ -86,6 +86,9 @@ case "${host}" in
esac
AC_SUBST(GDBINIT)
+#We need this for the host. BOUT header is in host order.
+AC_C_BIGENDIAN
+
te_file=generic
# Makefile target for installing gas in $(tooldir)/bin.
Index: bfd/bout.c
===================================================================
RCS file: /cvs/src/src/bfd/bout.c,v
retrieving revision 1.22
diff -u -p -r1.22 bout.c
--- bfd/bout.c 21 Jul 2004 15:42:57 -0000 1.22
+++ bfd/bout.c 28 Feb 2005 22:45:04 -0000
@@ -297,12 +297,10 @@ b_out_write_object_contents (abfd)
exec_hdr (abfd)->a_text = obj_textsec (abfd)->size;
exec_hdr (abfd)->a_data = obj_datasec (abfd)->size;
exec_hdr (abfd)->a_bss = obj_bsssec (abfd)->size;
- exec_hdr (abfd)->a_syms = bfd_get_symcount (abfd) * sizeof (struct nlist);
+ exec_hdr (abfd)->a_syms = bfd_get_symcount (abfd) * 12;
exec_hdr (abfd)->a_entry = bfd_get_start_address (abfd);
- exec_hdr (abfd)->a_trsize = ((obj_textsec (abfd)->reloc_count) *
- sizeof (struct relocation_info));
- exec_hdr (abfd)->a_drsize = ((obj_datasec (abfd)->reloc_count) *
- sizeof (struct relocation_info));
+ exec_hdr (abfd)->a_trsize = (obj_textsec (abfd)->reloc_count) * 8;
+ exec_hdr (abfd)->a_drsize = (obj_datasec (abfd)->reloc_count) * 8;
exec_hdr (abfd)->a_talign = obj_textsec (abfd)->alignment_power;
exec_hdr (abfd)->a_dalign = obj_datasec (abfd)->alignment_power;
@@ -993,7 +991,7 @@ b_out_set_section_contents (abfd, sectio
if (! aout_32_make_sections (abfd))
return FALSE;
- obj_textsec (abfd)->filepos = sizeof (struct internal_exec);
+ obj_textsec (abfd)->filepos = sizeof (struct external_exec);
obj_datasec(abfd)->filepos = obj_textsec(abfd)->filepos
+ obj_textsec (abfd)->size;
}
@@ -1044,7 +1042,7 @@ b_out_sizeof_headers (ignore_abfd, ignor
bfd *ignore_abfd ATTRIBUTE_UNUSED;
bfd_boolean ignore ATTRIBUTE_UNUSED;
{
- return sizeof (struct internal_exec);
+ return sizeof (struct external_exec);
}
Index: gas/write.c
===================================================================
RCS file: /cvs/src/src/gas/write.c,v
retrieving revision 1.82
diff -u -p -r1.82 write.c
--- gas/write.c 7 Feb 2005 03:13:10 -0000 1.82
+++ gas/write.c 28 Feb 2005 22:45:26 -0000
@@ -1569,11 +1569,11 @@ write_object_file (void)
Count the number of string-table chars we will emit.
Put this info into the headers as appropriate. */
know (zero_address_frag.fr_address == 0);
- string_byte_count = sizeof (string_byte_count);
+ string_byte_count = 4;
obj_crawl_symbol_chain (&headers);
- if (string_byte_count == sizeof (string_byte_count))
+ if (string_byte_count == 4)
string_byte_count = 0;
H_SET_STRING_SIZE (&headers, string_byte_count);
Index: gas/config/obj-aout.c
===================================================================
RCS file: /cvs/src/src/gas/config/obj-aout.c,v
retrieving revision 1.20
diff -u -p -r1.20 obj-aout.c
--- gas/config/obj-aout.c 27 Mar 2004 11:36:09 -0000 1.20
+++ gas/config/obj-aout.c 28 Feb 2005 22:45:26 -0000
@@ -1,6 +1,6 @@
/* a.out object file format
Copyright 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1999, 2000,
- 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+ 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
@@ -265,36 +265,39 @@ obj_emit_relocations (where, fixP, segme
#ifndef obj_header_append
/* Aout file generation & utilities */
+
+/* An AOUT header on disk is laid out in target byte order. */
+
void
obj_header_append (where, headers)
char **where;
object_headers *headers;
{
- tc_headers_hook (headers);
-
-#ifdef CROSS_COMPILE
- md_number_to_chars (*where, headers->header.a_info, sizeof (headers->header.a_info));
- *where += sizeof (headers->header.a_info);
- md_number_to_chars (*where, headers->header.a_text, sizeof (headers->header.a_text));
- *where += sizeof (headers->header.a_text);
- md_number_to_chars (*where, headers->header.a_data, sizeof (headers->header.a_data));
- *where += sizeof (headers->header.a_data);
- md_number_to_chars (*where, headers->header.a_bss, sizeof (headers->header.a_bss));
- *where += sizeof (headers->header.a_bss);
- md_number_to_chars (*where, headers->header.a_syms, sizeof (headers->header.a_syms));
- *where += sizeof (headers->header.a_syms);
- md_number_to_chars (*where, headers->header.a_entry, sizeof (headers->header.a_entry));
- *where += sizeof (headers->header.a_entry);
- md_number_to_chars (*where, headers->header.a_trsize, sizeof (headers->header.a_trsize));
- *where += sizeof (headers->header.a_trsize);
- md_number_to_chars (*where, headers->header.a_drsize, sizeof (headers->header.a_drsize));
- *where += sizeof (headers->header.a_drsize);
+ char *p;
-#else /* CROSS_COMPILE */
-
- append (where, (char *) &headers->header, sizeof (headers->header));
-#endif /* CROSS_COMPILE */
+ tc_headers_hook (headers);
+#ifdef __A_OUT_GNU_H__
+#define SIZEOF_HEADER(PIECE) (sizeof (((struct exec_bytes *) 0)->PIECE))
+#else
+#define SIZEOF_HEADER(PIECE) 4
+#endif
+#define DO(PIECE) \
+ md_number_to_chars (p, headers->header.PIECE, SIZEOF_HEADER (PIECE)); \
+ p += SIZEOF_HEADER (PIECE);
+
+ p = *where;
+ DO (a_info);
+ DO (a_text);
+ DO (a_data);
+ DO (a_bss);
+ DO (a_syms);
+ DO (a_entry);
+ DO (a_trsize);
+ DO (a_drsize);
+ *where = p;
+#undef DO
+#undef SIZEOF_HEADER
}
#endif /* ! defined (obj_header_append) */
@@ -303,11 +306,17 @@ obj_symbol_to_chars (where, symbolP)
char **where;
symbolS *symbolP;
{
- md_number_to_chars ((char *) &(S_GET_OFFSET (symbolP)), S_GET_OFFSET (symbolP), sizeof (S_GET_OFFSET (symbolP)));
- md_number_to_chars ((char *) &(S_GET_DESC (symbolP)), S_GET_DESC (symbolP), sizeof (S_GET_DESC (symbolP)));
- md_number_to_chars ((char *) &(symbolP->sy_symbol.n_value), S_GET_VALUE (symbolP), sizeof (symbolP->sy_symbol.n_value));
-
- append (where, (char *) &symbolP->sy_symbol, sizeof (obj_symbol_type));
+ char *p = *where;
+ md_number_to_chars (p, S_GET_OFFSET (symbolP), 4);
+ p += 4;
+ /* Can't use S_GET_TYPE here as it masks. */
+ *p++ = symbolP->sy_symbol.n_type;
+ *p++ = symbolP->sy_symbol.n_other;
+ md_number_to_chars (p, S_GET_DESC (symbolP), 2);
+ p += 2;
+ md_number_to_chars (p, S_GET_VALUE (symbolP), 4);
+ p += 4;
+ *where = p;
}
void
@@ -538,18 +547,13 @@ obj_emit_strings (where)
{
symbolS *symbolP;
-#ifdef CROSS_COMPILE
- /* Gotta do md_ byte-ordering stuff for string_byte_count first - KWK */
- md_number_to_chars (*where, string_byte_count, sizeof (string_byte_count));
- *where += sizeof (string_byte_count);
-#else /* CROSS_COMPILE */
- append (where, (char *) &string_byte_count, (unsigned long) sizeof (string_byte_count));
-#endif /* CROSS_COMPILE */
+ md_number_to_chars (*where, string_byte_count, 4);
+ *where += 4;
for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next (symbolP))
{
if (S_GET_NAME (symbolP))
- append (&next_object_file_charP, S_GET_NAME (symbolP),
+ append (where, S_GET_NAME (symbolP),
(unsigned long) (strlen (S_GET_NAME (symbolP)) + 1));
} /* walk symbol chain */
}
Index: gas/config/obj-aout.h
===================================================================
RCS file: /cvs/src/src/gas/config/obj-aout.h,v
retrieving revision 1.9
diff -u -p -r1.9 obj-aout.h
--- gas/config/obj-aout.h 20 Nov 2003 00:01:54 -0000 1.9
+++ gas/config/obj-aout.h 28 Feb 2005 22:45:27 -0000
@@ -1,6 +1,6 @@
/* obj-aout.h, a.out object file format for gas, the assembler.
Copyright 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 2000,
- 2002, 2003 Free Software Foundation, Inc.
+ 2002, 2003, 2005 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
@@ -177,9 +177,10 @@ extern void obj_aout_frob_file_before_fi
#define H_GET_FILE_SIZE(h) (H_GET_HEADER_SIZE(h) \
+ H_GET_TEXT_SIZE(h) \
+ H_GET_DATA_SIZE(h) \
- + H_GET_SYMBOL_TABLE_SIZE(h) \
+ H_GET_TEXT_RELOCATION_SIZE(h) \
+ H_GET_DATA_RELOCATION_SIZE(h) \
+ + H_GET_LINENO_SIZE(h) \
+ + H_GET_SYMBOL_TABLE_SIZE(h) \
+ H_GET_STRING_SIZE(h))
#define H_GET_HEADER_SIZE(h) (EXEC_BYTES_SIZE)
Index: gas/config/obj-bout.c
===================================================================
RCS file: /cvs/src/src/gas/config/obj-bout.c,v
retrieving revision 1.11
diff -u -p -r1.11 obj-bout.c
--- gas/config/obj-bout.c 22 Nov 2003 15:32:28 -0000 1.11
+++ gas/config/obj-bout.c 28 Feb 2005 22:45:27 -0000
@@ -1,6 +1,6 @@
/* b.out object file format
- Copyright 1989, 1990, 1991, 1992, 1993, 1994, 1996, 2000, 2001, 2002
- Free Software Foundation, Inc.
+ Copyright 1989, 1990, 1991, 1992, 1993, 1994, 1996, 2000, 2001, 2002,
+ 2005 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
@@ -105,7 +105,7 @@ obj_emit_relocations (where, fixP, segme
fixP->fx_addsy = sym;
tc_bout_fix_to_chars (*where, fixP, segment_address_in_file);
- *where += sizeof (struct relocation_info);
+ *where += md_reloc_size;
} /* if there's a symbol */
} /* for each fixup */
}
@@ -120,6 +120,7 @@ obj_header_append (where, headers)
object_headers *headers;
{
/* Always leave in host byte order. */
+ char *p;
headers->header.a_talign = section_alignment[SEG_TEXT];
@@ -138,38 +139,32 @@ obj_header_append (where, headers)
headers->header.a_relaxable = linkrelax;
-#ifdef CROSS_COMPILE
- md_number_to_chars (*where, headers->header.a_magic, sizeof (headers->header.a_magic));
- *where += sizeof (headers->header.a_magic);
- md_number_to_chars (*where, headers->header.a_text, sizeof (headers->header.a_text));
- *where += sizeof (headers->header.a_text);
- md_number_to_chars (*where, headers->header.a_data, sizeof (headers->header.a_data));
- *where += sizeof (headers->header.a_data);
- md_number_to_chars (*where, headers->header.a_bss, sizeof (headers->header.a_bss));
- *where += sizeof (headers->header.a_bss);
- md_number_to_chars (*where, headers->header.a_syms, sizeof (headers->header.a_syms));
- *where += sizeof (headers->header.a_syms);
- md_number_to_chars (*where, headers->header.a_entry, sizeof (headers->header.a_entry));
- *where += sizeof (headers->header.a_entry);
- md_number_to_chars (*where, headers->header.a_trsize, sizeof (headers->header.a_trsize));
- *where += sizeof (headers->header.a_trsize);
- md_number_to_chars (*where, headers->header.a_drsize, sizeof (headers->header.a_drsize));
- *where += sizeof (headers->header.a_drsize);
- md_number_to_chars (*where, headers->header.a_tload, sizeof (headers->header.a_tload));
- *where += sizeof (headers->header.a_tload);
- md_number_to_chars (*where, headers->header.a_dload, sizeof (headers->header.a_dload));
- *where += sizeof (headers->header.a_dload);
- md_number_to_chars (*where, headers->header.a_talign, sizeof (headers->header.a_talign));
- *where += sizeof (headers->header.a_talign);
- md_number_to_chars (*where, headers->header.a_dalign, sizeof (headers->header.a_dalign));
- *where += sizeof (headers->header.a_dalign);
- md_number_to_chars (*where, headers->header.a_balign, sizeof (headers->header.a_balign));
- *where += sizeof (headers->header.a_balign);
- md_number_to_chars (*where, headers->header.a_relaxable, sizeof (headers->header.a_relaxable));
- *where += sizeof (headers->header.a_relaxable);
-#else /* ! CROSS_COMPILE */
- append (where, (char *) &headers->header, sizeof (headers->header));
-#endif /* ! CROSS_COMPILE */
+ p = *where;
+ host_number_to_chars (p, headers->header.a_magic, 4);
+ p += 4;
+ host_number_to_chars (p, headers->header.a_text, 4);
+ p += 4;
+ host_number_to_chars (p, headers->header.a_data, 4);
+ p += 4;
+ host_number_to_chars (p, headers->header.a_bss, 4);
+ p += 4;
+ host_number_to_chars (p, headers->header.a_syms, 4);
+ p += 4;
+ host_number_to_chars (p, headers->header.a_entry, 4);
+ p += 4;
+ host_number_to_chars (p, headers->header.a_trsize, 4);
+ p += 4;
+ host_number_to_chars (p, headers->header.a_drsize, 4);
+ p += 4;
+ host_number_to_chars (p, headers->header.a_tload, 4);
+ p += 4;
+ host_number_to_chars (p, headers->header.a_dload, 4);
+ p += 4;
+ *p++ = headers->header.a_talign;
+ *p++ = headers->header.a_dalign;
+ *p++ = headers->header.a_balign;
+ *p++ = headers->header.a_relaxable;
+ *where = p;
}
void
@@ -177,19 +172,17 @@ obj_symbol_to_chars (where, symbolP)
char **where;
symbolS *symbolP;
{
- md_number_to_chars ((char *) &(S_GET_OFFSET (symbolP)),
- S_GET_OFFSET (symbolP),
- sizeof (S_GET_OFFSET (symbolP)));
-
- md_number_to_chars ((char *) &(S_GET_DESC (symbolP)),
- S_GET_DESC (symbolP),
- sizeof (S_GET_DESC (symbolP)));
-
- md_number_to_chars ((char *) &symbolP->sy_symbol.n_value,
- S_GET_VALUE (symbolP),
- sizeof (symbolP->sy_symbol.n_value));
-
- append (where, (char *) &symbolP->sy_symbol, sizeof (obj_symbol_type));
+ char *p = *where;
+ host_number_to_chars (p, S_GET_OFFSET (symbolP), 4);
+ p += 4;
+ /* Can't use S_GET_TYPE here as it masks. */
+ *p++ = symbolP->sy_symbol.n_type;
+ *p++ = symbolP->sy_symbol.n_other;
+ host_number_to_chars (p, S_GET_DESC (symbolP), 2);
+ p += 2;
+ host_number_to_chars (p, S_GET_VALUE (symbolP), 4);
+ p += 4;
+ *where = p;
}
void
@@ -336,14 +329,8 @@ obj_emit_strings (where)
{
symbolS *symbolP;
-#ifdef CROSS_COMPILE
- /* Gotta do md_ byte-ordering stuff for string_byte_count first - KWK */
- md_number_to_chars (*where, string_byte_count, sizeof (string_byte_count));
- *where += sizeof (string_byte_count);
-#else /* CROSS_COMPILE */
- append (where, (char *) &string_byte_count,
- (unsigned long) sizeof (string_byte_count));
-#endif /* CROSS_COMPILE */
+ md_number_to_chars (*where, string_byte_count, 4);
+ *where += 4;
for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next (symbolP))
{
Index: gas/config/obj-bout.h
===================================================================
RCS file: /cvs/src/src/gas/config/obj-bout.h,v
retrieving revision 1.7
diff -u -p -r1.7 obj-bout.h
--- gas/config/obj-bout.h 20 Nov 2003 00:01:54 -0000 1.7
+++ gas/config/obj-bout.h 28 Feb 2005 22:45:27 -0000
@@ -1,6 +1,6 @@
/* b.out object file format
Copyright 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 2000,
- 2002, 2003 Free Software Foundation, Inc.
+ 2002, 2003, 2005 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
@@ -106,8 +106,10 @@ struct exec
unsigned char a_relaxable; /* Contains enough info to relax */
};
+#define EXEC_BYTES_SIZE (10 * 4 + 4 * 1)
+
#define N_BADMAG(x) (((x).a_magic)!=BMAGIC)
-#define N_TXTOFF(x) ( sizeof (struct exec) )
+#define N_TXTOFF(x) EXEC_BYTES_SIZE
#define N_DATOFF(x) ( N_TXTOFF(x) + (x).a_text )
#define N_TROFF(x) ( N_DATOFF(x) + (x).a_data )
#define N_DROFF(x) ( N_TROFF(x) + (x).a_trsize )
@@ -245,14 +247,14 @@ struct relocation_info
/* File header macro and type definition */
-#define H_GET_FILE_SIZE(h) (sizeof (struct exec) + \
+#define H_GET_FILE_SIZE(h) (EXEC_BYTES_SIZE + \
H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h) + \
H_GET_SYMBOL_TABLE_SIZE(h) + \
H_GET_TEXT_RELOCATION_SIZE(h) + \
H_GET_DATA_RELOCATION_SIZE(h) + \
(h)->string_table_size)
-#define H_GET_HEADER_SIZE(h) (sizeof (struct exec))
+#define H_GET_HEADER_SIZE(h) EXEC_BYTES_SIZE
#define H_GET_TEXT_SIZE(h) ((h)->header.a_text)
#define H_GET_DATA_SIZE(h) ((h)->header.a_data)
#define H_GET_BSS_SIZE(h) ((h)->header.a_bss)
@@ -280,8 +282,7 @@ struct relocation_info
#define H_SET_TEXT_RELOCATION_SIZE(h,v) ((h)->header.a_trsize = (v))
#define H_SET_DATA_RELOCATION_SIZE(h,v) ((h)->header.a_drsize = (v))
-#define H_SET_SYMBOL_TABLE_SIZE(h,v) ((h)->header.a_syms = (v) * \
- sizeof (struct nlist))
+#define H_SET_SYMBOL_TABLE_SIZE(h,v) ((h)->header.a_syms = (v) * 12)
#define H_SET_MAGIC_NUMBER(h,v) ((h)->header.a_magic = (v))
@@ -306,6 +307,12 @@ object_headers;
#define OBJ_EMIT_LINENO(a, b, c) {;}
#define obj_pre_write_hook(a) {;}
+#if WORDS_BIGENDIAN
+#define host_number_to_chars number_to_chars_bigendian
+#else
+#define host_number_to_chars number_to_chars_littleendian
+#endif
+
#if __STDC__
struct fix;
#endif
Index: gas/config/obj-hp300.c
===================================================================
RCS file: /cvs/src/src/gas/config/obj-hp300.c,v
retrieving revision 1.3
diff -u -p -r1.3 obj-hp300.c
--- gas/config/obj-hp300.c 8 Mar 2001 23:24:22 -0000 1.3
+++ gas/config/obj-hp300.c 28 Feb 2005 22:45:27 -0000
@@ -1,5 +1,5 @@
/* This file is obj-hp300.h
- Copyright 1993, 2000 Free Software Foundation, Inc.
+ Copyright 1993, 2000, 2005 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
@@ -30,8 +30,9 @@ hp300_header_append (where, headers)
#define DO(FIELD) \
{ \
- md_number_to_chars (*where, headers->header.FIELD, sizeof (headers->header.FIELD)); \
- *where += sizeof (headers->header.FIELD); \
+ md_number_to_chars (*where, headers->header.FIELD, \
+ sizeof (((struct exec_bytes *) 0)->FIELD)); \
+ *where += sizeof (((struct exec_bytes *) 0)->FIELD); \
}
DO (a_info);
Index: gas/config/tc-i960.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-i960.c,v
retrieving revision 1.20
diff -u -p -r1.20 tc-i960.c
--- gas/config/tc-i960.c 23 Feb 2005 12:28:04 -0000 1.20
+++ gas/config/tc-i960.c 28 Feb 2005 22:45:31 -0000
@@ -859,7 +859,7 @@ md_number_to_field (instrP, val, bfixP)
/* Surprise! -- we stored the number of bits to be modified rather
than a pointer to a structure. */
- numbits = (int) bfixP;
+ numbits = (int) (size_t) bfixP;
if (numbits == 1)
{
/* This is a no-op, stuck here by reloc_callj() */
@@ -1116,9 +1116,6 @@ md_estimate_size_before_relax (fragP, se
executable code is actually downloaded to the i80960). Therefore,
we leave it in host byte order.
- The above comment is no longer true. This routine now really
- does do the reordering (Ian Taylor 28 Aug 92).
-
*************************************************************************** */
static void md_ri_to_chars PARAMS ((char *, struct relocation_info *));
@@ -1127,17 +1124,25 @@ md_ri_to_chars (where, ri)
char *where;
struct relocation_info *ri;
{
- md_number_to_chars (where, ri->r_address,
- sizeof (ri->r_address));
- where[4] = ri->r_index & 0x0ff;
- where[5] = (ri->r_index >> 8) & 0x0ff;
- where[6] = (ri->r_index >> 16) & 0x0ff;
- where[7] = ((ri->r_pcrel << 0)
- | (ri->r_length << 1)
- | (ri->r_extern << 3)
- | (ri->r_bsr << 4)
- | (ri->r_disp << 5)
- | (ri->r_callj << 6));
+ host_number_to_chars (where, ri->r_address, 4);
+ host_number_to_chars (where + 4, ri->r_index, 3);
+#if WORDS_BIGENDIAN
+ where[7] = (ri->r_pcrel << 7
+ | ri->r_length << 5
+ | ri->r_extern << 4
+ | ri->r_bsr << 3
+ | ri->r_disp << 2
+ | ri->r_callj << 1
+ | ri->nuthin << 0);
+#else
+ where[7] = (ri->r_pcrel << 0
+ | ri->r_length << 1
+ | ri->r_extern << 3
+ | ri->r_bsr << 4
+ | ri->r_disp << 5
+ | ri->r_callj << 6
+ | ri->nuthin << 7);
+#endif
}
#endif /* defined(OBJ_AOUT) | defined(OBJ_BOUT) */
@@ -1508,7 +1513,7 @@ get_cdisp (dispP, ifmtP, instr, numbits,
* bit_fix structure. So we're going to lie and store
* the number of bits affected instead of a pointer.
*/
- fixP->fx_bit_fixP = (bit_fixS *) numbits;
+ fixP->fx_bit_fixP = (bit_fixS *) (size_t) numbits;
}
}
else
@@ -2832,7 +2837,7 @@ md_apply_fix3 (fixP, valP, seg)
md_number_to_imm (place, val, fixP->fx_size);
}
- else if ((int) fixP->fx_bit_fixP == 13
+ else if ((int) (size_t) fixP->fx_bit_fixP == 13
&& fixP->fx_addsy != NULL
&& S_GET_SEGMENT (fixP->fx_addsy) == undefined_section)
{
--
Alan Modra
IBM OzLabs - Linux Technology Centre
More information about the Binutils
mailing list