* ldver.c: Increase version number to 1.97, for consistency with ../binutils.
[deliverable/binutils-gdb.git] / ld / relax.c
1
2
3 /*
4
5 new age linking
6
7
8 Tie together all the interseting blocks
9
10 */
11
12
13 #include "bfd.h"
14 #include "../bfd/seclet.h"
15 #include "coff/internal.h"
16 #include "sysdep.h"
17
18 #include "ldlang.h"
19 #include "ld.h"
20 #include "ldwrite.h"
21 #include "ldmisc.h"
22 #include "ldsym.h"
23 #include "ldgram.h"
24 #include "relax.h"
25 static void
26 DEFUN(build_it,(statement),
27 lang_statement_union_type *statement)
28 {
29 switch (statement->header.type) {
30 {
31 #if 0
32 bfd_byte play_area[SHORT_SIZE];
33 unsigned int i;
34 bfd_putshort(output_bfd, statement->fill_statement.fill, play_area);
35 /* Write out all entire shorts */
36 for (i = 0;
37 i < statement->fill_statement.size - SHORT_SIZE + 1;
38 i+= SHORT_SIZE)
39 {
40 bfd_set_section_contents(output_bfd,
41 statement->fill_statement.output_section,
42 play_area,
43 statement->data_statement.output_offset +i,
44 SHORT_SIZE);
45
46 }
47
48 /* Now write any remaining byte */
49 if (i < statement->fill_statement.size)
50 {
51 bfd_set_section_contents(output_bfd,
52 statement->fill_statement.output_section,
53 play_area,
54 statement->data_statement.output_offset +i,
55 1);
56
57 }
58 #endif
59 abort();
60 }
61 break;
62 case lang_data_statement_enum:
63 #if 0
64 {
65
66 bfd_vma value = statement->data_statement.value;
67 bfd_byte play_area[LONG_SIZE];
68 unsigned int size = 0;
69 switch (statement->data_statement.type) {
70 case LONG:
71 bfd_put_32(output_bfd, value, play_area);
72 size = LONG_SIZE;
73 break;
74 case SHORT:
75 bfd_put_16(output_bfd, value, play_area);
76 size = SHORT_SIZE;
77 break;
78 case BYTE:
79 bfd_put_8(output_bfd, value, play_area);
80 size = BYTE_SIZE;
81 break;
82 }
83
84 bfd_set_section_contents(output_bfd,
85 statement->data_statement.output_section,
86 play_area,
87 statement->data_statement.output_vma,
88 size);
89
90
91
92 }
93 #endif
94 break;
95 case lang_input_section_enum:
96 {
97 /* Create a new seclet in the output section with this
98 attached */
99
100 asection *i = statement->input_section.section;
101
102 asection *output_section = i->output_section;
103
104 bfd_seclet_type *seclet = bfd_new_seclet(output_section->owner,output_section);
105
106 seclet->type = bfd_indirect_seclet;
107 seclet->u.indirect.section = i;
108 seclet->u.indirect.symbols = statement->input_section.ifile->asymbols;
109 seclet->size = bfd_get_section_size_before_reloc(i);
110 seclet->offset = i->output_offset;
111 seclet->next = 0;
112
113 }
114 break;
115 case lang_padding_statement_enum:
116 /* Make a new seclet with the right filler */
117 {
118 /* Create a new seclet in the output section with this
119 attached */
120
121 bfd_seclet_type *seclet =
122 bfd_new_seclet(statement->padding_statement.output_section->owner,
123 statement->padding_statement.output_section);
124
125 seclet->type = bfd_fill_seclet;
126 seclet->size = statement->padding_statement.size;
127 seclet->offset = statement->padding_statement.output_offset;
128 seclet->u.fill.value = statement->padding_statement.fill;
129 seclet->next = 0;
130 }
131 break;
132
133
134
135 break;
136 default:
137 /* All the other ones fall through */
138 ;
139
140 }
141
142
143
144 }
145
146
147 void
148 DEFUN(write_relaxnorel,(output_bfd),
149 bfd *output_bfd)
150 {
151 /* Tie up all the statements to generate an output bfd structure which
152 bfd can mull over */
153
154
155 lang_for_each_statement(build_it);
156
157 seclet_dump(output_bfd);
158
159 }
160
161
162
163
164
165 /* See if we can change the size of this section by shrinking the
166 relocations in it. If this happens, then we'll have to renumber the
167 symbols in it, and shift around the data too.
168 */
169 boolean
170 DEFUN(relax_section,(this_ptr),
171 lang_statement_union_type **this_ptr)
172 {
173
174 lang_input_section_type *is = &((*this_ptr)->input_section);
175 asection *i = is->section;
176
177 return bfd_relax_section(i->owner, i, is->ifile->asymbols);
178
179 }
180
This page took 0.032259 seconds and 4 git commands to generate.