use flex & bison from ../ if they exist
[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 if (statement->input_section.ifile->just_syms_flag == false)
100 {
101 asection *i = statement->input_section.section;
102
103 asection *output_section = i->output_section;
104
105 bfd_seclet_type *seclet = bfd_new_seclet(output_section->owner,output_section);
106
107 seclet->type = bfd_indirect_seclet;
108 seclet->u.indirect.section = i;
109 seclet->u.indirect.symbols = statement->input_section.ifile->asymbols;
110 seclet->size = bfd_get_section_size_before_reloc(i);
111 seclet->offset = i->output_offset;
112 seclet->next = 0;
113 }
114
115 }
116 break;
117 case lang_padding_statement_enum:
118 /* Make a new seclet with the right filler */
119 {
120 /* Create a new seclet in the output section with this
121 attached */
122
123 bfd_seclet_type *seclet =
124 bfd_new_seclet(statement->padding_statement.output_section->owner,
125 statement->padding_statement.output_section);
126
127 seclet->type = bfd_fill_seclet;
128 seclet->size = statement->padding_statement.size;
129 seclet->offset = statement->padding_statement.output_offset;
130 seclet->u.fill.value = statement->padding_statement.fill;
131 seclet->next = 0;
132 }
133 break;
134
135
136
137 break;
138 default:
139 /* All the other ones fall through */
140 ;
141
142 }
143
144
145
146 }
147
148
149 void
150 DEFUN(write_relaxnorel,(output_bfd),
151 bfd *output_bfd)
152 {
153 /* Tie up all the statements to generate an output bfd structure which
154 bfd can mull over */
155
156
157 lang_for_each_statement(build_it);
158
159 seclet_dump(output_bfd);
160
161 }
162
163
164
165
166
167 /* See if we can change the size of this section by shrinking the
168 relocations in it. If this happens, then we'll have to renumber the
169 symbols in it, and shift around the data too.
170 */
171 boolean
172 DEFUN(relax_section,(this_ptr),
173 lang_statement_union_type **this_ptr)
174 {
175
176 lang_input_section_type *is = &((*this_ptr)->input_section);
177 asection *i = is->section;
178
179 return bfd_relax_section(i->owner, i, is->ifile->asymbols);
180
181 }
182
This page took 0.031936 seconds and 4 git commands to generate.