RIP gzip, we found a nicer playmate.
[dragonfly.git] / gnu / usr.bin / as / write.c
1 /* write.c - emit .o file
2
3    Copyright (C) 1986, 1987, 1990, 1991, 1992 Free Software Foundation, Inc.
4
5    This file is part of GAS, the GNU Assembler.
6
7    GAS is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2, or (at your option)
10    any later version.
11
12    GAS is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with GAS; see the file COPYING.  If not, write to
19    the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
20
21 /* This thing should be set up to do byteordering correctly.  But... */
22
23 /*
24  * $FreeBSD: src/gnu/usr.bin/as/write.c,v 1.11 1999/08/27 23:34:23 peter Exp $
25  * $DragonFly: src/gnu/usr.bin/as/Attic/write.c,v 1.2 2003/06/17 04:25:44 dillon Exp $
26  */
27 #include "as.h"
28 #include "subsegs.h"
29 #include "obstack.h"
30 #include "output-file.h"
31
32 /* The NOP_OPCODE is for the alignment fill value.
33  * fill it a nop instruction so that the disassembler does not choke
34  * on it
35  */
36 #ifndef NOP_OPCODE
37 #define NOP_OPCODE 0x00
38 #endif
39
40 #ifndef MANY_SEGMENTS
41 static struct frag *text_frag_root;
42 static struct frag *data_frag_root;
43
44 static struct frag *text_last_frag;     /* Last frag in segment. */
45 static struct frag *data_last_frag;     /* Last frag in segment. */
46 #endif
47
48 #ifndef WORKING_DOT_WORD
49 extern const int md_short_jump_size;
50 extern const int md_long_jump_size;
51 #endif
52
53 static object_headers headers;
54
55 long string_byte_count;
56
57 static char *the_object_file;
58
59 char *next_object_file_charP;   /* Tracks object file bytes. */
60
61 /* static long          length; JF unused */    /* String length, including trailing '\0'. */
62
63
64 #if __STDC__ == 1
65
66 static int is_dnrange(struct frag *f1, struct frag *f2);
67 static long fixup_segment(fixS *fixP, segT this_segment_type);
68 static relax_addressT relax_align(relax_addressT address, long alignment);
69 void relax_segment(struct frag *segment_frag_root, segT segment_type);
70
71 #else
72
73 static int is_dnrange();
74 static long fixup_segment();
75 static relax_addressT relax_align();
76 void relax_segment();
77
78 #endif /* not __STDC__ */
79
80 /*
81  *                      fix_new()
82  *
83  * Create a fixS in obstack 'notes'.
84  */
85 #ifdef PIC
86 fixS *fix_new(frag, where, size, add_symbol, sub_symbol, offset, pcrel, r_type, got_symbol)
87 #else
88 fixS *fix_new(frag, where, size, add_symbol, sub_symbol, offset, pcrel, r_type)
89 #endif
90 fragS *frag;            /* Which frag? */
91 int where;              /* Where in that frag? */
92 short int size;         /* 1, 2, or 4 usually. */
93 symbolS *add_symbol;    /* X_add_symbol. */
94 symbolS *sub_symbol;    /* X_subtract_symbol. */
95 #ifdef PIC
96 symbolS *got_symbol;    /* X_got. */
97 #endif
98 long offset;            /* X_add_number. */
99 int pcrel;              /* TRUE if PC-relative relocation. */
100 enum reloc_type r_type; /* Relocation type */
101 {
102         fixS *fixP;
103
104         fixP = (fixS *) obstack_alloc(&notes, sizeof(fixS));
105
106         fixP->fx_frag   = frag;
107         fixP->fx_where  = where;
108         fixP->fx_size   = size;
109         fixP->fx_addsy  = add_symbol;
110         fixP->fx_subsy  = sub_symbol;
111 #ifdef PIC
112         fixP->fx_gotsy  = got_symbol;
113         if (got_symbol)
114                 pcrel = 1;
115 #endif
116         fixP->fx_offset = offset;
117         fixP->fx_pcrel  = pcrel;
118         fixP->fx_r_type = r_type;
119
120         /* JF these 'cuz of the NS32K stuff */
121         fixP->fx_im_disp = 0;
122         fixP->fx_pcrel_adjust = 0;
123         fixP->fx_bsr = 0;
124         fixP->fx_bit_fixP = 0;
125
126         /* usually, we want relocs sorted numerically, but while
127            comparing to older versions of gas that have relocs
128            reverse sorted, it is convenient to have this compile
129            time option.  xoxorich. */
130
131 #ifdef REVERSE_SORT_RELOCS
132
133         fixP->fx_next = *seg_fix_rootP;
134         *seg_fix_rootP = fixP;
135
136 #else /* REVERSE_SORT_RELOCS */
137
138         fixP->fx_next   = NULL;
139
140         if (*seg_fix_tailP)
141             (*seg_fix_tailP)->fx_next = fixP;
142         else
143             *seg_fix_rootP = fixP;
144         *seg_fix_tailP = fixP;
145
146 #endif /* REVERSE_SORT_RELOCS */
147
148         fixP->fx_callj = 0;
149         return(fixP);
150 } /* fix_new() */
151
152 #ifndef BFD
153 void write_object_file()
154 {
155         register struct frchain *       frchainP; /* Track along all frchains. */
156         register fragS *                fragP;  /* Track along all frags. */
157         register struct frchain *       next_frchainP;
158         register fragS * *              prev_fragPP;
159         /*  register char *             name; */
160         /*  symbolS *symbolP; */
161         /*  register symbolS **         symbolPP; */
162         /* register fixS *              fixP; JF unused */
163         unsigned int data_siz;
164
165         long object_file_size;
166
167 #ifdef  OBJ_VMS
168         /*
169          *      Under VMS we try to be compatible with VAX-11 "C".  Thus, we
170          *      call a routine to check for the definition of the procedure
171          *      "_main", and if so -- fix it up so that it can be program
172          *      entry point.
173          */
174         VMS_Check_For_Main();
175 #endif /* OBJ_VMS */
176         /*
177          * After every sub-segment, we fake an ".align ...". This conforms to BSD4.2
178          * brane-damage. We then fake ".fill 0" because that is the kind of frag
179          * that requires least thought. ".align" frags like to have a following
180          * frag since that makes calculating their intended length trivial.
181          */
182 #ifndef SUB_SEGMENT_ALIGN
183 #define SUB_SEGMENT_ALIGN (2)
184 #endif
185         for (frchainP = frchain_root; frchainP; frchainP = frchainP->frch_next) {
186 #ifdef  OBJ_VMS
187                 /*
188                  *      Under VAX/VMS, the linker (and PSECT specifications)
189                  *      take care of correctly aligning the segments.
190                  *      Doing the alignment here (on initialized data) can
191                  *      mess up the calculation of global data PSECT sizes.
192                  */
193 #undef  SUB_SEGMENT_ALIGN
194 #define SUB_SEGMENT_ALIGN ((frchainP->frch_seg != SEG_DATA) ? 2 : 0)
195 #endif  /* OBJ_VMS */
196                 subseg_new (frchainP->frch_seg, frchainP->frch_subseg);
197                 frag_align (SUB_SEGMENT_ALIGN, NOP_OPCODE);
198                 /* frag_align will have left a new frag. */
199                 /* Use this last frag for an empty ".fill". */
200                 /*
201                  * For this segment ...
202                  * Create a last frag. Do not leave a "being filled in frag".
203                  */
204                 frag_wane (frag_now);
205                 frag_now->fr_fix        = 0;
206                 know( frag_now->fr_next == NULL );
207                 /* know(frags.obstack_c_base == frags.obstack_c_next_free); */
208                 /* Above shows we haven't left a half-completed object on obstack. */
209         } /* walk the frag chain */
210
211         /*
212          * From now on, we don't care about sub-segments.
213          * Build one frag chain for each segment. Linked thru fr_next.
214          * We know that there is at least 1 text frchain & at least 1 data frchain.
215          */
216         prev_fragPP = &text_frag_root;
217         for (frchainP = frchain_root; frchainP; frchainP = next_frchainP) {
218                 know( frchainP->frch_root );
219                 *prev_fragPP = frchainP->frch_root;
220                 prev_fragPP = & frchainP->frch_last->fr_next;
221
222                 if (((next_frchainP = frchainP->frch_next) == NULL)
223                     || next_frchainP == data0_frchainP) {
224                         prev_fragPP = &data_frag_root;
225                         if (next_frchainP) {
226                                 text_last_frag = frchainP->frch_last;
227                         } else {
228                                 data_last_frag = frchainP->frch_last;
229                         }
230                 }
231         } /* walk the frag chain */
232
233         /*
234          * We have two segments. If user gave -R flag, then we must put the
235          * data frags into the text segment. Do this before relaxing so
236          * we know to take advantage of -R and make shorter addresses.
237          */
238         if (flagseen[ 'R' ]) {
239                 fixS *tmp;
240
241                 text_last_frag->fr_next = data_frag_root;
242                 text_last_frag = data_last_frag;
243                 data_last_frag = NULL;
244                 data_frag_root = NULL;
245                 if (text_fix_root) {
246                         for (tmp = text_fix_root; tmp->fx_next; tmp = tmp->fx_next) ;;
247                         tmp->fx_next = data_fix_root;
248                 } else
249                     text_fix_root = data_fix_root;
250                 data_fix_root = NULL;
251         }
252
253         relax_segment(text_frag_root, SEG_TEXT);
254         relax_segment(data_frag_root, SEG_DATA);
255         /*
256          * Now the addresses of frags are correct within the segment.
257          */
258
259         know(text_last_frag->fr_type == rs_fill && text_last_frag->fr_offset == 0);
260         H_SET_TEXT_SIZE(&headers, text_last_frag->fr_address);
261         text_last_frag->fr_address = H_GET_TEXT_SIZE(&headers);
262
263         /*
264          * Join the 2 segments into 1 huge segment.
265          * To do this, re-compute every rn_address in the SEG_DATA frags.
266          * Then join the data frags after the text frags.
267          *
268          * Determine a_data [length of data segment].
269          */
270         if (data_frag_root) {
271                 register relax_addressT slide;
272
273                 know((text_last_frag->fr_type == rs_fill) && (text_last_frag->fr_offset == 0));
274
275                 H_SET_DATA_SIZE(&headers, data_last_frag->fr_address);
276                 data_last_frag->fr_address = H_GET_DATA_SIZE(&headers);
277                 slide = H_GET_TEXT_SIZE(&headers); /* & in file of the data segment. */
278
279                 for (fragP = data_frag_root; fragP; fragP = fragP->fr_next) {
280                         fragP->fr_address += slide;
281                 } /* for each data frag */
282
283                 know(text_last_frag != 0);
284                 text_last_frag->fr_next = data_frag_root;
285         } else {
286                 H_SET_DATA_SIZE(&headers,0);
287                 data_siz = 0;
288         }
289
290         bss_address_frag.fr_address = (H_GET_TEXT_SIZE(&headers) +
291                                        H_GET_DATA_SIZE(&headers));
292
293         H_SET_BSS_SIZE(&headers,local_bss_counter);
294
295         /*
296          *
297          * Crawl the symbol chain.
298          *
299          * For each symbol whose value depends on a frag, take the address of
300          * that frag and subsume it into the value of the symbol.
301          * After this, there is just one way to lookup a symbol value.
302          * Values are left in their final state for object file emission.
303          * We adjust the values of 'L' local symbols, even if we do
304          * not intend to emit them to the object file, because their values
305          * are needed for fix-ups.
306          *
307          * Unless we saw a -L flag, remove all symbols that begin with 'L'
308          * from the symbol chain.  (They are still pointed to by the fixes.)
309          *
310          * Count the remaining symbols.
311          * Assign a symbol number to each symbol.
312          * Count the number of string-table chars we will emit.
313          * Put this info into the headers as appropriate.
314          *
315          */
316         know(zero_address_frag.fr_address == 0);
317         string_byte_count = sizeof(string_byte_count);
318
319         obj_crawl_symbol_chain(&headers);
320
321         if (string_byte_count == sizeof(string_byte_count)) {
322                 string_byte_count = 0;
323         } /* if no strings, then no count. */
324
325         H_SET_STRING_SIZE(&headers, string_byte_count);
326
327         /*
328          * Addresses of frags now reflect addresses we use in the object file.
329          * Symbol values are correct.
330          * Scan the frags, converting any ".org"s and ".align"s to ".fill"s.
331          * Also converting any machine-dependent frags using md_convert_frag();
332          */
333         subseg_change(SEG_TEXT, 0);
334
335         for (fragP = text_frag_root;  fragP;  fragP = fragP->fr_next) {
336                 switch (fragP->fr_type) {
337                 case rs_align:
338                 case rs_org:
339                         fragP->fr_type = rs_fill;
340                         know(fragP->fr_var == 1);
341                         know(fragP->fr_next != NULL);
342
343                         fragP->fr_offset = (fragP->fr_next->fr_address
344                                             - fragP->fr_address
345                                             - fragP->fr_fix);
346                         break;
347
348                 case rs_fill:
349                         break;
350
351                 case rs_machine_dependent:
352                         md_convert_frag(&headers, fragP);
353
354                         know((fragP->fr_next == NULL) || ((fragP->fr_next->fr_address - fragP->fr_address) == fragP->fr_fix));
355
356                         /*
357                          * After md_convert_frag, we make the frag into a ".space 0".
358                          * Md_convert_frag() should set up any fixSs and constants
359                          * required.
360                          */
361                         frag_wane(fragP);
362                         break;
363
364 #ifndef WORKING_DOT_WORD
365                 case rs_broken_word: {
366                         struct broken_word *lie;
367
368                         if (fragP->fr_subtype) {
369                                 fragP->fr_fix+=md_short_jump_size;
370                                 for (lie=(struct broken_word *)(fragP->fr_symbol);lie && lie->dispfrag == fragP;lie=lie->next_broken_word)
371                                     if (lie->added == 1)
372                                         fragP->fr_fix+=md_long_jump_size;
373                         }
374                         frag_wane(fragP);
375                 }
376                         break;
377 #endif
378
379                 default:
380                         BAD_CASE( fragP->fr_type );
381                         break;
382                 } /* switch (fr_type) */
383
384                 know((fragP->fr_next == NULL)
385                      || ((fragP->fr_next->fr_address - fragP->fr_address)
386                          == (fragP->fr_fix + (fragP->fr_offset * fragP->fr_var))));
387         } /* for each frag. */
388
389 #ifndef WORKING_DOT_WORD
390         {
391                 struct broken_word *lie;
392                 struct broken_word **prevP;
393
394                 prevP = &broken_words;
395                 for (lie = broken_words; lie; lie = lie->next_broken_word)
396                     if (!lie->added) {
397 #ifdef TC_NS32K
398                             fix_new_ns32k(lie->frag,
399                                           lie->word_goes_here - lie->frag->fr_literal,
400                                           2,
401                                           lie->add,
402                                           lie->sub,
403                                           lie->addnum,
404                                           0, 0, 2, 0, 0, NO_RELOC);
405 #else /* TC_NS32K */
406 #ifdef PIC
407                             fix_new(lie->frag, lie->word_goes_here - lie->frag->fr_literal,
408                                     2, lie->add,
409                                     lie->sub, lie->addnum,
410                                     0, NO_RELOC, (symbolS *)0);
411 #else
412                             fix_new(lie->frag, lie->word_goes_here - lie->frag->fr_literal,
413                                     2, lie->add,
414                                     lie->sub, lie->addnum,
415                                     0, NO_RELOC);
416 #endif
417 #endif /* TC_NS32K */
418                             /* md_number_to_chars(lie->word_goes_here,
419                                S_GET_VALUE(lie->add)
420                                + lie->addnum
421                                - S_GET_VALUE(lie->sub),
422                                2); */
423                             *prevP = lie->next_broken_word;
424                     } else
425                         prevP = &(lie->next_broken_word);
426
427                 for (lie = broken_words; lie;) {
428                         struct broken_word *untruth;
429                         char *table_ptr;
430                         long table_addr;
431                         long from_addr,
432                         to_addr;
433                         int n,
434                         m;
435
436                         fragP = lie->dispfrag;
437
438                         /* Find out how many broken_words go here */
439                         n=0;
440                         for (untruth = lie; untruth && untruth->dispfrag == fragP; untruth = untruth->next_broken_word)
441                             if (untruth->added == 1)
442                                 n++;
443
444                         table_ptr = lie->dispfrag->fr_opcode;
445                         table_addr = lie->dispfrag->fr_address + (table_ptr - lie->dispfrag->fr_literal);
446                         /* Create the jump around the long jumps */
447                         /* This is a short jump from table_ptr+0 to table_ptr+n*long_jump_size */
448                         from_addr = table_addr;
449                         to_addr = table_addr + md_short_jump_size + n * md_long_jump_size;
450                         md_create_short_jump(table_ptr, from_addr, to_addr, lie->dispfrag, lie->add);
451                         table_ptr += md_short_jump_size;
452                         table_addr += md_short_jump_size;
453
454                         for (m = 0; lie && lie->dispfrag == fragP; m++, lie = lie->next_broken_word) {
455                                 if (lie->added == 2)
456                                     continue;
457                                 /* Patch the jump table */
458                                 /* This is the offset from ??? to table_ptr+0 */
459                                 to_addr = table_addr
460                                     - S_GET_VALUE(lie->sub);
461                                 md_number_to_chars(lie->word_goes_here, to_addr, 2);
462                                 for (untruth = lie->next_broken_word;
463                                      untruth && untruth->dispfrag == fragP;
464                                      untruth = untruth->next_broken_word) {
465                                         if (untruth->use_jump == lie)
466                                             md_number_to_chars(untruth->word_goes_here, to_addr, 2);
467                                 }
468
469                                 /* Install the long jump */
470                                 /* this is a long jump from table_ptr+0 to the final target */
471                                 from_addr = table_addr;
472                                 to_addr = S_GET_VALUE(lie->add) + lie->addnum;
473                                 md_create_long_jump(table_ptr, from_addr, to_addr, lie->dispfrag, lie->add);
474                                 table_ptr += md_long_jump_size;
475                                 table_addr += md_long_jump_size;
476                         }
477                 }
478         }
479 #endif /* not WORKING_DOT_WORD */
480
481 #ifndef OBJ_VMS
482         { /* not vms */
483                 /*
484                  * Scan every FixS performing fixups. We had to wait until now to do
485                  * this because md_convert_frag() may have made some fixSs.
486                  */
487
488                 H_SET_RELOCATION_SIZE(&headers,
489                                       md_reloc_size * fixup_segment(text_fix_root, SEG_TEXT),
490                                       md_reloc_size * fixup_segment(data_fix_root, SEG_DATA));
491
492
493                 obj_pre_write_hook(&headers);
494
495                 if ((had_warnings() && flagseen['Z'])
496                     || had_errors() > 0) {
497                         if (flagseen['Z']) {
498                                 as_warn("%d error%s, %d warning%s, generating bad object file.\n",
499                                         had_errors(), had_errors() == 1 ? "" : "s",
500                                         had_warnings(), had_warnings() == 1 ? "" : "s");
501                         } else {
502                                 as_fatal("%d error%s, %d warning%s, no object file generated.\n",
503                                          had_errors(), had_errors() == 1 ? "" : "s",
504                                          had_warnings(), had_warnings() == 1 ? "" : "s");
505                         } /* on want output */
506                 } /* on error condition */
507
508                 object_file_size = H_GET_FILE_SIZE(&headers);
509                 next_object_file_charP = the_object_file = xmalloc(object_file_size);
510
511                 output_file_create(out_file_name);
512
513                 obj_header_append(&next_object_file_charP, &headers);
514
515                 know((next_object_file_charP - the_object_file) == H_GET_HEADER_SIZE(&headers));
516
517                 /*
518                  * Emit code.
519                  */
520                 for (fragP = text_frag_root;  fragP;  fragP = fragP->fr_next) {
521                         register long count;
522                         register char *fill_literal;
523                         register long fill_size;
524
525                         know(fragP->fr_type == rs_fill);
526                         append(&next_object_file_charP, fragP->fr_literal, (unsigned long) fragP->fr_fix);
527                         fill_literal = fragP->fr_literal + fragP->fr_fix;
528                         fill_size = fragP->fr_var;
529                         know(fragP->fr_offset >= 0);
530
531                         for (count = fragP->fr_offset; count; count--) {
532                                 append(&next_object_file_charP, fill_literal, (unsigned long) fill_size);
533                         } /* for each  */
534
535                 } /* for each code frag. */
536
537                 know((next_object_file_charP - the_object_file) == (H_GET_HEADER_SIZE(&headers) + H_GET_TEXT_SIZE(&headers) + H_GET_DATA_SIZE(&headers)));
538
539                 /*
540                  * Emit relocations.
541                  */
542                 obj_emit_relocations(&next_object_file_charP, text_fix_root, (relax_addressT)0);
543                 know((next_object_file_charP - the_object_file) == (H_GET_HEADER_SIZE(&headers) + H_GET_TEXT_SIZE(&headers) + H_GET_DATA_SIZE(&headers) + H_GET_TEXT_RELOCATION_SIZE(&headers)));
544 #ifdef TC_I960
545                 /* Make addresses in data relocation directives relative to beginning of
546                  * first data fragment, not end of last text fragment:  alignment of the
547                  * start of the data segment may place a gap between the segments.
548                  */
549                 obj_emit_relocations(&next_object_file_charP, data_fix_root, data0_frchainP->frch_root->fr_address);
550 #else /* TC_I960 */
551                 obj_emit_relocations(&next_object_file_charP, data_fix_root, text_last_frag->fr_address);
552 #endif /* TC_I960 */
553
554                 know((next_object_file_charP - the_object_file) == (H_GET_HEADER_SIZE(&headers) + H_GET_TEXT_SIZE(&headers) + H_GET_DATA_SIZE(&headers) + H_GET_TEXT_RELOCATION_SIZE(&headers) + H_GET_DATA_RELOCATION_SIZE(&headers)));
555
556                 /*
557                  * Emit line number entries.
558                  */
559                 OBJ_EMIT_LINENO(&next_object_file_charP, lineno_rootP, the_object_file);
560                 know((next_object_file_charP - the_object_file) == (H_GET_HEADER_SIZE(&headers) + H_GET_TEXT_SIZE(&headers) + H_GET_DATA_SIZE(&headers) + H_GET_TEXT_RELOCATION_SIZE(&headers) + H_GET_DATA_RELOCATION_SIZE(&headers) + H_GET_LINENO_SIZE(&headers)));
561
562                 /*
563                  * Emit symbols.
564                  */
565                 obj_emit_symbols(&next_object_file_charP, symbol_rootP);
566                 know((next_object_file_charP - the_object_file) == (H_GET_HEADER_SIZE(&headers) + H_GET_TEXT_SIZE(&headers) + H_GET_DATA_SIZE(&headers) + H_GET_TEXT_RELOCATION_SIZE(&headers) + H_GET_DATA_RELOCATION_SIZE(&headers) + H_GET_LINENO_SIZE(&headers) + H_GET_SYMBOL_TABLE_SIZE(&headers)));
567
568                 /*
569                  * Emit strings.
570                  */
571
572                 if (string_byte_count > 0) {
573                         obj_emit_strings(&next_object_file_charP);
574                 } /* only if we have a string table */
575
576                 /*        know((next_object_file_charP - the_object_file) == (H_GET_HEADER_SIZE(&headers) + H_GET_TEXT_SIZE(&headers) + H_GET_DATA_SIZE(&headers) + H_GET_TEXT_RELOCATION_SIZE(&headers) + H_GET_DATA_RELOCATION_SIZE(&headers) + H_GET_LINENO_SIZE(&headers) + H_GET_SYMBOL_TABLE_SIZE(&headers) + H_GET_STRING_SIZE(&headers)));
577                  */
578                 /*        know(next_object_file_charP == the_object_file + object_file_size);*/
579
580 #ifdef BFD_HEADERS
581                 bfd_seek(stdoutput, 0, 0);
582                 bfd_write(the_object_file, 1, object_file_size,  stdoutput);
583 #else
584
585                 /* Write the data to the file */
586                 output_file_append(the_object_file, object_file_size, out_file_name);
587 #endif
588
589                 output_file_close(out_file_name);
590         } /* non vms output */
591 #else   /* OBJ_VMS */
592         /*
593          *      Now do the VMS-dependent part of writing the object file
594          */
595   VMS_write_object_file(H_GET_TEXT_SIZE(&headers), H_GET_DATA_SIZE(&headers),
596                  text_frag_root, data_frag_root);
597 #endif  /* OBJ_VMS */
598 } /* write_object_file() */
599 #else
600 #endif
601
602 /*
603  *                      relax_segment()
604  *
605  * Now we have a segment, not a crowd of sub-segments, we can make fr_address
606  * values.
607  *
608  * Relax the frags.
609  *
610  * After this, all frags in this segment have addresses that are correct
611  * within the segment. Since segments live in different file addresses,
612  * these frag addresses may not be the same as final object-file addresses.
613  */
614
615
616
617 void relax_segment(segment_frag_root, segment)
618 struct frag *   segment_frag_root;
619 segT            segment; /* SEG_DATA or SEG_TEXT */
620 {
621         register struct frag *  fragP;
622         register relax_addressT address;
623         /* register relax_addressT      old_address; JF unused */
624         /* register relax_addressT      new_address; JF unused */
625 #ifndef MANY_SEGMENTS
626         know(segment == SEG_DATA || segment == SEG_TEXT);
627 #endif
628         /* In case md_estimate_size_before_relax() wants to make fixSs. */
629         subseg_change(segment, 0);
630
631         /*
632          * For each frag in segment: count and store  (a 1st guess of) fr_address.
633          */
634         address = 0;
635         for (fragP = segment_frag_root; fragP; fragP = fragP->fr_next) {
636                 fragP->fr_address = address;
637                 address += fragP->fr_fix;
638
639                 switch (fragP->fr_type) {
640                 case rs_fill:
641                         address += fragP->fr_offset * fragP->fr_var ;
642                         break;
643
644                 case rs_align:
645                         address += relax_align(address, fragP->fr_offset);
646                         break;
647
648                 case rs_org:
649                         /*
650                          * Assume .org is nugatory. It will grow with 1st relax.
651                          */
652                         break;
653
654                 case rs_machine_dependent:
655                         address += md_estimate_size_before_relax(fragP, segment);
656                         break;
657
658 #ifndef WORKING_DOT_WORD
659                         /* Broken words don't concern us yet */
660                 case rs_broken_word:
661                         break;
662 #endif
663
664                 default:
665                         BAD_CASE(fragP->fr_type);
666                         break;
667                 } /* switch (fr_type) */
668         } /* for each frag in the segment */
669
670         /*
671          * Do relax().
672          */
673         {
674                 register long stretch; /* May be any size, 0 or negative. */
675                 /* Cumulative number of addresses we have */
676                 /* relaxed this pass. */
677                 /* We may have relaxed more than one address. */
678                 register long stretched;  /* Have we stretched on this pass? */
679                 /* This is 'cuz stretch may be zero, when,
680                    in fact some piece of code grew, and
681                    another shrank.  If a branch instruction
682                    doesn't fit anymore, we could be scrod */
683
684                 do {
685                         stretch = stretched = 0;
686                         for (fragP = segment_frag_root;  fragP;  fragP = fragP->fr_next) {
687                                 register long growth = 0;
688                                 register unsigned long was_address;
689                                 register long offset;
690                                 register symbolS *symbolP;
691                                 register long target;
692                                 register long after;
693                                 register long aim;
694
695                                 was_address = fragP->fr_address;
696                                 address = fragP->fr_address += stretch;
697                                 symbolP = fragP->fr_symbol;
698                                 offset = fragP->fr_offset;
699
700                                 switch (fragP->fr_type) {
701                                 case rs_fill:   /* .fill never relaxes. */
702                                         growth = 0;
703                                         break;
704
705 #ifndef WORKING_DOT_WORD
706                                         /* JF:  This is RMS's idea.  I do *NOT* want to be blamed
707                                            for it I do not want to write it.  I do not want to have
708                                            anything to do with it.  This is not the proper way to
709                                            implement this misfeature. */
710                                 case rs_broken_word: {
711                                         struct broken_word *lie;
712                                         struct broken_word *untruth;
713
714                                         /* Yes this is ugly (storing the broken_word pointer
715                                            in the symbol slot).  Still, this whole chunk of
716                                            code is ugly, and I don't feel like doing anything
717                                            about it.  Think of it as stubbornness in action */
718                                         growth=0;
719                                         for (lie=(struct broken_word *)(fragP->fr_symbol);
720                                              lie && lie->dispfrag == fragP;
721                                              lie=lie->next_broken_word) {
722
723                                                 if (lie->added)
724                                                     continue;
725
726                                                 offset = lie->add->sy_frag->fr_address+ S_GET_VALUE(lie->add) + lie->addnum -
727                                                     (lie->sub->sy_frag->fr_address+ S_GET_VALUE(lie->sub));
728                                                 if (offset <= -32768 || offset >= 32767) {
729 #if 0
730                                                         if (flagseen['K'])
731                                                             as_warn(".word %s-%s+%ld didn't fit",
732                                                                     S_GET_NAME(lie->add),
733                                                                     S_GET_NAME(lie->sub),
734                                                                     lie->addnum);
735 #endif
736                                                         lie->added=1;
737                                                         if (fragP->fr_subtype == 0) {
738                                                                 fragP->fr_subtype++;
739                                                                 growth+=md_short_jump_size;
740                                                         }
741                                                         for (untruth=lie->next_broken_word;untruth && untruth->dispfrag == lie->dispfrag;untruth=untruth->next_broken_word)
742                                                             if ((untruth->add->sy_frag == lie->add->sy_frag)
743                                                                 && S_GET_VALUE(untruth->add) == S_GET_VALUE(lie->add)) {
744                                                                     untruth->added=2;
745                                                                     untruth->use_jump=lie;
746                                                             }
747                                                         growth += md_long_jump_size;
748                                                 }
749                                         }
750
751                                         break;
752                                 } /* case rs_broken_word */
753 #endif
754                                 case rs_align:
755                                         growth = relax_align((relax_addressT) (address + fragP->fr_fix), offset)
756                                             - relax_align((relax_addressT) (was_address + fragP->fr_fix), offset);
757                                         break;
758
759                                 case rs_org:
760                                         target = offset;
761
762                                         if (symbolP) {
763 #ifdef MANY_SEGMENTS
764 #else
765                                                 know((S_GET_SEGMENT(symbolP) == SEG_ABSOLUTE) || (S_GET_SEGMENT(symbolP) == SEG_DATA) || (S_GET_SEGMENT(symbolP) == SEG_TEXT));
766                                                 know(symbolP->sy_frag);
767                                                 know(!(S_GET_SEGMENT(symbolP) == SEG_ABSOLUTE) || (symbolP->sy_frag == &zero_address_frag));
768 #endif
769                                                 target += S_GET_VALUE(symbolP)
770                                                     + symbolP->sy_frag->fr_address;
771                                         } /* if we have a symbol */
772
773                                         know(fragP->fr_next);
774                                         after = fragP->fr_next->fr_address;
775                                         growth = ((target - after ) > 0) ? (target - after) : 0;
776                                         /* Growth may be -ve, but variable part */
777                                         /* of frag cannot have < 0 chars. */
778                                         /* That is, we can't .org backwards. */
779
780                                         growth -= stretch;      /* This is an absolute growth factor */
781                                         break;
782
783                                 case rs_machine_dependent: {
784                                         register const relax_typeS *    this_type;
785                                         register const relax_typeS *    start_type;
786                                         register relax_substateT        next_state;
787                                         register relax_substateT        this_state;
788
789                                         start_type = this_type = md_relax_table + (this_state = fragP->fr_subtype);
790                                         target = offset;
791
792                                         if (symbolP) {
793 #ifndef MANY_SEGMENTS
794                                                 know((S_GET_SEGMENT(symbolP) == SEG_ABSOLUTE) || (S_GET_SEGMENT(symbolP) == SEG_DATA) || (S_GET_SEGMENT(symbolP) == SEG_TEXT));
795 #endif
796                                                 know(symbolP->sy_frag);
797                                                 know(!(S_GET_SEGMENT(symbolP) == SEG_ABSOLUTE) || symbolP->sy_frag == &zero_address_frag );
798                                                 target +=
799                                                     S_GET_VALUE(symbolP)
800                                                         + symbolP->sy_frag->fr_address;
801
802                                                 /* If frag has yet to be reached on this pass,
803                                                    assume it will move by STRETCH just as we did.
804                                                    If this is not so, it will be because some frag
805                                                    between grows, and that will force another pass.  */
806
807                                                 /* JF was just address */
808                                                 /* JF also added is_dnrange hack */
809                                                 /* There's gotta be a better/faster/etc way
810                                                    to do this... */
811                                                 /* gnu@cygnus.com:  I changed this from > to >=
812                                                    because I ran into a zero-length frag (fr_fix=0)
813                                                    which was created when the obstack needed a new
814                                                    chunk JUST AFTER the opcode of a branch.  Since
815                                                    fr_fix is zero, fr_address of this frag is the same
816                                                    as fr_address of the next frag.  This
817                                                    zero-length frag was variable and jumped to .+2
818                                                    (in the next frag), but since the > comparison
819                                                    below failed (the two were =, not >), "stretch"
820                                                    was not added to the target.  Stretch was 178, so
821                                                    the offset appeared to be .-176 instead, which did
822                                                    not fit into a byte branch, so the assembler
823                                                    relaxed the branch to a word.  This didn't compare
824                                                    with what happened when the same source file was
825                                                    assembled on other machines, which is how I found it.
826                                                    You might want to think about what other places have
827                                                    trouble with zero length frags... */
828
829                                                 if (symbolP->sy_frag->fr_address >= was_address
830                                                     && is_dnrange(fragP,symbolP->sy_frag)) {
831                                                         target += stretch;
832                                                 } /*  */
833
834                                         } /* if there's a symbol attached */
835
836                                         aim = target - address - fragP->fr_fix;
837                                         /* The displacement is affected by the instruction size
838                                          * for the 32k architecture. I think we ought to be able
839                                          * to add fragP->fr_pcrel_adjust in all cases (it should be
840                                          * zero if not used), but just in case it breaks something
841                                          * else we'll put this inside #ifdef NS32K ... #endif
842                                          */
843 #ifdef TC_NS32K
844                                         aim += fragP->fr_pcrel_adjust;
845 #endif /* TC_NS32K */
846
847                                         if (aim < 0) {
848                                                 /* Look backwards. */
849                                                 for (next_state = this_type->rlx_more; next_state; ) {
850                                                         if (aim >= this_type->rlx_backward) {
851                                                                 next_state = 0;
852                                                         } else { /* Grow to next state. */
853                                                                 this_type = md_relax_table + (this_state = next_state);
854                                                                 next_state = this_type->rlx_more;
855                                                         }
856                                                 }
857                                         } else {
858 #ifdef DONTDEF
859                                                 /* JF these next few lines of code are for the mc68020 which can't handle short
860                                                    offsets of zero in branch instructions.  What a kludge! */
861                                                 if (aim == 0 && this_state == (1<<2+0)) { /* FOO hard encoded from m.c */
862                                                         aim=this_type->rlx_forward+1; /* Force relaxation into word mode */
863                                                 }
864 #endif
865 #ifdef M68K_AIM_KLUDGE
866                                                 M68K_AIM_KLUDGE(aim, this_state, this_type);
867 #endif
868                                                 /* JF end of 68020 code */
869                                                 /* Look forwards. */
870                                                 for (next_state = this_type->rlx_more; next_state; ) {
871                                                         if (aim <= this_type->rlx_forward) {
872                                                                 next_state = 0;
873                                                         } else { /* Grow to next state. */
874                                                                 this_type = md_relax_table + (this_state = next_state);
875                                                                 next_state = this_type->rlx_more;
876                                                         }
877                                                 }
878                                         }
879
880                                         if ((growth = this_type->rlx_length - start_type->rlx_length) != 0)
881                                             fragP->fr_subtype = this_state;
882
883                                         break;
884                                 } /* case rs_machine_dependent */
885
886                                 default:
887                                         BAD_CASE( fragP->fr_type );
888                                         break;
889                                 }
890                                 if (growth) {
891                                         stretch += growth;
892                                         stretched++;
893                                 }
894                         } /* For each frag in the segment. */
895                 } while (stretched);    /* Until nothing further to relax. */
896         } /* do_relax */
897
898         /*
899          * We now have valid fr_address'es for each frag.
900          */
901
902         /*
903          * All fr_address's are correct, relative to their own segment.
904          * We have made all the fixS we will ever make.
905          */
906 } /* relax_segment() */
907
908 /*
909  * Relax_align. Advance location counter to next address that has 'alignment'
910  * lowest order bits all 0s.
911  */
912
913 /* How many addresses does the .align take? */
914 static relax_addressT relax_align(address, alignment)
915 register relax_addressT address; /* Address now. */
916 register long alignment; /* Alignment (binary). */
917 {
918         relax_addressT  mask;
919         relax_addressT  new_address;
920
921         mask = ~ ( (~0) << alignment );
922         new_address = (address + mask) & (~ mask);
923         return (new_address - address);
924 } /* relax_align() */
925
926 /* fixup_segment()
927
928    Go through all the fixS's in a segment and see which ones can be
929    handled now.  (These consist of fixS where we have since discovered
930    the value of a symbol, or the address of the frag involved.)
931    For each one, call md_apply_fix to put the fix into the frag data.
932
933    Result is a count of how many relocation structs will be needed to
934    handle the remaining fixS's that we couldn't completely handle here.
935    These will be output later by emit_relocations().  */
936
937 static long fixup_segment(fixP, this_segment_type)
938 register fixS *fixP;
939 segT this_segment_type; /* N_TYPE bits for segment. */
940 {
941         register long seg_reloc_count;
942         register symbolS *add_symbolP;
943         register symbolS *sub_symbolP;
944         register long add_number;
945         register int size;
946         register char *place;
947         register long where;
948         register char pcrel;
949         register fragS *fragP;
950         register segT add_symbol_segment = SEG_ABSOLUTE;
951
952         /* FIXME: remove this line */ /*        fixS *orig = fixP; */
953         seg_reloc_count = 0;
954
955         for ( ;  fixP;  fixP = fixP->fx_next) {
956                 fragP = fixP->fx_frag;
957                 know(fragP);
958                 where = fixP->fx_where;
959                 place = fragP->fr_literal + where;
960                 size = fixP->fx_size;
961                 add_symbolP = fixP->fx_addsy;
962 #ifdef TC_I960
963                 if (fixP->fx_callj && TC_S_IS_CALLNAME(add_symbolP)) {
964                         /* Relocation should be done via the
965                            associated 'bal' entry point
966                            symbol. */
967
968                         if (!TC_S_IS_BALNAME(tc_get_bal_of_call(add_symbolP))) {
969                                 as_bad("No 'bal' entry point for leafproc %s",
970                                        S_GET_NAME(add_symbolP));
971                                 continue;
972                         }
973                         fixP->fx_addsy = add_symbolP = tc_get_bal_of_call(add_symbolP);
974                 }       /* callj relocation */
975 #endif
976                 sub_symbolP = fixP->fx_subsy;
977                 add_number = fixP->fx_offset;
978                 pcrel = fixP->fx_pcrel;
979
980                 if (add_symbolP) {
981                         add_symbol_segment = S_GET_SEGMENT(add_symbolP);
982                 }       /* if there is an addend */
983
984                 if (sub_symbolP) {
985                         if (!add_symbolP) {
986                                 /* Its just -sym */
987                                 if (S_GET_SEGMENT(sub_symbolP) != SEG_ABSOLUTE) {
988                                         as_bad("Negative of non-absolute symbol %s", S_GET_NAME(sub_symbolP));
989                                 } /* not absolute */
990
991                                 add_number -= S_GET_VALUE(sub_symbolP);
992
993                                 /* if sub_symbol is in the same segment that add_symbol
994                                    and add_symbol is either in DATA, TEXT, BSS or ABSOLUTE */
995                         } else if ((S_GET_SEGMENT(sub_symbolP) == add_symbol_segment)
996                                    && (SEG_NORMAL(add_symbol_segment)
997                                        || (add_symbol_segment == SEG_ABSOLUTE))) {
998                                 /* Difference of 2 symbols from same segment. */
999                                 /* Can't make difference of 2 undefineds: 'value' means */
1000                                 /* something different for N_UNDF. */
1001 #ifdef TC_I960
1002                                 /* Makes no sense to use the difference of 2 arbitrary symbols
1003                                  * as the target of a call instruction.
1004                                  */
1005                                 if (fixP->fx_callj) {
1006                                         as_bad("callj to difference of 2 symbols");
1007                                 }
1008 #endif  /* TC_I960 */
1009 #ifdef PIC
1010                                 if (picmode &&
1011                                                 S_IS_EXTERNAL(add_symbolP)) {
1012                                         as_bad("Can't reduce difference of external symbols in PIC code");
1013                                 }
1014 #endif
1015                                 add_number += S_GET_VALUE(add_symbolP) -
1016                                     S_GET_VALUE(sub_symbolP);
1017
1018                                 add_symbolP = NULL;
1019                                 fixP->fx_addsy = NULL;
1020                         } else {
1021                                 /* Different segments in subtraction. */
1022                                 know(!(S_IS_EXTERNAL(sub_symbolP) && (S_GET_SEGMENT(sub_symbolP) == SEG_ABSOLUTE)));
1023
1024                                 if ((S_GET_SEGMENT(sub_symbolP) == SEG_ABSOLUTE)) {
1025                                         add_number -= S_GET_VALUE(sub_symbolP);
1026                                 } else {
1027                                         as_bad("Can't emit reloc {- %s-seg symbol \"%s\"} @ file address %d.",
1028                                                segment_name(S_GET_SEGMENT(sub_symbolP)),
1029                                                S_GET_NAME(sub_symbolP), fragP->fr_address + where);
1030                                 } /* if absolute */
1031                         }
1032                 } /* if sub_symbolP */
1033
1034 #ifdef PIC
1035                 /*
1036                  * Bring _GLOBAL_OFFSET_TABLE_ forward, now we've had the
1037                  * chance to collapse any accompanying symbols into a number.
1038                  * This is the sequel of the hack in expr.c to parse operands
1039                  * of the form `_GLOBAL_OFFSET_TABLE_+(L1-L2)'. Note that
1040                  * _GLOBAL_OFFSET_TABLE_ can only be an "add symbol".
1041                  */
1042                 if (add_symbolP == NULL && fixP->fx_gotsy != NULL) {
1043                         add_symbolP = fixP->fx_addsy = fixP->fx_gotsy;
1044                         add_symbol_segment = S_GET_SEGMENT(add_symbolP);
1045                 }
1046 #endif
1047
1048                 if (add_symbolP) {
1049                         if (add_symbol_segment == this_segment_type && pcrel) {
1050                                 /*
1051                                  * This fixup was made when the symbol's segment was
1052                                  * SEG_UNKNOWN, but it is now in the local segment.
1053                                  * So we know how to do the address without relocation.
1054                                  */
1055 #ifdef TC_I960
1056                                 /* reloc_callj() may replace a 'call' with a 'calls' or a 'bal',
1057                                  * in which cases it modifies *fixP as appropriate.  In the case
1058                                  * of a 'calls', no further work is required, and *fixP has been
1059                                  * set up to make the rest of the code below a no-op.
1060                                  */
1061                                 reloc_callj(fixP);
1062 #endif /* TC_I960 */
1063
1064                                 add_number += S_GET_VALUE(add_symbolP);
1065                                 add_number -= md_pcrel_from(fixP);
1066                                 pcrel = 0; /* Lie. Don't want further pcrel processing. */
1067                                 fixP->fx_addsy = NULL; /* No relocations please. */
1068                         } else {
1069                                 switch (add_symbol_segment) {
1070                                 case SEG_ABSOLUTE:
1071 #ifdef TC_I960
1072                                         reloc_callj(fixP); /* See comment about reloc_callj() above*/
1073 #endif /* TC_I960 */
1074                                         add_number += S_GET_VALUE(add_symbolP);
1075                                         fixP->fx_addsy = NULL;
1076                                         add_symbolP = NULL;
1077                                         break;
1078                                 default:
1079                                         seg_reloc_count ++;
1080 #ifdef PIC
1081                                         /*
1082                                          * Do not fixup refs to global data
1083                                          * even if defined here.
1084                                          */
1085                                         if (!picmode ||
1086 #ifdef TC_NS32K
1087                                            fixP->fx_pcrel ||
1088 #endif
1089                                            (fixP->fx_r_type != RELOC_GLOB_DAT &&
1090 #ifdef TC_I386
1091 /* XXX - This must be rationalized */
1092                                             fixP->fx_r_type != RELOC_GOT &&
1093                                             fixP->fx_r_type != RELOC_GOTOFF &&
1094 #endif
1095                                                 (fixP->fx_r_type != RELOC_32 ||
1096                                                 !S_IS_EXTERNAL(add_symbolP))))
1097 #endif
1098                                                 add_number += S_GET_VALUE(add_symbolP);
1099                                         break;
1100
1101                                 case SEG_UNKNOWN:
1102 #ifdef TC_I960
1103                                         if ((int)fixP->fx_bit_fixP == 13) {
1104                                                 /* This is a COBR instruction.  They have only a
1105                                                  * 13-bit displacement and are only to be used
1106                                                  * for local branches: flag as error, don't generate
1107                                                  * relocation.
1108                                                  */
1109                                                 as_bad("can't use COBR format with external label");
1110                                                 fixP->fx_addsy = NULL;  /* No relocations please. */
1111                                                 continue;
1112                                         } /* COBR */
1113 #endif /* TC_I960 */
1114
1115 #ifdef OBJ_COFF
1116 #ifdef TE_I386AIX
1117                                         if (S_IS_COMMON(add_symbolP))
1118                                             add_number += S_GET_VALUE(add_symbolP);
1119 #endif /* TE_I386AIX */
1120 #endif /* OBJ_COFF */
1121                                         ++seg_reloc_count;
1122
1123                                         break;
1124
1125
1126                                 } /* switch on symbol seg */
1127                         } /* if not in local seg */
1128                 } /* if there was a + symbol */
1129
1130                 if (pcrel) {
1131                         add_number -= md_pcrel_from(fixP);
1132                         if (add_symbolP == 0) {
1133                                 fixP->fx_addsy = & abs_symbol;
1134                                 ++seg_reloc_count;
1135                         } /* if there's an add_symbol */
1136                 } /* if pcrel */
1137
1138                 if (!fixP->fx_bit_fixP) {
1139                         if ((size == 1 &&
1140                              (add_number& ~0xFF)   && (add_number & ~0xFF != (-1 & ~0xFF))) ||
1141                             (size == 2 &&
1142                              (add_number& ~0xFFFF) && (add_number & ~0xFFFF != (-1 & ~0xFFFF)))) {
1143                                 as_bad("Value of %d too large for field of %d bytes at 0x%x",
1144                                        add_number, size, fragP->fr_address + where);
1145                         } /* generic error checking */
1146                 } /* not a bit fix */
1147
1148                 md_apply_fix(fixP, add_number);
1149         } /* For each fixS in this segment. */
1150
1151 #ifdef OBJ_COFF
1152 #ifdef TC_I960
1153         {
1154                 fixS *topP = fixP;
1155
1156                 /* two relocs per callj under coff. */
1157                 for (fixP = topP; fixP; fixP = fixP->fx_next) {
1158                         if (fixP->fx_callj && fixP->fx_addsy != 0) {
1159                                 ++seg_reloc_count;
1160                         } /* if callj and not already fixed. */
1161                 } /* for each fix */
1162         }
1163 #endif /* TC_I960 */
1164
1165 #endif /* OBJ_COFF */
1166         return(seg_reloc_count);
1167 } /* fixup_segment() */
1168
1169
1170 static int is_dnrange(f1,f2)
1171 struct frag *f1;
1172 struct frag *f2;
1173 {
1174         while (f1) {
1175                 if (f1->fr_next == f2)
1176                     return 1;
1177                 f1=f1->fr_next;
1178         }
1179         return 0;
1180 } /* is_dnrange() */
1181
1182 /* Append a string onto another string, bumping the pointer along.  */
1183 void
1184     append (charPP, fromP, length)
1185 char    **charPP;
1186 char    *fromP;
1187 unsigned long length;
1188 {
1189         if (length) {           /* Don't trust memcpy() of 0 chars. */
1190                 memcpy(*charPP, fromP, (int) length);
1191                 *charPP += length;
1192         }
1193 }
1194
1195 int section_alignment[SEG_MAXIMUM_ORDINAL];
1196
1197 /*
1198  * This routine records the largest alignment seen for each segment.
1199  * If the beginning of the segment is aligned on the worst-case
1200  * boundary, all of the other alignments within it will work.  At
1201  * least one object format really uses this info.
1202  */
1203 void record_alignment(seg, align)
1204 segT seg;       /* Segment to which alignment pertains */
1205 int align;      /* Alignment, as a power of 2
1206                  *      (e.g., 1 => 2-byte boundary, 2 => 4-byte boundary, etc.)
1207                  */
1208 {
1209
1210         if ( align > section_alignment[(int) seg] ){
1211                 section_alignment[(int) seg] = align;
1212         } /* if highest yet */
1213
1214         return;
1215 } /* record_alignment() */
1216
1217 /*
1218  * Local Variables:
1219  * comment-column: 0
1220  * fill-column: 131
1221  * End:
1222  */
1223
1224 /* end of write.c */