* Makefile.in: Change mkscript rule into one for ./mkscript
[deliverable/binutils-gdb.git] / ld / relax.c
CommitLineData
2e2bf962
SC
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
25static void
26DEFUN(build_it,(statement),
27 lang_statement_union_type *statement)
28{
29 switch (statement->header.type) {
30 case lang_fill_statement_enum:
58216160 31 {
2e2bf962
SC
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
58216160 60 abort();
2e2bf962
SC
61 }
62 break;
63 case lang_data_statement_enum:
2e2bf962 64#if 0
58216160
MT
65 {
66
2e2bf962
SC
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
2e2bf962
SC
92
93 }
58216160 94#endif
2e2bf962
SC
95 break;
96 case lang_input_section_enum:
58216160
MT
97 {
98 /* Create a new seclet in the output section with this
99 attached */
2e2bf962 100
58216160 101 asection *i = statement->input_section.section;
2e2bf962 102
58216160 103 asection *output_section = i->output_section;
2e2bf962 104
58216160 105 bfd_seclet_type *seclet = bfd_new_seclet(output_section->owner,output_section);
2e2bf962 106
58216160
MT
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;
2e2bf962 113
58216160 114 }
2e2bf962
SC
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
2e2bf962
SC
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
870f54b2 158 return bfd_relax_section(i->owner, i, is->ifile->asymbols);
2e2bf962
SC
159
160}
161
This page took 0.0307460000000001 seconds and 4 git commands to generate.