summaryrefslogtreecommitdiff
path: root/gas/config/obj-coff.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@bigpond.net.au>2002-05-23 08:08:48 +0000
committerAlan Modra <amodra@bigpond.net.au>2002-05-23 08:08:48 +0000
commitbec7ba6423bae2c455cee0f2eea123711feea646 (patch)
tree29de4e171e9fd1f2cf41d017996c971d3a4f4677 /gas/config/obj-coff.c
parent115f7498a958aa1d27cc6bb8ff9c55b1cde93fd4 (diff)
downloadbinutils-redhat-bec7ba6423bae2c455cee0f2eea123711feea646.tar.gz
* 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/config/obj-coff.c')
-rw-r--r--gas/config/obj-coff.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/gas/config/obj-coff.c b/gas/config/obj-coff.c
index 72233b81d1..c48ba63f1b 100644
--- a/gas/config/obj-coff.c
+++ b/gas/config/obj-coff.c
@@ -3420,6 +3420,19 @@ remove_subsegs ()
unsigned long machine;
int coff_flags;
+#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
+#define SUB_SEGMENT_ALIGN(SEG, FRCHAIN) 1
+#endif
+#endif
+
extern void
write_object_file ()
{
@@ -3443,28 +3456,27 @@ write_object_file ()
string_byte_count = 4;
+ /* Run through all the sub-segments and align them up. Also
+ close any open frags. We tack a .fill onto the end of the
+ frag chain so that any .align's size can be worked by looking
+ at the next frag. */
for (frchain_ptr = frchain_root;
frchain_ptr != (struct frchain *) NULL;
frchain_ptr = frchain_ptr->frch_next)
{
- /* Run through all the sub-segments and align them up. Also
- close any open frags. We tack a .fill onto the end of the
- frag chain so that any .align's size can be worked by looking
- at the next frag. */
+ int alignment;
subseg_set (frchain_ptr->frch_seg, frchain_ptr->frch_subseg);
-#ifndef SUB_SEGMENT_ALIGN
-#define SUB_SEGMENT_ALIGN(SEG) 1
-#endif
+ alignment = SUB_SEGMENT_ALIGN (now_seg, frchain_ptr)
+
#ifdef md_do_align
- md_do_align (SUB_SEGMENT_ALIGN (now_seg), (char *) NULL, 0, 0,
- alignment_done);
+ md_do_align (alignment, (char *) NULL, 0, 0, alignment_done);
#endif
if (subseg_text_p (now_seg))
- frag_align_code (SUB_SEGMENT_ALIGN (now_seg), 0);
+ frag_align_code (alignment, 0);
else
- frag_align (SUB_SEGMENT_ALIGN (now_seg), 0, 0);
+ frag_align (alignment, 0, 0);
#ifdef md_do_align
alignment_done: