* read.c (do_align): Add max parameter. Change all callers.

Remove useless static variables.
	(s_align): New static function.  Do common portion of
	s_align_bytes and s_align_ptwo.
	(s_align_bytes, s_align_ptwo): Just call s_align.
	* frags.c (frag_align): Add max parameter.  Change all callers.
	(frag_align_pattern): Likewise.
	* frags.h (frag_align, frag_align_pattern): Update declarations.
	* write.c (relax_segment): Limit alignment change to fr_subtype.
	Fix some types to be addressT.
	* config/obj-coff.c (size_section): Likewise.
	* config/obj-ieee.c (size_section): Likewise.
	* config/tc-d10v.h (md_do_align): Add max parameter.
	* config/tc-i386.h (md_do_align): Likewise.
	* config/tc-m88k.h (md_do_align): Likewise.
	* config/tc-m88k.c (m88k_do_align): Likewise.
	* config/tc-sh.h (md_do_align): Likewise.
	* config/tc-sh.c (sh_do_align): Likewise.
	* as.h: Improve comments on rs_align and rs_align_code.
	* doc/as.texinfo: Document new alignment arguments.
	* doc/internals.texi (Frags): Document use of fr_subtype field for
	rs_align and rs_align_code.
This commit is contained in:
Ian Lance Taylor 1997-02-14 22:49:25 +00:00
parent d7e89eaff8
commit d7bf6158eb
8 changed files with 178 additions and 31 deletions

View File

@ -1,3 +1,32 @@
Fri Feb 14 17:24:48 1997 Ian Lance Taylor <ian@cygnus.com>
* read.c (do_align): Add max parameter. Change all callers.
Remove useless static variables.
(s_align): New static function. Do common portion of
s_align_bytes and s_align_ptwo.
(s_align_bytes, s_align_ptwo): Just call s_align.
* frags.c (frag_align): Add max parameter. Change all callers.
(frag_align_pattern): Likewise.
* frags.h (frag_align, frag_align_pattern): Update declarations.
* write.c (relax_segment): Limit alignment change to fr_subtype.
Fix some types to be addressT.
* config/obj-coff.c (size_section): Likewise.
* config/obj-ieee.c (size_section): Likewise.
* config/tc-d10v.h (md_do_align): Add max parameter.
* config/tc-i386.h (md_do_align): Likewise.
* config/tc-m88k.h (md_do_align): Likewise.
* config/tc-m88k.c (m88k_do_align): Likewise.
* config/tc-sh.h (md_do_align): Likewise.
* config/tc-sh.c (sh_do_align): Likewise.
* as.h: Improve comments on rs_align and rs_align_code.
* doc/as.texinfo: Document new alignment arguments.
* doc/internals.texi (Frags): Document use of fr_subtype field for
rs_align and rs_align_code.
Fri Feb 14 15:56:06 1997 Gavin Koch <gavin@cygnus.com>
* config/tc-mips.c: Changed opcode parsing.
Thu Feb 13 20:02:16 1997 Fred Fish <fnf@cygnus.com> Thu Feb 13 20:02:16 1997 Fred Fish <fnf@cygnus.com>
* config/{tc-alpha.h, tc-arc.h, tc-d10v.h, tc-generic.h, tc-i960.h, * config/{tc-alpha.h, tc-arc.h, tc-d10v.h, tc-generic.h, tc-i960.h,

View File

@ -1524,8 +1524,15 @@ size_section (abfd, idx)
break; break;
case rs_align: case rs_align:
case rs_align_code: case rs_align_code:
size += frag->fr_fix; {
size += relax_align (size, frag->fr_offset); addressT off;
size += frag->fr_fix;
off = relax_align (size, frag->fr_offset);
if (frag->fr_subtype != 0 && off > frag->fr_subtype)
off = 0;
size += off;
}
break; break;
default: default:
BAD_CASE (frag->fr_type); BAD_CASE (frag->fr_type);
@ -1648,7 +1655,16 @@ do_relocs_for (abfd, h, file_cursor)
while (symbol_ptr->sy_value.X_op == O_symbol while (symbol_ptr->sy_value.X_op == O_symbol
&& (! S_IS_DEFINED (symbol_ptr) && (! S_IS_DEFINED (symbol_ptr)
|| S_IS_COMMON (symbol_ptr))) || S_IS_COMMON (symbol_ptr)))
symbol_ptr = symbol_ptr->sy_value.X_add_symbol; {
symbolS *n;
/* We must avoid looping, as that can occur
with a badly written program. */
n = symbol_ptr->sy_value.X_add_symbol;
if (n == symbol_ptr)
break;
symbol_ptr = n;
}
/* Turn the segment of the symbol into an offset. */ /* Turn the segment of the symbol into an offset. */
if (symbol_ptr) if (symbol_ptr)
@ -3106,10 +3122,10 @@ write_object_file ()
#ifdef md_do_align #ifdef md_do_align
{ {
static char nop = NOP_OPCODE; static char nop = NOP_OPCODE;
md_do_align (SUB_SEGMENT_ALIGN (now_seg), &nop, 1, alignment_done); md_do_align (SUB_SEGMENT_ALIGN (now_seg), &nop, 1, 0, alignment_done);
} }
#endif #endif
frag_align (SUB_SEGMENT_ALIGN (now_seg), NOP_OPCODE); frag_align (SUB_SEGMENT_ALIGN (now_seg), NOP_OPCODE, 0);
#ifdef md_do_align #ifdef md_do_align
alignment_done: alignment_done:
#endif #endif
@ -3848,6 +3864,34 @@ fixup_segment (segP, this_segment_type)
happened if these are expression symbols. */ happened if these are expression symbols. */
if (add_symbolP != NULL && ! add_symbolP->sy_resolved) if (add_symbolP != NULL && ! add_symbolP->sy_resolved)
resolve_symbol_value (add_symbolP); resolve_symbol_value (add_symbolP);
if (add_symbolP != NULL)
{
/* If this fixup is against a symbol which has been equated
to another symbol, convert it to the other symbol. */
if (add_symbolP->sy_value.X_op == O_symbol
&& (! S_IS_DEFINED (add_symbolP)
|| S_IS_COMMON (add_symbolP)))
{
while (add_symbolP->sy_value.X_op == O_symbol
&& (! S_IS_DEFINED (add_symbolP)
|| S_IS_COMMON (add_symbolP)))
{
symbolS *n;
/* We must avoid looping, as that can occur with a
badly written program. */
n = add_symbolP->sy_value.X_add_symbol;
if (n == add_symbolP)
break;
add_number += add_symbolP->sy_value.X_add_number;
add_symbolP = n;
}
fixP->fx_addsy = add_symbolP;
fixP->fx_offset = add_number;
}
}
if (sub_symbolP != NULL && ! sub_symbolP->sy_resolved) if (sub_symbolP != NULL && ! sub_symbolP->sy_resolved)
resolve_symbol_value (sub_symbolP); resolve_symbol_value (sub_symbolP);
@ -4096,12 +4140,12 @@ fixup_segment (segP, this_segment_type)
&& ((add_number & ~0xFF) && ((add_number & ~0xFF)
|| (fixP->fx_signed && (add_number & 0x80))) || (fixP->fx_signed && (add_number & 0x80)))
&& ((add_number & ~0xFF) != (-1 & ~0xFF) && ((add_number & ~0xFF) != (-1 & ~0xFF)
|| (fixP->fx_signed && (add_number & 0x80) == 0))) || (add_number & 0x80) == 0))
|| (size == 2 || (size == 2
&& ((add_number & ~0xFFFF) && ((add_number & ~0xFFFF)
|| (fixP->fx_signed && (add_number & 0x8000))) || (fixP->fx_signed && (add_number & 0x8000)))
&& ((add_number & ~0xFFFF) != (-1 & ~0xFFFF) && ((add_number & ~0xFFFF) != (-1 & ~0xFFFF)
|| (fixP->fx_signed && (add_number & 0x8000) == 0)))) || (add_number & 0x8000) == 0)))
{ {
as_bad_where (fixP->fx_file, fixP->fx_line, as_bad_where (fixP->fx_file, fixP->fx_line,
"Value of %ld too large for field of %d bytes at 0x%lx", "Value of %ld too large for field of %d bytes at 0x%lx",

View File

@ -1,5 +1,5 @@
/* obj-format for ieee-695 records. /* obj-format for ieee-695 records.
Copyright (C) 1991, 1992 Free Software Foundation, Inc. Copyright (C) 1991, 92, 93, 94, 95, 1997 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler. This file is part of GAS, the GNU Assembler.
@ -14,8 +14,9 @@
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to along with GAS; see the file COPYING. If not, write to the Free
the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA. */
/* /*
@ -76,7 +77,15 @@ DEFUN (size_section, (abfd, idx),
size += frag->fr_offset * frag->fr_var; size += frag->fr_offset * frag->fr_var;
break; break;
case rs_align: case rs_align:
size += relax_align (size, frag->fr_offset); case rs_align_code:
{
addressT off;
off = relax_align (size, frag->fr_offset);
if (frag->fr_subtype != 0 && off > frag->fr_subtype)
off = 0;
size += off;
}
} }
frag = frag->fr_next; frag = frag->fr_next;
} }
@ -529,7 +538,7 @@ DEFUN_VOID (write_object_file)
#ifndef SUB_SEGMENT_ALIGN #ifndef SUB_SEGMENT_ALIGN
#define SUB_SEGMENT_ALIGN(SEG) 2 #define SUB_SEGMENT_ALIGN(SEG) 2
#endif #endif
frag_align (SUB_SEGMENT_ALIGN (now_seg), 0); frag_align (SUB_SEGMENT_ALIGN (now_seg), 0, 0);
frag_wane (frag_now); frag_wane (frag_now);
frag_now->fr_fix = 0; frag_now->fr_fix = 0;
know (frag_now->fr_next == NULL); know (frag_now->fr_next == NULL);

View File

@ -1,5 +1,5 @@
/* tc-d10v.h -- Header file for tc-d10v.c. /* tc-d10v.h -- Header file for tc-d10v.c.
Copyright (C) 1996 Free Software Foundation, Inc. Copyright (C) 1996, 1997 Free Software Foundation, Inc.
Written by Martin Hunt, Cygnus Support. Written by Martin Hunt, Cygnus Support.
This file is part of GAS, the GNU Assembler. This file is part of GAS, the GNU Assembler.
@ -20,6 +20,8 @@
#define TC_D10V #define TC_D10V
#define TARGET_BYTES_BIG_ENDIAN 0
#ifndef BFD_ASSEMBLER #ifndef BFD_ASSEMBLER
#error D10V support requires BFD_ASSEMBLER #error D10V support requires BFD_ASSEMBLER
#endif #endif
@ -50,7 +52,7 @@
int d10v_cleanup PARAMS ((void)); int d10v_cleanup PARAMS ((void));
#define md_after_pass_hook() d10v_cleanup() #define md_after_pass_hook() d10v_cleanup()
#define md_cleanup() d10v_cleanup() #define md_cleanup() d10v_cleanup()
#define md_do_align(a,b,c,d) d10v_cleanup() #define md_do_align(a,b,c,d,e) d10v_cleanup()
#define TC_START_LABEL(ch, ptr) (ch == ':' && d10v_cleanup()) #define TC_START_LABEL(ch, ptr) (ch == ':' && d10v_cleanup())

View File

@ -1,5 +1,5 @@
/* tc-i386.h -- Header file for tc-i386.c /* tc-i386.h -- Header file for tc-i386.c
Copyright (C) 1989, 1992, 1993, 1994, 1995 Free Software Foundation. Copyright (C) 1989, 92, 93, 94, 95, 96, 1997 Free Software Foundation.
This file is part of GAS, the GNU Assembler. This file is part of GAS, the GNU Assembler.
@ -20,6 +20,8 @@
#ifndef TC_I386 #ifndef TC_I386
#define TC_I386 1 #define TC_I386 1
#define TARGET_BYTES_BIG_ENDIAN 0
#ifdef TE_LYNX #ifdef TE_LYNX
#define TARGET_FORMAT "coff-i386-lynx" #define TARGET_FORMAT "coff-i386-lynx"
#endif #endif
@ -59,7 +61,6 @@
&& (FIX)->fx_r_type != BFD_RELOC_386_GOTPC) && (FIX)->fx_r_type != BFD_RELOC_386_GOTPC)
#define TARGET_ARCH bfd_arch_i386 #define TARGET_ARCH bfd_arch_i386
#define TARGET_BYTES_BIG_ENDIAN 0
#ifdef OBJ_AOUT #ifdef OBJ_AOUT
#ifdef TE_NetBSD #ifdef TE_NetBSD
@ -90,17 +91,26 @@
#define COFF_MAGIC I386MAGIC #define COFF_MAGIC I386MAGIC
#define BFD_ARCH bfd_arch_i386 #define BFD_ARCH bfd_arch_i386
#define COFF_FLAGS F_AR32WR #define COFF_FLAGS F_AR32WR
#define TC_COUNT_RELOC(x) ((x)->fx_addsy /* ||(x)->fx_subsy||(x)->fx_offset */) #define TC_COUNT_RELOC(x) ((x)->fx_addsy || (x)->fx_r_type==7)
#define TC_FORCE_RELOCATION(x) ((x)->fx_r_type==7)
#define TC_COFF_FIX2RTYPE(fixP) tc_coff_fix2rtype(fixP) #define TC_COFF_FIX2RTYPE(fixP) tc_coff_fix2rtype(fixP)
extern short tc_coff_fix2rtype (); extern short tc_coff_fix2rtype ();
#define TC_COFF_SIZEMACHDEP(frag) tc_coff_sizemachdep(frag) #define TC_COFF_SIZEMACHDEP(frag) tc_coff_sizemachdep(frag)
extern int tc_coff_sizemachdep PARAMS ((fragS *frag)); extern int tc_coff_sizemachdep PARAMS ((fragS *frag));
#define SUB_SEGMENT_ALIGN(SEG) 2 #define SUB_SEGMENT_ALIGN(SEG) 2
#define TC_RVA_RELOC 7
/* Need this for PIC relocations */ /* Need this for PIC relocations */
#define NEED_FX_R_TYPE #define NEED_FX_R_TYPE
#ifdef TE_386BSD
/* The BSDI linker apparently rejects objects with a machine type of
M_386 (100). */
#define AOUT_MACHTYPE 0
#else
#define AOUT_MACHTYPE 100 #define AOUT_MACHTYPE 100
#endif
#undef REVERSE_SORT_RELOCS #undef REVERSE_SORT_RELOCS
#endif /* ! BFD_ASSEMBLER */ #endif /* ! BFD_ASSEMBLER */
@ -113,11 +123,13 @@ extern int tc_coff_sizemachdep PARAMS ((fragS *frag));
#define tc_coff_symbol_emit_hook(a) ; /* not used */ #define tc_coff_symbol_emit_hook(a) ; /* not used */
#ifndef OBJ_AOUT #ifndef OBJ_AOUT
#ifndef TE_PE
/* Local labels starts with .L */ /* Local labels starts with .L */
#define LOCAL_LABEL(name) (name[0] == '.' \ #define LOCAL_LABEL(name) (name[0] == '.' \
&& (name[1] == 'L' || name[1] == 'X' || name[1] == '.')) && (name[1] == 'L' || name[1] == 'X' || name[1] == '.'))
#define FAKE_LABEL_NAME ".L0\001" #define FAKE_LABEL_NAME ".L0\001"
#endif #endif
#endif
#define LOCAL_LABELS_FB 1 #define LOCAL_LABELS_FB 1
#define tc_aout_pre_write_hook(x) {;} /* not used */ #define tc_aout_pre_write_hook(x) {;} /* not used */
@ -363,4 +375,40 @@ void i386_validate_fix ();
extern const struct relax_type md_relax_table[]; extern const struct relax_type md_relax_table[];
#define TC_GENERIC_RELAX_TABLE md_relax_table #define TC_GENERIC_RELAX_TABLE md_relax_table
extern int flag_16bit_code;
#define md_do_align(n, fill, len, max, around) \
if ((n) && !need_pass_2 \
&& (!(fill) || ((char)*(fill) == (char)0x90 && (len) == 1)) \
&& now_seg != data_section && now_seg != bss_section) \
{ \
char *p; \
p = frag_var (rs_align_code, 15, 1, (relax_substateT) max, \
(symbolS *) 0, (long) (n), (char *) 0); \
*p = 0x90; \
goto around; \
}
extern void i386_align_code PARAMS ((fragS *, int));
#define HANDLE_ALIGN(fragP) \
if (fragP->fr_type == rs_align_code) \
i386_align_code (fragP, (fragP->fr_next->fr_address \
- fragP->fr_address \
- fragP->fr_fix));
/* call md_apply_fix3 with segment instead of md_apply_fix */
#define MD_APPLY_FIX3
void i386_print_statistics PARAMS ((FILE *));
#define tc_print_statistics i386_print_statistics
#define md_number_to_chars number_to_chars_littleendian
#ifdef SCO_ELF
#define tc_init_after_args() sco_id ()
extern void sco_id PARAMS ((void));
#endif
/* end of tc-i386.h */ /* end of tc-i386.h */

View File

@ -1,7 +1,7 @@
/* m88k.c -- Assembler for the Motorola 88000 /* m88k.c -- Assembler for the Motorola 88000
Contributed by Devon Bowen of Buffalo University Contributed by Devon Bowen of Buffalo University
and Torbjorn Granlund of the Swedish Institute of Computer Science. and Torbjorn Granlund of the Swedish Institute of Computer Science.
Copyright (C) 1989, 90, 91, 92, 93, 94, 95, 1996 Copyright (C) 1989, 90, 91, 92, 93, 94, 95, 96, 1997
Free Software Foundation, Inc. Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler. This file is part of GAS, the GNU Assembler.
@ -17,8 +17,9 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to along with GAS; see the file COPYING. If not, write to the Free
the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA. */
#include <ctype.h> #include <ctype.h>
#include "as.h" #include "as.h"
@ -1291,7 +1292,7 @@ s_bss ()
subseg_set (SEG_BSS, 1); /* switch to bss */ subseg_set (SEG_BSS, 1); /* switch to bss */
if (bss_align) if (bss_align)
frag_align (bss_align, 0); frag_align (bss_align, 0, 0);
/* detach from old frag */ /* detach from old frag */
if (symbolP->sy_type == N_BSS && symbolP->sy_frag != NULL) if (symbolP->sy_type == N_BSS && symbolP->sy_frag != NULL)
@ -1433,16 +1434,17 @@ md_pcrel_from (fixp)
/* When we align the .init section, insert the correct NOP pattern. */ /* When we align the .init section, insert the correct NOP pattern. */
int int
m88k_do_align (n, fill, len) m88k_do_align (n, fill, max, len)
int n; int n;
const char *fill; const char *fill;
int len; int len;
int max;
{ {
if ((fill == NULL || (*fill == 0 && len == 1)) if ((fill == NULL || (*fill == 0 && len == 1))
&& strcmp (obj_segment_name (now_seg), ".init") == 0) && strcmp (obj_segment_name (now_seg), ".init") == 0)
{ {
static const unsigned char nop_pattern[] = { 0xf4, 0x00, 0x58, 0x00 }; static const unsigned char nop_pattern[] = { 0xf4, 0x00, 0x58, 0x00 };
frag_align_pattern (n, nop_pattern, sizeof (nop_pattern)); frag_align_pattern (n, nop_pattern, sizeof (nop_pattern), max);
return 1; return 1;
} }
return 0; return 0;

View File

@ -1,7 +1,7 @@
/* m88k.h -- Assembler for the Motorola 88000 /* m88k.h -- Assembler for the Motorola 88000
Contributed by Devon Bowen of Buffalo University Contributed by Devon Bowen of Buffalo University
and Torbjorn Granlund of the Swedish Institute of Computer Science. and Torbjorn Granlund of the Swedish Institute of Computer Science.
Copyright (C) 1989, 90, 91, 92, 93, 94, 95, 1996 Copyright (C) 1989, 90, 91, 92, 93, 94, 95, 96, 1997
Free Software Foundation, Inc. Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler. This file is part of GAS, the GNU Assembler.
@ -17,8 +17,9 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to along with GAS; see the file COPYING. If not, write to the Free
the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA. */
#define TC_M88K #define TC_M88K
@ -98,7 +99,7 @@ struct reloc_info_m88k
/* We use a special alignment function to insert the correct nop /* We use a special alignment function to insert the correct nop
pattern in .init. */ pattern in .init. */
extern int m88k_do_align PARAMS ((int, const char *, int)); extern int m88k_do_align PARAMS ((int, const char *, int, int));
#define md_do_align(n,fill,len,l) if (m88k_do_align(n,fill,len)) goto l #define md_do_align(n,fill,len,max,l) if (m88k_do_align(n,fill,max,len)) goto l
#endif /* M88KCOFF */ #endif /* M88KCOFF */

View File

@ -495,8 +495,11 @@ The start of the following frag should be aligned on some boundary. In this
frag, @code{fr_offset} is the logarithm (base 2) of the alignment in bytes. frag, @code{fr_offset} is the logarithm (base 2) of the alignment in bytes.
(For example, if alignment on an 8-byte boundary were desired, @code{fr_offset} (For example, if alignment on an 8-byte boundary were desired, @code{fr_offset}
would have a value of 3.) The variable characters indicate the fill pattern to would have a value of 3.) The variable characters indicate the fill pattern to
be used. Target backends can use @code{rs_align_code} to handle certain types be used. The @code{fr_subtype} field holds the maximum number of bytes to skip
of alignment differently. when doing this alignment. If more bytes are needed, the alignment is not
done. An @code{fr_subtype} value of 0 means no maximum, which is the normal
case. Target backends can use @code{rs_align_code} to handle certain types of
alignment differently.
@item rs_broken_word @item rs_broken_word
This indicates that ``broken word'' processing should be done (@pxref{Broken This indicates that ``broken word'' processing should be done (@pxref{Broken
@ -858,6 +861,15 @@ expression. You can define this to handle special symbols in a special way.
If a symbol always has a certain value, you should normally enter it in the If a symbol always has a certain value, you should normally enter it in the
symbol table, perhaps using @code{reg_section}. symbol table, perhaps using @code{reg_section}.
@item md_undefined_symbol
@cindex md_undefined_symbol
GAS will call this function when a symbol table lookup fails, before it
creates a new symbol. Typically this would be used to supply symbols whose
name or value changes dynamically, possibly in a context sensitive way.
Predefined symbols with fixed values, such as register names or condition
codes, are typically entered directly into the symbol table when @code{md_begin}
is called.
@item md_operand @item md_operand
@cindex md_operand @cindex md_operand
GAS will call this function for any expression that can not be recognized. GAS will call this function for any expression that can not be recognized.