diff options
author | Alan Modra <amodra@gmail.com> | 2005-03-01 00:43:58 +0000 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2005-03-01 00:43:58 +0000 |
commit | 44f2f9d2a3fca1612061a377f6c6f512be635fff (patch) | |
tree | fc0679a0cb8eb8a0b0e7d08982fc5ef527ec9cf2 /gas/config | |
parent | 70bfececf5f88eb75203859f69a5382bad663f9b (diff) | |
download | gdb-44f2f9d2a3fca1612061a377f6c6f512be635fff.zip gdb-44f2f9d2a3fca1612061a377f6c6f512be635fff.tar.gz gdb-44f2f9d2a3fca1612061a377f6c6f512be635fff.tar.bz2 |
* 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.
Diffstat (limited to 'gas/config')
-rw-r--r-- | gas/config/obj-aout.c | 78 | ||||
-rw-r--r-- | gas/config/obj-aout.h | 5 | ||||
-rw-r--r-- | gas/config/obj-bout.c | 99 | ||||
-rw-r--r-- | gas/config/obj-bout.h | 19 | ||||
-rw-r--r-- | gas/config/obj-hp300.c | 7 | ||||
-rw-r--r-- | gas/config/tc-i960.c | 39 |
6 files changed, 126 insertions, 121 deletions
diff --git a/gas/config/obj-aout.c b/gas/config/obj-aout.c index 74e52a5..6a47a9b 100644 --- a/gas/config/obj-aout.c +++ b/gas/config/obj-aout.c @@ -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, segment_address_in_file) #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); + char *p; -#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); - -#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 */ } diff --git a/gas/config/obj-aout.h b/gas/config/obj-aout.h index 23a2907..2718686 100644 --- a/gas/config/obj-aout.h +++ b/gas/config/obj-aout.h @@ -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_fix PARAMS ((void)); #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) diff --git a/gas/config/obj-bout.c b/gas/config/obj-bout.c index 88ea0f1..2163543 100644 --- a/gas/config/obj-bout.c +++ b/gas/config/obj-bout.c @@ -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, segment_address_in_file) 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)) { diff --git a/gas/config/obj-bout.h b/gas/config/obj-bout.h index aaa9d9b..278fcc4 100644 --- a/gas/config/obj-bout.h +++ b/gas/config/obj-bout.h @@ -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 diff --git a/gas/config/obj-hp300.c b/gas/config/obj-hp300.c index 2fc0f25..0dc3435 100644 --- a/gas/config/obj-hp300.c +++ b/gas/config/obj-hp300.c @@ -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); diff --git a/gas/config/tc-i960.c b/gas/config/tc-i960.c index 8b0a538..1786afe 100644 --- a/gas/config/tc-i960.c +++ b/gas/config/tc-i960.c @@ -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, segment_type) 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, var_frag, callj) * 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) { |