1 /* Copyright (C) 1992, 1993 Free Software Foundation, Inc.
3 This file is part of GLD, the Gnu Linker.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
24 Tie together all the interseting blocks
30 #include "../bfd/seclet.h"
31 #include "coff/internal.h"
42 DEFUN(build_it
,(statement
),
43 lang_statement_union_type
*statement
)
45 switch (statement
->header
.type
) {
49 bfd_byte play_area
[SHORT_SIZE
];
51 bfd_putshort(output_bfd
, statement
->fill_statement
.fill
, play_area
);
52 /* Write out all entire shorts */
54 i
< statement
->fill_statement
.size
- SHORT_SIZE
+ 1;
57 bfd_set_section_contents(output_bfd
,
58 statement
->fill_statement
.output_section
,
60 statement
->data_statement
.output_offset
+i
,
65 /* Now write any remaining byte */
66 if (i
< statement
->fill_statement
.size
)
68 bfd_set_section_contents(output_bfd
,
69 statement
->fill_statement
.output_section
,
71 statement
->data_statement
.output_offset
+i
,
80 case lang_data_statement_enum
:
84 bfd_vma value
= statement
->data_statement
.value
;
85 bfd_byte play_area
[LONG_SIZE
];
86 unsigned int size
= 0;
87 asection
* output_section
= statement
->data_statement
.output_section
;
88 switch (statement
->data_statement
.type
) {
90 bfd_put_32(output_section
->owner
, value
, play_area
);
94 bfd_put_16(output_section
->owner
, value
, play_area
);
98 bfd_put_8(output_section
->owner
, value
, play_area
);
103 bfd_set_section_contents(output_section
->owner
,
104 statement
->data_statement
.output_section
,
106 statement
->data_statement
.output_vma
,
114 case lang_input_section_enum
:
116 /* Create a new seclet in the output section with this
118 if (statement
->input_section
.ifile
->just_syms_flag
== false)
120 asection
*i
= statement
->input_section
.section
;
122 asection
*output_section
= i
->output_section
;
124 bfd_seclet_type
*seclet
= bfd_new_seclet(output_section
->owner
,output_section
);
126 seclet
->type
= bfd_indirect_seclet
;
127 seclet
->u
.indirect
.section
= i
;
128 seclet
->u
.indirect
.symbols
= statement
->input_section
.ifile
->asymbols
;
129 seclet
->size
= i
->_cooked_size
;
130 seclet
->offset
= i
->output_offset
;
136 case lang_padding_statement_enum
:
137 /* Make a new seclet with the right filler */
139 /* Create a new seclet in the output section with this
142 bfd_seclet_type
*seclet
=
143 bfd_new_seclet(statement
->padding_statement
.output_section
->owner
,
144 statement
->padding_statement
.output_section
);
146 seclet
->type
= bfd_fill_seclet
;
147 seclet
->size
= statement
->padding_statement
.size
;
148 seclet
->offset
= statement
->padding_statement
.output_offset
;
149 seclet
->u
.fill
.value
= statement
->padding_statement
.fill
;
158 /* All the other ones fall through */
169 DEFUN(write_relax
,(output_bfd
, data
, relocateable
),
172 boolean relocateable
)
174 /* Tie up all the statements to generate an output bfd structure which
178 lang_for_each_statement(build_it
);
180 bfd_seclet_link(output_bfd
, data
, relocateable
);
188 /* See if we can change the size of this section by shrinking the
189 relocations in it. If this happens, then we'll have to renumber the
190 symbols in it, and shift around the data too.
193 DEFUN(relax_section
,(this_ptr
),
194 lang_statement_union_type
**this_ptr
)
196 extern lang_input_statement_type
*script_file
;
197 lang_input_section_type
*is
= &((*this_ptr
)->input_section
);
198 asection
*i
= is
->section
;
199 if (!(i
->owner
->flags
& BFD_IS_RELAXABLE
))
201 if (i
->owner
!= script_file
->the_bfd
)
202 einfo("%B: not assembled with -linkrelax\n", i
->owner
);
205 return bfd_relax_section(i
->owner
, i
, is
->ifile
->asymbols
);