aboutsummaryrefslogtreecommitdiff
path: root/gas/config/tc-sh.c
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>2000-12-28 10:07:56 +0000
committerRichard Henderson <rth@redhat.com>2000-12-28 10:07:56 +0000
commit0a9ef439079f50221dad9eb5248387236d370c87 (patch)
treec9e2b708439e46a331746ead00c3c709f5c82bb9 /gas/config/tc-sh.c
parentbda9cb723c0f733f03ed6fe74dfc3b87fe5e775f (diff)
downloadgdb-0a9ef439079f50221dad9eb5248387236d370c87.zip
gdb-0a9ef439079f50221dad9eb5248387236d370c87.tar.gz
gdb-0a9ef439079f50221dad9eb5248387236d370c87.tar.bz2
* as.h (rs_align_test): New.
* frags.c (NOP_OPCODE): Move default from read.c. (MAX_MEM_FOR_RS_ALIGN_CODE): New default. (frag_align_code): New. * frags.h (frag_align_code): Declare. * read.c (NOP_OPCODE): Remove. (do_align): Use frag_align_code. * write.c (NOP_OPCODE): Remove. (get_recorded_alignment): New. (cvt_frag_to_fill): Handle rs_align_test. (relax_segment): Likewise. (subsegs_finish): Align last subseg in section to the section alignment. Use frag_align_code. * write.h (get_recorded_alignment): Declare. * config/obj-coff.c (size_section): Handle rs_align_test. (fill_section, fixup_mdeps): Likewise. (write_object_file): Use frag_align_code. * config/tc-alpha.c (alpha_align): Use frag_align_code. (alpha_handle_align): New. * config/tc-alpha.h (HANDLE_ALIGN): New. (MAX_MEM_FOR_RS_ALIGN_CODE): New. * config/tc-i386.h (md_do_align): Use frag_align_code. (MAX_MEM_FOR_RS_ALIGN_CODE): New. * config/tc-ia64.c (ia64_md_do_align): Don't do code alignment. (ia64_handle_align): New. * config/tc-ia64.h (HANDLE_ALIGN): New. (MAX_MEM_FOR_RS_ALIGN_CODE): New. * config/tc-m32r.c (m32r_do_align): Remove. (m32r_handle_align): New. (fill_insn): Use frag_align_code. * config/tc-m32r.h (md_do_align): Remove. (HANDLE_ALIGN, MAX_MEM_FOR_RS_ALIGN_CODE): New. * config/tc-m88k.c, config/tc-m88k.h: Similarly. * config/tc-mips.c, config/tc-mips.h: Similarly. * config/tc-sh.c (sh_cons_align): Use rs_align_test. (sh_handle_align): Likewise. Handle rs_align_code. (sh_do_align): Remove. * config/tc-sh.h (md_do_align): Remove. (MAX_MEM_FOR_RS_ALIGN_CODE): New. * config/tc-sparc.c (sparc_cons_align): Use rs_align_test. (sparc_handle_align): Likewise. Handle rs_align_code. * config/tc-sparc.h (md_do_align): Remove. (MAX_MEM_FOR_RS_ALIGN_CODE): New.
Diffstat (limited to 'gas/config/tc-sh.c')
-rw-r--r--gas/config/tc-sh.c72
1 files changed, 36 insertions, 36 deletions
diff --git a/gas/config/tc-sh.c b/gas/config/tc-sh.c
index ee40584..275415a 100644
--- a/gas/config/tc-sh.c
+++ b/gas/config/tc-sh.c
@@ -2582,7 +2582,7 @@ sh_cons_align (nbytes)
return;
}
- p = frag_var (rs_align_code, 1, 1, (relax_substateT) 0,
+ p = frag_var (rs_align_test, 1, 1, (relax_substateT) 0,
(symbolS *) NULL, (offsetT) nalign, (char *) NULL);
record_alignment (now_seg, nalign);
@@ -2596,17 +2596,47 @@ void
sh_handle_align (frag)
fragS *frag;
{
+ int bytes = frag->fr_next->fr_address - frag->fr_address - frag->fr_fix;
+
+ if (frag->fr_type == rs_align_code)
+ {
+ static const unsigned char big_nop_pattern[] = { 0x00, 0x09 };
+ static const unsigned char little_nop_pattern[] = { 0x09, 0x00 };
+
+ char *p = frag->fr_literal + frag->fr_fix;
+
+ if (bytes & 1)
+ {
+ *p++ = 0;
+ bytes--;
+ frag->fr_fix += 1;
+ }
+
+ if (target_big_endian)
+ {
+ memcpy (p, big_nop_pattern, sizeof big_nop_pattern);
+ frag->fr_var = sizeof big_nop_pattern;
+ }
+ else
+ {
+ memcpy (p, little_nop_pattern, sizeof little_nop_pattern);
+ frag->fr_var = sizeof little_nop_pattern;
+ }
+ }
+ else if (frag->fr_type == rs_align_test)
+ {
+ if (bytes != 0)
+ as_warn_where (frag->fr_file, frag->fr_line, _("misaligned data"));
+ }
+
if (sh_relax
- && frag->fr_type == rs_align
+ && (frag->fr_type == rs_align
+ || frag->fr_type == rs_align_code)
&& frag->fr_address + frag->fr_fix > 0
&& frag->fr_offset > 1
&& now_seg != bss_section)
fix_new (frag, frag->fr_fix, 2, &abs_symbol, frag->fr_offset, 0,
BFD_RELOC_SH_ALIGN);
-
- if (frag->fr_type == rs_align_code
- && frag->fr_next->fr_address - frag->fr_address - frag->fr_fix != 0)
- as_warn_where (frag->fr_file, frag->fr_line, _("misaligned data"));
}
/* This macro decides whether a particular reloc is an entry in a
@@ -3082,36 +3112,6 @@ tc_coff_sizemachdep (frag)
#endif /* OBJ_COFF */
-/* When we align the .text section, insert the correct NOP pattern. */
-
-int
-sh_do_align (n, fill, len, max)
- int n;
- const char *fill;
- int len ATTRIBUTE_UNUSED;
- int max;
-{
- if (fill == NULL
- && subseg_text_p (now_seg)
- && n > 1)
- {
- static const unsigned char big_nop_pattern[] = { 0x00, 0x09 };
- static const unsigned char little_nop_pattern[] = { 0x09, 0x00 };
-
- /* First align to a 2 byte boundary, in case there is an odd
- .byte. */
- frag_align (1, 0, 0);
- if (target_big_endian)
- frag_align_pattern (n, big_nop_pattern, sizeof big_nop_pattern, max);
- else
- frag_align_pattern (n, little_nop_pattern, sizeof little_nop_pattern,
- max);
- return 1;
- }
-
- return 0;
-}
-
#ifndef BFD_ASSEMBLER
#ifdef OBJ_COFF