diff options
Diffstat (limited to 'gas/config')
-rw-r--r-- | gas/config/obj-coff.c | 12 | ||||
-rw-r--r-- | gas/config/tc-alpha.c | 70 | ||||
-rw-r--r-- | gas/config/tc-alpha.h | 5 | ||||
-rw-r--r-- | gas/config/tc-i386.h | 7 | ||||
-rw-r--r-- | gas/config/tc-ia64.c | 64 | ||||
-rw-r--r-- | gas/config/tc-ia64.h | 8 | ||||
-rw-r--r-- | gas/config/tc-m32r.c | 76 | ||||
-rw-r--r-- | gas/config/tc-m32r.h | 10 | ||||
-rw-r--r-- | gas/config/tc-m88k.c | 37 | ||||
-rw-r--r-- | gas/config/tc-m88k.h | 9 | ||||
-rw-r--r-- | gas/config/tc-mips.c | 41 | ||||
-rw-r--r-- | gas/config/tc-mips.h | 6 | ||||
-rw-r--r-- | gas/config/tc-sh.c | 72 | ||||
-rw-r--r-- | gas/config/tc-sh.h | 7 | ||||
-rw-r--r-- | gas/config/tc-sparc.c | 76 | ||||
-rw-r--r-- | gas/config/tc-sparc.h | 19 |
16 files changed, 289 insertions, 230 deletions
diff --git a/gas/config/obj-coff.c b/gas/config/obj-coff.c index 67e6075..e16e5df 100644 --- a/gas/config/obj-coff.c +++ b/gas/config/obj-coff.c @@ -1826,6 +1826,7 @@ size_section (abfd, idx) break; case rs_align: case rs_align_code: + case rs_align_test: { addressT off; @@ -2135,6 +2136,7 @@ fill_section (abfd, h, file_cursor) case rs_fill: case rs_align: case rs_align_code: + case rs_align_test: case rs_org: if (frag->fr_fix) { @@ -3443,12 +3445,15 @@ write_object_file () md_do_align (SUB_SEGMENT_ALIGN (now_seg), (char *) NULL, 0, 0, alignment_done); #endif - frag_align (SUB_SEGMENT_ALIGN (now_seg), - subseg_text_p (now_seg) ? NOP_OPCODE : 0, - 0); + if (subseg_text_p (now_seg)) + frag_align_code (SUB_SEGMENT_ALIGN (now_seg), 0); + else + frag_align (SUB_SEGMENT_ALIGN (now_seg), 0, 0); + #ifdef md_do_align alignment_done: #endif + frag_wane (frag_now); frag_now->fr_fix = 0; know (frag_now->fr_next == NULL); @@ -4092,6 +4097,7 @@ fixup_mdeps (frags, h, this_segment) { case rs_align: case rs_align_code: + case rs_align_test: case rs_org: #ifdef HANDLE_ALIGN HANDLE_ALIGN (frags); diff --git a/gas/config/tc-alpha.c b/gas/config/tc-alpha.c index 6a7116e..01e9bbd 100644 --- a/gas/config/tc-alpha.c +++ b/gas/config/tc-alpha.c @@ -5673,27 +5673,8 @@ alpha_align (n, pfill, label, force) if (pfill == NULL) { - if (n > 2 - && (bfd_get_section_flags (stdoutput, now_seg) & SEC_CODE) != 0) - { - static char const unop[4] = { 0x00, 0x00, 0xe0, 0x2f }; - static char const nopunop[8] = { - 0x1f, 0x04, 0xff, 0x47, - 0x00, 0x00, 0xe0, 0x2f - }; - - /* First, make sure we're on a four-byte boundary, in case - someone has been putting .byte values into the text - section. The DEC assembler silently fills with unaligned - no-op instructions. This will zero-fill, then nop-fill - with proper alignment. */ - if (alpha_current_align < 2) - frag_align (2, 0, 0); - if (alpha_current_align < 3) - frag_align_pattern (3, unop, sizeof unop, 0); - if (n > 3) - frag_align_pattern (n, nopunop, sizeof nopunop, 0); - } + if (subseg_text_p (now_seg)) + frag_align_code (n, 0); else frag_align (n, 0, 0); } @@ -5710,10 +5691,55 @@ alpha_align (n, pfill, label, force) record_alignment (now_seg, n); - /* ??? if alpha_flag_relax && force && elf, record the requested alignment + /* ??? If alpha_flag_relax && force && elf, record the requested alignment in a reloc for the linker to see. */ } +/* This is called from HANDLE_ALIGN in write.c. Fill in the contents + of an rs_align_code fragment. */ + +void +alpha_handle_align (fragp) + fragS *fragp; +{ + static char const unop[4] = { 0x00, 0x00, 0xe0, 0x2f }; + static char const nopunop[8] = { + 0x1f, 0x04, 0xff, 0x47, + 0x00, 0x00, 0xe0, 0x2f + }; + + int bytes, fix; + char *p; + + if (fragp->fr_type != rs_align_code) + return; + + bytes = fragp->fr_next->fr_address - fragp->fr_address - fragp->fr_fix; + p = fragp->fr_literal + fragp->fr_fix; + fix = 0; + + if (bytes & 3) + { + fix = bytes & 3; + memset (p, 0, fix); + p += fix; + bytes -= fix; + } + + if (bytes & 4) + { + memcpy (p, unop, 4); + p += 4; + bytes -= 4; + fix += 4; + } + + memcpy (p, nopunop, 8); + + fragp->fr_fix += fix; + fragp->fr_var = 8; +} + /* The Alpha has support for some VAX floating point types, as well as for IEEE floating point. We consider IEEE to be the primary floating point format, and sneak in the VAX floating point support here. */ diff --git a/gas/config/tc-alpha.h b/gas/config/tc-alpha.h index b4335e3..7edc412 100644 --- a/gas/config/tc-alpha.h +++ b/gas/config/tc-alpha.h @@ -90,6 +90,11 @@ extern void alpha_define_label PARAMS ((symbolS *)); #define md_cons_align(nbytes) alpha_cons_align (nbytes) extern void alpha_cons_align PARAMS ((int)); +#define HANDLE_ALIGN(fragp) alpha_handle_align (fragp) +extern void alpha_handle_align PARAMS ((struct frag *)); + +#define MAX_MEM_FOR_RS_ALIGN_CODE (3 + 4 + 8) + #ifdef OBJ_ECOFF #define tc_frob_file_before_adjust() alpha_frob_file_before_adjust () extern void alpha_frob_file_before_adjust PARAMS ((void)); diff --git a/gas/config/tc-i386.h b/gas/config/tc-i386.h index 3c2efbf..9648201 100644 --- a/gas/config/tc-i386.h +++ b/gas/config/tc-i386.h @@ -505,13 +505,12 @@ if ((n) && !need_pass_2 \ && (!(fill) || ((char)*(fill) == (char)0x90 && (len) == 1)) \ && subseg_text_p (now_seg)) \ { \ - char *p; \ - p = frag_var (rs_align_code, 15, 1, (relax_substateT) max, \ - (symbolS *) 0, (offsetT) (n), (char *) 0); \ - *p = 0x90; \ + frag_align_code ((n), (max)); \ goto around; \ } +#define MAX_MEM_FOR_RS_ALIGN_CODE 15 + extern void i386_align_code PARAMS ((fragS *, int)); #define HANDLE_ALIGN(fragP) \ diff --git a/gas/config/tc-ia64.c b/gas/config/tc-ia64.c index 9bf22a8..b0ff7ed 100644 --- a/gas/config/tc-ia64.c +++ b/gas/config/tc-ia64.c @@ -9768,42 +9768,52 @@ md_section_align (seg, size) /* Handle ia64 specific semantics of the align directive. */ -int +void ia64_md_do_align (n, fill, len, max) int n; const char *fill; int len ATTRIBUTE_UNUSED; int max; { - /* Fill any pending bundle with nops. */ - if (bfd_get_section_flags (stdoutput, now_seg) & SEC_CODE) + if (subseg_text_p (now_seg)) ia64_flush_insns (); +} - /* When we align code in a text section, emit a bundle of 3 nops instead of - zero bytes. We can only do this if a multiple of 16 bytes was requested. - N is log base 2 of the requested alignment. */ - if (fill == NULL - && bfd_get_section_flags (stdoutput, now_seg) & SEC_CODE - && n > 4) - { - /* Use mfi bundle of nops with no stop bits. */ - static const unsigned char be_nop[] - = { 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0c}; - static const unsigned char le_nop[] - = { 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00}; - - /* Make sure we are on a 16-byte boundary, in case someone has been - putting data into a text section. */ - frag_align (4, 0, 0); +/* This is called from HANDLE_ALIGN in write.c. Fill in the contents + of an rs_align_code fragment. */ - if (target_big_endian) - frag_align_pattern (n, be_nop, 16, max); - else - frag_align_pattern (n, le_nop, 16, max); - return 1; +void +ia64_handle_align (fragp) + fragS *fragp; +{ + /* Use mfi bundle of nops with no stop bits. */ + static const unsigned char be_nop[] + = { 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0c}; + static const unsigned char le_nop[] + = { 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00}; + + int bytes; + char *p; + + if (fragp->fr_type != rs_align_code) + return; + + bytes = fragp->fr_next->fr_address - fragp->fr_address - fragp->fr_fix; + p = fragp->fr_literal + fragp->fr_fix; + + /* Make sure we are on a 16-byte boundary, in case someone has been + putting data into a text section. */ + if (bytes & 15) + { + int fix = bytes & 15; + memset (p, 0, fix); + p += fix; + bytes -= fix; + fragp->fr_fix += fix; } - return 0; + memcpy (p, (target_big_endian ? be_nop : le_nop), 16); + fragp->fr_var = 16; } diff --git a/gas/config/tc-ia64.h b/gas/config/tc-ia64.h index 73add66..fd802de 100644 --- a/gas/config/tc-ia64.h +++ b/gas/config/tc-ia64.h @@ -83,7 +83,8 @@ extern void ia64_validate_fix PARAMS ((struct fix *fix)); extern char * ia64_canonicalize_symbol_name PARAMS ((char *)); extern flagword ia64_elf_section_flags PARAMS ((flagword, int, int)); extern long ia64_pcrel_from_section PARAMS ((struct fix *fix, segT sec)); -extern int ia64_md_do_align PARAMS ((int, const char *, int, int)); +extern void ia64_md_do_align PARAMS ((int, const char *, int, int)); +extern void ia64_handle_align PARAMS ((fragS *f)); #define md_end() ia64_end_of_source () #define md_start_line_hook() ia64_start_line () @@ -108,7 +109,10 @@ extern int ia64_md_do_align PARAMS ((int, const char *, int, int)); #define TC_CONS_FIX_NEW(f,o,l,e) ia64_cons_fix_new (f, o, l, e) #define TC_VALIDATE_FIX(fix,seg,skip) ia64_validate_fix (fix) #define MD_PCREL_FROM_SECTION(fix,sec) ia64_pcrel_from_section (fix, sec) -#define md_do_align(n,f,l,m,j) if (ia64_md_do_align (n,f,l,m)) goto j +#define md_do_align(n,f,l,m,j) ia64_md_do_align (n,f,l,m) +#define HANDLE_ALIGN(f) ia64_handle_align (f) + +#define MAX_MEM_FOR_RS_ALIGN_CODE (15 + 16) /* Call md_apply_fix3 with segment instead of md_apply_fix. */ #define MD_APPLY_FIX3 diff --git a/gas/config/tc-m32r.c b/gas/config/tc-m32r.c index 4bf21da..d31dd8d 100644 --- a/gas/config/tc-m32r.c +++ b/gas/config/tc-m32r.c @@ -327,54 +327,44 @@ const pseudo_typeS md_pseudo_table[] = #define NOP_INSN 0x7000 #define PAR_NOP_INSN 0xf000 /* Can only be used in 2nd slot. */ -/* When we align the .text section, insert the correct NOP pattern. - N is the power of 2 alignment. LEN is the length of pattern FILL. - MAX is the maximum number of characters to skip when doing the alignment, - or 0 if there is no maximum. */ +/* This is called from HANDLE_ALIGN in write.c. Fill in the contents + of an rs_align_code fragment. */ -int -m32r_do_align (n, fill, len, max) - int n; - const char *fill; - int len; - int max; +void +m32r_handle_align (fragp) { - /* Only do this if the fill pattern wasn't specified. */ - if (fill == NULL - && subseg_text_p (now_seg) - /* Only do this special handling if aligning to at least a - 4 byte boundary. */ - && n > 1 - /* Only do this special handling if we're allowed to emit at - least two bytes. */ - && (max == 0 || max > 1)) - { - static const unsigned char nop_pattern[] = { 0xf0, 0x00 }; + static const unsigned char nop_pattern[] = { 0xf0, 0x00 }; + static const unsigned char multi_nop_pattern[] = { 0x70, 0x00, 0xf0, 0x00 }; -#if 0 - /* First align to a 2 byte boundary, in case there is an odd .byte. */ - /* FIXME: How much memory will cause gas to use when assembling a big - program? Perhaps we can avoid the frag_align call? */ - frag_align (1, 0, 0); -#endif - /* Next align to a 4 byte boundary (we know n >= 2) using a parallel - nop. */ - frag_align_pattern (2, nop_pattern, sizeof nop_pattern, 0); - /* If doing larger alignments use a repeating sequence of appropriate - nops. */ - if (n > 2) - { - static const unsigned char multi_nop_pattern[] = - { 0x70, 0x00, 0xf0, 0x00 }; - frag_align_pattern (n, multi_nop_pattern, sizeof multi_nop_pattern, - max ? max - 2 : 0); - } + int bytes, fix; + char *p; - prev_insn.insn = NULL; - return 1; + if (fragp->fr_type != rs_align_code) + return; + + bytes = fragp->fr_next->fr_address - fragp->fr_address - fragp->fr_fix; + p = fragp->fr_literal + fragp->fr_fix; + fix = 0; + + if (bytes & 1) + { + fix = 1; + *p++ = 0; + bytes--; } - return 0; + if (bytes & 2) + { + memcpy (p, nop_pattern, 2); + p += 2; + bytes -= 2; + fix += 2; + } + + memcpy (p, multi_nop_pattern, 4); + + fragp->fr_fix += fix; + fragp->fr_var = 4; } /* If the last instruction was the first of 2 16 bit insns, @@ -390,7 +380,7 @@ static void fill_insn (ignore) int ignore; { - (void) m32r_do_align (2, NULL, 0, 0); + frag_align_code (2, 0); prev_insn.insn = NULL; seen_relaxable_p = 0; } diff --git a/gas/config/tc-m32r.h b/gas/config/tc-m32r.h index 2191947..9e04c19 100644 --- a/gas/config/tc-m32r.h +++ b/gas/config/tc-m32r.h @@ -61,11 +61,11 @@ m32r_relax_frag (fragP, stretch) /* Account for nop if 32 bit insn falls on odd halfword boundary. */ #define TC_CGEN_MAX_RELAX(insn, len) (6) -/* Alignments are used to ensure 32 bit insns live on 32 bit boundaries, so - we use a special alignment function to insert the correct nop pattern. */ -extern int m32r_do_align PARAMS ((int, const char *, int, int)); -#define md_do_align(n, fill, len, max, l) \ -if (m32r_do_align (n, fill, len, max)) goto l +/* Fill in rs_align_code fragments. */ +extern void m32r_handle_align PARAMS ((fragS *)); +#define HANDLE_ALIGN(f) m32r_handle_align (f) + +#define MAX_MEM_FOR_RS_ALIGN_CODE (1 + 2 + 4) #define MD_APPLY_FIX3 #define md_apply_fix3 gas_cgen_md_apply_fix3 diff --git a/gas/config/tc-m88k.c b/gas/config/tc-m88k.c index 86496cf..af243b2 100644 --- a/gas/config/tc-m88k.c +++ b/gas/config/tc-m88k.c @@ -1427,23 +1427,34 @@ md_pcrel_from (fixp) /*NOTREACHED*/ } -/* When we align the .init section, insert the correct NOP pattern. */ +/* Fill in rs_align_code fragments. */ -int -m88k_do_align (n, fill, max, len) - int n; - const char *fill; - int len; - int max; +void +m88k_handle_align (fragp) + fragS *fragp; { - if (fill == NULL - && strcmp (obj_segment_name (now_seg), ".init") == 0) + static const unsigned char nop_pattern[] = { 0xf4, 0x00, 0x58, 0x00 }; + + int bytes; + char *p; + + if (fragp->fr_type != rs_align_code) + return; + + bytes = fragp->fr_next->fr_address - fragp->fr_address - fragp->fr_fix; + p = fragp->fr_literal + fragp->fr_fix; + + if (bytes & 3) { - static const unsigned char nop_pattern[] = { 0xf4, 0x00, 0x58, 0x00 }; - frag_align_pattern (n, nop_pattern, sizeof (nop_pattern), max); - return 1; + int fix = bytes & 3; + memset (p, 0, fix); + p += fix; + bytes -= fix; + fragp->fr_fix += fix; } - return 0; + + memcpy (p, nop_pattern, 4); + fragp->fr_var = 4; } #endif /* M88KCOFF */ diff --git a/gas/config/tc-m88k.h b/gas/config/tc-m88k.h index cbd69c8..6e28820 100644 --- a/gas/config/tc-m88k.h +++ b/gas/config/tc-m88k.h @@ -100,9 +100,10 @@ struct reloc_info_m88k #endif #define SUB_SEGMENT_ALIGN(SEG) max (section_alignment[(int) (SEG)], 4) -/* We use a special alignment function to insert the correct nop - pattern in .init. */ -extern int m88k_do_align PARAMS ((int, const char *, int, int)); -#define md_do_align(n,fill,len,max,l) if (m88k_do_align(n,fill,max,len)) goto l +/* Fill in rs_align_code fragments. */ +extern void m88k_handle_align PARAMS ((fragS *)); +#define HANDLE_ALIGN(frag) m88k_handle_align (frag) + +#define MAX_MEM_FOR_RS_ALIGN_CODE (3 + 4) #endif /* M88KCOFF */ diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c index 02abcc5..a0405852 100644 --- a/gas/config/tc-mips.c +++ b/gas/config/tc-mips.c @@ -11550,34 +11550,37 @@ static procS cur_proc; static procS *cur_proc_ptr; static int numprocs; -/* When we align code in the .text section of mips16, use the correct two - byte nop pattern of 0x6500 (move $0,$0) */ +/* Fill in an rs_align_code fragment. */ -int -mips_do_align (n, fill, len, max) - int n; - const char *fill; - int len ATTRIBUTE_UNUSED; - int max; +void +mips_handle_align (fragp) + fragS *fragp; { - if (fill == NULL - && subseg_text_p (now_seg) - && n > 1 - && mips_opts.mips16) + if (fragp->fr_type != rs_align_code) + return; + + if (mips_opts.mips16) { static const unsigned char be_nop[] = { 0x65, 0x00 }; static const unsigned char le_nop[] = { 0x00, 0x65 }; - frag_align (1, 0, 0); + int bytes; + char *p; - if (target_big_endian) - frag_align_pattern (n, be_nop, 2, max); - else - frag_align_pattern (n, le_nop, 2, max); - return 1; + bytes = fragp->fr_next->fr_address - fragp->fr_address - fragp->fr_fix; + p = fragp->fr_literal + fragp->fr_fix; + + if (bytes & 1) + { + *p++ = 0; + fragp->fr_fix += 1; + } + + memcpy (p, (target_big_endian ? be_nop : le_nop), 2); + fragp->fr_var = 2; } - return 0; + /* For mips32, a nop is a zero, which we trivially get by doing nothing. */ } static void diff --git a/gas/config/tc-mips.h b/gas/config/tc-mips.h index 14ac44f..561d5d7 100644 --- a/gas/config/tc-mips.h +++ b/gas/config/tc-mips.h @@ -55,8 +55,10 @@ extern int mips_relax_frag PARAMS ((struct frag *, long)); #define md_undefined_symbol(name) (0) #define md_operand(x) -extern int mips_do_align PARAMS ((int, const char *, int, int)); -#define md_do_align(n,fill,len,max,l) if (mips_do_align (n,fill,len,max)) goto l +extern void mips_handle_align PARAMS ((struct frag *)); +#define HANDLE_ALIGN(fragp) mips_handle_align (fragp) + +#define MAX_MEM_FOR_RS_ALIGN_CODE (1 + 2) /* We permit PC relative difference expressions when generating embedded PIC code. */ 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 diff --git a/gas/config/tc-sh.h b/gas/config/tc-sh.h index ed17a47..eebc21a 100644 --- a/gas/config/tc-sh.h +++ b/gas/config/tc-sh.h @@ -53,6 +53,8 @@ extern void sh_cons_align PARAMS ((int)); #define HANDLE_ALIGN(frag) sh_handle_align (frag) extern void sh_handle_align PARAMS ((fragS *)); +#define MAX_MEM_FOR_RS_ALIGN_CODE (1 + 2) + /* We need to force out some relocations when relaxing. */ #define TC_FORCE_RELOCATION(fix) sh_force_relocation (fix) extern int sh_force_relocation (); @@ -76,11 +78,6 @@ extern boolean sh_fix_adjustable PARAMS ((struct fix *)); extern const struct relax_type md_relax_table[]; #define TC_GENERIC_RELAX_TABLE md_relax_table -/* We use a special alignment function to insert the correct nop - pattern. */ -extern int sh_do_align PARAMS ((int, const char *, int, int)); -#define md_do_align(n,fill,len,max,l) if (sh_do_align (n,fill,len,max)) goto l - /* We record, for each section, whether we have most recently output a CODE reloc or a DATA reloc. */ struct sh_segment_info_type diff --git a/gas/config/tc-sparc.c b/gas/config/tc-sparc.c index 850e606..d606267 100644 --- a/gas/config/tc-sparc.c +++ b/gas/config/tc-sparc.c @@ -4085,53 +4085,65 @@ sparc_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); } -/* This is where we do the unexpected alignment check. - This is called from HANDLE_ALIGN in tc-sparc.h. */ +/* This is called from HANDLE_ALIGN in tc-sparc.h. */ void sparc_handle_align (fragp) fragS *fragp; { - if (fragp->fr_type == rs_align_code && !fragp->fr_subtype - && fragp->fr_next->fr_address - fragp->fr_address - fragp->fr_fix != 0) - as_bad_where (fragp->fr_file, fragp->fr_line, _("misaligned data")); - if (fragp->fr_type == rs_align_code && fragp->fr_subtype == 1024) + int count, fix; + char *p; + + count = fragp->fr_next->fr_address - fragp->fr_address - fragp->fr_fix; + + switch (fragp->fr_type) { - int count = - fragp->fr_next->fr_address - fragp->fr_address - fragp->fr_fix; + case rs_align_test: + if (count != 0) + as_bad_where (fragp->fr_file, fragp->fr_line, _("misaligned data")); + break; - if (count >= 4 - && !(count & 3) - && count <= 1024 - && !((long) (fragp->fr_literal + fragp->fr_fix) & 3)) - { - unsigned *p = (unsigned *) (fragp->fr_literal + fragp->fr_fix); - int i; + case rs_align_code: + p = fragp->fr_literal + fragp->fr_fix; + fix = 0; - for (i = 0; i < count; i += 4, p++) - if (INSN_BIG_ENDIAN) - /* Emit nops. */ - number_to_chars_bigendian ((char *) p, 0x01000000, 4); - else - number_to_chars_littleendian ((char *) p, 0x10000000, 4); + if (count & 3) + { + fix = count & 3; + memset (p, 0, fix); + p += fix; + count -= fix; + } - if (SPARC_OPCODE_ARCH_V9_P (max_architecture) && count > 8) - { - char *waddr = &fragp->fr_literal[fragp->fr_fix]; - unsigned wval = (0x30680000 | count >> 2); /* ba,a,pt %xcc, 1f */ - if (INSN_BIG_ENDIAN) - number_to_chars_bigendian (waddr, wval, 4); - else - number_to_chars_littleendian (waddr, wval, 4); - } - fragp->fr_var = count; + if (SPARC_OPCODE_ARCH_V9_P (max_architecture) && count > 8) + { + unsigned wval = (0x30680000 | count >> 2); /* ba,a,pt %xcc, 1f */ + if (INSN_BIG_ENDIAN) + number_to_chars_bigendian (p, wval, 4); + else + number_to_chars_littleendian (p, wval, 4); + p += 4; + count -= 4; + fix += 4; } + + if (INSN_BIG_ENDIAN) + number_to_chars_bigendian (p, 0x01000000, 4); + else + number_to_chars_littleendian (p, 0x01000000, 4); + + fragp->fr_fix += fix; + fragp->fr_var = 4; + break; + + default: + break; } } diff --git a/gas/config/tc-sparc.h b/gas/config/tc-sparc.h index 9a477ab..17bef83 100644 --- a/gas/config/tc-sparc.h +++ b/gas/config/tc-sparc.h @@ -50,31 +50,24 @@ extern const char *sparc_target_format PARAMS ((void)); #define WORKING_DOT_WORD -#define md_convert_frag(b,s,f) {as_fatal (_("sparc convert_frag\n"));} +#define md_convert_frag(b,s,f) \ + as_fatal (_("sparc convert_frag\n")) #define md_estimate_size_before_relax(f,s) \ - (as_fatal(_("estimate_size_before_relax called")),1) + (as_fatal(_("estimate_size_before_relax called")), 1) #define LISTING_HEADER "SPARC GAS " extern int sparc_pic_code; -#define md_do_align(n, fill, len, max, around) \ -if ((n) && (n) <= 10 && !need_pass_2 && !(fill) \ - && subseg_text_p (now_seg)) \ - { \ - char *p; \ - p = frag_var (rs_align_code, 1 << n, 1, (relax_substateT) 1024, \ - (symbolS *) 0, (offsetT) (n), (char *) 0); \ - *p = 0x00; \ - goto around; \ - } - /* We require .word, et. al., to be aligned correctly. */ #define md_cons_align(nbytes) sparc_cons_align (nbytes) extern void sparc_cons_align PARAMS ((int)); + #define HANDLE_ALIGN(fragp) sparc_handle_align (fragp) extern void sparc_handle_align PARAMS ((struct frag *)); +#define MAX_MEM_FOR_RS_ALIGN_CODE (3 + 4 + 4) + #if defined (OBJ_ELF) || defined (OBJ_AOUT) /* This expression evaluates to false if the relocation is for a local |