1 /* This module is part of BFD */
4 /* The intention is that one day, all the code which uses sections
5 will change and use seclets instead - maybe seglet would have been
8 Anyway, a seclet contains enough info to be able to describe an
9 area of output memory in one go.
11 The only description so far catered for is that of the
12 <<bfd_indirect_seclet>>, which is a select which points to a
13 <<section>> and the <<asymbols>> associated with the section, so
14 that relocation can be done when needed.
16 One day there will be more types - they will at least migrate from
17 the linker's data structures - also there could be extra stuff,
18 like a bss seclet, which descibes a lump of memory as containing
19 zeros compactly, without the horrible SEC_* flag cruft.
28 #include "coff/internal.h"
30 DEFUN(bfd_new_seclet
,(abfd
, section
),
34 bfd_seclet_type
*n
= (bfd_seclet_type
*)bfd_alloc(abfd
, sizeof(bfd_seclet_type
));
35 if (section
->seclets_tail
!= (bfd_seclet_type
*)NULL
) {
36 section
->seclets_tail
->next
= n
;
40 section
->seclets_head
= n
;
42 section
->seclets_tail
= n
;
50 #define MAX_ERRORS_IN_A_ROW 10
51 extern bfd_error_vector_type bfd_error_vector
;
55 DEFUN(rel
,(abfd
, seclet
, output_section
),
57 bfd_seclet_type
*seclet AND
58 asection
*output_section
)
61 if (output_section
->flags
& SEC_HAS_CONTENTS
62 && !(output_section
->flags
& SEC_NEVER_LOAD
))
64 bfd_byte
*data
= (bfd_byte
*)alloca(seclet
->size
);
65 data
= bfd_get_relocated_section_contents(abfd
, seclet
, data
);
66 if(bfd_set_section_contents(abfd
,
70 seclet
->size
) == false)
79 DEFUN(seclet_dump_seclet
,(abfd
, seclet
, section
),
81 bfd_seclet_type
*seclet AND
86 case bfd_indirect_seclet
:
87 /* The contents of this section come from another one somewhere
89 rel(abfd
, seclet
, section
);
92 /* Fill in the section with us */
94 char *d
= malloc(seclet
->size
);
96 for (i
=0; i
< seclet
->size
; i
+=2) {
97 d
[i
] = seclet
->u
.fill
.value
>> 8;
99 for (i
= 1; i
< seclet
->size
; i
+=2) {
100 d
[i
] = seclet
->u
.fill
.value
;
102 bfd_set_section_contents(abfd
, section
, d
, seclet
->offset
, seclet
->size
);
112 DEFUN(seclet_dump
,(abfd
),
115 /* Write all the seclets on the bfd out, relocate etc according to the
118 asection
*o
= abfd
->sections
;
119 while (o
!= (asection
*)NULL
)
121 bfd_seclet_type
*p
= o
->seclets_head
;
122 while (p
!= (bfd_seclet_type
*)NULL
)
124 seclet_dump_seclet(abfd
, p
, o
);