diff options
author | Alan Modra <amodra@gmail.com> | 2002-05-23 08:08:48 +0000 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2002-05-23 08:08:48 +0000 |
commit | 18e1d4877373547c80bd8ac79a7884390f95f4a9 (patch) | |
tree | 54dc8c8f5a258a3981dd58f51b324f800359aa5c /gas/write.c | |
parent | 9d66a1d9d68238024e4accd78e82f3432c6292af (diff) | |
download | gdb-18e1d4877373547c80bd8ac79a7884390f95f4a9.zip gdb-18e1d4877373547c80bd8ac79a7884390f95f4a9.tar.gz gdb-18e1d4877373547c80bd8ac79a7884390f95f4a9.tar.bz2 |
* write.c (size_seg): Check adjustment to last frag.
(SUB_SEGMENT_ALIGN): If HANDLE_ALIGN defined, pad out last frag to
section alignment.
* config/obj-coff.c (SUB_SEGMENT_ALIGN): Likewise.
* config/obj-ieee.c (SUB_SEGMENT_ALIGN): Likewise.
(write_object_file): Invoke md_do_align if available, and use
frag_align_code on text sections.
* config/obj-vms.h (SUB_SEGMENT_ALIGN): Now two args.
* config/tc-m88k.h (SUB_SEGMENT_ALIGN): Likewise.
* config/tc-ppc.h (SUB_SEGMENT_ALIGN): Likewise.
* config/tc-sh.h (SUB_SEGMENT_ALIGN): Likewise.
* config/tc-i386.h (SUB_SEGMENT_ALIGN): Likewise. Define for
BFD_ASSEMBLER too.
Diffstat (limited to 'gas/write.c')
-rw-r--r-- | gas/write.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/gas/write.c b/gas/write.c index 8d08674..ce3ca8d 100644 --- a/gas/write.c +++ b/gas/write.c @@ -678,7 +678,14 @@ size_seg (abfd, sec, xxx) while (fragp->fr_next != last) fragp = fragp->fr_next; last->fr_address = size; - fragp->fr_offset += newsize - size; + if ((newsize - size) % fragp->fr_var == 0) + fragp->fr_offset += (newsize - size) / fragp->fr_var; + else + /* If we hit this abort, it's likely due to subsegs_finish not + providing sufficient alignment on the last frag, and the + machine dependent code using alignment frags with fr_var + greater than 1. */ + abort (); } #ifdef tc_frob_section @@ -1418,10 +1425,19 @@ set_segment_vma (abfd, sec, xxx) makes calculating their intended length trivial. */ #ifndef SUB_SEGMENT_ALIGN +#ifdef HANDLE_ALIGN +/* 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. */ +#define SUB_SEGMENT_ALIGN(SEG, FRCHAIN) \ + (!(FRCHAIN)->frch_next || (FRCHAIN)->frch_next->frch_seg != (SEG) \ + ? get_recorded_alignment (SEG) : 0) +#else #ifdef BFD_ASSEMBLER -#define SUB_SEGMENT_ALIGN(SEG) (0) +#define SUB_SEGMENT_ALIGN(SEG, FRCHAIN) 0 #else -#define SUB_SEGMENT_ALIGN(SEG) (2) +#define SUB_SEGMENT_ALIGN(SEG, FRCHAIN) 2 +#endif #endif #endif @@ -1432,14 +1448,15 @@ subsegs_finish () for (frchainP = frchain_root; frchainP; frchainP = frchainP->frch_next) { - int alignment; + int alignment = 0; 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. */ - alignment = had_errors () ? 0 : SUB_SEGMENT_ALIGN (now_seg); + if (!had_errors ()) + alignment = SUB_SEGMENT_ALIGN (now_seg, frchainP); if (subseg_text_p (now_seg)) frag_align_code (alignment, 0); |