aboutsummaryrefslogtreecommitdiff
path: root/gas/write.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/write.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/write.c')
-rw-r--r--gas/write.c42
1 files changed, 33 insertions, 9 deletions
diff --git a/gas/write.c b/gas/write.c
index 4599338..897e707 100644
--- a/gas/write.c
+++ b/gas/write.c
@@ -31,12 +31,6 @@
#undef BFD_FAST_SECTION_FILL
#define BFD_FAST_SECTION_FILL
-/* The NOP_OPCODE is for the alignment fill value. Fill it with a nop
- instruction so that the disassembler does not choke on it. */
-#ifndef NOP_OPCODE
-#define NOP_OPCODE 0x00
-#endif
-
#ifndef TC_ADJUST_RELOC_COUNT
#define TC_ADJUST_RELOC_COUNT(FIXP,COUNT)
#endif
@@ -383,6 +377,19 @@ record_alignment (seg, align)
#endif
}
+int
+get_recorded_alignment (seg)
+ segT seg;
+{
+ if (seg == absolute_section)
+ return 0;
+#ifdef BFD_ASSEMBLER
+ return bfd_get_section_alignment (stdoutput, seg);
+#else
+ return section_alignment[(int) seg];
+#endif
+}
+
#ifdef BFD_ASSEMBLER
/* Reset the section indices after removing the gas created sections. */
@@ -494,6 +501,7 @@ cvt_frag_to_fill (headersP, sec, fragP)
{
case rs_align:
case rs_align_code:
+ case rs_align_test:
case rs_org:
case rs_space:
#ifdef HANDLE_ALIGN
@@ -1390,14 +1398,28 @@ subsegs_finish ()
for (frchainP = frchain_root; frchainP; frchainP = frchainP->frch_next)
{
+ int alignment;
+
subseg_set (frchainP->frch_seg, frchainP->frch_subseg);
/* This now gets called even if we had errors. In that case,
any alignment is meaningless, and, moreover, will look weird
if we are generating a listing. */
- frag_align (had_errors () ? 0 : SUB_SEGMENT_ALIGN (now_seg),
- subseg_text_p (now_seg) ? NOP_OPCODE : 0,
- 0);
+ alignment = had_errors () ? 0 : SUB_SEGMENT_ALIGN (now_seg);
+
+ /* The last subsegment gets an aligment corresponding to the
+ alignment of the section. This allows proper nop-filling
+ at the end of code-bearing sections. */
+ if (!frchainP->frch_next || frchainP->frch_next->frch_seg != now_seg)
+ alignment = get_recorded_alignment (now_seg);
+
+ if (alignment > 0)
+ {
+ if (subseg_text_p (now_seg))
+ frag_align_code (alignment, 0);
+ else
+ frag_align (alignment, 0, 0);
+ }
/* frag_align will have left a new frag.
Use this last frag for an empty ".fill".
@@ -2156,6 +2178,7 @@ relax_segment (segment_frag_root, segment)
case rs_align:
case rs_align_code:
+ case rs_align_test:
{
addressT offset = relax_align (address, (int) fragP->fr_offset);
@@ -2305,6 +2328,7 @@ relax_segment (segment_frag_root, segment)
#endif
case rs_align:
case rs_align_code:
+ case rs_align_test:
{
addressT oldoff, newoff;