More cleanups for gprof, especially with the '386 target.
[deliverable/binutils-gdb.git] / ld / relax.c
... / ...
CommitLineData
1
2
3/*
4
5new age linking
6
7
8Tie 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"
25static void
26DEFUN(build_it,(statement),
27 lang_statement_union_type *statement)
28{
29 switch (statement->header.type) {
30 case lang_fill_statement_enum:
31 {
32#if 0
33 bfd_byte play_area[SHORT_SIZE];
34 unsigned int i;
35 bfd_putshort(output_bfd, statement->fill_statement.fill, play_area);
36 /* Write out all entire shorts */
37 for (i = 0;
38 i < statement->fill_statement.size - SHORT_SIZE + 1;
39 i+= SHORT_SIZE)
40 {
41 bfd_set_section_contents(output_bfd,
42 statement->fill_statement.output_section,
43 play_area,
44 statement->data_statement.output_offset +i,
45 SHORT_SIZE);
46
47 }
48
49 /* Now write any remaining byte */
50 if (i < statement->fill_statement.size)
51 {
52 bfd_set_section_contents(output_bfd,
53 statement->fill_statement.output_section,
54 play_area,
55 statement->data_statement.output_offset +i,
56 1);
57
58 }
59#endif
60 abort();
61 }
62 break;
63 case lang_data_statement_enum:
64#if 0
65 {
66
67 bfd_vma value = statement->data_statement.value;
68 bfd_byte play_area[LONG_SIZE];
69 unsigned int size = 0;
70 switch (statement->data_statement.type) {
71 case LONG:
72 bfd_put_32(output_bfd, value, play_area);
73 size = LONG_SIZE;
74 break;
75 case SHORT:
76 bfd_put_16(output_bfd, value, play_area);
77 size = SHORT_SIZE;
78 break;
79 case BYTE:
80 bfd_put_8(output_bfd, value, play_area);
81 size = BYTE_SIZE;
82 break;
83 }
84
85 bfd_set_section_contents(output_bfd,
86 statement->data_statement.output_section,
87 play_area,
88 statement->data_statement.output_vma,
89 size);
90
91
92
93 }
94#endif
95 break;
96 case lang_input_section_enum:
97 {
98 /* Create a new seclet in the output section with this
99 attached */
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 break;
116
117 default:
118 /* All the other ones fall through */
119 ;
120
121 }
122
123
124
125}
126
127
128void
129DEFUN(write_relaxnorel,(output_bfd),
130 bfd *output_bfd)
131{
132/* Tie up all the statements to generate an output bfd structure which
133 bfd can mull over */
134
135
136 lang_for_each_statement(build_it);
137
138 seclet_dump(output_bfd);
139
140}
141
142
143
144
145
146/* See if we can change the size of this section by shrinking the
147 relocations in it. If this happens, then we'll have to renumber the
148 symbols in it, and shift around the data too.
149 */
150boolean
151DEFUN(relax_section,(this_ptr),
152 lang_statement_union_type **this_ptr)
153{
154
155 lang_input_section_type *is = &((*this_ptr)->input_section);
156 asection *i = is->section;
157
158 return bfd_relax_section(i->owner, i, is->ifile->asymbols);
159
160}
161
This page took 0.024251 seconds and 4 git commands to generate.