/src/binutils-gdb/bfd/coffcode.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* Support for the generic parts of most COFF variants, for BFD. |
2 | | Copyright (C) 1990-2023 Free Software Foundation, Inc. |
3 | | Written by Cygnus Support. |
4 | | |
5 | | This file is part of BFD, the Binary File Descriptor library. |
6 | | |
7 | | This program is free software; you can redistribute it and/or modify |
8 | | it under the terms of the GNU General Public License as published by |
9 | | the Free Software Foundation; either version 3 of the License, or |
10 | | (at your option) any later version. |
11 | | |
12 | | This program is distributed in the hope that it will be useful, |
13 | | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | | GNU General Public License for more details. |
16 | | |
17 | | You should have received a copy of the GNU General Public License |
18 | | along with this program; if not, write to the Free Software |
19 | | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, |
20 | | MA 02110-1301, USA. */ |
21 | | |
22 | | /* Most of this hacked by Steve Chamberlain, |
23 | | sac@cygnus.com. */ |
24 | | /* |
25 | | SECTION |
26 | | coff backends |
27 | | |
28 | | BFD supports a number of different flavours of coff format. |
29 | | The major differences between formats are the sizes and |
30 | | alignments of fields in structures on disk, and the occasional |
31 | | extra field. |
32 | | |
33 | | Coff in all its varieties is implemented with a few common |
34 | | files and a number of implementation specific files. For |
35 | | example, the i386 coff format is implemented in the file |
36 | | @file{coff-i386.c}. This file @code{#include}s |
37 | | @file{coff/i386.h} which defines the external structure of the |
38 | | coff format for the i386, and @file{coff/internal.h} which |
39 | | defines the internal structure. @file{coff-i386.c} also |
40 | | defines the relocations used by the i386 coff format |
41 | | @xref{Relocations}. |
42 | | |
43 | | SUBSECTION |
44 | | Porting to a new version of coff |
45 | | |
46 | | The recommended method is to select from the existing |
47 | | implementations the version of coff which is most like the one |
48 | | you want to use. For example, we'll say that i386 coff is |
49 | | the one you select, and that your coff flavour is called foo. |
50 | | Copy @file{i386coff.c} to @file{foocoff.c}, copy |
51 | | @file{../include/coff/i386.h} to @file{../include/coff/foo.h}, |
52 | | and add the lines to @file{targets.c} and @file{Makefile.in} |
53 | | so that your new back end is used. Alter the shapes of the |
54 | | structures in @file{../include/coff/foo.h} so that they match |
55 | | what you need. You will probably also have to add |
56 | | @code{#ifdef}s to the code in @file{coff/internal.h} and |
57 | | @file{coffcode.h} if your version of coff is too wild. |
58 | | |
59 | | You can verify that your new BFD backend works quite simply by |
60 | | building @file{objdump} from the @file{binutils} directory, |
61 | | and making sure that its version of what's going on and your |
62 | | host system's idea (assuming it has the pretty standard coff |
63 | | dump utility, usually called @code{att-dump} or just |
64 | | @code{dump}) are the same. Then clean up your code, and send |
65 | | what you've done to Cygnus. Then your stuff will be in the |
66 | | next release, and you won't have to keep integrating it. |
67 | | |
68 | | SUBSECTION |
69 | | How the coff backend works |
70 | | |
71 | | SUBSUBSECTION |
72 | | File layout |
73 | | |
74 | | The Coff backend is split into generic routines that are |
75 | | applicable to any Coff target and routines that are specific |
76 | | to a particular target. The target-specific routines are |
77 | | further split into ones which are basically the same for all |
78 | | Coff targets except that they use the external symbol format |
79 | | or use different values for certain constants. |
80 | | |
81 | | The generic routines are in @file{coffgen.c}. These routines |
82 | | work for any Coff target. They use some hooks into the target |
83 | | specific code; the hooks are in a @code{bfd_coff_backend_data} |
84 | | structure, one of which exists for each target. |
85 | | |
86 | | The essentially similar target-specific routines are in |
87 | | @file{coffcode.h}. This header file includes executable C code. |
88 | | The various Coff targets first include the appropriate Coff |
89 | | header file, make any special defines that are needed, and |
90 | | then include @file{coffcode.h}. |
91 | | |
92 | | Some of the Coff targets then also have additional routines in |
93 | | the target source file itself. |
94 | | |
95 | | SUBSUBSECTION |
96 | | Coff long section names |
97 | | |
98 | | In the standard Coff object format, section names are limited to |
99 | | the eight bytes available in the @code{s_name} field of the |
100 | | @code{SCNHDR} section header structure. The format requires the |
101 | | field to be NUL-padded, but not necessarily NUL-terminated, so |
102 | | the longest section names permitted are a full eight characters. |
103 | | |
104 | | The Microsoft PE variants of the Coff object file format add |
105 | | an extension to support the use of long section names. This |
106 | | extension is defined in section 4 of the Microsoft PE/COFF |
107 | | specification (rev 8.1). If a section name is too long to fit |
108 | | into the section header's @code{s_name} field, it is instead |
109 | | placed into the string table, and the @code{s_name} field is |
110 | | filled with a slash ("/") followed by the ASCII decimal |
111 | | representation of the offset of the full name relative to the |
112 | | string table base. |
113 | | |
114 | | Note that this implies that the extension can only be used in object |
115 | | files, as executables do not contain a string table. The standard |
116 | | specifies that long section names from objects emitted into executable |
117 | | images are to be truncated. |
118 | | |
119 | | However, as a GNU extension, BFD can generate executable images |
120 | | that contain a string table and long section names. This |
121 | | would appear to be technically valid, as the standard only says |
122 | | that Coff debugging information is deprecated, not forbidden, |
123 | | and in practice it works, although some tools that parse PE files |
124 | | expecting the MS standard format may become confused; @file{PEview} is |
125 | | one known example. |
126 | | |
127 | | The functionality is supported in BFD by code implemented under |
128 | | the control of the macro @code{COFF_LONG_SECTION_NAMES}. If not |
129 | | defined, the format does not support long section names in any way. |
130 | | If defined, it is used to initialise a flag, |
131 | | @code{_bfd_coff_long_section_names}, and a hook function pointer, |
132 | | @code{_bfd_coff_set_long_section_names}, in the Coff backend data |
133 | | structure. The flag controls the generation of long section names |
134 | | in output BFDs at runtime; if it is false, as it will be by default |
135 | | when generating an executable image, long section names are truncated; |
136 | | if true, the long section names extension is employed. The hook |
137 | | points to a function that allows the value of a copy of the flag |
138 | | in coff object tdata to be altered at runtime, on formats that |
139 | | support long section names at all; on other formats it points |
140 | | to a stub that returns an error indication. |
141 | | |
142 | | With input BFDs, the flag is set according to whether any long section |
143 | | names are detected while reading the section headers. For a completely |
144 | | new BFD, the flag is set to the default for the target format. This |
145 | | information can be used by a client of the BFD library when deciding |
146 | | what output format to generate, and means that a BFD that is opened |
147 | | for read and subsequently converted to a writeable BFD and modified |
148 | | in-place will retain whatever format it had on input. |
149 | | |
150 | | If @code{COFF_LONG_SECTION_NAMES} is simply defined (blank), or is |
151 | | defined to the value "1", then long section names are enabled by |
152 | | default; if it is defined to the value zero, they are disabled by |
153 | | default (but still accepted in input BFDs). The header @file{coffcode.h} |
154 | | defines a macro, @code{COFF_DEFAULT_LONG_SECTION_NAMES}, which is |
155 | | used in the backends to initialise the backend data structure fields |
156 | | appropriately; see the comments for further detail. |
157 | | |
158 | | SUBSUBSECTION |
159 | | Bit twiddling |
160 | | |
161 | | Each flavour of coff supported in BFD has its own header file |
162 | | describing the external layout of the structures. There is also |
163 | | an internal description of the coff layout, in |
164 | | @file{coff/internal.h}. A major function of the |
165 | | coff backend is swapping the bytes and twiddling the bits to |
166 | | translate the external form of the structures into the normal |
167 | | internal form. This is all performed in the |
168 | | @code{bfd_swap}_@i{thing}_@i{direction} routines. Some |
169 | | elements are different sizes between different versions of |
170 | | coff; it is the duty of the coff version specific include file |
171 | | to override the definitions of various packing routines in |
172 | | @file{coffcode.h}. E.g., the size of line number entry in coff is |
173 | | sometimes 16 bits, and sometimes 32 bits. @code{#define}ing |
174 | | @code{PUT_LNSZ_LNNO} and @code{GET_LNSZ_LNNO} will select the |
175 | | correct one. No doubt, some day someone will find a version of |
176 | | coff which has a varying field size not catered to at the |
177 | | moment. To port BFD, that person will have to add more @code{#defines}. |
178 | | Three of the bit twiddling routines are exported to |
179 | | @code{gdb}; @code{coff_swap_aux_in}, @code{coff_swap_sym_in} |
180 | | and @code{coff_swap_lineno_in}. @code{GDB} reads the symbol |
181 | | table on its own, but uses BFD to fix things up. More of the |
182 | | bit twiddlers are exported for @code{gas}; |
183 | | @code{coff_swap_aux_out}, @code{coff_swap_sym_out}, |
184 | | @code{coff_swap_lineno_out}, @code{coff_swap_reloc_out}, |
185 | | @code{coff_swap_filehdr_out}, @code{coff_swap_aouthdr_out}, |
186 | | @code{coff_swap_scnhdr_out}. @code{Gas} currently keeps track |
187 | | of all the symbol table and reloc drudgery itself, thereby |
188 | | saving the internal BFD overhead, but uses BFD to swap things |
189 | | on the way out, making cross ports much safer. Doing so also |
190 | | allows BFD (and thus the linker) to use the same header files |
191 | | as @code{gas}, which makes one avenue to disaster disappear. |
192 | | |
193 | | SUBSUBSECTION |
194 | | Symbol reading |
195 | | |
196 | | The simple canonical form for symbols used by BFD is not rich |
197 | | enough to keep all the information available in a coff symbol |
198 | | table. The back end gets around this problem by keeping the original |
199 | | symbol table around, "behind the scenes". |
200 | | |
201 | | When a symbol table is requested (through a call to |
202 | | @code{bfd_canonicalize_symtab}), a request gets through to |
203 | | @code{coff_get_normalized_symtab}. This reads the symbol table from |
204 | | the coff file and swaps all the structures inside into the |
205 | | internal form. It also fixes up all the pointers in the table |
206 | | (represented in the file by offsets from the first symbol in |
207 | | the table) into physical pointers to elements in the new |
208 | | internal table. This involves some work since the meanings of |
209 | | fields change depending upon context: a field that is a |
210 | | pointer to another structure in the symbol table at one moment |
211 | | may be the size in bytes of a structure at the next. Another |
212 | | pass is made over the table. All symbols which mark file names |
213 | | (<<C_FILE>> symbols) are modified so that the internal |
214 | | string points to the value in the auxent (the real filename) |
215 | | rather than the normal text associated with the symbol |
216 | | (@code{".file"}). |
217 | | |
218 | | At this time the symbol names are moved around. Coff stores |
219 | | all symbols less than nine characters long physically |
220 | | within the symbol table; longer strings are kept at the end of |
221 | | the file in the string table. This pass moves all strings |
222 | | into memory and replaces them with pointers to the strings. |
223 | | |
224 | | The symbol table is massaged once again, this time to create |
225 | | the canonical table used by the BFD application. Each symbol |
226 | | is inspected in turn, and a decision made (using the |
227 | | @code{sclass} field) about the various flags to set in the |
228 | | @code{asymbol}. @xref{Symbols}. The generated canonical table |
229 | | shares strings with the hidden internal symbol table. |
230 | | |
231 | | Any linenumbers are read from the coff file too, and attached |
232 | | to the symbols which own the functions the linenumbers belong to. |
233 | | |
234 | | SUBSUBSECTION |
235 | | Symbol writing |
236 | | |
237 | | Writing a symbol to a coff file which didn't come from a coff |
238 | | file will lose any debugging information. The @code{asymbol} |
239 | | structure remembers the BFD from which the symbol was taken, and on |
240 | | output the back end makes sure that the same destination target as |
241 | | source target is present. |
242 | | |
243 | | When the symbols have come from a coff file then all the |
244 | | debugging information is preserved. |
245 | | |
246 | | Symbol tables are provided for writing to the back end in a |
247 | | vector of pointers to pointers. This allows applications like |
248 | | the linker to accumulate and output large symbol tables |
249 | | without having to do too much byte copying. |
250 | | |
251 | | This function runs through the provided symbol table and |
252 | | patches each symbol marked as a file place holder |
253 | | (@code{C_FILE}) to point to the next file place holder in the |
254 | | list. It also marks each @code{offset} field in the list with |
255 | | the offset from the first symbol of the current symbol. |
256 | | |
257 | | Another function of this procedure is to turn the canonical |
258 | | value form of BFD into the form used by coff. Internally, BFD |
259 | | expects symbol values to be offsets from a section base; so a |
260 | | symbol physically at 0x120, but in a section starting at |
261 | | 0x100, would have the value 0x20. Coff expects symbols to |
262 | | contain their final value, so symbols have their values |
263 | | changed at this point to reflect their sum with their owning |
264 | | section. This transformation uses the |
265 | | <<output_section>> field of the @code{asymbol}'s |
266 | | @code{asection} @xref{Sections}. |
267 | | |
268 | | o <<coff_mangle_symbols>> |
269 | | |
270 | | This routine runs though the provided symbol table and uses |
271 | | the offsets generated by the previous pass and the pointers |
272 | | generated when the symbol table was read in to create the |
273 | | structured hierarchy required by coff. It changes each pointer |
274 | | to a symbol into the index into the symbol table of the asymbol. |
275 | | |
276 | | o <<coff_write_symbols>> |
277 | | |
278 | | This routine runs through the symbol table and patches up the |
279 | | symbols from their internal form into the coff way, calls the |
280 | | bit twiddlers, and writes out the table to the file. |
281 | | |
282 | | */ |
283 | | |
284 | | /* |
285 | | INTERNAL_DEFINITION |
286 | | coff_symbol_type |
287 | | |
288 | | DESCRIPTION |
289 | | The hidden information for an <<asymbol>> is described in a |
290 | | <<combined_entry_type>>: |
291 | | |
292 | | CODE_FRAGMENT |
293 | | .typedef struct coff_ptr_struct |
294 | | .{ |
295 | | . {* Remembers the offset from the first symbol in the file for |
296 | | . this symbol. Generated by coff_renumber_symbols. *} |
297 | | . unsigned int offset; |
298 | | . |
299 | | . {* Selects between the elements of the union below. *} |
300 | | . unsigned int is_sym : 1; |
301 | | . |
302 | | . {* Selects between the elements of the x_sym.x_tagndx union. If set, |
303 | | . p is valid and the field will be renumbered. *} |
304 | | . unsigned int fix_tag : 1; |
305 | | . |
306 | | . {* Selects between the elements of the x_sym.x_fcnary.x_fcn.x_endndx |
307 | | . union. If set, p is valid and the field will be renumbered. *} |
308 | | . unsigned int fix_end : 1; |
309 | | . |
310 | | . {* Selects between the elements of the x_csect.x_scnlen union. If set, |
311 | | . p is valid and the field will be renumbered. *} |
312 | | . unsigned int fix_scnlen : 1; |
313 | | . |
314 | | . {* If set, u.syment.n_value contains a pointer to a symbol. The final |
315 | | . value will be the offset field. Used for XCOFF C_BSTAT symbols. *} |
316 | | . unsigned int fix_value : 1; |
317 | | . |
318 | | . {* If set, u.syment.n_value is an index into the line number entries. |
319 | | . Used for XCOFF C_BINCL/C_EINCL symbols. *} |
320 | | . unsigned int fix_line : 1; |
321 | | . |
322 | | . {* The container for the symbol structure as read and translated |
323 | | . from the file. *} |
324 | | . union |
325 | | . { |
326 | | . union internal_auxent auxent; |
327 | | . struct internal_syment syment; |
328 | | . } u; |
329 | | . |
330 | | . {* An extra pointer which can used by format based on COFF (like XCOFF) |
331 | | . to provide extra information to their backend. *} |
332 | | . void *extrap; |
333 | | .} combined_entry_type; |
334 | | . |
335 | | .{* Each canonical asymbol really looks like this: *} |
336 | | . |
337 | | .typedef struct coff_symbol_struct |
338 | | .{ |
339 | | . {* The actual symbol which the rest of BFD works with *} |
340 | | . asymbol symbol; |
341 | | . |
342 | | . {* A pointer to the hidden information for this symbol *} |
343 | | . combined_entry_type *native; |
344 | | . |
345 | | . {* A pointer to the linenumber information for this symbol *} |
346 | | . struct lineno_cache_entry *lineno; |
347 | | . |
348 | | . {* Have the line numbers been relocated yet ? *} |
349 | | . bool done_lineno; |
350 | | .} coff_symbol_type; |
351 | | . |
352 | | */ |
353 | | |
354 | | #include "libiberty.h" |
355 | | |
356 | | #ifdef COFF_WITH_PE |
357 | | #include "peicode.h" |
358 | | #else |
359 | | #include "coffswap.h" |
360 | | #endif |
361 | | |
362 | 0 | #define STRING_SIZE_SIZE 4 |
363 | | |
364 | 474k | #define DOT_DEBUG ".debug" |
365 | 474k | #define DOT_ZDEBUG ".zdebug" |
366 | 117k | #define GNU_LINKONCE_WI ".gnu.linkonce.wi." |
367 | 117k | #define GNU_LINKONCE_WT ".gnu.linkonce.wt." |
368 | 0 | #define DOT_RELOC ".reloc" |
369 | | |
370 | | #if defined(COFF_WITH_PE) || defined(COFF_GO32_EXE) || defined(COFF_GO32) |
371 | | # define COFF_WITH_EXTENDED_RELOC_COUNTER |
372 | | #endif |
373 | | |
374 | | #if defined (COFF_LONG_SECTION_NAMES) |
375 | | /* Needed to expand the inputs to BLANKOR1TOODD. */ |
376 | | #define COFFLONGSECTIONCATHELPER(x,y) x ## y |
377 | | /* If the input macro Y is blank or '1', return an odd number; if it is |
378 | | '0', return an even number. Result undefined in all other cases. */ |
379 | | #define BLANKOR1TOODD(y) COFFLONGSECTIONCATHELPER(1,y) |
380 | | /* Defined to numerical 0 or 1 according to whether generation of long |
381 | | section names is disabled or enabled by default. */ |
382 | | #define COFF_ENABLE_LONG_SECTION_NAMES (BLANKOR1TOODD(COFF_LONG_SECTION_NAMES) & 1) |
383 | | /* Where long section names are supported, we allow them to be enabled |
384 | | and disabled at runtime, so select an appropriate hook function for |
385 | | _bfd_coff_set_long_section_names. */ |
386 | | #define COFF_LONG_SECTION_NAMES_SETTER bfd_coff_set_long_section_names_allowed |
387 | | #else /* !defined (COFF_LONG_SECTION_NAMES) */ |
388 | | /* If long section names are not supported, this stub disallows any |
389 | | attempt to enable them at run-time. */ |
390 | | #define COFF_LONG_SECTION_NAMES_SETTER bfd_coff_set_long_section_names_disallowed |
391 | | #endif /* defined (COFF_LONG_SECTION_NAMES) */ |
392 | | |
393 | | /* Define a macro that can be used to initialise both the fields relating |
394 | | to long section names in the backend data struct simultaneously. */ |
395 | | #if COFF_ENABLE_LONG_SECTION_NAMES |
396 | | #define COFF_DEFAULT_LONG_SECTION_NAMES (true), COFF_LONG_SECTION_NAMES_SETTER |
397 | | #else /* !COFF_ENABLE_LONG_SECTION_NAMES */ |
398 | | #define COFF_DEFAULT_LONG_SECTION_NAMES (false), COFF_LONG_SECTION_NAMES_SETTER |
399 | | #endif /* COFF_ENABLE_LONG_SECTION_NAMES */ |
400 | | |
401 | | static enum coff_symbol_classification coff_classify_symbol |
402 | | (bfd *, struct internal_syment *); |
403 | | |
404 | | /* void warning(); */ |
405 | | |
406 | | #if defined (COFF_LONG_SECTION_NAMES) |
407 | | static bool |
408 | | bfd_coff_set_long_section_names_allowed (bfd *abfd, int enable) |
409 | 186k | { |
410 | 186k | bfd_coff_long_section_names (abfd) = enable; |
411 | 186k | return true; |
412 | 186k | } pei-i386.c:bfd_coff_set_long_section_names_allowed Line | Count | Source | 409 | 3.25k | { | 410 | 3.25k | bfd_coff_long_section_names (abfd) = enable; | 411 | 3.25k | return true; | 412 | 3.25k | } |
pe-x86_64.c:bfd_coff_set_long_section_names_allowed Line | Count | Source | 409 | 5.33k | { | 410 | 5.33k | bfd_coff_long_section_names (abfd) = enable; | 411 | 5.33k | return true; | 412 | 5.33k | } |
pei-x86_64.c:bfd_coff_set_long_section_names_allowed Line | Count | Source | 409 | 3.26k | { | 410 | 3.26k | bfd_coff_long_section_names (abfd) = enable; | 411 | 3.26k | return true; | 412 | 3.26k | } |
pei-aarch64.c:bfd_coff_set_long_section_names_allowed Line | Count | Source | 409 | 1.74k | { | 410 | 1.74k | bfd_coff_long_section_names (abfd) = enable; | 411 | 1.74k | return true; | 412 | 1.74k | } |
pe-aarch64.c:bfd_coff_set_long_section_names_allowed Line | Count | Source | 409 | 5.48k | { | 410 | 5.48k | bfd_coff_long_section_names (abfd) = enable; | 411 | 5.48k | return true; | 412 | 5.48k | } |
pei-ia64.c:bfd_coff_set_long_section_names_allowed Line | Count | Source | 409 | 2.23k | { | 410 | 2.23k | bfd_coff_long_section_names (abfd) = enable; | 411 | 2.23k | return true; | 412 | 2.23k | } |
pei-loongarch64.c:bfd_coff_set_long_section_names_allowed Line | Count | Source | 409 | 8.55k | { | 410 | 8.55k | bfd_coff_long_section_names (abfd) = enable; | 411 | 8.55k | return true; | 412 | 8.55k | } |
coff-go32.c:bfd_coff_set_long_section_names_allowed Line | Count | Source | 409 | 117k | { | 410 | 117k | bfd_coff_long_section_names (abfd) = enable; | 411 | 117k | return true; | 412 | 117k | } |
coff-stgo32.c:bfd_coff_set_long_section_names_allowed Line | Count | Source | 409 | 13.7k | { | 410 | 13.7k | bfd_coff_long_section_names (abfd) = enable; | 411 | 13.7k | return true; | 412 | 13.7k | } |
pe-arm-wince.c:bfd_coff_set_long_section_names_allowed Line | Count | Source | 409 | 1.23k | { | 410 | 1.23k | bfd_coff_long_section_names (abfd) = enable; | 411 | 1.23k | return true; | 412 | 1.23k | } |
pe-arm.c:bfd_coff_set_long_section_names_allowed Line | Count | Source | 409 | 1.23k | { | 410 | 1.23k | bfd_coff_long_section_names (abfd) = enable; | 411 | 1.23k | return true; | 412 | 1.23k | } |
pe-i386.c:bfd_coff_set_long_section_names_allowed Line | Count | Source | 409 | 7.12k | { | 410 | 7.12k | bfd_coff_long_section_names (abfd) = enable; | 411 | 7.12k | return true; | 412 | 7.12k | } |
pe-mcore.c:bfd_coff_set_long_section_names_allowed Line | Count | Source | 409 | 3.32k | { | 410 | 3.32k | bfd_coff_long_section_names (abfd) = enable; | 411 | 3.32k | return true; | 412 | 3.32k | } |
pe-sh.c:bfd_coff_set_long_section_names_allowed Line | Count | Source | 409 | 2.59k | { | 410 | 2.59k | bfd_coff_long_section_names (abfd) = enable; | 411 | 2.59k | return true; | 412 | 2.59k | } |
pei-arm-wince.c:bfd_coff_set_long_section_names_allowed Line | Count | Source | 409 | 2.09k | { | 410 | 2.09k | bfd_coff_long_section_names (abfd) = enable; | 411 | 2.09k | return true; | 412 | 2.09k | } |
pei-arm.c:bfd_coff_set_long_section_names_allowed Line | Count | Source | 409 | 2.74k | { | 410 | 2.74k | bfd_coff_long_section_names (abfd) = enable; | 411 | 2.74k | return true; | 412 | 2.74k | } |
pei-mcore.c:bfd_coff_set_long_section_names_allowed Line | Count | Source | 409 | 3.55k | { | 410 | 3.55k | bfd_coff_long_section_names (abfd) = enable; | 411 | 3.55k | return true; | 412 | 3.55k | } |
pei-sh.c:bfd_coff_set_long_section_names_allowed Line | Count | Source | 409 | 1.70k | { | 410 | 1.70k | bfd_coff_long_section_names (abfd) = enable; | 411 | 1.70k | return true; | 412 | 1.70k | } |
|
413 | | #else /* !defined (COFF_LONG_SECTION_NAMES) */ |
414 | | static bool |
415 | | bfd_coff_set_long_section_names_disallowed (bfd *abfd ATTRIBUTE_UNUSED, |
416 | | int enable ATTRIBUTE_UNUSED) |
417 | 816k | { |
418 | 816k | return false; |
419 | 816k | } coff-x86_64.c:bfd_coff_set_long_section_names_disallowed Line | Count | Source | 417 | 199k | { | 418 | 199k | return false; | 419 | 199k | } |
coff64-rs6000.c:bfd_coff_set_long_section_names_disallowed Line | Count | Source | 417 | 46.2k | { | 418 | 46.2k | return false; | 419 | 46.2k | } |
cf-i386lynx.c:bfd_coff_set_long_section_names_disallowed Line | Count | Source | 417 | 140k | { | 418 | 140k | return false; | 419 | 140k | } |
coff-i386.c:bfd_coff_set_long_section_names_disallowed Line | Count | Source | 417 | 127k | { | 418 | 127k | return false; | 419 | 127k | } |
coff-rs6000.c:bfd_coff_set_long_section_names_disallowed Line | Count | Source | 417 | 85.1k | { | 418 | 85.1k | return false; | 419 | 85.1k | } |
coff-sh.c:bfd_coff_set_long_section_names_disallowed Line | Count | Source | 417 | 20.6k | { | 418 | 20.6k | return false; | 419 | 20.6k | } |
coff-tic30.c:bfd_coff_set_long_section_names_disallowed Line | Count | Source | 417 | 37.6k | { | 418 | 37.6k | return false; | 419 | 37.6k | } |
Unexecuted instantiation: coff-tic4x.c:bfd_coff_set_long_section_names_disallowed coff-tic54x.c:bfd_coff_set_long_section_names_disallowed Line | Count | Source | 417 | 55.7k | { | 418 | 55.7k | return false; | 419 | 55.7k | } |
coff-z80.c:bfd_coff_set_long_section_names_disallowed Line | Count | Source | 417 | 43.4k | { | 418 | 43.4k | return false; | 419 | 43.4k | } |
coff-z8k.c:bfd_coff_set_long_section_names_disallowed Line | Count | Source | 417 | 59.7k | { | 418 | 59.7k | return false; | 419 | 59.7k | } |
|
420 | | #endif /* defined (COFF_LONG_SECTION_NAMES) */ |
421 | | |
422 | | /* Return a word with STYP_* (scnhdr.s_flags) flags set to represent |
423 | | the incoming SEC_* flags. The inverse of this function is |
424 | | styp_to_sec_flags(). NOTE: If you add to/change this routine, you |
425 | | should probably mirror the changes in styp_to_sec_flags(). */ |
426 | | |
427 | | #ifndef COFF_WITH_PE |
428 | | |
429 | | /* Macros for setting debugging flags. */ |
430 | | |
431 | | #ifdef STYP_DEBUG |
432 | 0 | #define STYP_XCOFF_DEBUG STYP_DEBUG |
433 | | #else |
434 | 0 | #define STYP_XCOFF_DEBUG STYP_INFO |
435 | | #endif |
436 | | |
437 | | #ifdef COFF_ALIGN_IN_S_FLAGS |
438 | 0 | #define STYP_DEBUG_INFO STYP_DSECT |
439 | | #else |
440 | 0 | #define STYP_DEBUG_INFO STYP_INFO |
441 | | #endif |
442 | | |
443 | | static long |
444 | | sec_to_styp_flags (const char *sec_name, flagword sec_flags) |
445 | 0 | { |
446 | 0 | long styp_flags = 0; |
447 | |
|
448 | 0 | if (!strcmp (sec_name, _TEXT)) |
449 | 0 | { |
450 | 0 | styp_flags = STYP_TEXT; |
451 | 0 | } |
452 | 0 | else if (!strcmp (sec_name, _DATA)) |
453 | 0 | { |
454 | 0 | styp_flags = STYP_DATA; |
455 | 0 | } |
456 | 0 | else if (!strcmp (sec_name, _BSS)) |
457 | 0 | { |
458 | 0 | styp_flags = STYP_BSS; |
459 | | #ifdef _COMMENT |
460 | | } |
461 | 0 | else if (!strcmp (sec_name, _COMMENT)) |
462 | 0 | { |
463 | 0 | styp_flags = STYP_INFO; |
464 | | #endif /* _COMMENT */ |
465 | | #ifdef _LIB |
466 | | } |
467 | 0 | else if (!strcmp (sec_name, _LIB)) |
468 | 0 | { |
469 | 0 | styp_flags = STYP_LIB; |
470 | | #endif /* _LIB */ |
471 | | #ifdef _LIT |
472 | | } |
473 | | else if (!strcmp (sec_name, _LIT)) |
474 | | { |
475 | | styp_flags = STYP_LIT; |
476 | | #endif /* _LIT */ |
477 | 0 | } |
478 | 0 | else if (startswith (sec_name, DOT_DEBUG) |
479 | 0 | || startswith (sec_name, DOT_ZDEBUG)) |
480 | 0 | { |
481 | | /* Handle the XCOFF debug section and DWARF2 debug sections. */ |
482 | 0 | if (!sec_name[6]) |
483 | 0 | styp_flags = STYP_XCOFF_DEBUG; |
484 | 0 | else |
485 | 0 | styp_flags = STYP_DEBUG_INFO; |
486 | 0 | } |
487 | 0 | else if (startswith (sec_name, ".stab")) |
488 | 0 | { |
489 | 0 | styp_flags = STYP_DEBUG_INFO; |
490 | 0 | } |
491 | | #ifdef COFF_LONG_SECTION_NAMES |
492 | 0 | else if (startswith (sec_name, GNU_LINKONCE_WI) |
493 | 0 | || startswith (sec_name, GNU_LINKONCE_WT)) |
494 | 0 | { |
495 | 0 | styp_flags = STYP_DEBUG_INFO; |
496 | 0 | } |
497 | 0 | #endif |
498 | | #ifdef RS6000COFF_C |
499 | 0 | else if (!strcmp (sec_name, _TDATA)) |
500 | 0 | { |
501 | 0 | styp_flags = STYP_TDATA; |
502 | 0 | } |
503 | 0 | else if (!strcmp (sec_name, _TBSS)) |
504 | 0 | { |
505 | 0 | styp_flags = STYP_TBSS; |
506 | 0 | } |
507 | 0 | else if (!strcmp (sec_name, _PAD)) |
508 | 0 | { |
509 | 0 | styp_flags = STYP_PAD; |
510 | 0 | } |
511 | 0 | else if (!strcmp (sec_name, _LOADER)) |
512 | 0 | { |
513 | 0 | styp_flags = STYP_LOADER; |
514 | 0 | } |
515 | 0 | else if (!strcmp (sec_name, _EXCEPT)) |
516 | 0 | { |
517 | 0 | styp_flags = STYP_EXCEPT; |
518 | 0 | } |
519 | 0 | else if (!strcmp (sec_name, _TYPCHK)) |
520 | 0 | { |
521 | 0 | styp_flags = STYP_TYPCHK; |
522 | 0 | } |
523 | 0 | else if (sec_flags & SEC_DEBUGGING) |
524 | 0 | { |
525 | 0 | int i; |
526 | |
|
527 | 0 | for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++) |
528 | 0 | if (!strcmp (sec_name, xcoff_dwsect_names[i].xcoff_name)) |
529 | 0 | { |
530 | 0 | styp_flags = STYP_DWARF | xcoff_dwsect_names[i].flag; |
531 | 0 | break; |
532 | 0 | } |
533 | 0 | } |
534 | 0 | #endif |
535 | | /* Try and figure out what it should be */ |
536 | 0 | else if (sec_flags & SEC_CODE) |
537 | 0 | { |
538 | 0 | styp_flags = STYP_TEXT; |
539 | 0 | } |
540 | 0 | else if (sec_flags & SEC_DATA) |
541 | 0 | { |
542 | 0 | styp_flags = STYP_DATA; |
543 | 0 | } |
544 | 0 | else if (sec_flags & SEC_READONLY) |
545 | 0 | { |
546 | 0 | #ifdef STYP_LIT /* 29k readonly text/data section */ |
547 | 0 | styp_flags = STYP_LIT; |
548 | | #else |
549 | | styp_flags = STYP_TEXT; |
550 | | #endif /* STYP_LIT */ |
551 | 0 | } |
552 | 0 | else if (sec_flags & SEC_LOAD) |
553 | 0 | { |
554 | 0 | styp_flags = STYP_TEXT; |
555 | 0 | } |
556 | 0 | else if (sec_flags & SEC_ALLOC) |
557 | 0 | { |
558 | 0 | styp_flags = STYP_BSS; |
559 | 0 | } |
560 | |
|
561 | | #ifdef STYP_CLINK |
562 | 0 | if (sec_flags & SEC_TIC54X_CLINK) |
563 | 0 | styp_flags |= STYP_CLINK; |
564 | | #endif |
565 | |
|
566 | | #ifdef STYP_BLOCK |
567 | 0 | if (sec_flags & SEC_TIC54X_BLOCK) |
568 | 0 | styp_flags |= STYP_BLOCK; |
569 | | #endif |
570 | |
|
571 | 0 | #ifdef STYP_NOLOAD |
572 | 0 | if ((sec_flags & (SEC_NEVER_LOAD | SEC_COFF_SHARED_LIBRARY)) != 0) |
573 | 0 | styp_flags |= STYP_NOLOAD; |
574 | 0 | #endif |
575 | |
|
576 | 0 | return styp_flags; |
577 | 0 | } Unexecuted instantiation: coff-x86_64.c:sec_to_styp_flags Unexecuted instantiation: coff64-rs6000.c:sec_to_styp_flags Unexecuted instantiation: cf-i386lynx.c:sec_to_styp_flags Unexecuted instantiation: coff-go32.c:sec_to_styp_flags Unexecuted instantiation: coff-i386.c:sec_to_styp_flags Unexecuted instantiation: coff-rs6000.c:sec_to_styp_flags Unexecuted instantiation: coff-sh.c:sec_to_styp_flags Unexecuted instantiation: coff-stgo32.c:sec_to_styp_flags Unexecuted instantiation: coff-tic30.c:sec_to_styp_flags Unexecuted instantiation: coff-tic4x.c:sec_to_styp_flags Unexecuted instantiation: coff-tic54x.c:sec_to_styp_flags Unexecuted instantiation: coff-z80.c:sec_to_styp_flags Unexecuted instantiation: coff-z8k.c:sec_to_styp_flags |
578 | | |
579 | | #else /* COFF_WITH_PE */ |
580 | | |
581 | | /* The PE version; see above for the general comments. The non-PE |
582 | | case seems to be more guessing, and breaks PE format; specifically, |
583 | | .rdata is readonly, but it sure ain't text. Really, all this |
584 | | should be set up properly in gas (or whatever assembler is in use), |
585 | | and honor whatever objcopy/strip, etc. sent us as input. */ |
586 | | |
587 | | static long |
588 | | sec_to_styp_flags (const char *sec_name, flagword sec_flags) |
589 | 0 | { |
590 | 0 | long styp_flags = 0; |
591 | 0 | bool is_dbg = false; |
592 | |
|
593 | 0 | if (startswith (sec_name, DOT_DEBUG) |
594 | 0 | || startswith (sec_name, DOT_ZDEBUG) |
595 | 0 | #ifdef COFF_LONG_SECTION_NAMES |
596 | 0 | || startswith (sec_name, GNU_LINKONCE_WI) |
597 | 0 | || startswith (sec_name, GNU_LINKONCE_WT) |
598 | 0 | #endif |
599 | 0 | || startswith (sec_name, ".stab")) |
600 | 0 | is_dbg = true; |
601 | | |
602 | | /* caution: there are at least three groups of symbols that have |
603 | | very similar bits and meanings: IMAGE_SCN*, SEC_*, and STYP_*. |
604 | | SEC_* are the BFD internal flags, used for generic BFD |
605 | | information. STYP_* are the COFF section flags which appear in |
606 | | COFF files. IMAGE_SCN_* are the PE section flags which appear in |
607 | | PE files. The STYP_* flags and the IMAGE_SCN_* flags overlap, |
608 | | but there are more IMAGE_SCN_* flags. */ |
609 | | |
610 | | /* FIXME: There is no gas syntax to specify the debug section flag. */ |
611 | 0 | if (is_dbg) |
612 | 0 | { |
613 | 0 | sec_flags &= (SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD |
614 | 0 | | SEC_LINK_DUPLICATES_SAME_CONTENTS |
615 | 0 | | SEC_LINK_DUPLICATES_SAME_SIZE); |
616 | 0 | sec_flags |= SEC_DEBUGGING | SEC_READONLY; |
617 | 0 | } |
618 | | |
619 | | /* skip LOAD */ |
620 | | /* READONLY later */ |
621 | | /* skip RELOC */ |
622 | 0 | if ((sec_flags & SEC_CODE) != 0) |
623 | 0 | styp_flags |= IMAGE_SCN_CNT_CODE; |
624 | 0 | if ((sec_flags & (SEC_DATA | SEC_DEBUGGING)) != 0) |
625 | 0 | styp_flags |= IMAGE_SCN_CNT_INITIALIZED_DATA; |
626 | 0 | if ((sec_flags & SEC_ALLOC) != 0 && (sec_flags & SEC_LOAD) == 0) |
627 | 0 | styp_flags |= IMAGE_SCN_CNT_UNINITIALIZED_DATA; /* ==STYP_BSS */ |
628 | | /* skip ROM */ |
629 | | /* skip constRUCTOR */ |
630 | | /* skip CONTENTS */ |
631 | | #ifndef COFF_IMAGE_WITH_PE |
632 | | /* I don't think any of the IMAGE_SCN_LNK_* flags set below should be set |
633 | | when the output is PE. Only object files should have them, for the linker |
634 | | to consume. */ |
635 | 0 | if ((sec_flags & SEC_IS_COMMON) != 0) |
636 | 0 | styp_flags |= IMAGE_SCN_LNK_COMDAT; |
637 | | #endif |
638 | 0 | if ((sec_flags & SEC_DEBUGGING) != 0) |
639 | 0 | styp_flags |= IMAGE_SCN_MEM_DISCARDABLE; |
640 | 0 | if ((sec_flags & (SEC_EXCLUDE | SEC_NEVER_LOAD)) != 0 && !is_dbg) |
641 | | #ifdef COFF_IMAGE_WITH_PE |
642 | 0 | styp_flags |= IMAGE_SCN_MEM_DISCARDABLE; |
643 | | #else |
644 | 0 | styp_flags |= IMAGE_SCN_LNK_REMOVE; |
645 | | #endif |
646 | | /* skip IN_MEMORY */ |
647 | | /* skip SORT */ |
648 | | #ifndef COFF_IMAGE_WITH_PE |
649 | 0 | if (sec_flags & SEC_LINK_ONCE) |
650 | 0 | styp_flags |= IMAGE_SCN_LNK_COMDAT; |
651 | 0 | if ((sec_flags |
652 | 0 | & (SEC_LINK_DUPLICATES_DISCARD | SEC_LINK_DUPLICATES_SAME_CONTENTS |
653 | 0 | | SEC_LINK_DUPLICATES_SAME_SIZE)) != 0) |
654 | 0 | styp_flags |= IMAGE_SCN_LNK_COMDAT; |
655 | | #endif |
656 | | |
657 | | /* skip LINKER_CREATED */ |
658 | |
|
659 | 0 | if ((sec_flags & SEC_COFF_NOREAD) == 0) |
660 | 0 | styp_flags |= IMAGE_SCN_MEM_READ; /* Invert NOREAD for read. */ |
661 | 0 | if ((sec_flags & SEC_READONLY) == 0) |
662 | 0 | styp_flags |= IMAGE_SCN_MEM_WRITE; /* Invert READONLY for write. */ |
663 | 0 | if (sec_flags & SEC_CODE) |
664 | 0 | styp_flags |= IMAGE_SCN_MEM_EXECUTE; /* CODE->EXECUTE. */ |
665 | 0 | if (sec_flags & SEC_COFF_SHARED) |
666 | 0 | styp_flags |= IMAGE_SCN_MEM_SHARED; /* Shared remains meaningful. */ |
667 | |
|
668 | 0 | return styp_flags; |
669 | 0 | } Unexecuted instantiation: pei-i386.c:sec_to_styp_flags Unexecuted instantiation: pe-x86_64.c:sec_to_styp_flags Unexecuted instantiation: pei-x86_64.c:sec_to_styp_flags Unexecuted instantiation: pei-aarch64.c:sec_to_styp_flags Unexecuted instantiation: pe-aarch64.c:sec_to_styp_flags Unexecuted instantiation: pei-ia64.c:sec_to_styp_flags Unexecuted instantiation: pei-loongarch64.c:sec_to_styp_flags Unexecuted instantiation: pe-arm-wince.c:sec_to_styp_flags Unexecuted instantiation: pe-arm.c:sec_to_styp_flags Unexecuted instantiation: pe-i386.c:sec_to_styp_flags Unexecuted instantiation: pe-mcore.c:sec_to_styp_flags Unexecuted instantiation: pe-sh.c:sec_to_styp_flags Unexecuted instantiation: pei-arm-wince.c:sec_to_styp_flags Unexecuted instantiation: pei-arm.c:sec_to_styp_flags Unexecuted instantiation: pei-mcore.c:sec_to_styp_flags Unexecuted instantiation: pei-sh.c:sec_to_styp_flags |
670 | | |
671 | | #endif /* COFF_WITH_PE */ |
672 | | |
673 | | /* Return a word with SEC_* flags set to represent the incoming STYP_* |
674 | | flags (from scnhdr.s_flags). The inverse of this function is |
675 | | sec_to_styp_flags(). NOTE: If you add to/change this routine, you |
676 | | should probably mirror the changes in sec_to_styp_flags(). */ |
677 | | |
678 | | #ifndef COFF_WITH_PE |
679 | | |
680 | | static bool |
681 | | styp_to_sec_flags (bfd *abfd, |
682 | | void * hdr, |
683 | | const char *name, |
684 | | asection *section ATTRIBUTE_UNUSED, |
685 | | flagword *flags_ptr) |
686 | 947k | { |
687 | 947k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; |
688 | 947k | unsigned long styp_flags = internal_s->s_flags; |
689 | 947k | flagword sec_flags = 0; |
690 | | |
691 | | #ifdef STYP_BLOCK |
692 | 55.7k | if (styp_flags & STYP_BLOCK) |
693 | 7.86k | sec_flags |= SEC_TIC54X_BLOCK; |
694 | | #endif |
695 | | |
696 | | #ifdef STYP_CLINK |
697 | 55.7k | if (styp_flags & STYP_CLINK) |
698 | 8.55k | sec_flags |= SEC_TIC54X_CLINK; |
699 | | #endif |
700 | | |
701 | 947k | #ifdef STYP_NOLOAD |
702 | 947k | if (styp_flags & STYP_NOLOAD) |
703 | 254k | sec_flags |= SEC_NEVER_LOAD; |
704 | 947k | #endif /* STYP_NOLOAD */ |
705 | | |
706 | | /* For 386 COFF, at least, an unloadable text or data section is |
707 | | actually a shared library section. */ |
708 | 947k | if (styp_flags & STYP_TEXT) |
709 | 269k | { |
710 | 269k | if (sec_flags & SEC_NEVER_LOAD) |
711 | 124k | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; |
712 | 145k | else |
713 | 145k | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; |
714 | 269k | } |
715 | 677k | else if (styp_flags & STYP_DATA) |
716 | 82.7k | { |
717 | 82.7k | if (sec_flags & SEC_NEVER_LOAD) |
718 | 40.1k | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; |
719 | 42.5k | else |
720 | 42.5k | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; |
721 | 82.7k | } |
722 | 594k | else if (styp_flags & STYP_BSS) |
723 | 60.5k | { |
724 | | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY |
725 | 47.0k | if (sec_flags & SEC_NEVER_LOAD) |
726 | 25.4k | sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY; |
727 | 21.5k | else |
728 | 21.5k | #endif |
729 | 35.1k | sec_flags |= SEC_ALLOC; |
730 | 60.5k | } |
731 | 534k | else if (styp_flags & STYP_INFO) |
732 | 68.1k | { |
733 | | /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is |
734 | | defined. coff_compute_section_file_positions uses |
735 | | COFF_PAGE_SIZE to ensure that the low order bits of the |
736 | | section VMA and the file offset match. If we don't know |
737 | | COFF_PAGE_SIZE, we can't ensure the correct correspondence, |
738 | | and demand page loading of the file will fail. */ |
739 | | #if defined (COFF_PAGE_SIZE) && !defined (COFF_ALIGN_IN_S_FLAGS) |
740 | 34.1k | sec_flags |= SEC_DEBUGGING; |
741 | | #endif |
742 | 68.1k | } |
743 | 466k | else if (styp_flags & STYP_PAD) |
744 | 31.7k | sec_flags = 0; |
745 | | #ifdef RS6000COFF_C |
746 | 67.6k | else if (styp_flags & STYP_TDATA) |
747 | 4.60k | { |
748 | 4.60k | if (sec_flags & SEC_NEVER_LOAD) |
749 | 683 | sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY; |
750 | 3.92k | else |
751 | 3.92k | sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_LOAD | SEC_ALLOC; |
752 | 4.60k | } |
753 | 62.9k | else if (styp_flags & STYP_TBSS) |
754 | 1.54k | { |
755 | | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY |
756 | | if (sec_flags & SEC_NEVER_LOAD) |
757 | | sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY; |
758 | | else |
759 | | #endif |
760 | 1.54k | sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL; |
761 | 1.54k | } |
762 | 61.4k | else if (styp_flags & STYP_EXCEPT) |
763 | 5.48k | sec_flags |= SEC_LOAD; |
764 | 55.9k | else if (styp_flags & STYP_LOADER) |
765 | 1.15k | sec_flags |= SEC_LOAD; |
766 | 54.8k | else if (styp_flags & STYP_TYPCHK) |
767 | 626 | sec_flags |= SEC_LOAD; |
768 | 54.1k | else if (styp_flags & STYP_DWARF) |
769 | 987 | sec_flags |= SEC_DEBUGGING; |
770 | 53.2k | #endif |
771 | 419k | else if (strcmp (name, _TEXT) == 0) |
772 | 117 | { |
773 | 117 | if (sec_flags & SEC_NEVER_LOAD) |
774 | 21 | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; |
775 | 96 | else |
776 | 96 | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; |
777 | 117 | } |
778 | 419k | else if (strcmp (name, _DATA) == 0) |
779 | 185 | { |
780 | 185 | if (sec_flags & SEC_NEVER_LOAD) |
781 | 24 | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; |
782 | 161 | else |
783 | 161 | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; |
784 | 185 | } |
785 | 419k | else if (strcmp (name, _BSS) == 0) |
786 | 213 | { |
787 | | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY |
788 | 125 | if (sec_flags & SEC_NEVER_LOAD) |
789 | 20 | sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY; |
790 | 105 | else |
791 | 105 | #endif |
792 | 193 | sec_flags |= SEC_ALLOC; |
793 | 213 | } |
794 | 419k | else if (startswith (name, DOT_DEBUG) |
795 | 419k | || startswith (name, DOT_ZDEBUG) |
796 | | #ifdef _COMMENT |
797 | 332k | || strcmp (name, _COMMENT) == 0 |
798 | | #endif |
799 | | #ifdef COFF_LONG_SECTION_NAMES |
800 | 62.5k | || startswith (name, GNU_LINKONCE_WI) |
801 | 62.5k | || startswith (name, GNU_LINKONCE_WT) |
802 | | #endif |
803 | 419k | || startswith (name, ".stab")) |
804 | 503 | { |
805 | | #ifdef COFF_PAGE_SIZE |
806 | 305 | sec_flags |= SEC_DEBUGGING; |
807 | | #endif |
808 | 503 | } |
809 | | #ifdef _LIB |
810 | 332k | else if (strcmp (name, _LIB) == 0) |
811 | 26 | ; |
812 | 332k | #endif |
813 | | #ifdef _LIT |
814 | | else if (strcmp (name, _LIT) == 0) |
815 | | sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY; |
816 | | #endif |
817 | 332k | else |
818 | 418k | sec_flags |= SEC_ALLOC | SEC_LOAD; |
819 | | |
820 | 947k | #ifdef STYP_LIT /* A29k readonly text/data section type. */ |
821 | 947k | if ((styp_flags & STYP_LIT) == STYP_LIT) |
822 | 94.9k | sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY); |
823 | 947k | #endif /* STYP_LIT */ |
824 | | |
825 | | #ifdef STYP_OTHER_LOAD /* Other loaded sections. */ |
826 | | if (styp_flags & STYP_OTHER_LOAD) |
827 | | sec_flags = (SEC_LOAD | SEC_ALLOC); |
828 | | #endif /* STYP_SDATA */ |
829 | | |
830 | 947k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 |
831 | 947k | && (startswith (name, ".sbss") |
832 | 0 | || startswith (name, ".sdata"))) |
833 | 0 | sec_flags |= SEC_SMALL_DATA; |
834 | | |
835 | | #if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE) |
836 | | /* As a GNU extension, if the name begins with .gnu.linkonce, we |
837 | | only link a single copy of the section. This is used to support |
838 | | g++. g++ will emit each template expansion in its own section. |
839 | | The symbols will be defined as weak, so that multiple definitions |
840 | | are permitted. The GNU linker extension is to actually discard |
841 | | all but one of the sections. */ |
842 | 130k | if (startswith (name, ".gnu.linkonce")) |
843 | 0 | sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; |
844 | | #endif |
845 | | |
846 | 947k | if (flags_ptr == NULL) |
847 | 0 | return false; |
848 | | |
849 | 947k | * flags_ptr = sec_flags; |
850 | 947k | return true; |
851 | 947k | } coff-x86_64.c:styp_to_sec_flags Line | Count | Source | 686 | 199k | { | 687 | 199k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 688 | 199k | unsigned long styp_flags = internal_s->s_flags; | 689 | 199k | flagword sec_flags = 0; | 690 | | | 691 | | #ifdef STYP_BLOCK | 692 | | if (styp_flags & STYP_BLOCK) | 693 | | sec_flags |= SEC_TIC54X_BLOCK; | 694 | | #endif | 695 | | | 696 | | #ifdef STYP_CLINK | 697 | | if (styp_flags & STYP_CLINK) | 698 | | sec_flags |= SEC_TIC54X_CLINK; | 699 | | #endif | 700 | | | 701 | 199k | #ifdef STYP_NOLOAD | 702 | 199k | if (styp_flags & STYP_NOLOAD) | 703 | 78.1k | sec_flags |= SEC_NEVER_LOAD; | 704 | 199k | #endif /* STYP_NOLOAD */ | 705 | | | 706 | | /* For 386 COFF, at least, an unloadable text or data section is | 707 | | actually a shared library section. */ | 708 | 199k | if (styp_flags & STYP_TEXT) | 709 | 75.1k | { | 710 | 75.1k | if (sec_flags & SEC_NEVER_LOAD) | 711 | 37.2k | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 712 | 37.8k | else | 713 | 37.8k | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 714 | 75.1k | } | 715 | 124k | else if (styp_flags & STYP_DATA) | 716 | 31.3k | { | 717 | 31.3k | if (sec_flags & SEC_NEVER_LOAD) | 718 | 15.9k | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; | 719 | 15.4k | else | 720 | 15.4k | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; | 721 | 31.3k | } | 722 | 93.4k | else if (styp_flags & STYP_BSS) | 723 | 21.1k | { | 724 | 21.1k | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY | 725 | 21.1k | if (sec_flags & SEC_NEVER_LOAD) | 726 | 13.2k | sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY; | 727 | 7.89k | else | 728 | 7.89k | #endif | 729 | 7.89k | sec_flags |= SEC_ALLOC; | 730 | 21.1k | } | 731 | 72.3k | else if (styp_flags & STYP_INFO) | 732 | 13.2k | { | 733 | | /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is | 734 | | defined. coff_compute_section_file_positions uses | 735 | | COFF_PAGE_SIZE to ensure that the low order bits of the | 736 | | section VMA and the file offset match. If we don't know | 737 | | COFF_PAGE_SIZE, we can't ensure the correct correspondence, | 738 | | and demand page loading of the file will fail. */ | 739 | 13.2k | #if defined (COFF_PAGE_SIZE) && !defined (COFF_ALIGN_IN_S_FLAGS) | 740 | 13.2k | sec_flags |= SEC_DEBUGGING; | 741 | 13.2k | #endif | 742 | 13.2k | } | 743 | 59.1k | else if (styp_flags & STYP_PAD) | 744 | 6.03k | sec_flags = 0; | 745 | | #ifdef RS6000COFF_C | 746 | | else if (styp_flags & STYP_TDATA) | 747 | | { | 748 | | if (sec_flags & SEC_NEVER_LOAD) | 749 | | sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY; | 750 | | else | 751 | | sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_LOAD | SEC_ALLOC; | 752 | | } | 753 | | else if (styp_flags & STYP_TBSS) | 754 | | { | 755 | | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY | 756 | | if (sec_flags & SEC_NEVER_LOAD) | 757 | | sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY; | 758 | | else | 759 | | #endif | 760 | | sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL; | 761 | | } | 762 | | else if (styp_flags & STYP_EXCEPT) | 763 | | sec_flags |= SEC_LOAD; | 764 | | else if (styp_flags & STYP_LOADER) | 765 | | sec_flags |= SEC_LOAD; | 766 | | else if (styp_flags & STYP_TYPCHK) | 767 | | sec_flags |= SEC_LOAD; | 768 | | else if (styp_flags & STYP_DWARF) | 769 | | sec_flags |= SEC_DEBUGGING; | 770 | | #endif | 771 | 53.0k | else if (strcmp (name, _TEXT) == 0) | 772 | 8 | { | 773 | 8 | if (sec_flags & SEC_NEVER_LOAD) | 774 | 1 | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 775 | 7 | else | 776 | 7 | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 777 | 8 | } | 778 | 53.0k | else if (strcmp (name, _DATA) == 0) | 779 | 17 | { | 780 | 17 | if (sec_flags & SEC_NEVER_LOAD) | 781 | 1 | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; | 782 | 16 | else | 783 | 16 | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; | 784 | 17 | } | 785 | 53.0k | else if (strcmp (name, _BSS) == 0) | 786 | 36 | { | 787 | 36 | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY | 788 | 36 | if (sec_flags & SEC_NEVER_LOAD) | 789 | 9 | sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY; | 790 | 27 | else | 791 | 27 | #endif | 792 | 27 | sec_flags |= SEC_ALLOC; | 793 | 36 | } | 794 | 53.0k | else if (startswith (name, DOT_DEBUG) | 795 | 53.0k | || startswith (name, DOT_ZDEBUG) | 796 | 53.0k | #ifdef _COMMENT | 797 | 53.0k | || strcmp (name, _COMMENT) == 0 | 798 | 53.0k | #endif | 799 | | #ifdef COFF_LONG_SECTION_NAMES | 800 | | || startswith (name, GNU_LINKONCE_WI) | 801 | | || startswith (name, GNU_LINKONCE_WT) | 802 | | #endif | 803 | 53.0k | || startswith (name, ".stab")) | 804 | 57 | { | 805 | 57 | #ifdef COFF_PAGE_SIZE | 806 | 57 | sec_flags |= SEC_DEBUGGING; | 807 | 57 | #endif | 808 | 57 | } | 809 | 52.9k | #ifdef _LIB | 810 | 52.9k | else if (strcmp (name, _LIB) == 0) | 811 | 6 | ; | 812 | 52.9k | #endif | 813 | | #ifdef _LIT | 814 | | else if (strcmp (name, _LIT) == 0) | 815 | | sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY; | 816 | | #endif | 817 | 52.9k | else | 818 | 52.9k | sec_flags |= SEC_ALLOC | SEC_LOAD; | 819 | | | 820 | 199k | #ifdef STYP_LIT /* A29k readonly text/data section type. */ | 821 | 199k | if ((styp_flags & STYP_LIT) == STYP_LIT) | 822 | 32.4k | sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY); | 823 | 199k | #endif /* STYP_LIT */ | 824 | | | 825 | | #ifdef STYP_OTHER_LOAD /* Other loaded sections. */ | 826 | | if (styp_flags & STYP_OTHER_LOAD) | 827 | | sec_flags = (SEC_LOAD | SEC_ALLOC); | 828 | | #endif /* STYP_SDATA */ | 829 | | | 830 | 199k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 831 | 199k | && (startswith (name, ".sbss") | 832 | 0 | || startswith (name, ".sdata"))) | 833 | 0 | sec_flags |= SEC_SMALL_DATA; | 834 | | | 835 | | #if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE) | 836 | | /* As a GNU extension, if the name begins with .gnu.linkonce, we | 837 | | only link a single copy of the section. This is used to support | 838 | | g++. g++ will emit each template expansion in its own section. | 839 | | The symbols will be defined as weak, so that multiple definitions | 840 | | are permitted. The GNU linker extension is to actually discard | 841 | | all but one of the sections. */ | 842 | | if (startswith (name, ".gnu.linkonce")) | 843 | | sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; | 844 | | #endif | 845 | | | 846 | 199k | if (flags_ptr == NULL) | 847 | 0 | return false; | 848 | | | 849 | 199k | * flags_ptr = sec_flags; | 850 | 199k | return true; | 851 | 199k | } |
coff64-rs6000.c:styp_to_sec_flags Line | Count | Source | 686 | 46.2k | { | 687 | 46.2k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 688 | 46.2k | unsigned long styp_flags = internal_s->s_flags; | 689 | 46.2k | flagword sec_flags = 0; | 690 | | | 691 | | #ifdef STYP_BLOCK | 692 | | if (styp_flags & STYP_BLOCK) | 693 | | sec_flags |= SEC_TIC54X_BLOCK; | 694 | | #endif | 695 | | | 696 | | #ifdef STYP_CLINK | 697 | | if (styp_flags & STYP_CLINK) | 698 | | sec_flags |= SEC_TIC54X_CLINK; | 699 | | #endif | 700 | | | 701 | 46.2k | #ifdef STYP_NOLOAD | 702 | 46.2k | if (styp_flags & STYP_NOLOAD) | 703 | 10.1k | sec_flags |= SEC_NEVER_LOAD; | 704 | 46.2k | #endif /* STYP_NOLOAD */ | 705 | | | 706 | | /* For 386 COFF, at least, an unloadable text or data section is | 707 | | actually a shared library section. */ | 708 | 46.2k | if (styp_flags & STYP_TEXT) | 709 | 9.68k | { | 710 | 9.68k | if (sec_flags & SEC_NEVER_LOAD) | 711 | 5.21k | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 712 | 4.47k | else | 713 | 4.47k | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 714 | 9.68k | } | 715 | 36.5k | else if (styp_flags & STYP_DATA) | 716 | 2.54k | { | 717 | 2.54k | if (sec_flags & SEC_NEVER_LOAD) | 718 | 1.16k | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; | 719 | 1.38k | else | 720 | 1.38k | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; | 721 | 2.54k | } | 722 | 34.0k | else if (styp_flags & STYP_BSS) | 723 | 1.40k | { | 724 | | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY | 725 | | if (sec_flags & SEC_NEVER_LOAD) | 726 | | sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY; | 727 | | else | 728 | | #endif | 729 | 1.40k | sec_flags |= SEC_ALLOC; | 730 | 1.40k | } | 731 | 32.6k | else if (styp_flags & STYP_INFO) | 732 | 3.69k | { | 733 | | /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is | 734 | | defined. coff_compute_section_file_positions uses | 735 | | COFF_PAGE_SIZE to ensure that the low order bits of the | 736 | | section VMA and the file offset match. If we don't know | 737 | | COFF_PAGE_SIZE, we can't ensure the correct correspondence, | 738 | | and demand page loading of the file will fail. */ | 739 | | #if defined (COFF_PAGE_SIZE) && !defined (COFF_ALIGN_IN_S_FLAGS) | 740 | | sec_flags |= SEC_DEBUGGING; | 741 | | #endif | 742 | 3.69k | } | 743 | 28.9k | else if (styp_flags & STYP_PAD) | 744 | 1.95k | sec_flags = 0; | 745 | 26.9k | #ifdef RS6000COFF_C | 746 | 26.9k | else if (styp_flags & STYP_TDATA) | 747 | 1.40k | { | 748 | 1.40k | if (sec_flags & SEC_NEVER_LOAD) | 749 | 306 | sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY; | 750 | 1.10k | else | 751 | 1.10k | sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_LOAD | SEC_ALLOC; | 752 | 1.40k | } | 753 | 25.5k | else if (styp_flags & STYP_TBSS) | 754 | 601 | { | 755 | | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY | 756 | | if (sec_flags & SEC_NEVER_LOAD) | 757 | | sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY; | 758 | | else | 759 | | #endif | 760 | 601 | sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL; | 761 | 601 | } | 762 | 24.9k | else if (styp_flags & STYP_EXCEPT) | 763 | 2.79k | sec_flags |= SEC_LOAD; | 764 | 22.1k | else if (styp_flags & STYP_LOADER) | 765 | 553 | sec_flags |= SEC_LOAD; | 766 | 21.6k | else if (styp_flags & STYP_TYPCHK) | 767 | 266 | sec_flags |= SEC_LOAD; | 768 | 21.3k | else if (styp_flags & STYP_DWARF) | 769 | 366 | sec_flags |= SEC_DEBUGGING; | 770 | 20.9k | #endif | 771 | 20.9k | else if (strcmp (name, _TEXT) == 0) | 772 | 5 | { | 773 | 5 | if (sec_flags & SEC_NEVER_LOAD) | 774 | 1 | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 775 | 4 | else | 776 | 4 | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 777 | 5 | } | 778 | 20.9k | else if (strcmp (name, _DATA) == 0) | 779 | 7 | { | 780 | 7 | if (sec_flags & SEC_NEVER_LOAD) | 781 | 1 | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; | 782 | 6 | else | 783 | 6 | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; | 784 | 7 | } | 785 | 20.9k | else if (strcmp (name, _BSS) == 0) | 786 | 11 | { | 787 | | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY | 788 | | if (sec_flags & SEC_NEVER_LOAD) | 789 | | sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY; | 790 | | else | 791 | | #endif | 792 | 11 | sec_flags |= SEC_ALLOC; | 793 | 11 | } | 794 | 20.9k | else if (startswith (name, DOT_DEBUG) | 795 | 20.9k | || startswith (name, DOT_ZDEBUG) | 796 | | #ifdef _COMMENT | 797 | | || strcmp (name, _COMMENT) == 0 | 798 | | #endif | 799 | | #ifdef COFF_LONG_SECTION_NAMES | 800 | | || startswith (name, GNU_LINKONCE_WI) | 801 | | || startswith (name, GNU_LINKONCE_WT) | 802 | | #endif | 803 | 20.9k | || startswith (name, ".stab")) | 804 | 11 | { | 805 | | #ifdef COFF_PAGE_SIZE | 806 | | sec_flags |= SEC_DEBUGGING; | 807 | | #endif | 808 | 11 | } | 809 | | #ifdef _LIB | 810 | | else if (strcmp (name, _LIB) == 0) | 811 | | ; | 812 | | #endif | 813 | | #ifdef _LIT | 814 | | else if (strcmp (name, _LIT) == 0) | 815 | | sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY; | 816 | | #endif | 817 | 20.9k | else | 818 | 20.9k | sec_flags |= SEC_ALLOC | SEC_LOAD; | 819 | | | 820 | 46.2k | #ifdef STYP_LIT /* A29k readonly text/data section type. */ | 821 | 46.2k | if ((styp_flags & STYP_LIT) == STYP_LIT) | 822 | 3.06k | sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY); | 823 | 46.2k | #endif /* STYP_LIT */ | 824 | | | 825 | | #ifdef STYP_OTHER_LOAD /* Other loaded sections. */ | 826 | | if (styp_flags & STYP_OTHER_LOAD) | 827 | | sec_flags = (SEC_LOAD | SEC_ALLOC); | 828 | | #endif /* STYP_SDATA */ | 829 | | | 830 | 46.2k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 831 | 46.2k | && (startswith (name, ".sbss") | 832 | 0 | || startswith (name, ".sdata"))) | 833 | 0 | sec_flags |= SEC_SMALL_DATA; | 834 | | | 835 | | #if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE) | 836 | | /* As a GNU extension, if the name begins with .gnu.linkonce, we | 837 | | only link a single copy of the section. This is used to support | 838 | | g++. g++ will emit each template expansion in its own section. | 839 | | The symbols will be defined as weak, so that multiple definitions | 840 | | are permitted. The GNU linker extension is to actually discard | 841 | | all but one of the sections. */ | 842 | | if (startswith (name, ".gnu.linkonce")) | 843 | | sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; | 844 | | #endif | 845 | | | 846 | 46.2k | if (flags_ptr == NULL) | 847 | 0 | return false; | 848 | | | 849 | 46.2k | * flags_ptr = sec_flags; | 850 | 46.2k | return true; | 851 | 46.2k | } |
cf-i386lynx.c:styp_to_sec_flags Line | Count | Source | 686 | 140k | { | 687 | 140k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 688 | 140k | unsigned long styp_flags = internal_s->s_flags; | 689 | 140k | flagword sec_flags = 0; | 690 | | | 691 | | #ifdef STYP_BLOCK | 692 | | if (styp_flags & STYP_BLOCK) | 693 | | sec_flags |= SEC_TIC54X_BLOCK; | 694 | | #endif | 695 | | | 696 | | #ifdef STYP_CLINK | 697 | | if (styp_flags & STYP_CLINK) | 698 | | sec_flags |= SEC_TIC54X_CLINK; | 699 | | #endif | 700 | | | 701 | 140k | #ifdef STYP_NOLOAD | 702 | 140k | if (styp_flags & STYP_NOLOAD) | 703 | 32.9k | sec_flags |= SEC_NEVER_LOAD; | 704 | 140k | #endif /* STYP_NOLOAD */ | 705 | | | 706 | | /* For 386 COFF, at least, an unloadable text or data section is | 707 | | actually a shared library section. */ | 708 | 140k | if (styp_flags & STYP_TEXT) | 709 | 40.2k | { | 710 | 40.2k | if (sec_flags & SEC_NEVER_LOAD) | 711 | 16.9k | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 712 | 23.2k | else | 713 | 23.2k | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 714 | 40.2k | } | 715 | 100k | else if (styp_flags & STYP_DATA) | 716 | 10.7k | { | 717 | 10.7k | if (sec_flags & SEC_NEVER_LOAD) | 718 | 5.07k | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; | 719 | 5.70k | else | 720 | 5.70k | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; | 721 | 10.7k | } | 722 | 89.8k | else if (styp_flags & STYP_BSS) | 723 | 9.51k | { | 724 | 9.51k | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY | 725 | 9.51k | if (sec_flags & SEC_NEVER_LOAD) | 726 | 4.68k | sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY; | 727 | 4.83k | else | 728 | 4.83k | #endif | 729 | 4.83k | sec_flags |= SEC_ALLOC; | 730 | 9.51k | } | 731 | 80.3k | else if (styp_flags & STYP_INFO) | 732 | 7.50k | { | 733 | | /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is | 734 | | defined. coff_compute_section_file_positions uses | 735 | | COFF_PAGE_SIZE to ensure that the low order bits of the | 736 | | section VMA and the file offset match. If we don't know | 737 | | COFF_PAGE_SIZE, we can't ensure the correct correspondence, | 738 | | and demand page loading of the file will fail. */ | 739 | 7.50k | #if defined (COFF_PAGE_SIZE) && !defined (COFF_ALIGN_IN_S_FLAGS) | 740 | 7.50k | sec_flags |= SEC_DEBUGGING; | 741 | 7.50k | #endif | 742 | 7.50k | } | 743 | 72.7k | else if (styp_flags & STYP_PAD) | 744 | 3.57k | sec_flags = 0; | 745 | | #ifdef RS6000COFF_C | 746 | | else if (styp_flags & STYP_TDATA) | 747 | | { | 748 | | if (sec_flags & SEC_NEVER_LOAD) | 749 | | sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY; | 750 | | else | 751 | | sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_LOAD | SEC_ALLOC; | 752 | | } | 753 | | else if (styp_flags & STYP_TBSS) | 754 | | { | 755 | | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY | 756 | | if (sec_flags & SEC_NEVER_LOAD) | 757 | | sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY; | 758 | | else | 759 | | #endif | 760 | | sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL; | 761 | | } | 762 | | else if (styp_flags & STYP_EXCEPT) | 763 | | sec_flags |= SEC_LOAD; | 764 | | else if (styp_flags & STYP_LOADER) | 765 | | sec_flags |= SEC_LOAD; | 766 | | else if (styp_flags & STYP_TYPCHK) | 767 | | sec_flags |= SEC_LOAD; | 768 | | else if (styp_flags & STYP_DWARF) | 769 | | sec_flags |= SEC_DEBUGGING; | 770 | | #endif | 771 | 69.2k | else if (strcmp (name, _TEXT) == 0) | 772 | 12 | { | 773 | 12 | if (sec_flags & SEC_NEVER_LOAD) | 774 | 2 | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 775 | 10 | else | 776 | 10 | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 777 | 12 | } | 778 | 69.2k | else if (strcmp (name, _DATA) == 0) | 779 | 32 | { | 780 | 32 | if (sec_flags & SEC_NEVER_LOAD) | 781 | 5 | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; | 782 | 27 | else | 783 | 27 | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; | 784 | 32 | } | 785 | 69.1k | else if (strcmp (name, _BSS) == 0) | 786 | 36 | { | 787 | 36 | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY | 788 | 36 | if (sec_flags & SEC_NEVER_LOAD) | 789 | 5 | sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY; | 790 | 31 | else | 791 | 31 | #endif | 792 | 31 | sec_flags |= SEC_ALLOC; | 793 | 36 | } | 794 | 69.1k | else if (startswith (name, DOT_DEBUG) | 795 | 69.1k | || startswith (name, DOT_ZDEBUG) | 796 | 69.1k | #ifdef _COMMENT | 797 | 69.1k | || strcmp (name, _COMMENT) == 0 | 798 | 69.1k | #endif | 799 | | #ifdef COFF_LONG_SECTION_NAMES | 800 | | || startswith (name, GNU_LINKONCE_WI) | 801 | | || startswith (name, GNU_LINKONCE_WT) | 802 | | #endif | 803 | 69.1k | || startswith (name, ".stab")) | 804 | 94 | { | 805 | 94 | #ifdef COFF_PAGE_SIZE | 806 | 94 | sec_flags |= SEC_DEBUGGING; | 807 | 94 | #endif | 808 | 94 | } | 809 | 69.0k | #ifdef _LIB | 810 | 69.0k | else if (strcmp (name, _LIB) == 0) | 811 | 5 | ; | 812 | 69.0k | #endif | 813 | | #ifdef _LIT | 814 | | else if (strcmp (name, _LIT) == 0) | 815 | | sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY; | 816 | | #endif | 817 | 69.0k | else | 818 | 69.0k | sec_flags |= SEC_ALLOC | SEC_LOAD; | 819 | | | 820 | 140k | #ifdef STYP_LIT /* A29k readonly text/data section type. */ | 821 | 140k | if ((styp_flags & STYP_LIT) == STYP_LIT) | 822 | 14.0k | sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY); | 823 | 140k | #endif /* STYP_LIT */ | 824 | | | 825 | | #ifdef STYP_OTHER_LOAD /* Other loaded sections. */ | 826 | | if (styp_flags & STYP_OTHER_LOAD) | 827 | | sec_flags = (SEC_LOAD | SEC_ALLOC); | 828 | | #endif /* STYP_SDATA */ | 829 | | | 830 | 140k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 831 | 140k | && (startswith (name, ".sbss") | 832 | 0 | || startswith (name, ".sdata"))) | 833 | 0 | sec_flags |= SEC_SMALL_DATA; | 834 | | | 835 | | #if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE) | 836 | | /* As a GNU extension, if the name begins with .gnu.linkonce, we | 837 | | only link a single copy of the section. This is used to support | 838 | | g++. g++ will emit each template expansion in its own section. | 839 | | The symbols will be defined as weak, so that multiple definitions | 840 | | are permitted. The GNU linker extension is to actually discard | 841 | | all but one of the sections. */ | 842 | | if (startswith (name, ".gnu.linkonce")) | 843 | | sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; | 844 | | #endif | 845 | | | 846 | 140k | if (flags_ptr == NULL) | 847 | 0 | return false; | 848 | | | 849 | 140k | * flags_ptr = sec_flags; | 850 | 140k | return true; | 851 | 140k | } |
coff-go32.c:styp_to_sec_flags Line | Count | Source | 686 | 116k | { | 687 | 116k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 688 | 116k | unsigned long styp_flags = internal_s->s_flags; | 689 | 116k | flagword sec_flags = 0; | 690 | | | 691 | | #ifdef STYP_BLOCK | 692 | | if (styp_flags & STYP_BLOCK) | 693 | | sec_flags |= SEC_TIC54X_BLOCK; | 694 | | #endif | 695 | | | 696 | | #ifdef STYP_CLINK | 697 | | if (styp_flags & STYP_CLINK) | 698 | | sec_flags |= SEC_TIC54X_CLINK; | 699 | | #endif | 700 | | | 701 | 116k | #ifdef STYP_NOLOAD | 702 | 116k | if (styp_flags & STYP_NOLOAD) | 703 | 26.8k | sec_flags |= SEC_NEVER_LOAD; | 704 | 116k | #endif /* STYP_NOLOAD */ | 705 | | | 706 | | /* For 386 COFF, at least, an unloadable text or data section is | 707 | | actually a shared library section. */ | 708 | 116k | if (styp_flags & STYP_TEXT) | 709 | 35.3k | { | 710 | 35.3k | if (sec_flags & SEC_NEVER_LOAD) | 711 | 14.9k | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 712 | 20.4k | else | 713 | 20.4k | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 714 | 35.3k | } | 715 | 81.5k | else if (styp_flags & STYP_DATA) | 716 | 9.17k | { | 717 | 9.17k | if (sec_flags & SEC_NEVER_LOAD) | 718 | 4.26k | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; | 719 | 4.91k | else | 720 | 4.91k | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; | 721 | 9.17k | } | 722 | 72.3k | else if (styp_flags & STYP_BSS) | 723 | 6.79k | { | 724 | 6.79k | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY | 725 | 6.79k | if (sec_flags & SEC_NEVER_LOAD) | 726 | 2.76k | sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY; | 727 | 4.03k | else | 728 | 4.03k | #endif | 729 | 4.03k | sec_flags |= SEC_ALLOC; | 730 | 6.79k | } | 731 | 65.5k | else if (styp_flags & STYP_INFO) | 732 | 5.93k | { | 733 | | /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is | 734 | | defined. coff_compute_section_file_positions uses | 735 | | COFF_PAGE_SIZE to ensure that the low order bits of the | 736 | | section VMA and the file offset match. If we don't know | 737 | | COFF_PAGE_SIZE, we can't ensure the correct correspondence, | 738 | | and demand page loading of the file will fail. */ | 739 | 5.93k | #if defined (COFF_PAGE_SIZE) && !defined (COFF_ALIGN_IN_S_FLAGS) | 740 | 5.93k | sec_flags |= SEC_DEBUGGING; | 741 | 5.93k | #endif | 742 | 5.93k | } | 743 | 59.6k | else if (styp_flags & STYP_PAD) | 744 | 3.09k | sec_flags = 0; | 745 | | #ifdef RS6000COFF_C | 746 | | else if (styp_flags & STYP_TDATA) | 747 | | { | 748 | | if (sec_flags & SEC_NEVER_LOAD) | 749 | | sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY; | 750 | | else | 751 | | sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_LOAD | SEC_ALLOC; | 752 | | } | 753 | | else if (styp_flags & STYP_TBSS) | 754 | | { | 755 | | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY | 756 | | if (sec_flags & SEC_NEVER_LOAD) | 757 | | sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY; | 758 | | else | 759 | | #endif | 760 | | sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL; | 761 | | } | 762 | | else if (styp_flags & STYP_EXCEPT) | 763 | | sec_flags |= SEC_LOAD; | 764 | | else if (styp_flags & STYP_LOADER) | 765 | | sec_flags |= SEC_LOAD; | 766 | | else if (styp_flags & STYP_TYPCHK) | 767 | | sec_flags |= SEC_LOAD; | 768 | | else if (styp_flags & STYP_DWARF) | 769 | | sec_flags |= SEC_DEBUGGING; | 770 | | #endif | 771 | 56.5k | else if (strcmp (name, _TEXT) == 0) | 772 | 8 | { | 773 | 8 | if (sec_flags & SEC_NEVER_LOAD) | 774 | 1 | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 775 | 7 | else | 776 | 7 | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 777 | 8 | } | 778 | 56.5k | else if (strcmp (name, _DATA) == 0) | 779 | 12 | { | 780 | 12 | if (sec_flags & SEC_NEVER_LOAD) | 781 | 1 | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; | 782 | 11 | else | 783 | 11 | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; | 784 | 12 | } | 785 | 56.5k | else if (strcmp (name, _BSS) == 0) | 786 | 17 | { | 787 | 17 | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY | 788 | 17 | if (sec_flags & SEC_NEVER_LOAD) | 789 | 1 | sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY; | 790 | 16 | else | 791 | 16 | #endif | 792 | 16 | sec_flags |= SEC_ALLOC; | 793 | 17 | } | 794 | 56.5k | else if (startswith (name, DOT_DEBUG) | 795 | 56.5k | || startswith (name, DOT_ZDEBUG) | 796 | 56.5k | #ifdef _COMMENT | 797 | 56.5k | || strcmp (name, _COMMENT) == 0 | 798 | 56.5k | #endif | 799 | 56.5k | #ifdef COFF_LONG_SECTION_NAMES | 800 | 56.5k | || startswith (name, GNU_LINKONCE_WI) | 801 | 56.5k | || startswith (name, GNU_LINKONCE_WT) | 802 | 56.5k | #endif | 803 | 56.5k | || startswith (name, ".stab")) | 804 | 60 | { | 805 | 60 | #ifdef COFF_PAGE_SIZE | 806 | 60 | sec_flags |= SEC_DEBUGGING; | 807 | 60 | #endif | 808 | 60 | } | 809 | 56.4k | #ifdef _LIB | 810 | 56.4k | else if (strcmp (name, _LIB) == 0) | 811 | 4 | ; | 812 | 56.4k | #endif | 813 | | #ifdef _LIT | 814 | | else if (strcmp (name, _LIT) == 0) | 815 | | sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY; | 816 | | #endif | 817 | 56.4k | else | 818 | 56.4k | sec_flags |= SEC_ALLOC | SEC_LOAD; | 819 | | | 820 | 116k | #ifdef STYP_LIT /* A29k readonly text/data section type. */ | 821 | 116k | if ((styp_flags & STYP_LIT) == STYP_LIT) | 822 | 12.5k | sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY); | 823 | 116k | #endif /* STYP_LIT */ | 824 | | | 825 | | #ifdef STYP_OTHER_LOAD /* Other loaded sections. */ | 826 | | if (styp_flags & STYP_OTHER_LOAD) | 827 | | sec_flags = (SEC_LOAD | SEC_ALLOC); | 828 | | #endif /* STYP_SDATA */ | 829 | | | 830 | 116k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 831 | 116k | && (startswith (name, ".sbss") | 832 | 0 | || startswith (name, ".sdata"))) | 833 | 0 | sec_flags |= SEC_SMALL_DATA; | 834 | | | 835 | 116k | #if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE) | 836 | | /* As a GNU extension, if the name begins with .gnu.linkonce, we | 837 | | only link a single copy of the section. This is used to support | 838 | | g++. g++ will emit each template expansion in its own section. | 839 | | The symbols will be defined as weak, so that multiple definitions | 840 | | are permitted. The GNU linker extension is to actually discard | 841 | | all but one of the sections. */ | 842 | 116k | if (startswith (name, ".gnu.linkonce")) | 843 | 0 | sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; | 844 | 116k | #endif | 845 | | | 846 | 116k | if (flags_ptr == NULL) | 847 | 0 | return false; | 848 | | | 849 | 116k | * flags_ptr = sec_flags; | 850 | 116k | return true; | 851 | 116k | } |
coff-i386.c:styp_to_sec_flags Line | Count | Source | 686 | 127k | { | 687 | 127k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 688 | 127k | unsigned long styp_flags = internal_s->s_flags; | 689 | 127k | flagword sec_flags = 0; | 690 | | | 691 | | #ifdef STYP_BLOCK | 692 | | if (styp_flags & STYP_BLOCK) | 693 | | sec_flags |= SEC_TIC54X_BLOCK; | 694 | | #endif | 695 | | | 696 | | #ifdef STYP_CLINK | 697 | | if (styp_flags & STYP_CLINK) | 698 | | sec_flags |= SEC_TIC54X_CLINK; | 699 | | #endif | 700 | | | 701 | 127k | #ifdef STYP_NOLOAD | 702 | 127k | if (styp_flags & STYP_NOLOAD) | 703 | 28.4k | sec_flags |= SEC_NEVER_LOAD; | 704 | 127k | #endif /* STYP_NOLOAD */ | 705 | | | 706 | | /* For 386 COFF, at least, an unloadable text or data section is | 707 | | actually a shared library section. */ | 708 | 127k | if (styp_flags & STYP_TEXT) | 709 | 37.4k | { | 710 | 37.4k | if (sec_flags & SEC_NEVER_LOAD) | 711 | 15.8k | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 712 | 21.6k | else | 713 | 21.6k | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 714 | 37.4k | } | 715 | 89.9k | else if (styp_flags & STYP_DATA) | 716 | 9.80k | { | 717 | 9.80k | if (sec_flags & SEC_NEVER_LOAD) | 718 | 4.53k | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; | 719 | 5.26k | else | 720 | 5.26k | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; | 721 | 9.80k | } | 722 | 80.1k | else if (styp_flags & STYP_BSS) | 723 | 7.16k | { | 724 | 7.16k | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY | 725 | 7.16k | if (sec_flags & SEC_NEVER_LOAD) | 726 | 2.85k | sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY; | 727 | 4.31k | else | 728 | 4.31k | #endif | 729 | 4.31k | sec_flags |= SEC_ALLOC; | 730 | 7.16k | } | 731 | 72.9k | else if (styp_flags & STYP_INFO) | 732 | 6.42k | { | 733 | | /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is | 734 | | defined. coff_compute_section_file_positions uses | 735 | | COFF_PAGE_SIZE to ensure that the low order bits of the | 736 | | section VMA and the file offset match. If we don't know | 737 | | COFF_PAGE_SIZE, we can't ensure the correct correspondence, | 738 | | and demand page loading of the file will fail. */ | 739 | 6.42k | #if defined (COFF_PAGE_SIZE) && !defined (COFF_ALIGN_IN_S_FLAGS) | 740 | 6.42k | sec_flags |= SEC_DEBUGGING; | 741 | 6.42k | #endif | 742 | 6.42k | } | 743 | 66.5k | else if (styp_flags & STYP_PAD) | 744 | 3.35k | sec_flags = 0; | 745 | | #ifdef RS6000COFF_C | 746 | | else if (styp_flags & STYP_TDATA) | 747 | | { | 748 | | if (sec_flags & SEC_NEVER_LOAD) | 749 | | sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY; | 750 | | else | 751 | | sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_LOAD | SEC_ALLOC; | 752 | | } | 753 | | else if (styp_flags & STYP_TBSS) | 754 | | { | 755 | | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY | 756 | | if (sec_flags & SEC_NEVER_LOAD) | 757 | | sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY; | 758 | | else | 759 | | #endif | 760 | | sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL; | 761 | | } | 762 | | else if (styp_flags & STYP_EXCEPT) | 763 | | sec_flags |= SEC_LOAD; | 764 | | else if (styp_flags & STYP_LOADER) | 765 | | sec_flags |= SEC_LOAD; | 766 | | else if (styp_flags & STYP_TYPCHK) | 767 | | sec_flags |= SEC_LOAD; | 768 | | else if (styp_flags & STYP_DWARF) | 769 | | sec_flags |= SEC_DEBUGGING; | 770 | | #endif | 771 | 63.1k | else if (strcmp (name, _TEXT) == 0) | 772 | 10 | { | 773 | 10 | if (sec_flags & SEC_NEVER_LOAD) | 774 | 1 | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 775 | 9 | else | 776 | 9 | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 777 | 10 | } | 778 | 63.1k | else if (strcmp (name, _DATA) == 0) | 779 | 13 | { | 780 | 13 | if (sec_flags & SEC_NEVER_LOAD) | 781 | 1 | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; | 782 | 12 | else | 783 | 12 | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; | 784 | 13 | } | 785 | 63.1k | else if (strcmp (name, _BSS) == 0) | 786 | 17 | { | 787 | 17 | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY | 788 | 17 | if (sec_flags & SEC_NEVER_LOAD) | 789 | 1 | sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY; | 790 | 16 | else | 791 | 16 | #endif | 792 | 16 | sec_flags |= SEC_ALLOC; | 793 | 17 | } | 794 | 63.1k | else if (startswith (name, DOT_DEBUG) | 795 | 63.1k | || startswith (name, DOT_ZDEBUG) | 796 | 63.1k | #ifdef _COMMENT | 797 | 63.1k | || strcmp (name, _COMMENT) == 0 | 798 | 63.1k | #endif | 799 | | #ifdef COFF_LONG_SECTION_NAMES | 800 | | || startswith (name, GNU_LINKONCE_WI) | 801 | | || startswith (name, GNU_LINKONCE_WT) | 802 | | #endif | 803 | 63.1k | || startswith (name, ".stab")) | 804 | 62 | { | 805 | 62 | #ifdef COFF_PAGE_SIZE | 806 | 62 | sec_flags |= SEC_DEBUGGING; | 807 | 62 | #endif | 808 | 62 | } | 809 | 63.0k | #ifdef _LIB | 810 | 63.0k | else if (strcmp (name, _LIB) == 0) | 811 | 4 | ; | 812 | 63.0k | #endif | 813 | | #ifdef _LIT | 814 | | else if (strcmp (name, _LIT) == 0) | 815 | | sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY; | 816 | | #endif | 817 | 63.0k | else | 818 | 63.0k | sec_flags |= SEC_ALLOC | SEC_LOAD; | 819 | | | 820 | 127k | #ifdef STYP_LIT /* A29k readonly text/data section type. */ | 821 | 127k | if ((styp_flags & STYP_LIT) == STYP_LIT) | 822 | 13.0k | sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY); | 823 | 127k | #endif /* STYP_LIT */ | 824 | | | 825 | | #ifdef STYP_OTHER_LOAD /* Other loaded sections. */ | 826 | | if (styp_flags & STYP_OTHER_LOAD) | 827 | | sec_flags = (SEC_LOAD | SEC_ALLOC); | 828 | | #endif /* STYP_SDATA */ | 829 | | | 830 | 127k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 831 | 127k | && (startswith (name, ".sbss") | 832 | 0 | || startswith (name, ".sdata"))) | 833 | 0 | sec_flags |= SEC_SMALL_DATA; | 834 | | | 835 | | #if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE) | 836 | | /* As a GNU extension, if the name begins with .gnu.linkonce, we | 837 | | only link a single copy of the section. This is used to support | 838 | | g++. g++ will emit each template expansion in its own section. | 839 | | The symbols will be defined as weak, so that multiple definitions | 840 | | are permitted. The GNU linker extension is to actually discard | 841 | | all but one of the sections. */ | 842 | | if (startswith (name, ".gnu.linkonce")) | 843 | | sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; | 844 | | #endif | 845 | | | 846 | 127k | if (flags_ptr == NULL) | 847 | 0 | return false; | 848 | | | 849 | 127k | * flags_ptr = sec_flags; | 850 | 127k | return true; | 851 | 127k | } |
coff-rs6000.c:styp_to_sec_flags Line | Count | Source | 686 | 85.1k | { | 687 | 85.1k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 688 | 85.1k | unsigned long styp_flags = internal_s->s_flags; | 689 | 85.1k | flagword sec_flags = 0; | 690 | | | 691 | | #ifdef STYP_BLOCK | 692 | | if (styp_flags & STYP_BLOCK) | 693 | | sec_flags |= SEC_TIC54X_BLOCK; | 694 | | #endif | 695 | | | 696 | | #ifdef STYP_CLINK | 697 | | if (styp_flags & STYP_CLINK) | 698 | | sec_flags |= SEC_TIC54X_CLINK; | 699 | | #endif | 700 | | | 701 | 85.1k | #ifdef STYP_NOLOAD | 702 | 85.1k | if (styp_flags & STYP_NOLOAD) | 703 | 24.7k | sec_flags |= SEC_NEVER_LOAD; | 704 | 85.1k | #endif /* STYP_NOLOAD */ | 705 | | | 706 | | /* For 386 COFF, at least, an unloadable text or data section is | 707 | | actually a shared library section. */ | 708 | 85.1k | if (styp_flags & STYP_TEXT) | 709 | 20.3k | { | 710 | 20.3k | if (sec_flags & SEC_NEVER_LOAD) | 711 | 9.73k | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 712 | 10.6k | else | 713 | 10.6k | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 714 | 20.3k | } | 715 | 64.7k | else if (styp_flags & STYP_DATA) | 716 | 6.10k | { | 717 | 6.10k | if (sec_flags & SEC_NEVER_LOAD) | 718 | 2.83k | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; | 719 | 3.27k | else | 720 | 3.27k | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; | 721 | 6.10k | } | 722 | 58.6k | else if (styp_flags & STYP_BSS) | 723 | 5.23k | { | 724 | | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY | 725 | | if (sec_flags & SEC_NEVER_LOAD) | 726 | | sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY; | 727 | | else | 728 | | #endif | 729 | 5.23k | sec_flags |= SEC_ALLOC; | 730 | 5.23k | } | 731 | 53.4k | else if (styp_flags & STYP_INFO) | 732 | 10.1k | { | 733 | | /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is | 734 | | defined. coff_compute_section_file_positions uses | 735 | | COFF_PAGE_SIZE to ensure that the low order bits of the | 736 | | section VMA and the file offset match. If we don't know | 737 | | COFF_PAGE_SIZE, we can't ensure the correct correspondence, | 738 | | and demand page loading of the file will fail. */ | 739 | | #if defined (COFF_PAGE_SIZE) && !defined (COFF_ALIGN_IN_S_FLAGS) | 740 | | sec_flags |= SEC_DEBUGGING; | 741 | | #endif | 742 | 10.1k | } | 743 | 43.2k | else if (styp_flags & STYP_PAD) | 744 | 2.63k | sec_flags = 0; | 745 | 40.6k | #ifdef RS6000COFF_C | 746 | 40.6k | else if (styp_flags & STYP_TDATA) | 747 | 3.19k | { | 748 | 3.19k | if (sec_flags & SEC_NEVER_LOAD) | 749 | 377 | sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY; | 750 | 2.82k | else | 751 | 2.82k | sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_LOAD | SEC_ALLOC; | 752 | 3.19k | } | 753 | 37.4k | else if (styp_flags & STYP_TBSS) | 754 | 948 | { | 755 | | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY | 756 | | if (sec_flags & SEC_NEVER_LOAD) | 757 | | sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY; | 758 | | else | 759 | | #endif | 760 | 948 | sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL; | 761 | 948 | } | 762 | 36.4k | else if (styp_flags & STYP_EXCEPT) | 763 | 2.68k | sec_flags |= SEC_LOAD; | 764 | 33.7k | else if (styp_flags & STYP_LOADER) | 765 | 599 | sec_flags |= SEC_LOAD; | 766 | 33.1k | else if (styp_flags & STYP_TYPCHK) | 767 | 360 | sec_flags |= SEC_LOAD; | 768 | 32.8k | else if (styp_flags & STYP_DWARF) | 769 | 621 | sec_flags |= SEC_DEBUGGING; | 770 | 32.2k | #endif | 771 | 32.2k | else if (strcmp (name, _TEXT) == 0) | 772 | 42 | { | 773 | 42 | if (sec_flags & SEC_NEVER_LOAD) | 774 | 10 | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 775 | 32 | else | 776 | 32 | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 777 | 42 | } | 778 | 32.1k | else if (strcmp (name, _DATA) == 0) | 779 | 27 | { | 780 | 27 | if (sec_flags & SEC_NEVER_LOAD) | 781 | 0 | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; | 782 | 27 | else | 783 | 27 | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; | 784 | 27 | } | 785 | 32.1k | else if (strcmp (name, _BSS) == 0) | 786 | 15 | { | 787 | | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY | 788 | | if (sec_flags & SEC_NEVER_LOAD) | 789 | | sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY; | 790 | | else | 791 | | #endif | 792 | 15 | sec_flags |= SEC_ALLOC; | 793 | 15 | } | 794 | 32.1k | else if (startswith (name, DOT_DEBUG) | 795 | 32.1k | || startswith (name, DOT_ZDEBUG) | 796 | | #ifdef _COMMENT | 797 | | || strcmp (name, _COMMENT) == 0 | 798 | | #endif | 799 | | #ifdef COFF_LONG_SECTION_NAMES | 800 | | || startswith (name, GNU_LINKONCE_WI) | 801 | | || startswith (name, GNU_LINKONCE_WT) | 802 | | #endif | 803 | 32.1k | || startswith (name, ".stab")) | 804 | 31 | { | 805 | | #ifdef COFF_PAGE_SIZE | 806 | | sec_flags |= SEC_DEBUGGING; | 807 | | #endif | 808 | 31 | } | 809 | | #ifdef _LIB | 810 | | else if (strcmp (name, _LIB) == 0) | 811 | | ; | 812 | | #endif | 813 | | #ifdef _LIT | 814 | | else if (strcmp (name, _LIT) == 0) | 815 | | sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY; | 816 | | #endif | 817 | 32.0k | else | 818 | 32.0k | sec_flags |= SEC_ALLOC | SEC_LOAD; | 819 | | | 820 | 85.1k | #ifdef STYP_LIT /* A29k readonly text/data section type. */ | 821 | 85.1k | if ((styp_flags & STYP_LIT) == STYP_LIT) | 822 | 6.13k | sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY); | 823 | 85.1k | #endif /* STYP_LIT */ | 824 | | | 825 | | #ifdef STYP_OTHER_LOAD /* Other loaded sections. */ | 826 | | if (styp_flags & STYP_OTHER_LOAD) | 827 | | sec_flags = (SEC_LOAD | SEC_ALLOC); | 828 | | #endif /* STYP_SDATA */ | 829 | | | 830 | 85.1k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 831 | 85.1k | && (startswith (name, ".sbss") | 832 | 0 | || startswith (name, ".sdata"))) | 833 | 0 | sec_flags |= SEC_SMALL_DATA; | 834 | | | 835 | | #if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE) | 836 | | /* As a GNU extension, if the name begins with .gnu.linkonce, we | 837 | | only link a single copy of the section. This is used to support | 838 | | g++. g++ will emit each template expansion in its own section. | 839 | | The symbols will be defined as weak, so that multiple definitions | 840 | | are permitted. The GNU linker extension is to actually discard | 841 | | all but one of the sections. */ | 842 | | if (startswith (name, ".gnu.linkonce")) | 843 | | sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; | 844 | | #endif | 845 | | | 846 | 85.1k | if (flags_ptr == NULL) | 847 | 0 | return false; | 848 | | | 849 | 85.1k | * flags_ptr = sec_flags; | 850 | 85.1k | return true; | 851 | 85.1k | } |
coff-sh.c:styp_to_sec_flags Line | Count | Source | 686 | 20.6k | { | 687 | 20.6k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 688 | 20.6k | unsigned long styp_flags = internal_s->s_flags; | 689 | 20.6k | flagword sec_flags = 0; | 690 | | | 691 | | #ifdef STYP_BLOCK | 692 | | if (styp_flags & STYP_BLOCK) | 693 | | sec_flags |= SEC_TIC54X_BLOCK; | 694 | | #endif | 695 | | | 696 | | #ifdef STYP_CLINK | 697 | | if (styp_flags & STYP_CLINK) | 698 | | sec_flags |= SEC_TIC54X_CLINK; | 699 | | #endif | 700 | | | 701 | 20.6k | #ifdef STYP_NOLOAD | 702 | 20.6k | if (styp_flags & STYP_NOLOAD) | 703 | 5.23k | sec_flags |= SEC_NEVER_LOAD; | 704 | 20.6k | #endif /* STYP_NOLOAD */ | 705 | | | 706 | | /* For 386 COFF, at least, an unloadable text or data section is | 707 | | actually a shared library section. */ | 708 | 20.6k | if (styp_flags & STYP_TEXT) | 709 | 6.97k | { | 710 | 6.97k | if (sec_flags & SEC_NEVER_LOAD) | 711 | 2.70k | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 712 | 4.26k | else | 713 | 4.26k | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 714 | 6.97k | } | 715 | 13.6k | else if (styp_flags & STYP_DATA) | 716 | 1.87k | { | 717 | 1.87k | if (sec_flags & SEC_NEVER_LOAD) | 718 | 1.04k | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; | 719 | 830 | else | 720 | 830 | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; | 721 | 1.87k | } | 722 | 11.7k | else if (styp_flags & STYP_BSS) | 723 | 852 | { | 724 | | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY | 725 | | if (sec_flags & SEC_NEVER_LOAD) | 726 | | sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY; | 727 | | else | 728 | | #endif | 729 | 852 | sec_flags |= SEC_ALLOC; | 730 | 852 | } | 731 | 10.9k | else if (styp_flags & STYP_INFO) | 732 | 1.15k | { | 733 | | /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is | 734 | | defined. coff_compute_section_file_positions uses | 735 | | COFF_PAGE_SIZE to ensure that the low order bits of the | 736 | | section VMA and the file offset match. If we don't know | 737 | | COFF_PAGE_SIZE, we can't ensure the correct correspondence, | 738 | | and demand page loading of the file will fail. */ | 739 | | #if defined (COFF_PAGE_SIZE) && !defined (COFF_ALIGN_IN_S_FLAGS) | 740 | | sec_flags |= SEC_DEBUGGING; | 741 | | #endif | 742 | 1.15k | } | 743 | 9.74k | else if (styp_flags & STYP_PAD) | 744 | 796 | sec_flags = 0; | 745 | | #ifdef RS6000COFF_C | 746 | | else if (styp_flags & STYP_TDATA) | 747 | | { | 748 | | if (sec_flags & SEC_NEVER_LOAD) | 749 | | sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY; | 750 | | else | 751 | | sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_LOAD | SEC_ALLOC; | 752 | | } | 753 | | else if (styp_flags & STYP_TBSS) | 754 | | { | 755 | | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY | 756 | | if (sec_flags & SEC_NEVER_LOAD) | 757 | | sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY; | 758 | | else | 759 | | #endif | 760 | | sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL; | 761 | | } | 762 | | else if (styp_flags & STYP_EXCEPT) | 763 | | sec_flags |= SEC_LOAD; | 764 | | else if (styp_flags & STYP_LOADER) | 765 | | sec_flags |= SEC_LOAD; | 766 | | else if (styp_flags & STYP_TYPCHK) | 767 | | sec_flags |= SEC_LOAD; | 768 | | else if (styp_flags & STYP_DWARF) | 769 | | sec_flags |= SEC_DEBUGGING; | 770 | | #endif | 771 | 8.94k | else if (strcmp (name, _TEXT) == 0) | 772 | 6 | { | 773 | 6 | if (sec_flags & SEC_NEVER_LOAD) | 774 | 0 | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 775 | 6 | else | 776 | 6 | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 777 | 6 | } | 778 | 8.94k | else if (strcmp (name, _DATA) == 0) | 779 | 8 | { | 780 | 8 | if (sec_flags & SEC_NEVER_LOAD) | 781 | 2 | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; | 782 | 6 | else | 783 | 6 | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; | 784 | 8 | } | 785 | 8.93k | else if (strcmp (name, _BSS) == 0) | 786 | 20 | { | 787 | | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY | 788 | | if (sec_flags & SEC_NEVER_LOAD) | 789 | | sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY; | 790 | | else | 791 | | #endif | 792 | 20 | sec_flags |= SEC_ALLOC; | 793 | 20 | } | 794 | 8.91k | else if (startswith (name, DOT_DEBUG) | 795 | 8.91k | || startswith (name, DOT_ZDEBUG) | 796 | 8.91k | #ifdef _COMMENT | 797 | 8.91k | || strcmp (name, _COMMENT) == 0 | 798 | 8.91k | #endif | 799 | | #ifdef COFF_LONG_SECTION_NAMES | 800 | | || startswith (name, GNU_LINKONCE_WI) | 801 | | || startswith (name, GNU_LINKONCE_WT) | 802 | | #endif | 803 | 8.91k | || startswith (name, ".stab")) | 804 | 54 | { | 805 | | #ifdef COFF_PAGE_SIZE | 806 | | sec_flags |= SEC_DEBUGGING; | 807 | | #endif | 808 | 54 | } | 809 | 8.85k | #ifdef _LIB | 810 | 8.85k | else if (strcmp (name, _LIB) == 0) | 811 | 2 | ; | 812 | 8.85k | #endif | 813 | | #ifdef _LIT | 814 | | else if (strcmp (name, _LIT) == 0) | 815 | | sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY; | 816 | | #endif | 817 | 8.85k | else | 818 | 8.85k | sec_flags |= SEC_ALLOC | SEC_LOAD; | 819 | | | 820 | 20.6k | #ifdef STYP_LIT /* A29k readonly text/data section type. */ | 821 | 20.6k | if ((styp_flags & STYP_LIT) == STYP_LIT) | 822 | 1.86k | sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY); | 823 | 20.6k | #endif /* STYP_LIT */ | 824 | | | 825 | | #ifdef STYP_OTHER_LOAD /* Other loaded sections. */ | 826 | | if (styp_flags & STYP_OTHER_LOAD) | 827 | | sec_flags = (SEC_LOAD | SEC_ALLOC); | 828 | | #endif /* STYP_SDATA */ | 829 | | | 830 | 20.6k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 831 | 20.6k | && (startswith (name, ".sbss") | 832 | 0 | || startswith (name, ".sdata"))) | 833 | 0 | sec_flags |= SEC_SMALL_DATA; | 834 | | | 835 | | #if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE) | 836 | | /* As a GNU extension, if the name begins with .gnu.linkonce, we | 837 | | only link a single copy of the section. This is used to support | 838 | | g++. g++ will emit each template expansion in its own section. | 839 | | The symbols will be defined as weak, so that multiple definitions | 840 | | are permitted. The GNU linker extension is to actually discard | 841 | | all but one of the sections. */ | 842 | | if (startswith (name, ".gnu.linkonce")) | 843 | | sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; | 844 | | #endif | 845 | | | 846 | 20.6k | if (flags_ptr == NULL) | 847 | 0 | return false; | 848 | | | 849 | 20.6k | * flags_ptr = sec_flags; | 850 | 20.6k | return true; | 851 | 20.6k | } |
coff-stgo32.c:styp_to_sec_flags Line | Count | Source | 686 | 13.6k | { | 687 | 13.6k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 688 | 13.6k | unsigned long styp_flags = internal_s->s_flags; | 689 | 13.6k | flagword sec_flags = 0; | 690 | | | 691 | | #ifdef STYP_BLOCK | 692 | | if (styp_flags & STYP_BLOCK) | 693 | | sec_flags |= SEC_TIC54X_BLOCK; | 694 | | #endif | 695 | | | 696 | | #ifdef STYP_CLINK | 697 | | if (styp_flags & STYP_CLINK) | 698 | | sec_flags |= SEC_TIC54X_CLINK; | 699 | | #endif | 700 | | | 701 | 13.6k | #ifdef STYP_NOLOAD | 702 | 13.6k | if (styp_flags & STYP_NOLOAD) | 703 | 4.61k | sec_flags |= SEC_NEVER_LOAD; | 704 | 13.6k | #endif /* STYP_NOLOAD */ | 705 | | | 706 | | /* For 386 COFF, at least, an unloadable text or data section is | 707 | | actually a shared library section. */ | 708 | 13.6k | if (styp_flags & STYP_TEXT) | 709 | 2.79k | { | 710 | 2.79k | if (sec_flags & SEC_NEVER_LOAD) | 711 | 1.16k | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 712 | 1.63k | else | 713 | 1.63k | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 714 | 2.79k | } | 715 | 10.9k | else if (styp_flags & STYP_DATA) | 716 | 1.10k | { | 717 | 1.10k | if (sec_flags & SEC_NEVER_LOAD) | 718 | 663 | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; | 719 | 442 | else | 720 | 442 | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; | 721 | 1.10k | } | 722 | 9.79k | else if (styp_flags & STYP_BSS) | 723 | 2.35k | { | 724 | 2.35k | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY | 725 | 2.35k | if (sec_flags & SEC_NEVER_LOAD) | 726 | 1.83k | sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY; | 727 | 520 | else | 728 | 520 | #endif | 729 | 520 | sec_flags |= SEC_ALLOC; | 730 | 2.35k | } | 731 | 7.44k | else if (styp_flags & STYP_INFO) | 732 | 1.08k | { | 733 | | /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is | 734 | | defined. coff_compute_section_file_positions uses | 735 | | COFF_PAGE_SIZE to ensure that the low order bits of the | 736 | | section VMA and the file offset match. If we don't know | 737 | | COFF_PAGE_SIZE, we can't ensure the correct correspondence, | 738 | | and demand page loading of the file will fail. */ | 739 | 1.08k | #if defined (COFF_PAGE_SIZE) && !defined (COFF_ALIGN_IN_S_FLAGS) | 740 | 1.08k | sec_flags |= SEC_DEBUGGING; | 741 | 1.08k | #endif | 742 | 1.08k | } | 743 | 6.35k | else if (styp_flags & STYP_PAD) | 744 | 223 | sec_flags = 0; | 745 | | #ifdef RS6000COFF_C | 746 | | else if (styp_flags & STYP_TDATA) | 747 | | { | 748 | | if (sec_flags & SEC_NEVER_LOAD) | 749 | | sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY; | 750 | | else | 751 | | sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_LOAD | SEC_ALLOC; | 752 | | } | 753 | | else if (styp_flags & STYP_TBSS) | 754 | | { | 755 | | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY | 756 | | if (sec_flags & SEC_NEVER_LOAD) | 757 | | sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY; | 758 | | else | 759 | | #endif | 760 | | sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL; | 761 | | } | 762 | | else if (styp_flags & STYP_EXCEPT) | 763 | | sec_flags |= SEC_LOAD; | 764 | | else if (styp_flags & STYP_LOADER) | 765 | | sec_flags |= SEC_LOAD; | 766 | | else if (styp_flags & STYP_TYPCHK) | 767 | | sec_flags |= SEC_LOAD; | 768 | | else if (styp_flags & STYP_DWARF) | 769 | | sec_flags |= SEC_DEBUGGING; | 770 | | #endif | 771 | 6.13k | else if (strcmp (name, _TEXT) == 0) | 772 | 2 | { | 773 | 2 | if (sec_flags & SEC_NEVER_LOAD) | 774 | 1 | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 775 | 1 | else | 776 | 1 | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 777 | 2 | } | 778 | 6.13k | else if (strcmp (name, _DATA) == 0) | 779 | 19 | { | 780 | 19 | if (sec_flags & SEC_NEVER_LOAD) | 781 | 4 | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; | 782 | 15 | else | 783 | 15 | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; | 784 | 19 | } | 785 | 6.11k | else if (strcmp (name, _BSS) == 0) | 786 | 19 | { | 787 | 19 | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY | 788 | 19 | if (sec_flags & SEC_NEVER_LOAD) | 789 | 4 | sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY; | 790 | 15 | else | 791 | 15 | #endif | 792 | 15 | sec_flags |= SEC_ALLOC; | 793 | 19 | } | 794 | 6.09k | else if (startswith (name, DOT_DEBUG) | 795 | 6.09k | || startswith (name, DOT_ZDEBUG) | 796 | 6.09k | #ifdef _COMMENT | 797 | 6.09k | || strcmp (name, _COMMENT) == 0 | 798 | 6.09k | #endif | 799 | 6.09k | #ifdef COFF_LONG_SECTION_NAMES | 800 | 6.09k | || startswith (name, GNU_LINKONCE_WI) | 801 | 6.09k | || startswith (name, GNU_LINKONCE_WT) | 802 | 6.09k | #endif | 803 | 6.09k | || startswith (name, ".stab")) | 804 | 32 | { | 805 | 32 | #ifdef COFF_PAGE_SIZE | 806 | 32 | sec_flags |= SEC_DEBUGGING; | 807 | 32 | #endif | 808 | 32 | } | 809 | 6.06k | #ifdef _LIB | 810 | 6.06k | else if (strcmp (name, _LIB) == 0) | 811 | 1 | ; | 812 | 6.06k | #endif | 813 | | #ifdef _LIT | 814 | | else if (strcmp (name, _LIT) == 0) | 815 | | sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY; | 816 | | #endif | 817 | 6.06k | else | 818 | 6.06k | sec_flags |= SEC_ALLOC | SEC_LOAD; | 819 | | | 820 | 13.6k | #ifdef STYP_LIT /* A29k readonly text/data section type. */ | 821 | 13.6k | if ((styp_flags & STYP_LIT) == STYP_LIT) | 822 | 993 | sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY); | 823 | 13.6k | #endif /* STYP_LIT */ | 824 | | | 825 | | #ifdef STYP_OTHER_LOAD /* Other loaded sections. */ | 826 | | if (styp_flags & STYP_OTHER_LOAD) | 827 | | sec_flags = (SEC_LOAD | SEC_ALLOC); | 828 | | #endif /* STYP_SDATA */ | 829 | | | 830 | 13.6k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 831 | 13.6k | && (startswith (name, ".sbss") | 832 | 0 | || startswith (name, ".sdata"))) | 833 | 0 | sec_flags |= SEC_SMALL_DATA; | 834 | | | 835 | 13.6k | #if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE) | 836 | | /* As a GNU extension, if the name begins with .gnu.linkonce, we | 837 | | only link a single copy of the section. This is used to support | 838 | | g++. g++ will emit each template expansion in its own section. | 839 | | The symbols will be defined as weak, so that multiple definitions | 840 | | are permitted. The GNU linker extension is to actually discard | 841 | | all but one of the sections. */ | 842 | 13.6k | if (startswith (name, ".gnu.linkonce")) | 843 | 0 | sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; | 844 | 13.6k | #endif | 845 | | | 846 | 13.6k | if (flags_ptr == NULL) | 847 | 0 | return false; | 848 | | | 849 | 13.6k | * flags_ptr = sec_flags; | 850 | 13.6k | return true; | 851 | 13.6k | } |
coff-tic30.c:styp_to_sec_flags Line | Count | Source | 686 | 37.6k | { | 687 | 37.6k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 688 | 37.6k | unsigned long styp_flags = internal_s->s_flags; | 689 | 37.6k | flagword sec_flags = 0; | 690 | | | 691 | | #ifdef STYP_BLOCK | 692 | | if (styp_flags & STYP_BLOCK) | 693 | | sec_flags |= SEC_TIC54X_BLOCK; | 694 | | #endif | 695 | | | 696 | | #ifdef STYP_CLINK | 697 | | if (styp_flags & STYP_CLINK) | 698 | | sec_flags |= SEC_TIC54X_CLINK; | 699 | | #endif | 700 | | | 701 | 37.6k | #ifdef STYP_NOLOAD | 702 | 37.6k | if (styp_flags & STYP_NOLOAD) | 703 | 8.96k | sec_flags |= SEC_NEVER_LOAD; | 704 | 37.6k | #endif /* STYP_NOLOAD */ | 705 | | | 706 | | /* For 386 COFF, at least, an unloadable text or data section is | 707 | | actually a shared library section. */ | 708 | 37.6k | if (styp_flags & STYP_TEXT) | 709 | 9.43k | { | 710 | 9.43k | if (sec_flags & SEC_NEVER_LOAD) | 711 | 4.25k | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 712 | 5.18k | else | 713 | 5.18k | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 714 | 9.43k | } | 715 | 28.2k | else if (styp_flags & STYP_DATA) | 716 | 2.76k | { | 717 | 2.76k | if (sec_flags & SEC_NEVER_LOAD) | 718 | 1.53k | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; | 719 | 1.23k | else | 720 | 1.23k | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; | 721 | 2.76k | } | 722 | 25.4k | else if (styp_flags & STYP_BSS) | 723 | 1.25k | { | 724 | | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY | 725 | | if (sec_flags & SEC_NEVER_LOAD) | 726 | | sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY; | 727 | | else | 728 | | #endif | 729 | 1.25k | sec_flags |= SEC_ALLOC; | 730 | 1.25k | } | 731 | 24.1k | else if (styp_flags & STYP_INFO) | 732 | 3.26k | { | 733 | | /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is | 734 | | defined. coff_compute_section_file_positions uses | 735 | | COFF_PAGE_SIZE to ensure that the low order bits of the | 736 | | section VMA and the file offset match. If we don't know | 737 | | COFF_PAGE_SIZE, we can't ensure the correct correspondence, | 738 | | and demand page loading of the file will fail. */ | 739 | | #if defined (COFF_PAGE_SIZE) && !defined (COFF_ALIGN_IN_S_FLAGS) | 740 | | sec_flags |= SEC_DEBUGGING; | 741 | | #endif | 742 | 3.26k | } | 743 | 20.9k | else if (styp_flags & STYP_PAD) | 744 | 2.87k | sec_flags = 0; | 745 | | #ifdef RS6000COFF_C | 746 | | else if (styp_flags & STYP_TDATA) | 747 | | { | 748 | | if (sec_flags & SEC_NEVER_LOAD) | 749 | | sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY; | 750 | | else | 751 | | sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_LOAD | SEC_ALLOC; | 752 | | } | 753 | | else if (styp_flags & STYP_TBSS) | 754 | | { | 755 | | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY | 756 | | if (sec_flags & SEC_NEVER_LOAD) | 757 | | sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY; | 758 | | else | 759 | | #endif | 760 | | sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL; | 761 | | } | 762 | | else if (styp_flags & STYP_EXCEPT) | 763 | | sec_flags |= SEC_LOAD; | 764 | | else if (styp_flags & STYP_LOADER) | 765 | | sec_flags |= SEC_LOAD; | 766 | | else if (styp_flags & STYP_TYPCHK) | 767 | | sec_flags |= SEC_LOAD; | 768 | | else if (styp_flags & STYP_DWARF) | 769 | | sec_flags |= SEC_DEBUGGING; | 770 | | #endif | 771 | 18.0k | else if (strcmp (name, _TEXT) == 0) | 772 | 7 | { | 773 | 7 | if (sec_flags & SEC_NEVER_LOAD) | 774 | 1 | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 775 | 6 | else | 776 | 6 | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 777 | 7 | } | 778 | 18.0k | else if (strcmp (name, _DATA) == 0) | 779 | 7 | { | 780 | 7 | if (sec_flags & SEC_NEVER_LOAD) | 781 | 1 | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; | 782 | 6 | else | 783 | 6 | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; | 784 | 7 | } | 785 | 18.0k | else if (strcmp (name, _BSS) == 0) | 786 | 19 | { | 787 | | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY | 788 | | if (sec_flags & SEC_NEVER_LOAD) | 789 | | sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY; | 790 | | else | 791 | | #endif | 792 | 19 | sec_flags |= SEC_ALLOC; | 793 | 19 | } | 794 | 18.0k | else if (startswith (name, DOT_DEBUG) | 795 | 18.0k | || startswith (name, DOT_ZDEBUG) | 796 | 18.0k | #ifdef _COMMENT | 797 | 18.0k | || strcmp (name, _COMMENT) == 0 | 798 | 18.0k | #endif | 799 | | #ifdef COFF_LONG_SECTION_NAMES | 800 | | || startswith (name, GNU_LINKONCE_WI) | 801 | | || startswith (name, GNU_LINKONCE_WT) | 802 | | #endif | 803 | 18.0k | || startswith (name, ".stab")) | 804 | 26 | { | 805 | | #ifdef COFF_PAGE_SIZE | 806 | | sec_flags |= SEC_DEBUGGING; | 807 | | #endif | 808 | 26 | } | 809 | 17.9k | #ifdef _LIB | 810 | 17.9k | else if (strcmp (name, _LIB) == 0) | 811 | 0 | ; | 812 | 17.9k | #endif | 813 | | #ifdef _LIT | 814 | | else if (strcmp (name, _LIT) == 0) | 815 | | sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY; | 816 | | #endif | 817 | 17.9k | else | 818 | 17.9k | sec_flags |= SEC_ALLOC | SEC_LOAD; | 819 | | | 820 | 37.6k | #ifdef STYP_LIT /* A29k readonly text/data section type. */ | 821 | 37.6k | if ((styp_flags & STYP_LIT) == STYP_LIT) | 822 | 2.50k | sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY); | 823 | 37.6k | #endif /* STYP_LIT */ | 824 | | | 825 | | #ifdef STYP_OTHER_LOAD /* Other loaded sections. */ | 826 | | if (styp_flags & STYP_OTHER_LOAD) | 827 | | sec_flags = (SEC_LOAD | SEC_ALLOC); | 828 | | #endif /* STYP_SDATA */ | 829 | | | 830 | 37.6k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 831 | 37.6k | && (startswith (name, ".sbss") | 832 | 0 | || startswith (name, ".sdata"))) | 833 | 0 | sec_flags |= SEC_SMALL_DATA; | 834 | | | 835 | | #if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE) | 836 | | /* As a GNU extension, if the name begins with .gnu.linkonce, we | 837 | | only link a single copy of the section. This is used to support | 838 | | g++. g++ will emit each template expansion in its own section. | 839 | | The symbols will be defined as weak, so that multiple definitions | 840 | | are permitted. The GNU linker extension is to actually discard | 841 | | all but one of the sections. */ | 842 | | if (startswith (name, ".gnu.linkonce")) | 843 | | sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; | 844 | | #endif | 845 | | | 846 | 37.6k | if (flags_ptr == NULL) | 847 | 0 | return false; | 848 | | | 849 | 37.6k | * flags_ptr = sec_flags; | 850 | 37.6k | return true; | 851 | 37.6k | } |
Unexecuted instantiation: coff-tic4x.c:styp_to_sec_flags coff-tic54x.c:styp_to_sec_flags Line | Count | Source | 686 | 55.7k | { | 687 | 55.7k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 688 | 55.7k | unsigned long styp_flags = internal_s->s_flags; | 689 | 55.7k | flagword sec_flags = 0; | 690 | | | 691 | 55.7k | #ifdef STYP_BLOCK | 692 | 55.7k | if (styp_flags & STYP_BLOCK) | 693 | 7.86k | sec_flags |= SEC_TIC54X_BLOCK; | 694 | 55.7k | #endif | 695 | | | 696 | 55.7k | #ifdef STYP_CLINK | 697 | 55.7k | if (styp_flags & STYP_CLINK) | 698 | 8.55k | sec_flags |= SEC_TIC54X_CLINK; | 699 | 55.7k | #endif | 700 | | | 701 | 55.7k | #ifdef STYP_NOLOAD | 702 | 55.7k | if (styp_flags & STYP_NOLOAD) | 703 | 10.8k | sec_flags |= SEC_NEVER_LOAD; | 704 | 55.7k | #endif /* STYP_NOLOAD */ | 705 | | | 706 | | /* For 386 COFF, at least, an unloadable text or data section is | 707 | | actually a shared library section. */ | 708 | 55.7k | if (styp_flags & STYP_TEXT) | 709 | 11.4k | { | 710 | 11.4k | if (sec_flags & SEC_NEVER_LOAD) | 711 | 4.78k | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 712 | 6.63k | else | 713 | 6.63k | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 714 | 11.4k | } | 715 | 44.3k | else if (styp_flags & STYP_DATA) | 716 | 2.20k | { | 717 | 2.20k | if (sec_flags & SEC_NEVER_LOAD) | 718 | 1.03k | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; | 719 | 1.17k | else | 720 | 1.17k | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; | 721 | 2.20k | } | 722 | 42.1k | else if (styp_flags & STYP_BSS) | 723 | 1.31k | { | 724 | | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY | 725 | | if (sec_flags & SEC_NEVER_LOAD) | 726 | | sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY; | 727 | | else | 728 | | #endif | 729 | 1.31k | sec_flags |= SEC_ALLOC; | 730 | 1.31k | } | 731 | 40.8k | else if (styp_flags & STYP_INFO) | 732 | 5.42k | { | 733 | | /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is | 734 | | defined. coff_compute_section_file_positions uses | 735 | | COFF_PAGE_SIZE to ensure that the low order bits of the | 736 | | section VMA and the file offset match. If we don't know | 737 | | COFF_PAGE_SIZE, we can't ensure the correct correspondence, | 738 | | and demand page loading of the file will fail. */ | 739 | | #if defined (COFF_PAGE_SIZE) && !defined (COFF_ALIGN_IN_S_FLAGS) | 740 | | sec_flags |= SEC_DEBUGGING; | 741 | | #endif | 742 | 5.42k | } | 743 | 35.4k | else if (styp_flags & STYP_PAD) | 744 | 2.10k | sec_flags = 0; | 745 | | #ifdef RS6000COFF_C | 746 | | else if (styp_flags & STYP_TDATA) | 747 | | { | 748 | | if (sec_flags & SEC_NEVER_LOAD) | 749 | | sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY; | 750 | | else | 751 | | sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_LOAD | SEC_ALLOC; | 752 | | } | 753 | | else if (styp_flags & STYP_TBSS) | 754 | | { | 755 | | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY | 756 | | if (sec_flags & SEC_NEVER_LOAD) | 757 | | sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY; | 758 | | else | 759 | | #endif | 760 | | sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL; | 761 | | } | 762 | | else if (styp_flags & STYP_EXCEPT) | 763 | | sec_flags |= SEC_LOAD; | 764 | | else if (styp_flags & STYP_LOADER) | 765 | | sec_flags |= SEC_LOAD; | 766 | | else if (styp_flags & STYP_TYPCHK) | 767 | | sec_flags |= SEC_LOAD; | 768 | | else if (styp_flags & STYP_DWARF) | 769 | | sec_flags |= SEC_DEBUGGING; | 770 | | #endif | 771 | 33.3k | else if (strcmp (name, _TEXT) == 0) | 772 | 4 | { | 773 | 4 | if (sec_flags & SEC_NEVER_LOAD) | 774 | 1 | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 775 | 3 | else | 776 | 3 | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 777 | 4 | } | 778 | 33.3k | else if (strcmp (name, _DATA) == 0) | 779 | 9 | { | 780 | 9 | if (sec_flags & SEC_NEVER_LOAD) | 781 | 6 | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; | 782 | 3 | else | 783 | 3 | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; | 784 | 9 | } | 785 | 33.3k | else if (strcmp (name, _BSS) == 0) | 786 | 3 | { | 787 | | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY | 788 | | if (sec_flags & SEC_NEVER_LOAD) | 789 | | sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY; | 790 | | else | 791 | | #endif | 792 | 3 | sec_flags |= SEC_ALLOC; | 793 | 3 | } | 794 | 33.3k | else if (startswith (name, DOT_DEBUG) | 795 | 33.3k | || startswith (name, DOT_ZDEBUG) | 796 | | #ifdef _COMMENT | 797 | | || strcmp (name, _COMMENT) == 0 | 798 | | #endif | 799 | | #ifdef COFF_LONG_SECTION_NAMES | 800 | | || startswith (name, GNU_LINKONCE_WI) | 801 | | || startswith (name, GNU_LINKONCE_WT) | 802 | | #endif | 803 | 33.3k | || startswith (name, ".stab")) | 804 | 17 | { | 805 | | #ifdef COFF_PAGE_SIZE | 806 | | sec_flags |= SEC_DEBUGGING; | 807 | | #endif | 808 | 17 | } | 809 | | #ifdef _LIB | 810 | | else if (strcmp (name, _LIB) == 0) | 811 | | ; | 812 | | #endif | 813 | | #ifdef _LIT | 814 | | else if (strcmp (name, _LIT) == 0) | 815 | | sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY; | 816 | | #endif | 817 | 33.2k | else | 818 | 33.2k | sec_flags |= SEC_ALLOC | SEC_LOAD; | 819 | | | 820 | 55.7k | #ifdef STYP_LIT /* A29k readonly text/data section type. */ | 821 | 55.7k | if ((styp_flags & STYP_LIT) == STYP_LIT) | 822 | 2.89k | sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY); | 823 | 55.7k | #endif /* STYP_LIT */ | 824 | | | 825 | | #ifdef STYP_OTHER_LOAD /* Other loaded sections. */ | 826 | | if (styp_flags & STYP_OTHER_LOAD) | 827 | | sec_flags = (SEC_LOAD | SEC_ALLOC); | 828 | | #endif /* STYP_SDATA */ | 829 | | | 830 | 55.7k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 831 | 55.7k | && (startswith (name, ".sbss") | 832 | 0 | || startswith (name, ".sdata"))) | 833 | 0 | sec_flags |= SEC_SMALL_DATA; | 834 | | | 835 | | #if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE) | 836 | | /* As a GNU extension, if the name begins with .gnu.linkonce, we | 837 | | only link a single copy of the section. This is used to support | 838 | | g++. g++ will emit each template expansion in its own section. | 839 | | The symbols will be defined as weak, so that multiple definitions | 840 | | are permitted. The GNU linker extension is to actually discard | 841 | | all but one of the sections. */ | 842 | | if (startswith (name, ".gnu.linkonce")) | 843 | | sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; | 844 | | #endif | 845 | | | 846 | 55.7k | if (flags_ptr == NULL) | 847 | 0 | return false; | 848 | | | 849 | 55.7k | * flags_ptr = sec_flags; | 850 | 55.7k | return true; | 851 | 55.7k | } |
coff-z80.c:styp_to_sec_flags Line | Count | Source | 686 | 43.4k | { | 687 | 43.4k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 688 | 43.4k | unsigned long styp_flags = internal_s->s_flags; | 689 | 43.4k | flagword sec_flags = 0; | 690 | | | 691 | | #ifdef STYP_BLOCK | 692 | | if (styp_flags & STYP_BLOCK) | 693 | | sec_flags |= SEC_TIC54X_BLOCK; | 694 | | #endif | 695 | | | 696 | | #ifdef STYP_CLINK | 697 | | if (styp_flags & STYP_CLINK) | 698 | | sec_flags |= SEC_TIC54X_CLINK; | 699 | | #endif | 700 | | | 701 | 43.4k | #ifdef STYP_NOLOAD | 702 | 43.4k | if (styp_flags & STYP_NOLOAD) | 703 | 12.4k | sec_flags |= SEC_NEVER_LOAD; | 704 | 43.4k | #endif /* STYP_NOLOAD */ | 705 | | | 706 | | /* For 386 COFF, at least, an unloadable text or data section is | 707 | | actually a shared library section. */ | 708 | 43.4k | if (styp_flags & STYP_TEXT) | 709 | 9.69k | { | 710 | 9.69k | if (sec_flags & SEC_NEVER_LOAD) | 711 | 6.23k | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 712 | 3.46k | else | 713 | 3.46k | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 714 | 9.69k | } | 715 | 33.7k | else if (styp_flags & STYP_DATA) | 716 | 2.11k | { | 717 | 2.11k | if (sec_flags & SEC_NEVER_LOAD) | 718 | 976 | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; | 719 | 1.13k | else | 720 | 1.13k | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; | 721 | 2.11k | } | 722 | 31.6k | else if (styp_flags & STYP_BSS) | 723 | 1.86k | { | 724 | | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY | 725 | | if (sec_flags & SEC_NEVER_LOAD) | 726 | | sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY; | 727 | | else | 728 | | #endif | 729 | 1.86k | sec_flags |= SEC_ALLOC; | 730 | 1.86k | } | 731 | 29.7k | else if (styp_flags & STYP_INFO) | 732 | 5.38k | { | 733 | | /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is | 734 | | defined. coff_compute_section_file_positions uses | 735 | | COFF_PAGE_SIZE to ensure that the low order bits of the | 736 | | section VMA and the file offset match. If we don't know | 737 | | COFF_PAGE_SIZE, we can't ensure the correct correspondence, | 738 | | and demand page loading of the file will fail. */ | 739 | | #if defined (COFF_PAGE_SIZE) && !defined (COFF_ALIGN_IN_S_FLAGS) | 740 | | sec_flags |= SEC_DEBUGGING; | 741 | | #endif | 742 | 5.38k | } | 743 | 24.4k | else if (styp_flags & STYP_PAD) | 744 | 2.56k | sec_flags = 0; | 745 | | #ifdef RS6000COFF_C | 746 | | else if (styp_flags & STYP_TDATA) | 747 | | { | 748 | | if (sec_flags & SEC_NEVER_LOAD) | 749 | | sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY; | 750 | | else | 751 | | sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_LOAD | SEC_ALLOC; | 752 | | } | 753 | | else if (styp_flags & STYP_TBSS) | 754 | | { | 755 | | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY | 756 | | if (sec_flags & SEC_NEVER_LOAD) | 757 | | sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY; | 758 | | else | 759 | | #endif | 760 | | sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL; | 761 | | } | 762 | | else if (styp_flags & STYP_EXCEPT) | 763 | | sec_flags |= SEC_LOAD; | 764 | | else if (styp_flags & STYP_LOADER) | 765 | | sec_flags |= SEC_LOAD; | 766 | | else if (styp_flags & STYP_TYPCHK) | 767 | | sec_flags |= SEC_LOAD; | 768 | | else if (styp_flags & STYP_DWARF) | 769 | | sec_flags |= SEC_DEBUGGING; | 770 | | #endif | 771 | 21.8k | else if (strcmp (name, _TEXT) == 0) | 772 | 9 | { | 773 | 9 | if (sec_flags & SEC_NEVER_LOAD) | 774 | 1 | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 775 | 8 | else | 776 | 8 | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 777 | 9 | } | 778 | 21.8k | else if (strcmp (name, _DATA) == 0) | 779 | 19 | { | 780 | 19 | if (sec_flags & SEC_NEVER_LOAD) | 781 | 1 | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; | 782 | 18 | else | 783 | 18 | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; | 784 | 19 | } | 785 | 21.8k | else if (strcmp (name, _BSS) == 0) | 786 | 6 | { | 787 | | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY | 788 | | if (sec_flags & SEC_NEVER_LOAD) | 789 | | sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY; | 790 | | else | 791 | | #endif | 792 | 6 | sec_flags |= SEC_ALLOC; | 793 | 6 | } | 794 | 21.8k | else if (startswith (name, DOT_DEBUG) | 795 | 21.8k | || startswith (name, DOT_ZDEBUG) | 796 | 21.8k | #ifdef _COMMENT | 797 | 21.8k | || strcmp (name, _COMMENT) == 0 | 798 | 21.8k | #endif | 799 | | #ifdef COFF_LONG_SECTION_NAMES | 800 | | || startswith (name, GNU_LINKONCE_WI) | 801 | | || startswith (name, GNU_LINKONCE_WT) | 802 | | #endif | 803 | 21.8k | || startswith (name, ".stab")) | 804 | 29 | { | 805 | | #ifdef COFF_PAGE_SIZE | 806 | | sec_flags |= SEC_DEBUGGING; | 807 | | #endif | 808 | 29 | } | 809 | 21.7k | #ifdef _LIB | 810 | 21.7k | else if (strcmp (name, _LIB) == 0) | 811 | 1 | ; | 812 | 21.7k | #endif | 813 | | #ifdef _LIT | 814 | | else if (strcmp (name, _LIT) == 0) | 815 | | sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY; | 816 | | #endif | 817 | 21.7k | else | 818 | 21.7k | sec_flags |= SEC_ALLOC | SEC_LOAD; | 819 | | | 820 | 43.4k | #ifdef STYP_LIT /* A29k readonly text/data section type. */ | 821 | 43.4k | if ((styp_flags & STYP_LIT) == STYP_LIT) | 822 | 2.39k | sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY); | 823 | 43.4k | #endif /* STYP_LIT */ | 824 | | | 825 | | #ifdef STYP_OTHER_LOAD /* Other loaded sections. */ | 826 | | if (styp_flags & STYP_OTHER_LOAD) | 827 | | sec_flags = (SEC_LOAD | SEC_ALLOC); | 828 | | #endif /* STYP_SDATA */ | 829 | | | 830 | 43.4k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 831 | 43.4k | && (startswith (name, ".sbss") | 832 | 0 | || startswith (name, ".sdata"))) | 833 | 0 | sec_flags |= SEC_SMALL_DATA; | 834 | | | 835 | | #if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE) | 836 | | /* As a GNU extension, if the name begins with .gnu.linkonce, we | 837 | | only link a single copy of the section. This is used to support | 838 | | g++. g++ will emit each template expansion in its own section. | 839 | | The symbols will be defined as weak, so that multiple definitions | 840 | | are permitted. The GNU linker extension is to actually discard | 841 | | all but one of the sections. */ | 842 | | if (startswith (name, ".gnu.linkonce")) | 843 | | sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; | 844 | | #endif | 845 | | | 846 | 43.4k | if (flags_ptr == NULL) | 847 | 0 | return false; | 848 | | | 849 | 43.4k | * flags_ptr = sec_flags; | 850 | 43.4k | return true; | 851 | 43.4k | } |
coff-z8k.c:styp_to_sec_flags Line | Count | Source | 686 | 59.7k | { | 687 | 59.7k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 688 | 59.7k | unsigned long styp_flags = internal_s->s_flags; | 689 | 59.7k | flagword sec_flags = 0; | 690 | | | 691 | | #ifdef STYP_BLOCK | 692 | | if (styp_flags & STYP_BLOCK) | 693 | | sec_flags |= SEC_TIC54X_BLOCK; | 694 | | #endif | 695 | | | 696 | | #ifdef STYP_CLINK | 697 | | if (styp_flags & STYP_CLINK) | 698 | | sec_flags |= SEC_TIC54X_CLINK; | 699 | | #endif | 700 | | | 701 | 59.7k | #ifdef STYP_NOLOAD | 702 | 59.7k | if (styp_flags & STYP_NOLOAD) | 703 | 11.2k | sec_flags |= SEC_NEVER_LOAD; | 704 | 59.7k | #endif /* STYP_NOLOAD */ | 705 | | | 706 | | /* For 386 COFF, at least, an unloadable text or data section is | 707 | | actually a shared library section. */ | 708 | 59.7k | if (styp_flags & STYP_TEXT) | 709 | 11.4k | { | 710 | 11.4k | if (sec_flags & SEC_NEVER_LOAD) | 711 | 5.64k | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 712 | 5.77k | else | 713 | 5.77k | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 714 | 11.4k | } | 715 | 48.3k | else if (styp_flags & STYP_DATA) | 716 | 2.88k | { | 717 | 2.88k | if (sec_flags & SEC_NEVER_LOAD) | 718 | 1.09k | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; | 719 | 1.78k | else | 720 | 1.78k | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; | 721 | 2.88k | } | 722 | 45.4k | else if (styp_flags & STYP_BSS) | 723 | 1.65k | { | 724 | | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY | 725 | | if (sec_flags & SEC_NEVER_LOAD) | 726 | | sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY; | 727 | | else | 728 | | #endif | 729 | 1.65k | sec_flags |= SEC_ALLOC; | 730 | 1.65k | } | 731 | 43.7k | else if (styp_flags & STYP_INFO) | 732 | 4.90k | { | 733 | | /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is | 734 | | defined. coff_compute_section_file_positions uses | 735 | | COFF_PAGE_SIZE to ensure that the low order bits of the | 736 | | section VMA and the file offset match. If we don't know | 737 | | COFF_PAGE_SIZE, we can't ensure the correct correspondence, | 738 | | and demand page loading of the file will fail. */ | 739 | | #if defined (COFF_PAGE_SIZE) && !defined (COFF_ALIGN_IN_S_FLAGS) | 740 | | sec_flags |= SEC_DEBUGGING; | 741 | | #endif | 742 | 4.90k | } | 743 | 38.8k | else if (styp_flags & STYP_PAD) | 744 | 2.56k | sec_flags = 0; | 745 | | #ifdef RS6000COFF_C | 746 | | else if (styp_flags & STYP_TDATA) | 747 | | { | 748 | | if (sec_flags & SEC_NEVER_LOAD) | 749 | | sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY; | 750 | | else | 751 | | sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_LOAD | SEC_ALLOC; | 752 | | } | 753 | | else if (styp_flags & STYP_TBSS) | 754 | | { | 755 | | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY | 756 | | if (sec_flags & SEC_NEVER_LOAD) | 757 | | sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY; | 758 | | else | 759 | | #endif | 760 | | sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL; | 761 | | } | 762 | | else if (styp_flags & STYP_EXCEPT) | 763 | | sec_flags |= SEC_LOAD; | 764 | | else if (styp_flags & STYP_LOADER) | 765 | | sec_flags |= SEC_LOAD; | 766 | | else if (styp_flags & STYP_TYPCHK) | 767 | | sec_flags |= SEC_LOAD; | 768 | | else if (styp_flags & STYP_DWARF) | 769 | | sec_flags |= SEC_DEBUGGING; | 770 | | #endif | 771 | 36.3k | else if (strcmp (name, _TEXT) == 0) | 772 | 4 | { | 773 | 4 | if (sec_flags & SEC_NEVER_LOAD) | 774 | 1 | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 775 | 3 | else | 776 | 3 | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 777 | 4 | } | 778 | 36.3k | else if (strcmp (name, _DATA) == 0) | 779 | 15 | { | 780 | 15 | if (sec_flags & SEC_NEVER_LOAD) | 781 | 1 | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; | 782 | 14 | else | 783 | 14 | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; | 784 | 15 | } | 785 | 36.3k | else if (strcmp (name, _BSS) == 0) | 786 | 14 | { | 787 | | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY | 788 | | if (sec_flags & SEC_NEVER_LOAD) | 789 | | sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY; | 790 | | else | 791 | | #endif | 792 | 14 | sec_flags |= SEC_ALLOC; | 793 | 14 | } | 794 | 36.2k | else if (startswith (name, DOT_DEBUG) | 795 | 36.2k | || startswith (name, DOT_ZDEBUG) | 796 | 36.2k | #ifdef _COMMENT | 797 | 36.2k | || strcmp (name, _COMMENT) == 0 | 798 | 36.2k | #endif | 799 | | #ifdef COFF_LONG_SECTION_NAMES | 800 | | || startswith (name, GNU_LINKONCE_WI) | 801 | | || startswith (name, GNU_LINKONCE_WT) | 802 | | #endif | 803 | 36.2k | || startswith (name, ".stab")) | 804 | 30 | { | 805 | | #ifdef COFF_PAGE_SIZE | 806 | | sec_flags |= SEC_DEBUGGING; | 807 | | #endif | 808 | 30 | } | 809 | 36.2k | #ifdef _LIB | 810 | 36.2k | else if (strcmp (name, _LIB) == 0) | 811 | 3 | ; | 812 | 36.2k | #endif | 813 | | #ifdef _LIT | 814 | | else if (strcmp (name, _LIT) == 0) | 815 | | sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY; | 816 | | #endif | 817 | 36.2k | else | 818 | 36.2k | sec_flags |= SEC_ALLOC | SEC_LOAD; | 819 | | | 820 | 59.7k | #ifdef STYP_LIT /* A29k readonly text/data section type. */ | 821 | 59.7k | if ((styp_flags & STYP_LIT) == STYP_LIT) | 822 | 2.99k | sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY); | 823 | 59.7k | #endif /* STYP_LIT */ | 824 | | | 825 | | #ifdef STYP_OTHER_LOAD /* Other loaded sections. */ | 826 | | if (styp_flags & STYP_OTHER_LOAD) | 827 | | sec_flags = (SEC_LOAD | SEC_ALLOC); | 828 | | #endif /* STYP_SDATA */ | 829 | | | 830 | 59.7k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 831 | 59.7k | && (startswith (name, ".sbss") | 832 | 0 | || startswith (name, ".sdata"))) | 833 | 0 | sec_flags |= SEC_SMALL_DATA; | 834 | | | 835 | | #if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE) | 836 | | /* As a GNU extension, if the name begins with .gnu.linkonce, we | 837 | | only link a single copy of the section. This is used to support | 838 | | g++. g++ will emit each template expansion in its own section. | 839 | | The symbols will be defined as weak, so that multiple definitions | 840 | | are permitted. The GNU linker extension is to actually discard | 841 | | all but one of the sections. */ | 842 | | if (startswith (name, ".gnu.linkonce")) | 843 | | sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; | 844 | | #endif | 845 | | | 846 | 59.7k | if (flags_ptr == NULL) | 847 | 0 | return false; | 848 | | | 849 | 59.7k | * flags_ptr = sec_flags; | 850 | 59.7k | return true; | 851 | 59.7k | } |
|
852 | | |
853 | | #else /* COFF_WITH_PE */ |
854 | | |
855 | | static bool |
856 | | handle_COMDAT (bfd * abfd, |
857 | | flagword *sec_flags, |
858 | | void * hdr, |
859 | | const char *name, |
860 | | asection *section) |
861 | 3.18k | { |
862 | 3.18k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; |
863 | 3.18k | bfd_byte *esymstart, *esym, *esymend; |
864 | 3.18k | int seen_state = 0; |
865 | 3.18k | char *target_name = NULL; |
866 | | |
867 | 3.18k | *sec_flags |= SEC_LINK_ONCE; |
868 | | |
869 | | /* Unfortunately, the PE format stores essential information in |
870 | | the symbol table, of all places. We need to extract that |
871 | | information now, so that objdump and the linker will know how |
872 | | to handle the section without worrying about the symbols. We |
873 | | can't call slurp_symtab, because the linker doesn't want the |
874 | | swapped symbols. */ |
875 | | |
876 | | /* COMDAT sections are special. The first symbol is the section |
877 | | symbol, which tells what kind of COMDAT section it is. The |
878 | | second symbol is the "comdat symbol" - the one with the |
879 | | unique name. GNU uses the section symbol for the unique |
880 | | name; MS uses ".text" for every comdat section. Sigh. - DJ */ |
881 | | |
882 | | /* This is not mirrored in sec_to_styp_flags(), but there |
883 | | doesn't seem to be a need to, either, and it would at best be |
884 | | rather messy. */ |
885 | | |
886 | 3.18k | if (! _bfd_coff_get_external_symbols (abfd)) |
887 | 934 | return true; |
888 | | |
889 | 2.25k | esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd); |
890 | 2.25k | esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd); |
891 | | |
892 | 2.25k | for (struct internal_syment isym; |
893 | 380k | esym < esymend; |
894 | 378k | esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd)) |
895 | 378k | { |
896 | 378k | char buf[SYMNMLEN + 1]; |
897 | 378k | const char *symname; |
898 | | |
899 | 378k | bfd_coff_swap_sym_in (abfd, esym, &isym); |
900 | | |
901 | 378k | BFD_ASSERT (sizeof (internal_s->s_name) <= SYMNMLEN); |
902 | | |
903 | 378k | if (isym.n_scnum == section->target_index) |
904 | 583 | { |
905 | | /* According to the MSVC documentation, the first |
906 | | TWO entries with the section # are both of |
907 | | interest to us. The first one is the "section |
908 | | symbol" (section name). The second is the comdat |
909 | | symbol name. Here, we've found the first |
910 | | qualifying entry; we distinguish it from the |
911 | | second with a state flag. |
912 | | |
913 | | In the case of gas-generated (at least until that |
914 | | is fixed) .o files, it isn't necessarily the |
915 | | second one. It may be some other later symbol. |
916 | | |
917 | | Since gas also doesn't follow MS conventions and |
918 | | emits the section similar to .text$<name>, where |
919 | | <something> is the name we're looking for, we |
920 | | distinguish the two as follows: |
921 | | |
922 | | If the section name is simply a section name (no |
923 | | $) we presume it's MS-generated, and look at |
924 | | precisely the second symbol for the comdat name. |
925 | | If the section name has a $, we assume it's |
926 | | gas-generated, and look for <something> (whatever |
927 | | follows the $) as the comdat symbol. */ |
928 | | |
929 | | /* All 3 branches use this. */ |
930 | 583 | symname = _bfd_coff_internal_syment_name (abfd, &isym, buf); |
931 | | |
932 | | /* PR 17512 file: 078-11867-0.004 */ |
933 | 583 | if (symname == NULL) |
934 | 47 | { |
935 | 47 | _bfd_error_handler (_("%pB: unable to load COMDAT section name"), |
936 | 47 | abfd); |
937 | 47 | return false; |
938 | 47 | } |
939 | | |
940 | 536 | switch (seen_state) |
941 | 536 | { |
942 | 402 | case 0: |
943 | 402 | { |
944 | | /* The first time we've seen the symbol. */ |
945 | 402 | union internal_auxent aux; |
946 | | |
947 | | /* If it isn't the stuff we're expecting, die; |
948 | | The MS documentation is vague, but it |
949 | | appears that the second entry serves BOTH |
950 | | as the comdat symbol and the defining |
951 | | symbol record (either C_STAT or C_EXT, |
952 | | possibly with an aux entry with debug |
953 | | information if it's a function.) It |
954 | | appears the only way to find the second one |
955 | | is to count. (On Intel, they appear to be |
956 | | adjacent, but on Alpha, they have been |
957 | | found separated.) |
958 | | |
959 | | Here, we think we've found the first one, |
960 | | but there's some checking we can do to be |
961 | | sure. */ |
962 | | |
963 | 402 | if (! ((isym.n_sclass == C_STAT |
964 | 402 | || isym.n_sclass == C_EXT) |
965 | 402 | && BTYPE (isym.n_type) == T_NULL |
966 | 402 | && isym.n_value == 0)) |
967 | 97 | { |
968 | | /* Malformed input files can trigger this test. |
969 | | cf PR 21781. */ |
970 | 97 | _bfd_error_handler (_("%pB: error: unexpected symbol '%s' in COMDAT section"), |
971 | 97 | abfd, symname); |
972 | 97 | return false; |
973 | 97 | } |
974 | | |
975 | | /* FIXME LATER: MSVC generates section names |
976 | | like .text for comdats. Gas generates |
977 | | names like .text$foo__Fv (in the case of a |
978 | | function). See comment above for more. */ |
979 | | |
980 | 305 | if (isym.n_sclass == C_STAT && strcmp (name, symname) != 0) |
981 | | /* xgettext:c-format */ |
982 | 164 | _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'" |
983 | 164 | " does not match section name '%s'"), |
984 | 164 | abfd, symname, name); |
985 | | |
986 | | /* This is the section symbol. */ |
987 | 305 | seen_state = 1; |
988 | 305 | target_name = strchr (name, '$'); |
989 | 305 | if (target_name != NULL) |
990 | 66 | { |
991 | | /* Gas mode. */ |
992 | 66 | seen_state = 2; |
993 | | /* Skip the `$'. */ |
994 | 66 | target_name += 1; |
995 | 66 | } |
996 | | |
997 | 305 | if (isym.n_numaux == 0) |
998 | 120 | aux.x_scn.x_comdat = 0; |
999 | 185 | else |
1000 | 185 | { |
1001 | | /* PR 17512: file: e2cfe54f. */ |
1002 | 185 | if (esym + bfd_coff_symesz (abfd) >= esymend) |
1003 | 19 | { |
1004 | | /* xgettext:c-format */ |
1005 | 19 | _bfd_error_handler (_("%pB: warning: no symbol for" |
1006 | 19 | " section '%s' found"), |
1007 | 19 | abfd, symname); |
1008 | 19 | break; |
1009 | 19 | } |
1010 | 166 | bfd_coff_swap_aux_in (abfd, esym + bfd_coff_symesz (abfd), |
1011 | 166 | isym.n_type, isym.n_sclass, |
1012 | 166 | 0, isym.n_numaux, &aux); |
1013 | 166 | } |
1014 | | |
1015 | | /* FIXME: Microsoft uses NODUPLICATES and |
1016 | | ASSOCIATIVE, but gnu uses ANY and |
1017 | | SAME_SIZE. Unfortunately, gnu doesn't do |
1018 | | the comdat symbols right. So, until we can |
1019 | | fix it to do the right thing, we are |
1020 | | temporarily disabling comdats for the MS |
1021 | | types (they're used in DLLs and C++, but we |
1022 | | don't support *their* C++ libraries anyway |
1023 | | - DJ. */ |
1024 | | |
1025 | | /* Cygwin does not follow the MS style, and |
1026 | | uses ANY and SAME_SIZE where NODUPLICATES |
1027 | | and ASSOCIATIVE should be used. For |
1028 | | Interix, we just do the right thing up |
1029 | | front. */ |
1030 | | |
1031 | 286 | switch (aux.x_scn.x_comdat) |
1032 | 286 | { |
1033 | 19 | case IMAGE_COMDAT_SELECT_NODUPLICATES: |
1034 | | #ifdef STRICT_PE_FORMAT |
1035 | | *sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY; |
1036 | | #else |
1037 | 19 | *sec_flags &= ~SEC_LINK_ONCE; |
1038 | 19 | #endif |
1039 | 19 | break; |
1040 | | |
1041 | 0 | case IMAGE_COMDAT_SELECT_ANY: |
1042 | 0 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; |
1043 | 0 | break; |
1044 | | |
1045 | 16 | case IMAGE_COMDAT_SELECT_SAME_SIZE: |
1046 | 16 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE; |
1047 | 16 | break; |
1048 | | |
1049 | 17 | case IMAGE_COMDAT_SELECT_EXACT_MATCH: |
1050 | | /* Not yet fully implemented ??? */ |
1051 | 17 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS; |
1052 | 17 | break; |
1053 | | |
1054 | | /* debug$S gets this case; other |
1055 | | implications ??? */ |
1056 | | |
1057 | | /* There may be no symbol... we'll search |
1058 | | the whole table... Is this the right |
1059 | | place to play this game? Or should we do |
1060 | | it when reading it in. */ |
1061 | 19 | case IMAGE_COMDAT_SELECT_ASSOCIATIVE: |
1062 | | #ifdef STRICT_PE_FORMAT |
1063 | | /* FIXME: This is not currently implemented. */ |
1064 | | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; |
1065 | | #else |
1066 | 19 | *sec_flags &= ~SEC_LINK_ONCE; |
1067 | 19 | #endif |
1068 | 19 | break; |
1069 | | |
1070 | 215 | default: /* 0 means "no symbol" */ |
1071 | | /* debug$F gets this case; other |
1072 | | implications ??? */ |
1073 | 215 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; |
1074 | 215 | break; |
1075 | 286 | } |
1076 | 286 | } |
1077 | 286 | break; |
1078 | | |
1079 | 286 | case 2: |
1080 | | /* Gas mode: the first matching on partial name. */ |
1081 | | |
1082 | | #ifndef TARGET_UNDERSCORE |
1083 | 26 | #define TARGET_UNDERSCORE 0 |
1084 | | #endif |
1085 | | /* Is this the name we're looking for ? */ |
1086 | 83 | if (strcmp (target_name, |
1087 | 83 | symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0) |
1088 | 71 | { |
1089 | | /* Not the name we're looking for */ |
1090 | 71 | continue; |
1091 | 71 | } |
1092 | | /* Fall through. */ |
1093 | 63 | case 1: |
1094 | | /* MSVC mode: the lexically second symbol (or |
1095 | | drop through from the above). */ |
1096 | 63 | { |
1097 | | /* This must the second symbol with the |
1098 | | section #. It is the actual symbol name. |
1099 | | Intel puts the two adjacent, but Alpha (at |
1100 | | least) spreads them out. */ |
1101 | | |
1102 | 63 | struct coff_comdat_info *comdat; |
1103 | 63 | size_t len = strlen (symname) + 1; |
1104 | | |
1105 | 63 | comdat = bfd_alloc (abfd, sizeof (*comdat) + len); |
1106 | 63 | if (comdat == NULL) |
1107 | 0 | return false; |
1108 | | |
1109 | 63 | coff_section_data (abfd, section)->comdat = comdat; |
1110 | 63 | comdat->symbol = (esym - esymstart) / bfd_coff_symesz (abfd); |
1111 | 63 | char *newname = (char *) (comdat + 1); |
1112 | 63 | comdat->name = newname; |
1113 | 63 | memcpy (newname, symname, len); |
1114 | 63 | return true; |
1115 | 63 | } |
1116 | 536 | } |
1117 | 536 | } |
1118 | 378k | } |
1119 | | |
1120 | 2.04k | return true; |
1121 | 2.25k | } Line | Count | Source | 861 | 116 | { | 862 | 116 | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 863 | 116 | bfd_byte *esymstart, *esym, *esymend; | 864 | 116 | int seen_state = 0; | 865 | 116 | char *target_name = NULL; | 866 | | | 867 | 116 | *sec_flags |= SEC_LINK_ONCE; | 868 | | | 869 | | /* Unfortunately, the PE format stores essential information in | 870 | | the symbol table, of all places. We need to extract that | 871 | | information now, so that objdump and the linker will know how | 872 | | to handle the section without worrying about the symbols. We | 873 | | can't call slurp_symtab, because the linker doesn't want the | 874 | | swapped symbols. */ | 875 | | | 876 | | /* COMDAT sections are special. The first symbol is the section | 877 | | symbol, which tells what kind of COMDAT section it is. The | 878 | | second symbol is the "comdat symbol" - the one with the | 879 | | unique name. GNU uses the section symbol for the unique | 880 | | name; MS uses ".text" for every comdat section. Sigh. - DJ */ | 881 | | | 882 | | /* This is not mirrored in sec_to_styp_flags(), but there | 883 | | doesn't seem to be a need to, either, and it would at best be | 884 | | rather messy. */ | 885 | | | 886 | 116 | if (! _bfd_coff_get_external_symbols (abfd)) | 887 | 35 | return true; | 888 | | | 889 | 81 | esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd); | 890 | 81 | esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd); | 891 | | | 892 | 81 | for (struct internal_syment isym; | 893 | 644 | esym < esymend; | 894 | 563 | esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd)) | 895 | 570 | { | 896 | 570 | char buf[SYMNMLEN + 1]; | 897 | 570 | const char *symname; | 898 | | | 899 | 570 | bfd_coff_swap_sym_in (abfd, esym, &isym); | 900 | | | 901 | 570 | BFD_ASSERT (sizeof (internal_s->s_name) <= SYMNMLEN); | 902 | | | 903 | 570 | if (isym.n_scnum == section->target_index) | 904 | 21 | { | 905 | | /* According to the MSVC documentation, the first | 906 | | TWO entries with the section # are both of | 907 | | interest to us. The first one is the "section | 908 | | symbol" (section name). The second is the comdat | 909 | | symbol name. Here, we've found the first | 910 | | qualifying entry; we distinguish it from the | 911 | | second with a state flag. | 912 | | | 913 | | In the case of gas-generated (at least until that | 914 | | is fixed) .o files, it isn't necessarily the | 915 | | second one. It may be some other later symbol. | 916 | | | 917 | | Since gas also doesn't follow MS conventions and | 918 | | emits the section similar to .text$<name>, where | 919 | | <something> is the name we're looking for, we | 920 | | distinguish the two as follows: | 921 | | | 922 | | If the section name is simply a section name (no | 923 | | $) we presume it's MS-generated, and look at | 924 | | precisely the second symbol for the comdat name. | 925 | | If the section name has a $, we assume it's | 926 | | gas-generated, and look for <something> (whatever | 927 | | follows the $) as the comdat symbol. */ | 928 | | | 929 | | /* All 3 branches use this. */ | 930 | 21 | symname = _bfd_coff_internal_syment_name (abfd, &isym, buf); | 931 | | | 932 | | /* PR 17512 file: 078-11867-0.004 */ | 933 | 21 | if (symname == NULL) | 934 | 1 | { | 935 | 1 | _bfd_error_handler (_("%pB: unable to load COMDAT section name"), | 936 | 1 | abfd); | 937 | 1 | return false; | 938 | 1 | } | 939 | | | 940 | 20 | switch (seen_state) | 941 | 20 | { | 942 | 16 | case 0: | 943 | 16 | { | 944 | | /* The first time we've seen the symbol. */ | 945 | 16 | union internal_auxent aux; | 946 | | | 947 | | /* If it isn't the stuff we're expecting, die; | 948 | | The MS documentation is vague, but it | 949 | | appears that the second entry serves BOTH | 950 | | as the comdat symbol and the defining | 951 | | symbol record (either C_STAT or C_EXT, | 952 | | possibly with an aux entry with debug | 953 | | information if it's a function.) It | 954 | | appears the only way to find the second one | 955 | | is to count. (On Intel, they appear to be | 956 | | adjacent, but on Alpha, they have been | 957 | | found separated.) | 958 | | | 959 | | Here, we think we've found the first one, | 960 | | but there's some checking we can do to be | 961 | | sure. */ | 962 | | | 963 | 16 | if (! ((isym.n_sclass == C_STAT | 964 | 16 | || isym.n_sclass == C_EXT) | 965 | 16 | && BTYPE (isym.n_type) == T_NULL | 966 | 16 | && isym.n_value == 0)) | 967 | 3 | { | 968 | | /* Malformed input files can trigger this test. | 969 | | cf PR 21781. */ | 970 | 3 | _bfd_error_handler (_("%pB: error: unexpected symbol '%s' in COMDAT section"), | 971 | 3 | abfd, symname); | 972 | 3 | return false; | 973 | 3 | } | 974 | | | 975 | | /* FIXME LATER: MSVC generates section names | 976 | | like .text for comdats. Gas generates | 977 | | names like .text$foo__Fv (in the case of a | 978 | | function). See comment above for more. */ | 979 | | | 980 | 13 | if (isym.n_sclass == C_STAT && strcmp (name, symname) != 0) | 981 | | /* xgettext:c-format */ | 982 | 5 | _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'" | 983 | 5 | " does not match section name '%s'"), | 984 | 5 | abfd, symname, name); | 985 | | | 986 | | /* This is the section symbol. */ | 987 | 13 | seen_state = 1; | 988 | 13 | target_name = strchr (name, '$'); | 989 | 13 | if (target_name != NULL) | 990 | 1 | { | 991 | | /* Gas mode. */ | 992 | 1 | seen_state = 2; | 993 | | /* Skip the `$'. */ | 994 | 1 | target_name += 1; | 995 | 1 | } | 996 | | | 997 | 13 | if (isym.n_numaux == 0) | 998 | 4 | aux.x_scn.x_comdat = 0; | 999 | 9 | else | 1000 | 9 | { | 1001 | | /* PR 17512: file: e2cfe54f. */ | 1002 | 9 | if (esym + bfd_coff_symesz (abfd) >= esymend) | 1003 | 1 | { | 1004 | | /* xgettext:c-format */ | 1005 | 1 | _bfd_error_handler (_("%pB: warning: no symbol for" | 1006 | 1 | " section '%s' found"), | 1007 | 1 | abfd, symname); | 1008 | 1 | break; | 1009 | 1 | } | 1010 | 8 | bfd_coff_swap_aux_in (abfd, esym + bfd_coff_symesz (abfd), | 1011 | 8 | isym.n_type, isym.n_sclass, | 1012 | 8 | 0, isym.n_numaux, &aux); | 1013 | 8 | } | 1014 | | | 1015 | | /* FIXME: Microsoft uses NODUPLICATES and | 1016 | | ASSOCIATIVE, but gnu uses ANY and | 1017 | | SAME_SIZE. Unfortunately, gnu doesn't do | 1018 | | the comdat symbols right. So, until we can | 1019 | | fix it to do the right thing, we are | 1020 | | temporarily disabling comdats for the MS | 1021 | | types (they're used in DLLs and C++, but we | 1022 | | don't support *their* C++ libraries anyway | 1023 | | - DJ. */ | 1024 | | | 1025 | | /* Cygwin does not follow the MS style, and | 1026 | | uses ANY and SAME_SIZE where NODUPLICATES | 1027 | | and ASSOCIATIVE should be used. For | 1028 | | Interix, we just do the right thing up | 1029 | | front. */ | 1030 | | | 1031 | 12 | switch (aux.x_scn.x_comdat) | 1032 | 12 | { | 1033 | 3 | case IMAGE_COMDAT_SELECT_NODUPLICATES: | 1034 | | #ifdef STRICT_PE_FORMAT | 1035 | | *sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY; | 1036 | | #else | 1037 | 3 | *sec_flags &= ~SEC_LINK_ONCE; | 1038 | 3 | #endif | 1039 | 3 | break; | 1040 | | | 1041 | 0 | case IMAGE_COMDAT_SELECT_ANY: | 1042 | 0 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1043 | 0 | break; | 1044 | | | 1045 | 0 | case IMAGE_COMDAT_SELECT_SAME_SIZE: | 1046 | 0 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE; | 1047 | 0 | break; | 1048 | | | 1049 | 1 | case IMAGE_COMDAT_SELECT_EXACT_MATCH: | 1050 | | /* Not yet fully implemented ??? */ | 1051 | 1 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS; | 1052 | 1 | break; | 1053 | | | 1054 | | /* debug$S gets this case; other | 1055 | | implications ??? */ | 1056 | | | 1057 | | /* There may be no symbol... we'll search | 1058 | | the whole table... Is this the right | 1059 | | place to play this game? Or should we do | 1060 | | it when reading it in. */ | 1061 | 0 | case IMAGE_COMDAT_SELECT_ASSOCIATIVE: | 1062 | | #ifdef STRICT_PE_FORMAT | 1063 | | /* FIXME: This is not currently implemented. */ | 1064 | | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1065 | | #else | 1066 | 0 | *sec_flags &= ~SEC_LINK_ONCE; | 1067 | 0 | #endif | 1068 | 0 | break; | 1069 | | | 1070 | 8 | default: /* 0 means "no symbol" */ | 1071 | | /* debug$F gets this case; other | 1072 | | implications ??? */ | 1073 | 8 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1074 | 8 | break; | 1075 | 12 | } | 1076 | 12 | } | 1077 | 12 | break; | 1078 | | | 1079 | 12 | case 2: | 1080 | | /* Gas mode: the first matching on partial name. */ | 1081 | | | 1082 | | #ifndef TARGET_UNDERSCORE | 1083 | | #define TARGET_UNDERSCORE 0 | 1084 | | #endif | 1085 | | /* Is this the name we're looking for ? */ | 1086 | 1 | if (strcmp (target_name, | 1087 | 1 | symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0) | 1088 | 1 | { | 1089 | | /* Not the name we're looking for */ | 1090 | 1 | continue; | 1091 | 1 | } | 1092 | | /* Fall through. */ | 1093 | 3 | case 1: | 1094 | | /* MSVC mode: the lexically second symbol (or | 1095 | | drop through from the above). */ | 1096 | 3 | { | 1097 | | /* This must the second symbol with the | 1098 | | section #. It is the actual symbol name. | 1099 | | Intel puts the two adjacent, but Alpha (at | 1100 | | least) spreads them out. */ | 1101 | | | 1102 | 3 | struct coff_comdat_info *comdat; | 1103 | 3 | size_t len = strlen (symname) + 1; | 1104 | | | 1105 | 3 | comdat = bfd_alloc (abfd, sizeof (*comdat) + len); | 1106 | 3 | if (comdat == NULL) | 1107 | 0 | return false; | 1108 | | | 1109 | 3 | coff_section_data (abfd, section)->comdat = comdat; | 1110 | 3 | comdat->symbol = (esym - esymstart) / bfd_coff_symesz (abfd); | 1111 | 3 | char *newname = (char *) (comdat + 1); | 1112 | 3 | comdat->name = newname; | 1113 | 3 | memcpy (newname, symname, len); | 1114 | 3 | return true; | 1115 | 3 | } | 1116 | 20 | } | 1117 | 20 | } | 1118 | 570 | } | 1119 | | | 1120 | 74 | return true; | 1121 | 81 | } |
pe-x86_64.c:handle_COMDAT Line | Count | Source | 861 | 547 | { | 862 | 547 | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 863 | 547 | bfd_byte *esymstart, *esym, *esymend; | 864 | 547 | int seen_state = 0; | 865 | 547 | char *target_name = NULL; | 866 | | | 867 | 547 | *sec_flags |= SEC_LINK_ONCE; | 868 | | | 869 | | /* Unfortunately, the PE format stores essential information in | 870 | | the symbol table, of all places. We need to extract that | 871 | | information now, so that objdump and the linker will know how | 872 | | to handle the section without worrying about the symbols. We | 873 | | can't call slurp_symtab, because the linker doesn't want the | 874 | | swapped symbols. */ | 875 | | | 876 | | /* COMDAT sections are special. The first symbol is the section | 877 | | symbol, which tells what kind of COMDAT section it is. The | 878 | | second symbol is the "comdat symbol" - the one with the | 879 | | unique name. GNU uses the section symbol for the unique | 880 | | name; MS uses ".text" for every comdat section. Sigh. - DJ */ | 881 | | | 882 | | /* This is not mirrored in sec_to_styp_flags(), but there | 883 | | doesn't seem to be a need to, either, and it would at best be | 884 | | rather messy. */ | 885 | | | 886 | 547 | if (! _bfd_coff_get_external_symbols (abfd)) | 887 | 135 | return true; | 888 | | | 889 | 412 | esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd); | 890 | 412 | esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd); | 891 | | | 892 | 412 | for (struct internal_syment isym; | 893 | 31.2k | esym < esymend; | 894 | 30.8k | esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd)) | 895 | 30.8k | { | 896 | 30.8k | char buf[SYMNMLEN + 1]; | 897 | 30.8k | const char *symname; | 898 | | | 899 | 30.8k | bfd_coff_swap_sym_in (abfd, esym, &isym); | 900 | | | 901 | 30.8k | BFD_ASSERT (sizeof (internal_s->s_name) <= SYMNMLEN); | 902 | | | 903 | 30.8k | if (isym.n_scnum == section->target_index) | 904 | 104 | { | 905 | | /* According to the MSVC documentation, the first | 906 | | TWO entries with the section # are both of | 907 | | interest to us. The first one is the "section | 908 | | symbol" (section name). The second is the comdat | 909 | | symbol name. Here, we've found the first | 910 | | qualifying entry; we distinguish it from the | 911 | | second with a state flag. | 912 | | | 913 | | In the case of gas-generated (at least until that | 914 | | is fixed) .o files, it isn't necessarily the | 915 | | second one. It may be some other later symbol. | 916 | | | 917 | | Since gas also doesn't follow MS conventions and | 918 | | emits the section similar to .text$<name>, where | 919 | | <something> is the name we're looking for, we | 920 | | distinguish the two as follows: | 921 | | | 922 | | If the section name is simply a section name (no | 923 | | $) we presume it's MS-generated, and look at | 924 | | precisely the second symbol for the comdat name. | 925 | | If the section name has a $, we assume it's | 926 | | gas-generated, and look for <something> (whatever | 927 | | follows the $) as the comdat symbol. */ | 928 | | | 929 | | /* All 3 branches use this. */ | 930 | 104 | symname = _bfd_coff_internal_syment_name (abfd, &isym, buf); | 931 | | | 932 | | /* PR 17512 file: 078-11867-0.004 */ | 933 | 104 | if (symname == NULL) | 934 | 13 | { | 935 | 13 | _bfd_error_handler (_("%pB: unable to load COMDAT section name"), | 936 | 13 | abfd); | 937 | 13 | return false; | 938 | 13 | } | 939 | | | 940 | 91 | switch (seen_state) | 941 | 91 | { | 942 | 74 | case 0: | 943 | 74 | { | 944 | | /* The first time we've seen the symbol. */ | 945 | 74 | union internal_auxent aux; | 946 | | | 947 | | /* If it isn't the stuff we're expecting, die; | 948 | | The MS documentation is vague, but it | 949 | | appears that the second entry serves BOTH | 950 | | as the comdat symbol and the defining | 951 | | symbol record (either C_STAT or C_EXT, | 952 | | possibly with an aux entry with debug | 953 | | information if it's a function.) It | 954 | | appears the only way to find the second one | 955 | | is to count. (On Intel, they appear to be | 956 | | adjacent, but on Alpha, they have been | 957 | | found separated.) | 958 | | | 959 | | Here, we think we've found the first one, | 960 | | but there's some checking we can do to be | 961 | | sure. */ | 962 | | | 963 | 74 | if (! ((isym.n_sclass == C_STAT | 964 | 74 | || isym.n_sclass == C_EXT) | 965 | 74 | && BTYPE (isym.n_type) == T_NULL | 966 | 74 | && isym.n_value == 0)) | 967 | 31 | { | 968 | | /* Malformed input files can trigger this test. | 969 | | cf PR 21781. */ | 970 | 31 | _bfd_error_handler (_("%pB: error: unexpected symbol '%s' in COMDAT section"), | 971 | 31 | abfd, symname); | 972 | 31 | return false; | 973 | 31 | } | 974 | | | 975 | | /* FIXME LATER: MSVC generates section names | 976 | | like .text for comdats. Gas generates | 977 | | names like .text$foo__Fv (in the case of a | 978 | | function). See comment above for more. */ | 979 | | | 980 | 43 | if (isym.n_sclass == C_STAT && strcmp (name, symname) != 0) | 981 | | /* xgettext:c-format */ | 982 | 32 | _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'" | 983 | 32 | " does not match section name '%s'"), | 984 | 32 | abfd, symname, name); | 985 | | | 986 | | /* This is the section symbol. */ | 987 | 43 | seen_state = 1; | 988 | 43 | target_name = strchr (name, '$'); | 989 | 43 | if (target_name != NULL) | 990 | 8 | { | 991 | | /* Gas mode. */ | 992 | 8 | seen_state = 2; | 993 | | /* Skip the `$'. */ | 994 | 8 | target_name += 1; | 995 | 8 | } | 996 | | | 997 | 43 | if (isym.n_numaux == 0) | 998 | 15 | aux.x_scn.x_comdat = 0; | 999 | 28 | else | 1000 | 28 | { | 1001 | | /* PR 17512: file: e2cfe54f. */ | 1002 | 28 | if (esym + bfd_coff_symesz (abfd) >= esymend) | 1003 | 3 | { | 1004 | | /* xgettext:c-format */ | 1005 | 3 | _bfd_error_handler (_("%pB: warning: no symbol for" | 1006 | 3 | " section '%s' found"), | 1007 | 3 | abfd, symname); | 1008 | 3 | break; | 1009 | 3 | } | 1010 | 25 | bfd_coff_swap_aux_in (abfd, esym + bfd_coff_symesz (abfd), | 1011 | 25 | isym.n_type, isym.n_sclass, | 1012 | 25 | 0, isym.n_numaux, &aux); | 1013 | 25 | } | 1014 | | | 1015 | | /* FIXME: Microsoft uses NODUPLICATES and | 1016 | | ASSOCIATIVE, but gnu uses ANY and | 1017 | | SAME_SIZE. Unfortunately, gnu doesn't do | 1018 | | the comdat symbols right. So, until we can | 1019 | | fix it to do the right thing, we are | 1020 | | temporarily disabling comdats for the MS | 1021 | | types (they're used in DLLs and C++, but we | 1022 | | don't support *their* C++ libraries anyway | 1023 | | - DJ. */ | 1024 | | | 1025 | | /* Cygwin does not follow the MS style, and | 1026 | | uses ANY and SAME_SIZE where NODUPLICATES | 1027 | | and ASSOCIATIVE should be used. For | 1028 | | Interix, we just do the right thing up | 1029 | | front. */ | 1030 | | | 1031 | 40 | switch (aux.x_scn.x_comdat) | 1032 | 40 | { | 1033 | 3 | case IMAGE_COMDAT_SELECT_NODUPLICATES: | 1034 | | #ifdef STRICT_PE_FORMAT | 1035 | | *sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY; | 1036 | | #else | 1037 | 3 | *sec_flags &= ~SEC_LINK_ONCE; | 1038 | 3 | #endif | 1039 | 3 | break; | 1040 | | | 1041 | 0 | case IMAGE_COMDAT_SELECT_ANY: | 1042 | 0 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1043 | 0 | break; | 1044 | | | 1045 | 3 | case IMAGE_COMDAT_SELECT_SAME_SIZE: | 1046 | 3 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE; | 1047 | 3 | break; | 1048 | | | 1049 | 3 | case IMAGE_COMDAT_SELECT_EXACT_MATCH: | 1050 | | /* Not yet fully implemented ??? */ | 1051 | 3 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS; | 1052 | 3 | break; | 1053 | | | 1054 | | /* debug$S gets this case; other | 1055 | | implications ??? */ | 1056 | | | 1057 | | /* There may be no symbol... we'll search | 1058 | | the whole table... Is this the right | 1059 | | place to play this game? Or should we do | 1060 | | it when reading it in. */ | 1061 | 3 | case IMAGE_COMDAT_SELECT_ASSOCIATIVE: | 1062 | | #ifdef STRICT_PE_FORMAT | 1063 | | /* FIXME: This is not currently implemented. */ | 1064 | | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1065 | | #else | 1066 | 3 | *sec_flags &= ~SEC_LINK_ONCE; | 1067 | 3 | #endif | 1068 | 3 | break; | 1069 | | | 1070 | 28 | default: /* 0 means "no symbol" */ | 1071 | | /* debug$F gets this case; other | 1072 | | implications ??? */ | 1073 | 28 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1074 | 28 | break; | 1075 | 40 | } | 1076 | 40 | } | 1077 | 40 | break; | 1078 | | | 1079 | 40 | case 2: | 1080 | | /* Gas mode: the first matching on partial name. */ | 1081 | | | 1082 | | #ifndef TARGET_UNDERSCORE | 1083 | | #define TARGET_UNDERSCORE 0 | 1084 | | #endif | 1085 | | /* Is this the name we're looking for ? */ | 1086 | 10 | if (strcmp (target_name, | 1087 | 10 | symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0) | 1088 | 7 | { | 1089 | | /* Not the name we're looking for */ | 1090 | 7 | continue; | 1091 | 7 | } | 1092 | | /* Fall through. */ | 1093 | 10 | case 1: | 1094 | | /* MSVC mode: the lexically second symbol (or | 1095 | | drop through from the above). */ | 1096 | 10 | { | 1097 | | /* This must the second symbol with the | 1098 | | section #. It is the actual symbol name. | 1099 | | Intel puts the two adjacent, but Alpha (at | 1100 | | least) spreads them out. */ | 1101 | | | 1102 | 10 | struct coff_comdat_info *comdat; | 1103 | 10 | size_t len = strlen (symname) + 1; | 1104 | | | 1105 | 10 | comdat = bfd_alloc (abfd, sizeof (*comdat) + len); | 1106 | 10 | if (comdat == NULL) | 1107 | 0 | return false; | 1108 | | | 1109 | 10 | coff_section_data (abfd, section)->comdat = comdat; | 1110 | 10 | comdat->symbol = (esym - esymstart) / bfd_coff_symesz (abfd); | 1111 | 10 | char *newname = (char *) (comdat + 1); | 1112 | 10 | comdat->name = newname; | 1113 | 10 | memcpy (newname, symname, len); | 1114 | 10 | return true; | 1115 | 10 | } | 1116 | 91 | } | 1117 | 91 | } | 1118 | 30.8k | } | 1119 | | | 1120 | 358 | return true; | 1121 | 412 | } |
pei-x86_64.c:handle_COMDAT Line | Count | Source | 861 | 264 | { | 862 | 264 | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 863 | 264 | bfd_byte *esymstart, *esym, *esymend; | 864 | 264 | int seen_state = 0; | 865 | 264 | char *target_name = NULL; | 866 | | | 867 | 264 | *sec_flags |= SEC_LINK_ONCE; | 868 | | | 869 | | /* Unfortunately, the PE format stores essential information in | 870 | | the symbol table, of all places. We need to extract that | 871 | | information now, so that objdump and the linker will know how | 872 | | to handle the section without worrying about the symbols. We | 873 | | can't call slurp_symtab, because the linker doesn't want the | 874 | | swapped symbols. */ | 875 | | | 876 | | /* COMDAT sections are special. The first symbol is the section | 877 | | symbol, which tells what kind of COMDAT section it is. The | 878 | | second symbol is the "comdat symbol" - the one with the | 879 | | unique name. GNU uses the section symbol for the unique | 880 | | name; MS uses ".text" for every comdat section. Sigh. - DJ */ | 881 | | | 882 | | /* This is not mirrored in sec_to_styp_flags(), but there | 883 | | doesn't seem to be a need to, either, and it would at best be | 884 | | rather messy. */ | 885 | | | 886 | 264 | if (! _bfd_coff_get_external_symbols (abfd)) | 887 | 25 | return true; | 888 | | | 889 | 239 | esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd); | 890 | 239 | esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd); | 891 | | | 892 | 239 | for (struct internal_syment isym; | 893 | 40.8k | esym < esymend; | 894 | 40.6k | esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd)) | 895 | 40.6k | { | 896 | 40.6k | char buf[SYMNMLEN + 1]; | 897 | 40.6k | const char *symname; | 898 | | | 899 | 40.6k | bfd_coff_swap_sym_in (abfd, esym, &isym); | 900 | | | 901 | 40.6k | BFD_ASSERT (sizeof (internal_s->s_name) <= SYMNMLEN); | 902 | | | 903 | 40.6k | if (isym.n_scnum == section->target_index) | 904 | 18 | { | 905 | | /* According to the MSVC documentation, the first | 906 | | TWO entries with the section # are both of | 907 | | interest to us. The first one is the "section | 908 | | symbol" (section name). The second is the comdat | 909 | | symbol name. Here, we've found the first | 910 | | qualifying entry; we distinguish it from the | 911 | | second with a state flag. | 912 | | | 913 | | In the case of gas-generated (at least until that | 914 | | is fixed) .o files, it isn't necessarily the | 915 | | second one. It may be some other later symbol. | 916 | | | 917 | | Since gas also doesn't follow MS conventions and | 918 | | emits the section similar to .text$<name>, where | 919 | | <something> is the name we're looking for, we | 920 | | distinguish the two as follows: | 921 | | | 922 | | If the section name is simply a section name (no | 923 | | $) we presume it's MS-generated, and look at | 924 | | precisely the second symbol for the comdat name. | 925 | | If the section name has a $, we assume it's | 926 | | gas-generated, and look for <something> (whatever | 927 | | follows the $) as the comdat symbol. */ | 928 | | | 929 | | /* All 3 branches use this. */ | 930 | 18 | symname = _bfd_coff_internal_syment_name (abfd, &isym, buf); | 931 | | | 932 | | /* PR 17512 file: 078-11867-0.004 */ | 933 | 18 | if (symname == NULL) | 934 | 1 | { | 935 | 1 | _bfd_error_handler (_("%pB: unable to load COMDAT section name"), | 936 | 1 | abfd); | 937 | 1 | return false; | 938 | 1 | } | 939 | | | 940 | 17 | switch (seen_state) | 941 | 17 | { | 942 | 14 | case 0: | 943 | 14 | { | 944 | | /* The first time we've seen the symbol. */ | 945 | 14 | union internal_auxent aux; | 946 | | | 947 | | /* If it isn't the stuff we're expecting, die; | 948 | | The MS documentation is vague, but it | 949 | | appears that the second entry serves BOTH | 950 | | as the comdat symbol and the defining | 951 | | symbol record (either C_STAT or C_EXT, | 952 | | possibly with an aux entry with debug | 953 | | information if it's a function.) It | 954 | | appears the only way to find the second one | 955 | | is to count. (On Intel, they appear to be | 956 | | adjacent, but on Alpha, they have been | 957 | | found separated.) | 958 | | | 959 | | Here, we think we've found the first one, | 960 | | but there's some checking we can do to be | 961 | | sure. */ | 962 | | | 963 | 14 | if (! ((isym.n_sclass == C_STAT | 964 | 14 | || isym.n_sclass == C_EXT) | 965 | 14 | && BTYPE (isym.n_type) == T_NULL | 966 | 14 | && isym.n_value == 0)) | 967 | 3 | { | 968 | | /* Malformed input files can trigger this test. | 969 | | cf PR 21781. */ | 970 | 3 | _bfd_error_handler (_("%pB: error: unexpected symbol '%s' in COMDAT section"), | 971 | 3 | abfd, symname); | 972 | 3 | return false; | 973 | 3 | } | 974 | | | 975 | | /* FIXME LATER: MSVC generates section names | 976 | | like .text for comdats. Gas generates | 977 | | names like .text$foo__Fv (in the case of a | 978 | | function). See comment above for more. */ | 979 | | | 980 | 11 | if (isym.n_sclass == C_STAT && strcmp (name, symname) != 0) | 981 | | /* xgettext:c-format */ | 982 | 1 | _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'" | 983 | 1 | " does not match section name '%s'"), | 984 | 1 | abfd, symname, name); | 985 | | | 986 | | /* This is the section symbol. */ | 987 | 11 | seen_state = 1; | 988 | 11 | target_name = strchr (name, '$'); | 989 | 11 | if (target_name != NULL) | 990 | 0 | { | 991 | | /* Gas mode. */ | 992 | 0 | seen_state = 2; | 993 | | /* Skip the `$'. */ | 994 | 0 | target_name += 1; | 995 | 0 | } | 996 | | | 997 | 11 | if (isym.n_numaux == 0) | 998 | 5 | aux.x_scn.x_comdat = 0; | 999 | 6 | else | 1000 | 6 | { | 1001 | | /* PR 17512: file: e2cfe54f. */ | 1002 | 6 | if (esym + bfd_coff_symesz (abfd) >= esymend) | 1003 | 3 | { | 1004 | | /* xgettext:c-format */ | 1005 | 3 | _bfd_error_handler (_("%pB: warning: no symbol for" | 1006 | 3 | " section '%s' found"), | 1007 | 3 | abfd, symname); | 1008 | 3 | break; | 1009 | 3 | } | 1010 | 3 | bfd_coff_swap_aux_in (abfd, esym + bfd_coff_symesz (abfd), | 1011 | 3 | isym.n_type, isym.n_sclass, | 1012 | 3 | 0, isym.n_numaux, &aux); | 1013 | 3 | } | 1014 | | | 1015 | | /* FIXME: Microsoft uses NODUPLICATES and | 1016 | | ASSOCIATIVE, but gnu uses ANY and | 1017 | | SAME_SIZE. Unfortunately, gnu doesn't do | 1018 | | the comdat symbols right. So, until we can | 1019 | | fix it to do the right thing, we are | 1020 | | temporarily disabling comdats for the MS | 1021 | | types (they're used in DLLs and C++, but we | 1022 | | don't support *their* C++ libraries anyway | 1023 | | - DJ. */ | 1024 | | | 1025 | | /* Cygwin does not follow the MS style, and | 1026 | | uses ANY and SAME_SIZE where NODUPLICATES | 1027 | | and ASSOCIATIVE should be used. For | 1028 | | Interix, we just do the right thing up | 1029 | | front. */ | 1030 | | | 1031 | 8 | switch (aux.x_scn.x_comdat) | 1032 | 8 | { | 1033 | 0 | case IMAGE_COMDAT_SELECT_NODUPLICATES: | 1034 | | #ifdef STRICT_PE_FORMAT | 1035 | | *sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY; | 1036 | | #else | 1037 | 0 | *sec_flags &= ~SEC_LINK_ONCE; | 1038 | 0 | #endif | 1039 | 0 | break; | 1040 | | | 1041 | 0 | case IMAGE_COMDAT_SELECT_ANY: | 1042 | 0 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1043 | 0 | break; | 1044 | | | 1045 | 0 | case IMAGE_COMDAT_SELECT_SAME_SIZE: | 1046 | 0 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE; | 1047 | 0 | break; | 1048 | | | 1049 | 0 | case IMAGE_COMDAT_SELECT_EXACT_MATCH: | 1050 | | /* Not yet fully implemented ??? */ | 1051 | 0 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS; | 1052 | 0 | break; | 1053 | | | 1054 | | /* debug$S gets this case; other | 1055 | | implications ??? */ | 1056 | | | 1057 | | /* There may be no symbol... we'll search | 1058 | | the whole table... Is this the right | 1059 | | place to play this game? Or should we do | 1060 | | it when reading it in. */ | 1061 | 0 | case IMAGE_COMDAT_SELECT_ASSOCIATIVE: | 1062 | | #ifdef STRICT_PE_FORMAT | 1063 | | /* FIXME: This is not currently implemented. */ | 1064 | | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1065 | | #else | 1066 | 0 | *sec_flags &= ~SEC_LINK_ONCE; | 1067 | 0 | #endif | 1068 | 0 | break; | 1069 | | | 1070 | 8 | default: /* 0 means "no symbol" */ | 1071 | | /* debug$F gets this case; other | 1072 | | implications ??? */ | 1073 | 8 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1074 | 8 | break; | 1075 | 8 | } | 1076 | 8 | } | 1077 | 8 | break; | 1078 | | | 1079 | 8 | case 2: | 1080 | | /* Gas mode: the first matching on partial name. */ | 1081 | |
| 1082 | | #ifndef TARGET_UNDERSCORE | 1083 | | #define TARGET_UNDERSCORE 0 | 1084 | | #endif | 1085 | | /* Is this the name we're looking for ? */ | 1086 | 0 | if (strcmp (target_name, | 1087 | 0 | symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0) | 1088 | 0 | { | 1089 | | /* Not the name we're looking for */ | 1090 | 0 | continue; | 1091 | 0 | } | 1092 | | /* Fall through. */ | 1093 | 3 | case 1: | 1094 | | /* MSVC mode: the lexically second symbol (or | 1095 | | drop through from the above). */ | 1096 | 3 | { | 1097 | | /* This must the second symbol with the | 1098 | | section #. It is the actual symbol name. | 1099 | | Intel puts the two adjacent, but Alpha (at | 1100 | | least) spreads them out. */ | 1101 | | | 1102 | 3 | struct coff_comdat_info *comdat; | 1103 | 3 | size_t len = strlen (symname) + 1; | 1104 | | | 1105 | 3 | comdat = bfd_alloc (abfd, sizeof (*comdat) + len); | 1106 | 3 | if (comdat == NULL) | 1107 | 0 | return false; | 1108 | | | 1109 | 3 | coff_section_data (abfd, section)->comdat = comdat; | 1110 | 3 | comdat->symbol = (esym - esymstart) / bfd_coff_symesz (abfd); | 1111 | 3 | char *newname = (char *) (comdat + 1); | 1112 | 3 | comdat->name = newname; | 1113 | 3 | memcpy (newname, symname, len); | 1114 | 3 | return true; | 1115 | 3 | } | 1116 | 17 | } | 1117 | 17 | } | 1118 | 40.6k | } | 1119 | | | 1120 | 232 | return true; | 1121 | 239 | } |
pei-aarch64.c:handle_COMDAT Line | Count | Source | 861 | 86 | { | 862 | 86 | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 863 | 86 | bfd_byte *esymstart, *esym, *esymend; | 864 | 86 | int seen_state = 0; | 865 | 86 | char *target_name = NULL; | 866 | | | 867 | 86 | *sec_flags |= SEC_LINK_ONCE; | 868 | | | 869 | | /* Unfortunately, the PE format stores essential information in | 870 | | the symbol table, of all places. We need to extract that | 871 | | information now, so that objdump and the linker will know how | 872 | | to handle the section without worrying about the symbols. We | 873 | | can't call slurp_symtab, because the linker doesn't want the | 874 | | swapped symbols. */ | 875 | | | 876 | | /* COMDAT sections are special. The first symbol is the section | 877 | | symbol, which tells what kind of COMDAT section it is. The | 878 | | second symbol is the "comdat symbol" - the one with the | 879 | | unique name. GNU uses the section symbol for the unique | 880 | | name; MS uses ".text" for every comdat section. Sigh. - DJ */ | 881 | | | 882 | | /* This is not mirrored in sec_to_styp_flags(), but there | 883 | | doesn't seem to be a need to, either, and it would at best be | 884 | | rather messy. */ | 885 | | | 886 | 86 | if (! _bfd_coff_get_external_symbols (abfd)) | 887 | 33 | return true; | 888 | | | 889 | 53 | esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd); | 890 | 53 | esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd); | 891 | | | 892 | 53 | for (struct internal_syment isym; | 893 | 826 | esym < esymend; | 894 | 773 | esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd)) | 895 | 780 | { | 896 | 780 | char buf[SYMNMLEN + 1]; | 897 | 780 | const char *symname; | 898 | | | 899 | 780 | bfd_coff_swap_sym_in (abfd, esym, &isym); | 900 | | | 901 | 780 | BFD_ASSERT (sizeof (internal_s->s_name) <= SYMNMLEN); | 902 | | | 903 | 780 | if (isym.n_scnum == section->target_index) | 904 | 14 | { | 905 | | /* According to the MSVC documentation, the first | 906 | | TWO entries with the section # are both of | 907 | | interest to us. The first one is the "section | 908 | | symbol" (section name). The second is the comdat | 909 | | symbol name. Here, we've found the first | 910 | | qualifying entry; we distinguish it from the | 911 | | second with a state flag. | 912 | | | 913 | | In the case of gas-generated (at least until that | 914 | | is fixed) .o files, it isn't necessarily the | 915 | | second one. It may be some other later symbol. | 916 | | | 917 | | Since gas also doesn't follow MS conventions and | 918 | | emits the section similar to .text$<name>, where | 919 | | <something> is the name we're looking for, we | 920 | | distinguish the two as follows: | 921 | | | 922 | | If the section name is simply a section name (no | 923 | | $) we presume it's MS-generated, and look at | 924 | | precisely the second symbol for the comdat name. | 925 | | If the section name has a $, we assume it's | 926 | | gas-generated, and look for <something> (whatever | 927 | | follows the $) as the comdat symbol. */ | 928 | | | 929 | | /* All 3 branches use this. */ | 930 | 14 | symname = _bfd_coff_internal_syment_name (abfd, &isym, buf); | 931 | | | 932 | | /* PR 17512 file: 078-11867-0.004 */ | 933 | 14 | if (symname == NULL) | 934 | 1 | { | 935 | 1 | _bfd_error_handler (_("%pB: unable to load COMDAT section name"), | 936 | 1 | abfd); | 937 | 1 | return false; | 938 | 1 | } | 939 | | | 940 | 13 | switch (seen_state) | 941 | 13 | { | 942 | 11 | case 0: | 943 | 11 | { | 944 | | /* The first time we've seen the symbol. */ | 945 | 11 | union internal_auxent aux; | 946 | | | 947 | | /* If it isn't the stuff we're expecting, die; | 948 | | The MS documentation is vague, but it | 949 | | appears that the second entry serves BOTH | 950 | | as the comdat symbol and the defining | 951 | | symbol record (either C_STAT or C_EXT, | 952 | | possibly with an aux entry with debug | 953 | | information if it's a function.) It | 954 | | appears the only way to find the second one | 955 | | is to count. (On Intel, they appear to be | 956 | | adjacent, but on Alpha, they have been | 957 | | found separated.) | 958 | | | 959 | | Here, we think we've found the first one, | 960 | | but there's some checking we can do to be | 961 | | sure. */ | 962 | | | 963 | 11 | if (! ((isym.n_sclass == C_STAT | 964 | 11 | || isym.n_sclass == C_EXT) | 965 | 11 | && BTYPE (isym.n_type) == T_NULL | 966 | 11 | && isym.n_value == 0)) | 967 | 4 | { | 968 | | /* Malformed input files can trigger this test. | 969 | | cf PR 21781. */ | 970 | 4 | _bfd_error_handler (_("%pB: error: unexpected symbol '%s' in COMDAT section"), | 971 | 4 | abfd, symname); | 972 | 4 | return false; | 973 | 4 | } | 974 | | | 975 | | /* FIXME LATER: MSVC generates section names | 976 | | like .text for comdats. Gas generates | 977 | | names like .text$foo__Fv (in the case of a | 978 | | function). See comment above for more. */ | 979 | | | 980 | 7 | if (isym.n_sclass == C_STAT && strcmp (name, symname) != 0) | 981 | | /* xgettext:c-format */ | 982 | 1 | _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'" | 983 | 1 | " does not match section name '%s'"), | 984 | 1 | abfd, symname, name); | 985 | | | 986 | | /* This is the section symbol. */ | 987 | 7 | seen_state = 1; | 988 | 7 | target_name = strchr (name, '$'); | 989 | 7 | if (target_name != NULL) | 990 | 0 | { | 991 | | /* Gas mode. */ | 992 | 0 | seen_state = 2; | 993 | | /* Skip the `$'. */ | 994 | 0 | target_name += 1; | 995 | 0 | } | 996 | | | 997 | 7 | if (isym.n_numaux == 0) | 998 | 4 | aux.x_scn.x_comdat = 0; | 999 | 3 | else | 1000 | 3 | { | 1001 | | /* PR 17512: file: e2cfe54f. */ | 1002 | 3 | if (esym + bfd_coff_symesz (abfd) >= esymend) | 1003 | 0 | { | 1004 | | /* xgettext:c-format */ | 1005 | 0 | _bfd_error_handler (_("%pB: warning: no symbol for" | 1006 | 0 | " section '%s' found"), | 1007 | 0 | abfd, symname); | 1008 | 0 | break; | 1009 | 0 | } | 1010 | 3 | bfd_coff_swap_aux_in (abfd, esym + bfd_coff_symesz (abfd), | 1011 | 3 | isym.n_type, isym.n_sclass, | 1012 | 3 | 0, isym.n_numaux, &aux); | 1013 | 3 | } | 1014 | | | 1015 | | /* FIXME: Microsoft uses NODUPLICATES and | 1016 | | ASSOCIATIVE, but gnu uses ANY and | 1017 | | SAME_SIZE. Unfortunately, gnu doesn't do | 1018 | | the comdat symbols right. So, until we can | 1019 | | fix it to do the right thing, we are | 1020 | | temporarily disabling comdats for the MS | 1021 | | types (they're used in DLLs and C++, but we | 1022 | | don't support *their* C++ libraries anyway | 1023 | | - DJ. */ | 1024 | | | 1025 | | /* Cygwin does not follow the MS style, and | 1026 | | uses ANY and SAME_SIZE where NODUPLICATES | 1027 | | and ASSOCIATIVE should be used. For | 1028 | | Interix, we just do the right thing up | 1029 | | front. */ | 1030 | | | 1031 | 7 | switch (aux.x_scn.x_comdat) | 1032 | 7 | { | 1033 | 0 | case IMAGE_COMDAT_SELECT_NODUPLICATES: | 1034 | | #ifdef STRICT_PE_FORMAT | 1035 | | *sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY; | 1036 | | #else | 1037 | 0 | *sec_flags &= ~SEC_LINK_ONCE; | 1038 | 0 | #endif | 1039 | 0 | break; | 1040 | | | 1041 | 0 | case IMAGE_COMDAT_SELECT_ANY: | 1042 | 0 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1043 | 0 | break; | 1044 | | | 1045 | 1 | case IMAGE_COMDAT_SELECT_SAME_SIZE: | 1046 | 1 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE; | 1047 | 1 | break; | 1048 | | | 1049 | 1 | case IMAGE_COMDAT_SELECT_EXACT_MATCH: | 1050 | | /* Not yet fully implemented ??? */ | 1051 | 1 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS; | 1052 | 1 | break; | 1053 | | | 1054 | | /* debug$S gets this case; other | 1055 | | implications ??? */ | 1056 | | | 1057 | | /* There may be no symbol... we'll search | 1058 | | the whole table... Is this the right | 1059 | | place to play this game? Or should we do | 1060 | | it when reading it in. */ | 1061 | 1 | case IMAGE_COMDAT_SELECT_ASSOCIATIVE: | 1062 | | #ifdef STRICT_PE_FORMAT | 1063 | | /* FIXME: This is not currently implemented. */ | 1064 | | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1065 | | #else | 1066 | 1 | *sec_flags &= ~SEC_LINK_ONCE; | 1067 | 1 | #endif | 1068 | 1 | break; | 1069 | | | 1070 | 4 | default: /* 0 means "no symbol" */ | 1071 | | /* debug$F gets this case; other | 1072 | | implications ??? */ | 1073 | 4 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1074 | 4 | break; | 1075 | 7 | } | 1076 | 7 | } | 1077 | 7 | break; | 1078 | | | 1079 | 7 | case 2: | 1080 | | /* Gas mode: the first matching on partial name. */ | 1081 | |
| 1082 | 0 | #ifndef TARGET_UNDERSCORE | 1083 | 0 | #define TARGET_UNDERSCORE 0 | 1084 | 0 | #endif | 1085 | | /* Is this the name we're looking for ? */ | 1086 | 0 | if (strcmp (target_name, | 1087 | 0 | symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0) | 1088 | 0 | { | 1089 | | /* Not the name we're looking for */ | 1090 | 0 | continue; | 1091 | 0 | } | 1092 | | /* Fall through. */ | 1093 | 2 | case 1: | 1094 | | /* MSVC mode: the lexically second symbol (or | 1095 | | drop through from the above). */ | 1096 | 2 | { | 1097 | | /* This must the second symbol with the | 1098 | | section #. It is the actual symbol name. | 1099 | | Intel puts the two adjacent, but Alpha (at | 1100 | | least) spreads them out. */ | 1101 | | | 1102 | 2 | struct coff_comdat_info *comdat; | 1103 | 2 | size_t len = strlen (symname) + 1; | 1104 | | | 1105 | 2 | comdat = bfd_alloc (abfd, sizeof (*comdat) + len); | 1106 | 2 | if (comdat == NULL) | 1107 | 0 | return false; | 1108 | | | 1109 | 2 | coff_section_data (abfd, section)->comdat = comdat; | 1110 | 2 | comdat->symbol = (esym - esymstart) / bfd_coff_symesz (abfd); | 1111 | 2 | char *newname = (char *) (comdat + 1); | 1112 | 2 | comdat->name = newname; | 1113 | 2 | memcpy (newname, symname, len); | 1114 | 2 | return true; | 1115 | 2 | } | 1116 | 13 | } | 1117 | 13 | } | 1118 | 780 | } | 1119 | | | 1120 | 46 | return true; | 1121 | 53 | } |
pe-aarch64.c:handle_COMDAT Line | Count | Source | 861 | 136 | { | 862 | 136 | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 863 | 136 | bfd_byte *esymstart, *esym, *esymend; | 864 | 136 | int seen_state = 0; | 865 | 136 | char *target_name = NULL; | 866 | | | 867 | 136 | *sec_flags |= SEC_LINK_ONCE; | 868 | | | 869 | | /* Unfortunately, the PE format stores essential information in | 870 | | the symbol table, of all places. We need to extract that | 871 | | information now, so that objdump and the linker will know how | 872 | | to handle the section without worrying about the symbols. We | 873 | | can't call slurp_symtab, because the linker doesn't want the | 874 | | swapped symbols. */ | 875 | | | 876 | | /* COMDAT sections are special. The first symbol is the section | 877 | | symbol, which tells what kind of COMDAT section it is. The | 878 | | second symbol is the "comdat symbol" - the one with the | 879 | | unique name. GNU uses the section symbol for the unique | 880 | | name; MS uses ".text" for every comdat section. Sigh. - DJ */ | 881 | | | 882 | | /* This is not mirrored in sec_to_styp_flags(), but there | 883 | | doesn't seem to be a need to, either, and it would at best be | 884 | | rather messy. */ | 885 | | | 886 | 136 | if (! _bfd_coff_get_external_symbols (abfd)) | 887 | 38 | return true; | 888 | | | 889 | 98 | esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd); | 890 | 98 | esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd); | 891 | | | 892 | 98 | for (struct internal_syment isym; | 893 | 2.07k | esym < esymend; | 894 | 1.98k | esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd)) | 895 | 1.98k | { | 896 | 1.98k | char buf[SYMNMLEN + 1]; | 897 | 1.98k | const char *symname; | 898 | | | 899 | 1.98k | bfd_coff_swap_sym_in (abfd, esym, &isym); | 900 | | | 901 | 1.98k | BFD_ASSERT (sizeof (internal_s->s_name) <= SYMNMLEN); | 902 | | | 903 | 1.98k | if (isym.n_scnum == section->target_index) | 904 | 35 | { | 905 | | /* According to the MSVC documentation, the first | 906 | | TWO entries with the section # are both of | 907 | | interest to us. The first one is the "section | 908 | | symbol" (section name). The second is the comdat | 909 | | symbol name. Here, we've found the first | 910 | | qualifying entry; we distinguish it from the | 911 | | second with a state flag. | 912 | | | 913 | | In the case of gas-generated (at least until that | 914 | | is fixed) .o files, it isn't necessarily the | 915 | | second one. It may be some other later symbol. | 916 | | | 917 | | Since gas also doesn't follow MS conventions and | 918 | | emits the section similar to .text$<name>, where | 919 | | <something> is the name we're looking for, we | 920 | | distinguish the two as follows: | 921 | | | 922 | | If the section name is simply a section name (no | 923 | | $) we presume it's MS-generated, and look at | 924 | | precisely the second symbol for the comdat name. | 925 | | If the section name has a $, we assume it's | 926 | | gas-generated, and look for <something> (whatever | 927 | | follows the $) as the comdat symbol. */ | 928 | | | 929 | | /* All 3 branches use this. */ | 930 | 35 | symname = _bfd_coff_internal_syment_name (abfd, &isym, buf); | 931 | | | 932 | | /* PR 17512 file: 078-11867-0.004 */ | 933 | 35 | if (symname == NULL) | 934 | 3 | { | 935 | 3 | _bfd_error_handler (_("%pB: unable to load COMDAT section name"), | 936 | 3 | abfd); | 937 | 3 | return false; | 938 | 3 | } | 939 | | | 940 | 32 | switch (seen_state) | 941 | 32 | { | 942 | 20 | case 0: | 943 | 20 | { | 944 | | /* The first time we've seen the symbol. */ | 945 | 20 | union internal_auxent aux; | 946 | | | 947 | | /* If it isn't the stuff we're expecting, die; | 948 | | The MS documentation is vague, but it | 949 | | appears that the second entry serves BOTH | 950 | | as the comdat symbol and the defining | 951 | | symbol record (either C_STAT or C_EXT, | 952 | | possibly with an aux entry with debug | 953 | | information if it's a function.) It | 954 | | appears the only way to find the second one | 955 | | is to count. (On Intel, they appear to be | 956 | | adjacent, but on Alpha, they have been | 957 | | found separated.) | 958 | | | 959 | | Here, we think we've found the first one, | 960 | | but there's some checking we can do to be | 961 | | sure. */ | 962 | | | 963 | 20 | if (! ((isym.n_sclass == C_STAT | 964 | 20 | || isym.n_sclass == C_EXT) | 965 | 20 | && BTYPE (isym.n_type) == T_NULL | 966 | 20 | && isym.n_value == 0)) | 967 | 4 | { | 968 | | /* Malformed input files can trigger this test. | 969 | | cf PR 21781. */ | 970 | 4 | _bfd_error_handler (_("%pB: error: unexpected symbol '%s' in COMDAT section"), | 971 | 4 | abfd, symname); | 972 | 4 | return false; | 973 | 4 | } | 974 | | | 975 | | /* FIXME LATER: MSVC generates section names | 976 | | like .text for comdats. Gas generates | 977 | | names like .text$foo__Fv (in the case of a | 978 | | function). See comment above for more. */ | 979 | | | 980 | 16 | if (isym.n_sclass == C_STAT && strcmp (name, symname) != 0) | 981 | | /* xgettext:c-format */ | 982 | 9 | _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'" | 983 | 9 | " does not match section name '%s'"), | 984 | 9 | abfd, symname, name); | 985 | | | 986 | | /* This is the section symbol. */ | 987 | 16 | seen_state = 1; | 988 | 16 | target_name = strchr (name, '$'); | 989 | 16 | if (target_name != NULL) | 990 | 6 | { | 991 | | /* Gas mode. */ | 992 | 6 | seen_state = 2; | 993 | | /* Skip the `$'. */ | 994 | 6 | target_name += 1; | 995 | 6 | } | 996 | | | 997 | 16 | if (isym.n_numaux == 0) | 998 | 10 | aux.x_scn.x_comdat = 0; | 999 | 6 | else | 1000 | 6 | { | 1001 | | /* PR 17512: file: e2cfe54f. */ | 1002 | 6 | if (esym + bfd_coff_symesz (abfd) >= esymend) | 1003 | 1 | { | 1004 | | /* xgettext:c-format */ | 1005 | 1 | _bfd_error_handler (_("%pB: warning: no symbol for" | 1006 | 1 | " section '%s' found"), | 1007 | 1 | abfd, symname); | 1008 | 1 | break; | 1009 | 1 | } | 1010 | 5 | bfd_coff_swap_aux_in (abfd, esym + bfd_coff_symesz (abfd), | 1011 | 5 | isym.n_type, isym.n_sclass, | 1012 | 5 | 0, isym.n_numaux, &aux); | 1013 | 5 | } | 1014 | | | 1015 | | /* FIXME: Microsoft uses NODUPLICATES and | 1016 | | ASSOCIATIVE, but gnu uses ANY and | 1017 | | SAME_SIZE. Unfortunately, gnu doesn't do | 1018 | | the comdat symbols right. So, until we can | 1019 | | fix it to do the right thing, we are | 1020 | | temporarily disabling comdats for the MS | 1021 | | types (they're used in DLLs and C++, but we | 1022 | | don't support *their* C++ libraries anyway | 1023 | | - DJ. */ | 1024 | | | 1025 | | /* Cygwin does not follow the MS style, and | 1026 | | uses ANY and SAME_SIZE where NODUPLICATES | 1027 | | and ASSOCIATIVE should be used. For | 1028 | | Interix, we just do the right thing up | 1029 | | front. */ | 1030 | | | 1031 | 15 | switch (aux.x_scn.x_comdat) | 1032 | 15 | { | 1033 | 1 | case IMAGE_COMDAT_SELECT_NODUPLICATES: | 1034 | | #ifdef STRICT_PE_FORMAT | 1035 | | *sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY; | 1036 | | #else | 1037 | 1 | *sec_flags &= ~SEC_LINK_ONCE; | 1038 | 1 | #endif | 1039 | 1 | break; | 1040 | | | 1041 | 0 | case IMAGE_COMDAT_SELECT_ANY: | 1042 | 0 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1043 | 0 | break; | 1044 | | | 1045 | 1 | case IMAGE_COMDAT_SELECT_SAME_SIZE: | 1046 | 1 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE; | 1047 | 1 | break; | 1048 | | | 1049 | 1 | case IMAGE_COMDAT_SELECT_EXACT_MATCH: | 1050 | | /* Not yet fully implemented ??? */ | 1051 | 1 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS; | 1052 | 1 | break; | 1053 | | | 1054 | | /* debug$S gets this case; other | 1055 | | implications ??? */ | 1056 | | | 1057 | | /* There may be no symbol... we'll search | 1058 | | the whole table... Is this the right | 1059 | | place to play this game? Or should we do | 1060 | | it when reading it in. */ | 1061 | 1 | case IMAGE_COMDAT_SELECT_ASSOCIATIVE: | 1062 | | #ifdef STRICT_PE_FORMAT | 1063 | | /* FIXME: This is not currently implemented. */ | 1064 | | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1065 | | #else | 1066 | 1 | *sec_flags &= ~SEC_LINK_ONCE; | 1067 | 1 | #endif | 1068 | 1 | break; | 1069 | | | 1070 | 11 | default: /* 0 means "no symbol" */ | 1071 | | /* debug$F gets this case; other | 1072 | | implications ??? */ | 1073 | 11 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1074 | 11 | break; | 1075 | 15 | } | 1076 | 15 | } | 1077 | 15 | break; | 1078 | | | 1079 | 15 | case 2: | 1080 | | /* Gas mode: the first matching on partial name. */ | 1081 | | | 1082 | 11 | #ifndef TARGET_UNDERSCORE | 1083 | 11 | #define TARGET_UNDERSCORE 0 | 1084 | 11 | #endif | 1085 | | /* Is this the name we're looking for ? */ | 1086 | 11 | if (strcmp (target_name, | 1087 | 11 | symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0) | 1088 | 10 | { | 1089 | | /* Not the name we're looking for */ | 1090 | 10 | continue; | 1091 | 10 | } | 1092 | | /* Fall through. */ | 1093 | 2 | case 1: | 1094 | | /* MSVC mode: the lexically second symbol (or | 1095 | | drop through from the above). */ | 1096 | 2 | { | 1097 | | /* This must the second symbol with the | 1098 | | section #. It is the actual symbol name. | 1099 | | Intel puts the two adjacent, but Alpha (at | 1100 | | least) spreads them out. */ | 1101 | | | 1102 | 2 | struct coff_comdat_info *comdat; | 1103 | 2 | size_t len = strlen (symname) + 1; | 1104 | | | 1105 | 2 | comdat = bfd_alloc (abfd, sizeof (*comdat) + len); | 1106 | 2 | if (comdat == NULL) | 1107 | 0 | return false; | 1108 | | | 1109 | 2 | coff_section_data (abfd, section)->comdat = comdat; | 1110 | 2 | comdat->symbol = (esym - esymstart) / bfd_coff_symesz (abfd); | 1111 | 2 | char *newname = (char *) (comdat + 1); | 1112 | 2 | comdat->name = newname; | 1113 | 2 | memcpy (newname, symname, len); | 1114 | 2 | return true; | 1115 | 2 | } | 1116 | 32 | } | 1117 | 32 | } | 1118 | 1.98k | } | 1119 | | | 1120 | 89 | return true; | 1121 | 98 | } |
Line | Count | Source | 861 | 196 | { | 862 | 196 | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 863 | 196 | bfd_byte *esymstart, *esym, *esymend; | 864 | 196 | int seen_state = 0; | 865 | 196 | char *target_name = NULL; | 866 | | | 867 | 196 | *sec_flags |= SEC_LINK_ONCE; | 868 | | | 869 | | /* Unfortunately, the PE format stores essential information in | 870 | | the symbol table, of all places. We need to extract that | 871 | | information now, so that objdump and the linker will know how | 872 | | to handle the section without worrying about the symbols. We | 873 | | can't call slurp_symtab, because the linker doesn't want the | 874 | | swapped symbols. */ | 875 | | | 876 | | /* COMDAT sections are special. The first symbol is the section | 877 | | symbol, which tells what kind of COMDAT section it is. The | 878 | | second symbol is the "comdat symbol" - the one with the | 879 | | unique name. GNU uses the section symbol for the unique | 880 | | name; MS uses ".text" for every comdat section. Sigh. - DJ */ | 881 | | | 882 | | /* This is not mirrored in sec_to_styp_flags(), but there | 883 | | doesn't seem to be a need to, either, and it would at best be | 884 | | rather messy. */ | 885 | | | 886 | 196 | if (! _bfd_coff_get_external_symbols (abfd)) | 887 | 48 | return true; | 888 | | | 889 | 148 | esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd); | 890 | 148 | esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd); | 891 | | | 892 | 148 | for (struct internal_syment isym; | 893 | 11.7k | esym < esymend; | 894 | 11.6k | esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd)) | 895 | 11.6k | { | 896 | 11.6k | char buf[SYMNMLEN + 1]; | 897 | 11.6k | const char *symname; | 898 | | | 899 | 11.6k | bfd_coff_swap_sym_in (abfd, esym, &isym); | 900 | | | 901 | 11.6k | BFD_ASSERT (sizeof (internal_s->s_name) <= SYMNMLEN); | 902 | | | 903 | 11.6k | if (isym.n_scnum == section->target_index) | 904 | 44 | { | 905 | | /* According to the MSVC documentation, the first | 906 | | TWO entries with the section # are both of | 907 | | interest to us. The first one is the "section | 908 | | symbol" (section name). The second is the comdat | 909 | | symbol name. Here, we've found the first | 910 | | qualifying entry; we distinguish it from the | 911 | | second with a state flag. | 912 | | | 913 | | In the case of gas-generated (at least until that | 914 | | is fixed) .o files, it isn't necessarily the | 915 | | second one. It may be some other later symbol. | 916 | | | 917 | | Since gas also doesn't follow MS conventions and | 918 | | emits the section similar to .text$<name>, where | 919 | | <something> is the name we're looking for, we | 920 | | distinguish the two as follows: | 921 | | | 922 | | If the section name is simply a section name (no | 923 | | $) we presume it's MS-generated, and look at | 924 | | precisely the second symbol for the comdat name. | 925 | | If the section name has a $, we assume it's | 926 | | gas-generated, and look for <something> (whatever | 927 | | follows the $) as the comdat symbol. */ | 928 | | | 929 | | /* All 3 branches use this. */ | 930 | 44 | symname = _bfd_coff_internal_syment_name (abfd, &isym, buf); | 931 | | | 932 | | /* PR 17512 file: 078-11867-0.004 */ | 933 | 44 | if (symname == NULL) | 934 | 1 | { | 935 | 1 | _bfd_error_handler (_("%pB: unable to load COMDAT section name"), | 936 | 1 | abfd); | 937 | 1 | return false; | 938 | 1 | } | 939 | | | 940 | 43 | switch (seen_state) | 941 | 43 | { | 942 | 31 | case 0: | 943 | 31 | { | 944 | | /* The first time we've seen the symbol. */ | 945 | 31 | union internal_auxent aux; | 946 | | | 947 | | /* If it isn't the stuff we're expecting, die; | 948 | | The MS documentation is vague, but it | 949 | | appears that the second entry serves BOTH | 950 | | as the comdat symbol and the defining | 951 | | symbol record (either C_STAT or C_EXT, | 952 | | possibly with an aux entry with debug | 953 | | information if it's a function.) It | 954 | | appears the only way to find the second one | 955 | | is to count. (On Intel, they appear to be | 956 | | adjacent, but on Alpha, they have been | 957 | | found separated.) | 958 | | | 959 | | Here, we think we've found the first one, | 960 | | but there's some checking we can do to be | 961 | | sure. */ | 962 | | | 963 | 31 | if (! ((isym.n_sclass == C_STAT | 964 | 31 | || isym.n_sclass == C_EXT) | 965 | 31 | && BTYPE (isym.n_type) == T_NULL | 966 | 31 | && isym.n_value == 0)) | 967 | 4 | { | 968 | | /* Malformed input files can trigger this test. | 969 | | cf PR 21781. */ | 970 | 4 | _bfd_error_handler (_("%pB: error: unexpected symbol '%s' in COMDAT section"), | 971 | 4 | abfd, symname); | 972 | 4 | return false; | 973 | 4 | } | 974 | | | 975 | | /* FIXME LATER: MSVC generates section names | 976 | | like .text for comdats. Gas generates | 977 | | names like .text$foo__Fv (in the case of a | 978 | | function). See comment above for more. */ | 979 | | | 980 | 27 | if (isym.n_sclass == C_STAT && strcmp (name, symname) != 0) | 981 | | /* xgettext:c-format */ | 982 | 12 | _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'" | 983 | 12 | " does not match section name '%s'"), | 984 | 12 | abfd, symname, name); | 985 | | | 986 | | /* This is the section symbol. */ | 987 | 27 | seen_state = 1; | 988 | 27 | target_name = strchr (name, '$'); | 989 | 27 | if (target_name != NULL) | 990 | 5 | { | 991 | | /* Gas mode. */ | 992 | 5 | seen_state = 2; | 993 | | /* Skip the `$'. */ | 994 | 5 | target_name += 1; | 995 | 5 | } | 996 | | | 997 | 27 | if (isym.n_numaux == 0) | 998 | 13 | aux.x_scn.x_comdat = 0; | 999 | 14 | else | 1000 | 14 | { | 1001 | | /* PR 17512: file: e2cfe54f. */ | 1002 | 14 | if (esym + bfd_coff_symesz (abfd) >= esymend) | 1003 | 1 | { | 1004 | | /* xgettext:c-format */ | 1005 | 1 | _bfd_error_handler (_("%pB: warning: no symbol for" | 1006 | 1 | " section '%s' found"), | 1007 | 1 | abfd, symname); | 1008 | 1 | break; | 1009 | 1 | } | 1010 | 13 | bfd_coff_swap_aux_in (abfd, esym + bfd_coff_symesz (abfd), | 1011 | 13 | isym.n_type, isym.n_sclass, | 1012 | 13 | 0, isym.n_numaux, &aux); | 1013 | 13 | } | 1014 | | | 1015 | | /* FIXME: Microsoft uses NODUPLICATES and | 1016 | | ASSOCIATIVE, but gnu uses ANY and | 1017 | | SAME_SIZE. Unfortunately, gnu doesn't do | 1018 | | the comdat symbols right. So, until we can | 1019 | | fix it to do the right thing, we are | 1020 | | temporarily disabling comdats for the MS | 1021 | | types (they're used in DLLs and C++, but we | 1022 | | don't support *their* C++ libraries anyway | 1023 | | - DJ. */ | 1024 | | | 1025 | | /* Cygwin does not follow the MS style, and | 1026 | | uses ANY and SAME_SIZE where NODUPLICATES | 1027 | | and ASSOCIATIVE should be used. For | 1028 | | Interix, we just do the right thing up | 1029 | | front. */ | 1030 | | | 1031 | 26 | switch (aux.x_scn.x_comdat) | 1032 | 26 | { | 1033 | 1 | case IMAGE_COMDAT_SELECT_NODUPLICATES: | 1034 | | #ifdef STRICT_PE_FORMAT | 1035 | | *sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY; | 1036 | | #else | 1037 | 1 | *sec_flags &= ~SEC_LINK_ONCE; | 1038 | 1 | #endif | 1039 | 1 | break; | 1040 | | | 1041 | 0 | case IMAGE_COMDAT_SELECT_ANY: | 1042 | 0 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1043 | 0 | break; | 1044 | | | 1045 | 1 | case IMAGE_COMDAT_SELECT_SAME_SIZE: | 1046 | 1 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE; | 1047 | 1 | break; | 1048 | | | 1049 | 1 | case IMAGE_COMDAT_SELECT_EXACT_MATCH: | 1050 | | /* Not yet fully implemented ??? */ | 1051 | 1 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS; | 1052 | 1 | break; | 1053 | | | 1054 | | /* debug$S gets this case; other | 1055 | | implications ??? */ | 1056 | | | 1057 | | /* There may be no symbol... we'll search | 1058 | | the whole table... Is this the right | 1059 | | place to play this game? Or should we do | 1060 | | it when reading it in. */ | 1061 | 3 | case IMAGE_COMDAT_SELECT_ASSOCIATIVE: | 1062 | | #ifdef STRICT_PE_FORMAT | 1063 | | /* FIXME: This is not currently implemented. */ | 1064 | | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1065 | | #else | 1066 | 3 | *sec_flags &= ~SEC_LINK_ONCE; | 1067 | 3 | #endif | 1068 | 3 | break; | 1069 | | | 1070 | 20 | default: /* 0 means "no symbol" */ | 1071 | | /* debug$F gets this case; other | 1072 | | implications ??? */ | 1073 | 20 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1074 | 20 | break; | 1075 | 26 | } | 1076 | 26 | } | 1077 | 26 | break; | 1078 | | | 1079 | 26 | case 2: | 1080 | | /* Gas mode: the first matching on partial name. */ | 1081 | | | 1082 | | #ifndef TARGET_UNDERSCORE | 1083 | | #define TARGET_UNDERSCORE 0 | 1084 | | #endif | 1085 | | /* Is this the name we're looking for ? */ | 1086 | 4 | if (strcmp (target_name, | 1087 | 4 | symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0) | 1088 | 3 | { | 1089 | | /* Not the name we're looking for */ | 1090 | 3 | continue; | 1091 | 3 | } | 1092 | | /* Fall through. */ | 1093 | 9 | case 1: | 1094 | | /* MSVC mode: the lexically second symbol (or | 1095 | | drop through from the above). */ | 1096 | 9 | { | 1097 | | /* This must the second symbol with the | 1098 | | section #. It is the actual symbol name. | 1099 | | Intel puts the two adjacent, but Alpha (at | 1100 | | least) spreads them out. */ | 1101 | | | 1102 | 9 | struct coff_comdat_info *comdat; | 1103 | 9 | size_t len = strlen (symname) + 1; | 1104 | | | 1105 | 9 | comdat = bfd_alloc (abfd, sizeof (*comdat) + len); | 1106 | 9 | if (comdat == NULL) | 1107 | 0 | return false; | 1108 | | | 1109 | 9 | coff_section_data (abfd, section)->comdat = comdat; | 1110 | 9 | comdat->symbol = (esym - esymstart) / bfd_coff_symesz (abfd); | 1111 | 9 | char *newname = (char *) (comdat + 1); | 1112 | 9 | comdat->name = newname; | 1113 | 9 | memcpy (newname, symname, len); | 1114 | 9 | return true; | 1115 | 9 | } | 1116 | 43 | } | 1117 | 43 | } | 1118 | 11.6k | } | 1119 | | | 1120 | 134 | return true; | 1121 | 148 | } |
pei-loongarch64.c:handle_COMDAT Line | Count | Source | 861 | 228 | { | 862 | 228 | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 863 | 228 | bfd_byte *esymstart, *esym, *esymend; | 864 | 228 | int seen_state = 0; | 865 | 228 | char *target_name = NULL; | 866 | | | 867 | 228 | *sec_flags |= SEC_LINK_ONCE; | 868 | | | 869 | | /* Unfortunately, the PE format stores essential information in | 870 | | the symbol table, of all places. We need to extract that | 871 | | information now, so that objdump and the linker will know how | 872 | | to handle the section without worrying about the symbols. We | 873 | | can't call slurp_symtab, because the linker doesn't want the | 874 | | swapped symbols. */ | 875 | | | 876 | | /* COMDAT sections are special. The first symbol is the section | 877 | | symbol, which tells what kind of COMDAT section it is. The | 878 | | second symbol is the "comdat symbol" - the one with the | 879 | | unique name. GNU uses the section symbol for the unique | 880 | | name; MS uses ".text" for every comdat section. Sigh. - DJ */ | 881 | | | 882 | | /* This is not mirrored in sec_to_styp_flags(), but there | 883 | | doesn't seem to be a need to, either, and it would at best be | 884 | | rather messy. */ | 885 | | | 886 | 228 | if (! _bfd_coff_get_external_symbols (abfd)) | 887 | 68 | return true; | 888 | | | 889 | 160 | esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd); | 890 | 160 | esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd); | 891 | | | 892 | 160 | for (struct internal_syment isym; | 893 | 41.9k | esym < esymend; | 894 | 41.7k | esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd)) | 895 | 41.8k | { | 896 | 41.8k | char buf[SYMNMLEN + 1]; | 897 | 41.8k | const char *symname; | 898 | | | 899 | 41.8k | bfd_coff_swap_sym_in (abfd, esym, &isym); | 900 | | | 901 | 41.8k | BFD_ASSERT (sizeof (internal_s->s_name) <= SYMNMLEN); | 902 | | | 903 | 41.8k | if (isym.n_scnum == section->target_index) | 904 | 30 | { | 905 | | /* According to the MSVC documentation, the first | 906 | | TWO entries with the section # are both of | 907 | | interest to us. The first one is the "section | 908 | | symbol" (section name). The second is the comdat | 909 | | symbol name. Here, we've found the first | 910 | | qualifying entry; we distinguish it from the | 911 | | second with a state flag. | 912 | | | 913 | | In the case of gas-generated (at least until that | 914 | | is fixed) .o files, it isn't necessarily the | 915 | | second one. It may be some other later symbol. | 916 | | | 917 | | Since gas also doesn't follow MS conventions and | 918 | | emits the section similar to .text$<name>, where | 919 | | <something> is the name we're looking for, we | 920 | | distinguish the two as follows: | 921 | | | 922 | | If the section name is simply a section name (no | 923 | | $) we presume it's MS-generated, and look at | 924 | | precisely the second symbol for the comdat name. | 925 | | If the section name has a $, we assume it's | 926 | | gas-generated, and look for <something> (whatever | 927 | | follows the $) as the comdat symbol. */ | 928 | | | 929 | | /* All 3 branches use this. */ | 930 | 30 | symname = _bfd_coff_internal_syment_name (abfd, &isym, buf); | 931 | | | 932 | | /* PR 17512 file: 078-11867-0.004 */ | 933 | 30 | if (symname == NULL) | 934 | 3 | { | 935 | 3 | _bfd_error_handler (_("%pB: unable to load COMDAT section name"), | 936 | 3 | abfd); | 937 | 3 | return false; | 938 | 3 | } | 939 | | | 940 | 27 | switch (seen_state) | 941 | 27 | { | 942 | 25 | case 0: | 943 | 25 | { | 944 | | /* The first time we've seen the symbol. */ | 945 | 25 | union internal_auxent aux; | 946 | | | 947 | | /* If it isn't the stuff we're expecting, die; | 948 | | The MS documentation is vague, but it | 949 | | appears that the second entry serves BOTH | 950 | | as the comdat symbol and the defining | 951 | | symbol record (either C_STAT or C_EXT, | 952 | | possibly with an aux entry with debug | 953 | | information if it's a function.) It | 954 | | appears the only way to find the second one | 955 | | is to count. (On Intel, they appear to be | 956 | | adjacent, but on Alpha, they have been | 957 | | found separated.) | 958 | | | 959 | | Here, we think we've found the first one, | 960 | | but there's some checking we can do to be | 961 | | sure. */ | 962 | | | 963 | 25 | if (! ((isym.n_sclass == C_STAT | 964 | 25 | || isym.n_sclass == C_EXT) | 965 | 25 | && BTYPE (isym.n_type) == T_NULL | 966 | 25 | && isym.n_value == 0)) | 967 | 8 | { | 968 | | /* Malformed input files can trigger this test. | 969 | | cf PR 21781. */ | 970 | 8 | _bfd_error_handler (_("%pB: error: unexpected symbol '%s' in COMDAT section"), | 971 | 8 | abfd, symname); | 972 | 8 | return false; | 973 | 8 | } | 974 | | | 975 | | /* FIXME LATER: MSVC generates section names | 976 | | like .text for comdats. Gas generates | 977 | | names like .text$foo__Fv (in the case of a | 978 | | function). See comment above for more. */ | 979 | | | 980 | 17 | if (isym.n_sclass == C_STAT && strcmp (name, symname) != 0) | 981 | | /* xgettext:c-format */ | 982 | 5 | _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'" | 983 | 5 | " does not match section name '%s'"), | 984 | 5 | abfd, symname, name); | 985 | | | 986 | | /* This is the section symbol. */ | 987 | 17 | seen_state = 1; | 988 | 17 | target_name = strchr (name, '$'); | 989 | 17 | if (target_name != NULL) | 990 | 0 | { | 991 | | /* Gas mode. */ | 992 | 0 | seen_state = 2; | 993 | | /* Skip the `$'. */ | 994 | 0 | target_name += 1; | 995 | 0 | } | 996 | | | 997 | 17 | if (isym.n_numaux == 0) | 998 | 3 | aux.x_scn.x_comdat = 0; | 999 | 14 | else | 1000 | 14 | { | 1001 | | /* PR 17512: file: e2cfe54f. */ | 1002 | 14 | if (esym + bfd_coff_symesz (abfd) >= esymend) | 1003 | 1 | { | 1004 | | /* xgettext:c-format */ | 1005 | 1 | _bfd_error_handler (_("%pB: warning: no symbol for" | 1006 | 1 | " section '%s' found"), | 1007 | 1 | abfd, symname); | 1008 | 1 | break; | 1009 | 1 | } | 1010 | 13 | bfd_coff_swap_aux_in (abfd, esym + bfd_coff_symesz (abfd), | 1011 | 13 | isym.n_type, isym.n_sclass, | 1012 | 13 | 0, isym.n_numaux, &aux); | 1013 | 13 | } | 1014 | | | 1015 | | /* FIXME: Microsoft uses NODUPLICATES and | 1016 | | ASSOCIATIVE, but gnu uses ANY and | 1017 | | SAME_SIZE. Unfortunately, gnu doesn't do | 1018 | | the comdat symbols right. So, until we can | 1019 | | fix it to do the right thing, we are | 1020 | | temporarily disabling comdats for the MS | 1021 | | types (they're used in DLLs and C++, but we | 1022 | | don't support *their* C++ libraries anyway | 1023 | | - DJ. */ | 1024 | | | 1025 | | /* Cygwin does not follow the MS style, and | 1026 | | uses ANY and SAME_SIZE where NODUPLICATES | 1027 | | and ASSOCIATIVE should be used. For | 1028 | | Interix, we just do the right thing up | 1029 | | front. */ | 1030 | | | 1031 | 16 | switch (aux.x_scn.x_comdat) | 1032 | 16 | { | 1033 | 1 | case IMAGE_COMDAT_SELECT_NODUPLICATES: | 1034 | | #ifdef STRICT_PE_FORMAT | 1035 | | *sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY; | 1036 | | #else | 1037 | 1 | *sec_flags &= ~SEC_LINK_ONCE; | 1038 | 1 | #endif | 1039 | 1 | break; | 1040 | | | 1041 | 0 | case IMAGE_COMDAT_SELECT_ANY: | 1042 | 0 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1043 | 0 | break; | 1044 | | | 1045 | 1 | case IMAGE_COMDAT_SELECT_SAME_SIZE: | 1046 | 1 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE; | 1047 | 1 | break; | 1048 | | | 1049 | 1 | case IMAGE_COMDAT_SELECT_EXACT_MATCH: | 1050 | | /* Not yet fully implemented ??? */ | 1051 | 1 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS; | 1052 | 1 | break; | 1053 | | | 1054 | | /* debug$S gets this case; other | 1055 | | implications ??? */ | 1056 | | | 1057 | | /* There may be no symbol... we'll search | 1058 | | the whole table... Is this the right | 1059 | | place to play this game? Or should we do | 1060 | | it when reading it in. */ | 1061 | 3 | case IMAGE_COMDAT_SELECT_ASSOCIATIVE: | 1062 | | #ifdef STRICT_PE_FORMAT | 1063 | | /* FIXME: This is not currently implemented. */ | 1064 | | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1065 | | #else | 1066 | 3 | *sec_flags &= ~SEC_LINK_ONCE; | 1067 | 3 | #endif | 1068 | 3 | break; | 1069 | | | 1070 | 10 | default: /* 0 means "no symbol" */ | 1071 | | /* debug$F gets this case; other | 1072 | | implications ??? */ | 1073 | 10 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1074 | 10 | break; | 1075 | 16 | } | 1076 | 16 | } | 1077 | 16 | break; | 1078 | | | 1079 | 16 | case 2: | 1080 | | /* Gas mode: the first matching on partial name. */ | 1081 | |
| 1082 | 0 | #ifndef TARGET_UNDERSCORE | 1083 | 0 | #define TARGET_UNDERSCORE 0 | 1084 | 0 | #endif | 1085 | | /* Is this the name we're looking for ? */ | 1086 | 0 | if (strcmp (target_name, | 1087 | 0 | symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0) | 1088 | 0 | { | 1089 | | /* Not the name we're looking for */ | 1090 | 0 | continue; | 1091 | 0 | } | 1092 | | /* Fall through. */ | 1093 | 2 | case 1: | 1094 | | /* MSVC mode: the lexically second symbol (or | 1095 | | drop through from the above). */ | 1096 | 2 | { | 1097 | | /* This must the second symbol with the | 1098 | | section #. It is the actual symbol name. | 1099 | | Intel puts the two adjacent, but Alpha (at | 1100 | | least) spreads them out. */ | 1101 | | | 1102 | 2 | struct coff_comdat_info *comdat; | 1103 | 2 | size_t len = strlen (symname) + 1; | 1104 | | | 1105 | 2 | comdat = bfd_alloc (abfd, sizeof (*comdat) + len); | 1106 | 2 | if (comdat == NULL) | 1107 | 0 | return false; | 1108 | | | 1109 | 2 | coff_section_data (abfd, section)->comdat = comdat; | 1110 | 2 | comdat->symbol = (esym - esymstart) / bfd_coff_symesz (abfd); | 1111 | 2 | char *newname = (char *) (comdat + 1); | 1112 | 2 | comdat->name = newname; | 1113 | 2 | memcpy (newname, symname, len); | 1114 | 2 | return true; | 1115 | 2 | } | 1116 | 27 | } | 1117 | 27 | } | 1118 | 41.8k | } | 1119 | | | 1120 | 147 | return true; | 1121 | 160 | } |
pe-arm-wince.c:handle_COMDAT Line | Count | Source | 861 | 179 | { | 862 | 179 | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 863 | 179 | bfd_byte *esymstart, *esym, *esymend; | 864 | 179 | int seen_state = 0; | 865 | 179 | char *target_name = NULL; | 866 | | | 867 | 179 | *sec_flags |= SEC_LINK_ONCE; | 868 | | | 869 | | /* Unfortunately, the PE format stores essential information in | 870 | | the symbol table, of all places. We need to extract that | 871 | | information now, so that objdump and the linker will know how | 872 | | to handle the section without worrying about the symbols. We | 873 | | can't call slurp_symtab, because the linker doesn't want the | 874 | | swapped symbols. */ | 875 | | | 876 | | /* COMDAT sections are special. The first symbol is the section | 877 | | symbol, which tells what kind of COMDAT section it is. The | 878 | | second symbol is the "comdat symbol" - the one with the | 879 | | unique name. GNU uses the section symbol for the unique | 880 | | name; MS uses ".text" for every comdat section. Sigh. - DJ */ | 881 | | | 882 | | /* This is not mirrored in sec_to_styp_flags(), but there | 883 | | doesn't seem to be a need to, either, and it would at best be | 884 | | rather messy. */ | 885 | | | 886 | 179 | if (! _bfd_coff_get_external_symbols (abfd)) | 887 | 47 | return true; | 888 | | | 889 | 132 | esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd); | 890 | 132 | esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd); | 891 | | | 892 | 132 | for (struct internal_syment isym; | 893 | 6.40k | esym < esymend; | 894 | 6.27k | esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd)) | 895 | 6.28k | { | 896 | 6.28k | char buf[SYMNMLEN + 1]; | 897 | 6.28k | const char *symname; | 898 | | | 899 | 6.28k | bfd_coff_swap_sym_in (abfd, esym, &isym); | 900 | | | 901 | 6.28k | BFD_ASSERT (sizeof (internal_s->s_name) <= SYMNMLEN); | 902 | | | 903 | 6.28k | if (isym.n_scnum == section->target_index) | 904 | 41 | { | 905 | | /* According to the MSVC documentation, the first | 906 | | TWO entries with the section # are both of | 907 | | interest to us. The first one is the "section | 908 | | symbol" (section name). The second is the comdat | 909 | | symbol name. Here, we've found the first | 910 | | qualifying entry; we distinguish it from the | 911 | | second with a state flag. | 912 | | | 913 | | In the case of gas-generated (at least until that | 914 | | is fixed) .o files, it isn't necessarily the | 915 | | second one. It may be some other later symbol. | 916 | | | 917 | | Since gas also doesn't follow MS conventions and | 918 | | emits the section similar to .text$<name>, where | 919 | | <something> is the name we're looking for, we | 920 | | distinguish the two as follows: | 921 | | | 922 | | If the section name is simply a section name (no | 923 | | $) we presume it's MS-generated, and look at | 924 | | precisely the second symbol for the comdat name. | 925 | | If the section name has a $, we assume it's | 926 | | gas-generated, and look for <something> (whatever | 927 | | follows the $) as the comdat symbol. */ | 928 | | | 929 | | /* All 3 branches use this. */ | 930 | 41 | symname = _bfd_coff_internal_syment_name (abfd, &isym, buf); | 931 | | | 932 | | /* PR 17512 file: 078-11867-0.004 */ | 933 | 41 | if (symname == NULL) | 934 | 5 | { | 935 | 5 | _bfd_error_handler (_("%pB: unable to load COMDAT section name"), | 936 | 5 | abfd); | 937 | 5 | return false; | 938 | 5 | } | 939 | | | 940 | 36 | switch (seen_state) | 941 | 36 | { | 942 | 28 | case 0: | 943 | 28 | { | 944 | | /* The first time we've seen the symbol. */ | 945 | 28 | union internal_auxent aux; | 946 | | | 947 | | /* If it isn't the stuff we're expecting, die; | 948 | | The MS documentation is vague, but it | 949 | | appears that the second entry serves BOTH | 950 | | as the comdat symbol and the defining | 951 | | symbol record (either C_STAT or C_EXT, | 952 | | possibly with an aux entry with debug | 953 | | information if it's a function.) It | 954 | | appears the only way to find the second one | 955 | | is to count. (On Intel, they appear to be | 956 | | adjacent, but on Alpha, they have been | 957 | | found separated.) | 958 | | | 959 | | Here, we think we've found the first one, | 960 | | but there's some checking we can do to be | 961 | | sure. */ | 962 | | | 963 | 28 | if (! ((isym.n_sclass == C_STAT | 964 | 28 | || isym.n_sclass == C_EXT) | 965 | 28 | && BTYPE (isym.n_type) == T_NULL | 966 | 28 | && isym.n_value == 0)) | 967 | 5 | { | 968 | | /* Malformed input files can trigger this test. | 969 | | cf PR 21781. */ | 970 | 5 | _bfd_error_handler (_("%pB: error: unexpected symbol '%s' in COMDAT section"), | 971 | 5 | abfd, symname); | 972 | 5 | return false; | 973 | 5 | } | 974 | | | 975 | | /* FIXME LATER: MSVC generates section names | 976 | | like .text for comdats. Gas generates | 977 | | names like .text$foo__Fv (in the case of a | 978 | | function). See comment above for more. */ | 979 | | | 980 | 23 | if (isym.n_sclass == C_STAT && strcmp (name, symname) != 0) | 981 | | /* xgettext:c-format */ | 982 | 16 | _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'" | 983 | 16 | " does not match section name '%s'"), | 984 | 16 | abfd, symname, name); | 985 | | | 986 | | /* This is the section symbol. */ | 987 | 23 | seen_state = 1; | 988 | 23 | target_name = strchr (name, '$'); | 989 | 23 | if (target_name != NULL) | 990 | 6 | { | 991 | | /* Gas mode. */ | 992 | 6 | seen_state = 2; | 993 | | /* Skip the `$'. */ | 994 | 6 | target_name += 1; | 995 | 6 | } | 996 | | | 997 | 23 | if (isym.n_numaux == 0) | 998 | 3 | aux.x_scn.x_comdat = 0; | 999 | 20 | else | 1000 | 20 | { | 1001 | | /* PR 17512: file: e2cfe54f. */ | 1002 | 20 | if (esym + bfd_coff_symesz (abfd) >= esymend) | 1003 | 1 | { | 1004 | | /* xgettext:c-format */ | 1005 | 1 | _bfd_error_handler (_("%pB: warning: no symbol for" | 1006 | 1 | " section '%s' found"), | 1007 | 1 | abfd, symname); | 1008 | 1 | break; | 1009 | 1 | } | 1010 | 19 | bfd_coff_swap_aux_in (abfd, esym + bfd_coff_symesz (abfd), | 1011 | 19 | isym.n_type, isym.n_sclass, | 1012 | 19 | 0, isym.n_numaux, &aux); | 1013 | 19 | } | 1014 | | | 1015 | | /* FIXME: Microsoft uses NODUPLICATES and | 1016 | | ASSOCIATIVE, but gnu uses ANY and | 1017 | | SAME_SIZE. Unfortunately, gnu doesn't do | 1018 | | the comdat symbols right. So, until we can | 1019 | | fix it to do the right thing, we are | 1020 | | temporarily disabling comdats for the MS | 1021 | | types (they're used in DLLs and C++, but we | 1022 | | don't support *their* C++ libraries anyway | 1023 | | - DJ. */ | 1024 | | | 1025 | | /* Cygwin does not follow the MS style, and | 1026 | | uses ANY and SAME_SIZE where NODUPLICATES | 1027 | | and ASSOCIATIVE should be used. For | 1028 | | Interix, we just do the right thing up | 1029 | | front. */ | 1030 | | | 1031 | 22 | switch (aux.x_scn.x_comdat) | 1032 | 22 | { | 1033 | 1 | case IMAGE_COMDAT_SELECT_NODUPLICATES: | 1034 | | #ifdef STRICT_PE_FORMAT | 1035 | | *sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY; | 1036 | | #else | 1037 | 1 | *sec_flags &= ~SEC_LINK_ONCE; | 1038 | 1 | #endif | 1039 | 1 | break; | 1040 | | | 1041 | 0 | case IMAGE_COMDAT_SELECT_ANY: | 1042 | 0 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1043 | 0 | break; | 1044 | | | 1045 | 1 | case IMAGE_COMDAT_SELECT_SAME_SIZE: | 1046 | 1 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE; | 1047 | 1 | break; | 1048 | | | 1049 | 1 | case IMAGE_COMDAT_SELECT_EXACT_MATCH: | 1050 | | /* Not yet fully implemented ??? */ | 1051 | 1 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS; | 1052 | 1 | break; | 1053 | | | 1054 | | /* debug$S gets this case; other | 1055 | | implications ??? */ | 1056 | | | 1057 | | /* There may be no symbol... we'll search | 1058 | | the whole table... Is this the right | 1059 | | place to play this game? Or should we do | 1060 | | it when reading it in. */ | 1061 | 1 | case IMAGE_COMDAT_SELECT_ASSOCIATIVE: | 1062 | | #ifdef STRICT_PE_FORMAT | 1063 | | /* FIXME: This is not currently implemented. */ | 1064 | | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1065 | | #else | 1066 | 1 | *sec_flags &= ~SEC_LINK_ONCE; | 1067 | 1 | #endif | 1068 | 1 | break; | 1069 | | | 1070 | 18 | default: /* 0 means "no symbol" */ | 1071 | | /* debug$F gets this case; other | 1072 | | implications ??? */ | 1073 | 18 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1074 | 18 | break; | 1075 | 22 | } | 1076 | 22 | } | 1077 | 22 | break; | 1078 | | | 1079 | 22 | case 2: | 1080 | | /* Gas mode: the first matching on partial name. */ | 1081 | | | 1082 | | #ifndef TARGET_UNDERSCORE | 1083 | | #define TARGET_UNDERSCORE 0 | 1084 | | #endif | 1085 | | /* Is this the name we're looking for ? */ | 1086 | 7 | if (strcmp (target_name, | 1087 | 7 | symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0) | 1088 | 6 | { | 1089 | | /* Not the name we're looking for */ | 1090 | 6 | continue; | 1091 | 6 | } | 1092 | | /* Fall through. */ | 1093 | 2 | case 1: | 1094 | | /* MSVC mode: the lexically second symbol (or | 1095 | | drop through from the above). */ | 1096 | 2 | { | 1097 | | /* This must the second symbol with the | 1098 | | section #. It is the actual symbol name. | 1099 | | Intel puts the two adjacent, but Alpha (at | 1100 | | least) spreads them out. */ | 1101 | | | 1102 | 2 | struct coff_comdat_info *comdat; | 1103 | 2 | size_t len = strlen (symname) + 1; | 1104 | | | 1105 | 2 | comdat = bfd_alloc (abfd, sizeof (*comdat) + len); | 1106 | 2 | if (comdat == NULL) | 1107 | 0 | return false; | 1108 | | | 1109 | 2 | coff_section_data (abfd, section)->comdat = comdat; | 1110 | 2 | comdat->symbol = (esym - esymstart) / bfd_coff_symesz (abfd); | 1111 | 2 | char *newname = (char *) (comdat + 1); | 1112 | 2 | comdat->name = newname; | 1113 | 2 | memcpy (newname, symname, len); | 1114 | 2 | return true; | 1115 | 2 | } | 1116 | 36 | } | 1117 | 36 | } | 1118 | 6.28k | } | 1119 | | | 1120 | 120 | return true; | 1121 | 132 | } |
Line | Count | Source | 861 | 179 | { | 862 | 179 | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 863 | 179 | bfd_byte *esymstart, *esym, *esymend; | 864 | 179 | int seen_state = 0; | 865 | 179 | char *target_name = NULL; | 866 | | | 867 | 179 | *sec_flags |= SEC_LINK_ONCE; | 868 | | | 869 | | /* Unfortunately, the PE format stores essential information in | 870 | | the symbol table, of all places. We need to extract that | 871 | | information now, so that objdump and the linker will know how | 872 | | to handle the section without worrying about the symbols. We | 873 | | can't call slurp_symtab, because the linker doesn't want the | 874 | | swapped symbols. */ | 875 | | | 876 | | /* COMDAT sections are special. The first symbol is the section | 877 | | symbol, which tells what kind of COMDAT section it is. The | 878 | | second symbol is the "comdat symbol" - the one with the | 879 | | unique name. GNU uses the section symbol for the unique | 880 | | name; MS uses ".text" for every comdat section. Sigh. - DJ */ | 881 | | | 882 | | /* This is not mirrored in sec_to_styp_flags(), but there | 883 | | doesn't seem to be a need to, either, and it would at best be | 884 | | rather messy. */ | 885 | | | 886 | 179 | if (! _bfd_coff_get_external_symbols (abfd)) | 887 | 47 | return true; | 888 | | | 889 | 132 | esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd); | 890 | 132 | esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd); | 891 | | | 892 | 132 | for (struct internal_syment isym; | 893 | 6.40k | esym < esymend; | 894 | 6.27k | esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd)) | 895 | 6.28k | { | 896 | 6.28k | char buf[SYMNMLEN + 1]; | 897 | 6.28k | const char *symname; | 898 | | | 899 | 6.28k | bfd_coff_swap_sym_in (abfd, esym, &isym); | 900 | | | 901 | 6.28k | BFD_ASSERT (sizeof (internal_s->s_name) <= SYMNMLEN); | 902 | | | 903 | 6.28k | if (isym.n_scnum == section->target_index) | 904 | 41 | { | 905 | | /* According to the MSVC documentation, the first | 906 | | TWO entries with the section # are both of | 907 | | interest to us. The first one is the "section | 908 | | symbol" (section name). The second is the comdat | 909 | | symbol name. Here, we've found the first | 910 | | qualifying entry; we distinguish it from the | 911 | | second with a state flag. | 912 | | | 913 | | In the case of gas-generated (at least until that | 914 | | is fixed) .o files, it isn't necessarily the | 915 | | second one. It may be some other later symbol. | 916 | | | 917 | | Since gas also doesn't follow MS conventions and | 918 | | emits the section similar to .text$<name>, where | 919 | | <something> is the name we're looking for, we | 920 | | distinguish the two as follows: | 921 | | | 922 | | If the section name is simply a section name (no | 923 | | $) we presume it's MS-generated, and look at | 924 | | precisely the second symbol for the comdat name. | 925 | | If the section name has a $, we assume it's | 926 | | gas-generated, and look for <something> (whatever | 927 | | follows the $) as the comdat symbol. */ | 928 | | | 929 | | /* All 3 branches use this. */ | 930 | 41 | symname = _bfd_coff_internal_syment_name (abfd, &isym, buf); | 931 | | | 932 | | /* PR 17512 file: 078-11867-0.004 */ | 933 | 41 | if (symname == NULL) | 934 | 5 | { | 935 | 5 | _bfd_error_handler (_("%pB: unable to load COMDAT section name"), | 936 | 5 | abfd); | 937 | 5 | return false; | 938 | 5 | } | 939 | | | 940 | 36 | switch (seen_state) | 941 | 36 | { | 942 | 28 | case 0: | 943 | 28 | { | 944 | | /* The first time we've seen the symbol. */ | 945 | 28 | union internal_auxent aux; | 946 | | | 947 | | /* If it isn't the stuff we're expecting, die; | 948 | | The MS documentation is vague, but it | 949 | | appears that the second entry serves BOTH | 950 | | as the comdat symbol and the defining | 951 | | symbol record (either C_STAT or C_EXT, | 952 | | possibly with an aux entry with debug | 953 | | information if it's a function.) It | 954 | | appears the only way to find the second one | 955 | | is to count. (On Intel, they appear to be | 956 | | adjacent, but on Alpha, they have been | 957 | | found separated.) | 958 | | | 959 | | Here, we think we've found the first one, | 960 | | but there's some checking we can do to be | 961 | | sure. */ | 962 | | | 963 | 28 | if (! ((isym.n_sclass == C_STAT | 964 | 28 | || isym.n_sclass == C_EXT) | 965 | 28 | && BTYPE (isym.n_type) == T_NULL | 966 | 28 | && isym.n_value == 0)) | 967 | 5 | { | 968 | | /* Malformed input files can trigger this test. | 969 | | cf PR 21781. */ | 970 | 5 | _bfd_error_handler (_("%pB: error: unexpected symbol '%s' in COMDAT section"), | 971 | 5 | abfd, symname); | 972 | 5 | return false; | 973 | 5 | } | 974 | | | 975 | | /* FIXME LATER: MSVC generates section names | 976 | | like .text for comdats. Gas generates | 977 | | names like .text$foo__Fv (in the case of a | 978 | | function). See comment above for more. */ | 979 | | | 980 | 23 | if (isym.n_sclass == C_STAT && strcmp (name, symname) != 0) | 981 | | /* xgettext:c-format */ | 982 | 16 | _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'" | 983 | 16 | " does not match section name '%s'"), | 984 | 16 | abfd, symname, name); | 985 | | | 986 | | /* This is the section symbol. */ | 987 | 23 | seen_state = 1; | 988 | 23 | target_name = strchr (name, '$'); | 989 | 23 | if (target_name != NULL) | 990 | 6 | { | 991 | | /* Gas mode. */ | 992 | 6 | seen_state = 2; | 993 | | /* Skip the `$'. */ | 994 | 6 | target_name += 1; | 995 | 6 | } | 996 | | | 997 | 23 | if (isym.n_numaux == 0) | 998 | 3 | aux.x_scn.x_comdat = 0; | 999 | 20 | else | 1000 | 20 | { | 1001 | | /* PR 17512: file: e2cfe54f. */ | 1002 | 20 | if (esym + bfd_coff_symesz (abfd) >= esymend) | 1003 | 1 | { | 1004 | | /* xgettext:c-format */ | 1005 | 1 | _bfd_error_handler (_("%pB: warning: no symbol for" | 1006 | 1 | " section '%s' found"), | 1007 | 1 | abfd, symname); | 1008 | 1 | break; | 1009 | 1 | } | 1010 | 19 | bfd_coff_swap_aux_in (abfd, esym + bfd_coff_symesz (abfd), | 1011 | 19 | isym.n_type, isym.n_sclass, | 1012 | 19 | 0, isym.n_numaux, &aux); | 1013 | 19 | } | 1014 | | | 1015 | | /* FIXME: Microsoft uses NODUPLICATES and | 1016 | | ASSOCIATIVE, but gnu uses ANY and | 1017 | | SAME_SIZE. Unfortunately, gnu doesn't do | 1018 | | the comdat symbols right. So, until we can | 1019 | | fix it to do the right thing, we are | 1020 | | temporarily disabling comdats for the MS | 1021 | | types (they're used in DLLs and C++, but we | 1022 | | don't support *their* C++ libraries anyway | 1023 | | - DJ. */ | 1024 | | | 1025 | | /* Cygwin does not follow the MS style, and | 1026 | | uses ANY and SAME_SIZE where NODUPLICATES | 1027 | | and ASSOCIATIVE should be used. For | 1028 | | Interix, we just do the right thing up | 1029 | | front. */ | 1030 | | | 1031 | 22 | switch (aux.x_scn.x_comdat) | 1032 | 22 | { | 1033 | 1 | case IMAGE_COMDAT_SELECT_NODUPLICATES: | 1034 | | #ifdef STRICT_PE_FORMAT | 1035 | | *sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY; | 1036 | | #else | 1037 | 1 | *sec_flags &= ~SEC_LINK_ONCE; | 1038 | 1 | #endif | 1039 | 1 | break; | 1040 | | | 1041 | 0 | case IMAGE_COMDAT_SELECT_ANY: | 1042 | 0 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1043 | 0 | break; | 1044 | | | 1045 | 1 | case IMAGE_COMDAT_SELECT_SAME_SIZE: | 1046 | 1 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE; | 1047 | 1 | break; | 1048 | | | 1049 | 1 | case IMAGE_COMDAT_SELECT_EXACT_MATCH: | 1050 | | /* Not yet fully implemented ??? */ | 1051 | 1 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS; | 1052 | 1 | break; | 1053 | | | 1054 | | /* debug$S gets this case; other | 1055 | | implications ??? */ | 1056 | | | 1057 | | /* There may be no symbol... we'll search | 1058 | | the whole table... Is this the right | 1059 | | place to play this game? Or should we do | 1060 | | it when reading it in. */ | 1061 | 1 | case IMAGE_COMDAT_SELECT_ASSOCIATIVE: | 1062 | | #ifdef STRICT_PE_FORMAT | 1063 | | /* FIXME: This is not currently implemented. */ | 1064 | | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1065 | | #else | 1066 | 1 | *sec_flags &= ~SEC_LINK_ONCE; | 1067 | 1 | #endif | 1068 | 1 | break; | 1069 | | | 1070 | 18 | default: /* 0 means "no symbol" */ | 1071 | | /* debug$F gets this case; other | 1072 | | implications ??? */ | 1073 | 18 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1074 | 18 | break; | 1075 | 22 | } | 1076 | 22 | } | 1077 | 22 | break; | 1078 | | | 1079 | 22 | case 2: | 1080 | | /* Gas mode: the first matching on partial name. */ | 1081 | | | 1082 | | #ifndef TARGET_UNDERSCORE | 1083 | | #define TARGET_UNDERSCORE 0 | 1084 | | #endif | 1085 | | /* Is this the name we're looking for ? */ | 1086 | 7 | if (strcmp (target_name, | 1087 | 7 | symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0) | 1088 | 6 | { | 1089 | | /* Not the name we're looking for */ | 1090 | 6 | continue; | 1091 | 6 | } | 1092 | | /* Fall through. */ | 1093 | 2 | case 1: | 1094 | | /* MSVC mode: the lexically second symbol (or | 1095 | | drop through from the above). */ | 1096 | 2 | { | 1097 | | /* This must the second symbol with the | 1098 | | section #. It is the actual symbol name. | 1099 | | Intel puts the two adjacent, but Alpha (at | 1100 | | least) spreads them out. */ | 1101 | | | 1102 | 2 | struct coff_comdat_info *comdat; | 1103 | 2 | size_t len = strlen (symname) + 1; | 1104 | | | 1105 | 2 | comdat = bfd_alloc (abfd, sizeof (*comdat) + len); | 1106 | 2 | if (comdat == NULL) | 1107 | 0 | return false; | 1108 | | | 1109 | 2 | coff_section_data (abfd, section)->comdat = comdat; | 1110 | 2 | comdat->symbol = (esym - esymstart) / bfd_coff_symesz (abfd); | 1111 | 2 | char *newname = (char *) (comdat + 1); | 1112 | 2 | comdat->name = newname; | 1113 | 2 | memcpy (newname, symname, len); | 1114 | 2 | return true; | 1115 | 2 | } | 1116 | 36 | } | 1117 | 36 | } | 1118 | 6.28k | } | 1119 | | | 1120 | 120 | return true; | 1121 | 132 | } |
Line | Count | Source | 861 | 286 | { | 862 | 286 | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 863 | 286 | bfd_byte *esymstart, *esym, *esymend; | 864 | 286 | int seen_state = 0; | 865 | 286 | char *target_name = NULL; | 866 | | | 867 | 286 | *sec_flags |= SEC_LINK_ONCE; | 868 | | | 869 | | /* Unfortunately, the PE format stores essential information in | 870 | | the symbol table, of all places. We need to extract that | 871 | | information now, so that objdump and the linker will know how | 872 | | to handle the section without worrying about the symbols. We | 873 | | can't call slurp_symtab, because the linker doesn't want the | 874 | | swapped symbols. */ | 875 | | | 876 | | /* COMDAT sections are special. The first symbol is the section | 877 | | symbol, which tells what kind of COMDAT section it is. The | 878 | | second symbol is the "comdat symbol" - the one with the | 879 | | unique name. GNU uses the section symbol for the unique | 880 | | name; MS uses ".text" for every comdat section. Sigh. - DJ */ | 881 | | | 882 | | /* This is not mirrored in sec_to_styp_flags(), but there | 883 | | doesn't seem to be a need to, either, and it would at best be | 884 | | rather messy. */ | 885 | | | 886 | 286 | if (! _bfd_coff_get_external_symbols (abfd)) | 887 | 169 | return true; | 888 | | | 889 | 117 | esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd); | 890 | 117 | esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd); | 891 | | | 892 | 117 | for (struct internal_syment isym; | 893 | 679 | esym < esymend; | 894 | 562 | esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd)) | 895 | 573 | { | 896 | 573 | char buf[SYMNMLEN + 1]; | 897 | 573 | const char *symname; | 898 | | | 899 | 573 | bfd_coff_swap_sym_in (abfd, esym, &isym); | 900 | | | 901 | 573 | BFD_ASSERT (sizeof (internal_s->s_name) <= SYMNMLEN); | 902 | | | 903 | 573 | if (isym.n_scnum == section->target_index) | 904 | 43 | { | 905 | | /* According to the MSVC documentation, the first | 906 | | TWO entries with the section # are both of | 907 | | interest to us. The first one is the "section | 908 | | symbol" (section name). The second is the comdat | 909 | | symbol name. Here, we've found the first | 910 | | qualifying entry; we distinguish it from the | 911 | | second with a state flag. | 912 | | | 913 | | In the case of gas-generated (at least until that | 914 | | is fixed) .o files, it isn't necessarily the | 915 | | second one. It may be some other later symbol. | 916 | | | 917 | | Since gas also doesn't follow MS conventions and | 918 | | emits the section similar to .text$<name>, where | 919 | | <something> is the name we're looking for, we | 920 | | distinguish the two as follows: | 921 | | | 922 | | If the section name is simply a section name (no | 923 | | $) we presume it's MS-generated, and look at | 924 | | precisely the second symbol for the comdat name. | 925 | | If the section name has a $, we assume it's | 926 | | gas-generated, and look for <something> (whatever | 927 | | follows the $) as the comdat symbol. */ | 928 | | | 929 | | /* All 3 branches use this. */ | 930 | 43 | symname = _bfd_coff_internal_syment_name (abfd, &isym, buf); | 931 | | | 932 | | /* PR 17512 file: 078-11867-0.004 */ | 933 | 43 | if (symname == NULL) | 934 | 3 | { | 935 | 3 | _bfd_error_handler (_("%pB: unable to load COMDAT section name"), | 936 | 3 | abfd); | 937 | 3 | return false; | 938 | 3 | } | 939 | | | 940 | 40 | switch (seen_state) | 941 | 40 | { | 942 | 26 | case 0: | 943 | 26 | { | 944 | | /* The first time we've seen the symbol. */ | 945 | 26 | union internal_auxent aux; | 946 | | | 947 | | /* If it isn't the stuff we're expecting, die; | 948 | | The MS documentation is vague, but it | 949 | | appears that the second entry serves BOTH | 950 | | as the comdat symbol and the defining | 951 | | symbol record (either C_STAT or C_EXT, | 952 | | possibly with an aux entry with debug | 953 | | information if it's a function.) It | 954 | | appears the only way to find the second one | 955 | | is to count. (On Intel, they appear to be | 956 | | adjacent, but on Alpha, they have been | 957 | | found separated.) | 958 | | | 959 | | Here, we think we've found the first one, | 960 | | but there's some checking we can do to be | 961 | | sure. */ | 962 | | | 963 | 26 | if (! ((isym.n_sclass == C_STAT | 964 | 26 | || isym.n_sclass == C_EXT) | 965 | 26 | && BTYPE (isym.n_type) == T_NULL | 966 | 26 | && isym.n_value == 0)) | 967 | 4 | { | 968 | | /* Malformed input files can trigger this test. | 969 | | cf PR 21781. */ | 970 | 4 | _bfd_error_handler (_("%pB: error: unexpected symbol '%s' in COMDAT section"), | 971 | 4 | abfd, symname); | 972 | 4 | return false; | 973 | 4 | } | 974 | | | 975 | | /* FIXME LATER: MSVC generates section names | 976 | | like .text for comdats. Gas generates | 977 | | names like .text$foo__Fv (in the case of a | 978 | | function). See comment above for more. */ | 979 | | | 980 | 22 | if (isym.n_sclass == C_STAT && strcmp (name, symname) != 0) | 981 | | /* xgettext:c-format */ | 982 | 8 | _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'" | 983 | 8 | " does not match section name '%s'"), | 984 | 8 | abfd, symname, name); | 985 | | | 986 | | /* This is the section symbol. */ | 987 | 22 | seen_state = 1; | 988 | 22 | target_name = strchr (name, '$'); | 989 | 22 | if (target_name != NULL) | 990 | 5 | { | 991 | | /* Gas mode. */ | 992 | 5 | seen_state = 2; | 993 | | /* Skip the `$'. */ | 994 | 5 | target_name += 1; | 995 | 5 | } | 996 | | | 997 | 22 | if (isym.n_numaux == 0) | 998 | 17 | aux.x_scn.x_comdat = 0; | 999 | 5 | else | 1000 | 5 | { | 1001 | | /* PR 17512: file: e2cfe54f. */ | 1002 | 5 | if (esym + bfd_coff_symesz (abfd) >= esymend) | 1003 | 1 | { | 1004 | | /* xgettext:c-format */ | 1005 | 1 | _bfd_error_handler (_("%pB: warning: no symbol for" | 1006 | 1 | " section '%s' found"), | 1007 | 1 | abfd, symname); | 1008 | 1 | break; | 1009 | 1 | } | 1010 | 4 | bfd_coff_swap_aux_in (abfd, esym + bfd_coff_symesz (abfd), | 1011 | 4 | isym.n_type, isym.n_sclass, | 1012 | 4 | 0, isym.n_numaux, &aux); | 1013 | 4 | } | 1014 | | | 1015 | | /* FIXME: Microsoft uses NODUPLICATES and | 1016 | | ASSOCIATIVE, but gnu uses ANY and | 1017 | | SAME_SIZE. Unfortunately, gnu doesn't do | 1018 | | the comdat symbols right. So, until we can | 1019 | | fix it to do the right thing, we are | 1020 | | temporarily disabling comdats for the MS | 1021 | | types (they're used in DLLs and C++, but we | 1022 | | don't support *their* C++ libraries anyway | 1023 | | - DJ. */ | 1024 | | | 1025 | | /* Cygwin does not follow the MS style, and | 1026 | | uses ANY and SAME_SIZE where NODUPLICATES | 1027 | | and ASSOCIATIVE should be used. For | 1028 | | Interix, we just do the right thing up | 1029 | | front. */ | 1030 | | | 1031 | 21 | switch (aux.x_scn.x_comdat) | 1032 | 21 | { | 1033 | 1 | case IMAGE_COMDAT_SELECT_NODUPLICATES: | 1034 | | #ifdef STRICT_PE_FORMAT | 1035 | | *sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY; | 1036 | | #else | 1037 | 1 | *sec_flags &= ~SEC_LINK_ONCE; | 1038 | 1 | #endif | 1039 | 1 | break; | 1040 | | | 1041 | 0 | case IMAGE_COMDAT_SELECT_ANY: | 1042 | 0 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1043 | 0 | break; | 1044 | | | 1045 | 1 | case IMAGE_COMDAT_SELECT_SAME_SIZE: | 1046 | 1 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE; | 1047 | 1 | break; | 1048 | | | 1049 | 1 | case IMAGE_COMDAT_SELECT_EXACT_MATCH: | 1050 | | /* Not yet fully implemented ??? */ | 1051 | 1 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS; | 1052 | 1 | break; | 1053 | | | 1054 | | /* debug$S gets this case; other | 1055 | | implications ??? */ | 1056 | | | 1057 | | /* There may be no symbol... we'll search | 1058 | | the whole table... Is this the right | 1059 | | place to play this game? Or should we do | 1060 | | it when reading it in. */ | 1061 | 0 | case IMAGE_COMDAT_SELECT_ASSOCIATIVE: | 1062 | | #ifdef STRICT_PE_FORMAT | 1063 | | /* FIXME: This is not currently implemented. */ | 1064 | | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1065 | | #else | 1066 | 0 | *sec_flags &= ~SEC_LINK_ONCE; | 1067 | 0 | #endif | 1068 | 0 | break; | 1069 | | | 1070 | 18 | default: /* 0 means "no symbol" */ | 1071 | | /* debug$F gets this case; other | 1072 | | implications ??? */ | 1073 | 18 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1074 | 18 | break; | 1075 | 21 | } | 1076 | 21 | } | 1077 | 21 | break; | 1078 | | | 1079 | 21 | case 2: | 1080 | | /* Gas mode: the first matching on partial name. */ | 1081 | | | 1082 | | #ifndef TARGET_UNDERSCORE | 1083 | | #define TARGET_UNDERSCORE 0 | 1084 | | #endif | 1085 | | /* Is this the name we're looking for ? */ | 1086 | 12 | if (strcmp (target_name, | 1087 | 12 | symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0) | 1088 | 10 | { | 1089 | | /* Not the name we're looking for */ | 1090 | 10 | continue; | 1091 | 10 | } | 1092 | | /* Fall through. */ | 1093 | 4 | case 1: | 1094 | | /* MSVC mode: the lexically second symbol (or | 1095 | | drop through from the above). */ | 1096 | 4 | { | 1097 | | /* This must the second symbol with the | 1098 | | section #. It is the actual symbol name. | 1099 | | Intel puts the two adjacent, but Alpha (at | 1100 | | least) spreads them out. */ | 1101 | | | 1102 | 4 | struct coff_comdat_info *comdat; | 1103 | 4 | size_t len = strlen (symname) + 1; | 1104 | | | 1105 | 4 | comdat = bfd_alloc (abfd, sizeof (*comdat) + len); | 1106 | 4 | if (comdat == NULL) | 1107 | 0 | return false; | 1108 | | | 1109 | 4 | coff_section_data (abfd, section)->comdat = comdat; | 1110 | 4 | comdat->symbol = (esym - esymstart) / bfd_coff_symesz (abfd); | 1111 | 4 | char *newname = (char *) (comdat + 1); | 1112 | 4 | comdat->name = newname; | 1113 | 4 | memcpy (newname, symname, len); | 1114 | 4 | return true; | 1115 | 4 | } | 1116 | 40 | } | 1117 | 40 | } | 1118 | 573 | } | 1119 | | | 1120 | 106 | return true; | 1121 | 117 | } |
Line | Count | Source | 861 | 212 | { | 862 | 212 | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 863 | 212 | bfd_byte *esymstart, *esym, *esymend; | 864 | 212 | int seen_state = 0; | 865 | 212 | char *target_name = NULL; | 866 | | | 867 | 212 | *sec_flags |= SEC_LINK_ONCE; | 868 | | | 869 | | /* Unfortunately, the PE format stores essential information in | 870 | | the symbol table, of all places. We need to extract that | 871 | | information now, so that objdump and the linker will know how | 872 | | to handle the section without worrying about the symbols. We | 873 | | can't call slurp_symtab, because the linker doesn't want the | 874 | | swapped symbols. */ | 875 | | | 876 | | /* COMDAT sections are special. The first symbol is the section | 877 | | symbol, which tells what kind of COMDAT section it is. The | 878 | | second symbol is the "comdat symbol" - the one with the | 879 | | unique name. GNU uses the section symbol for the unique | 880 | | name; MS uses ".text" for every comdat section. Sigh. - DJ */ | 881 | | | 882 | | /* This is not mirrored in sec_to_styp_flags(), but there | 883 | | doesn't seem to be a need to, either, and it would at best be | 884 | | rather messy. */ | 885 | | | 886 | 212 | if (! _bfd_coff_get_external_symbols (abfd)) | 887 | 83 | return true; | 888 | | | 889 | 129 | esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd); | 890 | 129 | esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd); | 891 | | | 892 | 129 | for (struct internal_syment isym; | 893 | 139k | esym < esymend; | 894 | 139k | esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd)) | 895 | 139k | { | 896 | 139k | char buf[SYMNMLEN + 1]; | 897 | 139k | const char *symname; | 898 | | | 899 | 139k | bfd_coff_swap_sym_in (abfd, esym, &isym); | 900 | | | 901 | 139k | BFD_ASSERT (sizeof (internal_s->s_name) <= SYMNMLEN); | 902 | | | 903 | 139k | if (isym.n_scnum == section->target_index) | 904 | 33 | { | 905 | | /* According to the MSVC documentation, the first | 906 | | TWO entries with the section # are both of | 907 | | interest to us. The first one is the "section | 908 | | symbol" (section name). The second is the comdat | 909 | | symbol name. Here, we've found the first | 910 | | qualifying entry; we distinguish it from the | 911 | | second with a state flag. | 912 | | | 913 | | In the case of gas-generated (at least until that | 914 | | is fixed) .o files, it isn't necessarily the | 915 | | second one. It may be some other later symbol. | 916 | | | 917 | | Since gas also doesn't follow MS conventions and | 918 | | emits the section similar to .text$<name>, where | 919 | | <something> is the name we're looking for, we | 920 | | distinguish the two as follows: | 921 | | | 922 | | If the section name is simply a section name (no | 923 | | $) we presume it's MS-generated, and look at | 924 | | precisely the second symbol for the comdat name. | 925 | | If the section name has a $, we assume it's | 926 | | gas-generated, and look for <something> (whatever | 927 | | follows the $) as the comdat symbol. */ | 928 | | | 929 | | /* All 3 branches use this. */ | 930 | 33 | symname = _bfd_coff_internal_syment_name (abfd, &isym, buf); | 931 | | | 932 | | /* PR 17512 file: 078-11867-0.004 */ | 933 | 33 | if (symname == NULL) | 934 | 2 | { | 935 | 2 | _bfd_error_handler (_("%pB: unable to load COMDAT section name"), | 936 | 2 | abfd); | 937 | 2 | return false; | 938 | 2 | } | 939 | | | 940 | 31 | switch (seen_state) | 941 | 31 | { | 942 | 18 | case 0: | 943 | 18 | { | 944 | | /* The first time we've seen the symbol. */ | 945 | 18 | union internal_auxent aux; | 946 | | | 947 | | /* If it isn't the stuff we're expecting, die; | 948 | | The MS documentation is vague, but it | 949 | | appears that the second entry serves BOTH | 950 | | as the comdat symbol and the defining | 951 | | symbol record (either C_STAT or C_EXT, | 952 | | possibly with an aux entry with debug | 953 | | information if it's a function.) It | 954 | | appears the only way to find the second one | 955 | | is to count. (On Intel, they appear to be | 956 | | adjacent, but on Alpha, they have been | 957 | | found separated.) | 958 | | | 959 | | Here, we think we've found the first one, | 960 | | but there's some checking we can do to be | 961 | | sure. */ | 962 | | | 963 | 18 | if (! ((isym.n_sclass == C_STAT | 964 | 18 | || isym.n_sclass == C_EXT) | 965 | 18 | && BTYPE (isym.n_type) == T_NULL | 966 | 18 | && isym.n_value == 0)) | 967 | 3 | { | 968 | | /* Malformed input files can trigger this test. | 969 | | cf PR 21781. */ | 970 | 3 | _bfd_error_handler (_("%pB: error: unexpected symbol '%s' in COMDAT section"), | 971 | 3 | abfd, symname); | 972 | 3 | return false; | 973 | 3 | } | 974 | | | 975 | | /* FIXME LATER: MSVC generates section names | 976 | | like .text for comdats. Gas generates | 977 | | names like .text$foo__Fv (in the case of a | 978 | | function). See comment above for more. */ | 979 | | | 980 | 15 | if (isym.n_sclass == C_STAT && strcmp (name, symname) != 0) | 981 | | /* xgettext:c-format */ | 982 | 8 | _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'" | 983 | 8 | " does not match section name '%s'"), | 984 | 8 | abfd, symname, name); | 985 | | | 986 | | /* This is the section symbol. */ | 987 | 15 | seen_state = 1; | 988 | 15 | target_name = strchr (name, '$'); | 989 | 15 | if (target_name != NULL) | 990 | 8 | { | 991 | | /* Gas mode. */ | 992 | 8 | seen_state = 2; | 993 | | /* Skip the `$'. */ | 994 | 8 | target_name += 1; | 995 | 8 | } | 996 | | | 997 | 15 | if (isym.n_numaux == 0) | 998 | 1 | aux.x_scn.x_comdat = 0; | 999 | 14 | else | 1000 | 14 | { | 1001 | | /* PR 17512: file: e2cfe54f. */ | 1002 | 14 | if (esym + bfd_coff_symesz (abfd) >= esymend) | 1003 | 1 | { | 1004 | | /* xgettext:c-format */ | 1005 | 1 | _bfd_error_handler (_("%pB: warning: no symbol for" | 1006 | 1 | " section '%s' found"), | 1007 | 1 | abfd, symname); | 1008 | 1 | break; | 1009 | 1 | } | 1010 | 13 | bfd_coff_swap_aux_in (abfd, esym + bfd_coff_symesz (abfd), | 1011 | 13 | isym.n_type, isym.n_sclass, | 1012 | 13 | 0, isym.n_numaux, &aux); | 1013 | 13 | } | 1014 | | | 1015 | | /* FIXME: Microsoft uses NODUPLICATES and | 1016 | | ASSOCIATIVE, but gnu uses ANY and | 1017 | | SAME_SIZE. Unfortunately, gnu doesn't do | 1018 | | the comdat symbols right. So, until we can | 1019 | | fix it to do the right thing, we are | 1020 | | temporarily disabling comdats for the MS | 1021 | | types (they're used in DLLs and C++, but we | 1022 | | don't support *their* C++ libraries anyway | 1023 | | - DJ. */ | 1024 | | | 1025 | | /* Cygwin does not follow the MS style, and | 1026 | | uses ANY and SAME_SIZE where NODUPLICATES | 1027 | | and ASSOCIATIVE should be used. For | 1028 | | Interix, we just do the right thing up | 1029 | | front. */ | 1030 | | | 1031 | 14 | switch (aux.x_scn.x_comdat) | 1032 | 14 | { | 1033 | 1 | case IMAGE_COMDAT_SELECT_NODUPLICATES: | 1034 | | #ifdef STRICT_PE_FORMAT | 1035 | | *sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY; | 1036 | | #else | 1037 | 1 | *sec_flags &= ~SEC_LINK_ONCE; | 1038 | 1 | #endif | 1039 | 1 | break; | 1040 | | | 1041 | 0 | case IMAGE_COMDAT_SELECT_ANY: | 1042 | 0 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1043 | 0 | break; | 1044 | | | 1045 | 1 | case IMAGE_COMDAT_SELECT_SAME_SIZE: | 1046 | 1 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE; | 1047 | 1 | break; | 1048 | | | 1049 | 1 | case IMAGE_COMDAT_SELECT_EXACT_MATCH: | 1050 | | /* Not yet fully implemented ??? */ | 1051 | 1 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS; | 1052 | 1 | break; | 1053 | | | 1054 | | /* debug$S gets this case; other | 1055 | | implications ??? */ | 1056 | | | 1057 | | /* There may be no symbol... we'll search | 1058 | | the whole table... Is this the right | 1059 | | place to play this game? Or should we do | 1060 | | it when reading it in. */ | 1061 | 1 | case IMAGE_COMDAT_SELECT_ASSOCIATIVE: | 1062 | | #ifdef STRICT_PE_FORMAT | 1063 | | /* FIXME: This is not currently implemented. */ | 1064 | | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1065 | | #else | 1066 | 1 | *sec_flags &= ~SEC_LINK_ONCE; | 1067 | 1 | #endif | 1068 | 1 | break; | 1069 | | | 1070 | 10 | default: /* 0 means "no symbol" */ | 1071 | | /* debug$F gets this case; other | 1072 | | implications ??? */ | 1073 | 10 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1074 | 10 | break; | 1075 | 14 | } | 1076 | 14 | } | 1077 | 14 | break; | 1078 | | | 1079 | 14 | case 2: | 1080 | | /* Gas mode: the first matching on partial name. */ | 1081 | | | 1082 | 12 | #ifndef TARGET_UNDERSCORE | 1083 | 12 | #define TARGET_UNDERSCORE 0 | 1084 | 12 | #endif | 1085 | | /* Is this the name we're looking for ? */ | 1086 | 12 | if (strcmp (target_name, | 1087 | 12 | symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0) | 1088 | 11 | { | 1089 | | /* Not the name we're looking for */ | 1090 | 11 | continue; | 1091 | 11 | } | 1092 | | /* Fall through. */ | 1093 | 2 | case 1: | 1094 | | /* MSVC mode: the lexically second symbol (or | 1095 | | drop through from the above). */ | 1096 | 2 | { | 1097 | | /* This must the second symbol with the | 1098 | | section #. It is the actual symbol name. | 1099 | | Intel puts the two adjacent, but Alpha (at | 1100 | | least) spreads them out. */ | 1101 | | | 1102 | 2 | struct coff_comdat_info *comdat; | 1103 | 2 | size_t len = strlen (symname) + 1; | 1104 | | | 1105 | 2 | comdat = bfd_alloc (abfd, sizeof (*comdat) + len); | 1106 | 2 | if (comdat == NULL) | 1107 | 0 | return false; | 1108 | | | 1109 | 2 | coff_section_data (abfd, section)->comdat = comdat; | 1110 | 2 | comdat->symbol = (esym - esymstart) / bfd_coff_symesz (abfd); | 1111 | 2 | char *newname = (char *) (comdat + 1); | 1112 | 2 | comdat->name = newname; | 1113 | 2 | memcpy (newname, symname, len); | 1114 | 2 | return true; | 1115 | 2 | } | 1116 | 31 | } | 1117 | 31 | } | 1118 | 139k | } | 1119 | | | 1120 | 122 | return true; | 1121 | 129 | } |
Line | Count | Source | 861 | 186 | { | 862 | 186 | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 863 | 186 | bfd_byte *esymstart, *esym, *esymend; | 864 | 186 | int seen_state = 0; | 865 | 186 | char *target_name = NULL; | 866 | | | 867 | 186 | *sec_flags |= SEC_LINK_ONCE; | 868 | | | 869 | | /* Unfortunately, the PE format stores essential information in | 870 | | the symbol table, of all places. We need to extract that | 871 | | information now, so that objdump and the linker will know how | 872 | | to handle the section without worrying about the symbols. We | 873 | | can't call slurp_symtab, because the linker doesn't want the | 874 | | swapped symbols. */ | 875 | | | 876 | | /* COMDAT sections are special. The first symbol is the section | 877 | | symbol, which tells what kind of COMDAT section it is. The | 878 | | second symbol is the "comdat symbol" - the one with the | 879 | | unique name. GNU uses the section symbol for the unique | 880 | | name; MS uses ".text" for every comdat section. Sigh. - DJ */ | 881 | | | 882 | | /* This is not mirrored in sec_to_styp_flags(), but there | 883 | | doesn't seem to be a need to, either, and it would at best be | 884 | | rather messy. */ | 885 | | | 886 | 186 | if (! _bfd_coff_get_external_symbols (abfd)) | 887 | 66 | return true; | 888 | | | 889 | 120 | esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd); | 890 | 120 | esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd); | 891 | | | 892 | 120 | for (struct internal_syment isym; | 893 | 5.29k | esym < esymend; | 894 | 5.17k | esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd)) | 895 | 5.18k | { | 896 | 5.18k | char buf[SYMNMLEN + 1]; | 897 | 5.18k | const char *symname; | 898 | | | 899 | 5.18k | bfd_coff_swap_sym_in (abfd, esym, &isym); | 900 | | | 901 | 5.18k | BFD_ASSERT (sizeof (internal_s->s_name) <= SYMNMLEN); | 902 | | | 903 | 5.18k | if (isym.n_scnum == section->target_index) | 904 | 50 | { | 905 | | /* According to the MSVC documentation, the first | 906 | | TWO entries with the section # are both of | 907 | | interest to us. The first one is the "section | 908 | | symbol" (section name). The second is the comdat | 909 | | symbol name. Here, we've found the first | 910 | | qualifying entry; we distinguish it from the | 911 | | second with a state flag. | 912 | | | 913 | | In the case of gas-generated (at least until that | 914 | | is fixed) .o files, it isn't necessarily the | 915 | | second one. It may be some other later symbol. | 916 | | | 917 | | Since gas also doesn't follow MS conventions and | 918 | | emits the section similar to .text$<name>, where | 919 | | <something> is the name we're looking for, we | 920 | | distinguish the two as follows: | 921 | | | 922 | | If the section name is simply a section name (no | 923 | | $) we presume it's MS-generated, and look at | 924 | | precisely the second symbol for the comdat name. | 925 | | If the section name has a $, we assume it's | 926 | | gas-generated, and look for <something> (whatever | 927 | | follows the $) as the comdat symbol. */ | 928 | | | 929 | | /* All 3 branches use this. */ | 930 | 50 | symname = _bfd_coff_internal_syment_name (abfd, &isym, buf); | 931 | | | 932 | | /* PR 17512 file: 078-11867-0.004 */ | 933 | 50 | if (symname == NULL) | 934 | 1 | { | 935 | 1 | _bfd_error_handler (_("%pB: unable to load COMDAT section name"), | 936 | 1 | abfd); | 937 | 1 | return false; | 938 | 1 | } | 939 | | | 940 | 49 | switch (seen_state) | 941 | 49 | { | 942 | 32 | case 0: | 943 | 32 | { | 944 | | /* The first time we've seen the symbol. */ | 945 | 32 | union internal_auxent aux; | 946 | | | 947 | | /* If it isn't the stuff we're expecting, die; | 948 | | The MS documentation is vague, but it | 949 | | appears that the second entry serves BOTH | 950 | | as the comdat symbol and the defining | 951 | | symbol record (either C_STAT or C_EXT, | 952 | | possibly with an aux entry with debug | 953 | | information if it's a function.) It | 954 | | appears the only way to find the second one | 955 | | is to count. (On Intel, they appear to be | 956 | | adjacent, but on Alpha, they have been | 957 | | found separated.) | 958 | | | 959 | | Here, we think we've found the first one, | 960 | | but there's some checking we can do to be | 961 | | sure. */ | 962 | | | 963 | 32 | if (! ((isym.n_sclass == C_STAT | 964 | 32 | || isym.n_sclass == C_EXT) | 965 | 32 | && BTYPE (isym.n_type) == T_NULL | 966 | 32 | && isym.n_value == 0)) | 967 | 6 | { | 968 | | /* Malformed input files can trigger this test. | 969 | | cf PR 21781. */ | 970 | 6 | _bfd_error_handler (_("%pB: error: unexpected symbol '%s' in COMDAT section"), | 971 | 6 | abfd, symname); | 972 | 6 | return false; | 973 | 6 | } | 974 | | | 975 | | /* FIXME LATER: MSVC generates section names | 976 | | like .text for comdats. Gas generates | 977 | | names like .text$foo__Fv (in the case of a | 978 | | function). See comment above for more. */ | 979 | | | 980 | 26 | if (isym.n_sclass == C_STAT && strcmp (name, symname) != 0) | 981 | | /* xgettext:c-format */ | 982 | 10 | _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'" | 983 | 10 | " does not match section name '%s'"), | 984 | 10 | abfd, symname, name); | 985 | | | 986 | | /* This is the section symbol. */ | 987 | 26 | seen_state = 1; | 988 | 26 | target_name = strchr (name, '$'); | 989 | 26 | if (target_name != NULL) | 990 | 4 | { | 991 | | /* Gas mode. */ | 992 | 4 | seen_state = 2; | 993 | | /* Skip the `$'. */ | 994 | 4 | target_name += 1; | 995 | 4 | } | 996 | | | 997 | 26 | if (isym.n_numaux == 0) | 998 | 7 | aux.x_scn.x_comdat = 0; | 999 | 19 | else | 1000 | 19 | { | 1001 | | /* PR 17512: file: e2cfe54f. */ | 1002 | 19 | if (esym + bfd_coff_symesz (abfd) >= esymend) | 1003 | 1 | { | 1004 | | /* xgettext:c-format */ | 1005 | 1 | _bfd_error_handler (_("%pB: warning: no symbol for" | 1006 | 1 | " section '%s' found"), | 1007 | 1 | abfd, symname); | 1008 | 1 | break; | 1009 | 1 | } | 1010 | 18 | bfd_coff_swap_aux_in (abfd, esym + bfd_coff_symesz (abfd), | 1011 | 18 | isym.n_type, isym.n_sclass, | 1012 | 18 | 0, isym.n_numaux, &aux); | 1013 | 18 | } | 1014 | | | 1015 | | /* FIXME: Microsoft uses NODUPLICATES and | 1016 | | ASSOCIATIVE, but gnu uses ANY and | 1017 | | SAME_SIZE. Unfortunately, gnu doesn't do | 1018 | | the comdat symbols right. So, until we can | 1019 | | fix it to do the right thing, we are | 1020 | | temporarily disabling comdats for the MS | 1021 | | types (they're used in DLLs and C++, but we | 1022 | | don't support *their* C++ libraries anyway | 1023 | | - DJ. */ | 1024 | | | 1025 | | /* Cygwin does not follow the MS style, and | 1026 | | uses ANY and SAME_SIZE where NODUPLICATES | 1027 | | and ASSOCIATIVE should be used. For | 1028 | | Interix, we just do the right thing up | 1029 | | front. */ | 1030 | | | 1031 | 25 | switch (aux.x_scn.x_comdat) | 1032 | 25 | { | 1033 | 2 | case IMAGE_COMDAT_SELECT_NODUPLICATES: | 1034 | | #ifdef STRICT_PE_FORMAT | 1035 | | *sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY; | 1036 | | #else | 1037 | 2 | *sec_flags &= ~SEC_LINK_ONCE; | 1038 | 2 | #endif | 1039 | 2 | break; | 1040 | | | 1041 | 0 | case IMAGE_COMDAT_SELECT_ANY: | 1042 | 0 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1043 | 0 | break; | 1044 | | | 1045 | 1 | case IMAGE_COMDAT_SELECT_SAME_SIZE: | 1046 | 1 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE; | 1047 | 1 | break; | 1048 | | | 1049 | 1 | case IMAGE_COMDAT_SELECT_EXACT_MATCH: | 1050 | | /* Not yet fully implemented ??? */ | 1051 | 1 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS; | 1052 | 1 | break; | 1053 | | | 1054 | | /* debug$S gets this case; other | 1055 | | implications ??? */ | 1056 | | | 1057 | | /* There may be no symbol... we'll search | 1058 | | the whole table... Is this the right | 1059 | | place to play this game? Or should we do | 1060 | | it when reading it in. */ | 1061 | 1 | case IMAGE_COMDAT_SELECT_ASSOCIATIVE: | 1062 | | #ifdef STRICT_PE_FORMAT | 1063 | | /* FIXME: This is not currently implemented. */ | 1064 | | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1065 | | #else | 1066 | 1 | *sec_flags &= ~SEC_LINK_ONCE; | 1067 | 1 | #endif | 1068 | 1 | break; | 1069 | | | 1070 | 20 | default: /* 0 means "no symbol" */ | 1071 | | /* debug$F gets this case; other | 1072 | | implications ??? */ | 1073 | 20 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1074 | 20 | break; | 1075 | 25 | } | 1076 | 25 | } | 1077 | 25 | break; | 1078 | | | 1079 | 25 | case 2: | 1080 | | /* Gas mode: the first matching on partial name. */ | 1081 | | | 1082 | | #ifndef TARGET_UNDERSCORE | 1083 | | #define TARGET_UNDERSCORE 0 | 1084 | | #endif | 1085 | | /* Is this the name we're looking for ? */ | 1086 | 10 | if (strcmp (target_name, | 1087 | 10 | symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0) | 1088 | 10 | { | 1089 | | /* Not the name we're looking for */ | 1090 | 10 | continue; | 1091 | 10 | } | 1092 | | /* Fall through. */ | 1093 | 7 | case 1: | 1094 | | /* MSVC mode: the lexically second symbol (or | 1095 | | drop through from the above). */ | 1096 | 7 | { | 1097 | | /* This must the second symbol with the | 1098 | | section #. It is the actual symbol name. | 1099 | | Intel puts the two adjacent, but Alpha (at | 1100 | | least) spreads them out. */ | 1101 | | | 1102 | 7 | struct coff_comdat_info *comdat; | 1103 | 7 | size_t len = strlen (symname) + 1; | 1104 | | | 1105 | 7 | comdat = bfd_alloc (abfd, sizeof (*comdat) + len); | 1106 | 7 | if (comdat == NULL) | 1107 | 0 | return false; | 1108 | | | 1109 | 7 | coff_section_data (abfd, section)->comdat = comdat; | 1110 | 7 | comdat->symbol = (esym - esymstart) / bfd_coff_symesz (abfd); | 1111 | 7 | char *newname = (char *) (comdat + 1); | 1112 | 7 | comdat->name = newname; | 1113 | 7 | memcpy (newname, symname, len); | 1114 | 7 | return true; | 1115 | 7 | } | 1116 | 49 | } | 1117 | 49 | } | 1118 | 5.18k | } | 1119 | | | 1120 | 106 | return true; | 1121 | 120 | } |
pei-arm-wince.c:handle_COMDAT Line | Count | Source | 861 | 118 | { | 862 | 118 | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 863 | 118 | bfd_byte *esymstart, *esym, *esymend; | 864 | 118 | int seen_state = 0; | 865 | 118 | char *target_name = NULL; | 866 | | | 867 | 118 | *sec_flags |= SEC_LINK_ONCE; | 868 | | | 869 | | /* Unfortunately, the PE format stores essential information in | 870 | | the symbol table, of all places. We need to extract that | 871 | | information now, so that objdump and the linker will know how | 872 | | to handle the section without worrying about the symbols. We | 873 | | can't call slurp_symtab, because the linker doesn't want the | 874 | | swapped symbols. */ | 875 | | | 876 | | /* COMDAT sections are special. The first symbol is the section | 877 | | symbol, which tells what kind of COMDAT section it is. The | 878 | | second symbol is the "comdat symbol" - the one with the | 879 | | unique name. GNU uses the section symbol for the unique | 880 | | name; MS uses ".text" for every comdat section. Sigh. - DJ */ | 881 | | | 882 | | /* This is not mirrored in sec_to_styp_flags(), but there | 883 | | doesn't seem to be a need to, either, and it would at best be | 884 | | rather messy. */ | 885 | | | 886 | 118 | if (! _bfd_coff_get_external_symbols (abfd)) | 887 | 31 | return true; | 888 | | | 889 | 87 | esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd); | 890 | 87 | esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd); | 891 | | | 892 | 87 | for (struct internal_syment isym; | 893 | 1.08k | esym < esymend; | 894 | 997 | esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd)) | 895 | 1.00k | { | 896 | 1.00k | char buf[SYMNMLEN + 1]; | 897 | 1.00k | const char *symname; | 898 | | | 899 | 1.00k | bfd_coff_swap_sym_in (abfd, esym, &isym); | 900 | | | 901 | 1.00k | BFD_ASSERT (sizeof (internal_s->s_name) <= SYMNMLEN); | 902 | | | 903 | 1.00k | if (isym.n_scnum == section->target_index) | 904 | 24 | { | 905 | | /* According to the MSVC documentation, the first | 906 | | TWO entries with the section # are both of | 907 | | interest to us. The first one is the "section | 908 | | symbol" (section name). The second is the comdat | 909 | | symbol name. Here, we've found the first | 910 | | qualifying entry; we distinguish it from the | 911 | | second with a state flag. | 912 | | | 913 | | In the case of gas-generated (at least until that | 914 | | is fixed) .o files, it isn't necessarily the | 915 | | second one. It may be some other later symbol. | 916 | | | 917 | | Since gas also doesn't follow MS conventions and | 918 | | emits the section similar to .text$<name>, where | 919 | | <something> is the name we're looking for, we | 920 | | distinguish the two as follows: | 921 | | | 922 | | If the section name is simply a section name (no | 923 | | $) we presume it's MS-generated, and look at | 924 | | precisely the second symbol for the comdat name. | 925 | | If the section name has a $, we assume it's | 926 | | gas-generated, and look for <something> (whatever | 927 | | follows the $) as the comdat symbol. */ | 928 | | | 929 | | /* All 3 branches use this. */ | 930 | 24 | symname = _bfd_coff_internal_syment_name (abfd, &isym, buf); | 931 | | | 932 | | /* PR 17512 file: 078-11867-0.004 */ | 933 | 24 | if (symname == NULL) | 934 | 1 | { | 935 | 1 | _bfd_error_handler (_("%pB: unable to load COMDAT section name"), | 936 | 1 | abfd); | 937 | 1 | return false; | 938 | 1 | } | 939 | | | 940 | 23 | switch (seen_state) | 941 | 23 | { | 942 | 19 | case 0: | 943 | 19 | { | 944 | | /* The first time we've seen the symbol. */ | 945 | 19 | union internal_auxent aux; | 946 | | | 947 | | /* If it isn't the stuff we're expecting, die; | 948 | | The MS documentation is vague, but it | 949 | | appears that the second entry serves BOTH | 950 | | as the comdat symbol and the defining | 951 | | symbol record (either C_STAT or C_EXT, | 952 | | possibly with an aux entry with debug | 953 | | information if it's a function.) It | 954 | | appears the only way to find the second one | 955 | | is to count. (On Intel, they appear to be | 956 | | adjacent, but on Alpha, they have been | 957 | | found separated.) | 958 | | | 959 | | Here, we think we've found the first one, | 960 | | but there's some checking we can do to be | 961 | | sure. */ | 962 | | | 963 | 19 | if (! ((isym.n_sclass == C_STAT | 964 | 19 | || isym.n_sclass == C_EXT) | 965 | 19 | && BTYPE (isym.n_type) == T_NULL | 966 | 19 | && isym.n_value == 0)) | 967 | 4 | { | 968 | | /* Malformed input files can trigger this test. | 969 | | cf PR 21781. */ | 970 | 4 | _bfd_error_handler (_("%pB: error: unexpected symbol '%s' in COMDAT section"), | 971 | 4 | abfd, symname); | 972 | 4 | return false; | 973 | 4 | } | 974 | | | 975 | | /* FIXME LATER: MSVC generates section names | 976 | | like .text for comdats. Gas generates | 977 | | names like .text$foo__Fv (in the case of a | 978 | | function). See comment above for more. */ | 979 | | | 980 | 15 | if (isym.n_sclass == C_STAT && strcmp (name, symname) != 0) | 981 | | /* xgettext:c-format */ | 982 | 9 | _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'" | 983 | 9 | " does not match section name '%s'"), | 984 | 9 | abfd, symname, name); | 985 | | | 986 | | /* This is the section symbol. */ | 987 | 15 | seen_state = 1; | 988 | 15 | target_name = strchr (name, '$'); | 989 | 15 | if (target_name != NULL) | 990 | 3 | { | 991 | | /* Gas mode. */ | 992 | 3 | seen_state = 2; | 993 | | /* Skip the `$'. */ | 994 | 3 | target_name += 1; | 995 | 3 | } | 996 | | | 997 | 15 | if (isym.n_numaux == 0) | 998 | 5 | aux.x_scn.x_comdat = 0; | 999 | 10 | else | 1000 | 10 | { | 1001 | | /* PR 17512: file: e2cfe54f. */ | 1002 | 10 | if (esym + bfd_coff_symesz (abfd) >= esymend) | 1003 | 1 | { | 1004 | | /* xgettext:c-format */ | 1005 | 1 | _bfd_error_handler (_("%pB: warning: no symbol for" | 1006 | 1 | " section '%s' found"), | 1007 | 1 | abfd, symname); | 1008 | 1 | break; | 1009 | 1 | } | 1010 | 9 | bfd_coff_swap_aux_in (abfd, esym + bfd_coff_symesz (abfd), | 1011 | 9 | isym.n_type, isym.n_sclass, | 1012 | 9 | 0, isym.n_numaux, &aux); | 1013 | 9 | } | 1014 | | | 1015 | | /* FIXME: Microsoft uses NODUPLICATES and | 1016 | | ASSOCIATIVE, but gnu uses ANY and | 1017 | | SAME_SIZE. Unfortunately, gnu doesn't do | 1018 | | the comdat symbols right. So, until we can | 1019 | | fix it to do the right thing, we are | 1020 | | temporarily disabling comdats for the MS | 1021 | | types (they're used in DLLs and C++, but we | 1022 | | don't support *their* C++ libraries anyway | 1023 | | - DJ. */ | 1024 | | | 1025 | | /* Cygwin does not follow the MS style, and | 1026 | | uses ANY and SAME_SIZE where NODUPLICATES | 1027 | | and ASSOCIATIVE should be used. For | 1028 | | Interix, we just do the right thing up | 1029 | | front. */ | 1030 | | | 1031 | 14 | switch (aux.x_scn.x_comdat) | 1032 | 14 | { | 1033 | 1 | case IMAGE_COMDAT_SELECT_NODUPLICATES: | 1034 | | #ifdef STRICT_PE_FORMAT | 1035 | | *sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY; | 1036 | | #else | 1037 | 1 | *sec_flags &= ~SEC_LINK_ONCE; | 1038 | 1 | #endif | 1039 | 1 | break; | 1040 | | | 1041 | 0 | case IMAGE_COMDAT_SELECT_ANY: | 1042 | 0 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1043 | 0 | break; | 1044 | | | 1045 | 1 | case IMAGE_COMDAT_SELECT_SAME_SIZE: | 1046 | 1 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE; | 1047 | 1 | break; | 1048 | | | 1049 | 2 | case IMAGE_COMDAT_SELECT_EXACT_MATCH: | 1050 | | /* Not yet fully implemented ??? */ | 1051 | 2 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS; | 1052 | 2 | break; | 1053 | | | 1054 | | /* debug$S gets this case; other | 1055 | | implications ??? */ | 1056 | | | 1057 | | /* There may be no symbol... we'll search | 1058 | | the whole table... Is this the right | 1059 | | place to play this game? Or should we do | 1060 | | it when reading it in. */ | 1061 | 1 | case IMAGE_COMDAT_SELECT_ASSOCIATIVE: | 1062 | | #ifdef STRICT_PE_FORMAT | 1063 | | /* FIXME: This is not currently implemented. */ | 1064 | | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1065 | | #else | 1066 | 1 | *sec_flags &= ~SEC_LINK_ONCE; | 1067 | 1 | #endif | 1068 | 1 | break; | 1069 | | | 1070 | 9 | default: /* 0 means "no symbol" */ | 1071 | | /* debug$F gets this case; other | 1072 | | implications ??? */ | 1073 | 9 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1074 | 9 | break; | 1075 | 14 | } | 1076 | 14 | } | 1077 | 14 | break; | 1078 | | | 1079 | 14 | case 2: | 1080 | | /* Gas mode: the first matching on partial name. */ | 1081 | |
| 1082 | | #ifndef TARGET_UNDERSCORE | 1083 | | #define TARGET_UNDERSCORE 0 | 1084 | | #endif | 1085 | | /* Is this the name we're looking for ? */ | 1086 | 0 | if (strcmp (target_name, | 1087 | 0 | symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0) | 1088 | 0 | { | 1089 | | /* Not the name we're looking for */ | 1090 | 0 | continue; | 1091 | 0 | } | 1092 | | /* Fall through. */ | 1093 | 4 | case 1: | 1094 | | /* MSVC mode: the lexically second symbol (or | 1095 | | drop through from the above). */ | 1096 | 4 | { | 1097 | | /* This must the second symbol with the | 1098 | | section #. It is the actual symbol name. | 1099 | | Intel puts the two adjacent, but Alpha (at | 1100 | | least) spreads them out. */ | 1101 | | | 1102 | 4 | struct coff_comdat_info *comdat; | 1103 | 4 | size_t len = strlen (symname) + 1; | 1104 | | | 1105 | 4 | comdat = bfd_alloc (abfd, sizeof (*comdat) + len); | 1106 | 4 | if (comdat == NULL) | 1107 | 0 | return false; | 1108 | | | 1109 | 4 | coff_section_data (abfd, section)->comdat = comdat; | 1110 | 4 | comdat->symbol = (esym - esymstart) / bfd_coff_symesz (abfd); | 1111 | 4 | char *newname = (char *) (comdat + 1); | 1112 | 4 | comdat->name = newname; | 1113 | 4 | memcpy (newname, symname, len); | 1114 | 4 | return true; | 1115 | 4 | } | 1116 | 23 | } | 1117 | 23 | } | 1118 | 1.00k | } | 1119 | | | 1120 | 78 | return true; | 1121 | 87 | } |
Line | Count | Source | 861 | 159 | { | 862 | 159 | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 863 | 159 | bfd_byte *esymstart, *esym, *esymend; | 864 | 159 | int seen_state = 0; | 865 | 159 | char *target_name = NULL; | 866 | | | 867 | 159 | *sec_flags |= SEC_LINK_ONCE; | 868 | | | 869 | | /* Unfortunately, the PE format stores essential information in | 870 | | the symbol table, of all places. We need to extract that | 871 | | information now, so that objdump and the linker will know how | 872 | | to handle the section without worrying about the symbols. We | 873 | | can't call slurp_symtab, because the linker doesn't want the | 874 | | swapped symbols. */ | 875 | | | 876 | | /* COMDAT sections are special. The first symbol is the section | 877 | | symbol, which tells what kind of COMDAT section it is. The | 878 | | second symbol is the "comdat symbol" - the one with the | 879 | | unique name. GNU uses the section symbol for the unique | 880 | | name; MS uses ".text" for every comdat section. Sigh. - DJ */ | 881 | | | 882 | | /* This is not mirrored in sec_to_styp_flags(), but there | 883 | | doesn't seem to be a need to, either, and it would at best be | 884 | | rather messy. */ | 885 | | | 886 | 159 | if (! _bfd_coff_get_external_symbols (abfd)) | 887 | 44 | return true; | 888 | | | 889 | 115 | esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd); | 890 | 115 | esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd); | 891 | | | 892 | 115 | for (struct internal_syment isym; | 893 | 1.90k | esym < esymend; | 894 | 1.78k | esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd)) | 895 | 1.79k | { | 896 | 1.79k | char buf[SYMNMLEN + 1]; | 897 | 1.79k | const char *symname; | 898 | | | 899 | 1.79k | bfd_coff_swap_sym_in (abfd, esym, &isym); | 900 | | | 901 | 1.79k | BFD_ASSERT (sizeof (internal_s->s_name) <= SYMNMLEN); | 902 | | | 903 | 1.79k | if (isym.n_scnum == section->target_index) | 904 | 33 | { | 905 | | /* According to the MSVC documentation, the first | 906 | | TWO entries with the section # are both of | 907 | | interest to us. The first one is the "section | 908 | | symbol" (section name). The second is the comdat | 909 | | symbol name. Here, we've found the first | 910 | | qualifying entry; we distinguish it from the | 911 | | second with a state flag. | 912 | | | 913 | | In the case of gas-generated (at least until that | 914 | | is fixed) .o files, it isn't necessarily the | 915 | | second one. It may be some other later symbol. | 916 | | | 917 | | Since gas also doesn't follow MS conventions and | 918 | | emits the section similar to .text$<name>, where | 919 | | <something> is the name we're looking for, we | 920 | | distinguish the two as follows: | 921 | | | 922 | | If the section name is simply a section name (no | 923 | | $) we presume it's MS-generated, and look at | 924 | | precisely the second symbol for the comdat name. | 925 | | If the section name has a $, we assume it's | 926 | | gas-generated, and look for <something> (whatever | 927 | | follows the $) as the comdat symbol. */ | 928 | | | 929 | | /* All 3 branches use this. */ | 930 | 33 | symname = _bfd_coff_internal_syment_name (abfd, &isym, buf); | 931 | | | 932 | | /* PR 17512 file: 078-11867-0.004 */ | 933 | 33 | if (symname == NULL) | 934 | 2 | { | 935 | 2 | _bfd_error_handler (_("%pB: unable to load COMDAT section name"), | 936 | 2 | abfd); | 937 | 2 | return false; | 938 | 2 | } | 939 | | | 940 | 31 | switch (seen_state) | 941 | 31 | { | 942 | 22 | case 0: | 943 | 22 | { | 944 | | /* The first time we've seen the symbol. */ | 945 | 22 | union internal_auxent aux; | 946 | | | 947 | | /* If it isn't the stuff we're expecting, die; | 948 | | The MS documentation is vague, but it | 949 | | appears that the second entry serves BOTH | 950 | | as the comdat symbol and the defining | 951 | | symbol record (either C_STAT or C_EXT, | 952 | | possibly with an aux entry with debug | 953 | | information if it's a function.) It | 954 | | appears the only way to find the second one | 955 | | is to count. (On Intel, they appear to be | 956 | | adjacent, but on Alpha, they have been | 957 | | found separated.) | 958 | | | 959 | | Here, we think we've found the first one, | 960 | | but there's some checking we can do to be | 961 | | sure. */ | 962 | | | 963 | 22 | if (! ((isym.n_sclass == C_STAT | 964 | 22 | || isym.n_sclass == C_EXT) | 965 | 22 | && BTYPE (isym.n_type) == T_NULL | 966 | 22 | && isym.n_value == 0)) | 967 | 4 | { | 968 | | /* Malformed input files can trigger this test. | 969 | | cf PR 21781. */ | 970 | 4 | _bfd_error_handler (_("%pB: error: unexpected symbol '%s' in COMDAT section"), | 971 | 4 | abfd, symname); | 972 | 4 | return false; | 973 | 4 | } | 974 | | | 975 | | /* FIXME LATER: MSVC generates section names | 976 | | like .text for comdats. Gas generates | 977 | | names like .text$foo__Fv (in the case of a | 978 | | function). See comment above for more. */ | 979 | | | 980 | 18 | if (isym.n_sclass == C_STAT && strcmp (name, symname) != 0) | 981 | | /* xgettext:c-format */ | 982 | 8 | _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'" | 983 | 8 | " does not match section name '%s'"), | 984 | 8 | abfd, symname, name); | 985 | | | 986 | | /* This is the section symbol. */ | 987 | 18 | seen_state = 1; | 988 | 18 | target_name = strchr (name, '$'); | 989 | 18 | if (target_name != NULL) | 990 | 4 | { | 991 | | /* Gas mode. */ | 992 | 4 | seen_state = 2; | 993 | | /* Skip the `$'. */ | 994 | 4 | target_name += 1; | 995 | 4 | } | 996 | | | 997 | 18 | if (isym.n_numaux == 0) | 998 | 11 | aux.x_scn.x_comdat = 0; | 999 | 7 | else | 1000 | 7 | { | 1001 | | /* PR 17512: file: e2cfe54f. */ | 1002 | 7 | if (esym + bfd_coff_symesz (abfd) >= esymend) | 1003 | 1 | { | 1004 | | /* xgettext:c-format */ | 1005 | 1 | _bfd_error_handler (_("%pB: warning: no symbol for" | 1006 | 1 | " section '%s' found"), | 1007 | 1 | abfd, symname); | 1008 | 1 | break; | 1009 | 1 | } | 1010 | 6 | bfd_coff_swap_aux_in (abfd, esym + bfd_coff_symesz (abfd), | 1011 | 6 | isym.n_type, isym.n_sclass, | 1012 | 6 | 0, isym.n_numaux, &aux); | 1013 | 6 | } | 1014 | | | 1015 | | /* FIXME: Microsoft uses NODUPLICATES and | 1016 | | ASSOCIATIVE, but gnu uses ANY and | 1017 | | SAME_SIZE. Unfortunately, gnu doesn't do | 1018 | | the comdat symbols right. So, until we can | 1019 | | fix it to do the right thing, we are | 1020 | | temporarily disabling comdats for the MS | 1021 | | types (they're used in DLLs and C++, but we | 1022 | | don't support *their* C++ libraries anyway | 1023 | | - DJ. */ | 1024 | | | 1025 | | /* Cygwin does not follow the MS style, and | 1026 | | uses ANY and SAME_SIZE where NODUPLICATES | 1027 | | and ASSOCIATIVE should be used. For | 1028 | | Interix, we just do the right thing up | 1029 | | front. */ | 1030 | | | 1031 | 17 | switch (aux.x_scn.x_comdat) | 1032 | 17 | { | 1033 | 1 | case IMAGE_COMDAT_SELECT_NODUPLICATES: | 1034 | | #ifdef STRICT_PE_FORMAT | 1035 | | *sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY; | 1036 | | #else | 1037 | 1 | *sec_flags &= ~SEC_LINK_ONCE; | 1038 | 1 | #endif | 1039 | 1 | break; | 1040 | | | 1041 | 0 | case IMAGE_COMDAT_SELECT_ANY: | 1042 | 0 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1043 | 0 | break; | 1044 | | | 1045 | 1 | case IMAGE_COMDAT_SELECT_SAME_SIZE: | 1046 | 1 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE; | 1047 | 1 | break; | 1048 | | | 1049 | 1 | case IMAGE_COMDAT_SELECT_EXACT_MATCH: | 1050 | | /* Not yet fully implemented ??? */ | 1051 | 1 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS; | 1052 | 1 | break; | 1053 | | | 1054 | | /* debug$S gets this case; other | 1055 | | implications ??? */ | 1056 | | | 1057 | | /* There may be no symbol... we'll search | 1058 | | the whole table... Is this the right | 1059 | | place to play this game? Or should we do | 1060 | | it when reading it in. */ | 1061 | 1 | case IMAGE_COMDAT_SELECT_ASSOCIATIVE: | 1062 | | #ifdef STRICT_PE_FORMAT | 1063 | | /* FIXME: This is not currently implemented. */ | 1064 | | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1065 | | #else | 1066 | 1 | *sec_flags &= ~SEC_LINK_ONCE; | 1067 | 1 | #endif | 1068 | 1 | break; | 1069 | | | 1070 | 13 | default: /* 0 means "no symbol" */ | 1071 | | /* debug$F gets this case; other | 1072 | | implications ??? */ | 1073 | 13 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1074 | 13 | break; | 1075 | 17 | } | 1076 | 17 | } | 1077 | 17 | break; | 1078 | | | 1079 | 17 | case 2: | 1080 | | /* Gas mode: the first matching on partial name. */ | 1081 | | | 1082 | | #ifndef TARGET_UNDERSCORE | 1083 | | #define TARGET_UNDERSCORE 0 | 1084 | | #endif | 1085 | | /* Is this the name we're looking for ? */ | 1086 | 4 | if (strcmp (target_name, | 1087 | 4 | symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0) | 1088 | 3 | { | 1089 | | /* Not the name we're looking for */ | 1090 | 3 | continue; | 1091 | 3 | } | 1092 | | /* Fall through. */ | 1093 | 6 | case 1: | 1094 | | /* MSVC mode: the lexically second symbol (or | 1095 | | drop through from the above). */ | 1096 | 6 | { | 1097 | | /* This must the second symbol with the | 1098 | | section #. It is the actual symbol name. | 1099 | | Intel puts the two adjacent, but Alpha (at | 1100 | | least) spreads them out. */ | 1101 | | | 1102 | 6 | struct coff_comdat_info *comdat; | 1103 | 6 | size_t len = strlen (symname) + 1; | 1104 | | | 1105 | 6 | comdat = bfd_alloc (abfd, sizeof (*comdat) + len); | 1106 | 6 | if (comdat == NULL) | 1107 | 0 | return false; | 1108 | | | 1109 | 6 | coff_section_data (abfd, section)->comdat = comdat; | 1110 | 6 | comdat->symbol = (esym - esymstart) / bfd_coff_symesz (abfd); | 1111 | 6 | char *newname = (char *) (comdat + 1); | 1112 | 6 | comdat->name = newname; | 1113 | 6 | memcpy (newname, symname, len); | 1114 | 6 | return true; | 1115 | 6 | } | 1116 | 31 | } | 1117 | 31 | } | 1118 | 1.79k | } | 1119 | | | 1120 | 103 | return true; | 1121 | 115 | } |
pei-mcore.c:handle_COMDAT Line | Count | Source | 861 | 188 | { | 862 | 188 | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 863 | 188 | bfd_byte *esymstart, *esym, *esymend; | 864 | 188 | int seen_state = 0; | 865 | 188 | char *target_name = NULL; | 866 | | | 867 | 188 | *sec_flags |= SEC_LINK_ONCE; | 868 | | | 869 | | /* Unfortunately, the PE format stores essential information in | 870 | | the symbol table, of all places. We need to extract that | 871 | | information now, so that objdump and the linker will know how | 872 | | to handle the section without worrying about the symbols. We | 873 | | can't call slurp_symtab, because the linker doesn't want the | 874 | | swapped symbols. */ | 875 | | | 876 | | /* COMDAT sections are special. The first symbol is the section | 877 | | symbol, which tells what kind of COMDAT section it is. The | 878 | | second symbol is the "comdat symbol" - the one with the | 879 | | unique name. GNU uses the section symbol for the unique | 880 | | name; MS uses ".text" for every comdat section. Sigh. - DJ */ | 881 | | | 882 | | /* This is not mirrored in sec_to_styp_flags(), but there | 883 | | doesn't seem to be a need to, either, and it would at best be | 884 | | rather messy. */ | 885 | | | 886 | 188 | if (! _bfd_coff_get_external_symbols (abfd)) | 887 | 37 | return true; | 888 | | | 889 | 151 | esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd); | 890 | 151 | esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd); | 891 | | | 892 | 151 | for (struct internal_syment isym; | 893 | 89.0k | esym < esymend; | 894 | 88.8k | esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd)) | 895 | 88.8k | { | 896 | 88.8k | char buf[SYMNMLEN + 1]; | 897 | 88.8k | const char *symname; | 898 | | | 899 | 88.8k | bfd_coff_swap_sym_in (abfd, esym, &isym); | 900 | | | 901 | 88.8k | BFD_ASSERT (sizeof (internal_s->s_name) <= SYMNMLEN); | 902 | | | 903 | 88.8k | if (isym.n_scnum == section->target_index) | 904 | 28 | { | 905 | | /* According to the MSVC documentation, the first | 906 | | TWO entries with the section # are both of | 907 | | interest to us. The first one is the "section | 908 | | symbol" (section name). The second is the comdat | 909 | | symbol name. Here, we've found the first | 910 | | qualifying entry; we distinguish it from the | 911 | | second with a state flag. | 912 | | | 913 | | In the case of gas-generated (at least until that | 914 | | is fixed) .o files, it isn't necessarily the | 915 | | second one. It may be some other later symbol. | 916 | | | 917 | | Since gas also doesn't follow MS conventions and | 918 | | emits the section similar to .text$<name>, where | 919 | | <something> is the name we're looking for, we | 920 | | distinguish the two as follows: | 921 | | | 922 | | If the section name is simply a section name (no | 923 | | $) we presume it's MS-generated, and look at | 924 | | precisely the second symbol for the comdat name. | 925 | | If the section name has a $, we assume it's | 926 | | gas-generated, and look for <something> (whatever | 927 | | follows the $) as the comdat symbol. */ | 928 | | | 929 | | /* All 3 branches use this. */ | 930 | 28 | symname = _bfd_coff_internal_syment_name (abfd, &isym, buf); | 931 | | | 932 | | /* PR 17512 file: 078-11867-0.004 */ | 933 | 28 | if (symname == NULL) | 934 | 2 | { | 935 | 2 | _bfd_error_handler (_("%pB: unable to load COMDAT section name"), | 936 | 2 | abfd); | 937 | 2 | return false; | 938 | 2 | } | 939 | | | 940 | 26 | switch (seen_state) | 941 | 26 | { | 942 | 20 | case 0: | 943 | 20 | { | 944 | | /* The first time we've seen the symbol. */ | 945 | 20 | union internal_auxent aux; | 946 | | | 947 | | /* If it isn't the stuff we're expecting, die; | 948 | | The MS documentation is vague, but it | 949 | | appears that the second entry serves BOTH | 950 | | as the comdat symbol and the defining | 951 | | symbol record (either C_STAT or C_EXT, | 952 | | possibly with an aux entry with debug | 953 | | information if it's a function.) It | 954 | | appears the only way to find the second one | 955 | | is to count. (On Intel, they appear to be | 956 | | adjacent, but on Alpha, they have been | 957 | | found separated.) | 958 | | | 959 | | Here, we think we've found the first one, | 960 | | but there's some checking we can do to be | 961 | | sure. */ | 962 | | | 963 | 20 | if (! ((isym.n_sclass == C_STAT | 964 | 20 | || isym.n_sclass == C_EXT) | 965 | 20 | && BTYPE (isym.n_type) == T_NULL | 966 | 20 | && isym.n_value == 0)) | 967 | 5 | { | 968 | | /* Malformed input files can trigger this test. | 969 | | cf PR 21781. */ | 970 | 5 | _bfd_error_handler (_("%pB: error: unexpected symbol '%s' in COMDAT section"), | 971 | 5 | abfd, symname); | 972 | 5 | return false; | 973 | 5 | } | 974 | | | 975 | | /* FIXME LATER: MSVC generates section names | 976 | | like .text for comdats. Gas generates | 977 | | names like .text$foo__Fv (in the case of a | 978 | | function). See comment above for more. */ | 979 | | | 980 | 15 | if (isym.n_sclass == C_STAT && strcmp (name, symname) != 0) | 981 | | /* xgettext:c-format */ | 982 | 12 | _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'" | 983 | 12 | " does not match section name '%s'"), | 984 | 12 | abfd, symname, name); | 985 | | | 986 | | /* This is the section symbol. */ | 987 | 15 | seen_state = 1; | 988 | 15 | target_name = strchr (name, '$'); | 989 | 15 | if (target_name != NULL) | 990 | 6 | { | 991 | | /* Gas mode. */ | 992 | 6 | seen_state = 2; | 993 | | /* Skip the `$'. */ | 994 | 6 | target_name += 1; | 995 | 6 | } | 996 | | | 997 | 15 | if (isym.n_numaux == 0) | 998 | 11 | aux.x_scn.x_comdat = 0; | 999 | 4 | else | 1000 | 4 | { | 1001 | | /* PR 17512: file: e2cfe54f. */ | 1002 | 4 | if (esym + bfd_coff_symesz (abfd) >= esymend) | 1003 | 1 | { | 1004 | | /* xgettext:c-format */ | 1005 | 1 | _bfd_error_handler (_("%pB: warning: no symbol for" | 1006 | 1 | " section '%s' found"), | 1007 | 1 | abfd, symname); | 1008 | 1 | break; | 1009 | 1 | } | 1010 | 3 | bfd_coff_swap_aux_in (abfd, esym + bfd_coff_symesz (abfd), | 1011 | 3 | isym.n_type, isym.n_sclass, | 1012 | 3 | 0, isym.n_numaux, &aux); | 1013 | 3 | } | 1014 | | | 1015 | | /* FIXME: Microsoft uses NODUPLICATES and | 1016 | | ASSOCIATIVE, but gnu uses ANY and | 1017 | | SAME_SIZE. Unfortunately, gnu doesn't do | 1018 | | the comdat symbols right. So, until we can | 1019 | | fix it to do the right thing, we are | 1020 | | temporarily disabling comdats for the MS | 1021 | | types (they're used in DLLs and C++, but we | 1022 | | don't support *their* C++ libraries anyway | 1023 | | - DJ. */ | 1024 | | | 1025 | | /* Cygwin does not follow the MS style, and | 1026 | | uses ANY and SAME_SIZE where NODUPLICATES | 1027 | | and ASSOCIATIVE should be used. For | 1028 | | Interix, we just do the right thing up | 1029 | | front. */ | 1030 | | | 1031 | 14 | switch (aux.x_scn.x_comdat) | 1032 | 14 | { | 1033 | 1 | case IMAGE_COMDAT_SELECT_NODUPLICATES: | 1034 | | #ifdef STRICT_PE_FORMAT | 1035 | | *sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY; | 1036 | | #else | 1037 | 1 | *sec_flags &= ~SEC_LINK_ONCE; | 1038 | 1 | #endif | 1039 | 1 | break; | 1040 | | | 1041 | 0 | case IMAGE_COMDAT_SELECT_ANY: | 1042 | 0 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1043 | 0 | break; | 1044 | | | 1045 | 1 | case IMAGE_COMDAT_SELECT_SAME_SIZE: | 1046 | 1 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE; | 1047 | 1 | break; | 1048 | | | 1049 | 0 | case IMAGE_COMDAT_SELECT_EXACT_MATCH: | 1050 | | /* Not yet fully implemented ??? */ | 1051 | 0 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS; | 1052 | 0 | break; | 1053 | | | 1054 | | /* debug$S gets this case; other | 1055 | | implications ??? */ | 1056 | | | 1057 | | /* There may be no symbol... we'll search | 1058 | | the whole table... Is this the right | 1059 | | place to play this game? Or should we do | 1060 | | it when reading it in. */ | 1061 | 1 | case IMAGE_COMDAT_SELECT_ASSOCIATIVE: | 1062 | | #ifdef STRICT_PE_FORMAT | 1063 | | /* FIXME: This is not currently implemented. */ | 1064 | | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1065 | | #else | 1066 | 1 | *sec_flags &= ~SEC_LINK_ONCE; | 1067 | 1 | #endif | 1068 | 1 | break; | 1069 | | | 1070 | 11 | default: /* 0 means "no symbol" */ | 1071 | | /* debug$F gets this case; other | 1072 | | implications ??? */ | 1073 | 11 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1074 | 11 | break; | 1075 | 14 | } | 1076 | 14 | } | 1077 | 14 | break; | 1078 | | | 1079 | 14 | case 2: | 1080 | | /* Gas mode: the first matching on partial name. */ | 1081 | | | 1082 | 3 | #ifndef TARGET_UNDERSCORE | 1083 | 3 | #define TARGET_UNDERSCORE 0 | 1084 | 3 | #endif | 1085 | | /* Is this the name we're looking for ? */ | 1086 | 3 | if (strcmp (target_name, | 1087 | 3 | symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0) | 1088 | 3 | { | 1089 | | /* Not the name we're looking for */ | 1090 | 3 | continue; | 1091 | 3 | } | 1092 | | /* Fall through. */ | 1093 | 3 | case 1: | 1094 | | /* MSVC mode: the lexically second symbol (or | 1095 | | drop through from the above). */ | 1096 | 3 | { | 1097 | | /* This must the second symbol with the | 1098 | | section #. It is the actual symbol name. | 1099 | | Intel puts the two adjacent, but Alpha (at | 1100 | | least) spreads them out. */ | 1101 | | | 1102 | 3 | struct coff_comdat_info *comdat; | 1103 | 3 | size_t len = strlen (symname) + 1; | 1104 | | | 1105 | 3 | comdat = bfd_alloc (abfd, sizeof (*comdat) + len); | 1106 | 3 | if (comdat == NULL) | 1107 | 0 | return false; | 1108 | | | 1109 | 3 | coff_section_data (abfd, section)->comdat = comdat; | 1110 | 3 | comdat->symbol = (esym - esymstart) / bfd_coff_symesz (abfd); | 1111 | 3 | char *newname = (char *) (comdat + 1); | 1112 | 3 | comdat->name = newname; | 1113 | 3 | memcpy (newname, symname, len); | 1114 | 3 | return true; | 1115 | 3 | } | 1116 | 26 | } | 1117 | 26 | } | 1118 | 88.8k | } | 1119 | | | 1120 | 141 | return true; | 1121 | 151 | } |
Line | Count | Source | 861 | 108 | { | 862 | 108 | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 863 | 108 | bfd_byte *esymstart, *esym, *esymend; | 864 | 108 | int seen_state = 0; | 865 | 108 | char *target_name = NULL; | 866 | | | 867 | 108 | *sec_flags |= SEC_LINK_ONCE; | 868 | | | 869 | | /* Unfortunately, the PE format stores essential information in | 870 | | the symbol table, of all places. We need to extract that | 871 | | information now, so that objdump and the linker will know how | 872 | | to handle the section without worrying about the symbols. We | 873 | | can't call slurp_symtab, because the linker doesn't want the | 874 | | swapped symbols. */ | 875 | | | 876 | | /* COMDAT sections are special. The first symbol is the section | 877 | | symbol, which tells what kind of COMDAT section it is. The | 878 | | second symbol is the "comdat symbol" - the one with the | 879 | | unique name. GNU uses the section symbol for the unique | 880 | | name; MS uses ".text" for every comdat section. Sigh. - DJ */ | 881 | | | 882 | | /* This is not mirrored in sec_to_styp_flags(), but there | 883 | | doesn't seem to be a need to, either, and it would at best be | 884 | | rather messy. */ | 885 | | | 886 | 108 | if (! _bfd_coff_get_external_symbols (abfd)) | 887 | 28 | return true; | 888 | | | 889 | 80 | esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd); | 890 | 80 | esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd); | 891 | | | 892 | 80 | for (struct internal_syment isym; | 893 | 524 | esym < esymend; | 894 | 444 | esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd)) | 895 | 453 | { | 896 | 453 | char buf[SYMNMLEN + 1]; | 897 | 453 | const char *symname; | 898 | | | 899 | 453 | bfd_coff_swap_sym_in (abfd, esym, &isym); | 900 | | | 901 | 453 | BFD_ASSERT (sizeof (internal_s->s_name) <= SYMNMLEN); | 902 | | | 903 | 453 | if (isym.n_scnum == section->target_index) | 904 | 24 | { | 905 | | /* According to the MSVC documentation, the first | 906 | | TWO entries with the section # are both of | 907 | | interest to us. The first one is the "section | 908 | | symbol" (section name). The second is the comdat | 909 | | symbol name. Here, we've found the first | 910 | | qualifying entry; we distinguish it from the | 911 | | second with a state flag. | 912 | | | 913 | | In the case of gas-generated (at least until that | 914 | | is fixed) .o files, it isn't necessarily the | 915 | | second one. It may be some other later symbol. | 916 | | | 917 | | Since gas also doesn't follow MS conventions and | 918 | | emits the section similar to .text$<name>, where | 919 | | <something> is the name we're looking for, we | 920 | | distinguish the two as follows: | 921 | | | 922 | | If the section name is simply a section name (no | 923 | | $) we presume it's MS-generated, and look at | 924 | | precisely the second symbol for the comdat name. | 925 | | If the section name has a $, we assume it's | 926 | | gas-generated, and look for <something> (whatever | 927 | | follows the $) as the comdat symbol. */ | 928 | | | 929 | | /* All 3 branches use this. */ | 930 | 24 | symname = _bfd_coff_internal_syment_name (abfd, &isym, buf); | 931 | | | 932 | | /* PR 17512 file: 078-11867-0.004 */ | 933 | 24 | if (symname == NULL) | 934 | 3 | { | 935 | 3 | _bfd_error_handler (_("%pB: unable to load COMDAT section name"), | 936 | 3 | abfd); | 937 | 3 | return false; | 938 | 3 | } | 939 | | | 940 | 21 | switch (seen_state) | 941 | 21 | { | 942 | 18 | case 0: | 943 | 18 | { | 944 | | /* The first time we've seen the symbol. */ | 945 | 18 | union internal_auxent aux; | 946 | | | 947 | | /* If it isn't the stuff we're expecting, die; | 948 | | The MS documentation is vague, but it | 949 | | appears that the second entry serves BOTH | 950 | | as the comdat symbol and the defining | 951 | | symbol record (either C_STAT or C_EXT, | 952 | | possibly with an aux entry with debug | 953 | | information if it's a function.) It | 954 | | appears the only way to find the second one | 955 | | is to count. (On Intel, they appear to be | 956 | | adjacent, but on Alpha, they have been | 957 | | found separated.) | 958 | | | 959 | | Here, we think we've found the first one, | 960 | | but there's some checking we can do to be | 961 | | sure. */ | 962 | | | 963 | 18 | if (! ((isym.n_sclass == C_STAT | 964 | 18 | || isym.n_sclass == C_EXT) | 965 | 18 | && BTYPE (isym.n_type) == T_NULL | 966 | 18 | && isym.n_value == 0)) | 967 | 4 | { | 968 | | /* Malformed input files can trigger this test. | 969 | | cf PR 21781. */ | 970 | 4 | _bfd_error_handler (_("%pB: error: unexpected symbol '%s' in COMDAT section"), | 971 | 4 | abfd, symname); | 972 | 4 | return false; | 973 | 4 | } | 974 | | | 975 | | /* FIXME LATER: MSVC generates section names | 976 | | like .text for comdats. Gas generates | 977 | | names like .text$foo__Fv (in the case of a | 978 | | function). See comment above for more. */ | 979 | | | 980 | 14 | if (isym.n_sclass == C_STAT && strcmp (name, symname) != 0) | 981 | | /* xgettext:c-format */ | 982 | 12 | _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'" | 983 | 12 | " does not match section name '%s'"), | 984 | 12 | abfd, symname, name); | 985 | | | 986 | | /* This is the section symbol. */ | 987 | 14 | seen_state = 1; | 988 | 14 | target_name = strchr (name, '$'); | 989 | 14 | if (target_name != NULL) | 990 | 4 | { | 991 | | /* Gas mode. */ | 992 | 4 | seen_state = 2; | 993 | | /* Skip the `$'. */ | 994 | 4 | target_name += 1; | 995 | 4 | } | 996 | | | 997 | 14 | if (isym.n_numaux == 0) | 998 | 8 | aux.x_scn.x_comdat = 0; | 999 | 6 | else | 1000 | 6 | { | 1001 | | /* PR 17512: file: e2cfe54f. */ | 1002 | 6 | if (esym + bfd_coff_symesz (abfd) >= esymend) | 1003 | 1 | { | 1004 | | /* xgettext:c-format */ | 1005 | 1 | _bfd_error_handler (_("%pB: warning: no symbol for" | 1006 | 1 | " section '%s' found"), | 1007 | 1 | abfd, symname); | 1008 | 1 | break; | 1009 | 1 | } | 1010 | 5 | bfd_coff_swap_aux_in (abfd, esym + bfd_coff_symesz (abfd), | 1011 | 5 | isym.n_type, isym.n_sclass, | 1012 | 5 | 0, isym.n_numaux, &aux); | 1013 | 5 | } | 1014 | | | 1015 | | /* FIXME: Microsoft uses NODUPLICATES and | 1016 | | ASSOCIATIVE, but gnu uses ANY and | 1017 | | SAME_SIZE. Unfortunately, gnu doesn't do | 1018 | | the comdat symbols right. So, until we can | 1019 | | fix it to do the right thing, we are | 1020 | | temporarily disabling comdats for the MS | 1021 | | types (they're used in DLLs and C++, but we | 1022 | | don't support *their* C++ libraries anyway | 1023 | | - DJ. */ | 1024 | | | 1025 | | /* Cygwin does not follow the MS style, and | 1026 | | uses ANY and SAME_SIZE where NODUPLICATES | 1027 | | and ASSOCIATIVE should be used. For | 1028 | | Interix, we just do the right thing up | 1029 | | front. */ | 1030 | | | 1031 | 13 | switch (aux.x_scn.x_comdat) | 1032 | 13 | { | 1033 | 1 | case IMAGE_COMDAT_SELECT_NODUPLICATES: | 1034 | | #ifdef STRICT_PE_FORMAT | 1035 | | *sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY; | 1036 | | #else | 1037 | 1 | *sec_flags &= ~SEC_LINK_ONCE; | 1038 | 1 | #endif | 1039 | 1 | break; | 1040 | | | 1041 | 0 | case IMAGE_COMDAT_SELECT_ANY: | 1042 | 0 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1043 | 0 | break; | 1044 | | | 1045 | 1 | case IMAGE_COMDAT_SELECT_SAME_SIZE: | 1046 | 1 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE; | 1047 | 1 | break; | 1048 | | | 1049 | 1 | case IMAGE_COMDAT_SELECT_EXACT_MATCH: | 1050 | | /* Not yet fully implemented ??? */ | 1051 | 1 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS; | 1052 | 1 | break; | 1053 | | | 1054 | | /* debug$S gets this case; other | 1055 | | implications ??? */ | 1056 | | | 1057 | | /* There may be no symbol... we'll search | 1058 | | the whole table... Is this the right | 1059 | | place to play this game? Or should we do | 1060 | | it when reading it in. */ | 1061 | 1 | case IMAGE_COMDAT_SELECT_ASSOCIATIVE: | 1062 | | #ifdef STRICT_PE_FORMAT | 1063 | | /* FIXME: This is not currently implemented. */ | 1064 | | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1065 | | #else | 1066 | 1 | *sec_flags &= ~SEC_LINK_ONCE; | 1067 | 1 | #endif | 1068 | 1 | break; | 1069 | | | 1070 | 9 | default: /* 0 means "no symbol" */ | 1071 | | /* debug$F gets this case; other | 1072 | | implications ??? */ | 1073 | 9 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1074 | 9 | break; | 1075 | 13 | } | 1076 | 13 | } | 1077 | 13 | break; | 1078 | | | 1079 | 13 | case 2: | 1080 | | /* Gas mode: the first matching on partial name. */ | 1081 | | | 1082 | | #ifndef TARGET_UNDERSCORE | 1083 | | #define TARGET_UNDERSCORE 0 | 1084 | | #endif | 1085 | | /* Is this the name we're looking for ? */ | 1086 | 2 | if (strcmp (target_name, | 1087 | 2 | symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0) | 1088 | 1 | { | 1089 | | /* Not the name we're looking for */ | 1090 | 1 | continue; | 1091 | 1 | } | 1092 | | /* Fall through. */ | 1093 | 2 | case 1: | 1094 | | /* MSVC mode: the lexically second symbol (or | 1095 | | drop through from the above). */ | 1096 | 2 | { | 1097 | | /* This must the second symbol with the | 1098 | | section #. It is the actual symbol name. | 1099 | | Intel puts the two adjacent, but Alpha (at | 1100 | | least) spreads them out. */ | 1101 | | | 1102 | 2 | struct coff_comdat_info *comdat; | 1103 | 2 | size_t len = strlen (symname) + 1; | 1104 | | | 1105 | 2 | comdat = bfd_alloc (abfd, sizeof (*comdat) + len); | 1106 | 2 | if (comdat == NULL) | 1107 | 0 | return false; | 1108 | | | 1109 | 2 | coff_section_data (abfd, section)->comdat = comdat; | 1110 | 2 | comdat->symbol = (esym - esymstart) / bfd_coff_symesz (abfd); | 1111 | 2 | char *newname = (char *) (comdat + 1); | 1112 | 2 | comdat->name = newname; | 1113 | 2 | memcpy (newname, symname, len); | 1114 | 2 | return true; | 1115 | 2 | } | 1116 | 21 | } | 1117 | 21 | } | 1118 | 453 | } | 1119 | | | 1120 | 71 | return true; | 1121 | 80 | } |
|
1122 | | |
1123 | | |
1124 | | /* The PE version; see above for the general comments. |
1125 | | |
1126 | | Since to set the SEC_LINK_ONCE and associated flags, we have to |
1127 | | look at the symbol table anyway, we return the symbol table index |
1128 | | of the symbol being used as the COMDAT symbol. This is admittedly |
1129 | | ugly, but there's really nowhere else that we have access to the |
1130 | | required information. FIXME: Is the COMDAT symbol index used for |
1131 | | any purpose other than objdump? */ |
1132 | | |
1133 | | static bool |
1134 | | styp_to_sec_flags (bfd *abfd, |
1135 | | void * hdr, |
1136 | | const char *name, |
1137 | | asection *section, |
1138 | | flagword *flags_ptr) |
1139 | 55.2k | { |
1140 | 55.2k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; |
1141 | 55.2k | unsigned long styp_flags = internal_s->s_flags; |
1142 | 55.2k | flagword sec_flags; |
1143 | 55.2k | bool result = true; |
1144 | 55.2k | bool is_dbg = false; |
1145 | | |
1146 | 55.2k | if (startswith (name, DOT_DEBUG) |
1147 | 55.2k | || startswith (name, DOT_ZDEBUG) |
1148 | 55.2k | #ifdef COFF_LONG_SECTION_NAMES |
1149 | 55.2k | || startswith (name, GNU_LINKONCE_WI) |
1150 | 55.2k | || startswith (name, GNU_LINKONCE_WT) |
1151 | | /* FIXME: These definitions ought to be in a header file. */ |
1152 | 55.2k | #define GNU_DEBUGLINK ".gnu_debuglink" |
1153 | 55.2k | #define GNU_DEBUGALTLINK ".gnu_debugaltlink" |
1154 | 55.2k | || startswith (name, GNU_DEBUGLINK) |
1155 | 55.2k | || startswith (name, GNU_DEBUGALTLINK) |
1156 | 55.2k | #endif |
1157 | 55.2k | || startswith (name, ".stab")) |
1158 | 325 | is_dbg = true; |
1159 | | /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified. */ |
1160 | 55.2k | sec_flags = SEC_READONLY; |
1161 | | |
1162 | | /* If section disallows read, then set the NOREAD flag. */ |
1163 | 55.2k | if ((styp_flags & IMAGE_SCN_MEM_READ) == 0) |
1164 | 37.1k | sec_flags |= SEC_COFF_NOREAD; |
1165 | | |
1166 | | /* Process each flag bit in styp_flags in turn. */ |
1167 | 360k | while (styp_flags) |
1168 | 305k | { |
1169 | 305k | unsigned long flag = styp_flags & - styp_flags; |
1170 | 305k | char * unhandled = NULL; |
1171 | | |
1172 | 305k | styp_flags &= ~ flag; |
1173 | | |
1174 | | /* We infer from the distinct read/write/execute bits the settings |
1175 | | of some of the bfd flags; the actual values, should we need them, |
1176 | | are also in pei_section_data (abfd, section)->pe_flags. */ |
1177 | | |
1178 | 305k | switch (flag) |
1179 | 305k | { |
1180 | 1.18k | case STYP_DSECT: |
1181 | 1.18k | unhandled = "STYP_DSECT"; |
1182 | 1.18k | break; |
1183 | 1.16k | case STYP_GROUP: |
1184 | 1.16k | unhandled = "STYP_GROUP"; |
1185 | 1.16k | break; |
1186 | 1.18k | case STYP_COPY: |
1187 | 1.18k | unhandled = "STYP_COPY"; |
1188 | 1.18k | break; |
1189 | 1.26k | case STYP_OVER: |
1190 | 1.26k | unhandled = "STYP_OVER"; |
1191 | 1.26k | break; |
1192 | 0 | #ifdef SEC_NEVER_LOAD |
1193 | 10.7k | case STYP_NOLOAD: |
1194 | 10.7k | sec_flags |= SEC_NEVER_LOAD; |
1195 | 10.7k | break; |
1196 | 0 | #endif |
1197 | 18.1k | case IMAGE_SCN_MEM_READ: |
1198 | 18.1k | sec_flags &= ~SEC_COFF_NOREAD; |
1199 | 18.1k | break; |
1200 | 14.8k | case IMAGE_SCN_TYPE_NO_PAD: |
1201 | | /* Skip. */ |
1202 | 14.8k | break; |
1203 | 1.35k | case IMAGE_SCN_LNK_OTHER: |
1204 | 1.35k | unhandled = "IMAGE_SCN_LNK_OTHER"; |
1205 | 1.35k | break; |
1206 | 1.22k | case IMAGE_SCN_MEM_NOT_CACHED: |
1207 | 1.22k | unhandled = "IMAGE_SCN_MEM_NOT_CACHED"; |
1208 | 1.22k | break; |
1209 | 15.9k | case IMAGE_SCN_MEM_NOT_PAGED: |
1210 | | /* Generate a warning message rather using the 'unhandled' |
1211 | | variable as this will allow some .sys files generate by |
1212 | | other toolchains to be processed. See bugzilla issue 196. */ |
1213 | | /* xgettext:c-format */ |
1214 | 15.9k | _bfd_error_handler (_("%pB: warning: ignoring section flag" |
1215 | 15.9k | " %s in section %s"), |
1216 | 15.9k | abfd, "IMAGE_SCN_MEM_NOT_PAGED", name); |
1217 | 15.9k | break; |
1218 | 17.6k | case IMAGE_SCN_MEM_EXECUTE: |
1219 | 17.6k | sec_flags |= SEC_CODE; |
1220 | 17.6k | break; |
1221 | 8.98k | case IMAGE_SCN_MEM_WRITE: |
1222 | 8.98k | sec_flags &= ~ SEC_READONLY; |
1223 | 8.98k | break; |
1224 | 10.9k | case IMAGE_SCN_MEM_DISCARDABLE: |
1225 | | /* The MS PE spec says that debug sections are DISCARDABLE, |
1226 | | but the presence of a DISCARDABLE flag does not necessarily |
1227 | | mean that a given section contains debug information. Thus |
1228 | | we only set the SEC_DEBUGGING flag on sections that we |
1229 | | recognise as containing debug information. */ |
1230 | 10.9k | if (is_dbg |
1231 | 10.9k | #ifdef _COMMENT |
1232 | 10.9k | || strcmp (name, _COMMENT) == 0 |
1233 | 10.9k | #endif |
1234 | 10.9k | ) |
1235 | 163 | { |
1236 | 163 | sec_flags |= SEC_DEBUGGING | SEC_READONLY; |
1237 | 163 | } |
1238 | 10.9k | break; |
1239 | 2.13k | case IMAGE_SCN_MEM_SHARED: |
1240 | 2.13k | sec_flags |= SEC_COFF_SHARED; |
1241 | 2.13k | break; |
1242 | 15.4k | case IMAGE_SCN_LNK_REMOVE: |
1243 | 15.4k | if (!is_dbg) |
1244 | 15.3k | sec_flags |= SEC_EXCLUDE; |
1245 | 15.4k | break; |
1246 | 16.7k | case IMAGE_SCN_CNT_CODE: |
1247 | 16.7k | sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD; |
1248 | 16.7k | break; |
1249 | 17.1k | case IMAGE_SCN_CNT_INITIALIZED_DATA: |
1250 | 17.1k | if (is_dbg) |
1251 | 103 | sec_flags |= SEC_DEBUGGING; |
1252 | 17.0k | else |
1253 | 17.0k | sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD; |
1254 | 17.1k | break; |
1255 | 8.05k | case IMAGE_SCN_CNT_UNINITIALIZED_DATA: |
1256 | 8.05k | sec_flags |= SEC_ALLOC; |
1257 | 8.05k | break; |
1258 | 10.7k | case IMAGE_SCN_LNK_INFO: |
1259 | | /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is |
1260 | | defined. coff_compute_section_file_positions uses |
1261 | | COFF_PAGE_SIZE to ensure that the low order bits of the |
1262 | | section VMA and the file offset match. If we don't know |
1263 | | COFF_PAGE_SIZE, we can't ensure the correct correspondence, |
1264 | | and demand page loading of the file will fail. */ |
1265 | | #ifdef COFF_PAGE_SIZE |
1266 | 10.5k | sec_flags |= SEC_DEBUGGING; |
1267 | | #endif |
1268 | 10.7k | break; |
1269 | 3.18k | case IMAGE_SCN_LNK_COMDAT: |
1270 | | /* COMDAT gets very special treatment. */ |
1271 | 3.18k | if (!handle_COMDAT (abfd, &sec_flags, hdr, name, section)) |
1272 | 144 | result = false; |
1273 | 3.18k | break; |
1274 | 127k | default: |
1275 | | /* Silently ignore for now. */ |
1276 | 127k | break; |
1277 | 305k | } |
1278 | | |
1279 | | /* If the section flag was not handled, report it here. */ |
1280 | 305k | if (unhandled != NULL) |
1281 | 7.37k | { |
1282 | 7.37k | _bfd_error_handler |
1283 | | /* xgettext:c-format */ |
1284 | 7.37k | (_("%pB (%s): section flag %s (%#lx) ignored"), |
1285 | 7.37k | abfd, name, unhandled, flag); |
1286 | 7.37k | result = false; |
1287 | 7.37k | } |
1288 | 305k | } |
1289 | | |
1290 | 55.2k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 |
1291 | 55.2k | && (startswith (name, ".sbss") |
1292 | 0 | || startswith (name, ".sdata"))) |
1293 | 0 | sec_flags |= SEC_SMALL_DATA; |
1294 | | |
1295 | | #if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE) |
1296 | | /* As a GNU extension, if the name begins with .gnu.linkonce, we |
1297 | | only link a single copy of the section. This is used to support |
1298 | | g++. g++ will emit each template expansion in its own section. |
1299 | | The symbols will be defined as weak, so that multiple definitions |
1300 | | are permitted. The GNU linker extension is to actually discard |
1301 | | all but one of the sections. */ |
1302 | 18.9k | if (startswith (name, ".gnu.linkonce")) |
1303 | 0 | sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; |
1304 | | #endif |
1305 | | |
1306 | 55.2k | if (flags_ptr) |
1307 | 55.2k | * flags_ptr = sec_flags; |
1308 | | |
1309 | 55.2k | return result; |
1310 | 55.2k | } pei-i386.c:styp_to_sec_flags Line | Count | Source | 1139 | 3.24k | { | 1140 | 3.24k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 1141 | 3.24k | unsigned long styp_flags = internal_s->s_flags; | 1142 | 3.24k | flagword sec_flags; | 1143 | 3.24k | bool result = true; | 1144 | 3.24k | bool is_dbg = false; | 1145 | | | 1146 | 3.24k | if (startswith (name, DOT_DEBUG) | 1147 | 3.24k | || startswith (name, DOT_ZDEBUG) | 1148 | 3.24k | #ifdef COFF_LONG_SECTION_NAMES | 1149 | 3.24k | || startswith (name, GNU_LINKONCE_WI) | 1150 | 3.24k | || startswith (name, GNU_LINKONCE_WT) | 1151 | | /* FIXME: These definitions ought to be in a header file. */ | 1152 | 3.24k | #define GNU_DEBUGLINK ".gnu_debuglink" | 1153 | 3.24k | #define GNU_DEBUGALTLINK ".gnu_debugaltlink" | 1154 | 3.24k | || startswith (name, GNU_DEBUGLINK) | 1155 | 3.24k | || startswith (name, GNU_DEBUGALTLINK) | 1156 | 3.24k | #endif | 1157 | 3.24k | || startswith (name, ".stab")) | 1158 | 21 | is_dbg = true; | 1159 | | /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified. */ | 1160 | 3.24k | sec_flags = SEC_READONLY; | 1161 | | | 1162 | | /* If section disallows read, then set the NOREAD flag. */ | 1163 | 3.24k | if ((styp_flags & IMAGE_SCN_MEM_READ) == 0) | 1164 | 2.85k | sec_flags |= SEC_COFF_NOREAD; | 1165 | | | 1166 | | /* Process each flag bit in styp_flags in turn. */ | 1167 | 12.1k | while (styp_flags) | 1168 | 8.86k | { | 1169 | 8.86k | unsigned long flag = styp_flags & - styp_flags; | 1170 | 8.86k | char * unhandled = NULL; | 1171 | | | 1172 | 8.86k | styp_flags &= ~ flag; | 1173 | | | 1174 | | /* We infer from the distinct read/write/execute bits the settings | 1175 | | of some of the bfd flags; the actual values, should we need them, | 1176 | | are also in pei_section_data (abfd, section)->pe_flags. */ | 1177 | | | 1178 | 8.86k | switch (flag) | 1179 | 8.86k | { | 1180 | 32 | case STYP_DSECT: | 1181 | 32 | unhandled = "STYP_DSECT"; | 1182 | 32 | break; | 1183 | 32 | case STYP_GROUP: | 1184 | 32 | unhandled = "STYP_GROUP"; | 1185 | 32 | break; | 1186 | 36 | case STYP_COPY: | 1187 | 36 | unhandled = "STYP_COPY"; | 1188 | 36 | break; | 1189 | 40 | case STYP_OVER: | 1190 | 40 | unhandled = "STYP_OVER"; | 1191 | 40 | break; | 1192 | 0 | #ifdef SEC_NEVER_LOAD | 1193 | 640 | case STYP_NOLOAD: | 1194 | 640 | sec_flags |= SEC_NEVER_LOAD; | 1195 | 640 | break; | 1196 | 0 | #endif | 1197 | 391 | case IMAGE_SCN_MEM_READ: | 1198 | 391 | sec_flags &= ~SEC_COFF_NOREAD; | 1199 | 391 | break; | 1200 | 268 | case IMAGE_SCN_TYPE_NO_PAD: | 1201 | | /* Skip. */ | 1202 | 268 | break; | 1203 | 33 | case IMAGE_SCN_LNK_OTHER: | 1204 | 33 | unhandled = "IMAGE_SCN_LNK_OTHER"; | 1205 | 33 | break; | 1206 | 34 | case IMAGE_SCN_MEM_NOT_CACHED: | 1207 | 34 | unhandled = "IMAGE_SCN_MEM_NOT_CACHED"; | 1208 | 34 | break; | 1209 | 302 | case IMAGE_SCN_MEM_NOT_PAGED: | 1210 | | /* Generate a warning message rather using the 'unhandled' | 1211 | | variable as this will allow some .sys files generate by | 1212 | | other toolchains to be processed. See bugzilla issue 196. */ | 1213 | | /* xgettext:c-format */ | 1214 | 302 | _bfd_error_handler (_("%pB: warning: ignoring section flag" | 1215 | 302 | " %s in section %s"), | 1216 | 302 | abfd, "IMAGE_SCN_MEM_NOT_PAGED", name); | 1217 | 302 | break; | 1218 | 299 | case IMAGE_SCN_MEM_EXECUTE: | 1219 | 299 | sec_flags |= SEC_CODE; | 1220 | 299 | break; | 1221 | 340 | case IMAGE_SCN_MEM_WRITE: | 1222 | 340 | sec_flags &= ~ SEC_READONLY; | 1223 | 340 | break; | 1224 | 666 | case IMAGE_SCN_MEM_DISCARDABLE: | 1225 | | /* The MS PE spec says that debug sections are DISCARDABLE, | 1226 | | but the presence of a DISCARDABLE flag does not necessarily | 1227 | | mean that a given section contains debug information. Thus | 1228 | | we only set the SEC_DEBUGGING flag on sections that we | 1229 | | recognise as containing debug information. */ | 1230 | 666 | if (is_dbg | 1231 | 666 | #ifdef _COMMENT | 1232 | 666 | || strcmp (name, _COMMENT) == 0 | 1233 | 666 | #endif | 1234 | 666 | ) | 1235 | 9 | { | 1236 | 9 | sec_flags |= SEC_DEBUGGING | SEC_READONLY; | 1237 | 9 | } | 1238 | 666 | break; | 1239 | 121 | case IMAGE_SCN_MEM_SHARED: | 1240 | 121 | sec_flags |= SEC_COFF_SHARED; | 1241 | 121 | break; | 1242 | 260 | case IMAGE_SCN_LNK_REMOVE: | 1243 | 260 | if (!is_dbg) | 1244 | 252 | sec_flags |= SEC_EXCLUDE; | 1245 | 260 | break; | 1246 | 316 | case IMAGE_SCN_CNT_CODE: | 1247 | 316 | sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD; | 1248 | 316 | break; | 1249 | 349 | case IMAGE_SCN_CNT_INITIALIZED_DATA: | 1250 | 349 | if (is_dbg) | 1251 | 7 | sec_flags |= SEC_DEBUGGING; | 1252 | 342 | else | 1253 | 342 | sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD; | 1254 | 349 | break; | 1255 | 289 | case IMAGE_SCN_CNT_UNINITIALIZED_DATA: | 1256 | 289 | sec_flags |= SEC_ALLOC; | 1257 | 289 | break; | 1258 | 612 | case IMAGE_SCN_LNK_INFO: | 1259 | | /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is | 1260 | | defined. coff_compute_section_file_positions uses | 1261 | | COFF_PAGE_SIZE to ensure that the low order bits of the | 1262 | | section VMA and the file offset match. If we don't know | 1263 | | COFF_PAGE_SIZE, we can't ensure the correct correspondence, | 1264 | | and demand page loading of the file will fail. */ | 1265 | 612 | #ifdef COFF_PAGE_SIZE | 1266 | 612 | sec_flags |= SEC_DEBUGGING; | 1267 | 612 | #endif | 1268 | 612 | break; | 1269 | 116 | case IMAGE_SCN_LNK_COMDAT: | 1270 | | /* COMDAT gets very special treatment. */ | 1271 | 116 | if (!handle_COMDAT (abfd, &sec_flags, hdr, name, section)) | 1272 | 4 | result = false; | 1273 | 116 | break; | 1274 | 3.68k | default: | 1275 | | /* Silently ignore for now. */ | 1276 | 3.68k | break; | 1277 | 8.86k | } | 1278 | | | 1279 | | /* If the section flag was not handled, report it here. */ | 1280 | 8.86k | if (unhandled != NULL) | 1281 | 207 | { | 1282 | 207 | _bfd_error_handler | 1283 | | /* xgettext:c-format */ | 1284 | 207 | (_("%pB (%s): section flag %s (%#lx) ignored"), | 1285 | 207 | abfd, name, unhandled, flag); | 1286 | 207 | result = false; | 1287 | 207 | } | 1288 | 8.86k | } | 1289 | | | 1290 | 3.24k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 1291 | 3.24k | && (startswith (name, ".sbss") | 1292 | 0 | || startswith (name, ".sdata"))) | 1293 | 0 | sec_flags |= SEC_SMALL_DATA; | 1294 | | | 1295 | 3.24k | #if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE) | 1296 | | /* As a GNU extension, if the name begins with .gnu.linkonce, we | 1297 | | only link a single copy of the section. This is used to support | 1298 | | g++. g++ will emit each template expansion in its own section. | 1299 | | The symbols will be defined as weak, so that multiple definitions | 1300 | | are permitted. The GNU linker extension is to actually discard | 1301 | | all but one of the sections. */ | 1302 | 3.24k | if (startswith (name, ".gnu.linkonce")) | 1303 | 0 | sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; | 1304 | 3.24k | #endif | 1305 | | | 1306 | 3.24k | if (flags_ptr) | 1307 | 3.24k | * flags_ptr = sec_flags; | 1308 | | | 1309 | 3.24k | return result; | 1310 | 3.24k | } |
pe-x86_64.c:styp_to_sec_flags Line | Count | Source | 1139 | 5.29k | { | 1140 | 5.29k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 1141 | 5.29k | unsigned long styp_flags = internal_s->s_flags; | 1142 | 5.29k | flagword sec_flags; | 1143 | 5.29k | bool result = true; | 1144 | 5.29k | bool is_dbg = false; | 1145 | | | 1146 | 5.29k | if (startswith (name, DOT_DEBUG) | 1147 | 5.29k | || startswith (name, DOT_ZDEBUG) | 1148 | 5.29k | #ifdef COFF_LONG_SECTION_NAMES | 1149 | 5.29k | || startswith (name, GNU_LINKONCE_WI) | 1150 | 5.29k | || startswith (name, GNU_LINKONCE_WT) | 1151 | | /* FIXME: These definitions ought to be in a header file. */ | 1152 | 5.29k | #define GNU_DEBUGLINK ".gnu_debuglink" | 1153 | 5.29k | #define GNU_DEBUGALTLINK ".gnu_debugaltlink" | 1154 | 5.29k | || startswith (name, GNU_DEBUGLINK) | 1155 | 5.29k | || startswith (name, GNU_DEBUGALTLINK) | 1156 | 5.29k | #endif | 1157 | 5.29k | || startswith (name, ".stab")) | 1158 | 65 | is_dbg = true; | 1159 | | /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified. */ | 1160 | 5.29k | sec_flags = SEC_READONLY; | 1161 | | | 1162 | | /* If section disallows read, then set the NOREAD flag. */ | 1163 | 5.29k | if ((styp_flags & IMAGE_SCN_MEM_READ) == 0) | 1164 | 4.64k | sec_flags |= SEC_COFF_NOREAD; | 1165 | | | 1166 | | /* Process each flag bit in styp_flags in turn. */ | 1167 | 25.3k | while (styp_flags) | 1168 | 20.0k | { | 1169 | 20.0k | unsigned long flag = styp_flags & - styp_flags; | 1170 | 20.0k | char * unhandled = NULL; | 1171 | | | 1172 | 20.0k | styp_flags &= ~ flag; | 1173 | | | 1174 | | /* We infer from the distinct read/write/execute bits the settings | 1175 | | of some of the bfd flags; the actual values, should we need them, | 1176 | | are also in pei_section_data (abfd, section)->pe_flags. */ | 1177 | | | 1178 | 20.0k | switch (flag) | 1179 | 20.0k | { | 1180 | 248 | case STYP_DSECT: | 1181 | 248 | unhandled = "STYP_DSECT"; | 1182 | 248 | break; | 1183 | 237 | case STYP_GROUP: | 1184 | 237 | unhandled = "STYP_GROUP"; | 1185 | 237 | break; | 1186 | 240 | case STYP_COPY: | 1187 | 240 | unhandled = "STYP_COPY"; | 1188 | 240 | break; | 1189 | 270 | case STYP_OVER: | 1190 | 270 | unhandled = "STYP_OVER"; | 1191 | 270 | break; | 1192 | 0 | #ifdef SEC_NEVER_LOAD | 1193 | 893 | case STYP_NOLOAD: | 1194 | 893 | sec_flags |= SEC_NEVER_LOAD; | 1195 | 893 | break; | 1196 | 0 | #endif | 1197 | 644 | case IMAGE_SCN_MEM_READ: | 1198 | 644 | sec_flags &= ~SEC_COFF_NOREAD; | 1199 | 644 | break; | 1200 | 811 | case IMAGE_SCN_TYPE_NO_PAD: | 1201 | | /* Skip. */ | 1202 | 811 | break; | 1203 | 289 | case IMAGE_SCN_LNK_OTHER: | 1204 | 289 | unhandled = "IMAGE_SCN_LNK_OTHER"; | 1205 | 289 | break; | 1206 | 279 | case IMAGE_SCN_MEM_NOT_CACHED: | 1207 | 279 | unhandled = "IMAGE_SCN_MEM_NOT_CACHED"; | 1208 | 279 | break; | 1209 | 1.22k | case IMAGE_SCN_MEM_NOT_PAGED: | 1210 | | /* Generate a warning message rather using the 'unhandled' | 1211 | | variable as this will allow some .sys files generate by | 1212 | | other toolchains to be processed. See bugzilla issue 196. */ | 1213 | | /* xgettext:c-format */ | 1214 | 1.22k | _bfd_error_handler (_("%pB: warning: ignoring section flag" | 1215 | 1.22k | " %s in section %s"), | 1216 | 1.22k | abfd, "IMAGE_SCN_MEM_NOT_PAGED", name); | 1217 | 1.22k | break; | 1218 | 752 | case IMAGE_SCN_MEM_EXECUTE: | 1219 | 752 | sec_flags |= SEC_CODE; | 1220 | 752 | break; | 1221 | 472 | case IMAGE_SCN_MEM_WRITE: | 1222 | 472 | sec_flags &= ~ SEC_READONLY; | 1223 | 472 | break; | 1224 | 1.17k | case IMAGE_SCN_MEM_DISCARDABLE: | 1225 | | /* The MS PE spec says that debug sections are DISCARDABLE, | 1226 | | but the presence of a DISCARDABLE flag does not necessarily | 1227 | | mean that a given section contains debug information. Thus | 1228 | | we only set the SEC_DEBUGGING flag on sections that we | 1229 | | recognise as containing debug information. */ | 1230 | 1.17k | if (is_dbg | 1231 | 1.17k | #ifdef _COMMENT | 1232 | 1.17k | || strcmp (name, _COMMENT) == 0 | 1233 | 1.17k | #endif | 1234 | 1.17k | ) | 1235 | 25 | { | 1236 | 25 | sec_flags |= SEC_DEBUGGING | SEC_READONLY; | 1237 | 25 | } | 1238 | 1.17k | break; | 1239 | 498 | case IMAGE_SCN_MEM_SHARED: | 1240 | 498 | sec_flags |= SEC_COFF_SHARED; | 1241 | 498 | break; | 1242 | 945 | case IMAGE_SCN_LNK_REMOVE: | 1243 | 945 | if (!is_dbg) | 1244 | 930 | sec_flags |= SEC_EXCLUDE; | 1245 | 945 | break; | 1246 | 647 | case IMAGE_SCN_CNT_CODE: | 1247 | 647 | sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD; | 1248 | 647 | break; | 1249 | 492 | case IMAGE_SCN_CNT_INITIALIZED_DATA: | 1250 | 492 | if (is_dbg) | 1251 | 22 | sec_flags |= SEC_DEBUGGING; | 1252 | 470 | else | 1253 | 470 | sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD; | 1254 | 492 | break; | 1255 | 300 | case IMAGE_SCN_CNT_UNINITIALIZED_DATA: | 1256 | 300 | sec_flags |= SEC_ALLOC; | 1257 | 300 | break; | 1258 | 1.00k | case IMAGE_SCN_LNK_INFO: | 1259 | | /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is | 1260 | | defined. coff_compute_section_file_positions uses | 1261 | | COFF_PAGE_SIZE to ensure that the low order bits of the | 1262 | | section VMA and the file offset match. If we don't know | 1263 | | COFF_PAGE_SIZE, we can't ensure the correct correspondence, | 1264 | | and demand page loading of the file will fail. */ | 1265 | 1.00k | #ifdef COFF_PAGE_SIZE | 1266 | 1.00k | sec_flags |= SEC_DEBUGGING; | 1267 | 1.00k | #endif | 1268 | 1.00k | break; | 1269 | 547 | case IMAGE_SCN_LNK_COMDAT: | 1270 | | /* COMDAT gets very special treatment. */ | 1271 | 547 | if (!handle_COMDAT (abfd, &sec_flags, hdr, name, section)) | 1272 | 44 | result = false; | 1273 | 547 | break; | 1274 | 8.10k | default: | 1275 | | /* Silently ignore for now. */ | 1276 | 8.10k | break; | 1277 | 20.0k | } | 1278 | | | 1279 | | /* If the section flag was not handled, report it here. */ | 1280 | 20.0k | if (unhandled != NULL) | 1281 | 1.56k | { | 1282 | 1.56k | _bfd_error_handler | 1283 | | /* xgettext:c-format */ | 1284 | 1.56k | (_("%pB (%s): section flag %s (%#lx) ignored"), | 1285 | 1.56k | abfd, name, unhandled, flag); | 1286 | 1.56k | result = false; | 1287 | 1.56k | } | 1288 | 20.0k | } | 1289 | | | 1290 | 5.29k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 1291 | 5.29k | && (startswith (name, ".sbss") | 1292 | 0 | || startswith (name, ".sdata"))) | 1293 | 0 | sec_flags |= SEC_SMALL_DATA; | 1294 | | | 1295 | 5.29k | #if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE) | 1296 | | /* As a GNU extension, if the name begins with .gnu.linkonce, we | 1297 | | only link a single copy of the section. This is used to support | 1298 | | g++. g++ will emit each template expansion in its own section. | 1299 | | The symbols will be defined as weak, so that multiple definitions | 1300 | | are permitted. The GNU linker extension is to actually discard | 1301 | | all but one of the sections. */ | 1302 | 5.29k | if (startswith (name, ".gnu.linkonce")) | 1303 | 0 | sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; | 1304 | 5.29k | #endif | 1305 | | | 1306 | 5.29k | if (flags_ptr) | 1307 | 5.29k | * flags_ptr = sec_flags; | 1308 | | | 1309 | 5.29k | return result; | 1310 | 5.29k | } |
pei-x86_64.c:styp_to_sec_flags Line | Count | Source | 1139 | 3.26k | { | 1140 | 3.26k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 1141 | 3.26k | unsigned long styp_flags = internal_s->s_flags; | 1142 | 3.26k | flagword sec_flags; | 1143 | 3.26k | bool result = true; | 1144 | 3.26k | bool is_dbg = false; | 1145 | | | 1146 | 3.26k | if (startswith (name, DOT_DEBUG) | 1147 | 3.26k | || startswith (name, DOT_ZDEBUG) | 1148 | 3.26k | #ifdef COFF_LONG_SECTION_NAMES | 1149 | 3.26k | || startswith (name, GNU_LINKONCE_WI) | 1150 | 3.26k | || startswith (name, GNU_LINKONCE_WT) | 1151 | | /* FIXME: These definitions ought to be in a header file. */ | 1152 | 3.26k | #define GNU_DEBUGLINK ".gnu_debuglink" | 1153 | 3.26k | #define GNU_DEBUGALTLINK ".gnu_debugaltlink" | 1154 | 3.26k | || startswith (name, GNU_DEBUGLINK) | 1155 | 3.26k | || startswith (name, GNU_DEBUGALTLINK) | 1156 | 3.26k | #endif | 1157 | 3.26k | || startswith (name, ".stab")) | 1158 | 26 | is_dbg = true; | 1159 | | /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified. */ | 1160 | 3.26k | sec_flags = SEC_READONLY; | 1161 | | | 1162 | | /* If section disallows read, then set the NOREAD flag. */ | 1163 | 3.26k | if ((styp_flags & IMAGE_SCN_MEM_READ) == 0) | 1164 | 2.94k | sec_flags |= SEC_COFF_NOREAD; | 1165 | | | 1166 | | /* Process each flag bit in styp_flags in turn. */ | 1167 | 10.3k | while (styp_flags) | 1168 | 7.08k | { | 1169 | 7.08k | unsigned long flag = styp_flags & - styp_flags; | 1170 | 7.08k | char * unhandled = NULL; | 1171 | | | 1172 | 7.08k | styp_flags &= ~ flag; | 1173 | | | 1174 | | /* We infer from the distinct read/write/execute bits the settings | 1175 | | of some of the bfd flags; the actual values, should we need them, | 1176 | | are also in pei_section_data (abfd, section)->pe_flags. */ | 1177 | | | 1178 | 7.08k | switch (flag) | 1179 | 7.08k | { | 1180 | 42 | case STYP_DSECT: | 1181 | 42 | unhandled = "STYP_DSECT"; | 1182 | 42 | break; | 1183 | 40 | case STYP_GROUP: | 1184 | 40 | unhandled = "STYP_GROUP"; | 1185 | 40 | break; | 1186 | 32 | case STYP_COPY: | 1187 | 32 | unhandled = "STYP_COPY"; | 1188 | 32 | break; | 1189 | 40 | case STYP_OVER: | 1190 | 40 | unhandled = "STYP_OVER"; | 1191 | 40 | break; | 1192 | 0 | #ifdef SEC_NEVER_LOAD | 1193 | 316 | case STYP_NOLOAD: | 1194 | 316 | sec_flags |= SEC_NEVER_LOAD; | 1195 | 316 | break; | 1196 | 0 | #endif | 1197 | 319 | case IMAGE_SCN_MEM_READ: | 1198 | 319 | sec_flags &= ~SEC_COFF_NOREAD; | 1199 | 319 | break; | 1200 | 260 | case IMAGE_SCN_TYPE_NO_PAD: | 1201 | | /* Skip. */ | 1202 | 260 | break; | 1203 | 42 | case IMAGE_SCN_LNK_OTHER: | 1204 | 42 | unhandled = "IMAGE_SCN_LNK_OTHER"; | 1205 | 42 | break; | 1206 | 42 | case IMAGE_SCN_MEM_NOT_CACHED: | 1207 | 42 | unhandled = "IMAGE_SCN_MEM_NOT_CACHED"; | 1208 | 42 | break; | 1209 | 313 | case IMAGE_SCN_MEM_NOT_PAGED: | 1210 | | /* Generate a warning message rather using the 'unhandled' | 1211 | | variable as this will allow some .sys files generate by | 1212 | | other toolchains to be processed. See bugzilla issue 196. */ | 1213 | | /* xgettext:c-format */ | 1214 | 313 | _bfd_error_handler (_("%pB: warning: ignoring section flag" | 1215 | 313 | " %s in section %s"), | 1216 | 313 | abfd, "IMAGE_SCN_MEM_NOT_PAGED", name); | 1217 | 313 | break; | 1218 | 309 | case IMAGE_SCN_MEM_EXECUTE: | 1219 | 309 | sec_flags |= SEC_CODE; | 1220 | 309 | break; | 1221 | 283 | case IMAGE_SCN_MEM_WRITE: | 1222 | 283 | sec_flags &= ~ SEC_READONLY; | 1223 | 283 | break; | 1224 | 349 | case IMAGE_SCN_MEM_DISCARDABLE: | 1225 | | /* The MS PE spec says that debug sections are DISCARDABLE, | 1226 | | but the presence of a DISCARDABLE flag does not necessarily | 1227 | | mean that a given section contains debug information. Thus | 1228 | | we only set the SEC_DEBUGGING flag on sections that we | 1229 | | recognise as containing debug information. */ | 1230 | 349 | if (is_dbg | 1231 | 349 | #ifdef _COMMENT | 1232 | 349 | || strcmp (name, _COMMENT) == 0 | 1233 | 349 | #endif | 1234 | 349 | ) | 1235 | 11 | { | 1236 | 11 | sec_flags |= SEC_DEBUGGING | SEC_READONLY; | 1237 | 11 | } | 1238 | 349 | break; | 1239 | 114 | case IMAGE_SCN_MEM_SHARED: | 1240 | 114 | sec_flags |= SEC_COFF_SHARED; | 1241 | 114 | break; | 1242 | 333 | case IMAGE_SCN_LNK_REMOVE: | 1243 | 333 | if (!is_dbg) | 1244 | 329 | sec_flags |= SEC_EXCLUDE; | 1245 | 333 | break; | 1246 | 263 | case IMAGE_SCN_CNT_CODE: | 1247 | 263 | sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD; | 1248 | 263 | break; | 1249 | 270 | case IMAGE_SCN_CNT_INITIALIZED_DATA: | 1250 | 270 | if (is_dbg) | 1251 | 4 | sec_flags |= SEC_DEBUGGING; | 1252 | 266 | else | 1253 | 266 | sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD; | 1254 | 270 | break; | 1255 | 212 | case IMAGE_SCN_CNT_UNINITIALIZED_DATA: | 1256 | 212 | sec_flags |= SEC_ALLOC; | 1257 | 212 | break; | 1258 | 381 | case IMAGE_SCN_LNK_INFO: | 1259 | | /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is | 1260 | | defined. coff_compute_section_file_positions uses | 1261 | | COFF_PAGE_SIZE to ensure that the low order bits of the | 1262 | | section VMA and the file offset match. If we don't know | 1263 | | COFF_PAGE_SIZE, we can't ensure the correct correspondence, | 1264 | | and demand page loading of the file will fail. */ | 1265 | 381 | #ifdef COFF_PAGE_SIZE | 1266 | 381 | sec_flags |= SEC_DEBUGGING; | 1267 | 381 | #endif | 1268 | 381 | break; | 1269 | 264 | case IMAGE_SCN_LNK_COMDAT: | 1270 | | /* COMDAT gets very special treatment. */ | 1271 | 264 | if (!handle_COMDAT (abfd, &sec_flags, hdr, name, section)) | 1272 | 4 | result = false; | 1273 | 264 | break; | 1274 | 2.86k | default: | 1275 | | /* Silently ignore for now. */ | 1276 | 2.86k | break; | 1277 | 7.08k | } | 1278 | | | 1279 | | /* If the section flag was not handled, report it here. */ | 1280 | 7.08k | if (unhandled != NULL) | 1281 | 238 | { | 1282 | 238 | _bfd_error_handler | 1283 | | /* xgettext:c-format */ | 1284 | 238 | (_("%pB (%s): section flag %s (%#lx) ignored"), | 1285 | 238 | abfd, name, unhandled, flag); | 1286 | 238 | result = false; | 1287 | 238 | } | 1288 | 7.08k | } | 1289 | | | 1290 | 3.26k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 1291 | 3.26k | && (startswith (name, ".sbss") | 1292 | 0 | || startswith (name, ".sdata"))) | 1293 | 0 | sec_flags |= SEC_SMALL_DATA; | 1294 | | | 1295 | 3.26k | #if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE) | 1296 | | /* As a GNU extension, if the name begins with .gnu.linkonce, we | 1297 | | only link a single copy of the section. This is used to support | 1298 | | g++. g++ will emit each template expansion in its own section. | 1299 | | The symbols will be defined as weak, so that multiple definitions | 1300 | | are permitted. The GNU linker extension is to actually discard | 1301 | | all but one of the sections. */ | 1302 | 3.26k | if (startswith (name, ".gnu.linkonce")) | 1303 | 0 | sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; | 1304 | 3.26k | #endif | 1305 | | | 1306 | 3.26k | if (flags_ptr) | 1307 | 3.26k | * flags_ptr = sec_flags; | 1308 | | | 1309 | 3.26k | return result; | 1310 | 3.26k | } |
pei-aarch64.c:styp_to_sec_flags Line | Count | Source | 1139 | 1.73k | { | 1140 | 1.73k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 1141 | 1.73k | unsigned long styp_flags = internal_s->s_flags; | 1142 | 1.73k | flagword sec_flags; | 1143 | 1.73k | bool result = true; | 1144 | 1.73k | bool is_dbg = false; | 1145 | | | 1146 | 1.73k | if (startswith (name, DOT_DEBUG) | 1147 | 1.73k | || startswith (name, DOT_ZDEBUG) | 1148 | 1.73k | #ifdef COFF_LONG_SECTION_NAMES | 1149 | 1.73k | || startswith (name, GNU_LINKONCE_WI) | 1150 | 1.73k | || startswith (name, GNU_LINKONCE_WT) | 1151 | | /* FIXME: These definitions ought to be in a header file. */ | 1152 | 1.73k | #define GNU_DEBUGLINK ".gnu_debuglink" | 1153 | 1.73k | #define GNU_DEBUGALTLINK ".gnu_debugaltlink" | 1154 | 1.73k | || startswith (name, GNU_DEBUGLINK) | 1155 | 1.73k | || startswith (name, GNU_DEBUGALTLINK) | 1156 | 1.73k | #endif | 1157 | 1.73k | || startswith (name, ".stab")) | 1158 | 5 | is_dbg = true; | 1159 | | /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified. */ | 1160 | 1.73k | sec_flags = SEC_READONLY; | 1161 | | | 1162 | | /* If section disallows read, then set the NOREAD flag. */ | 1163 | 1.73k | if ((styp_flags & IMAGE_SCN_MEM_READ) == 0) | 1164 | 1.43k | sec_flags |= SEC_COFF_NOREAD; | 1165 | | | 1166 | | /* Process each flag bit in styp_flags in turn. */ | 1167 | 8.88k | while (styp_flags) | 1168 | 7.14k | { | 1169 | 7.14k | unsigned long flag = styp_flags & - styp_flags; | 1170 | 7.14k | char * unhandled = NULL; | 1171 | | | 1172 | 7.14k | styp_flags &= ~ flag; | 1173 | | | 1174 | | /* We infer from the distinct read/write/execute bits the settings | 1175 | | of some of the bfd flags; the actual values, should we need them, | 1176 | | are also in pei_section_data (abfd, section)->pe_flags. */ | 1177 | | | 1178 | 7.14k | switch (flag) | 1179 | 7.14k | { | 1180 | 47 | case STYP_DSECT: | 1181 | 47 | unhandled = "STYP_DSECT"; | 1182 | 47 | break; | 1183 | 45 | case STYP_GROUP: | 1184 | 45 | unhandled = "STYP_GROUP"; | 1185 | 45 | break; | 1186 | 46 | case STYP_COPY: | 1187 | 46 | unhandled = "STYP_COPY"; | 1188 | 46 | break; | 1189 | 41 | case STYP_OVER: | 1190 | 41 | unhandled = "STYP_OVER"; | 1191 | 41 | break; | 1192 | 0 | #ifdef SEC_NEVER_LOAD | 1193 | 249 | case STYP_NOLOAD: | 1194 | 249 | sec_flags |= SEC_NEVER_LOAD; | 1195 | 249 | break; | 1196 | 0 | #endif | 1197 | 301 | case IMAGE_SCN_MEM_READ: | 1198 | 301 | sec_flags &= ~SEC_COFF_NOREAD; | 1199 | 301 | break; | 1200 | 435 | case IMAGE_SCN_TYPE_NO_PAD: | 1201 | | /* Skip. */ | 1202 | 435 | break; | 1203 | 52 | case IMAGE_SCN_LNK_OTHER: | 1204 | 52 | unhandled = "IMAGE_SCN_LNK_OTHER"; | 1205 | 52 | break; | 1206 | 40 | case IMAGE_SCN_MEM_NOT_CACHED: | 1207 | 40 | unhandled = "IMAGE_SCN_MEM_NOT_CACHED"; | 1208 | 40 | break; | 1209 | 446 | case IMAGE_SCN_MEM_NOT_PAGED: | 1210 | | /* Generate a warning message rather using the 'unhandled' | 1211 | | variable as this will allow some .sys files generate by | 1212 | | other toolchains to be processed. See bugzilla issue 196. */ | 1213 | | /* xgettext:c-format */ | 1214 | 446 | _bfd_error_handler (_("%pB: warning: ignoring section flag" | 1215 | 446 | " %s in section %s"), | 1216 | 446 | abfd, "IMAGE_SCN_MEM_NOT_PAGED", name); | 1217 | 446 | break; | 1218 | 417 | case IMAGE_SCN_MEM_EXECUTE: | 1219 | 417 | sec_flags |= SEC_CODE; | 1220 | 417 | break; | 1221 | 151 | case IMAGE_SCN_MEM_WRITE: | 1222 | 151 | sec_flags &= ~ SEC_READONLY; | 1223 | 151 | break; | 1224 | 262 | case IMAGE_SCN_MEM_DISCARDABLE: | 1225 | | /* The MS PE spec says that debug sections are DISCARDABLE, | 1226 | | but the presence of a DISCARDABLE flag does not necessarily | 1227 | | mean that a given section contains debug information. Thus | 1228 | | we only set the SEC_DEBUGGING flag on sections that we | 1229 | | recognise as containing debug information. */ | 1230 | 262 | if (is_dbg | 1231 | 262 | #ifdef _COMMENT | 1232 | 262 | || strcmp (name, _COMMENT) == 0 | 1233 | 262 | #endif | 1234 | 262 | ) | 1235 | 1 | { | 1236 | 1 | sec_flags |= SEC_DEBUGGING | SEC_READONLY; | 1237 | 1 | } | 1238 | 262 | break; | 1239 | 65 | case IMAGE_SCN_MEM_SHARED: | 1240 | 65 | sec_flags |= SEC_COFF_SHARED; | 1241 | 65 | break; | 1242 | 464 | case IMAGE_SCN_LNK_REMOVE: | 1243 | 464 | if (!is_dbg) | 1244 | 463 | sec_flags |= SEC_EXCLUDE; | 1245 | 464 | break; | 1246 | 393 | case IMAGE_SCN_CNT_CODE: | 1247 | 393 | sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD; | 1248 | 393 | break; | 1249 | 293 | case IMAGE_SCN_CNT_INITIALIZED_DATA: | 1250 | 293 | if (is_dbg) | 1251 | 2 | sec_flags |= SEC_DEBUGGING; | 1252 | 291 | else | 1253 | 291 | sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD; | 1254 | 293 | break; | 1255 | 151 | case IMAGE_SCN_CNT_UNINITIALIZED_DATA: | 1256 | 151 | sec_flags |= SEC_ALLOC; | 1257 | 151 | break; | 1258 | 246 | case IMAGE_SCN_LNK_INFO: | 1259 | | /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is | 1260 | | defined. coff_compute_section_file_positions uses | 1261 | | COFF_PAGE_SIZE to ensure that the low order bits of the | 1262 | | section VMA and the file offset match. If we don't know | 1263 | | COFF_PAGE_SIZE, we can't ensure the correct correspondence, | 1264 | | and demand page loading of the file will fail. */ | 1265 | 246 | #ifdef COFF_PAGE_SIZE | 1266 | 246 | sec_flags |= SEC_DEBUGGING; | 1267 | 246 | #endif | 1268 | 246 | break; | 1269 | 86 | case IMAGE_SCN_LNK_COMDAT: | 1270 | | /* COMDAT gets very special treatment. */ | 1271 | 86 | if (!handle_COMDAT (abfd, &sec_flags, hdr, name, section)) | 1272 | 5 | result = false; | 1273 | 86 | break; | 1274 | 2.91k | default: | 1275 | | /* Silently ignore for now. */ | 1276 | 2.91k | break; | 1277 | 7.14k | } | 1278 | | | 1279 | | /* If the section flag was not handled, report it here. */ | 1280 | 7.14k | if (unhandled != NULL) | 1281 | 271 | { | 1282 | 271 | _bfd_error_handler | 1283 | | /* xgettext:c-format */ | 1284 | 271 | (_("%pB (%s): section flag %s (%#lx) ignored"), | 1285 | 271 | abfd, name, unhandled, flag); | 1286 | 271 | result = false; | 1287 | 271 | } | 1288 | 7.14k | } | 1289 | | | 1290 | 1.73k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 1291 | 1.73k | && (startswith (name, ".sbss") | 1292 | 0 | || startswith (name, ".sdata"))) | 1293 | 0 | sec_flags |= SEC_SMALL_DATA; | 1294 | | | 1295 | | #if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE) | 1296 | | /* As a GNU extension, if the name begins with .gnu.linkonce, we | 1297 | | only link a single copy of the section. This is used to support | 1298 | | g++. g++ will emit each template expansion in its own section. | 1299 | | The symbols will be defined as weak, so that multiple definitions | 1300 | | are permitted. The GNU linker extension is to actually discard | 1301 | | all but one of the sections. */ | 1302 | | if (startswith (name, ".gnu.linkonce")) | 1303 | | sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; | 1304 | | #endif | 1305 | | | 1306 | 1.73k | if (flags_ptr) | 1307 | 1.73k | * flags_ptr = sec_flags; | 1308 | | | 1309 | 1.73k | return result; | 1310 | 1.73k | } |
pe-aarch64.c:styp_to_sec_flags Line | Count | Source | 1139 | 5.47k | { | 1140 | 5.47k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 1141 | 5.47k | unsigned long styp_flags = internal_s->s_flags; | 1142 | 5.47k | flagword sec_flags; | 1143 | 5.47k | bool result = true; | 1144 | 5.47k | bool is_dbg = false; | 1145 | | | 1146 | 5.47k | if (startswith (name, DOT_DEBUG) | 1147 | 5.47k | || startswith (name, DOT_ZDEBUG) | 1148 | 5.47k | #ifdef COFF_LONG_SECTION_NAMES | 1149 | 5.47k | || startswith (name, GNU_LINKONCE_WI) | 1150 | 5.47k | || startswith (name, GNU_LINKONCE_WT) | 1151 | | /* FIXME: These definitions ought to be in a header file. */ | 1152 | 5.47k | #define GNU_DEBUGLINK ".gnu_debuglink" | 1153 | 5.47k | #define GNU_DEBUGALTLINK ".gnu_debugaltlink" | 1154 | 5.47k | || startswith (name, GNU_DEBUGLINK) | 1155 | 5.47k | || startswith (name, GNU_DEBUGALTLINK) | 1156 | 5.47k | #endif | 1157 | 5.47k | || startswith (name, ".stab")) | 1158 | 16 | is_dbg = true; | 1159 | | /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified. */ | 1160 | 5.47k | sec_flags = SEC_READONLY; | 1161 | | | 1162 | | /* If section disallows read, then set the NOREAD flag. */ | 1163 | 5.47k | if ((styp_flags & IMAGE_SCN_MEM_READ) == 0) | 1164 | 5.08k | sec_flags |= SEC_COFF_NOREAD; | 1165 | | | 1166 | | /* Process each flag bit in styp_flags in turn. */ | 1167 | 15.8k | while (styp_flags) | 1168 | 10.4k | { | 1169 | 10.4k | unsigned long flag = styp_flags & - styp_flags; | 1170 | 10.4k | char * unhandled = NULL; | 1171 | | | 1172 | 10.4k | styp_flags &= ~ flag; | 1173 | | | 1174 | | /* We infer from the distinct read/write/execute bits the settings | 1175 | | of some of the bfd flags; the actual values, should we need them, | 1176 | | are also in pei_section_data (abfd, section)->pe_flags. */ | 1177 | | | 1178 | 10.4k | switch (flag) | 1179 | 10.4k | { | 1180 | 67 | case STYP_DSECT: | 1181 | 67 | unhandled = "STYP_DSECT"; | 1182 | 67 | break; | 1183 | 66 | case STYP_GROUP: | 1184 | 66 | unhandled = "STYP_GROUP"; | 1185 | 66 | break; | 1186 | 57 | case STYP_COPY: | 1187 | 57 | unhandled = "STYP_COPY"; | 1188 | 57 | break; | 1189 | 84 | case STYP_OVER: | 1190 | 84 | unhandled = "STYP_OVER"; | 1191 | 84 | break; | 1192 | 0 | #ifdef SEC_NEVER_LOAD | 1193 | 1.28k | case STYP_NOLOAD: | 1194 | 1.28k | sec_flags |= SEC_NEVER_LOAD; | 1195 | 1.28k | break; | 1196 | 0 | #endif | 1197 | 392 | case IMAGE_SCN_MEM_READ: | 1198 | 392 | sec_flags &= ~SEC_COFF_NOREAD; | 1199 | 392 | break; | 1200 | 550 | case IMAGE_SCN_TYPE_NO_PAD: | 1201 | | /* Skip. */ | 1202 | 550 | break; | 1203 | 81 | case IMAGE_SCN_LNK_OTHER: | 1204 | 81 | unhandled = "IMAGE_SCN_LNK_OTHER"; | 1205 | 81 | break; | 1206 | 65 | case IMAGE_SCN_MEM_NOT_CACHED: | 1207 | 65 | unhandled = "IMAGE_SCN_MEM_NOT_CACHED"; | 1208 | 65 | break; | 1209 | 615 | case IMAGE_SCN_MEM_NOT_PAGED: | 1210 | | /* Generate a warning message rather using the 'unhandled' | 1211 | | variable as this will allow some .sys files generate by | 1212 | | other toolchains to be processed. See bugzilla issue 196. */ | 1213 | | /* xgettext:c-format */ | 1214 | 615 | _bfd_error_handler (_("%pB: warning: ignoring section flag" | 1215 | 615 | " %s in section %s"), | 1216 | 615 | abfd, "IMAGE_SCN_MEM_NOT_PAGED", name); | 1217 | 615 | break; | 1218 | 374 | case IMAGE_SCN_MEM_EXECUTE: | 1219 | 374 | sec_flags |= SEC_CODE; | 1220 | 374 | break; | 1221 | 192 | case IMAGE_SCN_MEM_WRITE: | 1222 | 192 | sec_flags &= ~ SEC_READONLY; | 1223 | 192 | break; | 1224 | 594 | case IMAGE_SCN_MEM_DISCARDABLE: | 1225 | | /* The MS PE spec says that debug sections are DISCARDABLE, | 1226 | | but the presence of a DISCARDABLE flag does not necessarily | 1227 | | mean that a given section contains debug information. Thus | 1228 | | we only set the SEC_DEBUGGING flag on sections that we | 1229 | | recognise as containing debug information. */ | 1230 | 594 | if (is_dbg | 1231 | 594 | #ifdef _COMMENT | 1232 | 594 | || strcmp (name, _COMMENT) == 0 | 1233 | 594 | #endif | 1234 | 594 | ) | 1235 | 6 | { | 1236 | 6 | sec_flags |= SEC_DEBUGGING | SEC_READONLY; | 1237 | 6 | } | 1238 | 594 | break; | 1239 | 119 | case IMAGE_SCN_MEM_SHARED: | 1240 | 119 | sec_flags |= SEC_COFF_SHARED; | 1241 | 119 | break; | 1242 | 597 | case IMAGE_SCN_LNK_REMOVE: | 1243 | 597 | if (!is_dbg) | 1244 | 593 | sec_flags |= SEC_EXCLUDE; | 1245 | 597 | break; | 1246 | 330 | case IMAGE_SCN_CNT_CODE: | 1247 | 330 | sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD; | 1248 | 330 | break; | 1249 | 332 | case IMAGE_SCN_CNT_INITIALIZED_DATA: | 1250 | 332 | if (is_dbg) | 1251 | 4 | sec_flags |= SEC_DEBUGGING; | 1252 | 328 | else | 1253 | 328 | sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD; | 1254 | 332 | break; | 1255 | 163 | case IMAGE_SCN_CNT_UNINITIALIZED_DATA: | 1256 | 163 | sec_flags |= SEC_ALLOC; | 1257 | 163 | break; | 1258 | 635 | case IMAGE_SCN_LNK_INFO: | 1259 | | /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is | 1260 | | defined. coff_compute_section_file_positions uses | 1261 | | COFF_PAGE_SIZE to ensure that the low order bits of the | 1262 | | section VMA and the file offset match. If we don't know | 1263 | | COFF_PAGE_SIZE, we can't ensure the correct correspondence, | 1264 | | and demand page loading of the file will fail. */ | 1265 | 635 | #ifdef COFF_PAGE_SIZE | 1266 | 635 | sec_flags |= SEC_DEBUGGING; | 1267 | 635 | #endif | 1268 | 635 | break; | 1269 | 136 | case IMAGE_SCN_LNK_COMDAT: | 1270 | | /* COMDAT gets very special treatment. */ | 1271 | 136 | if (!handle_COMDAT (abfd, &sec_flags, hdr, name, section)) | 1272 | 7 | result = false; | 1273 | 136 | break; | 1274 | 3.66k | default: | 1275 | | /* Silently ignore for now. */ | 1276 | 3.66k | break; | 1277 | 10.4k | } | 1278 | | | 1279 | | /* If the section flag was not handled, report it here. */ | 1280 | 10.4k | if (unhandled != NULL) | 1281 | 420 | { | 1282 | 420 | _bfd_error_handler | 1283 | | /* xgettext:c-format */ | 1284 | 420 | (_("%pB (%s): section flag %s (%#lx) ignored"), | 1285 | 420 | abfd, name, unhandled, flag); | 1286 | 420 | result = false; | 1287 | 420 | } | 1288 | 10.4k | } | 1289 | | | 1290 | 5.47k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 1291 | 5.47k | && (startswith (name, ".sbss") | 1292 | 0 | || startswith (name, ".sdata"))) | 1293 | 0 | sec_flags |= SEC_SMALL_DATA; | 1294 | | | 1295 | | #if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE) | 1296 | | /* As a GNU extension, if the name begins with .gnu.linkonce, we | 1297 | | only link a single copy of the section. This is used to support | 1298 | | g++. g++ will emit each template expansion in its own section. | 1299 | | The symbols will be defined as weak, so that multiple definitions | 1300 | | are permitted. The GNU linker extension is to actually discard | 1301 | | all but one of the sections. */ | 1302 | | if (startswith (name, ".gnu.linkonce")) | 1303 | | sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; | 1304 | | #endif | 1305 | | | 1306 | 5.47k | if (flags_ptr) | 1307 | 5.47k | * flags_ptr = sec_flags; | 1308 | | | 1309 | 5.47k | return result; | 1310 | 5.47k | } |
pei-ia64.c:styp_to_sec_flags Line | Count | Source | 1139 | 2.23k | { | 1140 | 2.23k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 1141 | 2.23k | unsigned long styp_flags = internal_s->s_flags; | 1142 | 2.23k | flagword sec_flags; | 1143 | 2.23k | bool result = true; | 1144 | 2.23k | bool is_dbg = false; | 1145 | | | 1146 | 2.23k | if (startswith (name, DOT_DEBUG) | 1147 | 2.23k | || startswith (name, DOT_ZDEBUG) | 1148 | 2.23k | #ifdef COFF_LONG_SECTION_NAMES | 1149 | 2.23k | || startswith (name, GNU_LINKONCE_WI) | 1150 | 2.23k | || startswith (name, GNU_LINKONCE_WT) | 1151 | | /* FIXME: These definitions ought to be in a header file. */ | 1152 | 2.23k | #define GNU_DEBUGLINK ".gnu_debuglink" | 1153 | 2.23k | #define GNU_DEBUGALTLINK ".gnu_debugaltlink" | 1154 | 2.23k | || startswith (name, GNU_DEBUGLINK) | 1155 | 2.23k | || startswith (name, GNU_DEBUGALTLINK) | 1156 | 2.23k | #endif | 1157 | 2.23k | || startswith (name, ".stab")) | 1158 | 4 | is_dbg = true; | 1159 | | /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified. */ | 1160 | 2.23k | sec_flags = SEC_READONLY; | 1161 | | | 1162 | | /* If section disallows read, then set the NOREAD flag. */ | 1163 | 2.23k | if ((styp_flags & IMAGE_SCN_MEM_READ) == 0) | 1164 | 1.77k | sec_flags |= SEC_COFF_NOREAD; | 1165 | | | 1166 | | /* Process each flag bit in styp_flags in turn. */ | 1167 | 12.1k | while (styp_flags) | 1168 | 9.88k | { | 1169 | 9.88k | unsigned long flag = styp_flags & - styp_flags; | 1170 | 9.88k | char * unhandled = NULL; | 1171 | | | 1172 | 9.88k | styp_flags &= ~ flag; | 1173 | | | 1174 | | /* We infer from the distinct read/write/execute bits the settings | 1175 | | of some of the bfd flags; the actual values, should we need them, | 1176 | | are also in pei_section_data (abfd, section)->pe_flags. */ | 1177 | | | 1178 | 9.88k | switch (flag) | 1179 | 9.88k | { | 1180 | 32 | case STYP_DSECT: | 1181 | 32 | unhandled = "STYP_DSECT"; | 1182 | 32 | break; | 1183 | 31 | case STYP_GROUP: | 1184 | 31 | unhandled = "STYP_GROUP"; | 1185 | 31 | break; | 1186 | 34 | case STYP_COPY: | 1187 | 34 | unhandled = "STYP_COPY"; | 1188 | 34 | break; | 1189 | 35 | case STYP_OVER: | 1190 | 35 | unhandled = "STYP_OVER"; | 1191 | 35 | break; | 1192 | 0 | #ifdef SEC_NEVER_LOAD | 1193 | 594 | case STYP_NOLOAD: | 1194 | 594 | sec_flags |= SEC_NEVER_LOAD; | 1195 | 594 | break; | 1196 | 0 | #endif | 1197 | 452 | case IMAGE_SCN_MEM_READ: | 1198 | 452 | sec_flags &= ~SEC_COFF_NOREAD; | 1199 | 452 | break; | 1200 | 254 | case IMAGE_SCN_TYPE_NO_PAD: | 1201 | | /* Skip. */ | 1202 | 254 | break; | 1203 | 39 | case IMAGE_SCN_LNK_OTHER: | 1204 | 39 | unhandled = "IMAGE_SCN_LNK_OTHER"; | 1205 | 39 | break; | 1206 | 49 | case IMAGE_SCN_MEM_NOT_CACHED: | 1207 | 49 | unhandled = "IMAGE_SCN_MEM_NOT_CACHED"; | 1208 | 49 | break; | 1209 | 364 | case IMAGE_SCN_MEM_NOT_PAGED: | 1210 | | /* Generate a warning message rather using the 'unhandled' | 1211 | | variable as this will allow some .sys files generate by | 1212 | | other toolchains to be processed. See bugzilla issue 196. */ | 1213 | | /* xgettext:c-format */ | 1214 | 364 | _bfd_error_handler (_("%pB: warning: ignoring section flag" | 1215 | 364 | " %s in section %s"), | 1216 | 364 | abfd, "IMAGE_SCN_MEM_NOT_PAGED", name); | 1217 | 364 | break; | 1218 | 353 | case IMAGE_SCN_MEM_EXECUTE: | 1219 | 353 | sec_flags |= SEC_CODE; | 1220 | 353 | break; | 1221 | 485 | case IMAGE_SCN_MEM_WRITE: | 1222 | 485 | sec_flags &= ~ SEC_READONLY; | 1223 | 485 | break; | 1224 | 634 | case IMAGE_SCN_MEM_DISCARDABLE: | 1225 | | /* The MS PE spec says that debug sections are DISCARDABLE, | 1226 | | but the presence of a DISCARDABLE flag does not necessarily | 1227 | | mean that a given section contains debug information. Thus | 1228 | | we only set the SEC_DEBUGGING flag on sections that we | 1229 | | recognise as containing debug information. */ | 1230 | 634 | if (is_dbg | 1231 | 634 | #ifdef _COMMENT | 1232 | 634 | || strcmp (name, _COMMENT) == 0 | 1233 | 634 | #endif | 1234 | 634 | ) | 1235 | 3 | { | 1236 | 3 | sec_flags |= SEC_DEBUGGING | SEC_READONLY; | 1237 | 3 | } | 1238 | 634 | break; | 1239 | 88 | case IMAGE_SCN_MEM_SHARED: | 1240 | 88 | sec_flags |= SEC_COFF_SHARED; | 1241 | 88 | break; | 1242 | 284 | case IMAGE_SCN_LNK_REMOVE: | 1243 | 284 | if (!is_dbg) | 1244 | 282 | sec_flags |= SEC_EXCLUDE; | 1245 | 284 | break; | 1246 | 282 | case IMAGE_SCN_CNT_CODE: | 1247 | 282 | sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD; | 1248 | 282 | break; | 1249 | 391 | case IMAGE_SCN_CNT_INITIALIZED_DATA: | 1250 | 391 | if (is_dbg) | 1251 | 1 | sec_flags |= SEC_DEBUGGING; | 1252 | 390 | else | 1253 | 390 | sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD; | 1254 | 391 | break; | 1255 | 366 | case IMAGE_SCN_CNT_UNINITIALIZED_DATA: | 1256 | 366 | sec_flags |= SEC_ALLOC; | 1257 | 366 | break; | 1258 | 612 | case IMAGE_SCN_LNK_INFO: | 1259 | | /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is | 1260 | | defined. coff_compute_section_file_positions uses | 1261 | | COFF_PAGE_SIZE to ensure that the low order bits of the | 1262 | | section VMA and the file offset match. If we don't know | 1263 | | COFF_PAGE_SIZE, we can't ensure the correct correspondence, | 1264 | | and demand page loading of the file will fail. */ | 1265 | 612 | #ifdef COFF_PAGE_SIZE | 1266 | 612 | sec_flags |= SEC_DEBUGGING; | 1267 | 612 | #endif | 1268 | 612 | break; | 1269 | 196 | case IMAGE_SCN_LNK_COMDAT: | 1270 | | /* COMDAT gets very special treatment. */ | 1271 | 196 | if (!handle_COMDAT (abfd, &sec_flags, hdr, name, section)) | 1272 | 5 | result = false; | 1273 | 196 | break; | 1274 | 4.31k | default: | 1275 | | /* Silently ignore for now. */ | 1276 | 4.31k | break; | 1277 | 9.88k | } | 1278 | | | 1279 | | /* If the section flag was not handled, report it here. */ | 1280 | 9.88k | if (unhandled != NULL) | 1281 | 220 | { | 1282 | 220 | _bfd_error_handler | 1283 | | /* xgettext:c-format */ | 1284 | 220 | (_("%pB (%s): section flag %s (%#lx) ignored"), | 1285 | 220 | abfd, name, unhandled, flag); | 1286 | 220 | result = false; | 1287 | 220 | } | 1288 | 9.88k | } | 1289 | | | 1290 | 2.23k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 1291 | 2.23k | && (startswith (name, ".sbss") | 1292 | 0 | || startswith (name, ".sdata"))) | 1293 | 0 | sec_flags |= SEC_SMALL_DATA; | 1294 | | | 1295 | | #if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE) | 1296 | | /* As a GNU extension, if the name begins with .gnu.linkonce, we | 1297 | | only link a single copy of the section. This is used to support | 1298 | | g++. g++ will emit each template expansion in its own section. | 1299 | | The symbols will be defined as weak, so that multiple definitions | 1300 | | are permitted. The GNU linker extension is to actually discard | 1301 | | all but one of the sections. */ | 1302 | | if (startswith (name, ".gnu.linkonce")) | 1303 | | sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; | 1304 | | #endif | 1305 | | | 1306 | 2.23k | if (flags_ptr) | 1307 | 2.23k | * flags_ptr = sec_flags; | 1308 | | | 1309 | 2.23k | return result; | 1310 | 2.23k | } |
pei-loongarch64.c:styp_to_sec_flags Line | Count | Source | 1139 | 8.55k | { | 1140 | 8.55k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 1141 | 8.55k | unsigned long styp_flags = internal_s->s_flags; | 1142 | 8.55k | flagword sec_flags; | 1143 | 8.55k | bool result = true; | 1144 | 8.55k | bool is_dbg = false; | 1145 | | | 1146 | 8.55k | if (startswith (name, DOT_DEBUG) | 1147 | 8.55k | || startswith (name, DOT_ZDEBUG) | 1148 | 8.55k | #ifdef COFF_LONG_SECTION_NAMES | 1149 | 8.55k | || startswith (name, GNU_LINKONCE_WI) | 1150 | 8.55k | || startswith (name, GNU_LINKONCE_WT) | 1151 | | /* FIXME: These definitions ought to be in a header file. */ | 1152 | 8.55k | #define GNU_DEBUGLINK ".gnu_debuglink" | 1153 | 8.55k | #define GNU_DEBUGALTLINK ".gnu_debugaltlink" | 1154 | 8.55k | || startswith (name, GNU_DEBUGLINK) | 1155 | 8.55k | || startswith (name, GNU_DEBUGALTLINK) | 1156 | 8.55k | #endif | 1157 | 8.55k | || startswith (name, ".stab")) | 1158 | 21 | is_dbg = true; | 1159 | | /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified. */ | 1160 | 8.55k | sec_flags = SEC_READONLY; | 1161 | | | 1162 | | /* If section disallows read, then set the NOREAD flag. */ | 1163 | 8.55k | if ((styp_flags & IMAGE_SCN_MEM_READ) == 0) | 1164 | 2.12k | sec_flags |= SEC_COFF_NOREAD; | 1165 | | | 1166 | | /* Process each flag bit in styp_flags in turn. */ | 1167 | 90.3k | while (styp_flags) | 1168 | 81.8k | { | 1169 | 81.8k | unsigned long flag = styp_flags & - styp_flags; | 1170 | 81.8k | char * unhandled = NULL; | 1171 | | | 1172 | 81.8k | styp_flags &= ~ flag; | 1173 | | | 1174 | | /* We infer from the distinct read/write/execute bits the settings | 1175 | | of some of the bfd flags; the actual values, should we need them, | 1176 | | are also in pei_section_data (abfd, section)->pe_flags. */ | 1177 | | | 1178 | 81.8k | switch (flag) | 1179 | 81.8k | { | 1180 | 46 | case STYP_DSECT: | 1181 | 46 | unhandled = "STYP_DSECT"; | 1182 | 46 | break; | 1183 | 48 | case STYP_GROUP: | 1184 | 48 | unhandled = "STYP_GROUP"; | 1185 | 48 | break; | 1186 | 51 | case STYP_COPY: | 1187 | 51 | unhandled = "STYP_COPY"; | 1188 | 51 | break; | 1189 | 49 | case STYP_OVER: | 1190 | 49 | unhandled = "STYP_OVER"; | 1191 | 49 | break; | 1192 | 0 | #ifdef SEC_NEVER_LOAD | 1193 | 450 | case STYP_NOLOAD: | 1194 | 450 | sec_flags |= SEC_NEVER_LOAD; | 1195 | 450 | break; | 1196 | 0 | #endif | 1197 | 6.43k | case IMAGE_SCN_MEM_READ: | 1198 | 6.43k | sec_flags &= ~SEC_COFF_NOREAD; | 1199 | 6.43k | break; | 1200 | 6.38k | case IMAGE_SCN_TYPE_NO_PAD: | 1201 | | /* Skip. */ | 1202 | 6.38k | break; | 1203 | 53 | case IMAGE_SCN_LNK_OTHER: | 1204 | 53 | unhandled = "IMAGE_SCN_LNK_OTHER"; | 1205 | 53 | break; | 1206 | 38 | case IMAGE_SCN_MEM_NOT_CACHED: | 1207 | 38 | unhandled = "IMAGE_SCN_MEM_NOT_CACHED"; | 1208 | 38 | break; | 1209 | 6.42k | case IMAGE_SCN_MEM_NOT_PAGED: | 1210 | | /* Generate a warning message rather using the 'unhandled' | 1211 | | variable as this will allow some .sys files generate by | 1212 | | other toolchains to be processed. See bugzilla issue 196. */ | 1213 | | /* xgettext:c-format */ | 1214 | 6.42k | _bfd_error_handler (_("%pB: warning: ignoring section flag" | 1215 | 6.42k | " %s in section %s"), | 1216 | 6.42k | abfd, "IMAGE_SCN_MEM_NOT_PAGED", name); | 1217 | 6.42k | break; | 1218 | 6.53k | case IMAGE_SCN_MEM_EXECUTE: | 1219 | 6.53k | sec_flags |= SEC_CODE; | 1220 | 6.53k | break; | 1221 | 279 | case IMAGE_SCN_MEM_WRITE: | 1222 | 279 | sec_flags &= ~ SEC_READONLY; | 1223 | 279 | break; | 1224 | 464 | case IMAGE_SCN_MEM_DISCARDABLE: | 1225 | | /* The MS PE spec says that debug sections are DISCARDABLE, | 1226 | | but the presence of a DISCARDABLE flag does not necessarily | 1227 | | mean that a given section contains debug information. Thus | 1228 | | we only set the SEC_DEBUGGING flag on sections that we | 1229 | | recognise as containing debug information. */ | 1230 | 464 | if (is_dbg | 1231 | 464 | #ifdef _COMMENT | 1232 | 464 | || strcmp (name, _COMMENT) == 0 | 1233 | 464 | #endif | 1234 | 464 | ) | 1235 | 17 | { | 1236 | 17 | sec_flags |= SEC_DEBUGGING | SEC_READONLY; | 1237 | 17 | } | 1238 | 464 | break; | 1239 | 65 | case IMAGE_SCN_MEM_SHARED: | 1240 | 65 | sec_flags |= SEC_COFF_SHARED; | 1241 | 65 | break; | 1242 | 6.45k | case IMAGE_SCN_LNK_REMOVE: | 1243 | 6.45k | if (!is_dbg) | 1244 | 6.44k | sec_flags |= SEC_EXCLUDE; | 1245 | 6.45k | break; | 1246 | 6.47k | case IMAGE_SCN_CNT_CODE: | 1247 | 6.47k | sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD; | 1248 | 6.47k | break; | 1249 | 6.38k | case IMAGE_SCN_CNT_INITIALIZED_DATA: | 1250 | 6.38k | if (is_dbg) | 1251 | 11 | sec_flags |= SEC_DEBUGGING; | 1252 | 6.37k | else | 1253 | 6.37k | sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD; | 1254 | 6.38k | break; | 1255 | 286 | case IMAGE_SCN_CNT_UNINITIALIZED_DATA: | 1256 | 286 | sec_flags |= SEC_ALLOC; | 1257 | 286 | break; | 1258 | 524 | case IMAGE_SCN_LNK_INFO: | 1259 | | /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is | 1260 | | defined. coff_compute_section_file_positions uses | 1261 | | COFF_PAGE_SIZE to ensure that the low order bits of the | 1262 | | section VMA and the file offset match. If we don't know | 1263 | | COFF_PAGE_SIZE, we can't ensure the correct correspondence, | 1264 | | and demand page loading of the file will fail. */ | 1265 | 524 | #ifdef COFF_PAGE_SIZE | 1266 | 524 | sec_flags |= SEC_DEBUGGING; | 1267 | 524 | #endif | 1268 | 524 | break; | 1269 | 228 | case IMAGE_SCN_LNK_COMDAT: | 1270 | | /* COMDAT gets very special treatment. */ | 1271 | 228 | if (!handle_COMDAT (abfd, &sec_flags, hdr, name, section)) | 1272 | 11 | result = false; | 1273 | 228 | break; | 1274 | 34.1k | default: | 1275 | | /* Silently ignore for now. */ | 1276 | 34.1k | break; | 1277 | 81.8k | } | 1278 | | | 1279 | | /* If the section flag was not handled, report it here. */ | 1280 | 81.8k | if (unhandled != NULL) | 1281 | 285 | { | 1282 | 285 | _bfd_error_handler | 1283 | | /* xgettext:c-format */ | 1284 | 285 | (_("%pB (%s): section flag %s (%#lx) ignored"), | 1285 | 285 | abfd, name, unhandled, flag); | 1286 | 285 | result = false; | 1287 | 285 | } | 1288 | 81.8k | } | 1289 | | | 1290 | 8.55k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 1291 | 8.55k | && (startswith (name, ".sbss") | 1292 | 0 | || startswith (name, ".sdata"))) | 1293 | 0 | sec_flags |= SEC_SMALL_DATA; | 1294 | | | 1295 | | #if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE) | 1296 | | /* As a GNU extension, if the name begins with .gnu.linkonce, we | 1297 | | only link a single copy of the section. This is used to support | 1298 | | g++. g++ will emit each template expansion in its own section. | 1299 | | The symbols will be defined as weak, so that multiple definitions | 1300 | | are permitted. The GNU linker extension is to actually discard | 1301 | | all but one of the sections. */ | 1302 | | if (startswith (name, ".gnu.linkonce")) | 1303 | | sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; | 1304 | | #endif | 1305 | | | 1306 | 8.55k | if (flags_ptr) | 1307 | 8.55k | * flags_ptr = sec_flags; | 1308 | | | 1309 | 8.55k | return result; | 1310 | 8.55k | } |
pe-arm-wince.c:styp_to_sec_flags Line | Count | Source | 1139 | 1.19k | { | 1140 | 1.19k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 1141 | 1.19k | unsigned long styp_flags = internal_s->s_flags; | 1142 | 1.19k | flagword sec_flags; | 1143 | 1.19k | bool result = true; | 1144 | 1.19k | bool is_dbg = false; | 1145 | | | 1146 | 1.19k | if (startswith (name, DOT_DEBUG) | 1147 | 1.19k | || startswith (name, DOT_ZDEBUG) | 1148 | 1.19k | #ifdef COFF_LONG_SECTION_NAMES | 1149 | 1.19k | || startswith (name, GNU_LINKONCE_WI) | 1150 | 1.19k | || startswith (name, GNU_LINKONCE_WT) | 1151 | | /* FIXME: These definitions ought to be in a header file. */ | 1152 | 1.19k | #define GNU_DEBUGLINK ".gnu_debuglink" | 1153 | 1.19k | #define GNU_DEBUGALTLINK ".gnu_debugaltlink" | 1154 | 1.19k | || startswith (name, GNU_DEBUGLINK) | 1155 | 1.19k | || startswith (name, GNU_DEBUGALTLINK) | 1156 | 1.19k | #endif | 1157 | 1.19k | || startswith (name, ".stab")) | 1158 | 15 | is_dbg = true; | 1159 | | /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified. */ | 1160 | 1.19k | sec_flags = SEC_READONLY; | 1161 | | | 1162 | | /* If section disallows read, then set the NOREAD flag. */ | 1163 | 1.19k | if ((styp_flags & IMAGE_SCN_MEM_READ) == 0) | 1164 | 734 | sec_flags |= SEC_COFF_NOREAD; | 1165 | | | 1166 | | /* Process each flag bit in styp_flags in turn. */ | 1167 | 9.96k | while (styp_flags) | 1168 | 8.77k | { | 1169 | 8.77k | unsigned long flag = styp_flags & - styp_flags; | 1170 | 8.77k | char * unhandled = NULL; | 1171 | | | 1172 | 8.77k | styp_flags &= ~ flag; | 1173 | | | 1174 | | /* We infer from the distinct read/write/execute bits the settings | 1175 | | of some of the bfd flags; the actual values, should we need them, | 1176 | | are also in pei_section_data (abfd, section)->pe_flags. */ | 1177 | | | 1178 | 8.77k | switch (flag) | 1179 | 8.77k | { | 1180 | 84 | case STYP_DSECT: | 1181 | 84 | unhandled = "STYP_DSECT"; | 1182 | 84 | break; | 1183 | 67 | case STYP_GROUP: | 1184 | 67 | unhandled = "STYP_GROUP"; | 1185 | 67 | break; | 1186 | 69 | case STYP_COPY: | 1187 | 69 | unhandled = "STYP_COPY"; | 1188 | 69 | break; | 1189 | 78 | case STYP_OVER: | 1190 | 78 | unhandled = "STYP_OVER"; | 1191 | 78 | break; | 1192 | 0 | #ifdef SEC_NEVER_LOAD | 1193 | 401 | case STYP_NOLOAD: | 1194 | 401 | sec_flags |= SEC_NEVER_LOAD; | 1195 | 401 | break; | 1196 | 0 | #endif | 1197 | 459 | case IMAGE_SCN_MEM_READ: | 1198 | 459 | sec_flags &= ~SEC_COFF_NOREAD; | 1199 | 459 | break; | 1200 | 258 | case IMAGE_SCN_TYPE_NO_PAD: | 1201 | | /* Skip. */ | 1202 | 258 | break; | 1203 | 90 | case IMAGE_SCN_LNK_OTHER: | 1204 | 90 | unhandled = "IMAGE_SCN_LNK_OTHER"; | 1205 | 90 | break; | 1206 | 75 | case IMAGE_SCN_MEM_NOT_CACHED: | 1207 | 75 | unhandled = "IMAGE_SCN_MEM_NOT_CACHED"; | 1208 | 75 | break; | 1209 | 293 | case IMAGE_SCN_MEM_NOT_PAGED: | 1210 | | /* Generate a warning message rather using the 'unhandled' | 1211 | | variable as this will allow some .sys files generate by | 1212 | | other toolchains to be processed. See bugzilla issue 196. */ | 1213 | | /* xgettext:c-format */ | 1214 | 293 | _bfd_error_handler (_("%pB: warning: ignoring section flag" | 1215 | 293 | " %s in section %s"), | 1216 | 293 | abfd, "IMAGE_SCN_MEM_NOT_PAGED", name); | 1217 | 293 | break; | 1218 | 479 | case IMAGE_SCN_MEM_EXECUTE: | 1219 | 479 | sec_flags |= SEC_CODE; | 1220 | 479 | break; | 1221 | 280 | case IMAGE_SCN_MEM_WRITE: | 1222 | 280 | sec_flags &= ~ SEC_READONLY; | 1223 | 280 | break; | 1224 | 434 | case IMAGE_SCN_MEM_DISCARDABLE: | 1225 | | /* The MS PE spec says that debug sections are DISCARDABLE, | 1226 | | but the presence of a DISCARDABLE flag does not necessarily | 1227 | | mean that a given section contains debug information. Thus | 1228 | | we only set the SEC_DEBUGGING flag on sections that we | 1229 | | recognise as containing debug information. */ | 1230 | 434 | if (is_dbg | 1231 | 434 | #ifdef _COMMENT | 1232 | 434 | || strcmp (name, _COMMENT) == 0 | 1233 | 434 | #endif | 1234 | 434 | ) | 1235 | 9 | { | 1236 | 9 | sec_flags |= SEC_DEBUGGING | SEC_READONLY; | 1237 | 9 | } | 1238 | 434 | break; | 1239 | 91 | case IMAGE_SCN_MEM_SHARED: | 1240 | 91 | sec_flags |= SEC_COFF_SHARED; | 1241 | 91 | break; | 1242 | 287 | case IMAGE_SCN_LNK_REMOVE: | 1243 | 287 | if (!is_dbg) | 1244 | 282 | sec_flags |= SEC_EXCLUDE; | 1245 | 287 | break; | 1246 | 431 | case IMAGE_SCN_CNT_CODE: | 1247 | 431 | sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD; | 1248 | 431 | break; | 1249 | 433 | case IMAGE_SCN_CNT_INITIALIZED_DATA: | 1250 | 433 | if (is_dbg) | 1251 | 5 | sec_flags |= SEC_DEBUGGING; | 1252 | 428 | else | 1253 | 428 | sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD; | 1254 | 433 | break; | 1255 | 258 | case IMAGE_SCN_CNT_UNINITIALIZED_DATA: | 1256 | 258 | sec_flags |= SEC_ALLOC; | 1257 | 258 | break; | 1258 | 447 | case IMAGE_SCN_LNK_INFO: | 1259 | | /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is | 1260 | | defined. coff_compute_section_file_positions uses | 1261 | | COFF_PAGE_SIZE to ensure that the low order bits of the | 1262 | | section VMA and the file offset match. If we don't know | 1263 | | COFF_PAGE_SIZE, we can't ensure the correct correspondence, | 1264 | | and demand page loading of the file will fail. */ | 1265 | 447 | #ifdef COFF_PAGE_SIZE | 1266 | 447 | sec_flags |= SEC_DEBUGGING; | 1267 | 447 | #endif | 1268 | 447 | break; | 1269 | 179 | case IMAGE_SCN_LNK_COMDAT: | 1270 | | /* COMDAT gets very special treatment. */ | 1271 | 179 | if (!handle_COMDAT (abfd, &sec_flags, hdr, name, section)) | 1272 | 10 | result = false; | 1273 | 179 | break; | 1274 | 3.57k | default: | 1275 | | /* Silently ignore for now. */ | 1276 | 3.57k | break; | 1277 | 8.77k | } | 1278 | | | 1279 | | /* If the section flag was not handled, report it here. */ | 1280 | 8.77k | if (unhandled != NULL) | 1281 | 463 | { | 1282 | 463 | _bfd_error_handler | 1283 | | /* xgettext:c-format */ | 1284 | 463 | (_("%pB (%s): section flag %s (%#lx) ignored"), | 1285 | 463 | abfd, name, unhandled, flag); | 1286 | 463 | result = false; | 1287 | 463 | } | 1288 | 8.77k | } | 1289 | | | 1290 | 1.19k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 1291 | 1.19k | && (startswith (name, ".sbss") | 1292 | 0 | || startswith (name, ".sdata"))) | 1293 | 0 | sec_flags |= SEC_SMALL_DATA; | 1294 | | | 1295 | | #if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE) | 1296 | | /* As a GNU extension, if the name begins with .gnu.linkonce, we | 1297 | | only link a single copy of the section. This is used to support | 1298 | | g++. g++ will emit each template expansion in its own section. | 1299 | | The symbols will be defined as weak, so that multiple definitions | 1300 | | are permitted. The GNU linker extension is to actually discard | 1301 | | all but one of the sections. */ | 1302 | | if (startswith (name, ".gnu.linkonce")) | 1303 | | sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; | 1304 | | #endif | 1305 | | | 1306 | 1.19k | if (flags_ptr) | 1307 | 1.19k | * flags_ptr = sec_flags; | 1308 | | | 1309 | 1.19k | return result; | 1310 | 1.19k | } |
pe-arm.c:styp_to_sec_flags Line | Count | Source | 1139 | 1.19k | { | 1140 | 1.19k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 1141 | 1.19k | unsigned long styp_flags = internal_s->s_flags; | 1142 | 1.19k | flagword sec_flags; | 1143 | 1.19k | bool result = true; | 1144 | 1.19k | bool is_dbg = false; | 1145 | | | 1146 | 1.19k | if (startswith (name, DOT_DEBUG) | 1147 | 1.19k | || startswith (name, DOT_ZDEBUG) | 1148 | 1.19k | #ifdef COFF_LONG_SECTION_NAMES | 1149 | 1.19k | || startswith (name, GNU_LINKONCE_WI) | 1150 | 1.19k | || startswith (name, GNU_LINKONCE_WT) | 1151 | | /* FIXME: These definitions ought to be in a header file. */ | 1152 | 1.19k | #define GNU_DEBUGLINK ".gnu_debuglink" | 1153 | 1.19k | #define GNU_DEBUGALTLINK ".gnu_debugaltlink" | 1154 | 1.19k | || startswith (name, GNU_DEBUGLINK) | 1155 | 1.19k | || startswith (name, GNU_DEBUGALTLINK) | 1156 | 1.19k | #endif | 1157 | 1.19k | || startswith (name, ".stab")) | 1158 | 15 | is_dbg = true; | 1159 | | /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified. */ | 1160 | 1.19k | sec_flags = SEC_READONLY; | 1161 | | | 1162 | | /* If section disallows read, then set the NOREAD flag. */ | 1163 | 1.19k | if ((styp_flags & IMAGE_SCN_MEM_READ) == 0) | 1164 | 734 | sec_flags |= SEC_COFF_NOREAD; | 1165 | | | 1166 | | /* Process each flag bit in styp_flags in turn. */ | 1167 | 9.96k | while (styp_flags) | 1168 | 8.77k | { | 1169 | 8.77k | unsigned long flag = styp_flags & - styp_flags; | 1170 | 8.77k | char * unhandled = NULL; | 1171 | | | 1172 | 8.77k | styp_flags &= ~ flag; | 1173 | | | 1174 | | /* We infer from the distinct read/write/execute bits the settings | 1175 | | of some of the bfd flags; the actual values, should we need them, | 1176 | | are also in pei_section_data (abfd, section)->pe_flags. */ | 1177 | | | 1178 | 8.77k | switch (flag) | 1179 | 8.77k | { | 1180 | 84 | case STYP_DSECT: | 1181 | 84 | unhandled = "STYP_DSECT"; | 1182 | 84 | break; | 1183 | 67 | case STYP_GROUP: | 1184 | 67 | unhandled = "STYP_GROUP"; | 1185 | 67 | break; | 1186 | 69 | case STYP_COPY: | 1187 | 69 | unhandled = "STYP_COPY"; | 1188 | 69 | break; | 1189 | 78 | case STYP_OVER: | 1190 | 78 | unhandled = "STYP_OVER"; | 1191 | 78 | break; | 1192 | 0 | #ifdef SEC_NEVER_LOAD | 1193 | 401 | case STYP_NOLOAD: | 1194 | 401 | sec_flags |= SEC_NEVER_LOAD; | 1195 | 401 | break; | 1196 | 0 | #endif | 1197 | 459 | case IMAGE_SCN_MEM_READ: | 1198 | 459 | sec_flags &= ~SEC_COFF_NOREAD; | 1199 | 459 | break; | 1200 | 258 | case IMAGE_SCN_TYPE_NO_PAD: | 1201 | | /* Skip. */ | 1202 | 258 | break; | 1203 | 90 | case IMAGE_SCN_LNK_OTHER: | 1204 | 90 | unhandled = "IMAGE_SCN_LNK_OTHER"; | 1205 | 90 | break; | 1206 | 75 | case IMAGE_SCN_MEM_NOT_CACHED: | 1207 | 75 | unhandled = "IMAGE_SCN_MEM_NOT_CACHED"; | 1208 | 75 | break; | 1209 | 293 | case IMAGE_SCN_MEM_NOT_PAGED: | 1210 | | /* Generate a warning message rather using the 'unhandled' | 1211 | | variable as this will allow some .sys files generate by | 1212 | | other toolchains to be processed. See bugzilla issue 196. */ | 1213 | | /* xgettext:c-format */ | 1214 | 293 | _bfd_error_handler (_("%pB: warning: ignoring section flag" | 1215 | 293 | " %s in section %s"), | 1216 | 293 | abfd, "IMAGE_SCN_MEM_NOT_PAGED", name); | 1217 | 293 | break; | 1218 | 479 | case IMAGE_SCN_MEM_EXECUTE: | 1219 | 479 | sec_flags |= SEC_CODE; | 1220 | 479 | break; | 1221 | 280 | case IMAGE_SCN_MEM_WRITE: | 1222 | 280 | sec_flags &= ~ SEC_READONLY; | 1223 | 280 | break; | 1224 | 434 | case IMAGE_SCN_MEM_DISCARDABLE: | 1225 | | /* The MS PE spec says that debug sections are DISCARDABLE, | 1226 | | but the presence of a DISCARDABLE flag does not necessarily | 1227 | | mean that a given section contains debug information. Thus | 1228 | | we only set the SEC_DEBUGGING flag on sections that we | 1229 | | recognise as containing debug information. */ | 1230 | 434 | if (is_dbg | 1231 | 434 | #ifdef _COMMENT | 1232 | 434 | || strcmp (name, _COMMENT) == 0 | 1233 | 434 | #endif | 1234 | 434 | ) | 1235 | 9 | { | 1236 | 9 | sec_flags |= SEC_DEBUGGING | SEC_READONLY; | 1237 | 9 | } | 1238 | 434 | break; | 1239 | 91 | case IMAGE_SCN_MEM_SHARED: | 1240 | 91 | sec_flags |= SEC_COFF_SHARED; | 1241 | 91 | break; | 1242 | 287 | case IMAGE_SCN_LNK_REMOVE: | 1243 | 287 | if (!is_dbg) | 1244 | 282 | sec_flags |= SEC_EXCLUDE; | 1245 | 287 | break; | 1246 | 431 | case IMAGE_SCN_CNT_CODE: | 1247 | 431 | sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD; | 1248 | 431 | break; | 1249 | 433 | case IMAGE_SCN_CNT_INITIALIZED_DATA: | 1250 | 433 | if (is_dbg) | 1251 | 5 | sec_flags |= SEC_DEBUGGING; | 1252 | 428 | else | 1253 | 428 | sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD; | 1254 | 433 | break; | 1255 | 258 | case IMAGE_SCN_CNT_UNINITIALIZED_DATA: | 1256 | 258 | sec_flags |= SEC_ALLOC; | 1257 | 258 | break; | 1258 | 447 | case IMAGE_SCN_LNK_INFO: | 1259 | | /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is | 1260 | | defined. coff_compute_section_file_positions uses | 1261 | | COFF_PAGE_SIZE to ensure that the low order bits of the | 1262 | | section VMA and the file offset match. If we don't know | 1263 | | COFF_PAGE_SIZE, we can't ensure the correct correspondence, | 1264 | | and demand page loading of the file will fail. */ | 1265 | 447 | #ifdef COFF_PAGE_SIZE | 1266 | 447 | sec_flags |= SEC_DEBUGGING; | 1267 | 447 | #endif | 1268 | 447 | break; | 1269 | 179 | case IMAGE_SCN_LNK_COMDAT: | 1270 | | /* COMDAT gets very special treatment. */ | 1271 | 179 | if (!handle_COMDAT (abfd, &sec_flags, hdr, name, section)) | 1272 | 10 | result = false; | 1273 | 179 | break; | 1274 | 3.57k | default: | 1275 | | /* Silently ignore for now. */ | 1276 | 3.57k | break; | 1277 | 8.77k | } | 1278 | | | 1279 | | /* If the section flag was not handled, report it here. */ | 1280 | 8.77k | if (unhandled != NULL) | 1281 | 463 | { | 1282 | 463 | _bfd_error_handler | 1283 | | /* xgettext:c-format */ | 1284 | 463 | (_("%pB (%s): section flag %s (%#lx) ignored"), | 1285 | 463 | abfd, name, unhandled, flag); | 1286 | 463 | result = false; | 1287 | 463 | } | 1288 | 8.77k | } | 1289 | | | 1290 | 1.19k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 1291 | 1.19k | && (startswith (name, ".sbss") | 1292 | 0 | || startswith (name, ".sdata"))) | 1293 | 0 | sec_flags |= SEC_SMALL_DATA; | 1294 | | | 1295 | | #if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE) | 1296 | | /* As a GNU extension, if the name begins with .gnu.linkonce, we | 1297 | | only link a single copy of the section. This is used to support | 1298 | | g++. g++ will emit each template expansion in its own section. | 1299 | | The symbols will be defined as weak, so that multiple definitions | 1300 | | are permitted. The GNU linker extension is to actually discard | 1301 | | all but one of the sections. */ | 1302 | | if (startswith (name, ".gnu.linkonce")) | 1303 | | sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; | 1304 | | #endif | 1305 | | | 1306 | 1.19k | if (flags_ptr) | 1307 | 1.19k | * flags_ptr = sec_flags; | 1308 | | | 1309 | 1.19k | return result; | 1310 | 1.19k | } |
pe-i386.c:styp_to_sec_flags Line | Count | Source | 1139 | 7.12k | { | 1140 | 7.12k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 1141 | 7.12k | unsigned long styp_flags = internal_s->s_flags; | 1142 | 7.12k | flagword sec_flags; | 1143 | 7.12k | bool result = true; | 1144 | 7.12k | bool is_dbg = false; | 1145 | | | 1146 | 7.12k | if (startswith (name, DOT_DEBUG) | 1147 | 7.12k | || startswith (name, DOT_ZDEBUG) | 1148 | 7.12k | #ifdef COFF_LONG_SECTION_NAMES | 1149 | 7.12k | || startswith (name, GNU_LINKONCE_WI) | 1150 | 7.12k | || startswith (name, GNU_LINKONCE_WT) | 1151 | | /* FIXME: These definitions ought to be in a header file. */ | 1152 | 7.12k | #define GNU_DEBUGLINK ".gnu_debuglink" | 1153 | 7.12k | #define GNU_DEBUGALTLINK ".gnu_debugaltlink" | 1154 | 7.12k | || startswith (name, GNU_DEBUGLINK) | 1155 | 7.12k | || startswith (name, GNU_DEBUGALTLINK) | 1156 | 7.12k | #endif | 1157 | 7.12k | || startswith (name, ".stab")) | 1158 | 56 | is_dbg = true; | 1159 | | /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified. */ | 1160 | 7.12k | sec_flags = SEC_READONLY; | 1161 | | | 1162 | | /* If section disallows read, then set the NOREAD flag. */ | 1163 | 7.12k | if ((styp_flags & IMAGE_SCN_MEM_READ) == 0) | 1164 | 3.44k | sec_flags |= SEC_COFF_NOREAD; | 1165 | | | 1166 | | /* Process each flag bit in styp_flags in turn. */ | 1167 | 68.6k | while (styp_flags) | 1168 | 61.5k | { | 1169 | 61.5k | unsigned long flag = styp_flags & - styp_flags; | 1170 | 61.5k | char * unhandled = NULL; | 1171 | | | 1172 | 61.5k | styp_flags &= ~ flag; | 1173 | | | 1174 | | /* We infer from the distinct read/write/execute bits the settings | 1175 | | of some of the bfd flags; the actual values, should we need them, | 1176 | | are also in pei_section_data (abfd, section)->pe_flags. */ | 1177 | | | 1178 | 61.5k | switch (flag) | 1179 | 61.5k | { | 1180 | 169 | case STYP_DSECT: | 1181 | 169 | unhandled = "STYP_DSECT"; | 1182 | 169 | break; | 1183 | 197 | case STYP_GROUP: | 1184 | 197 | unhandled = "STYP_GROUP"; | 1185 | 197 | break; | 1186 | 191 | case STYP_COPY: | 1187 | 191 | unhandled = "STYP_COPY"; | 1188 | 191 | break; | 1189 | 182 | case STYP_OVER: | 1190 | 182 | unhandled = "STYP_OVER"; | 1191 | 182 | break; | 1192 | 0 | #ifdef SEC_NEVER_LOAD | 1193 | 1.49k | case STYP_NOLOAD: | 1194 | 1.49k | sec_flags |= SEC_NEVER_LOAD; | 1195 | 1.49k | break; | 1196 | 0 | #endif | 1197 | 3.68k | case IMAGE_SCN_MEM_READ: | 1198 | 3.68k | sec_flags &= ~SEC_COFF_NOREAD; | 1199 | 3.68k | break; | 1200 | 2.56k | case IMAGE_SCN_TYPE_NO_PAD: | 1201 | | /* Skip. */ | 1202 | 2.56k | break; | 1203 | 190 | case IMAGE_SCN_LNK_OTHER: | 1204 | 190 | unhandled = "IMAGE_SCN_LNK_OTHER"; | 1205 | 190 | break; | 1206 | 185 | case IMAGE_SCN_MEM_NOT_CACHED: | 1207 | 185 | unhandled = "IMAGE_SCN_MEM_NOT_CACHED"; | 1208 | 185 | break; | 1209 | 2.59k | case IMAGE_SCN_MEM_NOT_PAGED: | 1210 | | /* Generate a warning message rather using the 'unhandled' | 1211 | | variable as this will allow some .sys files generate by | 1212 | | other toolchains to be processed. See bugzilla issue 196. */ | 1213 | | /* xgettext:c-format */ | 1214 | 2.59k | _bfd_error_handler (_("%pB: warning: ignoring section flag" | 1215 | 2.59k | " %s in section %s"), | 1216 | 2.59k | abfd, "IMAGE_SCN_MEM_NOT_PAGED", name); | 1217 | 2.59k | break; | 1218 | 3.65k | case IMAGE_SCN_MEM_EXECUTE: | 1219 | 3.65k | sec_flags |= SEC_CODE; | 1220 | 3.65k | break; | 1221 | 3.15k | case IMAGE_SCN_MEM_WRITE: | 1222 | 3.15k | sec_flags &= ~ SEC_READONLY; | 1223 | 3.15k | break; | 1224 | 1.58k | case IMAGE_SCN_MEM_DISCARDABLE: | 1225 | | /* The MS PE spec says that debug sections are DISCARDABLE, | 1226 | | but the presence of a DISCARDABLE flag does not necessarily | 1227 | | mean that a given section contains debug information. Thus | 1228 | | we only set the SEC_DEBUGGING flag on sections that we | 1229 | | recognise as containing debug information. */ | 1230 | 1.58k | if (is_dbg | 1231 | 1.58k | #ifdef _COMMENT | 1232 | 1.58k | || strcmp (name, _COMMENT) == 0 | 1233 | 1.58k | #endif | 1234 | 1.58k | ) | 1235 | 16 | { | 1236 | 16 | sec_flags |= SEC_DEBUGGING | SEC_READONLY; | 1237 | 16 | } | 1238 | 1.58k | break; | 1239 | 252 | case IMAGE_SCN_MEM_SHARED: | 1240 | 252 | sec_flags |= SEC_COFF_SHARED; | 1241 | 252 | break; | 1242 | 2.60k | case IMAGE_SCN_LNK_REMOVE: | 1243 | 2.60k | if (!is_dbg) | 1244 | 2.57k | sec_flags |= SEC_EXCLUDE; | 1245 | 2.60k | break; | 1246 | 3.60k | case IMAGE_SCN_CNT_CODE: | 1247 | 3.60k | sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD; | 1248 | 3.60k | break; | 1249 | 3.60k | case IMAGE_SCN_CNT_INITIALIZED_DATA: | 1250 | 3.60k | if (is_dbg) | 1251 | 9 | sec_flags |= SEC_DEBUGGING; | 1252 | 3.59k | else | 1253 | 3.59k | sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD; | 1254 | 3.60k | break; | 1255 | 3.11k | case IMAGE_SCN_CNT_UNINITIALIZED_DATA: | 1256 | 3.11k | sec_flags |= SEC_ALLOC; | 1257 | 3.11k | break; | 1258 | 1.57k | case IMAGE_SCN_LNK_INFO: | 1259 | | /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is | 1260 | | defined. coff_compute_section_file_positions uses | 1261 | | COFF_PAGE_SIZE to ensure that the low order bits of the | 1262 | | section VMA and the file offset match. If we don't know | 1263 | | COFF_PAGE_SIZE, we can't ensure the correct correspondence, | 1264 | | and demand page loading of the file will fail. */ | 1265 | 1.57k | #ifdef COFF_PAGE_SIZE | 1266 | 1.57k | sec_flags |= SEC_DEBUGGING; | 1267 | 1.57k | #endif | 1268 | 1.57k | break; | 1269 | 286 | case IMAGE_SCN_LNK_COMDAT: | 1270 | | /* COMDAT gets very special treatment. */ | 1271 | 286 | if (!handle_COMDAT (abfd, &sec_flags, hdr, name, section)) | 1272 | 7 | result = false; | 1273 | 286 | break; | 1274 | 26.6k | default: | 1275 | | /* Silently ignore for now. */ | 1276 | 26.6k | break; | 1277 | 61.5k | } | 1278 | | | 1279 | | /* If the section flag was not handled, report it here. */ | 1280 | 61.5k | if (unhandled != NULL) | 1281 | 1.11k | { | 1282 | 1.11k | _bfd_error_handler | 1283 | | /* xgettext:c-format */ | 1284 | 1.11k | (_("%pB (%s): section flag %s (%#lx) ignored"), | 1285 | 1.11k | abfd, name, unhandled, flag); | 1286 | 1.11k | result = false; | 1287 | 1.11k | } | 1288 | 61.5k | } | 1289 | | | 1290 | 7.12k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 1291 | 7.12k | && (startswith (name, ".sbss") | 1292 | 0 | || startswith (name, ".sdata"))) | 1293 | 0 | sec_flags |= SEC_SMALL_DATA; | 1294 | | | 1295 | 7.12k | #if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE) | 1296 | | /* As a GNU extension, if the name begins with .gnu.linkonce, we | 1297 | | only link a single copy of the section. This is used to support | 1298 | | g++. g++ will emit each template expansion in its own section. | 1299 | | The symbols will be defined as weak, so that multiple definitions | 1300 | | are permitted. The GNU linker extension is to actually discard | 1301 | | all but one of the sections. */ | 1302 | 7.12k | if (startswith (name, ".gnu.linkonce")) | 1303 | 0 | sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; | 1304 | 7.12k | #endif | 1305 | | | 1306 | 7.12k | if (flags_ptr) | 1307 | 7.12k | * flags_ptr = sec_flags; | 1308 | | | 1309 | 7.12k | return result; | 1310 | 7.12k | } |
pe-mcore.c:styp_to_sec_flags Line | Count | Source | 1139 | 3.32k | { | 1140 | 3.32k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 1141 | 3.32k | unsigned long styp_flags = internal_s->s_flags; | 1142 | 3.32k | flagword sec_flags; | 1143 | 3.32k | bool result = true; | 1144 | 3.32k | bool is_dbg = false; | 1145 | | | 1146 | 3.32k | if (startswith (name, DOT_DEBUG) | 1147 | 3.32k | || startswith (name, DOT_ZDEBUG) | 1148 | 3.32k | #ifdef COFF_LONG_SECTION_NAMES | 1149 | 3.32k | || startswith (name, GNU_LINKONCE_WI) | 1150 | 3.32k | || startswith (name, GNU_LINKONCE_WT) | 1151 | | /* FIXME: These definitions ought to be in a header file. */ | 1152 | 3.32k | #define GNU_DEBUGLINK ".gnu_debuglink" | 1153 | 3.32k | #define GNU_DEBUGALTLINK ".gnu_debugaltlink" | 1154 | 3.32k | || startswith (name, GNU_DEBUGLINK) | 1155 | 3.32k | || startswith (name, GNU_DEBUGALTLINK) | 1156 | 3.32k | #endif | 1157 | 3.32k | || startswith (name, ".stab")) | 1158 | 10 | is_dbg = true; | 1159 | | /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified. */ | 1160 | 3.32k | sec_flags = SEC_READONLY; | 1161 | | | 1162 | | /* If section disallows read, then set the NOREAD flag. */ | 1163 | 3.32k | if ((styp_flags & IMAGE_SCN_MEM_READ) == 0) | 1164 | 2.58k | sec_flags |= SEC_COFF_NOREAD; | 1165 | | | 1166 | | /* Process each flag bit in styp_flags in turn. */ | 1167 | 12.5k | while (styp_flags) | 1168 | 9.21k | { | 1169 | 9.21k | unsigned long flag = styp_flags & - styp_flags; | 1170 | 9.21k | char * unhandled = NULL; | 1171 | | | 1172 | 9.21k | styp_flags &= ~ flag; | 1173 | | | 1174 | | /* We infer from the distinct read/write/execute bits the settings | 1175 | | of some of the bfd flags; the actual values, should we need them, | 1176 | | are also in pei_section_data (abfd, section)->pe_flags. */ | 1177 | | | 1178 | 9.21k | switch (flag) | 1179 | 9.21k | { | 1180 | 53 | case STYP_DSECT: | 1181 | 53 | unhandled = "STYP_DSECT"; | 1182 | 53 | break; | 1183 | 54 | case STYP_GROUP: | 1184 | 54 | unhandled = "STYP_GROUP"; | 1185 | 54 | break; | 1186 | 52 | case STYP_COPY: | 1187 | 52 | unhandled = "STYP_COPY"; | 1188 | 52 | break; | 1189 | 62 | case STYP_OVER: | 1190 | 62 | unhandled = "STYP_OVER"; | 1191 | 62 | break; | 1192 | 0 | #ifdef SEC_NEVER_LOAD | 1193 | 356 | case STYP_NOLOAD: | 1194 | 356 | sec_flags |= SEC_NEVER_LOAD; | 1195 | 356 | break; | 1196 | 0 | #endif | 1197 | 732 | case IMAGE_SCN_MEM_READ: | 1198 | 732 | sec_flags &= ~SEC_COFF_NOREAD; | 1199 | 732 | break; | 1200 | 142 | case IMAGE_SCN_TYPE_NO_PAD: | 1201 | | /* Skip. */ | 1202 | 142 | break; | 1203 | 64 | case IMAGE_SCN_LNK_OTHER: | 1204 | 64 | unhandled = "IMAGE_SCN_LNK_OTHER"; | 1205 | 64 | break; | 1206 | 65 | case IMAGE_SCN_MEM_NOT_CACHED: | 1207 | 65 | unhandled = "IMAGE_SCN_MEM_NOT_CACHED"; | 1208 | 65 | break; | 1209 | 166 | case IMAGE_SCN_MEM_NOT_PAGED: | 1210 | | /* Generate a warning message rather using the 'unhandled' | 1211 | | variable as this will allow some .sys files generate by | 1212 | | other toolchains to be processed. See bugzilla issue 196. */ | 1213 | | /* xgettext:c-format */ | 1214 | 166 | _bfd_error_handler (_("%pB: warning: ignoring section flag" | 1215 | 166 | " %s in section %s"), | 1216 | 166 | abfd, "IMAGE_SCN_MEM_NOT_PAGED", name); | 1217 | 166 | break; | 1218 | 395 | case IMAGE_SCN_MEM_EXECUTE: | 1219 | 395 | sec_flags |= SEC_CODE; | 1220 | 395 | break; | 1221 | 385 | case IMAGE_SCN_MEM_WRITE: | 1222 | 385 | sec_flags &= ~ SEC_READONLY; | 1223 | 385 | break; | 1224 | 419 | case IMAGE_SCN_MEM_DISCARDABLE: | 1225 | | /* The MS PE spec says that debug sections are DISCARDABLE, | 1226 | | but the presence of a DISCARDABLE flag does not necessarily | 1227 | | mean that a given section contains debug information. Thus | 1228 | | we only set the SEC_DEBUGGING flag on sections that we | 1229 | | recognise as containing debug information. */ | 1230 | 419 | if (is_dbg | 1231 | 419 | #ifdef _COMMENT | 1232 | 419 | || strcmp (name, _COMMENT) == 0 | 1233 | 419 | #endif | 1234 | 419 | ) | 1235 | 3 | { | 1236 | 3 | sec_flags |= SEC_DEBUGGING | SEC_READONLY; | 1237 | 3 | } | 1238 | 419 | break; | 1239 | 110 | case IMAGE_SCN_MEM_SHARED: | 1240 | 110 | sec_flags |= SEC_COFF_SHARED; | 1241 | 110 | break; | 1242 | 159 | case IMAGE_SCN_LNK_REMOVE: | 1243 | 159 | if (!is_dbg) | 1244 | 157 | sec_flags |= SEC_EXCLUDE; | 1245 | 159 | break; | 1246 | 331 | case IMAGE_SCN_CNT_CODE: | 1247 | 331 | sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD; | 1248 | 331 | break; | 1249 | 643 | case IMAGE_SCN_CNT_INITIALIZED_DATA: | 1250 | 643 | if (is_dbg) | 1251 | 2 | sec_flags |= SEC_DEBUGGING; | 1252 | 641 | else | 1253 | 641 | sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD; | 1254 | 643 | break; | 1255 | 307 | case IMAGE_SCN_CNT_UNINITIALIZED_DATA: | 1256 | 307 | sec_flags |= SEC_ALLOC; | 1257 | 307 | break; | 1258 | 444 | case IMAGE_SCN_LNK_INFO: | 1259 | | /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is | 1260 | | defined. coff_compute_section_file_positions uses | 1261 | | COFF_PAGE_SIZE to ensure that the low order bits of the | 1262 | | section VMA and the file offset match. If we don't know | 1263 | | COFF_PAGE_SIZE, we can't ensure the correct correspondence, | 1264 | | and demand page loading of the file will fail. */ | 1265 | 444 | #ifdef COFF_PAGE_SIZE | 1266 | 444 | sec_flags |= SEC_DEBUGGING; | 1267 | 444 | #endif | 1268 | 444 | break; | 1269 | 212 | case IMAGE_SCN_LNK_COMDAT: | 1270 | | /* COMDAT gets very special treatment. */ | 1271 | 212 | if (!handle_COMDAT (abfd, &sec_flags, hdr, name, section)) | 1272 | 5 | result = false; | 1273 | 212 | break; | 1274 | 4.06k | default: | 1275 | | /* Silently ignore for now. */ | 1276 | 4.06k | break; | 1277 | 9.21k | } | 1278 | | | 1279 | | /* If the section flag was not handled, report it here. */ | 1280 | 9.21k | if (unhandled != NULL) | 1281 | 350 | { | 1282 | 350 | _bfd_error_handler | 1283 | | /* xgettext:c-format */ | 1284 | 350 | (_("%pB (%s): section flag %s (%#lx) ignored"), | 1285 | 350 | abfd, name, unhandled, flag); | 1286 | 350 | result = false; | 1287 | 350 | } | 1288 | 9.21k | } | 1289 | | | 1290 | 3.32k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 1291 | 3.32k | && (startswith (name, ".sbss") | 1292 | 0 | || startswith (name, ".sdata"))) | 1293 | 0 | sec_flags |= SEC_SMALL_DATA; | 1294 | | | 1295 | | #if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE) | 1296 | | /* As a GNU extension, if the name begins with .gnu.linkonce, we | 1297 | | only link a single copy of the section. This is used to support | 1298 | | g++. g++ will emit each template expansion in its own section. | 1299 | | The symbols will be defined as weak, so that multiple definitions | 1300 | | are permitted. The GNU linker extension is to actually discard | 1301 | | all but one of the sections. */ | 1302 | | if (startswith (name, ".gnu.linkonce")) | 1303 | | sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; | 1304 | | #endif | 1305 | | | 1306 | 3.32k | if (flags_ptr) | 1307 | 3.32k | * flags_ptr = sec_flags; | 1308 | | | 1309 | 3.32k | return result; | 1310 | 3.32k | } |
pe-sh.c:styp_to_sec_flags Line | Count | Source | 1139 | 2.57k | { | 1140 | 2.57k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 1141 | 2.57k | unsigned long styp_flags = internal_s->s_flags; | 1142 | 2.57k | flagword sec_flags; | 1143 | 2.57k | bool result = true; | 1144 | 2.57k | bool is_dbg = false; | 1145 | | | 1146 | 2.57k | if (startswith (name, DOT_DEBUG) | 1147 | 2.57k | || startswith (name, DOT_ZDEBUG) | 1148 | 2.57k | #ifdef COFF_LONG_SECTION_NAMES | 1149 | 2.57k | || startswith (name, GNU_LINKONCE_WI) | 1150 | 2.57k | || startswith (name, GNU_LINKONCE_WT) | 1151 | | /* FIXME: These definitions ought to be in a header file. */ | 1152 | 2.57k | #define GNU_DEBUGLINK ".gnu_debuglink" | 1153 | 2.57k | #define GNU_DEBUGALTLINK ".gnu_debugaltlink" | 1154 | 2.57k | || startswith (name, GNU_DEBUGLINK) | 1155 | 2.57k | || startswith (name, GNU_DEBUGALTLINK) | 1156 | 2.57k | #endif | 1157 | 2.57k | || startswith (name, ".stab")) | 1158 | 23 | is_dbg = true; | 1159 | | /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified. */ | 1160 | 2.57k | sec_flags = SEC_READONLY; | 1161 | | | 1162 | | /* If section disallows read, then set the NOREAD flag. */ | 1163 | 2.57k | if ((styp_flags & IMAGE_SCN_MEM_READ) == 0) | 1164 | 1.57k | sec_flags |= SEC_COFF_NOREAD; | 1165 | | | 1166 | | /* Process each flag bit in styp_flags in turn. */ | 1167 | 17.2k | while (styp_flags) | 1168 | 14.6k | { | 1169 | 14.6k | unsigned long flag = styp_flags & - styp_flags; | 1170 | 14.6k | char * unhandled = NULL; | 1171 | | | 1172 | 14.6k | styp_flags &= ~ flag; | 1173 | | | 1174 | | /* We infer from the distinct read/write/execute bits the settings | 1175 | | of some of the bfd flags; the actual values, should we need them, | 1176 | | are also in pei_section_data (abfd, section)->pe_flags. */ | 1177 | | | 1178 | 14.6k | switch (flag) | 1179 | 14.6k | { | 1180 | 103 | case STYP_DSECT: | 1181 | 103 | unhandled = "STYP_DSECT"; | 1182 | 103 | break; | 1183 | 91 | case STYP_GROUP: | 1184 | 91 | unhandled = "STYP_GROUP"; | 1185 | 91 | break; | 1186 | 101 | case STYP_COPY: | 1187 | 101 | unhandled = "STYP_COPY"; | 1188 | 101 | break; | 1189 | 86 | case STYP_OVER: | 1190 | 86 | unhandled = "STYP_OVER"; | 1191 | 86 | break; | 1192 | 0 | #ifdef SEC_NEVER_LOAD | 1193 | 236 | case STYP_NOLOAD: | 1194 | 236 | sec_flags |= SEC_NEVER_LOAD; | 1195 | 236 | break; | 1196 | 0 | #endif | 1197 | 996 | case IMAGE_SCN_MEM_READ: | 1198 | 996 | sec_flags &= ~SEC_COFF_NOREAD; | 1199 | 996 | break; | 1200 | 845 | case IMAGE_SCN_TYPE_NO_PAD: | 1201 | | /* Skip. */ | 1202 | 845 | break; | 1203 | 104 | case IMAGE_SCN_LNK_OTHER: | 1204 | 104 | unhandled = "IMAGE_SCN_LNK_OTHER"; | 1205 | 104 | break; | 1206 | 89 | case IMAGE_SCN_MEM_NOT_CACHED: | 1207 | 89 | unhandled = "IMAGE_SCN_MEM_NOT_CACHED"; | 1208 | 89 | break; | 1209 | 912 | case IMAGE_SCN_MEM_NOT_PAGED: | 1210 | | /* Generate a warning message rather using the 'unhandled' | 1211 | | variable as this will allow some .sys files generate by | 1212 | | other toolchains to be processed. See bugzilla issue 196. */ | 1213 | | /* xgettext:c-format */ | 1214 | 912 | _bfd_error_handler (_("%pB: warning: ignoring section flag" | 1215 | 912 | " %s in section %s"), | 1216 | 912 | abfd, "IMAGE_SCN_MEM_NOT_PAGED", name); | 1217 | 912 | break; | 1218 | 1.05k | case IMAGE_SCN_MEM_EXECUTE: | 1219 | 1.05k | sec_flags |= SEC_CODE; | 1220 | 1.05k | break; | 1221 | 249 | case IMAGE_SCN_MEM_WRITE: | 1222 | 249 | sec_flags &= ~ SEC_READONLY; | 1223 | 249 | break; | 1224 | 263 | case IMAGE_SCN_MEM_DISCARDABLE: | 1225 | | /* The MS PE spec says that debug sections are DISCARDABLE, | 1226 | | but the presence of a DISCARDABLE flag does not necessarily | 1227 | | mean that a given section contains debug information. Thus | 1228 | | we only set the SEC_DEBUGGING flag on sections that we | 1229 | | recognise as containing debug information. */ | 1230 | 263 | if (is_dbg | 1231 | 263 | #ifdef _COMMENT | 1232 | 263 | || strcmp (name, _COMMENT) == 0 | 1233 | 263 | #endif | 1234 | 263 | ) | 1235 | 11 | { | 1236 | 11 | sec_flags |= SEC_DEBUGGING | SEC_READONLY; | 1237 | 11 | } | 1238 | 263 | break; | 1239 | 167 | case IMAGE_SCN_MEM_SHARED: | 1240 | 167 | sec_flags |= SEC_COFF_SHARED; | 1241 | 167 | break; | 1242 | 887 | case IMAGE_SCN_LNK_REMOVE: | 1243 | 887 | if (!is_dbg) | 1244 | 881 | sec_flags |= SEC_EXCLUDE; | 1245 | 887 | break; | 1246 | 917 | case IMAGE_SCN_CNT_CODE: | 1247 | 917 | sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD; | 1248 | 917 | break; | 1249 | 873 | case IMAGE_SCN_CNT_INITIALIZED_DATA: | 1250 | 873 | if (is_dbg) | 1251 | 6 | sec_flags |= SEC_DEBUGGING; | 1252 | 867 | else | 1253 | 867 | sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD; | 1254 | 873 | break; | 1255 | 148 | case IMAGE_SCN_CNT_UNINITIALIZED_DATA: | 1256 | 148 | sec_flags |= SEC_ALLOC; | 1257 | 148 | break; | 1258 | 253 | case IMAGE_SCN_LNK_INFO: | 1259 | | /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is | 1260 | | defined. coff_compute_section_file_positions uses | 1261 | | COFF_PAGE_SIZE to ensure that the low order bits of the | 1262 | | section VMA and the file offset match. If we don't know | 1263 | | COFF_PAGE_SIZE, we can't ensure the correct correspondence, | 1264 | | and demand page loading of the file will fail. */ | 1265 | | #ifdef COFF_PAGE_SIZE | 1266 | | sec_flags |= SEC_DEBUGGING; | 1267 | | #endif | 1268 | 253 | break; | 1269 | 186 | case IMAGE_SCN_LNK_COMDAT: | 1270 | | /* COMDAT gets very special treatment. */ | 1271 | 186 | if (!handle_COMDAT (abfd, &sec_flags, hdr, name, section)) | 1272 | 7 | result = false; | 1273 | 186 | break; | 1274 | 6.07k | default: | 1275 | | /* Silently ignore for now. */ | 1276 | 6.07k | break; | 1277 | 14.6k | } | 1278 | | | 1279 | | /* If the section flag was not handled, report it here. */ | 1280 | 14.6k | if (unhandled != NULL) | 1281 | 574 | { | 1282 | 574 | _bfd_error_handler | 1283 | | /* xgettext:c-format */ | 1284 | 574 | (_("%pB (%s): section flag %s (%#lx) ignored"), | 1285 | 574 | abfd, name, unhandled, flag); | 1286 | 574 | result = false; | 1287 | 574 | } | 1288 | 14.6k | } | 1289 | | | 1290 | 2.57k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 1291 | 2.57k | && (startswith (name, ".sbss") | 1292 | 0 | || startswith (name, ".sdata"))) | 1293 | 0 | sec_flags |= SEC_SMALL_DATA; | 1294 | | | 1295 | | #if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE) | 1296 | | /* As a GNU extension, if the name begins with .gnu.linkonce, we | 1297 | | only link a single copy of the section. This is used to support | 1298 | | g++. g++ will emit each template expansion in its own section. | 1299 | | The symbols will be defined as weak, so that multiple definitions | 1300 | | are permitted. The GNU linker extension is to actually discard | 1301 | | all but one of the sections. */ | 1302 | | if (startswith (name, ".gnu.linkonce")) | 1303 | | sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; | 1304 | | #endif | 1305 | | | 1306 | 2.57k | if (flags_ptr) | 1307 | 2.57k | * flags_ptr = sec_flags; | 1308 | | | 1309 | 2.57k | return result; | 1310 | 2.57k | } |
pei-arm-wince.c:styp_to_sec_flags Line | Count | Source | 1139 | 2.09k | { | 1140 | 2.09k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 1141 | 2.09k | unsigned long styp_flags = internal_s->s_flags; | 1142 | 2.09k | flagword sec_flags; | 1143 | 2.09k | bool result = true; | 1144 | 2.09k | bool is_dbg = false; | 1145 | | | 1146 | 2.09k | if (startswith (name, DOT_DEBUG) | 1147 | 2.09k | || startswith (name, DOT_ZDEBUG) | 1148 | 2.09k | #ifdef COFF_LONG_SECTION_NAMES | 1149 | 2.09k | || startswith (name, GNU_LINKONCE_WI) | 1150 | 2.09k | || startswith (name, GNU_LINKONCE_WT) | 1151 | | /* FIXME: These definitions ought to be in a header file. */ | 1152 | 2.09k | #define GNU_DEBUGLINK ".gnu_debuglink" | 1153 | 2.09k | #define GNU_DEBUGALTLINK ".gnu_debugaltlink" | 1154 | 2.09k | || startswith (name, GNU_DEBUGLINK) | 1155 | 2.09k | || startswith (name, GNU_DEBUGALTLINK) | 1156 | 2.09k | #endif | 1157 | 2.09k | || startswith (name, ".stab")) | 1158 | 17 | is_dbg = true; | 1159 | | /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified. */ | 1160 | 2.09k | sec_flags = SEC_READONLY; | 1161 | | | 1162 | | /* If section disallows read, then set the NOREAD flag. */ | 1163 | 2.09k | if ((styp_flags & IMAGE_SCN_MEM_READ) == 0) | 1164 | 1.30k | sec_flags |= SEC_COFF_NOREAD; | 1165 | | | 1166 | | /* Process each flag bit in styp_flags in turn. */ | 1167 | 15.4k | while (styp_flags) | 1168 | 13.3k | { | 1169 | 13.3k | unsigned long flag = styp_flags & - styp_flags; | 1170 | 13.3k | char * unhandled = NULL; | 1171 | | | 1172 | 13.3k | styp_flags &= ~ flag; | 1173 | | | 1174 | | /* We infer from the distinct read/write/execute bits the settings | 1175 | | of some of the bfd flags; the actual values, should we need them, | 1176 | | are also in pei_section_data (abfd, section)->pe_flags. */ | 1177 | | | 1178 | 13.3k | switch (flag) | 1179 | 13.3k | { | 1180 | 36 | case STYP_DSECT: | 1181 | 36 | unhandled = "STYP_DSECT"; | 1182 | 36 | break; | 1183 | 40 | case STYP_GROUP: | 1184 | 40 | unhandled = "STYP_GROUP"; | 1185 | 40 | break; | 1186 | 43 | case STYP_COPY: | 1187 | 43 | unhandled = "STYP_COPY"; | 1188 | 43 | break; | 1189 | 49 | case STYP_OVER: | 1190 | 49 | unhandled = "STYP_OVER"; | 1191 | 49 | break; | 1192 | 0 | #ifdef SEC_NEVER_LOAD | 1193 | 553 | case STYP_NOLOAD: | 1194 | 553 | sec_flags |= SEC_NEVER_LOAD; | 1195 | 553 | break; | 1196 | 0 | #endif | 1197 | 781 | case IMAGE_SCN_MEM_READ: | 1198 | 781 | sec_flags &= ~SEC_COFF_NOREAD; | 1199 | 781 | break; | 1200 | 594 | case IMAGE_SCN_TYPE_NO_PAD: | 1201 | | /* Skip. */ | 1202 | 594 | break; | 1203 | 49 | case IMAGE_SCN_LNK_OTHER: | 1204 | 49 | unhandled = "IMAGE_SCN_LNK_OTHER"; | 1205 | 49 | break; | 1206 | 41 | case IMAGE_SCN_MEM_NOT_CACHED: | 1207 | 41 | unhandled = "IMAGE_SCN_MEM_NOT_CACHED"; | 1208 | 41 | break; | 1209 | 635 | case IMAGE_SCN_MEM_NOT_PAGED: | 1210 | | /* Generate a warning message rather using the 'unhandled' | 1211 | | variable as this will allow some .sys files generate by | 1212 | | other toolchains to be processed. See bugzilla issue 196. */ | 1213 | | /* xgettext:c-format */ | 1214 | 635 | _bfd_error_handler (_("%pB: warning: ignoring section flag" | 1215 | 635 | " %s in section %s"), | 1216 | 635 | abfd, "IMAGE_SCN_MEM_NOT_PAGED", name); | 1217 | 635 | break; | 1218 | 563 | case IMAGE_SCN_MEM_EXECUTE: | 1219 | 563 | sec_flags |= SEC_CODE; | 1220 | 563 | break; | 1221 | 574 | case IMAGE_SCN_MEM_WRITE: | 1222 | 574 | sec_flags &= ~ SEC_READONLY; | 1223 | 574 | break; | 1224 | 603 | case IMAGE_SCN_MEM_DISCARDABLE: | 1225 | | /* The MS PE spec says that debug sections are DISCARDABLE, | 1226 | | but the presence of a DISCARDABLE flag does not necessarily | 1227 | | mean that a given section contains debug information. Thus | 1228 | | we only set the SEC_DEBUGGING flag on sections that we | 1229 | | recognise as containing debug information. */ | 1230 | 603 | if (is_dbg | 1231 | 603 | #ifdef _COMMENT | 1232 | 603 | || strcmp (name, _COMMENT) == 0 | 1233 | 603 | #endif | 1234 | 603 | ) | 1235 | 17 | { | 1236 | 17 | sec_flags |= SEC_DEBUGGING | SEC_READONLY; | 1237 | 17 | } | 1238 | 603 | break; | 1239 | 86 | case IMAGE_SCN_MEM_SHARED: | 1240 | 86 | sec_flags |= SEC_COFF_SHARED; | 1241 | 86 | break; | 1242 | 603 | case IMAGE_SCN_LNK_REMOVE: | 1243 | 603 | if (!is_dbg) | 1244 | 600 | sec_flags |= SEC_EXCLUDE; | 1245 | 603 | break; | 1246 | 520 | case IMAGE_SCN_CNT_CODE: | 1247 | 520 | sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD; | 1248 | 520 | break; | 1249 | 731 | case IMAGE_SCN_CNT_INITIALIZED_DATA: | 1250 | 731 | if (is_dbg) | 1251 | 9 | sec_flags |= SEC_DEBUGGING; | 1252 | 722 | else | 1253 | 722 | sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD; | 1254 | 731 | break; | 1255 | 533 | case IMAGE_SCN_CNT_UNINITIALIZED_DATA: | 1256 | 533 | sec_flags |= SEC_ALLOC; | 1257 | 533 | break; | 1258 | 560 | case IMAGE_SCN_LNK_INFO: | 1259 | | /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is | 1260 | | defined. coff_compute_section_file_positions uses | 1261 | | COFF_PAGE_SIZE to ensure that the low order bits of the | 1262 | | section VMA and the file offset match. If we don't know | 1263 | | COFF_PAGE_SIZE, we can't ensure the correct correspondence, | 1264 | | and demand page loading of the file will fail. */ | 1265 | 560 | #ifdef COFF_PAGE_SIZE | 1266 | 560 | sec_flags |= SEC_DEBUGGING; | 1267 | 560 | #endif | 1268 | 560 | break; | 1269 | 118 | case IMAGE_SCN_LNK_COMDAT: | 1270 | | /* COMDAT gets very special treatment. */ | 1271 | 118 | if (!handle_COMDAT (abfd, &sec_flags, hdr, name, section)) | 1272 | 5 | result = false; | 1273 | 118 | break; | 1274 | 5.65k | default: | 1275 | | /* Silently ignore for now. */ | 1276 | 5.65k | break; | 1277 | 13.3k | } | 1278 | | | 1279 | | /* If the section flag was not handled, report it here. */ | 1280 | 13.3k | if (unhandled != NULL) | 1281 | 258 | { | 1282 | 258 | _bfd_error_handler | 1283 | | /* xgettext:c-format */ | 1284 | 258 | (_("%pB (%s): section flag %s (%#lx) ignored"), | 1285 | 258 | abfd, name, unhandled, flag); | 1286 | 258 | result = false; | 1287 | 258 | } | 1288 | 13.3k | } | 1289 | | | 1290 | 2.09k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 1291 | 2.09k | && (startswith (name, ".sbss") | 1292 | 0 | || startswith (name, ".sdata"))) | 1293 | 0 | sec_flags |= SEC_SMALL_DATA; | 1294 | | | 1295 | | #if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE) | 1296 | | /* As a GNU extension, if the name begins with .gnu.linkonce, we | 1297 | | only link a single copy of the section. This is used to support | 1298 | | g++. g++ will emit each template expansion in its own section. | 1299 | | The symbols will be defined as weak, so that multiple definitions | 1300 | | are permitted. The GNU linker extension is to actually discard | 1301 | | all but one of the sections. */ | 1302 | | if (startswith (name, ".gnu.linkonce")) | 1303 | | sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; | 1304 | | #endif | 1305 | | | 1306 | 2.09k | if (flags_ptr) | 1307 | 2.09k | * flags_ptr = sec_flags; | 1308 | | | 1309 | 2.09k | return result; | 1310 | 2.09k | } |
pei-arm.c:styp_to_sec_flags Line | Count | Source | 1139 | 2.74k | { | 1140 | 2.74k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 1141 | 2.74k | unsigned long styp_flags = internal_s->s_flags; | 1142 | 2.74k | flagword sec_flags; | 1143 | 2.74k | bool result = true; | 1144 | 2.74k | bool is_dbg = false; | 1145 | | | 1146 | 2.74k | if (startswith (name, DOT_DEBUG) | 1147 | 2.74k | || startswith (name, DOT_ZDEBUG) | 1148 | 2.74k | #ifdef COFF_LONG_SECTION_NAMES | 1149 | 2.74k | || startswith (name, GNU_LINKONCE_WI) | 1150 | 2.74k | || startswith (name, GNU_LINKONCE_WT) | 1151 | | /* FIXME: These definitions ought to be in a header file. */ | 1152 | 2.74k | #define GNU_DEBUGLINK ".gnu_debuglink" | 1153 | 2.74k | #define GNU_DEBUGALTLINK ".gnu_debugaltlink" | 1154 | 2.74k | || startswith (name, GNU_DEBUGLINK) | 1155 | 2.74k | || startswith (name, GNU_DEBUGALTLINK) | 1156 | 2.74k | #endif | 1157 | 2.74k | || startswith (name, ".stab")) | 1158 | 19 | is_dbg = true; | 1159 | | /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified. */ | 1160 | 2.74k | sec_flags = SEC_READONLY; | 1161 | | | 1162 | | /* If section disallows read, then set the NOREAD flag. */ | 1163 | 2.74k | if ((styp_flags & IMAGE_SCN_MEM_READ) == 0) | 1164 | 1.91k | sec_flags |= SEC_COFF_NOREAD; | 1165 | | | 1166 | | /* Process each flag bit in styp_flags in turn. */ | 1167 | 18.0k | while (styp_flags) | 1168 | 15.3k | { | 1169 | 15.3k | unsigned long flag = styp_flags & - styp_flags; | 1170 | 15.3k | char * unhandled = NULL; | 1171 | | | 1172 | 15.3k | styp_flags &= ~ flag; | 1173 | | | 1174 | | /* We infer from the distinct read/write/execute bits the settings | 1175 | | of some of the bfd flags; the actual values, should we need them, | 1176 | | are also in pei_section_data (abfd, section)->pe_flags. */ | 1177 | | | 1178 | 15.3k | switch (flag) | 1179 | 15.3k | { | 1180 | 60 | case STYP_DSECT: | 1181 | 60 | unhandled = "STYP_DSECT"; | 1182 | 60 | break; | 1183 | 65 | case STYP_GROUP: | 1184 | 65 | unhandled = "STYP_GROUP"; | 1185 | 65 | break; | 1186 | 69 | case STYP_COPY: | 1187 | 69 | unhandled = "STYP_COPY"; | 1188 | 69 | break; | 1189 | 84 | case STYP_OVER: | 1190 | 84 | unhandled = "STYP_OVER"; | 1191 | 84 | break; | 1192 | 0 | #ifdef SEC_NEVER_LOAD | 1193 | 609 | case STYP_NOLOAD: | 1194 | 609 | sec_flags |= SEC_NEVER_LOAD; | 1195 | 609 | break; | 1196 | 0 | #endif | 1197 | 826 | case IMAGE_SCN_MEM_READ: | 1198 | 826 | sec_flags &= ~SEC_COFF_NOREAD; | 1199 | 826 | break; | 1200 | 584 | case IMAGE_SCN_TYPE_NO_PAD: | 1201 | | /* Skip. */ | 1202 | 584 | break; | 1203 | 82 | case IMAGE_SCN_LNK_OTHER: | 1204 | 82 | unhandled = "IMAGE_SCN_LNK_OTHER"; | 1205 | 82 | break; | 1206 | 78 | case IMAGE_SCN_MEM_NOT_CACHED: | 1207 | 78 | unhandled = "IMAGE_SCN_MEM_NOT_CACHED"; | 1208 | 78 | break; | 1209 | 676 | case IMAGE_SCN_MEM_NOT_PAGED: | 1210 | | /* Generate a warning message rather using the 'unhandled' | 1211 | | variable as this will allow some .sys files generate by | 1212 | | other toolchains to be processed. See bugzilla issue 196. */ | 1213 | | /* xgettext:c-format */ | 1214 | 676 | _bfd_error_handler (_("%pB: warning: ignoring section flag" | 1215 | 676 | " %s in section %s"), | 1216 | 676 | abfd, "IMAGE_SCN_MEM_NOT_PAGED", name); | 1217 | 676 | break; | 1218 | 647 | case IMAGE_SCN_MEM_EXECUTE: | 1219 | 647 | sec_flags |= SEC_CODE; | 1220 | 647 | break; | 1221 | 651 | case IMAGE_SCN_MEM_WRITE: | 1222 | 651 | sec_flags &= ~ SEC_READONLY; | 1223 | 651 | break; | 1224 | 677 | case IMAGE_SCN_MEM_DISCARDABLE: | 1225 | | /* The MS PE spec says that debug sections are DISCARDABLE, | 1226 | | but the presence of a DISCARDABLE flag does not necessarily | 1227 | | mean that a given section contains debug information. Thus | 1228 | | we only set the SEC_DEBUGGING flag on sections that we | 1229 | | recognise as containing debug information. */ | 1230 | 677 | if (is_dbg | 1231 | 677 | #ifdef _COMMENT | 1232 | 677 | || strcmp (name, _COMMENT) == 0 | 1233 | 677 | #endif | 1234 | 677 | ) | 1235 | 18 | { | 1236 | 18 | sec_flags |= SEC_DEBUGGING | SEC_READONLY; | 1237 | 18 | } | 1238 | 677 | break; | 1239 | 127 | case IMAGE_SCN_MEM_SHARED: | 1240 | 127 | sec_flags |= SEC_COFF_SHARED; | 1241 | 127 | break; | 1242 | 605 | case IMAGE_SCN_LNK_REMOVE: | 1243 | 605 | if (!is_dbg) | 1244 | 602 | sec_flags |= SEC_EXCLUDE; | 1245 | 605 | break; | 1246 | 605 | case IMAGE_SCN_CNT_CODE: | 1247 | 605 | sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD; | 1248 | 605 | break; | 1249 | 778 | case IMAGE_SCN_CNT_INITIALIZED_DATA: | 1250 | 778 | if (is_dbg) | 1251 | 9 | sec_flags |= SEC_DEBUGGING; | 1252 | 769 | else | 1253 | 769 | sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD; | 1254 | 778 | break; | 1255 | 597 | case IMAGE_SCN_CNT_UNINITIALIZED_DATA: | 1256 | 597 | sec_flags |= SEC_ALLOC; | 1257 | 597 | break; | 1258 | 630 | case IMAGE_SCN_LNK_INFO: | 1259 | | /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is | 1260 | | defined. coff_compute_section_file_positions uses | 1261 | | COFF_PAGE_SIZE to ensure that the low order bits of the | 1262 | | section VMA and the file offset match. If we don't know | 1263 | | COFF_PAGE_SIZE, we can't ensure the correct correspondence, | 1264 | | and demand page loading of the file will fail. */ | 1265 | 630 | #ifdef COFF_PAGE_SIZE | 1266 | 630 | sec_flags |= SEC_DEBUGGING; | 1267 | 630 | #endif | 1268 | 630 | break; | 1269 | 159 | case IMAGE_SCN_LNK_COMDAT: | 1270 | | /* COMDAT gets very special treatment. */ | 1271 | 159 | if (!handle_COMDAT (abfd, &sec_flags, hdr, name, section)) | 1272 | 6 | result = false; | 1273 | 159 | break; | 1274 | 6.71k | default: | 1275 | | /* Silently ignore for now. */ | 1276 | 6.71k | break; | 1277 | 15.3k | } | 1278 | | | 1279 | | /* If the section flag was not handled, report it here. */ | 1280 | 15.3k | if (unhandled != NULL) | 1281 | 438 | { | 1282 | 438 | _bfd_error_handler | 1283 | | /* xgettext:c-format */ | 1284 | 438 | (_("%pB (%s): section flag %s (%#lx) ignored"), | 1285 | 438 | abfd, name, unhandled, flag); | 1286 | 438 | result = false; | 1287 | 438 | } | 1288 | 15.3k | } | 1289 | | | 1290 | 2.74k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 1291 | 2.74k | && (startswith (name, ".sbss") | 1292 | 0 | || startswith (name, ".sdata"))) | 1293 | 0 | sec_flags |= SEC_SMALL_DATA; | 1294 | | | 1295 | | #if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE) | 1296 | | /* As a GNU extension, if the name begins with .gnu.linkonce, we | 1297 | | only link a single copy of the section. This is used to support | 1298 | | g++. g++ will emit each template expansion in its own section. | 1299 | | The symbols will be defined as weak, so that multiple definitions | 1300 | | are permitted. The GNU linker extension is to actually discard | 1301 | | all but one of the sections. */ | 1302 | | if (startswith (name, ".gnu.linkonce")) | 1303 | | sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; | 1304 | | #endif | 1305 | | | 1306 | 2.74k | if (flags_ptr) | 1307 | 2.74k | * flags_ptr = sec_flags; | 1308 | | | 1309 | 2.74k | return result; | 1310 | 2.74k | } |
pei-mcore.c:styp_to_sec_flags Line | Count | Source | 1139 | 3.55k | { | 1140 | 3.55k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 1141 | 3.55k | unsigned long styp_flags = internal_s->s_flags; | 1142 | 3.55k | flagword sec_flags; | 1143 | 3.55k | bool result = true; | 1144 | 3.55k | bool is_dbg = false; | 1145 | | | 1146 | 3.55k | if (startswith (name, DOT_DEBUG) | 1147 | 3.55k | || startswith (name, DOT_ZDEBUG) | 1148 | 3.55k | #ifdef COFF_LONG_SECTION_NAMES | 1149 | 3.55k | || startswith (name, GNU_LINKONCE_WI) | 1150 | 3.55k | || startswith (name, GNU_LINKONCE_WT) | 1151 | | /* FIXME: These definitions ought to be in a header file. */ | 1152 | 3.55k | #define GNU_DEBUGLINK ".gnu_debuglink" | 1153 | 3.55k | #define GNU_DEBUGALTLINK ".gnu_debugaltlink" | 1154 | 3.55k | || startswith (name, GNU_DEBUGLINK) | 1155 | 3.55k | || startswith (name, GNU_DEBUGALTLINK) | 1156 | 3.55k | #endif | 1157 | 3.55k | || startswith (name, ".stab")) | 1158 | 6 | is_dbg = true; | 1159 | | /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified. */ | 1160 | 3.55k | sec_flags = SEC_READONLY; | 1161 | | | 1162 | | /* If section disallows read, then set the NOREAD flag. */ | 1163 | 3.55k | if ((styp_flags & IMAGE_SCN_MEM_READ) == 0) | 1164 | 2.59k | sec_flags |= SEC_COFF_NOREAD; | 1165 | | | 1166 | | /* Process each flag bit in styp_flags in turn. */ | 1167 | 25.5k | while (styp_flags) | 1168 | 21.9k | { | 1169 | 21.9k | unsigned long flag = styp_flags & - styp_flags; | 1170 | 21.9k | char * unhandled = NULL; | 1171 | | | 1172 | 21.9k | styp_flags &= ~ flag; | 1173 | | | 1174 | | /* We infer from the distinct read/write/execute bits the settings | 1175 | | of some of the bfd flags; the actual values, should we need them, | 1176 | | are also in pei_section_data (abfd, section)->pe_flags. */ | 1177 | | | 1178 | 21.9k | switch (flag) | 1179 | 21.9k | { | 1180 | 37 | case STYP_DSECT: | 1181 | 37 | unhandled = "STYP_DSECT"; | 1182 | 37 | break; | 1183 | 40 | case STYP_GROUP: | 1184 | 40 | unhandled = "STYP_GROUP"; | 1185 | 40 | break; | 1186 | 40 | case STYP_COPY: | 1187 | 40 | unhandled = "STYP_COPY"; | 1188 | 40 | break; | 1189 | 36 | case STYP_OVER: | 1190 | 36 | unhandled = "STYP_OVER"; | 1191 | 36 | break; | 1192 | 0 | #ifdef SEC_NEVER_LOAD | 1193 | 2.13k | case STYP_NOLOAD: | 1194 | 2.13k | sec_flags |= SEC_NEVER_LOAD; | 1195 | 2.13k | break; | 1196 | 0 | #endif | 1197 | 952 | case IMAGE_SCN_MEM_READ: | 1198 | 952 | sec_flags &= ~SEC_COFF_NOREAD; | 1199 | 952 | break; | 1200 | 332 | case IMAGE_SCN_TYPE_NO_PAD: | 1201 | | /* Skip. */ | 1202 | 332 | break; | 1203 | 43 | case IMAGE_SCN_LNK_OTHER: | 1204 | 43 | unhandled = "IMAGE_SCN_LNK_OTHER"; | 1205 | 43 | break; | 1206 | 36 | case IMAGE_SCN_MEM_NOT_CACHED: | 1207 | 36 | unhandled = "IMAGE_SCN_MEM_NOT_CACHED"; | 1208 | 36 | break; | 1209 | 349 | case IMAGE_SCN_MEM_NOT_PAGED: | 1210 | | /* Generate a warning message rather using the 'unhandled' | 1211 | | variable as this will allow some .sys files generate by | 1212 | | other toolchains to be processed. See bugzilla issue 196. */ | 1213 | | /* xgettext:c-format */ | 1214 | 349 | _bfd_error_handler (_("%pB: warning: ignoring section flag" | 1215 | 349 | " %s in section %s"), | 1216 | 349 | abfd, "IMAGE_SCN_MEM_NOT_PAGED", name); | 1217 | 349 | break; | 1218 | 899 | case IMAGE_SCN_MEM_EXECUTE: | 1219 | 899 | sec_flags |= SEC_CODE; | 1220 | 899 | break; | 1221 | 895 | case IMAGE_SCN_MEM_WRITE: | 1222 | 895 | sec_flags &= ~ SEC_READONLY; | 1223 | 895 | break; | 1224 | 2.17k | case IMAGE_SCN_MEM_DISCARDABLE: | 1225 | | /* The MS PE spec says that debug sections are DISCARDABLE, | 1226 | | but the presence of a DISCARDABLE flag does not necessarily | 1227 | | mean that a given section contains debug information. Thus | 1228 | | we only set the SEC_DEBUGGING flag on sections that we | 1229 | | recognise as containing debug information. */ | 1230 | 2.17k | if (is_dbg | 1231 | 2.17k | #ifdef _COMMENT | 1232 | 2.17k | || strcmp (name, _COMMENT) == 0 | 1233 | 2.17k | #endif | 1234 | 2.17k | ) | 1235 | 6 | { | 1236 | 6 | sec_flags |= SEC_DEBUGGING | SEC_READONLY; | 1237 | 6 | } | 1238 | 2.17k | break; | 1239 | 61 | case IMAGE_SCN_MEM_SHARED: | 1240 | 61 | sec_flags |= SEC_COFF_SHARED; | 1241 | 61 | break; | 1242 | 335 | case IMAGE_SCN_LNK_REMOVE: | 1243 | 335 | if (!is_dbg) | 1244 | 332 | sec_flags |= SEC_EXCLUDE; | 1245 | 335 | break; | 1246 | 877 | case IMAGE_SCN_CNT_CODE: | 1247 | 877 | sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD; | 1248 | 877 | break; | 1249 | 944 | case IMAGE_SCN_CNT_INITIALIZED_DATA: | 1250 | 944 | if (is_dbg) | 1251 | 4 | sec_flags |= SEC_DEBUGGING; | 1252 | 940 | else | 1253 | 940 | sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD; | 1254 | 944 | break; | 1255 | 860 | case IMAGE_SCN_CNT_UNINITIALIZED_DATA: | 1256 | 860 | sec_flags |= SEC_ALLOC; | 1257 | 860 | break; | 1258 | 2.23k | case IMAGE_SCN_LNK_INFO: | 1259 | | /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is | 1260 | | defined. coff_compute_section_file_positions uses | 1261 | | COFF_PAGE_SIZE to ensure that the low order bits of the | 1262 | | section VMA and the file offset match. If we don't know | 1263 | | COFF_PAGE_SIZE, we can't ensure the correct correspondence, | 1264 | | and demand page loading of the file will fail. */ | 1265 | 2.23k | #ifdef COFF_PAGE_SIZE | 1266 | 2.23k | sec_flags |= SEC_DEBUGGING; | 1267 | 2.23k | #endif | 1268 | 2.23k | break; | 1269 | 188 | case IMAGE_SCN_LNK_COMDAT: | 1270 | | /* COMDAT gets very special treatment. */ | 1271 | 188 | if (!handle_COMDAT (abfd, &sec_flags, hdr, name, section)) | 1272 | 7 | result = false; | 1273 | 188 | break; | 1274 | 8.49k | default: | 1275 | | /* Silently ignore for now. */ | 1276 | 8.49k | break; | 1277 | 21.9k | } | 1278 | | | 1279 | | /* If the section flag was not handled, report it here. */ | 1280 | 21.9k | if (unhandled != NULL) | 1281 | 232 | { | 1282 | 232 | _bfd_error_handler | 1283 | | /* xgettext:c-format */ | 1284 | 232 | (_("%pB (%s): section flag %s (%#lx) ignored"), | 1285 | 232 | abfd, name, unhandled, flag); | 1286 | 232 | result = false; | 1287 | 232 | } | 1288 | 21.9k | } | 1289 | | | 1290 | 3.55k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 1291 | 3.55k | && (startswith (name, ".sbss") | 1292 | 0 | || startswith (name, ".sdata"))) | 1293 | 0 | sec_flags |= SEC_SMALL_DATA; | 1294 | | | 1295 | | #if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE) | 1296 | | /* As a GNU extension, if the name begins with .gnu.linkonce, we | 1297 | | only link a single copy of the section. This is used to support | 1298 | | g++. g++ will emit each template expansion in its own section. | 1299 | | The symbols will be defined as weak, so that multiple definitions | 1300 | | are permitted. The GNU linker extension is to actually discard | 1301 | | all but one of the sections. */ | 1302 | | if (startswith (name, ".gnu.linkonce")) | 1303 | | sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; | 1304 | | #endif | 1305 | | | 1306 | 3.55k | if (flags_ptr) | 1307 | 3.55k | * flags_ptr = sec_flags; | 1308 | | | 1309 | 3.55k | return result; | 1310 | 3.55k | } |
pei-sh.c:styp_to_sec_flags Line | Count | Source | 1139 | 1.70k | { | 1140 | 1.70k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 1141 | 1.70k | unsigned long styp_flags = internal_s->s_flags; | 1142 | 1.70k | flagword sec_flags; | 1143 | 1.70k | bool result = true; | 1144 | 1.70k | bool is_dbg = false; | 1145 | | | 1146 | 1.70k | if (startswith (name, DOT_DEBUG) | 1147 | 1.70k | || startswith (name, DOT_ZDEBUG) | 1148 | 1.70k | #ifdef COFF_LONG_SECTION_NAMES | 1149 | 1.70k | || startswith (name, GNU_LINKONCE_WI) | 1150 | 1.70k | || startswith (name, GNU_LINKONCE_WT) | 1151 | | /* FIXME: These definitions ought to be in a header file. */ | 1152 | 1.70k | #define GNU_DEBUGLINK ".gnu_debuglink" | 1153 | 1.70k | #define GNU_DEBUGALTLINK ".gnu_debugaltlink" | 1154 | 1.70k | || startswith (name, GNU_DEBUGLINK) | 1155 | 1.70k | || startswith (name, GNU_DEBUGALTLINK) | 1156 | 1.70k | #endif | 1157 | 1.70k | || startswith (name, ".stab")) | 1158 | 6 | is_dbg = true; | 1159 | | /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified. */ | 1160 | 1.70k | sec_flags = SEC_READONLY; | 1161 | | | 1162 | | /* If section disallows read, then set the NOREAD flag. */ | 1163 | 1.70k | if ((styp_flags & IMAGE_SCN_MEM_READ) == 0) | 1164 | 1.39k | sec_flags |= SEC_COFF_NOREAD; | 1165 | | | 1166 | | /* Process each flag bit in styp_flags in turn. */ | 1167 | 8.25k | while (styp_flags) | 1168 | 6.55k | { | 1169 | 6.55k | unsigned long flag = styp_flags & - styp_flags; | 1170 | 6.55k | char * unhandled = NULL; | 1171 | | | 1172 | 6.55k | styp_flags &= ~ flag; | 1173 | | | 1174 | | /* We infer from the distinct read/write/execute bits the settings | 1175 | | of some of the bfd flags; the actual values, should we need them, | 1176 | | are also in pei_section_data (abfd, section)->pe_flags. */ | 1177 | | | 1178 | 6.55k | switch (flag) | 1179 | 6.55k | { | 1180 | 47 | case STYP_DSECT: | 1181 | 47 | unhandled = "STYP_DSECT"; | 1182 | 47 | break; | 1183 | 43 | case STYP_GROUP: | 1184 | 43 | unhandled = "STYP_GROUP"; | 1185 | 43 | break; | 1186 | 57 | case STYP_COPY: | 1187 | 57 | unhandled = "STYP_COPY"; | 1188 | 57 | break; | 1189 | 48 | case STYP_OVER: | 1190 | 48 | unhandled = "STYP_OVER"; | 1191 | 48 | break; | 1192 | 0 | #ifdef SEC_NEVER_LOAD | 1193 | 167 | case STYP_NOLOAD: | 1194 | 167 | sec_flags |= SEC_NEVER_LOAD; | 1195 | 167 | break; | 1196 | 0 | #endif | 1197 | 312 | case IMAGE_SCN_MEM_READ: | 1198 | 312 | sec_flags &= ~SEC_COFF_NOREAD; | 1199 | 312 | break; | 1200 | 328 | case IMAGE_SCN_TYPE_NO_PAD: | 1201 | | /* Skip. */ | 1202 | 328 | break; | 1203 | 51 | case IMAGE_SCN_LNK_OTHER: | 1204 | 51 | unhandled = "IMAGE_SCN_LNK_OTHER"; | 1205 | 51 | break; | 1206 | 35 | case IMAGE_SCN_MEM_NOT_CACHED: | 1207 | 35 | unhandled = "IMAGE_SCN_MEM_NOT_CACHED"; | 1208 | 35 | break; | 1209 | 344 | case IMAGE_SCN_MEM_NOT_PAGED: | 1210 | | /* Generate a warning message rather using the 'unhandled' | 1211 | | variable as this will allow some .sys files generate by | 1212 | | other toolchains to be processed. See bugzilla issue 196. */ | 1213 | | /* xgettext:c-format */ | 1214 | 344 | _bfd_error_handler (_("%pB: warning: ignoring section flag" | 1215 | 344 | " %s in section %s"), | 1216 | 344 | abfd, "IMAGE_SCN_MEM_NOT_PAGED", name); | 1217 | 344 | break; | 1218 | 413 | case IMAGE_SCN_MEM_EXECUTE: | 1219 | 413 | sec_flags |= SEC_CODE; | 1220 | 413 | break; | 1221 | 309 | case IMAGE_SCN_MEM_WRITE: | 1222 | 309 | sec_flags &= ~ SEC_READONLY; | 1223 | 309 | break; | 1224 | 183 | case IMAGE_SCN_MEM_DISCARDABLE: | 1225 | | /* The MS PE spec says that debug sections are DISCARDABLE, | 1226 | | but the presence of a DISCARDABLE flag does not necessarily | 1227 | | mean that a given section contains debug information. Thus | 1228 | | we only set the SEC_DEBUGGING flag on sections that we | 1229 | | recognise as containing debug information. */ | 1230 | 183 | if (is_dbg | 1231 | 183 | #ifdef _COMMENT | 1232 | 183 | || strcmp (name, _COMMENT) == 0 | 1233 | 183 | #endif | 1234 | 183 | ) | 1235 | 2 | { | 1236 | 2 | sec_flags |= SEC_DEBUGGING | SEC_READONLY; | 1237 | 2 | } | 1238 | 183 | break; | 1239 | 79 | case IMAGE_SCN_MEM_SHARED: | 1240 | 79 | sec_flags |= SEC_COFF_SHARED; | 1241 | 79 | break; | 1242 | 346 | case IMAGE_SCN_LNK_REMOVE: | 1243 | 346 | if (!is_dbg) | 1244 | 343 | sec_flags |= SEC_EXCLUDE; | 1245 | 346 | break; | 1246 | 371 | case IMAGE_SCN_CNT_CODE: | 1247 | 371 | sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD; | 1248 | 371 | break; | 1249 | 214 | case IMAGE_SCN_CNT_INITIALIZED_DATA: | 1250 | 214 | if (is_dbg) | 1251 | 3 | sec_flags |= SEC_DEBUGGING; | 1252 | 211 | else | 1253 | 211 | sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD; | 1254 | 214 | break; | 1255 | 210 | case IMAGE_SCN_CNT_UNINITIALIZED_DATA: | 1256 | 210 | sec_flags |= SEC_ALLOC; | 1257 | 210 | break; | 1258 | 183 | case IMAGE_SCN_LNK_INFO: | 1259 | | /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is | 1260 | | defined. coff_compute_section_file_positions uses | 1261 | | COFF_PAGE_SIZE to ensure that the low order bits of the | 1262 | | section VMA and the file offset match. If we don't know | 1263 | | COFF_PAGE_SIZE, we can't ensure the correct correspondence, | 1264 | | and demand page loading of the file will fail. */ | 1265 | 183 | #ifdef COFF_PAGE_SIZE | 1266 | 183 | sec_flags |= SEC_DEBUGGING; | 1267 | 183 | #endif | 1268 | 183 | break; | 1269 | 108 | case IMAGE_SCN_LNK_COMDAT: | 1270 | | /* COMDAT gets very special treatment. */ | 1271 | 108 | if (!handle_COMDAT (abfd, &sec_flags, hdr, name, section)) | 1272 | 7 | result = false; | 1273 | 108 | break; | 1274 | 2.70k | default: | 1275 | | /* Silently ignore for now. */ | 1276 | 2.70k | break; | 1277 | 6.55k | } | 1278 | | | 1279 | | /* If the section flag was not handled, report it here. */ | 1280 | 6.55k | if (unhandled != NULL) | 1281 | 281 | { | 1282 | 281 | _bfd_error_handler | 1283 | | /* xgettext:c-format */ | 1284 | 281 | (_("%pB (%s): section flag %s (%#lx) ignored"), | 1285 | 281 | abfd, name, unhandled, flag); | 1286 | 281 | result = false; | 1287 | 281 | } | 1288 | 6.55k | } | 1289 | | | 1290 | 1.70k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 1291 | 1.70k | && (startswith (name, ".sbss") | 1292 | 0 | || startswith (name, ".sdata"))) | 1293 | 0 | sec_flags |= SEC_SMALL_DATA; | 1294 | | | 1295 | | #if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE) | 1296 | | /* As a GNU extension, if the name begins with .gnu.linkonce, we | 1297 | | only link a single copy of the section. This is used to support | 1298 | | g++. g++ will emit each template expansion in its own section. | 1299 | | The symbols will be defined as weak, so that multiple definitions | 1300 | | are permitted. The GNU linker extension is to actually discard | 1301 | | all but one of the sections. */ | 1302 | | if (startswith (name, ".gnu.linkonce")) | 1303 | | sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; | 1304 | | #endif | 1305 | | | 1306 | 1.70k | if (flags_ptr) | 1307 | 1.70k | * flags_ptr = sec_flags; | 1308 | | | 1309 | 1.70k | return result; | 1310 | 1.70k | } |
|
1311 | | |
1312 | | #endif /* COFF_WITH_PE */ |
1313 | | |
1314 | 0 | #define get_index(symbol) ((symbol)->udata.i) |
1315 | | |
1316 | | /* |
1317 | | INTERNAL_DEFINITION |
1318 | | bfd_coff_backend_data |
1319 | | |
1320 | | INTERNAL |
1321 | | .{* COFF symbol classifications. *} |
1322 | | . |
1323 | | .enum coff_symbol_classification |
1324 | | .{ |
1325 | | . {* Global symbol. *} |
1326 | | . COFF_SYMBOL_GLOBAL, |
1327 | | . {* Common symbol. *} |
1328 | | . COFF_SYMBOL_COMMON, |
1329 | | . {* Undefined symbol. *} |
1330 | | . COFF_SYMBOL_UNDEFINED, |
1331 | | . {* Local symbol. *} |
1332 | | . COFF_SYMBOL_LOCAL, |
1333 | | . {* PE section symbol. *} |
1334 | | . COFF_SYMBOL_PE_SECTION |
1335 | | .}; |
1336 | | . |
1337 | | .typedef asection * (*coff_gc_mark_hook_fn) |
1338 | | . (asection *, struct bfd_link_info *, struct internal_reloc *, |
1339 | | . struct coff_link_hash_entry *, struct internal_syment *); |
1340 | | . |
1341 | | |
1342 | | Special entry points for gdb to swap in coff symbol table parts: |
1343 | | |
1344 | | CODE_FRAGMENT |
1345 | | .typedef struct |
1346 | | .{ |
1347 | | . void (*_bfd_coff_swap_aux_in) |
1348 | | . (bfd *, void *, int, int, int, int, void *); |
1349 | | . |
1350 | | . void (*_bfd_coff_swap_sym_in) |
1351 | | . (bfd *, void *, void *); |
1352 | | . |
1353 | | . void (*_bfd_coff_swap_lineno_in) |
1354 | | . (bfd *, void *, void *); |
1355 | | . |
1356 | | . unsigned int (*_bfd_coff_swap_aux_out) |
1357 | | . (bfd *, void *, int, int, int, int, void *); |
1358 | | . |
1359 | | . unsigned int (*_bfd_coff_swap_sym_out) |
1360 | | . (bfd *, void *, void *); |
1361 | | . |
1362 | | . unsigned int (*_bfd_coff_swap_lineno_out) |
1363 | | . (bfd *, void *, void *); |
1364 | | . |
1365 | | . unsigned int (*_bfd_coff_swap_reloc_out) |
1366 | | . (bfd *, void *, void *); |
1367 | | . |
1368 | | . unsigned int (*_bfd_coff_swap_filehdr_out) |
1369 | | . (bfd *, void *, void *); |
1370 | | . |
1371 | | . unsigned int (*_bfd_coff_swap_aouthdr_out) |
1372 | | . (bfd *, void *, void *); |
1373 | | . |
1374 | | . unsigned int (*_bfd_coff_swap_scnhdr_out) |
1375 | | . (bfd *, void *, void *); |
1376 | | . |
1377 | | . unsigned int _bfd_filhsz; |
1378 | | . unsigned int _bfd_aoutsz; |
1379 | | . unsigned int _bfd_scnhsz; |
1380 | | . unsigned int _bfd_symesz; |
1381 | | . unsigned int _bfd_auxesz; |
1382 | | . unsigned int _bfd_relsz; |
1383 | | . unsigned int _bfd_linesz; |
1384 | | . unsigned int _bfd_filnmlen; |
1385 | | . bool _bfd_coff_long_filenames; |
1386 | | . |
1387 | | . bool _bfd_coff_long_section_names; |
1388 | | . bool (*_bfd_coff_set_long_section_names) |
1389 | | . (bfd *, int); |
1390 | | . |
1391 | | . unsigned int _bfd_coff_default_section_alignment_power; |
1392 | | . bool _bfd_coff_force_symnames_in_strings; |
1393 | | . unsigned int _bfd_coff_debug_string_prefix_length; |
1394 | | . unsigned int _bfd_coff_max_nscns; |
1395 | | . |
1396 | | . void (*_bfd_coff_swap_filehdr_in) |
1397 | | . (bfd *, void *, void *); |
1398 | | . |
1399 | | . void (*_bfd_coff_swap_aouthdr_in) |
1400 | | . (bfd *, void *, void *); |
1401 | | . |
1402 | | . void (*_bfd_coff_swap_scnhdr_in) |
1403 | | . (bfd *, void *, void *); |
1404 | | . |
1405 | | . void (*_bfd_coff_swap_reloc_in) |
1406 | | . (bfd *abfd, void *, void *); |
1407 | | . |
1408 | | . bool (*_bfd_coff_bad_format_hook) |
1409 | | . (bfd *, void *); |
1410 | | . |
1411 | | . bool (*_bfd_coff_set_arch_mach_hook) |
1412 | | . (bfd *, void *); |
1413 | | . |
1414 | | . void * (*_bfd_coff_mkobject_hook) |
1415 | | . (bfd *, void *, void *); |
1416 | | . |
1417 | | . bool (*_bfd_styp_to_sec_flags_hook) |
1418 | | . (bfd *, void *, const char *, asection *, flagword *); |
1419 | | . |
1420 | | . void (*_bfd_set_alignment_hook) |
1421 | | . (bfd *, asection *, void *); |
1422 | | . |
1423 | | . bool (*_bfd_coff_slurp_symbol_table) |
1424 | | . (bfd *); |
1425 | | . |
1426 | | . bool (*_bfd_coff_symname_in_debug) |
1427 | | . (bfd *, struct internal_syment *); |
1428 | | . |
1429 | | . bool (*_bfd_coff_pointerize_aux_hook) |
1430 | | . (bfd *, combined_entry_type *, combined_entry_type *, |
1431 | | . unsigned int, combined_entry_type *); |
1432 | | . |
1433 | | . bool (*_bfd_coff_print_aux) |
1434 | | . (bfd *, FILE *, combined_entry_type *, combined_entry_type *, |
1435 | | . combined_entry_type *, unsigned int); |
1436 | | . |
1437 | | . bool (*_bfd_coff_reloc16_extra_cases) |
1438 | | . (bfd *, struct bfd_link_info *, struct bfd_link_order *, arelent *, |
1439 | | . bfd_byte *, size_t *, size_t *); |
1440 | | . |
1441 | | . int (*_bfd_coff_reloc16_estimate) |
1442 | | . (bfd *, asection *, arelent *, unsigned int, |
1443 | | . struct bfd_link_info *); |
1444 | | . |
1445 | | . enum coff_symbol_classification (*_bfd_coff_classify_symbol) |
1446 | | . (bfd *, struct internal_syment *); |
1447 | | . |
1448 | | . bool (*_bfd_coff_compute_section_file_positions) |
1449 | | . (bfd *); |
1450 | | . |
1451 | | . bool (*_bfd_coff_start_final_link) |
1452 | | . (bfd *, struct bfd_link_info *); |
1453 | | . |
1454 | | . bool (*_bfd_coff_relocate_section) |
1455 | | . (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, |
1456 | | . struct internal_reloc *, struct internal_syment *, asection **); |
1457 | | . |
1458 | | . reloc_howto_type *(*_bfd_coff_rtype_to_howto) |
1459 | | . (bfd *, asection *, struct internal_reloc *, |
1460 | | . struct coff_link_hash_entry *, struct internal_syment *, bfd_vma *); |
1461 | | . |
1462 | | . bool (*_bfd_coff_adjust_symndx) |
1463 | | . (bfd *, struct bfd_link_info *, bfd *, asection *, |
1464 | | . struct internal_reloc *, bool *); |
1465 | | . |
1466 | | . bool (*_bfd_coff_link_add_one_symbol) |
1467 | | . (struct bfd_link_info *, bfd *, const char *, flagword, |
1468 | | . asection *, bfd_vma, const char *, bool, bool, |
1469 | | . struct bfd_link_hash_entry **); |
1470 | | . |
1471 | | . bool (*_bfd_coff_link_output_has_begun) |
1472 | | . (bfd *, struct coff_final_link_info *); |
1473 | | . |
1474 | | . bool (*_bfd_coff_final_link_postscript) |
1475 | | . (bfd *, struct coff_final_link_info *); |
1476 | | . |
1477 | | . bool (*_bfd_coff_print_pdata) |
1478 | | . (bfd *, void *); |
1479 | | . |
1480 | | .} bfd_coff_backend_data; |
1481 | | . |
1482 | | |
1483 | | INTERNAL |
1484 | | .#define coff_backend_info(abfd) \ |
1485 | | . ((const bfd_coff_backend_data *) (abfd)->xvec->backend_data) |
1486 | | . |
1487 | | .#define bfd_coff_swap_aux_in(a,e,t,c,ind,num,i) \ |
1488 | | . ((coff_backend_info (a)->_bfd_coff_swap_aux_in) (a,e,t,c,ind,num,i)) |
1489 | | . |
1490 | | .#define bfd_coff_swap_sym_in(a,e,i) \ |
1491 | | . ((coff_backend_info (a)->_bfd_coff_swap_sym_in) (a,e,i)) |
1492 | | . |
1493 | | .#define bfd_coff_swap_lineno_in(a,e,i) \ |
1494 | | . ((coff_backend_info ( a)->_bfd_coff_swap_lineno_in) (a,e,i)) |
1495 | | . |
1496 | | .#define bfd_coff_swap_reloc_out(abfd, i, o) \ |
1497 | | . ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_out) (abfd, i, o)) |
1498 | | . |
1499 | | .#define bfd_coff_swap_lineno_out(abfd, i, o) \ |
1500 | | . ((coff_backend_info (abfd)->_bfd_coff_swap_lineno_out) (abfd, i, o)) |
1501 | | . |
1502 | | .#define bfd_coff_swap_aux_out(a,i,t,c,ind,num,o) \ |
1503 | | . ((coff_backend_info (a)->_bfd_coff_swap_aux_out) (a,i,t,c,ind,num,o)) |
1504 | | . |
1505 | | .#define bfd_coff_swap_sym_out(abfd, i,o) \ |
1506 | | . ((coff_backend_info (abfd)->_bfd_coff_swap_sym_out) (abfd, i, o)) |
1507 | | . |
1508 | | .#define bfd_coff_swap_scnhdr_out(abfd, i,o) \ |
1509 | | . ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_out) (abfd, i, o)) |
1510 | | . |
1511 | | .#define bfd_coff_swap_filehdr_out(abfd, i,o) \ |
1512 | | . ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_out) (abfd, i, o)) |
1513 | | . |
1514 | | .#define bfd_coff_swap_aouthdr_out(abfd, i,o) \ |
1515 | | . ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_out) (abfd, i, o)) |
1516 | | . |
1517 | | .#define bfd_coff_filhsz(abfd) (coff_backend_info (abfd)->_bfd_filhsz) |
1518 | | .#define bfd_coff_aoutsz(abfd) (coff_backend_info (abfd)->_bfd_aoutsz) |
1519 | | .#define bfd_coff_scnhsz(abfd) (coff_backend_info (abfd)->_bfd_scnhsz) |
1520 | | .#define bfd_coff_symesz(abfd) (coff_backend_info (abfd)->_bfd_symesz) |
1521 | | .#define bfd_coff_auxesz(abfd) (coff_backend_info (abfd)->_bfd_auxesz) |
1522 | | .#define bfd_coff_relsz(abfd) (coff_backend_info (abfd)->_bfd_relsz) |
1523 | | .#define bfd_coff_linesz(abfd) (coff_backend_info (abfd)->_bfd_linesz) |
1524 | | .#define bfd_coff_filnmlen(abfd) (coff_backend_info (abfd)->_bfd_filnmlen) |
1525 | | .#define bfd_coff_long_filenames(abfd) \ |
1526 | | . (coff_backend_info (abfd)->_bfd_coff_long_filenames) |
1527 | | .#define bfd_coff_long_section_names(abfd) \ |
1528 | | . (coff_data (abfd)->long_section_names) |
1529 | | .#define bfd_coff_set_long_section_names(abfd, enable) \ |
1530 | | . ((coff_backend_info (abfd)->_bfd_coff_set_long_section_names) (abfd, enable)) |
1531 | | .#define bfd_coff_default_section_alignment_power(abfd) \ |
1532 | | . (coff_backend_info (abfd)->_bfd_coff_default_section_alignment_power) |
1533 | | .#define bfd_coff_max_nscns(abfd) \ |
1534 | | . (coff_backend_info (abfd)->_bfd_coff_max_nscns) |
1535 | | . |
1536 | | .#define bfd_coff_swap_filehdr_in(abfd, i,o) \ |
1537 | | . ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_in) (abfd, i, o)) |
1538 | | . |
1539 | | .#define bfd_coff_swap_aouthdr_in(abfd, i,o) \ |
1540 | | . ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_in) (abfd, i, o)) |
1541 | | . |
1542 | | .#define bfd_coff_swap_scnhdr_in(abfd, i,o) \ |
1543 | | . ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_in) (abfd, i, o)) |
1544 | | . |
1545 | | .#define bfd_coff_swap_reloc_in(abfd, i, o) \ |
1546 | | . ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_in) (abfd, i, o)) |
1547 | | . |
1548 | | .#define bfd_coff_bad_format_hook(abfd, filehdr) \ |
1549 | | . ((coff_backend_info (abfd)->_bfd_coff_bad_format_hook) (abfd, filehdr)) |
1550 | | . |
1551 | | .#define bfd_coff_set_arch_mach_hook(abfd, filehdr)\ |
1552 | | . ((coff_backend_info (abfd)->_bfd_coff_set_arch_mach_hook) (abfd, filehdr)) |
1553 | | .#define bfd_coff_mkobject_hook(abfd, filehdr, aouthdr)\ |
1554 | | . ((coff_backend_info (abfd)->_bfd_coff_mkobject_hook)\ |
1555 | | . (abfd, filehdr, aouthdr)) |
1556 | | . |
1557 | | .#define bfd_coff_styp_to_sec_flags_hook(abfd, scnhdr, name, section, flags_ptr)\ |
1558 | | . ((coff_backend_info (abfd)->_bfd_styp_to_sec_flags_hook)\ |
1559 | | . (abfd, scnhdr, name, section, flags_ptr)) |
1560 | | . |
1561 | | .#define bfd_coff_set_alignment_hook(abfd, sec, scnhdr)\ |
1562 | | . ((coff_backend_info (abfd)->_bfd_set_alignment_hook) (abfd, sec, scnhdr)) |
1563 | | . |
1564 | | .#define bfd_coff_slurp_symbol_table(abfd)\ |
1565 | | . ((coff_backend_info (abfd)->_bfd_coff_slurp_symbol_table) (abfd)) |
1566 | | . |
1567 | | .#define bfd_coff_symname_in_debug(abfd, sym)\ |
1568 | | . ((coff_backend_info (abfd)->_bfd_coff_symname_in_debug) (abfd, sym)) |
1569 | | . |
1570 | | .#define bfd_coff_force_symnames_in_strings(abfd)\ |
1571 | | . (coff_backend_info (abfd)->_bfd_coff_force_symnames_in_strings) |
1572 | | . |
1573 | | .#define bfd_coff_debug_string_prefix_length(abfd)\ |
1574 | | . (coff_backend_info (abfd)->_bfd_coff_debug_string_prefix_length) |
1575 | | . |
1576 | | .#define bfd_coff_print_aux(abfd, file, base, symbol, aux, indaux)\ |
1577 | | . ((coff_backend_info (abfd)->_bfd_coff_print_aux)\ |
1578 | | . (abfd, file, base, symbol, aux, indaux)) |
1579 | | . |
1580 | | .#define bfd_coff_reloc16_extra_cases(abfd, link_info, link_order,\ |
1581 | | . reloc, data, src_ptr, dst_ptr)\ |
1582 | | . ((coff_backend_info (abfd)->_bfd_coff_reloc16_extra_cases)\ |
1583 | | . (abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr)) |
1584 | | . |
1585 | | .#define bfd_coff_reloc16_estimate(abfd, section, reloc, shrink, link_info)\ |
1586 | | . ((coff_backend_info (abfd)->_bfd_coff_reloc16_estimate)\ |
1587 | | . (abfd, section, reloc, shrink, link_info)) |
1588 | | . |
1589 | | .#define bfd_coff_classify_symbol(abfd, sym)\ |
1590 | | . ((coff_backend_info (abfd)->_bfd_coff_classify_symbol)\ |
1591 | | . (abfd, sym)) |
1592 | | . |
1593 | | .#define bfd_coff_compute_section_file_positions(abfd)\ |
1594 | | . ((coff_backend_info (abfd)->_bfd_coff_compute_section_file_positions)\ |
1595 | | . (abfd)) |
1596 | | . |
1597 | | .#define bfd_coff_start_final_link(obfd, info)\ |
1598 | | . ((coff_backend_info (obfd)->_bfd_coff_start_final_link)\ |
1599 | | . (obfd, info)) |
1600 | | .#define bfd_coff_relocate_section(obfd,info,ibfd,o,con,rel,isyms,secs)\ |
1601 | | . ((coff_backend_info (ibfd)->_bfd_coff_relocate_section)\ |
1602 | | . (obfd, info, ibfd, o, con, rel, isyms, secs)) |
1603 | | .#define bfd_coff_rtype_to_howto(abfd, sec, rel, h, sym, addendp)\ |
1604 | | . ((coff_backend_info (abfd)->_bfd_coff_rtype_to_howto)\ |
1605 | | . (abfd, sec, rel, h, sym, addendp)) |
1606 | | .#define bfd_coff_adjust_symndx(obfd, info, ibfd, sec, rel, adjustedp)\ |
1607 | | . ((coff_backend_info (abfd)->_bfd_coff_adjust_symndx)\ |
1608 | | . (obfd, info, ibfd, sec, rel, adjustedp)) |
1609 | | .#define bfd_coff_link_add_one_symbol(info, abfd, name, flags, section,\ |
1610 | | . value, string, cp, coll, hashp)\ |
1611 | | . ((coff_backend_info (abfd)->_bfd_coff_link_add_one_symbol)\ |
1612 | | . (info, abfd, name, flags, section, value, string, cp, coll, hashp)) |
1613 | | . |
1614 | | .#define bfd_coff_link_output_has_begun(a,p) \ |
1615 | | . ((coff_backend_info (a)->_bfd_coff_link_output_has_begun) (a, p)) |
1616 | | .#define bfd_coff_final_link_postscript(a,p) \ |
1617 | | . ((coff_backend_info (a)->_bfd_coff_final_link_postscript) (a, p)) |
1618 | | . |
1619 | | .#define bfd_coff_have_print_pdata(a) \ |
1620 | | . (coff_backend_info (a)->_bfd_coff_print_pdata) |
1621 | | .#define bfd_coff_print_pdata(a,p) \ |
1622 | | . ((coff_backend_info (a)->_bfd_coff_print_pdata) (a, p)) |
1623 | | . |
1624 | | .{* Macro: Returns true if the bfd is a PE executable as opposed to a |
1625 | | . PE object file. *} |
1626 | | .#define bfd_pei_p(abfd) \ |
1627 | | . (startswith ((abfd)->xvec->name, "pei-")) |
1628 | | */ |
1629 | | |
1630 | | /* See whether the magic number matches. */ |
1631 | | |
1632 | | static bool |
1633 | | coff_bad_format_hook (bfd * abfd ATTRIBUTE_UNUSED, void * filehdr) |
1634 | 585k | { |
1635 | 585k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; |
1636 | | |
1637 | 585k | if (BADMAG (*internal_f)) |
1638 | 571k | return false; |
1639 | | |
1640 | 14.2k | return true; |
1641 | 585k | } pei-i386.c:coff_bad_format_hook Line | Count | Source | 1634 | 3.19k | { | 1635 | 3.19k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 3.19k | if (BADMAG (*internal_f)) | 1638 | 2.62k | return false; | 1639 | | | 1640 | 566 | return true; | 1641 | 3.19k | } |
pe-x86_64.c:coff_bad_format_hook Line | Count | Source | 1634 | 41.2k | { | 1635 | 41.2k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 41.2k | if (BADMAG (*internal_f)) | 1638 | 39.7k | return false; | 1639 | | | 1640 | 1.45k | return true; | 1641 | 41.2k | } |
pei-x86_64.c:coff_bad_format_hook Line | Count | Source | 1634 | 3.12k | { | 1635 | 3.12k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 3.12k | if (BADMAG (*internal_f)) | 1638 | 2.64k | return false; | 1639 | | | 1640 | 482 | return true; | 1641 | 3.12k | } |
coff-x86_64.c:coff_bad_format_hook Line | Count | Source | 1634 | 21.6k | { | 1635 | 21.6k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 21.6k | if (BADMAG (*internal_f)) | 1638 | 20.6k | return false; | 1639 | | | 1640 | 1.03k | return true; | 1641 | 21.6k | } |
Unexecuted instantiation: coff64-rs6000.c:coff_bad_format_hook pei-aarch64.c:coff_bad_format_hook Line | Count | Source | 1634 | 2.99k | { | 1635 | 2.99k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 2.99k | if (BADMAG (*internal_f)) | 1638 | 2.67k | return false; | 1639 | | | 1640 | 319 | return true; | 1641 | 2.99k | } |
pe-aarch64.c:coff_bad_format_hook Line | Count | Source | 1634 | 21.6k | { | 1635 | 21.6k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 21.6k | if (BADMAG (*internal_f)) | 1638 | 21.1k | return false; | 1639 | | | 1640 | 510 | return true; | 1641 | 21.6k | } |
pei-ia64.c:coff_bad_format_hook Line | Count | Source | 1634 | 2.57k | { | 1635 | 2.57k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 2.57k | if (BADMAG (*internal_f)) | 1638 | 2.18k | return false; | 1639 | | | 1640 | 386 | return true; | 1641 | 2.57k | } |
pei-loongarch64.c:coff_bad_format_hook Line | Count | Source | 1634 | 2.99k | { | 1635 | 2.99k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 2.99k | if (BADMAG (*internal_f)) | 1638 | 2.53k | return false; | 1639 | | | 1640 | 456 | return true; | 1641 | 2.99k | } |
cf-i386lynx.c:coff_bad_format_hook Line | Count | Source | 1634 | 21.6k | { | 1635 | 21.6k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 21.6k | if (BADMAG (*internal_f)) | 1638 | 20.9k | return false; | 1639 | | | 1640 | 735 | return true; | 1641 | 21.6k | } |
coff-go32.c:coff_bad_format_hook Line | Count | Source | 1634 | 21.6k | { | 1635 | 21.6k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 21.6k | if (BADMAG (*internal_f)) | 1638 | 20.9k | return false; | 1639 | | | 1640 | 656 | return true; | 1641 | 21.6k | } |
coff-i386.c:coff_bad_format_hook Line | Count | Source | 1634 | 21.6k | { | 1635 | 21.6k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 21.6k | if (BADMAG (*internal_f)) | 1638 | 20.9k | return false; | 1639 | | | 1640 | 656 | return true; | 1641 | 21.6k | } |
coff-rs6000.c:coff_bad_format_hook Line | Count | Source | 1634 | 21.6k | { | 1635 | 21.6k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 21.6k | if (BADMAG (*internal_f)) | 1638 | 21.0k | return false; | 1639 | | | 1640 | 612 | return true; | 1641 | 21.6k | } |
coff-sh.c:coff_bad_format_hook Line | Count | Source | 1634 | 86.5k | { | 1635 | 86.5k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 86.5k | if (BADMAG (*internal_f)) | 1638 | 85.5k | return false; | 1639 | | | 1640 | 998 | return true; | 1641 | 86.5k | } |
coff-stgo32.c:coff_bad_format_hook Line | Count | Source | 1634 | 88 | { | 1635 | 88 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 88 | if (BADMAG (*internal_f)) | 1638 | 8 | return false; | 1639 | | | 1640 | 80 | return true; | 1641 | 88 | } |
coff-tic30.c:coff_bad_format_hook Line | Count | Source | 1634 | 21.6k | { | 1635 | 21.6k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 21.6k | if (BADMAG (*internal_f)) | 1638 | 21.2k | return false; | 1639 | | | 1640 | 430 | return true; | 1641 | 21.6k | } |
Unexecuted instantiation: coff-tic4x.c:coff_bad_format_hook coff-tic54x.c:coff_bad_format_hook Line | Count | Source | 1634 | 42.8k | { | 1635 | 42.8k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 42.8k | if (BADMAG (*internal_f)) | 1638 | 42.8k | return false; | 1639 | | | 1640 | 5 | return true; | 1641 | 42.8k | } |
coff-z80.c:coff_bad_format_hook Line | Count | Source | 1634 | 21.6k | { | 1635 | 21.6k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 21.6k | if (BADMAG (*internal_f)) | 1638 | 21.2k | return false; | 1639 | | | 1640 | 363 | return true; | 1641 | 21.6k | } |
coff-z8k.c:coff_bad_format_hook Line | Count | Source | 1634 | 21.6k | { | 1635 | 21.6k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 21.6k | if (BADMAG (*internal_f)) | 1638 | 21.2k | return false; | 1639 | | | 1640 | 373 | return true; | 1641 | 21.6k | } |
pe-arm-wince.c:coff_bad_format_hook Line | Count | Source | 1634 | 43.2k | { | 1635 | 43.2k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 43.2k | if (BADMAG (*internal_f)) | 1638 | 43.0k | return false; | 1639 | | | 1640 | 232 | return true; | 1641 | 43.2k | } |
pe-arm.c:coff_bad_format_hook Line | Count | Source | 1634 | 43.2k | { | 1635 | 43.2k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 43.2k | if (BADMAG (*internal_f)) | 1638 | 43.0k | return false; | 1639 | | | 1640 | 232 | return true; | 1641 | 43.2k | } |
pe-i386.c:coff_bad_format_hook Line | Count | Source | 1634 | 40.8k | { | 1635 | 40.8k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 40.8k | if (BADMAG (*internal_f)) | 1638 | 40.0k | return false; | 1639 | | | 1640 | 863 | return true; | 1641 | 40.8k | } |
pe-mcore.c:coff_bad_format_hook Line | Count | Source | 1634 | 43.2k | { | 1635 | 43.2k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 43.2k | if (BADMAG (*internal_f)) | 1638 | 42.8k | return false; | 1639 | | | 1640 | 401 | return true; | 1641 | 43.2k | } |
pe-sh.c:coff_bad_format_hook Line | Count | Source | 1634 | 21.6k | { | 1635 | 21.6k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 21.6k | if (BADMAG (*internal_f)) | 1638 | 21.1k | return false; | 1639 | | | 1640 | 486 | return true; | 1641 | 21.6k | } |
pei-arm-wince.c:coff_bad_format_hook Line | Count | Source | 1634 | 3.13k | { | 1635 | 3.13k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 3.13k | if (BADMAG (*internal_f)) | 1638 | 2.50k | return false; | 1639 | | | 1640 | 632 | return true; | 1641 | 3.13k | } |
pei-arm.c:coff_bad_format_hook Line | Count | Source | 1634 | 3.13k | { | 1635 | 3.13k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 3.13k | if (BADMAG (*internal_f)) | 1638 | 2.50k | return false; | 1639 | | | 1640 | 632 | return true; | 1641 | 3.13k | } |
pei-mcore.c:coff_bad_format_hook Line | Count | Source | 1634 | 3.13k | { | 1635 | 3.13k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 3.13k | if (BADMAG (*internal_f)) | 1638 | 2.83k | return false; | 1639 | | | 1640 | 303 | return true; | 1641 | 3.13k | } |
pei-sh.c:coff_bad_format_hook Line | Count | Source | 1634 | 2.99k | { | 1635 | 2.99k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 2.99k | if (BADMAG (*internal_f)) | 1638 | 2.69k | return false; | 1639 | | | 1640 | 303 | return true; | 1641 | 2.99k | } |
|
1642 | | |
1643 | | #ifdef TICOFF |
1644 | | static bool |
1645 | | ticoff0_bad_format_hook (bfd *abfd ATTRIBUTE_UNUSED, void * filehdr) |
1646 | 43.2k | { |
1647 | 43.2k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; |
1648 | | |
1649 | 43.2k | if (COFF0_BADMAG (*internal_f)) |
1650 | 42.8k | return false; |
1651 | | |
1652 | 412 | return true; |
1653 | 43.2k | } Unexecuted instantiation: coff-tic4x.c:ticoff0_bad_format_hook coff-tic54x.c:ticoff0_bad_format_hook Line | Count | Source | 1646 | 43.2k | { | 1647 | 43.2k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1648 | | | 1649 | 43.2k | if (COFF0_BADMAG (*internal_f)) | 1650 | 42.8k | return false; | 1651 | | | 1652 | 412 | return true; | 1653 | 43.2k | } |
|
1654 | | #endif |
1655 | | |
1656 | | #ifdef TICOFF |
1657 | | static bool |
1658 | | ticoff1_bad_format_hook (bfd *abfd ATTRIBUTE_UNUSED, void * filehdr) |
1659 | 42.8k | { |
1660 | 42.8k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; |
1661 | | |
1662 | 42.8k | if (COFF1_BADMAG (*internal_f)) |
1663 | 42.8k | return false; |
1664 | | |
1665 | 1 | return true; |
1666 | 42.8k | } Unexecuted instantiation: coff-tic4x.c:ticoff1_bad_format_hook coff-tic54x.c:ticoff1_bad_format_hook Line | Count | Source | 1659 | 42.8k | { | 1660 | 42.8k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1661 | | | 1662 | 42.8k | if (COFF1_BADMAG (*internal_f)) | 1663 | 42.8k | return false; | 1664 | | | 1665 | 1 | return true; | 1666 | 42.8k | } |
|
1667 | | #endif |
1668 | | |
1669 | | /* Check whether this section uses an alignment other than the |
1670 | | default. */ |
1671 | | |
1672 | | static void |
1673 | | coff_set_custom_section_alignment (bfd *abfd ATTRIBUTE_UNUSED, |
1674 | | asection *section, |
1675 | | const struct coff_section_alignment_entry *alignment_table, |
1676 | | const unsigned int table_size) |
1677 | 1.00M | { |
1678 | 1.00M | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; |
1679 | 1.00M | unsigned int i; |
1680 | | |
1681 | 6.66M | for (i = 0; i < table_size; ++i) |
1682 | 5.66M | { |
1683 | 5.66M | const char *secname = bfd_section_name (section); |
1684 | | |
1685 | 5.66M | if (alignment_table[i].comparison_length == (unsigned int) -1 |
1686 | 5.66M | ? strcmp (alignment_table[i].name, secname) == 0 |
1687 | 5.66M | : strncmp (alignment_table[i].name, secname, |
1688 | 3.48M | alignment_table[i].comparison_length) == 0) |
1689 | 1.40k | break; |
1690 | 5.66M | } |
1691 | 1.00M | if (i >= table_size) |
1692 | 1.00M | return; |
1693 | | |
1694 | 1.40k | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY |
1695 | 1.40k | && default_alignment < alignment_table[i].default_alignment_min) |
1696 | 451 | return; |
1697 | | |
1698 | 957 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY |
1699 | | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 |
1700 | 0 | && default_alignment > alignment_table[i].default_alignment_max |
1701 | | #endif |
1702 | 957 | ) |
1703 | 0 | return; |
1704 | | |
1705 | 957 | section->alignment_power = alignment_table[i].alignment_power; |
1706 | 957 | } pei-i386.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 3.29k | { | 1678 | 3.29k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 3.29k | unsigned int i; | 1680 | | | 1681 | 29.2k | for (i = 0; i < table_size; ++i) | 1682 | 26.0k | { | 1683 | 26.0k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 26.0k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 26.0k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 26.0k | : strncmp (alignment_table[i].name, secname, | 1688 | 16.2k | alignment_table[i].comparison_length) == 0) | 1689 | 57 | break; | 1690 | 26.0k | } | 1691 | 3.29k | if (i >= table_size) | 1692 | 3.23k | return; | 1693 | | | 1694 | 57 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 57 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 12 | return; | 1697 | | | 1698 | 45 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 45 | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 45 | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 45 | #endif | 1702 | 45 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 45 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 45 | } |
pe-x86_64.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 5.33k | { | 1678 | 5.33k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 5.33k | unsigned int i; | 1680 | | | 1681 | 73.9k | for (i = 0; i < table_size; ++i) | 1682 | 68.7k | { | 1683 | 68.7k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 68.7k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 68.7k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 68.7k | : strncmp (alignment_table[i].name, secname, | 1688 | 47.6k | alignment_table[i].comparison_length) == 0) | 1689 | 100 | break; | 1690 | 68.7k | } | 1691 | 5.33k | if (i >= table_size) | 1692 | 5.23k | return; | 1693 | | | 1694 | 100 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 100 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 25 | return; | 1697 | | | 1698 | 75 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 75 | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 75 | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 75 | #endif | 1702 | 75 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 75 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 75 | } |
pei-x86_64.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 3.29k | { | 1678 | 3.29k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 3.29k | unsigned int i; | 1680 | | | 1681 | 42.1k | for (i = 0; i < table_size; ++i) | 1682 | 38.9k | { | 1683 | 38.9k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 38.9k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 38.9k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 38.9k | : strncmp (alignment_table[i].name, secname, | 1688 | 26.0k | alignment_table[i].comparison_length) == 0) | 1689 | 87 | break; | 1690 | 38.9k | } | 1691 | 3.29k | if (i >= table_size) | 1692 | 3.20k | return; | 1693 | | | 1694 | 87 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 87 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 3 | return; | 1697 | | | 1698 | 84 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 84 | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 84 | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 84 | #endif | 1702 | 84 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 84 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 84 | } |
coff-x86_64.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 199k | { | 1678 | 199k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 199k | unsigned int i; | 1680 | | | 1681 | 999k | for (i = 0; i < table_size; ++i) | 1682 | 799k | { | 1683 | 799k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 799k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 799k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 799k | : strncmp (alignment_table[i].name, secname, | 1688 | 399k | alignment_table[i].comparison_length) == 0) | 1689 | 63 | break; | 1690 | 799k | } | 1691 | 199k | if (i >= table_size) | 1692 | 199k | return; | 1693 | | | 1694 | 63 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 63 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 52 | return; | 1697 | | | 1698 | 11 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 11 | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 11 | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 11 | #endif | 1702 | 11 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 11 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 11 | } |
coff64-rs6000.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 46.2k | { | 1678 | 46.2k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 46.2k | unsigned int i; | 1680 | | | 1681 | 231k | for (i = 0; i < table_size; ++i) | 1682 | 185k | { | 1683 | 185k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 185k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 185k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 185k | : strncmp (alignment_table[i].name, secname, | 1688 | 92.5k | alignment_table[i].comparison_length) == 0) | 1689 | 37 | break; | 1690 | 185k | } | 1691 | 46.2k | if (i >= table_size) | 1692 | 46.2k | return; | 1693 | | | 1694 | 37 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 37 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 0 | return; | 1697 | | | 1698 | 37 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 37 | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 37 | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 37 | #endif | 1702 | 37 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 37 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 37 | } |
pei-aarch64.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 1.77k | { | 1678 | 1.77k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 1.77k | unsigned int i; | 1680 | | | 1681 | 22.8k | for (i = 0; i < table_size; ++i) | 1682 | 21.1k | { | 1683 | 21.1k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 21.1k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 21.1k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 21.1k | : strncmp (alignment_table[i].name, secname, | 1688 | 8.77k | alignment_table[i].comparison_length) == 0) | 1689 | 31 | break; | 1690 | 21.1k | } | 1691 | 1.77k | if (i >= table_size) | 1692 | 1.74k | return; | 1693 | | | 1694 | 31 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 31 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 1 | return; | 1697 | | | 1698 | 30 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 30 | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 30 | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 30 | #endif | 1702 | 30 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 30 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 30 | } |
pe-aarch64.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 5.50k | { | 1678 | 5.50k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 5.50k | unsigned int i; | 1680 | | | 1681 | 71.4k | for (i = 0; i < table_size; ++i) | 1682 | 65.9k | { | 1683 | 65.9k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 65.9k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 65.9k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 65.9k | : strncmp (alignment_table[i].name, secname, | 1688 | 27.4k | alignment_table[i].comparison_length) == 0) | 1689 | 13 | break; | 1690 | 65.9k | } | 1691 | 5.50k | if (i >= table_size) | 1692 | 5.49k | return; | 1693 | | | 1694 | 13 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 13 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 5 | return; | 1697 | | | 1698 | 8 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 8 | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 8 | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 8 | #endif | 1702 | 8 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 8 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 8 | } |
pei-ia64.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 2.25k | { | 1678 | 2.25k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 2.25k | unsigned int i; | 1680 | | | 1681 | 11.2k | for (i = 0; i < table_size; ++i) | 1682 | 9.03k | { | 1683 | 9.03k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 9.03k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 9.03k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 9.03k | : strncmp (alignment_table[i].name, secname, | 1688 | 4.51k | alignment_table[i].comparison_length) == 0) | 1689 | 2 | break; | 1690 | 9.03k | } | 1691 | 2.25k | if (i >= table_size) | 1692 | 2.25k | return; | 1693 | | | 1694 | 2 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 2 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 2 | return; | 1697 | | | 1698 | 0 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 0 | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 0 | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 0 | #endif | 1702 | 0 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 0 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 0 | } |
pei-loongarch64.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 8.62k | { | 1678 | 8.62k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 8.62k | unsigned int i; | 1680 | | | 1681 | 111k | for (i = 0; i < table_size; ++i) | 1682 | 103k | { | 1683 | 103k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 103k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 103k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 103k | : strncmp (alignment_table[i].name, secname, | 1688 | 43.0k | alignment_table[i].comparison_length) == 0) | 1689 | 45 | break; | 1690 | 103k | } | 1691 | 8.62k | if (i >= table_size) | 1692 | 8.57k | return; | 1693 | | | 1694 | 45 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 45 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 11 | return; | 1697 | | | 1698 | 34 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 34 | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 34 | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 34 | #endif | 1702 | 34 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 34 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 34 | } |
cf-i386lynx.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 140k | { | 1678 | 140k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 140k | unsigned int i; | 1680 | | | 1681 | 703k | for (i = 0; i < table_size; ++i) | 1682 | 563k | { | 1683 | 563k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 563k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 563k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 563k | : strncmp (alignment_table[i].name, secname, | 1688 | 281k | alignment_table[i].comparison_length) == 0) | 1689 | 110 | break; | 1690 | 563k | } | 1691 | 140k | if (i >= table_size) | 1692 | 140k | return; | 1693 | | | 1694 | 110 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 110 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 65 | return; | 1697 | | | 1698 | 45 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 45 | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 45 | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 45 | #endif | 1702 | 45 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 45 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 45 | } |
coff-go32.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 116k | { | 1678 | 116k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 116k | unsigned int i; | 1680 | | | 1681 | 1.86M | for (i = 0; i < table_size; ++i) | 1682 | 1.75M | { | 1683 | 1.75M | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 1.75M | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 1.75M | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 1.75M | : strncmp (alignment_table[i].name, secname, | 1688 | 1.51M | alignment_table[i].comparison_length) == 0) | 1689 | 172 | break; | 1690 | 1.75M | } | 1691 | 116k | if (i >= table_size) | 1692 | 116k | return; | 1693 | | | 1694 | 172 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 172 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 41 | return; | 1697 | | | 1698 | 131 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 131 | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 131 | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 131 | #endif | 1702 | 131 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 131 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 131 | } |
coff-i386.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 127k | { | 1678 | 127k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 127k | unsigned int i; | 1680 | | | 1681 | 636k | for (i = 0; i < table_size; ++i) | 1682 | 509k | { | 1683 | 509k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 509k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 509k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 509k | : strncmp (alignment_table[i].name, secname, | 1688 | 254k | alignment_table[i].comparison_length) == 0) | 1689 | 75 | break; | 1690 | 509k | } | 1691 | 127k | if (i >= table_size) | 1692 | 127k | return; | 1693 | | | 1694 | 75 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 75 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 41 | return; | 1697 | | | 1698 | 34 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 34 | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 34 | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 34 | #endif | 1702 | 34 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 34 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 34 | } |
coff-rs6000.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 85.1k | { | 1678 | 85.1k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 85.1k | unsigned int i; | 1680 | | | 1681 | 425k | for (i = 0; i < table_size; ++i) | 1682 | 340k | { | 1683 | 340k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 340k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 340k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 340k | : strncmp (alignment_table[i].name, secname, | 1688 | 170k | alignment_table[i].comparison_length) == 0) | 1689 | 30 | break; | 1690 | 340k | } | 1691 | 85.1k | if (i >= table_size) | 1692 | 85.1k | return; | 1693 | | | 1694 | 30 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 30 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 0 | return; | 1697 | | | 1698 | 30 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 30 | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 30 | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 30 | #endif | 1702 | 30 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 30 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 30 | } |
coff-sh.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 20.6k | { | 1678 | 20.6k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 20.6k | unsigned int i; | 1680 | | | 1681 | 102k | for (i = 0; i < table_size; ++i) | 1682 | 82.3k | { | 1683 | 82.3k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 82.3k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 82.3k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 82.3k | : strncmp (alignment_table[i].name, secname, | 1688 | 41.2k | alignment_table[i].comparison_length) == 0) | 1689 | 62 | break; | 1690 | 82.3k | } | 1691 | 20.6k | if (i >= table_size) | 1692 | 20.5k | return; | 1693 | | | 1694 | 62 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 62 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 0 | return; | 1697 | | | 1698 | 62 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 62 | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 62 | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 62 | #endif | 1702 | 62 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 62 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 62 | } |
coff-stgo32.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 13.6k | { | 1678 | 13.6k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 13.6k | unsigned int i; | 1680 | | | 1681 | 122k | for (i = 0; i < table_size; ++i) | 1682 | 109k | { | 1683 | 109k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 109k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 109k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 109k | : strncmp (alignment_table[i].name, secname, | 1688 | 54.6k | alignment_table[i].comparison_length) == 0) | 1689 | 76 | break; | 1690 | 109k | } | 1691 | 13.6k | if (i >= table_size) | 1692 | 13.6k | return; | 1693 | | | 1694 | 76 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 76 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 24 | return; | 1697 | | | 1698 | 52 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 52 | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 52 | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 52 | #endif | 1702 | 52 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 52 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 52 | } |
coff-tic30.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 37.6k | { | 1678 | 37.6k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 37.6k | unsigned int i; | 1680 | | | 1681 | 188k | for (i = 0; i < table_size; ++i) | 1682 | 150k | { | 1683 | 150k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 150k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 150k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 150k | : strncmp (alignment_table[i].name, secname, | 1688 | 75.2k | alignment_table[i].comparison_length) == 0) | 1689 | 22 | break; | 1690 | 150k | } | 1691 | 37.6k | if (i >= table_size) | 1692 | 37.6k | return; | 1693 | | | 1694 | 22 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 22 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 20 | return; | 1697 | | | 1698 | 2 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 2 | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 2 | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 2 | #endif | 1702 | 2 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 2 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 2 | } |
Unexecuted instantiation: coff-tic4x.c:coff_set_custom_section_alignment coff-tic54x.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 55.7k | { | 1678 | 55.7k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 55.7k | unsigned int i; | 1680 | | | 1681 | 278k | for (i = 0; i < table_size; ++i) | 1682 | 223k | { | 1683 | 223k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 223k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 223k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 223k | : strncmp (alignment_table[i].name, secname, | 1688 | 111k | alignment_table[i].comparison_length) == 0) | 1689 | 9 | break; | 1690 | 223k | } | 1691 | 55.7k | if (i >= table_size) | 1692 | 55.7k | return; | 1693 | | | 1694 | 9 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 9 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 9 | return; | 1697 | | | 1698 | 0 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | | && default_alignment > alignment_table[i].default_alignment_max | 1701 | | #endif | 1702 | 0 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 0 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 0 | } |
coff-z80.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 43.4k | { | 1678 | 43.4k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 43.4k | unsigned int i; | 1680 | | | 1681 | 217k | for (i = 0; i < table_size; ++i) | 1682 | 173k | { | 1683 | 173k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 173k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 173k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 173k | : strncmp (alignment_table[i].name, secname, | 1688 | 86.9k | alignment_table[i].comparison_length) == 0) | 1689 | 10 | break; | 1690 | 173k | } | 1691 | 43.4k | if (i >= table_size) | 1692 | 43.4k | return; | 1693 | | | 1694 | 10 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 10 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 10 | return; | 1697 | | | 1698 | 0 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | | && default_alignment > alignment_table[i].default_alignment_max | 1701 | | #endif | 1702 | 0 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 0 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 0 | } |
coff-z8k.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 59.7k | { | 1678 | 59.7k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 59.7k | unsigned int i; | 1680 | | | 1681 | 298k | for (i = 0; i < table_size; ++i) | 1682 | 238k | { | 1683 | 238k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 238k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 238k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 238k | : strncmp (alignment_table[i].name, secname, | 1688 | 119k | alignment_table[i].comparison_length) == 0) | 1689 | 65 | break; | 1690 | 238k | } | 1691 | 59.7k | if (i >= table_size) | 1692 | 59.6k | return; | 1693 | | | 1694 | 65 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 65 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 38 | return; | 1697 | | | 1698 | 27 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 27 | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 27 | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 27 | #endif | 1702 | 27 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 27 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 27 | } |
pe-arm-wince.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 1.21k | { | 1678 | 1.21k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 1.21k | unsigned int i; | 1680 | | | 1681 | 16.7k | for (i = 0; i < table_size; ++i) | 1682 | 15.5k | { | 1683 | 15.5k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 15.5k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 15.5k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 15.5k | : strncmp (alignment_table[i].name, secname, | 1688 | 7.17k | alignment_table[i].comparison_length) == 0) | 1689 | 27 | break; | 1690 | 15.5k | } | 1691 | 1.21k | if (i >= table_size) | 1692 | 1.18k | return; | 1693 | | | 1694 | 27 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 27 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 6 | return; | 1697 | | | 1698 | 21 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 21 | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 21 | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 21 | #endif | 1702 | 21 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 21 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 21 | } |
pe-arm.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 1.21k | { | 1678 | 1.21k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 1.21k | unsigned int i; | 1680 | | | 1681 | 16.7k | for (i = 0; i < table_size; ++i) | 1682 | 15.5k | { | 1683 | 15.5k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 15.5k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 15.5k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 15.5k | : strncmp (alignment_table[i].name, secname, | 1688 | 7.17k | alignment_table[i].comparison_length) == 0) | 1689 | 27 | break; | 1690 | 15.5k | } | 1691 | 1.21k | if (i >= table_size) | 1692 | 1.18k | return; | 1693 | | | 1694 | 27 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 27 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 6 | return; | 1697 | | | 1698 | 21 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 21 | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 21 | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 21 | #endif | 1702 | 21 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 21 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 21 | } |
pe-i386.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 7.14k | { | 1678 | 7.14k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 7.14k | unsigned int i; | 1680 | | | 1681 | 71.0k | for (i = 0; i < table_size; ++i) | 1682 | 64.0k | { | 1683 | 64.0k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 64.0k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 64.0k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 64.0k | : strncmp (alignment_table[i].name, secname, | 1688 | 42.7k | alignment_table[i].comparison_length) == 0) | 1689 | 65 | break; | 1690 | 64.0k | } | 1691 | 7.14k | if (i >= table_size) | 1692 | 7.07k | return; | 1693 | | | 1694 | 65 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 65 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 17 | return; | 1697 | | | 1698 | 48 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 48 | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 48 | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 48 | #endif | 1702 | 48 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 48 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 48 | } |
pe-mcore.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 3.33k | { | 1678 | 3.33k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 3.33k | unsigned int i; | 1680 | | | 1681 | 16.6k | for (i = 0; i < table_size; ++i) | 1682 | 13.3k | { | 1683 | 13.3k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 13.3k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 13.3k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 13.3k | : strncmp (alignment_table[i].name, secname, | 1688 | 6.67k | alignment_table[i].comparison_length) == 0) | 1689 | 9 | break; | 1690 | 13.3k | } | 1691 | 3.33k | if (i >= table_size) | 1692 | 3.32k | return; | 1693 | | | 1694 | 9 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 9 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 8 | return; | 1697 | | | 1698 | 1 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 1 | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 1 | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 1 | #endif | 1702 | 1 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 1 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 1 | } |
pe-sh.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 2.59k | { | 1678 | 2.59k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 2.59k | unsigned int i; | 1680 | | | 1681 | 12.9k | for (i = 0; i < table_size; ++i) | 1682 | 10.3k | { | 1683 | 10.3k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 10.3k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 10.3k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 10.3k | : strncmp (alignment_table[i].name, secname, | 1688 | 5.18k | alignment_table[i].comparison_length) == 0) | 1689 | 25 | break; | 1690 | 10.3k | } | 1691 | 2.59k | if (i >= table_size) | 1692 | 2.57k | return; | 1693 | | | 1694 | 25 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 25 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 23 | return; | 1697 | | | 1698 | 2 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 2 | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 2 | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 2 | #endif | 1702 | 2 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 2 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 2 | } |
pei-arm-wince.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 2.14k | { | 1678 | 2.14k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 2.14k | unsigned int i; | 1680 | | | 1681 | 27.2k | for (i = 0; i < table_size; ++i) | 1682 | 25.1k | { | 1683 | 25.1k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 25.1k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 25.1k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 25.1k | : strncmp (alignment_table[i].name, secname, | 1688 | 10.4k | alignment_table[i].comparison_length) == 0) | 1689 | 89 | break; | 1690 | 25.1k | } | 1691 | 2.14k | if (i >= table_size) | 1692 | 2.05k | return; | 1693 | | | 1694 | 89 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 89 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 13 | return; | 1697 | | | 1698 | 76 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 76 | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 76 | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 76 | #endif | 1702 | 76 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 76 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 76 | } |
pei-arm.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 2.80k | { | 1678 | 2.80k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 2.80k | unsigned int i; | 1680 | | | 1681 | 35.8k | for (i = 0; i < table_size; ++i) | 1682 | 33.0k | { | 1683 | 33.0k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 33.0k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 33.0k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 33.0k | : strncmp (alignment_table[i].name, secname, | 1688 | 13.7k | alignment_table[i].comparison_length) == 0) | 1689 | 91 | break; | 1690 | 33.0k | } | 1691 | 2.80k | if (i >= table_size) | 1692 | 2.71k | return; | 1693 | | | 1694 | 91 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 91 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 13 | return; | 1697 | | | 1698 | 78 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 78 | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 78 | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 78 | #endif | 1702 | 78 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 78 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 78 | } |
pei-mcore.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 3.56k | { | 1678 | 3.56k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 3.56k | unsigned int i; | 1680 | | | 1681 | 17.8k | for (i = 0; i < table_size; ++i) | 1682 | 14.2k | { | 1683 | 14.2k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 14.2k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 14.2k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 14.2k | : strncmp (alignment_table[i].name, secname, | 1688 | 7.13k | alignment_table[i].comparison_length) == 0) | 1689 | 5 | break; | 1690 | 14.2k | } | 1691 | 3.56k | if (i >= table_size) | 1692 | 3.56k | return; | 1693 | | | 1694 | 5 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 5 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 4 | return; | 1697 | | | 1698 | 1 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 1 | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 1 | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 1 | #endif | 1702 | 1 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 1 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 1 | } |
pei-sh.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 1.88k | { | 1678 | 1.88k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 1.88k | unsigned int i; | 1680 | | | 1681 | 9.41k | for (i = 0; i < table_size; ++i) | 1682 | 7.53k | { | 1683 | 7.53k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 7.53k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 7.53k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 7.53k | : strncmp (alignment_table[i].name, secname, | 1688 | 3.77k | alignment_table[i].comparison_length) == 0) | 1689 | 4 | break; | 1690 | 7.53k | } | 1691 | 1.88k | if (i >= table_size) | 1692 | 1.88k | return; | 1693 | | | 1694 | 4 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 4 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 2 | return; | 1697 | | | 1698 | 2 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 2 | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 2 | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 2 | #endif | 1702 | 2 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 2 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 2 | } |
|
1707 | | |
1708 | | /* Custom section alignment records. */ |
1709 | | |
1710 | | static const struct coff_section_alignment_entry |
1711 | | coff_section_alignment_table[] = |
1712 | | { |
1713 | | #ifdef COFF_SECTION_ALIGNMENT_ENTRIES |
1714 | | COFF_SECTION_ALIGNMENT_ENTRIES, |
1715 | | #endif |
1716 | | /* There must not be any gaps between .stabstr sections. */ |
1717 | | { COFF_SECTION_NAME_PARTIAL_MATCH (".stabstr"), |
1718 | | 1, COFF_ALIGNMENT_FIELD_EMPTY, 0 }, |
1719 | | /* The .stab section must be aligned to 2**2 at most, to avoid gaps. */ |
1720 | | { COFF_SECTION_NAME_PARTIAL_MATCH (".stab"), |
1721 | | 3, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, |
1722 | | /* Similarly for the .ctors and .dtors sections. */ |
1723 | | { COFF_SECTION_NAME_EXACT_MATCH (".ctors"), |
1724 | | 3, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, |
1725 | | { COFF_SECTION_NAME_EXACT_MATCH (".dtors"), |
1726 | | 3, COFF_ALIGNMENT_FIELD_EMPTY, 2 } |
1727 | | }; |
1728 | | |
1729 | | static const unsigned int coff_section_alignment_table_size = |
1730 | | sizeof coff_section_alignment_table / sizeof coff_section_alignment_table[0]; |
1731 | | |
1732 | | /* Initialize a section structure with information peculiar to this |
1733 | | particular implementation of COFF. */ |
1734 | | |
1735 | | static bool |
1736 | | coff_new_section_hook (bfd * abfd, asection * section) |
1737 | 1.00M | { |
1738 | 1.00M | combined_entry_type *native; |
1739 | 1.00M | size_t amt; |
1740 | 1.00M | unsigned char sclass = C_STAT; |
1741 | | |
1742 | 1.00M | section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; |
1743 | | |
1744 | | #ifdef RS6000COFF_C |
1745 | 131k | if (bfd_xcoff_text_align_power (abfd) != 0 |
1746 | 131k | && strcmp (bfd_section_name (section), ".text") == 0) |
1747 | 87 | section->alignment_power = bfd_xcoff_text_align_power (abfd); |
1748 | 131k | else if (bfd_xcoff_data_align_power (abfd) != 0 |
1749 | 131k | && strcmp (bfd_section_name (section), ".data") == 0) |
1750 | 0 | section->alignment_power = bfd_xcoff_data_align_power (abfd); |
1751 | 131k | else |
1752 | 131k | { |
1753 | 131k | int i; |
1754 | | |
1755 | 1.57M | for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++) |
1756 | 1.44M | if (strcmp (bfd_section_name (section), |
1757 | 1.44M | xcoff_dwsect_names[i].xcoff_name) == 0) |
1758 | 73 | { |
1759 | 73 | section->alignment_power = 0; |
1760 | 73 | sclass = C_DWARF; |
1761 | 73 | break; |
1762 | 73 | } |
1763 | 131k | } |
1764 | | #endif |
1765 | | |
1766 | | /* Set up the section symbol. */ |
1767 | 1.00M | if (!_bfd_generic_new_section_hook (abfd, section)) |
1768 | 0 | return false; |
1769 | | |
1770 | | /* Allocate aux records for section symbols, to store size and |
1771 | | related info. |
1772 | | |
1773 | | @@ The 10 is a guess at a plausible maximum number of aux entries |
1774 | | (but shouldn't be a constant). */ |
1775 | 1.00M | amt = sizeof (combined_entry_type) * 10; |
1776 | 1.00M | native = (combined_entry_type *) bfd_zalloc (abfd, amt); |
1777 | 1.00M | if (native == NULL) |
1778 | 0 | return false; |
1779 | | |
1780 | | /* We don't need to set up n_name, n_value, or n_scnum in the native |
1781 | | symbol information, since they'll be overridden by the BFD symbol |
1782 | | anyhow. However, we do need to set the type and storage class, |
1783 | | in case this symbol winds up getting written out. The value 0 |
1784 | | for n_numaux is already correct. */ |
1785 | | |
1786 | 1.00M | native->is_sym = true; |
1787 | 1.00M | native->u.syment.n_type = T_NULL; |
1788 | 1.00M | native->u.syment.n_sclass = sclass; |
1789 | | |
1790 | 1.00M | coffsymbol (section->symbol)->native = native; |
1791 | | |
1792 | 1.00M | coff_set_custom_section_alignment (abfd, section, |
1793 | 1.00M | coff_section_alignment_table, |
1794 | 1.00M | coff_section_alignment_table_size); |
1795 | | |
1796 | 1.00M | return true; |
1797 | 1.00M | } pei-i386.c:coff_new_section_hook Line | Count | Source | 1737 | 3.29k | { | 1738 | 3.29k | combined_entry_type *native; | 1739 | 3.29k | size_t amt; | 1740 | 3.29k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 3.29k | section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1743 | | | 1744 | | #ifdef RS6000COFF_C | 1745 | | if (bfd_xcoff_text_align_power (abfd) != 0 | 1746 | | && strcmp (bfd_section_name (section), ".text") == 0) | 1747 | | section->alignment_power = bfd_xcoff_text_align_power (abfd); | 1748 | | else if (bfd_xcoff_data_align_power (abfd) != 0 | 1749 | | && strcmp (bfd_section_name (section), ".data") == 0) | 1750 | | section->alignment_power = bfd_xcoff_data_align_power (abfd); | 1751 | | else | 1752 | | { | 1753 | | int i; | 1754 | | | 1755 | | for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++) | 1756 | | if (strcmp (bfd_section_name (section), | 1757 | | xcoff_dwsect_names[i].xcoff_name) == 0) | 1758 | | { | 1759 | | section->alignment_power = 0; | 1760 | | sclass = C_DWARF; | 1761 | | break; | 1762 | | } | 1763 | | } | 1764 | | #endif | 1765 | | | 1766 | | /* Set up the section symbol. */ | 1767 | 3.29k | if (!_bfd_generic_new_section_hook (abfd, section)) | 1768 | 0 | return false; | 1769 | | | 1770 | | /* Allocate aux records for section symbols, to store size and | 1771 | | related info. | 1772 | | | 1773 | | @@ The 10 is a guess at a plausible maximum number of aux entries | 1774 | | (but shouldn't be a constant). */ | 1775 | 3.29k | amt = sizeof (combined_entry_type) * 10; | 1776 | 3.29k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 3.29k | if (native == NULL) | 1778 | 0 | return false; | 1779 | | | 1780 | | /* We don't need to set up n_name, n_value, or n_scnum in the native | 1781 | | symbol information, since they'll be overridden by the BFD symbol | 1782 | | anyhow. However, we do need to set the type and storage class, | 1783 | | in case this symbol winds up getting written out. The value 0 | 1784 | | for n_numaux is already correct. */ | 1785 | | | 1786 | 3.29k | native->is_sym = true; | 1787 | 3.29k | native->u.syment.n_type = T_NULL; | 1788 | 3.29k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 3.29k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 3.29k | coff_set_custom_section_alignment (abfd, section, | 1793 | 3.29k | coff_section_alignment_table, | 1794 | 3.29k | coff_section_alignment_table_size); | 1795 | | | 1796 | 3.29k | return true; | 1797 | 3.29k | } |
pe-x86_64.c:coff_new_section_hook Line | Count | Source | 1737 | 5.33k | { | 1738 | 5.33k | combined_entry_type *native; | 1739 | 5.33k | size_t amt; | 1740 | 5.33k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 5.33k | section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1743 | | | 1744 | | #ifdef RS6000COFF_C | 1745 | | if (bfd_xcoff_text_align_power (abfd) != 0 | 1746 | | && strcmp (bfd_section_name (section), ".text") == 0) | 1747 | | section->alignment_power = bfd_xcoff_text_align_power (abfd); | 1748 | | else if (bfd_xcoff_data_align_power (abfd) != 0 | 1749 | | && strcmp (bfd_section_name (section), ".data") == 0) | 1750 | | section->alignment_power = bfd_xcoff_data_align_power (abfd); | 1751 | | else | 1752 | | { | 1753 | | int i; | 1754 | | | 1755 | | for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++) | 1756 | | if (strcmp (bfd_section_name (section), | 1757 | | xcoff_dwsect_names[i].xcoff_name) == 0) | 1758 | | { | 1759 | | section->alignment_power = 0; | 1760 | | sclass = C_DWARF; | 1761 | | break; | 1762 | | } | 1763 | | } | 1764 | | #endif | 1765 | | | 1766 | | /* Set up the section symbol. */ | 1767 | 5.33k | if (!_bfd_generic_new_section_hook (abfd, section)) | 1768 | 0 | return false; | 1769 | | | 1770 | | /* Allocate aux records for section symbols, to store size and | 1771 | | related info. | 1772 | | | 1773 | | @@ The 10 is a guess at a plausible maximum number of aux entries | 1774 | | (but shouldn't be a constant). */ | 1775 | 5.33k | amt = sizeof (combined_entry_type) * 10; | 1776 | 5.33k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 5.33k | if (native == NULL) | 1778 | 0 | return false; | 1779 | | | 1780 | | /* We don't need to set up n_name, n_value, or n_scnum in the native | 1781 | | symbol information, since they'll be overridden by the BFD symbol | 1782 | | anyhow. However, we do need to set the type and storage class, | 1783 | | in case this symbol winds up getting written out. The value 0 | 1784 | | for n_numaux is already correct. */ | 1785 | | | 1786 | 5.33k | native->is_sym = true; | 1787 | 5.33k | native->u.syment.n_type = T_NULL; | 1788 | 5.33k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 5.33k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 5.33k | coff_set_custom_section_alignment (abfd, section, | 1793 | 5.33k | coff_section_alignment_table, | 1794 | 5.33k | coff_section_alignment_table_size); | 1795 | | | 1796 | 5.33k | return true; | 1797 | 5.33k | } |
pei-x86_64.c:coff_new_section_hook Line | Count | Source | 1737 | 3.29k | { | 1738 | 3.29k | combined_entry_type *native; | 1739 | 3.29k | size_t amt; | 1740 | 3.29k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 3.29k | section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1743 | | | 1744 | | #ifdef RS6000COFF_C | 1745 | | if (bfd_xcoff_text_align_power (abfd) != 0 | 1746 | | && strcmp (bfd_section_name (section), ".text") == 0) | 1747 | | section->alignment_power = bfd_xcoff_text_align_power (abfd); | 1748 | | else if (bfd_xcoff_data_align_power (abfd) != 0 | 1749 | | && strcmp (bfd_section_name (section), ".data") == 0) | 1750 | | section->alignment_power = bfd_xcoff_data_align_power (abfd); | 1751 | | else | 1752 | | { | 1753 | | int i; | 1754 | | | 1755 | | for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++) | 1756 | | if (strcmp (bfd_section_name (section), | 1757 | | xcoff_dwsect_names[i].xcoff_name) == 0) | 1758 | | { | 1759 | | section->alignment_power = 0; | 1760 | | sclass = C_DWARF; | 1761 | | break; | 1762 | | } | 1763 | | } | 1764 | | #endif | 1765 | | | 1766 | | /* Set up the section symbol. */ | 1767 | 3.29k | if (!_bfd_generic_new_section_hook (abfd, section)) | 1768 | 0 | return false; | 1769 | | | 1770 | | /* Allocate aux records for section symbols, to store size and | 1771 | | related info. | 1772 | | | 1773 | | @@ The 10 is a guess at a plausible maximum number of aux entries | 1774 | | (but shouldn't be a constant). */ | 1775 | 3.29k | amt = sizeof (combined_entry_type) * 10; | 1776 | 3.29k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 3.29k | if (native == NULL) | 1778 | 0 | return false; | 1779 | | | 1780 | | /* We don't need to set up n_name, n_value, or n_scnum in the native | 1781 | | symbol information, since they'll be overridden by the BFD symbol | 1782 | | anyhow. However, we do need to set the type and storage class, | 1783 | | in case this symbol winds up getting written out. The value 0 | 1784 | | for n_numaux is already correct. */ | 1785 | | | 1786 | 3.29k | native->is_sym = true; | 1787 | 3.29k | native->u.syment.n_type = T_NULL; | 1788 | 3.29k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 3.29k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 3.29k | coff_set_custom_section_alignment (abfd, section, | 1793 | 3.29k | coff_section_alignment_table, | 1794 | 3.29k | coff_section_alignment_table_size); | 1795 | | | 1796 | 3.29k | return true; | 1797 | 3.29k | } |
coff-x86_64.c:coff_new_section_hook Line | Count | Source | 1737 | 199k | { | 1738 | 199k | combined_entry_type *native; | 1739 | 199k | size_t amt; | 1740 | 199k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 199k | section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1743 | | | 1744 | | #ifdef RS6000COFF_C | 1745 | | if (bfd_xcoff_text_align_power (abfd) != 0 | 1746 | | && strcmp (bfd_section_name (section), ".text") == 0) | 1747 | | section->alignment_power = bfd_xcoff_text_align_power (abfd); | 1748 | | else if (bfd_xcoff_data_align_power (abfd) != 0 | 1749 | | && strcmp (bfd_section_name (section), ".data") == 0) | 1750 | | section->alignment_power = bfd_xcoff_data_align_power (abfd); | 1751 | | else | 1752 | | { | 1753 | | int i; | 1754 | | | 1755 | | for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++) | 1756 | | if (strcmp (bfd_section_name (section), | 1757 | | xcoff_dwsect_names[i].xcoff_name) == 0) | 1758 | | { | 1759 | | section->alignment_power = 0; | 1760 | | sclass = C_DWARF; | 1761 | | break; | 1762 | | } | 1763 | | } | 1764 | | #endif | 1765 | | | 1766 | | /* Set up the section symbol. */ | 1767 | 199k | if (!_bfd_generic_new_section_hook (abfd, section)) | 1768 | 0 | return false; | 1769 | | | 1770 | | /* Allocate aux records for section symbols, to store size and | 1771 | | related info. | 1772 | | | 1773 | | @@ The 10 is a guess at a plausible maximum number of aux entries | 1774 | | (but shouldn't be a constant). */ | 1775 | 199k | amt = sizeof (combined_entry_type) * 10; | 1776 | 199k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 199k | if (native == NULL) | 1778 | 0 | return false; | 1779 | | | 1780 | | /* We don't need to set up n_name, n_value, or n_scnum in the native | 1781 | | symbol information, since they'll be overridden by the BFD symbol | 1782 | | anyhow. However, we do need to set the type and storage class, | 1783 | | in case this symbol winds up getting written out. The value 0 | 1784 | | for n_numaux is already correct. */ | 1785 | | | 1786 | 199k | native->is_sym = true; | 1787 | 199k | native->u.syment.n_type = T_NULL; | 1788 | 199k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 199k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 199k | coff_set_custom_section_alignment (abfd, section, | 1793 | 199k | coff_section_alignment_table, | 1794 | 199k | coff_section_alignment_table_size); | 1795 | | | 1796 | 199k | return true; | 1797 | 199k | } |
coff64-rs6000.c:coff_new_section_hook Line | Count | Source | 1737 | 46.2k | { | 1738 | 46.2k | combined_entry_type *native; | 1739 | 46.2k | size_t amt; | 1740 | 46.2k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 46.2k | section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1743 | | | 1744 | 46.2k | #ifdef RS6000COFF_C | 1745 | 46.2k | if (bfd_xcoff_text_align_power (abfd) != 0 | 1746 | 46.2k | && strcmp (bfd_section_name (section), ".text") == 0) | 1747 | 20 | section->alignment_power = bfd_xcoff_text_align_power (abfd); | 1748 | 46.2k | else if (bfd_xcoff_data_align_power (abfd) != 0 | 1749 | 46.2k | && strcmp (bfd_section_name (section), ".data") == 0) | 1750 | 0 | section->alignment_power = bfd_xcoff_data_align_power (abfd); | 1751 | 46.2k | else | 1752 | 46.2k | { | 1753 | 46.2k | int i; | 1754 | | | 1755 | 554k | for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++) | 1756 | 508k | if (strcmp (bfd_section_name (section), | 1757 | 508k | xcoff_dwsect_names[i].xcoff_name) == 0) | 1758 | 8 | { | 1759 | 8 | section->alignment_power = 0; | 1760 | 8 | sclass = C_DWARF; | 1761 | 8 | break; | 1762 | 8 | } | 1763 | 46.2k | } | 1764 | 46.2k | #endif | 1765 | | | 1766 | | /* Set up the section symbol. */ | 1767 | 46.2k | if (!_bfd_generic_new_section_hook (abfd, section)) | 1768 | 0 | return false; | 1769 | | | 1770 | | /* Allocate aux records for section symbols, to store size and | 1771 | | related info. | 1772 | | | 1773 | | @@ The 10 is a guess at a plausible maximum number of aux entries | 1774 | | (but shouldn't be a constant). */ | 1775 | 46.2k | amt = sizeof (combined_entry_type) * 10; | 1776 | 46.2k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 46.2k | if (native == NULL) | 1778 | 0 | return false; | 1779 | | | 1780 | | /* We don't need to set up n_name, n_value, or n_scnum in the native | 1781 | | symbol information, since they'll be overridden by the BFD symbol | 1782 | | anyhow. However, we do need to set the type and storage class, | 1783 | | in case this symbol winds up getting written out. The value 0 | 1784 | | for n_numaux is already correct. */ | 1785 | | | 1786 | 46.2k | native->is_sym = true; | 1787 | 46.2k | native->u.syment.n_type = T_NULL; | 1788 | 46.2k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 46.2k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 46.2k | coff_set_custom_section_alignment (abfd, section, | 1793 | 46.2k | coff_section_alignment_table, | 1794 | 46.2k | coff_section_alignment_table_size); | 1795 | | | 1796 | 46.2k | return true; | 1797 | 46.2k | } |
pei-aarch64.c:coff_new_section_hook Line | Count | Source | 1737 | 1.77k | { | 1738 | 1.77k | combined_entry_type *native; | 1739 | 1.77k | size_t amt; | 1740 | 1.77k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 1.77k | section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1743 | | | 1744 | | #ifdef RS6000COFF_C | 1745 | | if (bfd_xcoff_text_align_power (abfd) != 0 | 1746 | | && strcmp (bfd_section_name (section), ".text") == 0) | 1747 | | section->alignment_power = bfd_xcoff_text_align_power (abfd); | 1748 | | else if (bfd_xcoff_data_align_power (abfd) != 0 | 1749 | | && strcmp (bfd_section_name (section), ".data") == 0) | 1750 | | section->alignment_power = bfd_xcoff_data_align_power (abfd); | 1751 | | else | 1752 | | { | 1753 | | int i; | 1754 | | | 1755 | | for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++) | 1756 | | if (strcmp (bfd_section_name (section), | 1757 | | xcoff_dwsect_names[i].xcoff_name) == 0) | 1758 | | { | 1759 | | section->alignment_power = 0; | 1760 | | sclass = C_DWARF; | 1761 | | break; | 1762 | | } | 1763 | | } | 1764 | | #endif | 1765 | | | 1766 | | /* Set up the section symbol. */ | 1767 | 1.77k | if (!_bfd_generic_new_section_hook (abfd, section)) | 1768 | 0 | return false; | 1769 | | | 1770 | | /* Allocate aux records for section symbols, to store size and | 1771 | | related info. | 1772 | | | 1773 | | @@ The 10 is a guess at a plausible maximum number of aux entries | 1774 | | (but shouldn't be a constant). */ | 1775 | 1.77k | amt = sizeof (combined_entry_type) * 10; | 1776 | 1.77k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 1.77k | if (native == NULL) | 1778 | 0 | return false; | 1779 | | | 1780 | | /* We don't need to set up n_name, n_value, or n_scnum in the native | 1781 | | symbol information, since they'll be overridden by the BFD symbol | 1782 | | anyhow. However, we do need to set the type and storage class, | 1783 | | in case this symbol winds up getting written out. The value 0 | 1784 | | for n_numaux is already correct. */ | 1785 | | | 1786 | 1.77k | native->is_sym = true; | 1787 | 1.77k | native->u.syment.n_type = T_NULL; | 1788 | 1.77k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 1.77k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 1.77k | coff_set_custom_section_alignment (abfd, section, | 1793 | 1.77k | coff_section_alignment_table, | 1794 | 1.77k | coff_section_alignment_table_size); | 1795 | | | 1796 | 1.77k | return true; | 1797 | 1.77k | } |
pe-aarch64.c:coff_new_section_hook Line | Count | Source | 1737 | 5.50k | { | 1738 | 5.50k | combined_entry_type *native; | 1739 | 5.50k | size_t amt; | 1740 | 5.50k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 5.50k | section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1743 | | | 1744 | | #ifdef RS6000COFF_C | 1745 | | if (bfd_xcoff_text_align_power (abfd) != 0 | 1746 | | && strcmp (bfd_section_name (section), ".text") == 0) | 1747 | | section->alignment_power = bfd_xcoff_text_align_power (abfd); | 1748 | | else if (bfd_xcoff_data_align_power (abfd) != 0 | 1749 | | && strcmp (bfd_section_name (section), ".data") == 0) | 1750 | | section->alignment_power = bfd_xcoff_data_align_power (abfd); | 1751 | | else | 1752 | | { | 1753 | | int i; | 1754 | | | 1755 | | for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++) | 1756 | | if (strcmp (bfd_section_name (section), | 1757 | | xcoff_dwsect_names[i].xcoff_name) == 0) | 1758 | | { | 1759 | | section->alignment_power = 0; | 1760 | | sclass = C_DWARF; | 1761 | | break; | 1762 | | } | 1763 | | } | 1764 | | #endif | 1765 | | | 1766 | | /* Set up the section symbol. */ | 1767 | 5.50k | if (!_bfd_generic_new_section_hook (abfd, section)) | 1768 | 0 | return false; | 1769 | | | 1770 | | /* Allocate aux records for section symbols, to store size and | 1771 | | related info. | 1772 | | | 1773 | | @@ The 10 is a guess at a plausible maximum number of aux entries | 1774 | | (but shouldn't be a constant). */ | 1775 | 5.50k | amt = sizeof (combined_entry_type) * 10; | 1776 | 5.50k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 5.50k | if (native == NULL) | 1778 | 0 | return false; | 1779 | | | 1780 | | /* We don't need to set up n_name, n_value, or n_scnum in the native | 1781 | | symbol information, since they'll be overridden by the BFD symbol | 1782 | | anyhow. However, we do need to set the type and storage class, | 1783 | | in case this symbol winds up getting written out. The value 0 | 1784 | | for n_numaux is already correct. */ | 1785 | | | 1786 | 5.50k | native->is_sym = true; | 1787 | 5.50k | native->u.syment.n_type = T_NULL; | 1788 | 5.50k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 5.50k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 5.50k | coff_set_custom_section_alignment (abfd, section, | 1793 | 5.50k | coff_section_alignment_table, | 1794 | 5.50k | coff_section_alignment_table_size); | 1795 | | | 1796 | 5.50k | return true; | 1797 | 5.50k | } |
pei-ia64.c:coff_new_section_hook Line | Count | Source | 1737 | 2.25k | { | 1738 | 2.25k | combined_entry_type *native; | 1739 | 2.25k | size_t amt; | 1740 | 2.25k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 2.25k | section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1743 | | | 1744 | | #ifdef RS6000COFF_C | 1745 | | if (bfd_xcoff_text_align_power (abfd) != 0 | 1746 | | && strcmp (bfd_section_name (section), ".text") == 0) | 1747 | | section->alignment_power = bfd_xcoff_text_align_power (abfd); | 1748 | | else if (bfd_xcoff_data_align_power (abfd) != 0 | 1749 | | && strcmp (bfd_section_name (section), ".data") == 0) | 1750 | | section->alignment_power = bfd_xcoff_data_align_power (abfd); | 1751 | | else | 1752 | | { | 1753 | | int i; | 1754 | | | 1755 | | for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++) | 1756 | | if (strcmp (bfd_section_name (section), | 1757 | | xcoff_dwsect_names[i].xcoff_name) == 0) | 1758 | | { | 1759 | | section->alignment_power = 0; | 1760 | | sclass = C_DWARF; | 1761 | | break; | 1762 | | } | 1763 | | } | 1764 | | #endif | 1765 | | | 1766 | | /* Set up the section symbol. */ | 1767 | 2.25k | if (!_bfd_generic_new_section_hook (abfd, section)) | 1768 | 0 | return false; | 1769 | | | 1770 | | /* Allocate aux records for section symbols, to store size and | 1771 | | related info. | 1772 | | | 1773 | | @@ The 10 is a guess at a plausible maximum number of aux entries | 1774 | | (but shouldn't be a constant). */ | 1775 | 2.25k | amt = sizeof (combined_entry_type) * 10; | 1776 | 2.25k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 2.25k | if (native == NULL) | 1778 | 0 | return false; | 1779 | | | 1780 | | /* We don't need to set up n_name, n_value, or n_scnum in the native | 1781 | | symbol information, since they'll be overridden by the BFD symbol | 1782 | | anyhow. However, we do need to set the type and storage class, | 1783 | | in case this symbol winds up getting written out. The value 0 | 1784 | | for n_numaux is already correct. */ | 1785 | | | 1786 | 2.25k | native->is_sym = true; | 1787 | 2.25k | native->u.syment.n_type = T_NULL; | 1788 | 2.25k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 2.25k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 2.25k | coff_set_custom_section_alignment (abfd, section, | 1793 | 2.25k | coff_section_alignment_table, | 1794 | 2.25k | coff_section_alignment_table_size); | 1795 | | | 1796 | 2.25k | return true; | 1797 | 2.25k | } |
pei-loongarch64.c:coff_new_section_hook Line | Count | Source | 1737 | 8.62k | { | 1738 | 8.62k | combined_entry_type *native; | 1739 | 8.62k | size_t amt; | 1740 | 8.62k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 8.62k | section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1743 | | | 1744 | | #ifdef RS6000COFF_C | 1745 | | if (bfd_xcoff_text_align_power (abfd) != 0 | 1746 | | && strcmp (bfd_section_name (section), ".text") == 0) | 1747 | | section->alignment_power = bfd_xcoff_text_align_power (abfd); | 1748 | | else if (bfd_xcoff_data_align_power (abfd) != 0 | 1749 | | && strcmp (bfd_section_name (section), ".data") == 0) | 1750 | | section->alignment_power = bfd_xcoff_data_align_power (abfd); | 1751 | | else | 1752 | | { | 1753 | | int i; | 1754 | | | 1755 | | for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++) | 1756 | | if (strcmp (bfd_section_name (section), | 1757 | | xcoff_dwsect_names[i].xcoff_name) == 0) | 1758 | | { | 1759 | | section->alignment_power = 0; | 1760 | | sclass = C_DWARF; | 1761 | | break; | 1762 | | } | 1763 | | } | 1764 | | #endif | 1765 | | | 1766 | | /* Set up the section symbol. */ | 1767 | 8.62k | if (!_bfd_generic_new_section_hook (abfd, section)) | 1768 | 0 | return false; | 1769 | | | 1770 | | /* Allocate aux records for section symbols, to store size and | 1771 | | related info. | 1772 | | | 1773 | | @@ The 10 is a guess at a plausible maximum number of aux entries | 1774 | | (but shouldn't be a constant). */ | 1775 | 8.62k | amt = sizeof (combined_entry_type) * 10; | 1776 | 8.62k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 8.62k | if (native == NULL) | 1778 | 0 | return false; | 1779 | | | 1780 | | /* We don't need to set up n_name, n_value, or n_scnum in the native | 1781 | | symbol information, since they'll be overridden by the BFD symbol | 1782 | | anyhow. However, we do need to set the type and storage class, | 1783 | | in case this symbol winds up getting written out. The value 0 | 1784 | | for n_numaux is already correct. */ | 1785 | | | 1786 | 8.62k | native->is_sym = true; | 1787 | 8.62k | native->u.syment.n_type = T_NULL; | 1788 | 8.62k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 8.62k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 8.62k | coff_set_custom_section_alignment (abfd, section, | 1793 | 8.62k | coff_section_alignment_table, | 1794 | 8.62k | coff_section_alignment_table_size); | 1795 | | | 1796 | 8.62k | return true; | 1797 | 8.62k | } |
cf-i386lynx.c:coff_new_section_hook Line | Count | Source | 1737 | 140k | { | 1738 | 140k | combined_entry_type *native; | 1739 | 140k | size_t amt; | 1740 | 140k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 140k | section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1743 | | | 1744 | | #ifdef RS6000COFF_C | 1745 | | if (bfd_xcoff_text_align_power (abfd) != 0 | 1746 | | && strcmp (bfd_section_name (section), ".text") == 0) | 1747 | | section->alignment_power = bfd_xcoff_text_align_power (abfd); | 1748 | | else if (bfd_xcoff_data_align_power (abfd) != 0 | 1749 | | && strcmp (bfd_section_name (section), ".data") == 0) | 1750 | | section->alignment_power = bfd_xcoff_data_align_power (abfd); | 1751 | | else | 1752 | | { | 1753 | | int i; | 1754 | | | 1755 | | for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++) | 1756 | | if (strcmp (bfd_section_name (section), | 1757 | | xcoff_dwsect_names[i].xcoff_name) == 0) | 1758 | | { | 1759 | | section->alignment_power = 0; | 1760 | | sclass = C_DWARF; | 1761 | | break; | 1762 | | } | 1763 | | } | 1764 | | #endif | 1765 | | | 1766 | | /* Set up the section symbol. */ | 1767 | 140k | if (!_bfd_generic_new_section_hook (abfd, section)) | 1768 | 0 | return false; | 1769 | | | 1770 | | /* Allocate aux records for section symbols, to store size and | 1771 | | related info. | 1772 | | | 1773 | | @@ The 10 is a guess at a plausible maximum number of aux entries | 1774 | | (but shouldn't be a constant). */ | 1775 | 140k | amt = sizeof (combined_entry_type) * 10; | 1776 | 140k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 140k | if (native == NULL) | 1778 | 0 | return false; | 1779 | | | 1780 | | /* We don't need to set up n_name, n_value, or n_scnum in the native | 1781 | | symbol information, since they'll be overridden by the BFD symbol | 1782 | | anyhow. However, we do need to set the type and storage class, | 1783 | | in case this symbol winds up getting written out. The value 0 | 1784 | | for n_numaux is already correct. */ | 1785 | | | 1786 | 140k | native->is_sym = true; | 1787 | 140k | native->u.syment.n_type = T_NULL; | 1788 | 140k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 140k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 140k | coff_set_custom_section_alignment (abfd, section, | 1793 | 140k | coff_section_alignment_table, | 1794 | 140k | coff_section_alignment_table_size); | 1795 | | | 1796 | 140k | return true; | 1797 | 140k | } |
coff-go32.c:coff_new_section_hook Line | Count | Source | 1737 | 116k | { | 1738 | 116k | combined_entry_type *native; | 1739 | 116k | size_t amt; | 1740 | 116k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 116k | section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1743 | | | 1744 | | #ifdef RS6000COFF_C | 1745 | | if (bfd_xcoff_text_align_power (abfd) != 0 | 1746 | | && strcmp (bfd_section_name (section), ".text") == 0) | 1747 | | section->alignment_power = bfd_xcoff_text_align_power (abfd); | 1748 | | else if (bfd_xcoff_data_align_power (abfd) != 0 | 1749 | | && strcmp (bfd_section_name (section), ".data") == 0) | 1750 | | section->alignment_power = bfd_xcoff_data_align_power (abfd); | 1751 | | else | 1752 | | { | 1753 | | int i; | 1754 | | | 1755 | | for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++) | 1756 | | if (strcmp (bfd_section_name (section), | 1757 | | xcoff_dwsect_names[i].xcoff_name) == 0) | 1758 | | { | 1759 | | section->alignment_power = 0; | 1760 | | sclass = C_DWARF; | 1761 | | break; | 1762 | | } | 1763 | | } | 1764 | | #endif | 1765 | | | 1766 | | /* Set up the section symbol. */ | 1767 | 116k | if (!_bfd_generic_new_section_hook (abfd, section)) | 1768 | 0 | return false; | 1769 | | | 1770 | | /* Allocate aux records for section symbols, to store size and | 1771 | | related info. | 1772 | | | 1773 | | @@ The 10 is a guess at a plausible maximum number of aux entries | 1774 | | (but shouldn't be a constant). */ | 1775 | 116k | amt = sizeof (combined_entry_type) * 10; | 1776 | 116k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 116k | if (native == NULL) | 1778 | 0 | return false; | 1779 | | | 1780 | | /* We don't need to set up n_name, n_value, or n_scnum in the native | 1781 | | symbol information, since they'll be overridden by the BFD symbol | 1782 | | anyhow. However, we do need to set the type and storage class, | 1783 | | in case this symbol winds up getting written out. The value 0 | 1784 | | for n_numaux is already correct. */ | 1785 | | | 1786 | 116k | native->is_sym = true; | 1787 | 116k | native->u.syment.n_type = T_NULL; | 1788 | 116k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 116k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 116k | coff_set_custom_section_alignment (abfd, section, | 1793 | 116k | coff_section_alignment_table, | 1794 | 116k | coff_section_alignment_table_size); | 1795 | | | 1796 | 116k | return true; | 1797 | 116k | } |
coff-i386.c:coff_new_section_hook Line | Count | Source | 1737 | 127k | { | 1738 | 127k | combined_entry_type *native; | 1739 | 127k | size_t amt; | 1740 | 127k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 127k | section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1743 | | | 1744 | | #ifdef RS6000COFF_C | 1745 | | if (bfd_xcoff_text_align_power (abfd) != 0 | 1746 | | && strcmp (bfd_section_name (section), ".text") == 0) | 1747 | | section->alignment_power = bfd_xcoff_text_align_power (abfd); | 1748 | | else if (bfd_xcoff_data_align_power (abfd) != 0 | 1749 | | && strcmp (bfd_section_name (section), ".data") == 0) | 1750 | | section->alignment_power = bfd_xcoff_data_align_power (abfd); | 1751 | | else | 1752 | | { | 1753 | | int i; | 1754 | | | 1755 | | for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++) | 1756 | | if (strcmp (bfd_section_name (section), | 1757 | | xcoff_dwsect_names[i].xcoff_name) == 0) | 1758 | | { | 1759 | | section->alignment_power = 0; | 1760 | | sclass = C_DWARF; | 1761 | | break; | 1762 | | } | 1763 | | } | 1764 | | #endif | 1765 | | | 1766 | | /* Set up the section symbol. */ | 1767 | 127k | if (!_bfd_generic_new_section_hook (abfd, section)) | 1768 | 0 | return false; | 1769 | | | 1770 | | /* Allocate aux records for section symbols, to store size and | 1771 | | related info. | 1772 | | | 1773 | | @@ The 10 is a guess at a plausible maximum number of aux entries | 1774 | | (but shouldn't be a constant). */ | 1775 | 127k | amt = sizeof (combined_entry_type) * 10; | 1776 | 127k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 127k | if (native == NULL) | 1778 | 0 | return false; | 1779 | | | 1780 | | /* We don't need to set up n_name, n_value, or n_scnum in the native | 1781 | | symbol information, since they'll be overridden by the BFD symbol | 1782 | | anyhow. However, we do need to set the type and storage class, | 1783 | | in case this symbol winds up getting written out. The value 0 | 1784 | | for n_numaux is already correct. */ | 1785 | | | 1786 | 127k | native->is_sym = true; | 1787 | 127k | native->u.syment.n_type = T_NULL; | 1788 | 127k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 127k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 127k | coff_set_custom_section_alignment (abfd, section, | 1793 | 127k | coff_section_alignment_table, | 1794 | 127k | coff_section_alignment_table_size); | 1795 | | | 1796 | 127k | return true; | 1797 | 127k | } |
coff-rs6000.c:coff_new_section_hook Line | Count | Source | 1737 | 85.1k | { | 1738 | 85.1k | combined_entry_type *native; | 1739 | 85.1k | size_t amt; | 1740 | 85.1k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 85.1k | section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1743 | | | 1744 | 85.1k | #ifdef RS6000COFF_C | 1745 | 85.1k | if (bfd_xcoff_text_align_power (abfd) != 0 | 1746 | 85.1k | && strcmp (bfd_section_name (section), ".text") == 0) | 1747 | 67 | section->alignment_power = bfd_xcoff_text_align_power (abfd); | 1748 | 85.0k | else if (bfd_xcoff_data_align_power (abfd) != 0 | 1749 | 85.0k | && strcmp (bfd_section_name (section), ".data") == 0) | 1750 | 0 | section->alignment_power = bfd_xcoff_data_align_power (abfd); | 1751 | 85.0k | else | 1752 | 85.0k | { | 1753 | 85.0k | int i; | 1754 | | | 1755 | 1.02M | for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++) | 1756 | 935k | if (strcmp (bfd_section_name (section), | 1757 | 935k | xcoff_dwsect_names[i].xcoff_name) == 0) | 1758 | 65 | { | 1759 | 65 | section->alignment_power = 0; | 1760 | 65 | sclass = C_DWARF; | 1761 | 65 | break; | 1762 | 65 | } | 1763 | 85.0k | } | 1764 | 85.1k | #endif | 1765 | | | 1766 | | /* Set up the section symbol. */ | 1767 | 85.1k | if (!_bfd_generic_new_section_hook (abfd, section)) | 1768 | 0 | return false; | 1769 | | | 1770 | | /* Allocate aux records for section symbols, to store size and | 1771 | | related info. | 1772 | | | 1773 | | @@ The 10 is a guess at a plausible maximum number of aux entries | 1774 | | (but shouldn't be a constant). */ | 1775 | 85.1k | amt = sizeof (combined_entry_type) * 10; | 1776 | 85.1k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 85.1k | if (native == NULL) | 1778 | 0 | return false; | 1779 | | | 1780 | | /* We don't need to set up n_name, n_value, or n_scnum in the native | 1781 | | symbol information, since they'll be overridden by the BFD symbol | 1782 | | anyhow. However, we do need to set the type and storage class, | 1783 | | in case this symbol winds up getting written out. The value 0 | 1784 | | for n_numaux is already correct. */ | 1785 | | | 1786 | 85.1k | native->is_sym = true; | 1787 | 85.1k | native->u.syment.n_type = T_NULL; | 1788 | 85.1k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 85.1k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 85.1k | coff_set_custom_section_alignment (abfd, section, | 1793 | 85.1k | coff_section_alignment_table, | 1794 | 85.1k | coff_section_alignment_table_size); | 1795 | | | 1796 | 85.1k | return true; | 1797 | 85.1k | } |
coff-sh.c:coff_new_section_hook Line | Count | Source | 1737 | 20.6k | { | 1738 | 20.6k | combined_entry_type *native; | 1739 | 20.6k | size_t amt; | 1740 | 20.6k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 20.6k | section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1743 | | | 1744 | | #ifdef RS6000COFF_C | 1745 | | if (bfd_xcoff_text_align_power (abfd) != 0 | 1746 | | && strcmp (bfd_section_name (section), ".text") == 0) | 1747 | | section->alignment_power = bfd_xcoff_text_align_power (abfd); | 1748 | | else if (bfd_xcoff_data_align_power (abfd) != 0 | 1749 | | && strcmp (bfd_section_name (section), ".data") == 0) | 1750 | | section->alignment_power = bfd_xcoff_data_align_power (abfd); | 1751 | | else | 1752 | | { | 1753 | | int i; | 1754 | | | 1755 | | for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++) | 1756 | | if (strcmp (bfd_section_name (section), | 1757 | | xcoff_dwsect_names[i].xcoff_name) == 0) | 1758 | | { | 1759 | | section->alignment_power = 0; | 1760 | | sclass = C_DWARF; | 1761 | | break; | 1762 | | } | 1763 | | } | 1764 | | #endif | 1765 | | | 1766 | | /* Set up the section symbol. */ | 1767 | 20.6k | if (!_bfd_generic_new_section_hook (abfd, section)) | 1768 | 0 | return false; | 1769 | | | 1770 | | /* Allocate aux records for section symbols, to store size and | 1771 | | related info. | 1772 | | | 1773 | | @@ The 10 is a guess at a plausible maximum number of aux entries | 1774 | | (but shouldn't be a constant). */ | 1775 | 20.6k | amt = sizeof (combined_entry_type) * 10; | 1776 | 20.6k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 20.6k | if (native == NULL) | 1778 | 0 | return false; | 1779 | | | 1780 | | /* We don't need to set up n_name, n_value, or n_scnum in the native | 1781 | | symbol information, since they'll be overridden by the BFD symbol | 1782 | | anyhow. However, we do need to set the type and storage class, | 1783 | | in case this symbol winds up getting written out. The value 0 | 1784 | | for n_numaux is already correct. */ | 1785 | | | 1786 | 20.6k | native->is_sym = true; | 1787 | 20.6k | native->u.syment.n_type = T_NULL; | 1788 | 20.6k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 20.6k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 20.6k | coff_set_custom_section_alignment (abfd, section, | 1793 | 20.6k | coff_section_alignment_table, | 1794 | 20.6k | coff_section_alignment_table_size); | 1795 | | | 1796 | 20.6k | return true; | 1797 | 20.6k | } |
coff-stgo32.c:coff_new_section_hook Line | Count | Source | 1737 | 13.6k | { | 1738 | 13.6k | combined_entry_type *native; | 1739 | 13.6k | size_t amt; | 1740 | 13.6k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 13.6k | section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1743 | | | 1744 | | #ifdef RS6000COFF_C | 1745 | | if (bfd_xcoff_text_align_power (abfd) != 0 | 1746 | | && strcmp (bfd_section_name (section), ".text") == 0) | 1747 | | section->alignment_power = bfd_xcoff_text_align_power (abfd); | 1748 | | else if (bfd_xcoff_data_align_power (abfd) != 0 | 1749 | | && strcmp (bfd_section_name (section), ".data") == 0) | 1750 | | section->alignment_power = bfd_xcoff_data_align_power (abfd); | 1751 | | else | 1752 | | { | 1753 | | int i; | 1754 | | | 1755 | | for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++) | 1756 | | if (strcmp (bfd_section_name (section), | 1757 | | xcoff_dwsect_names[i].xcoff_name) == 0) | 1758 | | { | 1759 | | section->alignment_power = 0; | 1760 | | sclass = C_DWARF; | 1761 | | break; | 1762 | | } | 1763 | | } | 1764 | | #endif | 1765 | | | 1766 | | /* Set up the section symbol. */ | 1767 | 13.6k | if (!_bfd_generic_new_section_hook (abfd, section)) | 1768 | 0 | return false; | 1769 | | | 1770 | | /* Allocate aux records for section symbols, to store size and | 1771 | | related info. | 1772 | | | 1773 | | @@ The 10 is a guess at a plausible maximum number of aux entries | 1774 | | (but shouldn't be a constant). */ | 1775 | 13.6k | amt = sizeof (combined_entry_type) * 10; | 1776 | 13.6k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 13.6k | if (native == NULL) | 1778 | 0 | return false; | 1779 | | | 1780 | | /* We don't need to set up n_name, n_value, or n_scnum in the native | 1781 | | symbol information, since they'll be overridden by the BFD symbol | 1782 | | anyhow. However, we do need to set the type and storage class, | 1783 | | in case this symbol winds up getting written out. The value 0 | 1784 | | for n_numaux is already correct. */ | 1785 | | | 1786 | 13.6k | native->is_sym = true; | 1787 | 13.6k | native->u.syment.n_type = T_NULL; | 1788 | 13.6k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 13.6k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 13.6k | coff_set_custom_section_alignment (abfd, section, | 1793 | 13.6k | coff_section_alignment_table, | 1794 | 13.6k | coff_section_alignment_table_size); | 1795 | | | 1796 | 13.6k | return true; | 1797 | 13.6k | } |
coff-tic30.c:coff_new_section_hook Line | Count | Source | 1737 | 37.6k | { | 1738 | 37.6k | combined_entry_type *native; | 1739 | 37.6k | size_t amt; | 1740 | 37.6k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 37.6k | section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1743 | | | 1744 | | #ifdef RS6000COFF_C | 1745 | | if (bfd_xcoff_text_align_power (abfd) != 0 | 1746 | | && strcmp (bfd_section_name (section), ".text") == 0) | 1747 | | section->alignment_power = bfd_xcoff_text_align_power (abfd); | 1748 | | else if (bfd_xcoff_data_align_power (abfd) != 0 | 1749 | | && strcmp (bfd_section_name (section), ".data") == 0) | 1750 | | section->alignment_power = bfd_xcoff_data_align_power (abfd); | 1751 | | else | 1752 | | { | 1753 | | int i; | 1754 | | | 1755 | | for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++) | 1756 | | if (strcmp (bfd_section_name (section), | 1757 | | xcoff_dwsect_names[i].xcoff_name) == 0) | 1758 | | { | 1759 | | section->alignment_power = 0; | 1760 | | sclass = C_DWARF; | 1761 | | break; | 1762 | | } | 1763 | | } | 1764 | | #endif | 1765 | | | 1766 | | /* Set up the section symbol. */ | 1767 | 37.6k | if (!_bfd_generic_new_section_hook (abfd, section)) | 1768 | 0 | return false; | 1769 | | | 1770 | | /* Allocate aux records for section symbols, to store size and | 1771 | | related info. | 1772 | | | 1773 | | @@ The 10 is a guess at a plausible maximum number of aux entries | 1774 | | (but shouldn't be a constant). */ | 1775 | 37.6k | amt = sizeof (combined_entry_type) * 10; | 1776 | 37.6k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 37.6k | if (native == NULL) | 1778 | 0 | return false; | 1779 | | | 1780 | | /* We don't need to set up n_name, n_value, or n_scnum in the native | 1781 | | symbol information, since they'll be overridden by the BFD symbol | 1782 | | anyhow. However, we do need to set the type and storage class, | 1783 | | in case this symbol winds up getting written out. The value 0 | 1784 | | for n_numaux is already correct. */ | 1785 | | | 1786 | 37.6k | native->is_sym = true; | 1787 | 37.6k | native->u.syment.n_type = T_NULL; | 1788 | 37.6k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 37.6k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 37.6k | coff_set_custom_section_alignment (abfd, section, | 1793 | 37.6k | coff_section_alignment_table, | 1794 | 37.6k | coff_section_alignment_table_size); | 1795 | | | 1796 | 37.6k | return true; | 1797 | 37.6k | } |
Unexecuted instantiation: coff-tic4x.c:coff_new_section_hook coff-tic54x.c:coff_new_section_hook Line | Count | Source | 1737 | 55.7k | { | 1738 | 55.7k | combined_entry_type *native; | 1739 | 55.7k | size_t amt; | 1740 | 55.7k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 55.7k | section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1743 | | | 1744 | | #ifdef RS6000COFF_C | 1745 | | if (bfd_xcoff_text_align_power (abfd) != 0 | 1746 | | && strcmp (bfd_section_name (section), ".text") == 0) | 1747 | | section->alignment_power = bfd_xcoff_text_align_power (abfd); | 1748 | | else if (bfd_xcoff_data_align_power (abfd) != 0 | 1749 | | && strcmp (bfd_section_name (section), ".data") == 0) | 1750 | | section->alignment_power = bfd_xcoff_data_align_power (abfd); | 1751 | | else | 1752 | | { | 1753 | | int i; | 1754 | | | 1755 | | for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++) | 1756 | | if (strcmp (bfd_section_name (section), | 1757 | | xcoff_dwsect_names[i].xcoff_name) == 0) | 1758 | | { | 1759 | | section->alignment_power = 0; | 1760 | | sclass = C_DWARF; | 1761 | | break; | 1762 | | } | 1763 | | } | 1764 | | #endif | 1765 | | | 1766 | | /* Set up the section symbol. */ | 1767 | 55.7k | if (!_bfd_generic_new_section_hook (abfd, section)) | 1768 | 0 | return false; | 1769 | | | 1770 | | /* Allocate aux records for section symbols, to store size and | 1771 | | related info. | 1772 | | | 1773 | | @@ The 10 is a guess at a plausible maximum number of aux entries | 1774 | | (but shouldn't be a constant). */ | 1775 | 55.7k | amt = sizeof (combined_entry_type) * 10; | 1776 | 55.7k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 55.7k | if (native == NULL) | 1778 | 0 | return false; | 1779 | | | 1780 | | /* We don't need to set up n_name, n_value, or n_scnum in the native | 1781 | | symbol information, since they'll be overridden by the BFD symbol | 1782 | | anyhow. However, we do need to set the type and storage class, | 1783 | | in case this symbol winds up getting written out. The value 0 | 1784 | | for n_numaux is already correct. */ | 1785 | | | 1786 | 55.7k | native->is_sym = true; | 1787 | 55.7k | native->u.syment.n_type = T_NULL; | 1788 | 55.7k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 55.7k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 55.7k | coff_set_custom_section_alignment (abfd, section, | 1793 | 55.7k | coff_section_alignment_table, | 1794 | 55.7k | coff_section_alignment_table_size); | 1795 | | | 1796 | 55.7k | return true; | 1797 | 55.7k | } |
coff-z80.c:coff_new_section_hook Line | Count | Source | 1737 | 43.4k | { | 1738 | 43.4k | combined_entry_type *native; | 1739 | 43.4k | size_t amt; | 1740 | 43.4k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 43.4k | section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1743 | | | 1744 | | #ifdef RS6000COFF_C | 1745 | | if (bfd_xcoff_text_align_power (abfd) != 0 | 1746 | | && strcmp (bfd_section_name (section), ".text") == 0) | 1747 | | section->alignment_power = bfd_xcoff_text_align_power (abfd); | 1748 | | else if (bfd_xcoff_data_align_power (abfd) != 0 | 1749 | | && strcmp (bfd_section_name (section), ".data") == 0) | 1750 | | section->alignment_power = bfd_xcoff_data_align_power (abfd); | 1751 | | else | 1752 | | { | 1753 | | int i; | 1754 | | | 1755 | | for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++) | 1756 | | if (strcmp (bfd_section_name (section), | 1757 | | xcoff_dwsect_names[i].xcoff_name) == 0) | 1758 | | { | 1759 | | section->alignment_power = 0; | 1760 | | sclass = C_DWARF; | 1761 | | break; | 1762 | | } | 1763 | | } | 1764 | | #endif | 1765 | | | 1766 | | /* Set up the section symbol. */ | 1767 | 43.4k | if (!_bfd_generic_new_section_hook (abfd, section)) | 1768 | 0 | return false; | 1769 | | | 1770 | | /* Allocate aux records for section symbols, to store size and | 1771 | | related info. | 1772 | | | 1773 | | @@ The 10 is a guess at a plausible maximum number of aux entries | 1774 | | (but shouldn't be a constant). */ | 1775 | 43.4k | amt = sizeof (combined_entry_type) * 10; | 1776 | 43.4k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 43.4k | if (native == NULL) | 1778 | 0 | return false; | 1779 | | | 1780 | | /* We don't need to set up n_name, n_value, or n_scnum in the native | 1781 | | symbol information, since they'll be overridden by the BFD symbol | 1782 | | anyhow. However, we do need to set the type and storage class, | 1783 | | in case this symbol winds up getting written out. The value 0 | 1784 | | for n_numaux is already correct. */ | 1785 | | | 1786 | 43.4k | native->is_sym = true; | 1787 | 43.4k | native->u.syment.n_type = T_NULL; | 1788 | 43.4k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 43.4k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 43.4k | coff_set_custom_section_alignment (abfd, section, | 1793 | 43.4k | coff_section_alignment_table, | 1794 | 43.4k | coff_section_alignment_table_size); | 1795 | | | 1796 | 43.4k | return true; | 1797 | 43.4k | } |
coff-z8k.c:coff_new_section_hook Line | Count | Source | 1737 | 59.7k | { | 1738 | 59.7k | combined_entry_type *native; | 1739 | 59.7k | size_t amt; | 1740 | 59.7k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 59.7k | section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1743 | | | 1744 | | #ifdef RS6000COFF_C | 1745 | | if (bfd_xcoff_text_align_power (abfd) != 0 | 1746 | | && strcmp (bfd_section_name (section), ".text") == 0) | 1747 | | section->alignment_power = bfd_xcoff_text_align_power (abfd); | 1748 | | else if (bfd_xcoff_data_align_power (abfd) != 0 | 1749 | | && strcmp (bfd_section_name (section), ".data") == 0) | 1750 | | section->alignment_power = bfd_xcoff_data_align_power (abfd); | 1751 | | else | 1752 | | { | 1753 | | int i; | 1754 | | | 1755 | | for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++) | 1756 | | if (strcmp (bfd_section_name (section), | 1757 | | xcoff_dwsect_names[i].xcoff_name) == 0) | 1758 | | { | 1759 | | section->alignment_power = 0; | 1760 | | sclass = C_DWARF; | 1761 | | break; | 1762 | | } | 1763 | | } | 1764 | | #endif | 1765 | | | 1766 | | /* Set up the section symbol. */ | 1767 | 59.7k | if (!_bfd_generic_new_section_hook (abfd, section)) | 1768 | 0 | return false; | 1769 | | | 1770 | | /* Allocate aux records for section symbols, to store size and | 1771 | | related info. | 1772 | | | 1773 | | @@ The 10 is a guess at a plausible maximum number of aux entries | 1774 | | (but shouldn't be a constant). */ | 1775 | 59.7k | amt = sizeof (combined_entry_type) * 10; | 1776 | 59.7k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 59.7k | if (native == NULL) | 1778 | 0 | return false; | 1779 | | | 1780 | | /* We don't need to set up n_name, n_value, or n_scnum in the native | 1781 | | symbol information, since they'll be overridden by the BFD symbol | 1782 | | anyhow. However, we do need to set the type and storage class, | 1783 | | in case this symbol winds up getting written out. The value 0 | 1784 | | for n_numaux is already correct. */ | 1785 | | | 1786 | 59.7k | native->is_sym = true; | 1787 | 59.7k | native->u.syment.n_type = T_NULL; | 1788 | 59.7k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 59.7k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 59.7k | coff_set_custom_section_alignment (abfd, section, | 1793 | 59.7k | coff_section_alignment_table, | 1794 | 59.7k | coff_section_alignment_table_size); | 1795 | | | 1796 | 59.7k | return true; | 1797 | 59.7k | } |
pe-arm-wince.c:coff_new_section_hook Line | Count | Source | 1737 | 1.21k | { | 1738 | 1.21k | combined_entry_type *native; | 1739 | 1.21k | size_t amt; | 1740 | 1.21k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 1.21k | section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1743 | | | 1744 | | #ifdef RS6000COFF_C | 1745 | | if (bfd_xcoff_text_align_power (abfd) != 0 | 1746 | | && strcmp (bfd_section_name (section), ".text") == 0) | 1747 | | section->alignment_power = bfd_xcoff_text_align_power (abfd); | 1748 | | else if (bfd_xcoff_data_align_power (abfd) != 0 | 1749 | | && strcmp (bfd_section_name (section), ".data") == 0) | 1750 | | section->alignment_power = bfd_xcoff_data_align_power (abfd); | 1751 | | else | 1752 | | { | 1753 | | int i; | 1754 | | | 1755 | | for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++) | 1756 | | if (strcmp (bfd_section_name (section), | 1757 | | xcoff_dwsect_names[i].xcoff_name) == 0) | 1758 | | { | 1759 | | section->alignment_power = 0; | 1760 | | sclass = C_DWARF; | 1761 | | break; | 1762 | | } | 1763 | | } | 1764 | | #endif | 1765 | | | 1766 | | /* Set up the section symbol. */ | 1767 | 1.21k | if (!_bfd_generic_new_section_hook (abfd, section)) | 1768 | 0 | return false; | 1769 | | | 1770 | | /* Allocate aux records for section symbols, to store size and | 1771 | | related info. | 1772 | | | 1773 | | @@ The 10 is a guess at a plausible maximum number of aux entries | 1774 | | (but shouldn't be a constant). */ | 1775 | 1.21k | amt = sizeof (combined_entry_type) * 10; | 1776 | 1.21k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 1.21k | if (native == NULL) | 1778 | 0 | return false; | 1779 | | | 1780 | | /* We don't need to set up n_name, n_value, or n_scnum in the native | 1781 | | symbol information, since they'll be overridden by the BFD symbol | 1782 | | anyhow. However, we do need to set the type and storage class, | 1783 | | in case this symbol winds up getting written out. The value 0 | 1784 | | for n_numaux is already correct. */ | 1785 | | | 1786 | 1.21k | native->is_sym = true; | 1787 | 1.21k | native->u.syment.n_type = T_NULL; | 1788 | 1.21k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 1.21k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 1.21k | coff_set_custom_section_alignment (abfd, section, | 1793 | 1.21k | coff_section_alignment_table, | 1794 | 1.21k | coff_section_alignment_table_size); | 1795 | | | 1796 | 1.21k | return true; | 1797 | 1.21k | } |
pe-arm.c:coff_new_section_hook Line | Count | Source | 1737 | 1.21k | { | 1738 | 1.21k | combined_entry_type *native; | 1739 | 1.21k | size_t amt; | 1740 | 1.21k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 1.21k | section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1743 | | | 1744 | | #ifdef RS6000COFF_C | 1745 | | if (bfd_xcoff_text_align_power (abfd) != 0 | 1746 | | && strcmp (bfd_section_name (section), ".text") == 0) | 1747 | | section->alignment_power = bfd_xcoff_text_align_power (abfd); | 1748 | | else if (bfd_xcoff_data_align_power (abfd) != 0 | 1749 | | && strcmp (bfd_section_name (section), ".data") == 0) | 1750 | | section->alignment_power = bfd_xcoff_data_align_power (abfd); | 1751 | | else | 1752 | | { | 1753 | | int i; | 1754 | | | 1755 | | for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++) | 1756 | | if (strcmp (bfd_section_name (section), | 1757 | | xcoff_dwsect_names[i].xcoff_name) == 0) | 1758 | | { | 1759 | | section->alignment_power = 0; | 1760 | | sclass = C_DWARF; | 1761 | | break; | 1762 | | } | 1763 | | } | 1764 | | #endif | 1765 | | | 1766 | | /* Set up the section symbol. */ | 1767 | 1.21k | if (!_bfd_generic_new_section_hook (abfd, section)) | 1768 | 0 | return false; | 1769 | | | 1770 | | /* Allocate aux records for section symbols, to store size and | 1771 | | related info. | 1772 | | | 1773 | | @@ The 10 is a guess at a plausible maximum number of aux entries | 1774 | | (but shouldn't be a constant). */ | 1775 | 1.21k | amt = sizeof (combined_entry_type) * 10; | 1776 | 1.21k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 1.21k | if (native == NULL) | 1778 | 0 | return false; | 1779 | | | 1780 | | /* We don't need to set up n_name, n_value, or n_scnum in the native | 1781 | | symbol information, since they'll be overridden by the BFD symbol | 1782 | | anyhow. However, we do need to set the type and storage class, | 1783 | | in case this symbol winds up getting written out. The value 0 | 1784 | | for n_numaux is already correct. */ | 1785 | | | 1786 | 1.21k | native->is_sym = true; | 1787 | 1.21k | native->u.syment.n_type = T_NULL; | 1788 | 1.21k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 1.21k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 1.21k | coff_set_custom_section_alignment (abfd, section, | 1793 | 1.21k | coff_section_alignment_table, | 1794 | 1.21k | coff_section_alignment_table_size); | 1795 | | | 1796 | 1.21k | return true; | 1797 | 1.21k | } |
pe-i386.c:coff_new_section_hook Line | Count | Source | 1737 | 7.14k | { | 1738 | 7.14k | combined_entry_type *native; | 1739 | 7.14k | size_t amt; | 1740 | 7.14k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 7.14k | section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1743 | | | 1744 | | #ifdef RS6000COFF_C | 1745 | | if (bfd_xcoff_text_align_power (abfd) != 0 | 1746 | | && strcmp (bfd_section_name (section), ".text") == 0) | 1747 | | section->alignment_power = bfd_xcoff_text_align_power (abfd); | 1748 | | else if (bfd_xcoff_data_align_power (abfd) != 0 | 1749 | | && strcmp (bfd_section_name (section), ".data") == 0) | 1750 | | section->alignment_power = bfd_xcoff_data_align_power (abfd); | 1751 | | else | 1752 | | { | 1753 | | int i; | 1754 | | | 1755 | | for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++) | 1756 | | if (strcmp (bfd_section_name (section), | 1757 | | xcoff_dwsect_names[i].xcoff_name) == 0) | 1758 | | { | 1759 | | section->alignment_power = 0; | 1760 | | sclass = C_DWARF; | 1761 | | break; | 1762 | | } | 1763 | | } | 1764 | | #endif | 1765 | | | 1766 | | /* Set up the section symbol. */ | 1767 | 7.14k | if (!_bfd_generic_new_section_hook (abfd, section)) | 1768 | 0 | return false; | 1769 | | | 1770 | | /* Allocate aux records for section symbols, to store size and | 1771 | | related info. | 1772 | | | 1773 | | @@ The 10 is a guess at a plausible maximum number of aux entries | 1774 | | (but shouldn't be a constant). */ | 1775 | 7.14k | amt = sizeof (combined_entry_type) * 10; | 1776 | 7.14k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 7.14k | if (native == NULL) | 1778 | 0 | return false; | 1779 | | | 1780 | | /* We don't need to set up n_name, n_value, or n_scnum in the native | 1781 | | symbol information, since they'll be overridden by the BFD symbol | 1782 | | anyhow. However, we do need to set the type and storage class, | 1783 | | in case this symbol winds up getting written out. The value 0 | 1784 | | for n_numaux is already correct. */ | 1785 | | | 1786 | 7.14k | native->is_sym = true; | 1787 | 7.14k | native->u.syment.n_type = T_NULL; | 1788 | 7.14k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 7.14k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 7.14k | coff_set_custom_section_alignment (abfd, section, | 1793 | 7.14k | coff_section_alignment_table, | 1794 | 7.14k | coff_section_alignment_table_size); | 1795 | | | 1796 | 7.14k | return true; | 1797 | 7.14k | } |
pe-mcore.c:coff_new_section_hook Line | Count | Source | 1737 | 3.33k | { | 1738 | 3.33k | combined_entry_type *native; | 1739 | 3.33k | size_t amt; | 1740 | 3.33k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 3.33k | section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1743 | | | 1744 | | #ifdef RS6000COFF_C | 1745 | | if (bfd_xcoff_text_align_power (abfd) != 0 | 1746 | | && strcmp (bfd_section_name (section), ".text") == 0) | 1747 | | section->alignment_power = bfd_xcoff_text_align_power (abfd); | 1748 | | else if (bfd_xcoff_data_align_power (abfd) != 0 | 1749 | | && strcmp (bfd_section_name (section), ".data") == 0) | 1750 | | section->alignment_power = bfd_xcoff_data_align_power (abfd); | 1751 | | else | 1752 | | { | 1753 | | int i; | 1754 | | | 1755 | | for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++) | 1756 | | if (strcmp (bfd_section_name (section), | 1757 | | xcoff_dwsect_names[i].xcoff_name) == 0) | 1758 | | { | 1759 | | section->alignment_power = 0; | 1760 | | sclass = C_DWARF; | 1761 | | break; | 1762 | | } | 1763 | | } | 1764 | | #endif | 1765 | | | 1766 | | /* Set up the section symbol. */ | 1767 | 3.33k | if (!_bfd_generic_new_section_hook (abfd, section)) | 1768 | 0 | return false; | 1769 | | | 1770 | | /* Allocate aux records for section symbols, to store size and | 1771 | | related info. | 1772 | | | 1773 | | @@ The 10 is a guess at a plausible maximum number of aux entries | 1774 | | (but shouldn't be a constant). */ | 1775 | 3.33k | amt = sizeof (combined_entry_type) * 10; | 1776 | 3.33k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 3.33k | if (native == NULL) | 1778 | 0 | return false; | 1779 | | | 1780 | | /* We don't need to set up n_name, n_value, or n_scnum in the native | 1781 | | symbol information, since they'll be overridden by the BFD symbol | 1782 | | anyhow. However, we do need to set the type and storage class, | 1783 | | in case this symbol winds up getting written out. The value 0 | 1784 | | for n_numaux is already correct. */ | 1785 | | | 1786 | 3.33k | native->is_sym = true; | 1787 | 3.33k | native->u.syment.n_type = T_NULL; | 1788 | 3.33k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 3.33k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 3.33k | coff_set_custom_section_alignment (abfd, section, | 1793 | 3.33k | coff_section_alignment_table, | 1794 | 3.33k | coff_section_alignment_table_size); | 1795 | | | 1796 | 3.33k | return true; | 1797 | 3.33k | } |
pe-sh.c:coff_new_section_hook Line | Count | Source | 1737 | 2.59k | { | 1738 | 2.59k | combined_entry_type *native; | 1739 | 2.59k | size_t amt; | 1740 | 2.59k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 2.59k | section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1743 | | | 1744 | | #ifdef RS6000COFF_C | 1745 | | if (bfd_xcoff_text_align_power (abfd) != 0 | 1746 | | && strcmp (bfd_section_name (section), ".text") == 0) | 1747 | | section->alignment_power = bfd_xcoff_text_align_power (abfd); | 1748 | | else if (bfd_xcoff_data_align_power (abfd) != 0 | 1749 | | && strcmp (bfd_section_name (section), ".data") == 0) | 1750 | | section->alignment_power = bfd_xcoff_data_align_power (abfd); | 1751 | | else | 1752 | | { | 1753 | | int i; | 1754 | | | 1755 | | for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++) | 1756 | | if (strcmp (bfd_section_name (section), | 1757 | | xcoff_dwsect_names[i].xcoff_name) == 0) | 1758 | | { | 1759 | | section->alignment_power = 0; | 1760 | | sclass = C_DWARF; | 1761 | | break; | 1762 | | } | 1763 | | } | 1764 | | #endif | 1765 | | | 1766 | | /* Set up the section symbol. */ | 1767 | 2.59k | if (!_bfd_generic_new_section_hook (abfd, section)) | 1768 | 0 | return false; | 1769 | | | 1770 | | /* Allocate aux records for section symbols, to store size and | 1771 | | related info. | 1772 | | | 1773 | | @@ The 10 is a guess at a plausible maximum number of aux entries | 1774 | | (but shouldn't be a constant). */ | 1775 | 2.59k | amt = sizeof (combined_entry_type) * 10; | 1776 | 2.59k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 2.59k | if (native == NULL) | 1778 | 0 | return false; | 1779 | | | 1780 | | /* We don't need to set up n_name, n_value, or n_scnum in the native | 1781 | | symbol information, since they'll be overridden by the BFD symbol | 1782 | | anyhow. However, we do need to set the type and storage class, | 1783 | | in case this symbol winds up getting written out. The value 0 | 1784 | | for n_numaux is already correct. */ | 1785 | | | 1786 | 2.59k | native->is_sym = true; | 1787 | 2.59k | native->u.syment.n_type = T_NULL; | 1788 | 2.59k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 2.59k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 2.59k | coff_set_custom_section_alignment (abfd, section, | 1793 | 2.59k | coff_section_alignment_table, | 1794 | 2.59k | coff_section_alignment_table_size); | 1795 | | | 1796 | 2.59k | return true; | 1797 | 2.59k | } |
pei-arm-wince.c:coff_new_section_hook Line | Count | Source | 1737 | 2.14k | { | 1738 | 2.14k | combined_entry_type *native; | 1739 | 2.14k | size_t amt; | 1740 | 2.14k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 2.14k | section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1743 | | | 1744 | | #ifdef RS6000COFF_C | 1745 | | if (bfd_xcoff_text_align_power (abfd) != 0 | 1746 | | && strcmp (bfd_section_name (section), ".text") == 0) | 1747 | | section->alignment_power = bfd_xcoff_text_align_power (abfd); | 1748 | | else if (bfd_xcoff_data_align_power (abfd) != 0 | 1749 | | && strcmp (bfd_section_name (section), ".data") == 0) | 1750 | | section->alignment_power = bfd_xcoff_data_align_power (abfd); | 1751 | | else | 1752 | | { | 1753 | | int i; | 1754 | | | 1755 | | for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++) | 1756 | | if (strcmp (bfd_section_name (section), | 1757 | | xcoff_dwsect_names[i].xcoff_name) == 0) | 1758 | | { | 1759 | | section->alignment_power = 0; | 1760 | | sclass = C_DWARF; | 1761 | | break; | 1762 | | } | 1763 | | } | 1764 | | #endif | 1765 | | | 1766 | | /* Set up the section symbol. */ | 1767 | 2.14k | if (!_bfd_generic_new_section_hook (abfd, section)) | 1768 | 0 | return false; | 1769 | | | 1770 | | /* Allocate aux records for section symbols, to store size and | 1771 | | related info. | 1772 | | | 1773 | | @@ The 10 is a guess at a plausible maximum number of aux entries | 1774 | | (but shouldn't be a constant). */ | 1775 | 2.14k | amt = sizeof (combined_entry_type) * 10; | 1776 | 2.14k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 2.14k | if (native == NULL) | 1778 | 0 | return false; | 1779 | | | 1780 | | /* We don't need to set up n_name, n_value, or n_scnum in the native | 1781 | | symbol information, since they'll be overridden by the BFD symbol | 1782 | | anyhow. However, we do need to set the type and storage class, | 1783 | | in case this symbol winds up getting written out. The value 0 | 1784 | | for n_numaux is already correct. */ | 1785 | | | 1786 | 2.14k | native->is_sym = true; | 1787 | 2.14k | native->u.syment.n_type = T_NULL; | 1788 | 2.14k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 2.14k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 2.14k | coff_set_custom_section_alignment (abfd, section, | 1793 | 2.14k | coff_section_alignment_table, | 1794 | 2.14k | coff_section_alignment_table_size); | 1795 | | | 1796 | 2.14k | return true; | 1797 | 2.14k | } |
pei-arm.c:coff_new_section_hook Line | Count | Source | 1737 | 2.80k | { | 1738 | 2.80k | combined_entry_type *native; | 1739 | 2.80k | size_t amt; | 1740 | 2.80k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 2.80k | section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1743 | | | 1744 | | #ifdef RS6000COFF_C | 1745 | | if (bfd_xcoff_text_align_power (abfd) != 0 | 1746 | | && strcmp (bfd_section_name (section), ".text") == 0) | 1747 | | section->alignment_power = bfd_xcoff_text_align_power (abfd); | 1748 | | else if (bfd_xcoff_data_align_power (abfd) != 0 | 1749 | | && strcmp (bfd_section_name (section), ".data") == 0) | 1750 | | section->alignment_power = bfd_xcoff_data_align_power (abfd); | 1751 | | else | 1752 | | { | 1753 | | int i; | 1754 | | | 1755 | | for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++) | 1756 | | if (strcmp (bfd_section_name (section), | 1757 | | xcoff_dwsect_names[i].xcoff_name) == 0) | 1758 | | { | 1759 | | section->alignment_power = 0; | 1760 | | sclass = C_DWARF; | 1761 | | break; | 1762 | | } | 1763 | | } | 1764 | | #endif | 1765 | | | 1766 | | /* Set up the section symbol. */ | 1767 | 2.80k | if (!_bfd_generic_new_section_hook (abfd, section)) | 1768 | 0 | return false; | 1769 | | | 1770 | | /* Allocate aux records for section symbols, to store size and | 1771 | | related info. | 1772 | | | 1773 | | @@ The 10 is a guess at a plausible maximum number of aux entries | 1774 | | (but shouldn't be a constant). */ | 1775 | 2.80k | amt = sizeof (combined_entry_type) * 10; | 1776 | 2.80k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 2.80k | if (native == NULL) | 1778 | 0 | return false; | 1779 | | | 1780 | | /* We don't need to set up n_name, n_value, or n_scnum in the native | 1781 | | symbol information, since they'll be overridden by the BFD symbol | 1782 | | anyhow. However, we do need to set the type and storage class, | 1783 | | in case this symbol winds up getting written out. The value 0 | 1784 | | for n_numaux is already correct. */ | 1785 | | | 1786 | 2.80k | native->is_sym = true; | 1787 | 2.80k | native->u.syment.n_type = T_NULL; | 1788 | 2.80k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 2.80k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 2.80k | coff_set_custom_section_alignment (abfd, section, | 1793 | 2.80k | coff_section_alignment_table, | 1794 | 2.80k | coff_section_alignment_table_size); | 1795 | | | 1796 | 2.80k | return true; | 1797 | 2.80k | } |
pei-mcore.c:coff_new_section_hook Line | Count | Source | 1737 | 3.56k | { | 1738 | 3.56k | combined_entry_type *native; | 1739 | 3.56k | size_t amt; | 1740 | 3.56k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 3.56k | section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1743 | | | 1744 | | #ifdef RS6000COFF_C | 1745 | | if (bfd_xcoff_text_align_power (abfd) != 0 | 1746 | | && strcmp (bfd_section_name (section), ".text") == 0) | 1747 | | section->alignment_power = bfd_xcoff_text_align_power (abfd); | 1748 | | else if (bfd_xcoff_data_align_power (abfd) != 0 | 1749 | | && strcmp (bfd_section_name (section), ".data") == 0) | 1750 | | section->alignment_power = bfd_xcoff_data_align_power (abfd); | 1751 | | else | 1752 | | { | 1753 | | int i; | 1754 | | | 1755 | | for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++) | 1756 | | if (strcmp (bfd_section_name (section), | 1757 | | xcoff_dwsect_names[i].xcoff_name) == 0) | 1758 | | { | 1759 | | section->alignment_power = 0; | 1760 | | sclass = C_DWARF; | 1761 | | break; | 1762 | | } | 1763 | | } | 1764 | | #endif | 1765 | | | 1766 | | /* Set up the section symbol. */ | 1767 | 3.56k | if (!_bfd_generic_new_section_hook (abfd, section)) | 1768 | 0 | return false; | 1769 | | | 1770 | | /* Allocate aux records for section symbols, to store size and | 1771 | | related info. | 1772 | | | 1773 | | @@ The 10 is a guess at a plausible maximum number of aux entries | 1774 | | (but shouldn't be a constant). */ | 1775 | 3.56k | amt = sizeof (combined_entry_type) * 10; | 1776 | 3.56k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 3.56k | if (native == NULL) | 1778 | 0 | return false; | 1779 | | | 1780 | | /* We don't need to set up n_name, n_value, or n_scnum in the native | 1781 | | symbol information, since they'll be overridden by the BFD symbol | 1782 | | anyhow. However, we do need to set the type and storage class, | 1783 | | in case this symbol winds up getting written out. The value 0 | 1784 | | for n_numaux is already correct. */ | 1785 | | | 1786 | 3.56k | native->is_sym = true; | 1787 | 3.56k | native->u.syment.n_type = T_NULL; | 1788 | 3.56k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 3.56k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 3.56k | coff_set_custom_section_alignment (abfd, section, | 1793 | 3.56k | coff_section_alignment_table, | 1794 | 3.56k | coff_section_alignment_table_size); | 1795 | | | 1796 | 3.56k | return true; | 1797 | 3.56k | } |
pei-sh.c:coff_new_section_hook Line | Count | Source | 1737 | 1.88k | { | 1738 | 1.88k | combined_entry_type *native; | 1739 | 1.88k | size_t amt; | 1740 | 1.88k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 1.88k | section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1743 | | | 1744 | | #ifdef RS6000COFF_C | 1745 | | if (bfd_xcoff_text_align_power (abfd) != 0 | 1746 | | && strcmp (bfd_section_name (section), ".text") == 0) | 1747 | | section->alignment_power = bfd_xcoff_text_align_power (abfd); | 1748 | | else if (bfd_xcoff_data_align_power (abfd) != 0 | 1749 | | && strcmp (bfd_section_name (section), ".data") == 0) | 1750 | | section->alignment_power = bfd_xcoff_data_align_power (abfd); | 1751 | | else | 1752 | | { | 1753 | | int i; | 1754 | | | 1755 | | for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++) | 1756 | | if (strcmp (bfd_section_name (section), | 1757 | | xcoff_dwsect_names[i].xcoff_name) == 0) | 1758 | | { | 1759 | | section->alignment_power = 0; | 1760 | | sclass = C_DWARF; | 1761 | | break; | 1762 | | } | 1763 | | } | 1764 | | #endif | 1765 | | | 1766 | | /* Set up the section symbol. */ | 1767 | 1.88k | if (!_bfd_generic_new_section_hook (abfd, section)) | 1768 | 0 | return false; | 1769 | | | 1770 | | /* Allocate aux records for section symbols, to store size and | 1771 | | related info. | 1772 | | | 1773 | | @@ The 10 is a guess at a plausible maximum number of aux entries | 1774 | | (but shouldn't be a constant). */ | 1775 | 1.88k | amt = sizeof (combined_entry_type) * 10; | 1776 | 1.88k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 1.88k | if (native == NULL) | 1778 | 0 | return false; | 1779 | | | 1780 | | /* We don't need to set up n_name, n_value, or n_scnum in the native | 1781 | | symbol information, since they'll be overridden by the BFD symbol | 1782 | | anyhow. However, we do need to set the type and storage class, | 1783 | | in case this symbol winds up getting written out. The value 0 | 1784 | | for n_numaux is already correct. */ | 1785 | | | 1786 | 1.88k | native->is_sym = true; | 1787 | 1.88k | native->u.syment.n_type = T_NULL; | 1788 | 1.88k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 1.88k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 1.88k | coff_set_custom_section_alignment (abfd, section, | 1793 | 1.88k | coff_section_alignment_table, | 1794 | 1.88k | coff_section_alignment_table_size); | 1795 | | | 1796 | 1.88k | return true; | 1797 | 1.88k | } |
|
1798 | | |
1799 | | #ifdef COFF_ALIGN_IN_SECTION_HEADER |
1800 | | |
1801 | | /* Set the alignment of a BFD section. */ |
1802 | | |
1803 | | static void |
1804 | | coff_set_alignment_hook (bfd * abfd ATTRIBUTE_UNUSED, |
1805 | | asection * section, |
1806 | | void * scnhdr) |
1807 | 99.2k | { |
1808 | 99.2k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; |
1809 | 99.2k | unsigned int i; |
1810 | | |
1811 | 99.2k | #ifdef COFF_DECODE_ALIGNMENT |
1812 | 99.2k | i = COFF_DECODE_ALIGNMENT(hdr->s_flags); |
1813 | 99.2k | #endif |
1814 | 99.2k | section->alignment_power = i; |
1815 | | |
1816 | | #ifdef coff_set_section_load_page |
1817 | 55.7k | coff_set_section_load_page (section, hdr->s_page); |
1818 | | #endif |
1819 | 99.2k | } Unexecuted instantiation: coff-tic4x.c:coff_set_alignment_hook coff-tic54x.c:coff_set_alignment_hook Line | Count | Source | 1807 | 55.7k | { | 1808 | 55.7k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; | 1809 | 55.7k | unsigned int i; | 1810 | | | 1811 | 55.7k | #ifdef COFF_DECODE_ALIGNMENT | 1812 | 55.7k | i = COFF_DECODE_ALIGNMENT(hdr->s_flags); | 1813 | 55.7k | #endif | 1814 | 55.7k | section->alignment_power = i; | 1815 | | | 1816 | 55.7k | #ifdef coff_set_section_load_page | 1817 | 55.7k | coff_set_section_load_page (section, hdr->s_page); | 1818 | 55.7k | #endif | 1819 | 55.7k | } |
coff-z80.c:coff_set_alignment_hook Line | Count | Source | 1807 | 43.4k | { | 1808 | 43.4k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; | 1809 | 43.4k | unsigned int i; | 1810 | | | 1811 | 43.4k | #ifdef COFF_DECODE_ALIGNMENT | 1812 | 43.4k | i = COFF_DECODE_ALIGNMENT(hdr->s_flags); | 1813 | 43.4k | #endif | 1814 | 43.4k | section->alignment_power = i; | 1815 | | | 1816 | | #ifdef coff_set_section_load_page | 1817 | | coff_set_section_load_page (section, hdr->s_page); | 1818 | | #endif | 1819 | 43.4k | } |
|
1820 | | |
1821 | | #else /* ! COFF_ALIGN_IN_SECTION_HEADER */ |
1822 | | #ifdef COFF_WITH_PE |
1823 | | |
1824 | | static void |
1825 | | coff_set_alignment_hook (bfd * abfd ATTRIBUTE_UNUSED, |
1826 | | asection * section, |
1827 | | void * scnhdr) |
1828 | 55.2k | { |
1829 | 55.2k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; |
1830 | 55.2k | size_t amt; |
1831 | 55.2k | unsigned int alignment_power_const |
1832 | 55.2k | = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK; |
1833 | | |
1834 | 55.2k | switch (alignment_power_const) |
1835 | 55.2k | { |
1836 | 4.71k | case IMAGE_SCN_ALIGN_8192BYTES: |
1837 | 4.81k | case IMAGE_SCN_ALIGN_4096BYTES: |
1838 | 6.35k | case IMAGE_SCN_ALIGN_2048BYTES: |
1839 | 6.46k | case IMAGE_SCN_ALIGN_1024BYTES: |
1840 | 7.40k | case IMAGE_SCN_ALIGN_512BYTES: |
1841 | 7.67k | case IMAGE_SCN_ALIGN_256BYTES: |
1842 | 8.19k | case IMAGE_SCN_ALIGN_128BYTES: |
1843 | 8.43k | case IMAGE_SCN_ALIGN_64BYTES: |
1844 | 18.1k | case IMAGE_SCN_ALIGN_32BYTES: |
1845 | 18.3k | case IMAGE_SCN_ALIGN_16BYTES: |
1846 | 18.8k | case IMAGE_SCN_ALIGN_8BYTES: |
1847 | 19.1k | case IMAGE_SCN_ALIGN_4BYTES: |
1848 | 19.9k | case IMAGE_SCN_ALIGN_2BYTES: |
1849 | 20.7k | case IMAGE_SCN_ALIGN_1BYTES: |
1850 | 20.7k | section->alignment_power |
1851 | 20.7k | = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const); |
1852 | 20.7k | break; |
1853 | 34.5k | default: |
1854 | 34.5k | break; |
1855 | 55.2k | } |
1856 | | |
1857 | | /* In a PE image file, the s_paddr field holds the virtual size of a |
1858 | | section, while the s_size field holds the raw size. We also keep |
1859 | | the original section flag value, since not every bit can be |
1860 | | mapped onto a generic BFD section bit. */ |
1861 | 55.2k | if (coff_section_data (abfd, section) == NULL) |
1862 | 55.2k | { |
1863 | 55.2k | amt = sizeof (struct coff_section_tdata); |
1864 | 55.2k | section->used_by_bfd = bfd_zalloc (abfd, amt); |
1865 | 55.2k | if (section->used_by_bfd == NULL) |
1866 | | /* FIXME: Return error. */ |
1867 | 0 | abort (); |
1868 | 55.2k | } |
1869 | | |
1870 | 55.2k | if (pei_section_data (abfd, section) == NULL) |
1871 | 55.2k | { |
1872 | 55.2k | amt = sizeof (struct pei_section_tdata); |
1873 | 55.2k | coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt); |
1874 | 55.2k | if (coff_section_data (abfd, section)->tdata == NULL) |
1875 | | /* FIXME: Return error. */ |
1876 | 0 | abort (); |
1877 | 55.2k | } |
1878 | 55.2k | pei_section_data (abfd, section)->virt_size = hdr->s_paddr; |
1879 | 55.2k | pei_section_data (abfd, section)->pe_flags = hdr->s_flags; |
1880 | | |
1881 | 55.2k | section->lma = hdr->s_vaddr; |
1882 | | |
1883 | | /* Check for extended relocs. */ |
1884 | 55.2k | if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL) |
1885 | 3.14k | { |
1886 | 3.14k | struct external_reloc dst; |
1887 | 3.14k | struct internal_reloc n; |
1888 | 3.14k | file_ptr oldpos = bfd_tell (abfd); |
1889 | 3.14k | bfd_size_type relsz = bfd_coff_relsz (abfd); |
1890 | | |
1891 | 3.14k | if (bfd_seek (abfd, (file_ptr) hdr->s_relptr, 0) != 0) |
1892 | 0 | return; |
1893 | 3.14k | if (bfd_bread (& dst, relsz, abfd) != relsz) |
1894 | 1.76k | return; |
1895 | | |
1896 | 1.38k | bfd_coff_swap_reloc_in (abfd, &dst, &n); |
1897 | 1.38k | if (bfd_seek (abfd, oldpos, 0) != 0) |
1898 | 0 | return; |
1899 | 1.38k | if (n.r_vaddr < 0x10000) |
1900 | 446 | { |
1901 | 446 | _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd); |
1902 | 446 | bfd_set_error (bfd_error_bad_value); |
1903 | 446 | return; |
1904 | 446 | } |
1905 | 939 | section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1; |
1906 | 939 | section->rel_filepos += relsz; |
1907 | 939 | } |
1908 | 52.1k | else if (hdr->s_nreloc == 0xffff) |
1909 | 196 | _bfd_error_handler |
1910 | 196 | (_("%pB: warning: claims to have 0xffff relocs, without overflow"), |
1911 | 196 | abfd); |
1912 | 55.2k | } pei-i386.c:coff_set_alignment_hook Line | Count | Source | 1828 | 3.24k | { | 1829 | 3.24k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; | 1830 | 3.24k | size_t amt; | 1831 | 3.24k | unsigned int alignment_power_const | 1832 | 3.24k | = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK; | 1833 | | | 1834 | 3.24k | switch (alignment_power_const) | 1835 | 3.24k | { | 1836 | 86 | case IMAGE_SCN_ALIGN_8192BYTES: | 1837 | 86 | case IMAGE_SCN_ALIGN_4096BYTES: | 1838 | 183 | case IMAGE_SCN_ALIGN_2048BYTES: | 1839 | 183 | case IMAGE_SCN_ALIGN_1024BYTES: | 1840 | 252 | case IMAGE_SCN_ALIGN_512BYTES: | 1841 | 254 | case IMAGE_SCN_ALIGN_256BYTES: | 1842 | 292 | case IMAGE_SCN_ALIGN_128BYTES: | 1843 | 300 | case IMAGE_SCN_ALIGN_64BYTES: | 1844 | 334 | case IMAGE_SCN_ALIGN_32BYTES: | 1845 | 343 | case IMAGE_SCN_ALIGN_16BYTES: | 1846 | 363 | case IMAGE_SCN_ALIGN_8BYTES: | 1847 | 377 | case IMAGE_SCN_ALIGN_4BYTES: | 1848 | 409 | case IMAGE_SCN_ALIGN_2BYTES: | 1849 | 437 | case IMAGE_SCN_ALIGN_1BYTES: | 1850 | 437 | section->alignment_power | 1851 | 437 | = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const); | 1852 | 437 | break; | 1853 | 2.81k | default: | 1854 | 2.81k | break; | 1855 | 3.24k | } | 1856 | | | 1857 | | /* In a PE image file, the s_paddr field holds the virtual size of a | 1858 | | section, while the s_size field holds the raw size. We also keep | 1859 | | the original section flag value, since not every bit can be | 1860 | | mapped onto a generic BFD section bit. */ | 1861 | 3.24k | if (coff_section_data (abfd, section) == NULL) | 1862 | 3.24k | { | 1863 | 3.24k | amt = sizeof (struct coff_section_tdata); | 1864 | 3.24k | section->used_by_bfd = bfd_zalloc (abfd, amt); | 1865 | 3.24k | if (section->used_by_bfd == NULL) | 1866 | | /* FIXME: Return error. */ | 1867 | 0 | abort (); | 1868 | 3.24k | } | 1869 | | | 1870 | 3.24k | if (pei_section_data (abfd, section) == NULL) | 1871 | 3.24k | { | 1872 | 3.24k | amt = sizeof (struct pei_section_tdata); | 1873 | 3.24k | coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt); | 1874 | 3.24k | if (coff_section_data (abfd, section)->tdata == NULL) | 1875 | | /* FIXME: Return error. */ | 1876 | 0 | abort (); | 1877 | 3.24k | } | 1878 | 3.24k | pei_section_data (abfd, section)->virt_size = hdr->s_paddr; | 1879 | 3.24k | pei_section_data (abfd, section)->pe_flags = hdr->s_flags; | 1880 | | | 1881 | 3.24k | section->lma = hdr->s_vaddr; | 1882 | | | 1883 | | /* Check for extended relocs. */ | 1884 | 3.24k | if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL) | 1885 | 140 | { | 1886 | 140 | struct external_reloc dst; | 1887 | 140 | struct internal_reloc n; | 1888 | 140 | file_ptr oldpos = bfd_tell (abfd); | 1889 | 140 | bfd_size_type relsz = bfd_coff_relsz (abfd); | 1890 | | | 1891 | 140 | if (bfd_seek (abfd, (file_ptr) hdr->s_relptr, 0) != 0) | 1892 | 0 | return; | 1893 | 140 | if (bfd_bread (& dst, relsz, abfd) != relsz) | 1894 | 53 | return; | 1895 | | | 1896 | 87 | bfd_coff_swap_reloc_in (abfd, &dst, &n); | 1897 | 87 | if (bfd_seek (abfd, oldpos, 0) != 0) | 1898 | 0 | return; | 1899 | 87 | if (n.r_vaddr < 0x10000) | 1900 | 36 | { | 1901 | 36 | _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd); | 1902 | 36 | bfd_set_error (bfd_error_bad_value); | 1903 | 36 | return; | 1904 | 36 | } | 1905 | 51 | section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1; | 1906 | 51 | section->rel_filepos += relsz; | 1907 | 51 | } | 1908 | 3.10k | else if (hdr->s_nreloc == 0xffff) | 1909 | 0 | _bfd_error_handler | 1910 | 0 | (_("%pB: warning: claims to have 0xffff relocs, without overflow"), | 1911 | 0 | abfd); | 1912 | 3.24k | } |
pe-x86_64.c:coff_set_alignment_hook Line | Count | Source | 1828 | 5.29k | { | 1829 | 5.29k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; | 1830 | 5.29k | size_t amt; | 1831 | 5.29k | unsigned int alignment_power_const | 1832 | 5.29k | = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK; | 1833 | | | 1834 | 5.29k | switch (alignment_power_const) | 1835 | 5.29k | { | 1836 | 78 | case IMAGE_SCN_ALIGN_8192BYTES: | 1837 | 111 | case IMAGE_SCN_ALIGN_4096BYTES: | 1838 | 139 | case IMAGE_SCN_ALIGN_2048BYTES: | 1839 | 171 | case IMAGE_SCN_ALIGN_1024BYTES: | 1840 | 243 | case IMAGE_SCN_ALIGN_512BYTES: | 1841 | 292 | case IMAGE_SCN_ALIGN_256BYTES: | 1842 | 364 | case IMAGE_SCN_ALIGN_128BYTES: | 1843 | 404 | case IMAGE_SCN_ALIGN_64BYTES: | 1844 | 568 | case IMAGE_SCN_ALIGN_32BYTES: | 1845 | 592 | case IMAGE_SCN_ALIGN_16BYTES: | 1846 | 655 | case IMAGE_SCN_ALIGN_8BYTES: | 1847 | 693 | case IMAGE_SCN_ALIGN_4BYTES: | 1848 | 817 | case IMAGE_SCN_ALIGN_2BYTES: | 1849 | 1.06k | case IMAGE_SCN_ALIGN_1BYTES: | 1850 | 1.06k | section->alignment_power | 1851 | 1.06k | = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const); | 1852 | 1.06k | break; | 1853 | 4.22k | default: | 1854 | 4.22k | break; | 1855 | 5.29k | } | 1856 | | | 1857 | | /* In a PE image file, the s_paddr field holds the virtual size of a | 1858 | | section, while the s_size field holds the raw size. We also keep | 1859 | | the original section flag value, since not every bit can be | 1860 | | mapped onto a generic BFD section bit. */ | 1861 | 5.29k | if (coff_section_data (abfd, section) == NULL) | 1862 | 5.29k | { | 1863 | 5.29k | amt = sizeof (struct coff_section_tdata); | 1864 | 5.29k | section->used_by_bfd = bfd_zalloc (abfd, amt); | 1865 | 5.29k | if (section->used_by_bfd == NULL) | 1866 | | /* FIXME: Return error. */ | 1867 | 0 | abort (); | 1868 | 5.29k | } | 1869 | | | 1870 | 5.29k | if (pei_section_data (abfd, section) == NULL) | 1871 | 5.29k | { | 1872 | 5.29k | amt = sizeof (struct pei_section_tdata); | 1873 | 5.29k | coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt); | 1874 | 5.29k | if (coff_section_data (abfd, section)->tdata == NULL) | 1875 | | /* FIXME: Return error. */ | 1876 | 0 | abort (); | 1877 | 5.29k | } | 1878 | 5.29k | pei_section_data (abfd, section)->virt_size = hdr->s_paddr; | 1879 | 5.29k | pei_section_data (abfd, section)->pe_flags = hdr->s_flags; | 1880 | | | 1881 | 5.29k | section->lma = hdr->s_vaddr; | 1882 | | | 1883 | | /* Check for extended relocs. */ | 1884 | 5.29k | if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL) | 1885 | 689 | { | 1886 | 689 | struct external_reloc dst; | 1887 | 689 | struct internal_reloc n; | 1888 | 689 | file_ptr oldpos = bfd_tell (abfd); | 1889 | 689 | bfd_size_type relsz = bfd_coff_relsz (abfd); | 1890 | | | 1891 | 689 | if (bfd_seek (abfd, (file_ptr) hdr->s_relptr, 0) != 0) | 1892 | 0 | return; | 1893 | 689 | if (bfd_bread (& dst, relsz, abfd) != relsz) | 1894 | 405 | return; | 1895 | | | 1896 | 284 | bfd_coff_swap_reloc_in (abfd, &dst, &n); | 1897 | 284 | if (bfd_seek (abfd, oldpos, 0) != 0) | 1898 | 0 | return; | 1899 | 284 | if (n.r_vaddr < 0x10000) | 1900 | 98 | { | 1901 | 98 | _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd); | 1902 | 98 | bfd_set_error (bfd_error_bad_value); | 1903 | 98 | return; | 1904 | 98 | } | 1905 | 186 | section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1; | 1906 | 186 | section->rel_filepos += relsz; | 1907 | 186 | } | 1908 | 4.60k | else if (hdr->s_nreloc == 0xffff) | 1909 | 48 | _bfd_error_handler | 1910 | 48 | (_("%pB: warning: claims to have 0xffff relocs, without overflow"), | 1911 | 48 | abfd); | 1912 | 5.29k | } |
pei-x86_64.c:coff_set_alignment_hook Line | Count | Source | 1828 | 3.26k | { | 1829 | 3.26k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; | 1830 | 3.26k | size_t amt; | 1831 | 3.26k | unsigned int alignment_power_const | 1832 | 3.26k | = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK; | 1833 | | | 1834 | 3.26k | switch (alignment_power_const) | 1835 | 3.26k | { | 1836 | 134 | case IMAGE_SCN_ALIGN_8192BYTES: | 1837 | 137 | case IMAGE_SCN_ALIGN_4096BYTES: | 1838 | 149 | case IMAGE_SCN_ALIGN_2048BYTES: | 1839 | 160 | case IMAGE_SCN_ALIGN_1024BYTES: | 1840 | 183 | case IMAGE_SCN_ALIGN_512BYTES: | 1841 | 186 | case IMAGE_SCN_ALIGN_256BYTES: | 1842 | 196 | case IMAGE_SCN_ALIGN_128BYTES: | 1843 | 222 | case IMAGE_SCN_ALIGN_64BYTES: | 1844 | 267 | case IMAGE_SCN_ALIGN_32BYTES: | 1845 | 272 | case IMAGE_SCN_ALIGN_16BYTES: | 1846 | 298 | case IMAGE_SCN_ALIGN_8BYTES: | 1847 | 309 | case IMAGE_SCN_ALIGN_4BYTES: | 1848 | 321 | case IMAGE_SCN_ALIGN_2BYTES: | 1849 | 342 | case IMAGE_SCN_ALIGN_1BYTES: | 1850 | 342 | section->alignment_power | 1851 | 342 | = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const); | 1852 | 342 | break; | 1853 | 2.92k | default: | 1854 | 2.92k | break; | 1855 | 3.26k | } | 1856 | | | 1857 | | /* In a PE image file, the s_paddr field holds the virtual size of a | 1858 | | section, while the s_size field holds the raw size. We also keep | 1859 | | the original section flag value, since not every bit can be | 1860 | | mapped onto a generic BFD section bit. */ | 1861 | 3.26k | if (coff_section_data (abfd, section) == NULL) | 1862 | 3.26k | { | 1863 | 3.26k | amt = sizeof (struct coff_section_tdata); | 1864 | 3.26k | section->used_by_bfd = bfd_zalloc (abfd, amt); | 1865 | 3.26k | if (section->used_by_bfd == NULL) | 1866 | | /* FIXME: Return error. */ | 1867 | 0 | abort (); | 1868 | 3.26k | } | 1869 | | | 1870 | 3.26k | if (pei_section_data (abfd, section) == NULL) | 1871 | 3.26k | { | 1872 | 3.26k | amt = sizeof (struct pei_section_tdata); | 1873 | 3.26k | coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt); | 1874 | 3.26k | if (coff_section_data (abfd, section)->tdata == NULL) | 1875 | | /* FIXME: Return error. */ | 1876 | 0 | abort (); | 1877 | 3.26k | } | 1878 | 3.26k | pei_section_data (abfd, section)->virt_size = hdr->s_paddr; | 1879 | 3.26k | pei_section_data (abfd, section)->pe_flags = hdr->s_flags; | 1880 | | | 1881 | 3.26k | section->lma = hdr->s_vaddr; | 1882 | | | 1883 | | /* Check for extended relocs. */ | 1884 | 3.26k | if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL) | 1885 | 127 | { | 1886 | 127 | struct external_reloc dst; | 1887 | 127 | struct internal_reloc n; | 1888 | 127 | file_ptr oldpos = bfd_tell (abfd); | 1889 | 127 | bfd_size_type relsz = bfd_coff_relsz (abfd); | 1890 | | | 1891 | 127 | if (bfd_seek (abfd, (file_ptr) hdr->s_relptr, 0) != 0) | 1892 | 0 | return; | 1893 | 127 | if (bfd_bread (& dst, relsz, abfd) != relsz) | 1894 | 62 | return; | 1895 | | | 1896 | 65 | bfd_coff_swap_reloc_in (abfd, &dst, &n); | 1897 | 65 | if (bfd_seek (abfd, oldpos, 0) != 0) | 1898 | 0 | return; | 1899 | 65 | if (n.r_vaddr < 0x10000) | 1900 | 20 | { | 1901 | 20 | _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd); | 1902 | 20 | bfd_set_error (bfd_error_bad_value); | 1903 | 20 | return; | 1904 | 20 | } | 1905 | 45 | section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1; | 1906 | 45 | section->rel_filepos += relsz; | 1907 | 45 | } | 1908 | 3.13k | else if (hdr->s_nreloc == 0xffff) | 1909 | 0 | _bfd_error_handler | 1910 | 0 | (_("%pB: warning: claims to have 0xffff relocs, without overflow"), | 1911 | 0 | abfd); | 1912 | 3.26k | } |
pei-aarch64.c:coff_set_alignment_hook Line | Count | Source | 1828 | 1.73k | { | 1829 | 1.73k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; | 1830 | 1.73k | size_t amt; | 1831 | 1.73k | unsigned int alignment_power_const | 1832 | 1.73k | = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK; | 1833 | | | 1834 | 1.73k | switch (alignment_power_const) | 1835 | 1.73k | { | 1836 | 3 | case IMAGE_SCN_ALIGN_8192BYTES: | 1837 | 5 | case IMAGE_SCN_ALIGN_4096BYTES: | 1838 | 20 | case IMAGE_SCN_ALIGN_2048BYTES: | 1839 | 26 | case IMAGE_SCN_ALIGN_1024BYTES: | 1840 | 129 | case IMAGE_SCN_ALIGN_512BYTES: | 1841 | 134 | case IMAGE_SCN_ALIGN_256BYTES: | 1842 | 149 | case IMAGE_SCN_ALIGN_128BYTES: | 1843 | 159 | case IMAGE_SCN_ALIGN_64BYTES: | 1844 | 405 | case IMAGE_SCN_ALIGN_32BYTES: | 1845 | 408 | case IMAGE_SCN_ALIGN_16BYTES: | 1846 | 422 | case IMAGE_SCN_ALIGN_8BYTES: | 1847 | 432 | case IMAGE_SCN_ALIGN_4BYTES: | 1848 | 443 | case IMAGE_SCN_ALIGN_2BYTES: | 1849 | 459 | case IMAGE_SCN_ALIGN_1BYTES: | 1850 | 459 | section->alignment_power | 1851 | 459 | = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const); | 1852 | 459 | break; | 1853 | 1.28k | default: | 1854 | 1.28k | break; | 1855 | 1.73k | } | 1856 | | | 1857 | | /* In a PE image file, the s_paddr field holds the virtual size of a | 1858 | | section, while the s_size field holds the raw size. We also keep | 1859 | | the original section flag value, since not every bit can be | 1860 | | mapped onto a generic BFD section bit. */ | 1861 | 1.73k | if (coff_section_data (abfd, section) == NULL) | 1862 | 1.73k | { | 1863 | 1.73k | amt = sizeof (struct coff_section_tdata); | 1864 | 1.73k | section->used_by_bfd = bfd_zalloc (abfd, amt); | 1865 | 1.73k | if (section->used_by_bfd == NULL) | 1866 | | /* FIXME: Return error. */ | 1867 | 0 | abort (); | 1868 | 1.73k | } | 1869 | | | 1870 | 1.73k | if (pei_section_data (abfd, section) == NULL) | 1871 | 1.73k | { | 1872 | 1.73k | amt = sizeof (struct pei_section_tdata); | 1873 | 1.73k | coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt); | 1874 | 1.73k | if (coff_section_data (abfd, section)->tdata == NULL) | 1875 | | /* FIXME: Return error. */ | 1876 | 0 | abort (); | 1877 | 1.73k | } | 1878 | 1.73k | pei_section_data (abfd, section)->virt_size = hdr->s_paddr; | 1879 | 1.73k | pei_section_data (abfd, section)->pe_flags = hdr->s_flags; | 1880 | | | 1881 | 1.73k | section->lma = hdr->s_vaddr; | 1882 | | | 1883 | | /* Check for extended relocs. */ | 1884 | 1.73k | if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL) | 1885 | 103 | { | 1886 | 103 | struct external_reloc dst; | 1887 | 103 | struct internal_reloc n; | 1888 | 103 | file_ptr oldpos = bfd_tell (abfd); | 1889 | 103 | bfd_size_type relsz = bfd_coff_relsz (abfd); | 1890 | | | 1891 | 103 | if (bfd_seek (abfd, (file_ptr) hdr->s_relptr, 0) != 0) | 1892 | 0 | return; | 1893 | 103 | if (bfd_bread (& dst, relsz, abfd) != relsz) | 1894 | 57 | return; | 1895 | | | 1896 | 46 | bfd_coff_swap_reloc_in (abfd, &dst, &n); | 1897 | 46 | if (bfd_seek (abfd, oldpos, 0) != 0) | 1898 | 0 | return; | 1899 | 46 | if (n.r_vaddr < 0x10000) | 1900 | 13 | { | 1901 | 13 | _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd); | 1902 | 13 | bfd_set_error (bfd_error_bad_value); | 1903 | 13 | return; | 1904 | 13 | } | 1905 | 33 | section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1; | 1906 | 33 | section->rel_filepos += relsz; | 1907 | 33 | } | 1908 | 1.63k | else if (hdr->s_nreloc == 0xffff) | 1909 | 0 | _bfd_error_handler | 1910 | 0 | (_("%pB: warning: claims to have 0xffff relocs, without overflow"), | 1911 | 0 | abfd); | 1912 | 1.73k | } |
pe-aarch64.c:coff_set_alignment_hook Line | Count | Source | 1828 | 5.47k | { | 1829 | 5.47k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; | 1830 | 5.47k | size_t amt; | 1831 | 5.47k | unsigned int alignment_power_const | 1832 | 5.47k | = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK; | 1833 | | | 1834 | 5.47k | switch (alignment_power_const) | 1835 | 5.47k | { | 1836 | 12 | case IMAGE_SCN_ALIGN_8192BYTES: | 1837 | 23 | case IMAGE_SCN_ALIGN_4096BYTES: | 1838 | 38 | case IMAGE_SCN_ALIGN_2048BYTES: | 1839 | 41 | case IMAGE_SCN_ALIGN_1024BYTES: | 1840 | 57 | case IMAGE_SCN_ALIGN_512BYTES: | 1841 | 69 | case IMAGE_SCN_ALIGN_256BYTES: | 1842 | 168 | case IMAGE_SCN_ALIGN_128BYTES: | 1843 | 172 | case IMAGE_SCN_ALIGN_64BYTES: | 1844 | 448 | case IMAGE_SCN_ALIGN_32BYTES: | 1845 | 466 | case IMAGE_SCN_ALIGN_16BYTES: | 1846 | 475 | case IMAGE_SCN_ALIGN_8BYTES: | 1847 | 483 | case IMAGE_SCN_ALIGN_4BYTES: | 1848 | 506 | case IMAGE_SCN_ALIGN_2BYTES: | 1849 | 525 | case IMAGE_SCN_ALIGN_1BYTES: | 1850 | 525 | section->alignment_power | 1851 | 525 | = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const); | 1852 | 525 | break; | 1853 | 4.95k | default: | 1854 | 4.95k | break; | 1855 | 5.47k | } | 1856 | | | 1857 | | /* In a PE image file, the s_paddr field holds the virtual size of a | 1858 | | section, while the s_size field holds the raw size. We also keep | 1859 | | the original section flag value, since not every bit can be | 1860 | | mapped onto a generic BFD section bit. */ | 1861 | 5.47k | if (coff_section_data (abfd, section) == NULL) | 1862 | 5.47k | { | 1863 | 5.47k | amt = sizeof (struct coff_section_tdata); | 1864 | 5.47k | section->used_by_bfd = bfd_zalloc (abfd, amt); | 1865 | 5.47k | if (section->used_by_bfd == NULL) | 1866 | | /* FIXME: Return error. */ | 1867 | 0 | abort (); | 1868 | 5.47k | } | 1869 | | | 1870 | 5.47k | if (pei_section_data (abfd, section) == NULL) | 1871 | 5.47k | { | 1872 | 5.47k | amt = sizeof (struct pei_section_tdata); | 1873 | 5.47k | coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt); | 1874 | 5.47k | if (coff_section_data (abfd, section)->tdata == NULL) | 1875 | | /* FIXME: Return error. */ | 1876 | 0 | abort (); | 1877 | 5.47k | } | 1878 | 5.47k | pei_section_data (abfd, section)->virt_size = hdr->s_paddr; | 1879 | 5.47k | pei_section_data (abfd, section)->pe_flags = hdr->s_flags; | 1880 | | | 1881 | 5.47k | section->lma = hdr->s_vaddr; | 1882 | | | 1883 | | /* Check for extended relocs. */ | 1884 | 5.47k | if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL) | 1885 | 125 | { | 1886 | 125 | struct external_reloc dst; | 1887 | 125 | struct internal_reloc n; | 1888 | 125 | file_ptr oldpos = bfd_tell (abfd); | 1889 | 125 | bfd_size_type relsz = bfd_coff_relsz (abfd); | 1890 | | | 1891 | 125 | if (bfd_seek (abfd, (file_ptr) hdr->s_relptr, 0) != 0) | 1892 | 0 | return; | 1893 | 125 | if (bfd_bread (& dst, relsz, abfd) != relsz) | 1894 | 67 | return; | 1895 | | | 1896 | 58 | bfd_coff_swap_reloc_in (abfd, &dst, &n); | 1897 | 58 | if (bfd_seek (abfd, oldpos, 0) != 0) | 1898 | 0 | return; | 1899 | 58 | if (n.r_vaddr < 0x10000) | 1900 | 19 | { | 1901 | 19 | _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd); | 1902 | 19 | bfd_set_error (bfd_error_bad_value); | 1903 | 19 | return; | 1904 | 19 | } | 1905 | 39 | section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1; | 1906 | 39 | section->rel_filepos += relsz; | 1907 | 39 | } | 1908 | 5.35k | else if (hdr->s_nreloc == 0xffff) | 1909 | 15 | _bfd_error_handler | 1910 | 15 | (_("%pB: warning: claims to have 0xffff relocs, without overflow"), | 1911 | 15 | abfd); | 1912 | 5.47k | } |
pei-ia64.c:coff_set_alignment_hook Line | Count | Source | 1828 | 2.23k | { | 1829 | 2.23k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; | 1830 | 2.23k | size_t amt; | 1831 | 2.23k | unsigned int alignment_power_const | 1832 | 2.23k | = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK; | 1833 | | | 1834 | 2.23k | switch (alignment_power_const) | 1835 | 2.23k | { | 1836 | 15 | case IMAGE_SCN_ALIGN_8192BYTES: | 1837 | 19 | case IMAGE_SCN_ALIGN_4096BYTES: | 1838 | 334 | case IMAGE_SCN_ALIGN_2048BYTES: | 1839 | 335 | case IMAGE_SCN_ALIGN_1024BYTES: | 1840 | 344 | case IMAGE_SCN_ALIGN_512BYTES: | 1841 | 348 | case IMAGE_SCN_ALIGN_256BYTES: | 1842 | 353 | case IMAGE_SCN_ALIGN_128BYTES: | 1843 | 359 | case IMAGE_SCN_ALIGN_64BYTES: | 1844 | 389 | case IMAGE_SCN_ALIGN_32BYTES: | 1845 | 390 | case IMAGE_SCN_ALIGN_16BYTES: | 1846 | 409 | case IMAGE_SCN_ALIGN_8BYTES: | 1847 | 418 | case IMAGE_SCN_ALIGN_4BYTES: | 1848 | 641 | case IMAGE_SCN_ALIGN_2BYTES: | 1849 | 658 | case IMAGE_SCN_ALIGN_1BYTES: | 1850 | 658 | section->alignment_power | 1851 | 658 | = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const); | 1852 | 658 | break; | 1853 | 1.57k | default: | 1854 | 1.57k | break; | 1855 | 2.23k | } | 1856 | | | 1857 | | /* In a PE image file, the s_paddr field holds the virtual size of a | 1858 | | section, while the s_size field holds the raw size. We also keep | 1859 | | the original section flag value, since not every bit can be | 1860 | | mapped onto a generic BFD section bit. */ | 1861 | 2.23k | if (coff_section_data (abfd, section) == NULL) | 1862 | 2.23k | { | 1863 | 2.23k | amt = sizeof (struct coff_section_tdata); | 1864 | 2.23k | section->used_by_bfd = bfd_zalloc (abfd, amt); | 1865 | 2.23k | if (section->used_by_bfd == NULL) | 1866 | | /* FIXME: Return error. */ | 1867 | 0 | abort (); | 1868 | 2.23k | } | 1869 | | | 1870 | 2.23k | if (pei_section_data (abfd, section) == NULL) | 1871 | 2.23k | { | 1872 | 2.23k | amt = sizeof (struct pei_section_tdata); | 1873 | 2.23k | coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt); | 1874 | 2.23k | if (coff_section_data (abfd, section)->tdata == NULL) | 1875 | | /* FIXME: Return error. */ | 1876 | 0 | abort (); | 1877 | 2.23k | } | 1878 | 2.23k | pei_section_data (abfd, section)->virt_size = hdr->s_paddr; | 1879 | 2.23k | pei_section_data (abfd, section)->pe_flags = hdr->s_flags; | 1880 | | | 1881 | 2.23k | section->lma = hdr->s_vaddr; | 1882 | | | 1883 | | /* Check for extended relocs. */ | 1884 | 2.23k | if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL) | 1885 | 200 | { | 1886 | 200 | struct external_reloc dst; | 1887 | 200 | struct internal_reloc n; | 1888 | 200 | file_ptr oldpos = bfd_tell (abfd); | 1889 | 200 | bfd_size_type relsz = bfd_coff_relsz (abfd); | 1890 | | | 1891 | 200 | if (bfd_seek (abfd, (file_ptr) hdr->s_relptr, 0) != 0) | 1892 | 0 | return; | 1893 | 200 | if (bfd_bread (& dst, relsz, abfd) != relsz) | 1894 | 112 | return; | 1895 | | | 1896 | 88 | bfd_coff_swap_reloc_in (abfd, &dst, &n); | 1897 | 88 | if (bfd_seek (abfd, oldpos, 0) != 0) | 1898 | 0 | return; | 1899 | 88 | if (n.r_vaddr < 0x10000) | 1900 | 22 | { | 1901 | 22 | _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd); | 1902 | 22 | bfd_set_error (bfd_error_bad_value); | 1903 | 22 | return; | 1904 | 22 | } | 1905 | 66 | section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1; | 1906 | 66 | section->rel_filepos += relsz; | 1907 | 66 | } | 1908 | 2.03k | else if (hdr->s_nreloc == 0xffff) | 1909 | 0 | _bfd_error_handler | 1910 | 0 | (_("%pB: warning: claims to have 0xffff relocs, without overflow"), | 1911 | 0 | abfd); | 1912 | 2.23k | } |
pei-loongarch64.c:coff_set_alignment_hook Line | Count | Source | 1828 | 8.55k | { | 1829 | 8.55k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; | 1830 | 8.55k | size_t amt; | 1831 | 8.55k | unsigned int alignment_power_const | 1832 | 8.55k | = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK; | 1833 | | | 1834 | 8.55k | switch (alignment_power_const) | 1835 | 8.55k | { | 1836 | 76 | case IMAGE_SCN_ALIGN_8192BYTES: | 1837 | 77 | case IMAGE_SCN_ALIGN_4096BYTES: | 1838 | 85 | case IMAGE_SCN_ALIGN_2048BYTES: | 1839 | 88 | case IMAGE_SCN_ALIGN_1024BYTES: | 1840 | 163 | case IMAGE_SCN_ALIGN_512BYTES: | 1841 | 214 | case IMAGE_SCN_ALIGN_256BYTES: | 1842 | 320 | case IMAGE_SCN_ALIGN_128BYTES: | 1843 | 338 | case IMAGE_SCN_ALIGN_64BYTES: | 1844 | 6.64k | case IMAGE_SCN_ALIGN_32BYTES: | 1845 | 6.67k | case IMAGE_SCN_ALIGN_16BYTES: | 1846 | 6.68k | case IMAGE_SCN_ALIGN_8BYTES: | 1847 | 6.68k | case IMAGE_SCN_ALIGN_4BYTES: | 1848 | 6.72k | case IMAGE_SCN_ALIGN_2BYTES: | 1849 | 6.74k | case IMAGE_SCN_ALIGN_1BYTES: | 1850 | 6.74k | section->alignment_power | 1851 | 6.74k | = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const); | 1852 | 6.74k | break; | 1853 | 1.81k | default: | 1854 | 1.81k | break; | 1855 | 8.55k | } | 1856 | | | 1857 | | /* In a PE image file, the s_paddr field holds the virtual size of a | 1858 | | section, while the s_size field holds the raw size. We also keep | 1859 | | the original section flag value, since not every bit can be | 1860 | | mapped onto a generic BFD section bit. */ | 1861 | 8.55k | if (coff_section_data (abfd, section) == NULL) | 1862 | 8.55k | { | 1863 | 8.55k | amt = sizeof (struct coff_section_tdata); | 1864 | 8.55k | section->used_by_bfd = bfd_zalloc (abfd, amt); | 1865 | 8.55k | if (section->used_by_bfd == NULL) | 1866 | | /* FIXME: Return error. */ | 1867 | 0 | abort (); | 1868 | 8.55k | } | 1869 | | | 1870 | 8.55k | if (pei_section_data (abfd, section) == NULL) | 1871 | 8.55k | { | 1872 | 8.55k | amt = sizeof (struct pei_section_tdata); | 1873 | 8.55k | coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt); | 1874 | 8.55k | if (coff_section_data (abfd, section)->tdata == NULL) | 1875 | | /* FIXME: Return error. */ | 1876 | 0 | abort (); | 1877 | 8.55k | } | 1878 | 8.55k | pei_section_data (abfd, section)->virt_size = hdr->s_paddr; | 1879 | 8.55k | pei_section_data (abfd, section)->pe_flags = hdr->s_flags; | 1880 | | | 1881 | 8.55k | section->lma = hdr->s_vaddr; | 1882 | | | 1883 | | /* Check for extended relocs. */ | 1884 | 8.55k | if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL) | 1885 | 99 | { | 1886 | 99 | struct external_reloc dst; | 1887 | 99 | struct internal_reloc n; | 1888 | 99 | file_ptr oldpos = bfd_tell (abfd); | 1889 | 99 | bfd_size_type relsz = bfd_coff_relsz (abfd); | 1890 | | | 1891 | 99 | if (bfd_seek (abfd, (file_ptr) hdr->s_relptr, 0) != 0) | 1892 | 0 | return; | 1893 | 99 | if (bfd_bread (& dst, relsz, abfd) != relsz) | 1894 | 59 | return; | 1895 | | | 1896 | 40 | bfd_coff_swap_reloc_in (abfd, &dst, &n); | 1897 | 40 | if (bfd_seek (abfd, oldpos, 0) != 0) | 1898 | 0 | return; | 1899 | 40 | if (n.r_vaddr < 0x10000) | 1900 | 12 | { | 1901 | 12 | _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd); | 1902 | 12 | bfd_set_error (bfd_error_bad_value); | 1903 | 12 | return; | 1904 | 12 | } | 1905 | 28 | section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1; | 1906 | 28 | section->rel_filepos += relsz; | 1907 | 28 | } | 1908 | 8.45k | else if (hdr->s_nreloc == 0xffff) | 1909 | 0 | _bfd_error_handler | 1910 | 0 | (_("%pB: warning: claims to have 0xffff relocs, without overflow"), | 1911 | 0 | abfd); | 1912 | 8.55k | } |
pe-arm-wince.c:coff_set_alignment_hook Line | Count | Source | 1828 | 1.19k | { | 1829 | 1.19k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; | 1830 | 1.19k | size_t amt; | 1831 | 1.19k | unsigned int alignment_power_const | 1832 | 1.19k | = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK; | 1833 | | | 1834 | 1.19k | switch (alignment_power_const) | 1835 | 1.19k | { | 1836 | 154 | case IMAGE_SCN_ALIGN_8192BYTES: | 1837 | 155 | case IMAGE_SCN_ALIGN_4096BYTES: | 1838 | 202 | case IMAGE_SCN_ALIGN_2048BYTES: | 1839 | 204 | case IMAGE_SCN_ALIGN_1024BYTES: | 1840 | 211 | case IMAGE_SCN_ALIGN_512BYTES: | 1841 | 214 | case IMAGE_SCN_ALIGN_256BYTES: | 1842 | 224 | case IMAGE_SCN_ALIGN_128BYTES: | 1843 | 229 | case IMAGE_SCN_ALIGN_64BYTES: | 1844 | 433 | case IMAGE_SCN_ALIGN_32BYTES: | 1845 | 441 | case IMAGE_SCN_ALIGN_16BYTES: | 1846 | 447 | case IMAGE_SCN_ALIGN_8BYTES: | 1847 | 467 | case IMAGE_SCN_ALIGN_4BYTES: | 1848 | 508 | case IMAGE_SCN_ALIGN_2BYTES: | 1849 | 518 | case IMAGE_SCN_ALIGN_1BYTES: | 1850 | 518 | section->alignment_power | 1851 | 518 | = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const); | 1852 | 518 | break; | 1853 | 675 | default: | 1854 | 675 | break; | 1855 | 1.19k | } | 1856 | | | 1857 | | /* In a PE image file, the s_paddr field holds the virtual size of a | 1858 | | section, while the s_size field holds the raw size. We also keep | 1859 | | the original section flag value, since not every bit can be | 1860 | | mapped onto a generic BFD section bit. */ | 1861 | 1.19k | if (coff_section_data (abfd, section) == NULL) | 1862 | 1.19k | { | 1863 | 1.19k | amt = sizeof (struct coff_section_tdata); | 1864 | 1.19k | section->used_by_bfd = bfd_zalloc (abfd, amt); | 1865 | 1.19k | if (section->used_by_bfd == NULL) | 1866 | | /* FIXME: Return error. */ | 1867 | 0 | abort (); | 1868 | 1.19k | } | 1869 | | | 1870 | 1.19k | if (pei_section_data (abfd, section) == NULL) | 1871 | 1.19k | { | 1872 | 1.19k | amt = sizeof (struct pei_section_tdata); | 1873 | 1.19k | coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt); | 1874 | 1.19k | if (coff_section_data (abfd, section)->tdata == NULL) | 1875 | | /* FIXME: Return error. */ | 1876 | 0 | abort (); | 1877 | 1.19k | } | 1878 | 1.19k | pei_section_data (abfd, section)->virt_size = hdr->s_paddr; | 1879 | 1.19k | pei_section_data (abfd, section)->pe_flags = hdr->s_flags; | 1880 | | | 1881 | 1.19k | section->lma = hdr->s_vaddr; | 1882 | | | 1883 | | /* Check for extended relocs. */ | 1884 | 1.19k | if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL) | 1885 | 133 | { | 1886 | 133 | struct external_reloc dst; | 1887 | 133 | struct internal_reloc n; | 1888 | 133 | file_ptr oldpos = bfd_tell (abfd); | 1889 | 133 | bfd_size_type relsz = bfd_coff_relsz (abfd); | 1890 | | | 1891 | 133 | if (bfd_seek (abfd, (file_ptr) hdr->s_relptr, 0) != 0) | 1892 | 0 | return; | 1893 | 133 | if (bfd_bread (& dst, relsz, abfd) != relsz) | 1894 | 80 | return; | 1895 | | | 1896 | 53 | bfd_coff_swap_reloc_in (abfd, &dst, &n); | 1897 | 53 | if (bfd_seek (abfd, oldpos, 0) != 0) | 1898 | 0 | return; | 1899 | 53 | if (n.r_vaddr < 0x10000) | 1900 | 19 | { | 1901 | 19 | _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd); | 1902 | 19 | bfd_set_error (bfd_error_bad_value); | 1903 | 19 | return; | 1904 | 19 | } | 1905 | 34 | section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1; | 1906 | 34 | section->rel_filepos += relsz; | 1907 | 34 | } | 1908 | 1.06k | else if (hdr->s_nreloc == 0xffff) | 1909 | 21 | _bfd_error_handler | 1910 | 21 | (_("%pB: warning: claims to have 0xffff relocs, without overflow"), | 1911 | 21 | abfd); | 1912 | 1.19k | } |
pe-arm.c:coff_set_alignment_hook Line | Count | Source | 1828 | 1.19k | { | 1829 | 1.19k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; | 1830 | 1.19k | size_t amt; | 1831 | 1.19k | unsigned int alignment_power_const | 1832 | 1.19k | = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK; | 1833 | | | 1834 | 1.19k | switch (alignment_power_const) | 1835 | 1.19k | { | 1836 | 154 | case IMAGE_SCN_ALIGN_8192BYTES: | 1837 | 155 | case IMAGE_SCN_ALIGN_4096BYTES: | 1838 | 202 | case IMAGE_SCN_ALIGN_2048BYTES: | 1839 | 204 | case IMAGE_SCN_ALIGN_1024BYTES: | 1840 | 211 | case IMAGE_SCN_ALIGN_512BYTES: | 1841 | 214 | case IMAGE_SCN_ALIGN_256BYTES: | 1842 | 224 | case IMAGE_SCN_ALIGN_128BYTES: | 1843 | 229 | case IMAGE_SCN_ALIGN_64BYTES: | 1844 | 433 | case IMAGE_SCN_ALIGN_32BYTES: | 1845 | 441 | case IMAGE_SCN_ALIGN_16BYTES: | 1846 | 447 | case IMAGE_SCN_ALIGN_8BYTES: | 1847 | 467 | case IMAGE_SCN_ALIGN_4BYTES: | 1848 | 508 | case IMAGE_SCN_ALIGN_2BYTES: | 1849 | 518 | case IMAGE_SCN_ALIGN_1BYTES: | 1850 | 518 | section->alignment_power | 1851 | 518 | = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const); | 1852 | 518 | break; | 1853 | 675 | default: | 1854 | 675 | break; | 1855 | 1.19k | } | 1856 | | | 1857 | | /* In a PE image file, the s_paddr field holds the virtual size of a | 1858 | | section, while the s_size field holds the raw size. We also keep | 1859 | | the original section flag value, since not every bit can be | 1860 | | mapped onto a generic BFD section bit. */ | 1861 | 1.19k | if (coff_section_data (abfd, section) == NULL) | 1862 | 1.19k | { | 1863 | 1.19k | amt = sizeof (struct coff_section_tdata); | 1864 | 1.19k | section->used_by_bfd = bfd_zalloc (abfd, amt); | 1865 | 1.19k | if (section->used_by_bfd == NULL) | 1866 | | /* FIXME: Return error. */ | 1867 | 0 | abort (); | 1868 | 1.19k | } | 1869 | | | 1870 | 1.19k | if (pei_section_data (abfd, section) == NULL) | 1871 | 1.19k | { | 1872 | 1.19k | amt = sizeof (struct pei_section_tdata); | 1873 | 1.19k | coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt); | 1874 | 1.19k | if (coff_section_data (abfd, section)->tdata == NULL) | 1875 | | /* FIXME: Return error. */ | 1876 | 0 | abort (); | 1877 | 1.19k | } | 1878 | 1.19k | pei_section_data (abfd, section)->virt_size = hdr->s_paddr; | 1879 | 1.19k | pei_section_data (abfd, section)->pe_flags = hdr->s_flags; | 1880 | | | 1881 | 1.19k | section->lma = hdr->s_vaddr; | 1882 | | | 1883 | | /* Check for extended relocs. */ | 1884 | 1.19k | if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL) | 1885 | 133 | { | 1886 | 133 | struct external_reloc dst; | 1887 | 133 | struct internal_reloc n; | 1888 | 133 | file_ptr oldpos = bfd_tell (abfd); | 1889 | 133 | bfd_size_type relsz = bfd_coff_relsz (abfd); | 1890 | | | 1891 | 133 | if (bfd_seek (abfd, (file_ptr) hdr->s_relptr, 0) != 0) | 1892 | 0 | return; | 1893 | 133 | if (bfd_bread (& dst, relsz, abfd) != relsz) | 1894 | 80 | return; | 1895 | | | 1896 | 53 | bfd_coff_swap_reloc_in (abfd, &dst, &n); | 1897 | 53 | if (bfd_seek (abfd, oldpos, 0) != 0) | 1898 | 0 | return; | 1899 | 53 | if (n.r_vaddr < 0x10000) | 1900 | 19 | { | 1901 | 19 | _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd); | 1902 | 19 | bfd_set_error (bfd_error_bad_value); | 1903 | 19 | return; | 1904 | 19 | } | 1905 | 34 | section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1; | 1906 | 34 | section->rel_filepos += relsz; | 1907 | 34 | } | 1908 | 1.06k | else if (hdr->s_nreloc == 0xffff) | 1909 | 21 | _bfd_error_handler | 1910 | 21 | (_("%pB: warning: claims to have 0xffff relocs, without overflow"), | 1911 | 21 | abfd); | 1912 | 1.19k | } |
pe-i386.c:coff_set_alignment_hook Line | Count | Source | 1828 | 7.12k | { | 1829 | 7.12k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; | 1830 | 7.12k | size_t amt; | 1831 | 7.12k | unsigned int alignment_power_const | 1832 | 7.12k | = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK; | 1833 | | | 1834 | 7.12k | switch (alignment_power_const) | 1835 | 7.12k | { | 1836 | 2.95k | case IMAGE_SCN_ALIGN_8192BYTES: | 1837 | 2.96k | case IMAGE_SCN_ALIGN_4096BYTES: | 1838 | 3.01k | case IMAGE_SCN_ALIGN_2048BYTES: | 1839 | 3.02k | case IMAGE_SCN_ALIGN_1024BYTES: | 1840 | 3.07k | case IMAGE_SCN_ALIGN_512BYTES: | 1841 | 3.08k | case IMAGE_SCN_ALIGN_256BYTES: | 1842 | 3.12k | case IMAGE_SCN_ALIGN_128BYTES: | 1843 | 3.17k | case IMAGE_SCN_ALIGN_64BYTES: | 1844 | 3.64k | case IMAGE_SCN_ALIGN_32BYTES: | 1845 | 3.67k | case IMAGE_SCN_ALIGN_16BYTES: | 1846 | 3.70k | case IMAGE_SCN_ALIGN_8BYTES: | 1847 | 3.73k | case IMAGE_SCN_ALIGN_4BYTES: | 1848 | 3.78k | case IMAGE_SCN_ALIGN_2BYTES: | 1849 | 3.98k | case IMAGE_SCN_ALIGN_1BYTES: | 1850 | 3.98k | section->alignment_power | 1851 | 3.98k | = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const); | 1852 | 3.98k | break; | 1853 | 3.14k | default: | 1854 | 3.14k | break; | 1855 | 7.12k | } | 1856 | | | 1857 | | /* In a PE image file, the s_paddr field holds the virtual size of a | 1858 | | section, while the s_size field holds the raw size. We also keep | 1859 | | the original section flag value, since not every bit can be | 1860 | | mapped onto a generic BFD section bit. */ | 1861 | 7.12k | if (coff_section_data (abfd, section) == NULL) | 1862 | 7.12k | { | 1863 | 7.12k | amt = sizeof (struct coff_section_tdata); | 1864 | 7.12k | section->used_by_bfd = bfd_zalloc (abfd, amt); | 1865 | 7.12k | if (section->used_by_bfd == NULL) | 1866 | | /* FIXME: Return error. */ | 1867 | 0 | abort (); | 1868 | 7.12k | } | 1869 | | | 1870 | 7.12k | if (pei_section_data (abfd, section) == NULL) | 1871 | 7.12k | { | 1872 | 7.12k | amt = sizeof (struct pei_section_tdata); | 1873 | 7.12k | coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt); | 1874 | 7.12k | if (coff_section_data (abfd, section)->tdata == NULL) | 1875 | | /* FIXME: Return error. */ | 1876 | 0 | abort (); | 1877 | 7.12k | } | 1878 | 7.12k | pei_section_data (abfd, section)->virt_size = hdr->s_paddr; | 1879 | 7.12k | pei_section_data (abfd, section)->pe_flags = hdr->s_flags; | 1880 | | | 1881 | 7.12k | section->lma = hdr->s_vaddr; | 1882 | | | 1883 | | /* Check for extended relocs. */ | 1884 | 7.12k | if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL) | 1885 | 350 | { | 1886 | 350 | struct external_reloc dst; | 1887 | 350 | struct internal_reloc n; | 1888 | 350 | file_ptr oldpos = bfd_tell (abfd); | 1889 | 350 | bfd_size_type relsz = bfd_coff_relsz (abfd); | 1890 | | | 1891 | 350 | if (bfd_seek (abfd, (file_ptr) hdr->s_relptr, 0) != 0) | 1892 | 0 | return; | 1893 | 350 | if (bfd_bread (& dst, relsz, abfd) != relsz) | 1894 | 243 | return; | 1895 | | | 1896 | 107 | bfd_coff_swap_reloc_in (abfd, &dst, &n); | 1897 | 107 | if (bfd_seek (abfd, oldpos, 0) != 0) | 1898 | 0 | return; | 1899 | 107 | if (n.r_vaddr < 0x10000) | 1900 | 41 | { | 1901 | 41 | _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd); | 1902 | 41 | bfd_set_error (bfd_error_bad_value); | 1903 | 41 | return; | 1904 | 41 | } | 1905 | 66 | section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1; | 1906 | 66 | section->rel_filepos += relsz; | 1907 | 66 | } | 1908 | 6.77k | else if (hdr->s_nreloc == 0xffff) | 1909 | 48 | _bfd_error_handler | 1910 | 48 | (_("%pB: warning: claims to have 0xffff relocs, without overflow"), | 1911 | 48 | abfd); | 1912 | 7.12k | } |
pe-mcore.c:coff_set_alignment_hook Line | Count | Source | 1828 | 3.32k | { | 1829 | 3.32k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; | 1830 | 3.32k | size_t amt; | 1831 | 3.32k | unsigned int alignment_power_const | 1832 | 3.32k | = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK; | 1833 | | | 1834 | 3.32k | switch (alignment_power_const) | 1835 | 3.32k | { | 1836 | 238 | case IMAGE_SCN_ALIGN_8192BYTES: | 1837 | 240 | case IMAGE_SCN_ALIGN_4096BYTES: | 1838 | 269 | case IMAGE_SCN_ALIGN_2048BYTES: | 1839 | 271 | case IMAGE_SCN_ALIGN_1024BYTES: | 1840 | 287 | case IMAGE_SCN_ALIGN_512BYTES: | 1841 | 305 | case IMAGE_SCN_ALIGN_256BYTES: | 1842 | 336 | case IMAGE_SCN_ALIGN_128BYTES: | 1843 | 341 | case IMAGE_SCN_ALIGN_64BYTES: | 1844 | 402 | case IMAGE_SCN_ALIGN_32BYTES: | 1845 | 406 | case IMAGE_SCN_ALIGN_16BYTES: | 1846 | 718 | case IMAGE_SCN_ALIGN_8BYTES: | 1847 | 737 | case IMAGE_SCN_ALIGN_4BYTES: | 1848 | 768 | case IMAGE_SCN_ALIGN_2BYTES: | 1849 | 778 | case IMAGE_SCN_ALIGN_1BYTES: | 1850 | 778 | section->alignment_power | 1851 | 778 | = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const); | 1852 | 778 | break; | 1853 | 2.54k | default: | 1854 | 2.54k | break; | 1855 | 3.32k | } | 1856 | | | 1857 | | /* In a PE image file, the s_paddr field holds the virtual size of a | 1858 | | section, while the s_size field holds the raw size. We also keep | 1859 | | the original section flag value, since not every bit can be | 1860 | | mapped onto a generic BFD section bit. */ | 1861 | 3.32k | if (coff_section_data (abfd, section) == NULL) | 1862 | 3.32k | { | 1863 | 3.32k | amt = sizeof (struct coff_section_tdata); | 1864 | 3.32k | section->used_by_bfd = bfd_zalloc (abfd, amt); | 1865 | 3.32k | if (section->used_by_bfd == NULL) | 1866 | | /* FIXME: Return error. */ | 1867 | 0 | abort (); | 1868 | 3.32k | } | 1869 | | | 1870 | 3.32k | if (pei_section_data (abfd, section) == NULL) | 1871 | 3.32k | { | 1872 | 3.32k | amt = sizeof (struct pei_section_tdata); | 1873 | 3.32k | coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt); | 1874 | 3.32k | if (coff_section_data (abfd, section)->tdata == NULL) | 1875 | | /* FIXME: Return error. */ | 1876 | 0 | abort (); | 1877 | 3.32k | } | 1878 | 3.32k | pei_section_data (abfd, section)->virt_size = hdr->s_paddr; | 1879 | 3.32k | pei_section_data (abfd, section)->pe_flags = hdr->s_flags; | 1880 | | | 1881 | 3.32k | section->lma = hdr->s_vaddr; | 1882 | | | 1883 | | /* Check for extended relocs. */ | 1884 | 3.32k | if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL) | 1885 | 141 | { | 1886 | 141 | struct external_reloc dst; | 1887 | 141 | struct internal_reloc n; | 1888 | 141 | file_ptr oldpos = bfd_tell (abfd); | 1889 | 141 | bfd_size_type relsz = bfd_coff_relsz (abfd); | 1890 | | | 1891 | 141 | if (bfd_seek (abfd, (file_ptr) hdr->s_relptr, 0) != 0) | 1892 | 0 | return; | 1893 | 141 | if (bfd_bread (& dst, relsz, abfd) != relsz) | 1894 | 80 | return; | 1895 | | | 1896 | 61 | bfd_coff_swap_reloc_in (abfd, &dst, &n); | 1897 | 61 | if (bfd_seek (abfd, oldpos, 0) != 0) | 1898 | 0 | return; | 1899 | 61 | if (n.r_vaddr < 0x10000) | 1900 | 14 | { | 1901 | 14 | _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd); | 1902 | 14 | bfd_set_error (bfd_error_bad_value); | 1903 | 14 | return; | 1904 | 14 | } | 1905 | 47 | section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1; | 1906 | 47 | section->rel_filepos += relsz; | 1907 | 47 | } | 1908 | 3.18k | else if (hdr->s_nreloc == 0xffff) | 1909 | 32 | _bfd_error_handler | 1910 | 32 | (_("%pB: warning: claims to have 0xffff relocs, without overflow"), | 1911 | 32 | abfd); | 1912 | 3.32k | } |
pe-sh.c:coff_set_alignment_hook Line | Count | Source | 1828 | 2.57k | { | 1829 | 2.57k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; | 1830 | 2.57k | size_t amt; | 1831 | 2.57k | unsigned int alignment_power_const | 1832 | 2.57k | = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK; | 1833 | | | 1834 | 2.57k | switch (alignment_power_const) | 1835 | 2.57k | { | 1836 | 17 | case IMAGE_SCN_ALIGN_8192BYTES: | 1837 | 26 | case IMAGE_SCN_ALIGN_4096BYTES: | 1838 | 46 | case IMAGE_SCN_ALIGN_2048BYTES: | 1839 | 52 | case IMAGE_SCN_ALIGN_1024BYTES: | 1840 | 107 | case IMAGE_SCN_ALIGN_512BYTES: | 1841 | 112 | case IMAGE_SCN_ALIGN_256BYTES: | 1842 | 115 | case IMAGE_SCN_ALIGN_128BYTES: | 1843 | 125 | case IMAGE_SCN_ALIGN_64BYTES: | 1844 | 881 | case IMAGE_SCN_ALIGN_32BYTES: | 1845 | 892 | case IMAGE_SCN_ALIGN_16BYTES: | 1846 | 911 | case IMAGE_SCN_ALIGN_8BYTES: | 1847 | 925 | case IMAGE_SCN_ALIGN_4BYTES: | 1848 | 952 | case IMAGE_SCN_ALIGN_2BYTES: | 1849 | 1.01k | case IMAGE_SCN_ALIGN_1BYTES: | 1850 | 1.01k | section->alignment_power | 1851 | 1.01k | = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const); | 1852 | 1.01k | break; | 1853 | 1.56k | default: | 1854 | 1.56k | break; | 1855 | 2.57k | } | 1856 | | | 1857 | | /* In a PE image file, the s_paddr field holds the virtual size of a | 1858 | | section, while the s_size field holds the raw size. We also keep | 1859 | | the original section flag value, since not every bit can be | 1860 | | mapped onto a generic BFD section bit. */ | 1861 | 2.57k | if (coff_section_data (abfd, section) == NULL) | 1862 | 2.57k | { | 1863 | 2.57k | amt = sizeof (struct coff_section_tdata); | 1864 | 2.57k | section->used_by_bfd = bfd_zalloc (abfd, amt); | 1865 | 2.57k | if (section->used_by_bfd == NULL) | 1866 | | /* FIXME: Return error. */ | 1867 | 0 | abort (); | 1868 | 2.57k | } | 1869 | | | 1870 | 2.57k | if (pei_section_data (abfd, section) == NULL) | 1871 | 2.57k | { | 1872 | 2.57k | amt = sizeof (struct pei_section_tdata); | 1873 | 2.57k | coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt); | 1874 | 2.57k | if (coff_section_data (abfd, section)->tdata == NULL) | 1875 | | /* FIXME: Return error. */ | 1876 | 0 | abort (); | 1877 | 2.57k | } | 1878 | 2.57k | pei_section_data (abfd, section)->virt_size = hdr->s_paddr; | 1879 | 2.57k | pei_section_data (abfd, section)->pe_flags = hdr->s_flags; | 1880 | | | 1881 | 2.57k | section->lma = hdr->s_vaddr; | 1882 | | | 1883 | | /* Check for extended relocs. */ | 1884 | 2.57k | if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL) | 1885 | 262 | { | 1886 | 262 | struct external_reloc dst; | 1887 | 262 | struct internal_reloc n; | 1888 | 262 | file_ptr oldpos = bfd_tell (abfd); | 1889 | 262 | bfd_size_type relsz = bfd_coff_relsz (abfd); | 1890 | | | 1891 | 262 | if (bfd_seek (abfd, (file_ptr) hdr->s_relptr, 0) != 0) | 1892 | 0 | return; | 1893 | 262 | if (bfd_bread (& dst, relsz, abfd) != relsz) | 1894 | 125 | return; | 1895 | | | 1896 | 137 | bfd_coff_swap_reloc_in (abfd, &dst, &n); | 1897 | 137 | if (bfd_seek (abfd, oldpos, 0) != 0) | 1898 | 0 | return; | 1899 | 137 | if (n.r_vaddr < 0x10000) | 1900 | 62 | { | 1901 | 62 | _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd); | 1902 | 62 | bfd_set_error (bfd_error_bad_value); | 1903 | 62 | return; | 1904 | 62 | } | 1905 | 75 | section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1; | 1906 | 75 | section->rel_filepos += relsz; | 1907 | 75 | } | 1908 | 2.31k | else if (hdr->s_nreloc == 0xffff) | 1909 | 11 | _bfd_error_handler | 1910 | 11 | (_("%pB: warning: claims to have 0xffff relocs, without overflow"), | 1911 | 11 | abfd); | 1912 | 2.57k | } |
pei-arm-wince.c:coff_set_alignment_hook Line | Count | Source | 1828 | 2.09k | { | 1829 | 2.09k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; | 1830 | 2.09k | size_t amt; | 1831 | 2.09k | unsigned int alignment_power_const | 1832 | 2.09k | = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK; | 1833 | | | 1834 | 2.09k | switch (alignment_power_const) | 1835 | 2.09k | { | 1836 | 15 | case IMAGE_SCN_ALIGN_8192BYTES: | 1837 | 18 | case IMAGE_SCN_ALIGN_4096BYTES: | 1838 | 405 | case IMAGE_SCN_ALIGN_2048BYTES: | 1839 | 412 | case IMAGE_SCN_ALIGN_1024BYTES: | 1840 | 536 | case IMAGE_SCN_ALIGN_512BYTES: | 1841 | 558 | case IMAGE_SCN_ALIGN_256BYTES: | 1842 | 569 | case IMAGE_SCN_ALIGN_128BYTES: | 1843 | 585 | case IMAGE_SCN_ALIGN_64BYTES: | 1844 | 888 | case IMAGE_SCN_ALIGN_32BYTES: | 1845 | 895 | case IMAGE_SCN_ALIGN_16BYTES: | 1846 | 908 | case IMAGE_SCN_ALIGN_8BYTES: | 1847 | 918 | case IMAGE_SCN_ALIGN_4BYTES: | 1848 | 1.00k | case IMAGE_SCN_ALIGN_2BYTES: | 1849 | 1.03k | case IMAGE_SCN_ALIGN_1BYTES: | 1850 | 1.03k | section->alignment_power | 1851 | 1.03k | = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const); | 1852 | 1.03k | break; | 1853 | 1.05k | default: | 1854 | 1.05k | break; | 1855 | 2.09k | } | 1856 | | | 1857 | | /* In a PE image file, the s_paddr field holds the virtual size of a | 1858 | | section, while the s_size field holds the raw size. We also keep | 1859 | | the original section flag value, since not every bit can be | 1860 | | mapped onto a generic BFD section bit. */ | 1861 | 2.09k | if (coff_section_data (abfd, section) == NULL) | 1862 | 2.09k | { | 1863 | 2.09k | amt = sizeof (struct coff_section_tdata); | 1864 | 2.09k | section->used_by_bfd = bfd_zalloc (abfd, amt); | 1865 | 2.09k | if (section->used_by_bfd == NULL) | 1866 | | /* FIXME: Return error. */ | 1867 | 0 | abort (); | 1868 | 2.09k | } | 1869 | | | 1870 | 2.09k | if (pei_section_data (abfd, section) == NULL) | 1871 | 2.09k | { | 1872 | 2.09k | amt = sizeof (struct pei_section_tdata); | 1873 | 2.09k | coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt); | 1874 | 2.09k | if (coff_section_data (abfd, section)->tdata == NULL) | 1875 | | /* FIXME: Return error. */ | 1876 | 0 | abort (); | 1877 | 2.09k | } | 1878 | 2.09k | pei_section_data (abfd, section)->virt_size = hdr->s_paddr; | 1879 | 2.09k | pei_section_data (abfd, section)->pe_flags = hdr->s_flags; | 1880 | | | 1881 | 2.09k | section->lma = hdr->s_vaddr; | 1882 | | | 1883 | | /* Check for extended relocs. */ | 1884 | 2.09k | if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL) | 1885 | 135 | { | 1886 | 135 | struct external_reloc dst; | 1887 | 135 | struct internal_reloc n; | 1888 | 135 | file_ptr oldpos = bfd_tell (abfd); | 1889 | 135 | bfd_size_type relsz = bfd_coff_relsz (abfd); | 1890 | | | 1891 | 135 | if (bfd_seek (abfd, (file_ptr) hdr->s_relptr, 0) != 0) | 1892 | 0 | return; | 1893 | 135 | if (bfd_bread (& dst, relsz, abfd) != relsz) | 1894 | 67 | return; | 1895 | | | 1896 | 68 | bfd_coff_swap_reloc_in (abfd, &dst, &n); | 1897 | 68 | if (bfd_seek (abfd, oldpos, 0) != 0) | 1898 | 0 | return; | 1899 | 68 | if (n.r_vaddr < 0x10000) | 1900 | 6 | { | 1901 | 6 | _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd); | 1902 | 6 | bfd_set_error (bfd_error_bad_value); | 1903 | 6 | return; | 1904 | 6 | } | 1905 | 62 | section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1; | 1906 | 62 | section->rel_filepos += relsz; | 1907 | 62 | } | 1908 | 1.95k | else if (hdr->s_nreloc == 0xffff) | 1909 | 0 | _bfd_error_handler | 1910 | 0 | (_("%pB: warning: claims to have 0xffff relocs, without overflow"), | 1911 | 0 | abfd); | 1912 | 2.09k | } |
pei-arm.c:coff_set_alignment_hook Line | Count | Source | 1828 | 2.74k | { | 1829 | 2.74k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; | 1830 | 2.74k | size_t amt; | 1831 | 2.74k | unsigned int alignment_power_const | 1832 | 2.74k | = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK; | 1833 | | | 1834 | 2.74k | switch (alignment_power_const) | 1835 | 2.74k | { | 1836 | 15 | case IMAGE_SCN_ALIGN_8192BYTES: | 1837 | 22 | case IMAGE_SCN_ALIGN_4096BYTES: | 1838 | 411 | case IMAGE_SCN_ALIGN_2048BYTES: | 1839 | 422 | case IMAGE_SCN_ALIGN_1024BYTES: | 1840 | 581 | case IMAGE_SCN_ALIGN_512BYTES: | 1841 | 617 | case IMAGE_SCN_ALIGN_256BYTES: | 1842 | 664 | case IMAGE_SCN_ALIGN_128BYTES: | 1843 | 684 | case IMAGE_SCN_ALIGN_64BYTES: | 1844 | 1.02k | case IMAGE_SCN_ALIGN_32BYTES: | 1845 | 1.05k | case IMAGE_SCN_ALIGN_16BYTES: | 1846 | 1.07k | case IMAGE_SCN_ALIGN_8BYTES: | 1847 | 1.08k | case IMAGE_SCN_ALIGN_4BYTES: | 1848 | 1.17k | case IMAGE_SCN_ALIGN_2BYTES: | 1849 | 1.20k | case IMAGE_SCN_ALIGN_1BYTES: | 1850 | 1.20k | section->alignment_power | 1851 | 1.20k | = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const); | 1852 | 1.20k | break; | 1853 | 1.53k | default: | 1854 | 1.53k | break; | 1855 | 2.74k | } | 1856 | | | 1857 | | /* In a PE image file, the s_paddr field holds the virtual size of a | 1858 | | section, while the s_size field holds the raw size. We also keep | 1859 | | the original section flag value, since not every bit can be | 1860 | | mapped onto a generic BFD section bit. */ | 1861 | 2.74k | if (coff_section_data (abfd, section) == NULL) | 1862 | 2.74k | { | 1863 | 2.74k | amt = sizeof (struct coff_section_tdata); | 1864 | 2.74k | section->used_by_bfd = bfd_zalloc (abfd, amt); | 1865 | 2.74k | if (section->used_by_bfd == NULL) | 1866 | | /* FIXME: Return error. */ | 1867 | 0 | abort (); | 1868 | 2.74k | } | 1869 | | | 1870 | 2.74k | if (pei_section_data (abfd, section) == NULL) | 1871 | 2.74k | { | 1872 | 2.74k | amt = sizeof (struct pei_section_tdata); | 1873 | 2.74k | coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt); | 1874 | 2.74k | if (coff_section_data (abfd, section)->tdata == NULL) | 1875 | | /* FIXME: Return error. */ | 1876 | 0 | abort (); | 1877 | 2.74k | } | 1878 | 2.74k | pei_section_data (abfd, section)->virt_size = hdr->s_paddr; | 1879 | 2.74k | pei_section_data (abfd, section)->pe_flags = hdr->s_flags; | 1880 | | | 1881 | 2.74k | section->lma = hdr->s_vaddr; | 1882 | | | 1883 | | /* Check for extended relocs. */ | 1884 | 2.74k | if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL) | 1885 | 233 | { | 1886 | 233 | struct external_reloc dst; | 1887 | 233 | struct internal_reloc n; | 1888 | 233 | file_ptr oldpos = bfd_tell (abfd); | 1889 | 233 | bfd_size_type relsz = bfd_coff_relsz (abfd); | 1890 | | | 1891 | 233 | if (bfd_seek (abfd, (file_ptr) hdr->s_relptr, 0) != 0) | 1892 | 0 | return; | 1893 | 233 | if (bfd_bread (& dst, relsz, abfd) != relsz) | 1894 | 139 | return; | 1895 | | | 1896 | 94 | bfd_coff_swap_reloc_in (abfd, &dst, &n); | 1897 | 94 | if (bfd_seek (abfd, oldpos, 0) != 0) | 1898 | 0 | return; | 1899 | 94 | if (n.r_vaddr < 0x10000) | 1900 | 14 | { | 1901 | 14 | _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd); | 1902 | 14 | bfd_set_error (bfd_error_bad_value); | 1903 | 14 | return; | 1904 | 14 | } | 1905 | 80 | section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1; | 1906 | 80 | section->rel_filepos += relsz; | 1907 | 80 | } | 1908 | 2.50k | else if (hdr->s_nreloc == 0xffff) | 1909 | 0 | _bfd_error_handler | 1910 | 0 | (_("%pB: warning: claims to have 0xffff relocs, without overflow"), | 1911 | 0 | abfd); | 1912 | 2.74k | } |
pei-mcore.c:coff_set_alignment_hook Line | Count | Source | 1828 | 3.55k | { | 1829 | 3.55k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; | 1830 | 3.55k | size_t amt; | 1831 | 3.55k | unsigned int alignment_power_const | 1832 | 3.55k | = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK; | 1833 | | | 1834 | 3.55k | switch (alignment_power_const) | 1835 | 3.55k | { | 1836 | 759 | case IMAGE_SCN_ALIGN_8192BYTES: | 1837 | 762 | case IMAGE_SCN_ALIGN_4096BYTES: | 1838 | 834 | case IMAGE_SCN_ALIGN_2048BYTES: | 1839 | 838 | case IMAGE_SCN_ALIGN_1024BYTES: | 1840 | 841 | case IMAGE_SCN_ALIGN_512BYTES: | 1841 | 877 | case IMAGE_SCN_ALIGN_256BYTES: | 1842 | 893 | case IMAGE_SCN_ALIGN_128BYTES: | 1843 | 895 | case IMAGE_SCN_ALIGN_64BYTES: | 1844 | 988 | case IMAGE_SCN_ALIGN_32BYTES: | 1845 | 992 | case IMAGE_SCN_ALIGN_16BYTES: | 1846 | 999 | case IMAGE_SCN_ALIGN_8BYTES: | 1847 | 1.00k | case IMAGE_SCN_ALIGN_4BYTES: | 1848 | 1.02k | case IMAGE_SCN_ALIGN_2BYTES: | 1849 | 1.02k | case IMAGE_SCN_ALIGN_1BYTES: | 1850 | 1.02k | section->alignment_power | 1851 | 1.02k | = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const); | 1852 | 1.02k | break; | 1853 | 2.52k | default: | 1854 | 2.52k | break; | 1855 | 3.55k | } | 1856 | | | 1857 | | /* In a PE image file, the s_paddr field holds the virtual size of a | 1858 | | section, while the s_size field holds the raw size. We also keep | 1859 | | the original section flag value, since not every bit can be | 1860 | | mapped onto a generic BFD section bit. */ | 1861 | 3.55k | if (coff_section_data (abfd, section) == NULL) | 1862 | 3.55k | { | 1863 | 3.55k | amt = sizeof (struct coff_section_tdata); | 1864 | 3.55k | section->used_by_bfd = bfd_zalloc (abfd, amt); | 1865 | 3.55k | if (section->used_by_bfd == NULL) | 1866 | | /* FIXME: Return error. */ | 1867 | 0 | abort (); | 1868 | 3.55k | } | 1869 | | | 1870 | 3.55k | if (pei_section_data (abfd, section) == NULL) | 1871 | 3.55k | { | 1872 | 3.55k | amt = sizeof (struct pei_section_tdata); | 1873 | 3.55k | coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt); | 1874 | 3.55k | if (coff_section_data (abfd, section)->tdata == NULL) | 1875 | | /* FIXME: Return error. */ | 1876 | 0 | abort (); | 1877 | 3.55k | } | 1878 | 3.55k | pei_section_data (abfd, section)->virt_size = hdr->s_paddr; | 1879 | 3.55k | pei_section_data (abfd, section)->pe_flags = hdr->s_flags; | 1880 | | | 1881 | 3.55k | section->lma = hdr->s_vaddr; | 1882 | | | 1883 | | /* Check for extended relocs. */ | 1884 | 3.55k | if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL) | 1885 | 101 | { | 1886 | 101 | struct external_reloc dst; | 1887 | 101 | struct internal_reloc n; | 1888 | 101 | file_ptr oldpos = bfd_tell (abfd); | 1889 | 101 | bfd_size_type relsz = bfd_coff_relsz (abfd); | 1890 | | | 1891 | 101 | if (bfd_seek (abfd, (file_ptr) hdr->s_relptr, 0) != 0) | 1892 | 0 | return; | 1893 | 101 | if (bfd_bread (& dst, relsz, abfd) != relsz) | 1894 | 58 | return; | 1895 | | | 1896 | 43 | bfd_coff_swap_reloc_in (abfd, &dst, &n); | 1897 | 43 | if (bfd_seek (abfd, oldpos, 0) != 0) | 1898 | 0 | return; | 1899 | 43 | if (n.r_vaddr < 0x10000) | 1900 | 6 | { | 1901 | 6 | _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd); | 1902 | 6 | bfd_set_error (bfd_error_bad_value); | 1903 | 6 | return; | 1904 | 6 | } | 1905 | 37 | section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1; | 1906 | 37 | section->rel_filepos += relsz; | 1907 | 37 | } | 1908 | 3.45k | else if (hdr->s_nreloc == 0xffff) | 1909 | 0 | _bfd_error_handler | 1910 | 0 | (_("%pB: warning: claims to have 0xffff relocs, without overflow"), | 1911 | 0 | abfd); | 1912 | 3.55k | } |
pei-sh.c:coff_set_alignment_hook Line | Count | Source | 1828 | 1.70k | { | 1829 | 1.70k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; | 1830 | 1.70k | size_t amt; | 1831 | 1.70k | unsigned int alignment_power_const | 1832 | 1.70k | = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK; | 1833 | | | 1834 | 1.70k | switch (alignment_power_const) | 1835 | 1.70k | { | 1836 | 10 | case IMAGE_SCN_ALIGN_8192BYTES: | 1837 | 12 | case IMAGE_SCN_ALIGN_4096BYTES: | 1838 | 28 | case IMAGE_SCN_ALIGN_2048BYTES: | 1839 | 30 | case IMAGE_SCN_ALIGN_1024BYTES: | 1840 | 187 | case IMAGE_SCN_ALIGN_512BYTES: | 1841 | 193 | case IMAGE_SCN_ALIGN_256BYTES: | 1842 | 204 | case IMAGE_SCN_ALIGN_128BYTES: | 1843 | 210 | case IMAGE_SCN_ALIGN_64BYTES: | 1844 | 367 | case IMAGE_SCN_ALIGN_32BYTES: | 1845 | 371 | case IMAGE_SCN_ALIGN_16BYTES: | 1846 | 386 | case IMAGE_SCN_ALIGN_8BYTES: | 1847 | 397 | case IMAGE_SCN_ALIGN_4BYTES: | 1848 | 423 | case IMAGE_SCN_ALIGN_2BYTES: | 1849 | 448 | case IMAGE_SCN_ALIGN_1BYTES: | 1850 | 448 | section->alignment_power | 1851 | 448 | = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const); | 1852 | 448 | break; | 1853 | 1.25k | default: | 1854 | 1.25k | break; | 1855 | 1.70k | } | 1856 | | | 1857 | | /* In a PE image file, the s_paddr field holds the virtual size of a | 1858 | | section, while the s_size field holds the raw size. We also keep | 1859 | | the original section flag value, since not every bit can be | 1860 | | mapped onto a generic BFD section bit. */ | 1861 | 1.70k | if (coff_section_data (abfd, section) == NULL) | 1862 | 1.70k | { | 1863 | 1.70k | amt = sizeof (struct coff_section_tdata); | 1864 | 1.70k | section->used_by_bfd = bfd_zalloc (abfd, amt); | 1865 | 1.70k | if (section->used_by_bfd == NULL) | 1866 | | /* FIXME: Return error. */ | 1867 | 0 | abort (); | 1868 | 1.70k | } | 1869 | | | 1870 | 1.70k | if (pei_section_data (abfd, section) == NULL) | 1871 | 1.70k | { | 1872 | 1.70k | amt = sizeof (struct pei_section_tdata); | 1873 | 1.70k | coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt); | 1874 | 1.70k | if (coff_section_data (abfd, section)->tdata == NULL) | 1875 | | /* FIXME: Return error. */ | 1876 | 0 | abort (); | 1877 | 1.70k | } | 1878 | 1.70k | pei_section_data (abfd, section)->virt_size = hdr->s_paddr; | 1879 | 1.70k | pei_section_data (abfd, section)->pe_flags = hdr->s_flags; | 1880 | | | 1881 | 1.70k | section->lma = hdr->s_vaddr; | 1882 | | | 1883 | | /* Check for extended relocs. */ | 1884 | 1.70k | if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL) | 1885 | 177 | { | 1886 | 177 | struct external_reloc dst; | 1887 | 177 | struct internal_reloc n; | 1888 | 177 | file_ptr oldpos = bfd_tell (abfd); | 1889 | 177 | bfd_size_type relsz = bfd_coff_relsz (abfd); | 1890 | | | 1891 | 177 | if (bfd_seek (abfd, (file_ptr) hdr->s_relptr, 0) != 0) | 1892 | 0 | return; | 1893 | 177 | if (bfd_bread (& dst, relsz, abfd) != relsz) | 1894 | 76 | return; | 1895 | | | 1896 | 101 | bfd_coff_swap_reloc_in (abfd, &dst, &n); | 1897 | 101 | if (bfd_seek (abfd, oldpos, 0) != 0) | 1898 | 0 | return; | 1899 | 101 | if (n.r_vaddr < 0x10000) | 1900 | 45 | { | 1901 | 45 | _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd); | 1902 | 45 | bfd_set_error (bfd_error_bad_value); | 1903 | 45 | return; | 1904 | 45 | } | 1905 | 56 | section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1; | 1906 | 56 | section->rel_filepos += relsz; | 1907 | 56 | } | 1908 | 1.52k | else if (hdr->s_nreloc == 0xffff) | 1909 | 0 | _bfd_error_handler | 1910 | 0 | (_("%pB: warning: claims to have 0xffff relocs, without overflow"), | 1911 | 0 | abfd); | 1912 | 1.70k | } |
|
1913 | | #undef ALIGN_SET |
1914 | | #undef ELIFALIGN_SET |
1915 | | |
1916 | | #else /* ! COFF_WITH_PE */ |
1917 | | #ifdef RS6000COFF_C |
1918 | | |
1919 | | /* We grossly abuse this function to handle XCOFF overflow headers. |
1920 | | When we see one, we correct the reloc and line number counts in the |
1921 | | real header, and remove the section we just created. */ |
1922 | | |
1923 | | static void |
1924 | | coff_set_alignment_hook (bfd *abfd, asection *section, void * scnhdr) |
1925 | 131k | { |
1926 | 131k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; |
1927 | 131k | asection *real_sec; |
1928 | | |
1929 | 131k | if ((hdr->s_flags & STYP_OVRFLO) == 0) |
1930 | 110k | return; |
1931 | | |
1932 | 20.6k | real_sec = coff_section_from_bfd_index (abfd, (int) hdr->s_nreloc); |
1933 | 20.6k | if (real_sec == NULL) |
1934 | 0 | return; |
1935 | | |
1936 | 20.6k | real_sec->reloc_count = hdr->s_paddr; |
1937 | 20.6k | real_sec->lineno_count = hdr->s_vaddr; |
1938 | | |
1939 | 20.6k | if (!bfd_section_removed_from_list (abfd, section)) |
1940 | 20.6k | { |
1941 | 20.6k | bfd_section_list_remove (abfd, section); |
1942 | 20.6k | --abfd->section_count; |
1943 | 20.6k | } |
1944 | 20.6k | } coff64-rs6000.c:coff_set_alignment_hook Line | Count | Source | 1925 | 46.2k | { | 1926 | 46.2k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; | 1927 | 46.2k | asection *real_sec; | 1928 | | | 1929 | 46.2k | if ((hdr->s_flags & STYP_OVRFLO) == 0) | 1930 | 40.0k | return; | 1931 | | | 1932 | 6.18k | real_sec = coff_section_from_bfd_index (abfd, (int) hdr->s_nreloc); | 1933 | 6.18k | if (real_sec == NULL) | 1934 | 0 | return; | 1935 | | | 1936 | 6.18k | real_sec->reloc_count = hdr->s_paddr; | 1937 | 6.18k | real_sec->lineno_count = hdr->s_vaddr; | 1938 | | | 1939 | 6.18k | if (!bfd_section_removed_from_list (abfd, section)) | 1940 | 6.18k | { | 1941 | 6.18k | bfd_section_list_remove (abfd, section); | 1942 | 6.18k | --abfd->section_count; | 1943 | 6.18k | } | 1944 | 6.18k | } |
coff-rs6000.c:coff_set_alignment_hook Line | Count | Source | 1925 | 85.1k | { | 1926 | 85.1k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; | 1927 | 85.1k | asection *real_sec; | 1928 | | | 1929 | 85.1k | if ((hdr->s_flags & STYP_OVRFLO) == 0) | 1930 | 70.6k | return; | 1931 | | | 1932 | 14.4k | real_sec = coff_section_from_bfd_index (abfd, (int) hdr->s_nreloc); | 1933 | 14.4k | if (real_sec == NULL) | 1934 | 0 | return; | 1935 | | | 1936 | 14.4k | real_sec->reloc_count = hdr->s_paddr; | 1937 | 14.4k | real_sec->lineno_count = hdr->s_vaddr; | 1938 | | | 1939 | 14.4k | if (!bfd_section_removed_from_list (abfd, section)) | 1940 | 14.4k | { | 1941 | 14.4k | bfd_section_list_remove (abfd, section); | 1942 | 14.4k | --abfd->section_count; | 1943 | 14.4k | } | 1944 | 14.4k | } |
|
1945 | | |
1946 | | #else /* ! RS6000COFF_C */ |
1947 | | #if defined (COFF_GO32_EXE) || defined (COFF_GO32) |
1948 | | |
1949 | | static void |
1950 | | coff_set_alignment_hook (bfd * abfd, asection * section, void * scnhdr) |
1951 | 130k | { |
1952 | 130k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; |
1953 | | |
1954 | | /* Check for extended relocs. */ |
1955 | 130k | if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL) |
1956 | 30.9k | { |
1957 | 30.9k | struct external_reloc dst; |
1958 | 30.9k | struct internal_reloc n; |
1959 | 30.9k | const file_ptr oldpos = bfd_tell (abfd); |
1960 | 30.9k | const bfd_size_type relsz = bfd_coff_relsz (abfd); |
1961 | | |
1962 | 30.9k | if (bfd_seek (abfd, (file_ptr) hdr->s_relptr, 0) != 0) |
1963 | 0 | return; |
1964 | 30.9k | if (bfd_bread (& dst, relsz, abfd) != relsz) |
1965 | 25.8k | return; |
1966 | | |
1967 | 5.08k | bfd_coff_swap_reloc_in (abfd, &dst, &n); |
1968 | 5.08k | if (bfd_seek (abfd, oldpos, 0) != 0) |
1969 | 0 | return; |
1970 | 5.08k | section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1; |
1971 | 5.08k | section->rel_filepos += relsz; |
1972 | 5.08k | } |
1973 | 99.7k | else if (hdr->s_nreloc == 0xffff) |
1974 | 1.21k | _bfd_error_handler |
1975 | 1.21k | (_("%pB: warning: claims to have 0xffff relocs, without overflow"), |
1976 | 1.21k | abfd); |
1977 | 130k | } coff-go32.c:coff_set_alignment_hook Line | Count | Source | 1951 | 116k | { | 1952 | 116k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; | 1953 | | | 1954 | | /* Check for extended relocs. */ | 1955 | 116k | if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL) | 1956 | 28.9k | { | 1957 | 28.9k | struct external_reloc dst; | 1958 | 28.9k | struct internal_reloc n; | 1959 | 28.9k | const file_ptr oldpos = bfd_tell (abfd); | 1960 | 28.9k | const bfd_size_type relsz = bfd_coff_relsz (abfd); | 1961 | | | 1962 | 28.9k | if (bfd_seek (abfd, (file_ptr) hdr->s_relptr, 0) != 0) | 1963 | 0 | return; | 1964 | 28.9k | if (bfd_bread (& dst, relsz, abfd) != relsz) | 1965 | 24.2k | return; | 1966 | | | 1967 | 4.63k | bfd_coff_swap_reloc_in (abfd, &dst, &n); | 1968 | 4.63k | if (bfd_seek (abfd, oldpos, 0) != 0) | 1969 | 0 | return; | 1970 | 4.63k | section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1; | 1971 | 4.63k | section->rel_filepos += relsz; | 1972 | 4.63k | } | 1973 | 88.0k | else if (hdr->s_nreloc == 0xffff) | 1974 | 1.05k | _bfd_error_handler | 1975 | 1.05k | (_("%pB: warning: claims to have 0xffff relocs, without overflow"), | 1976 | 1.05k | abfd); | 1977 | 116k | } |
coff-stgo32.c:coff_set_alignment_hook Line | Count | Source | 1951 | 13.6k | { | 1952 | 13.6k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; | 1953 | | | 1954 | | /* Check for extended relocs. */ | 1955 | 13.6k | if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL) | 1956 | 2.01k | { | 1957 | 2.01k | struct external_reloc dst; | 1958 | 2.01k | struct internal_reloc n; | 1959 | 2.01k | const file_ptr oldpos = bfd_tell (abfd); | 1960 | 2.01k | const bfd_size_type relsz = bfd_coff_relsz (abfd); | 1961 | | | 1962 | 2.01k | if (bfd_seek (abfd, (file_ptr) hdr->s_relptr, 0) != 0) | 1963 | 0 | return; | 1964 | 2.01k | if (bfd_bread (& dst, relsz, abfd) != relsz) | 1965 | 1.56k | return; | 1966 | | | 1967 | 450 | bfd_coff_swap_reloc_in (abfd, &dst, &n); | 1968 | 450 | if (bfd_seek (abfd, oldpos, 0) != 0) | 1969 | 0 | return; | 1970 | 450 | section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1; | 1971 | 450 | section->rel_filepos += relsz; | 1972 | 450 | } | 1973 | 11.6k | else if (hdr->s_nreloc == 0xffff) | 1974 | 155 | _bfd_error_handler | 1975 | 155 | (_("%pB: warning: claims to have 0xffff relocs, without overflow"), | 1976 | 155 | abfd); | 1977 | 13.6k | } |
|
1978 | | |
1979 | | #else /* ! COFF_GO32_EXE && ! COFF_GO32 */ |
1980 | | |
1981 | | static void |
1982 | | coff_set_alignment_hook (bfd *abfd ATTRIBUTE_UNUSED, |
1983 | | asection *section ATTRIBUTE_UNUSED, |
1984 | | void *scnhdr ATTRIBUTE_UNUSED) |
1985 | 586k | { |
1986 | 586k | } coff-x86_64.c:coff_set_alignment_hook Line | Count | Source | 1985 | 199k | { | 1986 | 199k | } |
cf-i386lynx.c:coff_set_alignment_hook Line | Count | Source | 1985 | 140k | { | 1986 | 140k | } |
coff-i386.c:coff_set_alignment_hook Line | Count | Source | 1985 | 127k | { | 1986 | 127k | } |
coff-sh.c:coff_set_alignment_hook Line | Count | Source | 1985 | 20.6k | { | 1986 | 20.6k | } |
coff-tic30.c:coff_set_alignment_hook Line | Count | Source | 1985 | 37.6k | { | 1986 | 37.6k | } |
coff-z8k.c:coff_set_alignment_hook Line | Count | Source | 1985 | 59.7k | { | 1986 | 59.7k | } |
|
1987 | | |
1988 | | #endif /* ! COFF_GO32_EXE && ! COFF_GO32 */ |
1989 | | #endif /* ! RS6000COFF_C */ |
1990 | | #endif /* ! COFF_WITH_PE */ |
1991 | | #endif /* ! COFF_ALIGN_IN_SECTION_HEADER */ |
1992 | | |
1993 | | #ifndef coff_mkobject |
1994 | | |
1995 | | static bool |
1996 | | coff_mkobject (bfd * abfd) |
1997 | 3.86k | { |
1998 | 3.86k | coff_data_type *coff; |
1999 | 3.86k | size_t amt = sizeof (coff_data_type); |
2000 | | |
2001 | 3.86k | abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt); |
2002 | 3.86k | if (abfd->tdata.coff_obj_data == NULL) |
2003 | 0 | return false; |
2004 | | |
2005 | 3.86k | coff = coff_data (abfd); |
2006 | 3.86k | coff->symbols = NULL; |
2007 | 3.86k | coff->conversion_table = NULL; |
2008 | 3.86k | coff->raw_syments = NULL; |
2009 | 3.86k | coff->relocbase = 0; |
2010 | 3.86k | coff->local_toc_sym_map = 0; |
2011 | | |
2012 | 3.86k | bfd_coff_long_section_names (abfd) |
2013 | 3.86k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; |
2014 | | |
2015 | | /* make_abs_section(abfd);*/ |
2016 | | |
2017 | 3.86k | return true; |
2018 | 3.86k | } coff-x86_64.c:coff_mkobject Line | Count | Source | 1997 | 988 | { | 1998 | 988 | coff_data_type *coff; | 1999 | 988 | size_t amt = sizeof (coff_data_type); | 2000 | | | 2001 | 988 | abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt); | 2002 | 988 | if (abfd->tdata.coff_obj_data == NULL) | 2003 | 0 | return false; | 2004 | | | 2005 | 988 | coff = coff_data (abfd); | 2006 | 988 | coff->symbols = NULL; | 2007 | 988 | coff->conversion_table = NULL; | 2008 | 988 | coff->raw_syments = NULL; | 2009 | 988 | coff->relocbase = 0; | 2010 | 988 | coff->local_toc_sym_map = 0; | 2011 | | | 2012 | 988 | bfd_coff_long_section_names (abfd) | 2013 | 988 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 2014 | | | 2015 | | /* make_abs_section(abfd);*/ | 2016 | | | 2017 | 988 | return true; | 2018 | 988 | } |
cf-i386lynx.c:coff_mkobject Line | Count | Source | 1997 | 482 | { | 1998 | 482 | coff_data_type *coff; | 1999 | 482 | size_t amt = sizeof (coff_data_type); | 2000 | | | 2001 | 482 | abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt); | 2002 | 482 | if (abfd->tdata.coff_obj_data == NULL) | 2003 | 0 | return false; | 2004 | | | 2005 | 482 | coff = coff_data (abfd); | 2006 | 482 | coff->symbols = NULL; | 2007 | 482 | coff->conversion_table = NULL; | 2008 | 482 | coff->raw_syments = NULL; | 2009 | 482 | coff->relocbase = 0; | 2010 | 482 | coff->local_toc_sym_map = 0; | 2011 | | | 2012 | 482 | bfd_coff_long_section_names (abfd) | 2013 | 482 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 2014 | | | 2015 | | /* make_abs_section(abfd);*/ | 2016 | | | 2017 | 482 | return true; | 2018 | 482 | } |
coff-i386.c:coff_mkobject Line | Count | Source | 1997 | 403 | { | 1998 | 403 | coff_data_type *coff; | 1999 | 403 | size_t amt = sizeof (coff_data_type); | 2000 | | | 2001 | 403 | abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt); | 2002 | 403 | if (abfd->tdata.coff_obj_data == NULL) | 2003 | 0 | return false; | 2004 | | | 2005 | 403 | coff = coff_data (abfd); | 2006 | 403 | coff->symbols = NULL; | 2007 | 403 | coff->conversion_table = NULL; | 2008 | 403 | coff->raw_syments = NULL; | 2009 | 403 | coff->relocbase = 0; | 2010 | 403 | coff->local_toc_sym_map = 0; | 2011 | | | 2012 | 403 | bfd_coff_long_section_names (abfd) | 2013 | 403 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 2014 | | | 2015 | | /* make_abs_section(abfd);*/ | 2016 | | | 2017 | 403 | return true; | 2018 | 403 | } |
Line | Count | Source | 1997 | 430 | { | 1998 | 430 | coff_data_type *coff; | 1999 | 430 | size_t amt = sizeof (coff_data_type); | 2000 | | | 2001 | 430 | abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt); | 2002 | 430 | if (abfd->tdata.coff_obj_data == NULL) | 2003 | 0 | return false; | 2004 | | | 2005 | 430 | coff = coff_data (abfd); | 2006 | 430 | coff->symbols = NULL; | 2007 | 430 | coff->conversion_table = NULL; | 2008 | 430 | coff->raw_syments = NULL; | 2009 | 430 | coff->relocbase = 0; | 2010 | 430 | coff->local_toc_sym_map = 0; | 2011 | | | 2012 | 430 | bfd_coff_long_section_names (abfd) | 2013 | 430 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 2014 | | | 2015 | | /* make_abs_section(abfd);*/ | 2016 | | | 2017 | 430 | return true; | 2018 | 430 | } |
coff-tic30.c:coff_mkobject Line | Count | Source | 1997 | 430 | { | 1998 | 430 | coff_data_type *coff; | 1999 | 430 | size_t amt = sizeof (coff_data_type); | 2000 | | | 2001 | 430 | abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt); | 2002 | 430 | if (abfd->tdata.coff_obj_data == NULL) | 2003 | 0 | return false; | 2004 | | | 2005 | 430 | coff = coff_data (abfd); | 2006 | 430 | coff->symbols = NULL; | 2007 | 430 | coff->conversion_table = NULL; | 2008 | 430 | coff->raw_syments = NULL; | 2009 | 430 | coff->relocbase = 0; | 2010 | 430 | coff->local_toc_sym_map = 0; | 2011 | | | 2012 | 430 | bfd_coff_long_section_names (abfd) | 2013 | 430 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 2014 | | | 2015 | | /* make_abs_section(abfd);*/ | 2016 | | | 2017 | 430 | return true; | 2018 | 430 | } |
Unexecuted instantiation: coff-tic4x.c:coff_mkobject coff-tic54x.c:coff_mkobject Line | Count | Source | 1997 | 406 | { | 1998 | 406 | coff_data_type *coff; | 1999 | 406 | size_t amt = sizeof (coff_data_type); | 2000 | | | 2001 | 406 | abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt); | 2002 | 406 | if (abfd->tdata.coff_obj_data == NULL) | 2003 | 0 | return false; | 2004 | | | 2005 | 406 | coff = coff_data (abfd); | 2006 | 406 | coff->symbols = NULL; | 2007 | 406 | coff->conversion_table = NULL; | 2008 | 406 | coff->raw_syments = NULL; | 2009 | 406 | coff->relocbase = 0; | 2010 | 406 | coff->local_toc_sym_map = 0; | 2011 | | | 2012 | 406 | bfd_coff_long_section_names (abfd) | 2013 | 406 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 2014 | | | 2015 | | /* make_abs_section(abfd);*/ | 2016 | | | 2017 | 406 | return true; | 2018 | 406 | } |
Line | Count | Source | 1997 | 363 | { | 1998 | 363 | coff_data_type *coff; | 1999 | 363 | size_t amt = sizeof (coff_data_type); | 2000 | | | 2001 | 363 | abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt); | 2002 | 363 | if (abfd->tdata.coff_obj_data == NULL) | 2003 | 0 | return false; | 2004 | | | 2005 | 363 | coff = coff_data (abfd); | 2006 | 363 | coff->symbols = NULL; | 2007 | 363 | coff->conversion_table = NULL; | 2008 | 363 | coff->raw_syments = NULL; | 2009 | 363 | coff->relocbase = 0; | 2010 | 363 | coff->local_toc_sym_map = 0; | 2011 | | | 2012 | 363 | bfd_coff_long_section_names (abfd) | 2013 | 363 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 2014 | | | 2015 | | /* make_abs_section(abfd);*/ | 2016 | | | 2017 | 363 | return true; | 2018 | 363 | } |
Line | Count | Source | 1997 | 365 | { | 1998 | 365 | coff_data_type *coff; | 1999 | 365 | size_t amt = sizeof (coff_data_type); | 2000 | | | 2001 | 365 | abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt); | 2002 | 365 | if (abfd->tdata.coff_obj_data == NULL) | 2003 | 0 | return false; | 2004 | | | 2005 | 365 | coff = coff_data (abfd); | 2006 | 365 | coff->symbols = NULL; | 2007 | 365 | coff->conversion_table = NULL; | 2008 | 365 | coff->raw_syments = NULL; | 2009 | 365 | coff->relocbase = 0; | 2010 | 365 | coff->local_toc_sym_map = 0; | 2011 | | | 2012 | 365 | bfd_coff_long_section_names (abfd) | 2013 | 365 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 2014 | | | 2015 | | /* make_abs_section(abfd);*/ | 2016 | | | 2017 | 365 | return true; | 2018 | 365 | } |
|
2019 | | #endif |
2020 | | |
2021 | | /* Create the COFF backend specific information. */ |
2022 | | |
2023 | | #ifndef coff_mkobject_hook |
2024 | | static void * |
2025 | | coff_mkobject_hook (bfd * abfd, |
2026 | | void * filehdr, |
2027 | | void * aouthdr ATTRIBUTE_UNUSED) |
2028 | 5.58k | { |
2029 | 5.58k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; |
2030 | 5.58k | coff_data_type *coff; |
2031 | | |
2032 | 5.58k | if (! coff_mkobject (abfd)) |
2033 | 0 | return NULL; |
2034 | | |
2035 | 5.58k | coff = coff_data (abfd); |
2036 | | |
2037 | 5.58k | coff->sym_filepos = internal_f->f_symptr; |
2038 | | |
2039 | | /* These members communicate important constants about the symbol |
2040 | | table to GDB's symbol-reading code. These `constants' |
2041 | | unfortunately vary among coff implementations... */ |
2042 | 5.58k | coff->local_n_btmask = N_BTMASK; |
2043 | 5.58k | coff->local_n_btshft = N_BTSHFT; |
2044 | 5.58k | coff->local_n_tmask = N_TMASK; |
2045 | 5.58k | coff->local_n_tshift = N_TSHIFT; |
2046 | 5.58k | coff->local_symesz = bfd_coff_symesz (abfd); |
2047 | 5.58k | coff->local_auxesz = bfd_coff_auxesz (abfd); |
2048 | 5.58k | coff->local_linesz = bfd_coff_linesz (abfd); |
2049 | | |
2050 | 5.58k | coff->timestamp = internal_f->f_timdat; |
2051 | | |
2052 | 5.58k | obj_raw_syment_count (abfd) = |
2053 | 5.58k | obj_conv_table_size (abfd) = |
2054 | 5.58k | internal_f->f_nsyms; |
2055 | | |
2056 | | #ifdef RS6000COFF_C |
2057 | 1.23k | if ((internal_f->f_flags & F_SHROBJ) != 0) |
2058 | 135 | abfd->flags |= DYNAMIC; |
2059 | 1.23k | if (aouthdr != NULL && internal_f->f_opthdr >= bfd_coff_aoutsz (abfd)) |
2060 | 45 | { |
2061 | 45 | struct internal_aouthdr *internal_a = |
2062 | 45 | (struct internal_aouthdr *) aouthdr; |
2063 | 45 | struct xcoff_tdata *xcoff; |
2064 | | |
2065 | 45 | xcoff = xcoff_data (abfd); |
2066 | | # ifdef U803XTOCMAGIC |
2067 | 22 | xcoff->xcoff64 = internal_f->f_magic == U803XTOCMAGIC; |
2068 | | # else |
2069 | | xcoff->xcoff64 = 0; |
2070 | | # endif |
2071 | 45 | xcoff->full_aouthdr = true; |
2072 | 45 | xcoff->toc = internal_a->o_toc; |
2073 | 45 | xcoff->sntoc = internal_a->o_sntoc; |
2074 | 45 | xcoff->snentry = internal_a->o_snentry; |
2075 | 45 | bfd_xcoff_text_align_power (abfd) = internal_a->o_algntext; |
2076 | 45 | bfd_xcoff_data_align_power (abfd) = internal_a->o_algndata; |
2077 | 45 | xcoff->modtype = internal_a->o_modtype; |
2078 | 45 | xcoff->cputype = internal_a->o_cputype; |
2079 | 45 | xcoff->maxdata = internal_a->o_maxdata; |
2080 | 45 | xcoff->maxstack = internal_a->o_maxstack; |
2081 | 45 | } |
2082 | | #endif |
2083 | | |
2084 | | #ifdef ARM |
2085 | | /* Set the flags field from the COFF header read in. */ |
2086 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) |
2087 | | coff->flags = 0; |
2088 | | #endif |
2089 | | |
2090 | | #ifdef COFF_WITH_PE |
2091 | | /* FIXME: I'm not sure this is ever executed, since peicode.h |
2092 | | defines coff_mkobject_hook. */ |
2093 | | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) |
2094 | | abfd->flags |= HAS_DEBUG; |
2095 | | #endif |
2096 | | |
2097 | 5.58k | return coff; |
2098 | 5.58k | } coff-x86_64.c:coff_mkobject_hook Line | Count | Source | 2028 | 988 | { | 2029 | 988 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2030 | 988 | coff_data_type *coff; | 2031 | | | 2032 | 988 | if (! coff_mkobject (abfd)) | 2033 | 0 | return NULL; | 2034 | | | 2035 | 988 | coff = coff_data (abfd); | 2036 | | | 2037 | 988 | coff->sym_filepos = internal_f->f_symptr; | 2038 | | | 2039 | | /* These members communicate important constants about the symbol | 2040 | | table to GDB's symbol-reading code. These `constants' | 2041 | | unfortunately vary among coff implementations... */ | 2042 | 988 | coff->local_n_btmask = N_BTMASK; | 2043 | 988 | coff->local_n_btshft = N_BTSHFT; | 2044 | 988 | coff->local_n_tmask = N_TMASK; | 2045 | 988 | coff->local_n_tshift = N_TSHIFT; | 2046 | 988 | coff->local_symesz = bfd_coff_symesz (abfd); | 2047 | 988 | coff->local_auxesz = bfd_coff_auxesz (abfd); | 2048 | 988 | coff->local_linesz = bfd_coff_linesz (abfd); | 2049 | | | 2050 | 988 | coff->timestamp = internal_f->f_timdat; | 2051 | | | 2052 | 988 | obj_raw_syment_count (abfd) = | 2053 | 988 | obj_conv_table_size (abfd) = | 2054 | 988 | internal_f->f_nsyms; | 2055 | | | 2056 | | #ifdef RS6000COFF_C | 2057 | | if ((internal_f->f_flags & F_SHROBJ) != 0) | 2058 | | abfd->flags |= DYNAMIC; | 2059 | | if (aouthdr != NULL && internal_f->f_opthdr >= bfd_coff_aoutsz (abfd)) | 2060 | | { | 2061 | | struct internal_aouthdr *internal_a = | 2062 | | (struct internal_aouthdr *) aouthdr; | 2063 | | struct xcoff_tdata *xcoff; | 2064 | | | 2065 | | xcoff = xcoff_data (abfd); | 2066 | | # ifdef U803XTOCMAGIC | 2067 | | xcoff->xcoff64 = internal_f->f_magic == U803XTOCMAGIC; | 2068 | | # else | 2069 | | xcoff->xcoff64 = 0; | 2070 | | # endif | 2071 | | xcoff->full_aouthdr = true; | 2072 | | xcoff->toc = internal_a->o_toc; | 2073 | | xcoff->sntoc = internal_a->o_sntoc; | 2074 | | xcoff->snentry = internal_a->o_snentry; | 2075 | | bfd_xcoff_text_align_power (abfd) = internal_a->o_algntext; | 2076 | | bfd_xcoff_data_align_power (abfd) = internal_a->o_algndata; | 2077 | | xcoff->modtype = internal_a->o_modtype; | 2078 | | xcoff->cputype = internal_a->o_cputype; | 2079 | | xcoff->maxdata = internal_a->o_maxdata; | 2080 | | xcoff->maxstack = internal_a->o_maxstack; | 2081 | | } | 2082 | | #endif | 2083 | | | 2084 | | #ifdef ARM | 2085 | | /* Set the flags field from the COFF header read in. */ | 2086 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 2087 | | coff->flags = 0; | 2088 | | #endif | 2089 | | | 2090 | | #ifdef COFF_WITH_PE | 2091 | | /* FIXME: I'm not sure this is ever executed, since peicode.h | 2092 | | defines coff_mkobject_hook. */ | 2093 | | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 2094 | | abfd->flags |= HAS_DEBUG; | 2095 | | #endif | 2096 | | | 2097 | 988 | return coff; | 2098 | 988 | } |
coff64-rs6000.c:coff_mkobject_hook Line | Count | Source | 2028 | 627 | { | 2029 | 627 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2030 | 627 | coff_data_type *coff; | 2031 | | | 2032 | 627 | if (! coff_mkobject (abfd)) | 2033 | 0 | return NULL; | 2034 | | | 2035 | 627 | coff = coff_data (abfd); | 2036 | | | 2037 | 627 | coff->sym_filepos = internal_f->f_symptr; | 2038 | | | 2039 | | /* These members communicate important constants about the symbol | 2040 | | table to GDB's symbol-reading code. These `constants' | 2041 | | unfortunately vary among coff implementations... */ | 2042 | 627 | coff->local_n_btmask = N_BTMASK; | 2043 | 627 | coff->local_n_btshft = N_BTSHFT; | 2044 | 627 | coff->local_n_tmask = N_TMASK; | 2045 | 627 | coff->local_n_tshift = N_TSHIFT; | 2046 | 627 | coff->local_symesz = bfd_coff_symesz (abfd); | 2047 | 627 | coff->local_auxesz = bfd_coff_auxesz (abfd); | 2048 | 627 | coff->local_linesz = bfd_coff_linesz (abfd); | 2049 | | | 2050 | 627 | coff->timestamp = internal_f->f_timdat; | 2051 | | | 2052 | 627 | obj_raw_syment_count (abfd) = | 2053 | 627 | obj_conv_table_size (abfd) = | 2054 | 627 | internal_f->f_nsyms; | 2055 | | | 2056 | 627 | #ifdef RS6000COFF_C | 2057 | 627 | if ((internal_f->f_flags & F_SHROBJ) != 0) | 2058 | 85 | abfd->flags |= DYNAMIC; | 2059 | 627 | if (aouthdr != NULL && internal_f->f_opthdr >= bfd_coff_aoutsz (abfd)) | 2060 | 22 | { | 2061 | 22 | struct internal_aouthdr *internal_a = | 2062 | 22 | (struct internal_aouthdr *) aouthdr; | 2063 | 22 | struct xcoff_tdata *xcoff; | 2064 | | | 2065 | 22 | xcoff = xcoff_data (abfd); | 2066 | 22 | # ifdef U803XTOCMAGIC | 2067 | 22 | xcoff->xcoff64 = internal_f->f_magic == U803XTOCMAGIC; | 2068 | | # else | 2069 | | xcoff->xcoff64 = 0; | 2070 | | # endif | 2071 | 22 | xcoff->full_aouthdr = true; | 2072 | 22 | xcoff->toc = internal_a->o_toc; | 2073 | 22 | xcoff->sntoc = internal_a->o_sntoc; | 2074 | 22 | xcoff->snentry = internal_a->o_snentry; | 2075 | 22 | bfd_xcoff_text_align_power (abfd) = internal_a->o_algntext; | 2076 | 22 | bfd_xcoff_data_align_power (abfd) = internal_a->o_algndata; | 2077 | 22 | xcoff->modtype = internal_a->o_modtype; | 2078 | 22 | xcoff->cputype = internal_a->o_cputype; | 2079 | 22 | xcoff->maxdata = internal_a->o_maxdata; | 2080 | 22 | xcoff->maxstack = internal_a->o_maxstack; | 2081 | 22 | } | 2082 | 627 | #endif | 2083 | | | 2084 | | #ifdef ARM | 2085 | | /* Set the flags field from the COFF header read in. */ | 2086 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 2087 | | coff->flags = 0; | 2088 | | #endif | 2089 | | | 2090 | | #ifdef COFF_WITH_PE | 2091 | | /* FIXME: I'm not sure this is ever executed, since peicode.h | 2092 | | defines coff_mkobject_hook. */ | 2093 | | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 2094 | | abfd->flags |= HAS_DEBUG; | 2095 | | #endif | 2096 | | | 2097 | 627 | return coff; | 2098 | 627 | } |
cf-i386lynx.c:coff_mkobject_hook Line | Count | Source | 2028 | 482 | { | 2029 | 482 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2030 | 482 | coff_data_type *coff; | 2031 | | | 2032 | 482 | if (! coff_mkobject (abfd)) | 2033 | 0 | return NULL; | 2034 | | | 2035 | 482 | coff = coff_data (abfd); | 2036 | | | 2037 | 482 | coff->sym_filepos = internal_f->f_symptr; | 2038 | | | 2039 | | /* These members communicate important constants about the symbol | 2040 | | table to GDB's symbol-reading code. These `constants' | 2041 | | unfortunately vary among coff implementations... */ | 2042 | 482 | coff->local_n_btmask = N_BTMASK; | 2043 | 482 | coff->local_n_btshft = N_BTSHFT; | 2044 | 482 | coff->local_n_tmask = N_TMASK; | 2045 | 482 | coff->local_n_tshift = N_TSHIFT; | 2046 | 482 | coff->local_symesz = bfd_coff_symesz (abfd); | 2047 | 482 | coff->local_auxesz = bfd_coff_auxesz (abfd); | 2048 | 482 | coff->local_linesz = bfd_coff_linesz (abfd); | 2049 | | | 2050 | 482 | coff->timestamp = internal_f->f_timdat; | 2051 | | | 2052 | 482 | obj_raw_syment_count (abfd) = | 2053 | 482 | obj_conv_table_size (abfd) = | 2054 | 482 | internal_f->f_nsyms; | 2055 | | | 2056 | | #ifdef RS6000COFF_C | 2057 | | if ((internal_f->f_flags & F_SHROBJ) != 0) | 2058 | | abfd->flags |= DYNAMIC; | 2059 | | if (aouthdr != NULL && internal_f->f_opthdr >= bfd_coff_aoutsz (abfd)) | 2060 | | { | 2061 | | struct internal_aouthdr *internal_a = | 2062 | | (struct internal_aouthdr *) aouthdr; | 2063 | | struct xcoff_tdata *xcoff; | 2064 | | | 2065 | | xcoff = xcoff_data (abfd); | 2066 | | # ifdef U803XTOCMAGIC | 2067 | | xcoff->xcoff64 = internal_f->f_magic == U803XTOCMAGIC; | 2068 | | # else | 2069 | | xcoff->xcoff64 = 0; | 2070 | | # endif | 2071 | | xcoff->full_aouthdr = true; | 2072 | | xcoff->toc = internal_a->o_toc; | 2073 | | xcoff->sntoc = internal_a->o_sntoc; | 2074 | | xcoff->snentry = internal_a->o_snentry; | 2075 | | bfd_xcoff_text_align_power (abfd) = internal_a->o_algntext; | 2076 | | bfd_xcoff_data_align_power (abfd) = internal_a->o_algndata; | 2077 | | xcoff->modtype = internal_a->o_modtype; | 2078 | | xcoff->cputype = internal_a->o_cputype; | 2079 | | xcoff->maxdata = internal_a->o_maxdata; | 2080 | | xcoff->maxstack = internal_a->o_maxstack; | 2081 | | } | 2082 | | #endif | 2083 | | | 2084 | | #ifdef ARM | 2085 | | /* Set the flags field from the COFF header read in. */ | 2086 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 2087 | | coff->flags = 0; | 2088 | | #endif | 2089 | | | 2090 | | #ifdef COFF_WITH_PE | 2091 | | /* FIXME: I'm not sure this is ever executed, since peicode.h | 2092 | | defines coff_mkobject_hook. */ | 2093 | | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 2094 | | abfd->flags |= HAS_DEBUG; | 2095 | | #endif | 2096 | | | 2097 | 482 | return coff; | 2098 | 482 | } |
coff-go32.c:coff_mkobject_hook Line | Count | Source | 2028 | 403 | { | 2029 | 403 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2030 | 403 | coff_data_type *coff; | 2031 | | | 2032 | 403 | if (! coff_mkobject (abfd)) | 2033 | 0 | return NULL; | 2034 | | | 2035 | 403 | coff = coff_data (abfd); | 2036 | | | 2037 | 403 | coff->sym_filepos = internal_f->f_symptr; | 2038 | | | 2039 | | /* These members communicate important constants about the symbol | 2040 | | table to GDB's symbol-reading code. These `constants' | 2041 | | unfortunately vary among coff implementations... */ | 2042 | 403 | coff->local_n_btmask = N_BTMASK; | 2043 | 403 | coff->local_n_btshft = N_BTSHFT; | 2044 | 403 | coff->local_n_tmask = N_TMASK; | 2045 | 403 | coff->local_n_tshift = N_TSHIFT; | 2046 | 403 | coff->local_symesz = bfd_coff_symesz (abfd); | 2047 | 403 | coff->local_auxesz = bfd_coff_auxesz (abfd); | 2048 | 403 | coff->local_linesz = bfd_coff_linesz (abfd); | 2049 | | | 2050 | 403 | coff->timestamp = internal_f->f_timdat; | 2051 | | | 2052 | 403 | obj_raw_syment_count (abfd) = | 2053 | 403 | obj_conv_table_size (abfd) = | 2054 | 403 | internal_f->f_nsyms; | 2055 | | | 2056 | | #ifdef RS6000COFF_C | 2057 | | if ((internal_f->f_flags & F_SHROBJ) != 0) | 2058 | | abfd->flags |= DYNAMIC; | 2059 | | if (aouthdr != NULL && internal_f->f_opthdr >= bfd_coff_aoutsz (abfd)) | 2060 | | { | 2061 | | struct internal_aouthdr *internal_a = | 2062 | | (struct internal_aouthdr *) aouthdr; | 2063 | | struct xcoff_tdata *xcoff; | 2064 | | | 2065 | | xcoff = xcoff_data (abfd); | 2066 | | # ifdef U803XTOCMAGIC | 2067 | | xcoff->xcoff64 = internal_f->f_magic == U803XTOCMAGIC; | 2068 | | # else | 2069 | | xcoff->xcoff64 = 0; | 2070 | | # endif | 2071 | | xcoff->full_aouthdr = true; | 2072 | | xcoff->toc = internal_a->o_toc; | 2073 | | xcoff->sntoc = internal_a->o_sntoc; | 2074 | | xcoff->snentry = internal_a->o_snentry; | 2075 | | bfd_xcoff_text_align_power (abfd) = internal_a->o_algntext; | 2076 | | bfd_xcoff_data_align_power (abfd) = internal_a->o_algndata; | 2077 | | xcoff->modtype = internal_a->o_modtype; | 2078 | | xcoff->cputype = internal_a->o_cputype; | 2079 | | xcoff->maxdata = internal_a->o_maxdata; | 2080 | | xcoff->maxstack = internal_a->o_maxstack; | 2081 | | } | 2082 | | #endif | 2083 | | | 2084 | | #ifdef ARM | 2085 | | /* Set the flags field from the COFF header read in. */ | 2086 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 2087 | | coff->flags = 0; | 2088 | | #endif | 2089 | | | 2090 | | #ifdef COFF_WITH_PE | 2091 | | /* FIXME: I'm not sure this is ever executed, since peicode.h | 2092 | | defines coff_mkobject_hook. */ | 2093 | | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 2094 | | abfd->flags |= HAS_DEBUG; | 2095 | | #endif | 2096 | | | 2097 | 403 | return coff; | 2098 | 403 | } |
coff-i386.c:coff_mkobject_hook Line | Count | Source | 2028 | 403 | { | 2029 | 403 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2030 | 403 | coff_data_type *coff; | 2031 | | | 2032 | 403 | if (! coff_mkobject (abfd)) | 2033 | 0 | return NULL; | 2034 | | | 2035 | 403 | coff = coff_data (abfd); | 2036 | | | 2037 | 403 | coff->sym_filepos = internal_f->f_symptr; | 2038 | | | 2039 | | /* These members communicate important constants about the symbol | 2040 | | table to GDB's symbol-reading code. These `constants' | 2041 | | unfortunately vary among coff implementations... */ | 2042 | 403 | coff->local_n_btmask = N_BTMASK; | 2043 | 403 | coff->local_n_btshft = N_BTSHFT; | 2044 | 403 | coff->local_n_tmask = N_TMASK; | 2045 | 403 | coff->local_n_tshift = N_TSHIFT; | 2046 | 403 | coff->local_symesz = bfd_coff_symesz (abfd); | 2047 | 403 | coff->local_auxesz = bfd_coff_auxesz (abfd); | 2048 | 403 | coff->local_linesz = bfd_coff_linesz (abfd); | 2049 | | | 2050 | 403 | coff->timestamp = internal_f->f_timdat; | 2051 | | | 2052 | 403 | obj_raw_syment_count (abfd) = | 2053 | 403 | obj_conv_table_size (abfd) = | 2054 | 403 | internal_f->f_nsyms; | 2055 | | | 2056 | | #ifdef RS6000COFF_C | 2057 | | if ((internal_f->f_flags & F_SHROBJ) != 0) | 2058 | | abfd->flags |= DYNAMIC; | 2059 | | if (aouthdr != NULL && internal_f->f_opthdr >= bfd_coff_aoutsz (abfd)) | 2060 | | { | 2061 | | struct internal_aouthdr *internal_a = | 2062 | | (struct internal_aouthdr *) aouthdr; | 2063 | | struct xcoff_tdata *xcoff; | 2064 | | | 2065 | | xcoff = xcoff_data (abfd); | 2066 | | # ifdef U803XTOCMAGIC | 2067 | | xcoff->xcoff64 = internal_f->f_magic == U803XTOCMAGIC; | 2068 | | # else | 2069 | | xcoff->xcoff64 = 0; | 2070 | | # endif | 2071 | | xcoff->full_aouthdr = true; | 2072 | | xcoff->toc = internal_a->o_toc; | 2073 | | xcoff->sntoc = internal_a->o_sntoc; | 2074 | | xcoff->snentry = internal_a->o_snentry; | 2075 | | bfd_xcoff_text_align_power (abfd) = internal_a->o_algntext; | 2076 | | bfd_xcoff_data_align_power (abfd) = internal_a->o_algndata; | 2077 | | xcoff->modtype = internal_a->o_modtype; | 2078 | | xcoff->cputype = internal_a->o_cputype; | 2079 | | xcoff->maxdata = internal_a->o_maxdata; | 2080 | | xcoff->maxstack = internal_a->o_maxstack; | 2081 | | } | 2082 | | #endif | 2083 | | | 2084 | | #ifdef ARM | 2085 | | /* Set the flags field from the COFF header read in. */ | 2086 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 2087 | | coff->flags = 0; | 2088 | | #endif | 2089 | | | 2090 | | #ifdef COFF_WITH_PE | 2091 | | /* FIXME: I'm not sure this is ever executed, since peicode.h | 2092 | | defines coff_mkobject_hook. */ | 2093 | | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 2094 | | abfd->flags |= HAS_DEBUG; | 2095 | | #endif | 2096 | | | 2097 | 403 | return coff; | 2098 | 403 | } |
coff-rs6000.c:coff_mkobject_hook Line | Count | Source | 2028 | 611 | { | 2029 | 611 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2030 | 611 | coff_data_type *coff; | 2031 | | | 2032 | 611 | if (! coff_mkobject (abfd)) | 2033 | 0 | return NULL; | 2034 | | | 2035 | 611 | coff = coff_data (abfd); | 2036 | | | 2037 | 611 | coff->sym_filepos = internal_f->f_symptr; | 2038 | | | 2039 | | /* These members communicate important constants about the symbol | 2040 | | table to GDB's symbol-reading code. These `constants' | 2041 | | unfortunately vary among coff implementations... */ | 2042 | 611 | coff->local_n_btmask = N_BTMASK; | 2043 | 611 | coff->local_n_btshft = N_BTSHFT; | 2044 | 611 | coff->local_n_tmask = N_TMASK; | 2045 | 611 | coff->local_n_tshift = N_TSHIFT; | 2046 | 611 | coff->local_symesz = bfd_coff_symesz (abfd); | 2047 | 611 | coff->local_auxesz = bfd_coff_auxesz (abfd); | 2048 | 611 | coff->local_linesz = bfd_coff_linesz (abfd); | 2049 | | | 2050 | 611 | coff->timestamp = internal_f->f_timdat; | 2051 | | | 2052 | 611 | obj_raw_syment_count (abfd) = | 2053 | 611 | obj_conv_table_size (abfd) = | 2054 | 611 | internal_f->f_nsyms; | 2055 | | | 2056 | 611 | #ifdef RS6000COFF_C | 2057 | 611 | if ((internal_f->f_flags & F_SHROBJ) != 0) | 2058 | 50 | abfd->flags |= DYNAMIC; | 2059 | 611 | if (aouthdr != NULL && internal_f->f_opthdr >= bfd_coff_aoutsz (abfd)) | 2060 | 23 | { | 2061 | 23 | struct internal_aouthdr *internal_a = | 2062 | 23 | (struct internal_aouthdr *) aouthdr; | 2063 | 23 | struct xcoff_tdata *xcoff; | 2064 | | | 2065 | 23 | xcoff = xcoff_data (abfd); | 2066 | | # ifdef U803XTOCMAGIC | 2067 | | xcoff->xcoff64 = internal_f->f_magic == U803XTOCMAGIC; | 2068 | | # else | 2069 | 23 | xcoff->xcoff64 = 0; | 2070 | 23 | # endif | 2071 | 23 | xcoff->full_aouthdr = true; | 2072 | 23 | xcoff->toc = internal_a->o_toc; | 2073 | 23 | xcoff->sntoc = internal_a->o_sntoc; | 2074 | 23 | xcoff->snentry = internal_a->o_snentry; | 2075 | 23 | bfd_xcoff_text_align_power (abfd) = internal_a->o_algntext; | 2076 | 23 | bfd_xcoff_data_align_power (abfd) = internal_a->o_algndata; | 2077 | 23 | xcoff->modtype = internal_a->o_modtype; | 2078 | 23 | xcoff->cputype = internal_a->o_cputype; | 2079 | 23 | xcoff->maxdata = internal_a->o_maxdata; | 2080 | 23 | xcoff->maxstack = internal_a->o_maxstack; | 2081 | 23 | } | 2082 | 611 | #endif | 2083 | | | 2084 | | #ifdef ARM | 2085 | | /* Set the flags field from the COFF header read in. */ | 2086 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 2087 | | coff->flags = 0; | 2088 | | #endif | 2089 | | | 2090 | | #ifdef COFF_WITH_PE | 2091 | | /* FIXME: I'm not sure this is ever executed, since peicode.h | 2092 | | defines coff_mkobject_hook. */ | 2093 | | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 2094 | | abfd->flags |= HAS_DEBUG; | 2095 | | #endif | 2096 | | | 2097 | 611 | return coff; | 2098 | 611 | } |
coff-sh.c:coff_mkobject_hook Line | Count | Source | 2028 | 430 | { | 2029 | 430 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2030 | 430 | coff_data_type *coff; | 2031 | | | 2032 | 430 | if (! coff_mkobject (abfd)) | 2033 | 0 | return NULL; | 2034 | | | 2035 | 430 | coff = coff_data (abfd); | 2036 | | | 2037 | 430 | coff->sym_filepos = internal_f->f_symptr; | 2038 | | | 2039 | | /* These members communicate important constants about the symbol | 2040 | | table to GDB's symbol-reading code. These `constants' | 2041 | | unfortunately vary among coff implementations... */ | 2042 | 430 | coff->local_n_btmask = N_BTMASK; | 2043 | 430 | coff->local_n_btshft = N_BTSHFT; | 2044 | 430 | coff->local_n_tmask = N_TMASK; | 2045 | 430 | coff->local_n_tshift = N_TSHIFT; | 2046 | 430 | coff->local_symesz = bfd_coff_symesz (abfd); | 2047 | 430 | coff->local_auxesz = bfd_coff_auxesz (abfd); | 2048 | 430 | coff->local_linesz = bfd_coff_linesz (abfd); | 2049 | | | 2050 | 430 | coff->timestamp = internal_f->f_timdat; | 2051 | | | 2052 | 430 | obj_raw_syment_count (abfd) = | 2053 | 430 | obj_conv_table_size (abfd) = | 2054 | 430 | internal_f->f_nsyms; | 2055 | | | 2056 | | #ifdef RS6000COFF_C | 2057 | | if ((internal_f->f_flags & F_SHROBJ) != 0) | 2058 | | abfd->flags |= DYNAMIC; | 2059 | | if (aouthdr != NULL && internal_f->f_opthdr >= bfd_coff_aoutsz (abfd)) | 2060 | | { | 2061 | | struct internal_aouthdr *internal_a = | 2062 | | (struct internal_aouthdr *) aouthdr; | 2063 | | struct xcoff_tdata *xcoff; | 2064 | | | 2065 | | xcoff = xcoff_data (abfd); | 2066 | | # ifdef U803XTOCMAGIC | 2067 | | xcoff->xcoff64 = internal_f->f_magic == U803XTOCMAGIC; | 2068 | | # else | 2069 | | xcoff->xcoff64 = 0; | 2070 | | # endif | 2071 | | xcoff->full_aouthdr = true; | 2072 | | xcoff->toc = internal_a->o_toc; | 2073 | | xcoff->sntoc = internal_a->o_sntoc; | 2074 | | xcoff->snentry = internal_a->o_snentry; | 2075 | | bfd_xcoff_text_align_power (abfd) = internal_a->o_algntext; | 2076 | | bfd_xcoff_data_align_power (abfd) = internal_a->o_algndata; | 2077 | | xcoff->modtype = internal_a->o_modtype; | 2078 | | xcoff->cputype = internal_a->o_cputype; | 2079 | | xcoff->maxdata = internal_a->o_maxdata; | 2080 | | xcoff->maxstack = internal_a->o_maxstack; | 2081 | | } | 2082 | | #endif | 2083 | | | 2084 | | #ifdef ARM | 2085 | | /* Set the flags field from the COFF header read in. */ | 2086 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 2087 | | coff->flags = 0; | 2088 | | #endif | 2089 | | | 2090 | | #ifdef COFF_WITH_PE | 2091 | | /* FIXME: I'm not sure this is ever executed, since peicode.h | 2092 | | defines coff_mkobject_hook. */ | 2093 | | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 2094 | | abfd->flags |= HAS_DEBUG; | 2095 | | #endif | 2096 | | | 2097 | 430 | return coff; | 2098 | 430 | } |
coff-stgo32.c:coff_mkobject_hook Line | Count | Source | 2028 | 80 | { | 2029 | 80 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2030 | 80 | coff_data_type *coff; | 2031 | | | 2032 | 80 | if (! coff_mkobject (abfd)) | 2033 | 0 | return NULL; | 2034 | | | 2035 | 80 | coff = coff_data (abfd); | 2036 | | | 2037 | 80 | coff->sym_filepos = internal_f->f_symptr; | 2038 | | | 2039 | | /* These members communicate important constants about the symbol | 2040 | | table to GDB's symbol-reading code. These `constants' | 2041 | | unfortunately vary among coff implementations... */ | 2042 | 80 | coff->local_n_btmask = N_BTMASK; | 2043 | 80 | coff->local_n_btshft = N_BTSHFT; | 2044 | 80 | coff->local_n_tmask = N_TMASK; | 2045 | 80 | coff->local_n_tshift = N_TSHIFT; | 2046 | 80 | coff->local_symesz = bfd_coff_symesz (abfd); | 2047 | 80 | coff->local_auxesz = bfd_coff_auxesz (abfd); | 2048 | 80 | coff->local_linesz = bfd_coff_linesz (abfd); | 2049 | | | 2050 | 80 | coff->timestamp = internal_f->f_timdat; | 2051 | | | 2052 | 80 | obj_raw_syment_count (abfd) = | 2053 | 80 | obj_conv_table_size (abfd) = | 2054 | 80 | internal_f->f_nsyms; | 2055 | | | 2056 | | #ifdef RS6000COFF_C | 2057 | | if ((internal_f->f_flags & F_SHROBJ) != 0) | 2058 | | abfd->flags |= DYNAMIC; | 2059 | | if (aouthdr != NULL && internal_f->f_opthdr >= bfd_coff_aoutsz (abfd)) | 2060 | | { | 2061 | | struct internal_aouthdr *internal_a = | 2062 | | (struct internal_aouthdr *) aouthdr; | 2063 | | struct xcoff_tdata *xcoff; | 2064 | | | 2065 | | xcoff = xcoff_data (abfd); | 2066 | | # ifdef U803XTOCMAGIC | 2067 | | xcoff->xcoff64 = internal_f->f_magic == U803XTOCMAGIC; | 2068 | | # else | 2069 | | xcoff->xcoff64 = 0; | 2070 | | # endif | 2071 | | xcoff->full_aouthdr = true; | 2072 | | xcoff->toc = internal_a->o_toc; | 2073 | | xcoff->sntoc = internal_a->o_sntoc; | 2074 | | xcoff->snentry = internal_a->o_snentry; | 2075 | | bfd_xcoff_text_align_power (abfd) = internal_a->o_algntext; | 2076 | | bfd_xcoff_data_align_power (abfd) = internal_a->o_algndata; | 2077 | | xcoff->modtype = internal_a->o_modtype; | 2078 | | xcoff->cputype = internal_a->o_cputype; | 2079 | | xcoff->maxdata = internal_a->o_maxdata; | 2080 | | xcoff->maxstack = internal_a->o_maxstack; | 2081 | | } | 2082 | | #endif | 2083 | | | 2084 | | #ifdef ARM | 2085 | | /* Set the flags field from the COFF header read in. */ | 2086 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 2087 | | coff->flags = 0; | 2088 | | #endif | 2089 | | | 2090 | | #ifdef COFF_WITH_PE | 2091 | | /* FIXME: I'm not sure this is ever executed, since peicode.h | 2092 | | defines coff_mkobject_hook. */ | 2093 | | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 2094 | | abfd->flags |= HAS_DEBUG; | 2095 | | #endif | 2096 | | | 2097 | 80 | return coff; | 2098 | 80 | } |
coff-tic30.c:coff_mkobject_hook Line | Count | Source | 2028 | 430 | { | 2029 | 430 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2030 | 430 | coff_data_type *coff; | 2031 | | | 2032 | 430 | if (! coff_mkobject (abfd)) | 2033 | 0 | return NULL; | 2034 | | | 2035 | 430 | coff = coff_data (abfd); | 2036 | | | 2037 | 430 | coff->sym_filepos = internal_f->f_symptr; | 2038 | | | 2039 | | /* These members communicate important constants about the symbol | 2040 | | table to GDB's symbol-reading code. These `constants' | 2041 | | unfortunately vary among coff implementations... */ | 2042 | 430 | coff->local_n_btmask = N_BTMASK; | 2043 | 430 | coff->local_n_btshft = N_BTSHFT; | 2044 | 430 | coff->local_n_tmask = N_TMASK; | 2045 | 430 | coff->local_n_tshift = N_TSHIFT; | 2046 | 430 | coff->local_symesz = bfd_coff_symesz (abfd); | 2047 | 430 | coff->local_auxesz = bfd_coff_auxesz (abfd); | 2048 | 430 | coff->local_linesz = bfd_coff_linesz (abfd); | 2049 | | | 2050 | 430 | coff->timestamp = internal_f->f_timdat; | 2051 | | | 2052 | 430 | obj_raw_syment_count (abfd) = | 2053 | 430 | obj_conv_table_size (abfd) = | 2054 | 430 | internal_f->f_nsyms; | 2055 | | | 2056 | | #ifdef RS6000COFF_C | 2057 | | if ((internal_f->f_flags & F_SHROBJ) != 0) | 2058 | | abfd->flags |= DYNAMIC; | 2059 | | if (aouthdr != NULL && internal_f->f_opthdr >= bfd_coff_aoutsz (abfd)) | 2060 | | { | 2061 | | struct internal_aouthdr *internal_a = | 2062 | | (struct internal_aouthdr *) aouthdr; | 2063 | | struct xcoff_tdata *xcoff; | 2064 | | | 2065 | | xcoff = xcoff_data (abfd); | 2066 | | # ifdef U803XTOCMAGIC | 2067 | | xcoff->xcoff64 = internal_f->f_magic == U803XTOCMAGIC; | 2068 | | # else | 2069 | | xcoff->xcoff64 = 0; | 2070 | | # endif | 2071 | | xcoff->full_aouthdr = true; | 2072 | | xcoff->toc = internal_a->o_toc; | 2073 | | xcoff->sntoc = internal_a->o_sntoc; | 2074 | | xcoff->snentry = internal_a->o_snentry; | 2075 | | bfd_xcoff_text_align_power (abfd) = internal_a->o_algntext; | 2076 | | bfd_xcoff_data_align_power (abfd) = internal_a->o_algndata; | 2077 | | xcoff->modtype = internal_a->o_modtype; | 2078 | | xcoff->cputype = internal_a->o_cputype; | 2079 | | xcoff->maxdata = internal_a->o_maxdata; | 2080 | | xcoff->maxstack = internal_a->o_maxstack; | 2081 | | } | 2082 | | #endif | 2083 | | | 2084 | | #ifdef ARM | 2085 | | /* Set the flags field from the COFF header read in. */ | 2086 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 2087 | | coff->flags = 0; | 2088 | | #endif | 2089 | | | 2090 | | #ifdef COFF_WITH_PE | 2091 | | /* FIXME: I'm not sure this is ever executed, since peicode.h | 2092 | | defines coff_mkobject_hook. */ | 2093 | | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 2094 | | abfd->flags |= HAS_DEBUG; | 2095 | | #endif | 2096 | | | 2097 | 430 | return coff; | 2098 | 430 | } |
Unexecuted instantiation: coff-tic4x.c:coff_mkobject_hook coff-tic54x.c:coff_mkobject_hook Line | Count | Source | 2028 | 406 | { | 2029 | 406 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2030 | 406 | coff_data_type *coff; | 2031 | | | 2032 | 406 | if (! coff_mkobject (abfd)) | 2033 | 0 | return NULL; | 2034 | | | 2035 | 406 | coff = coff_data (abfd); | 2036 | | | 2037 | 406 | coff->sym_filepos = internal_f->f_symptr; | 2038 | | | 2039 | | /* These members communicate important constants about the symbol | 2040 | | table to GDB's symbol-reading code. These `constants' | 2041 | | unfortunately vary among coff implementations... */ | 2042 | 406 | coff->local_n_btmask = N_BTMASK; | 2043 | 406 | coff->local_n_btshft = N_BTSHFT; | 2044 | 406 | coff->local_n_tmask = N_TMASK; | 2045 | 406 | coff->local_n_tshift = N_TSHIFT; | 2046 | 406 | coff->local_symesz = bfd_coff_symesz (abfd); | 2047 | 406 | coff->local_auxesz = bfd_coff_auxesz (abfd); | 2048 | 406 | coff->local_linesz = bfd_coff_linesz (abfd); | 2049 | | | 2050 | 406 | coff->timestamp = internal_f->f_timdat; | 2051 | | | 2052 | 406 | obj_raw_syment_count (abfd) = | 2053 | 406 | obj_conv_table_size (abfd) = | 2054 | 406 | internal_f->f_nsyms; | 2055 | | | 2056 | | #ifdef RS6000COFF_C | 2057 | | if ((internal_f->f_flags & F_SHROBJ) != 0) | 2058 | | abfd->flags |= DYNAMIC; | 2059 | | if (aouthdr != NULL && internal_f->f_opthdr >= bfd_coff_aoutsz (abfd)) | 2060 | | { | 2061 | | struct internal_aouthdr *internal_a = | 2062 | | (struct internal_aouthdr *) aouthdr; | 2063 | | struct xcoff_tdata *xcoff; | 2064 | | | 2065 | | xcoff = xcoff_data (abfd); | 2066 | | # ifdef U803XTOCMAGIC | 2067 | | xcoff->xcoff64 = internal_f->f_magic == U803XTOCMAGIC; | 2068 | | # else | 2069 | | xcoff->xcoff64 = 0; | 2070 | | # endif | 2071 | | xcoff->full_aouthdr = true; | 2072 | | xcoff->toc = internal_a->o_toc; | 2073 | | xcoff->sntoc = internal_a->o_sntoc; | 2074 | | xcoff->snentry = internal_a->o_snentry; | 2075 | | bfd_xcoff_text_align_power (abfd) = internal_a->o_algntext; | 2076 | | bfd_xcoff_data_align_power (abfd) = internal_a->o_algndata; | 2077 | | xcoff->modtype = internal_a->o_modtype; | 2078 | | xcoff->cputype = internal_a->o_cputype; | 2079 | | xcoff->maxdata = internal_a->o_maxdata; | 2080 | | xcoff->maxstack = internal_a->o_maxstack; | 2081 | | } | 2082 | | #endif | 2083 | | | 2084 | | #ifdef ARM | 2085 | | /* Set the flags field from the COFF header read in. */ | 2086 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 2087 | | coff->flags = 0; | 2088 | | #endif | 2089 | | | 2090 | | #ifdef COFF_WITH_PE | 2091 | | /* FIXME: I'm not sure this is ever executed, since peicode.h | 2092 | | defines coff_mkobject_hook. */ | 2093 | | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 2094 | | abfd->flags |= HAS_DEBUG; | 2095 | | #endif | 2096 | | | 2097 | 406 | return coff; | 2098 | 406 | } |
coff-z80.c:coff_mkobject_hook Line | Count | Source | 2028 | 363 | { | 2029 | 363 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2030 | 363 | coff_data_type *coff; | 2031 | | | 2032 | 363 | if (! coff_mkobject (abfd)) | 2033 | 0 | return NULL; | 2034 | | | 2035 | 363 | coff = coff_data (abfd); | 2036 | | | 2037 | 363 | coff->sym_filepos = internal_f->f_symptr; | 2038 | | | 2039 | | /* These members communicate important constants about the symbol | 2040 | | table to GDB's symbol-reading code. These `constants' | 2041 | | unfortunately vary among coff implementations... */ | 2042 | 363 | coff->local_n_btmask = N_BTMASK; | 2043 | 363 | coff->local_n_btshft = N_BTSHFT; | 2044 | 363 | coff->local_n_tmask = N_TMASK; | 2045 | 363 | coff->local_n_tshift = N_TSHIFT; | 2046 | 363 | coff->local_symesz = bfd_coff_symesz (abfd); | 2047 | 363 | coff->local_auxesz = bfd_coff_auxesz (abfd); | 2048 | 363 | coff->local_linesz = bfd_coff_linesz (abfd); | 2049 | | | 2050 | 363 | coff->timestamp = internal_f->f_timdat; | 2051 | | | 2052 | 363 | obj_raw_syment_count (abfd) = | 2053 | 363 | obj_conv_table_size (abfd) = | 2054 | 363 | internal_f->f_nsyms; | 2055 | | | 2056 | | #ifdef RS6000COFF_C | 2057 | | if ((internal_f->f_flags & F_SHROBJ) != 0) | 2058 | | abfd->flags |= DYNAMIC; | 2059 | | if (aouthdr != NULL && internal_f->f_opthdr >= bfd_coff_aoutsz (abfd)) | 2060 | | { | 2061 | | struct internal_aouthdr *internal_a = | 2062 | | (struct internal_aouthdr *) aouthdr; | 2063 | | struct xcoff_tdata *xcoff; | 2064 | | | 2065 | | xcoff = xcoff_data (abfd); | 2066 | | # ifdef U803XTOCMAGIC | 2067 | | xcoff->xcoff64 = internal_f->f_magic == U803XTOCMAGIC; | 2068 | | # else | 2069 | | xcoff->xcoff64 = 0; | 2070 | | # endif | 2071 | | xcoff->full_aouthdr = true; | 2072 | | xcoff->toc = internal_a->o_toc; | 2073 | | xcoff->sntoc = internal_a->o_sntoc; | 2074 | | xcoff->snentry = internal_a->o_snentry; | 2075 | | bfd_xcoff_text_align_power (abfd) = internal_a->o_algntext; | 2076 | | bfd_xcoff_data_align_power (abfd) = internal_a->o_algndata; | 2077 | | xcoff->modtype = internal_a->o_modtype; | 2078 | | xcoff->cputype = internal_a->o_cputype; | 2079 | | xcoff->maxdata = internal_a->o_maxdata; | 2080 | | xcoff->maxstack = internal_a->o_maxstack; | 2081 | | } | 2082 | | #endif | 2083 | | | 2084 | | #ifdef ARM | 2085 | | /* Set the flags field from the COFF header read in. */ | 2086 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 2087 | | coff->flags = 0; | 2088 | | #endif | 2089 | | | 2090 | | #ifdef COFF_WITH_PE | 2091 | | /* FIXME: I'm not sure this is ever executed, since peicode.h | 2092 | | defines coff_mkobject_hook. */ | 2093 | | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 2094 | | abfd->flags |= HAS_DEBUG; | 2095 | | #endif | 2096 | | | 2097 | 363 | return coff; | 2098 | 363 | } |
coff-z8k.c:coff_mkobject_hook Line | Count | Source | 2028 | 365 | { | 2029 | 365 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2030 | 365 | coff_data_type *coff; | 2031 | | | 2032 | 365 | if (! coff_mkobject (abfd)) | 2033 | 0 | return NULL; | 2034 | | | 2035 | 365 | coff = coff_data (abfd); | 2036 | | | 2037 | 365 | coff->sym_filepos = internal_f->f_symptr; | 2038 | | | 2039 | | /* These members communicate important constants about the symbol | 2040 | | table to GDB's symbol-reading code. These `constants' | 2041 | | unfortunately vary among coff implementations... */ | 2042 | 365 | coff->local_n_btmask = N_BTMASK; | 2043 | 365 | coff->local_n_btshft = N_BTSHFT; | 2044 | 365 | coff->local_n_tmask = N_TMASK; | 2045 | 365 | coff->local_n_tshift = N_TSHIFT; | 2046 | 365 | coff->local_symesz = bfd_coff_symesz (abfd); | 2047 | 365 | coff->local_auxesz = bfd_coff_auxesz (abfd); | 2048 | 365 | coff->local_linesz = bfd_coff_linesz (abfd); | 2049 | | | 2050 | 365 | coff->timestamp = internal_f->f_timdat; | 2051 | | | 2052 | 365 | obj_raw_syment_count (abfd) = | 2053 | 365 | obj_conv_table_size (abfd) = | 2054 | 365 | internal_f->f_nsyms; | 2055 | | | 2056 | | #ifdef RS6000COFF_C | 2057 | | if ((internal_f->f_flags & F_SHROBJ) != 0) | 2058 | | abfd->flags |= DYNAMIC; | 2059 | | if (aouthdr != NULL && internal_f->f_opthdr >= bfd_coff_aoutsz (abfd)) | 2060 | | { | 2061 | | struct internal_aouthdr *internal_a = | 2062 | | (struct internal_aouthdr *) aouthdr; | 2063 | | struct xcoff_tdata *xcoff; | 2064 | | | 2065 | | xcoff = xcoff_data (abfd); | 2066 | | # ifdef U803XTOCMAGIC | 2067 | | xcoff->xcoff64 = internal_f->f_magic == U803XTOCMAGIC; | 2068 | | # else | 2069 | | xcoff->xcoff64 = 0; | 2070 | | # endif | 2071 | | xcoff->full_aouthdr = true; | 2072 | | xcoff->toc = internal_a->o_toc; | 2073 | | xcoff->sntoc = internal_a->o_sntoc; | 2074 | | xcoff->snentry = internal_a->o_snentry; | 2075 | | bfd_xcoff_text_align_power (abfd) = internal_a->o_algntext; | 2076 | | bfd_xcoff_data_align_power (abfd) = internal_a->o_algndata; | 2077 | | xcoff->modtype = internal_a->o_modtype; | 2078 | | xcoff->cputype = internal_a->o_cputype; | 2079 | | xcoff->maxdata = internal_a->o_maxdata; | 2080 | | xcoff->maxstack = internal_a->o_maxstack; | 2081 | | } | 2082 | | #endif | 2083 | | | 2084 | | #ifdef ARM | 2085 | | /* Set the flags field from the COFF header read in. */ | 2086 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 2087 | | coff->flags = 0; | 2088 | | #endif | 2089 | | | 2090 | | #ifdef COFF_WITH_PE | 2091 | | /* FIXME: I'm not sure this is ever executed, since peicode.h | 2092 | | defines coff_mkobject_hook. */ | 2093 | | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 2094 | | abfd->flags |= HAS_DEBUG; | 2095 | | #endif | 2096 | | | 2097 | 365 | return coff; | 2098 | 365 | } |
|
2099 | | #endif |
2100 | | |
2101 | | /* Determine the machine architecture and type. FIXME: This is target |
2102 | | dependent because the magic numbers are defined in the target |
2103 | | dependent header files. But there is no particular need for this. |
2104 | | If the magic numbers were moved to a separate file, this function |
2105 | | would be target independent and would also be much more successful |
2106 | | at linking together COFF files for different architectures. */ |
2107 | | |
2108 | | static bool |
2109 | | coff_set_arch_mach_hook (bfd *abfd, void * filehdr) |
2110 | 12.8k | { |
2111 | 12.8k | unsigned long machine; |
2112 | 12.8k | enum bfd_architecture arch; |
2113 | 12.8k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; |
2114 | | |
2115 | | /* Zero selects the default machine for an arch. */ |
2116 | 12.8k | machine = 0; |
2117 | 12.8k | switch (internal_f->f_magic) |
2118 | 12.8k | { |
2119 | | #ifdef I386MAGIC |
2120 | 749 | case I386MAGIC: |
2121 | 772 | case I386PTXMAGIC: |
2122 | 782 | case I386AIXMAGIC: /* Danbury PS/2 AIX C Compiler. */ |
2123 | 2.56k | case LYNXCOFFMAGIC: |
2124 | 2.57k | case I386_APPLE_MAGIC: |
2125 | 2.57k | case I386_FREEBSD_MAGIC: |
2126 | 2.57k | case I386_LINUX_MAGIC: |
2127 | 2.58k | case I386_NETBSD_MAGIC: |
2128 | 2.58k | arch = bfd_arch_i386; |
2129 | 2.58k | break; |
2130 | 0 | #endif |
2131 | | #ifdef AMD64MAGIC |
2132 | 819 | case AMD64MAGIC: |
2133 | 995 | case AMD64_APPLE_MAGIC: |
2134 | 1.02k | case AMD64_FREEBSD_MAGIC: |
2135 | 1.03k | case AMD64_LINUX_MAGIC: |
2136 | 2.87k | case AMD64_NETBSD_MAGIC: |
2137 | 2.87k | arch = bfd_arch_i386; |
2138 | 2.87k | machine = bfd_mach_x86_64; |
2139 | 2.87k | break; |
2140 | 0 | #endif |
2141 | | #ifdef IA64MAGIC |
2142 | 371 | case IA64MAGIC: |
2143 | 371 | arch = bfd_arch_ia64; |
2144 | 371 | break; |
2145 | 0 | #endif |
2146 | | #ifdef ARMMAGIC |
2147 | 997 | case ARMMAGIC: |
2148 | 1.07k | case ARMPEMAGIC: |
2149 | 1.13k | case THUMBPEMAGIC: |
2150 | 1.13k | arch = bfd_arch_arm; |
2151 | 1.13k | machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION); |
2152 | 1.13k | if (machine == bfd_mach_arm_unknown) |
2153 | 1.13k | { |
2154 | 1.13k | switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK) |
2155 | 1.13k | { |
2156 | 281 | case F_ARM_2: machine = bfd_mach_arm_2; break; |
2157 | 34 | case F_ARM_2a: machine = bfd_mach_arm_2a; break; |
2158 | 31 | case F_ARM_3: machine = bfd_mach_arm_3; break; |
2159 | 497 | default: |
2160 | 594 | case F_ARM_3M: machine = bfd_mach_arm_3M; break; |
2161 | 50 | case F_ARM_4: machine = bfd_mach_arm_4; break; |
2162 | 34 | case F_ARM_4T: machine = bfd_mach_arm_4T; break; |
2163 | | /* The COFF header does not have enough bits available |
2164 | | to cover all the different ARM architectures. So |
2165 | | we interpret F_ARM_5, the highest flag value to mean |
2166 | | "the highest ARM architecture known to BFD" which is |
2167 | | currently the XScale. */ |
2168 | 107 | case F_ARM_5: machine = bfd_mach_arm_XScale; break; |
2169 | 1.13k | } |
2170 | 1.13k | } |
2171 | 1.13k | break; |
2172 | 1.13k | #endif |
2173 | | #ifdef AARCH64MAGIC |
2174 | 792 | case AARCH64MAGIC: |
2175 | 792 | arch = bfd_arch_aarch64; |
2176 | 792 | machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK; |
2177 | 792 | break; |
2178 | 0 | #endif |
2179 | | #ifdef LOONGARCH64MAGIC |
2180 | 441 | case LOONGARCH64MAGIC: |
2181 | 441 | arch = bfd_arch_loongarch; |
2182 | 441 | machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK; |
2183 | 441 | break; |
2184 | 0 | #endif |
2185 | | #ifdef Z80MAGIC |
2186 | 363 | case Z80MAGIC: |
2187 | 363 | arch = bfd_arch_z80; |
2188 | 363 | switch (internal_f->f_flags & F_MACHMASK) |
2189 | 363 | { |
2190 | 2 | case bfd_mach_z80strict << 12: |
2191 | 6 | case bfd_mach_z80 << 12: |
2192 | 46 | case bfd_mach_z80n << 12: |
2193 | 54 | case bfd_mach_z80full << 12: |
2194 | 125 | case bfd_mach_r800 << 12: |
2195 | 151 | case bfd_mach_gbz80 << 12: |
2196 | 203 | case bfd_mach_z180 << 12: |
2197 | 350 | case bfd_mach_ez80_z80 << 12: |
2198 | 362 | case bfd_mach_ez80_adl << 12: |
2199 | 362 | machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12; |
2200 | 362 | break; |
2201 | 1 | default: |
2202 | 1 | return false; |
2203 | 363 | } |
2204 | 362 | break; |
2205 | 362 | #endif |
2206 | | #ifdef Z8KMAGIC |
2207 | 358 | case Z8KMAGIC: |
2208 | 358 | arch = bfd_arch_z8k; |
2209 | 358 | switch (internal_f->f_flags & F_MACHMASK) |
2210 | 358 | { |
2211 | 67 | case F_Z8001: |
2212 | 67 | machine = bfd_mach_z8001; |
2213 | 67 | break; |
2214 | 287 | case F_Z8002: |
2215 | 287 | machine = bfd_mach_z8002; |
2216 | 287 | break; |
2217 | 4 | default: |
2218 | 4 | return false; |
2219 | 358 | } |
2220 | 354 | break; |
2221 | 354 | #endif |
2222 | | |
2223 | | #ifdef RS6000COFF_C |
2224 | | #ifdef XCOFF64 |
2225 | 576 | case U64_TOCMAGIC: |
2226 | 623 | case U803XTOCMAGIC: |
2227 | | #else |
2228 | 567 | case U802ROMAGIC: |
2229 | 597 | case U802WRMAGIC: |
2230 | 608 | case U802TOCMAGIC: |
2231 | | #endif |
2232 | 608 | { |
2233 | 608 | int cputype; |
2234 | | |
2235 | 1.23k | if (xcoff_data (abfd)->cputype != -1) |
2236 | 37 | cputype = xcoff_data (abfd)->cputype & 0xff; |
2237 | 1.19k | else |
2238 | 1.19k | { |
2239 | | /* We did not get a value from the a.out header. If the |
2240 | | file has not been stripped, we may be able to get the |
2241 | | architecture information from the first symbol, if it |
2242 | | is a .file symbol. */ |
2243 | 1.19k | if (obj_raw_syment_count (abfd) == 0) |
2244 | 75 | cputype = 0; |
2245 | 1.11k | else |
2246 | 1.11k | { |
2247 | 1.11k | bfd_byte *buf; |
2248 | 1.11k | struct internal_syment sym; |
2249 | 1.11k | bfd_size_type amt = bfd_coff_symesz (abfd); |
2250 | | |
2251 | 1.11k | if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0) |
2252 | 3 | return false; |
2253 | 1.11k | buf = _bfd_malloc_and_read (abfd, amt, amt); |
2254 | 1.11k | if (buf == NULL) |
2255 | 9 | return false; |
2256 | 1.10k | bfd_coff_swap_sym_in (abfd, buf, & sym); |
2257 | 1.10k | if (sym.n_sclass == C_FILE) |
2258 | 3 | cputype = sym.n_type & 0xff; |
2259 | 1.10k | else |
2260 | 1.10k | cputype = 0; |
2261 | 1.10k | free (buf); |
2262 | 1.10k | } |
2263 | 1.19k | } |
2264 | | |
2265 | | /* FIXME: We don't handle all cases here. */ |
2266 | 1.21k | switch (cputype) |
2267 | 1.21k | { |
2268 | 18 | default: |
2269 | 1.20k | case 0: |
2270 | 1.20k | arch = bfd_xcoff_architecture (abfd); |
2271 | 1.20k | machine = bfd_xcoff_machine (abfd); |
2272 | 1.20k | break; |
2273 | | |
2274 | 4 | case 1: |
2275 | 4 | arch = bfd_arch_powerpc; |
2276 | 4 | machine = bfd_mach_ppc_601; |
2277 | 4 | break; |
2278 | 2 | case 2: /* 64 bit PowerPC */ |
2279 | 2 | arch = bfd_arch_powerpc; |
2280 | 2 | machine = bfd_mach_ppc_620; |
2281 | 2 | break; |
2282 | 4 | case 3: |
2283 | 4 | arch = bfd_arch_powerpc; |
2284 | 4 | machine = bfd_mach_ppc; |
2285 | 4 | break; |
2286 | 2 | case 4: |
2287 | 2 | arch = bfd_arch_rs6000; |
2288 | 2 | machine = bfd_mach_rs6k; |
2289 | 2 | break; |
2290 | 1.21k | } |
2291 | 1.21k | } |
2292 | 1.21k | break; |
2293 | 1.21k | #endif |
2294 | | |
2295 | | #ifdef SH_ARCH_MAGIC_BIG |
2296 | 1.14k | case SH_ARCH_MAGIC_BIG: |
2297 | 1.14k | case SH_ARCH_MAGIC_LITTLE: |
2298 | | #ifdef COFF_WITH_PE |
2299 | 800 | case SH_ARCH_MAGIC_WINCE: |
2300 | | #endif |
2301 | 800 | arch = bfd_arch_sh; |
2302 | 800 | break; |
2303 | 0 | #endif |
2304 | | |
2305 | | #ifdef MIPS_ARCH_MAGIC_WINCE |
2306 | | case MIPS_ARCH_MAGIC_WINCE: |
2307 | | arch = bfd_arch_mips; |
2308 | | break; |
2309 | | #endif |
2310 | | |
2311 | | #ifdef SPARCMAGIC |
2312 | | case SPARCMAGIC: |
2313 | | #ifdef LYNXCOFFMAGIC |
2314 | | case LYNXCOFFMAGIC: |
2315 | | #endif |
2316 | | arch = bfd_arch_sparc; |
2317 | | break; |
2318 | | #endif |
2319 | | |
2320 | | #ifdef TIC30MAGIC |
2321 | 429 | case TIC30MAGIC: |
2322 | 429 | arch = bfd_arch_tic30; |
2323 | 429 | break; |
2324 | 0 | #endif |
2325 | | |
2326 | | #ifdef TICOFF0MAGIC |
2327 | | #ifdef TICOFF_TARGET_ARCH |
2328 | | /* This TI COFF section should be used by all new TI COFF v0 targets. */ |
2329 | 397 | case TICOFF0MAGIC: |
2330 | 397 | arch = TICOFF_TARGET_ARCH; |
2331 | 397 | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); |
2332 | 397 | break; |
2333 | 0 | #endif |
2334 | 0 | #endif |
2335 | | |
2336 | | #ifdef TICOFF1MAGIC |
2337 | | /* This TI COFF section should be used by all new TI COFF v1/2 targets. */ |
2338 | | /* TI COFF1 and COFF2 use the target_id field to specify which arch. */ |
2339 | 1 | case TICOFF1MAGIC: |
2340 | 6 | case TICOFF2MAGIC: |
2341 | 6 | switch (internal_f->f_target_id) |
2342 | 6 | { |
2343 | 0 | #ifdef TI_TARGET_ID |
2344 | 6 | case TI_TARGET_ID: |
2345 | 6 | arch = TICOFF_TARGET_ARCH; |
2346 | 6 | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); |
2347 | 6 | break; |
2348 | 0 | #endif |
2349 | 0 | default: |
2350 | 0 | arch = bfd_arch_obscure; |
2351 | 0 | _bfd_error_handler |
2352 | 0 | (_("unrecognized TI COFF target id '0x%x'"), |
2353 | 0 | internal_f->f_target_id); |
2354 | 0 | break; |
2355 | 6 | } |
2356 | 6 | break; |
2357 | 6 | #endif |
2358 | | |
2359 | | #ifdef MCOREMAGIC |
2360 | 682 | case MCOREMAGIC: |
2361 | 682 | arch = bfd_arch_mcore; |
2362 | 682 | break; |
2363 | 0 | #endif |
2364 | | |
2365 | 39 | default: /* Unreadable input file type. */ |
2366 | 39 | arch = bfd_arch_obscure; |
2367 | 39 | break; |
2368 | 12.8k | } |
2369 | | |
2370 | 12.8k | bfd_default_set_arch_mach (abfd, arch, machine); |
2371 | 12.8k | return true; |
2372 | 12.8k | } pei-i386.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 556 | { | 2111 | 556 | unsigned long machine; | 2112 | 556 | enum bfd_architecture arch; | 2113 | 556 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 556 | machine = 0; | 2117 | 556 | switch (internal_f->f_magic) | 2118 | 556 | { | 2119 | 0 | #ifdef I386MAGIC | 2120 | 545 | case I386MAGIC: | 2121 | 548 | case I386PTXMAGIC: | 2122 | 551 | case I386AIXMAGIC: /* Danbury PS/2 AIX C Compiler. */ | 2123 | 554 | case LYNXCOFFMAGIC: | 2124 | 554 | case I386_APPLE_MAGIC: | 2125 | 554 | case I386_FREEBSD_MAGIC: | 2126 | 554 | case I386_LINUX_MAGIC: | 2127 | 556 | case I386_NETBSD_MAGIC: | 2128 | 556 | arch = bfd_arch_i386; | 2129 | 556 | break; | 2130 | 0 | #endif | 2131 | | #ifdef AMD64MAGIC | 2132 | | case AMD64MAGIC: | 2133 | | case AMD64_APPLE_MAGIC: | 2134 | | case AMD64_FREEBSD_MAGIC: | 2135 | | case AMD64_LINUX_MAGIC: | 2136 | | case AMD64_NETBSD_MAGIC: | 2137 | | arch = bfd_arch_i386; | 2138 | | machine = bfd_mach_x86_64; | 2139 | | break; | 2140 | | #endif | 2141 | | #ifdef IA64MAGIC | 2142 | | case IA64MAGIC: | 2143 | | arch = bfd_arch_ia64; | 2144 | | break; | 2145 | | #endif | 2146 | | #ifdef ARMMAGIC | 2147 | | case ARMMAGIC: | 2148 | | case ARMPEMAGIC: | 2149 | | case THUMBPEMAGIC: | 2150 | | arch = bfd_arch_arm; | 2151 | | machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION); | 2152 | | if (machine == bfd_mach_arm_unknown) | 2153 | | { | 2154 | | switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK) | 2155 | | { | 2156 | | case F_ARM_2: machine = bfd_mach_arm_2; break; | 2157 | | case F_ARM_2a: machine = bfd_mach_arm_2a; break; | 2158 | | case F_ARM_3: machine = bfd_mach_arm_3; break; | 2159 | | default: | 2160 | | case F_ARM_3M: machine = bfd_mach_arm_3M; break; | 2161 | | case F_ARM_4: machine = bfd_mach_arm_4; break; | 2162 | | case F_ARM_4T: machine = bfd_mach_arm_4T; break; | 2163 | | /* The COFF header does not have enough bits available | 2164 | | to cover all the different ARM architectures. So | 2165 | | we interpret F_ARM_5, the highest flag value to mean | 2166 | | "the highest ARM architecture known to BFD" which is | 2167 | | currently the XScale. */ | 2168 | | case F_ARM_5: machine = bfd_mach_arm_XScale; break; | 2169 | | } | 2170 | | } | 2171 | | break; | 2172 | | #endif | 2173 | | #ifdef AARCH64MAGIC | 2174 | | case AARCH64MAGIC: | 2175 | | arch = bfd_arch_aarch64; | 2176 | | machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK; | 2177 | | break; | 2178 | | #endif | 2179 | | #ifdef LOONGARCH64MAGIC | 2180 | | case LOONGARCH64MAGIC: | 2181 | | arch = bfd_arch_loongarch; | 2182 | | machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK; | 2183 | | break; | 2184 | | #endif | 2185 | | #ifdef Z80MAGIC | 2186 | | case Z80MAGIC: | 2187 | | arch = bfd_arch_z80; | 2188 | | switch (internal_f->f_flags & F_MACHMASK) | 2189 | | { | 2190 | | case bfd_mach_z80strict << 12: | 2191 | | case bfd_mach_z80 << 12: | 2192 | | case bfd_mach_z80n << 12: | 2193 | | case bfd_mach_z80full << 12: | 2194 | | case bfd_mach_r800 << 12: | 2195 | | case bfd_mach_gbz80 << 12: | 2196 | | case bfd_mach_z180 << 12: | 2197 | | case bfd_mach_ez80_z80 << 12: | 2198 | | case bfd_mach_ez80_adl << 12: | 2199 | | machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12; | 2200 | | break; | 2201 | | default: | 2202 | | return false; | 2203 | | } | 2204 | | break; | 2205 | | #endif | 2206 | | #ifdef Z8KMAGIC | 2207 | | case Z8KMAGIC: | 2208 | | arch = bfd_arch_z8k; | 2209 | | switch (internal_f->f_flags & F_MACHMASK) | 2210 | | { | 2211 | | case F_Z8001: | 2212 | | machine = bfd_mach_z8001; | 2213 | | break; | 2214 | | case F_Z8002: | 2215 | | machine = bfd_mach_z8002; | 2216 | | break; | 2217 | | default: | 2218 | | return false; | 2219 | | } | 2220 | | break; | 2221 | | #endif | 2222 | | | 2223 | | #ifdef RS6000COFF_C | 2224 | | #ifdef XCOFF64 | 2225 | | case U64_TOCMAGIC: | 2226 | | case U803XTOCMAGIC: | 2227 | | #else | 2228 | | case U802ROMAGIC: | 2229 | | case U802WRMAGIC: | 2230 | | case U802TOCMAGIC: | 2231 | | #endif | 2232 | | { | 2233 | | int cputype; | 2234 | | | 2235 | | if (xcoff_data (abfd)->cputype != -1) | 2236 | | cputype = xcoff_data (abfd)->cputype & 0xff; | 2237 | | else | 2238 | | { | 2239 | | /* We did not get a value from the a.out header. If the | 2240 | | file has not been stripped, we may be able to get the | 2241 | | architecture information from the first symbol, if it | 2242 | | is a .file symbol. */ | 2243 | | if (obj_raw_syment_count (abfd) == 0) | 2244 | | cputype = 0; | 2245 | | else | 2246 | | { | 2247 | | bfd_byte *buf; | 2248 | | struct internal_syment sym; | 2249 | | bfd_size_type amt = bfd_coff_symesz (abfd); | 2250 | | | 2251 | | if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0) | 2252 | | return false; | 2253 | | buf = _bfd_malloc_and_read (abfd, amt, amt); | 2254 | | if (buf == NULL) | 2255 | | return false; | 2256 | | bfd_coff_swap_sym_in (abfd, buf, & sym); | 2257 | | if (sym.n_sclass == C_FILE) | 2258 | | cputype = sym.n_type & 0xff; | 2259 | | else | 2260 | | cputype = 0; | 2261 | | free (buf); | 2262 | | } | 2263 | | } | 2264 | | | 2265 | | /* FIXME: We don't handle all cases here. */ | 2266 | | switch (cputype) | 2267 | | { | 2268 | | default: | 2269 | | case 0: | 2270 | | arch = bfd_xcoff_architecture (abfd); | 2271 | | machine = bfd_xcoff_machine (abfd); | 2272 | | break; | 2273 | | | 2274 | | case 1: | 2275 | | arch = bfd_arch_powerpc; | 2276 | | machine = bfd_mach_ppc_601; | 2277 | | break; | 2278 | | case 2: /* 64 bit PowerPC */ | 2279 | | arch = bfd_arch_powerpc; | 2280 | | machine = bfd_mach_ppc_620; | 2281 | | break; | 2282 | | case 3: | 2283 | | arch = bfd_arch_powerpc; | 2284 | | machine = bfd_mach_ppc; | 2285 | | break; | 2286 | | case 4: | 2287 | | arch = bfd_arch_rs6000; | 2288 | | machine = bfd_mach_rs6k; | 2289 | | break; | 2290 | | } | 2291 | | } | 2292 | | break; | 2293 | | #endif | 2294 | | | 2295 | | #ifdef SH_ARCH_MAGIC_BIG | 2296 | | case SH_ARCH_MAGIC_BIG: | 2297 | | case SH_ARCH_MAGIC_LITTLE: | 2298 | | #ifdef COFF_WITH_PE | 2299 | | case SH_ARCH_MAGIC_WINCE: | 2300 | | #endif | 2301 | | arch = bfd_arch_sh; | 2302 | | break; | 2303 | | #endif | 2304 | | | 2305 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 2306 | | case MIPS_ARCH_MAGIC_WINCE: | 2307 | | arch = bfd_arch_mips; | 2308 | | break; | 2309 | | #endif | 2310 | | | 2311 | | #ifdef SPARCMAGIC | 2312 | | case SPARCMAGIC: | 2313 | | #ifdef LYNXCOFFMAGIC | 2314 | | case LYNXCOFFMAGIC: | 2315 | | #endif | 2316 | | arch = bfd_arch_sparc; | 2317 | | break; | 2318 | | #endif | 2319 | | | 2320 | | #ifdef TIC30MAGIC | 2321 | | case TIC30MAGIC: | 2322 | | arch = bfd_arch_tic30; | 2323 | | break; | 2324 | | #endif | 2325 | | | 2326 | | #ifdef TICOFF0MAGIC | 2327 | | #ifdef TICOFF_TARGET_ARCH | 2328 | | /* This TI COFF section should be used by all new TI COFF v0 targets. */ | 2329 | | case TICOFF0MAGIC: | 2330 | | arch = TICOFF_TARGET_ARCH; | 2331 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2332 | | break; | 2333 | | #endif | 2334 | | #endif | 2335 | | | 2336 | | #ifdef TICOFF1MAGIC | 2337 | | /* This TI COFF section should be used by all new TI COFF v1/2 targets. */ | 2338 | | /* TI COFF1 and COFF2 use the target_id field to specify which arch. */ | 2339 | | case TICOFF1MAGIC: | 2340 | | case TICOFF2MAGIC: | 2341 | | switch (internal_f->f_target_id) | 2342 | | { | 2343 | | #ifdef TI_TARGET_ID | 2344 | | case TI_TARGET_ID: | 2345 | | arch = TICOFF_TARGET_ARCH; | 2346 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2347 | | break; | 2348 | | #endif | 2349 | | default: | 2350 | | arch = bfd_arch_obscure; | 2351 | | _bfd_error_handler | 2352 | | (_("unrecognized TI COFF target id '0x%x'"), | 2353 | | internal_f->f_target_id); | 2354 | | break; | 2355 | | } | 2356 | | break; | 2357 | | #endif | 2358 | | | 2359 | | #ifdef MCOREMAGIC | 2360 | | case MCOREMAGIC: | 2361 | | arch = bfd_arch_mcore; | 2362 | | break; | 2363 | | #endif | 2364 | | | 2365 | 0 | default: /* Unreadable input file type. */ | 2366 | 0 | arch = bfd_arch_obscure; | 2367 | 0 | break; | 2368 | 556 | } | 2369 | | | 2370 | 556 | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 556 | return true; | 2372 | 556 | } |
pe-x86_64.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 1.42k | { | 2111 | 1.42k | unsigned long machine; | 2112 | 1.42k | enum bfd_architecture arch; | 2113 | 1.42k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 1.42k | machine = 0; | 2117 | 1.42k | switch (internal_f->f_magic) | 2118 | 1.42k | { | 2119 | | #ifdef I386MAGIC | 2120 | | case I386MAGIC: | 2121 | | case I386PTXMAGIC: | 2122 | | case I386AIXMAGIC: /* Danbury PS/2 AIX C Compiler. */ | 2123 | | case LYNXCOFFMAGIC: | 2124 | | case I386_APPLE_MAGIC: | 2125 | | case I386_FREEBSD_MAGIC: | 2126 | | case I386_LINUX_MAGIC: | 2127 | | case I386_NETBSD_MAGIC: | 2128 | | arch = bfd_arch_i386; | 2129 | | break; | 2130 | | #endif | 2131 | 0 | #ifdef AMD64MAGIC | 2132 | 283 | case AMD64MAGIC: | 2133 | 379 | case AMD64_APPLE_MAGIC: | 2134 | 395 | case AMD64_FREEBSD_MAGIC: | 2135 | 401 | case AMD64_LINUX_MAGIC: | 2136 | 1.42k | case AMD64_NETBSD_MAGIC: | 2137 | 1.42k | arch = bfd_arch_i386; | 2138 | 1.42k | machine = bfd_mach_x86_64; | 2139 | 1.42k | break; | 2140 | 0 | #endif | 2141 | | #ifdef IA64MAGIC | 2142 | | case IA64MAGIC: | 2143 | | arch = bfd_arch_ia64; | 2144 | | break; | 2145 | | #endif | 2146 | | #ifdef ARMMAGIC | 2147 | | case ARMMAGIC: | 2148 | | case ARMPEMAGIC: | 2149 | | case THUMBPEMAGIC: | 2150 | | arch = bfd_arch_arm; | 2151 | | machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION); | 2152 | | if (machine == bfd_mach_arm_unknown) | 2153 | | { | 2154 | | switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK) | 2155 | | { | 2156 | | case F_ARM_2: machine = bfd_mach_arm_2; break; | 2157 | | case F_ARM_2a: machine = bfd_mach_arm_2a; break; | 2158 | | case F_ARM_3: machine = bfd_mach_arm_3; break; | 2159 | | default: | 2160 | | case F_ARM_3M: machine = bfd_mach_arm_3M; break; | 2161 | | case F_ARM_4: machine = bfd_mach_arm_4; break; | 2162 | | case F_ARM_4T: machine = bfd_mach_arm_4T; break; | 2163 | | /* The COFF header does not have enough bits available | 2164 | | to cover all the different ARM architectures. So | 2165 | | we interpret F_ARM_5, the highest flag value to mean | 2166 | | "the highest ARM architecture known to BFD" which is | 2167 | | currently the XScale. */ | 2168 | | case F_ARM_5: machine = bfd_mach_arm_XScale; break; | 2169 | | } | 2170 | | } | 2171 | | break; | 2172 | | #endif | 2173 | | #ifdef AARCH64MAGIC | 2174 | | case AARCH64MAGIC: | 2175 | | arch = bfd_arch_aarch64; | 2176 | | machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK; | 2177 | | break; | 2178 | | #endif | 2179 | | #ifdef LOONGARCH64MAGIC | 2180 | | case LOONGARCH64MAGIC: | 2181 | | arch = bfd_arch_loongarch; | 2182 | | machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK; | 2183 | | break; | 2184 | | #endif | 2185 | | #ifdef Z80MAGIC | 2186 | | case Z80MAGIC: | 2187 | | arch = bfd_arch_z80; | 2188 | | switch (internal_f->f_flags & F_MACHMASK) | 2189 | | { | 2190 | | case bfd_mach_z80strict << 12: | 2191 | | case bfd_mach_z80 << 12: | 2192 | | case bfd_mach_z80n << 12: | 2193 | | case bfd_mach_z80full << 12: | 2194 | | case bfd_mach_r800 << 12: | 2195 | | case bfd_mach_gbz80 << 12: | 2196 | | case bfd_mach_z180 << 12: | 2197 | | case bfd_mach_ez80_z80 << 12: | 2198 | | case bfd_mach_ez80_adl << 12: | 2199 | | machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12; | 2200 | | break; | 2201 | | default: | 2202 | | return false; | 2203 | | } | 2204 | | break; | 2205 | | #endif | 2206 | | #ifdef Z8KMAGIC | 2207 | | case Z8KMAGIC: | 2208 | | arch = bfd_arch_z8k; | 2209 | | switch (internal_f->f_flags & F_MACHMASK) | 2210 | | { | 2211 | | case F_Z8001: | 2212 | | machine = bfd_mach_z8001; | 2213 | | break; | 2214 | | case F_Z8002: | 2215 | | machine = bfd_mach_z8002; | 2216 | | break; | 2217 | | default: | 2218 | | return false; | 2219 | | } | 2220 | | break; | 2221 | | #endif | 2222 | | | 2223 | | #ifdef RS6000COFF_C | 2224 | | #ifdef XCOFF64 | 2225 | | case U64_TOCMAGIC: | 2226 | | case U803XTOCMAGIC: | 2227 | | #else | 2228 | | case U802ROMAGIC: | 2229 | | case U802WRMAGIC: | 2230 | | case U802TOCMAGIC: | 2231 | | #endif | 2232 | | { | 2233 | | int cputype; | 2234 | | | 2235 | | if (xcoff_data (abfd)->cputype != -1) | 2236 | | cputype = xcoff_data (abfd)->cputype & 0xff; | 2237 | | else | 2238 | | { | 2239 | | /* We did not get a value from the a.out header. If the | 2240 | | file has not been stripped, we may be able to get the | 2241 | | architecture information from the first symbol, if it | 2242 | | is a .file symbol. */ | 2243 | | if (obj_raw_syment_count (abfd) == 0) | 2244 | | cputype = 0; | 2245 | | else | 2246 | | { | 2247 | | bfd_byte *buf; | 2248 | | struct internal_syment sym; | 2249 | | bfd_size_type amt = bfd_coff_symesz (abfd); | 2250 | | | 2251 | | if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0) | 2252 | | return false; | 2253 | | buf = _bfd_malloc_and_read (abfd, amt, amt); | 2254 | | if (buf == NULL) | 2255 | | return false; | 2256 | | bfd_coff_swap_sym_in (abfd, buf, & sym); | 2257 | | if (sym.n_sclass == C_FILE) | 2258 | | cputype = sym.n_type & 0xff; | 2259 | | else | 2260 | | cputype = 0; | 2261 | | free (buf); | 2262 | | } | 2263 | | } | 2264 | | | 2265 | | /* FIXME: We don't handle all cases here. */ | 2266 | | switch (cputype) | 2267 | | { | 2268 | | default: | 2269 | | case 0: | 2270 | | arch = bfd_xcoff_architecture (abfd); | 2271 | | machine = bfd_xcoff_machine (abfd); | 2272 | | break; | 2273 | | | 2274 | | case 1: | 2275 | | arch = bfd_arch_powerpc; | 2276 | | machine = bfd_mach_ppc_601; | 2277 | | break; | 2278 | | case 2: /* 64 bit PowerPC */ | 2279 | | arch = bfd_arch_powerpc; | 2280 | | machine = bfd_mach_ppc_620; | 2281 | | break; | 2282 | | case 3: | 2283 | | arch = bfd_arch_powerpc; | 2284 | | machine = bfd_mach_ppc; | 2285 | | break; | 2286 | | case 4: | 2287 | | arch = bfd_arch_rs6000; | 2288 | | machine = bfd_mach_rs6k; | 2289 | | break; | 2290 | | } | 2291 | | } | 2292 | | break; | 2293 | | #endif | 2294 | | | 2295 | | #ifdef SH_ARCH_MAGIC_BIG | 2296 | | case SH_ARCH_MAGIC_BIG: | 2297 | | case SH_ARCH_MAGIC_LITTLE: | 2298 | | #ifdef COFF_WITH_PE | 2299 | | case SH_ARCH_MAGIC_WINCE: | 2300 | | #endif | 2301 | | arch = bfd_arch_sh; | 2302 | | break; | 2303 | | #endif | 2304 | | | 2305 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 2306 | | case MIPS_ARCH_MAGIC_WINCE: | 2307 | | arch = bfd_arch_mips; | 2308 | | break; | 2309 | | #endif | 2310 | | | 2311 | | #ifdef SPARCMAGIC | 2312 | | case SPARCMAGIC: | 2313 | | #ifdef LYNXCOFFMAGIC | 2314 | | case LYNXCOFFMAGIC: | 2315 | | #endif | 2316 | | arch = bfd_arch_sparc; | 2317 | | break; | 2318 | | #endif | 2319 | | | 2320 | | #ifdef TIC30MAGIC | 2321 | | case TIC30MAGIC: | 2322 | | arch = bfd_arch_tic30; | 2323 | | break; | 2324 | | #endif | 2325 | | | 2326 | | #ifdef TICOFF0MAGIC | 2327 | | #ifdef TICOFF_TARGET_ARCH | 2328 | | /* This TI COFF section should be used by all new TI COFF v0 targets. */ | 2329 | | case TICOFF0MAGIC: | 2330 | | arch = TICOFF_TARGET_ARCH; | 2331 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2332 | | break; | 2333 | | #endif | 2334 | | #endif | 2335 | | | 2336 | | #ifdef TICOFF1MAGIC | 2337 | | /* This TI COFF section should be used by all new TI COFF v1/2 targets. */ | 2338 | | /* TI COFF1 and COFF2 use the target_id field to specify which arch. */ | 2339 | | case TICOFF1MAGIC: | 2340 | | case TICOFF2MAGIC: | 2341 | | switch (internal_f->f_target_id) | 2342 | | { | 2343 | | #ifdef TI_TARGET_ID | 2344 | | case TI_TARGET_ID: | 2345 | | arch = TICOFF_TARGET_ARCH; | 2346 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2347 | | break; | 2348 | | #endif | 2349 | | default: | 2350 | | arch = bfd_arch_obscure; | 2351 | | _bfd_error_handler | 2352 | | (_("unrecognized TI COFF target id '0x%x'"), | 2353 | | internal_f->f_target_id); | 2354 | | break; | 2355 | | } | 2356 | | break; | 2357 | | #endif | 2358 | | | 2359 | | #ifdef MCOREMAGIC | 2360 | | case MCOREMAGIC: | 2361 | | arch = bfd_arch_mcore; | 2362 | | break; | 2363 | | #endif | 2364 | | | 2365 | 0 | default: /* Unreadable input file type. */ | 2366 | 0 | arch = bfd_arch_obscure; | 2367 | 0 | break; | 2368 | 1.42k | } | 2369 | | | 2370 | 1.42k | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 1.42k | return true; | 2372 | 1.42k | } |
pei-x86_64.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 472 | { | 2111 | 472 | unsigned long machine; | 2112 | 472 | enum bfd_architecture arch; | 2113 | 472 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 472 | machine = 0; | 2117 | 472 | switch (internal_f->f_magic) | 2118 | 472 | { | 2119 | | #ifdef I386MAGIC | 2120 | | case I386MAGIC: | 2121 | | case I386PTXMAGIC: | 2122 | | case I386AIXMAGIC: /* Danbury PS/2 AIX C Compiler. */ | 2123 | | case LYNXCOFFMAGIC: | 2124 | | case I386_APPLE_MAGIC: | 2125 | | case I386_FREEBSD_MAGIC: | 2126 | | case I386_LINUX_MAGIC: | 2127 | | case I386_NETBSD_MAGIC: | 2128 | | arch = bfd_arch_i386; | 2129 | | break; | 2130 | | #endif | 2131 | 0 | #ifdef AMD64MAGIC | 2132 | 370 | case AMD64MAGIC: | 2133 | 373 | case AMD64_APPLE_MAGIC: | 2134 | 376 | case AMD64_FREEBSD_MAGIC: | 2135 | 379 | case AMD64_LINUX_MAGIC: | 2136 | 472 | case AMD64_NETBSD_MAGIC: | 2137 | 472 | arch = bfd_arch_i386; | 2138 | 472 | machine = bfd_mach_x86_64; | 2139 | 472 | break; | 2140 | 0 | #endif | 2141 | | #ifdef IA64MAGIC | 2142 | | case IA64MAGIC: | 2143 | | arch = bfd_arch_ia64; | 2144 | | break; | 2145 | | #endif | 2146 | | #ifdef ARMMAGIC | 2147 | | case ARMMAGIC: | 2148 | | case ARMPEMAGIC: | 2149 | | case THUMBPEMAGIC: | 2150 | | arch = bfd_arch_arm; | 2151 | | machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION); | 2152 | | if (machine == bfd_mach_arm_unknown) | 2153 | | { | 2154 | | switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK) | 2155 | | { | 2156 | | case F_ARM_2: machine = bfd_mach_arm_2; break; | 2157 | | case F_ARM_2a: machine = bfd_mach_arm_2a; break; | 2158 | | case F_ARM_3: machine = bfd_mach_arm_3; break; | 2159 | | default: | 2160 | | case F_ARM_3M: machine = bfd_mach_arm_3M; break; | 2161 | | case F_ARM_4: machine = bfd_mach_arm_4; break; | 2162 | | case F_ARM_4T: machine = bfd_mach_arm_4T; break; | 2163 | | /* The COFF header does not have enough bits available | 2164 | | to cover all the different ARM architectures. So | 2165 | | we interpret F_ARM_5, the highest flag value to mean | 2166 | | "the highest ARM architecture known to BFD" which is | 2167 | | currently the XScale. */ | 2168 | | case F_ARM_5: machine = bfd_mach_arm_XScale; break; | 2169 | | } | 2170 | | } | 2171 | | break; | 2172 | | #endif | 2173 | | #ifdef AARCH64MAGIC | 2174 | | case AARCH64MAGIC: | 2175 | | arch = bfd_arch_aarch64; | 2176 | | machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK; | 2177 | | break; | 2178 | | #endif | 2179 | | #ifdef LOONGARCH64MAGIC | 2180 | | case LOONGARCH64MAGIC: | 2181 | | arch = bfd_arch_loongarch; | 2182 | | machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK; | 2183 | | break; | 2184 | | #endif | 2185 | | #ifdef Z80MAGIC | 2186 | | case Z80MAGIC: | 2187 | | arch = bfd_arch_z80; | 2188 | | switch (internal_f->f_flags & F_MACHMASK) | 2189 | | { | 2190 | | case bfd_mach_z80strict << 12: | 2191 | | case bfd_mach_z80 << 12: | 2192 | | case bfd_mach_z80n << 12: | 2193 | | case bfd_mach_z80full << 12: | 2194 | | case bfd_mach_r800 << 12: | 2195 | | case bfd_mach_gbz80 << 12: | 2196 | | case bfd_mach_z180 << 12: | 2197 | | case bfd_mach_ez80_z80 << 12: | 2198 | | case bfd_mach_ez80_adl << 12: | 2199 | | machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12; | 2200 | | break; | 2201 | | default: | 2202 | | return false; | 2203 | | } | 2204 | | break; | 2205 | | #endif | 2206 | | #ifdef Z8KMAGIC | 2207 | | case Z8KMAGIC: | 2208 | | arch = bfd_arch_z8k; | 2209 | | switch (internal_f->f_flags & F_MACHMASK) | 2210 | | { | 2211 | | case F_Z8001: | 2212 | | machine = bfd_mach_z8001; | 2213 | | break; | 2214 | | case F_Z8002: | 2215 | | machine = bfd_mach_z8002; | 2216 | | break; | 2217 | | default: | 2218 | | return false; | 2219 | | } | 2220 | | break; | 2221 | | #endif | 2222 | | | 2223 | | #ifdef RS6000COFF_C | 2224 | | #ifdef XCOFF64 | 2225 | | case U64_TOCMAGIC: | 2226 | | case U803XTOCMAGIC: | 2227 | | #else | 2228 | | case U802ROMAGIC: | 2229 | | case U802WRMAGIC: | 2230 | | case U802TOCMAGIC: | 2231 | | #endif | 2232 | | { | 2233 | | int cputype; | 2234 | | | 2235 | | if (xcoff_data (abfd)->cputype != -1) | 2236 | | cputype = xcoff_data (abfd)->cputype & 0xff; | 2237 | | else | 2238 | | { | 2239 | | /* We did not get a value from the a.out header. If the | 2240 | | file has not been stripped, we may be able to get the | 2241 | | architecture information from the first symbol, if it | 2242 | | is a .file symbol. */ | 2243 | | if (obj_raw_syment_count (abfd) == 0) | 2244 | | cputype = 0; | 2245 | | else | 2246 | | { | 2247 | | bfd_byte *buf; | 2248 | | struct internal_syment sym; | 2249 | | bfd_size_type amt = bfd_coff_symesz (abfd); | 2250 | | | 2251 | | if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0) | 2252 | | return false; | 2253 | | buf = _bfd_malloc_and_read (abfd, amt, amt); | 2254 | | if (buf == NULL) | 2255 | | return false; | 2256 | | bfd_coff_swap_sym_in (abfd, buf, & sym); | 2257 | | if (sym.n_sclass == C_FILE) | 2258 | | cputype = sym.n_type & 0xff; | 2259 | | else | 2260 | | cputype = 0; | 2261 | | free (buf); | 2262 | | } | 2263 | | } | 2264 | | | 2265 | | /* FIXME: We don't handle all cases here. */ | 2266 | | switch (cputype) | 2267 | | { | 2268 | | default: | 2269 | | case 0: | 2270 | | arch = bfd_xcoff_architecture (abfd); | 2271 | | machine = bfd_xcoff_machine (abfd); | 2272 | | break; | 2273 | | | 2274 | | case 1: | 2275 | | arch = bfd_arch_powerpc; | 2276 | | machine = bfd_mach_ppc_601; | 2277 | | break; | 2278 | | case 2: /* 64 bit PowerPC */ | 2279 | | arch = bfd_arch_powerpc; | 2280 | | machine = bfd_mach_ppc_620; | 2281 | | break; | 2282 | | case 3: | 2283 | | arch = bfd_arch_powerpc; | 2284 | | machine = bfd_mach_ppc; | 2285 | | break; | 2286 | | case 4: | 2287 | | arch = bfd_arch_rs6000; | 2288 | | machine = bfd_mach_rs6k; | 2289 | | break; | 2290 | | } | 2291 | | } | 2292 | | break; | 2293 | | #endif | 2294 | | | 2295 | | #ifdef SH_ARCH_MAGIC_BIG | 2296 | | case SH_ARCH_MAGIC_BIG: | 2297 | | case SH_ARCH_MAGIC_LITTLE: | 2298 | | #ifdef COFF_WITH_PE | 2299 | | case SH_ARCH_MAGIC_WINCE: | 2300 | | #endif | 2301 | | arch = bfd_arch_sh; | 2302 | | break; | 2303 | | #endif | 2304 | | | 2305 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 2306 | | case MIPS_ARCH_MAGIC_WINCE: | 2307 | | arch = bfd_arch_mips; | 2308 | | break; | 2309 | | #endif | 2310 | | | 2311 | | #ifdef SPARCMAGIC | 2312 | | case SPARCMAGIC: | 2313 | | #ifdef LYNXCOFFMAGIC | 2314 | | case LYNXCOFFMAGIC: | 2315 | | #endif | 2316 | | arch = bfd_arch_sparc; | 2317 | | break; | 2318 | | #endif | 2319 | | | 2320 | | #ifdef TIC30MAGIC | 2321 | | case TIC30MAGIC: | 2322 | | arch = bfd_arch_tic30; | 2323 | | break; | 2324 | | #endif | 2325 | | | 2326 | | #ifdef TICOFF0MAGIC | 2327 | | #ifdef TICOFF_TARGET_ARCH | 2328 | | /* This TI COFF section should be used by all new TI COFF v0 targets. */ | 2329 | | case TICOFF0MAGIC: | 2330 | | arch = TICOFF_TARGET_ARCH; | 2331 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2332 | | break; | 2333 | | #endif | 2334 | | #endif | 2335 | | | 2336 | | #ifdef TICOFF1MAGIC | 2337 | | /* This TI COFF section should be used by all new TI COFF v1/2 targets. */ | 2338 | | /* TI COFF1 and COFF2 use the target_id field to specify which arch. */ | 2339 | | case TICOFF1MAGIC: | 2340 | | case TICOFF2MAGIC: | 2341 | | switch (internal_f->f_target_id) | 2342 | | { | 2343 | | #ifdef TI_TARGET_ID | 2344 | | case TI_TARGET_ID: | 2345 | | arch = TICOFF_TARGET_ARCH; | 2346 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2347 | | break; | 2348 | | #endif | 2349 | | default: | 2350 | | arch = bfd_arch_obscure; | 2351 | | _bfd_error_handler | 2352 | | (_("unrecognized TI COFF target id '0x%x'"), | 2353 | | internal_f->f_target_id); | 2354 | | break; | 2355 | | } | 2356 | | break; | 2357 | | #endif | 2358 | | | 2359 | | #ifdef MCOREMAGIC | 2360 | | case MCOREMAGIC: | 2361 | | arch = bfd_arch_mcore; | 2362 | | break; | 2363 | | #endif | 2364 | | | 2365 | 0 | default: /* Unreadable input file type. */ | 2366 | 0 | arch = bfd_arch_obscure; | 2367 | 0 | break; | 2368 | 472 | } | 2369 | | | 2370 | 472 | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 472 | return true; | 2372 | 472 | } |
coff-x86_64.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 982 | { | 2111 | 982 | unsigned long machine; | 2112 | 982 | enum bfd_architecture arch; | 2113 | 982 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 982 | machine = 0; | 2117 | 982 | switch (internal_f->f_magic) | 2118 | 982 | { | 2119 | | #ifdef I386MAGIC | 2120 | | case I386MAGIC: | 2121 | | case I386PTXMAGIC: | 2122 | | case I386AIXMAGIC: /* Danbury PS/2 AIX C Compiler. */ | 2123 | | case LYNXCOFFMAGIC: | 2124 | | case I386_APPLE_MAGIC: | 2125 | | case I386_FREEBSD_MAGIC: | 2126 | | case I386_LINUX_MAGIC: | 2127 | | case I386_NETBSD_MAGIC: | 2128 | | arch = bfd_arch_i386; | 2129 | | break; | 2130 | | #endif | 2131 | 0 | #ifdef AMD64MAGIC | 2132 | 166 | case AMD64MAGIC: | 2133 | 243 | case AMD64_APPLE_MAGIC: | 2134 | 257 | case AMD64_FREEBSD_MAGIC: | 2135 | 259 | case AMD64_LINUX_MAGIC: | 2136 | 982 | case AMD64_NETBSD_MAGIC: | 2137 | 982 | arch = bfd_arch_i386; | 2138 | 982 | machine = bfd_mach_x86_64; | 2139 | 982 | break; | 2140 | 0 | #endif | 2141 | | #ifdef IA64MAGIC | 2142 | | case IA64MAGIC: | 2143 | | arch = bfd_arch_ia64; | 2144 | | break; | 2145 | | #endif | 2146 | | #ifdef ARMMAGIC | 2147 | | case ARMMAGIC: | 2148 | | case ARMPEMAGIC: | 2149 | | case THUMBPEMAGIC: | 2150 | | arch = bfd_arch_arm; | 2151 | | machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION); | 2152 | | if (machine == bfd_mach_arm_unknown) | 2153 | | { | 2154 | | switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK) | 2155 | | { | 2156 | | case F_ARM_2: machine = bfd_mach_arm_2; break; | 2157 | | case F_ARM_2a: machine = bfd_mach_arm_2a; break; | 2158 | | case F_ARM_3: machine = bfd_mach_arm_3; break; | 2159 | | default: | 2160 | | case F_ARM_3M: machine = bfd_mach_arm_3M; break; | 2161 | | case F_ARM_4: machine = bfd_mach_arm_4; break; | 2162 | | case F_ARM_4T: machine = bfd_mach_arm_4T; break; | 2163 | | /* The COFF header does not have enough bits available | 2164 | | to cover all the different ARM architectures. So | 2165 | | we interpret F_ARM_5, the highest flag value to mean | 2166 | | "the highest ARM architecture known to BFD" which is | 2167 | | currently the XScale. */ | 2168 | | case F_ARM_5: machine = bfd_mach_arm_XScale; break; | 2169 | | } | 2170 | | } | 2171 | | break; | 2172 | | #endif | 2173 | | #ifdef AARCH64MAGIC | 2174 | | case AARCH64MAGIC: | 2175 | | arch = bfd_arch_aarch64; | 2176 | | machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK; | 2177 | | break; | 2178 | | #endif | 2179 | | #ifdef LOONGARCH64MAGIC | 2180 | | case LOONGARCH64MAGIC: | 2181 | | arch = bfd_arch_loongarch; | 2182 | | machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK; | 2183 | | break; | 2184 | | #endif | 2185 | | #ifdef Z80MAGIC | 2186 | | case Z80MAGIC: | 2187 | | arch = bfd_arch_z80; | 2188 | | switch (internal_f->f_flags & F_MACHMASK) | 2189 | | { | 2190 | | case bfd_mach_z80strict << 12: | 2191 | | case bfd_mach_z80 << 12: | 2192 | | case bfd_mach_z80n << 12: | 2193 | | case bfd_mach_z80full << 12: | 2194 | | case bfd_mach_r800 << 12: | 2195 | | case bfd_mach_gbz80 << 12: | 2196 | | case bfd_mach_z180 << 12: | 2197 | | case bfd_mach_ez80_z80 << 12: | 2198 | | case bfd_mach_ez80_adl << 12: | 2199 | | machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12; | 2200 | | break; | 2201 | | default: | 2202 | | return false; | 2203 | | } | 2204 | | break; | 2205 | | #endif | 2206 | | #ifdef Z8KMAGIC | 2207 | | case Z8KMAGIC: | 2208 | | arch = bfd_arch_z8k; | 2209 | | switch (internal_f->f_flags & F_MACHMASK) | 2210 | | { | 2211 | | case F_Z8001: | 2212 | | machine = bfd_mach_z8001; | 2213 | | break; | 2214 | | case F_Z8002: | 2215 | | machine = bfd_mach_z8002; | 2216 | | break; | 2217 | | default: | 2218 | | return false; | 2219 | | } | 2220 | | break; | 2221 | | #endif | 2222 | | | 2223 | | #ifdef RS6000COFF_C | 2224 | | #ifdef XCOFF64 | 2225 | | case U64_TOCMAGIC: | 2226 | | case U803XTOCMAGIC: | 2227 | | #else | 2228 | | case U802ROMAGIC: | 2229 | | case U802WRMAGIC: | 2230 | | case U802TOCMAGIC: | 2231 | | #endif | 2232 | | { | 2233 | | int cputype; | 2234 | | | 2235 | | if (xcoff_data (abfd)->cputype != -1) | 2236 | | cputype = xcoff_data (abfd)->cputype & 0xff; | 2237 | | else | 2238 | | { | 2239 | | /* We did not get a value from the a.out header. If the | 2240 | | file has not been stripped, we may be able to get the | 2241 | | architecture information from the first symbol, if it | 2242 | | is a .file symbol. */ | 2243 | | if (obj_raw_syment_count (abfd) == 0) | 2244 | | cputype = 0; | 2245 | | else | 2246 | | { | 2247 | | bfd_byte *buf; | 2248 | | struct internal_syment sym; | 2249 | | bfd_size_type amt = bfd_coff_symesz (abfd); | 2250 | | | 2251 | | if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0) | 2252 | | return false; | 2253 | | buf = _bfd_malloc_and_read (abfd, amt, amt); | 2254 | | if (buf == NULL) | 2255 | | return false; | 2256 | | bfd_coff_swap_sym_in (abfd, buf, & sym); | 2257 | | if (sym.n_sclass == C_FILE) | 2258 | | cputype = sym.n_type & 0xff; | 2259 | | else | 2260 | | cputype = 0; | 2261 | | free (buf); | 2262 | | } | 2263 | | } | 2264 | | | 2265 | | /* FIXME: We don't handle all cases here. */ | 2266 | | switch (cputype) | 2267 | | { | 2268 | | default: | 2269 | | case 0: | 2270 | | arch = bfd_xcoff_architecture (abfd); | 2271 | | machine = bfd_xcoff_machine (abfd); | 2272 | | break; | 2273 | | | 2274 | | case 1: | 2275 | | arch = bfd_arch_powerpc; | 2276 | | machine = bfd_mach_ppc_601; | 2277 | | break; | 2278 | | case 2: /* 64 bit PowerPC */ | 2279 | | arch = bfd_arch_powerpc; | 2280 | | machine = bfd_mach_ppc_620; | 2281 | | break; | 2282 | | case 3: | 2283 | | arch = bfd_arch_powerpc; | 2284 | | machine = bfd_mach_ppc; | 2285 | | break; | 2286 | | case 4: | 2287 | | arch = bfd_arch_rs6000; | 2288 | | machine = bfd_mach_rs6k; | 2289 | | break; | 2290 | | } | 2291 | | } | 2292 | | break; | 2293 | | #endif | 2294 | | | 2295 | | #ifdef SH_ARCH_MAGIC_BIG | 2296 | | case SH_ARCH_MAGIC_BIG: | 2297 | | case SH_ARCH_MAGIC_LITTLE: | 2298 | | #ifdef COFF_WITH_PE | 2299 | | case SH_ARCH_MAGIC_WINCE: | 2300 | | #endif | 2301 | | arch = bfd_arch_sh; | 2302 | | break; | 2303 | | #endif | 2304 | | | 2305 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 2306 | | case MIPS_ARCH_MAGIC_WINCE: | 2307 | | arch = bfd_arch_mips; | 2308 | | break; | 2309 | | #endif | 2310 | | | 2311 | | #ifdef SPARCMAGIC | 2312 | | case SPARCMAGIC: | 2313 | | #ifdef LYNXCOFFMAGIC | 2314 | | case LYNXCOFFMAGIC: | 2315 | | #endif | 2316 | | arch = bfd_arch_sparc; | 2317 | | break; | 2318 | | #endif | 2319 | | | 2320 | | #ifdef TIC30MAGIC | 2321 | | case TIC30MAGIC: | 2322 | | arch = bfd_arch_tic30; | 2323 | | break; | 2324 | | #endif | 2325 | | | 2326 | | #ifdef TICOFF0MAGIC | 2327 | | #ifdef TICOFF_TARGET_ARCH | 2328 | | /* This TI COFF section should be used by all new TI COFF v0 targets. */ | 2329 | | case TICOFF0MAGIC: | 2330 | | arch = TICOFF_TARGET_ARCH; | 2331 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2332 | | break; | 2333 | | #endif | 2334 | | #endif | 2335 | | | 2336 | | #ifdef TICOFF1MAGIC | 2337 | | /* This TI COFF section should be used by all new TI COFF v1/2 targets. */ | 2338 | | /* TI COFF1 and COFF2 use the target_id field to specify which arch. */ | 2339 | | case TICOFF1MAGIC: | 2340 | | case TICOFF2MAGIC: | 2341 | | switch (internal_f->f_target_id) | 2342 | | { | 2343 | | #ifdef TI_TARGET_ID | 2344 | | case TI_TARGET_ID: | 2345 | | arch = TICOFF_TARGET_ARCH; | 2346 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2347 | | break; | 2348 | | #endif | 2349 | | default: | 2350 | | arch = bfd_arch_obscure; | 2351 | | _bfd_error_handler | 2352 | | (_("unrecognized TI COFF target id '0x%x'"), | 2353 | | internal_f->f_target_id); | 2354 | | break; | 2355 | | } | 2356 | | break; | 2357 | | #endif | 2358 | | | 2359 | | #ifdef MCOREMAGIC | 2360 | | case MCOREMAGIC: | 2361 | | arch = bfd_arch_mcore; | 2362 | | break; | 2363 | | #endif | 2364 | | | 2365 | 0 | default: /* Unreadable input file type. */ | 2366 | 0 | arch = bfd_arch_obscure; | 2367 | 0 | break; | 2368 | 982 | } | 2369 | | | 2370 | 982 | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 982 | return true; | 2372 | 982 | } |
coff64-rs6000.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 623 | { | 2111 | 623 | unsigned long machine; | 2112 | 623 | enum bfd_architecture arch; | 2113 | 623 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 623 | machine = 0; | 2117 | 623 | switch (internal_f->f_magic) | 2118 | 623 | { | 2119 | | #ifdef I386MAGIC | 2120 | | case I386MAGIC: | 2121 | | case I386PTXMAGIC: | 2122 | | case I386AIXMAGIC: /* Danbury PS/2 AIX C Compiler. */ | 2123 | | case LYNXCOFFMAGIC: | 2124 | | case I386_APPLE_MAGIC: | 2125 | | case I386_FREEBSD_MAGIC: | 2126 | | case I386_LINUX_MAGIC: | 2127 | | case I386_NETBSD_MAGIC: | 2128 | | arch = bfd_arch_i386; | 2129 | | break; | 2130 | | #endif | 2131 | | #ifdef AMD64MAGIC | 2132 | | case AMD64MAGIC: | 2133 | | case AMD64_APPLE_MAGIC: | 2134 | | case AMD64_FREEBSD_MAGIC: | 2135 | | case AMD64_LINUX_MAGIC: | 2136 | | case AMD64_NETBSD_MAGIC: | 2137 | | arch = bfd_arch_i386; | 2138 | | machine = bfd_mach_x86_64; | 2139 | | break; | 2140 | | #endif | 2141 | | #ifdef IA64MAGIC | 2142 | | case IA64MAGIC: | 2143 | | arch = bfd_arch_ia64; | 2144 | | break; | 2145 | | #endif | 2146 | | #ifdef ARMMAGIC | 2147 | | case ARMMAGIC: | 2148 | | case ARMPEMAGIC: | 2149 | | case THUMBPEMAGIC: | 2150 | | arch = bfd_arch_arm; | 2151 | | machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION); | 2152 | | if (machine == bfd_mach_arm_unknown) | 2153 | | { | 2154 | | switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK) | 2155 | | { | 2156 | | case F_ARM_2: machine = bfd_mach_arm_2; break; | 2157 | | case F_ARM_2a: machine = bfd_mach_arm_2a; break; | 2158 | | case F_ARM_3: machine = bfd_mach_arm_3; break; | 2159 | | default: | 2160 | | case F_ARM_3M: machine = bfd_mach_arm_3M; break; | 2161 | | case F_ARM_4: machine = bfd_mach_arm_4; break; | 2162 | | case F_ARM_4T: machine = bfd_mach_arm_4T; break; | 2163 | | /* The COFF header does not have enough bits available | 2164 | | to cover all the different ARM architectures. So | 2165 | | we interpret F_ARM_5, the highest flag value to mean | 2166 | | "the highest ARM architecture known to BFD" which is | 2167 | | currently the XScale. */ | 2168 | | case F_ARM_5: machine = bfd_mach_arm_XScale; break; | 2169 | | } | 2170 | | } | 2171 | | break; | 2172 | | #endif | 2173 | | #ifdef AARCH64MAGIC | 2174 | | case AARCH64MAGIC: | 2175 | | arch = bfd_arch_aarch64; | 2176 | | machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK; | 2177 | | break; | 2178 | | #endif | 2179 | | #ifdef LOONGARCH64MAGIC | 2180 | | case LOONGARCH64MAGIC: | 2181 | | arch = bfd_arch_loongarch; | 2182 | | machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK; | 2183 | | break; | 2184 | | #endif | 2185 | | #ifdef Z80MAGIC | 2186 | | case Z80MAGIC: | 2187 | | arch = bfd_arch_z80; | 2188 | | switch (internal_f->f_flags & F_MACHMASK) | 2189 | | { | 2190 | | case bfd_mach_z80strict << 12: | 2191 | | case bfd_mach_z80 << 12: | 2192 | | case bfd_mach_z80n << 12: | 2193 | | case bfd_mach_z80full << 12: | 2194 | | case bfd_mach_r800 << 12: | 2195 | | case bfd_mach_gbz80 << 12: | 2196 | | case bfd_mach_z180 << 12: | 2197 | | case bfd_mach_ez80_z80 << 12: | 2198 | | case bfd_mach_ez80_adl << 12: | 2199 | | machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12; | 2200 | | break; | 2201 | | default: | 2202 | | return false; | 2203 | | } | 2204 | | break; | 2205 | | #endif | 2206 | | #ifdef Z8KMAGIC | 2207 | | case Z8KMAGIC: | 2208 | | arch = bfd_arch_z8k; | 2209 | | switch (internal_f->f_flags & F_MACHMASK) | 2210 | | { | 2211 | | case F_Z8001: | 2212 | | machine = bfd_mach_z8001; | 2213 | | break; | 2214 | | case F_Z8002: | 2215 | | machine = bfd_mach_z8002; | 2216 | | break; | 2217 | | default: | 2218 | | return false; | 2219 | | } | 2220 | | break; | 2221 | | #endif | 2222 | | | 2223 | 0 | #ifdef RS6000COFF_C | 2224 | 0 | #ifdef XCOFF64 | 2225 | 576 | case U64_TOCMAGIC: | 2226 | 623 | case U803XTOCMAGIC: | 2227 | | #else | 2228 | | case U802ROMAGIC: | 2229 | | case U802WRMAGIC: | 2230 | | case U802TOCMAGIC: | 2231 | | #endif | 2232 | 623 | { | 2233 | 623 | int cputype; | 2234 | | | 2235 | 623 | if (xcoff_data (abfd)->cputype != -1) | 2236 | 16 | cputype = xcoff_data (abfd)->cputype & 0xff; | 2237 | 607 | else | 2238 | 607 | { | 2239 | | /* We did not get a value from the a.out header. If the | 2240 | | file has not been stripped, we may be able to get the | 2241 | | architecture information from the first symbol, if it | 2242 | | is a .file symbol. */ | 2243 | 607 | if (obj_raw_syment_count (abfd) == 0) | 2244 | 54 | cputype = 0; | 2245 | 553 | else | 2246 | 553 | { | 2247 | 553 | bfd_byte *buf; | 2248 | 553 | struct internal_syment sym; | 2249 | 553 | bfd_size_type amt = bfd_coff_symesz (abfd); | 2250 | | | 2251 | 553 | if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0) | 2252 | 3 | return false; | 2253 | 550 | buf = _bfd_malloc_and_read (abfd, amt, amt); | 2254 | 550 | if (buf == NULL) | 2255 | 2 | return false; | 2256 | 548 | bfd_coff_swap_sym_in (abfd, buf, & sym); | 2257 | 548 | if (sym.n_sclass == C_FILE) | 2258 | 2 | cputype = sym.n_type & 0xff; | 2259 | 546 | else | 2260 | 546 | cputype = 0; | 2261 | 548 | free (buf); | 2262 | 548 | } | 2263 | 607 | } | 2264 | | | 2265 | | /* FIXME: We don't handle all cases here. */ | 2266 | 618 | switch (cputype) | 2267 | 618 | { | 2268 | 8 | default: | 2269 | 613 | case 0: | 2270 | 613 | arch = bfd_xcoff_architecture (abfd); | 2271 | 613 | machine = bfd_xcoff_machine (abfd); | 2272 | 613 | break; | 2273 | | | 2274 | 2 | case 1: | 2275 | 2 | arch = bfd_arch_powerpc; | 2276 | 2 | machine = bfd_mach_ppc_601; | 2277 | 2 | break; | 2278 | 1 | case 2: /* 64 bit PowerPC */ | 2279 | 1 | arch = bfd_arch_powerpc; | 2280 | 1 | machine = bfd_mach_ppc_620; | 2281 | 1 | break; | 2282 | 1 | case 3: | 2283 | 1 | arch = bfd_arch_powerpc; | 2284 | 1 | machine = bfd_mach_ppc; | 2285 | 1 | break; | 2286 | 1 | case 4: | 2287 | 1 | arch = bfd_arch_rs6000; | 2288 | 1 | machine = bfd_mach_rs6k; | 2289 | 1 | break; | 2290 | 618 | } | 2291 | 618 | } | 2292 | 618 | break; | 2293 | 618 | #endif | 2294 | | | 2295 | | #ifdef SH_ARCH_MAGIC_BIG | 2296 | | case SH_ARCH_MAGIC_BIG: | 2297 | | case SH_ARCH_MAGIC_LITTLE: | 2298 | | #ifdef COFF_WITH_PE | 2299 | | case SH_ARCH_MAGIC_WINCE: | 2300 | | #endif | 2301 | | arch = bfd_arch_sh; | 2302 | | break; | 2303 | | #endif | 2304 | | | 2305 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 2306 | | case MIPS_ARCH_MAGIC_WINCE: | 2307 | | arch = bfd_arch_mips; | 2308 | | break; | 2309 | | #endif | 2310 | | | 2311 | | #ifdef SPARCMAGIC | 2312 | | case SPARCMAGIC: | 2313 | | #ifdef LYNXCOFFMAGIC | 2314 | | case LYNXCOFFMAGIC: | 2315 | | #endif | 2316 | | arch = bfd_arch_sparc; | 2317 | | break; | 2318 | | #endif | 2319 | | | 2320 | | #ifdef TIC30MAGIC | 2321 | | case TIC30MAGIC: | 2322 | | arch = bfd_arch_tic30; | 2323 | | break; | 2324 | | #endif | 2325 | | | 2326 | | #ifdef TICOFF0MAGIC | 2327 | | #ifdef TICOFF_TARGET_ARCH | 2328 | | /* This TI COFF section should be used by all new TI COFF v0 targets. */ | 2329 | | case TICOFF0MAGIC: | 2330 | | arch = TICOFF_TARGET_ARCH; | 2331 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2332 | | break; | 2333 | | #endif | 2334 | | #endif | 2335 | | | 2336 | | #ifdef TICOFF1MAGIC | 2337 | | /* This TI COFF section should be used by all new TI COFF v1/2 targets. */ | 2338 | | /* TI COFF1 and COFF2 use the target_id field to specify which arch. */ | 2339 | | case TICOFF1MAGIC: | 2340 | | case TICOFF2MAGIC: | 2341 | | switch (internal_f->f_target_id) | 2342 | | { | 2343 | | #ifdef TI_TARGET_ID | 2344 | | case TI_TARGET_ID: | 2345 | | arch = TICOFF_TARGET_ARCH; | 2346 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2347 | | break; | 2348 | | #endif | 2349 | | default: | 2350 | | arch = bfd_arch_obscure; | 2351 | | _bfd_error_handler | 2352 | | (_("unrecognized TI COFF target id '0x%x'"), | 2353 | | internal_f->f_target_id); | 2354 | | break; | 2355 | | } | 2356 | | break; | 2357 | | #endif | 2358 | | | 2359 | | #ifdef MCOREMAGIC | 2360 | | case MCOREMAGIC: | 2361 | | arch = bfd_arch_mcore; | 2362 | | break; | 2363 | | #endif | 2364 | | | 2365 | 618 | default: /* Unreadable input file type. */ | 2366 | 0 | arch = bfd_arch_obscure; | 2367 | 0 | break; | 2368 | 623 | } | 2369 | | | 2370 | 618 | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 618 | return true; | 2372 | 623 | } |
pei-aarch64.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 316 | { | 2111 | 316 | unsigned long machine; | 2112 | 316 | enum bfd_architecture arch; | 2113 | 316 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 316 | machine = 0; | 2117 | 316 | switch (internal_f->f_magic) | 2118 | 316 | { | 2119 | | #ifdef I386MAGIC | 2120 | | case I386MAGIC: | 2121 | | case I386PTXMAGIC: | 2122 | | case I386AIXMAGIC: /* Danbury PS/2 AIX C Compiler. */ | 2123 | | case LYNXCOFFMAGIC: | 2124 | | case I386_APPLE_MAGIC: | 2125 | | case I386_FREEBSD_MAGIC: | 2126 | | case I386_LINUX_MAGIC: | 2127 | | case I386_NETBSD_MAGIC: | 2128 | | arch = bfd_arch_i386; | 2129 | | break; | 2130 | | #endif | 2131 | | #ifdef AMD64MAGIC | 2132 | | case AMD64MAGIC: | 2133 | | case AMD64_APPLE_MAGIC: | 2134 | | case AMD64_FREEBSD_MAGIC: | 2135 | | case AMD64_LINUX_MAGIC: | 2136 | | case AMD64_NETBSD_MAGIC: | 2137 | | arch = bfd_arch_i386; | 2138 | | machine = bfd_mach_x86_64; | 2139 | | break; | 2140 | | #endif | 2141 | | #ifdef IA64MAGIC | 2142 | | case IA64MAGIC: | 2143 | | arch = bfd_arch_ia64; | 2144 | | break; | 2145 | | #endif | 2146 | | #ifdef ARMMAGIC | 2147 | | case ARMMAGIC: | 2148 | | case ARMPEMAGIC: | 2149 | | case THUMBPEMAGIC: | 2150 | | arch = bfd_arch_arm; | 2151 | | machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION); | 2152 | | if (machine == bfd_mach_arm_unknown) | 2153 | | { | 2154 | | switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK) | 2155 | | { | 2156 | | case F_ARM_2: machine = bfd_mach_arm_2; break; | 2157 | | case F_ARM_2a: machine = bfd_mach_arm_2a; break; | 2158 | | case F_ARM_3: machine = bfd_mach_arm_3; break; | 2159 | | default: | 2160 | | case F_ARM_3M: machine = bfd_mach_arm_3M; break; | 2161 | | case F_ARM_4: machine = bfd_mach_arm_4; break; | 2162 | | case F_ARM_4T: machine = bfd_mach_arm_4T; break; | 2163 | | /* The COFF header does not have enough bits available | 2164 | | to cover all the different ARM architectures. So | 2165 | | we interpret F_ARM_5, the highest flag value to mean | 2166 | | "the highest ARM architecture known to BFD" which is | 2167 | | currently the XScale. */ | 2168 | | case F_ARM_5: machine = bfd_mach_arm_XScale; break; | 2169 | | } | 2170 | | } | 2171 | | break; | 2172 | | #endif | 2173 | 0 | #ifdef AARCH64MAGIC | 2174 | 316 | case AARCH64MAGIC: | 2175 | 316 | arch = bfd_arch_aarch64; | 2176 | 316 | machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK; | 2177 | 316 | break; | 2178 | 0 | #endif | 2179 | | #ifdef LOONGARCH64MAGIC | 2180 | | case LOONGARCH64MAGIC: | 2181 | | arch = bfd_arch_loongarch; | 2182 | | machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK; | 2183 | | break; | 2184 | | #endif | 2185 | | #ifdef Z80MAGIC | 2186 | | case Z80MAGIC: | 2187 | | arch = bfd_arch_z80; | 2188 | | switch (internal_f->f_flags & F_MACHMASK) | 2189 | | { | 2190 | | case bfd_mach_z80strict << 12: | 2191 | | case bfd_mach_z80 << 12: | 2192 | | case bfd_mach_z80n << 12: | 2193 | | case bfd_mach_z80full << 12: | 2194 | | case bfd_mach_r800 << 12: | 2195 | | case bfd_mach_gbz80 << 12: | 2196 | | case bfd_mach_z180 << 12: | 2197 | | case bfd_mach_ez80_z80 << 12: | 2198 | | case bfd_mach_ez80_adl << 12: | 2199 | | machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12; | 2200 | | break; | 2201 | | default: | 2202 | | return false; | 2203 | | } | 2204 | | break; | 2205 | | #endif | 2206 | | #ifdef Z8KMAGIC | 2207 | | case Z8KMAGIC: | 2208 | | arch = bfd_arch_z8k; | 2209 | | switch (internal_f->f_flags & F_MACHMASK) | 2210 | | { | 2211 | | case F_Z8001: | 2212 | | machine = bfd_mach_z8001; | 2213 | | break; | 2214 | | case F_Z8002: | 2215 | | machine = bfd_mach_z8002; | 2216 | | break; | 2217 | | default: | 2218 | | return false; | 2219 | | } | 2220 | | break; | 2221 | | #endif | 2222 | | | 2223 | | #ifdef RS6000COFF_C | 2224 | | #ifdef XCOFF64 | 2225 | | case U64_TOCMAGIC: | 2226 | | case U803XTOCMAGIC: | 2227 | | #else | 2228 | | case U802ROMAGIC: | 2229 | | case U802WRMAGIC: | 2230 | | case U802TOCMAGIC: | 2231 | | #endif | 2232 | | { | 2233 | | int cputype; | 2234 | | | 2235 | | if (xcoff_data (abfd)->cputype != -1) | 2236 | | cputype = xcoff_data (abfd)->cputype & 0xff; | 2237 | | else | 2238 | | { | 2239 | | /* We did not get a value from the a.out header. If the | 2240 | | file has not been stripped, we may be able to get the | 2241 | | architecture information from the first symbol, if it | 2242 | | is a .file symbol. */ | 2243 | | if (obj_raw_syment_count (abfd) == 0) | 2244 | | cputype = 0; | 2245 | | else | 2246 | | { | 2247 | | bfd_byte *buf; | 2248 | | struct internal_syment sym; | 2249 | | bfd_size_type amt = bfd_coff_symesz (abfd); | 2250 | | | 2251 | | if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0) | 2252 | | return false; | 2253 | | buf = _bfd_malloc_and_read (abfd, amt, amt); | 2254 | | if (buf == NULL) | 2255 | | return false; | 2256 | | bfd_coff_swap_sym_in (abfd, buf, & sym); | 2257 | | if (sym.n_sclass == C_FILE) | 2258 | | cputype = sym.n_type & 0xff; | 2259 | | else | 2260 | | cputype = 0; | 2261 | | free (buf); | 2262 | | } | 2263 | | } | 2264 | | | 2265 | | /* FIXME: We don't handle all cases here. */ | 2266 | | switch (cputype) | 2267 | | { | 2268 | | default: | 2269 | | case 0: | 2270 | | arch = bfd_xcoff_architecture (abfd); | 2271 | | machine = bfd_xcoff_machine (abfd); | 2272 | | break; | 2273 | | | 2274 | | case 1: | 2275 | | arch = bfd_arch_powerpc; | 2276 | | machine = bfd_mach_ppc_601; | 2277 | | break; | 2278 | | case 2: /* 64 bit PowerPC */ | 2279 | | arch = bfd_arch_powerpc; | 2280 | | machine = bfd_mach_ppc_620; | 2281 | | break; | 2282 | | case 3: | 2283 | | arch = bfd_arch_powerpc; | 2284 | | machine = bfd_mach_ppc; | 2285 | | break; | 2286 | | case 4: | 2287 | | arch = bfd_arch_rs6000; | 2288 | | machine = bfd_mach_rs6k; | 2289 | | break; | 2290 | | } | 2291 | | } | 2292 | | break; | 2293 | | #endif | 2294 | | | 2295 | | #ifdef SH_ARCH_MAGIC_BIG | 2296 | | case SH_ARCH_MAGIC_BIG: | 2297 | | case SH_ARCH_MAGIC_LITTLE: | 2298 | | #ifdef COFF_WITH_PE | 2299 | | case SH_ARCH_MAGIC_WINCE: | 2300 | | #endif | 2301 | | arch = bfd_arch_sh; | 2302 | | break; | 2303 | | #endif | 2304 | | | 2305 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 2306 | | case MIPS_ARCH_MAGIC_WINCE: | 2307 | | arch = bfd_arch_mips; | 2308 | | break; | 2309 | | #endif | 2310 | | | 2311 | | #ifdef SPARCMAGIC | 2312 | | case SPARCMAGIC: | 2313 | | #ifdef LYNXCOFFMAGIC | 2314 | | case LYNXCOFFMAGIC: | 2315 | | #endif | 2316 | | arch = bfd_arch_sparc; | 2317 | | break; | 2318 | | #endif | 2319 | | | 2320 | | #ifdef TIC30MAGIC | 2321 | | case TIC30MAGIC: | 2322 | | arch = bfd_arch_tic30; | 2323 | | break; | 2324 | | #endif | 2325 | | | 2326 | | #ifdef TICOFF0MAGIC | 2327 | | #ifdef TICOFF_TARGET_ARCH | 2328 | | /* This TI COFF section should be used by all new TI COFF v0 targets. */ | 2329 | | case TICOFF0MAGIC: | 2330 | | arch = TICOFF_TARGET_ARCH; | 2331 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2332 | | break; | 2333 | | #endif | 2334 | | #endif | 2335 | | | 2336 | | #ifdef TICOFF1MAGIC | 2337 | | /* This TI COFF section should be used by all new TI COFF v1/2 targets. */ | 2338 | | /* TI COFF1 and COFF2 use the target_id field to specify which arch. */ | 2339 | | case TICOFF1MAGIC: | 2340 | | case TICOFF2MAGIC: | 2341 | | switch (internal_f->f_target_id) | 2342 | | { | 2343 | | #ifdef TI_TARGET_ID | 2344 | | case TI_TARGET_ID: | 2345 | | arch = TICOFF_TARGET_ARCH; | 2346 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2347 | | break; | 2348 | | #endif | 2349 | | default: | 2350 | | arch = bfd_arch_obscure; | 2351 | | _bfd_error_handler | 2352 | | (_("unrecognized TI COFF target id '0x%x'"), | 2353 | | internal_f->f_target_id); | 2354 | | break; | 2355 | | } | 2356 | | break; | 2357 | | #endif | 2358 | | | 2359 | | #ifdef MCOREMAGIC | 2360 | | case MCOREMAGIC: | 2361 | | arch = bfd_arch_mcore; | 2362 | | break; | 2363 | | #endif | 2364 | | | 2365 | 0 | default: /* Unreadable input file type. */ | 2366 | 0 | arch = bfd_arch_obscure; | 2367 | 0 | break; | 2368 | 316 | } | 2369 | | | 2370 | 316 | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 316 | return true; | 2372 | 316 | } |
pe-aarch64.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 476 | { | 2111 | 476 | unsigned long machine; | 2112 | 476 | enum bfd_architecture arch; | 2113 | 476 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 476 | machine = 0; | 2117 | 476 | switch (internal_f->f_magic) | 2118 | 476 | { | 2119 | | #ifdef I386MAGIC | 2120 | | case I386MAGIC: | 2121 | | case I386PTXMAGIC: | 2122 | | case I386AIXMAGIC: /* Danbury PS/2 AIX C Compiler. */ | 2123 | | case LYNXCOFFMAGIC: | 2124 | | case I386_APPLE_MAGIC: | 2125 | | case I386_FREEBSD_MAGIC: | 2126 | | case I386_LINUX_MAGIC: | 2127 | | case I386_NETBSD_MAGIC: | 2128 | | arch = bfd_arch_i386; | 2129 | | break; | 2130 | | #endif | 2131 | | #ifdef AMD64MAGIC | 2132 | | case AMD64MAGIC: | 2133 | | case AMD64_APPLE_MAGIC: | 2134 | | case AMD64_FREEBSD_MAGIC: | 2135 | | case AMD64_LINUX_MAGIC: | 2136 | | case AMD64_NETBSD_MAGIC: | 2137 | | arch = bfd_arch_i386; | 2138 | | machine = bfd_mach_x86_64; | 2139 | | break; | 2140 | | #endif | 2141 | | #ifdef IA64MAGIC | 2142 | | case IA64MAGIC: | 2143 | | arch = bfd_arch_ia64; | 2144 | | break; | 2145 | | #endif | 2146 | | #ifdef ARMMAGIC | 2147 | | case ARMMAGIC: | 2148 | | case ARMPEMAGIC: | 2149 | | case THUMBPEMAGIC: | 2150 | | arch = bfd_arch_arm; | 2151 | | machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION); | 2152 | | if (machine == bfd_mach_arm_unknown) | 2153 | | { | 2154 | | switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK) | 2155 | | { | 2156 | | case F_ARM_2: machine = bfd_mach_arm_2; break; | 2157 | | case F_ARM_2a: machine = bfd_mach_arm_2a; break; | 2158 | | case F_ARM_3: machine = bfd_mach_arm_3; break; | 2159 | | default: | 2160 | | case F_ARM_3M: machine = bfd_mach_arm_3M; break; | 2161 | | case F_ARM_4: machine = bfd_mach_arm_4; break; | 2162 | | case F_ARM_4T: machine = bfd_mach_arm_4T; break; | 2163 | | /* The COFF header does not have enough bits available | 2164 | | to cover all the different ARM architectures. So | 2165 | | we interpret F_ARM_5, the highest flag value to mean | 2166 | | "the highest ARM architecture known to BFD" which is | 2167 | | currently the XScale. */ | 2168 | | case F_ARM_5: machine = bfd_mach_arm_XScale; break; | 2169 | | } | 2170 | | } | 2171 | | break; | 2172 | | #endif | 2173 | 0 | #ifdef AARCH64MAGIC | 2174 | 476 | case AARCH64MAGIC: | 2175 | 476 | arch = bfd_arch_aarch64; | 2176 | 476 | machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK; | 2177 | 476 | break; | 2178 | 0 | #endif | 2179 | | #ifdef LOONGARCH64MAGIC | 2180 | | case LOONGARCH64MAGIC: | 2181 | | arch = bfd_arch_loongarch; | 2182 | | machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK; | 2183 | | break; | 2184 | | #endif | 2185 | | #ifdef Z80MAGIC | 2186 | | case Z80MAGIC: | 2187 | | arch = bfd_arch_z80; | 2188 | | switch (internal_f->f_flags & F_MACHMASK) | 2189 | | { | 2190 | | case bfd_mach_z80strict << 12: | 2191 | | case bfd_mach_z80 << 12: | 2192 | | case bfd_mach_z80n << 12: | 2193 | | case bfd_mach_z80full << 12: | 2194 | | case bfd_mach_r800 << 12: | 2195 | | case bfd_mach_gbz80 << 12: | 2196 | | case bfd_mach_z180 << 12: | 2197 | | case bfd_mach_ez80_z80 << 12: | 2198 | | case bfd_mach_ez80_adl << 12: | 2199 | | machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12; | 2200 | | break; | 2201 | | default: | 2202 | | return false; | 2203 | | } | 2204 | | break; | 2205 | | #endif | 2206 | | #ifdef Z8KMAGIC | 2207 | | case Z8KMAGIC: | 2208 | | arch = bfd_arch_z8k; | 2209 | | switch (internal_f->f_flags & F_MACHMASK) | 2210 | | { | 2211 | | case F_Z8001: | 2212 | | machine = bfd_mach_z8001; | 2213 | | break; | 2214 | | case F_Z8002: | 2215 | | machine = bfd_mach_z8002; | 2216 | | break; | 2217 | | default: | 2218 | | return false; | 2219 | | } | 2220 | | break; | 2221 | | #endif | 2222 | | | 2223 | | #ifdef RS6000COFF_C | 2224 | | #ifdef XCOFF64 | 2225 | | case U64_TOCMAGIC: | 2226 | | case U803XTOCMAGIC: | 2227 | | #else | 2228 | | case U802ROMAGIC: | 2229 | | case U802WRMAGIC: | 2230 | | case U802TOCMAGIC: | 2231 | | #endif | 2232 | | { | 2233 | | int cputype; | 2234 | | | 2235 | | if (xcoff_data (abfd)->cputype != -1) | 2236 | | cputype = xcoff_data (abfd)->cputype & 0xff; | 2237 | | else | 2238 | | { | 2239 | | /* We did not get a value from the a.out header. If the | 2240 | | file has not been stripped, we may be able to get the | 2241 | | architecture information from the first symbol, if it | 2242 | | is a .file symbol. */ | 2243 | | if (obj_raw_syment_count (abfd) == 0) | 2244 | | cputype = 0; | 2245 | | else | 2246 | | { | 2247 | | bfd_byte *buf; | 2248 | | struct internal_syment sym; | 2249 | | bfd_size_type amt = bfd_coff_symesz (abfd); | 2250 | | | 2251 | | if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0) | 2252 | | return false; | 2253 | | buf = _bfd_malloc_and_read (abfd, amt, amt); | 2254 | | if (buf == NULL) | 2255 | | return false; | 2256 | | bfd_coff_swap_sym_in (abfd, buf, & sym); | 2257 | | if (sym.n_sclass == C_FILE) | 2258 | | cputype = sym.n_type & 0xff; | 2259 | | else | 2260 | | cputype = 0; | 2261 | | free (buf); | 2262 | | } | 2263 | | } | 2264 | | | 2265 | | /* FIXME: We don't handle all cases here. */ | 2266 | | switch (cputype) | 2267 | | { | 2268 | | default: | 2269 | | case 0: | 2270 | | arch = bfd_xcoff_architecture (abfd); | 2271 | | machine = bfd_xcoff_machine (abfd); | 2272 | | break; | 2273 | | | 2274 | | case 1: | 2275 | | arch = bfd_arch_powerpc; | 2276 | | machine = bfd_mach_ppc_601; | 2277 | | break; | 2278 | | case 2: /* 64 bit PowerPC */ | 2279 | | arch = bfd_arch_powerpc; | 2280 | | machine = bfd_mach_ppc_620; | 2281 | | break; | 2282 | | case 3: | 2283 | | arch = bfd_arch_powerpc; | 2284 | | machine = bfd_mach_ppc; | 2285 | | break; | 2286 | | case 4: | 2287 | | arch = bfd_arch_rs6000; | 2288 | | machine = bfd_mach_rs6k; | 2289 | | break; | 2290 | | } | 2291 | | } | 2292 | | break; | 2293 | | #endif | 2294 | | | 2295 | | #ifdef SH_ARCH_MAGIC_BIG | 2296 | | case SH_ARCH_MAGIC_BIG: | 2297 | | case SH_ARCH_MAGIC_LITTLE: | 2298 | | #ifdef COFF_WITH_PE | 2299 | | case SH_ARCH_MAGIC_WINCE: | 2300 | | #endif | 2301 | | arch = bfd_arch_sh; | 2302 | | break; | 2303 | | #endif | 2304 | | | 2305 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 2306 | | case MIPS_ARCH_MAGIC_WINCE: | 2307 | | arch = bfd_arch_mips; | 2308 | | break; | 2309 | | #endif | 2310 | | | 2311 | | #ifdef SPARCMAGIC | 2312 | | case SPARCMAGIC: | 2313 | | #ifdef LYNXCOFFMAGIC | 2314 | | case LYNXCOFFMAGIC: | 2315 | | #endif | 2316 | | arch = bfd_arch_sparc; | 2317 | | break; | 2318 | | #endif | 2319 | | | 2320 | | #ifdef TIC30MAGIC | 2321 | | case TIC30MAGIC: | 2322 | | arch = bfd_arch_tic30; | 2323 | | break; | 2324 | | #endif | 2325 | | | 2326 | | #ifdef TICOFF0MAGIC | 2327 | | #ifdef TICOFF_TARGET_ARCH | 2328 | | /* This TI COFF section should be used by all new TI COFF v0 targets. */ | 2329 | | case TICOFF0MAGIC: | 2330 | | arch = TICOFF_TARGET_ARCH; | 2331 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2332 | | break; | 2333 | | #endif | 2334 | | #endif | 2335 | | | 2336 | | #ifdef TICOFF1MAGIC | 2337 | | /* This TI COFF section should be used by all new TI COFF v1/2 targets. */ | 2338 | | /* TI COFF1 and COFF2 use the target_id field to specify which arch. */ | 2339 | | case TICOFF1MAGIC: | 2340 | | case TICOFF2MAGIC: | 2341 | | switch (internal_f->f_target_id) | 2342 | | { | 2343 | | #ifdef TI_TARGET_ID | 2344 | | case TI_TARGET_ID: | 2345 | | arch = TICOFF_TARGET_ARCH; | 2346 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2347 | | break; | 2348 | | #endif | 2349 | | default: | 2350 | | arch = bfd_arch_obscure; | 2351 | | _bfd_error_handler | 2352 | | (_("unrecognized TI COFF target id '0x%x'"), | 2353 | | internal_f->f_target_id); | 2354 | | break; | 2355 | | } | 2356 | | break; | 2357 | | #endif | 2358 | | | 2359 | | #ifdef MCOREMAGIC | 2360 | | case MCOREMAGIC: | 2361 | | arch = bfd_arch_mcore; | 2362 | | break; | 2363 | | #endif | 2364 | | | 2365 | 0 | default: /* Unreadable input file type. */ | 2366 | 0 | arch = bfd_arch_obscure; | 2367 | 0 | break; | 2368 | 476 | } | 2369 | | | 2370 | 476 | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 476 | return true; | 2372 | 476 | } |
pei-ia64.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 371 | { | 2111 | 371 | unsigned long machine; | 2112 | 371 | enum bfd_architecture arch; | 2113 | 371 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 371 | machine = 0; | 2117 | 371 | switch (internal_f->f_magic) | 2118 | 371 | { | 2119 | | #ifdef I386MAGIC | 2120 | | case I386MAGIC: | 2121 | | case I386PTXMAGIC: | 2122 | | case I386AIXMAGIC: /* Danbury PS/2 AIX C Compiler. */ | 2123 | | case LYNXCOFFMAGIC: | 2124 | | case I386_APPLE_MAGIC: | 2125 | | case I386_FREEBSD_MAGIC: | 2126 | | case I386_LINUX_MAGIC: | 2127 | | case I386_NETBSD_MAGIC: | 2128 | | arch = bfd_arch_i386; | 2129 | | break; | 2130 | | #endif | 2131 | | #ifdef AMD64MAGIC | 2132 | | case AMD64MAGIC: | 2133 | | case AMD64_APPLE_MAGIC: | 2134 | | case AMD64_FREEBSD_MAGIC: | 2135 | | case AMD64_LINUX_MAGIC: | 2136 | | case AMD64_NETBSD_MAGIC: | 2137 | | arch = bfd_arch_i386; | 2138 | | machine = bfd_mach_x86_64; | 2139 | | break; | 2140 | | #endif | 2141 | 0 | #ifdef IA64MAGIC | 2142 | 371 | case IA64MAGIC: | 2143 | 371 | arch = bfd_arch_ia64; | 2144 | 371 | break; | 2145 | 0 | #endif | 2146 | | #ifdef ARMMAGIC | 2147 | | case ARMMAGIC: | 2148 | | case ARMPEMAGIC: | 2149 | | case THUMBPEMAGIC: | 2150 | | arch = bfd_arch_arm; | 2151 | | machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION); | 2152 | | if (machine == bfd_mach_arm_unknown) | 2153 | | { | 2154 | | switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK) | 2155 | | { | 2156 | | case F_ARM_2: machine = bfd_mach_arm_2; break; | 2157 | | case F_ARM_2a: machine = bfd_mach_arm_2a; break; | 2158 | | case F_ARM_3: machine = bfd_mach_arm_3; break; | 2159 | | default: | 2160 | | case F_ARM_3M: machine = bfd_mach_arm_3M; break; | 2161 | | case F_ARM_4: machine = bfd_mach_arm_4; break; | 2162 | | case F_ARM_4T: machine = bfd_mach_arm_4T; break; | 2163 | | /* The COFF header does not have enough bits available | 2164 | | to cover all the different ARM architectures. So | 2165 | | we interpret F_ARM_5, the highest flag value to mean | 2166 | | "the highest ARM architecture known to BFD" which is | 2167 | | currently the XScale. */ | 2168 | | case F_ARM_5: machine = bfd_mach_arm_XScale; break; | 2169 | | } | 2170 | | } | 2171 | | break; | 2172 | | #endif | 2173 | | #ifdef AARCH64MAGIC | 2174 | | case AARCH64MAGIC: | 2175 | | arch = bfd_arch_aarch64; | 2176 | | machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK; | 2177 | | break; | 2178 | | #endif | 2179 | | #ifdef LOONGARCH64MAGIC | 2180 | | case LOONGARCH64MAGIC: | 2181 | | arch = bfd_arch_loongarch; | 2182 | | machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK; | 2183 | | break; | 2184 | | #endif | 2185 | | #ifdef Z80MAGIC | 2186 | | case Z80MAGIC: | 2187 | | arch = bfd_arch_z80; | 2188 | | switch (internal_f->f_flags & F_MACHMASK) | 2189 | | { | 2190 | | case bfd_mach_z80strict << 12: | 2191 | | case bfd_mach_z80 << 12: | 2192 | | case bfd_mach_z80n << 12: | 2193 | | case bfd_mach_z80full << 12: | 2194 | | case bfd_mach_r800 << 12: | 2195 | | case bfd_mach_gbz80 << 12: | 2196 | | case bfd_mach_z180 << 12: | 2197 | | case bfd_mach_ez80_z80 << 12: | 2198 | | case bfd_mach_ez80_adl << 12: | 2199 | | machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12; | 2200 | | break; | 2201 | | default: | 2202 | | return false; | 2203 | | } | 2204 | | break; | 2205 | | #endif | 2206 | | #ifdef Z8KMAGIC | 2207 | | case Z8KMAGIC: | 2208 | | arch = bfd_arch_z8k; | 2209 | | switch (internal_f->f_flags & F_MACHMASK) | 2210 | | { | 2211 | | case F_Z8001: | 2212 | | machine = bfd_mach_z8001; | 2213 | | break; | 2214 | | case F_Z8002: | 2215 | | machine = bfd_mach_z8002; | 2216 | | break; | 2217 | | default: | 2218 | | return false; | 2219 | | } | 2220 | | break; | 2221 | | #endif | 2222 | | | 2223 | | #ifdef RS6000COFF_C | 2224 | | #ifdef XCOFF64 | 2225 | | case U64_TOCMAGIC: | 2226 | | case U803XTOCMAGIC: | 2227 | | #else | 2228 | | case U802ROMAGIC: | 2229 | | case U802WRMAGIC: | 2230 | | case U802TOCMAGIC: | 2231 | | #endif | 2232 | | { | 2233 | | int cputype; | 2234 | | | 2235 | | if (xcoff_data (abfd)->cputype != -1) | 2236 | | cputype = xcoff_data (abfd)->cputype & 0xff; | 2237 | | else | 2238 | | { | 2239 | | /* We did not get a value from the a.out header. If the | 2240 | | file has not been stripped, we may be able to get the | 2241 | | architecture information from the first symbol, if it | 2242 | | is a .file symbol. */ | 2243 | | if (obj_raw_syment_count (abfd) == 0) | 2244 | | cputype = 0; | 2245 | | else | 2246 | | { | 2247 | | bfd_byte *buf; | 2248 | | struct internal_syment sym; | 2249 | | bfd_size_type amt = bfd_coff_symesz (abfd); | 2250 | | | 2251 | | if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0) | 2252 | | return false; | 2253 | | buf = _bfd_malloc_and_read (abfd, amt, amt); | 2254 | | if (buf == NULL) | 2255 | | return false; | 2256 | | bfd_coff_swap_sym_in (abfd, buf, & sym); | 2257 | | if (sym.n_sclass == C_FILE) | 2258 | | cputype = sym.n_type & 0xff; | 2259 | | else | 2260 | | cputype = 0; | 2261 | | free (buf); | 2262 | | } | 2263 | | } | 2264 | | | 2265 | | /* FIXME: We don't handle all cases here. */ | 2266 | | switch (cputype) | 2267 | | { | 2268 | | default: | 2269 | | case 0: | 2270 | | arch = bfd_xcoff_architecture (abfd); | 2271 | | machine = bfd_xcoff_machine (abfd); | 2272 | | break; | 2273 | | | 2274 | | case 1: | 2275 | | arch = bfd_arch_powerpc; | 2276 | | machine = bfd_mach_ppc_601; | 2277 | | break; | 2278 | | case 2: /* 64 bit PowerPC */ | 2279 | | arch = bfd_arch_powerpc; | 2280 | | machine = bfd_mach_ppc_620; | 2281 | | break; | 2282 | | case 3: | 2283 | | arch = bfd_arch_powerpc; | 2284 | | machine = bfd_mach_ppc; | 2285 | | break; | 2286 | | case 4: | 2287 | | arch = bfd_arch_rs6000; | 2288 | | machine = bfd_mach_rs6k; | 2289 | | break; | 2290 | | } | 2291 | | } | 2292 | | break; | 2293 | | #endif | 2294 | | | 2295 | | #ifdef SH_ARCH_MAGIC_BIG | 2296 | | case SH_ARCH_MAGIC_BIG: | 2297 | | case SH_ARCH_MAGIC_LITTLE: | 2298 | | #ifdef COFF_WITH_PE | 2299 | | case SH_ARCH_MAGIC_WINCE: | 2300 | | #endif | 2301 | | arch = bfd_arch_sh; | 2302 | | break; | 2303 | | #endif | 2304 | | | 2305 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 2306 | | case MIPS_ARCH_MAGIC_WINCE: | 2307 | | arch = bfd_arch_mips; | 2308 | | break; | 2309 | | #endif | 2310 | | | 2311 | | #ifdef SPARCMAGIC | 2312 | | case SPARCMAGIC: | 2313 | | #ifdef LYNXCOFFMAGIC | 2314 | | case LYNXCOFFMAGIC: | 2315 | | #endif | 2316 | | arch = bfd_arch_sparc; | 2317 | | break; | 2318 | | #endif | 2319 | | | 2320 | | #ifdef TIC30MAGIC | 2321 | | case TIC30MAGIC: | 2322 | | arch = bfd_arch_tic30; | 2323 | | break; | 2324 | | #endif | 2325 | | | 2326 | | #ifdef TICOFF0MAGIC | 2327 | | #ifdef TICOFF_TARGET_ARCH | 2328 | | /* This TI COFF section should be used by all new TI COFF v0 targets. */ | 2329 | | case TICOFF0MAGIC: | 2330 | | arch = TICOFF_TARGET_ARCH; | 2331 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2332 | | break; | 2333 | | #endif | 2334 | | #endif | 2335 | | | 2336 | | #ifdef TICOFF1MAGIC | 2337 | | /* This TI COFF section should be used by all new TI COFF v1/2 targets. */ | 2338 | | /* TI COFF1 and COFF2 use the target_id field to specify which arch. */ | 2339 | | case TICOFF1MAGIC: | 2340 | | case TICOFF2MAGIC: | 2341 | | switch (internal_f->f_target_id) | 2342 | | { | 2343 | | #ifdef TI_TARGET_ID | 2344 | | case TI_TARGET_ID: | 2345 | | arch = TICOFF_TARGET_ARCH; | 2346 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2347 | | break; | 2348 | | #endif | 2349 | | default: | 2350 | | arch = bfd_arch_obscure; | 2351 | | _bfd_error_handler | 2352 | | (_("unrecognized TI COFF target id '0x%x'"), | 2353 | | internal_f->f_target_id); | 2354 | | break; | 2355 | | } | 2356 | | break; | 2357 | | #endif | 2358 | | | 2359 | | #ifdef MCOREMAGIC | 2360 | | case MCOREMAGIC: | 2361 | | arch = bfd_arch_mcore; | 2362 | | break; | 2363 | | #endif | 2364 | | | 2365 | 0 | default: /* Unreadable input file type. */ | 2366 | 0 | arch = bfd_arch_obscure; | 2367 | 0 | break; | 2368 | 371 | } | 2369 | | | 2370 | 371 | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 371 | return true; | 2372 | 371 | } |
pei-loongarch64.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 441 | { | 2111 | 441 | unsigned long machine; | 2112 | 441 | enum bfd_architecture arch; | 2113 | 441 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 441 | machine = 0; | 2117 | 441 | switch (internal_f->f_magic) | 2118 | 441 | { | 2119 | | #ifdef I386MAGIC | 2120 | | case I386MAGIC: | 2121 | | case I386PTXMAGIC: | 2122 | | case I386AIXMAGIC: /* Danbury PS/2 AIX C Compiler. */ | 2123 | | case LYNXCOFFMAGIC: | 2124 | | case I386_APPLE_MAGIC: | 2125 | | case I386_FREEBSD_MAGIC: | 2126 | | case I386_LINUX_MAGIC: | 2127 | | case I386_NETBSD_MAGIC: | 2128 | | arch = bfd_arch_i386; | 2129 | | break; | 2130 | | #endif | 2131 | | #ifdef AMD64MAGIC | 2132 | | case AMD64MAGIC: | 2133 | | case AMD64_APPLE_MAGIC: | 2134 | | case AMD64_FREEBSD_MAGIC: | 2135 | | case AMD64_LINUX_MAGIC: | 2136 | | case AMD64_NETBSD_MAGIC: | 2137 | | arch = bfd_arch_i386; | 2138 | | machine = bfd_mach_x86_64; | 2139 | | break; | 2140 | | #endif | 2141 | | #ifdef IA64MAGIC | 2142 | | case IA64MAGIC: | 2143 | | arch = bfd_arch_ia64; | 2144 | | break; | 2145 | | #endif | 2146 | | #ifdef ARMMAGIC | 2147 | | case ARMMAGIC: | 2148 | | case ARMPEMAGIC: | 2149 | | case THUMBPEMAGIC: | 2150 | | arch = bfd_arch_arm; | 2151 | | machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION); | 2152 | | if (machine == bfd_mach_arm_unknown) | 2153 | | { | 2154 | | switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK) | 2155 | | { | 2156 | | case F_ARM_2: machine = bfd_mach_arm_2; break; | 2157 | | case F_ARM_2a: machine = bfd_mach_arm_2a; break; | 2158 | | case F_ARM_3: machine = bfd_mach_arm_3; break; | 2159 | | default: | 2160 | | case F_ARM_3M: machine = bfd_mach_arm_3M; break; | 2161 | | case F_ARM_4: machine = bfd_mach_arm_4; break; | 2162 | | case F_ARM_4T: machine = bfd_mach_arm_4T; break; | 2163 | | /* The COFF header does not have enough bits available | 2164 | | to cover all the different ARM architectures. So | 2165 | | we interpret F_ARM_5, the highest flag value to mean | 2166 | | "the highest ARM architecture known to BFD" which is | 2167 | | currently the XScale. */ | 2168 | | case F_ARM_5: machine = bfd_mach_arm_XScale; break; | 2169 | | } | 2170 | | } | 2171 | | break; | 2172 | | #endif | 2173 | | #ifdef AARCH64MAGIC | 2174 | | case AARCH64MAGIC: | 2175 | | arch = bfd_arch_aarch64; | 2176 | | machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK; | 2177 | | break; | 2178 | | #endif | 2179 | 0 | #ifdef LOONGARCH64MAGIC | 2180 | 441 | case LOONGARCH64MAGIC: | 2181 | 441 | arch = bfd_arch_loongarch; | 2182 | 441 | machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK; | 2183 | 441 | break; | 2184 | 0 | #endif | 2185 | | #ifdef Z80MAGIC | 2186 | | case Z80MAGIC: | 2187 | | arch = bfd_arch_z80; | 2188 | | switch (internal_f->f_flags & F_MACHMASK) | 2189 | | { | 2190 | | case bfd_mach_z80strict << 12: | 2191 | | case bfd_mach_z80 << 12: | 2192 | | case bfd_mach_z80n << 12: | 2193 | | case bfd_mach_z80full << 12: | 2194 | | case bfd_mach_r800 << 12: | 2195 | | case bfd_mach_gbz80 << 12: | 2196 | | case bfd_mach_z180 << 12: | 2197 | | case bfd_mach_ez80_z80 << 12: | 2198 | | case bfd_mach_ez80_adl << 12: | 2199 | | machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12; | 2200 | | break; | 2201 | | default: | 2202 | | return false; | 2203 | | } | 2204 | | break; | 2205 | | #endif | 2206 | | #ifdef Z8KMAGIC | 2207 | | case Z8KMAGIC: | 2208 | | arch = bfd_arch_z8k; | 2209 | | switch (internal_f->f_flags & F_MACHMASK) | 2210 | | { | 2211 | | case F_Z8001: | 2212 | | machine = bfd_mach_z8001; | 2213 | | break; | 2214 | | case F_Z8002: | 2215 | | machine = bfd_mach_z8002; | 2216 | | break; | 2217 | | default: | 2218 | | return false; | 2219 | | } | 2220 | | break; | 2221 | | #endif | 2222 | | | 2223 | | #ifdef RS6000COFF_C | 2224 | | #ifdef XCOFF64 | 2225 | | case U64_TOCMAGIC: | 2226 | | case U803XTOCMAGIC: | 2227 | | #else | 2228 | | case U802ROMAGIC: | 2229 | | case U802WRMAGIC: | 2230 | | case U802TOCMAGIC: | 2231 | | #endif | 2232 | | { | 2233 | | int cputype; | 2234 | | | 2235 | | if (xcoff_data (abfd)->cputype != -1) | 2236 | | cputype = xcoff_data (abfd)->cputype & 0xff; | 2237 | | else | 2238 | | { | 2239 | | /* We did not get a value from the a.out header. If the | 2240 | | file has not been stripped, we may be able to get the | 2241 | | architecture information from the first symbol, if it | 2242 | | is a .file symbol. */ | 2243 | | if (obj_raw_syment_count (abfd) == 0) | 2244 | | cputype = 0; | 2245 | | else | 2246 | | { | 2247 | | bfd_byte *buf; | 2248 | | struct internal_syment sym; | 2249 | | bfd_size_type amt = bfd_coff_symesz (abfd); | 2250 | | | 2251 | | if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0) | 2252 | | return false; | 2253 | | buf = _bfd_malloc_and_read (abfd, amt, amt); | 2254 | | if (buf == NULL) | 2255 | | return false; | 2256 | | bfd_coff_swap_sym_in (abfd, buf, & sym); | 2257 | | if (sym.n_sclass == C_FILE) | 2258 | | cputype = sym.n_type & 0xff; | 2259 | | else | 2260 | | cputype = 0; | 2261 | | free (buf); | 2262 | | } | 2263 | | } | 2264 | | | 2265 | | /* FIXME: We don't handle all cases here. */ | 2266 | | switch (cputype) | 2267 | | { | 2268 | | default: | 2269 | | case 0: | 2270 | | arch = bfd_xcoff_architecture (abfd); | 2271 | | machine = bfd_xcoff_machine (abfd); | 2272 | | break; | 2273 | | | 2274 | | case 1: | 2275 | | arch = bfd_arch_powerpc; | 2276 | | machine = bfd_mach_ppc_601; | 2277 | | break; | 2278 | | case 2: /* 64 bit PowerPC */ | 2279 | | arch = bfd_arch_powerpc; | 2280 | | machine = bfd_mach_ppc_620; | 2281 | | break; | 2282 | | case 3: | 2283 | | arch = bfd_arch_powerpc; | 2284 | | machine = bfd_mach_ppc; | 2285 | | break; | 2286 | | case 4: | 2287 | | arch = bfd_arch_rs6000; | 2288 | | machine = bfd_mach_rs6k; | 2289 | | break; | 2290 | | } | 2291 | | } | 2292 | | break; | 2293 | | #endif | 2294 | | | 2295 | | #ifdef SH_ARCH_MAGIC_BIG | 2296 | | case SH_ARCH_MAGIC_BIG: | 2297 | | case SH_ARCH_MAGIC_LITTLE: | 2298 | | #ifdef COFF_WITH_PE | 2299 | | case SH_ARCH_MAGIC_WINCE: | 2300 | | #endif | 2301 | | arch = bfd_arch_sh; | 2302 | | break; | 2303 | | #endif | 2304 | | | 2305 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 2306 | | case MIPS_ARCH_MAGIC_WINCE: | 2307 | | arch = bfd_arch_mips; | 2308 | | break; | 2309 | | #endif | 2310 | | | 2311 | | #ifdef SPARCMAGIC | 2312 | | case SPARCMAGIC: | 2313 | | #ifdef LYNXCOFFMAGIC | 2314 | | case LYNXCOFFMAGIC: | 2315 | | #endif | 2316 | | arch = bfd_arch_sparc; | 2317 | | break; | 2318 | | #endif | 2319 | | | 2320 | | #ifdef TIC30MAGIC | 2321 | | case TIC30MAGIC: | 2322 | | arch = bfd_arch_tic30; | 2323 | | break; | 2324 | | #endif | 2325 | | | 2326 | | #ifdef TICOFF0MAGIC | 2327 | | #ifdef TICOFF_TARGET_ARCH | 2328 | | /* This TI COFF section should be used by all new TI COFF v0 targets. */ | 2329 | | case TICOFF0MAGIC: | 2330 | | arch = TICOFF_TARGET_ARCH; | 2331 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2332 | | break; | 2333 | | #endif | 2334 | | #endif | 2335 | | | 2336 | | #ifdef TICOFF1MAGIC | 2337 | | /* This TI COFF section should be used by all new TI COFF v1/2 targets. */ | 2338 | | /* TI COFF1 and COFF2 use the target_id field to specify which arch. */ | 2339 | | case TICOFF1MAGIC: | 2340 | | case TICOFF2MAGIC: | 2341 | | switch (internal_f->f_target_id) | 2342 | | { | 2343 | | #ifdef TI_TARGET_ID | 2344 | | case TI_TARGET_ID: | 2345 | | arch = TICOFF_TARGET_ARCH; | 2346 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2347 | | break; | 2348 | | #endif | 2349 | | default: | 2350 | | arch = bfd_arch_obscure; | 2351 | | _bfd_error_handler | 2352 | | (_("unrecognized TI COFF target id '0x%x'"), | 2353 | | internal_f->f_target_id); | 2354 | | break; | 2355 | | } | 2356 | | break; | 2357 | | #endif | 2358 | | | 2359 | | #ifdef MCOREMAGIC | 2360 | | case MCOREMAGIC: | 2361 | | arch = bfd_arch_mcore; | 2362 | | break; | 2363 | | #endif | 2364 | | | 2365 | 0 | default: /* Unreadable input file type. */ | 2366 | 0 | arch = bfd_arch_obscure; | 2367 | 0 | break; | 2368 | 441 | } | 2369 | | | 2370 | 441 | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 441 | return true; | 2372 | 441 | } |
cf-i386lynx.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 468 | { | 2111 | 468 | unsigned long machine; | 2112 | 468 | enum bfd_architecture arch; | 2113 | 468 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 468 | machine = 0; | 2117 | 468 | switch (internal_f->f_magic) | 2118 | 468 | { | 2119 | 0 | #ifdef I386MAGIC | 2120 | 51 | case I386MAGIC: | 2121 | 56 | case I386PTXMAGIC: | 2122 | 58 | case I386AIXMAGIC: /* Danbury PS/2 AIX C Compiler. */ | 2123 | 464 | case LYNXCOFFMAGIC: | 2124 | 465 | case I386_APPLE_MAGIC: | 2125 | 466 | case I386_FREEBSD_MAGIC: | 2126 | 467 | case I386_LINUX_MAGIC: | 2127 | 468 | case I386_NETBSD_MAGIC: | 2128 | 468 | arch = bfd_arch_i386; | 2129 | 468 | break; | 2130 | 0 | #endif | 2131 | | #ifdef AMD64MAGIC | 2132 | | case AMD64MAGIC: | 2133 | | case AMD64_APPLE_MAGIC: | 2134 | | case AMD64_FREEBSD_MAGIC: | 2135 | | case AMD64_LINUX_MAGIC: | 2136 | | case AMD64_NETBSD_MAGIC: | 2137 | | arch = bfd_arch_i386; | 2138 | | machine = bfd_mach_x86_64; | 2139 | | break; | 2140 | | #endif | 2141 | | #ifdef IA64MAGIC | 2142 | | case IA64MAGIC: | 2143 | | arch = bfd_arch_ia64; | 2144 | | break; | 2145 | | #endif | 2146 | | #ifdef ARMMAGIC | 2147 | | case ARMMAGIC: | 2148 | | case ARMPEMAGIC: | 2149 | | case THUMBPEMAGIC: | 2150 | | arch = bfd_arch_arm; | 2151 | | machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION); | 2152 | | if (machine == bfd_mach_arm_unknown) | 2153 | | { | 2154 | | switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK) | 2155 | | { | 2156 | | case F_ARM_2: machine = bfd_mach_arm_2; break; | 2157 | | case F_ARM_2a: machine = bfd_mach_arm_2a; break; | 2158 | | case F_ARM_3: machine = bfd_mach_arm_3; break; | 2159 | | default: | 2160 | | case F_ARM_3M: machine = bfd_mach_arm_3M; break; | 2161 | | case F_ARM_4: machine = bfd_mach_arm_4; break; | 2162 | | case F_ARM_4T: machine = bfd_mach_arm_4T; break; | 2163 | | /* The COFF header does not have enough bits available | 2164 | | to cover all the different ARM architectures. So | 2165 | | we interpret F_ARM_5, the highest flag value to mean | 2166 | | "the highest ARM architecture known to BFD" which is | 2167 | | currently the XScale. */ | 2168 | | case F_ARM_5: machine = bfd_mach_arm_XScale; break; | 2169 | | } | 2170 | | } | 2171 | | break; | 2172 | | #endif | 2173 | | #ifdef AARCH64MAGIC | 2174 | | case AARCH64MAGIC: | 2175 | | arch = bfd_arch_aarch64; | 2176 | | machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK; | 2177 | | break; | 2178 | | #endif | 2179 | | #ifdef LOONGARCH64MAGIC | 2180 | | case LOONGARCH64MAGIC: | 2181 | | arch = bfd_arch_loongarch; | 2182 | | machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK; | 2183 | | break; | 2184 | | #endif | 2185 | | #ifdef Z80MAGIC | 2186 | | case Z80MAGIC: | 2187 | | arch = bfd_arch_z80; | 2188 | | switch (internal_f->f_flags & F_MACHMASK) | 2189 | | { | 2190 | | case bfd_mach_z80strict << 12: | 2191 | | case bfd_mach_z80 << 12: | 2192 | | case bfd_mach_z80n << 12: | 2193 | | case bfd_mach_z80full << 12: | 2194 | | case bfd_mach_r800 << 12: | 2195 | | case bfd_mach_gbz80 << 12: | 2196 | | case bfd_mach_z180 << 12: | 2197 | | case bfd_mach_ez80_z80 << 12: | 2198 | | case bfd_mach_ez80_adl << 12: | 2199 | | machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12; | 2200 | | break; | 2201 | | default: | 2202 | | return false; | 2203 | | } | 2204 | | break; | 2205 | | #endif | 2206 | | #ifdef Z8KMAGIC | 2207 | | case Z8KMAGIC: | 2208 | | arch = bfd_arch_z8k; | 2209 | | switch (internal_f->f_flags & F_MACHMASK) | 2210 | | { | 2211 | | case F_Z8001: | 2212 | | machine = bfd_mach_z8001; | 2213 | | break; | 2214 | | case F_Z8002: | 2215 | | machine = bfd_mach_z8002; | 2216 | | break; | 2217 | | default: | 2218 | | return false; | 2219 | | } | 2220 | | break; | 2221 | | #endif | 2222 | | | 2223 | | #ifdef RS6000COFF_C | 2224 | | #ifdef XCOFF64 | 2225 | | case U64_TOCMAGIC: | 2226 | | case U803XTOCMAGIC: | 2227 | | #else | 2228 | | case U802ROMAGIC: | 2229 | | case U802WRMAGIC: | 2230 | | case U802TOCMAGIC: | 2231 | | #endif | 2232 | | { | 2233 | | int cputype; | 2234 | | | 2235 | | if (xcoff_data (abfd)->cputype != -1) | 2236 | | cputype = xcoff_data (abfd)->cputype & 0xff; | 2237 | | else | 2238 | | { | 2239 | | /* We did not get a value from the a.out header. If the | 2240 | | file has not been stripped, we may be able to get the | 2241 | | architecture information from the first symbol, if it | 2242 | | is a .file symbol. */ | 2243 | | if (obj_raw_syment_count (abfd) == 0) | 2244 | | cputype = 0; | 2245 | | else | 2246 | | { | 2247 | | bfd_byte *buf; | 2248 | | struct internal_syment sym; | 2249 | | bfd_size_type amt = bfd_coff_symesz (abfd); | 2250 | | | 2251 | | if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0) | 2252 | | return false; | 2253 | | buf = _bfd_malloc_and_read (abfd, amt, amt); | 2254 | | if (buf == NULL) | 2255 | | return false; | 2256 | | bfd_coff_swap_sym_in (abfd, buf, & sym); | 2257 | | if (sym.n_sclass == C_FILE) | 2258 | | cputype = sym.n_type & 0xff; | 2259 | | else | 2260 | | cputype = 0; | 2261 | | free (buf); | 2262 | | } | 2263 | | } | 2264 | | | 2265 | | /* FIXME: We don't handle all cases here. */ | 2266 | | switch (cputype) | 2267 | | { | 2268 | | default: | 2269 | | case 0: | 2270 | | arch = bfd_xcoff_architecture (abfd); | 2271 | | machine = bfd_xcoff_machine (abfd); | 2272 | | break; | 2273 | | | 2274 | | case 1: | 2275 | | arch = bfd_arch_powerpc; | 2276 | | machine = bfd_mach_ppc_601; | 2277 | | break; | 2278 | | case 2: /* 64 bit PowerPC */ | 2279 | | arch = bfd_arch_powerpc; | 2280 | | machine = bfd_mach_ppc_620; | 2281 | | break; | 2282 | | case 3: | 2283 | | arch = bfd_arch_powerpc; | 2284 | | machine = bfd_mach_ppc; | 2285 | | break; | 2286 | | case 4: | 2287 | | arch = bfd_arch_rs6000; | 2288 | | machine = bfd_mach_rs6k; | 2289 | | break; | 2290 | | } | 2291 | | } | 2292 | | break; | 2293 | | #endif | 2294 | | | 2295 | | #ifdef SH_ARCH_MAGIC_BIG | 2296 | | case SH_ARCH_MAGIC_BIG: | 2297 | | case SH_ARCH_MAGIC_LITTLE: | 2298 | | #ifdef COFF_WITH_PE | 2299 | | case SH_ARCH_MAGIC_WINCE: | 2300 | | #endif | 2301 | | arch = bfd_arch_sh; | 2302 | | break; | 2303 | | #endif | 2304 | | | 2305 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 2306 | | case MIPS_ARCH_MAGIC_WINCE: | 2307 | | arch = bfd_arch_mips; | 2308 | | break; | 2309 | | #endif | 2310 | | | 2311 | | #ifdef SPARCMAGIC | 2312 | | case SPARCMAGIC: | 2313 | | #ifdef LYNXCOFFMAGIC | 2314 | | case LYNXCOFFMAGIC: | 2315 | | #endif | 2316 | | arch = bfd_arch_sparc; | 2317 | | break; | 2318 | | #endif | 2319 | | | 2320 | | #ifdef TIC30MAGIC | 2321 | | case TIC30MAGIC: | 2322 | | arch = bfd_arch_tic30; | 2323 | | break; | 2324 | | #endif | 2325 | | | 2326 | | #ifdef TICOFF0MAGIC | 2327 | | #ifdef TICOFF_TARGET_ARCH | 2328 | | /* This TI COFF section should be used by all new TI COFF v0 targets. */ | 2329 | | case TICOFF0MAGIC: | 2330 | | arch = TICOFF_TARGET_ARCH; | 2331 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2332 | | break; | 2333 | | #endif | 2334 | | #endif | 2335 | | | 2336 | | #ifdef TICOFF1MAGIC | 2337 | | /* This TI COFF section should be used by all new TI COFF v1/2 targets. */ | 2338 | | /* TI COFF1 and COFF2 use the target_id field to specify which arch. */ | 2339 | | case TICOFF1MAGIC: | 2340 | | case TICOFF2MAGIC: | 2341 | | switch (internal_f->f_target_id) | 2342 | | { | 2343 | | #ifdef TI_TARGET_ID | 2344 | | case TI_TARGET_ID: | 2345 | | arch = TICOFF_TARGET_ARCH; | 2346 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2347 | | break; | 2348 | | #endif | 2349 | | default: | 2350 | | arch = bfd_arch_obscure; | 2351 | | _bfd_error_handler | 2352 | | (_("unrecognized TI COFF target id '0x%x'"), | 2353 | | internal_f->f_target_id); | 2354 | | break; | 2355 | | } | 2356 | | break; | 2357 | | #endif | 2358 | | | 2359 | | #ifdef MCOREMAGIC | 2360 | | case MCOREMAGIC: | 2361 | | arch = bfd_arch_mcore; | 2362 | | break; | 2363 | | #endif | 2364 | | | 2365 | 0 | default: /* Unreadable input file type. */ | 2366 | 0 | arch = bfd_arch_obscure; | 2367 | 0 | break; | 2368 | 468 | } | 2369 | | | 2370 | 468 | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 468 | return true; | 2372 | 468 | } |
coff-go32.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 389 | { | 2111 | 389 | unsigned long machine; | 2112 | 389 | enum bfd_architecture arch; | 2113 | 389 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 389 | machine = 0; | 2117 | 389 | switch (internal_f->f_magic) | 2118 | 389 | { | 2119 | 0 | #ifdef I386MAGIC | 2120 | 49 | case I386MAGIC: | 2121 | 54 | case I386PTXMAGIC: | 2122 | 55 | case I386AIXMAGIC: /* Danbury PS/2 AIX C Compiler. */ | 2123 | 385 | case LYNXCOFFMAGIC: | 2124 | 386 | case I386_APPLE_MAGIC: | 2125 | 387 | case I386_FREEBSD_MAGIC: | 2126 | 388 | case I386_LINUX_MAGIC: | 2127 | 389 | case I386_NETBSD_MAGIC: | 2128 | 389 | arch = bfd_arch_i386; | 2129 | 389 | break; | 2130 | 0 | #endif | 2131 | | #ifdef AMD64MAGIC | 2132 | | case AMD64MAGIC: | 2133 | | case AMD64_APPLE_MAGIC: | 2134 | | case AMD64_FREEBSD_MAGIC: | 2135 | | case AMD64_LINUX_MAGIC: | 2136 | | case AMD64_NETBSD_MAGIC: | 2137 | | arch = bfd_arch_i386; | 2138 | | machine = bfd_mach_x86_64; | 2139 | | break; | 2140 | | #endif | 2141 | | #ifdef IA64MAGIC | 2142 | | case IA64MAGIC: | 2143 | | arch = bfd_arch_ia64; | 2144 | | break; | 2145 | | #endif | 2146 | | #ifdef ARMMAGIC | 2147 | | case ARMMAGIC: | 2148 | | case ARMPEMAGIC: | 2149 | | case THUMBPEMAGIC: | 2150 | | arch = bfd_arch_arm; | 2151 | | machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION); | 2152 | | if (machine == bfd_mach_arm_unknown) | 2153 | | { | 2154 | | switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK) | 2155 | | { | 2156 | | case F_ARM_2: machine = bfd_mach_arm_2; break; | 2157 | | case F_ARM_2a: machine = bfd_mach_arm_2a; break; | 2158 | | case F_ARM_3: machine = bfd_mach_arm_3; break; | 2159 | | default: | 2160 | | case F_ARM_3M: machine = bfd_mach_arm_3M; break; | 2161 | | case F_ARM_4: machine = bfd_mach_arm_4; break; | 2162 | | case F_ARM_4T: machine = bfd_mach_arm_4T; break; | 2163 | | /* The COFF header does not have enough bits available | 2164 | | to cover all the different ARM architectures. So | 2165 | | we interpret F_ARM_5, the highest flag value to mean | 2166 | | "the highest ARM architecture known to BFD" which is | 2167 | | currently the XScale. */ | 2168 | | case F_ARM_5: machine = bfd_mach_arm_XScale; break; | 2169 | | } | 2170 | | } | 2171 | | break; | 2172 | | #endif | 2173 | | #ifdef AARCH64MAGIC | 2174 | | case AARCH64MAGIC: | 2175 | | arch = bfd_arch_aarch64; | 2176 | | machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK; | 2177 | | break; | 2178 | | #endif | 2179 | | #ifdef LOONGARCH64MAGIC | 2180 | | case LOONGARCH64MAGIC: | 2181 | | arch = bfd_arch_loongarch; | 2182 | | machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK; | 2183 | | break; | 2184 | | #endif | 2185 | | #ifdef Z80MAGIC | 2186 | | case Z80MAGIC: | 2187 | | arch = bfd_arch_z80; | 2188 | | switch (internal_f->f_flags & F_MACHMASK) | 2189 | | { | 2190 | | case bfd_mach_z80strict << 12: | 2191 | | case bfd_mach_z80 << 12: | 2192 | | case bfd_mach_z80n << 12: | 2193 | | case bfd_mach_z80full << 12: | 2194 | | case bfd_mach_r800 << 12: | 2195 | | case bfd_mach_gbz80 << 12: | 2196 | | case bfd_mach_z180 << 12: | 2197 | | case bfd_mach_ez80_z80 << 12: | 2198 | | case bfd_mach_ez80_adl << 12: | 2199 | | machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12; | 2200 | | break; | 2201 | | default: | 2202 | | return false; | 2203 | | } | 2204 | | break; | 2205 | | #endif | 2206 | | #ifdef Z8KMAGIC | 2207 | | case Z8KMAGIC: | 2208 | | arch = bfd_arch_z8k; | 2209 | | switch (internal_f->f_flags & F_MACHMASK) | 2210 | | { | 2211 | | case F_Z8001: | 2212 | | machine = bfd_mach_z8001; | 2213 | | break; | 2214 | | case F_Z8002: | 2215 | | machine = bfd_mach_z8002; | 2216 | | break; | 2217 | | default: | 2218 | | return false; | 2219 | | } | 2220 | | break; | 2221 | | #endif | 2222 | | | 2223 | | #ifdef RS6000COFF_C | 2224 | | #ifdef XCOFF64 | 2225 | | case U64_TOCMAGIC: | 2226 | | case U803XTOCMAGIC: | 2227 | | #else | 2228 | | case U802ROMAGIC: | 2229 | | case U802WRMAGIC: | 2230 | | case U802TOCMAGIC: | 2231 | | #endif | 2232 | | { | 2233 | | int cputype; | 2234 | | | 2235 | | if (xcoff_data (abfd)->cputype != -1) | 2236 | | cputype = xcoff_data (abfd)->cputype & 0xff; | 2237 | | else | 2238 | | { | 2239 | | /* We did not get a value from the a.out header. If the | 2240 | | file has not been stripped, we may be able to get the | 2241 | | architecture information from the first symbol, if it | 2242 | | is a .file symbol. */ | 2243 | | if (obj_raw_syment_count (abfd) == 0) | 2244 | | cputype = 0; | 2245 | | else | 2246 | | { | 2247 | | bfd_byte *buf; | 2248 | | struct internal_syment sym; | 2249 | | bfd_size_type amt = bfd_coff_symesz (abfd); | 2250 | | | 2251 | | if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0) | 2252 | | return false; | 2253 | | buf = _bfd_malloc_and_read (abfd, amt, amt); | 2254 | | if (buf == NULL) | 2255 | | return false; | 2256 | | bfd_coff_swap_sym_in (abfd, buf, & sym); | 2257 | | if (sym.n_sclass == C_FILE) | 2258 | | cputype = sym.n_type & 0xff; | 2259 | | else | 2260 | | cputype = 0; | 2261 | | free (buf); | 2262 | | } | 2263 | | } | 2264 | | | 2265 | | /* FIXME: We don't handle all cases here. */ | 2266 | | switch (cputype) | 2267 | | { | 2268 | | default: | 2269 | | case 0: | 2270 | | arch = bfd_xcoff_architecture (abfd); | 2271 | | machine = bfd_xcoff_machine (abfd); | 2272 | | break; | 2273 | | | 2274 | | case 1: | 2275 | | arch = bfd_arch_powerpc; | 2276 | | machine = bfd_mach_ppc_601; | 2277 | | break; | 2278 | | case 2: /* 64 bit PowerPC */ | 2279 | | arch = bfd_arch_powerpc; | 2280 | | machine = bfd_mach_ppc_620; | 2281 | | break; | 2282 | | case 3: | 2283 | | arch = bfd_arch_powerpc; | 2284 | | machine = bfd_mach_ppc; | 2285 | | break; | 2286 | | case 4: | 2287 | | arch = bfd_arch_rs6000; | 2288 | | machine = bfd_mach_rs6k; | 2289 | | break; | 2290 | | } | 2291 | | } | 2292 | | break; | 2293 | | #endif | 2294 | | | 2295 | | #ifdef SH_ARCH_MAGIC_BIG | 2296 | | case SH_ARCH_MAGIC_BIG: | 2297 | | case SH_ARCH_MAGIC_LITTLE: | 2298 | | #ifdef COFF_WITH_PE | 2299 | | case SH_ARCH_MAGIC_WINCE: | 2300 | | #endif | 2301 | | arch = bfd_arch_sh; | 2302 | | break; | 2303 | | #endif | 2304 | | | 2305 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 2306 | | case MIPS_ARCH_MAGIC_WINCE: | 2307 | | arch = bfd_arch_mips; | 2308 | | break; | 2309 | | #endif | 2310 | | | 2311 | | #ifdef SPARCMAGIC | 2312 | | case SPARCMAGIC: | 2313 | | #ifdef LYNXCOFFMAGIC | 2314 | | case LYNXCOFFMAGIC: | 2315 | | #endif | 2316 | | arch = bfd_arch_sparc; | 2317 | | break; | 2318 | | #endif | 2319 | | | 2320 | | #ifdef TIC30MAGIC | 2321 | | case TIC30MAGIC: | 2322 | | arch = bfd_arch_tic30; | 2323 | | break; | 2324 | | #endif | 2325 | | | 2326 | | #ifdef TICOFF0MAGIC | 2327 | | #ifdef TICOFF_TARGET_ARCH | 2328 | | /* This TI COFF section should be used by all new TI COFF v0 targets. */ | 2329 | | case TICOFF0MAGIC: | 2330 | | arch = TICOFF_TARGET_ARCH; | 2331 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2332 | | break; | 2333 | | #endif | 2334 | | #endif | 2335 | | | 2336 | | #ifdef TICOFF1MAGIC | 2337 | | /* This TI COFF section should be used by all new TI COFF v1/2 targets. */ | 2338 | | /* TI COFF1 and COFF2 use the target_id field to specify which arch. */ | 2339 | | case TICOFF1MAGIC: | 2340 | | case TICOFF2MAGIC: | 2341 | | switch (internal_f->f_target_id) | 2342 | | { | 2343 | | #ifdef TI_TARGET_ID | 2344 | | case TI_TARGET_ID: | 2345 | | arch = TICOFF_TARGET_ARCH; | 2346 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2347 | | break; | 2348 | | #endif | 2349 | | default: | 2350 | | arch = bfd_arch_obscure; | 2351 | | _bfd_error_handler | 2352 | | (_("unrecognized TI COFF target id '0x%x'"), | 2353 | | internal_f->f_target_id); | 2354 | | break; | 2355 | | } | 2356 | | break; | 2357 | | #endif | 2358 | | | 2359 | | #ifdef MCOREMAGIC | 2360 | | case MCOREMAGIC: | 2361 | | arch = bfd_arch_mcore; | 2362 | | break; | 2363 | | #endif | 2364 | | | 2365 | 0 | default: /* Unreadable input file type. */ | 2366 | 0 | arch = bfd_arch_obscure; | 2367 | 0 | break; | 2368 | 389 | } | 2369 | | | 2370 | 389 | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 389 | return true; | 2372 | 389 | } |
coff-i386.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 389 | { | 2111 | 389 | unsigned long machine; | 2112 | 389 | enum bfd_architecture arch; | 2113 | 389 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 389 | machine = 0; | 2117 | 389 | switch (internal_f->f_magic) | 2118 | 389 | { | 2119 | 0 | #ifdef I386MAGIC | 2120 | 49 | case I386MAGIC: | 2121 | 54 | case I386PTXMAGIC: | 2122 | 55 | case I386AIXMAGIC: /* Danbury PS/2 AIX C Compiler. */ | 2123 | 385 | case LYNXCOFFMAGIC: | 2124 | 386 | case I386_APPLE_MAGIC: | 2125 | 387 | case I386_FREEBSD_MAGIC: | 2126 | 388 | case I386_LINUX_MAGIC: | 2127 | 389 | case I386_NETBSD_MAGIC: | 2128 | 389 | arch = bfd_arch_i386; | 2129 | 389 | break; | 2130 | 0 | #endif | 2131 | | #ifdef AMD64MAGIC | 2132 | | case AMD64MAGIC: | 2133 | | case AMD64_APPLE_MAGIC: | 2134 | | case AMD64_FREEBSD_MAGIC: | 2135 | | case AMD64_LINUX_MAGIC: | 2136 | | case AMD64_NETBSD_MAGIC: | 2137 | | arch = bfd_arch_i386; | 2138 | | machine = bfd_mach_x86_64; | 2139 | | break; | 2140 | | #endif | 2141 | | #ifdef IA64MAGIC | 2142 | | case IA64MAGIC: | 2143 | | arch = bfd_arch_ia64; | 2144 | | break; | 2145 | | #endif | 2146 | | #ifdef ARMMAGIC | 2147 | | case ARMMAGIC: | 2148 | | case ARMPEMAGIC: | 2149 | | case THUMBPEMAGIC: | 2150 | | arch = bfd_arch_arm; | 2151 | | machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION); | 2152 | | if (machine == bfd_mach_arm_unknown) | 2153 | | { | 2154 | | switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK) | 2155 | | { | 2156 | | case F_ARM_2: machine = bfd_mach_arm_2; break; | 2157 | | case F_ARM_2a: machine = bfd_mach_arm_2a; break; | 2158 | | case F_ARM_3: machine = bfd_mach_arm_3; break; | 2159 | | default: | 2160 | | case F_ARM_3M: machine = bfd_mach_arm_3M; break; | 2161 | | case F_ARM_4: machine = bfd_mach_arm_4; break; | 2162 | | case F_ARM_4T: machine = bfd_mach_arm_4T; break; | 2163 | | /* The COFF header does not have enough bits available | 2164 | | to cover all the different ARM architectures. So | 2165 | | we interpret F_ARM_5, the highest flag value to mean | 2166 | | "the highest ARM architecture known to BFD" which is | 2167 | | currently the XScale. */ | 2168 | | case F_ARM_5: machine = bfd_mach_arm_XScale; break; | 2169 | | } | 2170 | | } | 2171 | | break; | 2172 | | #endif | 2173 | | #ifdef AARCH64MAGIC | 2174 | | case AARCH64MAGIC: | 2175 | | arch = bfd_arch_aarch64; | 2176 | | machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK; | 2177 | | break; | 2178 | | #endif | 2179 | | #ifdef LOONGARCH64MAGIC | 2180 | | case LOONGARCH64MAGIC: | 2181 | | arch = bfd_arch_loongarch; | 2182 | | machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK; | 2183 | | break; | 2184 | | #endif | 2185 | | #ifdef Z80MAGIC | 2186 | | case Z80MAGIC: | 2187 | | arch = bfd_arch_z80; | 2188 | | switch (internal_f->f_flags & F_MACHMASK) | 2189 | | { | 2190 | | case bfd_mach_z80strict << 12: | 2191 | | case bfd_mach_z80 << 12: | 2192 | | case bfd_mach_z80n << 12: | 2193 | | case bfd_mach_z80full << 12: | 2194 | | case bfd_mach_r800 << 12: | 2195 | | case bfd_mach_gbz80 << 12: | 2196 | | case bfd_mach_z180 << 12: | 2197 | | case bfd_mach_ez80_z80 << 12: | 2198 | | case bfd_mach_ez80_adl << 12: | 2199 | | machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12; | 2200 | | break; | 2201 | | default: | 2202 | | return false; | 2203 | | } | 2204 | | break; | 2205 | | #endif | 2206 | | #ifdef Z8KMAGIC | 2207 | | case Z8KMAGIC: | 2208 | | arch = bfd_arch_z8k; | 2209 | | switch (internal_f->f_flags & F_MACHMASK) | 2210 | | { | 2211 | | case F_Z8001: | 2212 | | machine = bfd_mach_z8001; | 2213 | | break; | 2214 | | case F_Z8002: | 2215 | | machine = bfd_mach_z8002; | 2216 | | break; | 2217 | | default: | 2218 | | return false; | 2219 | | } | 2220 | | break; | 2221 | | #endif | 2222 | | | 2223 | | #ifdef RS6000COFF_C | 2224 | | #ifdef XCOFF64 | 2225 | | case U64_TOCMAGIC: | 2226 | | case U803XTOCMAGIC: | 2227 | | #else | 2228 | | case U802ROMAGIC: | 2229 | | case U802WRMAGIC: | 2230 | | case U802TOCMAGIC: | 2231 | | #endif | 2232 | | { | 2233 | | int cputype; | 2234 | | | 2235 | | if (xcoff_data (abfd)->cputype != -1) | 2236 | | cputype = xcoff_data (abfd)->cputype & 0xff; | 2237 | | else | 2238 | | { | 2239 | | /* We did not get a value from the a.out header. If the | 2240 | | file has not been stripped, we may be able to get the | 2241 | | architecture information from the first symbol, if it | 2242 | | is a .file symbol. */ | 2243 | | if (obj_raw_syment_count (abfd) == 0) | 2244 | | cputype = 0; | 2245 | | else | 2246 | | { | 2247 | | bfd_byte *buf; | 2248 | | struct internal_syment sym; | 2249 | | bfd_size_type amt = bfd_coff_symesz (abfd); | 2250 | | | 2251 | | if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0) | 2252 | | return false; | 2253 | | buf = _bfd_malloc_and_read (abfd, amt, amt); | 2254 | | if (buf == NULL) | 2255 | | return false; | 2256 | | bfd_coff_swap_sym_in (abfd, buf, & sym); | 2257 | | if (sym.n_sclass == C_FILE) | 2258 | | cputype = sym.n_type & 0xff; | 2259 | | else | 2260 | | cputype = 0; | 2261 | | free (buf); | 2262 | | } | 2263 | | } | 2264 | | | 2265 | | /* FIXME: We don't handle all cases here. */ | 2266 | | switch (cputype) | 2267 | | { | 2268 | | default: | 2269 | | case 0: | 2270 | | arch = bfd_xcoff_architecture (abfd); | 2271 | | machine = bfd_xcoff_machine (abfd); | 2272 | | break; | 2273 | | | 2274 | | case 1: | 2275 | | arch = bfd_arch_powerpc; | 2276 | | machine = bfd_mach_ppc_601; | 2277 | | break; | 2278 | | case 2: /* 64 bit PowerPC */ | 2279 | | arch = bfd_arch_powerpc; | 2280 | | machine = bfd_mach_ppc_620; | 2281 | | break; | 2282 | | case 3: | 2283 | | arch = bfd_arch_powerpc; | 2284 | | machine = bfd_mach_ppc; | 2285 | | break; | 2286 | | case 4: | 2287 | | arch = bfd_arch_rs6000; | 2288 | | machine = bfd_mach_rs6k; | 2289 | | break; | 2290 | | } | 2291 | | } | 2292 | | break; | 2293 | | #endif | 2294 | | | 2295 | | #ifdef SH_ARCH_MAGIC_BIG | 2296 | | case SH_ARCH_MAGIC_BIG: | 2297 | | case SH_ARCH_MAGIC_LITTLE: | 2298 | | #ifdef COFF_WITH_PE | 2299 | | case SH_ARCH_MAGIC_WINCE: | 2300 | | #endif | 2301 | | arch = bfd_arch_sh; | 2302 | | break; | 2303 | | #endif | 2304 | | | 2305 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 2306 | | case MIPS_ARCH_MAGIC_WINCE: | 2307 | | arch = bfd_arch_mips; | 2308 | | break; | 2309 | | #endif | 2310 | | | 2311 | | #ifdef SPARCMAGIC | 2312 | | case SPARCMAGIC: | 2313 | | #ifdef LYNXCOFFMAGIC | 2314 | | case LYNXCOFFMAGIC: | 2315 | | #endif | 2316 | | arch = bfd_arch_sparc; | 2317 | | break; | 2318 | | #endif | 2319 | | | 2320 | | #ifdef TIC30MAGIC | 2321 | | case TIC30MAGIC: | 2322 | | arch = bfd_arch_tic30; | 2323 | | break; | 2324 | | #endif | 2325 | | | 2326 | | #ifdef TICOFF0MAGIC | 2327 | | #ifdef TICOFF_TARGET_ARCH | 2328 | | /* This TI COFF section should be used by all new TI COFF v0 targets. */ | 2329 | | case TICOFF0MAGIC: | 2330 | | arch = TICOFF_TARGET_ARCH; | 2331 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2332 | | break; | 2333 | | #endif | 2334 | | #endif | 2335 | | | 2336 | | #ifdef TICOFF1MAGIC | 2337 | | /* This TI COFF section should be used by all new TI COFF v1/2 targets. */ | 2338 | | /* TI COFF1 and COFF2 use the target_id field to specify which arch. */ | 2339 | | case TICOFF1MAGIC: | 2340 | | case TICOFF2MAGIC: | 2341 | | switch (internal_f->f_target_id) | 2342 | | { | 2343 | | #ifdef TI_TARGET_ID | 2344 | | case TI_TARGET_ID: | 2345 | | arch = TICOFF_TARGET_ARCH; | 2346 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2347 | | break; | 2348 | | #endif | 2349 | | default: | 2350 | | arch = bfd_arch_obscure; | 2351 | | _bfd_error_handler | 2352 | | (_("unrecognized TI COFF target id '0x%x'"), | 2353 | | internal_f->f_target_id); | 2354 | | break; | 2355 | | } | 2356 | | break; | 2357 | | #endif | 2358 | | | 2359 | | #ifdef MCOREMAGIC | 2360 | | case MCOREMAGIC: | 2361 | | arch = bfd_arch_mcore; | 2362 | | break; | 2363 | | #endif | 2364 | | | 2365 | 0 | default: /* Unreadable input file type. */ | 2366 | 0 | arch = bfd_arch_obscure; | 2367 | 0 | break; | 2368 | 389 | } | 2369 | | | 2370 | 389 | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 389 | return true; | 2372 | 389 | } |
coff-rs6000.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 608 | { | 2111 | 608 | unsigned long machine; | 2112 | 608 | enum bfd_architecture arch; | 2113 | 608 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 608 | machine = 0; | 2117 | 608 | switch (internal_f->f_magic) | 2118 | 608 | { | 2119 | | #ifdef I386MAGIC | 2120 | | case I386MAGIC: | 2121 | | case I386PTXMAGIC: | 2122 | | case I386AIXMAGIC: /* Danbury PS/2 AIX C Compiler. */ | 2123 | | case LYNXCOFFMAGIC: | 2124 | | case I386_APPLE_MAGIC: | 2125 | | case I386_FREEBSD_MAGIC: | 2126 | | case I386_LINUX_MAGIC: | 2127 | | case I386_NETBSD_MAGIC: | 2128 | | arch = bfd_arch_i386; | 2129 | | break; | 2130 | | #endif | 2131 | | #ifdef AMD64MAGIC | 2132 | | case AMD64MAGIC: | 2133 | | case AMD64_APPLE_MAGIC: | 2134 | | case AMD64_FREEBSD_MAGIC: | 2135 | | case AMD64_LINUX_MAGIC: | 2136 | | case AMD64_NETBSD_MAGIC: | 2137 | | arch = bfd_arch_i386; | 2138 | | machine = bfd_mach_x86_64; | 2139 | | break; | 2140 | | #endif | 2141 | | #ifdef IA64MAGIC | 2142 | | case IA64MAGIC: | 2143 | | arch = bfd_arch_ia64; | 2144 | | break; | 2145 | | #endif | 2146 | | #ifdef ARMMAGIC | 2147 | | case ARMMAGIC: | 2148 | | case ARMPEMAGIC: | 2149 | | case THUMBPEMAGIC: | 2150 | | arch = bfd_arch_arm; | 2151 | | machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION); | 2152 | | if (machine == bfd_mach_arm_unknown) | 2153 | | { | 2154 | | switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK) | 2155 | | { | 2156 | | case F_ARM_2: machine = bfd_mach_arm_2; break; | 2157 | | case F_ARM_2a: machine = bfd_mach_arm_2a; break; | 2158 | | case F_ARM_3: machine = bfd_mach_arm_3; break; | 2159 | | default: | 2160 | | case F_ARM_3M: machine = bfd_mach_arm_3M; break; | 2161 | | case F_ARM_4: machine = bfd_mach_arm_4; break; | 2162 | | case F_ARM_4T: machine = bfd_mach_arm_4T; break; | 2163 | | /* The COFF header does not have enough bits available | 2164 | | to cover all the different ARM architectures. So | 2165 | | we interpret F_ARM_5, the highest flag value to mean | 2166 | | "the highest ARM architecture known to BFD" which is | 2167 | | currently the XScale. */ | 2168 | | case F_ARM_5: machine = bfd_mach_arm_XScale; break; | 2169 | | } | 2170 | | } | 2171 | | break; | 2172 | | #endif | 2173 | | #ifdef AARCH64MAGIC | 2174 | | case AARCH64MAGIC: | 2175 | | arch = bfd_arch_aarch64; | 2176 | | machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK; | 2177 | | break; | 2178 | | #endif | 2179 | | #ifdef LOONGARCH64MAGIC | 2180 | | case LOONGARCH64MAGIC: | 2181 | | arch = bfd_arch_loongarch; | 2182 | | machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK; | 2183 | | break; | 2184 | | #endif | 2185 | | #ifdef Z80MAGIC | 2186 | | case Z80MAGIC: | 2187 | | arch = bfd_arch_z80; | 2188 | | switch (internal_f->f_flags & F_MACHMASK) | 2189 | | { | 2190 | | case bfd_mach_z80strict << 12: | 2191 | | case bfd_mach_z80 << 12: | 2192 | | case bfd_mach_z80n << 12: | 2193 | | case bfd_mach_z80full << 12: | 2194 | | case bfd_mach_r800 << 12: | 2195 | | case bfd_mach_gbz80 << 12: | 2196 | | case bfd_mach_z180 << 12: | 2197 | | case bfd_mach_ez80_z80 << 12: | 2198 | | case bfd_mach_ez80_adl << 12: | 2199 | | machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12; | 2200 | | break; | 2201 | | default: | 2202 | | return false; | 2203 | | } | 2204 | | break; | 2205 | | #endif | 2206 | | #ifdef Z8KMAGIC | 2207 | | case Z8KMAGIC: | 2208 | | arch = bfd_arch_z8k; | 2209 | | switch (internal_f->f_flags & F_MACHMASK) | 2210 | | { | 2211 | | case F_Z8001: | 2212 | | machine = bfd_mach_z8001; | 2213 | | break; | 2214 | | case F_Z8002: | 2215 | | machine = bfd_mach_z8002; | 2216 | | break; | 2217 | | default: | 2218 | | return false; | 2219 | | } | 2220 | | break; | 2221 | | #endif | 2222 | | | 2223 | 0 | #ifdef RS6000COFF_C | 2224 | | #ifdef XCOFF64 | 2225 | | case U64_TOCMAGIC: | 2226 | | case U803XTOCMAGIC: | 2227 | | #else | 2228 | 567 | case U802ROMAGIC: | 2229 | 597 | case U802WRMAGIC: | 2230 | 608 | case U802TOCMAGIC: | 2231 | 608 | #endif | 2232 | 608 | { | 2233 | 608 | int cputype; | 2234 | | | 2235 | 608 | if (xcoff_data (abfd)->cputype != -1) | 2236 | 21 | cputype = xcoff_data (abfd)->cputype & 0xff; | 2237 | 587 | else | 2238 | 587 | { | 2239 | | /* We did not get a value from the a.out header. If the | 2240 | | file has not been stripped, we may be able to get the | 2241 | | architecture information from the first symbol, if it | 2242 | | is a .file symbol. */ | 2243 | 587 | if (obj_raw_syment_count (abfd) == 0) | 2244 | 21 | cputype = 0; | 2245 | 566 | else | 2246 | 566 | { | 2247 | 566 | bfd_byte *buf; | 2248 | 566 | struct internal_syment sym; | 2249 | 566 | bfd_size_type amt = bfd_coff_symesz (abfd); | 2250 | | | 2251 | 566 | if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0) | 2252 | 0 | return false; | 2253 | 566 | buf = _bfd_malloc_and_read (abfd, amt, amt); | 2254 | 566 | if (buf == NULL) | 2255 | 7 | return false; | 2256 | 559 | bfd_coff_swap_sym_in (abfd, buf, & sym); | 2257 | 559 | if (sym.n_sclass == C_FILE) | 2258 | 1 | cputype = sym.n_type & 0xff; | 2259 | 558 | else | 2260 | 558 | cputype = 0; | 2261 | 559 | free (buf); | 2262 | 559 | } | 2263 | 587 | } | 2264 | | | 2265 | | /* FIXME: We don't handle all cases here. */ | 2266 | 601 | switch (cputype) | 2267 | 601 | { | 2268 | 10 | default: | 2269 | 594 | case 0: | 2270 | 594 | arch = bfd_xcoff_architecture (abfd); | 2271 | 594 | machine = bfd_xcoff_machine (abfd); | 2272 | 594 | break; | 2273 | | | 2274 | 2 | case 1: | 2275 | 2 | arch = bfd_arch_powerpc; | 2276 | 2 | machine = bfd_mach_ppc_601; | 2277 | 2 | break; | 2278 | 1 | case 2: /* 64 bit PowerPC */ | 2279 | 1 | arch = bfd_arch_powerpc; | 2280 | 1 | machine = bfd_mach_ppc_620; | 2281 | 1 | break; | 2282 | 3 | case 3: | 2283 | 3 | arch = bfd_arch_powerpc; | 2284 | 3 | machine = bfd_mach_ppc; | 2285 | 3 | break; | 2286 | 1 | case 4: | 2287 | 1 | arch = bfd_arch_rs6000; | 2288 | 1 | machine = bfd_mach_rs6k; | 2289 | 1 | break; | 2290 | 601 | } | 2291 | 601 | } | 2292 | 601 | break; | 2293 | 601 | #endif | 2294 | | | 2295 | | #ifdef SH_ARCH_MAGIC_BIG | 2296 | | case SH_ARCH_MAGIC_BIG: | 2297 | | case SH_ARCH_MAGIC_LITTLE: | 2298 | | #ifdef COFF_WITH_PE | 2299 | | case SH_ARCH_MAGIC_WINCE: | 2300 | | #endif | 2301 | | arch = bfd_arch_sh; | 2302 | | break; | 2303 | | #endif | 2304 | | | 2305 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 2306 | | case MIPS_ARCH_MAGIC_WINCE: | 2307 | | arch = bfd_arch_mips; | 2308 | | break; | 2309 | | #endif | 2310 | | | 2311 | | #ifdef SPARCMAGIC | 2312 | | case SPARCMAGIC: | 2313 | | #ifdef LYNXCOFFMAGIC | 2314 | | case LYNXCOFFMAGIC: | 2315 | | #endif | 2316 | | arch = bfd_arch_sparc; | 2317 | | break; | 2318 | | #endif | 2319 | | | 2320 | | #ifdef TIC30MAGIC | 2321 | | case TIC30MAGIC: | 2322 | | arch = bfd_arch_tic30; | 2323 | | break; | 2324 | | #endif | 2325 | | | 2326 | | #ifdef TICOFF0MAGIC | 2327 | | #ifdef TICOFF_TARGET_ARCH | 2328 | | /* This TI COFF section should be used by all new TI COFF v0 targets. */ | 2329 | | case TICOFF0MAGIC: | 2330 | | arch = TICOFF_TARGET_ARCH; | 2331 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2332 | | break; | 2333 | | #endif | 2334 | | #endif | 2335 | | | 2336 | | #ifdef TICOFF1MAGIC | 2337 | | /* This TI COFF section should be used by all new TI COFF v1/2 targets. */ | 2338 | | /* TI COFF1 and COFF2 use the target_id field to specify which arch. */ | 2339 | | case TICOFF1MAGIC: | 2340 | | case TICOFF2MAGIC: | 2341 | | switch (internal_f->f_target_id) | 2342 | | { | 2343 | | #ifdef TI_TARGET_ID | 2344 | | case TI_TARGET_ID: | 2345 | | arch = TICOFF_TARGET_ARCH; | 2346 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2347 | | break; | 2348 | | #endif | 2349 | | default: | 2350 | | arch = bfd_arch_obscure; | 2351 | | _bfd_error_handler | 2352 | | (_("unrecognized TI COFF target id '0x%x'"), | 2353 | | internal_f->f_target_id); | 2354 | | break; | 2355 | | } | 2356 | | break; | 2357 | | #endif | 2358 | | | 2359 | | #ifdef MCOREMAGIC | 2360 | | case MCOREMAGIC: | 2361 | | arch = bfd_arch_mcore; | 2362 | | break; | 2363 | | #endif | 2364 | | | 2365 | 601 | default: /* Unreadable input file type. */ | 2366 | 0 | arch = bfd_arch_obscure; | 2367 | 0 | break; | 2368 | 608 | } | 2369 | | | 2370 | 601 | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 601 | return true; | 2372 | 608 | } |
coff-sh.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 412 | { | 2111 | 412 | unsigned long machine; | 2112 | 412 | enum bfd_architecture arch; | 2113 | 412 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 412 | machine = 0; | 2117 | 412 | switch (internal_f->f_magic) | 2118 | 412 | { | 2119 | | #ifdef I386MAGIC | 2120 | | case I386MAGIC: | 2121 | | case I386PTXMAGIC: | 2122 | | case I386AIXMAGIC: /* Danbury PS/2 AIX C Compiler. */ | 2123 | | case LYNXCOFFMAGIC: | 2124 | | case I386_APPLE_MAGIC: | 2125 | | case I386_FREEBSD_MAGIC: | 2126 | | case I386_LINUX_MAGIC: | 2127 | | case I386_NETBSD_MAGIC: | 2128 | | arch = bfd_arch_i386; | 2129 | | break; | 2130 | | #endif | 2131 | | #ifdef AMD64MAGIC | 2132 | | case AMD64MAGIC: | 2133 | | case AMD64_APPLE_MAGIC: | 2134 | | case AMD64_FREEBSD_MAGIC: | 2135 | | case AMD64_LINUX_MAGIC: | 2136 | | case AMD64_NETBSD_MAGIC: | 2137 | | arch = bfd_arch_i386; | 2138 | | machine = bfd_mach_x86_64; | 2139 | | break; | 2140 | | #endif | 2141 | | #ifdef IA64MAGIC | 2142 | | case IA64MAGIC: | 2143 | | arch = bfd_arch_ia64; | 2144 | | break; | 2145 | | #endif | 2146 | | #ifdef ARMMAGIC | 2147 | | case ARMMAGIC: | 2148 | | case ARMPEMAGIC: | 2149 | | case THUMBPEMAGIC: | 2150 | | arch = bfd_arch_arm; | 2151 | | machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION); | 2152 | | if (machine == bfd_mach_arm_unknown) | 2153 | | { | 2154 | | switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK) | 2155 | | { | 2156 | | case F_ARM_2: machine = bfd_mach_arm_2; break; | 2157 | | case F_ARM_2a: machine = bfd_mach_arm_2a; break; | 2158 | | case F_ARM_3: machine = bfd_mach_arm_3; break; | 2159 | | default: | 2160 | | case F_ARM_3M: machine = bfd_mach_arm_3M; break; | 2161 | | case F_ARM_4: machine = bfd_mach_arm_4; break; | 2162 | | case F_ARM_4T: machine = bfd_mach_arm_4T; break; | 2163 | | /* The COFF header does not have enough bits available | 2164 | | to cover all the different ARM architectures. So | 2165 | | we interpret F_ARM_5, the highest flag value to mean | 2166 | | "the highest ARM architecture known to BFD" which is | 2167 | | currently the XScale. */ | 2168 | | case F_ARM_5: machine = bfd_mach_arm_XScale; break; | 2169 | | } | 2170 | | } | 2171 | | break; | 2172 | | #endif | 2173 | | #ifdef AARCH64MAGIC | 2174 | | case AARCH64MAGIC: | 2175 | | arch = bfd_arch_aarch64; | 2176 | | machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK; | 2177 | | break; | 2178 | | #endif | 2179 | | #ifdef LOONGARCH64MAGIC | 2180 | | case LOONGARCH64MAGIC: | 2181 | | arch = bfd_arch_loongarch; | 2182 | | machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK; | 2183 | | break; | 2184 | | #endif | 2185 | | #ifdef Z80MAGIC | 2186 | | case Z80MAGIC: | 2187 | | arch = bfd_arch_z80; | 2188 | | switch (internal_f->f_flags & F_MACHMASK) | 2189 | | { | 2190 | | case bfd_mach_z80strict << 12: | 2191 | | case bfd_mach_z80 << 12: | 2192 | | case bfd_mach_z80n << 12: | 2193 | | case bfd_mach_z80full << 12: | 2194 | | case bfd_mach_r800 << 12: | 2195 | | case bfd_mach_gbz80 << 12: | 2196 | | case bfd_mach_z180 << 12: | 2197 | | case bfd_mach_ez80_z80 << 12: | 2198 | | case bfd_mach_ez80_adl << 12: | 2199 | | machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12; | 2200 | | break; | 2201 | | default: | 2202 | | return false; | 2203 | | } | 2204 | | break; | 2205 | | #endif | 2206 | | #ifdef Z8KMAGIC | 2207 | | case Z8KMAGIC: | 2208 | | arch = bfd_arch_z8k; | 2209 | | switch (internal_f->f_flags & F_MACHMASK) | 2210 | | { | 2211 | | case F_Z8001: | 2212 | | machine = bfd_mach_z8001; | 2213 | | break; | 2214 | | case F_Z8002: | 2215 | | machine = bfd_mach_z8002; | 2216 | | break; | 2217 | | default: | 2218 | | return false; | 2219 | | } | 2220 | | break; | 2221 | | #endif | 2222 | | | 2223 | | #ifdef RS6000COFF_C | 2224 | | #ifdef XCOFF64 | 2225 | | case U64_TOCMAGIC: | 2226 | | case U803XTOCMAGIC: | 2227 | | #else | 2228 | | case U802ROMAGIC: | 2229 | | case U802WRMAGIC: | 2230 | | case U802TOCMAGIC: | 2231 | | #endif | 2232 | | { | 2233 | | int cputype; | 2234 | | | 2235 | | if (xcoff_data (abfd)->cputype != -1) | 2236 | | cputype = xcoff_data (abfd)->cputype & 0xff; | 2237 | | else | 2238 | | { | 2239 | | /* We did not get a value from the a.out header. If the | 2240 | | file has not been stripped, we may be able to get the | 2241 | | architecture information from the first symbol, if it | 2242 | | is a .file symbol. */ | 2243 | | if (obj_raw_syment_count (abfd) == 0) | 2244 | | cputype = 0; | 2245 | | else | 2246 | | { | 2247 | | bfd_byte *buf; | 2248 | | struct internal_syment sym; | 2249 | | bfd_size_type amt = bfd_coff_symesz (abfd); | 2250 | | | 2251 | | if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0) | 2252 | | return false; | 2253 | | buf = _bfd_malloc_and_read (abfd, amt, amt); | 2254 | | if (buf == NULL) | 2255 | | return false; | 2256 | | bfd_coff_swap_sym_in (abfd, buf, & sym); | 2257 | | if (sym.n_sclass == C_FILE) | 2258 | | cputype = sym.n_type & 0xff; | 2259 | | else | 2260 | | cputype = 0; | 2261 | | free (buf); | 2262 | | } | 2263 | | } | 2264 | | | 2265 | | /* FIXME: We don't handle all cases here. */ | 2266 | | switch (cputype) | 2267 | | { | 2268 | | default: | 2269 | | case 0: | 2270 | | arch = bfd_xcoff_architecture (abfd); | 2271 | | machine = bfd_xcoff_machine (abfd); | 2272 | | break; | 2273 | | | 2274 | | case 1: | 2275 | | arch = bfd_arch_powerpc; | 2276 | | machine = bfd_mach_ppc_601; | 2277 | | break; | 2278 | | case 2: /* 64 bit PowerPC */ | 2279 | | arch = bfd_arch_powerpc; | 2280 | | machine = bfd_mach_ppc_620; | 2281 | | break; | 2282 | | case 3: | 2283 | | arch = bfd_arch_powerpc; | 2284 | | machine = bfd_mach_ppc; | 2285 | | break; | 2286 | | case 4: | 2287 | | arch = bfd_arch_rs6000; | 2288 | | machine = bfd_mach_rs6k; | 2289 | | break; | 2290 | | } | 2291 | | } | 2292 | | break; | 2293 | | #endif | 2294 | | | 2295 | 0 | #ifdef SH_ARCH_MAGIC_BIG | 2296 | 400 | case SH_ARCH_MAGIC_BIG: | 2297 | 400 | case SH_ARCH_MAGIC_LITTLE: | 2298 | | #ifdef COFF_WITH_PE | 2299 | | case SH_ARCH_MAGIC_WINCE: | 2300 | | #endif | 2301 | 400 | arch = bfd_arch_sh; | 2302 | 400 | break; | 2303 | 0 | #endif | 2304 | | | 2305 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 2306 | | case MIPS_ARCH_MAGIC_WINCE: | 2307 | | arch = bfd_arch_mips; | 2308 | | break; | 2309 | | #endif | 2310 | | | 2311 | | #ifdef SPARCMAGIC | 2312 | | case SPARCMAGIC: | 2313 | | #ifdef LYNXCOFFMAGIC | 2314 | | case LYNXCOFFMAGIC: | 2315 | | #endif | 2316 | | arch = bfd_arch_sparc; | 2317 | | break; | 2318 | | #endif | 2319 | | | 2320 | | #ifdef TIC30MAGIC | 2321 | | case TIC30MAGIC: | 2322 | | arch = bfd_arch_tic30; | 2323 | | break; | 2324 | | #endif | 2325 | | | 2326 | | #ifdef TICOFF0MAGIC | 2327 | | #ifdef TICOFF_TARGET_ARCH | 2328 | | /* This TI COFF section should be used by all new TI COFF v0 targets. */ | 2329 | | case TICOFF0MAGIC: | 2330 | | arch = TICOFF_TARGET_ARCH; | 2331 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2332 | | break; | 2333 | | #endif | 2334 | | #endif | 2335 | | | 2336 | | #ifdef TICOFF1MAGIC | 2337 | | /* This TI COFF section should be used by all new TI COFF v1/2 targets. */ | 2338 | | /* TI COFF1 and COFF2 use the target_id field to specify which arch. */ | 2339 | | case TICOFF1MAGIC: | 2340 | | case TICOFF2MAGIC: | 2341 | | switch (internal_f->f_target_id) | 2342 | | { | 2343 | | #ifdef TI_TARGET_ID | 2344 | | case TI_TARGET_ID: | 2345 | | arch = TICOFF_TARGET_ARCH; | 2346 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2347 | | break; | 2348 | | #endif | 2349 | | default: | 2350 | | arch = bfd_arch_obscure; | 2351 | | _bfd_error_handler | 2352 | | (_("unrecognized TI COFF target id '0x%x'"), | 2353 | | internal_f->f_target_id); | 2354 | | break; | 2355 | | } | 2356 | | break; | 2357 | | #endif | 2358 | | | 2359 | | #ifdef MCOREMAGIC | 2360 | | case MCOREMAGIC: | 2361 | | arch = bfd_arch_mcore; | 2362 | | break; | 2363 | | #endif | 2364 | | | 2365 | 12 | default: /* Unreadable input file type. */ | 2366 | 12 | arch = bfd_arch_obscure; | 2367 | 12 | break; | 2368 | 412 | } | 2369 | | | 2370 | 412 | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 412 | return true; | 2372 | 412 | } |
coff-stgo32.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 80 | { | 2111 | 80 | unsigned long machine; | 2112 | 80 | enum bfd_architecture arch; | 2113 | 80 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 80 | machine = 0; | 2117 | 80 | switch (internal_f->f_magic) | 2118 | 80 | { | 2119 | 0 | #ifdef I386MAGIC | 2120 | 2 | case I386MAGIC: | 2121 | 2 | case I386PTXMAGIC: | 2122 | 3 | case I386AIXMAGIC: /* Danbury PS/2 AIX C Compiler. */ | 2123 | 80 | case LYNXCOFFMAGIC: | 2124 | 80 | case I386_APPLE_MAGIC: | 2125 | 80 | case I386_FREEBSD_MAGIC: | 2126 | 80 | case I386_LINUX_MAGIC: | 2127 | 80 | case I386_NETBSD_MAGIC: | 2128 | 80 | arch = bfd_arch_i386; | 2129 | 80 | break; | 2130 | 0 | #endif | 2131 | | #ifdef AMD64MAGIC | 2132 | | case AMD64MAGIC: | 2133 | | case AMD64_APPLE_MAGIC: | 2134 | | case AMD64_FREEBSD_MAGIC: | 2135 | | case AMD64_LINUX_MAGIC: | 2136 | | case AMD64_NETBSD_MAGIC: | 2137 | | arch = bfd_arch_i386; | 2138 | | machine = bfd_mach_x86_64; | 2139 | | break; | 2140 | | #endif | 2141 | | #ifdef IA64MAGIC | 2142 | | case IA64MAGIC: | 2143 | | arch = bfd_arch_ia64; | 2144 | | break; | 2145 | | #endif | 2146 | | #ifdef ARMMAGIC | 2147 | | case ARMMAGIC: | 2148 | | case ARMPEMAGIC: | 2149 | | case THUMBPEMAGIC: | 2150 | | arch = bfd_arch_arm; | 2151 | | machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION); | 2152 | | if (machine == bfd_mach_arm_unknown) | 2153 | | { | 2154 | | switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK) | 2155 | | { | 2156 | | case F_ARM_2: machine = bfd_mach_arm_2; break; | 2157 | | case F_ARM_2a: machine = bfd_mach_arm_2a; break; | 2158 | | case F_ARM_3: machine = bfd_mach_arm_3; break; | 2159 | | default: | 2160 | | case F_ARM_3M: machine = bfd_mach_arm_3M; break; | 2161 | | case F_ARM_4: machine = bfd_mach_arm_4; break; | 2162 | | case F_ARM_4T: machine = bfd_mach_arm_4T; break; | 2163 | | /* The COFF header does not have enough bits available | 2164 | | to cover all the different ARM architectures. So | 2165 | | we interpret F_ARM_5, the highest flag value to mean | 2166 | | "the highest ARM architecture known to BFD" which is | 2167 | | currently the XScale. */ | 2168 | | case F_ARM_5: machine = bfd_mach_arm_XScale; break; | 2169 | | } | 2170 | | } | 2171 | | break; | 2172 | | #endif | 2173 | | #ifdef AARCH64MAGIC | 2174 | | case AARCH64MAGIC: | 2175 | | arch = bfd_arch_aarch64; | 2176 | | machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK; | 2177 | | break; | 2178 | | #endif | 2179 | | #ifdef LOONGARCH64MAGIC | 2180 | | case LOONGARCH64MAGIC: | 2181 | | arch = bfd_arch_loongarch; | 2182 | | machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK; | 2183 | | break; | 2184 | | #endif | 2185 | | #ifdef Z80MAGIC | 2186 | | case Z80MAGIC: | 2187 | | arch = bfd_arch_z80; | 2188 | | switch (internal_f->f_flags & F_MACHMASK) | 2189 | | { | 2190 | | case bfd_mach_z80strict << 12: | 2191 | | case bfd_mach_z80 << 12: | 2192 | | case bfd_mach_z80n << 12: | 2193 | | case bfd_mach_z80full << 12: | 2194 | | case bfd_mach_r800 << 12: | 2195 | | case bfd_mach_gbz80 << 12: | 2196 | | case bfd_mach_z180 << 12: | 2197 | | case bfd_mach_ez80_z80 << 12: | 2198 | | case bfd_mach_ez80_adl << 12: | 2199 | | machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12; | 2200 | | break; | 2201 | | default: | 2202 | | return false; | 2203 | | } | 2204 | | break; | 2205 | | #endif | 2206 | | #ifdef Z8KMAGIC | 2207 | | case Z8KMAGIC: | 2208 | | arch = bfd_arch_z8k; | 2209 | | switch (internal_f->f_flags & F_MACHMASK) | 2210 | | { | 2211 | | case F_Z8001: | 2212 | | machine = bfd_mach_z8001; | 2213 | | break; | 2214 | | case F_Z8002: | 2215 | | machine = bfd_mach_z8002; | 2216 | | break; | 2217 | | default: | 2218 | | return false; | 2219 | | } | 2220 | | break; | 2221 | | #endif | 2222 | | | 2223 | | #ifdef RS6000COFF_C | 2224 | | #ifdef XCOFF64 | 2225 | | case U64_TOCMAGIC: | 2226 | | case U803XTOCMAGIC: | 2227 | | #else | 2228 | | case U802ROMAGIC: | 2229 | | case U802WRMAGIC: | 2230 | | case U802TOCMAGIC: | 2231 | | #endif | 2232 | | { | 2233 | | int cputype; | 2234 | | | 2235 | | if (xcoff_data (abfd)->cputype != -1) | 2236 | | cputype = xcoff_data (abfd)->cputype & 0xff; | 2237 | | else | 2238 | | { | 2239 | | /* We did not get a value from the a.out header. If the | 2240 | | file has not been stripped, we may be able to get the | 2241 | | architecture information from the first symbol, if it | 2242 | | is a .file symbol. */ | 2243 | | if (obj_raw_syment_count (abfd) == 0) | 2244 | | cputype = 0; | 2245 | | else | 2246 | | { | 2247 | | bfd_byte *buf; | 2248 | | struct internal_syment sym; | 2249 | | bfd_size_type amt = bfd_coff_symesz (abfd); | 2250 | | | 2251 | | if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0) | 2252 | | return false; | 2253 | | buf = _bfd_malloc_and_read (abfd, amt, amt); | 2254 | | if (buf == NULL) | 2255 | | return false; | 2256 | | bfd_coff_swap_sym_in (abfd, buf, & sym); | 2257 | | if (sym.n_sclass == C_FILE) | 2258 | | cputype = sym.n_type & 0xff; | 2259 | | else | 2260 | | cputype = 0; | 2261 | | free (buf); | 2262 | | } | 2263 | | } | 2264 | | | 2265 | | /* FIXME: We don't handle all cases here. */ | 2266 | | switch (cputype) | 2267 | | { | 2268 | | default: | 2269 | | case 0: | 2270 | | arch = bfd_xcoff_architecture (abfd); | 2271 | | machine = bfd_xcoff_machine (abfd); | 2272 | | break; | 2273 | | | 2274 | | case 1: | 2275 | | arch = bfd_arch_powerpc; | 2276 | | machine = bfd_mach_ppc_601; | 2277 | | break; | 2278 | | case 2: /* 64 bit PowerPC */ | 2279 | | arch = bfd_arch_powerpc; | 2280 | | machine = bfd_mach_ppc_620; | 2281 | | break; | 2282 | | case 3: | 2283 | | arch = bfd_arch_powerpc; | 2284 | | machine = bfd_mach_ppc; | 2285 | | break; | 2286 | | case 4: | 2287 | | arch = bfd_arch_rs6000; | 2288 | | machine = bfd_mach_rs6k; | 2289 | | break; | 2290 | | } | 2291 | | } | 2292 | | break; | 2293 | | #endif | 2294 | | | 2295 | | #ifdef SH_ARCH_MAGIC_BIG | 2296 | | case SH_ARCH_MAGIC_BIG: | 2297 | | case SH_ARCH_MAGIC_LITTLE: | 2298 | | #ifdef COFF_WITH_PE | 2299 | | case SH_ARCH_MAGIC_WINCE: | 2300 | | #endif | 2301 | | arch = bfd_arch_sh; | 2302 | | break; | 2303 | | #endif | 2304 | | | 2305 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 2306 | | case MIPS_ARCH_MAGIC_WINCE: | 2307 | | arch = bfd_arch_mips; | 2308 | | break; | 2309 | | #endif | 2310 | | | 2311 | | #ifdef SPARCMAGIC | 2312 | | case SPARCMAGIC: | 2313 | | #ifdef LYNXCOFFMAGIC | 2314 | | case LYNXCOFFMAGIC: | 2315 | | #endif | 2316 | | arch = bfd_arch_sparc; | 2317 | | break; | 2318 | | #endif | 2319 | | | 2320 | | #ifdef TIC30MAGIC | 2321 | | case TIC30MAGIC: | 2322 | | arch = bfd_arch_tic30; | 2323 | | break; | 2324 | | #endif | 2325 | | | 2326 | | #ifdef TICOFF0MAGIC | 2327 | | #ifdef TICOFF_TARGET_ARCH | 2328 | | /* This TI COFF section should be used by all new TI COFF v0 targets. */ | 2329 | | case TICOFF0MAGIC: | 2330 | | arch = TICOFF_TARGET_ARCH; | 2331 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2332 | | break; | 2333 | | #endif | 2334 | | #endif | 2335 | | | 2336 | | #ifdef TICOFF1MAGIC | 2337 | | /* This TI COFF section should be used by all new TI COFF v1/2 targets. */ | 2338 | | /* TI COFF1 and COFF2 use the target_id field to specify which arch. */ | 2339 | | case TICOFF1MAGIC: | 2340 | | case TICOFF2MAGIC: | 2341 | | switch (internal_f->f_target_id) | 2342 | | { | 2343 | | #ifdef TI_TARGET_ID | 2344 | | case TI_TARGET_ID: | 2345 | | arch = TICOFF_TARGET_ARCH; | 2346 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2347 | | break; | 2348 | | #endif | 2349 | | default: | 2350 | | arch = bfd_arch_obscure; | 2351 | | _bfd_error_handler | 2352 | | (_("unrecognized TI COFF target id '0x%x'"), | 2353 | | internal_f->f_target_id); | 2354 | | break; | 2355 | | } | 2356 | | break; | 2357 | | #endif | 2358 | | | 2359 | | #ifdef MCOREMAGIC | 2360 | | case MCOREMAGIC: | 2361 | | arch = bfd_arch_mcore; | 2362 | | break; | 2363 | | #endif | 2364 | | | 2365 | 0 | default: /* Unreadable input file type. */ | 2366 | 0 | arch = bfd_arch_obscure; | 2367 | 0 | break; | 2368 | 80 | } | 2369 | | | 2370 | 80 | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 80 | return true; | 2372 | 80 | } |
coff-tic30.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 429 | { | 2111 | 429 | unsigned long machine; | 2112 | 429 | enum bfd_architecture arch; | 2113 | 429 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 429 | machine = 0; | 2117 | 429 | switch (internal_f->f_magic) | 2118 | 429 | { | 2119 | | #ifdef I386MAGIC | 2120 | | case I386MAGIC: | 2121 | | case I386PTXMAGIC: | 2122 | | case I386AIXMAGIC: /* Danbury PS/2 AIX C Compiler. */ | 2123 | | case LYNXCOFFMAGIC: | 2124 | | case I386_APPLE_MAGIC: | 2125 | | case I386_FREEBSD_MAGIC: | 2126 | | case I386_LINUX_MAGIC: | 2127 | | case I386_NETBSD_MAGIC: | 2128 | | arch = bfd_arch_i386; | 2129 | | break; | 2130 | | #endif | 2131 | | #ifdef AMD64MAGIC | 2132 | | case AMD64MAGIC: | 2133 | | case AMD64_APPLE_MAGIC: | 2134 | | case AMD64_FREEBSD_MAGIC: | 2135 | | case AMD64_LINUX_MAGIC: | 2136 | | case AMD64_NETBSD_MAGIC: | 2137 | | arch = bfd_arch_i386; | 2138 | | machine = bfd_mach_x86_64; | 2139 | | break; | 2140 | | #endif | 2141 | | #ifdef IA64MAGIC | 2142 | | case IA64MAGIC: | 2143 | | arch = bfd_arch_ia64; | 2144 | | break; | 2145 | | #endif | 2146 | | #ifdef ARMMAGIC | 2147 | | case ARMMAGIC: | 2148 | | case ARMPEMAGIC: | 2149 | | case THUMBPEMAGIC: | 2150 | | arch = bfd_arch_arm; | 2151 | | machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION); | 2152 | | if (machine == bfd_mach_arm_unknown) | 2153 | | { | 2154 | | switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK) | 2155 | | { | 2156 | | case F_ARM_2: machine = bfd_mach_arm_2; break; | 2157 | | case F_ARM_2a: machine = bfd_mach_arm_2a; break; | 2158 | | case F_ARM_3: machine = bfd_mach_arm_3; break; | 2159 | | default: | 2160 | | case F_ARM_3M: machine = bfd_mach_arm_3M; break; | 2161 | | case F_ARM_4: machine = bfd_mach_arm_4; break; | 2162 | | case F_ARM_4T: machine = bfd_mach_arm_4T; break; | 2163 | | /* The COFF header does not have enough bits available | 2164 | | to cover all the different ARM architectures. So | 2165 | | we interpret F_ARM_5, the highest flag value to mean | 2166 | | "the highest ARM architecture known to BFD" which is | 2167 | | currently the XScale. */ | 2168 | | case F_ARM_5: machine = bfd_mach_arm_XScale; break; | 2169 | | } | 2170 | | } | 2171 | | break; | 2172 | | #endif | 2173 | | #ifdef AARCH64MAGIC | 2174 | | case AARCH64MAGIC: | 2175 | | arch = bfd_arch_aarch64; | 2176 | | machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK; | 2177 | | break; | 2178 | | #endif | 2179 | | #ifdef LOONGARCH64MAGIC | 2180 | | case LOONGARCH64MAGIC: | 2181 | | arch = bfd_arch_loongarch; | 2182 | | machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK; | 2183 | | break; | 2184 | | #endif | 2185 | | #ifdef Z80MAGIC | 2186 | | case Z80MAGIC: | 2187 | | arch = bfd_arch_z80; | 2188 | | switch (internal_f->f_flags & F_MACHMASK) | 2189 | | { | 2190 | | case bfd_mach_z80strict << 12: | 2191 | | case bfd_mach_z80 << 12: | 2192 | | case bfd_mach_z80n << 12: | 2193 | | case bfd_mach_z80full << 12: | 2194 | | case bfd_mach_r800 << 12: | 2195 | | case bfd_mach_gbz80 << 12: | 2196 | | case bfd_mach_z180 << 12: | 2197 | | case bfd_mach_ez80_z80 << 12: | 2198 | | case bfd_mach_ez80_adl << 12: | 2199 | | machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12; | 2200 | | break; | 2201 | | default: | 2202 | | return false; | 2203 | | } | 2204 | | break; | 2205 | | #endif | 2206 | | #ifdef Z8KMAGIC | 2207 | | case Z8KMAGIC: | 2208 | | arch = bfd_arch_z8k; | 2209 | | switch (internal_f->f_flags & F_MACHMASK) | 2210 | | { | 2211 | | case F_Z8001: | 2212 | | machine = bfd_mach_z8001; | 2213 | | break; | 2214 | | case F_Z8002: | 2215 | | machine = bfd_mach_z8002; | 2216 | | break; | 2217 | | default: | 2218 | | return false; | 2219 | | } | 2220 | | break; | 2221 | | #endif | 2222 | | | 2223 | | #ifdef RS6000COFF_C | 2224 | | #ifdef XCOFF64 | 2225 | | case U64_TOCMAGIC: | 2226 | | case U803XTOCMAGIC: | 2227 | | #else | 2228 | | case U802ROMAGIC: | 2229 | | case U802WRMAGIC: | 2230 | | case U802TOCMAGIC: | 2231 | | #endif | 2232 | | { | 2233 | | int cputype; | 2234 | | | 2235 | | if (xcoff_data (abfd)->cputype != -1) | 2236 | | cputype = xcoff_data (abfd)->cputype & 0xff; | 2237 | | else | 2238 | | { | 2239 | | /* We did not get a value from the a.out header. If the | 2240 | | file has not been stripped, we may be able to get the | 2241 | | architecture information from the first symbol, if it | 2242 | | is a .file symbol. */ | 2243 | | if (obj_raw_syment_count (abfd) == 0) | 2244 | | cputype = 0; | 2245 | | else | 2246 | | { | 2247 | | bfd_byte *buf; | 2248 | | struct internal_syment sym; | 2249 | | bfd_size_type amt = bfd_coff_symesz (abfd); | 2250 | | | 2251 | | if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0) | 2252 | | return false; | 2253 | | buf = _bfd_malloc_and_read (abfd, amt, amt); | 2254 | | if (buf == NULL) | 2255 | | return false; | 2256 | | bfd_coff_swap_sym_in (abfd, buf, & sym); | 2257 | | if (sym.n_sclass == C_FILE) | 2258 | | cputype = sym.n_type & 0xff; | 2259 | | else | 2260 | | cputype = 0; | 2261 | | free (buf); | 2262 | | } | 2263 | | } | 2264 | | | 2265 | | /* FIXME: We don't handle all cases here. */ | 2266 | | switch (cputype) | 2267 | | { | 2268 | | default: | 2269 | | case 0: | 2270 | | arch = bfd_xcoff_architecture (abfd); | 2271 | | machine = bfd_xcoff_machine (abfd); | 2272 | | break; | 2273 | | | 2274 | | case 1: | 2275 | | arch = bfd_arch_powerpc; | 2276 | | machine = bfd_mach_ppc_601; | 2277 | | break; | 2278 | | case 2: /* 64 bit PowerPC */ | 2279 | | arch = bfd_arch_powerpc; | 2280 | | machine = bfd_mach_ppc_620; | 2281 | | break; | 2282 | | case 3: | 2283 | | arch = bfd_arch_powerpc; | 2284 | | machine = bfd_mach_ppc; | 2285 | | break; | 2286 | | case 4: | 2287 | | arch = bfd_arch_rs6000; | 2288 | | machine = bfd_mach_rs6k; | 2289 | | break; | 2290 | | } | 2291 | | } | 2292 | | break; | 2293 | | #endif | 2294 | | | 2295 | | #ifdef SH_ARCH_MAGIC_BIG | 2296 | | case SH_ARCH_MAGIC_BIG: | 2297 | | case SH_ARCH_MAGIC_LITTLE: | 2298 | | #ifdef COFF_WITH_PE | 2299 | | case SH_ARCH_MAGIC_WINCE: | 2300 | | #endif | 2301 | | arch = bfd_arch_sh; | 2302 | | break; | 2303 | | #endif | 2304 | | | 2305 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 2306 | | case MIPS_ARCH_MAGIC_WINCE: | 2307 | | arch = bfd_arch_mips; | 2308 | | break; | 2309 | | #endif | 2310 | | | 2311 | | #ifdef SPARCMAGIC | 2312 | | case SPARCMAGIC: | 2313 | | #ifdef LYNXCOFFMAGIC | 2314 | | case LYNXCOFFMAGIC: | 2315 | | #endif | 2316 | | arch = bfd_arch_sparc; | 2317 | | break; | 2318 | | #endif | 2319 | | | 2320 | 0 | #ifdef TIC30MAGIC | 2321 | 429 | case TIC30MAGIC: | 2322 | 429 | arch = bfd_arch_tic30; | 2323 | 429 | break; | 2324 | 0 | #endif | 2325 | | | 2326 | | #ifdef TICOFF0MAGIC | 2327 | | #ifdef TICOFF_TARGET_ARCH | 2328 | | /* This TI COFF section should be used by all new TI COFF v0 targets. */ | 2329 | | case TICOFF0MAGIC: | 2330 | | arch = TICOFF_TARGET_ARCH; | 2331 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2332 | | break; | 2333 | | #endif | 2334 | | #endif | 2335 | | | 2336 | | #ifdef TICOFF1MAGIC | 2337 | | /* This TI COFF section should be used by all new TI COFF v1/2 targets. */ | 2338 | | /* TI COFF1 and COFF2 use the target_id field to specify which arch. */ | 2339 | | case TICOFF1MAGIC: | 2340 | | case TICOFF2MAGIC: | 2341 | | switch (internal_f->f_target_id) | 2342 | | { | 2343 | | #ifdef TI_TARGET_ID | 2344 | | case TI_TARGET_ID: | 2345 | | arch = TICOFF_TARGET_ARCH; | 2346 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2347 | | break; | 2348 | | #endif | 2349 | | default: | 2350 | | arch = bfd_arch_obscure; | 2351 | | _bfd_error_handler | 2352 | | (_("unrecognized TI COFF target id '0x%x'"), | 2353 | | internal_f->f_target_id); | 2354 | | break; | 2355 | | } | 2356 | | break; | 2357 | | #endif | 2358 | | | 2359 | | #ifdef MCOREMAGIC | 2360 | | case MCOREMAGIC: | 2361 | | arch = bfd_arch_mcore; | 2362 | | break; | 2363 | | #endif | 2364 | | | 2365 | 0 | default: /* Unreadable input file type. */ | 2366 | 0 | arch = bfd_arch_obscure; | 2367 | 0 | break; | 2368 | 429 | } | 2369 | | | 2370 | 429 | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 429 | return true; | 2372 | 429 | } |
Unexecuted instantiation: coff-tic4x.c:coff_set_arch_mach_hook coff-tic54x.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 403 | { | 2111 | 403 | unsigned long machine; | 2112 | 403 | enum bfd_architecture arch; | 2113 | 403 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 403 | machine = 0; | 2117 | 403 | switch (internal_f->f_magic) | 2118 | 403 | { | 2119 | | #ifdef I386MAGIC | 2120 | | case I386MAGIC: | 2121 | | case I386PTXMAGIC: | 2122 | | case I386AIXMAGIC: /* Danbury PS/2 AIX C Compiler. */ | 2123 | | case LYNXCOFFMAGIC: | 2124 | | case I386_APPLE_MAGIC: | 2125 | | case I386_FREEBSD_MAGIC: | 2126 | | case I386_LINUX_MAGIC: | 2127 | | case I386_NETBSD_MAGIC: | 2128 | | arch = bfd_arch_i386; | 2129 | | break; | 2130 | | #endif | 2131 | | #ifdef AMD64MAGIC | 2132 | | case AMD64MAGIC: | 2133 | | case AMD64_APPLE_MAGIC: | 2134 | | case AMD64_FREEBSD_MAGIC: | 2135 | | case AMD64_LINUX_MAGIC: | 2136 | | case AMD64_NETBSD_MAGIC: | 2137 | | arch = bfd_arch_i386; | 2138 | | machine = bfd_mach_x86_64; | 2139 | | break; | 2140 | | #endif | 2141 | | #ifdef IA64MAGIC | 2142 | | case IA64MAGIC: | 2143 | | arch = bfd_arch_ia64; | 2144 | | break; | 2145 | | #endif | 2146 | | #ifdef ARMMAGIC | 2147 | | case ARMMAGIC: | 2148 | | case ARMPEMAGIC: | 2149 | | case THUMBPEMAGIC: | 2150 | | arch = bfd_arch_arm; | 2151 | | machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION); | 2152 | | if (machine == bfd_mach_arm_unknown) | 2153 | | { | 2154 | | switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK) | 2155 | | { | 2156 | | case F_ARM_2: machine = bfd_mach_arm_2; break; | 2157 | | case F_ARM_2a: machine = bfd_mach_arm_2a; break; | 2158 | | case F_ARM_3: machine = bfd_mach_arm_3; break; | 2159 | | default: | 2160 | | case F_ARM_3M: machine = bfd_mach_arm_3M; break; | 2161 | | case F_ARM_4: machine = bfd_mach_arm_4; break; | 2162 | | case F_ARM_4T: machine = bfd_mach_arm_4T; break; | 2163 | | /* The COFF header does not have enough bits available | 2164 | | to cover all the different ARM architectures. So | 2165 | | we interpret F_ARM_5, the highest flag value to mean | 2166 | | "the highest ARM architecture known to BFD" which is | 2167 | | currently the XScale. */ | 2168 | | case F_ARM_5: machine = bfd_mach_arm_XScale; break; | 2169 | | } | 2170 | | } | 2171 | | break; | 2172 | | #endif | 2173 | | #ifdef AARCH64MAGIC | 2174 | | case AARCH64MAGIC: | 2175 | | arch = bfd_arch_aarch64; | 2176 | | machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK; | 2177 | | break; | 2178 | | #endif | 2179 | | #ifdef LOONGARCH64MAGIC | 2180 | | case LOONGARCH64MAGIC: | 2181 | | arch = bfd_arch_loongarch; | 2182 | | machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK; | 2183 | | break; | 2184 | | #endif | 2185 | | #ifdef Z80MAGIC | 2186 | | case Z80MAGIC: | 2187 | | arch = bfd_arch_z80; | 2188 | | switch (internal_f->f_flags & F_MACHMASK) | 2189 | | { | 2190 | | case bfd_mach_z80strict << 12: | 2191 | | case bfd_mach_z80 << 12: | 2192 | | case bfd_mach_z80n << 12: | 2193 | | case bfd_mach_z80full << 12: | 2194 | | case bfd_mach_r800 << 12: | 2195 | | case bfd_mach_gbz80 << 12: | 2196 | | case bfd_mach_z180 << 12: | 2197 | | case bfd_mach_ez80_z80 << 12: | 2198 | | case bfd_mach_ez80_adl << 12: | 2199 | | machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12; | 2200 | | break; | 2201 | | default: | 2202 | | return false; | 2203 | | } | 2204 | | break; | 2205 | | #endif | 2206 | | #ifdef Z8KMAGIC | 2207 | | case Z8KMAGIC: | 2208 | | arch = bfd_arch_z8k; | 2209 | | switch (internal_f->f_flags & F_MACHMASK) | 2210 | | { | 2211 | | case F_Z8001: | 2212 | | machine = bfd_mach_z8001; | 2213 | | break; | 2214 | | case F_Z8002: | 2215 | | machine = bfd_mach_z8002; | 2216 | | break; | 2217 | | default: | 2218 | | return false; | 2219 | | } | 2220 | | break; | 2221 | | #endif | 2222 | | | 2223 | | #ifdef RS6000COFF_C | 2224 | | #ifdef XCOFF64 | 2225 | | case U64_TOCMAGIC: | 2226 | | case U803XTOCMAGIC: | 2227 | | #else | 2228 | | case U802ROMAGIC: | 2229 | | case U802WRMAGIC: | 2230 | | case U802TOCMAGIC: | 2231 | | #endif | 2232 | | { | 2233 | | int cputype; | 2234 | | | 2235 | | if (xcoff_data (abfd)->cputype != -1) | 2236 | | cputype = xcoff_data (abfd)->cputype & 0xff; | 2237 | | else | 2238 | | { | 2239 | | /* We did not get a value from the a.out header. If the | 2240 | | file has not been stripped, we may be able to get the | 2241 | | architecture information from the first symbol, if it | 2242 | | is a .file symbol. */ | 2243 | | if (obj_raw_syment_count (abfd) == 0) | 2244 | | cputype = 0; | 2245 | | else | 2246 | | { | 2247 | | bfd_byte *buf; | 2248 | | struct internal_syment sym; | 2249 | | bfd_size_type amt = bfd_coff_symesz (abfd); | 2250 | | | 2251 | | if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0) | 2252 | | return false; | 2253 | | buf = _bfd_malloc_and_read (abfd, amt, amt); | 2254 | | if (buf == NULL) | 2255 | | return false; | 2256 | | bfd_coff_swap_sym_in (abfd, buf, & sym); | 2257 | | if (sym.n_sclass == C_FILE) | 2258 | | cputype = sym.n_type & 0xff; | 2259 | | else | 2260 | | cputype = 0; | 2261 | | free (buf); | 2262 | | } | 2263 | | } | 2264 | | | 2265 | | /* FIXME: We don't handle all cases here. */ | 2266 | | switch (cputype) | 2267 | | { | 2268 | | default: | 2269 | | case 0: | 2270 | | arch = bfd_xcoff_architecture (abfd); | 2271 | | machine = bfd_xcoff_machine (abfd); | 2272 | | break; | 2273 | | | 2274 | | case 1: | 2275 | | arch = bfd_arch_powerpc; | 2276 | | machine = bfd_mach_ppc_601; | 2277 | | break; | 2278 | | case 2: /* 64 bit PowerPC */ | 2279 | | arch = bfd_arch_powerpc; | 2280 | | machine = bfd_mach_ppc_620; | 2281 | | break; | 2282 | | case 3: | 2283 | | arch = bfd_arch_powerpc; | 2284 | | machine = bfd_mach_ppc; | 2285 | | break; | 2286 | | case 4: | 2287 | | arch = bfd_arch_rs6000; | 2288 | | machine = bfd_mach_rs6k; | 2289 | | break; | 2290 | | } | 2291 | | } | 2292 | | break; | 2293 | | #endif | 2294 | | | 2295 | | #ifdef SH_ARCH_MAGIC_BIG | 2296 | | case SH_ARCH_MAGIC_BIG: | 2297 | | case SH_ARCH_MAGIC_LITTLE: | 2298 | | #ifdef COFF_WITH_PE | 2299 | | case SH_ARCH_MAGIC_WINCE: | 2300 | | #endif | 2301 | | arch = bfd_arch_sh; | 2302 | | break; | 2303 | | #endif | 2304 | | | 2305 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 2306 | | case MIPS_ARCH_MAGIC_WINCE: | 2307 | | arch = bfd_arch_mips; | 2308 | | break; | 2309 | | #endif | 2310 | | | 2311 | | #ifdef SPARCMAGIC | 2312 | | case SPARCMAGIC: | 2313 | | #ifdef LYNXCOFFMAGIC | 2314 | | case LYNXCOFFMAGIC: | 2315 | | #endif | 2316 | | arch = bfd_arch_sparc; | 2317 | | break; | 2318 | | #endif | 2319 | | | 2320 | | #ifdef TIC30MAGIC | 2321 | | case TIC30MAGIC: | 2322 | | arch = bfd_arch_tic30; | 2323 | | break; | 2324 | | #endif | 2325 | | | 2326 | 0 | #ifdef TICOFF0MAGIC | 2327 | 0 | #ifdef TICOFF_TARGET_ARCH | 2328 | | /* This TI COFF section should be used by all new TI COFF v0 targets. */ | 2329 | 397 | case TICOFF0MAGIC: | 2330 | 397 | arch = TICOFF_TARGET_ARCH; | 2331 | 397 | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2332 | 397 | break; | 2333 | 0 | #endif | 2334 | 0 | #endif | 2335 | | | 2336 | 0 | #ifdef TICOFF1MAGIC | 2337 | | /* This TI COFF section should be used by all new TI COFF v1/2 targets. */ | 2338 | | /* TI COFF1 and COFF2 use the target_id field to specify which arch. */ | 2339 | 1 | case TICOFF1MAGIC: | 2340 | 6 | case TICOFF2MAGIC: | 2341 | 6 | switch (internal_f->f_target_id) | 2342 | 6 | { | 2343 | 0 | #ifdef TI_TARGET_ID | 2344 | 6 | case TI_TARGET_ID: | 2345 | 6 | arch = TICOFF_TARGET_ARCH; | 2346 | 6 | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2347 | 6 | break; | 2348 | 0 | #endif | 2349 | 0 | default: | 2350 | 0 | arch = bfd_arch_obscure; | 2351 | 0 | _bfd_error_handler | 2352 | 0 | (_("unrecognized TI COFF target id '0x%x'"), | 2353 | 0 | internal_f->f_target_id); | 2354 | 0 | break; | 2355 | 6 | } | 2356 | 6 | break; | 2357 | 6 | #endif | 2358 | | | 2359 | | #ifdef MCOREMAGIC | 2360 | | case MCOREMAGIC: | 2361 | | arch = bfd_arch_mcore; | 2362 | | break; | 2363 | | #endif | 2364 | | | 2365 | 6 | default: /* Unreadable input file type. */ | 2366 | 0 | arch = bfd_arch_obscure; | 2367 | 0 | break; | 2368 | 403 | } | 2369 | | | 2370 | 403 | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 403 | return true; | 2372 | 403 | } |
coff-z80.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 363 | { | 2111 | 363 | unsigned long machine; | 2112 | 363 | enum bfd_architecture arch; | 2113 | 363 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 363 | machine = 0; | 2117 | 363 | switch (internal_f->f_magic) | 2118 | 363 | { | 2119 | | #ifdef I386MAGIC | 2120 | | case I386MAGIC: | 2121 | | case I386PTXMAGIC: | 2122 | | case I386AIXMAGIC: /* Danbury PS/2 AIX C Compiler. */ | 2123 | | case LYNXCOFFMAGIC: | 2124 | | case I386_APPLE_MAGIC: | 2125 | | case I386_FREEBSD_MAGIC: | 2126 | | case I386_LINUX_MAGIC: | 2127 | | case I386_NETBSD_MAGIC: | 2128 | | arch = bfd_arch_i386; | 2129 | | break; | 2130 | | #endif | 2131 | | #ifdef AMD64MAGIC | 2132 | | case AMD64MAGIC: | 2133 | | case AMD64_APPLE_MAGIC: | 2134 | | case AMD64_FREEBSD_MAGIC: | 2135 | | case AMD64_LINUX_MAGIC: | 2136 | | case AMD64_NETBSD_MAGIC: | 2137 | | arch = bfd_arch_i386; | 2138 | | machine = bfd_mach_x86_64; | 2139 | | break; | 2140 | | #endif | 2141 | | #ifdef IA64MAGIC | 2142 | | case IA64MAGIC: | 2143 | | arch = bfd_arch_ia64; | 2144 | | break; | 2145 | | #endif | 2146 | | #ifdef ARMMAGIC | 2147 | | case ARMMAGIC: | 2148 | | case ARMPEMAGIC: | 2149 | | case THUMBPEMAGIC: | 2150 | | arch = bfd_arch_arm; | 2151 | | machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION); | 2152 | | if (machine == bfd_mach_arm_unknown) | 2153 | | { | 2154 | | switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK) | 2155 | | { | 2156 | | case F_ARM_2: machine = bfd_mach_arm_2; break; | 2157 | | case F_ARM_2a: machine = bfd_mach_arm_2a; break; | 2158 | | case F_ARM_3: machine = bfd_mach_arm_3; break; | 2159 | | default: | 2160 | | case F_ARM_3M: machine = bfd_mach_arm_3M; break; | 2161 | | case F_ARM_4: machine = bfd_mach_arm_4; break; | 2162 | | case F_ARM_4T: machine = bfd_mach_arm_4T; break; | 2163 | | /* The COFF header does not have enough bits available | 2164 | | to cover all the different ARM architectures. So | 2165 | | we interpret F_ARM_5, the highest flag value to mean | 2166 | | "the highest ARM architecture known to BFD" which is | 2167 | | currently the XScale. */ | 2168 | | case F_ARM_5: machine = bfd_mach_arm_XScale; break; | 2169 | | } | 2170 | | } | 2171 | | break; | 2172 | | #endif | 2173 | | #ifdef AARCH64MAGIC | 2174 | | case AARCH64MAGIC: | 2175 | | arch = bfd_arch_aarch64; | 2176 | | machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK; | 2177 | | break; | 2178 | | #endif | 2179 | | #ifdef LOONGARCH64MAGIC | 2180 | | case LOONGARCH64MAGIC: | 2181 | | arch = bfd_arch_loongarch; | 2182 | | machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK; | 2183 | | break; | 2184 | | #endif | 2185 | 0 | #ifdef Z80MAGIC | 2186 | 363 | case Z80MAGIC: | 2187 | 363 | arch = bfd_arch_z80; | 2188 | 363 | switch (internal_f->f_flags & F_MACHMASK) | 2189 | 363 | { | 2190 | 2 | case bfd_mach_z80strict << 12: | 2191 | 6 | case bfd_mach_z80 << 12: | 2192 | 46 | case bfd_mach_z80n << 12: | 2193 | 54 | case bfd_mach_z80full << 12: | 2194 | 125 | case bfd_mach_r800 << 12: | 2195 | 151 | case bfd_mach_gbz80 << 12: | 2196 | 203 | case bfd_mach_z180 << 12: | 2197 | 350 | case bfd_mach_ez80_z80 << 12: | 2198 | 362 | case bfd_mach_ez80_adl << 12: | 2199 | 362 | machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12; | 2200 | 362 | break; | 2201 | 1 | default: | 2202 | 1 | return false; | 2203 | 363 | } | 2204 | 362 | break; | 2205 | 362 | #endif | 2206 | | #ifdef Z8KMAGIC | 2207 | | case Z8KMAGIC: | 2208 | | arch = bfd_arch_z8k; | 2209 | | switch (internal_f->f_flags & F_MACHMASK) | 2210 | | { | 2211 | | case F_Z8001: | 2212 | | machine = bfd_mach_z8001; | 2213 | | break; | 2214 | | case F_Z8002: | 2215 | | machine = bfd_mach_z8002; | 2216 | | break; | 2217 | | default: | 2218 | | return false; | 2219 | | } | 2220 | | break; | 2221 | | #endif | 2222 | | | 2223 | | #ifdef RS6000COFF_C | 2224 | | #ifdef XCOFF64 | 2225 | | case U64_TOCMAGIC: | 2226 | | case U803XTOCMAGIC: | 2227 | | #else | 2228 | | case U802ROMAGIC: | 2229 | | case U802WRMAGIC: | 2230 | | case U802TOCMAGIC: | 2231 | | #endif | 2232 | | { | 2233 | | int cputype; | 2234 | | | 2235 | | if (xcoff_data (abfd)->cputype != -1) | 2236 | | cputype = xcoff_data (abfd)->cputype & 0xff; | 2237 | | else | 2238 | | { | 2239 | | /* We did not get a value from the a.out header. If the | 2240 | | file has not been stripped, we may be able to get the | 2241 | | architecture information from the first symbol, if it | 2242 | | is a .file symbol. */ | 2243 | | if (obj_raw_syment_count (abfd) == 0) | 2244 | | cputype = 0; | 2245 | | else | 2246 | | { | 2247 | | bfd_byte *buf; | 2248 | | struct internal_syment sym; | 2249 | | bfd_size_type amt = bfd_coff_symesz (abfd); | 2250 | | | 2251 | | if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0) | 2252 | | return false; | 2253 | | buf = _bfd_malloc_and_read (abfd, amt, amt); | 2254 | | if (buf == NULL) | 2255 | | return false; | 2256 | | bfd_coff_swap_sym_in (abfd, buf, & sym); | 2257 | | if (sym.n_sclass == C_FILE) | 2258 | | cputype = sym.n_type & 0xff; | 2259 | | else | 2260 | | cputype = 0; | 2261 | | free (buf); | 2262 | | } | 2263 | | } | 2264 | | | 2265 | | /* FIXME: We don't handle all cases here. */ | 2266 | | switch (cputype) | 2267 | | { | 2268 | | default: | 2269 | | case 0: | 2270 | | arch = bfd_xcoff_architecture (abfd); | 2271 | | machine = bfd_xcoff_machine (abfd); | 2272 | | break; | 2273 | | | 2274 | | case 1: | 2275 | | arch = bfd_arch_powerpc; | 2276 | | machine = bfd_mach_ppc_601; | 2277 | | break; | 2278 | | case 2: /* 64 bit PowerPC */ | 2279 | | arch = bfd_arch_powerpc; | 2280 | | machine = bfd_mach_ppc_620; | 2281 | | break; | 2282 | | case 3: | 2283 | | arch = bfd_arch_powerpc; | 2284 | | machine = bfd_mach_ppc; | 2285 | | break; | 2286 | | case 4: | 2287 | | arch = bfd_arch_rs6000; | 2288 | | machine = bfd_mach_rs6k; | 2289 | | break; | 2290 | | } | 2291 | | } | 2292 | | break; | 2293 | | #endif | 2294 | | | 2295 | | #ifdef SH_ARCH_MAGIC_BIG | 2296 | | case SH_ARCH_MAGIC_BIG: | 2297 | | case SH_ARCH_MAGIC_LITTLE: | 2298 | | #ifdef COFF_WITH_PE | 2299 | | case SH_ARCH_MAGIC_WINCE: | 2300 | | #endif | 2301 | | arch = bfd_arch_sh; | 2302 | | break; | 2303 | | #endif | 2304 | | | 2305 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 2306 | | case MIPS_ARCH_MAGIC_WINCE: | 2307 | | arch = bfd_arch_mips; | 2308 | | break; | 2309 | | #endif | 2310 | | | 2311 | | #ifdef SPARCMAGIC | 2312 | | case SPARCMAGIC: | 2313 | | #ifdef LYNXCOFFMAGIC | 2314 | | case LYNXCOFFMAGIC: | 2315 | | #endif | 2316 | | arch = bfd_arch_sparc; | 2317 | | break; | 2318 | | #endif | 2319 | | | 2320 | | #ifdef TIC30MAGIC | 2321 | | case TIC30MAGIC: | 2322 | | arch = bfd_arch_tic30; | 2323 | | break; | 2324 | | #endif | 2325 | | | 2326 | | #ifdef TICOFF0MAGIC | 2327 | | #ifdef TICOFF_TARGET_ARCH | 2328 | | /* This TI COFF section should be used by all new TI COFF v0 targets. */ | 2329 | | case TICOFF0MAGIC: | 2330 | | arch = TICOFF_TARGET_ARCH; | 2331 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2332 | | break; | 2333 | | #endif | 2334 | | #endif | 2335 | | | 2336 | | #ifdef TICOFF1MAGIC | 2337 | | /* This TI COFF section should be used by all new TI COFF v1/2 targets. */ | 2338 | | /* TI COFF1 and COFF2 use the target_id field to specify which arch. */ | 2339 | | case TICOFF1MAGIC: | 2340 | | case TICOFF2MAGIC: | 2341 | | switch (internal_f->f_target_id) | 2342 | | { | 2343 | | #ifdef TI_TARGET_ID | 2344 | | case TI_TARGET_ID: | 2345 | | arch = TICOFF_TARGET_ARCH; | 2346 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2347 | | break; | 2348 | | #endif | 2349 | | default: | 2350 | | arch = bfd_arch_obscure; | 2351 | | _bfd_error_handler | 2352 | | (_("unrecognized TI COFF target id '0x%x'"), | 2353 | | internal_f->f_target_id); | 2354 | | break; | 2355 | | } | 2356 | | break; | 2357 | | #endif | 2358 | | | 2359 | | #ifdef MCOREMAGIC | 2360 | | case MCOREMAGIC: | 2361 | | arch = bfd_arch_mcore; | 2362 | | break; | 2363 | | #endif | 2364 | | | 2365 | 362 | default: /* Unreadable input file type. */ | 2366 | 0 | arch = bfd_arch_obscure; | 2367 | 0 | break; | 2368 | 363 | } | 2369 | | | 2370 | 362 | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 362 | return true; | 2372 | 363 | } |
coff-z8k.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 358 | { | 2111 | 358 | unsigned long machine; | 2112 | 358 | enum bfd_architecture arch; | 2113 | 358 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 358 | machine = 0; | 2117 | 358 | switch (internal_f->f_magic) | 2118 | 358 | { | 2119 | | #ifdef I386MAGIC | 2120 | | case I386MAGIC: | 2121 | | case I386PTXMAGIC: | 2122 | | case I386AIXMAGIC: /* Danbury PS/2 AIX C Compiler. */ | 2123 | | case LYNXCOFFMAGIC: | 2124 | | case I386_APPLE_MAGIC: | 2125 | | case I386_FREEBSD_MAGIC: | 2126 | | case I386_LINUX_MAGIC: | 2127 | | case I386_NETBSD_MAGIC: | 2128 | | arch = bfd_arch_i386; | 2129 | | break; | 2130 | | #endif | 2131 | | #ifdef AMD64MAGIC | 2132 | | case AMD64MAGIC: | 2133 | | case AMD64_APPLE_MAGIC: | 2134 | | case AMD64_FREEBSD_MAGIC: | 2135 | | case AMD64_LINUX_MAGIC: | 2136 | | case AMD64_NETBSD_MAGIC: | 2137 | | arch = bfd_arch_i386; | 2138 | | machine = bfd_mach_x86_64; | 2139 | | break; | 2140 | | #endif | 2141 | | #ifdef IA64MAGIC | 2142 | | case IA64MAGIC: | 2143 | | arch = bfd_arch_ia64; | 2144 | | break; | 2145 | | #endif | 2146 | | #ifdef ARMMAGIC | 2147 | | case ARMMAGIC: | 2148 | | case ARMPEMAGIC: | 2149 | | case THUMBPEMAGIC: | 2150 | | arch = bfd_arch_arm; | 2151 | | machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION); | 2152 | | if (machine == bfd_mach_arm_unknown) | 2153 | | { | 2154 | | switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK) | 2155 | | { | 2156 | | case F_ARM_2: machine = bfd_mach_arm_2; break; | 2157 | | case F_ARM_2a: machine = bfd_mach_arm_2a; break; | 2158 | | case F_ARM_3: machine = bfd_mach_arm_3; break; | 2159 | | default: | 2160 | | case F_ARM_3M: machine = bfd_mach_arm_3M; break; | 2161 | | case F_ARM_4: machine = bfd_mach_arm_4; break; | 2162 | | case F_ARM_4T: machine = bfd_mach_arm_4T; break; | 2163 | | /* The COFF header does not have enough bits available | 2164 | | to cover all the different ARM architectures. So | 2165 | | we interpret F_ARM_5, the highest flag value to mean | 2166 | | "the highest ARM architecture known to BFD" which is | 2167 | | currently the XScale. */ | 2168 | | case F_ARM_5: machine = bfd_mach_arm_XScale; break; | 2169 | | } | 2170 | | } | 2171 | | break; | 2172 | | #endif | 2173 | | #ifdef AARCH64MAGIC | 2174 | | case AARCH64MAGIC: | 2175 | | arch = bfd_arch_aarch64; | 2176 | | machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK; | 2177 | | break; | 2178 | | #endif | 2179 | | #ifdef LOONGARCH64MAGIC | 2180 | | case LOONGARCH64MAGIC: | 2181 | | arch = bfd_arch_loongarch; | 2182 | | machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK; | 2183 | | break; | 2184 | | #endif | 2185 | | #ifdef Z80MAGIC | 2186 | | case Z80MAGIC: | 2187 | | arch = bfd_arch_z80; | 2188 | | switch (internal_f->f_flags & F_MACHMASK) | 2189 | | { | 2190 | | case bfd_mach_z80strict << 12: | 2191 | | case bfd_mach_z80 << 12: | 2192 | | case bfd_mach_z80n << 12: | 2193 | | case bfd_mach_z80full << 12: | 2194 | | case bfd_mach_r800 << 12: | 2195 | | case bfd_mach_gbz80 << 12: | 2196 | | case bfd_mach_z180 << 12: | 2197 | | case bfd_mach_ez80_z80 << 12: | 2198 | | case bfd_mach_ez80_adl << 12: | 2199 | | machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12; | 2200 | | break; | 2201 | | default: | 2202 | | return false; | 2203 | | } | 2204 | | break; | 2205 | | #endif | 2206 | 0 | #ifdef Z8KMAGIC | 2207 | 358 | case Z8KMAGIC: | 2208 | 358 | arch = bfd_arch_z8k; | 2209 | 358 | switch (internal_f->f_flags & F_MACHMASK) | 2210 | 358 | { | 2211 | 67 | case F_Z8001: | 2212 | 67 | machine = bfd_mach_z8001; | 2213 | 67 | break; | 2214 | 287 | case F_Z8002: | 2215 | 287 | machine = bfd_mach_z8002; | 2216 | 287 | break; | 2217 | 4 | default: | 2218 | 4 | return false; | 2219 | 358 | } | 2220 | 354 | break; | 2221 | 354 | #endif | 2222 | | | 2223 | | #ifdef RS6000COFF_C | 2224 | | #ifdef XCOFF64 | 2225 | | case U64_TOCMAGIC: | 2226 | | case U803XTOCMAGIC: | 2227 | | #else | 2228 | | case U802ROMAGIC: | 2229 | | case U802WRMAGIC: | 2230 | | case U802TOCMAGIC: | 2231 | | #endif | 2232 | | { | 2233 | | int cputype; | 2234 | | | 2235 | | if (xcoff_data (abfd)->cputype != -1) | 2236 | | cputype = xcoff_data (abfd)->cputype & 0xff; | 2237 | | else | 2238 | | { | 2239 | | /* We did not get a value from the a.out header. If the | 2240 | | file has not been stripped, we may be able to get the | 2241 | | architecture information from the first symbol, if it | 2242 | | is a .file symbol. */ | 2243 | | if (obj_raw_syment_count (abfd) == 0) | 2244 | | cputype = 0; | 2245 | | else | 2246 | | { | 2247 | | bfd_byte *buf; | 2248 | | struct internal_syment sym; | 2249 | | bfd_size_type amt = bfd_coff_symesz (abfd); | 2250 | | | 2251 | | if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0) | 2252 | | return false; | 2253 | | buf = _bfd_malloc_and_read (abfd, amt, amt); | 2254 | | if (buf == NULL) | 2255 | | return false; | 2256 | | bfd_coff_swap_sym_in (abfd, buf, & sym); | 2257 | | if (sym.n_sclass == C_FILE) | 2258 | | cputype = sym.n_type & 0xff; | 2259 | | else | 2260 | | cputype = 0; | 2261 | | free (buf); | 2262 | | } | 2263 | | } | 2264 | | | 2265 | | /* FIXME: We don't handle all cases here. */ | 2266 | | switch (cputype) | 2267 | | { | 2268 | | default: | 2269 | | case 0: | 2270 | | arch = bfd_xcoff_architecture (abfd); | 2271 | | machine = bfd_xcoff_machine (abfd); | 2272 | | break; | 2273 | | | 2274 | | case 1: | 2275 | | arch = bfd_arch_powerpc; | 2276 | | machine = bfd_mach_ppc_601; | 2277 | | break; | 2278 | | case 2: /* 64 bit PowerPC */ | 2279 | | arch = bfd_arch_powerpc; | 2280 | | machine = bfd_mach_ppc_620; | 2281 | | break; | 2282 | | case 3: | 2283 | | arch = bfd_arch_powerpc; | 2284 | | machine = bfd_mach_ppc; | 2285 | | break; | 2286 | | case 4: | 2287 | | arch = bfd_arch_rs6000; | 2288 | | machine = bfd_mach_rs6k; | 2289 | | break; | 2290 | | } | 2291 | | } | 2292 | | break; | 2293 | | #endif | 2294 | | | 2295 | | #ifdef SH_ARCH_MAGIC_BIG | 2296 | | case SH_ARCH_MAGIC_BIG: | 2297 | | case SH_ARCH_MAGIC_LITTLE: | 2298 | | #ifdef COFF_WITH_PE | 2299 | | case SH_ARCH_MAGIC_WINCE: | 2300 | | #endif | 2301 | | arch = bfd_arch_sh; | 2302 | | break; | 2303 | | #endif | 2304 | | | 2305 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 2306 | | case MIPS_ARCH_MAGIC_WINCE: | 2307 | | arch = bfd_arch_mips; | 2308 | | break; | 2309 | | #endif | 2310 | | | 2311 | | #ifdef SPARCMAGIC | 2312 | | case SPARCMAGIC: | 2313 | | #ifdef LYNXCOFFMAGIC | 2314 | | case LYNXCOFFMAGIC: | 2315 | | #endif | 2316 | | arch = bfd_arch_sparc; | 2317 | | break; | 2318 | | #endif | 2319 | | | 2320 | | #ifdef TIC30MAGIC | 2321 | | case TIC30MAGIC: | 2322 | | arch = bfd_arch_tic30; | 2323 | | break; | 2324 | | #endif | 2325 | | | 2326 | | #ifdef TICOFF0MAGIC | 2327 | | #ifdef TICOFF_TARGET_ARCH | 2328 | | /* This TI COFF section should be used by all new TI COFF v0 targets. */ | 2329 | | case TICOFF0MAGIC: | 2330 | | arch = TICOFF_TARGET_ARCH; | 2331 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2332 | | break; | 2333 | | #endif | 2334 | | #endif | 2335 | | | 2336 | | #ifdef TICOFF1MAGIC | 2337 | | /* This TI COFF section should be used by all new TI COFF v1/2 targets. */ | 2338 | | /* TI COFF1 and COFF2 use the target_id field to specify which arch. */ | 2339 | | case TICOFF1MAGIC: | 2340 | | case TICOFF2MAGIC: | 2341 | | switch (internal_f->f_target_id) | 2342 | | { | 2343 | | #ifdef TI_TARGET_ID | 2344 | | case TI_TARGET_ID: | 2345 | | arch = TICOFF_TARGET_ARCH; | 2346 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2347 | | break; | 2348 | | #endif | 2349 | | default: | 2350 | | arch = bfd_arch_obscure; | 2351 | | _bfd_error_handler | 2352 | | (_("unrecognized TI COFF target id '0x%x'"), | 2353 | | internal_f->f_target_id); | 2354 | | break; | 2355 | | } | 2356 | | break; | 2357 | | #endif | 2358 | | | 2359 | | #ifdef MCOREMAGIC | 2360 | | case MCOREMAGIC: | 2361 | | arch = bfd_arch_mcore; | 2362 | | break; | 2363 | | #endif | 2364 | | | 2365 | 354 | default: /* Unreadable input file type. */ | 2366 | 0 | arch = bfd_arch_obscure; | 2367 | 0 | break; | 2368 | 358 | } | 2369 | | | 2370 | 354 | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 354 | return true; | 2372 | 358 | } |
pe-arm-wince.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 207 | { | 2111 | 207 | unsigned long machine; | 2112 | 207 | enum bfd_architecture arch; | 2113 | 207 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 207 | machine = 0; | 2117 | 207 | switch (internal_f->f_magic) | 2118 | 207 | { | 2119 | | #ifdef I386MAGIC | 2120 | | case I386MAGIC: | 2121 | | case I386PTXMAGIC: | 2122 | | case I386AIXMAGIC: /* Danbury PS/2 AIX C Compiler. */ | 2123 | | case LYNXCOFFMAGIC: | 2124 | | case I386_APPLE_MAGIC: | 2125 | | case I386_FREEBSD_MAGIC: | 2126 | | case I386_LINUX_MAGIC: | 2127 | | case I386_NETBSD_MAGIC: | 2128 | | arch = bfd_arch_i386; | 2129 | | break; | 2130 | | #endif | 2131 | | #ifdef AMD64MAGIC | 2132 | | case AMD64MAGIC: | 2133 | | case AMD64_APPLE_MAGIC: | 2134 | | case AMD64_FREEBSD_MAGIC: | 2135 | | case AMD64_LINUX_MAGIC: | 2136 | | case AMD64_NETBSD_MAGIC: | 2137 | | arch = bfd_arch_i386; | 2138 | | machine = bfd_mach_x86_64; | 2139 | | break; | 2140 | | #endif | 2141 | | #ifdef IA64MAGIC | 2142 | | case IA64MAGIC: | 2143 | | arch = bfd_arch_ia64; | 2144 | | break; | 2145 | | #endif | 2146 | 0 | #ifdef ARMMAGIC | 2147 | 196 | case ARMMAGIC: | 2148 | 200 | case ARMPEMAGIC: | 2149 | 206 | case THUMBPEMAGIC: | 2150 | 206 | arch = bfd_arch_arm; | 2151 | 206 | machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION); | 2152 | 206 | if (machine == bfd_mach_arm_unknown) | 2153 | 206 | { | 2154 | 206 | switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK) | 2155 | 206 | { | 2156 | 6 | case F_ARM_2: machine = bfd_mach_arm_2; break; | 2157 | 9 | case F_ARM_2a: machine = bfd_mach_arm_2a; break; | 2158 | 8 | case F_ARM_3: machine = bfd_mach_arm_3; break; | 2159 | 133 | default: | 2160 | 145 | case F_ARM_3M: machine = bfd_mach_arm_3M; break; | 2161 | 8 | case F_ARM_4: machine = bfd_mach_arm_4; break; | 2162 | 7 | case F_ARM_4T: machine = bfd_mach_arm_4T; break; | 2163 | | /* The COFF header does not have enough bits available | 2164 | | to cover all the different ARM architectures. So | 2165 | | we interpret F_ARM_5, the highest flag value to mean | 2166 | | "the highest ARM architecture known to BFD" which is | 2167 | | currently the XScale. */ | 2168 | 23 | case F_ARM_5: machine = bfd_mach_arm_XScale; break; | 2169 | 206 | } | 2170 | 206 | } | 2171 | 206 | break; | 2172 | 206 | #endif | 2173 | | #ifdef AARCH64MAGIC | 2174 | | case AARCH64MAGIC: | 2175 | | arch = bfd_arch_aarch64; | 2176 | | machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK; | 2177 | | break; | 2178 | | #endif | 2179 | | #ifdef LOONGARCH64MAGIC | 2180 | | case LOONGARCH64MAGIC: | 2181 | | arch = bfd_arch_loongarch; | 2182 | | machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK; | 2183 | | break; | 2184 | | #endif | 2185 | | #ifdef Z80MAGIC | 2186 | | case Z80MAGIC: | 2187 | | arch = bfd_arch_z80; | 2188 | | switch (internal_f->f_flags & F_MACHMASK) | 2189 | | { | 2190 | | case bfd_mach_z80strict << 12: | 2191 | | case bfd_mach_z80 << 12: | 2192 | | case bfd_mach_z80n << 12: | 2193 | | case bfd_mach_z80full << 12: | 2194 | | case bfd_mach_r800 << 12: | 2195 | | case bfd_mach_gbz80 << 12: | 2196 | | case bfd_mach_z180 << 12: | 2197 | | case bfd_mach_ez80_z80 << 12: | 2198 | | case bfd_mach_ez80_adl << 12: | 2199 | | machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12; | 2200 | | break; | 2201 | | default: | 2202 | | return false; | 2203 | | } | 2204 | | break; | 2205 | | #endif | 2206 | | #ifdef Z8KMAGIC | 2207 | | case Z8KMAGIC: | 2208 | | arch = bfd_arch_z8k; | 2209 | | switch (internal_f->f_flags & F_MACHMASK) | 2210 | | { | 2211 | | case F_Z8001: | 2212 | | machine = bfd_mach_z8001; | 2213 | | break; | 2214 | | case F_Z8002: | 2215 | | machine = bfd_mach_z8002; | 2216 | | break; | 2217 | | default: | 2218 | | return false; | 2219 | | } | 2220 | | break; | 2221 | | #endif | 2222 | | | 2223 | | #ifdef RS6000COFF_C | 2224 | | #ifdef XCOFF64 | 2225 | | case U64_TOCMAGIC: | 2226 | | case U803XTOCMAGIC: | 2227 | | #else | 2228 | | case U802ROMAGIC: | 2229 | | case U802WRMAGIC: | 2230 | | case U802TOCMAGIC: | 2231 | | #endif | 2232 | | { | 2233 | | int cputype; | 2234 | | | 2235 | | if (xcoff_data (abfd)->cputype != -1) | 2236 | | cputype = xcoff_data (abfd)->cputype & 0xff; | 2237 | | else | 2238 | | { | 2239 | | /* We did not get a value from the a.out header. If the | 2240 | | file has not been stripped, we may be able to get the | 2241 | | architecture information from the first symbol, if it | 2242 | | is a .file symbol. */ | 2243 | | if (obj_raw_syment_count (abfd) == 0) | 2244 | | cputype = 0; | 2245 | | else | 2246 | | { | 2247 | | bfd_byte *buf; | 2248 | | struct internal_syment sym; | 2249 | | bfd_size_type amt = bfd_coff_symesz (abfd); | 2250 | | | 2251 | | if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0) | 2252 | | return false; | 2253 | | buf = _bfd_malloc_and_read (abfd, amt, amt); | 2254 | | if (buf == NULL) | 2255 | | return false; | 2256 | | bfd_coff_swap_sym_in (abfd, buf, & sym); | 2257 | | if (sym.n_sclass == C_FILE) | 2258 | | cputype = sym.n_type & 0xff; | 2259 | | else | 2260 | | cputype = 0; | 2261 | | free (buf); | 2262 | | } | 2263 | | } | 2264 | | | 2265 | | /* FIXME: We don't handle all cases here. */ | 2266 | | switch (cputype) | 2267 | | { | 2268 | | default: | 2269 | | case 0: | 2270 | | arch = bfd_xcoff_architecture (abfd); | 2271 | | machine = bfd_xcoff_machine (abfd); | 2272 | | break; | 2273 | | | 2274 | | case 1: | 2275 | | arch = bfd_arch_powerpc; | 2276 | | machine = bfd_mach_ppc_601; | 2277 | | break; | 2278 | | case 2: /* 64 bit PowerPC */ | 2279 | | arch = bfd_arch_powerpc; | 2280 | | machine = bfd_mach_ppc_620; | 2281 | | break; | 2282 | | case 3: | 2283 | | arch = bfd_arch_powerpc; | 2284 | | machine = bfd_mach_ppc; | 2285 | | break; | 2286 | | case 4: | 2287 | | arch = bfd_arch_rs6000; | 2288 | | machine = bfd_mach_rs6k; | 2289 | | break; | 2290 | | } | 2291 | | } | 2292 | | break; | 2293 | | #endif | 2294 | | | 2295 | | #ifdef SH_ARCH_MAGIC_BIG | 2296 | | case SH_ARCH_MAGIC_BIG: | 2297 | | case SH_ARCH_MAGIC_LITTLE: | 2298 | | #ifdef COFF_WITH_PE | 2299 | | case SH_ARCH_MAGIC_WINCE: | 2300 | | #endif | 2301 | | arch = bfd_arch_sh; | 2302 | | break; | 2303 | | #endif | 2304 | | | 2305 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 2306 | | case MIPS_ARCH_MAGIC_WINCE: | 2307 | | arch = bfd_arch_mips; | 2308 | | break; | 2309 | | #endif | 2310 | | | 2311 | | #ifdef SPARCMAGIC | 2312 | | case SPARCMAGIC: | 2313 | | #ifdef LYNXCOFFMAGIC | 2314 | | case LYNXCOFFMAGIC: | 2315 | | #endif | 2316 | | arch = bfd_arch_sparc; | 2317 | | break; | 2318 | | #endif | 2319 | | | 2320 | | #ifdef TIC30MAGIC | 2321 | | case TIC30MAGIC: | 2322 | | arch = bfd_arch_tic30; | 2323 | | break; | 2324 | | #endif | 2325 | | | 2326 | | #ifdef TICOFF0MAGIC | 2327 | | #ifdef TICOFF_TARGET_ARCH | 2328 | | /* This TI COFF section should be used by all new TI COFF v0 targets. */ | 2329 | | case TICOFF0MAGIC: | 2330 | | arch = TICOFF_TARGET_ARCH; | 2331 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2332 | | break; | 2333 | | #endif | 2334 | | #endif | 2335 | | | 2336 | | #ifdef TICOFF1MAGIC | 2337 | | /* This TI COFF section should be used by all new TI COFF v1/2 targets. */ | 2338 | | /* TI COFF1 and COFF2 use the target_id field to specify which arch. */ | 2339 | | case TICOFF1MAGIC: | 2340 | | case TICOFF2MAGIC: | 2341 | | switch (internal_f->f_target_id) | 2342 | | { | 2343 | | #ifdef TI_TARGET_ID | 2344 | | case TI_TARGET_ID: | 2345 | | arch = TICOFF_TARGET_ARCH; | 2346 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2347 | | break; | 2348 | | #endif | 2349 | | default: | 2350 | | arch = bfd_arch_obscure; | 2351 | | _bfd_error_handler | 2352 | | (_("unrecognized TI COFF target id '0x%x'"), | 2353 | | internal_f->f_target_id); | 2354 | | break; | 2355 | | } | 2356 | | break; | 2357 | | #endif | 2358 | | | 2359 | | #ifdef MCOREMAGIC | 2360 | | case MCOREMAGIC: | 2361 | | arch = bfd_arch_mcore; | 2362 | | break; | 2363 | | #endif | 2364 | | | 2365 | 206 | default: /* Unreadable input file type. */ | 2366 | 1 | arch = bfd_arch_obscure; | 2367 | 1 | break; | 2368 | 207 | } | 2369 | | | 2370 | 207 | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 207 | return true; | 2372 | 207 | } |
pe-arm.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 207 | { | 2111 | 207 | unsigned long machine; | 2112 | 207 | enum bfd_architecture arch; | 2113 | 207 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 207 | machine = 0; | 2117 | 207 | switch (internal_f->f_magic) | 2118 | 207 | { | 2119 | | #ifdef I386MAGIC | 2120 | | case I386MAGIC: | 2121 | | case I386PTXMAGIC: | 2122 | | case I386AIXMAGIC: /* Danbury PS/2 AIX C Compiler. */ | 2123 | | case LYNXCOFFMAGIC: | 2124 | | case I386_APPLE_MAGIC: | 2125 | | case I386_FREEBSD_MAGIC: | 2126 | | case I386_LINUX_MAGIC: | 2127 | | case I386_NETBSD_MAGIC: | 2128 | | arch = bfd_arch_i386; | 2129 | | break; | 2130 | | #endif | 2131 | | #ifdef AMD64MAGIC | 2132 | | case AMD64MAGIC: | 2133 | | case AMD64_APPLE_MAGIC: | 2134 | | case AMD64_FREEBSD_MAGIC: | 2135 | | case AMD64_LINUX_MAGIC: | 2136 | | case AMD64_NETBSD_MAGIC: | 2137 | | arch = bfd_arch_i386; | 2138 | | machine = bfd_mach_x86_64; | 2139 | | break; | 2140 | | #endif | 2141 | | #ifdef IA64MAGIC | 2142 | | case IA64MAGIC: | 2143 | | arch = bfd_arch_ia64; | 2144 | | break; | 2145 | | #endif | 2146 | 0 | #ifdef ARMMAGIC | 2147 | 196 | case ARMMAGIC: | 2148 | 200 | case ARMPEMAGIC: | 2149 | 206 | case THUMBPEMAGIC: | 2150 | 206 | arch = bfd_arch_arm; | 2151 | 206 | machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION); | 2152 | 206 | if (machine == bfd_mach_arm_unknown) | 2153 | 206 | { | 2154 | 206 | switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK) | 2155 | 206 | { | 2156 | 6 | case F_ARM_2: machine = bfd_mach_arm_2; break; | 2157 | 9 | case F_ARM_2a: machine = bfd_mach_arm_2a; break; | 2158 | 8 | case F_ARM_3: machine = bfd_mach_arm_3; break; | 2159 | 133 | default: | 2160 | 145 | case F_ARM_3M: machine = bfd_mach_arm_3M; break; | 2161 | 8 | case F_ARM_4: machine = bfd_mach_arm_4; break; | 2162 | 7 | case F_ARM_4T: machine = bfd_mach_arm_4T; break; | 2163 | | /* The COFF header does not have enough bits available | 2164 | | to cover all the different ARM architectures. So | 2165 | | we interpret F_ARM_5, the highest flag value to mean | 2166 | | "the highest ARM architecture known to BFD" which is | 2167 | | currently the XScale. */ | 2168 | 23 | case F_ARM_5: machine = bfd_mach_arm_XScale; break; | 2169 | 206 | } | 2170 | 206 | } | 2171 | 206 | break; | 2172 | 206 | #endif | 2173 | | #ifdef AARCH64MAGIC | 2174 | | case AARCH64MAGIC: | 2175 | | arch = bfd_arch_aarch64; | 2176 | | machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK; | 2177 | | break; | 2178 | | #endif | 2179 | | #ifdef LOONGARCH64MAGIC | 2180 | | case LOONGARCH64MAGIC: | 2181 | | arch = bfd_arch_loongarch; | 2182 | | machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK; | 2183 | | break; | 2184 | | #endif | 2185 | | #ifdef Z80MAGIC | 2186 | | case Z80MAGIC: | 2187 | | arch = bfd_arch_z80; | 2188 | | switch (internal_f->f_flags & F_MACHMASK) | 2189 | | { | 2190 | | case bfd_mach_z80strict << 12: | 2191 | | case bfd_mach_z80 << 12: | 2192 | | case bfd_mach_z80n << 12: | 2193 | | case bfd_mach_z80full << 12: | 2194 | | case bfd_mach_r800 << 12: | 2195 | | case bfd_mach_gbz80 << 12: | 2196 | | case bfd_mach_z180 << 12: | 2197 | | case bfd_mach_ez80_z80 << 12: | 2198 | | case bfd_mach_ez80_adl << 12: | 2199 | | machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12; | 2200 | | break; | 2201 | | default: | 2202 | | return false; | 2203 | | } | 2204 | | break; | 2205 | | #endif | 2206 | | #ifdef Z8KMAGIC | 2207 | | case Z8KMAGIC: | 2208 | | arch = bfd_arch_z8k; | 2209 | | switch (internal_f->f_flags & F_MACHMASK) | 2210 | | { | 2211 | | case F_Z8001: | 2212 | | machine = bfd_mach_z8001; | 2213 | | break; | 2214 | | case F_Z8002: | 2215 | | machine = bfd_mach_z8002; | 2216 | | break; | 2217 | | default: | 2218 | | return false; | 2219 | | } | 2220 | | break; | 2221 | | #endif | 2222 | | | 2223 | | #ifdef RS6000COFF_C | 2224 | | #ifdef XCOFF64 | 2225 | | case U64_TOCMAGIC: | 2226 | | case U803XTOCMAGIC: | 2227 | | #else | 2228 | | case U802ROMAGIC: | 2229 | | case U802WRMAGIC: | 2230 | | case U802TOCMAGIC: | 2231 | | #endif | 2232 | | { | 2233 | | int cputype; | 2234 | | | 2235 | | if (xcoff_data (abfd)->cputype != -1) | 2236 | | cputype = xcoff_data (abfd)->cputype & 0xff; | 2237 | | else | 2238 | | { | 2239 | | /* We did not get a value from the a.out header. If the | 2240 | | file has not been stripped, we may be able to get the | 2241 | | architecture information from the first symbol, if it | 2242 | | is a .file symbol. */ | 2243 | | if (obj_raw_syment_count (abfd) == 0) | 2244 | | cputype = 0; | 2245 | | else | 2246 | | { | 2247 | | bfd_byte *buf; | 2248 | | struct internal_syment sym; | 2249 | | bfd_size_type amt = bfd_coff_symesz (abfd); | 2250 | | | 2251 | | if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0) | 2252 | | return false; | 2253 | | buf = _bfd_malloc_and_read (abfd, amt, amt); | 2254 | | if (buf == NULL) | 2255 | | return false; | 2256 | | bfd_coff_swap_sym_in (abfd, buf, & sym); | 2257 | | if (sym.n_sclass == C_FILE) | 2258 | | cputype = sym.n_type & 0xff; | 2259 | | else | 2260 | | cputype = 0; | 2261 | | free (buf); | 2262 | | } | 2263 | | } | 2264 | | | 2265 | | /* FIXME: We don't handle all cases here. */ | 2266 | | switch (cputype) | 2267 | | { | 2268 | | default: | 2269 | | case 0: | 2270 | | arch = bfd_xcoff_architecture (abfd); | 2271 | | machine = bfd_xcoff_machine (abfd); | 2272 | | break; | 2273 | | | 2274 | | case 1: | 2275 | | arch = bfd_arch_powerpc; | 2276 | | machine = bfd_mach_ppc_601; | 2277 | | break; | 2278 | | case 2: /* 64 bit PowerPC */ | 2279 | | arch = bfd_arch_powerpc; | 2280 | | machine = bfd_mach_ppc_620; | 2281 | | break; | 2282 | | case 3: | 2283 | | arch = bfd_arch_powerpc; | 2284 | | machine = bfd_mach_ppc; | 2285 | | break; | 2286 | | case 4: | 2287 | | arch = bfd_arch_rs6000; | 2288 | | machine = bfd_mach_rs6k; | 2289 | | break; | 2290 | | } | 2291 | | } | 2292 | | break; | 2293 | | #endif | 2294 | | | 2295 | | #ifdef SH_ARCH_MAGIC_BIG | 2296 | | case SH_ARCH_MAGIC_BIG: | 2297 | | case SH_ARCH_MAGIC_LITTLE: | 2298 | | #ifdef COFF_WITH_PE | 2299 | | case SH_ARCH_MAGIC_WINCE: | 2300 | | #endif | 2301 | | arch = bfd_arch_sh; | 2302 | | break; | 2303 | | #endif | 2304 | | | 2305 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 2306 | | case MIPS_ARCH_MAGIC_WINCE: | 2307 | | arch = bfd_arch_mips; | 2308 | | break; | 2309 | | #endif | 2310 | | | 2311 | | #ifdef SPARCMAGIC | 2312 | | case SPARCMAGIC: | 2313 | | #ifdef LYNXCOFFMAGIC | 2314 | | case LYNXCOFFMAGIC: | 2315 | | #endif | 2316 | | arch = bfd_arch_sparc; | 2317 | | break; | 2318 | | #endif | 2319 | | | 2320 | | #ifdef TIC30MAGIC | 2321 | | case TIC30MAGIC: | 2322 | | arch = bfd_arch_tic30; | 2323 | | break; | 2324 | | #endif | 2325 | | | 2326 | | #ifdef TICOFF0MAGIC | 2327 | | #ifdef TICOFF_TARGET_ARCH | 2328 | | /* This TI COFF section should be used by all new TI COFF v0 targets. */ | 2329 | | case TICOFF0MAGIC: | 2330 | | arch = TICOFF_TARGET_ARCH; | 2331 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2332 | | break; | 2333 | | #endif | 2334 | | #endif | 2335 | | | 2336 | | #ifdef TICOFF1MAGIC | 2337 | | /* This TI COFF section should be used by all new TI COFF v1/2 targets. */ | 2338 | | /* TI COFF1 and COFF2 use the target_id field to specify which arch. */ | 2339 | | case TICOFF1MAGIC: | 2340 | | case TICOFF2MAGIC: | 2341 | | switch (internal_f->f_target_id) | 2342 | | { | 2343 | | #ifdef TI_TARGET_ID | 2344 | | case TI_TARGET_ID: | 2345 | | arch = TICOFF_TARGET_ARCH; | 2346 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2347 | | break; | 2348 | | #endif | 2349 | | default: | 2350 | | arch = bfd_arch_obscure; | 2351 | | _bfd_error_handler | 2352 | | (_("unrecognized TI COFF target id '0x%x'"), | 2353 | | internal_f->f_target_id); | 2354 | | break; | 2355 | | } | 2356 | | break; | 2357 | | #endif | 2358 | | | 2359 | | #ifdef MCOREMAGIC | 2360 | | case MCOREMAGIC: | 2361 | | arch = bfd_arch_mcore; | 2362 | | break; | 2363 | | #endif | 2364 | | | 2365 | 206 | default: /* Unreadable input file type. */ | 2366 | 1 | arch = bfd_arch_obscure; | 2367 | 1 | break; | 2368 | 207 | } | 2369 | | | 2370 | 207 | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 207 | return true; | 2372 | 207 | } |
pe-i386.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 702 | { | 2111 | 702 | unsigned long machine; | 2112 | 702 | enum bfd_architecture arch; | 2113 | 702 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 702 | machine = 0; | 2117 | 702 | switch (internal_f->f_magic) | 2118 | 702 | { | 2119 | 0 | #ifdef I386MAGIC | 2120 | 53 | case I386MAGIC: | 2121 | 58 | case I386PTXMAGIC: | 2122 | 60 | case I386AIXMAGIC: /* Danbury PS/2 AIX C Compiler. */ | 2123 | 698 | case LYNXCOFFMAGIC: | 2124 | 699 | case I386_APPLE_MAGIC: | 2125 | 700 | case I386_FREEBSD_MAGIC: | 2126 | 701 | case I386_LINUX_MAGIC: | 2127 | 702 | case I386_NETBSD_MAGIC: | 2128 | 702 | arch = bfd_arch_i386; | 2129 | 702 | break; | 2130 | 0 | #endif | 2131 | | #ifdef AMD64MAGIC | 2132 | | case AMD64MAGIC: | 2133 | | case AMD64_APPLE_MAGIC: | 2134 | | case AMD64_FREEBSD_MAGIC: | 2135 | | case AMD64_LINUX_MAGIC: | 2136 | | case AMD64_NETBSD_MAGIC: | 2137 | | arch = bfd_arch_i386; | 2138 | | machine = bfd_mach_x86_64; | 2139 | | break; | 2140 | | #endif | 2141 | | #ifdef IA64MAGIC | 2142 | | case IA64MAGIC: | 2143 | | arch = bfd_arch_ia64; | 2144 | | break; | 2145 | | #endif | 2146 | | #ifdef ARMMAGIC | 2147 | | case ARMMAGIC: | 2148 | | case ARMPEMAGIC: | 2149 | | case THUMBPEMAGIC: | 2150 | | arch = bfd_arch_arm; | 2151 | | machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION); | 2152 | | if (machine == bfd_mach_arm_unknown) | 2153 | | { | 2154 | | switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK) | 2155 | | { | 2156 | | case F_ARM_2: machine = bfd_mach_arm_2; break; | 2157 | | case F_ARM_2a: machine = bfd_mach_arm_2a; break; | 2158 | | case F_ARM_3: machine = bfd_mach_arm_3; break; | 2159 | | default: | 2160 | | case F_ARM_3M: machine = bfd_mach_arm_3M; break; | 2161 | | case F_ARM_4: machine = bfd_mach_arm_4; break; | 2162 | | case F_ARM_4T: machine = bfd_mach_arm_4T; break; | 2163 | | /* The COFF header does not have enough bits available | 2164 | | to cover all the different ARM architectures. So | 2165 | | we interpret F_ARM_5, the highest flag value to mean | 2166 | | "the highest ARM architecture known to BFD" which is | 2167 | | currently the XScale. */ | 2168 | | case F_ARM_5: machine = bfd_mach_arm_XScale; break; | 2169 | | } | 2170 | | } | 2171 | | break; | 2172 | | #endif | 2173 | | #ifdef AARCH64MAGIC | 2174 | | case AARCH64MAGIC: | 2175 | | arch = bfd_arch_aarch64; | 2176 | | machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK; | 2177 | | break; | 2178 | | #endif | 2179 | | #ifdef LOONGARCH64MAGIC | 2180 | | case LOONGARCH64MAGIC: | 2181 | | arch = bfd_arch_loongarch; | 2182 | | machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK; | 2183 | | break; | 2184 | | #endif | 2185 | | #ifdef Z80MAGIC | 2186 | | case Z80MAGIC: | 2187 | | arch = bfd_arch_z80; | 2188 | | switch (internal_f->f_flags & F_MACHMASK) | 2189 | | { | 2190 | | case bfd_mach_z80strict << 12: | 2191 | | case bfd_mach_z80 << 12: | 2192 | | case bfd_mach_z80n << 12: | 2193 | | case bfd_mach_z80full << 12: | 2194 | | case bfd_mach_r800 << 12: | 2195 | | case bfd_mach_gbz80 << 12: | 2196 | | case bfd_mach_z180 << 12: | 2197 | | case bfd_mach_ez80_z80 << 12: | 2198 | | case bfd_mach_ez80_adl << 12: | 2199 | | machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12; | 2200 | | break; | 2201 | | default: | 2202 | | return false; | 2203 | | } | 2204 | | break; | 2205 | | #endif | 2206 | | #ifdef Z8KMAGIC | 2207 | | case Z8KMAGIC: | 2208 | | arch = bfd_arch_z8k; | 2209 | | switch (internal_f->f_flags & F_MACHMASK) | 2210 | | { | 2211 | | case F_Z8001: | 2212 | | machine = bfd_mach_z8001; | 2213 | | break; | 2214 | | case F_Z8002: | 2215 | | machine = bfd_mach_z8002; | 2216 | | break; | 2217 | | default: | 2218 | | return false; | 2219 | | } | 2220 | | break; | 2221 | | #endif | 2222 | | | 2223 | | #ifdef RS6000COFF_C | 2224 | | #ifdef XCOFF64 | 2225 | | case U64_TOCMAGIC: | 2226 | | case U803XTOCMAGIC: | 2227 | | #else | 2228 | | case U802ROMAGIC: | 2229 | | case U802WRMAGIC: | 2230 | | case U802TOCMAGIC: | 2231 | | #endif | 2232 | | { | 2233 | | int cputype; | 2234 | | | 2235 | | if (xcoff_data (abfd)->cputype != -1) | 2236 | | cputype = xcoff_data (abfd)->cputype & 0xff; | 2237 | | else | 2238 | | { | 2239 | | /* We did not get a value from the a.out header. If the | 2240 | | file has not been stripped, we may be able to get the | 2241 | | architecture information from the first symbol, if it | 2242 | | is a .file symbol. */ | 2243 | | if (obj_raw_syment_count (abfd) == 0) | 2244 | | cputype = 0; | 2245 | | else | 2246 | | { | 2247 | | bfd_byte *buf; | 2248 | | struct internal_syment sym; | 2249 | | bfd_size_type amt = bfd_coff_symesz (abfd); | 2250 | | | 2251 | | if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0) | 2252 | | return false; | 2253 | | buf = _bfd_malloc_and_read (abfd, amt, amt); | 2254 | | if (buf == NULL) | 2255 | | return false; | 2256 | | bfd_coff_swap_sym_in (abfd, buf, & sym); | 2257 | | if (sym.n_sclass == C_FILE) | 2258 | | cputype = sym.n_type & 0xff; | 2259 | | else | 2260 | | cputype = 0; | 2261 | | free (buf); | 2262 | | } | 2263 | | } | 2264 | | | 2265 | | /* FIXME: We don't handle all cases here. */ | 2266 | | switch (cputype) | 2267 | | { | 2268 | | default: | 2269 | | case 0: | 2270 | | arch = bfd_xcoff_architecture (abfd); | 2271 | | machine = bfd_xcoff_machine (abfd); | 2272 | | break; | 2273 | | | 2274 | | case 1: | 2275 | | arch = bfd_arch_powerpc; | 2276 | | machine = bfd_mach_ppc_601; | 2277 | | break; | 2278 | | case 2: /* 64 bit PowerPC */ | 2279 | | arch = bfd_arch_powerpc; | 2280 | | machine = bfd_mach_ppc_620; | 2281 | | break; | 2282 | | case 3: | 2283 | | arch = bfd_arch_powerpc; | 2284 | | machine = bfd_mach_ppc; | 2285 | | break; | 2286 | | case 4: | 2287 | | arch = bfd_arch_rs6000; | 2288 | | machine = bfd_mach_rs6k; | 2289 | | break; | 2290 | | } | 2291 | | } | 2292 | | break; | 2293 | | #endif | 2294 | | | 2295 | | #ifdef SH_ARCH_MAGIC_BIG | 2296 | | case SH_ARCH_MAGIC_BIG: | 2297 | | case SH_ARCH_MAGIC_LITTLE: | 2298 | | #ifdef COFF_WITH_PE | 2299 | | case SH_ARCH_MAGIC_WINCE: | 2300 | | #endif | 2301 | | arch = bfd_arch_sh; | 2302 | | break; | 2303 | | #endif | 2304 | | | 2305 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 2306 | | case MIPS_ARCH_MAGIC_WINCE: | 2307 | | arch = bfd_arch_mips; | 2308 | | break; | 2309 | | #endif | 2310 | | | 2311 | | #ifdef SPARCMAGIC | 2312 | | case SPARCMAGIC: | 2313 | | #ifdef LYNXCOFFMAGIC | 2314 | | case LYNXCOFFMAGIC: | 2315 | | #endif | 2316 | | arch = bfd_arch_sparc; | 2317 | | break; | 2318 | | #endif | 2319 | | | 2320 | | #ifdef TIC30MAGIC | 2321 | | case TIC30MAGIC: | 2322 | | arch = bfd_arch_tic30; | 2323 | | break; | 2324 | | #endif | 2325 | | | 2326 | | #ifdef TICOFF0MAGIC | 2327 | | #ifdef TICOFF_TARGET_ARCH | 2328 | | /* This TI COFF section should be used by all new TI COFF v0 targets. */ | 2329 | | case TICOFF0MAGIC: | 2330 | | arch = TICOFF_TARGET_ARCH; | 2331 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2332 | | break; | 2333 | | #endif | 2334 | | #endif | 2335 | | | 2336 | | #ifdef TICOFF1MAGIC | 2337 | | /* This TI COFF section should be used by all new TI COFF v1/2 targets. */ | 2338 | | /* TI COFF1 and COFF2 use the target_id field to specify which arch. */ | 2339 | | case TICOFF1MAGIC: | 2340 | | case TICOFF2MAGIC: | 2341 | | switch (internal_f->f_target_id) | 2342 | | { | 2343 | | #ifdef TI_TARGET_ID | 2344 | | case TI_TARGET_ID: | 2345 | | arch = TICOFF_TARGET_ARCH; | 2346 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2347 | | break; | 2348 | | #endif | 2349 | | default: | 2350 | | arch = bfd_arch_obscure; | 2351 | | _bfd_error_handler | 2352 | | (_("unrecognized TI COFF target id '0x%x'"), | 2353 | | internal_f->f_target_id); | 2354 | | break; | 2355 | | } | 2356 | | break; | 2357 | | #endif | 2358 | | | 2359 | | #ifdef MCOREMAGIC | 2360 | | case MCOREMAGIC: | 2361 | | arch = bfd_arch_mcore; | 2362 | | break; | 2363 | | #endif | 2364 | | | 2365 | 0 | default: /* Unreadable input file type. */ | 2366 | 0 | arch = bfd_arch_obscure; | 2367 | 0 | break; | 2368 | 702 | } | 2369 | | | 2370 | 702 | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 702 | return true; | 2372 | 702 | } |
pe-mcore.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 394 | { | 2111 | 394 | unsigned long machine; | 2112 | 394 | enum bfd_architecture arch; | 2113 | 394 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 394 | machine = 0; | 2117 | 394 | switch (internal_f->f_magic) | 2118 | 394 | { | 2119 | | #ifdef I386MAGIC | 2120 | | case I386MAGIC: | 2121 | | case I386PTXMAGIC: | 2122 | | case I386AIXMAGIC: /* Danbury PS/2 AIX C Compiler. */ | 2123 | | case LYNXCOFFMAGIC: | 2124 | | case I386_APPLE_MAGIC: | 2125 | | case I386_FREEBSD_MAGIC: | 2126 | | case I386_LINUX_MAGIC: | 2127 | | case I386_NETBSD_MAGIC: | 2128 | | arch = bfd_arch_i386; | 2129 | | break; | 2130 | | #endif | 2131 | | #ifdef AMD64MAGIC | 2132 | | case AMD64MAGIC: | 2133 | | case AMD64_APPLE_MAGIC: | 2134 | | case AMD64_FREEBSD_MAGIC: | 2135 | | case AMD64_LINUX_MAGIC: | 2136 | | case AMD64_NETBSD_MAGIC: | 2137 | | arch = bfd_arch_i386; | 2138 | | machine = bfd_mach_x86_64; | 2139 | | break; | 2140 | | #endif | 2141 | | #ifdef IA64MAGIC | 2142 | | case IA64MAGIC: | 2143 | | arch = bfd_arch_ia64; | 2144 | | break; | 2145 | | #endif | 2146 | | #ifdef ARMMAGIC | 2147 | | case ARMMAGIC: | 2148 | | case ARMPEMAGIC: | 2149 | | case THUMBPEMAGIC: | 2150 | | arch = bfd_arch_arm; | 2151 | | machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION); | 2152 | | if (machine == bfd_mach_arm_unknown) | 2153 | | { | 2154 | | switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK) | 2155 | | { | 2156 | | case F_ARM_2: machine = bfd_mach_arm_2; break; | 2157 | | case F_ARM_2a: machine = bfd_mach_arm_2a; break; | 2158 | | case F_ARM_3: machine = bfd_mach_arm_3; break; | 2159 | | default: | 2160 | | case F_ARM_3M: machine = bfd_mach_arm_3M; break; | 2161 | | case F_ARM_4: machine = bfd_mach_arm_4; break; | 2162 | | case F_ARM_4T: machine = bfd_mach_arm_4T; break; | 2163 | | /* The COFF header does not have enough bits available | 2164 | | to cover all the different ARM architectures. So | 2165 | | we interpret F_ARM_5, the highest flag value to mean | 2166 | | "the highest ARM architecture known to BFD" which is | 2167 | | currently the XScale. */ | 2168 | | case F_ARM_5: machine = bfd_mach_arm_XScale; break; | 2169 | | } | 2170 | | } | 2171 | | break; | 2172 | | #endif | 2173 | | #ifdef AARCH64MAGIC | 2174 | | case AARCH64MAGIC: | 2175 | | arch = bfd_arch_aarch64; | 2176 | | machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK; | 2177 | | break; | 2178 | | #endif | 2179 | | #ifdef LOONGARCH64MAGIC | 2180 | | case LOONGARCH64MAGIC: | 2181 | | arch = bfd_arch_loongarch; | 2182 | | machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK; | 2183 | | break; | 2184 | | #endif | 2185 | | #ifdef Z80MAGIC | 2186 | | case Z80MAGIC: | 2187 | | arch = bfd_arch_z80; | 2188 | | switch (internal_f->f_flags & F_MACHMASK) | 2189 | | { | 2190 | | case bfd_mach_z80strict << 12: | 2191 | | case bfd_mach_z80 << 12: | 2192 | | case bfd_mach_z80n << 12: | 2193 | | case bfd_mach_z80full << 12: | 2194 | | case bfd_mach_r800 << 12: | 2195 | | case bfd_mach_gbz80 << 12: | 2196 | | case bfd_mach_z180 << 12: | 2197 | | case bfd_mach_ez80_z80 << 12: | 2198 | | case bfd_mach_ez80_adl << 12: | 2199 | | machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12; | 2200 | | break; | 2201 | | default: | 2202 | | return false; | 2203 | | } | 2204 | | break; | 2205 | | #endif | 2206 | | #ifdef Z8KMAGIC | 2207 | | case Z8KMAGIC: | 2208 | | arch = bfd_arch_z8k; | 2209 | | switch (internal_f->f_flags & F_MACHMASK) | 2210 | | { | 2211 | | case F_Z8001: | 2212 | | machine = bfd_mach_z8001; | 2213 | | break; | 2214 | | case F_Z8002: | 2215 | | machine = bfd_mach_z8002; | 2216 | | break; | 2217 | | default: | 2218 | | return false; | 2219 | | } | 2220 | | break; | 2221 | | #endif | 2222 | | | 2223 | | #ifdef RS6000COFF_C | 2224 | | #ifdef XCOFF64 | 2225 | | case U64_TOCMAGIC: | 2226 | | case U803XTOCMAGIC: | 2227 | | #else | 2228 | | case U802ROMAGIC: | 2229 | | case U802WRMAGIC: | 2230 | | case U802TOCMAGIC: | 2231 | | #endif | 2232 | | { | 2233 | | int cputype; | 2234 | | | 2235 | | if (xcoff_data (abfd)->cputype != -1) | 2236 | | cputype = xcoff_data (abfd)->cputype & 0xff; | 2237 | | else | 2238 | | { | 2239 | | /* We did not get a value from the a.out header. If the | 2240 | | file has not been stripped, we may be able to get the | 2241 | | architecture information from the first symbol, if it | 2242 | | is a .file symbol. */ | 2243 | | if (obj_raw_syment_count (abfd) == 0) | 2244 | | cputype = 0; | 2245 | | else | 2246 | | { | 2247 | | bfd_byte *buf; | 2248 | | struct internal_syment sym; | 2249 | | bfd_size_type amt = bfd_coff_symesz (abfd); | 2250 | | | 2251 | | if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0) | 2252 | | return false; | 2253 | | buf = _bfd_malloc_and_read (abfd, amt, amt); | 2254 | | if (buf == NULL) | 2255 | | return false; | 2256 | | bfd_coff_swap_sym_in (abfd, buf, & sym); | 2257 | | if (sym.n_sclass == C_FILE) | 2258 | | cputype = sym.n_type & 0xff; | 2259 | | else | 2260 | | cputype = 0; | 2261 | | free (buf); | 2262 | | } | 2263 | | } | 2264 | | | 2265 | | /* FIXME: We don't handle all cases here. */ | 2266 | | switch (cputype) | 2267 | | { | 2268 | | default: | 2269 | | case 0: | 2270 | | arch = bfd_xcoff_architecture (abfd); | 2271 | | machine = bfd_xcoff_machine (abfd); | 2272 | | break; | 2273 | | | 2274 | | case 1: | 2275 | | arch = bfd_arch_powerpc; | 2276 | | machine = bfd_mach_ppc_601; | 2277 | | break; | 2278 | | case 2: /* 64 bit PowerPC */ | 2279 | | arch = bfd_arch_powerpc; | 2280 | | machine = bfd_mach_ppc_620; | 2281 | | break; | 2282 | | case 3: | 2283 | | arch = bfd_arch_powerpc; | 2284 | | machine = bfd_mach_ppc; | 2285 | | break; | 2286 | | case 4: | 2287 | | arch = bfd_arch_rs6000; | 2288 | | machine = bfd_mach_rs6k; | 2289 | | break; | 2290 | | } | 2291 | | } | 2292 | | break; | 2293 | | #endif | 2294 | | | 2295 | | #ifdef SH_ARCH_MAGIC_BIG | 2296 | | case SH_ARCH_MAGIC_BIG: | 2297 | | case SH_ARCH_MAGIC_LITTLE: | 2298 | | #ifdef COFF_WITH_PE | 2299 | | case SH_ARCH_MAGIC_WINCE: | 2300 | | #endif | 2301 | | arch = bfd_arch_sh; | 2302 | | break; | 2303 | | #endif | 2304 | | | 2305 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 2306 | | case MIPS_ARCH_MAGIC_WINCE: | 2307 | | arch = bfd_arch_mips; | 2308 | | break; | 2309 | | #endif | 2310 | | | 2311 | | #ifdef SPARCMAGIC | 2312 | | case SPARCMAGIC: | 2313 | | #ifdef LYNXCOFFMAGIC | 2314 | | case LYNXCOFFMAGIC: | 2315 | | #endif | 2316 | | arch = bfd_arch_sparc; | 2317 | | break; | 2318 | | #endif | 2319 | | | 2320 | | #ifdef TIC30MAGIC | 2321 | | case TIC30MAGIC: | 2322 | | arch = bfd_arch_tic30; | 2323 | | break; | 2324 | | #endif | 2325 | | | 2326 | | #ifdef TICOFF0MAGIC | 2327 | | #ifdef TICOFF_TARGET_ARCH | 2328 | | /* This TI COFF section should be used by all new TI COFF v0 targets. */ | 2329 | | case TICOFF0MAGIC: | 2330 | | arch = TICOFF_TARGET_ARCH; | 2331 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2332 | | break; | 2333 | | #endif | 2334 | | #endif | 2335 | | | 2336 | | #ifdef TICOFF1MAGIC | 2337 | | /* This TI COFF section should be used by all new TI COFF v1/2 targets. */ | 2338 | | /* TI COFF1 and COFF2 use the target_id field to specify which arch. */ | 2339 | | case TICOFF1MAGIC: | 2340 | | case TICOFF2MAGIC: | 2341 | | switch (internal_f->f_target_id) | 2342 | | { | 2343 | | #ifdef TI_TARGET_ID | 2344 | | case TI_TARGET_ID: | 2345 | | arch = TICOFF_TARGET_ARCH; | 2346 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2347 | | break; | 2348 | | #endif | 2349 | | default: | 2350 | | arch = bfd_arch_obscure; | 2351 | | _bfd_error_handler | 2352 | | (_("unrecognized TI COFF target id '0x%x'"), | 2353 | | internal_f->f_target_id); | 2354 | | break; | 2355 | | } | 2356 | | break; | 2357 | | #endif | 2358 | | | 2359 | 0 | #ifdef MCOREMAGIC | 2360 | 394 | case MCOREMAGIC: | 2361 | 394 | arch = bfd_arch_mcore; | 2362 | 394 | break; | 2363 | 0 | #endif | 2364 | | | 2365 | 0 | default: /* Unreadable input file type. */ | 2366 | 0 | arch = bfd_arch_obscure; | 2367 | 0 | break; | 2368 | 394 | } | 2369 | | | 2370 | 394 | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 394 | return true; | 2372 | 394 | } |
pe-sh.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 462 | { | 2111 | 462 | unsigned long machine; | 2112 | 462 | enum bfd_architecture arch; | 2113 | 462 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 462 | machine = 0; | 2117 | 462 | switch (internal_f->f_magic) | 2118 | 462 | { | 2119 | | #ifdef I386MAGIC | 2120 | | case I386MAGIC: | 2121 | | case I386PTXMAGIC: | 2122 | | case I386AIXMAGIC: /* Danbury PS/2 AIX C Compiler. */ | 2123 | | case LYNXCOFFMAGIC: | 2124 | | case I386_APPLE_MAGIC: | 2125 | | case I386_FREEBSD_MAGIC: | 2126 | | case I386_LINUX_MAGIC: | 2127 | | case I386_NETBSD_MAGIC: | 2128 | | arch = bfd_arch_i386; | 2129 | | break; | 2130 | | #endif | 2131 | | #ifdef AMD64MAGIC | 2132 | | case AMD64MAGIC: | 2133 | | case AMD64_APPLE_MAGIC: | 2134 | | case AMD64_FREEBSD_MAGIC: | 2135 | | case AMD64_LINUX_MAGIC: | 2136 | | case AMD64_NETBSD_MAGIC: | 2137 | | arch = bfd_arch_i386; | 2138 | | machine = bfd_mach_x86_64; | 2139 | | break; | 2140 | | #endif | 2141 | | #ifdef IA64MAGIC | 2142 | | case IA64MAGIC: | 2143 | | arch = bfd_arch_ia64; | 2144 | | break; | 2145 | | #endif | 2146 | | #ifdef ARMMAGIC | 2147 | | case ARMMAGIC: | 2148 | | case ARMPEMAGIC: | 2149 | | case THUMBPEMAGIC: | 2150 | | arch = bfd_arch_arm; | 2151 | | machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION); | 2152 | | if (machine == bfd_mach_arm_unknown) | 2153 | | { | 2154 | | switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK) | 2155 | | { | 2156 | | case F_ARM_2: machine = bfd_mach_arm_2; break; | 2157 | | case F_ARM_2a: machine = bfd_mach_arm_2a; break; | 2158 | | case F_ARM_3: machine = bfd_mach_arm_3; break; | 2159 | | default: | 2160 | | case F_ARM_3M: machine = bfd_mach_arm_3M; break; | 2161 | | case F_ARM_4: machine = bfd_mach_arm_4; break; | 2162 | | case F_ARM_4T: machine = bfd_mach_arm_4T; break; | 2163 | | /* The COFF header does not have enough bits available | 2164 | | to cover all the different ARM architectures. So | 2165 | | we interpret F_ARM_5, the highest flag value to mean | 2166 | | "the highest ARM architecture known to BFD" which is | 2167 | | currently the XScale. */ | 2168 | | case F_ARM_5: machine = bfd_mach_arm_XScale; break; | 2169 | | } | 2170 | | } | 2171 | | break; | 2172 | | #endif | 2173 | | #ifdef AARCH64MAGIC | 2174 | | case AARCH64MAGIC: | 2175 | | arch = bfd_arch_aarch64; | 2176 | | machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK; | 2177 | | break; | 2178 | | #endif | 2179 | | #ifdef LOONGARCH64MAGIC | 2180 | | case LOONGARCH64MAGIC: | 2181 | | arch = bfd_arch_loongarch; | 2182 | | machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK; | 2183 | | break; | 2184 | | #endif | 2185 | | #ifdef Z80MAGIC | 2186 | | case Z80MAGIC: | 2187 | | arch = bfd_arch_z80; | 2188 | | switch (internal_f->f_flags & F_MACHMASK) | 2189 | | { | 2190 | | case bfd_mach_z80strict << 12: | 2191 | | case bfd_mach_z80 << 12: | 2192 | | case bfd_mach_z80n << 12: | 2193 | | case bfd_mach_z80full << 12: | 2194 | | case bfd_mach_r800 << 12: | 2195 | | case bfd_mach_gbz80 << 12: | 2196 | | case bfd_mach_z180 << 12: | 2197 | | case bfd_mach_ez80_z80 << 12: | 2198 | | case bfd_mach_ez80_adl << 12: | 2199 | | machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12; | 2200 | | break; | 2201 | | default: | 2202 | | return false; | 2203 | | } | 2204 | | break; | 2205 | | #endif | 2206 | | #ifdef Z8KMAGIC | 2207 | | case Z8KMAGIC: | 2208 | | arch = bfd_arch_z8k; | 2209 | | switch (internal_f->f_flags & F_MACHMASK) | 2210 | | { | 2211 | | case F_Z8001: | 2212 | | machine = bfd_mach_z8001; | 2213 | | break; | 2214 | | case F_Z8002: | 2215 | | machine = bfd_mach_z8002; | 2216 | | break; | 2217 | | default: | 2218 | | return false; | 2219 | | } | 2220 | | break; | 2221 | | #endif | 2222 | | | 2223 | | #ifdef RS6000COFF_C | 2224 | | #ifdef XCOFF64 | 2225 | | case U64_TOCMAGIC: | 2226 | | case U803XTOCMAGIC: | 2227 | | #else | 2228 | | case U802ROMAGIC: | 2229 | | case U802WRMAGIC: | 2230 | | case U802TOCMAGIC: | 2231 | | #endif | 2232 | | { | 2233 | | int cputype; | 2234 | | | 2235 | | if (xcoff_data (abfd)->cputype != -1) | 2236 | | cputype = xcoff_data (abfd)->cputype & 0xff; | 2237 | | else | 2238 | | { | 2239 | | /* We did not get a value from the a.out header. If the | 2240 | | file has not been stripped, we may be able to get the | 2241 | | architecture information from the first symbol, if it | 2242 | | is a .file symbol. */ | 2243 | | if (obj_raw_syment_count (abfd) == 0) | 2244 | | cputype = 0; | 2245 | | else | 2246 | | { | 2247 | | bfd_byte *buf; | 2248 | | struct internal_syment sym; | 2249 | | bfd_size_type amt = bfd_coff_symesz (abfd); | 2250 | | | 2251 | | if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0) | 2252 | | return false; | 2253 | | buf = _bfd_malloc_and_read (abfd, amt, amt); | 2254 | | if (buf == NULL) | 2255 | | return false; | 2256 | | bfd_coff_swap_sym_in (abfd, buf, & sym); | 2257 | | if (sym.n_sclass == C_FILE) | 2258 | | cputype = sym.n_type & 0xff; | 2259 | | else | 2260 | | cputype = 0; | 2261 | | free (buf); | 2262 | | } | 2263 | | } | 2264 | | | 2265 | | /* FIXME: We don't handle all cases here. */ | 2266 | | switch (cputype) | 2267 | | { | 2268 | | default: | 2269 | | case 0: | 2270 | | arch = bfd_xcoff_architecture (abfd); | 2271 | | machine = bfd_xcoff_machine (abfd); | 2272 | | break; | 2273 | | | 2274 | | case 1: | 2275 | | arch = bfd_arch_powerpc; | 2276 | | machine = bfd_mach_ppc_601; | 2277 | | break; | 2278 | | case 2: /* 64 bit PowerPC */ | 2279 | | arch = bfd_arch_powerpc; | 2280 | | machine = bfd_mach_ppc_620; | 2281 | | break; | 2282 | | case 3: | 2283 | | arch = bfd_arch_powerpc; | 2284 | | machine = bfd_mach_ppc; | 2285 | | break; | 2286 | | case 4: | 2287 | | arch = bfd_arch_rs6000; | 2288 | | machine = bfd_mach_rs6k; | 2289 | | break; | 2290 | | } | 2291 | | } | 2292 | | break; | 2293 | | #endif | 2294 | | | 2295 | 0 | #ifdef SH_ARCH_MAGIC_BIG | 2296 | 456 | case SH_ARCH_MAGIC_BIG: | 2297 | 457 | case SH_ARCH_MAGIC_LITTLE: | 2298 | 457 | #ifdef COFF_WITH_PE | 2299 | 462 | case SH_ARCH_MAGIC_WINCE: | 2300 | 462 | #endif | 2301 | 462 | arch = bfd_arch_sh; | 2302 | 462 | break; | 2303 | 0 | #endif | 2304 | | | 2305 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 2306 | | case MIPS_ARCH_MAGIC_WINCE: | 2307 | | arch = bfd_arch_mips; | 2308 | | break; | 2309 | | #endif | 2310 | | | 2311 | | #ifdef SPARCMAGIC | 2312 | | case SPARCMAGIC: | 2313 | | #ifdef LYNXCOFFMAGIC | 2314 | | case LYNXCOFFMAGIC: | 2315 | | #endif | 2316 | | arch = bfd_arch_sparc; | 2317 | | break; | 2318 | | #endif | 2319 | | | 2320 | | #ifdef TIC30MAGIC | 2321 | | case TIC30MAGIC: | 2322 | | arch = bfd_arch_tic30; | 2323 | | break; | 2324 | | #endif | 2325 | | | 2326 | | #ifdef TICOFF0MAGIC | 2327 | | #ifdef TICOFF_TARGET_ARCH | 2328 | | /* This TI COFF section should be used by all new TI COFF v0 targets. */ | 2329 | | case TICOFF0MAGIC: | 2330 | | arch = TICOFF_TARGET_ARCH; | 2331 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2332 | | break; | 2333 | | #endif | 2334 | | #endif | 2335 | | | 2336 | | #ifdef TICOFF1MAGIC | 2337 | | /* This TI COFF section should be used by all new TI COFF v1/2 targets. */ | 2338 | | /* TI COFF1 and COFF2 use the target_id field to specify which arch. */ | 2339 | | case TICOFF1MAGIC: | 2340 | | case TICOFF2MAGIC: | 2341 | | switch (internal_f->f_target_id) | 2342 | | { | 2343 | | #ifdef TI_TARGET_ID | 2344 | | case TI_TARGET_ID: | 2345 | | arch = TICOFF_TARGET_ARCH; | 2346 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2347 | | break; | 2348 | | #endif | 2349 | | default: | 2350 | | arch = bfd_arch_obscure; | 2351 | | _bfd_error_handler | 2352 | | (_("unrecognized TI COFF target id '0x%x'"), | 2353 | | internal_f->f_target_id); | 2354 | | break; | 2355 | | } | 2356 | | break; | 2357 | | #endif | 2358 | | | 2359 | | #ifdef MCOREMAGIC | 2360 | | case MCOREMAGIC: | 2361 | | arch = bfd_arch_mcore; | 2362 | | break; | 2363 | | #endif | 2364 | | | 2365 | 0 | default: /* Unreadable input file type. */ | 2366 | 0 | arch = bfd_arch_obscure; | 2367 | 0 | break; | 2368 | 462 | } | 2369 | | | 2370 | 462 | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 462 | return true; | 2372 | 462 | } |
pei-arm-wince.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 282 | { | 2111 | 282 | unsigned long machine; | 2112 | 282 | enum bfd_architecture arch; | 2113 | 282 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 282 | machine = 0; | 2117 | 282 | switch (internal_f->f_magic) | 2118 | 282 | { | 2119 | | #ifdef I386MAGIC | 2120 | | case I386MAGIC: | 2121 | | case I386PTXMAGIC: | 2122 | | case I386AIXMAGIC: /* Danbury PS/2 AIX C Compiler. */ | 2123 | | case LYNXCOFFMAGIC: | 2124 | | case I386_APPLE_MAGIC: | 2125 | | case I386_FREEBSD_MAGIC: | 2126 | | case I386_LINUX_MAGIC: | 2127 | | case I386_NETBSD_MAGIC: | 2128 | | arch = bfd_arch_i386; | 2129 | | break; | 2130 | | #endif | 2131 | | #ifdef AMD64MAGIC | 2132 | | case AMD64MAGIC: | 2133 | | case AMD64_APPLE_MAGIC: | 2134 | | case AMD64_FREEBSD_MAGIC: | 2135 | | case AMD64_LINUX_MAGIC: | 2136 | | case AMD64_NETBSD_MAGIC: | 2137 | | arch = bfd_arch_i386; | 2138 | | machine = bfd_mach_x86_64; | 2139 | | break; | 2140 | | #endif | 2141 | | #ifdef IA64MAGIC | 2142 | | case IA64MAGIC: | 2143 | | arch = bfd_arch_ia64; | 2144 | | break; | 2145 | | #endif | 2146 | 0 | #ifdef ARMMAGIC | 2147 | 232 | case ARMMAGIC: | 2148 | 263 | case ARMPEMAGIC: | 2149 | 272 | case THUMBPEMAGIC: | 2150 | 272 | arch = bfd_arch_arm; | 2151 | 272 | machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION); | 2152 | 272 | if (machine == bfd_mach_arm_unknown) | 2153 | 272 | { | 2154 | 272 | switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK) | 2155 | 272 | { | 2156 | 113 | case F_ARM_2: machine = bfd_mach_arm_2; break; | 2157 | 6 | case F_ARM_2a: machine = bfd_mach_arm_2a; break; | 2158 | 6 | case F_ARM_3: machine = bfd_mach_arm_3; break; | 2159 | 90 | default: | 2160 | 107 | case F_ARM_3M: machine = bfd_mach_arm_3M; break; | 2161 | 6 | case F_ARM_4: machine = bfd_mach_arm_4; break; | 2162 | 9 | case F_ARM_4T: machine = bfd_mach_arm_4T; break; | 2163 | | /* The COFF header does not have enough bits available | 2164 | | to cover all the different ARM architectures. So | 2165 | | we interpret F_ARM_5, the highest flag value to mean | 2166 | | "the highest ARM architecture known to BFD" which is | 2167 | | currently the XScale. */ | 2168 | 25 | case F_ARM_5: machine = bfd_mach_arm_XScale; break; | 2169 | 272 | } | 2170 | 272 | } | 2171 | 272 | break; | 2172 | 272 | #endif | 2173 | | #ifdef AARCH64MAGIC | 2174 | | case AARCH64MAGIC: | 2175 | | arch = bfd_arch_aarch64; | 2176 | | machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK; | 2177 | | break; | 2178 | | #endif | 2179 | | #ifdef LOONGARCH64MAGIC | 2180 | | case LOONGARCH64MAGIC: | 2181 | | arch = bfd_arch_loongarch; | 2182 | | machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK; | 2183 | | break; | 2184 | | #endif | 2185 | | #ifdef Z80MAGIC | 2186 | | case Z80MAGIC: | 2187 | | arch = bfd_arch_z80; | 2188 | | switch (internal_f->f_flags & F_MACHMASK) | 2189 | | { | 2190 | | case bfd_mach_z80strict << 12: | 2191 | | case bfd_mach_z80 << 12: | 2192 | | case bfd_mach_z80n << 12: | 2193 | | case bfd_mach_z80full << 12: | 2194 | | case bfd_mach_r800 << 12: | 2195 | | case bfd_mach_gbz80 << 12: | 2196 | | case bfd_mach_z180 << 12: | 2197 | | case bfd_mach_ez80_z80 << 12: | 2198 | | case bfd_mach_ez80_adl << 12: | 2199 | | machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12; | 2200 | | break; | 2201 | | default: | 2202 | | return false; | 2203 | | } | 2204 | | break; | 2205 | | #endif | 2206 | | #ifdef Z8KMAGIC | 2207 | | case Z8KMAGIC: | 2208 | | arch = bfd_arch_z8k; | 2209 | | switch (internal_f->f_flags & F_MACHMASK) | 2210 | | { | 2211 | | case F_Z8001: | 2212 | | machine = bfd_mach_z8001; | 2213 | | break; | 2214 | | case F_Z8002: | 2215 | | machine = bfd_mach_z8002; | 2216 | | break; | 2217 | | default: | 2218 | | return false; | 2219 | | } | 2220 | | break; | 2221 | | #endif | 2222 | | | 2223 | | #ifdef RS6000COFF_C | 2224 | | #ifdef XCOFF64 | 2225 | | case U64_TOCMAGIC: | 2226 | | case U803XTOCMAGIC: | 2227 | | #else | 2228 | | case U802ROMAGIC: | 2229 | | case U802WRMAGIC: | 2230 | | case U802TOCMAGIC: | 2231 | | #endif | 2232 | | { | 2233 | | int cputype; | 2234 | | | 2235 | | if (xcoff_data (abfd)->cputype != -1) | 2236 | | cputype = xcoff_data (abfd)->cputype & 0xff; | 2237 | | else | 2238 | | { | 2239 | | /* We did not get a value from the a.out header. If the | 2240 | | file has not been stripped, we may be able to get the | 2241 | | architecture information from the first symbol, if it | 2242 | | is a .file symbol. */ | 2243 | | if (obj_raw_syment_count (abfd) == 0) | 2244 | | cputype = 0; | 2245 | | else | 2246 | | { | 2247 | | bfd_byte *buf; | 2248 | | struct internal_syment sym; | 2249 | | bfd_size_type amt = bfd_coff_symesz (abfd); | 2250 | | | 2251 | | if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0) | 2252 | | return false; | 2253 | | buf = _bfd_malloc_and_read (abfd, amt, amt); | 2254 | | if (buf == NULL) | 2255 | | return false; | 2256 | | bfd_coff_swap_sym_in (abfd, buf, & sym); | 2257 | | if (sym.n_sclass == C_FILE) | 2258 | | cputype = sym.n_type & 0xff; | 2259 | | else | 2260 | | cputype = 0; | 2261 | | free (buf); | 2262 | | } | 2263 | | } | 2264 | | | 2265 | | /* FIXME: We don't handle all cases here. */ | 2266 | | switch (cputype) | 2267 | | { | 2268 | | default: | 2269 | | case 0: | 2270 | | arch = bfd_xcoff_architecture (abfd); | 2271 | | machine = bfd_xcoff_machine (abfd); | 2272 | | break; | 2273 | | | 2274 | | case 1: | 2275 | | arch = bfd_arch_powerpc; | 2276 | | machine = bfd_mach_ppc_601; | 2277 | | break; | 2278 | | case 2: /* 64 bit PowerPC */ | 2279 | | arch = bfd_arch_powerpc; | 2280 | | machine = bfd_mach_ppc_620; | 2281 | | break; | 2282 | | case 3: | 2283 | | arch = bfd_arch_powerpc; | 2284 | | machine = bfd_mach_ppc; | 2285 | | break; | 2286 | | case 4: | 2287 | | arch = bfd_arch_rs6000; | 2288 | | machine = bfd_mach_rs6k; | 2289 | | break; | 2290 | | } | 2291 | | } | 2292 | | break; | 2293 | | #endif | 2294 | | | 2295 | | #ifdef SH_ARCH_MAGIC_BIG | 2296 | | case SH_ARCH_MAGIC_BIG: | 2297 | | case SH_ARCH_MAGIC_LITTLE: | 2298 | | #ifdef COFF_WITH_PE | 2299 | | case SH_ARCH_MAGIC_WINCE: | 2300 | | #endif | 2301 | | arch = bfd_arch_sh; | 2302 | | break; | 2303 | | #endif | 2304 | | | 2305 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 2306 | | case MIPS_ARCH_MAGIC_WINCE: | 2307 | | arch = bfd_arch_mips; | 2308 | | break; | 2309 | | #endif | 2310 | | | 2311 | | #ifdef SPARCMAGIC | 2312 | | case SPARCMAGIC: | 2313 | | #ifdef LYNXCOFFMAGIC | 2314 | | case LYNXCOFFMAGIC: | 2315 | | #endif | 2316 | | arch = bfd_arch_sparc; | 2317 | | break; | 2318 | | #endif | 2319 | | | 2320 | | #ifdef TIC30MAGIC | 2321 | | case TIC30MAGIC: | 2322 | | arch = bfd_arch_tic30; | 2323 | | break; | 2324 | | #endif | 2325 | | | 2326 | | #ifdef TICOFF0MAGIC | 2327 | | #ifdef TICOFF_TARGET_ARCH | 2328 | | /* This TI COFF section should be used by all new TI COFF v0 targets. */ | 2329 | | case TICOFF0MAGIC: | 2330 | | arch = TICOFF_TARGET_ARCH; | 2331 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2332 | | break; | 2333 | | #endif | 2334 | | #endif | 2335 | | | 2336 | | #ifdef TICOFF1MAGIC | 2337 | | /* This TI COFF section should be used by all new TI COFF v1/2 targets. */ | 2338 | | /* TI COFF1 and COFF2 use the target_id field to specify which arch. */ | 2339 | | case TICOFF1MAGIC: | 2340 | | case TICOFF2MAGIC: | 2341 | | switch (internal_f->f_target_id) | 2342 | | { | 2343 | | #ifdef TI_TARGET_ID | 2344 | | case TI_TARGET_ID: | 2345 | | arch = TICOFF_TARGET_ARCH; | 2346 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2347 | | break; | 2348 | | #endif | 2349 | | default: | 2350 | | arch = bfd_arch_obscure; | 2351 | | _bfd_error_handler | 2352 | | (_("unrecognized TI COFF target id '0x%x'"), | 2353 | | internal_f->f_target_id); | 2354 | | break; | 2355 | | } | 2356 | | break; | 2357 | | #endif | 2358 | | | 2359 | | #ifdef MCOREMAGIC | 2360 | | case MCOREMAGIC: | 2361 | | arch = bfd_arch_mcore; | 2362 | | break; | 2363 | | #endif | 2364 | | | 2365 | 272 | default: /* Unreadable input file type. */ | 2366 | 10 | arch = bfd_arch_obscure; | 2367 | 10 | break; | 2368 | 282 | } | 2369 | | | 2370 | 282 | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 282 | return true; | 2372 | 282 | } |
pei-arm.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 462 | { | 2111 | 462 | unsigned long machine; | 2112 | 462 | enum bfd_architecture arch; | 2113 | 462 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 462 | machine = 0; | 2117 | 462 | switch (internal_f->f_magic) | 2118 | 462 | { | 2119 | | #ifdef I386MAGIC | 2120 | | case I386MAGIC: | 2121 | | case I386PTXMAGIC: | 2122 | | case I386AIXMAGIC: /* Danbury PS/2 AIX C Compiler. */ | 2123 | | case LYNXCOFFMAGIC: | 2124 | | case I386_APPLE_MAGIC: | 2125 | | case I386_FREEBSD_MAGIC: | 2126 | | case I386_LINUX_MAGIC: | 2127 | | case I386_NETBSD_MAGIC: | 2128 | | arch = bfd_arch_i386; | 2129 | | break; | 2130 | | #endif | 2131 | | #ifdef AMD64MAGIC | 2132 | | case AMD64MAGIC: | 2133 | | case AMD64_APPLE_MAGIC: | 2134 | | case AMD64_FREEBSD_MAGIC: | 2135 | | case AMD64_LINUX_MAGIC: | 2136 | | case AMD64_NETBSD_MAGIC: | 2137 | | arch = bfd_arch_i386; | 2138 | | machine = bfd_mach_x86_64; | 2139 | | break; | 2140 | | #endif | 2141 | | #ifdef IA64MAGIC | 2142 | | case IA64MAGIC: | 2143 | | arch = bfd_arch_ia64; | 2144 | | break; | 2145 | | #endif | 2146 | 0 | #ifdef ARMMAGIC | 2147 | 373 | case ARMMAGIC: | 2148 | 410 | case ARMPEMAGIC: | 2149 | 447 | case THUMBPEMAGIC: | 2150 | 447 | arch = bfd_arch_arm; | 2151 | 447 | machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION); | 2152 | 447 | if (machine == bfd_mach_arm_unknown) | 2153 | 447 | { | 2154 | 447 | switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK) | 2155 | 447 | { | 2156 | 156 | case F_ARM_2: machine = bfd_mach_arm_2; break; | 2157 | 10 | case F_ARM_2a: machine = bfd_mach_arm_2a; break; | 2158 | 9 | case F_ARM_3: machine = bfd_mach_arm_3; break; | 2159 | 141 | default: | 2160 | 197 | case F_ARM_3M: machine = bfd_mach_arm_3M; break; | 2161 | 28 | case F_ARM_4: machine = bfd_mach_arm_4; break; | 2162 | 11 | case F_ARM_4T: machine = bfd_mach_arm_4T; break; | 2163 | | /* The COFF header does not have enough bits available | 2164 | | to cover all the different ARM architectures. So | 2165 | | we interpret F_ARM_5, the highest flag value to mean | 2166 | | "the highest ARM architecture known to BFD" which is | 2167 | | currently the XScale. */ | 2168 | 36 | case F_ARM_5: machine = bfd_mach_arm_XScale; break; | 2169 | 447 | } | 2170 | 447 | } | 2171 | 447 | break; | 2172 | 447 | #endif | 2173 | | #ifdef AARCH64MAGIC | 2174 | | case AARCH64MAGIC: | 2175 | | arch = bfd_arch_aarch64; | 2176 | | machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK; | 2177 | | break; | 2178 | | #endif | 2179 | | #ifdef LOONGARCH64MAGIC | 2180 | | case LOONGARCH64MAGIC: | 2181 | | arch = bfd_arch_loongarch; | 2182 | | machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK; | 2183 | | break; | 2184 | | #endif | 2185 | | #ifdef Z80MAGIC | 2186 | | case Z80MAGIC: | 2187 | | arch = bfd_arch_z80; | 2188 | | switch (internal_f->f_flags & F_MACHMASK) | 2189 | | { | 2190 | | case bfd_mach_z80strict << 12: | 2191 | | case bfd_mach_z80 << 12: | 2192 | | case bfd_mach_z80n << 12: | 2193 | | case bfd_mach_z80full << 12: | 2194 | | case bfd_mach_r800 << 12: | 2195 | | case bfd_mach_gbz80 << 12: | 2196 | | case bfd_mach_z180 << 12: | 2197 | | case bfd_mach_ez80_z80 << 12: | 2198 | | case bfd_mach_ez80_adl << 12: | 2199 | | machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12; | 2200 | | break; | 2201 | | default: | 2202 | | return false; | 2203 | | } | 2204 | | break; | 2205 | | #endif | 2206 | | #ifdef Z8KMAGIC | 2207 | | case Z8KMAGIC: | 2208 | | arch = bfd_arch_z8k; | 2209 | | switch (internal_f->f_flags & F_MACHMASK) | 2210 | | { | 2211 | | case F_Z8001: | 2212 | | machine = bfd_mach_z8001; | 2213 | | break; | 2214 | | case F_Z8002: | 2215 | | machine = bfd_mach_z8002; | 2216 | | break; | 2217 | | default: | 2218 | | return false; | 2219 | | } | 2220 | | break; | 2221 | | #endif | 2222 | | | 2223 | | #ifdef RS6000COFF_C | 2224 | | #ifdef XCOFF64 | 2225 | | case U64_TOCMAGIC: | 2226 | | case U803XTOCMAGIC: | 2227 | | #else | 2228 | | case U802ROMAGIC: | 2229 | | case U802WRMAGIC: | 2230 | | case U802TOCMAGIC: | 2231 | | #endif | 2232 | | { | 2233 | | int cputype; | 2234 | | | 2235 | | if (xcoff_data (abfd)->cputype != -1) | 2236 | | cputype = xcoff_data (abfd)->cputype & 0xff; | 2237 | | else | 2238 | | { | 2239 | | /* We did not get a value from the a.out header. If the | 2240 | | file has not been stripped, we may be able to get the | 2241 | | architecture information from the first symbol, if it | 2242 | | is a .file symbol. */ | 2243 | | if (obj_raw_syment_count (abfd) == 0) | 2244 | | cputype = 0; | 2245 | | else | 2246 | | { | 2247 | | bfd_byte *buf; | 2248 | | struct internal_syment sym; | 2249 | | bfd_size_type amt = bfd_coff_symesz (abfd); | 2250 | | | 2251 | | if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0) | 2252 | | return false; | 2253 | | buf = _bfd_malloc_and_read (abfd, amt, amt); | 2254 | | if (buf == NULL) | 2255 | | return false; | 2256 | | bfd_coff_swap_sym_in (abfd, buf, & sym); | 2257 | | if (sym.n_sclass == C_FILE) | 2258 | | cputype = sym.n_type & 0xff; | 2259 | | else | 2260 | | cputype = 0; | 2261 | | free (buf); | 2262 | | } | 2263 | | } | 2264 | | | 2265 | | /* FIXME: We don't handle all cases here. */ | 2266 | | switch (cputype) | 2267 | | { | 2268 | | default: | 2269 | | case 0: | 2270 | | arch = bfd_xcoff_architecture (abfd); | 2271 | | machine = bfd_xcoff_machine (abfd); | 2272 | | break; | 2273 | | | 2274 | | case 1: | 2275 | | arch = bfd_arch_powerpc; | 2276 | | machine = bfd_mach_ppc_601; | 2277 | | break; | 2278 | | case 2: /* 64 bit PowerPC */ | 2279 | | arch = bfd_arch_powerpc; | 2280 | | machine = bfd_mach_ppc_620; | 2281 | | break; | 2282 | | case 3: | 2283 | | arch = bfd_arch_powerpc; | 2284 | | machine = bfd_mach_ppc; | 2285 | | break; | 2286 | | case 4: | 2287 | | arch = bfd_arch_rs6000; | 2288 | | machine = bfd_mach_rs6k; | 2289 | | break; | 2290 | | } | 2291 | | } | 2292 | | break; | 2293 | | #endif | 2294 | | | 2295 | | #ifdef SH_ARCH_MAGIC_BIG | 2296 | | case SH_ARCH_MAGIC_BIG: | 2297 | | case SH_ARCH_MAGIC_LITTLE: | 2298 | | #ifdef COFF_WITH_PE | 2299 | | case SH_ARCH_MAGIC_WINCE: | 2300 | | #endif | 2301 | | arch = bfd_arch_sh; | 2302 | | break; | 2303 | | #endif | 2304 | | | 2305 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 2306 | | case MIPS_ARCH_MAGIC_WINCE: | 2307 | | arch = bfd_arch_mips; | 2308 | | break; | 2309 | | #endif | 2310 | | | 2311 | | #ifdef SPARCMAGIC | 2312 | | case SPARCMAGIC: | 2313 | | #ifdef LYNXCOFFMAGIC | 2314 | | case LYNXCOFFMAGIC: | 2315 | | #endif | 2316 | | arch = bfd_arch_sparc; | 2317 | | break; | 2318 | | #endif | 2319 | | | 2320 | | #ifdef TIC30MAGIC | 2321 | | case TIC30MAGIC: | 2322 | | arch = bfd_arch_tic30; | 2323 | | break; | 2324 | | #endif | 2325 | | | 2326 | | #ifdef TICOFF0MAGIC | 2327 | | #ifdef TICOFF_TARGET_ARCH | 2328 | | /* This TI COFF section should be used by all new TI COFF v0 targets. */ | 2329 | | case TICOFF0MAGIC: | 2330 | | arch = TICOFF_TARGET_ARCH; | 2331 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2332 | | break; | 2333 | | #endif | 2334 | | #endif | 2335 | | | 2336 | | #ifdef TICOFF1MAGIC | 2337 | | /* This TI COFF section should be used by all new TI COFF v1/2 targets. */ | 2338 | | /* TI COFF1 and COFF2 use the target_id field to specify which arch. */ | 2339 | | case TICOFF1MAGIC: | 2340 | | case TICOFF2MAGIC: | 2341 | | switch (internal_f->f_target_id) | 2342 | | { | 2343 | | #ifdef TI_TARGET_ID | 2344 | | case TI_TARGET_ID: | 2345 | | arch = TICOFF_TARGET_ARCH; | 2346 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2347 | | break; | 2348 | | #endif | 2349 | | default: | 2350 | | arch = bfd_arch_obscure; | 2351 | | _bfd_error_handler | 2352 | | (_("unrecognized TI COFF target id '0x%x'"), | 2353 | | internal_f->f_target_id); | 2354 | | break; | 2355 | | } | 2356 | | break; | 2357 | | #endif | 2358 | | | 2359 | | #ifdef MCOREMAGIC | 2360 | | case MCOREMAGIC: | 2361 | | arch = bfd_arch_mcore; | 2362 | | break; | 2363 | | #endif | 2364 | | | 2365 | 447 | default: /* Unreadable input file type. */ | 2366 | 15 | arch = bfd_arch_obscure; | 2367 | 15 | break; | 2368 | 462 | } | 2369 | | | 2370 | 462 | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 462 | return true; | 2372 | 462 | } |
pei-mcore.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 288 | { | 2111 | 288 | unsigned long machine; | 2112 | 288 | enum bfd_architecture arch; | 2113 | 288 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 288 | machine = 0; | 2117 | 288 | switch (internal_f->f_magic) | 2118 | 288 | { | 2119 | | #ifdef I386MAGIC | 2120 | | case I386MAGIC: | 2121 | | case I386PTXMAGIC: | 2122 | | case I386AIXMAGIC: /* Danbury PS/2 AIX C Compiler. */ | 2123 | | case LYNXCOFFMAGIC: | 2124 | | case I386_APPLE_MAGIC: | 2125 | | case I386_FREEBSD_MAGIC: | 2126 | | case I386_LINUX_MAGIC: | 2127 | | case I386_NETBSD_MAGIC: | 2128 | | arch = bfd_arch_i386; | 2129 | | break; | 2130 | | #endif | 2131 | | #ifdef AMD64MAGIC | 2132 | | case AMD64MAGIC: | 2133 | | case AMD64_APPLE_MAGIC: | 2134 | | case AMD64_FREEBSD_MAGIC: | 2135 | | case AMD64_LINUX_MAGIC: | 2136 | | case AMD64_NETBSD_MAGIC: | 2137 | | arch = bfd_arch_i386; | 2138 | | machine = bfd_mach_x86_64; | 2139 | | break; | 2140 | | #endif | 2141 | | #ifdef IA64MAGIC | 2142 | | case IA64MAGIC: | 2143 | | arch = bfd_arch_ia64; | 2144 | | break; | 2145 | | #endif | 2146 | | #ifdef ARMMAGIC | 2147 | | case ARMMAGIC: | 2148 | | case ARMPEMAGIC: | 2149 | | case THUMBPEMAGIC: | 2150 | | arch = bfd_arch_arm; | 2151 | | machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION); | 2152 | | if (machine == bfd_mach_arm_unknown) | 2153 | | { | 2154 | | switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK) | 2155 | | { | 2156 | | case F_ARM_2: machine = bfd_mach_arm_2; break; | 2157 | | case F_ARM_2a: machine = bfd_mach_arm_2a; break; | 2158 | | case F_ARM_3: machine = bfd_mach_arm_3; break; | 2159 | | default: | 2160 | | case F_ARM_3M: machine = bfd_mach_arm_3M; break; | 2161 | | case F_ARM_4: machine = bfd_mach_arm_4; break; | 2162 | | case F_ARM_4T: machine = bfd_mach_arm_4T; break; | 2163 | | /* The COFF header does not have enough bits available | 2164 | | to cover all the different ARM architectures. So | 2165 | | we interpret F_ARM_5, the highest flag value to mean | 2166 | | "the highest ARM architecture known to BFD" which is | 2167 | | currently the XScale. */ | 2168 | | case F_ARM_5: machine = bfd_mach_arm_XScale; break; | 2169 | | } | 2170 | | } | 2171 | | break; | 2172 | | #endif | 2173 | | #ifdef AARCH64MAGIC | 2174 | | case AARCH64MAGIC: | 2175 | | arch = bfd_arch_aarch64; | 2176 | | machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK; | 2177 | | break; | 2178 | | #endif | 2179 | | #ifdef LOONGARCH64MAGIC | 2180 | | case LOONGARCH64MAGIC: | 2181 | | arch = bfd_arch_loongarch; | 2182 | | machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK; | 2183 | | break; | 2184 | | #endif | 2185 | | #ifdef Z80MAGIC | 2186 | | case Z80MAGIC: | 2187 | | arch = bfd_arch_z80; | 2188 | | switch (internal_f->f_flags & F_MACHMASK) | 2189 | | { | 2190 | | case bfd_mach_z80strict << 12: | 2191 | | case bfd_mach_z80 << 12: | 2192 | | case bfd_mach_z80n << 12: | 2193 | | case bfd_mach_z80full << 12: | 2194 | | case bfd_mach_r800 << 12: | 2195 | | case bfd_mach_gbz80 << 12: | 2196 | | case bfd_mach_z180 << 12: | 2197 | | case bfd_mach_ez80_z80 << 12: | 2198 | | case bfd_mach_ez80_adl << 12: | 2199 | | machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12; | 2200 | | break; | 2201 | | default: | 2202 | | return false; | 2203 | | } | 2204 | | break; | 2205 | | #endif | 2206 | | #ifdef Z8KMAGIC | 2207 | | case Z8KMAGIC: | 2208 | | arch = bfd_arch_z8k; | 2209 | | switch (internal_f->f_flags & F_MACHMASK) | 2210 | | { | 2211 | | case F_Z8001: | 2212 | | machine = bfd_mach_z8001; | 2213 | | break; | 2214 | | case F_Z8002: | 2215 | | machine = bfd_mach_z8002; | 2216 | | break; | 2217 | | default: | 2218 | | return false; | 2219 | | } | 2220 | | break; | 2221 | | #endif | 2222 | | | 2223 | | #ifdef RS6000COFF_C | 2224 | | #ifdef XCOFF64 | 2225 | | case U64_TOCMAGIC: | 2226 | | case U803XTOCMAGIC: | 2227 | | #else | 2228 | | case U802ROMAGIC: | 2229 | | case U802WRMAGIC: | 2230 | | case U802TOCMAGIC: | 2231 | | #endif | 2232 | | { | 2233 | | int cputype; | 2234 | | | 2235 | | if (xcoff_data (abfd)->cputype != -1) | 2236 | | cputype = xcoff_data (abfd)->cputype & 0xff; | 2237 | | else | 2238 | | { | 2239 | | /* We did not get a value from the a.out header. If the | 2240 | | file has not been stripped, we may be able to get the | 2241 | | architecture information from the first symbol, if it | 2242 | | is a .file symbol. */ | 2243 | | if (obj_raw_syment_count (abfd) == 0) | 2244 | | cputype = 0; | 2245 | | else | 2246 | | { | 2247 | | bfd_byte *buf; | 2248 | | struct internal_syment sym; | 2249 | | bfd_size_type amt = bfd_coff_symesz (abfd); | 2250 | | | 2251 | | if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0) | 2252 | | return false; | 2253 | | buf = _bfd_malloc_and_read (abfd, amt, amt); | 2254 | | if (buf == NULL) | 2255 | | return false; | 2256 | | bfd_coff_swap_sym_in (abfd, buf, & sym); | 2257 | | if (sym.n_sclass == C_FILE) | 2258 | | cputype = sym.n_type & 0xff; | 2259 | | else | 2260 | | cputype = 0; | 2261 | | free (buf); | 2262 | | } | 2263 | | } | 2264 | | | 2265 | | /* FIXME: We don't handle all cases here. */ | 2266 | | switch (cputype) | 2267 | | { | 2268 | | default: | 2269 | | case 0: | 2270 | | arch = bfd_xcoff_architecture (abfd); | 2271 | | machine = bfd_xcoff_machine (abfd); | 2272 | | break; | 2273 | | | 2274 | | case 1: | 2275 | | arch = bfd_arch_powerpc; | 2276 | | machine = bfd_mach_ppc_601; | 2277 | | break; | 2278 | | case 2: /* 64 bit PowerPC */ | 2279 | | arch = bfd_arch_powerpc; | 2280 | | machine = bfd_mach_ppc_620; | 2281 | | break; | 2282 | | case 3: | 2283 | | arch = bfd_arch_powerpc; | 2284 | | machine = bfd_mach_ppc; | 2285 | | break; | 2286 | | case 4: | 2287 | | arch = bfd_arch_rs6000; | 2288 | | machine = bfd_mach_rs6k; | 2289 | | break; | 2290 | | } | 2291 | | } | 2292 | | break; | 2293 | | #endif | 2294 | | | 2295 | | #ifdef SH_ARCH_MAGIC_BIG | 2296 | | case SH_ARCH_MAGIC_BIG: | 2297 | | case SH_ARCH_MAGIC_LITTLE: | 2298 | | #ifdef COFF_WITH_PE | 2299 | | case SH_ARCH_MAGIC_WINCE: | 2300 | | #endif | 2301 | | arch = bfd_arch_sh; | 2302 | | break; | 2303 | | #endif | 2304 | | | 2305 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 2306 | | case MIPS_ARCH_MAGIC_WINCE: | 2307 | | arch = bfd_arch_mips; | 2308 | | break; | 2309 | | #endif | 2310 | | | 2311 | | #ifdef SPARCMAGIC | 2312 | | case SPARCMAGIC: | 2313 | | #ifdef LYNXCOFFMAGIC | 2314 | | case LYNXCOFFMAGIC: | 2315 | | #endif | 2316 | | arch = bfd_arch_sparc; | 2317 | | break; | 2318 | | #endif | 2319 | | | 2320 | | #ifdef TIC30MAGIC | 2321 | | case TIC30MAGIC: | 2322 | | arch = bfd_arch_tic30; | 2323 | | break; | 2324 | | #endif | 2325 | | | 2326 | | #ifdef TICOFF0MAGIC | 2327 | | #ifdef TICOFF_TARGET_ARCH | 2328 | | /* This TI COFF section should be used by all new TI COFF v0 targets. */ | 2329 | | case TICOFF0MAGIC: | 2330 | | arch = TICOFF_TARGET_ARCH; | 2331 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2332 | | break; | 2333 | | #endif | 2334 | | #endif | 2335 | | | 2336 | | #ifdef TICOFF1MAGIC | 2337 | | /* This TI COFF section should be used by all new TI COFF v1/2 targets. */ | 2338 | | /* TI COFF1 and COFF2 use the target_id field to specify which arch. */ | 2339 | | case TICOFF1MAGIC: | 2340 | | case TICOFF2MAGIC: | 2341 | | switch (internal_f->f_target_id) | 2342 | | { | 2343 | | #ifdef TI_TARGET_ID | 2344 | | case TI_TARGET_ID: | 2345 | | arch = TICOFF_TARGET_ARCH; | 2346 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2347 | | break; | 2348 | | #endif | 2349 | | default: | 2350 | | arch = bfd_arch_obscure; | 2351 | | _bfd_error_handler | 2352 | | (_("unrecognized TI COFF target id '0x%x'"), | 2353 | | internal_f->f_target_id); | 2354 | | break; | 2355 | | } | 2356 | | break; | 2357 | | #endif | 2358 | | | 2359 | 0 | #ifdef MCOREMAGIC | 2360 | 288 | case MCOREMAGIC: | 2361 | 288 | arch = bfd_arch_mcore; | 2362 | 288 | break; | 2363 | 0 | #endif | 2364 | | | 2365 | 0 | default: /* Unreadable input file type. */ | 2366 | 0 | arch = bfd_arch_obscure; | 2367 | 0 | break; | 2368 | 288 | } | 2369 | | | 2370 | 288 | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 288 | return true; | 2372 | 288 | } |
pei-sh.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 338 | { | 2111 | 338 | unsigned long machine; | 2112 | 338 | enum bfd_architecture arch; | 2113 | 338 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 338 | machine = 0; | 2117 | 338 | switch (internal_f->f_magic) | 2118 | 338 | { | 2119 | | #ifdef I386MAGIC | 2120 | | case I386MAGIC: | 2121 | | case I386PTXMAGIC: | 2122 | | case I386AIXMAGIC: /* Danbury PS/2 AIX C Compiler. */ | 2123 | | case LYNXCOFFMAGIC: | 2124 | | case I386_APPLE_MAGIC: | 2125 | | case I386_FREEBSD_MAGIC: | 2126 | | case I386_LINUX_MAGIC: | 2127 | | case I386_NETBSD_MAGIC: | 2128 | | arch = bfd_arch_i386; | 2129 | | break; | 2130 | | #endif | 2131 | | #ifdef AMD64MAGIC | 2132 | | case AMD64MAGIC: | 2133 | | case AMD64_APPLE_MAGIC: | 2134 | | case AMD64_FREEBSD_MAGIC: | 2135 | | case AMD64_LINUX_MAGIC: | 2136 | | case AMD64_NETBSD_MAGIC: | 2137 | | arch = bfd_arch_i386; | 2138 | | machine = bfd_mach_x86_64; | 2139 | | break; | 2140 | | #endif | 2141 | | #ifdef IA64MAGIC | 2142 | | case IA64MAGIC: | 2143 | | arch = bfd_arch_ia64; | 2144 | | break; | 2145 | | #endif | 2146 | | #ifdef ARMMAGIC | 2147 | | case ARMMAGIC: | 2148 | | case ARMPEMAGIC: | 2149 | | case THUMBPEMAGIC: | 2150 | | arch = bfd_arch_arm; | 2151 | | machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION); | 2152 | | if (machine == bfd_mach_arm_unknown) | 2153 | | { | 2154 | | switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK) | 2155 | | { | 2156 | | case F_ARM_2: machine = bfd_mach_arm_2; break; | 2157 | | case F_ARM_2a: machine = bfd_mach_arm_2a; break; | 2158 | | case F_ARM_3: machine = bfd_mach_arm_3; break; | 2159 | | default: | 2160 | | case F_ARM_3M: machine = bfd_mach_arm_3M; break; | 2161 | | case F_ARM_4: machine = bfd_mach_arm_4; break; | 2162 | | case F_ARM_4T: machine = bfd_mach_arm_4T; break; | 2163 | | /* The COFF header does not have enough bits available | 2164 | | to cover all the different ARM architectures. So | 2165 | | we interpret F_ARM_5, the highest flag value to mean | 2166 | | "the highest ARM architecture known to BFD" which is | 2167 | | currently the XScale. */ | 2168 | | case F_ARM_5: machine = bfd_mach_arm_XScale; break; | 2169 | | } | 2170 | | } | 2171 | | break; | 2172 | | #endif | 2173 | | #ifdef AARCH64MAGIC | 2174 | | case AARCH64MAGIC: | 2175 | | arch = bfd_arch_aarch64; | 2176 | | machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK; | 2177 | | break; | 2178 | | #endif | 2179 | | #ifdef LOONGARCH64MAGIC | 2180 | | case LOONGARCH64MAGIC: | 2181 | | arch = bfd_arch_loongarch; | 2182 | | machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK; | 2183 | | break; | 2184 | | #endif | 2185 | | #ifdef Z80MAGIC | 2186 | | case Z80MAGIC: | 2187 | | arch = bfd_arch_z80; | 2188 | | switch (internal_f->f_flags & F_MACHMASK) | 2189 | | { | 2190 | | case bfd_mach_z80strict << 12: | 2191 | | case bfd_mach_z80 << 12: | 2192 | | case bfd_mach_z80n << 12: | 2193 | | case bfd_mach_z80full << 12: | 2194 | | case bfd_mach_r800 << 12: | 2195 | | case bfd_mach_gbz80 << 12: | 2196 | | case bfd_mach_z180 << 12: | 2197 | | case bfd_mach_ez80_z80 << 12: | 2198 | | case bfd_mach_ez80_adl << 12: | 2199 | | machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12; | 2200 | | break; | 2201 | | default: | 2202 | | return false; | 2203 | | } | 2204 | | break; | 2205 | | #endif | 2206 | | #ifdef Z8KMAGIC | 2207 | | case Z8KMAGIC: | 2208 | | arch = bfd_arch_z8k; | 2209 | | switch (internal_f->f_flags & F_MACHMASK) | 2210 | | { | 2211 | | case F_Z8001: | 2212 | | machine = bfd_mach_z8001; | 2213 | | break; | 2214 | | case F_Z8002: | 2215 | | machine = bfd_mach_z8002; | 2216 | | break; | 2217 | | default: | 2218 | | return false; | 2219 | | } | 2220 | | break; | 2221 | | #endif | 2222 | | | 2223 | | #ifdef RS6000COFF_C | 2224 | | #ifdef XCOFF64 | 2225 | | case U64_TOCMAGIC: | 2226 | | case U803XTOCMAGIC: | 2227 | | #else | 2228 | | case U802ROMAGIC: | 2229 | | case U802WRMAGIC: | 2230 | | case U802TOCMAGIC: | 2231 | | #endif | 2232 | | { | 2233 | | int cputype; | 2234 | | | 2235 | | if (xcoff_data (abfd)->cputype != -1) | 2236 | | cputype = xcoff_data (abfd)->cputype & 0xff; | 2237 | | else | 2238 | | { | 2239 | | /* We did not get a value from the a.out header. If the | 2240 | | file has not been stripped, we may be able to get the | 2241 | | architecture information from the first symbol, if it | 2242 | | is a .file symbol. */ | 2243 | | if (obj_raw_syment_count (abfd) == 0) | 2244 | | cputype = 0; | 2245 | | else | 2246 | | { | 2247 | | bfd_byte *buf; | 2248 | | struct internal_syment sym; | 2249 | | bfd_size_type amt = bfd_coff_symesz (abfd); | 2250 | | | 2251 | | if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0) | 2252 | | return false; | 2253 | | buf = _bfd_malloc_and_read (abfd, amt, amt); | 2254 | | if (buf == NULL) | 2255 | | return false; | 2256 | | bfd_coff_swap_sym_in (abfd, buf, & sym); | 2257 | | if (sym.n_sclass == C_FILE) | 2258 | | cputype = sym.n_type & 0xff; | 2259 | | else | 2260 | | cputype = 0; | 2261 | | free (buf); | 2262 | | } | 2263 | | } | 2264 | | | 2265 | | /* FIXME: We don't handle all cases here. */ | 2266 | | switch (cputype) | 2267 | | { | 2268 | | default: | 2269 | | case 0: | 2270 | | arch = bfd_xcoff_architecture (abfd); | 2271 | | machine = bfd_xcoff_machine (abfd); | 2272 | | break; | 2273 | | | 2274 | | case 1: | 2275 | | arch = bfd_arch_powerpc; | 2276 | | machine = bfd_mach_ppc_601; | 2277 | | break; | 2278 | | case 2: /* 64 bit PowerPC */ | 2279 | | arch = bfd_arch_powerpc; | 2280 | | machine = bfd_mach_ppc_620; | 2281 | | break; | 2282 | | case 3: | 2283 | | arch = bfd_arch_powerpc; | 2284 | | machine = bfd_mach_ppc; | 2285 | | break; | 2286 | | case 4: | 2287 | | arch = bfd_arch_rs6000; | 2288 | | machine = bfd_mach_rs6k; | 2289 | | break; | 2290 | | } | 2291 | | } | 2292 | | break; | 2293 | | #endif | 2294 | | | 2295 | 0 | #ifdef SH_ARCH_MAGIC_BIG | 2296 | 291 | case SH_ARCH_MAGIC_BIG: | 2297 | 292 | case SH_ARCH_MAGIC_LITTLE: | 2298 | 292 | #ifdef COFF_WITH_PE | 2299 | 338 | case SH_ARCH_MAGIC_WINCE: | 2300 | 338 | #endif | 2301 | 338 | arch = bfd_arch_sh; | 2302 | 338 | break; | 2303 | 0 | #endif | 2304 | | | 2305 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 2306 | | case MIPS_ARCH_MAGIC_WINCE: | 2307 | | arch = bfd_arch_mips; | 2308 | | break; | 2309 | | #endif | 2310 | | | 2311 | | #ifdef SPARCMAGIC | 2312 | | case SPARCMAGIC: | 2313 | | #ifdef LYNXCOFFMAGIC | 2314 | | case LYNXCOFFMAGIC: | 2315 | | #endif | 2316 | | arch = bfd_arch_sparc; | 2317 | | break; | 2318 | | #endif | 2319 | | | 2320 | | #ifdef TIC30MAGIC | 2321 | | case TIC30MAGIC: | 2322 | | arch = bfd_arch_tic30; | 2323 | | break; | 2324 | | #endif | 2325 | | | 2326 | | #ifdef TICOFF0MAGIC | 2327 | | #ifdef TICOFF_TARGET_ARCH | 2328 | | /* This TI COFF section should be used by all new TI COFF v0 targets. */ | 2329 | | case TICOFF0MAGIC: | 2330 | | arch = TICOFF_TARGET_ARCH; | 2331 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2332 | | break; | 2333 | | #endif | 2334 | | #endif | 2335 | | | 2336 | | #ifdef TICOFF1MAGIC | 2337 | | /* This TI COFF section should be used by all new TI COFF v1/2 targets. */ | 2338 | | /* TI COFF1 and COFF2 use the target_id field to specify which arch. */ | 2339 | | case TICOFF1MAGIC: | 2340 | | case TICOFF2MAGIC: | 2341 | | switch (internal_f->f_target_id) | 2342 | | { | 2343 | | #ifdef TI_TARGET_ID | 2344 | | case TI_TARGET_ID: | 2345 | | arch = TICOFF_TARGET_ARCH; | 2346 | | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2347 | | break; | 2348 | | #endif | 2349 | | default: | 2350 | | arch = bfd_arch_obscure; | 2351 | | _bfd_error_handler | 2352 | | (_("unrecognized TI COFF target id '0x%x'"), | 2353 | | internal_f->f_target_id); | 2354 | | break; | 2355 | | } | 2356 | | break; | 2357 | | #endif | 2358 | | | 2359 | | #ifdef MCOREMAGIC | 2360 | | case MCOREMAGIC: | 2361 | | arch = bfd_arch_mcore; | 2362 | | break; | 2363 | | #endif | 2364 | | | 2365 | 0 | default: /* Unreadable input file type. */ | 2366 | 0 | arch = bfd_arch_obscure; | 2367 | 0 | break; | 2368 | 338 | } | 2369 | | | 2370 | 338 | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 338 | return true; | 2372 | 338 | } |
|
2373 | | |
2374 | | static bool |
2375 | | symname_in_debug_hook (bfd *abfd ATTRIBUTE_UNUSED, |
2376 | | struct internal_syment *sym ATTRIBUTE_UNUSED) |
2377 | 295k | { |
2378 | | #ifdef SYMNAME_IN_DEBUG |
2379 | 107k | return SYMNAME_IN_DEBUG (sym) != 0; |
2380 | | #else |
2381 | | return false; |
2382 | | #endif |
2383 | 295k | } pei-i386.c:symname_in_debug_hook Line | Count | Source | 2377 | 6.30k | { | 2378 | | #ifdef SYMNAME_IN_DEBUG | 2379 | | return SYMNAME_IN_DEBUG (sym) != 0; | 2380 | | #else | 2381 | 6.30k | return false; | 2382 | 6.30k | #endif | 2383 | 6.30k | } |
pe-x86_64.c:symname_in_debug_hook Line | Count | Source | 2377 | 22.2k | { | 2378 | | #ifdef SYMNAME_IN_DEBUG | 2379 | | return SYMNAME_IN_DEBUG (sym) != 0; | 2380 | | #else | 2381 | 22.2k | return false; | 2382 | 22.2k | #endif | 2383 | 22.2k | } |
pei-x86_64.c:symname_in_debug_hook Line | Count | Source | 2377 | 4.46k | { | 2378 | | #ifdef SYMNAME_IN_DEBUG | 2379 | | return SYMNAME_IN_DEBUG (sym) != 0; | 2380 | | #else | 2381 | 4.46k | return false; | 2382 | 4.46k | #endif | 2383 | 4.46k | } |
coff-x86_64.c:symname_in_debug_hook Line | Count | Source | 2377 | 12.6k | { | 2378 | | #ifdef SYMNAME_IN_DEBUG | 2379 | | return SYMNAME_IN_DEBUG (sym) != 0; | 2380 | | #else | 2381 | 12.6k | return false; | 2382 | 12.6k | #endif | 2383 | 12.6k | } |
coff64-rs6000.c:symname_in_debug_hook Line | Count | Source | 2377 | 81.6k | { | 2378 | 81.6k | #ifdef SYMNAME_IN_DEBUG | 2379 | 81.6k | return SYMNAME_IN_DEBUG (sym) != 0; | 2380 | | #else | 2381 | | return false; | 2382 | | #endif | 2383 | 81.6k | } |
pei-aarch64.c:symname_in_debug_hook Line | Count | Source | 2377 | 1.27k | { | 2378 | | #ifdef SYMNAME_IN_DEBUG | 2379 | | return SYMNAME_IN_DEBUG (sym) != 0; | 2380 | | #else | 2381 | 1.27k | return false; | 2382 | 1.27k | #endif | 2383 | 1.27k | } |
pe-aarch64.c:symname_in_debug_hook Line | Count | Source | 2377 | 12.7k | { | 2378 | | #ifdef SYMNAME_IN_DEBUG | 2379 | | return SYMNAME_IN_DEBUG (sym) != 0; | 2380 | | #else | 2381 | 12.7k | return false; | 2382 | 12.7k | #endif | 2383 | 12.7k | } |
pei-ia64.c:symname_in_debug_hook Line | Count | Source | 2377 | 4.41k | { | 2378 | | #ifdef SYMNAME_IN_DEBUG | 2379 | | return SYMNAME_IN_DEBUG (sym) != 0; | 2380 | | #else | 2381 | 4.41k | return false; | 2382 | 4.41k | #endif | 2383 | 4.41k | } |
pei-loongarch64.c:symname_in_debug_hook Line | Count | Source | 2377 | 25.6k | { | 2378 | | #ifdef SYMNAME_IN_DEBUG | 2379 | | return SYMNAME_IN_DEBUG (sym) != 0; | 2380 | | #else | 2381 | 25.6k | return false; | 2382 | 25.6k | #endif | 2383 | 25.6k | } |
Unexecuted instantiation: cf-i386lynx.c:symname_in_debug_hook Unexecuted instantiation: coff-go32.c:symname_in_debug_hook Unexecuted instantiation: coff-i386.c:symname_in_debug_hook coff-rs6000.c:symname_in_debug_hook Line | Count | Source | 2377 | 26.1k | { | 2378 | 26.1k | #ifdef SYMNAME_IN_DEBUG | 2379 | 26.1k | return SYMNAME_IN_DEBUG (sym) != 0; | 2380 | | #else | 2381 | | return false; | 2382 | | #endif | 2383 | 26.1k | } |
Unexecuted instantiation: coff-sh.c:symname_in_debug_hook Unexecuted instantiation: coff-stgo32.c:symname_in_debug_hook coff-tic30.c:symname_in_debug_hook Line | Count | Source | 2377 | 4.23k | { | 2378 | | #ifdef SYMNAME_IN_DEBUG | 2379 | | return SYMNAME_IN_DEBUG (sym) != 0; | 2380 | | #else | 2381 | 4.23k | return false; | 2382 | 4.23k | #endif | 2383 | 4.23k | } |
Unexecuted instantiation: coff-tic4x.c:symname_in_debug_hook coff-tic54x.c:symname_in_debug_hook Line | Count | Source | 2377 | 8.19k | { | 2378 | | #ifdef SYMNAME_IN_DEBUG | 2379 | | return SYMNAME_IN_DEBUG (sym) != 0; | 2380 | | #else | 2381 | 8.19k | return false; | 2382 | 8.19k | #endif | 2383 | 8.19k | } |
coff-z80.c:symname_in_debug_hook Line | Count | Source | 2377 | 11.0k | { | 2378 | | #ifdef SYMNAME_IN_DEBUG | 2379 | | return SYMNAME_IN_DEBUG (sym) != 0; | 2380 | | #else | 2381 | 11.0k | return false; | 2382 | 11.0k | #endif | 2383 | 11.0k | } |
coff-z8k.c:symname_in_debug_hook Line | Count | Source | 2377 | 10.2k | { | 2378 | | #ifdef SYMNAME_IN_DEBUG | 2379 | | return SYMNAME_IN_DEBUG (sym) != 0; | 2380 | | #else | 2381 | 10.2k | return false; | 2382 | 10.2k | #endif | 2383 | 10.2k | } |
Unexecuted instantiation: pe-arm-wince.c:symname_in_debug_hook Unexecuted instantiation: pe-arm.c:symname_in_debug_hook pe-i386.c:symname_in_debug_hook Line | Count | Source | 2377 | 7.73k | { | 2378 | | #ifdef SYMNAME_IN_DEBUG | 2379 | | return SYMNAME_IN_DEBUG (sym) != 0; | 2380 | | #else | 2381 | 7.73k | return false; | 2382 | 7.73k | #endif | 2383 | 7.73k | } |
pe-mcore.c:symname_in_debug_hook Line | Count | Source | 2377 | 11.2k | { | 2378 | | #ifdef SYMNAME_IN_DEBUG | 2379 | | return SYMNAME_IN_DEBUG (sym) != 0; | 2380 | | #else | 2381 | 11.2k | return false; | 2382 | 11.2k | #endif | 2383 | 11.2k | } |
pe-sh.c:symname_in_debug_hook Line | Count | Source | 2377 | 6.93k | { | 2378 | | #ifdef SYMNAME_IN_DEBUG | 2379 | | return SYMNAME_IN_DEBUG (sym) != 0; | 2380 | | #else | 2381 | 6.93k | return false; | 2382 | 6.93k | #endif | 2383 | 6.93k | } |
pei-arm-wince.c:symname_in_debug_hook Line | Count | Source | 2377 | 5.45k | { | 2378 | | #ifdef SYMNAME_IN_DEBUG | 2379 | | return SYMNAME_IN_DEBUG (sym) != 0; | 2380 | | #else | 2381 | 5.45k | return false; | 2382 | 5.45k | #endif | 2383 | 5.45k | } |
pei-arm.c:symname_in_debug_hook Line | Count | Source | 2377 | 8.26k | { | 2378 | | #ifdef SYMNAME_IN_DEBUG | 2379 | | return SYMNAME_IN_DEBUG (sym) != 0; | 2380 | | #else | 2381 | 8.26k | return false; | 2382 | 8.26k | #endif | 2383 | 8.26k | } |
pei-mcore.c:symname_in_debug_hook Line | Count | Source | 2377 | 6.30k | { | 2378 | | #ifdef SYMNAME_IN_DEBUG | 2379 | | return SYMNAME_IN_DEBUG (sym) != 0; | 2380 | | #else | 2381 | 6.30k | return false; | 2382 | 6.30k | #endif | 2383 | 6.30k | } |
pei-sh.c:symname_in_debug_hook Line | Count | Source | 2377 | 17.7k | { | 2378 | | #ifdef SYMNAME_IN_DEBUG | 2379 | | return SYMNAME_IN_DEBUG (sym) != 0; | 2380 | | #else | 2381 | 17.7k | return false; | 2382 | 17.7k | #endif | 2383 | 17.7k | } |
|
2384 | | |
2385 | | #ifdef RS6000COFF_C |
2386 | | |
2387 | | #ifdef XCOFF64 |
2388 | | #define FORCE_SYMNAMES_IN_STRINGS |
2389 | | #endif |
2390 | | |
2391 | | /* Handle the csect auxent of a C_EXT, C_AIX_WEAKEXT or C_HIDEXT symbol. */ |
2392 | | |
2393 | | static bool |
2394 | | coff_pointerize_aux_hook (bfd *abfd ATTRIBUTE_UNUSED, |
2395 | | combined_entry_type *table_base, |
2396 | | combined_entry_type *symbol, |
2397 | | unsigned int indaux, |
2398 | | combined_entry_type *aux) |
2399 | 1.95M | { |
2400 | 1.95M | BFD_ASSERT (symbol->is_sym); |
2401 | 1.95M | int n_sclass = symbol->u.syment.n_sclass; |
2402 | | |
2403 | 1.95M | if (CSECT_SYM_P (n_sclass) |
2404 | 1.95M | && indaux + 1 == symbol->u.syment.n_numaux) |
2405 | 8.32k | { |
2406 | 8.32k | BFD_ASSERT (! aux->is_sym); |
2407 | 8.32k | if (SMTYP_SMTYP (aux->u.auxent.x_csect.x_smtyp) == XTY_LD |
2408 | 8.32k | && aux->u.auxent.x_csect.x_scnlen.u64 < obj_raw_syment_count (abfd)) |
2409 | 630 | { |
2410 | 630 | aux->u.auxent.x_csect.x_scnlen.p = |
2411 | 630 | table_base + aux->u.auxent.x_csect.x_scnlen.u64; |
2412 | 630 | aux->fix_scnlen = 1; |
2413 | 630 | } |
2414 | | |
2415 | | /* Return TRUE to indicate that the caller should not do any |
2416 | | further work on this auxent. */ |
2417 | 8.32k | return true; |
2418 | 8.32k | } |
2419 | | |
2420 | | /* Return FALSE to indicate that this auxent should be handled by |
2421 | | the caller. */ |
2422 | 1.94M | return false; |
2423 | 1.95M | } coff64-rs6000.c:coff_pointerize_aux_hook Line | Count | Source | 2399 | 586k | { | 2400 | 586k | BFD_ASSERT (symbol->is_sym); | 2401 | 586k | int n_sclass = symbol->u.syment.n_sclass; | 2402 | | | 2403 | 586k | if (CSECT_SYM_P (n_sclass) | 2404 | 586k | && indaux + 1 == symbol->u.syment.n_numaux) | 2405 | 4.75k | { | 2406 | 4.75k | BFD_ASSERT (! aux->is_sym); | 2407 | 4.75k | if (SMTYP_SMTYP (aux->u.auxent.x_csect.x_smtyp) == XTY_LD | 2408 | 4.75k | && aux->u.auxent.x_csect.x_scnlen.u64 < obj_raw_syment_count (abfd)) | 2409 | 3 | { | 2410 | 3 | aux->u.auxent.x_csect.x_scnlen.p = | 2411 | 3 | table_base + aux->u.auxent.x_csect.x_scnlen.u64; | 2412 | 3 | aux->fix_scnlen = 1; | 2413 | 3 | } | 2414 | | | 2415 | | /* Return TRUE to indicate that the caller should not do any | 2416 | | further work on this auxent. */ | 2417 | 4.75k | return true; | 2418 | 4.75k | } | 2419 | | | 2420 | | /* Return FALSE to indicate that this auxent should be handled by | 2421 | | the caller. */ | 2422 | 581k | return false; | 2423 | 586k | } |
coff-rs6000.c:coff_pointerize_aux_hook Line | Count | Source | 2399 | 1.36M | { | 2400 | 1.36M | BFD_ASSERT (symbol->is_sym); | 2401 | 1.36M | int n_sclass = symbol->u.syment.n_sclass; | 2402 | | | 2403 | 1.36M | if (CSECT_SYM_P (n_sclass) | 2404 | 1.36M | && indaux + 1 == symbol->u.syment.n_numaux) | 2405 | 3.57k | { | 2406 | 3.57k | BFD_ASSERT (! aux->is_sym); | 2407 | 3.57k | if (SMTYP_SMTYP (aux->u.auxent.x_csect.x_smtyp) == XTY_LD | 2408 | 3.57k | && aux->u.auxent.x_csect.x_scnlen.u64 < obj_raw_syment_count (abfd)) | 2409 | 627 | { | 2410 | 627 | aux->u.auxent.x_csect.x_scnlen.p = | 2411 | 627 | table_base + aux->u.auxent.x_csect.x_scnlen.u64; | 2412 | 627 | aux->fix_scnlen = 1; | 2413 | 627 | } | 2414 | | | 2415 | | /* Return TRUE to indicate that the caller should not do any | 2416 | | further work on this auxent. */ | 2417 | 3.57k | return true; | 2418 | 3.57k | } | 2419 | | | 2420 | | /* Return FALSE to indicate that this auxent should be handled by | 2421 | | the caller. */ | 2422 | 1.36M | return false; | 2423 | 1.36M | } |
|
2424 | | |
2425 | | #else |
2426 | | #define coff_pointerize_aux_hook 0 |
2427 | | #endif /* ! RS6000COFF_C */ |
2428 | | |
2429 | | /* Print an aux entry. This returns TRUE if it has printed it. */ |
2430 | | |
2431 | | static bool |
2432 | | coff_print_aux (bfd *abfd ATTRIBUTE_UNUSED, |
2433 | | FILE *file ATTRIBUTE_UNUSED, |
2434 | | combined_entry_type *table_base ATTRIBUTE_UNUSED, |
2435 | | combined_entry_type *symbol ATTRIBUTE_UNUSED, |
2436 | | combined_entry_type *aux ATTRIBUTE_UNUSED, |
2437 | | unsigned int indaux ATTRIBUTE_UNUSED) |
2438 | 0 | { |
2439 | 0 | BFD_ASSERT (symbol->is_sym); |
2440 | 0 | BFD_ASSERT (! aux->is_sym); |
2441 | | #ifdef RS6000COFF_C |
2442 | 0 | if (CSECT_SYM_P (symbol->u.syment.n_sclass) |
2443 | 0 | && indaux + 1 == symbol->u.syment.n_numaux) |
2444 | 0 | { |
2445 | | /* This is a csect entry. */ |
2446 | 0 | fprintf (file, "AUX "); |
2447 | 0 | if (SMTYP_SMTYP (aux->u.auxent.x_csect.x_smtyp) != XTY_LD) |
2448 | 0 | { |
2449 | 0 | BFD_ASSERT (! aux->fix_scnlen); |
2450 | 0 | fprintf (file, "val %5" PRIu64, |
2451 | 0 | aux->u.auxent.x_csect.x_scnlen.u64); |
2452 | 0 | } |
2453 | 0 | else |
2454 | 0 | { |
2455 | 0 | fprintf (file, "indx "); |
2456 | 0 | if (! aux->fix_scnlen) |
2457 | 0 | fprintf (file, "%4" PRIu64, |
2458 | 0 | aux->u.auxent.x_csect.x_scnlen.u64); |
2459 | 0 | else |
2460 | 0 | fprintf (file, "%4ld", |
2461 | 0 | (long) (aux->u.auxent.x_csect.x_scnlen.p - table_base)); |
2462 | 0 | } |
2463 | 0 | fprintf (file, |
2464 | 0 | " prmhsh %u snhsh %u typ %d algn %d clss %u stb %u snstb %u", |
2465 | 0 | aux->u.auxent.x_csect.x_parmhash, |
2466 | 0 | (unsigned int) aux->u.auxent.x_csect.x_snhash, |
2467 | 0 | SMTYP_SMTYP (aux->u.auxent.x_csect.x_smtyp), |
2468 | 0 | SMTYP_ALIGN (aux->u.auxent.x_csect.x_smtyp), |
2469 | 0 | (unsigned int) aux->u.auxent.x_csect.x_smclas, |
2470 | 0 | aux->u.auxent.x_csect.x_stab, |
2471 | 0 | (unsigned int) aux->u.auxent.x_csect.x_snstab); |
2472 | 0 | return true; |
2473 | 0 | } |
2474 | 0 | #endif |
2475 | | |
2476 | | /* Return FALSE to indicate that no special action was taken. */ |
2477 | 0 | return false; |
2478 | 0 | } Unexecuted instantiation: pei-i386.c:coff_print_aux Unexecuted instantiation: pe-x86_64.c:coff_print_aux Unexecuted instantiation: pei-x86_64.c:coff_print_aux Unexecuted instantiation: coff-x86_64.c:coff_print_aux Unexecuted instantiation: coff64-rs6000.c:coff_print_aux Unexecuted instantiation: pei-aarch64.c:coff_print_aux Unexecuted instantiation: pe-aarch64.c:coff_print_aux Unexecuted instantiation: pei-ia64.c:coff_print_aux Unexecuted instantiation: pei-loongarch64.c:coff_print_aux Unexecuted instantiation: cf-i386lynx.c:coff_print_aux Unexecuted instantiation: coff-go32.c:coff_print_aux Unexecuted instantiation: coff-i386.c:coff_print_aux Unexecuted instantiation: coff-rs6000.c:coff_print_aux Unexecuted instantiation: coff-sh.c:coff_print_aux Unexecuted instantiation: coff-stgo32.c:coff_print_aux Unexecuted instantiation: coff-tic30.c:coff_print_aux Unexecuted instantiation: coff-tic4x.c:coff_print_aux Unexecuted instantiation: coff-tic54x.c:coff_print_aux Unexecuted instantiation: coff-z80.c:coff_print_aux Unexecuted instantiation: coff-z8k.c:coff_print_aux Unexecuted instantiation: pe-arm-wince.c:coff_print_aux Unexecuted instantiation: pe-arm.c:coff_print_aux Unexecuted instantiation: pe-i386.c:coff_print_aux Unexecuted instantiation: pe-mcore.c:coff_print_aux Unexecuted instantiation: pe-sh.c:coff_print_aux Unexecuted instantiation: pei-arm-wince.c:coff_print_aux Unexecuted instantiation: pei-arm.c:coff_print_aux Unexecuted instantiation: pei-mcore.c:coff_print_aux Unexecuted instantiation: pei-sh.c:coff_print_aux |
2479 | | |
2480 | | /* |
2481 | | SUBSUBSECTION |
2482 | | Writing relocations |
2483 | | |
2484 | | To write relocations, the back end steps though the |
2485 | | canonical relocation table and create an |
2486 | | @code{internal_reloc}. The symbol index to use is removed from |
2487 | | the @code{offset} field in the symbol table supplied. The |
2488 | | address comes directly from the sum of the section base |
2489 | | address and the relocation offset; the type is dug directly |
2490 | | from the howto field. Then the @code{internal_reloc} is |
2491 | | swapped into the shape of an @code{external_reloc} and written |
2492 | | out to disk. |
2493 | | |
2494 | | */ |
2495 | | |
2496 | | #ifdef TARG_AUX |
2497 | | |
2498 | | |
2499 | | /* AUX's ld wants relocations to be sorted. */ |
2500 | | static int |
2501 | | compare_arelent_ptr (const void * x, const void * y) |
2502 | | { |
2503 | | const arelent **a = (const arelent **) x; |
2504 | | const arelent **b = (const arelent **) y; |
2505 | | bfd_size_type aadr = (*a)->address; |
2506 | | bfd_size_type badr = (*b)->address; |
2507 | | |
2508 | | return (aadr < badr ? -1 : badr < aadr ? 1 : 0); |
2509 | | } |
2510 | | |
2511 | | #endif /* TARG_AUX */ |
2512 | | |
2513 | | static bool |
2514 | | coff_write_relocs (bfd * abfd, int first_undef) |
2515 | 0 | { |
2516 | 0 | asection *s; |
2517 | |
|
2518 | 0 | for (s = abfd->sections; s != NULL; s = s->next) |
2519 | 0 | { |
2520 | 0 | unsigned int i; |
2521 | 0 | struct external_reloc dst; |
2522 | 0 | arelent **p; |
2523 | |
|
2524 | 0 | #ifndef TARG_AUX |
2525 | 0 | p = s->orelocation; |
2526 | | #else |
2527 | | { |
2528 | | /* Sort relocations before we write them out. */ |
2529 | | bfd_size_type amt; |
2530 | | |
2531 | | amt = s->reloc_count; |
2532 | | amt *= sizeof (arelent *); |
2533 | | p = bfd_malloc (amt); |
2534 | | if (p == NULL) |
2535 | | { |
2536 | | if (s->reloc_count > 0) |
2537 | | return false; |
2538 | | } |
2539 | | else |
2540 | | { |
2541 | | memcpy (p, s->orelocation, (size_t) amt); |
2542 | | qsort (p, s->reloc_count, sizeof (arelent *), compare_arelent_ptr); |
2543 | | } |
2544 | | } |
2545 | | #endif |
2546 | |
|
2547 | 0 | if (bfd_seek (abfd, s->rel_filepos, SEEK_SET) != 0) |
2548 | 0 | return false; |
2549 | | |
2550 | | #ifdef COFF_WITH_EXTENDED_RELOC_COUNTER |
2551 | 0 | if ((obj_pe (abfd) || obj_go32 (abfd)) && s->reloc_count >= 0xffff) |
2552 | 0 | { |
2553 | | /* Encode real count here as first reloc. */ |
2554 | 0 | struct internal_reloc n; |
2555 | |
|
2556 | 0 | memset (& n, 0, sizeof (n)); |
2557 | | /* Add one to count *this* reloc (grr). */ |
2558 | 0 | n.r_vaddr = s->reloc_count + 1; |
2559 | 0 | coff_swap_reloc_out (abfd, &n, &dst); |
2560 | 0 | if (bfd_bwrite (& dst, (bfd_size_type) bfd_coff_relsz (abfd), |
2561 | 0 | abfd) != bfd_coff_relsz (abfd)) |
2562 | 0 | return false; |
2563 | 0 | } |
2564 | 0 | #endif |
2565 | | |
2566 | 0 | for (i = 0; i < s->reloc_count; i++) |
2567 | 0 | { |
2568 | 0 | struct internal_reloc n; |
2569 | 0 | arelent *q = p[i]; |
2570 | |
|
2571 | 0 | memset (& n, 0, sizeof (n)); |
2572 | | |
2573 | | /* Now we've renumbered the symbols we know where the |
2574 | | undefined symbols live in the table. Check the reloc |
2575 | | entries for symbols who's output bfd isn't the right one. |
2576 | | This is because the symbol was undefined (which means |
2577 | | that all the pointers are never made to point to the same |
2578 | | place). This is a bad thing,'cause the symbols attached |
2579 | | to the output bfd are indexed, so that the relocation |
2580 | | entries know which symbol index they point to. So we |
2581 | | have to look up the output symbol here. */ |
2582 | |
|
2583 | 0 | if (q->sym_ptr_ptr[0] != NULL && q->sym_ptr_ptr[0]->the_bfd != abfd) |
2584 | 0 | { |
2585 | 0 | int j; |
2586 | 0 | const char *sname = q->sym_ptr_ptr[0]->name; |
2587 | 0 | asymbol **outsyms = abfd->outsymbols; |
2588 | |
|
2589 | 0 | for (j = first_undef; outsyms[j]; j++) |
2590 | 0 | { |
2591 | 0 | const char *intable = outsyms[j]->name; |
2592 | |
|
2593 | 0 | if (strcmp (intable, sname) == 0) |
2594 | 0 | { |
2595 | | /* Got a hit, so repoint the reloc. */ |
2596 | 0 | q->sym_ptr_ptr = outsyms + j; |
2597 | 0 | break; |
2598 | 0 | } |
2599 | 0 | } |
2600 | 0 | } |
2601 | |
|
2602 | 0 | n.r_vaddr = q->address + s->vma; |
2603 | |
|
2604 | | #ifdef R_IHCONST |
2605 | | /* The 29k const/consth reloc pair is a real kludge. The consth |
2606 | | part doesn't have a symbol; it has an offset. So rebuilt |
2607 | | that here. */ |
2608 | | if (q->howto->type == R_IHCONST) |
2609 | | n.r_symndx = q->addend; |
2610 | | else |
2611 | | #endif |
2612 | 0 | if (q->sym_ptr_ptr && q->sym_ptr_ptr[0] != NULL) |
2613 | 0 | { |
2614 | | #ifdef SECTION_RELATIVE_ABSOLUTE_SYMBOL_P |
2615 | 0 | if (SECTION_RELATIVE_ABSOLUTE_SYMBOL_P (q, s)) |
2616 | | #else |
2617 | 0 | if ((*q->sym_ptr_ptr)->section == bfd_abs_section_ptr |
2618 | 0 | && ((*q->sym_ptr_ptr)->flags & BSF_SECTION_SYM) != 0) |
2619 | 0 | #endif |
2620 | | /* This is a relocation relative to the absolute symbol. */ |
2621 | 0 | n.r_symndx = -1; |
2622 | 0 | else |
2623 | 0 | { |
2624 | 0 | n.r_symndx = get_index ((*(q->sym_ptr_ptr))); |
2625 | | /* Check to see if the symbol reloc points to a symbol |
2626 | | we don't have in our symbol table. */ |
2627 | 0 | if (n.r_symndx > obj_conv_table_size (abfd)) |
2628 | 0 | { |
2629 | 0 | bfd_set_error (bfd_error_bad_value); |
2630 | | /* xgettext:c-format */ |
2631 | 0 | _bfd_error_handler (_("%pB: reloc against a non-existent" |
2632 | 0 | " symbol index: %ld"), |
2633 | 0 | abfd, n.r_symndx); |
2634 | 0 | return false; |
2635 | 0 | } |
2636 | 0 | } |
2637 | 0 | } |
2638 | | |
2639 | | #ifdef SWAP_OUT_RELOC_OFFSET |
2640 | 0 | n.r_offset = q->addend; |
2641 | 0 | #endif |
2642 | |
|
2643 | | #ifdef SELECT_RELOC |
2644 | | /* Work out reloc type from what is required. */ |
2645 | 0 | if (q->howto) |
2646 | 0 | SELECT_RELOC (n, q->howto); |
2647 | | #else |
2648 | 0 | if (q->howto) |
2649 | 0 | n.r_type = q->howto->type; |
2650 | | #endif |
2651 | 0 | coff_swap_reloc_out (abfd, &n, &dst); |
2652 | |
|
2653 | 0 | if (bfd_bwrite (& dst, (bfd_size_type) bfd_coff_relsz (abfd), |
2654 | 0 | abfd) != bfd_coff_relsz (abfd)) |
2655 | 0 | return false; |
2656 | 0 | } |
2657 | |
|
2658 | | #ifdef TARG_AUX |
2659 | | free (p); |
2660 | | #endif |
2661 | 0 | } |
2662 | | |
2663 | 0 | return true; |
2664 | 0 | } Unexecuted instantiation: pei-i386.c:coff_write_relocs Unexecuted instantiation: pe-x86_64.c:coff_write_relocs Unexecuted instantiation: pei-x86_64.c:coff_write_relocs Unexecuted instantiation: coff-x86_64.c:coff_write_relocs Unexecuted instantiation: coff64-rs6000.c:coff_write_relocs Unexecuted instantiation: pei-aarch64.c:coff_write_relocs Unexecuted instantiation: pe-aarch64.c:coff_write_relocs Unexecuted instantiation: pei-ia64.c:coff_write_relocs Unexecuted instantiation: pei-loongarch64.c:coff_write_relocs Unexecuted instantiation: cf-i386lynx.c:coff_write_relocs Unexecuted instantiation: coff-go32.c:coff_write_relocs Unexecuted instantiation: coff-i386.c:coff_write_relocs Unexecuted instantiation: coff-rs6000.c:coff_write_relocs Unexecuted instantiation: coff-sh.c:coff_write_relocs Unexecuted instantiation: coff-stgo32.c:coff_write_relocs Unexecuted instantiation: coff-tic30.c:coff_write_relocs Unexecuted instantiation: coff-tic4x.c:coff_write_relocs Unexecuted instantiation: coff-tic54x.c:coff_write_relocs Unexecuted instantiation: coff-z80.c:coff_write_relocs Unexecuted instantiation: coff-z8k.c:coff_write_relocs Unexecuted instantiation: pe-arm-wince.c:coff_write_relocs Unexecuted instantiation: pe-arm.c:coff_write_relocs Unexecuted instantiation: pe-i386.c:coff_write_relocs Unexecuted instantiation: pe-mcore.c:coff_write_relocs Unexecuted instantiation: pe-sh.c:coff_write_relocs Unexecuted instantiation: pei-arm-wince.c:coff_write_relocs Unexecuted instantiation: pei-arm.c:coff_write_relocs Unexecuted instantiation: pei-mcore.c:coff_write_relocs Unexecuted instantiation: pei-sh.c:coff_write_relocs |
2665 | | |
2666 | | /* Set flags and magic number of a coff file from architecture and machine |
2667 | | type. Result is TRUE if we can represent the arch&type, FALSE if not. */ |
2668 | | |
2669 | | static bool |
2670 | | coff_set_flags (bfd * abfd, |
2671 | | unsigned int *magicp ATTRIBUTE_UNUSED, |
2672 | | unsigned short *flagsp ATTRIBUTE_UNUSED) |
2673 | 0 | { |
2674 | 0 | switch (bfd_get_arch (abfd)) |
2675 | 0 | { |
2676 | | #ifdef Z80MAGIC |
2677 | 0 | case bfd_arch_z80: |
2678 | 0 | *magicp = Z80MAGIC; |
2679 | 0 | switch (bfd_get_mach (abfd)) |
2680 | 0 | { |
2681 | 0 | case bfd_mach_z80strict: |
2682 | 0 | case bfd_mach_z80: |
2683 | 0 | case bfd_mach_z80n: |
2684 | 0 | case bfd_mach_z80full: |
2685 | 0 | case bfd_mach_r800: |
2686 | 0 | case bfd_mach_gbz80: |
2687 | 0 | case bfd_mach_z180: |
2688 | 0 | case bfd_mach_ez80_z80: |
2689 | 0 | case bfd_mach_ez80_adl: |
2690 | 0 | *flagsp = bfd_get_mach (abfd) << 12; |
2691 | 0 | break; |
2692 | 0 | default: |
2693 | 0 | return false; |
2694 | 0 | } |
2695 | 0 | return true; |
2696 | 0 | #endif |
2697 | | |
2698 | | #ifdef Z8KMAGIC |
2699 | 0 | case bfd_arch_z8k: |
2700 | 0 | *magicp = Z8KMAGIC; |
2701 | |
|
2702 | 0 | switch (bfd_get_mach (abfd)) |
2703 | 0 | { |
2704 | 0 | case bfd_mach_z8001: *flagsp = F_Z8001; break; |
2705 | 0 | case bfd_mach_z8002: *flagsp = F_Z8002; break; |
2706 | 0 | default: return false; |
2707 | 0 | } |
2708 | 0 | return true; |
2709 | 0 | #endif |
2710 | | |
2711 | | #ifdef TIC30MAGIC |
2712 | 0 | case bfd_arch_tic30: |
2713 | 0 | *magicp = TIC30MAGIC; |
2714 | 0 | return true; |
2715 | 0 | #endif |
2716 | | |
2717 | | #ifdef TICOFF_DEFAULT_MAGIC |
2718 | 0 | case TICOFF_TARGET_ARCH: |
2719 | | /* If there's no indication of which version we want, use the default. */ |
2720 | 0 | if (!abfd->xvec ) |
2721 | 0 | *magicp = TICOFF_DEFAULT_MAGIC; |
2722 | 0 | else |
2723 | 0 | { |
2724 | | /* We may want to output in a different COFF version. */ |
2725 | 0 | switch (abfd->xvec->name[4]) |
2726 | 0 | { |
2727 | 0 | case '0': |
2728 | 0 | *magicp = TICOFF0MAGIC; |
2729 | 0 | break; |
2730 | 0 | case '1': |
2731 | 0 | *magicp = TICOFF1MAGIC; |
2732 | 0 | break; |
2733 | 0 | case '2': |
2734 | 0 | *magicp = TICOFF2MAGIC; |
2735 | 0 | break; |
2736 | 0 | default: |
2737 | 0 | return false; |
2738 | 0 | } |
2739 | 0 | } |
2740 | 0 | TICOFF_TARGET_MACHINE_SET (flagsp, bfd_get_mach (abfd)); |
2741 | 0 | return true; |
2742 | 0 | #endif |
2743 | | |
2744 | | #ifdef AARCH64MAGIC |
2745 | 0 | case bfd_arch_aarch64: |
2746 | 0 | * magicp = AARCH64MAGIC; |
2747 | 0 | return true; |
2748 | 0 | #endif |
2749 | | |
2750 | | #ifdef LOONGARCH64MAGIC |
2751 | 0 | case bfd_arch_loongarch: |
2752 | 0 | * magicp = LOONGARCH64MAGIC; |
2753 | 0 | return true; |
2754 | 0 | #endif |
2755 | | |
2756 | | #ifdef ARMMAGIC |
2757 | 0 | case bfd_arch_arm: |
2758 | | #ifdef ARM_WINCE |
2759 | | * magicp = ARMPEMAGIC; |
2760 | | #else |
2761 | 0 | * magicp = ARMMAGIC; |
2762 | 0 | #endif |
2763 | 0 | * flagsp = 0; |
2764 | 0 | if (APCS_SET (abfd)) |
2765 | 0 | { |
2766 | 0 | if (APCS_26_FLAG (abfd)) |
2767 | 0 | * flagsp |= F_APCS26; |
2768 | | |
2769 | 0 | if (APCS_FLOAT_FLAG (abfd)) |
2770 | 0 | * flagsp |= F_APCS_FLOAT; |
2771 | |
|
2772 | 0 | if (PIC_FLAG (abfd)) |
2773 | 0 | * flagsp |= F_PIC; |
2774 | 0 | } |
2775 | 0 | if (INTERWORK_SET (abfd) && INTERWORK_FLAG (abfd)) |
2776 | 0 | * flagsp |= F_INTERWORK; |
2777 | 0 | switch (bfd_get_mach (abfd)) |
2778 | 0 | { |
2779 | 0 | case bfd_mach_arm_2: * flagsp |= F_ARM_2; break; |
2780 | 0 | case bfd_mach_arm_2a: * flagsp |= F_ARM_2a; break; |
2781 | 0 | case bfd_mach_arm_3: * flagsp |= F_ARM_3; break; |
2782 | 0 | case bfd_mach_arm_3M: * flagsp |= F_ARM_3M; break; |
2783 | 0 | case bfd_mach_arm_4: * flagsp |= F_ARM_4; break; |
2784 | 0 | case bfd_mach_arm_4T: * flagsp |= F_ARM_4T; break; |
2785 | 0 | case bfd_mach_arm_5: * flagsp |= F_ARM_5; break; |
2786 | | /* FIXME: we do not have F_ARM vaues greater than F_ARM_5. |
2787 | | See also the comment in coff_set_arch_mach_hook(). */ |
2788 | 0 | case bfd_mach_arm_5T: * flagsp |= F_ARM_5; break; |
2789 | 0 | case bfd_mach_arm_5TE: * flagsp |= F_ARM_5; break; |
2790 | 0 | case bfd_mach_arm_XScale: * flagsp |= F_ARM_5; break; |
2791 | 0 | } |
2792 | 0 | return true; |
2793 | 0 | #endif |
2794 | | |
2795 | | #if defined(I386MAGIC) || defined(AMD64MAGIC) |
2796 | 0 | case bfd_arch_i386: |
2797 | | #if defined(I386MAGIC) |
2798 | 0 | *magicp = I386MAGIC; |
2799 | | #endif |
2800 | | #if defined LYNXOS |
2801 | | /* Just overwrite the usual value if we're doing Lynx. */ |
2802 | 0 | *magicp = LYNXCOFFMAGIC; |
2803 | | #endif |
2804 | | #if defined AMD64MAGIC |
2805 | 0 | *magicp = AMD64MAGIC; |
2806 | | #endif |
2807 | 0 | return true; |
2808 | 0 | #endif |
2809 | | |
2810 | | #ifdef IA64MAGIC |
2811 | 0 | case bfd_arch_ia64: |
2812 | 0 | *magicp = IA64MAGIC; |
2813 | 0 | return true; |
2814 | 0 | #endif |
2815 | | |
2816 | | #ifdef SH_ARCH_MAGIC_BIG |
2817 | 0 | case bfd_arch_sh: |
2818 | | #ifdef COFF_IMAGE_WITH_PE |
2819 | 0 | *magicp = SH_ARCH_MAGIC_WINCE; |
2820 | | #else |
2821 | 0 | if (bfd_big_endian (abfd)) |
2822 | 0 | *magicp = SH_ARCH_MAGIC_BIG; |
2823 | 0 | else |
2824 | 0 | *magicp = SH_ARCH_MAGIC_LITTLE; |
2825 | | #endif |
2826 | 0 | return true; |
2827 | 0 | #endif |
2828 | | |
2829 | | #ifdef MIPS_ARCH_MAGIC_WINCE |
2830 | | case bfd_arch_mips: |
2831 | | *magicp = MIPS_ARCH_MAGIC_WINCE; |
2832 | | return true; |
2833 | | #endif |
2834 | | |
2835 | | #ifdef SPARCMAGIC |
2836 | | case bfd_arch_sparc: |
2837 | | *magicp = SPARCMAGIC; |
2838 | | #ifdef LYNXOS |
2839 | | /* Just overwrite the usual value if we're doing Lynx. */ |
2840 | | *magicp = LYNXCOFFMAGIC; |
2841 | | #endif |
2842 | | return true; |
2843 | | #endif |
2844 | | |
2845 | | #ifdef RS6000COFF_C |
2846 | 0 | case bfd_arch_rs6000: |
2847 | 0 | case bfd_arch_powerpc: |
2848 | 0 | BFD_ASSERT (bfd_get_flavour (abfd) == bfd_target_xcoff_flavour); |
2849 | 0 | *magicp = bfd_xcoff_magic_number (abfd); |
2850 | 0 | return true; |
2851 | 0 | #endif |
2852 | | |
2853 | | #ifdef MCOREMAGIC |
2854 | 0 | case bfd_arch_mcore: |
2855 | 0 | * magicp = MCOREMAGIC; |
2856 | 0 | return true; |
2857 | 0 | #endif |
2858 | | |
2859 | 0 | default: /* Unknown architecture. */ |
2860 | 0 | break; |
2861 | 0 | } |
2862 | | |
2863 | 0 | return false; |
2864 | 0 | } Unexecuted instantiation: pei-i386.c:coff_set_flags Unexecuted instantiation: pe-x86_64.c:coff_set_flags Unexecuted instantiation: pei-x86_64.c:coff_set_flags Unexecuted instantiation: coff-x86_64.c:coff_set_flags Unexecuted instantiation: coff64-rs6000.c:coff_set_flags Unexecuted instantiation: pei-aarch64.c:coff_set_flags Unexecuted instantiation: pe-aarch64.c:coff_set_flags Unexecuted instantiation: pei-ia64.c:coff_set_flags Unexecuted instantiation: pei-loongarch64.c:coff_set_flags Unexecuted instantiation: cf-i386lynx.c:coff_set_flags Unexecuted instantiation: coff-go32.c:coff_set_flags Unexecuted instantiation: coff-i386.c:coff_set_flags Unexecuted instantiation: coff-rs6000.c:coff_set_flags Unexecuted instantiation: coff-sh.c:coff_set_flags Unexecuted instantiation: coff-stgo32.c:coff_set_flags Unexecuted instantiation: coff-tic30.c:coff_set_flags Unexecuted instantiation: coff-tic4x.c:coff_set_flags Unexecuted instantiation: coff-tic54x.c:coff_set_flags Unexecuted instantiation: coff-z80.c:coff_set_flags Unexecuted instantiation: coff-z8k.c:coff_set_flags Unexecuted instantiation: pe-arm-wince.c:coff_set_flags Unexecuted instantiation: pe-arm.c:coff_set_flags Unexecuted instantiation: pe-i386.c:coff_set_flags Unexecuted instantiation: pe-mcore.c:coff_set_flags Unexecuted instantiation: pe-sh.c:coff_set_flags Unexecuted instantiation: pei-arm-wince.c:coff_set_flags Unexecuted instantiation: pei-arm.c:coff_set_flags Unexecuted instantiation: pei-mcore.c:coff_set_flags Unexecuted instantiation: pei-sh.c:coff_set_flags |
2865 | | |
2866 | | static bool |
2867 | | coff_set_arch_mach (bfd * abfd, |
2868 | | enum bfd_architecture arch, |
2869 | | unsigned long machine) |
2870 | 0 | { |
2871 | 0 | unsigned dummy1; |
2872 | 0 | unsigned short dummy2; |
2873 | |
|
2874 | 0 | if (! bfd_default_set_arch_mach (abfd, arch, machine)) |
2875 | 0 | return false; |
2876 | | |
2877 | 0 | if (arch != bfd_arch_unknown |
2878 | 0 | && ! coff_set_flags (abfd, &dummy1, &dummy2)) |
2879 | 0 | return false; /* We can't represent this type. */ |
2880 | | |
2881 | 0 | return true; /* We're easy... */ |
2882 | 0 | } Unexecuted instantiation: pei-i386.c:coff_set_arch_mach Unexecuted instantiation: pe-x86_64.c:coff_set_arch_mach Unexecuted instantiation: pei-x86_64.c:coff_set_arch_mach Unexecuted instantiation: coff-x86_64.c:coff_set_arch_mach Unexecuted instantiation: coff64-rs6000.c:coff_set_arch_mach Unexecuted instantiation: pei-aarch64.c:coff_set_arch_mach Unexecuted instantiation: pe-aarch64.c:coff_set_arch_mach Unexecuted instantiation: pei-ia64.c:coff_set_arch_mach Unexecuted instantiation: pei-loongarch64.c:coff_set_arch_mach Unexecuted instantiation: cf-i386lynx.c:coff_set_arch_mach Unexecuted instantiation: coff-go32.c:coff_set_arch_mach Unexecuted instantiation: coff-i386.c:coff_set_arch_mach Unexecuted instantiation: coff-rs6000.c:coff_set_arch_mach Unexecuted instantiation: coff-sh.c:coff_set_arch_mach Unexecuted instantiation: coff-stgo32.c:coff_set_arch_mach Unexecuted instantiation: coff-tic30.c:coff_set_arch_mach Unexecuted instantiation: coff-tic4x.c:coff_set_arch_mach Unexecuted instantiation: coff-tic54x.c:coff_set_arch_mach Unexecuted instantiation: coff-z80.c:coff_set_arch_mach Unexecuted instantiation: coff-z8k.c:coff_set_arch_mach Unexecuted instantiation: pe-arm-wince.c:coff_set_arch_mach Unexecuted instantiation: pe-arm.c:coff_set_arch_mach Unexecuted instantiation: pe-i386.c:coff_set_arch_mach Unexecuted instantiation: pe-mcore.c:coff_set_arch_mach Unexecuted instantiation: pe-sh.c:coff_set_arch_mach Unexecuted instantiation: pei-arm-wince.c:coff_set_arch_mach Unexecuted instantiation: pei-arm.c:coff_set_arch_mach Unexecuted instantiation: pei-mcore.c:coff_set_arch_mach Unexecuted instantiation: pei-sh.c:coff_set_arch_mach |
2883 | | |
2884 | | #ifdef COFF_IMAGE_WITH_PE |
2885 | | |
2886 | | /* This is used to sort sections by VMA, as required by PE image |
2887 | | files. */ |
2888 | | |
2889 | | static int |
2890 | | sort_by_secaddr (const void * arg1, const void * arg2) |
2891 | 0 | { |
2892 | 0 | const asection *a = *(const asection **) arg1; |
2893 | 0 | const asection *b = *(const asection **) arg2; |
2894 | |
|
2895 | 0 | if (a->vma < b->vma) |
2896 | 0 | return -1; |
2897 | 0 | else if (a->vma > b->vma) |
2898 | 0 | return 1; |
2899 | | |
2900 | 0 | return 0; |
2901 | 0 | } Unexecuted instantiation: pei-i386.c:sort_by_secaddr Unexecuted instantiation: pei-x86_64.c:sort_by_secaddr Unexecuted instantiation: pei-aarch64.c:sort_by_secaddr Unexecuted instantiation: pei-ia64.c:sort_by_secaddr Unexecuted instantiation: pei-loongarch64.c:sort_by_secaddr Unexecuted instantiation: pei-arm-wince.c:sort_by_secaddr Unexecuted instantiation: pei-arm.c:sort_by_secaddr Unexecuted instantiation: pei-mcore.c:sort_by_secaddr Unexecuted instantiation: pei-sh.c:sort_by_secaddr |
2902 | | |
2903 | | #endif /* COFF_IMAGE_WITH_PE */ |
2904 | | |
2905 | | /* Calculate the file position for each section. */ |
2906 | | |
2907 | | #define ALIGN_SECTIONS_IN_FILE |
2908 | | #ifdef TICOFF |
2909 | | #undef ALIGN_SECTIONS_IN_FILE |
2910 | | #endif |
2911 | | |
2912 | | static bool |
2913 | | coff_compute_section_file_positions (bfd * abfd) |
2914 | 0 | { |
2915 | 0 | asection *current; |
2916 | 0 | file_ptr sofar = bfd_coff_filhsz (abfd); |
2917 | 0 | bool align_adjust; |
2918 | 0 | unsigned int target_index; |
2919 | | #ifdef ALIGN_SECTIONS_IN_FILE |
2920 | | asection *previous = NULL; |
2921 | | file_ptr old_sofar; |
2922 | | #endif |
2923 | |
|
2924 | | #ifdef COFF_IMAGE_WITH_PE |
2925 | | unsigned int page_size; |
2926 | | |
2927 | 0 | if (coff_data (abfd)->link_info |
2928 | 0 | || (pe_data (abfd) && pe_data (abfd)->pe_opthdr.FileAlignment)) |
2929 | 0 | { |
2930 | 0 | page_size = pe_data (abfd)->pe_opthdr.FileAlignment; |
2931 | | |
2932 | | /* If no file alignment has been set, default to one. |
2933 | | This repairs 'ld -r' for arm-wince-pe target. */ |
2934 | 0 | if (page_size == 0) |
2935 | 0 | page_size = 1; |
2936 | 0 | } |
2937 | 0 | else |
2938 | 0 | page_size = PE_DEF_FILE_ALIGNMENT; |
2939 | | #else |
2940 | | #ifdef COFF_PAGE_SIZE |
2941 | 0 | unsigned int page_size = COFF_PAGE_SIZE; |
2942 | | #endif |
2943 | | #endif |
2944 | |
|
2945 | | #ifdef RS6000COFF_C |
2946 | | /* On XCOFF, if we have symbols, set up the .debug section. */ |
2947 | 0 | if (bfd_get_symcount (abfd) > 0) |
2948 | 0 | { |
2949 | 0 | bfd_size_type sz; |
2950 | 0 | bfd_size_type i, symcount; |
2951 | 0 | asymbol **symp; |
2952 | | |
2953 | | sz = 0; |
2954 | | symcount = bfd_get_symcount (abfd); |
2955 | 0 | for (symp = abfd->outsymbols, i = 0; i < symcount; symp++, i++) |
2956 | 0 | { |
2957 | 0 | coff_symbol_type *cf; |
2958 | |
|
2959 | 0 | cf = coff_symbol_from (*symp); |
2960 | 0 | if (cf != NULL |
2961 | 0 | && cf->native != NULL |
2962 | 0 | && cf->native->is_sym |
2963 | 0 | && SYMNAME_IN_DEBUG (&cf->native->u.syment)) |
2964 | 0 | { |
2965 | 0 | size_t len; |
2966 | |
|
2967 | 0 | len = strlen (bfd_asymbol_name (*symp)); |
2968 | 0 | if (len > SYMNMLEN || bfd_coff_force_symnames_in_strings (abfd)) |
2969 | 0 | sz += len + 1 + bfd_coff_debug_string_prefix_length (abfd); |
2970 | 0 | } |
2971 | 0 | } |
2972 | 0 | if (sz > 0) |
2973 | 0 | { |
2974 | 0 | asection *dsec; |
2975 | |
|
2976 | 0 | dsec = bfd_make_section_old_way (abfd, DOT_DEBUG); |
2977 | 0 | if (dsec == NULL) |
2978 | 0 | abort (); |
2979 | 0 | dsec->size = sz; |
2980 | 0 | dsec->flags |= SEC_HAS_CONTENTS; |
2981 | 0 | } |
2982 | 0 | } |
2983 | 0 | #endif |
2984 | | |
2985 | 0 | if (bfd_get_start_address (abfd)) |
2986 | | /* A start address may have been added to the original file. In this |
2987 | | case it will need an optional header to record it. */ |
2988 | 0 | abfd->flags |= EXEC_P; |
2989 | |
|
2990 | 0 | if (abfd->flags & EXEC_P) |
2991 | 0 | sofar += bfd_coff_aoutsz (abfd); |
2992 | | #ifdef RS6000COFF_C |
2993 | 0 | else if (xcoff_data (abfd)->full_aouthdr) |
2994 | 0 | sofar += bfd_coff_aoutsz (abfd); |
2995 | 0 | else |
2996 | 0 | sofar += SMALL_AOUTSZ; |
2997 | | #endif |
2998 | |
|
2999 | 0 | sofar += abfd->section_count * bfd_coff_scnhsz (abfd); |
3000 | |
|
3001 | | #ifdef RS6000COFF_C |
3002 | | /* XCOFF handles overflows in the reloc and line number count fields |
3003 | | by allocating a new section header to hold the correct counts. */ |
3004 | 0 | for (current = abfd->sections; current != NULL; current = current->next) |
3005 | 0 | if (current->reloc_count >= 0xffff || current->lineno_count >= 0xffff) |
3006 | 0 | sofar += bfd_coff_scnhsz (abfd); |
3007 | | #endif |
3008 | |
|
3009 | 0 | if (coff_data (abfd)->section_by_target_index) |
3010 | 0 | htab_empty (coff_data (abfd)->section_by_target_index); |
3011 | |
|
3012 | | #ifdef COFF_IMAGE_WITH_PE |
3013 | | { |
3014 | | /* PE requires the sections to be in memory order when listed in |
3015 | | the section headers. It also does not like empty loadable |
3016 | | sections. The sections apparently do not have to be in the |
3017 | | right order in the image file itself, but we do need to get the |
3018 | | target_index values right. */ |
3019 | | |
3020 | | unsigned int count; |
3021 | | asection **section_list; |
3022 | | unsigned int i; |
3023 | | bfd_size_type amt; |
3024 | | |
3025 | | #ifdef COFF_PAGE_SIZE |
3026 | | /* Clear D_PAGED if section / file alignment aren't suitable for |
3027 | | paging at COFF_PAGE_SIZE granularity. */ |
3028 | 0 | if (pe_data (abfd)->pe_opthdr.SectionAlignment < COFF_PAGE_SIZE |
3029 | 0 | || page_size < COFF_PAGE_SIZE) |
3030 | 0 | abfd->flags &= ~D_PAGED; |
3031 | | #endif |
3032 | | |
3033 | | count = 0; |
3034 | 0 | for (current = abfd->sections; current != NULL; current = current->next) |
3035 | 0 | ++count; |
3036 | | |
3037 | | /* We allocate an extra cell to simplify the final loop. */ |
3038 | | amt = sizeof (struct asection *) * (count + 1); |
3039 | | section_list = (asection **) bfd_malloc (amt); |
3040 | 0 | if (section_list == NULL) |
3041 | 0 | return false; |
3042 | | |
3043 | 0 | i = 0; |
3044 | 0 | for (current = abfd->sections; current != NULL; current = current->next) |
3045 | 0 | { |
3046 | 0 | section_list[i] = current; |
3047 | 0 | ++i; |
3048 | 0 | } |
3049 | 0 | section_list[i] = NULL; |
3050 | |
|
3051 | 0 | qsort (section_list, count, sizeof (asection *), sort_by_secaddr); |
3052 | | |
3053 | | /* Rethread the linked list into sorted order; at the same time, |
3054 | | assign target_index values. */ |
3055 | 0 | target_index = 1; |
3056 | 0 | abfd->sections = NULL; |
3057 | 0 | abfd->section_last = NULL; |
3058 | 0 | for (i = 0; i < count; i++) |
3059 | 0 | { |
3060 | 0 | current = section_list[i]; |
3061 | 0 | bfd_section_list_append (abfd, current); |
3062 | | |
3063 | | /* Later, if the section has zero size, we'll be throwing it |
3064 | | away, so we don't want to number it now. Note that having |
3065 | | a zero size and having real contents are different |
3066 | | concepts: .bss has no contents, but (usually) non-zero |
3067 | | size. */ |
3068 | 0 | if (current->size == 0) |
3069 | 0 | { |
3070 | | /* Discard. However, it still might have (valid) symbols |
3071 | | in it, so arbitrarily set it to section 1 (indexing is |
3072 | | 1-based here; usually .text). __end__ and other |
3073 | | contents of .endsection really have this happen. |
3074 | | FIXME: This seems somewhat dubious. */ |
3075 | 0 | current->target_index = 1; |
3076 | 0 | } |
3077 | 0 | else |
3078 | 0 | current->target_index = target_index++; |
3079 | 0 | } |
3080 | |
|
3081 | 0 | free (section_list); |
3082 | 0 | } |
3083 | | #else /* ! COFF_IMAGE_WITH_PE */ |
3084 | | { |
3085 | | /* Set the target_index field. */ |
3086 | | target_index = 1; |
3087 | 0 | for (current = abfd->sections; current != NULL; current = current->next) |
3088 | 0 | current->target_index = target_index++; |
3089 | | } |
3090 | | #endif /* ! COFF_IMAGE_WITH_PE */ |
3091 | | |
3092 | 0 | if (target_index >= bfd_coff_max_nscns (abfd)) |
3093 | 0 | { |
3094 | 0 | bfd_set_error (bfd_error_file_too_big); |
3095 | 0 | _bfd_error_handler |
3096 | | /* xgettext:c-format */ |
3097 | 0 | (_("%pB: too many sections (%d)"), abfd, target_index); |
3098 | 0 | return false; |
3099 | 0 | } |
3100 | | |
3101 | 0 | align_adjust = false; |
3102 | 0 | for (current = abfd->sections; |
3103 | 0 | current != NULL; |
3104 | 0 | current = current->next) |
3105 | 0 | { |
3106 | | #ifdef COFF_IMAGE_WITH_PE |
3107 | | /* With PE we have to pad each section to be a multiple of its |
3108 | | page size too, and remember both sizes. */ |
3109 | 0 | if (coff_section_data (abfd, current) == NULL) |
3110 | 0 | { |
3111 | 0 | size_t amt = sizeof (struct coff_section_tdata); |
3112 | | |
3113 | | current->used_by_bfd = bfd_zalloc (abfd, amt); |
3114 | 0 | if (current->used_by_bfd == NULL) |
3115 | 0 | return false; |
3116 | 0 | } |
3117 | 0 | if (pei_section_data (abfd, current) == NULL) |
3118 | 0 | { |
3119 | 0 | size_t amt = sizeof (struct pei_section_tdata); |
3120 | |
|
3121 | 0 | coff_section_data (abfd, current)->tdata = bfd_zalloc (abfd, amt); |
3122 | 0 | if (coff_section_data (abfd, current)->tdata == NULL) |
3123 | 0 | return false; |
3124 | 0 | } |
3125 | 0 | if (pei_section_data (abfd, current)->virt_size == 0) |
3126 | 0 | pei_section_data (abfd, current)->virt_size = current->size; |
3127 | 0 | #endif |
3128 | | |
3129 | | /* Only deal with sections which have contents. */ |
3130 | 0 | if (!(current->flags & SEC_HAS_CONTENTS)) |
3131 | 0 | continue; |
3132 | | |
3133 | 0 | current->rawsize = current->size; |
3134 | |
|
3135 | | #ifdef COFF_IMAGE_WITH_PE |
3136 | | /* Make sure we skip empty sections in a PE image. */ |
3137 | 0 | if (current->size == 0) |
3138 | 0 | continue; |
3139 | 0 | #endif |
3140 | | |
3141 | | /* Align the sections in the file to the same boundary on |
3142 | | which they are aligned in virtual memory. */ |
3143 | | #ifdef ALIGN_SECTIONS_IN_FILE |
3144 | 0 | if ((abfd->flags & EXEC_P) != 0) |
3145 | 0 | { |
3146 | | /* Make sure this section is aligned on the right boundary - by |
3147 | | padding the previous section up if necessary. */ |
3148 | 0 | old_sofar = sofar; |
3149 | |
|
3150 | | #ifdef COFF_IMAGE_WITH_PE |
3151 | 0 | sofar = BFD_ALIGN (sofar, page_size); |
3152 | | #else |
3153 | 0 | sofar = BFD_ALIGN (sofar, (bfd_vma) 1 << current->alignment_power); |
3154 | | #endif |
3155 | |
|
3156 | | #ifdef RS6000COFF_C |
3157 | | /* Make sure the file offset and the vma of .text/.data are at the |
3158 | | same page offset, so that the file can be mmap'ed without being |
3159 | | relocated. Failing that, AIX is able to load and execute the |
3160 | | program, but it will be silently relocated (possible as |
3161 | | executables are PIE). But the relocation is slightly costly and |
3162 | | complexify the use of addr2line or gdb. So better to avoid it, |
3163 | | like does the native linker. Usually gnu ld makes sure that |
3164 | | the vma of .text is the file offset so this issue shouldn't |
3165 | | appear unless you are stripping such an executable. |
3166 | | |
3167 | | AIX loader checks the text section alignment of (vma - filepos), |
3168 | | and the native linker doesn't try to align the text sections. |
3169 | | For example: |
3170 | | |
3171 | | 0 .text 000054cc 10000128 10000128 00000128 2**5 |
3172 | | CONTENTS, ALLOC, LOAD, CODE |
3173 | | |
3174 | | Don't perform the above tweak if the previous one is .tdata, |
3175 | | as it will increase the memory allocated for every threads |
3176 | | created and not just improve performances with gdb. |
3177 | | */ |
3178 | | |
3179 | 0 | if ((!strcmp (current->name, _TEXT) |
3180 | 0 | || !strcmp (current->name, _DATA)) |
3181 | 0 | && (previous == NULL || strcmp(previous->name, _TDATA))) |
3182 | 0 | { |
3183 | 0 | bfd_vma align = 4096; |
3184 | 0 | bfd_vma sofar_off = sofar % align; |
3185 | 0 | bfd_vma vma_off = current->vma % align; |
3186 | |
|
3187 | 0 | if (vma_off > sofar_off) |
3188 | 0 | sofar += vma_off - sofar_off; |
3189 | 0 | else if (vma_off < sofar_off) |
3190 | 0 | sofar += align + vma_off - sofar_off; |
3191 | 0 | } |
3192 | | #endif |
3193 | 0 | if (previous != NULL) |
3194 | 0 | previous->size += sofar - old_sofar; |
3195 | 0 | } |
3196 | |
|
3197 | 0 | #endif |
3198 | | |
3199 | | /* In demand paged files the low order bits of the file offset |
3200 | | must match the low order bits of the virtual address. */ |
3201 | | #ifdef COFF_PAGE_SIZE |
3202 | 0 | if ((abfd->flags & D_PAGED) != 0 |
3203 | 0 | && (current->flags & SEC_ALLOC) != 0) |
3204 | 0 | sofar += (current->vma - (bfd_vma) sofar) % page_size; |
3205 | | #endif |
3206 | 0 | current->filepos = sofar; |
3207 | |
|
3208 | | #ifdef COFF_IMAGE_WITH_PE |
3209 | | /* Set the padded size. */ |
3210 | | current->size = (current->size + page_size - 1) & -page_size; |
3211 | | #endif |
3212 | |
|
3213 | 0 | sofar += current->size; |
3214 | |
|
3215 | | #ifdef ALIGN_SECTIONS_IN_FILE |
3216 | | /* Make sure that this section is of the right size too. */ |
3217 | 0 | if ((abfd->flags & EXEC_P) == 0) |
3218 | 0 | { |
3219 | 0 | bfd_size_type old_size; |
3220 | |
|
3221 | 0 | old_size = current->size; |
3222 | 0 | current->size = BFD_ALIGN (current->size, |
3223 | 0 | (bfd_vma) 1 << current->alignment_power); |
3224 | 0 | align_adjust = current->size != old_size; |
3225 | 0 | sofar += current->size - old_size; |
3226 | 0 | } |
3227 | 0 | else |
3228 | 0 | { |
3229 | 0 | old_sofar = sofar; |
3230 | | #ifdef COFF_IMAGE_WITH_PE |
3231 | 0 | sofar = BFD_ALIGN (sofar, page_size); |
3232 | | #else |
3233 | 0 | sofar = BFD_ALIGN (sofar, (bfd_vma) 1 << current->alignment_power); |
3234 | | #endif |
3235 | 0 | align_adjust = sofar != old_sofar; |
3236 | 0 | current->size += sofar - old_sofar; |
3237 | 0 | } |
3238 | | #endif |
3239 | |
|
3240 | | #ifdef COFF_IMAGE_WITH_PE |
3241 | | /* For PE we need to make sure we pad out to the aligned |
3242 | | size, in case the caller only writes out data to the |
3243 | | unaligned size. */ |
3244 | 0 | if (pei_section_data (abfd, current)->virt_size < current->size) |
3245 | 0 | align_adjust = true; |
3246 | | #endif |
3247 | |
|
3248 | | #ifdef _LIB |
3249 | | /* Force .lib sections to start at zero. The vma is then |
3250 | | incremented in coff_set_section_contents. This is right for |
3251 | | SVR3.2. */ |
3252 | 0 | if (strcmp (current->name, _LIB) == 0) |
3253 | 0 | bfd_set_section_vma (current, 0); |
3254 | | #endif |
3255 | |
|
3256 | | #ifdef ALIGN_SECTIONS_IN_FILE |
3257 | | previous = current; |
3258 | | #endif |
3259 | 0 | } |
3260 | | |
3261 | | /* It is now safe to write to the output file. If we needed an |
3262 | | alignment adjustment for the last section, then make sure that |
3263 | | there is a byte at offset sofar. If there are no symbols and no |
3264 | | relocs, then nothing follows the last section. If we don't force |
3265 | | the last byte out, then the file may appear to be truncated. */ |
3266 | 0 | if (align_adjust) |
3267 | 0 | { |
3268 | 0 | bfd_byte b; |
3269 | |
|
3270 | 0 | b = 0; |
3271 | 0 | if (bfd_seek (abfd, sofar - 1, SEEK_SET) != 0 |
3272 | 0 | || bfd_bwrite (&b, (bfd_size_type) 1, abfd) != 1) |
3273 | 0 | return false; |
3274 | 0 | } |
3275 | | |
3276 | | /* Make sure the relocations are aligned. We don't need to make |
3277 | | sure that this byte exists, because it will only matter if there |
3278 | | really are relocs. */ |
3279 | 0 | sofar = BFD_ALIGN (sofar, |
3280 | 0 | (bfd_vma) 1 << COFF_DEFAULT_SECTION_ALIGNMENT_POWER); |
3281 | |
|
3282 | 0 | obj_relocbase (abfd) = sofar; |
3283 | 0 | abfd->output_has_begun = true; |
3284 | |
|
3285 | 0 | return true; |
3286 | 0 | } Unexecuted instantiation: pei-i386.c:coff_compute_section_file_positions Unexecuted instantiation: pe-x86_64.c:coff_compute_section_file_positions Unexecuted instantiation: pei-x86_64.c:coff_compute_section_file_positions Unexecuted instantiation: coff-x86_64.c:coff_compute_section_file_positions Unexecuted instantiation: coff64-rs6000.c:coff_compute_section_file_positions Unexecuted instantiation: pei-aarch64.c:coff_compute_section_file_positions Unexecuted instantiation: pe-aarch64.c:coff_compute_section_file_positions Unexecuted instantiation: pei-ia64.c:coff_compute_section_file_positions Unexecuted instantiation: pei-loongarch64.c:coff_compute_section_file_positions Unexecuted instantiation: cf-i386lynx.c:coff_compute_section_file_positions Unexecuted instantiation: coff-go32.c:coff_compute_section_file_positions Unexecuted instantiation: coff-i386.c:coff_compute_section_file_positions Unexecuted instantiation: coff-rs6000.c:coff_compute_section_file_positions Unexecuted instantiation: coff-sh.c:coff_compute_section_file_positions Unexecuted instantiation: coff-stgo32.c:coff_compute_section_file_positions Unexecuted instantiation: coff-tic30.c:coff_compute_section_file_positions Unexecuted instantiation: coff-tic4x.c:coff_compute_section_file_positions Unexecuted instantiation: coff-tic54x.c:coff_compute_section_file_positions Unexecuted instantiation: coff-z80.c:coff_compute_section_file_positions Unexecuted instantiation: coff-z8k.c:coff_compute_section_file_positions Unexecuted instantiation: pe-arm-wince.c:coff_compute_section_file_positions Unexecuted instantiation: pe-arm.c:coff_compute_section_file_positions Unexecuted instantiation: pe-i386.c:coff_compute_section_file_positions Unexecuted instantiation: pe-mcore.c:coff_compute_section_file_positions Unexecuted instantiation: pe-sh.c:coff_compute_section_file_positions Unexecuted instantiation: pei-arm-wince.c:coff_compute_section_file_positions Unexecuted instantiation: pei-arm.c:coff_compute_section_file_positions Unexecuted instantiation: pei-mcore.c:coff_compute_section_file_positions Unexecuted instantiation: pei-sh.c:coff_compute_section_file_positions |
3287 | | |
3288 | | #ifdef COFF_IMAGE_WITH_PE |
3289 | | |
3290 | | static bool |
3291 | | coff_read_word (bfd *abfd, unsigned int *value, unsigned int *pelength) |
3292 | 0 | { |
3293 | 0 | unsigned char b[2]; |
3294 | 0 | int status; |
3295 | |
|
3296 | 0 | status = bfd_bread (b, (bfd_size_type) 2, abfd); |
3297 | 0 | if (status < 1) |
3298 | 0 | { |
3299 | 0 | *value = 0; |
3300 | 0 | return false; |
3301 | 0 | } |
3302 | | |
3303 | 0 | if (status == 1) |
3304 | 0 | *value = (unsigned int) b[0]; |
3305 | 0 | else |
3306 | 0 | *value = (unsigned int) (b[0] + (b[1] << 8)); |
3307 | |
|
3308 | 0 | *pelength += status; |
3309 | |
|
3310 | 0 | return true; |
3311 | 0 | } Unexecuted instantiation: pei-i386.c:coff_read_word Unexecuted instantiation: pei-x86_64.c:coff_read_word Unexecuted instantiation: pei-aarch64.c:coff_read_word Unexecuted instantiation: pei-ia64.c:coff_read_word Unexecuted instantiation: pei-loongarch64.c:coff_read_word Unexecuted instantiation: pei-arm-wince.c:coff_read_word Unexecuted instantiation: pei-arm.c:coff_read_word Unexecuted instantiation: pei-mcore.c:coff_read_word Unexecuted instantiation: pei-sh.c:coff_read_word |
3312 | | |
3313 | | /* Read a two byte number from buffer B returning the result in VALUE. |
3314 | | No more than BUF_SIZE bytes will be read. |
3315 | | Returns true upobn success, false otherwise. |
3316 | | If successful, increases the value stored in PELENGTH by the number |
3317 | | of bytes read. */ |
3318 | | |
3319 | | static bool |
3320 | | coff_read_word_from_buffer (unsigned char * b, |
3321 | | int buf_size, |
3322 | | unsigned int * value, |
3323 | | unsigned int * pelength) |
3324 | 0 | { |
3325 | 0 | if (buf_size < 1) |
3326 | 0 | { |
3327 | 0 | *value = 0; |
3328 | 0 | return false; |
3329 | 0 | } |
3330 | | |
3331 | 0 | if (buf_size == 1) |
3332 | 0 | { |
3333 | 0 | *value = (unsigned int)b[0]; |
3334 | 0 | *pelength += 1; |
3335 | 0 | } |
3336 | 0 | else |
3337 | 0 | { |
3338 | 0 | *value = (unsigned int)(b[0] + (b[1] << 8)); |
3339 | 0 | *pelength += 2; |
3340 | 0 | } |
3341 | |
|
3342 | 0 | return true; |
3343 | 0 | } Unexecuted instantiation: pei-i386.c:coff_read_word_from_buffer Unexecuted instantiation: pei-x86_64.c:coff_read_word_from_buffer Unexecuted instantiation: pei-aarch64.c:coff_read_word_from_buffer Unexecuted instantiation: pei-ia64.c:coff_read_word_from_buffer Unexecuted instantiation: pei-loongarch64.c:coff_read_word_from_buffer Unexecuted instantiation: pei-arm-wince.c:coff_read_word_from_buffer Unexecuted instantiation: pei-arm.c:coff_read_word_from_buffer Unexecuted instantiation: pei-mcore.c:coff_read_word_from_buffer Unexecuted instantiation: pei-sh.c:coff_read_word_from_buffer |
3344 | | |
3345 | 0 | #define COFF_CHECKSUM_BUFFER_SIZE 0x800000 |
3346 | | |
3347 | | static unsigned int |
3348 | | coff_compute_checksum (bfd *abfd, unsigned int *pelength) |
3349 | 0 | { |
3350 | 0 | file_ptr filepos; |
3351 | 0 | unsigned int value; |
3352 | 0 | unsigned int total; |
3353 | 0 | unsigned char *buf; |
3354 | 0 | int buf_size; |
3355 | |
|
3356 | 0 | total = 0; |
3357 | 0 | *pelength = 0; |
3358 | 0 | filepos = (file_ptr) 0; |
3359 | 0 | buf = (unsigned char *) bfd_malloc (COFF_CHECKSUM_BUFFER_SIZE); |
3360 | 0 | if (buf == NULL) |
3361 | 0 | return 0; |
3362 | 0 | buf_size = 0; |
3363 | |
|
3364 | 0 | do |
3365 | 0 | { |
3366 | 0 | unsigned char *cur_buf; |
3367 | 0 | int cur_buf_size; |
3368 | |
|
3369 | 0 | if (bfd_seek (abfd, filepos, SEEK_SET) != 0) |
3370 | 0 | return 0; |
3371 | | |
3372 | 0 | buf_size = bfd_bread (buf, COFF_CHECKSUM_BUFFER_SIZE, abfd); |
3373 | 0 | cur_buf_size = buf_size; |
3374 | 0 | cur_buf = buf; |
3375 | |
|
3376 | 0 | while (cur_buf_size > 0) |
3377 | 0 | { |
3378 | 0 | coff_read_word_from_buffer (cur_buf, cur_buf_size, &value, pelength); |
3379 | 0 | cur_buf += 2; |
3380 | 0 | cur_buf_size -= 2; |
3381 | 0 | total += value; |
3382 | 0 | total = 0xffff & (total + (total >> 0x10)); |
3383 | 0 | } |
3384 | |
|
3385 | 0 | filepos += buf_size; |
3386 | 0 | } |
3387 | 0 | while (buf_size > 0); |
3388 | | |
3389 | 0 | free (buf); |
3390 | |
|
3391 | 0 | return (0xffff & (total + (total >> 0x10))); |
3392 | 0 | } Unexecuted instantiation: pei-i386.c:coff_compute_checksum Unexecuted instantiation: pei-x86_64.c:coff_compute_checksum Unexecuted instantiation: pei-aarch64.c:coff_compute_checksum Unexecuted instantiation: pei-ia64.c:coff_compute_checksum Unexecuted instantiation: pei-loongarch64.c:coff_compute_checksum Unexecuted instantiation: pei-arm-wince.c:coff_compute_checksum Unexecuted instantiation: pei-arm.c:coff_compute_checksum Unexecuted instantiation: pei-mcore.c:coff_compute_checksum Unexecuted instantiation: pei-sh.c:coff_compute_checksum |
3393 | | |
3394 | | static bool |
3395 | | coff_apply_checksum (bfd *abfd) |
3396 | 0 | { |
3397 | 0 | unsigned int computed; |
3398 | 0 | unsigned int checksum = 0; |
3399 | 0 | unsigned int peheader; |
3400 | 0 | unsigned int pelength; |
3401 | |
|
3402 | 0 | if (bfd_seek (abfd, 0x3c, SEEK_SET) != 0) |
3403 | 0 | return false; |
3404 | | |
3405 | 0 | if (!coff_read_word (abfd, &peheader, &pelength)) |
3406 | 0 | return false; |
3407 | | |
3408 | 0 | if (bfd_seek (abfd, peheader + 0x58, SEEK_SET) != 0) |
3409 | 0 | return false; |
3410 | | |
3411 | 0 | checksum = 0; |
3412 | 0 | bfd_bwrite (&checksum, (bfd_size_type) 4, abfd); |
3413 | |
|
3414 | 0 | if (bfd_seek (abfd, peheader, SEEK_SET) != 0) |
3415 | 0 | return false; |
3416 | | |
3417 | 0 | computed = coff_compute_checksum (abfd, &pelength); |
3418 | |
|
3419 | 0 | checksum = computed + pelength; |
3420 | |
|
3421 | 0 | if (bfd_seek (abfd, peheader + 0x58, SEEK_SET) != 0) |
3422 | 0 | return false; |
3423 | | |
3424 | 0 | bfd_bwrite (&checksum, (bfd_size_type) 4, abfd); |
3425 | |
|
3426 | 0 | return true; |
3427 | 0 | } Unexecuted instantiation: pei-i386.c:coff_apply_checksum Unexecuted instantiation: pei-x86_64.c:coff_apply_checksum Unexecuted instantiation: pei-aarch64.c:coff_apply_checksum Unexecuted instantiation: pei-ia64.c:coff_apply_checksum Unexecuted instantiation: pei-loongarch64.c:coff_apply_checksum Unexecuted instantiation: pei-arm-wince.c:coff_apply_checksum Unexecuted instantiation: pei-arm.c:coff_apply_checksum Unexecuted instantiation: pei-mcore.c:coff_apply_checksum Unexecuted instantiation: pei-sh.c:coff_apply_checksum |
3428 | | |
3429 | | #endif /* COFF_IMAGE_WITH_PE */ |
3430 | | |
3431 | | static bool |
3432 | | coff_write_object_contents (bfd * abfd) |
3433 | 0 | { |
3434 | 0 | asection *current; |
3435 | 0 | bool hasrelocs = false; |
3436 | 0 | bool haslinno = false; |
3437 | | #ifdef COFF_IMAGE_WITH_PE |
3438 | | bool hasdebug = false; |
3439 | | #endif |
3440 | 0 | file_ptr scn_base; |
3441 | 0 | file_ptr reloc_base; |
3442 | 0 | file_ptr lineno_base; |
3443 | 0 | file_ptr sym_base; |
3444 | 0 | unsigned long reloc_size = 0, reloc_count = 0; |
3445 | 0 | unsigned long lnno_size = 0; |
3446 | 0 | bool long_section_names; |
3447 | 0 | asection *text_sec = NULL; |
3448 | 0 | asection *data_sec = NULL; |
3449 | 0 | asection *bss_sec = NULL; |
3450 | | #ifdef RS6000COFF_C |
3451 | | asection *tdata_sec = NULL; |
3452 | | asection *tbss_sec = NULL; |
3453 | | #endif |
3454 | 0 | struct internal_filehdr internal_f; |
3455 | 0 | struct internal_aouthdr internal_a; |
3456 | | #ifdef COFF_LONG_SECTION_NAMES |
3457 | 0 | size_t string_size = STRING_SIZE_SIZE; |
3458 | | #endif |
3459 | |
|
3460 | 0 | bfd_set_error (bfd_error_system_call); |
3461 | | |
3462 | | /* Make a pass through the symbol table to count line number entries and |
3463 | | put them into the correct asections. */ |
3464 | 0 | lnno_size = coff_count_linenumbers (abfd) * bfd_coff_linesz (abfd); |
3465 | |
|
3466 | 0 | if (! abfd->output_has_begun) |
3467 | 0 | { |
3468 | 0 | if (! coff_compute_section_file_positions (abfd)) |
3469 | 0 | return false; |
3470 | 0 | } |
3471 | | |
3472 | 0 | reloc_base = obj_relocbase (abfd); |
3473 | | |
3474 | | /* Work out the size of the reloc and linno areas. */ |
3475 | |
|
3476 | 0 | for (current = abfd->sections; current != NULL; current = |
3477 | 0 | current->next) |
3478 | 0 | { |
3479 | | #ifdef COFF_WITH_EXTENDED_RELOC_COUNTER |
3480 | | /* We store the actual reloc count in the first reloc's addr. */ |
3481 | 0 | if ((obj_pe (abfd) || obj_go32 (abfd)) && current->reloc_count >= 0xffff) |
3482 | 0 | reloc_count ++; |
3483 | | #endif |
3484 | 0 | reloc_count += current->reloc_count; |
3485 | 0 | } |
3486 | |
|
3487 | 0 | reloc_size = reloc_count * bfd_coff_relsz (abfd); |
3488 | |
|
3489 | 0 | lineno_base = reloc_base + reloc_size; |
3490 | 0 | sym_base = lineno_base + lnno_size; |
3491 | | |
3492 | | /* Indicate in each section->line_filepos its actual file address. */ |
3493 | 0 | for (current = abfd->sections; current != NULL; current = |
3494 | 0 | current->next) |
3495 | 0 | { |
3496 | 0 | if (current->lineno_count) |
3497 | 0 | { |
3498 | 0 | current->line_filepos = lineno_base; |
3499 | 0 | current->moving_line_filepos = lineno_base; |
3500 | 0 | lineno_base += current->lineno_count * bfd_coff_linesz (abfd); |
3501 | 0 | } |
3502 | 0 | else |
3503 | 0 | current->line_filepos = 0; |
3504 | |
|
3505 | 0 | if (current->reloc_count) |
3506 | 0 | { |
3507 | 0 | current->rel_filepos = reloc_base; |
3508 | 0 | reloc_base += current->reloc_count * bfd_coff_relsz (abfd); |
3509 | | #ifdef COFF_WITH_EXTENDED_RELOC_COUNTER |
3510 | | /* Extra reloc to hold real count. */ |
3511 | 0 | if ((obj_pe (abfd) || obj_go32 (abfd)) && current->reloc_count >= 0xffff) |
3512 | 0 | reloc_base += bfd_coff_relsz (abfd); |
3513 | | #endif |
3514 | 0 | } |
3515 | 0 | else |
3516 | 0 | current->rel_filepos = 0; |
3517 | 0 | } |
3518 | | |
3519 | | /* Write section headers to the file. */ |
3520 | 0 | internal_f.f_nscns = 0; |
3521 | |
|
3522 | 0 | if ((abfd->flags & EXEC_P) != 0) |
3523 | 0 | scn_base = bfd_coff_filhsz (abfd) + bfd_coff_aoutsz (abfd); |
3524 | 0 | else |
3525 | 0 | { |
3526 | 0 | scn_base = bfd_coff_filhsz (abfd); |
3527 | | #ifdef RS6000COFF_C |
3528 | | #ifndef XCOFF64 |
3529 | 0 | if (xcoff_data (abfd)->full_aouthdr) |
3530 | 0 | scn_base += bfd_coff_aoutsz (abfd); |
3531 | 0 | else |
3532 | 0 | scn_base += SMALL_AOUTSZ; |
3533 | | #endif |
3534 | | #endif |
3535 | 0 | } |
3536 | |
|
3537 | 0 | if (bfd_seek (abfd, scn_base, SEEK_SET) != 0) |
3538 | 0 | return false; |
3539 | | |
3540 | 0 | long_section_names = false; |
3541 | 0 | for (current = abfd->sections; |
3542 | 0 | current != NULL; |
3543 | 0 | current = current->next) |
3544 | 0 | { |
3545 | 0 | struct internal_scnhdr section; |
3546 | | #ifdef COFF_IMAGE_WITH_PE |
3547 | | bool is_reloc_section = false; |
3548 | | |
3549 | 0 | if (strcmp (current->name, DOT_RELOC) == 0) |
3550 | 0 | { |
3551 | 0 | is_reloc_section = true; |
3552 | 0 | hasrelocs = true; |
3553 | 0 | pe_data (abfd)->has_reloc_section = 1; |
3554 | 0 | } |
3555 | | #endif |
3556 | |
|
3557 | 0 | internal_f.f_nscns++; |
3558 | |
|
3559 | 0 | strncpy (section.s_name, current->name, SCNNMLEN); |
3560 | |
|
3561 | | #ifdef COFF_LONG_SECTION_NAMES |
3562 | | /* Handle long section names as in PE. This must be compatible |
3563 | | with the code in coff_write_symbols and _bfd_coff_final_link. */ |
3564 | 0 | if (bfd_coff_long_section_names (abfd)) |
3565 | 0 | { |
3566 | 0 | size_t len; |
3567 | | |
3568 | | len = strlen (current->name); |
3569 | 0 | if (len > SCNNMLEN) |
3570 | 0 | { |
3571 | | |
3572 | | /* An inherent limitation of the /nnnnnnn notation used to indicate |
3573 | | the offset of the long name in the string table is that we |
3574 | | cannot address entries beyone the ten million byte boundary. */ |
3575 | 0 | if (string_size < 10000000) |
3576 | 0 | { |
3577 | | /* The s_name field is defined to be NUL-padded but need not |
3578 | | be NUL-terminated. We use a temporary buffer so that we |
3579 | | can still sprintf all eight chars without splatting a |
3580 | | terminating NUL over the first byte of the following |
3581 | | member (s_paddr). */ |
3582 | | /* PR 21096: The +20 is to stop a bogus warning from gcc7 |
3583 | | about a possible buffer overflow. */ |
3584 | | char s_name_buf[SCNNMLEN + 1 + 20]; |
3585 | | |
3586 | | /* We do not need to use snprintf here as we have already |
3587 | | verified that string_size is not too big, plus we have |
3588 | | an overlarge buffer, just in case. */ |
3589 | 0 | sprintf (s_name_buf, "/%lu", (unsigned long) string_size); |
3590 | | /* Then strncpy takes care of any padding for us. */ |
3591 | 0 | strncpy (section.s_name, s_name_buf, SCNNMLEN); |
3592 | 0 | } |
3593 | 0 | else |
3594 | | #ifdef COFF_WITH_PE |
3595 | 0 | { |
3596 | | /* PE use a base 64 encoding for long section names whose |
3597 | | index is very large. But contrary to RFC 4648, there is |
3598 | | no padding: 6 characters must be generated. */ |
3599 | 0 | static const char base64[] = |
3600 | 0 | "ABCDEFGHIJKLMNOPQRSTUVWXYZ" |
3601 | 0 | "abcdefghijklmnopqrstuvwxyz" |
3602 | 0 | "0123456789+/"; |
3603 | 0 | unsigned long off = string_size; |
3604 | 0 | unsigned i; |
3605 | |
|
3606 | 0 | section.s_name[0] = '/'; |
3607 | 0 | section.s_name[1] = '/'; |
3608 | 0 | for (i = SCNNMLEN - 1; i >= 2; i--) |
3609 | 0 | { |
3610 | 0 | section.s_name[i] = base64[off & 0x3f]; |
3611 | 0 | off >>= 6; |
3612 | 0 | } |
3613 | 0 | } |
3614 | | #endif |
3615 | 0 | if (string_size > 0xffffffffUL - (len + 1) |
3616 | | #ifndef COFF_WITH_PE |
3617 | 0 | || string_size >= 10000000 |
3618 | | #endif |
3619 | 0 | ) |
3620 | 0 | { |
3621 | 0 | bfd_set_error (bfd_error_file_too_big); |
3622 | 0 | _bfd_error_handler |
3623 | | /* xgettext:c-format */ |
3624 | 0 | (_("%pB: section %pA: string table overflow at offset %ld"), |
3625 | 0 | abfd, current, (unsigned long) string_size); |
3626 | 0 | return false; |
3627 | 0 | } |
3628 | | |
3629 | 0 | string_size += len + 1; |
3630 | 0 | long_section_names = true; |
3631 | 0 | } |
3632 | 0 | } |
3633 | 0 | #endif |
3634 | | |
3635 | | #ifdef _LIB |
3636 | | /* Always set s_vaddr of .lib to 0. This is right for SVR3.2 |
3637 | | Ian Taylor <ian@cygnus.com>. */ |
3638 | 0 | if (strcmp (current->name, _LIB) == 0) |
3639 | 0 | section.s_vaddr = 0; |
3640 | 0 | else |
3641 | 0 | #endif |
3642 | 0 | section.s_vaddr = current->vma; |
3643 | 0 | section.s_paddr = current->lma; |
3644 | 0 | section.s_size = current->size; |
3645 | | #ifdef coff_get_section_load_page |
3646 | 0 | section.s_page = coff_get_section_load_page (current); |
3647 | | #else |
3648 | | section.s_page = 0; |
3649 | | #endif |
3650 | |
|
3651 | | #ifdef COFF_WITH_PE |
3652 | | section.s_paddr = 0; |
3653 | | #endif |
3654 | | #ifdef COFF_IMAGE_WITH_PE |
3655 | | /* Reminder: s_paddr holds the virtual size of the section. */ |
3656 | 0 | if (coff_section_data (abfd, current) != NULL |
3657 | 0 | && pei_section_data (abfd, current) != NULL) |
3658 | 0 | section.s_paddr = pei_section_data (abfd, current)->virt_size; |
3659 | 0 | else |
3660 | 0 | section.s_paddr = 0; |
3661 | | #endif |
3662 | | |
3663 | | /* If this section has no size or is unloadable then the scnptr |
3664 | | will be 0 too. */ |
3665 | 0 | if (current->size == 0 |
3666 | 0 | || (current->flags & (SEC_LOAD | SEC_HAS_CONTENTS)) == 0) |
3667 | 0 | section.s_scnptr = 0; |
3668 | 0 | else |
3669 | 0 | section.s_scnptr = current->filepos; |
3670 | |
|
3671 | 0 | section.s_relptr = current->rel_filepos; |
3672 | 0 | section.s_lnnoptr = current->line_filepos; |
3673 | 0 | section.s_nreloc = current->reloc_count; |
3674 | 0 | section.s_nlnno = current->lineno_count; |
3675 | | #ifndef COFF_IMAGE_WITH_PE |
3676 | | /* In PEI, relocs come in the .reloc section. */ |
3677 | 0 | if (current->reloc_count != 0) |
3678 | 0 | hasrelocs = true; |
3679 | | #endif |
3680 | 0 | if (current->lineno_count != 0) |
3681 | 0 | haslinno = true; |
3682 | | #ifdef COFF_IMAGE_WITH_PE |
3683 | 0 | if ((current->flags & SEC_DEBUGGING) != 0 |
3684 | 0 | && ! is_reloc_section) |
3685 | 0 | hasdebug = true; |
3686 | | #endif |
3687 | |
|
3688 | | #ifdef RS6000COFF_C |
3689 | | #ifndef XCOFF64 |
3690 | | /* Indicate the use of an XCOFF overflow section header. */ |
3691 | 0 | if (current->reloc_count >= 0xffff || current->lineno_count >= 0xffff) |
3692 | 0 | { |
3693 | 0 | section.s_nreloc = 0xffff; |
3694 | 0 | section.s_nlnno = 0xffff; |
3695 | 0 | } |
3696 | | #endif |
3697 | | #endif |
3698 | |
|
3699 | 0 | section.s_flags = sec_to_styp_flags (current->name, current->flags); |
3700 | |
|
3701 | 0 | if (!strcmp (current->name, _TEXT)) |
3702 | 0 | text_sec = current; |
3703 | 0 | else if (!strcmp (current->name, _DATA)) |
3704 | 0 | data_sec = current; |
3705 | 0 | else if (!strcmp (current->name, _BSS)) |
3706 | 0 | bss_sec = current; |
3707 | | #ifdef RS6000COFF_C |
3708 | 0 | else if (!strcmp (current->name, _TDATA)) |
3709 | 0 | tdata_sec = current; |
3710 | 0 | else if (!strcmp (current->name, _TBSS)) |
3711 | 0 | tbss_sec = current; |
3712 | | #endif |
3713 | | |
3714 | |
|
3715 | | #ifdef COFF_ENCODE_ALIGNMENT |
3716 | 0 | if (COFF_ENCODE_ALIGNMENT (abfd, section, current->alignment_power) |
3717 | 0 | && (COFF_DECODE_ALIGNMENT (section.s_flags) |
3718 | 0 | != current->alignment_power)) |
3719 | 0 | { |
3720 | 0 | bool warn = (coff_data (abfd)->link_info |
3721 | 0 | && !bfd_link_relocatable (coff_data (abfd)->link_info)); |
3722 | |
|
3723 | 0 | _bfd_error_handler |
3724 | | /* xgettext:c-format */ |
3725 | 0 | (_("%pB:%s section %s: alignment 2**%u not representable"), |
3726 | 0 | abfd, warn ? " warning:" : "", current->name, |
3727 | 0 | current->alignment_power); |
3728 | 0 | if (!warn) |
3729 | 0 | { |
3730 | 0 | bfd_set_error (bfd_error_nonrepresentable_section); |
3731 | 0 | return false; |
3732 | 0 | } |
3733 | 0 | } |
3734 | 0 | #endif |
3735 | | |
3736 | | #ifdef COFF_IMAGE_WITH_PE |
3737 | | /* Suppress output of the sections if they are null. ld |
3738 | | includes the bss and data sections even if there is no size |
3739 | | assigned to them. NT loader doesn't like it if these section |
3740 | | headers are included if the sections themselves are not |
3741 | | needed. See also coff_compute_section_file_positions. */ |
3742 | 0 | if (section.s_size == 0) |
3743 | 0 | internal_f.f_nscns--; |
3744 | 0 | else |
3745 | 0 | #endif |
3746 | 0 | { |
3747 | 0 | SCNHDR buff; |
3748 | 0 | bfd_size_type amt = bfd_coff_scnhsz (abfd); |
3749 | |
|
3750 | 0 | if (bfd_coff_swap_scnhdr_out (abfd, §ion, &buff) == 0 |
3751 | 0 | || bfd_bwrite (& buff, amt, abfd) != amt) |
3752 | 0 | return false; |
3753 | 0 | } |
3754 | | |
3755 | | #ifdef COFF_WITH_PE |
3756 | | /* PE stores COMDAT section information in the symbol table. If |
3757 | | this section is supposed to have some COMDAT info, track down |
3758 | | the symbol in the symbol table and modify it. */ |
3759 | 0 | if ((current->flags & SEC_LINK_ONCE) != 0) |
3760 | 0 | { |
3761 | 0 | unsigned int i, count; |
3762 | 0 | asymbol **psym; |
3763 | 0 | coff_symbol_type *csym = NULL; |
3764 | 0 | asymbol **psymsec; |
3765 | | |
3766 | | psymsec = NULL; |
3767 | | count = bfd_get_symcount (abfd); |
3768 | 0 | for (i = 0, psym = abfd->outsymbols; i < count; i++, psym++) |
3769 | 0 | { |
3770 | 0 | if ((*psym)->section != current) |
3771 | 0 | continue; |
3772 | | |
3773 | | /* Remember the location of the first symbol in this |
3774 | | section. */ |
3775 | 0 | if (psymsec == NULL) |
3776 | 0 | psymsec = psym; |
3777 | | |
3778 | | /* See if this is the section symbol. */ |
3779 | 0 | if (strcmp ((*psym)->name, current->name) == 0) |
3780 | 0 | { |
3781 | 0 | csym = coff_symbol_from (*psym); |
3782 | 0 | if (csym == NULL |
3783 | 0 | || csym->native == NULL |
3784 | 0 | || ! csym->native->is_sym |
3785 | 0 | || csym->native->u.syment.n_numaux < 1 |
3786 | 0 | || csym->native->u.syment.n_sclass != C_STAT |
3787 | 0 | || csym->native->u.syment.n_type != T_NULL) |
3788 | 0 | continue; |
3789 | | |
3790 | | /* Here *PSYM is the section symbol for CURRENT. */ |
3791 | | |
3792 | 0 | break; |
3793 | 0 | } |
3794 | 0 | } |
3795 | | |
3796 | | /* Did we find it? |
3797 | | Note that we might not if we're converting the file from |
3798 | | some other object file format. */ |
3799 | 0 | if (i < count) |
3800 | 0 | { |
3801 | 0 | combined_entry_type *aux; |
3802 | | |
3803 | | /* We don't touch the x_checksum field. The |
3804 | | x_associated field is not currently supported. */ |
3805 | |
|
3806 | 0 | aux = csym->native + 1; |
3807 | 0 | BFD_ASSERT (! aux->is_sym); |
3808 | 0 | switch (current->flags & SEC_LINK_DUPLICATES) |
3809 | 0 | { |
3810 | 0 | case SEC_LINK_DUPLICATES_DISCARD: |
3811 | 0 | aux->u.auxent.x_scn.x_comdat = IMAGE_COMDAT_SELECT_ANY; |
3812 | 0 | break; |
3813 | | |
3814 | 0 | case SEC_LINK_DUPLICATES_ONE_ONLY: |
3815 | 0 | aux->u.auxent.x_scn.x_comdat = |
3816 | 0 | IMAGE_COMDAT_SELECT_NODUPLICATES; |
3817 | 0 | break; |
3818 | | |
3819 | 0 | case SEC_LINK_DUPLICATES_SAME_SIZE: |
3820 | 0 | aux->u.auxent.x_scn.x_comdat = |
3821 | 0 | IMAGE_COMDAT_SELECT_SAME_SIZE; |
3822 | 0 | break; |
3823 | | |
3824 | 0 | case SEC_LINK_DUPLICATES_SAME_CONTENTS: |
3825 | 0 | aux->u.auxent.x_scn.x_comdat = |
3826 | 0 | IMAGE_COMDAT_SELECT_EXACT_MATCH; |
3827 | 0 | break; |
3828 | 0 | } |
3829 | | |
3830 | | /* The COMDAT symbol must be the first symbol from this |
3831 | | section in the symbol table. In order to make this |
3832 | | work, we move the COMDAT symbol before the first |
3833 | | symbol we found in the search above. It's OK to |
3834 | | rearrange the symbol table at this point, because |
3835 | | coff_renumber_symbols is going to rearrange it |
3836 | | further and fix up all the aux entries. */ |
3837 | 0 | if (psym != psymsec) |
3838 | 0 | { |
3839 | 0 | asymbol *hold; |
3840 | 0 | asymbol **pcopy; |
3841 | |
|
3842 | 0 | hold = *psym; |
3843 | 0 | for (pcopy = psym; pcopy > psymsec; pcopy--) |
3844 | 0 | pcopy[0] = pcopy[-1]; |
3845 | 0 | *psymsec = hold; |
3846 | 0 | } |
3847 | 0 | } |
3848 | 0 | } |
3849 | | #endif /* COFF_WITH_PE */ |
3850 | 0 | } |
3851 | | |
3852 | | #ifdef RS6000COFF_C |
3853 | | #ifndef XCOFF64 |
3854 | | /* XCOFF handles overflows in the reloc and line number count fields |
3855 | | by creating a new section header to hold the correct values. */ |
3856 | 0 | for (current = abfd->sections; current != NULL; current = current->next) |
3857 | 0 | { |
3858 | 0 | if (current->reloc_count >= 0xffff || current->lineno_count >= 0xffff) |
3859 | 0 | { |
3860 | 0 | struct internal_scnhdr scnhdr; |
3861 | 0 | SCNHDR buff; |
3862 | 0 | bfd_size_type amt; |
3863 | |
|
3864 | 0 | internal_f.f_nscns++; |
3865 | 0 | memcpy (scnhdr.s_name, ".ovrflo", 8); |
3866 | 0 | scnhdr.s_paddr = current->reloc_count; |
3867 | 0 | scnhdr.s_vaddr = current->lineno_count; |
3868 | 0 | scnhdr.s_size = 0; |
3869 | 0 | scnhdr.s_scnptr = 0; |
3870 | 0 | scnhdr.s_relptr = current->rel_filepos; |
3871 | 0 | scnhdr.s_lnnoptr = current->line_filepos; |
3872 | 0 | scnhdr.s_nreloc = current->target_index; |
3873 | 0 | scnhdr.s_nlnno = current->target_index; |
3874 | 0 | scnhdr.s_flags = STYP_OVRFLO; |
3875 | 0 | amt = bfd_coff_scnhsz (abfd); |
3876 | 0 | if (bfd_coff_swap_scnhdr_out (abfd, &scnhdr, &buff) == 0 |
3877 | 0 | || bfd_bwrite (& buff, amt, abfd) != amt) |
3878 | 0 | return false; |
3879 | 0 | } |
3880 | 0 | } |
3881 | 0 | #endif |
3882 | | #endif |
3883 | | |
3884 | | #if defined (COFF_GO32_EXE) || defined (COFF_GO32) |
3885 | | /* Pad section headers. */ |
3886 | 0 | if ((abfd->flags & EXEC_P) && abfd->sections != NULL) |
3887 | 0 | { |
3888 | 0 | file_ptr cur_ptr = scn_base |
3889 | 0 | + abfd->section_count * bfd_coff_scnhsz (abfd); |
3890 | 0 | long fill_size = (abfd->sections->filepos - cur_ptr); |
3891 | 0 | bfd_byte *b = bfd_zmalloc (fill_size); |
3892 | 0 | if (b) |
3893 | 0 | { |
3894 | 0 | bfd_bwrite (b, fill_size, abfd); |
3895 | 0 | free (b); |
3896 | 0 | } |
3897 | 0 | } |
3898 | 0 | #endif |
3899 | | |
3900 | | /* OK, now set up the filehdr... */ |
3901 | | |
3902 | | /* Don't include the internal abs section in the section count */ |
3903 | | |
3904 | | /* We will NOT put a fucking timestamp in the header here. Every time you |
3905 | | put it back, I will come in and take it out again. I'm sorry. This |
3906 | | field does not belong here. We fill it with a 0 so it compares the |
3907 | | same but is not a reasonable time. -- gnu@cygnus.com */ |
3908 | 0 | internal_f.f_timdat = 0; |
3909 | 0 | internal_f.f_flags = 0; |
3910 | |
|
3911 | 0 | if (abfd->flags & EXEC_P) |
3912 | 0 | internal_f.f_opthdr = bfd_coff_aoutsz (abfd); |
3913 | 0 | else |
3914 | 0 | { |
3915 | 0 | internal_f.f_opthdr = 0; |
3916 | | #ifdef RS6000COFF_C |
3917 | | #ifndef XCOFF64 |
3918 | 0 | if (xcoff_data (abfd)->full_aouthdr) |
3919 | 0 | internal_f.f_opthdr = bfd_coff_aoutsz (abfd); |
3920 | 0 | else |
3921 | 0 | internal_f.f_opthdr = SMALL_AOUTSZ; |
3922 | | #endif |
3923 | | #endif |
3924 | 0 | } |
3925 | |
|
3926 | 0 | if (!hasrelocs) |
3927 | 0 | internal_f.f_flags |= F_RELFLG; |
3928 | 0 | if (!haslinno) |
3929 | 0 | internal_f.f_flags |= F_LNNO; |
3930 | 0 | if (abfd->flags & EXEC_P) |
3931 | 0 | internal_f.f_flags |= F_EXEC; |
3932 | | #ifdef COFF_IMAGE_WITH_PE |
3933 | 0 | if (! hasdebug) |
3934 | 0 | internal_f.f_flags |= IMAGE_FILE_DEBUG_STRIPPED; |
3935 | 0 | if (pe_data (abfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) |
3936 | 0 | internal_f.f_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; |
3937 | | #endif |
3938 | |
|
3939 | | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) |
3940 | | #ifdef COFF_WITH_PE |
3941 | 0 | internal_f.f_flags |= IMAGE_FILE_32BIT_MACHINE; |
3942 | | #else |
3943 | 0 | if (bfd_little_endian (abfd)) |
3944 | 0 | internal_f.f_flags |= F_AR32WR; |
3945 | 0 | else |
3946 | 0 | internal_f.f_flags |= F_AR32W; |
3947 | | #endif |
3948 | | #endif |
3949 | |
|
3950 | | #ifdef TI_TARGET_ID |
3951 | | /* Target id is used in TI COFF v1 and later; COFF0 won't use this field, |
3952 | | but it doesn't hurt to set it internally. */ |
3953 | 0 | internal_f.f_target_id = TI_TARGET_ID; |
3954 | | #endif |
3955 | | |
3956 | | /* FIXME, should do something about the other byte orders and |
3957 | | architectures. */ |
3958 | |
|
3959 | | #ifdef RS6000COFF_C |
3960 | 0 | if ((abfd->flags & DYNAMIC) != 0) |
3961 | 0 | internal_f.f_flags |= F_SHROBJ; |
3962 | 0 | if (bfd_get_section_by_name (abfd, _LOADER) != NULL) |
3963 | 0 | internal_f.f_flags |= F_DYNLOAD; |
3964 | | #endif |
3965 | |
|
3966 | 0 | memset (&internal_a, 0, sizeof internal_a); |
3967 | | |
3968 | | /* Set up architecture-dependent stuff. */ |
3969 | 0 | { |
3970 | 0 | unsigned int magic = 0; |
3971 | 0 | unsigned short flags = 0; |
3972 | |
|
3973 | 0 | coff_set_flags (abfd, &magic, &flags); |
3974 | 0 | internal_f.f_magic = magic; |
3975 | 0 | internal_f.f_flags |= flags; |
3976 | | /* ...and the "opt"hdr... */ |
3977 | |
|
3978 | | #ifdef TICOFF_AOUT_MAGIC |
3979 | 0 | internal_a.magic = TICOFF_AOUT_MAGIC; |
3980 | | #define __A_MAGIC_SET__ |
3981 | | #endif |
3982 | |
|
3983 | | #if defined(ARM) |
3984 | | #define __A_MAGIC_SET__ |
3985 | 0 | internal_a.magic = ZMAGIC; |
3986 | | #endif |
3987 | |
|
3988 | | #if defined(AARCH64) |
3989 | | #define __A_MAGIC_SET__ |
3990 | 0 | internal_a.magic = ZMAGIC; |
3991 | | #endif |
3992 | |
|
3993 | | #if defined(LOONGARCH64) |
3994 | | #define __A_MAGIC_SET__ |
3995 | 0 | internal_a.magic = ZMAGIC; |
3996 | | #endif |
3997 | |
|
3998 | | #if defined MCORE_PE |
3999 | | #define __A_MAGIC_SET__ |
4000 | 0 | internal_a.magic = IMAGE_NT_OPTIONAL_HDR_MAGIC; |
4001 | | #endif |
4002 | |
|
4003 | | #if defined(I386) |
4004 | | #define __A_MAGIC_SET__ |
4005 | | #if defined LYNXOS |
4006 | 0 | internal_a.magic = LYNXCOFFMAGIC; |
4007 | | #elif defined AMD64 |
4008 | 0 | internal_a.magic = IMAGE_NT_OPTIONAL_HDR64_MAGIC; |
4009 | | #else |
4010 | 0 | internal_a.magic = ZMAGIC; |
4011 | | #endif |
4012 | | #endif /* I386 */ |
4013 | |
|
4014 | | #if defined(IA64) |
4015 | | #define __A_MAGIC_SET__ |
4016 | 0 | internal_a.magic = PE32PMAGIC; |
4017 | | #endif /* IA64 */ |
4018 | |
|
4019 | | #if defined(SPARC) |
4020 | | #define __A_MAGIC_SET__ |
4021 | | #if defined(LYNXOS) |
4022 | | internal_a.magic = LYNXCOFFMAGIC; |
4023 | | #endif /* LYNXOS */ |
4024 | | #endif /* SPARC */ |
4025 | |
|
4026 | | #ifdef RS6000COFF_C |
4027 | | #define __A_MAGIC_SET__ |
4028 | 0 | internal_a.magic = (abfd->flags & D_PAGED) ? RS6K_AOUTHDR_ZMAGIC : |
4029 | 0 | (abfd->flags & WP_TEXT) ? RS6K_AOUTHDR_NMAGIC : |
4030 | 0 | RS6K_AOUTHDR_OMAGIC; |
4031 | | #endif |
4032 | |
|
4033 | | #if defined(SH) && defined(COFF_WITH_PE) |
4034 | | #define __A_MAGIC_SET__ |
4035 | 0 | internal_a.magic = SH_PE_MAGIC; |
4036 | | #endif |
4037 | |
|
4038 | | #if defined(MIPS) && defined(COFF_WITH_PE) |
4039 | | #define __A_MAGIC_SET__ |
4040 | | internal_a.magic = MIPS_PE_MAGIC; |
4041 | | #endif |
4042 | |
|
4043 | | #ifndef __A_MAGIC_SET__ |
4044 | | #include "Your aouthdr magic number is not being set!" |
4045 | | #else |
4046 | 0 | #undef __A_MAGIC_SET__ |
4047 | 0 | #endif |
4048 | 0 | } |
4049 | |
|
4050 | | #ifdef RS6000COFF_C |
4051 | | /* XCOFF 32bit needs this to have new behaviour for n_type field. */ |
4052 | | internal_a.vstamp = 2; |
4053 | | #else |
4054 | | /* FIXME: Does anybody ever set this to another value? */ |
4055 | | internal_a.vstamp = 0; |
4056 | | #endif |
4057 | | |
4058 | | /* Now should write relocs, strings, syms. */ |
4059 | 0 | obj_sym_filepos (abfd) = sym_base; |
4060 | |
|
4061 | 0 | if (bfd_get_symcount (abfd) != 0) |
4062 | 0 | { |
4063 | 0 | int firstundef; |
4064 | |
|
4065 | 0 | if (!coff_renumber_symbols (abfd, &firstundef)) |
4066 | 0 | return false; |
4067 | 0 | coff_mangle_symbols (abfd); |
4068 | 0 | if (! coff_write_symbols (abfd)) |
4069 | 0 | return false; |
4070 | 0 | if (! coff_write_linenumbers (abfd)) |
4071 | 0 | return false; |
4072 | 0 | if (! coff_write_relocs (abfd, firstundef)) |
4073 | 0 | return false; |
4074 | 0 | } |
4075 | | #ifdef COFF_LONG_SECTION_NAMES |
4076 | 0 | else if (long_section_names && ! obj_coff_strings_written (abfd)) |
4077 | 0 | { |
4078 | | /* If we have long section names we have to write out the string |
4079 | | table even if there are no symbols. */ |
4080 | 0 | if (! coff_write_symbols (abfd)) |
4081 | 0 | return false; |
4082 | 0 | } |
4083 | 0 | #endif |
4084 | | /* If bfd_get_symcount (abfd) != 0, then we are not using the COFF |
4085 | | backend linker, and obj_raw_syment_count is not valid until after |
4086 | | coff_write_symbols is called. */ |
4087 | 0 | if (obj_raw_syment_count (abfd) != 0) |
4088 | 0 | { |
4089 | 0 | internal_f.f_symptr = sym_base; |
4090 | | #ifdef RS6000COFF_C |
4091 | | /* AIX appears to require that F_RELFLG not be set if there are |
4092 | | local symbols but no relocations. */ |
4093 | 0 | internal_f.f_flags &=~ F_RELFLG; |
4094 | | #endif |
4095 | 0 | } |
4096 | 0 | else |
4097 | 0 | { |
4098 | 0 | if (long_section_names) |
4099 | 0 | internal_f.f_symptr = sym_base; |
4100 | 0 | else |
4101 | 0 | internal_f.f_symptr = 0; |
4102 | 0 | internal_f.f_flags |= F_LSYMS; |
4103 | 0 | } |
4104 | |
|
4105 | 0 | if (text_sec) |
4106 | 0 | { |
4107 | 0 | internal_a.tsize = text_sec->size; |
4108 | 0 | internal_a.text_start = internal_a.tsize ? text_sec->vma : 0; |
4109 | 0 | } |
4110 | 0 | if (data_sec) |
4111 | 0 | { |
4112 | 0 | internal_a.dsize = data_sec->size; |
4113 | 0 | internal_a.data_start = internal_a.dsize ? data_sec->vma : 0; |
4114 | 0 | } |
4115 | 0 | if (bss_sec) |
4116 | 0 | { |
4117 | 0 | internal_a.bsize = bss_sec->size; |
4118 | 0 | if (internal_a.bsize && bss_sec->vma < internal_a.data_start) |
4119 | 0 | internal_a.data_start = bss_sec->vma; |
4120 | 0 | } |
4121 | |
|
4122 | 0 | internal_a.entry = bfd_get_start_address (abfd); |
4123 | 0 | internal_f.f_nsyms = obj_raw_syment_count (abfd); |
4124 | |
|
4125 | | #ifdef RS6000COFF_C |
4126 | 0 | if (xcoff_data (abfd)->full_aouthdr) |
4127 | 0 | { |
4128 | 0 | bfd_vma toc; |
4129 | 0 | asection *loader_sec; |
4130 | | |
4131 | | internal_a.vstamp = 2; |
4132 | | |
4133 | 0 | internal_a.o_snentry = xcoff_data (abfd)->snentry; |
4134 | 0 | if (internal_a.o_snentry == 0) |
4135 | 0 | internal_a.entry = (bfd_vma) -1; |
4136 | | |
4137 | 0 | if (text_sec != NULL) |
4138 | 0 | { |
4139 | 0 | internal_a.o_sntext = text_sec->target_index; |
4140 | 0 | internal_a.o_algntext = bfd_section_alignment (text_sec); |
4141 | 0 | } |
4142 | 0 | else |
4143 | 0 | { |
4144 | 0 | internal_a.o_sntext = 0; |
4145 | 0 | internal_a.o_algntext = 0; |
4146 | 0 | } |
4147 | 0 | if (data_sec != NULL) |
4148 | 0 | { |
4149 | 0 | internal_a.o_sndata = data_sec->target_index; |
4150 | 0 | internal_a.o_algndata = bfd_section_alignment (data_sec); |
4151 | 0 | } |
4152 | 0 | else |
4153 | 0 | { |
4154 | 0 | internal_a.o_sndata = 0; |
4155 | 0 | internal_a.o_algndata = 0; |
4156 | 0 | } |
4157 | | loader_sec = bfd_get_section_by_name (abfd, ".loader"); |
4158 | 0 | if (loader_sec != NULL) |
4159 | 0 | internal_a.o_snloader = loader_sec->target_index; |
4160 | 0 | else |
4161 | 0 | internal_a.o_snloader = 0; |
4162 | 0 | if (bss_sec != NULL) |
4163 | 0 | internal_a.o_snbss = bss_sec->target_index; |
4164 | 0 | else |
4165 | 0 | internal_a.o_snbss = 0; |
4166 | |
|
4167 | 0 | if (tdata_sec != NULL) |
4168 | 0 | { |
4169 | 0 | internal_a.o_sntdata = tdata_sec->target_index; |
4170 | | /* TODO: o_flags should be set to RS6K_AOUTHDR_TLS_LE |
4171 | | if there is at least one R_TLS_LE relocations. */ |
4172 | 0 | internal_a.o_flags = 0; |
4173 | | #ifdef XCOFF64 |
4174 | | internal_a.o_x64flags = 0; |
4175 | | #endif |
4176 | 0 | } |
4177 | 0 | else |
4178 | 0 | { |
4179 | 0 | internal_a.o_sntdata = 0; |
4180 | 0 | internal_a.o_flags = 0; |
4181 | | #ifdef XCOFF64 |
4182 | | internal_a.o_x64flags = 0; |
4183 | | #endif |
4184 | 0 | } |
4185 | 0 | if (tbss_sec != NULL) |
4186 | 0 | internal_a.o_sntbss = tbss_sec->target_index; |
4187 | 0 | else |
4188 | 0 | internal_a.o_sntbss = 0; |
4189 | | |
4190 | 0 | toc = xcoff_data (abfd)->toc; |
4191 | | internal_a.o_toc = toc; |
4192 | 0 | internal_a.o_sntoc = xcoff_data (abfd)->sntoc; |
4193 | |
|
4194 | 0 | internal_a.o_modtype = xcoff_data (abfd)->modtype; |
4195 | 0 | if (xcoff_data (abfd)->cputype != -1) |
4196 | 0 | internal_a.o_cputype = xcoff_data (abfd)->cputype; |
4197 | 0 | else |
4198 | 0 | { |
4199 | 0 | switch (bfd_get_arch (abfd)) |
4200 | 0 | { |
4201 | 0 | case bfd_arch_rs6000: |
4202 | 0 | internal_a.o_cputype = 4; |
4203 | 0 | break; |
4204 | 0 | case bfd_arch_powerpc: |
4205 | 0 | if (bfd_get_mach (abfd) == bfd_mach_ppc) |
4206 | 0 | internal_a.o_cputype = 3; |
4207 | 0 | else if (bfd_get_mach (abfd) == bfd_mach_ppc_620) |
4208 | 0 | internal_a.o_cputype = 2; |
4209 | 0 | else |
4210 | 0 | internal_a.o_cputype = 1; |
4211 | 0 | break; |
4212 | 0 | default: |
4213 | 0 | abort (); |
4214 | 0 | } |
4215 | 0 | } |
4216 | 0 | internal_a.o_maxstack = xcoff_data (abfd)->maxstack; |
4217 | 0 | internal_a.o_maxdata = xcoff_data (abfd)->maxdata; |
4218 | 0 | } |
4219 | 0 | #endif |
4220 | | |
4221 | | #ifdef COFF_WITH_PE |
4222 | | { |
4223 | | /* After object contents are finalized so we can compute a reasonable hash, |
4224 | | but before header is written so we can update it to point to debug directory. */ |
4225 | 0 | struct pe_tdata *pe = pe_data (abfd); |
4226 | | |
4227 | 0 | if (pe->build_id.after_write_object_contents != NULL) |
4228 | 0 | (*pe->build_id.after_write_object_contents) (abfd); |
4229 | | } |
4230 | | #endif |
4231 | | |
4232 | | /* Now write header. */ |
4233 | 0 | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) |
4234 | 0 | return false; |
4235 | | |
4236 | 0 | { |
4237 | 0 | char * buff; |
4238 | 0 | bfd_size_type amount = bfd_coff_filhsz (abfd); |
4239 | |
|
4240 | 0 | buff = (char *) bfd_malloc (amount); |
4241 | 0 | if (buff == NULL) |
4242 | 0 | return false; |
4243 | | |
4244 | 0 | bfd_coff_swap_filehdr_out (abfd, & internal_f, buff); |
4245 | 0 | amount = bfd_bwrite (buff, amount, abfd); |
4246 | |
|
4247 | 0 | free (buff); |
4248 | |
|
4249 | 0 | if (amount != bfd_coff_filhsz (abfd)) |
4250 | 0 | return false; |
4251 | 0 | } |
4252 | | |
4253 | 0 | if (abfd->flags & EXEC_P) |
4254 | 0 | { |
4255 | | /* Note that peicode.h fills in a PEAOUTHDR, not an AOUTHDR. |
4256 | | include/coff/pe.h sets AOUTSZ == sizeof (PEAOUTHDR)). */ |
4257 | 0 | char * buff; |
4258 | 0 | bfd_size_type amount = bfd_coff_aoutsz (abfd); |
4259 | |
|
4260 | 0 | buff = (char *) bfd_malloc (amount); |
4261 | 0 | if (buff == NULL) |
4262 | 0 | return false; |
4263 | | |
4264 | 0 | coff_swap_aouthdr_out (abfd, & internal_a, buff); |
4265 | 0 | amount = bfd_bwrite (buff, amount, abfd); |
4266 | |
|
4267 | 0 | free (buff); |
4268 | |
|
4269 | 0 | if (amount != bfd_coff_aoutsz (abfd)) |
4270 | 0 | return false; |
4271 | | |
4272 | | #ifdef COFF_IMAGE_WITH_PE |
4273 | 0 | if (! coff_apply_checksum (abfd)) |
4274 | 0 | return false; |
4275 | | #endif |
4276 | 0 | } |
4277 | | #ifdef RS6000COFF_C |
4278 | | #ifndef XCOFF64 |
4279 | | else |
4280 | 0 | { |
4281 | 0 | AOUTHDR buff; |
4282 | 0 | size_t size; |
4283 | | |
4284 | | /* XCOFF32 seems to always write at least a small a.out header. */ |
4285 | 0 | coff_swap_aouthdr_out (abfd, & internal_a, & buff); |
4286 | 0 | if (xcoff_data (abfd)->full_aouthdr) |
4287 | 0 | size = bfd_coff_aoutsz (abfd); |
4288 | 0 | else |
4289 | 0 | size = SMALL_AOUTSZ; |
4290 | 0 | if (bfd_bwrite (& buff, (bfd_size_type) size, abfd) != size) |
4291 | 0 | return false; |
4292 | 0 | } |
4293 | 0 | #endif |
4294 | | #endif |
4295 | | |
4296 | 0 | return true; |
4297 | 0 | } Unexecuted instantiation: pei-i386.c:coff_write_object_contents Unexecuted instantiation: pe-x86_64.c:coff_write_object_contents Unexecuted instantiation: pei-x86_64.c:coff_write_object_contents Unexecuted instantiation: coff-x86_64.c:coff_write_object_contents Unexecuted instantiation: coff64-rs6000.c:coff_write_object_contents Unexecuted instantiation: pei-aarch64.c:coff_write_object_contents Unexecuted instantiation: pe-aarch64.c:coff_write_object_contents Unexecuted instantiation: pei-ia64.c:coff_write_object_contents Unexecuted instantiation: pei-loongarch64.c:coff_write_object_contents Unexecuted instantiation: cf-i386lynx.c:coff_write_object_contents Unexecuted instantiation: coff-go32.c:coff_write_object_contents Unexecuted instantiation: coff-i386.c:coff_write_object_contents Unexecuted instantiation: coff-rs6000.c:coff_write_object_contents Unexecuted instantiation: coff-sh.c:coff_write_object_contents Unexecuted instantiation: coff-stgo32.c:coff_write_object_contents Unexecuted instantiation: coff-tic30.c:coff_write_object_contents Unexecuted instantiation: coff-tic4x.c:coff_write_object_contents Unexecuted instantiation: coff-tic54x.c:coff_write_object_contents Unexecuted instantiation: coff-z80.c:coff_write_object_contents Unexecuted instantiation: coff-z8k.c:coff_write_object_contents Unexecuted instantiation: pe-arm-wince.c:coff_write_object_contents Unexecuted instantiation: pe-arm.c:coff_write_object_contents Unexecuted instantiation: pe-i386.c:coff_write_object_contents Unexecuted instantiation: pe-mcore.c:coff_write_object_contents Unexecuted instantiation: pe-sh.c:coff_write_object_contents Unexecuted instantiation: pei-arm-wince.c:coff_write_object_contents Unexecuted instantiation: pei-arm.c:coff_write_object_contents Unexecuted instantiation: pei-mcore.c:coff_write_object_contents Unexecuted instantiation: pei-sh.c:coff_write_object_contents |
4298 | | |
4299 | | static bool |
4300 | | coff_set_section_contents (bfd * abfd, |
4301 | | sec_ptr section, |
4302 | | const void * location, |
4303 | | file_ptr offset, |
4304 | | bfd_size_type count) |
4305 | 0 | { |
4306 | 0 | if (! abfd->output_has_begun) /* Set by bfd.c handler. */ |
4307 | 0 | { |
4308 | 0 | if (! coff_compute_section_file_positions (abfd)) |
4309 | 0 | return false; |
4310 | 0 | } |
4311 | | |
4312 | | #if defined(_LIB) && !defined(TARG_AUX) |
4313 | | /* The physical address field of a .lib section is used to hold the |
4314 | | number of shared libraries in the section. This code counts the |
4315 | | number of sections being written, and increments the lma field |
4316 | | with the number. |
4317 | | |
4318 | | I have found no documentation on the contents of this section. |
4319 | | Experimentation indicates that the section contains zero or more |
4320 | | records, each of which has the following structure: |
4321 | | |
4322 | | - a (four byte) word holding the length of this record, in words, |
4323 | | - a word that always seems to be set to "2", |
4324 | | - the path to a shared library, null-terminated and then padded |
4325 | | to a whole word boundary. |
4326 | | |
4327 | | bfd_assert calls have been added to alert if an attempt is made |
4328 | | to write a section which doesn't follow these assumptions. The |
4329 | | code has been tested on ISC 4.1 by me, and on SCO by Robert Lipe |
4330 | | <robertl@arnet.com> (Thanks!). |
4331 | | |
4332 | | Gvran Uddeborg <gvran@uddeborg.pp.se>. */ |
4333 | 0 | if (strcmp (section->name, _LIB) == 0) |
4334 | 0 | { |
4335 | 0 | bfd_byte *rec, *recend; |
4336 | | |
4337 | | rec = (bfd_byte *) location; |
4338 | | recend = rec + count; |
4339 | 0 | while (recend - rec >= 4) |
4340 | 0 | { |
4341 | 0 | size_t len = bfd_get_32 (abfd, rec); |
4342 | 0 | if (len == 0 || len > (size_t) (recend - rec) / 4) |
4343 | 0 | break; |
4344 | 0 | rec += len * 4; |
4345 | 0 | ++section->lma; |
4346 | 0 | } |
4347 | |
|
4348 | 0 | BFD_ASSERT (rec == recend); |
4349 | 0 | } |
4350 | 0 | #endif |
4351 | | |
4352 | | /* Don't write out bss sections - one way to do this is to |
4353 | | see if the filepos has not been set. */ |
4354 | 0 | if (section->filepos == 0) |
4355 | 0 | return true; |
4356 | | |
4357 | 0 | if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0) |
4358 | 0 | return false; |
4359 | | |
4360 | 0 | if (count == 0) |
4361 | 0 | return true; |
4362 | | |
4363 | 0 | return bfd_bwrite (location, count, abfd) == count; |
4364 | 0 | } Unexecuted instantiation: pei-i386.c:coff_set_section_contents Unexecuted instantiation: pe-x86_64.c:coff_set_section_contents Unexecuted instantiation: pei-x86_64.c:coff_set_section_contents Unexecuted instantiation: coff-x86_64.c:coff_set_section_contents Unexecuted instantiation: coff64-rs6000.c:coff_set_section_contents Unexecuted instantiation: pei-aarch64.c:coff_set_section_contents Unexecuted instantiation: pe-aarch64.c:coff_set_section_contents Unexecuted instantiation: pei-ia64.c:coff_set_section_contents Unexecuted instantiation: pei-loongarch64.c:coff_set_section_contents Unexecuted instantiation: cf-i386lynx.c:coff_set_section_contents Unexecuted instantiation: coff-go32.c:coff_set_section_contents Unexecuted instantiation: coff-i386.c:coff_set_section_contents Unexecuted instantiation: coff-rs6000.c:coff_set_section_contents Unexecuted instantiation: coff-sh.c:coff_set_section_contents Unexecuted instantiation: coff-stgo32.c:coff_set_section_contents Unexecuted instantiation: coff-tic30.c:coff_set_section_contents Unexecuted instantiation: coff-tic4x.c:coff_set_section_contents Unexecuted instantiation: coff-tic54x.c:coff_set_section_contents Unexecuted instantiation: coff-z80.c:coff_set_section_contents Unexecuted instantiation: coff-z8k.c:coff_set_section_contents Unexecuted instantiation: pe-arm-wince.c:coff_set_section_contents Unexecuted instantiation: pe-arm.c:coff_set_section_contents Unexecuted instantiation: pe-i386.c:coff_set_section_contents Unexecuted instantiation: pe-mcore.c:coff_set_section_contents Unexecuted instantiation: pe-sh.c:coff_set_section_contents Unexecuted instantiation: pei-arm-wince.c:coff_set_section_contents Unexecuted instantiation: pei-arm.c:coff_set_section_contents Unexecuted instantiation: pei-mcore.c:coff_set_section_contents Unexecuted instantiation: pei-sh.c:coff_set_section_contents |
4365 | | |
4366 | | static void * |
4367 | | buy_and_read (bfd *abfd, file_ptr where, |
4368 | | bfd_size_type nmemb, bfd_size_type size) |
4369 | 6.93k | { |
4370 | 6.93k | size_t amt; |
4371 | | |
4372 | 6.93k | if (_bfd_mul_overflow (nmemb, size, &amt)) |
4373 | 0 | { |
4374 | 0 | bfd_set_error (bfd_error_file_too_big); |
4375 | 0 | return NULL; |
4376 | 0 | } |
4377 | 6.93k | if (bfd_seek (abfd, where, SEEK_SET) != 0) |
4378 | 139 | return NULL; |
4379 | 6.80k | return _bfd_malloc_and_read (abfd, amt, amt); |
4380 | 6.93k | } Line | Count | Source | 4369 | 174 | { | 4370 | 174 | size_t amt; | 4371 | | | 4372 | 174 | if (_bfd_mul_overflow (nmemb, size, &amt)) | 4373 | 0 | { | 4374 | 0 | bfd_set_error (bfd_error_file_too_big); | 4375 | 0 | return NULL; | 4376 | 0 | } | 4377 | 174 | if (bfd_seek (abfd, where, SEEK_SET) != 0) | 4378 | 0 | return NULL; | 4379 | 174 | return _bfd_malloc_and_read (abfd, amt, amt); | 4380 | 174 | } |
Line | Count | Source | 4369 | 270 | { | 4370 | 270 | size_t amt; | 4371 | | | 4372 | 270 | if (_bfd_mul_overflow (nmemb, size, &amt)) | 4373 | 0 | { | 4374 | 0 | bfd_set_error (bfd_error_file_too_big); | 4375 | 0 | return NULL; | 4376 | 0 | } | 4377 | 270 | if (bfd_seek (abfd, where, SEEK_SET) != 0) | 4378 | 0 | return NULL; | 4379 | 270 | return _bfd_malloc_and_read (abfd, amt, amt); | 4380 | 270 | } |
pei-x86_64.c:buy_and_read Line | Count | Source | 4369 | 113 | { | 4370 | 113 | size_t amt; | 4371 | | | 4372 | 113 | if (_bfd_mul_overflow (nmemb, size, &amt)) | 4373 | 0 | { | 4374 | 0 | bfd_set_error (bfd_error_file_too_big); | 4375 | 0 | return NULL; | 4376 | 0 | } | 4377 | 113 | if (bfd_seek (abfd, where, SEEK_SET) != 0) | 4378 | 0 | return NULL; | 4379 | 113 | return _bfd_malloc_and_read (abfd, amt, amt); | 4380 | 113 | } |
coff-x86_64.c:buy_and_read Line | Count | Source | 4369 | 459 | { | 4370 | 459 | size_t amt; | 4371 | | | 4372 | 459 | if (_bfd_mul_overflow (nmemb, size, &amt)) | 4373 | 0 | { | 4374 | 0 | bfd_set_error (bfd_error_file_too_big); | 4375 | 0 | return NULL; | 4376 | 0 | } | 4377 | 459 | if (bfd_seek (abfd, where, SEEK_SET) != 0) | 4378 | 0 | return NULL; | 4379 | 459 | return _bfd_malloc_and_read (abfd, amt, amt); | 4380 | 459 | } |
coff64-rs6000.c:buy_and_read Line | Count | Source | 4369 | 315 | { | 4370 | 315 | size_t amt; | 4371 | | | 4372 | 315 | if (_bfd_mul_overflow (nmemb, size, &amt)) | 4373 | 0 | { | 4374 | 0 | bfd_set_error (bfd_error_file_too_big); | 4375 | 0 | return NULL; | 4376 | 0 | } | 4377 | 315 | if (bfd_seek (abfd, where, SEEK_SET) != 0) | 4378 | 139 | return NULL; | 4379 | 176 | return _bfd_malloc_and_read (abfd, amt, amt); | 4380 | 315 | } |
pei-aarch64.c:buy_and_read Line | Count | Source | 4369 | 95 | { | 4370 | 95 | size_t amt; | 4371 | | | 4372 | 95 | if (_bfd_mul_overflow (nmemb, size, &amt)) | 4373 | 0 | { | 4374 | 0 | bfd_set_error (bfd_error_file_too_big); | 4375 | 0 | return NULL; | 4376 | 0 | } | 4377 | 95 | if (bfd_seek (abfd, where, SEEK_SET) != 0) | 4378 | 0 | return NULL; | 4379 | 95 | return _bfd_malloc_and_read (abfd, amt, amt); | 4380 | 95 | } |
pe-aarch64.c:buy_and_read Line | Count | Source | 4369 | 1.41k | { | 4370 | 1.41k | size_t amt; | 4371 | | | 4372 | 1.41k | if (_bfd_mul_overflow (nmemb, size, &amt)) | 4373 | 0 | { | 4374 | 0 | bfd_set_error (bfd_error_file_too_big); | 4375 | 0 | return NULL; | 4376 | 0 | } | 4377 | 1.41k | if (bfd_seek (abfd, where, SEEK_SET) != 0) | 4378 | 0 | return NULL; | 4379 | 1.41k | return _bfd_malloc_and_read (abfd, amt, amt); | 4380 | 1.41k | } |
Line | Count | Source | 4369 | 118 | { | 4370 | 118 | size_t amt; | 4371 | | | 4372 | 118 | if (_bfd_mul_overflow (nmemb, size, &amt)) | 4373 | 0 | { | 4374 | 0 | bfd_set_error (bfd_error_file_too_big); | 4375 | 0 | return NULL; | 4376 | 0 | } | 4377 | 118 | if (bfd_seek (abfd, where, SEEK_SET) != 0) | 4378 | 0 | return NULL; | 4379 | 118 | return _bfd_malloc_and_read (abfd, amt, amt); | 4380 | 118 | } |
pei-loongarch64.c:buy_and_read Line | Count | Source | 4369 | 136 | { | 4370 | 136 | size_t amt; | 4371 | | | 4372 | 136 | if (_bfd_mul_overflow (nmemb, size, &amt)) | 4373 | 0 | { | 4374 | 0 | bfd_set_error (bfd_error_file_too_big); | 4375 | 0 | return NULL; | 4376 | 0 | } | 4377 | 136 | if (bfd_seek (abfd, where, SEEK_SET) != 0) | 4378 | 0 | return NULL; | 4379 | 136 | return _bfd_malloc_and_read (abfd, amt, amt); | 4380 | 136 | } |
Unexecuted instantiation: cf-i386lynx.c:buy_and_read Unexecuted instantiation: coff-go32.c:buy_and_read Unexecuted instantiation: coff-i386.c:buy_and_read coff-rs6000.c:buy_and_read Line | Count | Source | 4369 | 266 | { | 4370 | 266 | size_t amt; | 4371 | | | 4372 | 266 | if (_bfd_mul_overflow (nmemb, size, &amt)) | 4373 | 0 | { | 4374 | 0 | bfd_set_error (bfd_error_file_too_big); | 4375 | 0 | return NULL; | 4376 | 0 | } | 4377 | 266 | if (bfd_seek (abfd, where, SEEK_SET) != 0) | 4378 | 0 | return NULL; | 4379 | 266 | return _bfd_malloc_and_read (abfd, amt, amt); | 4380 | 266 | } |
Unexecuted instantiation: coff-sh.c:buy_and_read Unexecuted instantiation: coff-stgo32.c:buy_and_read coff-tic30.c:buy_and_read Line | Count | Source | 4369 | 1.06k | { | 4370 | 1.06k | size_t amt; | 4371 | | | 4372 | 1.06k | if (_bfd_mul_overflow (nmemb, size, &amt)) | 4373 | 0 | { | 4374 | 0 | bfd_set_error (bfd_error_file_too_big); | 4375 | 0 | return NULL; | 4376 | 0 | } | 4377 | 1.06k | if (bfd_seek (abfd, where, SEEK_SET) != 0) | 4378 | 0 | return NULL; | 4379 | 1.06k | return _bfd_malloc_and_read (abfd, amt, amt); | 4380 | 1.06k | } |
Unexecuted instantiation: coff-tic4x.c:buy_and_read coff-tic54x.c:buy_and_read Line | Count | Source | 4369 | 322 | { | 4370 | 322 | size_t amt; | 4371 | | | 4372 | 322 | if (_bfd_mul_overflow (nmemb, size, &amt)) | 4373 | 0 | { | 4374 | 0 | bfd_set_error (bfd_error_file_too_big); | 4375 | 0 | return NULL; | 4376 | 0 | } | 4377 | 322 | if (bfd_seek (abfd, where, SEEK_SET) != 0) | 4378 | 0 | return NULL; | 4379 | 322 | return _bfd_malloc_and_read (abfd, amt, amt); | 4380 | 322 | } |
Line | Count | Source | 4369 | 520 | { | 4370 | 520 | size_t amt; | 4371 | | | 4372 | 520 | if (_bfd_mul_overflow (nmemb, size, &amt)) | 4373 | 0 | { | 4374 | 0 | bfd_set_error (bfd_error_file_too_big); | 4375 | 0 | return NULL; | 4376 | 0 | } | 4377 | 520 | if (bfd_seek (abfd, where, SEEK_SET) != 0) | 4378 | 0 | return NULL; | 4379 | 520 | return _bfd_malloc_and_read (abfd, amt, amt); | 4380 | 520 | } |
Line | Count | Source | 4369 | 304 | { | 4370 | 304 | size_t amt; | 4371 | | | 4372 | 304 | if (_bfd_mul_overflow (nmemb, size, &amt)) | 4373 | 0 | { | 4374 | 0 | bfd_set_error (bfd_error_file_too_big); | 4375 | 0 | return NULL; | 4376 | 0 | } | 4377 | 304 | if (bfd_seek (abfd, where, SEEK_SET) != 0) | 4378 | 0 | return NULL; | 4379 | 304 | return _bfd_malloc_and_read (abfd, amt, amt); | 4380 | 304 | } |
Unexecuted instantiation: pe-arm-wince.c:buy_and_read Unexecuted instantiation: pe-arm.c:buy_and_read Line | Count | Source | 4369 | 280 | { | 4370 | 280 | size_t amt; | 4371 | | | 4372 | 280 | if (_bfd_mul_overflow (nmemb, size, &amt)) | 4373 | 0 | { | 4374 | 0 | bfd_set_error (bfd_error_file_too_big); | 4375 | 0 | return NULL; | 4376 | 0 | } | 4377 | 280 | if (bfd_seek (abfd, where, SEEK_SET) != 0) | 4378 | 0 | return NULL; | 4379 | 280 | return _bfd_malloc_and_read (abfd, amt, amt); | 4380 | 280 | } |
Line | Count | Source | 4369 | 378 | { | 4370 | 378 | size_t amt; | 4371 | | | 4372 | 378 | if (_bfd_mul_overflow (nmemb, size, &amt)) | 4373 | 0 | { | 4374 | 0 | bfd_set_error (bfd_error_file_too_big); | 4375 | 0 | return NULL; | 4376 | 0 | } | 4377 | 378 | if (bfd_seek (abfd, where, SEEK_SET) != 0) | 4378 | 0 | return NULL; | 4379 | 378 | return _bfd_malloc_and_read (abfd, amt, amt); | 4380 | 378 | } |
Line | Count | Source | 4369 | 216 | { | 4370 | 216 | size_t amt; | 4371 | | | 4372 | 216 | if (_bfd_mul_overflow (nmemb, size, &amt)) | 4373 | 0 | { | 4374 | 0 | bfd_set_error (bfd_error_file_too_big); | 4375 | 0 | return NULL; | 4376 | 0 | } | 4377 | 216 | if (bfd_seek (abfd, where, SEEK_SET) != 0) | 4378 | 0 | return NULL; | 4379 | 216 | return _bfd_malloc_and_read (abfd, amt, amt); | 4380 | 216 | } |
pei-arm-wince.c:buy_and_read Line | Count | Source | 4369 | 117 | { | 4370 | 117 | size_t amt; | 4371 | | | 4372 | 117 | if (_bfd_mul_overflow (nmemb, size, &amt)) | 4373 | 0 | { | 4374 | 0 | bfd_set_error (bfd_error_file_too_big); | 4375 | 0 | return NULL; | 4376 | 0 | } | 4377 | 117 | if (bfd_seek (abfd, where, SEEK_SET) != 0) | 4378 | 0 | return NULL; | 4379 | 117 | return _bfd_malloc_and_read (abfd, amt, amt); | 4380 | 117 | } |
Line | Count | Source | 4369 | 167 | { | 4370 | 167 | size_t amt; | 4371 | | | 4372 | 167 | if (_bfd_mul_overflow (nmemb, size, &amt)) | 4373 | 0 | { | 4374 | 0 | bfd_set_error (bfd_error_file_too_big); | 4375 | 0 | return NULL; | 4376 | 0 | } | 4377 | 167 | if (bfd_seek (abfd, where, SEEK_SET) != 0) | 4378 | 0 | return NULL; | 4379 | 167 | return _bfd_malloc_and_read (abfd, amt, amt); | 4380 | 167 | } |
Line | Count | Source | 4369 | 114 | { | 4370 | 114 | size_t amt; | 4371 | | | 4372 | 114 | if (_bfd_mul_overflow (nmemb, size, &amt)) | 4373 | 0 | { | 4374 | 0 | bfd_set_error (bfd_error_file_too_big); | 4375 | 0 | return NULL; | 4376 | 0 | } | 4377 | 114 | if (bfd_seek (abfd, where, SEEK_SET) != 0) | 4378 | 0 | return NULL; | 4379 | 114 | return _bfd_malloc_and_read (abfd, amt, amt); | 4380 | 114 | } |
Line | Count | Source | 4369 | 101 | { | 4370 | 101 | size_t amt; | 4371 | | | 4372 | 101 | if (_bfd_mul_overflow (nmemb, size, &amt)) | 4373 | 0 | { | 4374 | 0 | bfd_set_error (bfd_error_file_too_big); | 4375 | 0 | return NULL; | 4376 | 0 | } | 4377 | 101 | if (bfd_seek (abfd, where, SEEK_SET) != 0) | 4378 | 0 | return NULL; | 4379 | 101 | return _bfd_malloc_and_read (abfd, amt, amt); | 4380 | 101 | } |
|
4381 | | |
4382 | | /* |
4383 | | SUBSUBSECTION |
4384 | | Reading linenumbers |
4385 | | |
4386 | | Creating the linenumber table is done by reading in the entire |
4387 | | coff linenumber table, and creating another table for internal use. |
4388 | | |
4389 | | A coff linenumber table is structured so that each function |
4390 | | is marked as having a line number of 0. Each line within the |
4391 | | function is an offset from the first line in the function. The |
4392 | | base of the line number information for the table is stored in |
4393 | | the symbol associated with the function. |
4394 | | |
4395 | | Note: The PE format uses line number 0 for a flag indicating a |
4396 | | new source file. |
4397 | | |
4398 | | The information is copied from the external to the internal |
4399 | | table, and each symbol which marks a function is marked by |
4400 | | pointing its... |
4401 | | |
4402 | | How does this work ? |
4403 | | */ |
4404 | | |
4405 | | static int |
4406 | | coff_sort_func_alent (const void * arg1, const void * arg2) |
4407 | 3.89M | { |
4408 | 3.89M | const alent *al1 = *(const alent **) arg1; |
4409 | 3.89M | const alent *al2 = *(const alent **) arg2; |
4410 | 3.89M | const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym); |
4411 | 3.89M | const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym); |
4412 | | |
4413 | 3.89M | if (s1 == NULL || s2 == NULL) |
4414 | 0 | return 0; |
4415 | 3.89M | if (s1->symbol.value < s2->symbol.value) |
4416 | 31.8k | return -1; |
4417 | 3.86M | else if (s1->symbol.value > s2->symbol.value) |
4418 | 674k | return 1; |
4419 | | |
4420 | 3.19M | return 0; |
4421 | 3.89M | } pei-i386.c:coff_sort_func_alent Line | Count | Source | 4407 | 306k | { | 4408 | 306k | const alent *al1 = *(const alent **) arg1; | 4409 | 306k | const alent *al2 = *(const alent **) arg2; | 4410 | 306k | const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym); | 4411 | 306k | const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym); | 4412 | | | 4413 | 306k | if (s1 == NULL || s2 == NULL) | 4414 | 0 | return 0; | 4415 | 306k | if (s1->symbol.value < s2->symbol.value) | 4416 | 2.65k | return -1; | 4417 | 304k | else if (s1->symbol.value > s2->symbol.value) | 4418 | 34.1k | return 1; | 4419 | | | 4420 | 270k | return 0; | 4421 | 306k | } |
pe-x86_64.c:coff_sort_func_alent Line | Count | Source | 4407 | 306k | { | 4408 | 306k | const alent *al1 = *(const alent **) arg1; | 4409 | 306k | const alent *al2 = *(const alent **) arg2; | 4410 | 306k | const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym); | 4411 | 306k | const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym); | 4412 | | | 4413 | 306k | if (s1 == NULL || s2 == NULL) | 4414 | 0 | return 0; | 4415 | 306k | if (s1->symbol.value < s2->symbol.value) | 4416 | 2.24k | return -1; | 4417 | 304k | else if (s1->symbol.value > s2->symbol.value) | 4418 | 62.1k | return 1; | 4419 | | | 4420 | 242k | return 0; | 4421 | 306k | } |
pei-x86_64.c:coff_sort_func_alent Line | Count | Source | 4407 | 138k | { | 4408 | 138k | const alent *al1 = *(const alent **) arg1; | 4409 | 138k | const alent *al2 = *(const alent **) arg2; | 4410 | 138k | const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym); | 4411 | 138k | const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym); | 4412 | | | 4413 | 138k | if (s1 == NULL || s2 == NULL) | 4414 | 0 | return 0; | 4415 | 138k | if (s1->symbol.value < s2->symbol.value) | 4416 | 861 | return -1; | 4417 | 137k | else if (s1->symbol.value > s2->symbol.value) | 4418 | 2.59k | return 1; | 4419 | | | 4420 | 134k | return 0; | 4421 | 138k | } |
coff-x86_64.c:coff_sort_func_alent Line | Count | Source | 4407 | 417k | { | 4408 | 417k | const alent *al1 = *(const alent **) arg1; | 4409 | 417k | const alent *al2 = *(const alent **) arg2; | 4410 | 417k | const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym); | 4411 | 417k | const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym); | 4412 | | | 4413 | 417k | if (s1 == NULL || s2 == NULL) | 4414 | 0 | return 0; | 4415 | 417k | if (s1->symbol.value < s2->symbol.value) | 4416 | 2.65k | return -1; | 4417 | 415k | else if (s1->symbol.value > s2->symbol.value) | 4418 | 80.9k | return 1; | 4419 | | | 4420 | 334k | return 0; | 4421 | 417k | } |
coff64-rs6000.c:coff_sort_func_alent Line | Count | Source | 4407 | 442k | { | 4408 | 442k | const alent *al1 = *(const alent **) arg1; | 4409 | 442k | const alent *al2 = *(const alent **) arg2; | 4410 | 442k | const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym); | 4411 | 442k | const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym); | 4412 | | | 4413 | 442k | if (s1 == NULL || s2 == NULL) | 4414 | 0 | return 0; | 4415 | 442k | if (s1->symbol.value < s2->symbol.value) | 4416 | 4.78k | return -1; | 4417 | 437k | else if (s1->symbol.value > s2->symbol.value) | 4418 | 34.6k | return 1; | 4419 | | | 4420 | 403k | return 0; | 4421 | 442k | } |
pei-aarch64.c:coff_sort_func_alent Line | Count | Source | 4407 | 51.3k | { | 4408 | 51.3k | const alent *al1 = *(const alent **) arg1; | 4409 | 51.3k | const alent *al2 = *(const alent **) arg2; | 4410 | 51.3k | const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym); | 4411 | 51.3k | const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym); | 4412 | | | 4413 | 51.3k | if (s1 == NULL || s2 == NULL) | 4414 | 0 | return 0; | 4415 | 51.3k | if (s1->symbol.value < s2->symbol.value) | 4416 | 217 | return -1; | 4417 | 51.1k | else if (s1->symbol.value > s2->symbol.value) | 4418 | 6.76k | return 1; | 4419 | | | 4420 | 44.3k | return 0; | 4421 | 51.3k | } |
pe-aarch64.c:coff_sort_func_alent Line | Count | Source | 4407 | 25.4k | { | 4408 | 25.4k | const alent *al1 = *(const alent **) arg1; | 4409 | 25.4k | const alent *al2 = *(const alent **) arg2; | 4410 | 25.4k | const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym); | 4411 | 25.4k | const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym); | 4412 | | | 4413 | 25.4k | if (s1 == NULL || s2 == NULL) | 4414 | 0 | return 0; | 4415 | 25.4k | if (s1->symbol.value < s2->symbol.value) | 4416 | 310 | return -1; | 4417 | 25.1k | else if (s1->symbol.value > s2->symbol.value) | 4418 | 5.59k | return 1; | 4419 | | | 4420 | 19.5k | return 0; | 4421 | 25.4k | } |
pei-ia64.c:coff_sort_func_alent Line | Count | Source | 4407 | 10.5k | { | 4408 | 10.5k | const alent *al1 = *(const alent **) arg1; | 4409 | 10.5k | const alent *al2 = *(const alent **) arg2; | 4410 | 10.5k | const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym); | 4411 | 10.5k | const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym); | 4412 | | | 4413 | 10.5k | if (s1 == NULL || s2 == NULL) | 4414 | 0 | return 0; | 4415 | 10.5k | if (s1->symbol.value < s2->symbol.value) | 4416 | 225 | return -1; | 4417 | 10.3k | else if (s1->symbol.value > s2->symbol.value) | 4418 | 1.48k | return 1; | 4419 | | | 4420 | 8.84k | return 0; | 4421 | 10.5k | } |
pei-loongarch64.c:coff_sort_func_alent Line | Count | Source | 4407 | 325k | { | 4408 | 325k | const alent *al1 = *(const alent **) arg1; | 4409 | 325k | const alent *al2 = *(const alent **) arg2; | 4410 | 325k | const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym); | 4411 | 325k | const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym); | 4412 | | | 4413 | 325k | if (s1 == NULL || s2 == NULL) | 4414 | 0 | return 0; | 4415 | 325k | if (s1->symbol.value < s2->symbol.value) | 4416 | 396 | return -1; | 4417 | 325k | else if (s1->symbol.value > s2->symbol.value) | 4418 | 65.6k | return 1; | 4419 | | | 4420 | 259k | return 0; | 4421 | 325k | } |
Unexecuted instantiation: cf-i386lynx.c:coff_sort_func_alent Unexecuted instantiation: coff-go32.c:coff_sort_func_alent Unexecuted instantiation: coff-i386.c:coff_sort_func_alent coff-rs6000.c:coff_sort_func_alent Line | Count | Source | 4407 | 156k | { | 4408 | 156k | const alent *al1 = *(const alent **) arg1; | 4409 | 156k | const alent *al2 = *(const alent **) arg2; | 4410 | 156k | const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym); | 4411 | 156k | const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym); | 4412 | | | 4413 | 156k | if (s1 == NULL || s2 == NULL) | 4414 | 0 | return 0; | 4415 | 156k | if (s1->symbol.value < s2->symbol.value) | 4416 | 1.09k | return -1; | 4417 | 154k | else if (s1->symbol.value > s2->symbol.value) | 4418 | 36.3k | return 1; | 4419 | | | 4420 | 118k | return 0; | 4421 | 156k | } |
Unexecuted instantiation: coff-sh.c:coff_sort_func_alent Unexecuted instantiation: coff-stgo32.c:coff_sort_func_alent coff-tic30.c:coff_sort_func_alent Line | Count | Source | 4407 | 251k | { | 4408 | 251k | const alent *al1 = *(const alent **) arg1; | 4409 | 251k | const alent *al2 = *(const alent **) arg2; | 4410 | 251k | const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym); | 4411 | 251k | const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym); | 4412 | | | 4413 | 251k | if (s1 == NULL || s2 == NULL) | 4414 | 0 | return 0; | 4415 | 251k | if (s1->symbol.value < s2->symbol.value) | 4416 | 1.73k | return -1; | 4417 | 249k | else if (s1->symbol.value > s2->symbol.value) | 4418 | 43.8k | return 1; | 4419 | | | 4420 | 205k | return 0; | 4421 | 251k | } |
Unexecuted instantiation: coff-tic4x.c:coff_sort_func_alent coff-tic54x.c:coff_sort_func_alent Line | Count | Source | 4407 | 369k | { | 4408 | 369k | const alent *al1 = *(const alent **) arg1; | 4409 | 369k | const alent *al2 = *(const alent **) arg2; | 4410 | 369k | const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym); | 4411 | 369k | const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym); | 4412 | | | 4413 | 369k | if (s1 == NULL || s2 == NULL) | 4414 | 0 | return 0; | 4415 | 369k | if (s1->symbol.value < s2->symbol.value) | 4416 | 1.88k | return -1; | 4417 | 367k | else if (s1->symbol.value > s2->symbol.value) | 4418 | 53.8k | return 1; | 4419 | | | 4420 | 313k | return 0; | 4421 | 369k | } |
coff-z80.c:coff_sort_func_alent Line | Count | Source | 4407 | 121k | { | 4408 | 121k | const alent *al1 = *(const alent **) arg1; | 4409 | 121k | const alent *al2 = *(const alent **) arg2; | 4410 | 121k | const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym); | 4411 | 121k | const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym); | 4412 | | | 4413 | 121k | if (s1 == NULL || s2 == NULL) | 4414 | 0 | return 0; | 4415 | 121k | if (s1->symbol.value < s2->symbol.value) | 4416 | 1.87k | return -1; | 4417 | 119k | else if (s1->symbol.value > s2->symbol.value) | 4418 | 26.3k | return 1; | 4419 | | | 4420 | 93.6k | return 0; | 4421 | 121k | } |
coff-z8k.c:coff_sort_func_alent Line | Count | Source | 4407 | 211k | { | 4408 | 211k | const alent *al1 = *(const alent **) arg1; | 4409 | 211k | const alent *al2 = *(const alent **) arg2; | 4410 | 211k | const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym); | 4411 | 211k | const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym); | 4412 | | | 4413 | 211k | if (s1 == NULL || s2 == NULL) | 4414 | 0 | return 0; | 4415 | 211k | if (s1->symbol.value < s2->symbol.value) | 4416 | 889 | return -1; | 4417 | 210k | else if (s1->symbol.value > s2->symbol.value) | 4418 | 54.8k | return 1; | 4419 | | | 4420 | 155k | return 0; | 4421 | 211k | } |
Unexecuted instantiation: pe-arm-wince.c:coff_sort_func_alent Unexecuted instantiation: pe-arm.c:coff_sort_func_alent pe-i386.c:coff_sort_func_alent Line | Count | Source | 4407 | 147k | { | 4408 | 147k | const alent *al1 = *(const alent **) arg1; | 4409 | 147k | const alent *al2 = *(const alent **) arg2; | 4410 | 147k | const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym); | 4411 | 147k | const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym); | 4412 | | | 4413 | 147k | if (s1 == NULL || s2 == NULL) | 4414 | 0 | return 0; | 4415 | 147k | if (s1->symbol.value < s2->symbol.value) | 4416 | 2.39k | return -1; | 4417 | 144k | else if (s1->symbol.value > s2->symbol.value) | 4418 | 29.0k | return 1; | 4419 | | | 4420 | 115k | return 0; | 4421 | 147k | } |
pe-mcore.c:coff_sort_func_alent Line | Count | Source | 4407 | 111k | { | 4408 | 111k | const alent *al1 = *(const alent **) arg1; | 4409 | 111k | const alent *al2 = *(const alent **) arg2; | 4410 | 111k | const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym); | 4411 | 111k | const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym); | 4412 | | | 4413 | 111k | if (s1 == NULL || s2 == NULL) | 4414 | 0 | return 0; | 4415 | 111k | if (s1->symbol.value < s2->symbol.value) | 4416 | 185 | return -1; | 4417 | 110k | else if (s1->symbol.value > s2->symbol.value) | 4418 | 19.9k | return 1; | 4419 | | | 4420 | 90.9k | return 0; | 4421 | 111k | } |
pe-sh.c:coff_sort_func_alent Line | Count | Source | 4407 | 239k | { | 4408 | 239k | const alent *al1 = *(const alent **) arg1; | 4409 | 239k | const alent *al2 = *(const alent **) arg2; | 4410 | 239k | const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym); | 4411 | 239k | const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym); | 4412 | | | 4413 | 239k | if (s1 == NULL || s2 == NULL) | 4414 | 0 | return 0; | 4415 | 239k | if (s1->symbol.value < s2->symbol.value) | 4416 | 5.69k | return -1; | 4417 | 233k | else if (s1->symbol.value > s2->symbol.value) | 4418 | 87.8k | return 1; | 4419 | | | 4420 | 145k | return 0; | 4421 | 239k | } |
pei-arm-wince.c:coff_sort_func_alent Line | Count | Source | 4407 | 10.5k | { | 4408 | 10.5k | const alent *al1 = *(const alent **) arg1; | 4409 | 10.5k | const alent *al2 = *(const alent **) arg2; | 4410 | 10.5k | const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym); | 4411 | 10.5k | const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym); | 4412 | | | 4413 | 10.5k | if (s1 == NULL || s2 == NULL) | 4414 | 0 | return 0; | 4415 | 10.5k | if (s1->symbol.value < s2->symbol.value) | 4416 | 73 | return -1; | 4417 | 10.4k | else if (s1->symbol.value > s2->symbol.value) | 4418 | 2.37k | return 1; | 4419 | | | 4420 | 8.05k | return 0; | 4421 | 10.5k | } |
pei-arm.c:coff_sort_func_alent Line | Count | Source | 4407 | 76.1k | { | 4408 | 76.1k | const alent *al1 = *(const alent **) arg1; | 4409 | 76.1k | const alent *al2 = *(const alent **) arg2; | 4410 | 76.1k | const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym); | 4411 | 76.1k | const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym); | 4412 | | | 4413 | 76.1k | if (s1 == NULL || s2 == NULL) | 4414 | 0 | return 0; | 4415 | 76.1k | if (s1->symbol.value < s2->symbol.value) | 4416 | 429 | return -1; | 4417 | 75.7k | else if (s1->symbol.value > s2->symbol.value) | 4418 | 12.2k | return 1; | 4419 | | | 4420 | 63.4k | return 0; | 4421 | 76.1k | } |
pei-mcore.c:coff_sort_func_alent Line | Count | Source | 4407 | 84.5k | { | 4408 | 84.5k | const alent *al1 = *(const alent **) arg1; | 4409 | 84.5k | const alent *al2 = *(const alent **) arg2; | 4410 | 84.5k | const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym); | 4411 | 84.5k | const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym); | 4412 | | | 4413 | 84.5k | if (s1 == NULL || s2 == NULL) | 4414 | 0 | return 0; | 4415 | 84.5k | if (s1->symbol.value < s2->symbol.value) | 4416 | 530 | return -1; | 4417 | 83.9k | else if (s1->symbol.value > s2->symbol.value) | 4418 | 1.69k | return 1; | 4419 | | | 4420 | 82.2k | return 0; | 4421 | 84.5k | } |
pei-sh.c:coff_sort_func_alent Line | Count | Source | 4407 | 94.5k | { | 4408 | 94.5k | const alent *al1 = *(const alent **) arg1; | 4409 | 94.5k | const alent *al2 = *(const alent **) arg2; | 4410 | 94.5k | const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym); | 4411 | 94.5k | const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym); | 4412 | | | 4413 | 94.5k | if (s1 == NULL || s2 == NULL) | 4414 | 0 | return 0; | 4415 | 94.5k | if (s1->symbol.value < s2->symbol.value) | 4416 | 734 | return -1; | 4417 | 93.7k | else if (s1->symbol.value > s2->symbol.value) | 4418 | 12.4k | return 1; | 4419 | | | 4420 | 81.3k | return 0; | 4421 | 94.5k | } |
|
4422 | | |
4423 | | static bool |
4424 | | coff_slurp_line_table (bfd *abfd, asection *asect) |
4425 | 24.9k | { |
4426 | 24.9k | LINENO *native_lineno; |
4427 | 24.9k | alent *lineno_cache; |
4428 | 24.9k | unsigned int counter; |
4429 | 24.9k | alent *cache_ptr; |
4430 | 24.9k | bfd_vma prev_offset = 0; |
4431 | 24.9k | bool ordered = true; |
4432 | 24.9k | unsigned int nbr_func; |
4433 | 24.9k | LINENO *src; |
4434 | 24.9k | bool have_func; |
4435 | 24.9k | bool ret = true; |
4436 | 24.9k | size_t amt; |
4437 | | |
4438 | 24.9k | if (asect->lineno_count == 0) |
4439 | 21.1k | return true; |
4440 | | |
4441 | 3.87k | BFD_ASSERT (asect->lineno == NULL); |
4442 | | |
4443 | 3.87k | native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, |
4444 | 3.87k | asect->lineno_count, |
4445 | 3.87k | bfd_coff_linesz (abfd)); |
4446 | 3.87k | if (native_lineno == NULL) |
4447 | 1.44k | { |
4448 | 1.44k | _bfd_error_handler |
4449 | 1.44k | (_("%pB: warning: line number table read failed"), abfd); |
4450 | 1.44k | return false; |
4451 | 1.44k | } |
4452 | | |
4453 | 2.43k | if (_bfd_mul_overflow (asect->lineno_count + 1, sizeof (alent), &amt)) |
4454 | 0 | { |
4455 | 0 | bfd_set_error (bfd_error_file_too_big); |
4456 | 0 | free (native_lineno); |
4457 | 0 | return false; |
4458 | 0 | } |
4459 | 2.43k | lineno_cache = (alent *) bfd_alloc (abfd, amt); |
4460 | 2.43k | if (lineno_cache == NULL) |
4461 | 0 | { |
4462 | 0 | free (native_lineno); |
4463 | 0 | return false; |
4464 | 0 | } |
4465 | | |
4466 | 2.43k | cache_ptr = lineno_cache; |
4467 | 2.43k | asect->lineno = lineno_cache; |
4468 | 2.43k | src = native_lineno; |
4469 | 2.43k | nbr_func = 0; |
4470 | 2.43k | have_func = false; |
4471 | | |
4472 | 2.94M | for (counter = 0; counter < asect->lineno_count; counter++, src++) |
4473 | 2.94M | { |
4474 | 2.94M | struct internal_lineno dst; |
4475 | | |
4476 | 2.94M | bfd_coff_swap_lineno_in (abfd, src, &dst); |
4477 | 2.94M | cache_ptr->line_number = dst.l_lnno; |
4478 | | /* Appease memory checkers that get all excited about |
4479 | | uninitialised memory when copying alents if u.offset is |
4480 | | larger than u.sym. (64-bit BFD on 32-bit host.) */ |
4481 | 2.94M | memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); |
4482 | | |
4483 | 2.94M | if (cache_ptr->line_number == 0) |
4484 | 1.22M | { |
4485 | 1.22M | combined_entry_type * ent; |
4486 | 1.22M | unsigned long symndx; |
4487 | 1.22M | coff_symbol_type *sym; |
4488 | | |
4489 | 1.22M | have_func = false; |
4490 | 1.22M | symndx = dst.l_addr.l_symndx; |
4491 | 1.22M | if (symndx >= obj_raw_syment_count (abfd)) |
4492 | 444k | { |
4493 | 444k | _bfd_error_handler |
4494 | | /* xgettext:c-format */ |
4495 | 444k | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), |
4496 | 444k | abfd, symndx, counter); |
4497 | 444k | cache_ptr->line_number = -1; |
4498 | 444k | ret = false; |
4499 | 444k | continue; |
4500 | 444k | } |
4501 | | |
4502 | 779k | ent = obj_raw_syments (abfd) + symndx; |
4503 | | /* FIXME: We should not be casting between ints and |
4504 | | pointers like this. */ |
4505 | 779k | if (! ent->is_sym) |
4506 | 76.1k | { |
4507 | 76.1k | _bfd_error_handler |
4508 | | /* xgettext:c-format */ |
4509 | 76.1k | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), |
4510 | 76.1k | abfd, symndx, counter); |
4511 | 76.1k | cache_ptr->line_number = -1; |
4512 | 76.1k | ret = false; |
4513 | 76.1k | continue; |
4514 | 76.1k | } |
4515 | 702k | sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); |
4516 | | |
4517 | | /* PR 17512 file: 078-10659-0.004 */ |
4518 | 702k | if (sym < obj_symbols (abfd) |
4519 | 702k | || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd)) |
4520 | 0 | { |
4521 | 0 | _bfd_error_handler |
4522 | | /* xgettext:c-format */ |
4523 | 0 | (_("%pB: warning: illegal symbol in line number entry %d"), |
4524 | 0 | abfd, counter); |
4525 | 0 | cache_ptr->line_number = -1; |
4526 | 0 | ret = false; |
4527 | 0 | continue; |
4528 | 0 | } |
4529 | | |
4530 | 702k | have_func = true; |
4531 | 702k | nbr_func++; |
4532 | 702k | cache_ptr->u.sym = (asymbol *) sym; |
4533 | 702k | if (sym->lineno != NULL) |
4534 | 695k | _bfd_error_handler |
4535 | | /* xgettext:c-format */ |
4536 | 695k | (_("%pB: warning: duplicate line number information for `%s'"), |
4537 | 695k | abfd, bfd_asymbol_name (&sym->symbol)); |
4538 | | |
4539 | 702k | sym->lineno = cache_ptr; |
4540 | 702k | if (sym->symbol.value < prev_offset) |
4541 | 13.6k | ordered = false; |
4542 | 702k | prev_offset = sym->symbol.value; |
4543 | 702k | } |
4544 | 1.72M | else if (!have_func) |
4545 | | /* Drop line information that has no associated function. |
4546 | | PR 17521: file: 078-10659-0.004. */ |
4547 | 1.02M | continue; |
4548 | 694k | else |
4549 | 694k | cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect); |
4550 | 1.39M | cache_ptr++; |
4551 | 1.39M | } |
4552 | | |
4553 | 2.43k | asect->lineno_count = cache_ptr - lineno_cache; |
4554 | 2.43k | memset (cache_ptr, 0, sizeof (*cache_ptr)); |
4555 | 2.43k | free (native_lineno); |
4556 | | |
4557 | | /* On some systems (eg AIX5.3) the lineno table may not be sorted. */ |
4558 | 2.43k | if (!ordered) |
4559 | 1.02k | { |
4560 | | /* Sort the table. */ |
4561 | 1.02k | alent **func_table; |
4562 | 1.02k | alent *n_lineno_cache; |
4563 | | |
4564 | | /* Create a table of functions. */ |
4565 | 1.02k | if (_bfd_mul_overflow (nbr_func, sizeof (alent *), &amt)) |
4566 | 0 | { |
4567 | 0 | bfd_set_error (bfd_error_file_too_big); |
4568 | 0 | ret = false; |
4569 | 0 | } |
4570 | 1.02k | else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL) |
4571 | 1.02k | { |
4572 | 1.02k | alent **p = func_table; |
4573 | 1.02k | unsigned int i; |
4574 | | |
4575 | 1.23M | for (i = 0; i < asect->lineno_count; i++) |
4576 | 1.23M | if (lineno_cache[i].line_number == 0) |
4577 | 590k | *p++ = &lineno_cache[i]; |
4578 | | |
4579 | 1.02k | BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func); |
4580 | | |
4581 | | /* Sort by functions. */ |
4582 | 1.02k | qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent); |
4583 | | |
4584 | | /* Create the new sorted table. */ |
4585 | 1.02k | if (_bfd_mul_overflow (asect->lineno_count, sizeof (alent), &amt)) |
4586 | 0 | { |
4587 | 0 | bfd_set_error (bfd_error_file_too_big); |
4588 | 0 | ret = false; |
4589 | 0 | } |
4590 | 1.02k | else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL) |
4591 | 1.02k | { |
4592 | 1.02k | alent *n_cache_ptr = n_lineno_cache; |
4593 | | |
4594 | 591k | for (i = 0; i < nbr_func; i++) |
4595 | 590k | { |
4596 | 590k | coff_symbol_type *sym; |
4597 | 590k | alent *old_ptr = func_table[i]; |
4598 | | |
4599 | | /* Update the function entry. */ |
4600 | 590k | sym = (coff_symbol_type *) old_ptr->u.sym; |
4601 | | /* PR binutils/17512: Point the lineno to where |
4602 | | this entry will be after the memcpy below. */ |
4603 | 590k | sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); |
4604 | | /* Copy the function and line number entries. */ |
4605 | 590k | do |
4606 | 1.23M | *n_cache_ptr++ = *old_ptr++; |
4607 | 1.23M | while (old_ptr->line_number != 0); |
4608 | 590k | } |
4609 | | |
4610 | 1.02k | memcpy (lineno_cache, n_lineno_cache, |
4611 | 1.02k | asect->lineno_count * sizeof (alent)); |
4612 | 1.02k | } |
4613 | 0 | else |
4614 | 0 | ret = false; |
4615 | 1.02k | bfd_release (abfd, func_table); |
4616 | 1.02k | } |
4617 | 0 | else |
4618 | 0 | ret = false; |
4619 | 1.02k | } |
4620 | | |
4621 | 2.43k | return ret; |
4622 | 2.43k | } pei-i386.c:coff_slurp_line_table Line | Count | Source | 4425 | 508 | { | 4426 | 508 | LINENO *native_lineno; | 4427 | 508 | alent *lineno_cache; | 4428 | 508 | unsigned int counter; | 4429 | 508 | alent *cache_ptr; | 4430 | 508 | bfd_vma prev_offset = 0; | 4431 | 508 | bool ordered = true; | 4432 | 508 | unsigned int nbr_func; | 4433 | 508 | LINENO *src; | 4434 | 508 | bool have_func; | 4435 | 508 | bool ret = true; | 4436 | 508 | size_t amt; | 4437 | | | 4438 | 508 | if (asect->lineno_count == 0) | 4439 | 334 | return true; | 4440 | | | 4441 | 174 | BFD_ASSERT (asect->lineno == NULL); | 4442 | | | 4443 | 174 | native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, | 4444 | 174 | asect->lineno_count, | 4445 | 174 | bfd_coff_linesz (abfd)); | 4446 | 174 | if (native_lineno == NULL) | 4447 | 55 | { | 4448 | 55 | _bfd_error_handler | 4449 | 55 | (_("%pB: warning: line number table read failed"), abfd); | 4450 | 55 | return false; | 4451 | 55 | } | 4452 | | | 4453 | 119 | if (_bfd_mul_overflow (asect->lineno_count + 1, sizeof (alent), &amt)) | 4454 | 0 | { | 4455 | 0 | bfd_set_error (bfd_error_file_too_big); | 4456 | 0 | free (native_lineno); | 4457 | 0 | return false; | 4458 | 0 | } | 4459 | 119 | lineno_cache = (alent *) bfd_alloc (abfd, amt); | 4460 | 119 | if (lineno_cache == NULL) | 4461 | 0 | { | 4462 | 0 | free (native_lineno); | 4463 | 0 | return false; | 4464 | 0 | } | 4465 | | | 4466 | 119 | cache_ptr = lineno_cache; | 4467 | 119 | asect->lineno = lineno_cache; | 4468 | 119 | src = native_lineno; | 4469 | 119 | nbr_func = 0; | 4470 | 119 | have_func = false; | 4471 | | | 4472 | 216k | for (counter = 0; counter < asect->lineno_count; counter++, src++) | 4473 | 216k | { | 4474 | 216k | struct internal_lineno dst; | 4475 | | | 4476 | 216k | bfd_coff_swap_lineno_in (abfd, src, &dst); | 4477 | 216k | cache_ptr->line_number = dst.l_lnno; | 4478 | | /* Appease memory checkers that get all excited about | 4479 | | uninitialised memory when copying alents if u.offset is | 4480 | | larger than u.sym. (64-bit BFD on 32-bit host.) */ | 4481 | 216k | memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); | 4482 | | | 4483 | 216k | if (cache_ptr->line_number == 0) | 4484 | 112k | { | 4485 | 112k | combined_entry_type * ent; | 4486 | 112k | unsigned long symndx; | 4487 | 112k | coff_symbol_type *sym; | 4488 | | | 4489 | 112k | have_func = false; | 4490 | 112k | symndx = dst.l_addr.l_symndx; | 4491 | 112k | if (symndx >= obj_raw_syment_count (abfd)) | 4492 | 45.7k | { | 4493 | 45.7k | _bfd_error_handler | 4494 | | /* xgettext:c-format */ | 4495 | 45.7k | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4496 | 45.7k | abfd, symndx, counter); | 4497 | 45.7k | cache_ptr->line_number = -1; | 4498 | 45.7k | ret = false; | 4499 | 45.7k | continue; | 4500 | 45.7k | } | 4501 | | | 4502 | 66.3k | ent = obj_raw_syments (abfd) + symndx; | 4503 | | /* FIXME: We should not be casting between ints and | 4504 | | pointers like this. */ | 4505 | 66.3k | if (! ent->is_sym) | 4506 | 10.8k | { | 4507 | 10.8k | _bfd_error_handler | 4508 | | /* xgettext:c-format */ | 4509 | 10.8k | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4510 | 10.8k | abfd, symndx, counter); | 4511 | 10.8k | cache_ptr->line_number = -1; | 4512 | 10.8k | ret = false; | 4513 | 10.8k | continue; | 4514 | 10.8k | } | 4515 | 55.4k | sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); | 4516 | | | 4517 | | /* PR 17512 file: 078-10659-0.004 */ | 4518 | 55.4k | if (sym < obj_symbols (abfd) | 4519 | 55.4k | || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd)) | 4520 | 0 | { | 4521 | 0 | _bfd_error_handler | 4522 | | /* xgettext:c-format */ | 4523 | 0 | (_("%pB: warning: illegal symbol in line number entry %d"), | 4524 | 0 | abfd, counter); | 4525 | 0 | cache_ptr->line_number = -1; | 4526 | 0 | ret = false; | 4527 | 0 | continue; | 4528 | 0 | } | 4529 | | | 4530 | 55.4k | have_func = true; | 4531 | 55.4k | nbr_func++; | 4532 | 55.4k | cache_ptr->u.sym = (asymbol *) sym; | 4533 | 55.4k | if (sym->lineno != NULL) | 4534 | 54.8k | _bfd_error_handler | 4535 | | /* xgettext:c-format */ | 4536 | 54.8k | (_("%pB: warning: duplicate line number information for `%s'"), | 4537 | 54.8k | abfd, bfd_asymbol_name (&sym->symbol)); | 4538 | | | 4539 | 55.4k | sym->lineno = cache_ptr; | 4540 | 55.4k | if (sym->symbol.value < prev_offset) | 4541 | 744 | ordered = false; | 4542 | 55.4k | prev_offset = sym->symbol.value; | 4543 | 55.4k | } | 4544 | 104k | else if (!have_func) | 4545 | | /* Drop line information that has no associated function. | 4546 | | PR 17521: file: 078-10659-0.004. */ | 4547 | 65.5k | continue; | 4548 | 38.6k | else | 4549 | 38.6k | cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect); | 4550 | 94.0k | cache_ptr++; | 4551 | 94.0k | } | 4552 | | | 4553 | 119 | asect->lineno_count = cache_ptr - lineno_cache; | 4554 | 119 | memset (cache_ptr, 0, sizeof (*cache_ptr)); | 4555 | 119 | free (native_lineno); | 4556 | | | 4557 | | /* On some systems (eg AIX5.3) the lineno table may not be sorted. */ | 4558 | 119 | if (!ordered) | 4559 | 68 | { | 4560 | | /* Sort the table. */ | 4561 | 68 | alent **func_table; | 4562 | 68 | alent *n_lineno_cache; | 4563 | | | 4564 | | /* Create a table of functions. */ | 4565 | 68 | if (_bfd_mul_overflow (nbr_func, sizeof (alent *), &amt)) | 4566 | 0 | { | 4567 | 0 | bfd_set_error (bfd_error_file_too_big); | 4568 | 0 | ret = false; | 4569 | 0 | } | 4570 | 68 | else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL) | 4571 | 68 | { | 4572 | 68 | alent **p = func_table; | 4573 | 68 | unsigned int i; | 4574 | | | 4575 | 92.5k | for (i = 0; i < asect->lineno_count; i++) | 4576 | 92.5k | if (lineno_cache[i].line_number == 0) | 4577 | 54.2k | *p++ = &lineno_cache[i]; | 4578 | | | 4579 | 68 | BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func); | 4580 | | | 4581 | | /* Sort by functions. */ | 4582 | 68 | qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent); | 4583 | | | 4584 | | /* Create the new sorted table. */ | 4585 | 68 | if (_bfd_mul_overflow (asect->lineno_count, sizeof (alent), &amt)) | 4586 | 0 | { | 4587 | 0 | bfd_set_error (bfd_error_file_too_big); | 4588 | 0 | ret = false; | 4589 | 0 | } | 4590 | 68 | else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL) | 4591 | 68 | { | 4592 | 68 | alent *n_cache_ptr = n_lineno_cache; | 4593 | | | 4594 | 54.3k | for (i = 0; i < nbr_func; i++) | 4595 | 54.2k | { | 4596 | 54.2k | coff_symbol_type *sym; | 4597 | 54.2k | alent *old_ptr = func_table[i]; | 4598 | | | 4599 | | /* Update the function entry. */ | 4600 | 54.2k | sym = (coff_symbol_type *) old_ptr->u.sym; | 4601 | | /* PR binutils/17512: Point the lineno to where | 4602 | | this entry will be after the memcpy below. */ | 4603 | 54.2k | sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); | 4604 | | /* Copy the function and line number entries. */ | 4605 | 54.2k | do | 4606 | 92.5k | *n_cache_ptr++ = *old_ptr++; | 4607 | 92.5k | while (old_ptr->line_number != 0); | 4608 | 54.2k | } | 4609 | | | 4610 | 68 | memcpy (lineno_cache, n_lineno_cache, | 4611 | 68 | asect->lineno_count * sizeof (alent)); | 4612 | 68 | } | 4613 | 0 | else | 4614 | 0 | ret = false; | 4615 | 68 | bfd_release (abfd, func_table); | 4616 | 68 | } | 4617 | 0 | else | 4618 | 0 | ret = false; | 4619 | 68 | } | 4620 | | | 4621 | 119 | return ret; | 4622 | 119 | } |
pe-x86_64.c:coff_slurp_line_table Line | Count | Source | 4425 | 612 | { | 4426 | 612 | LINENO *native_lineno; | 4427 | 612 | alent *lineno_cache; | 4428 | 612 | unsigned int counter; | 4429 | 612 | alent *cache_ptr; | 4430 | 612 | bfd_vma prev_offset = 0; | 4431 | 612 | bool ordered = true; | 4432 | 612 | unsigned int nbr_func; | 4433 | 612 | LINENO *src; | 4434 | 612 | bool have_func; | 4435 | 612 | bool ret = true; | 4436 | 612 | size_t amt; | 4437 | | | 4438 | 612 | if (asect->lineno_count == 0) | 4439 | 440 | return true; | 4440 | | | 4441 | 172 | BFD_ASSERT (asect->lineno == NULL); | 4442 | | | 4443 | 172 | native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, | 4444 | 172 | asect->lineno_count, | 4445 | 172 | bfd_coff_linesz (abfd)); | 4446 | 172 | if (native_lineno == NULL) | 4447 | 48 | { | 4448 | 48 | _bfd_error_handler | 4449 | 48 | (_("%pB: warning: line number table read failed"), abfd); | 4450 | 48 | return false; | 4451 | 48 | } | 4452 | | | 4453 | 124 | if (_bfd_mul_overflow (asect->lineno_count + 1, sizeof (alent), &amt)) | 4454 | 0 | { | 4455 | 0 | bfd_set_error (bfd_error_file_too_big); | 4456 | 0 | free (native_lineno); | 4457 | 0 | return false; | 4458 | 0 | } | 4459 | 124 | lineno_cache = (alent *) bfd_alloc (abfd, amt); | 4460 | 124 | if (lineno_cache == NULL) | 4461 | 0 | { | 4462 | 0 | free (native_lineno); | 4463 | 0 | return false; | 4464 | 0 | } | 4465 | | | 4466 | 124 | cache_ptr = lineno_cache; | 4467 | 124 | asect->lineno = lineno_cache; | 4468 | 124 | src = native_lineno; | 4469 | 124 | nbr_func = 0; | 4470 | 124 | have_func = false; | 4471 | | | 4472 | 315k | for (counter = 0; counter < asect->lineno_count; counter++, src++) | 4473 | 315k | { | 4474 | 315k | struct internal_lineno dst; | 4475 | | | 4476 | 315k | bfd_coff_swap_lineno_in (abfd, src, &dst); | 4477 | 315k | cache_ptr->line_number = dst.l_lnno; | 4478 | | /* Appease memory checkers that get all excited about | 4479 | | uninitialised memory when copying alents if u.offset is | 4480 | | larger than u.sym. (64-bit BFD on 32-bit host.) */ | 4481 | 315k | memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); | 4482 | | | 4483 | 315k | if (cache_ptr->line_number == 0) | 4484 | 138k | { | 4485 | 138k | combined_entry_type * ent; | 4486 | 138k | unsigned long symndx; | 4487 | 138k | coff_symbol_type *sym; | 4488 | | | 4489 | 138k | have_func = false; | 4490 | 138k | symndx = dst.l_addr.l_symndx; | 4491 | 138k | if (symndx >= obj_raw_syment_count (abfd)) | 4492 | 32.3k | { | 4493 | 32.3k | _bfd_error_handler | 4494 | | /* xgettext:c-format */ | 4495 | 32.3k | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4496 | 32.3k | abfd, symndx, counter); | 4497 | 32.3k | cache_ptr->line_number = -1; | 4498 | 32.3k | ret = false; | 4499 | 32.3k | continue; | 4500 | 32.3k | } | 4501 | | | 4502 | 106k | ent = obj_raw_syments (abfd) + symndx; | 4503 | | /* FIXME: We should not be casting between ints and | 4504 | | pointers like this. */ | 4505 | 106k | if (! ent->is_sym) | 4506 | 8.55k | { | 4507 | 8.55k | _bfd_error_handler | 4508 | | /* xgettext:c-format */ | 4509 | 8.55k | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4510 | 8.55k | abfd, symndx, counter); | 4511 | 8.55k | cache_ptr->line_number = -1; | 4512 | 8.55k | ret = false; | 4513 | 8.55k | continue; | 4514 | 8.55k | } | 4515 | 97.9k | sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); | 4516 | | | 4517 | | /* PR 17512 file: 078-10659-0.004 */ | 4518 | 97.9k | if (sym < obj_symbols (abfd) | 4519 | 97.9k | || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd)) | 4520 | 0 | { | 4521 | 0 | _bfd_error_handler | 4522 | | /* xgettext:c-format */ | 4523 | 0 | (_("%pB: warning: illegal symbol in line number entry %d"), | 4524 | 0 | abfd, counter); | 4525 | 0 | cache_ptr->line_number = -1; | 4526 | 0 | ret = false; | 4527 | 0 | continue; | 4528 | 0 | } | 4529 | | | 4530 | 97.9k | have_func = true; | 4531 | 97.9k | nbr_func++; | 4532 | 97.9k | cache_ptr->u.sym = (asymbol *) sym; | 4533 | 97.9k | if (sym->lineno != NULL) | 4534 | 97.4k | _bfd_error_handler | 4535 | | /* xgettext:c-format */ | 4536 | 97.4k | (_("%pB: warning: duplicate line number information for `%s'"), | 4537 | 97.4k | abfd, bfd_asymbol_name (&sym->symbol)); | 4538 | | | 4539 | 97.9k | sym->lineno = cache_ptr; | 4540 | 97.9k | if (sym->symbol.value < prev_offset) | 4541 | 990 | ordered = false; | 4542 | 97.9k | prev_offset = sym->symbol.value; | 4543 | 97.9k | } | 4544 | 176k | else if (!have_func) | 4545 | | /* Drop line information that has no associated function. | 4546 | | PR 17521: file: 078-10659-0.004. */ | 4547 | 110k | continue; | 4548 | 66.4k | else | 4549 | 66.4k | cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect); | 4550 | 164k | cache_ptr++; | 4551 | 164k | } | 4552 | | | 4553 | 124 | asect->lineno_count = cache_ptr - lineno_cache; | 4554 | 124 | memset (cache_ptr, 0, sizeof (*cache_ptr)); | 4555 | 124 | free (native_lineno); | 4556 | | | 4557 | | /* On some systems (eg AIX5.3) the lineno table may not be sorted. */ | 4558 | 124 | if (!ordered) | 4559 | 61 | { | 4560 | | /* Sort the table. */ | 4561 | 61 | alent **func_table; | 4562 | 61 | alent *n_lineno_cache; | 4563 | | | 4564 | | /* Create a table of functions. */ | 4565 | 61 | if (_bfd_mul_overflow (nbr_func, sizeof (alent *), &amt)) | 4566 | 0 | { | 4567 | 0 | bfd_set_error (bfd_error_file_too_big); | 4568 | 0 | ret = false; | 4569 | 0 | } | 4570 | 61 | else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL) | 4571 | 61 | { | 4572 | 61 | alent **p = func_table; | 4573 | 61 | unsigned int i; | 4574 | | | 4575 | 108k | for (i = 0; i < asect->lineno_count; i++) | 4576 | 108k | if (lineno_cache[i].line_number == 0) | 4577 | 42.0k | *p++ = &lineno_cache[i]; | 4578 | | | 4579 | 61 | BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func); | 4580 | | | 4581 | | /* Sort by functions. */ | 4582 | 61 | qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent); | 4583 | | | 4584 | | /* Create the new sorted table. */ | 4585 | 61 | if (_bfd_mul_overflow (asect->lineno_count, sizeof (alent), &amt)) | 4586 | 0 | { | 4587 | 0 | bfd_set_error (bfd_error_file_too_big); | 4588 | 0 | ret = false; | 4589 | 0 | } | 4590 | 61 | else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL) | 4591 | 61 | { | 4592 | 61 | alent *n_cache_ptr = n_lineno_cache; | 4593 | | | 4594 | 42.0k | for (i = 0; i < nbr_func; i++) | 4595 | 42.0k | { | 4596 | 42.0k | coff_symbol_type *sym; | 4597 | 42.0k | alent *old_ptr = func_table[i]; | 4598 | | | 4599 | | /* Update the function entry. */ | 4600 | 42.0k | sym = (coff_symbol_type *) old_ptr->u.sym; | 4601 | | /* PR binutils/17512: Point the lineno to where | 4602 | | this entry will be after the memcpy below. */ | 4603 | 42.0k | sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); | 4604 | | /* Copy the function and line number entries. */ | 4605 | 42.0k | do | 4606 | 108k | *n_cache_ptr++ = *old_ptr++; | 4607 | 108k | while (old_ptr->line_number != 0); | 4608 | 42.0k | } | 4609 | | | 4610 | 61 | memcpy (lineno_cache, n_lineno_cache, | 4611 | 61 | asect->lineno_count * sizeof (alent)); | 4612 | 61 | } | 4613 | 0 | else | 4614 | 0 | ret = false; | 4615 | 61 | bfd_release (abfd, func_table); | 4616 | 61 | } | 4617 | 0 | else | 4618 | 0 | ret = false; | 4619 | 61 | } | 4620 | | | 4621 | 124 | return ret; | 4622 | 124 | } |
pei-x86_64.c:coff_slurp_line_table Line | Count | Source | 4425 | 209 | { | 4426 | 209 | LINENO *native_lineno; | 4427 | 209 | alent *lineno_cache; | 4428 | 209 | unsigned int counter; | 4429 | 209 | alent *cache_ptr; | 4430 | 209 | bfd_vma prev_offset = 0; | 4431 | 209 | bool ordered = true; | 4432 | 209 | unsigned int nbr_func; | 4433 | 209 | LINENO *src; | 4434 | 209 | bool have_func; | 4435 | 209 | bool ret = true; | 4436 | 209 | size_t amt; | 4437 | | | 4438 | 209 | if (asect->lineno_count == 0) | 4439 | 96 | return true; | 4440 | | | 4441 | 113 | BFD_ASSERT (asect->lineno == NULL); | 4442 | | | 4443 | 113 | native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, | 4444 | 113 | asect->lineno_count, | 4445 | 113 | bfd_coff_linesz (abfd)); | 4446 | 113 | if (native_lineno == NULL) | 4447 | 63 | { | 4448 | 63 | _bfd_error_handler | 4449 | 63 | (_("%pB: warning: line number table read failed"), abfd); | 4450 | 63 | return false; | 4451 | 63 | } | 4452 | | | 4453 | 50 | if (_bfd_mul_overflow (asect->lineno_count + 1, sizeof (alent), &amt)) | 4454 | 0 | { | 4455 | 0 | bfd_set_error (bfd_error_file_too_big); | 4456 | 0 | free (native_lineno); | 4457 | 0 | return false; | 4458 | 0 | } | 4459 | 50 | lineno_cache = (alent *) bfd_alloc (abfd, amt); | 4460 | 50 | if (lineno_cache == NULL) | 4461 | 0 | { | 4462 | 0 | free (native_lineno); | 4463 | 0 | return false; | 4464 | 0 | } | 4465 | | | 4466 | 50 | cache_ptr = lineno_cache; | 4467 | 50 | asect->lineno = lineno_cache; | 4468 | 50 | src = native_lineno; | 4469 | 50 | nbr_func = 0; | 4470 | 50 | have_func = false; | 4471 | | | 4472 | 58.2k | for (counter = 0; counter < asect->lineno_count; counter++, src++) | 4473 | 58.1k | { | 4474 | 58.1k | struct internal_lineno dst; | 4475 | | | 4476 | 58.1k | bfd_coff_swap_lineno_in (abfd, src, &dst); | 4477 | 58.1k | cache_ptr->line_number = dst.l_lnno; | 4478 | | /* Appease memory checkers that get all excited about | 4479 | | uninitialised memory when copying alents if u.offset is | 4480 | | larger than u.sym. (64-bit BFD on 32-bit host.) */ | 4481 | 58.1k | memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); | 4482 | | | 4483 | 58.1k | if (cache_ptr->line_number == 0) | 4484 | 31.1k | { | 4485 | 31.1k | combined_entry_type * ent; | 4486 | 31.1k | unsigned long symndx; | 4487 | 31.1k | coff_symbol_type *sym; | 4488 | | | 4489 | 31.1k | have_func = false; | 4490 | 31.1k | symndx = dst.l_addr.l_symndx; | 4491 | 31.1k | if (symndx >= obj_raw_syment_count (abfd)) | 4492 | 6.14k | { | 4493 | 6.14k | _bfd_error_handler | 4494 | | /* xgettext:c-format */ | 4495 | 6.14k | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4496 | 6.14k | abfd, symndx, counter); | 4497 | 6.14k | cache_ptr->line_number = -1; | 4498 | 6.14k | ret = false; | 4499 | 6.14k | continue; | 4500 | 6.14k | } | 4501 | | | 4502 | 25.0k | ent = obj_raw_syments (abfd) + symndx; | 4503 | | /* FIXME: We should not be casting between ints and | 4504 | | pointers like this. */ | 4505 | 25.0k | if (! ent->is_sym) | 4506 | 447 | { | 4507 | 447 | _bfd_error_handler | 4508 | | /* xgettext:c-format */ | 4509 | 447 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4510 | 447 | abfd, symndx, counter); | 4511 | 447 | cache_ptr->line_number = -1; | 4512 | 447 | ret = false; | 4513 | 447 | continue; | 4514 | 447 | } | 4515 | 24.5k | sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); | 4516 | | | 4517 | | /* PR 17512 file: 078-10659-0.004 */ | 4518 | 24.5k | if (sym < obj_symbols (abfd) | 4519 | 24.5k | || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd)) | 4520 | 0 | { | 4521 | 0 | _bfd_error_handler | 4522 | | /* xgettext:c-format */ | 4523 | 0 | (_("%pB: warning: illegal symbol in line number entry %d"), | 4524 | 0 | abfd, counter); | 4525 | 0 | cache_ptr->line_number = -1; | 4526 | 0 | ret = false; | 4527 | 0 | continue; | 4528 | 0 | } | 4529 | | | 4530 | 24.5k | have_func = true; | 4531 | 24.5k | nbr_func++; | 4532 | 24.5k | cache_ptr->u.sym = (asymbol *) sym; | 4533 | 24.5k | if (sym->lineno != NULL) | 4534 | 24.4k | _bfd_error_handler | 4535 | | /* xgettext:c-format */ | 4536 | 24.4k | (_("%pB: warning: duplicate line number information for `%s'"), | 4537 | 24.4k | abfd, bfd_asymbol_name (&sym->symbol)); | 4538 | | | 4539 | 24.5k | sym->lineno = cache_ptr; | 4540 | 24.5k | if (sym->symbol.value < prev_offset) | 4541 | 341 | ordered = false; | 4542 | 24.5k | prev_offset = sym->symbol.value; | 4543 | 24.5k | } | 4544 | 27.0k | else if (!have_func) | 4545 | | /* Drop line information that has no associated function. | 4546 | | PR 17521: file: 078-10659-0.004. */ | 4547 | 16.7k | continue; | 4548 | 10.2k | else | 4549 | 10.2k | cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect); | 4550 | 34.8k | cache_ptr++; | 4551 | 34.8k | } | 4552 | | | 4553 | 50 | asect->lineno_count = cache_ptr - lineno_cache; | 4554 | 50 | memset (cache_ptr, 0, sizeof (*cache_ptr)); | 4555 | 50 | free (native_lineno); | 4556 | | | 4557 | | /* On some systems (eg AIX5.3) the lineno table may not be sorted. */ | 4558 | 50 | if (!ordered) | 4559 | 37 | { | 4560 | | /* Sort the table. */ | 4561 | 37 | alent **func_table; | 4562 | 37 | alent *n_lineno_cache; | 4563 | | | 4564 | | /* Create a table of functions. */ | 4565 | 37 | if (_bfd_mul_overflow (nbr_func, sizeof (alent *), &amt)) | 4566 | 0 | { | 4567 | 0 | bfd_set_error (bfd_error_file_too_big); | 4568 | 0 | ret = false; | 4569 | 0 | } | 4570 | 37 | else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL) | 4571 | 37 | { | 4572 | 37 | alent **p = func_table; | 4573 | 37 | unsigned int i; | 4574 | | | 4575 | 34.8k | for (i = 0; i < asect->lineno_count; i++) | 4576 | 34.8k | if (lineno_cache[i].line_number == 0) | 4577 | 24.5k | *p++ = &lineno_cache[i]; | 4578 | | | 4579 | 37 | BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func); | 4580 | | | 4581 | | /* Sort by functions. */ | 4582 | 37 | qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent); | 4583 | | | 4584 | | /* Create the new sorted table. */ | 4585 | 37 | if (_bfd_mul_overflow (asect->lineno_count, sizeof (alent), &amt)) | 4586 | 0 | { | 4587 | 0 | bfd_set_error (bfd_error_file_too_big); | 4588 | 0 | ret = false; | 4589 | 0 | } | 4590 | 37 | else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL) | 4591 | 37 | { | 4592 | 37 | alent *n_cache_ptr = n_lineno_cache; | 4593 | | | 4594 | 24.6k | for (i = 0; i < nbr_func; i++) | 4595 | 24.5k | { | 4596 | 24.5k | coff_symbol_type *sym; | 4597 | 24.5k | alent *old_ptr = func_table[i]; | 4598 | | | 4599 | | /* Update the function entry. */ | 4600 | 24.5k | sym = (coff_symbol_type *) old_ptr->u.sym; | 4601 | | /* PR binutils/17512: Point the lineno to where | 4602 | | this entry will be after the memcpy below. */ | 4603 | 24.5k | sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); | 4604 | | /* Copy the function and line number entries. */ | 4605 | 24.5k | do | 4606 | 34.8k | *n_cache_ptr++ = *old_ptr++; | 4607 | 34.8k | while (old_ptr->line_number != 0); | 4608 | 24.5k | } | 4609 | | | 4610 | 37 | memcpy (lineno_cache, n_lineno_cache, | 4611 | 37 | asect->lineno_count * sizeof (alent)); | 4612 | 37 | } | 4613 | 0 | else | 4614 | 0 | ret = false; | 4615 | 37 | bfd_release (abfd, func_table); | 4616 | 37 | } | 4617 | 0 | else | 4618 | 0 | ret = false; | 4619 | 37 | } | 4620 | | | 4621 | 50 | return ret; | 4622 | 50 | } |
coff-x86_64.c:coff_slurp_line_table Line | Count | Source | 4425 | 1.37k | { | 4426 | 1.37k | LINENO *native_lineno; | 4427 | 1.37k | alent *lineno_cache; | 4428 | 1.37k | unsigned int counter; | 4429 | 1.37k | alent *cache_ptr; | 4430 | 1.37k | bfd_vma prev_offset = 0; | 4431 | 1.37k | bool ordered = true; | 4432 | 1.37k | unsigned int nbr_func; | 4433 | 1.37k | LINENO *src; | 4434 | 1.37k | bool have_func; | 4435 | 1.37k | bool ret = true; | 4436 | 1.37k | size_t amt; | 4437 | | | 4438 | 1.37k | if (asect->lineno_count == 0) | 4439 | 1.05k | return true; | 4440 | | | 4441 | 311 | BFD_ASSERT (asect->lineno == NULL); | 4442 | | | 4443 | 311 | native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, | 4444 | 311 | asect->lineno_count, | 4445 | 311 | bfd_coff_linesz (abfd)); | 4446 | 311 | if (native_lineno == NULL) | 4447 | 129 | { | 4448 | 129 | _bfd_error_handler | 4449 | 129 | (_("%pB: warning: line number table read failed"), abfd); | 4450 | 129 | return false; | 4451 | 129 | } | 4452 | | | 4453 | 182 | if (_bfd_mul_overflow (asect->lineno_count + 1, sizeof (alent), &amt)) | 4454 | 0 | { | 4455 | 0 | bfd_set_error (bfd_error_file_too_big); | 4456 | 0 | free (native_lineno); | 4457 | 0 | return false; | 4458 | 0 | } | 4459 | 182 | lineno_cache = (alent *) bfd_alloc (abfd, amt); | 4460 | 182 | if (lineno_cache == NULL) | 4461 | 0 | { | 4462 | 0 | free (native_lineno); | 4463 | 0 | return false; | 4464 | 0 | } | 4465 | | | 4466 | 182 | cache_ptr = lineno_cache; | 4467 | 182 | asect->lineno = lineno_cache; | 4468 | 182 | src = native_lineno; | 4469 | 182 | nbr_func = 0; | 4470 | 182 | have_func = false; | 4471 | | | 4472 | 348k | for (counter = 0; counter < asect->lineno_count; counter++, src++) | 4473 | 348k | { | 4474 | 348k | struct internal_lineno dst; | 4475 | | | 4476 | 348k | bfd_coff_swap_lineno_in (abfd, src, &dst); | 4477 | 348k | cache_ptr->line_number = dst.l_lnno; | 4478 | | /* Appease memory checkers that get all excited about | 4479 | | uninitialised memory when copying alents if u.offset is | 4480 | | larger than u.sym. (64-bit BFD on 32-bit host.) */ | 4481 | 348k | memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); | 4482 | | | 4483 | 348k | if (cache_ptr->line_number == 0) | 4484 | 142k | { | 4485 | 142k | combined_entry_type * ent; | 4486 | 142k | unsigned long symndx; | 4487 | 142k | coff_symbol_type *sym; | 4488 | | | 4489 | 142k | have_func = false; | 4490 | 142k | symndx = dst.l_addr.l_symndx; | 4491 | 142k | if (symndx >= obj_raw_syment_count (abfd)) | 4492 | 63.6k | { | 4493 | 63.6k | _bfd_error_handler | 4494 | | /* xgettext:c-format */ | 4495 | 63.6k | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4496 | 63.6k | abfd, symndx, counter); | 4497 | 63.6k | cache_ptr->line_number = -1; | 4498 | 63.6k | ret = false; | 4499 | 63.6k | continue; | 4500 | 63.6k | } | 4501 | | | 4502 | 78.8k | ent = obj_raw_syments (abfd) + symndx; | 4503 | | /* FIXME: We should not be casting between ints and | 4504 | | pointers like this. */ | 4505 | 78.8k | if (! ent->is_sym) | 4506 | 13.3k | { | 4507 | 13.3k | _bfd_error_handler | 4508 | | /* xgettext:c-format */ | 4509 | 13.3k | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4510 | 13.3k | abfd, symndx, counter); | 4511 | 13.3k | cache_ptr->line_number = -1; | 4512 | 13.3k | ret = false; | 4513 | 13.3k | continue; | 4514 | 13.3k | } | 4515 | 65.5k | sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); | 4516 | | | 4517 | | /* PR 17512 file: 078-10659-0.004 */ | 4518 | 65.5k | if (sym < obj_symbols (abfd) | 4519 | 65.5k | || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd)) | 4520 | 0 | { | 4521 | 0 | _bfd_error_handler | 4522 | | /* xgettext:c-format */ | 4523 | 0 | (_("%pB: warning: illegal symbol in line number entry %d"), | 4524 | 0 | abfd, counter); | 4525 | 0 | cache_ptr->line_number = -1; | 4526 | 0 | ret = false; | 4527 | 0 | continue; | 4528 | 0 | } | 4529 | | | 4530 | 65.5k | have_func = true; | 4531 | 65.5k | nbr_func++; | 4532 | 65.5k | cache_ptr->u.sym = (asymbol *) sym; | 4533 | 65.5k | if (sym->lineno != NULL) | 4534 | 65.0k | _bfd_error_handler | 4535 | | /* xgettext:c-format */ | 4536 | 65.0k | (_("%pB: warning: duplicate line number information for `%s'"), | 4537 | 65.0k | abfd, bfd_asymbol_name (&sym->symbol)); | 4538 | | | 4539 | 65.5k | sym->lineno = cache_ptr; | 4540 | 65.5k | if (sym->symbol.value < prev_offset) | 4541 | 876 | ordered = false; | 4542 | 65.5k | prev_offset = sym->symbol.value; | 4543 | 65.5k | } | 4544 | 205k | else if (!have_func) | 4545 | | /* Drop line information that has no associated function. | 4546 | | PR 17521: file: 078-10659-0.004. */ | 4547 | 122k | continue; | 4548 | 83.5k | else | 4549 | 83.5k | cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect); | 4550 | 149k | cache_ptr++; | 4551 | 149k | } | 4552 | | | 4553 | 182 | asect->lineno_count = cache_ptr - lineno_cache; | 4554 | 182 | memset (cache_ptr, 0, sizeof (*cache_ptr)); | 4555 | 182 | free (native_lineno); | 4556 | | | 4557 | | /* On some systems (eg AIX5.3) the lineno table may not be sorted. */ | 4558 | 182 | if (!ordered) | 4559 | 74 | { | 4560 | | /* Sort the table. */ | 4561 | 74 | alent **func_table; | 4562 | 74 | alent *n_lineno_cache; | 4563 | | | 4564 | | /* Create a table of functions. */ | 4565 | 74 | if (_bfd_mul_overflow (nbr_func, sizeof (alent *), &amt)) | 4566 | 0 | { | 4567 | 0 | bfd_set_error (bfd_error_file_too_big); | 4568 | 0 | ret = false; | 4569 | 0 | } | 4570 | 74 | else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL) | 4571 | 74 | { | 4572 | 74 | alent **p = func_table; | 4573 | 74 | unsigned int i; | 4574 | | | 4575 | 142k | for (i = 0; i < asect->lineno_count; i++) | 4576 | 141k | if (lineno_cache[i].line_number == 0) | 4577 | 61.3k | *p++ = &lineno_cache[i]; | 4578 | | | 4579 | 74 | BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func); | 4580 | | | 4581 | | /* Sort by functions. */ | 4582 | 74 | qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent); | 4583 | | | 4584 | | /* Create the new sorted table. */ | 4585 | 74 | if (_bfd_mul_overflow (asect->lineno_count, sizeof (alent), &amt)) | 4586 | 0 | { | 4587 | 0 | bfd_set_error (bfd_error_file_too_big); | 4588 | 0 | ret = false; | 4589 | 0 | } | 4590 | 74 | else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL) | 4591 | 74 | { | 4592 | 74 | alent *n_cache_ptr = n_lineno_cache; | 4593 | | | 4594 | 61.3k | for (i = 0; i < nbr_func; i++) | 4595 | 61.3k | { | 4596 | 61.3k | coff_symbol_type *sym; | 4597 | 61.3k | alent *old_ptr = func_table[i]; | 4598 | | | 4599 | | /* Update the function entry. */ | 4600 | 61.3k | sym = (coff_symbol_type *) old_ptr->u.sym; | 4601 | | /* PR binutils/17512: Point the lineno to where | 4602 | | this entry will be after the memcpy below. */ | 4603 | 61.3k | sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); | 4604 | | /* Copy the function and line number entries. */ | 4605 | 61.3k | do | 4606 | 141k | *n_cache_ptr++ = *old_ptr++; | 4607 | 141k | while (old_ptr->line_number != 0); | 4608 | 61.3k | } | 4609 | | | 4610 | 74 | memcpy (lineno_cache, n_lineno_cache, | 4611 | 74 | asect->lineno_count * sizeof (alent)); | 4612 | 74 | } | 4613 | 0 | else | 4614 | 0 | ret = false; | 4615 | 74 | bfd_release (abfd, func_table); | 4616 | 74 | } | 4617 | 0 | else | 4618 | 0 | ret = false; | 4619 | 74 | } | 4620 | | | 4621 | 182 | return ret; | 4622 | 182 | } |
coff64-rs6000.c:coff_slurp_line_table Line | Count | Source | 4425 | 1.22k | { | 4426 | 1.22k | LINENO *native_lineno; | 4427 | 1.22k | alent *lineno_cache; | 4428 | 1.22k | unsigned int counter; | 4429 | 1.22k | alent *cache_ptr; | 4430 | 1.22k | bfd_vma prev_offset = 0; | 4431 | 1.22k | bool ordered = true; | 4432 | 1.22k | unsigned int nbr_func; | 4433 | 1.22k | LINENO *src; | 4434 | 1.22k | bool have_func; | 4435 | 1.22k | bool ret = true; | 4436 | 1.22k | size_t amt; | 4437 | | | 4438 | 1.22k | if (asect->lineno_count == 0) | 4439 | 928 | return true; | 4440 | | | 4441 | 296 | BFD_ASSERT (asect->lineno == NULL); | 4442 | | | 4443 | 296 | native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, | 4444 | 296 | asect->lineno_count, | 4445 | 296 | bfd_coff_linesz (abfd)); | 4446 | 296 | if (native_lineno == NULL) | 4447 | 188 | { | 4448 | 188 | _bfd_error_handler | 4449 | 188 | (_("%pB: warning: line number table read failed"), abfd); | 4450 | 188 | return false; | 4451 | 188 | } | 4452 | | | 4453 | 108 | if (_bfd_mul_overflow (asect->lineno_count + 1, sizeof (alent), &amt)) | 4454 | 0 | { | 4455 | 0 | bfd_set_error (bfd_error_file_too_big); | 4456 | 0 | free (native_lineno); | 4457 | 0 | return false; | 4458 | 0 | } | 4459 | 108 | lineno_cache = (alent *) bfd_alloc (abfd, amt); | 4460 | 108 | if (lineno_cache == NULL) | 4461 | 0 | { | 4462 | 0 | free (native_lineno); | 4463 | 0 | return false; | 4464 | 0 | } | 4465 | | | 4466 | 108 | cache_ptr = lineno_cache; | 4467 | 108 | asect->lineno = lineno_cache; | 4468 | 108 | src = native_lineno; | 4469 | 108 | nbr_func = 0; | 4470 | 108 | have_func = false; | 4471 | | | 4472 | 362k | for (counter = 0; counter < asect->lineno_count; counter++, src++) | 4473 | 362k | { | 4474 | 362k | struct internal_lineno dst; | 4475 | | | 4476 | 362k | bfd_coff_swap_lineno_in (abfd, src, &dst); | 4477 | 362k | cache_ptr->line_number = dst.l_lnno; | 4478 | | /* Appease memory checkers that get all excited about | 4479 | | uninitialised memory when copying alents if u.offset is | 4480 | | larger than u.sym. (64-bit BFD on 32-bit host.) */ | 4481 | 362k | memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); | 4482 | | | 4483 | 362k | if (cache_ptr->line_number == 0) | 4484 | 99.6k | { | 4485 | 99.6k | combined_entry_type * ent; | 4486 | 99.6k | unsigned long symndx; | 4487 | 99.6k | coff_symbol_type *sym; | 4488 | | | 4489 | 99.6k | have_func = false; | 4490 | 99.6k | symndx = dst.l_addr.l_symndx; | 4491 | 99.6k | if (symndx >= obj_raw_syment_count (abfd)) | 4492 | 27.7k | { | 4493 | 27.7k | _bfd_error_handler | 4494 | | /* xgettext:c-format */ | 4495 | 27.7k | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4496 | 27.7k | abfd, symndx, counter); | 4497 | 27.7k | cache_ptr->line_number = -1; | 4498 | 27.7k | ret = false; | 4499 | 27.7k | continue; | 4500 | 27.7k | } | 4501 | | | 4502 | 71.9k | ent = obj_raw_syments (abfd) + symndx; | 4503 | | /* FIXME: We should not be casting between ints and | 4504 | | pointers like this. */ | 4505 | 71.9k | if (! ent->is_sym) | 4506 | 4.02k | { | 4507 | 4.02k | _bfd_error_handler | 4508 | | /* xgettext:c-format */ | 4509 | 4.02k | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4510 | 4.02k | abfd, symndx, counter); | 4511 | 4.02k | cache_ptr->line_number = -1; | 4512 | 4.02k | ret = false; | 4513 | 4.02k | continue; | 4514 | 4.02k | } | 4515 | 67.9k | sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); | 4516 | | | 4517 | | /* PR 17512 file: 078-10659-0.004 */ | 4518 | 67.9k | if (sym < obj_symbols (abfd) | 4519 | 67.9k | || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd)) | 4520 | 0 | { | 4521 | 0 | _bfd_error_handler | 4522 | | /* xgettext:c-format */ | 4523 | 0 | (_("%pB: warning: illegal symbol in line number entry %d"), | 4524 | 0 | abfd, counter); | 4525 | 0 | cache_ptr->line_number = -1; | 4526 | 0 | ret = false; | 4527 | 0 | continue; | 4528 | 0 | } | 4529 | | | 4530 | 67.9k | have_func = true; | 4531 | 67.9k | nbr_func++; | 4532 | 67.9k | cache_ptr->u.sym = (asymbol *) sym; | 4533 | 67.9k | if (sym->lineno != NULL) | 4534 | 67.4k | _bfd_error_handler | 4535 | | /* xgettext:c-format */ | 4536 | 67.4k | (_("%pB: warning: duplicate line number information for `%s'"), | 4537 | 67.4k | abfd, bfd_asymbol_name (&sym->symbol)); | 4538 | | | 4539 | 67.9k | sym->lineno = cache_ptr; | 4540 | 67.9k | if (sym->symbol.value < prev_offset) | 4541 | 1.37k | ordered = false; | 4542 | 67.9k | prev_offset = sym->symbol.value; | 4543 | 67.9k | } | 4544 | 262k | else if (!have_func) | 4545 | | /* Drop line information that has no associated function. | 4546 | | PR 17521: file: 078-10659-0.004. */ | 4547 | 132k | continue; | 4548 | 130k | else | 4549 | 130k | cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect); | 4550 | 197k | cache_ptr++; | 4551 | 197k | } | 4552 | | | 4553 | 108 | asect->lineno_count = cache_ptr - lineno_cache; | 4554 | 108 | memset (cache_ptr, 0, sizeof (*cache_ptr)); | 4555 | 108 | free (native_lineno); | 4556 | | | 4557 | | /* On some systems (eg AIX5.3) the lineno table may not be sorted. */ | 4558 | 108 | if (!ordered) | 4559 | 62 | { | 4560 | | /* Sort the table. */ | 4561 | 62 | alent **func_table; | 4562 | 62 | alent *n_lineno_cache; | 4563 | | | 4564 | | /* Create a table of functions. */ | 4565 | 62 | if (_bfd_mul_overflow (nbr_func, sizeof (alent *), &amt)) | 4566 | 0 | { | 4567 | 0 | bfd_set_error (bfd_error_file_too_big); | 4568 | 0 | ret = false; | 4569 | 0 | } | 4570 | 62 | else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL) | 4571 | 62 | { | 4572 | 62 | alent **p = func_table; | 4573 | 62 | unsigned int i; | 4574 | | | 4575 | 196k | for (i = 0; i < asect->lineno_count; i++) | 4576 | 195k | if (lineno_cache[i].line_number == 0) | 4577 | 66.9k | *p++ = &lineno_cache[i]; | 4578 | | | 4579 | 62 | BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func); | 4580 | | | 4581 | | /* Sort by functions. */ | 4582 | 62 | qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent); | 4583 | | | 4584 | | /* Create the new sorted table. */ | 4585 | 62 | if (_bfd_mul_overflow (asect->lineno_count, sizeof (alent), &amt)) | 4586 | 0 | { | 4587 | 0 | bfd_set_error (bfd_error_file_too_big); | 4588 | 0 | ret = false; | 4589 | 0 | } | 4590 | 62 | else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL) | 4591 | 62 | { | 4592 | 62 | alent *n_cache_ptr = n_lineno_cache; | 4593 | | | 4594 | 67.0k | for (i = 0; i < nbr_func; i++) | 4595 | 66.9k | { | 4596 | 66.9k | coff_symbol_type *sym; | 4597 | 66.9k | alent *old_ptr = func_table[i]; | 4598 | | | 4599 | | /* Update the function entry. */ | 4600 | 66.9k | sym = (coff_symbol_type *) old_ptr->u.sym; | 4601 | | /* PR binutils/17512: Point the lineno to where | 4602 | | this entry will be after the memcpy below. */ | 4603 | 66.9k | sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); | 4604 | | /* Copy the function and line number entries. */ | 4605 | 66.9k | do | 4606 | 195k | *n_cache_ptr++ = *old_ptr++; | 4607 | 195k | while (old_ptr->line_number != 0); | 4608 | 66.9k | } | 4609 | | | 4610 | 62 | memcpy (lineno_cache, n_lineno_cache, | 4611 | 62 | asect->lineno_count * sizeof (alent)); | 4612 | 62 | } | 4613 | 0 | else | 4614 | 0 | ret = false; | 4615 | 62 | bfd_release (abfd, func_table); | 4616 | 62 | } | 4617 | 0 | else | 4618 | 0 | ret = false; | 4619 | 62 | } | 4620 | | | 4621 | 108 | return ret; | 4622 | 108 | } |
pei-aarch64.c:coff_slurp_line_table Line | Count | Source | 4425 | 303 | { | 4426 | 303 | LINENO *native_lineno; | 4427 | 303 | alent *lineno_cache; | 4428 | 303 | unsigned int counter; | 4429 | 303 | alent *cache_ptr; | 4430 | 303 | bfd_vma prev_offset = 0; | 4431 | 303 | bool ordered = true; | 4432 | 303 | unsigned int nbr_func; | 4433 | 303 | LINENO *src; | 4434 | 303 | bool have_func; | 4435 | 303 | bool ret = true; | 4436 | 303 | size_t amt; | 4437 | | | 4438 | 303 | if (asect->lineno_count == 0) | 4439 | 208 | return true; | 4440 | | | 4441 | 95 | BFD_ASSERT (asect->lineno == NULL); | 4442 | | | 4443 | 95 | native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, | 4444 | 95 | asect->lineno_count, | 4445 | 95 | bfd_coff_linesz (abfd)); | 4446 | 95 | if (native_lineno == NULL) | 4447 | 29 | { | 4448 | 29 | _bfd_error_handler | 4449 | 29 | (_("%pB: warning: line number table read failed"), abfd); | 4450 | 29 | return false; | 4451 | 29 | } | 4452 | | | 4453 | 66 | if (_bfd_mul_overflow (asect->lineno_count + 1, sizeof (alent), &amt)) | 4454 | 0 | { | 4455 | 0 | bfd_set_error (bfd_error_file_too_big); | 4456 | 0 | free (native_lineno); | 4457 | 0 | return false; | 4458 | 0 | } | 4459 | 66 | lineno_cache = (alent *) bfd_alloc (abfd, amt); | 4460 | 66 | if (lineno_cache == NULL) | 4461 | 0 | { | 4462 | 0 | free (native_lineno); | 4463 | 0 | return false; | 4464 | 0 | } | 4465 | | | 4466 | 66 | cache_ptr = lineno_cache; | 4467 | 66 | asect->lineno = lineno_cache; | 4468 | 66 | src = native_lineno; | 4469 | 66 | nbr_func = 0; | 4470 | 66 | have_func = false; | 4471 | | | 4472 | 33.2k | for (counter = 0; counter < asect->lineno_count; counter++, src++) | 4473 | 33.1k | { | 4474 | 33.1k | struct internal_lineno dst; | 4475 | | | 4476 | 33.1k | bfd_coff_swap_lineno_in (abfd, src, &dst); | 4477 | 33.1k | cache_ptr->line_number = dst.l_lnno; | 4478 | | /* Appease memory checkers that get all excited about | 4479 | | uninitialised memory when copying alents if u.offset is | 4480 | | larger than u.sym. (64-bit BFD on 32-bit host.) */ | 4481 | 33.1k | memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); | 4482 | | | 4483 | 33.1k | if (cache_ptr->line_number == 0) | 4484 | 17.0k | { | 4485 | 17.0k | combined_entry_type * ent; | 4486 | 17.0k | unsigned long symndx; | 4487 | 17.0k | coff_symbol_type *sym; | 4488 | | | 4489 | 17.0k | have_func = false; | 4490 | 17.0k | symndx = dst.l_addr.l_symndx; | 4491 | 17.0k | if (symndx >= obj_raw_syment_count (abfd)) | 4492 | 5.52k | { | 4493 | 5.52k | _bfd_error_handler | 4494 | | /* xgettext:c-format */ | 4495 | 5.52k | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4496 | 5.52k | abfd, symndx, counter); | 4497 | 5.52k | cache_ptr->line_number = -1; | 4498 | 5.52k | ret = false; | 4499 | 5.52k | continue; | 4500 | 5.52k | } | 4501 | | | 4502 | 11.5k | ent = obj_raw_syments (abfd) + symndx; | 4503 | | /* FIXME: We should not be casting between ints and | 4504 | | pointers like this. */ | 4505 | 11.5k | if (! ent->is_sym) | 4506 | 796 | { | 4507 | 796 | _bfd_error_handler | 4508 | | /* xgettext:c-format */ | 4509 | 796 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4510 | 796 | abfd, symndx, counter); | 4511 | 796 | cache_ptr->line_number = -1; | 4512 | 796 | ret = false; | 4513 | 796 | continue; | 4514 | 796 | } | 4515 | 10.7k | sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); | 4516 | | | 4517 | | /* PR 17512 file: 078-10659-0.004 */ | 4518 | 10.7k | if (sym < obj_symbols (abfd) | 4519 | 10.7k | || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd)) | 4520 | 0 | { | 4521 | 0 | _bfd_error_handler | 4522 | | /* xgettext:c-format */ | 4523 | 0 | (_("%pB: warning: illegal symbol in line number entry %d"), | 4524 | 0 | abfd, counter); | 4525 | 0 | cache_ptr->line_number = -1; | 4526 | 0 | ret = false; | 4527 | 0 | continue; | 4528 | 0 | } | 4529 | | | 4530 | 10.7k | have_func = true; | 4531 | 10.7k | nbr_func++; | 4532 | 10.7k | cache_ptr->u.sym = (asymbol *) sym; | 4533 | 10.7k | if (sym->lineno != NULL) | 4534 | 10.5k | _bfd_error_handler | 4535 | | /* xgettext:c-format */ | 4536 | 10.5k | (_("%pB: warning: duplicate line number information for `%s'"), | 4537 | 10.5k | abfd, bfd_asymbol_name (&sym->symbol)); | 4538 | | | 4539 | 10.7k | sym->lineno = cache_ptr; | 4540 | 10.7k | if (sym->symbol.value < prev_offset) | 4541 | 114 | ordered = false; | 4542 | 10.7k | prev_offset = sym->symbol.value; | 4543 | 10.7k | } | 4544 | 16.1k | else if (!have_func) | 4545 | | /* Drop line information that has no associated function. | 4546 | | PR 17521: file: 078-10659-0.004. */ | 4547 | 9.76k | continue; | 4548 | 6.37k | else | 4549 | 6.37k | cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect); | 4550 | 17.0k | cache_ptr++; | 4551 | 17.0k | } | 4552 | | | 4553 | 66 | asect->lineno_count = cache_ptr - lineno_cache; | 4554 | 66 | memset (cache_ptr, 0, sizeof (*cache_ptr)); | 4555 | 66 | free (native_lineno); | 4556 | | | 4557 | | /* On some systems (eg AIX5.3) the lineno table may not be sorted. */ | 4558 | 66 | if (!ordered) | 4559 | 42 | { | 4560 | | /* Sort the table. */ | 4561 | 42 | alent **func_table; | 4562 | 42 | alent *n_lineno_cache; | 4563 | | | 4564 | | /* Create a table of functions. */ | 4565 | 42 | if (_bfd_mul_overflow (nbr_func, sizeof (alent *), &amt)) | 4566 | 0 | { | 4567 | 0 | bfd_set_error (bfd_error_file_too_big); | 4568 | 0 | ret = false; | 4569 | 0 | } | 4570 | 42 | else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL) | 4571 | 42 | { | 4572 | 42 | alent **p = func_table; | 4573 | 42 | unsigned int i; | 4574 | | | 4575 | 15.3k | for (i = 0; i < asect->lineno_count; i++) | 4576 | 15.2k | if (lineno_cache[i].line_number == 0) | 4577 | 9.62k | *p++ = &lineno_cache[i]; | 4578 | | | 4579 | 42 | BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func); | 4580 | | | 4581 | | /* Sort by functions. */ | 4582 | 42 | qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent); | 4583 | | | 4584 | | /* Create the new sorted table. */ | 4585 | 42 | if (_bfd_mul_overflow (asect->lineno_count, sizeof (alent), &amt)) | 4586 | 0 | { | 4587 | 0 | bfd_set_error (bfd_error_file_too_big); | 4588 | 0 | ret = false; | 4589 | 0 | } | 4590 | 42 | else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL) | 4591 | 42 | { | 4592 | 42 | alent *n_cache_ptr = n_lineno_cache; | 4593 | | | 4594 | 9.66k | for (i = 0; i < nbr_func; i++) | 4595 | 9.62k | { | 4596 | 9.62k | coff_symbol_type *sym; | 4597 | 9.62k | alent *old_ptr = func_table[i]; | 4598 | | | 4599 | | /* Update the function entry. */ | 4600 | 9.62k | sym = (coff_symbol_type *) old_ptr->u.sym; | 4601 | | /* PR binutils/17512: Point the lineno to where | 4602 | | this entry will be after the memcpy below. */ | 4603 | 9.62k | sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); | 4604 | | /* Copy the function and line number entries. */ | 4605 | 9.62k | do | 4606 | 15.2k | *n_cache_ptr++ = *old_ptr++; | 4607 | 15.2k | while (old_ptr->line_number != 0); | 4608 | 9.62k | } | 4609 | | | 4610 | 42 | memcpy (lineno_cache, n_lineno_cache, | 4611 | 42 | asect->lineno_count * sizeof (alent)); | 4612 | 42 | } | 4613 | 0 | else | 4614 | 0 | ret = false; | 4615 | 42 | bfd_release (abfd, func_table); | 4616 | 42 | } | 4617 | 0 | else | 4618 | 0 | ret = false; | 4619 | 42 | } | 4620 | | | 4621 | 66 | return ret; | 4622 | 66 | } |
pe-aarch64.c:coff_slurp_line_table Line | Count | Source | 4425 | 3.35k | { | 4426 | 3.35k | LINENO *native_lineno; | 4427 | 3.35k | alent *lineno_cache; | 4428 | 3.35k | unsigned int counter; | 4429 | 3.35k | alent *cache_ptr; | 4430 | 3.35k | bfd_vma prev_offset = 0; | 4431 | 3.35k | bool ordered = true; | 4432 | 3.35k | unsigned int nbr_func; | 4433 | 3.35k | LINENO *src; | 4434 | 3.35k | bool have_func; | 4435 | 3.35k | bool ret = true; | 4436 | 3.35k | size_t amt; | 4437 | | | 4438 | 3.35k | if (asect->lineno_count == 0) | 4439 | 3.24k | return true; | 4440 | | | 4441 | 114 | BFD_ASSERT (asect->lineno == NULL); | 4442 | | | 4443 | 114 | native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, | 4444 | 114 | asect->lineno_count, | 4445 | 114 | bfd_coff_linesz (abfd)); | 4446 | 114 | if (native_lineno == NULL) | 4447 | 35 | { | 4448 | 35 | _bfd_error_handler | 4449 | 35 | (_("%pB: warning: line number table read failed"), abfd); | 4450 | 35 | return false; | 4451 | 35 | } | 4452 | | | 4453 | 79 | if (_bfd_mul_overflow (asect->lineno_count + 1, sizeof (alent), &amt)) | 4454 | 0 | { | 4455 | 0 | bfd_set_error (bfd_error_file_too_big); | 4456 | 0 | free (native_lineno); | 4457 | 0 | return false; | 4458 | 0 | } | 4459 | 79 | lineno_cache = (alent *) bfd_alloc (abfd, amt); | 4460 | 79 | if (lineno_cache == NULL) | 4461 | 0 | { | 4462 | 0 | free (native_lineno); | 4463 | 0 | return false; | 4464 | 0 | } | 4465 | | | 4466 | 79 | cache_ptr = lineno_cache; | 4467 | 79 | asect->lineno = lineno_cache; | 4468 | 79 | src = native_lineno; | 4469 | 79 | nbr_func = 0; | 4470 | 79 | have_func = false; | 4471 | | | 4472 | 24.4k | for (counter = 0; counter < asect->lineno_count; counter++, src++) | 4473 | 24.3k | { | 4474 | 24.3k | struct internal_lineno dst; | 4475 | | | 4476 | 24.3k | bfd_coff_swap_lineno_in (abfd, src, &dst); | 4477 | 24.3k | cache_ptr->line_number = dst.l_lnno; | 4478 | | /* Appease memory checkers that get all excited about | 4479 | | uninitialised memory when copying alents if u.offset is | 4480 | | larger than u.sym. (64-bit BFD on 32-bit host.) */ | 4481 | 24.3k | memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); | 4482 | | | 4483 | 24.3k | if (cache_ptr->line_number == 0) | 4484 | 12.3k | { | 4485 | 12.3k | combined_entry_type * ent; | 4486 | 12.3k | unsigned long symndx; | 4487 | 12.3k | coff_symbol_type *sym; | 4488 | | | 4489 | 12.3k | have_func = false; | 4490 | 12.3k | symndx = dst.l_addr.l_symndx; | 4491 | 12.3k | if (symndx >= obj_raw_syment_count (abfd)) | 4492 | 5.50k | { | 4493 | 5.50k | _bfd_error_handler | 4494 | | /* xgettext:c-format */ | 4495 | 5.50k | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4496 | 5.50k | abfd, symndx, counter); | 4497 | 5.50k | cache_ptr->line_number = -1; | 4498 | 5.50k | ret = false; | 4499 | 5.50k | continue; | 4500 | 5.50k | } | 4501 | | | 4502 | 6.89k | ent = obj_raw_syments (abfd) + symndx; | 4503 | | /* FIXME: We should not be casting between ints and | 4504 | | pointers like this. */ | 4505 | 6.89k | if (! ent->is_sym) | 4506 | 418 | { | 4507 | 418 | _bfd_error_handler | 4508 | | /* xgettext:c-format */ | 4509 | 418 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4510 | 418 | abfd, symndx, counter); | 4511 | 418 | cache_ptr->line_number = -1; | 4512 | 418 | ret = false; | 4513 | 418 | continue; | 4514 | 418 | } | 4515 | 6.47k | sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); | 4516 | | | 4517 | | /* PR 17512 file: 078-10659-0.004 */ | 4518 | 6.47k | if (sym < obj_symbols (abfd) | 4519 | 6.47k | || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd)) | 4520 | 0 | { | 4521 | 0 | _bfd_error_handler | 4522 | | /* xgettext:c-format */ | 4523 | 0 | (_("%pB: warning: illegal symbol in line number entry %d"), | 4524 | 0 | abfd, counter); | 4525 | 0 | cache_ptr->line_number = -1; | 4526 | 0 | ret = false; | 4527 | 0 | continue; | 4528 | 0 | } | 4529 | | | 4530 | 6.47k | have_func = true; | 4531 | 6.47k | nbr_func++; | 4532 | 6.47k | cache_ptr->u.sym = (asymbol *) sym; | 4533 | 6.47k | if (sym->lineno != NULL) | 4534 | 6.29k | _bfd_error_handler | 4535 | | /* xgettext:c-format */ | 4536 | 6.29k | (_("%pB: warning: duplicate line number information for `%s'"), | 4537 | 6.29k | abfd, bfd_asymbol_name (&sym->symbol)); | 4538 | | | 4539 | 6.47k | sym->lineno = cache_ptr; | 4540 | 6.47k | if (sym->symbol.value < prev_offset) | 4541 | 177 | ordered = false; | 4542 | 6.47k | prev_offset = sym->symbol.value; | 4543 | 6.47k | } | 4544 | 11.9k | else if (!have_func) | 4545 | | /* Drop line information that has no associated function. | 4546 | | PR 17521: file: 078-10659-0.004. */ | 4547 | 7.00k | continue; | 4548 | 4.92k | else | 4549 | 4.92k | cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect); | 4550 | 11.3k | cache_ptr++; | 4551 | 11.3k | } | 4552 | | | 4553 | 79 | asect->lineno_count = cache_ptr - lineno_cache; | 4554 | 79 | memset (cache_ptr, 0, sizeof (*cache_ptr)); | 4555 | 79 | free (native_lineno); | 4556 | | | 4557 | | /* On some systems (eg AIX5.3) the lineno table may not be sorted. */ | 4558 | 79 | if (!ordered) | 4559 | 42 | { | 4560 | | /* Sort the table. */ | 4561 | 42 | alent **func_table; | 4562 | 42 | alent *n_lineno_cache; | 4563 | | | 4564 | | /* Create a table of functions. */ | 4565 | 42 | if (_bfd_mul_overflow (nbr_func, sizeof (alent *), &amt)) | 4566 | 0 | { | 4567 | 0 | bfd_set_error (bfd_error_file_too_big); | 4568 | 0 | ret = false; | 4569 | 0 | } | 4570 | 42 | else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL) | 4571 | 42 | { | 4572 | 42 | alent **p = func_table; | 4573 | 42 | unsigned int i; | 4574 | | | 4575 | 9.52k | for (i = 0; i < asect->lineno_count; i++) | 4576 | 9.48k | if (lineno_cache[i].line_number == 0) | 4577 | 4.90k | *p++ = &lineno_cache[i]; | 4578 | | | 4579 | 42 | BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func); | 4580 | | | 4581 | | /* Sort by functions. */ | 4582 | 42 | qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent); | 4583 | | | 4584 | | /* Create the new sorted table. */ | 4585 | 42 | if (_bfd_mul_overflow (asect->lineno_count, sizeof (alent), &amt)) | 4586 | 0 | { | 4587 | 0 | bfd_set_error (bfd_error_file_too_big); | 4588 | 0 | ret = false; | 4589 | 0 | } | 4590 | 42 | else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL) | 4591 | 42 | { | 4592 | 42 | alent *n_cache_ptr = n_lineno_cache; | 4593 | | | 4594 | 4.94k | for (i = 0; i < nbr_func; i++) | 4595 | 4.90k | { | 4596 | 4.90k | coff_symbol_type *sym; | 4597 | 4.90k | alent *old_ptr = func_table[i]; | 4598 | | | 4599 | | /* Update the function entry. */ | 4600 | 4.90k | sym = (coff_symbol_type *) old_ptr->u.sym; | 4601 | | /* PR binutils/17512: Point the lineno to where | 4602 | | this entry will be after the memcpy below. */ | 4603 | 4.90k | sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); | 4604 | | /* Copy the function and line number entries. */ | 4605 | 4.90k | do | 4606 | 9.48k | *n_cache_ptr++ = *old_ptr++; | 4607 | 9.48k | while (old_ptr->line_number != 0); | 4608 | 4.90k | } | 4609 | | | 4610 | 42 | memcpy (lineno_cache, n_lineno_cache, | 4611 | 42 | asect->lineno_count * sizeof (alent)); | 4612 | 42 | } | 4613 | 0 | else | 4614 | 0 | ret = false; | 4615 | 42 | bfd_release (abfd, func_table); | 4616 | 42 | } | 4617 | 0 | else | 4618 | 0 | ret = false; | 4619 | 42 | } | 4620 | | | 4621 | 79 | return ret; | 4622 | 79 | } |
pei-ia64.c:coff_slurp_line_table Line | Count | Source | 4425 | 308 | { | 4426 | 308 | LINENO *native_lineno; | 4427 | 308 | alent *lineno_cache; | 4428 | 308 | unsigned int counter; | 4429 | 308 | alent *cache_ptr; | 4430 | 308 | bfd_vma prev_offset = 0; | 4431 | 308 | bool ordered = true; | 4432 | 308 | unsigned int nbr_func; | 4433 | 308 | LINENO *src; | 4434 | 308 | bool have_func; | 4435 | 308 | bool ret = true; | 4436 | 308 | size_t amt; | 4437 | | | 4438 | 308 | if (asect->lineno_count == 0) | 4439 | 190 | return true; | 4440 | | | 4441 | 118 | BFD_ASSERT (asect->lineno == NULL); | 4442 | | | 4443 | 118 | native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, | 4444 | 118 | asect->lineno_count, | 4445 | 118 | bfd_coff_linesz (abfd)); | 4446 | 118 | if (native_lineno == NULL) | 4447 | 26 | { | 4448 | 26 | _bfd_error_handler | 4449 | 26 | (_("%pB: warning: line number table read failed"), abfd); | 4450 | 26 | return false; | 4451 | 26 | } | 4452 | | | 4453 | 92 | if (_bfd_mul_overflow (asect->lineno_count + 1, sizeof (alent), &amt)) | 4454 | 0 | { | 4455 | 0 | bfd_set_error (bfd_error_file_too_big); | 4456 | 0 | free (native_lineno); | 4457 | 0 | return false; | 4458 | 0 | } | 4459 | 92 | lineno_cache = (alent *) bfd_alloc (abfd, amt); | 4460 | 92 | if (lineno_cache == NULL) | 4461 | 0 | { | 4462 | 0 | free (native_lineno); | 4463 | 0 | return false; | 4464 | 0 | } | 4465 | | | 4466 | 92 | cache_ptr = lineno_cache; | 4467 | 92 | asect->lineno = lineno_cache; | 4468 | 92 | src = native_lineno; | 4469 | 92 | nbr_func = 0; | 4470 | 92 | have_func = false; | 4471 | | | 4472 | 16.8k | for (counter = 0; counter < asect->lineno_count; counter++, src++) | 4473 | 16.7k | { | 4474 | 16.7k | struct internal_lineno dst; | 4475 | | | 4476 | 16.7k | bfd_coff_swap_lineno_in (abfd, src, &dst); | 4477 | 16.7k | cache_ptr->line_number = dst.l_lnno; | 4478 | | /* Appease memory checkers that get all excited about | 4479 | | uninitialised memory when copying alents if u.offset is | 4480 | | larger than u.sym. (64-bit BFD on 32-bit host.) */ | 4481 | 16.7k | memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); | 4482 | | | 4483 | 16.7k | if (cache_ptr->line_number == 0) | 4484 | 6.80k | { | 4485 | 6.80k | combined_entry_type * ent; | 4486 | 6.80k | unsigned long symndx; | 4487 | 6.80k | coff_symbol_type *sym; | 4488 | | | 4489 | 6.80k | have_func = false; | 4490 | 6.80k | symndx = dst.l_addr.l_symndx; | 4491 | 6.80k | if (symndx >= obj_raw_syment_count (abfd)) | 4492 | 3.18k | { | 4493 | 3.18k | _bfd_error_handler | 4494 | | /* xgettext:c-format */ | 4495 | 3.18k | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4496 | 3.18k | abfd, symndx, counter); | 4497 | 3.18k | cache_ptr->line_number = -1; | 4498 | 3.18k | ret = false; | 4499 | 3.18k | continue; | 4500 | 3.18k | } | 4501 | | | 4502 | 3.62k | ent = obj_raw_syments (abfd) + symndx; | 4503 | | /* FIXME: We should not be casting between ints and | 4504 | | pointers like this. */ | 4505 | 3.62k | if (! ent->is_sym) | 4506 | 300 | { | 4507 | 300 | _bfd_error_handler | 4508 | | /* xgettext:c-format */ | 4509 | 300 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4510 | 300 | abfd, symndx, counter); | 4511 | 300 | cache_ptr->line_number = -1; | 4512 | 300 | ret = false; | 4513 | 300 | continue; | 4514 | 300 | } | 4515 | 3.32k | sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); | 4516 | | | 4517 | | /* PR 17512 file: 078-10659-0.004 */ | 4518 | 3.32k | if (sym < obj_symbols (abfd) | 4519 | 3.32k | || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd)) | 4520 | 0 | { | 4521 | 0 | _bfd_error_handler | 4522 | | /* xgettext:c-format */ | 4523 | 0 | (_("%pB: warning: illegal symbol in line number entry %d"), | 4524 | 0 | abfd, counter); | 4525 | 0 | cache_ptr->line_number = -1; | 4526 | 0 | ret = false; | 4527 | 0 | continue; | 4528 | 0 | } | 4529 | | | 4530 | 3.32k | have_func = true; | 4531 | 3.32k | nbr_func++; | 4532 | 3.32k | cache_ptr->u.sym = (asymbol *) sym; | 4533 | 3.32k | if (sym->lineno != NULL) | 4534 | 3.15k | _bfd_error_handler | 4535 | | /* xgettext:c-format */ | 4536 | 3.15k | (_("%pB: warning: duplicate line number information for `%s'"), | 4537 | 3.15k | abfd, bfd_asymbol_name (&sym->symbol)); | 4538 | | | 4539 | 3.32k | sym->lineno = cache_ptr; | 4540 | 3.32k | if (sym->symbol.value < prev_offset) | 4541 | 104 | ordered = false; | 4542 | 3.32k | prev_offset = sym->symbol.value; | 4543 | 3.32k | } | 4544 | 9.97k | else if (!have_func) | 4545 | | /* Drop line information that has no associated function. | 4546 | | PR 17521: file: 078-10659-0.004. */ | 4547 | 5.87k | continue; | 4548 | 4.10k | else | 4549 | 4.10k | cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect); | 4550 | 7.42k | cache_ptr++; | 4551 | 7.42k | } | 4552 | | | 4553 | 92 | asect->lineno_count = cache_ptr - lineno_cache; | 4554 | 92 | memset (cache_ptr, 0, sizeof (*cache_ptr)); | 4555 | 92 | free (native_lineno); | 4556 | | | 4557 | | /* On some systems (eg AIX5.3) the lineno table may not be sorted. */ | 4558 | 92 | if (!ordered) | 4559 | 36 | { | 4560 | | /* Sort the table. */ | 4561 | 36 | alent **func_table; | 4562 | 36 | alent *n_lineno_cache; | 4563 | | | 4564 | | /* Create a table of functions. */ | 4565 | 36 | if (_bfd_mul_overflow (nbr_func, sizeof (alent *), &amt)) | 4566 | 0 | { | 4567 | 0 | bfd_set_error (bfd_error_file_too_big); | 4568 | 0 | ret = false; | 4569 | 0 | } | 4570 | 36 | else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL) | 4571 | 36 | { | 4572 | 36 | alent **p = func_table; | 4573 | 36 | unsigned int i; | 4574 | | | 4575 | 6.05k | for (i = 0; i < asect->lineno_count; i++) | 4576 | 6.02k | if (lineno_cache[i].line_number == 0) | 4577 | 2.67k | *p++ = &lineno_cache[i]; | 4578 | | | 4579 | 36 | BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func); | 4580 | | | 4581 | | /* Sort by functions. */ | 4582 | 36 | qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent); | 4583 | | | 4584 | | /* Create the new sorted table. */ | 4585 | 36 | if (_bfd_mul_overflow (asect->lineno_count, sizeof (alent), &amt)) | 4586 | 0 | { | 4587 | 0 | bfd_set_error (bfd_error_file_too_big); | 4588 | 0 | ret = false; | 4589 | 0 | } | 4590 | 36 | else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL) | 4591 | 36 | { | 4592 | 36 | alent *n_cache_ptr = n_lineno_cache; | 4593 | | | 4594 | 2.71k | for (i = 0; i < nbr_func; i++) | 4595 | 2.67k | { | 4596 | 2.67k | coff_symbol_type *sym; | 4597 | 2.67k | alent *old_ptr = func_table[i]; | 4598 | | | 4599 | | /* Update the function entry. */ | 4600 | 2.67k | sym = (coff_symbol_type *) old_ptr->u.sym; | 4601 | | /* PR binutils/17512: Point the lineno to where | 4602 | | this entry will be after the memcpy below. */ | 4603 | 2.67k | sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); | 4604 | | /* Copy the function and line number entries. */ | 4605 | 2.67k | do | 4606 | 6.02k | *n_cache_ptr++ = *old_ptr++; | 4607 | 6.02k | while (old_ptr->line_number != 0); | 4608 | 2.67k | } | 4609 | | | 4610 | 36 | memcpy (lineno_cache, n_lineno_cache, | 4611 | 36 | asect->lineno_count * sizeof (alent)); | 4612 | 36 | } | 4613 | 0 | else | 4614 | 0 | ret = false; | 4615 | 36 | bfd_release (abfd, func_table); | 4616 | 36 | } | 4617 | 0 | else | 4618 | 0 | ret = false; | 4619 | 36 | } | 4620 | | | 4621 | 92 | return ret; | 4622 | 92 | } |
pei-loongarch64.c:coff_slurp_line_table Line | Count | Source | 4425 | 327 | { | 4426 | 327 | LINENO *native_lineno; | 4427 | 327 | alent *lineno_cache; | 4428 | 327 | unsigned int counter; | 4429 | 327 | alent *cache_ptr; | 4430 | 327 | bfd_vma prev_offset = 0; | 4431 | 327 | bool ordered = true; | 4432 | 327 | unsigned int nbr_func; | 4433 | 327 | LINENO *src; | 4434 | 327 | bool have_func; | 4435 | 327 | bool ret = true; | 4436 | 327 | size_t amt; | 4437 | | | 4438 | 327 | if (asect->lineno_count == 0) | 4439 | 191 | return true; | 4440 | | | 4441 | 136 | BFD_ASSERT (asect->lineno == NULL); | 4442 | | | 4443 | 136 | native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, | 4444 | 136 | asect->lineno_count, | 4445 | 136 | bfd_coff_linesz (abfd)); | 4446 | 136 | if (native_lineno == NULL) | 4447 | 72 | { | 4448 | 72 | _bfd_error_handler | 4449 | 72 | (_("%pB: warning: line number table read failed"), abfd); | 4450 | 72 | return false; | 4451 | 72 | } | 4452 | | | 4453 | 64 | if (_bfd_mul_overflow (asect->lineno_count + 1, sizeof (alent), &amt)) | 4454 | 0 | { | 4455 | 0 | bfd_set_error (bfd_error_file_too_big); | 4456 | 0 | free (native_lineno); | 4457 | 0 | return false; | 4458 | 0 | } | 4459 | 64 | lineno_cache = (alent *) bfd_alloc (abfd, amt); | 4460 | 64 | if (lineno_cache == NULL) | 4461 | 0 | { | 4462 | 0 | free (native_lineno); | 4463 | 0 | return false; | 4464 | 0 | } | 4465 | | | 4466 | 64 | cache_ptr = lineno_cache; | 4467 | 64 | asect->lineno = lineno_cache; | 4468 | 64 | src = native_lineno; | 4469 | 64 | nbr_func = 0; | 4470 | 64 | have_func = false; | 4471 | | | 4472 | 128k | for (counter = 0; counter < asect->lineno_count; counter++, src++) | 4473 | 128k | { | 4474 | 128k | struct internal_lineno dst; | 4475 | | | 4476 | 128k | bfd_coff_swap_lineno_in (abfd, src, &dst); | 4477 | 128k | cache_ptr->line_number = dst.l_lnno; | 4478 | | /* Appease memory checkers that get all excited about | 4479 | | uninitialised memory when copying alents if u.offset is | 4480 | | larger than u.sym. (64-bit BFD on 32-bit host.) */ | 4481 | 128k | memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); | 4482 | | | 4483 | 128k | if (cache_ptr->line_number == 0) | 4484 | 70.5k | { | 4485 | 70.5k | combined_entry_type * ent; | 4486 | 70.5k | unsigned long symndx; | 4487 | 70.5k | coff_symbol_type *sym; | 4488 | | | 4489 | 70.5k | have_func = false; | 4490 | 70.5k | symndx = dst.l_addr.l_symndx; | 4491 | 70.5k | if (symndx >= obj_raw_syment_count (abfd)) | 4492 | 20.6k | { | 4493 | 20.6k | _bfd_error_handler | 4494 | | /* xgettext:c-format */ | 4495 | 20.6k | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4496 | 20.6k | abfd, symndx, counter); | 4497 | 20.6k | cache_ptr->line_number = -1; | 4498 | 20.6k | ret = false; | 4499 | 20.6k | continue; | 4500 | 20.6k | } | 4501 | | | 4502 | 49.8k | ent = obj_raw_syments (abfd) + symndx; | 4503 | | /* FIXME: We should not be casting between ints and | 4504 | | pointers like this. */ | 4505 | 49.8k | if (! ent->is_sym) | 4506 | 3.82k | { | 4507 | 3.82k | _bfd_error_handler | 4508 | | /* xgettext:c-format */ | 4509 | 3.82k | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4510 | 3.82k | abfd, symndx, counter); | 4511 | 3.82k | cache_ptr->line_number = -1; | 4512 | 3.82k | ret = false; | 4513 | 3.82k | continue; | 4514 | 3.82k | } | 4515 | 46.0k | sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); | 4516 | | | 4517 | | /* PR 17512 file: 078-10659-0.004 */ | 4518 | 46.0k | if (sym < obj_symbols (abfd) | 4519 | 46.0k | || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd)) | 4520 | 0 | { | 4521 | 0 | _bfd_error_handler | 4522 | | /* xgettext:c-format */ | 4523 | 0 | (_("%pB: warning: illegal symbol in line number entry %d"), | 4524 | 0 | abfd, counter); | 4525 | 0 | cache_ptr->line_number = -1; | 4526 | 0 | ret = false; | 4527 | 0 | continue; | 4528 | 0 | } | 4529 | | | 4530 | 46.0k | have_func = true; | 4531 | 46.0k | nbr_func++; | 4532 | 46.0k | cache_ptr->u.sym = (asymbol *) sym; | 4533 | 46.0k | if (sym->lineno != NULL) | 4534 | 45.5k | _bfd_error_handler | 4535 | | /* xgettext:c-format */ | 4536 | 45.5k | (_("%pB: warning: duplicate line number information for `%s'"), | 4537 | 45.5k | abfd, bfd_asymbol_name (&sym->symbol)); | 4538 | | | 4539 | 46.0k | sym->lineno = cache_ptr; | 4540 | 46.0k | if (sym->symbol.value < prev_offset) | 4541 | 319 | ordered = false; | 4542 | 46.0k | prev_offset = sym->symbol.value; | 4543 | 46.0k | } | 4544 | 57.5k | else if (!have_func) | 4545 | | /* Drop line information that has no associated function. | 4546 | | PR 17521: file: 078-10659-0.004. */ | 4547 | 41.1k | continue; | 4548 | 16.3k | else | 4549 | 16.3k | cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect); | 4550 | 62.4k | cache_ptr++; | 4551 | 62.4k | } | 4552 | | | 4553 | 64 | asect->lineno_count = cache_ptr - lineno_cache; | 4554 | 64 | memset (cache_ptr, 0, sizeof (*cache_ptr)); | 4555 | 64 | free (native_lineno); | 4556 | | | 4557 | | /* On some systems (eg AIX5.3) the lineno table may not be sorted. */ | 4558 | 64 | if (!ordered) | 4559 | 46 | { | 4560 | | /* Sort the table. */ | 4561 | 46 | alent **func_table; | 4562 | 46 | alent *n_lineno_cache; | 4563 | | | 4564 | | /* Create a table of functions. */ | 4565 | 46 | if (_bfd_mul_overflow (nbr_func, sizeof (alent *), &amt)) | 4566 | 0 | { | 4567 | 0 | bfd_set_error (bfd_error_file_too_big); | 4568 | 0 | ret = false; | 4569 | 0 | } | 4570 | 46 | else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL) | 4571 | 46 | { | 4572 | 46 | alent **p = func_table; | 4573 | 46 | unsigned int i; | 4574 | | | 4575 | 62.1k | for (i = 0; i < asect->lineno_count; i++) | 4576 | 62.1k | if (lineno_cache[i].line_number == 0) | 4577 | 45.9k | *p++ = &lineno_cache[i]; | 4578 | | | 4579 | 46 | BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func); | 4580 | | | 4581 | | /* Sort by functions. */ | 4582 | 46 | qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent); | 4583 | | | 4584 | | /* Create the new sorted table. */ | 4585 | 46 | if (_bfd_mul_overflow (asect->lineno_count, sizeof (alent), &amt)) | 4586 | 0 | { | 4587 | 0 | bfd_set_error (bfd_error_file_too_big); | 4588 | 0 | ret = false; | 4589 | 0 | } | 4590 | 46 | else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL) | 4591 | 46 | { | 4592 | 46 | alent *n_cache_ptr = n_lineno_cache; | 4593 | | | 4594 | 45.9k | for (i = 0; i < nbr_func; i++) | 4595 | 45.9k | { | 4596 | 45.9k | coff_symbol_type *sym; | 4597 | 45.9k | alent *old_ptr = func_table[i]; | 4598 | | | 4599 | | /* Update the function entry. */ | 4600 | 45.9k | sym = (coff_symbol_type *) old_ptr->u.sym; | 4601 | | /* PR binutils/17512: Point the lineno to where | 4602 | | this entry will be after the memcpy below. */ | 4603 | 45.9k | sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); | 4604 | | /* Copy the function and line number entries. */ | 4605 | 45.9k | do | 4606 | 62.1k | *n_cache_ptr++ = *old_ptr++; | 4607 | 62.1k | while (old_ptr->line_number != 0); | 4608 | 45.9k | } | 4609 | | | 4610 | 46 | memcpy (lineno_cache, n_lineno_cache, | 4611 | 46 | asect->lineno_count * sizeof (alent)); | 4612 | 46 | } | 4613 | 0 | else | 4614 | 0 | ret = false; | 4615 | 46 | bfd_release (abfd, func_table); | 4616 | 46 | } | 4617 | 0 | else | 4618 | 0 | ret = false; | 4619 | 46 | } | 4620 | | | 4621 | 64 | return ret; | 4622 | 64 | } |
Unexecuted instantiation: cf-i386lynx.c:coff_slurp_line_table Unexecuted instantiation: coff-go32.c:coff_slurp_line_table Unexecuted instantiation: coff-i386.c:coff_slurp_line_table coff-rs6000.c:coff_slurp_line_table Line | Count | Source | 4425 | 1.90k | { | 4426 | 1.90k | LINENO *native_lineno; | 4427 | 1.90k | alent *lineno_cache; | 4428 | 1.90k | unsigned int counter; | 4429 | 1.90k | alent *cache_ptr; | 4430 | 1.90k | bfd_vma prev_offset = 0; | 4431 | 1.90k | bool ordered = true; | 4432 | 1.90k | unsigned int nbr_func; | 4433 | 1.90k | LINENO *src; | 4434 | 1.90k | bool have_func; | 4435 | 1.90k | bool ret = true; | 4436 | 1.90k | size_t amt; | 4437 | | | 4438 | 1.90k | if (asect->lineno_count == 0) | 4439 | 1.65k | return true; | 4440 | | | 4441 | 253 | BFD_ASSERT (asect->lineno == NULL); | 4442 | | | 4443 | 253 | native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, | 4444 | 253 | asect->lineno_count, | 4445 | 253 | bfd_coff_linesz (abfd)); | 4446 | 253 | if (native_lineno == NULL) | 4447 | 126 | { | 4448 | 126 | _bfd_error_handler | 4449 | 126 | (_("%pB: warning: line number table read failed"), abfd); | 4450 | 126 | return false; | 4451 | 126 | } | 4452 | | | 4453 | 127 | if (_bfd_mul_overflow (asect->lineno_count + 1, sizeof (alent), &amt)) | 4454 | 0 | { | 4455 | 0 | bfd_set_error (bfd_error_file_too_big); | 4456 | 0 | free (native_lineno); | 4457 | 0 | return false; | 4458 | 0 | } | 4459 | 127 | lineno_cache = (alent *) bfd_alloc (abfd, amt); | 4460 | 127 | if (lineno_cache == NULL) | 4461 | 0 | { | 4462 | 0 | free (native_lineno); | 4463 | 0 | return false; | 4464 | 0 | } | 4465 | | | 4466 | 127 | cache_ptr = lineno_cache; | 4467 | 127 | asect->lineno = lineno_cache; | 4468 | 127 | src = native_lineno; | 4469 | 127 | nbr_func = 0; | 4470 | 127 | have_func = false; | 4471 | | | 4472 | 135k | for (counter = 0; counter < asect->lineno_count; counter++, src++) | 4473 | 135k | { | 4474 | 135k | struct internal_lineno dst; | 4475 | | | 4476 | 135k | bfd_coff_swap_lineno_in (abfd, src, &dst); | 4477 | 135k | cache_ptr->line_number = dst.l_lnno; | 4478 | | /* Appease memory checkers that get all excited about | 4479 | | uninitialised memory when copying alents if u.offset is | 4480 | | larger than u.sym. (64-bit BFD on 32-bit host.) */ | 4481 | 135k | memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); | 4482 | | | 4483 | 135k | if (cache_ptr->line_number == 0) | 4484 | 55.2k | { | 4485 | 55.2k | combined_entry_type * ent; | 4486 | 55.2k | unsigned long symndx; | 4487 | 55.2k | coff_symbol_type *sym; | 4488 | | | 4489 | 55.2k | have_func = false; | 4490 | 55.2k | symndx = dst.l_addr.l_symndx; | 4491 | 55.2k | if (symndx >= obj_raw_syment_count (abfd)) | 4492 | 23.1k | { | 4493 | 23.1k | _bfd_error_handler | 4494 | | /* xgettext:c-format */ | 4495 | 23.1k | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4496 | 23.1k | abfd, symndx, counter); | 4497 | 23.1k | cache_ptr->line_number = -1; | 4498 | 23.1k | ret = false; | 4499 | 23.1k | continue; | 4500 | 23.1k | } | 4501 | | | 4502 | 32.1k | ent = obj_raw_syments (abfd) + symndx; | 4503 | | /* FIXME: We should not be casting between ints and | 4504 | | pointers like this. */ | 4505 | 32.1k | if (! ent->is_sym) | 4506 | 3.28k | { | 4507 | 3.28k | _bfd_error_handler | 4508 | | /* xgettext:c-format */ | 4509 | 3.28k | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4510 | 3.28k | abfd, symndx, counter); | 4511 | 3.28k | cache_ptr->line_number = -1; | 4512 | 3.28k | ret = false; | 4513 | 3.28k | continue; | 4514 | 3.28k | } | 4515 | 28.8k | sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); | 4516 | | | 4517 | | /* PR 17512 file: 078-10659-0.004 */ | 4518 | 28.8k | if (sym < obj_symbols (abfd) | 4519 | 28.8k | || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd)) | 4520 | 0 | { | 4521 | 0 | _bfd_error_handler | 4522 | | /* xgettext:c-format */ | 4523 | 0 | (_("%pB: warning: illegal symbol in line number entry %d"), | 4524 | 0 | abfd, counter); | 4525 | 0 | cache_ptr->line_number = -1; | 4526 | 0 | ret = false; | 4527 | 0 | continue; | 4528 | 0 | } | 4529 | | | 4530 | 28.8k | have_func = true; | 4531 | 28.8k | nbr_func++; | 4532 | 28.8k | cache_ptr->u.sym = (asymbol *) sym; | 4533 | 28.8k | if (sym->lineno != NULL) | 4534 | 28.4k | _bfd_error_handler | 4535 | | /* xgettext:c-format */ | 4536 | 28.4k | (_("%pB: warning: duplicate line number information for `%s'"), | 4537 | 28.4k | abfd, bfd_asymbol_name (&sym->symbol)); | 4538 | | | 4539 | 28.8k | sym->lineno = cache_ptr; | 4540 | 28.8k | if (sym->symbol.value < prev_offset) | 4541 | 637 | ordered = false; | 4542 | 28.8k | prev_offset = sym->symbol.value; | 4543 | 28.8k | } | 4544 | 80.3k | else if (!have_func) | 4545 | | /* Drop line information that has no associated function. | 4546 | | PR 17521: file: 078-10659-0.004. */ | 4547 | 36.9k | continue; | 4548 | 43.4k | else | 4549 | 43.4k | cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect); | 4550 | 72.3k | cache_ptr++; | 4551 | 72.3k | } | 4552 | | | 4553 | 127 | asect->lineno_count = cache_ptr - lineno_cache; | 4554 | 127 | memset (cache_ptr, 0, sizeof (*cache_ptr)); | 4555 | 127 | free (native_lineno); | 4556 | | | 4557 | | /* On some systems (eg AIX5.3) the lineno table may not be sorted. */ | 4558 | 127 | if (!ordered) | 4559 | 60 | { | 4560 | | /* Sort the table. */ | 4561 | 60 | alent **func_table; | 4562 | 60 | alent *n_lineno_cache; | 4563 | | | 4564 | | /* Create a table of functions. */ | 4565 | 60 | if (_bfd_mul_overflow (nbr_func, sizeof (alent *), &amt)) | 4566 | 0 | { | 4567 | 0 | bfd_set_error (bfd_error_file_too_big); | 4568 | 0 | ret = false; | 4569 | 0 | } | 4570 | 60 | else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL) | 4571 | 60 | { | 4572 | 60 | alent **p = func_table; | 4573 | 60 | unsigned int i; | 4574 | | | 4575 | 57.4k | for (i = 0; i < asect->lineno_count; i++) | 4576 | 57.3k | if (lineno_cache[i].line_number == 0) | 4577 | 23.0k | *p++ = &lineno_cache[i]; | 4578 | | | 4579 | 60 | BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func); | 4580 | | | 4581 | | /* Sort by functions. */ | 4582 | 60 | qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent); | 4583 | | | 4584 | | /* Create the new sorted table. */ | 4585 | 60 | if (_bfd_mul_overflow (asect->lineno_count, sizeof (alent), &amt)) | 4586 | 0 | { | 4587 | 0 | bfd_set_error (bfd_error_file_too_big); | 4588 | 0 | ret = false; | 4589 | 0 | } | 4590 | 60 | else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL) | 4591 | 60 | { | 4592 | 60 | alent *n_cache_ptr = n_lineno_cache; | 4593 | | | 4594 | 23.1k | for (i = 0; i < nbr_func; i++) | 4595 | 23.0k | { | 4596 | 23.0k | coff_symbol_type *sym; | 4597 | 23.0k | alent *old_ptr = func_table[i]; | 4598 | | | 4599 | | /* Update the function entry. */ | 4600 | 23.0k | sym = (coff_symbol_type *) old_ptr->u.sym; | 4601 | | /* PR binutils/17512: Point the lineno to where | 4602 | | this entry will be after the memcpy below. */ | 4603 | 23.0k | sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); | 4604 | | /* Copy the function and line number entries. */ | 4605 | 23.0k | do | 4606 | 57.3k | *n_cache_ptr++ = *old_ptr++; | 4607 | 57.3k | while (old_ptr->line_number != 0); | 4608 | 23.0k | } | 4609 | | | 4610 | 60 | memcpy (lineno_cache, n_lineno_cache, | 4611 | 60 | asect->lineno_count * sizeof (alent)); | 4612 | 60 | } | 4613 | 0 | else | 4614 | 0 | ret = false; | 4615 | 60 | bfd_release (abfd, func_table); | 4616 | 60 | } | 4617 | 0 | else | 4618 | 0 | ret = false; | 4619 | 60 | } | 4620 | | | 4621 | 127 | return ret; | 4622 | 127 | } |
Unexecuted instantiation: coff-sh.c:coff_slurp_line_table Unexecuted instantiation: coff-stgo32.c:coff_slurp_line_table coff-tic30.c:coff_slurp_line_table Line | Count | Source | 4425 | 4.06k | { | 4426 | 4.06k | LINENO *native_lineno; | 4427 | 4.06k | alent *lineno_cache; | 4428 | 4.06k | unsigned int counter; | 4429 | 4.06k | alent *cache_ptr; | 4430 | 4.06k | bfd_vma prev_offset = 0; | 4431 | 4.06k | bool ordered = true; | 4432 | 4.06k | unsigned int nbr_func; | 4433 | 4.06k | LINENO *src; | 4434 | 4.06k | bool have_func; | 4435 | 4.06k | bool ret = true; | 4436 | 4.06k | size_t amt; | 4437 | | | 4438 | 4.06k | if (asect->lineno_count == 0) | 4439 | 3.66k | return true; | 4440 | | | 4441 | 400 | BFD_ASSERT (asect->lineno == NULL); | 4442 | | | 4443 | 400 | native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, | 4444 | 400 | asect->lineno_count, | 4445 | 400 | bfd_coff_linesz (abfd)); | 4446 | 400 | if (native_lineno == NULL) | 4447 | 95 | { | 4448 | 95 | _bfd_error_handler | 4449 | 95 | (_("%pB: warning: line number table read failed"), abfd); | 4450 | 95 | return false; | 4451 | 95 | } | 4452 | | | 4453 | 305 | if (_bfd_mul_overflow (asect->lineno_count + 1, sizeof (alent), &amt)) | 4454 | 0 | { | 4455 | 0 | bfd_set_error (bfd_error_file_too_big); | 4456 | 0 | free (native_lineno); | 4457 | 0 | return false; | 4458 | 0 | } | 4459 | 305 | lineno_cache = (alent *) bfd_alloc (abfd, amt); | 4460 | 305 | if (lineno_cache == NULL) | 4461 | 0 | { | 4462 | 0 | free (native_lineno); | 4463 | 0 | return false; | 4464 | 0 | } | 4465 | | | 4466 | 305 | cache_ptr = lineno_cache; | 4467 | 305 | asect->lineno = lineno_cache; | 4468 | 305 | src = native_lineno; | 4469 | 305 | nbr_func = 0; | 4470 | 305 | have_func = false; | 4471 | | | 4472 | 181k | for (counter = 0; counter < asect->lineno_count; counter++, src++) | 4473 | 181k | { | 4474 | 181k | struct internal_lineno dst; | 4475 | | | 4476 | 181k | bfd_coff_swap_lineno_in (abfd, src, &dst); | 4477 | 181k | cache_ptr->line_number = dst.l_lnno; | 4478 | | /* Appease memory checkers that get all excited about | 4479 | | uninitialised memory when copying alents if u.offset is | 4480 | | larger than u.sym. (64-bit BFD on 32-bit host.) */ | 4481 | 181k | memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); | 4482 | | | 4483 | 181k | if (cache_ptr->line_number == 0) | 4484 | 63.0k | { | 4485 | 63.0k | combined_entry_type * ent; | 4486 | 63.0k | unsigned long symndx; | 4487 | 63.0k | coff_symbol_type *sym; | 4488 | | | 4489 | 63.0k | have_func = false; | 4490 | 63.0k | symndx = dst.l_addr.l_symndx; | 4491 | 63.0k | if (symndx >= obj_raw_syment_count (abfd)) | 4492 | 16.5k | { | 4493 | 16.5k | _bfd_error_handler | 4494 | | /* xgettext:c-format */ | 4495 | 16.5k | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4496 | 16.5k | abfd, symndx, counter); | 4497 | 16.5k | cache_ptr->line_number = -1; | 4498 | 16.5k | ret = false; | 4499 | 16.5k | continue; | 4500 | 16.5k | } | 4501 | | | 4502 | 46.4k | ent = obj_raw_syments (abfd) + symndx; | 4503 | | /* FIXME: We should not be casting between ints and | 4504 | | pointers like this. */ | 4505 | 46.4k | if (! ent->is_sym) | 4506 | 4.59k | { | 4507 | 4.59k | _bfd_error_handler | 4508 | | /* xgettext:c-format */ | 4509 | 4.59k | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4510 | 4.59k | abfd, symndx, counter); | 4511 | 4.59k | cache_ptr->line_number = -1; | 4512 | 4.59k | ret = false; | 4513 | 4.59k | continue; | 4514 | 4.59k | } | 4515 | 41.8k | sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); | 4516 | | | 4517 | | /* PR 17512 file: 078-10659-0.004 */ | 4518 | 41.8k | if (sym < obj_symbols (abfd) | 4519 | 41.8k | || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd)) | 4520 | 0 | { | 4521 | 0 | _bfd_error_handler | 4522 | | /* xgettext:c-format */ | 4523 | 0 | (_("%pB: warning: illegal symbol in line number entry %d"), | 4524 | 0 | abfd, counter); | 4525 | 0 | cache_ptr->line_number = -1; | 4526 | 0 | ret = false; | 4527 | 0 | continue; | 4528 | 0 | } | 4529 | | | 4530 | 41.8k | have_func = true; | 4531 | 41.8k | nbr_func++; | 4532 | 41.8k | cache_ptr->u.sym = (asymbol *) sym; | 4533 | 41.8k | if (sym->lineno != NULL) | 4534 | 41.2k | _bfd_error_handler | 4535 | | /* xgettext:c-format */ | 4536 | 41.2k | (_("%pB: warning: duplicate line number information for `%s'"), | 4537 | 41.2k | abfd, bfd_asymbol_name (&sym->symbol)); | 4538 | | | 4539 | 41.8k | sym->lineno = cache_ptr; | 4540 | 41.8k | if (sym->symbol.value < prev_offset) | 4541 | 512 | ordered = false; | 4542 | 41.8k | prev_offset = sym->symbol.value; | 4543 | 41.8k | } | 4544 | 118k | else if (!have_func) | 4545 | | /* Drop line information that has no associated function. | 4546 | | PR 17521: file: 078-10659-0.004. */ | 4547 | 65.9k | continue; | 4548 | 52.3k | else | 4549 | 52.3k | cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect); | 4550 | 94.2k | cache_ptr++; | 4551 | 94.2k | } | 4552 | | | 4553 | 305 | asect->lineno_count = cache_ptr - lineno_cache; | 4554 | 305 | memset (cache_ptr, 0, sizeof (*cache_ptr)); | 4555 | 305 | free (native_lineno); | 4556 | | | 4557 | | /* On some systems (eg AIX5.3) the lineno table may not be sorted. */ | 4558 | 305 | if (!ordered) | 4559 | 54 | { | 4560 | | /* Sort the table. */ | 4561 | 54 | alent **func_table; | 4562 | 54 | alent *n_lineno_cache; | 4563 | | | 4564 | | /* Create a table of functions. */ | 4565 | 54 | if (_bfd_mul_overflow (nbr_func, sizeof (alent *), &amt)) | 4566 | 0 | { | 4567 | 0 | bfd_set_error (bfd_error_file_too_big); | 4568 | 0 | ret = false; | 4569 | 0 | } | 4570 | 54 | else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL) | 4571 | 54 | { | 4572 | 54 | alent **p = func_table; | 4573 | 54 | unsigned int i; | 4574 | | | 4575 | 84.4k | for (i = 0; i < asect->lineno_count; i++) | 4576 | 84.4k | if (lineno_cache[i].line_number == 0) | 4577 | 37.3k | *p++ = &lineno_cache[i]; | 4578 | | | 4579 | 54 | BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func); | 4580 | | | 4581 | | /* Sort by functions. */ | 4582 | 54 | qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent); | 4583 | | | 4584 | | /* Create the new sorted table. */ | 4585 | 54 | if (_bfd_mul_overflow (asect->lineno_count, sizeof (alent), &amt)) | 4586 | 0 | { | 4587 | 0 | bfd_set_error (bfd_error_file_too_big); | 4588 | 0 | ret = false; | 4589 | 0 | } | 4590 | 54 | else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL) | 4591 | 54 | { | 4592 | 54 | alent *n_cache_ptr = n_lineno_cache; | 4593 | | | 4594 | 37.4k | for (i = 0; i < nbr_func; i++) | 4595 | 37.3k | { | 4596 | 37.3k | coff_symbol_type *sym; | 4597 | 37.3k | alent *old_ptr = func_table[i]; | 4598 | | | 4599 | | /* Update the function entry. */ | 4600 | 37.3k | sym = (coff_symbol_type *) old_ptr->u.sym; | 4601 | | /* PR binutils/17512: Point the lineno to where | 4602 | | this entry will be after the memcpy below. */ | 4603 | 37.3k | sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); | 4604 | | /* Copy the function and line number entries. */ | 4605 | 37.3k | do | 4606 | 84.4k | *n_cache_ptr++ = *old_ptr++; | 4607 | 84.4k | while (old_ptr->line_number != 0); | 4608 | 37.3k | } | 4609 | | | 4610 | 54 | memcpy (lineno_cache, n_lineno_cache, | 4611 | 54 | asect->lineno_count * sizeof (alent)); | 4612 | 54 | } | 4613 | 0 | else | 4614 | 0 | ret = false; | 4615 | 54 | bfd_release (abfd, func_table); | 4616 | 54 | } | 4617 | 0 | else | 4618 | 0 | ret = false; | 4619 | 54 | } | 4620 | | | 4621 | 305 | return ret; | 4622 | 305 | } |
Unexecuted instantiation: coff-tic4x.c:coff_slurp_line_table coff-tic54x.c:coff_slurp_line_table Line | Count | Source | 4425 | 3.32k | { | 4426 | 3.32k | LINENO *native_lineno; | 4427 | 3.32k | alent *lineno_cache; | 4428 | 3.32k | unsigned int counter; | 4429 | 3.32k | alent *cache_ptr; | 4430 | 3.32k | bfd_vma prev_offset = 0; | 4431 | 3.32k | bool ordered = true; | 4432 | 3.32k | unsigned int nbr_func; | 4433 | 3.32k | LINENO *src; | 4434 | 3.32k | bool have_func; | 4435 | 3.32k | bool ret = true; | 4436 | 3.32k | size_t amt; | 4437 | | | 4438 | 3.32k | if (asect->lineno_count == 0) | 4439 | 3.07k | return true; | 4440 | | | 4441 | 247 | BFD_ASSERT (asect->lineno == NULL); | 4442 | | | 4443 | 247 | native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, | 4444 | 247 | asect->lineno_count, | 4445 | 247 | bfd_coff_linesz (abfd)); | 4446 | 247 | if (native_lineno == NULL) | 4447 | 87 | { | 4448 | 87 | _bfd_error_handler | 4449 | 87 | (_("%pB: warning: line number table read failed"), abfd); | 4450 | 87 | return false; | 4451 | 87 | } | 4452 | | | 4453 | 160 | if (_bfd_mul_overflow (asect->lineno_count + 1, sizeof (alent), &amt)) | 4454 | 0 | { | 4455 | 0 | bfd_set_error (bfd_error_file_too_big); | 4456 | 0 | free (native_lineno); | 4457 | 0 | return false; | 4458 | 0 | } | 4459 | 160 | lineno_cache = (alent *) bfd_alloc (abfd, amt); | 4460 | 160 | if (lineno_cache == NULL) | 4461 | 0 | { | 4462 | 0 | free (native_lineno); | 4463 | 0 | return false; | 4464 | 0 | } | 4465 | | | 4466 | 160 | cache_ptr = lineno_cache; | 4467 | 160 | asect->lineno = lineno_cache; | 4468 | 160 | src = native_lineno; | 4469 | 160 | nbr_func = 0; | 4470 | 160 | have_func = false; | 4471 | | | 4472 | 192k | for (counter = 0; counter < asect->lineno_count; counter++, src++) | 4473 | 192k | { | 4474 | 192k | struct internal_lineno dst; | 4475 | | | 4476 | 192k | bfd_coff_swap_lineno_in (abfd, src, &dst); | 4477 | 192k | cache_ptr->line_number = dst.l_lnno; | 4478 | | /* Appease memory checkers that get all excited about | 4479 | | uninitialised memory when copying alents if u.offset is | 4480 | | larger than u.sym. (64-bit BFD on 32-bit host.) */ | 4481 | 192k | memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); | 4482 | | | 4483 | 192k | if (cache_ptr->line_number == 0) | 4484 | 101k | { | 4485 | 101k | combined_entry_type * ent; | 4486 | 101k | unsigned long symndx; | 4487 | 101k | coff_symbol_type *sym; | 4488 | | | 4489 | 101k | have_func = false; | 4490 | 101k | symndx = dst.l_addr.l_symndx; | 4491 | 101k | if (symndx >= obj_raw_syment_count (abfd)) | 4492 | 36.8k | { | 4493 | 36.8k | _bfd_error_handler | 4494 | | /* xgettext:c-format */ | 4495 | 36.8k | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4496 | 36.8k | abfd, symndx, counter); | 4497 | 36.8k | cache_ptr->line_number = -1; | 4498 | 36.8k | ret = false; | 4499 | 36.8k | continue; | 4500 | 36.8k | } | 4501 | | | 4502 | 64.8k | ent = obj_raw_syments (abfd) + symndx; | 4503 | | /* FIXME: We should not be casting between ints and | 4504 | | pointers like this. */ | 4505 | 64.8k | if (! ent->is_sym) | 4506 | 6.97k | { | 4507 | 6.97k | _bfd_error_handler | 4508 | | /* xgettext:c-format */ | 4509 | 6.97k | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4510 | 6.97k | abfd, symndx, counter); | 4511 | 6.97k | cache_ptr->line_number = -1; | 4512 | 6.97k | ret = false; | 4513 | 6.97k | continue; | 4514 | 6.97k | } | 4515 | 57.8k | sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); | 4516 | | | 4517 | | /* PR 17512 file: 078-10659-0.004 */ | 4518 | 57.8k | if (sym < obj_symbols (abfd) | 4519 | 57.8k | || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd)) | 4520 | 0 | { | 4521 | 0 | _bfd_error_handler | 4522 | | /* xgettext:c-format */ | 4523 | 0 | (_("%pB: warning: illegal symbol in line number entry %d"), | 4524 | 0 | abfd, counter); | 4525 | 0 | cache_ptr->line_number = -1; | 4526 | 0 | ret = false; | 4527 | 0 | continue; | 4528 | 0 | } | 4529 | | | 4530 | 57.8k | have_func = true; | 4531 | 57.8k | nbr_func++; | 4532 | 57.8k | cache_ptr->u.sym = (asymbol *) sym; | 4533 | 57.8k | if (sym->lineno != NULL) | 4534 | 57.2k | _bfd_error_handler | 4535 | | /* xgettext:c-format */ | 4536 | 57.2k | (_("%pB: warning: duplicate line number information for `%s'"), | 4537 | 57.2k | abfd, bfd_asymbol_name (&sym->symbol)); | 4538 | | | 4539 | 57.8k | sym->lineno = cache_ptr; | 4540 | 57.8k | if (sym->symbol.value < prev_offset) | 4541 | 748 | ordered = false; | 4542 | 57.8k | prev_offset = sym->symbol.value; | 4543 | 57.8k | } | 4544 | 91.0k | else if (!have_func) | 4545 | | /* Drop line information that has no associated function. | 4546 | | PR 17521: file: 078-10659-0.004. */ | 4547 | 61.5k | continue; | 4548 | 29.4k | else | 4549 | 29.4k | cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect); | 4550 | 87.3k | cache_ptr++; | 4551 | 87.3k | } | 4552 | | | 4553 | 160 | asect->lineno_count = cache_ptr - lineno_cache; | 4554 | 160 | memset (cache_ptr, 0, sizeof (*cache_ptr)); | 4555 | 160 | free (native_lineno); | 4556 | | | 4557 | | /* On some systems (eg AIX5.3) the lineno table may not be sorted. */ | 4558 | 160 | if (!ordered) | 4559 | 61 | { | 4560 | | /* Sort the table. */ | 4561 | 61 | alent **func_table; | 4562 | 61 | alent *n_lineno_cache; | 4563 | | | 4564 | | /* Create a table of functions. */ | 4565 | 61 | if (_bfd_mul_overflow (nbr_func, sizeof (alent *), &amt)) | 4566 | 0 | { | 4567 | 0 | bfd_set_error (bfd_error_file_too_big); | 4568 | 0 | ret = false; | 4569 | 0 | } | 4570 | 61 | else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL) | 4571 | 61 | { | 4572 | 61 | alent **p = func_table; | 4573 | 61 | unsigned int i; | 4574 | | | 4575 | 84.1k | for (i = 0; i < asect->lineno_count; i++) | 4576 | 84.0k | if (lineno_cache[i].line_number == 0) | 4577 | 54.9k | *p++ = &lineno_cache[i]; | 4578 | | | 4579 | 61 | BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func); | 4580 | | | 4581 | | /* Sort by functions. */ | 4582 | 61 | qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent); | 4583 | | | 4584 | | /* Create the new sorted table. */ | 4585 | 61 | if (_bfd_mul_overflow (asect->lineno_count, sizeof (alent), &amt)) | 4586 | 0 | { | 4587 | 0 | bfd_set_error (bfd_error_file_too_big); | 4588 | 0 | ret = false; | 4589 | 0 | } | 4590 | 61 | else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL) | 4591 | 61 | { | 4592 | 61 | alent *n_cache_ptr = n_lineno_cache; | 4593 | | | 4594 | 54.9k | for (i = 0; i < nbr_func; i++) | 4595 | 54.9k | { | 4596 | 54.9k | coff_symbol_type *sym; | 4597 | 54.9k | alent *old_ptr = func_table[i]; | 4598 | | | 4599 | | /* Update the function entry. */ | 4600 | 54.9k | sym = (coff_symbol_type *) old_ptr->u.sym; | 4601 | | /* PR binutils/17512: Point the lineno to where | 4602 | | this entry will be after the memcpy below. */ | 4603 | 54.9k | sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); | 4604 | | /* Copy the function and line number entries. */ | 4605 | 54.9k | do | 4606 | 84.0k | *n_cache_ptr++ = *old_ptr++; | 4607 | 84.0k | while (old_ptr->line_number != 0); | 4608 | 54.9k | } | 4609 | | | 4610 | 61 | memcpy (lineno_cache, n_lineno_cache, | 4611 | 61 | asect->lineno_count * sizeof (alent)); | 4612 | 61 | } | 4613 | 0 | else | 4614 | 0 | ret = false; | 4615 | 61 | bfd_release (abfd, func_table); | 4616 | 61 | } | 4617 | 0 | else | 4618 | 0 | ret = false; | 4619 | 61 | } | 4620 | | | 4621 | 160 | return ret; | 4622 | 160 | } |
coff-z80.c:coff_slurp_line_table Line | Count | Source | 4425 | 2.27k | { | 4426 | 2.27k | LINENO *native_lineno; | 4427 | 2.27k | alent *lineno_cache; | 4428 | 2.27k | unsigned int counter; | 4429 | 2.27k | alent *cache_ptr; | 4430 | 2.27k | bfd_vma prev_offset = 0; | 4431 | 2.27k | bool ordered = true; | 4432 | 2.27k | unsigned int nbr_func; | 4433 | 2.27k | LINENO *src; | 4434 | 2.27k | bool have_func; | 4435 | 2.27k | bool ret = true; | 4436 | 2.27k | size_t amt; | 4437 | | | 4438 | 2.27k | if (asect->lineno_count == 0) | 4439 | 2.03k | return true; | 4440 | | | 4441 | 238 | BFD_ASSERT (asect->lineno == NULL); | 4442 | | | 4443 | 238 | native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, | 4444 | 238 | asect->lineno_count, | 4445 | 238 | bfd_coff_linesz (abfd)); | 4446 | 238 | if (native_lineno == NULL) | 4447 | 60 | { | 4448 | 60 | _bfd_error_handler | 4449 | 60 | (_("%pB: warning: line number table read failed"), abfd); | 4450 | 60 | return false; | 4451 | 60 | } | 4452 | | | 4453 | 178 | if (_bfd_mul_overflow (asect->lineno_count + 1, sizeof (alent), &amt)) | 4454 | 0 | { | 4455 | 0 | bfd_set_error (bfd_error_file_too_big); | 4456 | 0 | free (native_lineno); | 4457 | 0 | return false; | 4458 | 0 | } | 4459 | 178 | lineno_cache = (alent *) bfd_alloc (abfd, amt); | 4460 | 178 | if (lineno_cache == NULL) | 4461 | 0 | { | 4462 | 0 | free (native_lineno); | 4463 | 0 | return false; | 4464 | 0 | } | 4465 | | | 4466 | 178 | cache_ptr = lineno_cache; | 4467 | 178 | asect->lineno = lineno_cache; | 4468 | 178 | src = native_lineno; | 4469 | 178 | nbr_func = 0; | 4470 | 178 | have_func = false; | 4471 | | | 4472 | 192k | for (counter = 0; counter < asect->lineno_count; counter++, src++) | 4473 | 192k | { | 4474 | 192k | struct internal_lineno dst; | 4475 | | | 4476 | 192k | bfd_coff_swap_lineno_in (abfd, src, &dst); | 4477 | 192k | cache_ptr->line_number = dst.l_lnno; | 4478 | | /* Appease memory checkers that get all excited about | 4479 | | uninitialised memory when copying alents if u.offset is | 4480 | | larger than u.sym. (64-bit BFD on 32-bit host.) */ | 4481 | 192k | memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); | 4482 | | | 4483 | 192k | if (cache_ptr->line_number == 0) | 4484 | 49.5k | { | 4485 | 49.5k | combined_entry_type * ent; | 4486 | 49.5k | unsigned long symndx; | 4487 | 49.5k | coff_symbol_type *sym; | 4488 | | | 4489 | 49.5k | have_func = false; | 4490 | 49.5k | symndx = dst.l_addr.l_symndx; | 4491 | 49.5k | if (symndx >= obj_raw_syment_count (abfd)) | 4492 | 19.5k | { | 4493 | 19.5k | _bfd_error_handler | 4494 | | /* xgettext:c-format */ | 4495 | 19.5k | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4496 | 19.5k | abfd, symndx, counter); | 4497 | 19.5k | cache_ptr->line_number = -1; | 4498 | 19.5k | ret = false; | 4499 | 19.5k | continue; | 4500 | 19.5k | } | 4501 | | | 4502 | 30.0k | ent = obj_raw_syments (abfd) + symndx; | 4503 | | /* FIXME: We should not be casting between ints and | 4504 | | pointers like this. */ | 4505 | 30.0k | if (! ent->is_sym) | 4506 | 5.66k | { | 4507 | 5.66k | _bfd_error_handler | 4508 | | /* xgettext:c-format */ | 4509 | 5.66k | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4510 | 5.66k | abfd, symndx, counter); | 4511 | 5.66k | cache_ptr->line_number = -1; | 4512 | 5.66k | ret = false; | 4513 | 5.66k | continue; | 4514 | 5.66k | } | 4515 | 24.3k | sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); | 4516 | | | 4517 | | /* PR 17512 file: 078-10659-0.004 */ | 4518 | 24.3k | if (sym < obj_symbols (abfd) | 4519 | 24.3k | || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd)) | 4520 | 0 | { | 4521 | 0 | _bfd_error_handler | 4522 | | /* xgettext:c-format */ | 4523 | 0 | (_("%pB: warning: illegal symbol in line number entry %d"), | 4524 | 0 | abfd, counter); | 4525 | 0 | cache_ptr->line_number = -1; | 4526 | 0 | ret = false; | 4527 | 0 | continue; | 4528 | 0 | } | 4529 | | | 4530 | 24.3k | have_func = true; | 4531 | 24.3k | nbr_func++; | 4532 | 24.3k | cache_ptr->u.sym = (asymbol *) sym; | 4533 | 24.3k | if (sym->lineno != NULL) | 4534 | 23.9k | _bfd_error_handler | 4535 | | /* xgettext:c-format */ | 4536 | 23.9k | (_("%pB: warning: duplicate line number information for `%s'"), | 4537 | 23.9k | abfd, bfd_asymbol_name (&sym->symbol)); | 4538 | | | 4539 | 24.3k | sym->lineno = cache_ptr; | 4540 | 24.3k | if (sym->symbol.value < prev_offset) | 4541 | 730 | ordered = false; | 4542 | 24.3k | prev_offset = sym->symbol.value; | 4543 | 24.3k | } | 4544 | 142k | else if (!have_func) | 4545 | | /* Drop line information that has no associated function. | 4546 | | PR 17521: file: 078-10659-0.004. */ | 4547 | 109k | continue; | 4548 | 33.5k | else | 4549 | 33.5k | cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect); | 4550 | 57.9k | cache_ptr++; | 4551 | 57.9k | } | 4552 | | | 4553 | 178 | asect->lineno_count = cache_ptr - lineno_cache; | 4554 | 178 | memset (cache_ptr, 0, sizeof (*cache_ptr)); | 4555 | 178 | free (native_lineno); | 4556 | | | 4557 | | /* On some systems (eg AIX5.3) the lineno table may not be sorted. */ | 4558 | 178 | if (!ordered) | 4559 | 54 | { | 4560 | | /* Sort the table. */ | 4561 | 54 | alent **func_table; | 4562 | 54 | alent *n_lineno_cache; | 4563 | | | 4564 | | /* Create a table of functions. */ | 4565 | 54 | if (_bfd_mul_overflow (nbr_func, sizeof (alent *), &amt)) | 4566 | 0 | { | 4567 | 0 | bfd_set_error (bfd_error_file_too_big); | 4568 | 0 | ret = false; | 4569 | 0 | } | 4570 | 54 | else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL) | 4571 | 54 | { | 4572 | 54 | alent **p = func_table; | 4573 | 54 | unsigned int i; | 4574 | | | 4575 | 52.0k | for (i = 0; i < asect->lineno_count; i++) | 4576 | 51.9k | if (lineno_cache[i].line_number == 0) | 4577 | 20.8k | *p++ = &lineno_cache[i]; | 4578 | | | 4579 | 54 | BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func); | 4580 | | | 4581 | | /* Sort by functions. */ | 4582 | 54 | qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent); | 4583 | | | 4584 | | /* Create the new sorted table. */ | 4585 | 54 | if (_bfd_mul_overflow (asect->lineno_count, sizeof (alent), &amt)) | 4586 | 0 | { | 4587 | 0 | bfd_set_error (bfd_error_file_too_big); | 4588 | 0 | ret = false; | 4589 | 0 | } | 4590 | 54 | else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL) | 4591 | 54 | { | 4592 | 54 | alent *n_cache_ptr = n_lineno_cache; | 4593 | | | 4594 | 20.9k | for (i = 0; i < nbr_func; i++) | 4595 | 20.8k | { | 4596 | 20.8k | coff_symbol_type *sym; | 4597 | 20.8k | alent *old_ptr = func_table[i]; | 4598 | | | 4599 | | /* Update the function entry. */ | 4600 | 20.8k | sym = (coff_symbol_type *) old_ptr->u.sym; | 4601 | | /* PR binutils/17512: Point the lineno to where | 4602 | | this entry will be after the memcpy below. */ | 4603 | 20.8k | sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); | 4604 | | /* Copy the function and line number entries. */ | 4605 | 20.8k | do | 4606 | 51.9k | *n_cache_ptr++ = *old_ptr++; | 4607 | 51.9k | while (old_ptr->line_number != 0); | 4608 | 20.8k | } | 4609 | | | 4610 | 54 | memcpy (lineno_cache, n_lineno_cache, | 4611 | 54 | asect->lineno_count * sizeof (alent)); | 4612 | 54 | } | 4613 | 0 | else | 4614 | 0 | ret = false; | 4615 | 54 | bfd_release (abfd, func_table); | 4616 | 54 | } | 4617 | 0 | else | 4618 | 0 | ret = false; | 4619 | 54 | } | 4620 | | | 4621 | 178 | return ret; | 4622 | 178 | } |
coff-z8k.c:coff_slurp_line_table Line | Count | Source | 4425 | 1.54k | { | 4426 | 1.54k | LINENO *native_lineno; | 4427 | 1.54k | alent *lineno_cache; | 4428 | 1.54k | unsigned int counter; | 4429 | 1.54k | alent *cache_ptr; | 4430 | 1.54k | bfd_vma prev_offset = 0; | 4431 | 1.54k | bool ordered = true; | 4432 | 1.54k | unsigned int nbr_func; | 4433 | 1.54k | LINENO *src; | 4434 | 1.54k | bool have_func; | 4435 | 1.54k | bool ret = true; | 4436 | 1.54k | size_t amt; | 4437 | | | 4438 | 1.54k | if (asect->lineno_count == 0) | 4439 | 1.32k | return true; | 4440 | | | 4441 | 222 | BFD_ASSERT (asect->lineno == NULL); | 4442 | | | 4443 | 222 | native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, | 4444 | 222 | asect->lineno_count, | 4445 | 222 | bfd_coff_linesz (abfd)); | 4446 | 222 | if (native_lineno == NULL) | 4447 | 70 | { | 4448 | 70 | _bfd_error_handler | 4449 | 70 | (_("%pB: warning: line number table read failed"), abfd); | 4450 | 70 | return false; | 4451 | 70 | } | 4452 | | | 4453 | 152 | if (_bfd_mul_overflow (asect->lineno_count + 1, sizeof (alent), &amt)) | 4454 | 0 | { | 4455 | 0 | bfd_set_error (bfd_error_file_too_big); | 4456 | 0 | free (native_lineno); | 4457 | 0 | return false; | 4458 | 0 | } | 4459 | 152 | lineno_cache = (alent *) bfd_alloc (abfd, amt); | 4460 | 152 | if (lineno_cache == NULL) | 4461 | 0 | { | 4462 | 0 | free (native_lineno); | 4463 | 0 | return false; | 4464 | 0 | } | 4465 | | | 4466 | 152 | cache_ptr = lineno_cache; | 4467 | 152 | asect->lineno = lineno_cache; | 4468 | 152 | src = native_lineno; | 4469 | 152 | nbr_func = 0; | 4470 | 152 | have_func = false; | 4471 | | | 4472 | 206k | for (counter = 0; counter < asect->lineno_count; counter++, src++) | 4473 | 206k | { | 4474 | 206k | struct internal_lineno dst; | 4475 | | | 4476 | 206k | bfd_coff_swap_lineno_in (abfd, src, &dst); | 4477 | 206k | cache_ptr->line_number = dst.l_lnno; | 4478 | | /* Appease memory checkers that get all excited about | 4479 | | uninitialised memory when copying alents if u.offset is | 4480 | | larger than u.sym. (64-bit BFD on 32-bit host.) */ | 4481 | 206k | memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); | 4482 | | | 4483 | 206k | if (cache_ptr->line_number == 0) | 4484 | 56.3k | { | 4485 | 56.3k | combined_entry_type * ent; | 4486 | 56.3k | unsigned long symndx; | 4487 | 56.3k | coff_symbol_type *sym; | 4488 | | | 4489 | 56.3k | have_func = false; | 4490 | 56.3k | symndx = dst.l_addr.l_symndx; | 4491 | 56.3k | if (symndx >= obj_raw_syment_count (abfd)) | 4492 | 22.6k | { | 4493 | 22.6k | _bfd_error_handler | 4494 | | /* xgettext:c-format */ | 4495 | 22.6k | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4496 | 22.6k | abfd, symndx, counter); | 4497 | 22.6k | cache_ptr->line_number = -1; | 4498 | 22.6k | ret = false; | 4499 | 22.6k | continue; | 4500 | 22.6k | } | 4501 | | | 4502 | 33.6k | ent = obj_raw_syments (abfd) + symndx; | 4503 | | /* FIXME: We should not be casting between ints and | 4504 | | pointers like this. */ | 4505 | 33.6k | if (! ent->is_sym) | 4506 | 2.28k | { | 4507 | 2.28k | _bfd_error_handler | 4508 | | /* xgettext:c-format */ | 4509 | 2.28k | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4510 | 2.28k | abfd, symndx, counter); | 4511 | 2.28k | cache_ptr->line_number = -1; | 4512 | 2.28k | ret = false; | 4513 | 2.28k | continue; | 4514 | 2.28k | } | 4515 | 31.3k | sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); | 4516 | | | 4517 | | /* PR 17512 file: 078-10659-0.004 */ | 4518 | 31.3k | if (sym < obj_symbols (abfd) | 4519 | 31.3k | || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd)) | 4520 | 0 | { | 4521 | 0 | _bfd_error_handler | 4522 | | /* xgettext:c-format */ | 4523 | 0 | (_("%pB: warning: illegal symbol in line number entry %d"), | 4524 | 0 | abfd, counter); | 4525 | 0 | cache_ptr->line_number = -1; | 4526 | 0 | ret = false; | 4527 | 0 | continue; | 4528 | 0 | } | 4529 | | | 4530 | 31.3k | have_func = true; | 4531 | 31.3k | nbr_func++; | 4532 | 31.3k | cache_ptr->u.sym = (asymbol *) sym; | 4533 | 31.3k | if (sym->lineno != NULL) | 4534 | 31.0k | _bfd_error_handler | 4535 | | /* xgettext:c-format */ | 4536 | 31.0k | (_("%pB: warning: duplicate line number information for `%s'"), | 4537 | 31.0k | abfd, bfd_asymbol_name (&sym->symbol)); | 4538 | | | 4539 | 31.3k | sym->lineno = cache_ptr; | 4540 | 31.3k | if (sym->symbol.value < prev_offset) | 4541 | 424 | ordered = false; | 4542 | 31.3k | prev_offset = sym->symbol.value; | 4543 | 31.3k | } | 4544 | 150k | else if (!have_func) | 4545 | | /* Drop line information that has no associated function. | 4546 | | PR 17521: file: 078-10659-0.004. */ | 4547 | 85.6k | continue; | 4548 | 64.7k | else | 4549 | 64.7k | cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect); | 4550 | 96.1k | cache_ptr++; | 4551 | 96.1k | } | 4552 | | | 4553 | 152 | asect->lineno_count = cache_ptr - lineno_cache; | 4554 | 152 | memset (cache_ptr, 0, sizeof (*cache_ptr)); | 4555 | 152 | free (native_lineno); | 4556 | | | 4557 | | /* On some systems (eg AIX5.3) the lineno table may not be sorted. */ | 4558 | 152 | if (!ordered) | 4559 | 61 | { | 4560 | | /* Sort the table. */ | 4561 | 61 | alent **func_table; | 4562 | 61 | alent *n_lineno_cache; | 4563 | | | 4564 | | /* Create a table of functions. */ | 4565 | 61 | if (_bfd_mul_overflow (nbr_func, sizeof (alent *), &amt)) | 4566 | 0 | { | 4567 | 0 | bfd_set_error (bfd_error_file_too_big); | 4568 | 0 | ret = false; | 4569 | 0 | } | 4570 | 61 | else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL) | 4571 | 61 | { | 4572 | 61 | alent **p = func_table; | 4573 | 61 | unsigned int i; | 4574 | | | 4575 | 86.5k | for (i = 0; i < asect->lineno_count; i++) | 4576 | 86.5k | if (lineno_cache[i].line_number == 0) | 4577 | 28.7k | *p++ = &lineno_cache[i]; | 4578 | | | 4579 | 61 | BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func); | 4580 | | | 4581 | | /* Sort by functions. */ | 4582 | 61 | qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent); | 4583 | | | 4584 | | /* Create the new sorted table. */ | 4585 | 61 | if (_bfd_mul_overflow (asect->lineno_count, sizeof (alent), &amt)) | 4586 | 0 | { | 4587 | 0 | bfd_set_error (bfd_error_file_too_big); | 4588 | 0 | ret = false; | 4589 | 0 | } | 4590 | 61 | else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL) | 4591 | 61 | { | 4592 | 61 | alent *n_cache_ptr = n_lineno_cache; | 4593 | | | 4594 | 28.8k | for (i = 0; i < nbr_func; i++) | 4595 | 28.7k | { | 4596 | 28.7k | coff_symbol_type *sym; | 4597 | 28.7k | alent *old_ptr = func_table[i]; | 4598 | | | 4599 | | /* Update the function entry. */ | 4600 | 28.7k | sym = (coff_symbol_type *) old_ptr->u.sym; | 4601 | | /* PR binutils/17512: Point the lineno to where | 4602 | | this entry will be after the memcpy below. */ | 4603 | 28.7k | sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); | 4604 | | /* Copy the function and line number entries. */ | 4605 | 28.7k | do | 4606 | 86.5k | *n_cache_ptr++ = *old_ptr++; | 4607 | 86.5k | while (old_ptr->line_number != 0); | 4608 | 28.7k | } | 4609 | | | 4610 | 61 | memcpy (lineno_cache, n_lineno_cache, | 4611 | 61 | asect->lineno_count * sizeof (alent)); | 4612 | 61 | } | 4613 | 0 | else | 4614 | 0 | ret = false; | 4615 | 61 | bfd_release (abfd, func_table); | 4616 | 61 | } | 4617 | 0 | else | 4618 | 0 | ret = false; | 4619 | 61 | } | 4620 | | | 4621 | 152 | return ret; | 4622 | 152 | } |
Unexecuted instantiation: pe-arm-wince.c:coff_slurp_line_table Unexecuted instantiation: pe-arm.c:coff_slurp_line_table pe-i386.c:coff_slurp_line_table Line | Count | Source | 4425 | 712 | { | 4426 | 712 | LINENO *native_lineno; | 4427 | 712 | alent *lineno_cache; | 4428 | 712 | unsigned int counter; | 4429 | 712 | alent *cache_ptr; | 4430 | 712 | bfd_vma prev_offset = 0; | 4431 | 712 | bool ordered = true; | 4432 | 712 | unsigned int nbr_func; | 4433 | 712 | LINENO *src; | 4434 | 712 | bool have_func; | 4435 | 712 | bool ret = true; | 4436 | 712 | size_t amt; | 4437 | | | 4438 | 712 | if (asect->lineno_count == 0) | 4439 | 554 | return true; | 4440 | | | 4441 | 158 | BFD_ASSERT (asect->lineno == NULL); | 4442 | | | 4443 | 158 | native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, | 4444 | 158 | asect->lineno_count, | 4445 | 158 | bfd_coff_linesz (abfd)); | 4446 | 158 | if (native_lineno == NULL) | 4447 | 36 | { | 4448 | 36 | _bfd_error_handler | 4449 | 36 | (_("%pB: warning: line number table read failed"), abfd); | 4450 | 36 | return false; | 4451 | 36 | } | 4452 | | | 4453 | 122 | if (_bfd_mul_overflow (asect->lineno_count + 1, sizeof (alent), &amt)) | 4454 | 0 | { | 4455 | 0 | bfd_set_error (bfd_error_file_too_big); | 4456 | 0 | free (native_lineno); | 4457 | 0 | return false; | 4458 | 0 | } | 4459 | 122 | lineno_cache = (alent *) bfd_alloc (abfd, amt); | 4460 | 122 | if (lineno_cache == NULL) | 4461 | 0 | { | 4462 | 0 | free (native_lineno); | 4463 | 0 | return false; | 4464 | 0 | } | 4465 | | | 4466 | 122 | cache_ptr = lineno_cache; | 4467 | 122 | asect->lineno = lineno_cache; | 4468 | 122 | src = native_lineno; | 4469 | 122 | nbr_func = 0; | 4470 | 122 | have_func = false; | 4471 | | | 4472 | 137k | for (counter = 0; counter < asect->lineno_count; counter++, src++) | 4473 | 137k | { | 4474 | 137k | struct internal_lineno dst; | 4475 | | | 4476 | 137k | bfd_coff_swap_lineno_in (abfd, src, &dst); | 4477 | 137k | cache_ptr->line_number = dst.l_lnno; | 4478 | | /* Appease memory checkers that get all excited about | 4479 | | uninitialised memory when copying alents if u.offset is | 4480 | | larger than u.sym. (64-bit BFD on 32-bit host.) */ | 4481 | 137k | memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); | 4482 | | | 4483 | 137k | if (cache_ptr->line_number == 0) | 4484 | 58.4k | { | 4485 | 58.4k | combined_entry_type * ent; | 4486 | 58.4k | unsigned long symndx; | 4487 | 58.4k | coff_symbol_type *sym; | 4488 | | | 4489 | 58.4k | have_func = false; | 4490 | 58.4k | symndx = dst.l_addr.l_symndx; | 4491 | 58.4k | if (symndx >= obj_raw_syment_count (abfd)) | 4492 | 26.5k | { | 4493 | 26.5k | _bfd_error_handler | 4494 | | /* xgettext:c-format */ | 4495 | 26.5k | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4496 | 26.5k | abfd, symndx, counter); | 4497 | 26.5k | cache_ptr->line_number = -1; | 4498 | 26.5k | ret = false; | 4499 | 26.5k | continue; | 4500 | 26.5k | } | 4501 | | | 4502 | 31.9k | ent = obj_raw_syments (abfd) + symndx; | 4503 | | /* FIXME: We should not be casting between ints and | 4504 | | pointers like this. */ | 4505 | 31.9k | if (! ent->is_sym) | 4506 | 3.78k | { | 4507 | 3.78k | _bfd_error_handler | 4508 | | /* xgettext:c-format */ | 4509 | 3.78k | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4510 | 3.78k | abfd, symndx, counter); | 4511 | 3.78k | cache_ptr->line_number = -1; | 4512 | 3.78k | ret = false; | 4513 | 3.78k | continue; | 4514 | 3.78k | } | 4515 | 28.1k | sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); | 4516 | | | 4517 | | /* PR 17512 file: 078-10659-0.004 */ | 4518 | 28.1k | if (sym < obj_symbols (abfd) | 4519 | 28.1k | || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd)) | 4520 | 0 | { | 4521 | 0 | _bfd_error_handler | 4522 | | /* xgettext:c-format */ | 4523 | 0 | (_("%pB: warning: illegal symbol in line number entry %d"), | 4524 | 0 | abfd, counter); | 4525 | 0 | cache_ptr->line_number = -1; | 4526 | 0 | ret = false; | 4527 | 0 | continue; | 4528 | 0 | } | 4529 | | | 4530 | 28.1k | have_func = true; | 4531 | 28.1k | nbr_func++; | 4532 | 28.1k | cache_ptr->u.sym = (asymbol *) sym; | 4533 | 28.1k | if (sym->lineno != NULL) | 4534 | 27.4k | _bfd_error_handler | 4535 | | /* xgettext:c-format */ | 4536 | 27.4k | (_("%pB: warning: duplicate line number information for `%s'"), | 4537 | 27.4k | abfd, bfd_asymbol_name (&sym->symbol)); | 4538 | | | 4539 | 28.1k | sym->lineno = cache_ptr; | 4540 | 28.1k | if (sym->symbol.value < prev_offset) | 4541 | 908 | ordered = false; | 4542 | 28.1k | prev_offset = sym->symbol.value; | 4543 | 28.1k | } | 4544 | 79.0k | else if (!have_func) | 4545 | | /* Drop line information that has no associated function. | 4546 | | PR 17521: file: 078-10659-0.004. */ | 4547 | 48.0k | continue; | 4548 | 30.9k | else | 4549 | 30.9k | cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect); | 4550 | 59.1k | cache_ptr++; | 4551 | 59.1k | } | 4552 | | | 4553 | 122 | asect->lineno_count = cache_ptr - lineno_cache; | 4554 | 122 | memset (cache_ptr, 0, sizeof (*cache_ptr)); | 4555 | 122 | free (native_lineno); | 4556 | | | 4557 | | /* On some systems (eg AIX5.3) the lineno table may not be sorted. */ | 4558 | 122 | if (!ordered) | 4559 | 68 | { | 4560 | | /* Sort the table. */ | 4561 | 68 | alent **func_table; | 4562 | 68 | alent *n_lineno_cache; | 4563 | | | 4564 | | /* Create a table of functions. */ | 4565 | 68 | if (_bfd_mul_overflow (nbr_func, sizeof (alent *), &amt)) | 4566 | 0 | { | 4567 | 0 | bfd_set_error (bfd_error_file_too_big); | 4568 | 0 | ret = false; | 4569 | 0 | } | 4570 | 68 | else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL) | 4571 | 68 | { | 4572 | 68 | alent **p = func_table; | 4573 | 68 | unsigned int i; | 4574 | | | 4575 | 53.8k | for (i = 0; i < asect->lineno_count; i++) | 4576 | 53.7k | if (lineno_cache[i].line_number == 0) | 4577 | 26.1k | *p++ = &lineno_cache[i]; | 4578 | | | 4579 | 68 | BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func); | 4580 | | | 4581 | | /* Sort by functions. */ | 4582 | 68 | qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent); | 4583 | | | 4584 | | /* Create the new sorted table. */ | 4585 | 68 | if (_bfd_mul_overflow (asect->lineno_count, sizeof (alent), &amt)) | 4586 | 0 | { | 4587 | 0 | bfd_set_error (bfd_error_file_too_big); | 4588 | 0 | ret = false; | 4589 | 0 | } | 4590 | 68 | else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL) | 4591 | 68 | { | 4592 | 68 | alent *n_cache_ptr = n_lineno_cache; | 4593 | | | 4594 | 26.2k | for (i = 0; i < nbr_func; i++) | 4595 | 26.1k | { | 4596 | 26.1k | coff_symbol_type *sym; | 4597 | 26.1k | alent *old_ptr = func_table[i]; | 4598 | | | 4599 | | /* Update the function entry. */ | 4600 | 26.1k | sym = (coff_symbol_type *) old_ptr->u.sym; | 4601 | | /* PR binutils/17512: Point the lineno to where | 4602 | | this entry will be after the memcpy below. */ | 4603 | 26.1k | sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); | 4604 | | /* Copy the function and line number entries. */ | 4605 | 26.1k | do | 4606 | 53.7k | *n_cache_ptr++ = *old_ptr++; | 4607 | 53.7k | while (old_ptr->line_number != 0); | 4608 | 26.1k | } | 4609 | | | 4610 | 68 | memcpy (lineno_cache, n_lineno_cache, | 4611 | 68 | asect->lineno_count * sizeof (alent)); | 4612 | 68 | } | 4613 | 0 | else | 4614 | 0 | ret = false; | 4615 | 68 | bfd_release (abfd, func_table); | 4616 | 68 | } | 4617 | 0 | else | 4618 | 0 | ret = false; | 4619 | 68 | } | 4620 | | | 4621 | 122 | return ret; | 4622 | 122 | } |
pe-mcore.c:coff_slurp_line_table Line | Count | Source | 4425 | 1.07k | { | 4426 | 1.07k | LINENO *native_lineno; | 4427 | 1.07k | alent *lineno_cache; | 4428 | 1.07k | unsigned int counter; | 4429 | 1.07k | alent *cache_ptr; | 4430 | 1.07k | bfd_vma prev_offset = 0; | 4431 | 1.07k | bool ordered = true; | 4432 | 1.07k | unsigned int nbr_func; | 4433 | 1.07k | LINENO *src; | 4434 | 1.07k | bool have_func; | 4435 | 1.07k | bool ret = true; | 4436 | 1.07k | size_t amt; | 4437 | | | 4438 | 1.07k | if (asect->lineno_count == 0) | 4439 | 856 | return true; | 4440 | | | 4441 | 219 | BFD_ASSERT (asect->lineno == NULL); | 4442 | | | 4443 | 219 | native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, | 4444 | 219 | asect->lineno_count, | 4445 | 219 | bfd_coff_linesz (abfd)); | 4446 | 219 | if (native_lineno == NULL) | 4447 | 53 | { | 4448 | 53 | _bfd_error_handler | 4449 | 53 | (_("%pB: warning: line number table read failed"), abfd); | 4450 | 53 | return false; | 4451 | 53 | } | 4452 | | | 4453 | 166 | if (_bfd_mul_overflow (asect->lineno_count + 1, sizeof (alent), &amt)) | 4454 | 0 | { | 4455 | 0 | bfd_set_error (bfd_error_file_too_big); | 4456 | 0 | free (native_lineno); | 4457 | 0 | return false; | 4458 | 0 | } | 4459 | 166 | lineno_cache = (alent *) bfd_alloc (abfd, amt); | 4460 | 166 | if (lineno_cache == NULL) | 4461 | 0 | { | 4462 | 0 | free (native_lineno); | 4463 | 0 | return false; | 4464 | 0 | } | 4465 | | | 4466 | 166 | cache_ptr = lineno_cache; | 4467 | 166 | asect->lineno = lineno_cache; | 4468 | 166 | src = native_lineno; | 4469 | 166 | nbr_func = 0; | 4470 | 166 | have_func = false; | 4471 | | | 4472 | 48.2k | for (counter = 0; counter < asect->lineno_count; counter++, src++) | 4473 | 48.0k | { | 4474 | 48.0k | struct internal_lineno dst; | 4475 | | | 4476 | 48.0k | bfd_coff_swap_lineno_in (abfd, src, &dst); | 4477 | 48.0k | cache_ptr->line_number = dst.l_lnno; | 4478 | | /* Appease memory checkers that get all excited about | 4479 | | uninitialised memory when copying alents if u.offset is | 4480 | | larger than u.sym. (64-bit BFD on 32-bit host.) */ | 4481 | 48.0k | memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); | 4482 | | | 4483 | 48.0k | if (cache_ptr->line_number == 0) | 4484 | 26.1k | { | 4485 | 26.1k | combined_entry_type * ent; | 4486 | 26.1k | unsigned long symndx; | 4487 | 26.1k | coff_symbol_type *sym; | 4488 | | | 4489 | 26.1k | have_func = false; | 4490 | 26.1k | symndx = dst.l_addr.l_symndx; | 4491 | 26.1k | if (symndx >= obj_raw_syment_count (abfd)) | 4492 | 5.09k | { | 4493 | 5.09k | _bfd_error_handler | 4494 | | /* xgettext:c-format */ | 4495 | 5.09k | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4496 | 5.09k | abfd, symndx, counter); | 4497 | 5.09k | cache_ptr->line_number = -1; | 4498 | 5.09k | ret = false; | 4499 | 5.09k | continue; | 4500 | 5.09k | } | 4501 | | | 4502 | 21.0k | ent = obj_raw_syments (abfd) + symndx; | 4503 | | /* FIXME: We should not be casting between ints and | 4504 | | pointers like this. */ | 4505 | 21.0k | if (! ent->is_sym) | 4506 | 1.42k | { | 4507 | 1.42k | _bfd_error_handler | 4508 | | /* xgettext:c-format */ | 4509 | 1.42k | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4510 | 1.42k | abfd, symndx, counter); | 4511 | 1.42k | cache_ptr->line_number = -1; | 4512 | 1.42k | ret = false; | 4513 | 1.42k | continue; | 4514 | 1.42k | } | 4515 | 19.5k | sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); | 4516 | | | 4517 | | /* PR 17512 file: 078-10659-0.004 */ | 4518 | 19.5k | if (sym < obj_symbols (abfd) | 4519 | 19.5k | || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd)) | 4520 | 0 | { | 4521 | 0 | _bfd_error_handler | 4522 | | /* xgettext:c-format */ | 4523 | 0 | (_("%pB: warning: illegal symbol in line number entry %d"), | 4524 | 0 | abfd, counter); | 4525 | 0 | cache_ptr->line_number = -1; | 4526 | 0 | ret = false; | 4527 | 0 | continue; | 4528 | 0 | } | 4529 | | | 4530 | 19.5k | have_func = true; | 4531 | 19.5k | nbr_func++; | 4532 | 19.5k | cache_ptr->u.sym = (asymbol *) sym; | 4533 | 19.5k | if (sym->lineno != NULL) | 4534 | 19.3k | _bfd_error_handler | 4535 | | /* xgettext:c-format */ | 4536 | 19.3k | (_("%pB: warning: duplicate line number information for `%s'"), | 4537 | 19.3k | abfd, bfd_asymbol_name (&sym->symbol)); | 4538 | | | 4539 | 19.5k | sym->lineno = cache_ptr; | 4540 | 19.5k | if (sym->symbol.value < prev_offset) | 4541 | 108 | ordered = false; | 4542 | 19.5k | prev_offset = sym->symbol.value; | 4543 | 19.5k | } | 4544 | 21.9k | else if (!have_func) | 4545 | | /* Drop line information that has no associated function. | 4546 | | PR 17521: file: 078-10659-0.004. */ | 4547 | 13.6k | continue; | 4548 | 8.31k | else | 4549 | 8.31k | cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect); | 4550 | 27.8k | cache_ptr++; | 4551 | 27.8k | } | 4552 | | | 4553 | 166 | asect->lineno_count = cache_ptr - lineno_cache; | 4554 | 166 | memset (cache_ptr, 0, sizeof (*cache_ptr)); | 4555 | 166 | free (native_lineno); | 4556 | | | 4557 | | /* On some systems (eg AIX5.3) the lineno table may not be sorted. */ | 4558 | 166 | if (!ordered) | 4559 | 35 | { | 4560 | | /* Sort the table. */ | 4561 | 35 | alent **func_table; | 4562 | 35 | alent *n_lineno_cache; | 4563 | | | 4564 | | /* Create a table of functions. */ | 4565 | 35 | if (_bfd_mul_overflow (nbr_func, sizeof (alent *), &amt)) | 4566 | 0 | { | 4567 | 0 | bfd_set_error (bfd_error_file_too_big); | 4568 | 0 | ret = false; | 4569 | 0 | } | 4570 | 35 | else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL) | 4571 | 35 | { | 4572 | 35 | alent **p = func_table; | 4573 | 35 | unsigned int i; | 4574 | | | 4575 | 23.3k | for (i = 0; i < asect->lineno_count; i++) | 4576 | 23.3k | if (lineno_cache[i].line_number == 0) | 4577 | 15.3k | *p++ = &lineno_cache[i]; | 4578 | | | 4579 | 35 | BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func); | 4580 | | | 4581 | | /* Sort by functions. */ | 4582 | 35 | qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent); | 4583 | | | 4584 | | /* Create the new sorted table. */ | 4585 | 35 | if (_bfd_mul_overflow (asect->lineno_count, sizeof (alent), &amt)) | 4586 | 0 | { | 4587 | 0 | bfd_set_error (bfd_error_file_too_big); | 4588 | 0 | ret = false; | 4589 | 0 | } | 4590 | 35 | else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL) | 4591 | 35 | { | 4592 | 35 | alent *n_cache_ptr = n_lineno_cache; | 4593 | | | 4594 | 15.3k | for (i = 0; i < nbr_func; i++) | 4595 | 15.3k | { | 4596 | 15.3k | coff_symbol_type *sym; | 4597 | 15.3k | alent *old_ptr = func_table[i]; | 4598 | | | 4599 | | /* Update the function entry. */ | 4600 | 15.3k | sym = (coff_symbol_type *) old_ptr->u.sym; | 4601 | | /* PR binutils/17512: Point the lineno to where | 4602 | | this entry will be after the memcpy below. */ | 4603 | 15.3k | sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); | 4604 | | /* Copy the function and line number entries. */ | 4605 | 15.3k | do | 4606 | 23.3k | *n_cache_ptr++ = *old_ptr++; | 4607 | 23.3k | while (old_ptr->line_number != 0); | 4608 | 15.3k | } | 4609 | | | 4610 | 35 | memcpy (lineno_cache, n_lineno_cache, | 4611 | 35 | asect->lineno_count * sizeof (alent)); | 4612 | 35 | } | 4613 | 0 | else | 4614 | 0 | ret = false; | 4615 | 35 | bfd_release (abfd, func_table); | 4616 | 35 | } | 4617 | 0 | else | 4618 | 0 | ret = false; | 4619 | 35 | } | 4620 | | | 4621 | 166 | return ret; | 4622 | 166 | } |
pe-sh.c:coff_slurp_line_table Line | Count | Source | 4425 | 642 | { | 4426 | 642 | LINENO *native_lineno; | 4427 | 642 | alent *lineno_cache; | 4428 | 642 | unsigned int counter; | 4429 | 642 | alent *cache_ptr; | 4430 | 642 | bfd_vma prev_offset = 0; | 4431 | 642 | bool ordered = true; | 4432 | 642 | unsigned int nbr_func; | 4433 | 642 | LINENO *src; | 4434 | 642 | bool have_func; | 4435 | 642 | bool ret = true; | 4436 | 642 | size_t amt; | 4437 | | | 4438 | 642 | if (asect->lineno_count == 0) | 4439 | 534 | return true; | 4440 | | | 4441 | 108 | BFD_ASSERT (asect->lineno == NULL); | 4442 | | | 4443 | 108 | native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, | 4444 | 108 | asect->lineno_count, | 4445 | 108 | bfd_coff_linesz (abfd)); | 4446 | 108 | if (native_lineno == NULL) | 4447 | 31 | { | 4448 | 31 | _bfd_error_handler | 4449 | 31 | (_("%pB: warning: line number table read failed"), abfd); | 4450 | 31 | return false; | 4451 | 31 | } | 4452 | | | 4453 | 77 | if (_bfd_mul_overflow (asect->lineno_count + 1, sizeof (alent), &amt)) | 4454 | 0 | { | 4455 | 0 | bfd_set_error (bfd_error_file_too_big); | 4456 | 0 | free (native_lineno); | 4457 | 0 | return false; | 4458 | 0 | } | 4459 | 77 | lineno_cache = (alent *) bfd_alloc (abfd, amt); | 4460 | 77 | if (lineno_cache == NULL) | 4461 | 0 | { | 4462 | 0 | free (native_lineno); | 4463 | 0 | return false; | 4464 | 0 | } | 4465 | | | 4466 | 77 | cache_ptr = lineno_cache; | 4467 | 77 | asect->lineno = lineno_cache; | 4468 | 77 | src = native_lineno; | 4469 | 77 | nbr_func = 0; | 4470 | 77 | have_func = false; | 4471 | | | 4472 | 177k | for (counter = 0; counter < asect->lineno_count; counter++, src++) | 4473 | 177k | { | 4474 | 177k | struct internal_lineno dst; | 4475 | | | 4476 | 177k | bfd_coff_swap_lineno_in (abfd, src, &dst); | 4477 | 177k | cache_ptr->line_number = dst.l_lnno; | 4478 | | /* Appease memory checkers that get all excited about | 4479 | | uninitialised memory when copying alents if u.offset is | 4480 | | larger than u.sym. (64-bit BFD on 32-bit host.) */ | 4481 | 177k | memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); | 4482 | | | 4483 | 177k | if (cache_ptr->line_number == 0) | 4484 | 102k | { | 4485 | 102k | combined_entry_type * ent; | 4486 | 102k | unsigned long symndx; | 4487 | 102k | coff_symbol_type *sym; | 4488 | | | 4489 | 102k | have_func = false; | 4490 | 102k | symndx = dst.l_addr.l_symndx; | 4491 | 102k | if (symndx >= obj_raw_syment_count (abfd)) | 4492 | 58.0k | { | 4493 | 58.0k | _bfd_error_handler | 4494 | | /* xgettext:c-format */ | 4495 | 58.0k | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4496 | 58.0k | abfd, symndx, counter); | 4497 | 58.0k | cache_ptr->line_number = -1; | 4498 | 58.0k | ret = false; | 4499 | 58.0k | continue; | 4500 | 58.0k | } | 4501 | | | 4502 | 43.9k | ent = obj_raw_syments (abfd) + symndx; | 4503 | | /* FIXME: We should not be casting between ints and | 4504 | | pointers like this. */ | 4505 | 43.9k | if (! ent->is_sym) | 4506 | 3.60k | { | 4507 | 3.60k | _bfd_error_handler | 4508 | | /* xgettext:c-format */ | 4509 | 3.60k | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4510 | 3.60k | abfd, symndx, counter); | 4511 | 3.60k | cache_ptr->line_number = -1; | 4512 | 3.60k | ret = false; | 4513 | 3.60k | continue; | 4514 | 3.60k | } | 4515 | 40.3k | sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); | 4516 | | | 4517 | | /* PR 17512 file: 078-10659-0.004 */ | 4518 | 40.3k | if (sym < obj_symbols (abfd) | 4519 | 40.3k | || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd)) | 4520 | 0 | { | 4521 | 0 | _bfd_error_handler | 4522 | | /* xgettext:c-format */ | 4523 | 0 | (_("%pB: warning: illegal symbol in line number entry %d"), | 4524 | 0 | abfd, counter); | 4525 | 0 | cache_ptr->line_number = -1; | 4526 | 0 | ret = false; | 4527 | 0 | continue; | 4528 | 0 | } | 4529 | | | 4530 | 40.3k | have_func = true; | 4531 | 40.3k | nbr_func++; | 4532 | 40.3k | cache_ptr->u.sym = (asymbol *) sym; | 4533 | 40.3k | if (sym->lineno != NULL) | 4534 | 40.1k | _bfd_error_handler | 4535 | | /* xgettext:c-format */ | 4536 | 40.1k | (_("%pB: warning: duplicate line number information for `%s'"), | 4537 | 40.1k | abfd, bfd_asymbol_name (&sym->symbol)); | 4538 | | | 4539 | 40.3k | sym->lineno = cache_ptr; | 4540 | 40.3k | if (sym->symbol.value < prev_offset) | 4541 | 3.96k | ordered = false; | 4542 | 40.3k | prev_offset = sym->symbol.value; | 4543 | 40.3k | } | 4544 | 75.2k | else if (!have_func) | 4545 | | /* Drop line information that has no associated function. | 4546 | | PR 17521: file: 078-10659-0.004. */ | 4547 | 47.1k | continue; | 4548 | 28.0k | else | 4549 | 28.0k | cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect); | 4550 | 68.4k | cache_ptr++; | 4551 | 68.4k | } | 4552 | | | 4553 | 77 | asect->lineno_count = cache_ptr - lineno_cache; | 4554 | 77 | memset (cache_ptr, 0, sizeof (*cache_ptr)); | 4555 | 77 | free (native_lineno); | 4556 | | | 4557 | | /* On some systems (eg AIX5.3) the lineno table may not be sorted. */ | 4558 | 77 | if (!ordered) | 4559 | 27 | { | 4560 | | /* Sort the table. */ | 4561 | 27 | alent **func_table; | 4562 | 27 | alent *n_lineno_cache; | 4563 | | | 4564 | | /* Create a table of functions. */ | 4565 | 27 | if (_bfd_mul_overflow (nbr_func, sizeof (alent *), &amt)) | 4566 | 0 | { | 4567 | 0 | bfd_set_error (bfd_error_file_too_big); | 4568 | 0 | ret = false; | 4569 | 0 | } | 4570 | 27 | else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL) | 4571 | 27 | { | 4572 | 27 | alent **p = func_table; | 4573 | 27 | unsigned int i; | 4574 | | | 4575 | 35.0k | for (i = 0; i < asect->lineno_count; i++) | 4576 | 35.0k | if (lineno_cache[i].line_number == 0) | 4577 | 25.3k | *p++ = &lineno_cache[i]; | 4578 | | | 4579 | 27 | BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func); | 4580 | | | 4581 | | /* Sort by functions. */ | 4582 | 27 | qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent); | 4583 | | | 4584 | | /* Create the new sorted table. */ | 4585 | 27 | if (_bfd_mul_overflow (asect->lineno_count, sizeof (alent), &amt)) | 4586 | 0 | { | 4587 | 0 | bfd_set_error (bfd_error_file_too_big); | 4588 | 0 | ret = false; | 4589 | 0 | } | 4590 | 27 | else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL) | 4591 | 27 | { | 4592 | 27 | alent *n_cache_ptr = n_lineno_cache; | 4593 | | | 4594 | 25.4k | for (i = 0; i < nbr_func; i++) | 4595 | 25.3k | { | 4596 | 25.3k | coff_symbol_type *sym; | 4597 | 25.3k | alent *old_ptr = func_table[i]; | 4598 | | | 4599 | | /* Update the function entry. */ | 4600 | 25.3k | sym = (coff_symbol_type *) old_ptr->u.sym; | 4601 | | /* PR binutils/17512: Point the lineno to where | 4602 | | this entry will be after the memcpy below. */ | 4603 | 25.3k | sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); | 4604 | | /* Copy the function and line number entries. */ | 4605 | 25.3k | do | 4606 | 35.0k | *n_cache_ptr++ = *old_ptr++; | 4607 | 35.0k | while (old_ptr->line_number != 0); | 4608 | 25.3k | } | 4609 | | | 4610 | 27 | memcpy (lineno_cache, n_lineno_cache, | 4611 | 27 | asect->lineno_count * sizeof (alent)); | 4612 | 27 | } | 4613 | 0 | else | 4614 | 0 | ret = false; | 4615 | 27 | bfd_release (abfd, func_table); | 4616 | 27 | } | 4617 | 0 | else | 4618 | 0 | ret = false; | 4619 | 27 | } | 4620 | | | 4621 | 77 | return ret; | 4622 | 77 | } |
pei-arm-wince.c:coff_slurp_line_table Line | Count | Source | 4425 | 170 | { | 4426 | 170 | LINENO *native_lineno; | 4427 | 170 | alent *lineno_cache; | 4428 | 170 | unsigned int counter; | 4429 | 170 | alent *cache_ptr; | 4430 | 170 | bfd_vma prev_offset = 0; | 4431 | 170 | bool ordered = true; | 4432 | 170 | unsigned int nbr_func; | 4433 | 170 | LINENO *src; | 4434 | 170 | bool have_func; | 4435 | 170 | bool ret = true; | 4436 | 170 | size_t amt; | 4437 | | | 4438 | 170 | if (asect->lineno_count == 0) | 4439 | 53 | return true; | 4440 | | | 4441 | 117 | BFD_ASSERT (asect->lineno == NULL); | 4442 | | | 4443 | 117 | native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, | 4444 | 117 | asect->lineno_count, | 4445 | 117 | bfd_coff_linesz (abfd)); | 4446 | 117 | if (native_lineno == NULL) | 4447 | 76 | { | 4448 | 76 | _bfd_error_handler | 4449 | 76 | (_("%pB: warning: line number table read failed"), abfd); | 4450 | 76 | return false; | 4451 | 76 | } | 4452 | | | 4453 | 41 | if (_bfd_mul_overflow (asect->lineno_count + 1, sizeof (alent), &amt)) | 4454 | 0 | { | 4455 | 0 | bfd_set_error (bfd_error_file_too_big); | 4456 | 0 | free (native_lineno); | 4457 | 0 | return false; | 4458 | 0 | } | 4459 | 41 | lineno_cache = (alent *) bfd_alloc (abfd, amt); | 4460 | 41 | if (lineno_cache == NULL) | 4461 | 0 | { | 4462 | 0 | free (native_lineno); | 4463 | 0 | return false; | 4464 | 0 | } | 4465 | | | 4466 | 41 | cache_ptr = lineno_cache; | 4467 | 41 | asect->lineno = lineno_cache; | 4468 | 41 | src = native_lineno; | 4469 | 41 | nbr_func = 0; | 4470 | 41 | have_func = false; | 4471 | | | 4472 | 9.86k | for (counter = 0; counter < asect->lineno_count; counter++, src++) | 4473 | 9.82k | { | 4474 | 9.82k | struct internal_lineno dst; | 4475 | | | 4476 | 9.82k | bfd_coff_swap_lineno_in (abfd, src, &dst); | 4477 | 9.82k | cache_ptr->line_number = dst.l_lnno; | 4478 | | /* Appease memory checkers that get all excited about | 4479 | | uninitialised memory when copying alents if u.offset is | 4480 | | larger than u.sym. (64-bit BFD on 32-bit host.) */ | 4481 | 9.82k | memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); | 4482 | | | 4483 | 9.82k | if (cache_ptr->line_number == 0) | 4484 | 5.48k | { | 4485 | 5.48k | combined_entry_type * ent; | 4486 | 5.48k | unsigned long symndx; | 4487 | 5.48k | coff_symbol_type *sym; | 4488 | | | 4489 | 5.48k | have_func = false; | 4490 | 5.48k | symndx = dst.l_addr.l_symndx; | 4491 | 5.48k | if (symndx >= obj_raw_syment_count (abfd)) | 4492 | 3.01k | { | 4493 | 3.01k | _bfd_error_handler | 4494 | | /* xgettext:c-format */ | 4495 | 3.01k | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4496 | 3.01k | abfd, symndx, counter); | 4497 | 3.01k | cache_ptr->line_number = -1; | 4498 | 3.01k | ret = false; | 4499 | 3.01k | continue; | 4500 | 3.01k | } | 4501 | | | 4502 | 2.46k | ent = obj_raw_syments (abfd) + symndx; | 4503 | | /* FIXME: We should not be casting between ints and | 4504 | | pointers like this. */ | 4505 | 2.46k | if (! ent->is_sym) | 4506 | 394 | { | 4507 | 394 | _bfd_error_handler | 4508 | | /* xgettext:c-format */ | 4509 | 394 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4510 | 394 | abfd, symndx, counter); | 4511 | 394 | cache_ptr->line_number = -1; | 4512 | 394 | ret = false; | 4513 | 394 | continue; | 4514 | 394 | } | 4515 | 2.07k | sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); | 4516 | | | 4517 | | /* PR 17512 file: 078-10659-0.004 */ | 4518 | 2.07k | if (sym < obj_symbols (abfd) | 4519 | 2.07k | || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd)) | 4520 | 0 | { | 4521 | 0 | _bfd_error_handler | 4522 | | /* xgettext:c-format */ | 4523 | 0 | (_("%pB: warning: illegal symbol in line number entry %d"), | 4524 | 0 | abfd, counter); | 4525 | 0 | cache_ptr->line_number = -1; | 4526 | 0 | ret = false; | 4527 | 0 | continue; | 4528 | 0 | } | 4529 | | | 4530 | 2.07k | have_func = true; | 4531 | 2.07k | nbr_func++; | 4532 | 2.07k | cache_ptr->u.sym = (asymbol *) sym; | 4533 | 2.07k | if (sym->lineno != NULL) | 4534 | 1.99k | _bfd_error_handler | 4535 | | /* xgettext:c-format */ | 4536 | 1.99k | (_("%pB: warning: duplicate line number information for `%s'"), | 4537 | 1.99k | abfd, bfd_asymbol_name (&sym->symbol)); | 4538 | | | 4539 | 2.07k | sym->lineno = cache_ptr; | 4540 | 2.07k | if (sym->symbol.value < prev_offset) | 4541 | 53 | ordered = false; | 4542 | 2.07k | prev_offset = sym->symbol.value; | 4543 | 2.07k | } | 4544 | 4.34k | else if (!have_func) | 4545 | | /* Drop line information that has no associated function. | 4546 | | PR 17521: file: 078-10659-0.004. */ | 4547 | 3.18k | continue; | 4548 | 1.16k | else | 4549 | 1.16k | cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect); | 4550 | 3.23k | cache_ptr++; | 4551 | 3.23k | } | 4552 | | | 4553 | 41 | asect->lineno_count = cache_ptr - lineno_cache; | 4554 | 41 | memset (cache_ptr, 0, sizeof (*cache_ptr)); | 4555 | 41 | free (native_lineno); | 4556 | | | 4557 | | /* On some systems (eg AIX5.3) the lineno table may not be sorted. */ | 4558 | 41 | if (!ordered) | 4559 | 21 | { | 4560 | | /* Sort the table. */ | 4561 | 21 | alent **func_table; | 4562 | 21 | alent *n_lineno_cache; | 4563 | | | 4564 | | /* Create a table of functions. */ | 4565 | 21 | if (_bfd_mul_overflow (nbr_func, sizeof (alent *), &amt)) | 4566 | 0 | { | 4567 | 0 | bfd_set_error (bfd_error_file_too_big); | 4568 | 0 | ret = false; | 4569 | 0 | } | 4570 | 21 | else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL) | 4571 | 21 | { | 4572 | 21 | alent **p = func_table; | 4573 | 21 | unsigned int i; | 4574 | | | 4575 | 3.12k | for (i = 0; i < asect->lineno_count; i++) | 4576 | 3.10k | if (lineno_cache[i].line_number == 0) | 4577 | 2.00k | *p++ = &lineno_cache[i]; | 4578 | | | 4579 | 21 | BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func); | 4580 | | | 4581 | | /* Sort by functions. */ | 4582 | 21 | qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent); | 4583 | | | 4584 | | /* Create the new sorted table. */ | 4585 | 21 | if (_bfd_mul_overflow (asect->lineno_count, sizeof (alent), &amt)) | 4586 | 0 | { | 4587 | 0 | bfd_set_error (bfd_error_file_too_big); | 4588 | 0 | ret = false; | 4589 | 0 | } | 4590 | 21 | else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL) | 4591 | 21 | { | 4592 | 21 | alent *n_cache_ptr = n_lineno_cache; | 4593 | | | 4594 | 2.02k | for (i = 0; i < nbr_func; i++) | 4595 | 2.00k | { | 4596 | 2.00k | coff_symbol_type *sym; | 4597 | 2.00k | alent *old_ptr = func_table[i]; | 4598 | | | 4599 | | /* Update the function entry. */ | 4600 | 2.00k | sym = (coff_symbol_type *) old_ptr->u.sym; | 4601 | | /* PR binutils/17512: Point the lineno to where | 4602 | | this entry will be after the memcpy below. */ | 4603 | 2.00k | sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); | 4604 | | /* Copy the function and line number entries. */ | 4605 | 2.00k | do | 4606 | 3.10k | *n_cache_ptr++ = *old_ptr++; | 4607 | 3.10k | while (old_ptr->line_number != 0); | 4608 | 2.00k | } | 4609 | | | 4610 | 21 | memcpy (lineno_cache, n_lineno_cache, | 4611 | 21 | asect->lineno_count * sizeof (alent)); | 4612 | 21 | } | 4613 | 0 | else | 4614 | 0 | ret = false; | 4615 | 21 | bfd_release (abfd, func_table); | 4616 | 21 | } | 4617 | 0 | else | 4618 | 0 | ret = false; | 4619 | 21 | } | 4620 | | | 4621 | 41 | return ret; | 4622 | 41 | } |
pei-arm.c:coff_slurp_line_table Line | Count | Source | 4425 | 348 | { | 4426 | 348 | LINENO *native_lineno; | 4427 | 348 | alent *lineno_cache; | 4428 | 348 | unsigned int counter; | 4429 | 348 | alent *cache_ptr; | 4430 | 348 | bfd_vma prev_offset = 0; | 4431 | 348 | bool ordered = true; | 4432 | 348 | unsigned int nbr_func; | 4433 | 348 | LINENO *src; | 4434 | 348 | bool have_func; | 4435 | 348 | bool ret = true; | 4436 | 348 | size_t amt; | 4437 | | | 4438 | 348 | if (asect->lineno_count == 0) | 4439 | 181 | return true; | 4440 | | | 4441 | 167 | BFD_ASSERT (asect->lineno == NULL); | 4442 | | | 4443 | 167 | native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, | 4444 | 167 | asect->lineno_count, | 4445 | 167 | bfd_coff_linesz (abfd)); | 4446 | 167 | if (native_lineno == NULL) | 4447 | 85 | { | 4448 | 85 | _bfd_error_handler | 4449 | 85 | (_("%pB: warning: line number table read failed"), abfd); | 4450 | 85 | return false; | 4451 | 85 | } | 4452 | | | 4453 | 82 | if (_bfd_mul_overflow (asect->lineno_count + 1, sizeof (alent), &amt)) | 4454 | 0 | { | 4455 | 0 | bfd_set_error (bfd_error_file_too_big); | 4456 | 0 | free (native_lineno); | 4457 | 0 | return false; | 4458 | 0 | } | 4459 | 82 | lineno_cache = (alent *) bfd_alloc (abfd, amt); | 4460 | 82 | if (lineno_cache == NULL) | 4461 | 0 | { | 4462 | 0 | free (native_lineno); | 4463 | 0 | return false; | 4464 | 0 | } | 4465 | | | 4466 | 82 | cache_ptr = lineno_cache; | 4467 | 82 | asect->lineno = lineno_cache; | 4468 | 82 | src = native_lineno; | 4469 | 82 | nbr_func = 0; | 4470 | 82 | have_func = false; | 4471 | | | 4472 | 43.0k | for (counter = 0; counter < asect->lineno_count; counter++, src++) | 4473 | 42.9k | { | 4474 | 42.9k | struct internal_lineno dst; | 4475 | | | 4476 | 42.9k | bfd_coff_swap_lineno_in (abfd, src, &dst); | 4477 | 42.9k | cache_ptr->line_number = dst.l_lnno; | 4478 | | /* Appease memory checkers that get all excited about | 4479 | | uninitialised memory when copying alents if u.offset is | 4480 | | larger than u.sym. (64-bit BFD on 32-bit host.) */ | 4481 | 42.9k | memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); | 4482 | | | 4483 | 42.9k | if (cache_ptr->line_number == 0) | 4484 | 25.1k | { | 4485 | 25.1k | combined_entry_type * ent; | 4486 | 25.1k | unsigned long symndx; | 4487 | 25.1k | coff_symbol_type *sym; | 4488 | | | 4489 | 25.1k | have_func = false; | 4490 | 25.1k | symndx = dst.l_addr.l_symndx; | 4491 | 25.1k | if (symndx >= obj_raw_syment_count (abfd)) | 4492 | 6.45k | { | 4493 | 6.45k | _bfd_error_handler | 4494 | | /* xgettext:c-format */ | 4495 | 6.45k | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4496 | 6.45k | abfd, symndx, counter); | 4497 | 6.45k | cache_ptr->line_number = -1; | 4498 | 6.45k | ret = false; | 4499 | 6.45k | continue; | 4500 | 6.45k | } | 4501 | | | 4502 | 18.7k | ent = obj_raw_syments (abfd) + symndx; | 4503 | | /* FIXME: We should not be casting between ints and | 4504 | | pointers like this. */ | 4505 | 18.7k | if (! ent->is_sym) | 4506 | 280 | { | 4507 | 280 | _bfd_error_handler | 4508 | | /* xgettext:c-format */ | 4509 | 280 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4510 | 280 | abfd, symndx, counter); | 4511 | 280 | cache_ptr->line_number = -1; | 4512 | 280 | ret = false; | 4513 | 280 | continue; | 4514 | 280 | } | 4515 | 18.4k | sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); | 4516 | | | 4517 | | /* PR 17512 file: 078-10659-0.004 */ | 4518 | 18.4k | if (sym < obj_symbols (abfd) | 4519 | 18.4k | || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd)) | 4520 | 0 | { | 4521 | 0 | _bfd_error_handler | 4522 | | /* xgettext:c-format */ | 4523 | 0 | (_("%pB: warning: illegal symbol in line number entry %d"), | 4524 | 0 | abfd, counter); | 4525 | 0 | cache_ptr->line_number = -1; | 4526 | 0 | ret = false; | 4527 | 0 | continue; | 4528 | 0 | } | 4529 | | | 4530 | 18.4k | have_func = true; | 4531 | 18.4k | nbr_func++; | 4532 | 18.4k | cache_ptr->u.sym = (asymbol *) sym; | 4533 | 18.4k | if (sym->lineno != NULL) | 4534 | 18.1k | _bfd_error_handler | 4535 | | /* xgettext:c-format */ | 4536 | 18.1k | (_("%pB: warning: duplicate line number information for `%s'"), | 4537 | 18.1k | abfd, bfd_asymbol_name (&sym->symbol)); | 4538 | | | 4539 | 18.4k | sym->lineno = cache_ptr; | 4540 | 18.4k | if (sym->symbol.value < prev_offset) | 4541 | 173 | ordered = false; | 4542 | 18.4k | prev_offset = sym->symbol.value; | 4543 | 18.4k | } | 4544 | 17.7k | else if (!have_func) | 4545 | | /* Drop line information that has no associated function. | 4546 | | PR 17521: file: 078-10659-0.004. */ | 4547 | 9.44k | continue; | 4548 | 8.31k | else | 4549 | 8.31k | cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect); | 4550 | 26.7k | cache_ptr++; | 4551 | 26.7k | } | 4552 | | | 4553 | 82 | asect->lineno_count = cache_ptr - lineno_cache; | 4554 | 82 | memset (cache_ptr, 0, sizeof (*cache_ptr)); | 4555 | 82 | free (native_lineno); | 4556 | | | 4557 | | /* On some systems (eg AIX5.3) the lineno table may not be sorted. */ | 4558 | 82 | if (!ordered) | 4559 | 40 | { | 4560 | | /* Sort the table. */ | 4561 | 40 | alent **func_table; | 4562 | 40 | alent *n_lineno_cache; | 4563 | | | 4564 | | /* Create a table of functions. */ | 4565 | 40 | if (_bfd_mul_overflow (nbr_func, sizeof (alent *), &amt)) | 4566 | 0 | { | 4567 | 0 | bfd_set_error (bfd_error_file_too_big); | 4568 | 0 | ret = false; | 4569 | 0 | } | 4570 | 40 | else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL) | 4571 | 40 | { | 4572 | 40 | alent **p = func_table; | 4573 | 40 | unsigned int i; | 4574 | | | 4575 | 19.9k | for (i = 0; i < asect->lineno_count; i++) | 4576 | 19.9k | if (lineno_cache[i].line_number == 0) | 4577 | 13.0k | *p++ = &lineno_cache[i]; | 4578 | | | 4579 | 40 | BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func); | 4580 | | | 4581 | | /* Sort by functions. */ | 4582 | 40 | qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent); | 4583 | | | 4584 | | /* Create the new sorted table. */ | 4585 | 40 | if (_bfd_mul_overflow (asect->lineno_count, sizeof (alent), &amt)) | 4586 | 0 | { | 4587 | 0 | bfd_set_error (bfd_error_file_too_big); | 4588 | 0 | ret = false; | 4589 | 0 | } | 4590 | 40 | else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL) | 4591 | 40 | { | 4592 | 40 | alent *n_cache_ptr = n_lineno_cache; | 4593 | | | 4594 | 13.1k | for (i = 0; i < nbr_func; i++) | 4595 | 13.0k | { | 4596 | 13.0k | coff_symbol_type *sym; | 4597 | 13.0k | alent *old_ptr = func_table[i]; | 4598 | | | 4599 | | /* Update the function entry. */ | 4600 | 13.0k | sym = (coff_symbol_type *) old_ptr->u.sym; | 4601 | | /* PR binutils/17512: Point the lineno to where | 4602 | | this entry will be after the memcpy below. */ | 4603 | 13.0k | sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); | 4604 | | /* Copy the function and line number entries. */ | 4605 | 13.0k | do | 4606 | 19.9k | *n_cache_ptr++ = *old_ptr++; | 4607 | 19.9k | while (old_ptr->line_number != 0); | 4608 | 13.0k | } | 4609 | | | 4610 | 40 | memcpy (lineno_cache, n_lineno_cache, | 4611 | 40 | asect->lineno_count * sizeof (alent)); | 4612 | 40 | } | 4613 | 0 | else | 4614 | 0 | ret = false; | 4615 | 40 | bfd_release (abfd, func_table); | 4616 | 40 | } | 4617 | 0 | else | 4618 | 0 | ret = false; | 4619 | 40 | } | 4620 | | | 4621 | 82 | return ret; | 4622 | 82 | } |
pei-mcore.c:coff_slurp_line_table Line | Count | Source | 4425 | 331 | { | 4426 | 331 | LINENO *native_lineno; | 4427 | 331 | alent *lineno_cache; | 4428 | 331 | unsigned int counter; | 4429 | 331 | alent *cache_ptr; | 4430 | 331 | bfd_vma prev_offset = 0; | 4431 | 331 | bool ordered = true; | 4432 | 331 | unsigned int nbr_func; | 4433 | 331 | LINENO *src; | 4434 | 331 | bool have_func; | 4435 | 331 | bool ret = true; | 4436 | 331 | size_t amt; | 4437 | | | 4438 | 331 | if (asect->lineno_count == 0) | 4439 | 217 | return true; | 4440 | | | 4441 | 114 | BFD_ASSERT (asect->lineno == NULL); | 4442 | | | 4443 | 114 | native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, | 4444 | 114 | asect->lineno_count, | 4445 | 114 | bfd_coff_linesz (abfd)); | 4446 | 114 | if (native_lineno == NULL) | 4447 | 41 | { | 4448 | 41 | _bfd_error_handler | 4449 | 41 | (_("%pB: warning: line number table read failed"), abfd); | 4450 | 41 | return false; | 4451 | 41 | } | 4452 | | | 4453 | 73 | if (_bfd_mul_overflow (asect->lineno_count + 1, sizeof (alent), &amt)) | 4454 | 0 | { | 4455 | 0 | bfd_set_error (bfd_error_file_too_big); | 4456 | 0 | free (native_lineno); | 4457 | 0 | return false; | 4458 | 0 | } | 4459 | 73 | lineno_cache = (alent *) bfd_alloc (abfd, amt); | 4460 | 73 | if (lineno_cache == NULL) | 4461 | 0 | { | 4462 | 0 | free (native_lineno); | 4463 | 0 | return false; | 4464 | 0 | } | 4465 | | | 4466 | 73 | cache_ptr = lineno_cache; | 4467 | 73 | asect->lineno = lineno_cache; | 4468 | 73 | src = native_lineno; | 4469 | 73 | nbr_func = 0; | 4470 | 73 | have_func = false; | 4471 | | | 4472 | 50.4k | for (counter = 0; counter < asect->lineno_count; counter++, src++) | 4473 | 50.3k | { | 4474 | 50.3k | struct internal_lineno dst; | 4475 | | | 4476 | 50.3k | bfd_coff_swap_lineno_in (abfd, src, &dst); | 4477 | 50.3k | cache_ptr->line_number = dst.l_lnno; | 4478 | | /* Appease memory checkers that get all excited about | 4479 | | uninitialised memory when copying alents if u.offset is | 4480 | | larger than u.sym. (64-bit BFD on 32-bit host.) */ | 4481 | 50.3k | memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); | 4482 | | | 4483 | 50.3k | if (cache_ptr->line_number == 0) | 4484 | 20.3k | { | 4485 | 20.3k | combined_entry_type * ent; | 4486 | 20.3k | unsigned long symndx; | 4487 | 20.3k | coff_symbol_type *sym; | 4488 | | | 4489 | 20.3k | have_func = false; | 4490 | 20.3k | symndx = dst.l_addr.l_symndx; | 4491 | 20.3k | if (symndx >= obj_raw_syment_count (abfd)) | 4492 | 4.96k | { | 4493 | 4.96k | _bfd_error_handler | 4494 | | /* xgettext:c-format */ | 4495 | 4.96k | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4496 | 4.96k | abfd, symndx, counter); | 4497 | 4.96k | cache_ptr->line_number = -1; | 4498 | 4.96k | ret = false; | 4499 | 4.96k | continue; | 4500 | 4.96k | } | 4501 | | | 4502 | 15.3k | ent = obj_raw_syments (abfd) + symndx; | 4503 | | /* FIXME: We should not be casting between ints and | 4504 | | pointers like this. */ | 4505 | 15.3k | if (! ent->is_sym) | 4506 | 486 | { | 4507 | 486 | _bfd_error_handler | 4508 | | /* xgettext:c-format */ | 4509 | 486 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4510 | 486 | abfd, symndx, counter); | 4511 | 486 | cache_ptr->line_number = -1; | 4512 | 486 | ret = false; | 4513 | 486 | continue; | 4514 | 486 | } | 4515 | 14.8k | sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); | 4516 | | | 4517 | | /* PR 17512 file: 078-10659-0.004 */ | 4518 | 14.8k | if (sym < obj_symbols (abfd) | 4519 | 14.8k | || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd)) | 4520 | 0 | { | 4521 | 0 | _bfd_error_handler | 4522 | | /* xgettext:c-format */ | 4523 | 0 | (_("%pB: warning: illegal symbol in line number entry %d"), | 4524 | 0 | abfd, counter); | 4525 | 0 | cache_ptr->line_number = -1; | 4526 | 0 | ret = false; | 4527 | 0 | continue; | 4528 | 0 | } | 4529 | | | 4530 | 14.8k | have_func = true; | 4531 | 14.8k | nbr_func++; | 4532 | 14.8k | cache_ptr->u.sym = (asymbol *) sym; | 4533 | 14.8k | if (sym->lineno != NULL) | 4534 | 14.7k | _bfd_error_handler | 4535 | | /* xgettext:c-format */ | 4536 | 14.7k | (_("%pB: warning: duplicate line number information for `%s'"), | 4537 | 14.7k | abfd, bfd_asymbol_name (&sym->symbol)); | 4538 | | | 4539 | 14.8k | sym->lineno = cache_ptr; | 4540 | 14.8k | if (sym->symbol.value < prev_offset) | 4541 | 174 | ordered = false; | 4542 | 14.8k | prev_offset = sym->symbol.value; | 4543 | 14.8k | } | 4544 | 30.0k | else if (!have_func) | 4545 | | /* Drop line information that has no associated function. | 4546 | | PR 17521: file: 078-10659-0.004. */ | 4547 | 14.5k | continue; | 4548 | 15.4k | else | 4549 | 15.4k | cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect); | 4550 | 30.3k | cache_ptr++; | 4551 | 30.3k | } | 4552 | | | 4553 | 73 | asect->lineno_count = cache_ptr - lineno_cache; | 4554 | 73 | memset (cache_ptr, 0, sizeof (*cache_ptr)); | 4555 | 73 | free (native_lineno); | 4556 | | | 4557 | | /* On some systems (eg AIX5.3) the lineno table may not be sorted. */ | 4558 | 73 | if (!ordered) | 4559 | 37 | { | 4560 | | /* Sort the table. */ | 4561 | 37 | alent **func_table; | 4562 | 37 | alent *n_lineno_cache; | 4563 | | | 4564 | | /* Create a table of functions. */ | 4565 | 37 | if (_bfd_mul_overflow (nbr_func, sizeof (alent *), &amt)) | 4566 | 0 | { | 4567 | 0 | bfd_set_error (bfd_error_file_too_big); | 4568 | 0 | ret = false; | 4569 | 0 | } | 4570 | 37 | else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL) | 4571 | 37 | { | 4572 | 37 | alent **p = func_table; | 4573 | 37 | unsigned int i; | 4574 | | | 4575 | 29.6k | for (i = 0; i < asect->lineno_count; i++) | 4576 | 29.5k | if (lineno_cache[i].line_number == 0) | 4577 | 14.3k | *p++ = &lineno_cache[i]; | 4578 | | | 4579 | 37 | BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func); | 4580 | | | 4581 | | /* Sort by functions. */ | 4582 | 37 | qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent); | 4583 | | | 4584 | | /* Create the new sorted table. */ | 4585 | 37 | if (_bfd_mul_overflow (asect->lineno_count, sizeof (alent), &amt)) | 4586 | 0 | { | 4587 | 0 | bfd_set_error (bfd_error_file_too_big); | 4588 | 0 | ret = false; | 4589 | 0 | } | 4590 | 37 | else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL) | 4591 | 37 | { | 4592 | 37 | alent *n_cache_ptr = n_lineno_cache; | 4593 | | | 4594 | 14.3k | for (i = 0; i < nbr_func; i++) | 4595 | 14.3k | { | 4596 | 14.3k | coff_symbol_type *sym; | 4597 | 14.3k | alent *old_ptr = func_table[i]; | 4598 | | | 4599 | | /* Update the function entry. */ | 4600 | 14.3k | sym = (coff_symbol_type *) old_ptr->u.sym; | 4601 | | /* PR binutils/17512: Point the lineno to where | 4602 | | this entry will be after the memcpy below. */ | 4603 | 14.3k | sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); | 4604 | | /* Copy the function and line number entries. */ | 4605 | 14.3k | do | 4606 | 29.5k | *n_cache_ptr++ = *old_ptr++; | 4607 | 29.5k | while (old_ptr->line_number != 0); | 4608 | 14.3k | } | 4609 | | | 4610 | 37 | memcpy (lineno_cache, n_lineno_cache, | 4611 | 37 | asect->lineno_count * sizeof (alent)); | 4612 | 37 | } | 4613 | 0 | else | 4614 | 0 | ret = false; | 4615 | 37 | bfd_release (abfd, func_table); | 4616 | 37 | } | 4617 | 0 | else | 4618 | 0 | ret = false; | 4619 | 37 | } | 4620 | | | 4621 | 73 | return ret; | 4622 | 73 | } |
pei-sh.c:coff_slurp_line_table Line | Count | Source | 4425 | 369 | { | 4426 | 369 | LINENO *native_lineno; | 4427 | 369 | alent *lineno_cache; | 4428 | 369 | unsigned int counter; | 4429 | 369 | alent *cache_ptr; | 4430 | 369 | bfd_vma prev_offset = 0; | 4431 | 369 | bool ordered = true; | 4432 | 369 | unsigned int nbr_func; | 4433 | 369 | LINENO *src; | 4434 | 369 | bool have_func; | 4435 | 369 | bool ret = true; | 4436 | 369 | size_t amt; | 4437 | | | 4438 | 369 | if (asect->lineno_count == 0) | 4439 | 268 | return true; | 4440 | | | 4441 | 101 | BFD_ASSERT (asect->lineno == NULL); | 4442 | | | 4443 | 101 | native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, | 4444 | 101 | asect->lineno_count, | 4445 | 101 | bfd_coff_linesz (abfd)); | 4446 | 101 | if (native_lineno == NULL) | 4447 | 38 | { | 4448 | 38 | _bfd_error_handler | 4449 | 38 | (_("%pB: warning: line number table read failed"), abfd); | 4450 | 38 | return false; | 4451 | 38 | } | 4452 | | | 4453 | 63 | if (_bfd_mul_overflow (asect->lineno_count + 1, sizeof (alent), &amt)) | 4454 | 0 | { | 4455 | 0 | bfd_set_error (bfd_error_file_too_big); | 4456 | 0 | free (native_lineno); | 4457 | 0 | return false; | 4458 | 0 | } | 4459 | 63 | lineno_cache = (alent *) bfd_alloc (abfd, amt); | 4460 | 63 | if (lineno_cache == NULL) | 4461 | 0 | { | 4462 | 0 | free (native_lineno); | 4463 | 0 | return false; | 4464 | 0 | } | 4465 | | | 4466 | 63 | cache_ptr = lineno_cache; | 4467 | 63 | asect->lineno = lineno_cache; | 4468 | 63 | src = native_lineno; | 4469 | 63 | nbr_func = 0; | 4470 | 63 | have_func = false; | 4471 | | | 4472 | 65.8k | for (counter = 0; counter < asect->lineno_count; counter++, src++) | 4473 | 65.7k | { | 4474 | 65.7k | struct internal_lineno dst; | 4475 | | | 4476 | 65.7k | bfd_coff_swap_lineno_in (abfd, src, &dst); | 4477 | 65.7k | cache_ptr->line_number = dst.l_lnno; | 4478 | | /* Appease memory checkers that get all excited about | 4479 | | uninitialised memory when copying alents if u.offset is | 4480 | | larger than u.sym. (64-bit BFD on 32-bit host.) */ | 4481 | 65.7k | memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); | 4482 | | | 4483 | 65.7k | if (cache_ptr->line_number == 0) | 4484 | 28.9k | { | 4485 | 28.9k | combined_entry_type * ent; | 4486 | 28.9k | unsigned long symndx; | 4487 | 28.9k | coff_symbol_type *sym; | 4488 | | | 4489 | 28.9k | have_func = false; | 4490 | 28.9k | symndx = dst.l_addr.l_symndx; | 4491 | 28.9k | if (symndx >= obj_raw_syment_count (abfd)) | 4492 | 11.0k | { | 4493 | 11.0k | _bfd_error_handler | 4494 | | /* xgettext:c-format */ | 4495 | 11.0k | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4496 | 11.0k | abfd, symndx, counter); | 4497 | 11.0k | cache_ptr->line_number = -1; | 4498 | 11.0k | ret = false; | 4499 | 11.0k | continue; | 4500 | 11.0k | } | 4501 | | | 4502 | 17.8k | ent = obj_raw_syments (abfd) + symndx; | 4503 | | /* FIXME: We should not be casting between ints and | 4504 | | pointers like this. */ | 4505 | 17.8k | if (! ent->is_sym) | 4506 | 743 | { | 4507 | 743 | _bfd_error_handler | 4508 | | /* xgettext:c-format */ | 4509 | 743 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4510 | 743 | abfd, symndx, counter); | 4511 | 743 | cache_ptr->line_number = -1; | 4512 | 743 | ret = false; | 4513 | 743 | continue; | 4514 | 743 | } | 4515 | 17.1k | sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); | 4516 | | | 4517 | | /* PR 17512 file: 078-10659-0.004 */ | 4518 | 17.1k | if (sym < obj_symbols (abfd) | 4519 | 17.1k | || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd)) | 4520 | 0 | { | 4521 | 0 | _bfd_error_handler | 4522 | | /* xgettext:c-format */ | 4523 | 0 | (_("%pB: warning: illegal symbol in line number entry %d"), | 4524 | 0 | abfd, counter); | 4525 | 0 | cache_ptr->line_number = -1; | 4526 | 0 | ret = false; | 4527 | 0 | continue; | 4528 | 0 | } | 4529 | | | 4530 | 17.1k | have_func = true; | 4531 | 17.1k | nbr_func++; | 4532 | 17.1k | cache_ptr->u.sym = (asymbol *) sym; | 4533 | 17.1k | if (sym->lineno != NULL) | 4534 | 16.9k | _bfd_error_handler | 4535 | | /* xgettext:c-format */ | 4536 | 16.9k | (_("%pB: warning: duplicate line number information for `%s'"), | 4537 | 16.9k | abfd, bfd_asymbol_name (&sym->symbol)); | 4538 | | | 4539 | 17.1k | sym->lineno = cache_ptr; | 4540 | 17.1k | if (sym->symbol.value < prev_offset) | 4541 | 207 | ordered = false; | 4542 | 17.1k | prev_offset = sym->symbol.value; | 4543 | 17.1k | } | 4544 | 36.7k | else if (!have_func) | 4545 | | /* Drop line information that has no associated function. | 4546 | | PR 17521: file: 078-10659-0.004. */ | 4547 | 18.9k | continue; | 4548 | 17.8k | else | 4549 | 17.8k | cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect); | 4550 | 34.9k | cache_ptr++; | 4551 | 34.9k | } | 4552 | | | 4553 | 63 | asect->lineno_count = cache_ptr - lineno_cache; | 4554 | 63 | memset (cache_ptr, 0, sizeof (*cache_ptr)); | 4555 | 63 | free (native_lineno); | 4556 | | | 4557 | | /* On some systems (eg AIX5.3) the lineno table may not be sorted. */ | 4558 | 63 | if (!ordered) | 4559 | 39 | { | 4560 | | /* Sort the table. */ | 4561 | 39 | alent **func_table; | 4562 | 39 | alent *n_lineno_cache; | 4563 | | | 4564 | | /* Create a table of functions. */ | 4565 | 39 | if (_bfd_mul_overflow (nbr_func, sizeof (alent *), &amt)) | 4566 | 0 | { | 4567 | 0 | bfd_set_error (bfd_error_file_too_big); | 4568 | 0 | ret = false; | 4569 | 0 | } | 4570 | 39 | else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL) | 4571 | 39 | { | 4572 | 39 | alent **p = func_table; | 4573 | 39 | unsigned int i; | 4574 | | | 4575 | 34.7k | for (i = 0; i < asect->lineno_count; i++) | 4576 | 34.6k | if (lineno_cache[i].line_number == 0) | 4577 | 16.9k | *p++ = &lineno_cache[i]; | 4578 | | | 4579 | 39 | BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func); | 4580 | | | 4581 | | /* Sort by functions. */ | 4582 | 39 | qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent); | 4583 | | | 4584 | | /* Create the new sorted table. */ | 4585 | 39 | if (_bfd_mul_overflow (asect->lineno_count, sizeof (alent), &amt)) | 4586 | 0 | { | 4587 | 0 | bfd_set_error (bfd_error_file_too_big); | 4588 | 0 | ret = false; | 4589 | 0 | } | 4590 | 39 | else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL) | 4591 | 39 | { | 4592 | 39 | alent *n_cache_ptr = n_lineno_cache; | 4593 | | | 4594 | 16.9k | for (i = 0; i < nbr_func; i++) | 4595 | 16.9k | { | 4596 | 16.9k | coff_symbol_type *sym; | 4597 | 16.9k | alent *old_ptr = func_table[i]; | 4598 | | | 4599 | | /* Update the function entry. */ | 4600 | 16.9k | sym = (coff_symbol_type *) old_ptr->u.sym; | 4601 | | /* PR binutils/17512: Point the lineno to where | 4602 | | this entry will be after the memcpy below. */ | 4603 | 16.9k | sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); | 4604 | | /* Copy the function and line number entries. */ | 4605 | 16.9k | do | 4606 | 34.6k | *n_cache_ptr++ = *old_ptr++; | 4607 | 34.6k | while (old_ptr->line_number != 0); | 4608 | 16.9k | } | 4609 | | | 4610 | 39 | memcpy (lineno_cache, n_lineno_cache, | 4611 | 39 | asect->lineno_count * sizeof (alent)); | 4612 | 39 | } | 4613 | 0 | else | 4614 | 0 | ret = false; | 4615 | 39 | bfd_release (abfd, func_table); | 4616 | 39 | } | 4617 | 0 | else | 4618 | 0 | ret = false; | 4619 | 39 | } | 4620 | | | 4621 | 63 | return ret; | 4622 | 63 | } |
|
4623 | | |
4624 | | /* Slurp in the symbol table, converting it to generic form. Note |
4625 | | that if coff_relocate_section is defined, the linker will read |
4626 | | symbols via coff_link_add_symbols, rather than via this routine. */ |
4627 | | |
4628 | | static bool |
4629 | | coff_slurp_symbol_table (bfd * abfd) |
4630 | 12.2k | { |
4631 | 12.2k | combined_entry_type *native_symbols; |
4632 | 12.2k | coff_symbol_type *cached_area; |
4633 | 12.2k | unsigned int *table_ptr; |
4634 | 12.2k | unsigned int number_of_symbols = 0; |
4635 | 12.2k | bool ret = true; |
4636 | 12.2k | size_t amt; |
4637 | | |
4638 | 12.2k | if (obj_symbols (abfd)) |
4639 | 5.51k | return true; |
4640 | | |
4641 | | /* Read in the symbol table. */ |
4642 | 6.72k | if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) |
4643 | 2.37k | return false; |
4644 | | |
4645 | | /* Allocate enough room for all the symbols in cached form. */ |
4646 | 4.35k | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), |
4647 | 4.35k | sizeof (*cached_area), &amt)) |
4648 | 0 | { |
4649 | 0 | bfd_set_error (bfd_error_file_too_big); |
4650 | 0 | return false; |
4651 | 0 | } |
4652 | 4.35k | cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt); |
4653 | 4.35k | if (cached_area == NULL) |
4654 | 0 | return false; |
4655 | | |
4656 | 4.35k | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), |
4657 | 4.35k | sizeof (*table_ptr), &amt)) |
4658 | 0 | { |
4659 | 0 | bfd_set_error (bfd_error_file_too_big); |
4660 | 0 | return false; |
4661 | 0 | } |
4662 | 4.35k | table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); |
4663 | 4.35k | if (table_ptr == NULL) |
4664 | 0 | return false; |
4665 | 4.35k | else |
4666 | 4.35k | { |
4667 | 4.35k | coff_symbol_type *dst = cached_area; |
4668 | 4.35k | unsigned int last_native_index = obj_raw_syment_count (abfd); |
4669 | 4.35k | unsigned int this_index = 0; |
4670 | | |
4671 | 963k | while (this_index < last_native_index) |
4672 | 958k | { |
4673 | 958k | combined_entry_type *src = native_symbols + this_index; |
4674 | 958k | table_ptr[this_index] = number_of_symbols; |
4675 | | |
4676 | 958k | dst->symbol.the_bfd = abfd; |
4677 | 958k | BFD_ASSERT (src->is_sym); |
4678 | 958k | dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset); |
4679 | | /* We use the native name field to point to the cached field. */ |
4680 | 958k | src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; |
4681 | 958k | dst->symbol.section = coff_section_from_bfd_index (abfd, |
4682 | 958k | src->u.syment.n_scnum); |
4683 | 958k | dst->symbol.flags = 0; |
4684 | | /* PR 17512: file: 079-7098-0.001:0.1. */ |
4685 | 958k | dst->symbol.value = 0; |
4686 | 958k | dst->done_lineno = false; |
4687 | | |
4688 | 958k | switch (src->u.syment.n_sclass) |
4689 | 958k | { |
4690 | 25.5k | case C_EXT: |
4691 | 26.5k | case C_WEAKEXT: |
4692 | | #if defined ARM |
4693 | 667 | case C_THUMBEXT: |
4694 | 754 | case C_THUMBEXTFUNC: |
4695 | | #endif |
4696 | | #ifdef RS6000COFF_C |
4697 | 8.25k | case C_HIDEXT: |
4698 | 8.25k | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT |
4699 | 8.41k | case C_AIX_WEAKEXT: |
4700 | | #endif |
4701 | | #endif |
4702 | 8.41k | #ifdef C_SYSTEM |
4703 | 28.8k | case C_SYSTEM: /* System Wide variable. */ |
4704 | 28.8k | #endif |
4705 | | #ifdef COFF_WITH_PE |
4706 | | /* In PE, 0x68 (104) denotes a section symbol. */ |
4707 | 16.0k | case C_SECTION: |
4708 | | /* In PE, 0x69 (105) denotes a weak external symbol. */ |
4709 | 16.7k | case C_NT_WEAK: |
4710 | | #endif |
4711 | 16.7k | switch (coff_classify_symbol (abfd, &src->u.syment)) |
4712 | 16.7k | { |
4713 | 26.9k | case COFF_SYMBOL_GLOBAL: |
4714 | 26.9k | dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL; |
4715 | | #if defined COFF_WITH_PE |
4716 | | /* PE sets the symbol to a value relative to the |
4717 | | start of the section. */ |
4718 | | dst->symbol.value = src->u.syment.n_value; |
4719 | | #else |
4720 | | dst->symbol.value = (src->u.syment.n_value |
4721 | | - dst->symbol.section->vma); |
4722 | | #endif |
4723 | 26.9k | if (ISFCN ((src->u.syment.n_type))) |
4724 | | /* A function ext does not go at the end of a |
4725 | | file. */ |
4726 | 629 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; |
4727 | 26.9k | break; |
4728 | | |
4729 | 1.52k | case COFF_SYMBOL_COMMON: |
4730 | 1.52k | dst->symbol.section = bfd_com_section_ptr; |
4731 | 1.52k | dst->symbol.value = src->u.syment.n_value; |
4732 | 1.52k | break; |
4733 | | |
4734 | 905 | case COFF_SYMBOL_UNDEFINED: |
4735 | 905 | dst->symbol.section = bfd_und_section_ptr; |
4736 | 905 | dst->symbol.value = 0; |
4737 | 905 | break; |
4738 | | |
4739 | 19 | case COFF_SYMBOL_PE_SECTION: |
4740 | 19 | dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM; |
4741 | 19 | dst->symbol.value = 0; |
4742 | 19 | break; |
4743 | | |
4744 | 349 | case COFF_SYMBOL_LOCAL: |
4745 | 349 | dst->symbol.flags = BSF_LOCAL; |
4746 | | #if defined COFF_WITH_PE |
4747 | | /* PE sets the symbol to a value relative to the |
4748 | | start of the section. */ |
4749 | | dst->symbol.value = src->u.syment.n_value; |
4750 | | #else |
4751 | | dst->symbol.value = (src->u.syment.n_value |
4752 | | - dst->symbol.section->vma); |
4753 | | #endif |
4754 | 349 | if (ISFCN ((src->u.syment.n_type))) |
4755 | 284 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; |
4756 | 349 | break; |
4757 | 16.7k | } |
4758 | | |
4759 | | #ifdef RS6000COFF_C |
4760 | | /* A symbol with a csect entry should not go at the end. */ |
4761 | 9.00k | if (src->u.syment.n_numaux > 0) |
4762 | 7.85k | dst->symbol.flags |= BSF_NOT_AT_END; |
4763 | | #endif |
4764 | | |
4765 | | #ifdef COFF_WITH_PE |
4766 | 16.7k | if (src->u.syment.n_sclass == C_NT_WEAK) |
4767 | 735 | dst->symbol.flags |= BSF_WEAK; |
4768 | | |
4769 | 16.7k | if (src->u.syment.n_sclass == C_SECTION |
4770 | 16.7k | && src->u.syment.n_scnum > 0) |
4771 | 18 | dst->symbol.flags = BSF_LOCAL; |
4772 | | #endif |
4773 | 29.7k | if (src->u.syment.n_sclass == C_WEAKEXT |
4774 | | #ifdef RS6000COFF_C |
4775 | 8.74k | || src->u.syment.n_sclass == C_AIX_WEAKEXT |
4776 | | #endif |
4777 | 3.98k | ) |
4778 | 1.11k | dst->symbol.flags |= BSF_WEAK; |
4779 | | |
4780 | 3.98k | break; |
4781 | | |
4782 | 8.78k | case C_STAT: /* Static. */ |
4783 | | #if defined ARM |
4784 | 677 | case C_THUMBSTAT: /* Thumb static. */ |
4785 | 690 | case C_THUMBLABEL: /* Thumb label. */ |
4786 | 798 | case C_THUMBSTATFUNC:/* Thumb static function. */ |
4787 | | #endif |
4788 | | #ifdef RS6000COFF_C |
4789 | 1.41k | case C_DWARF: /* A label in a dwarf section. */ |
4790 | 1.73k | case C_INFO: /* A label in a comment section. */ |
4791 | | #endif |
4792 | 17.5k | case C_LABEL: /* Label. */ |
4793 | 17.5k | if (src->u.syment.n_scnum == N_DEBUG) |
4794 | 26 | dst->symbol.flags = BSF_DEBUGGING; |
4795 | 17.4k | else |
4796 | 17.4k | dst->symbol.flags = BSF_LOCAL; |
4797 | | |
4798 | | /* Base the value as an index from the base of the |
4799 | | section, if there is one. */ |
4800 | 17.5k | if (dst->symbol.section) |
4801 | 17.5k | { |
4802 | | #if defined COFF_WITH_PE |
4803 | | /* PE sets the symbol to a value relative to the |
4804 | | start of the section. */ |
4805 | | dst->symbol.value = src->u.syment.n_value; |
4806 | | #else |
4807 | | dst->symbol.value = (src->u.syment.n_value |
4808 | | - dst->symbol.section->vma); |
4809 | | #endif |
4810 | 17.5k | } |
4811 | 0 | else |
4812 | 0 | dst->symbol.value = src->u.syment.n_value; |
4813 | 17.5k | break; |
4814 | | |
4815 | 2.93k | case C_FILE: /* File name. */ |
4816 | 2.93k | dst->symbol.flags = BSF_FILE; |
4817 | | /* Fall through. */ |
4818 | 11.9k | case C_MOS: /* Member of structure. */ |
4819 | 13.3k | case C_EOS: /* End of structure. */ |
4820 | 15.4k | case C_REGPARM: /* Register parameter. */ |
4821 | 20.2k | case C_REG: /* register variable. */ |
4822 | | /* C_AUTOARG conflicts with TI COFF C_UEXT. */ |
4823 | 24.4k | case C_TPDEF: /* Type definition. */ |
4824 | 30.8k | case C_ARG: |
4825 | 72.1k | case C_AUTO: /* Automatic variable. */ |
4826 | 76.0k | case C_FIELD: /* Bit field. */ |
4827 | 78.6k | case C_ENTAG: /* Enumeration tag. */ |
4828 | 85.6k | case C_MOE: /* Member of enumeration. */ |
4829 | 88.1k | case C_MOU: /* Member of union. */ |
4830 | 94.3k | case C_UNTAG: /* Union tag. */ |
4831 | 108k | case C_STRTAG: /* Structure tag. */ |
4832 | | #ifdef RS6000COFF_C |
4833 | 29.8k | case C_GSYM: |
4834 | 30.4k | case C_LSYM: |
4835 | 30.6k | case C_PSYM: |
4836 | 30.7k | case C_RSYM: |
4837 | 31.2k | case C_RPSYM: |
4838 | 31.3k | case C_STSYM: |
4839 | 31.6k | case C_TCSYM: |
4840 | 31.7k | case C_BCOMM: |
4841 | 31.9k | case C_ECOML: |
4842 | 32.2k | case C_ECOMM: |
4843 | 32.8k | case C_DECL: |
4844 | 32.9k | case C_ENTRY: |
4845 | 33.1k | case C_FUN: |
4846 | 33.9k | case C_ESTAT: |
4847 | | #endif |
4848 | 113k | dst->symbol.flags |= BSF_DEBUGGING; |
4849 | 33.9k | dst->symbol.value = (src->u.syment.n_value); |
4850 | 33.9k | break; |
4851 | | |
4852 | | #ifdef RS6000COFF_C |
4853 | 556 | case C_BINCL: /* Beginning of include file. */ |
4854 | 779 | case C_EINCL: /* Ending of include file. */ |
4855 | | /* The value is actually a pointer into the line numbers |
4856 | | of the file. We locate the line number entry, and |
4857 | | set the section to the section which contains it, and |
4858 | | the value to the index in that section. */ |
4859 | 779 | { |
4860 | 779 | asection *sec; |
4861 | | |
4862 | 779 | dst->symbol.flags = BSF_DEBUGGING; |
4863 | 75.3k | for (sec = abfd->sections; sec != NULL; sec = sec->next) |
4864 | 74.8k | if (sec->line_filepos <= (file_ptr) src->u.syment.n_value |
4865 | 74.8k | && ((file_ptr) (sec->line_filepos |
4866 | 60.6k | + sec->lineno_count * bfd_coff_linesz (abfd)) |
4867 | 60.6k | > (file_ptr) src->u.syment.n_value)) |
4868 | 289 | break; |
4869 | 779 | if (sec == NULL) |
4870 | 490 | dst->symbol.value = 0; |
4871 | 289 | else |
4872 | 289 | { |
4873 | 289 | dst->symbol.section = sec; |
4874 | 289 | dst->symbol.value = ((src->u.syment.n_value |
4875 | 289 | - sec->line_filepos) |
4876 | 289 | / bfd_coff_linesz (abfd)); |
4877 | 289 | src->fix_line = 1; |
4878 | 289 | } |
4879 | 779 | } |
4880 | 779 | break; |
4881 | | |
4882 | 167 | case C_BSTAT: |
4883 | 167 | dst->symbol.flags = BSF_DEBUGGING; |
4884 | | |
4885 | 167 | if (src->u.syment.n_value >= obj_raw_syment_count (abfd)) |
4886 | 151 | dst->symbol.value = 0; |
4887 | 16 | else |
4888 | 16 | { |
4889 | | /* The value is actually a symbol index. Save a pointer |
4890 | | to the symbol instead of the index. FIXME: This |
4891 | | should use a union. */ |
4892 | 16 | src->u.syment.n_value |
4893 | 16 | = (uintptr_t) (native_symbols + src->u.syment.n_value); |
4894 | 16 | dst->symbol.value = src->u.syment.n_value; |
4895 | 16 | src->fix_value = 1; |
4896 | 16 | } |
4897 | 167 | break; |
4898 | 0 | #endif |
4899 | | |
4900 | 881 | case C_BLOCK: /* ".bb" or ".eb". */ |
4901 | 2.74k | case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */ |
4902 | 6.17k | case C_EFCN: /* Physical end of function. */ |
4903 | | #if defined COFF_WITH_PE |
4904 | | /* PE sets the symbol to a value relative to the start |
4905 | | of the section. */ |
4906 | | dst->symbol.value = src->u.syment.n_value; |
4907 | 3.72k | if (strcmp (dst->symbol.name, ".bf") != 0) |
4908 | 3.72k | { |
4909 | | /* PE uses funny values for .ef and .lf; don't |
4910 | | relocate them. */ |
4911 | 3.72k | dst->symbol.flags = BSF_DEBUGGING; |
4912 | 3.72k | } |
4913 | 0 | else |
4914 | 0 | dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC; |
4915 | | #else |
4916 | | /* Base the value as an index from the base of the |
4917 | | section. */ |
4918 | 2.45k | dst->symbol.flags = BSF_LOCAL; |
4919 | | dst->symbol.value = (src->u.syment.n_value |
4920 | | - dst->symbol.section->vma); |
4921 | | #endif |
4922 | 6.17k | break; |
4923 | | |
4924 | 1.85k | case C_STATLAB: /* Static load time label. */ |
4925 | 1.85k | dst->symbol.value = src->u.syment.n_value; |
4926 | 1.85k | dst->symbol.flags = BSF_GLOBAL; |
4927 | 1.85k | break; |
4928 | | |
4929 | 679k | case C_NULL: |
4930 | | /* PE DLLs sometimes have zeroed out symbols for some |
4931 | | reason. Just ignore them without a warning. */ |
4932 | 679k | if (src->u.syment.n_type == 0 |
4933 | 679k | && src->u.syment.n_value == 0 |
4934 | 679k | && src->u.syment.n_scnum == 0) |
4935 | 333k | break; |
4936 | | #ifdef RS6000COFF_C |
4937 | | /* XCOFF specific: deleted entry. */ |
4938 | 104k | if (src->u.syment.n_value == C_NULL_VALUE) |
4939 | 1 | break; |
4940 | 104k | #endif |
4941 | | /* Fall through. */ |
4942 | 347k | case C_EXTDEF: /* External definition. */ |
4943 | 350k | case C_ULABEL: /* Undefined label. */ |
4944 | 351k | case C_USTATIC: /* Undefined static. */ |
4945 | | #ifndef COFF_WITH_PE |
4946 | | /* C_LINE in regular coff is 0x68. NT has taken over this storage |
4947 | | class to represent a section symbol. */ |
4948 | 165k | case C_LINE: /* line # reformatted as symbol table entry. */ |
4949 | | /* NT uses 0x67 for a weak symbol, not C_ALIAS. */ |
4950 | 165k | case C_ALIAS: /* Duplicate tag. */ |
4951 | 165k | #endif |
4952 | | /* New storage classes for TI COFF. */ |
4953 | | #ifdef TICOFF |
4954 | 11.1k | case C_UEXT: /* Tentative external definition. */ |
4955 | | #endif |
4956 | 352k | case C_EXTLAB: /* External load time label. */ |
4957 | 453k | default: |
4958 | 453k | _bfd_error_handler |
4959 | | /* xgettext:c-format */ |
4960 | 453k | (_("%pB: unrecognized storage class %d for %s symbol `%s'"), |
4961 | 453k | abfd, src->u.syment.n_sclass, |
4962 | 453k | dst->symbol.section->name, dst->symbol.name); |
4963 | 453k | ret = false; |
4964 | | /* Fall through. */ |
4965 | 455k | case C_HIDDEN: /* Ext symbol in dmert public lib. */ |
4966 | | /* PR 20722: These symbols can also be generated by |
4967 | | building DLLs with --gc-sections enabled. */ |
4968 | 455k | dst->symbol.flags = BSF_DEBUGGING; |
4969 | 455k | dst->symbol.value = (src->u.syment.n_value); |
4970 | 455k | break; |
4971 | 958k | } |
4972 | | |
4973 | 958k | dst->native = src; |
4974 | 958k | dst->symbol.udata.i = 0; |
4975 | 958k | dst->lineno = NULL; |
4976 | | |
4977 | 958k | this_index += (src->u.syment.n_numaux) + 1; |
4978 | 958k | dst++; |
4979 | 958k | number_of_symbols++; |
4980 | 958k | } |
4981 | 4.35k | } |
4982 | | |
4983 | 4.35k | obj_symbols (abfd) = cached_area; |
4984 | 4.35k | obj_raw_syments (abfd) = native_symbols; |
4985 | | |
4986 | 4.35k | abfd->symcount = number_of_symbols; |
4987 | 4.35k | obj_convert (abfd) = table_ptr; |
4988 | | /* Slurp the line tables for each section too. */ |
4989 | 4.35k | { |
4990 | 4.35k | asection *p; |
4991 | | |
4992 | 4.35k | p = abfd->sections; |
4993 | 26.3k | while (p) |
4994 | 24.9k | { |
4995 | 24.9k | if (! coff_slurp_line_table (abfd, p)) |
4996 | 2.95k | return false; |
4997 | 22.0k | p = p->next; |
4998 | 22.0k | } |
4999 | 4.35k | } |
5000 | | |
5001 | 1.39k | return ret; |
5002 | 4.35k | } pei-i386.c:coff_slurp_symbol_table Line | Count | Source | 4630 | 293 | { | 4631 | 293 | combined_entry_type *native_symbols; | 4632 | 293 | coff_symbol_type *cached_area; | 4633 | 293 | unsigned int *table_ptr; | 4634 | 293 | unsigned int number_of_symbols = 0; | 4635 | 293 | bool ret = true; | 4636 | 293 | size_t amt; | 4637 | | | 4638 | 293 | if (obj_symbols (abfd)) | 4639 | 51 | return true; | 4640 | | | 4641 | | /* Read in the symbol table. */ | 4642 | 242 | if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) | 4643 | 84 | return false; | 4644 | | | 4645 | | /* Allocate enough room for all the symbols in cached form. */ | 4646 | 158 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4647 | 158 | sizeof (*cached_area), &amt)) | 4648 | 0 | { | 4649 | 0 | bfd_set_error (bfd_error_file_too_big); | 4650 | 0 | return false; | 4651 | 0 | } | 4652 | 158 | cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt); | 4653 | 158 | if (cached_area == NULL) | 4654 | 0 | return false; | 4655 | | | 4656 | 158 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4657 | 158 | sizeof (*table_ptr), &amt)) | 4658 | 0 | { | 4659 | 0 | bfd_set_error (bfd_error_file_too_big); | 4660 | 0 | return false; | 4661 | 0 | } | 4662 | 158 | table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); | 4663 | 158 | if (table_ptr == NULL) | 4664 | 0 | return false; | 4665 | 158 | else | 4666 | 158 | { | 4667 | 158 | coff_symbol_type *dst = cached_area; | 4668 | 158 | unsigned int last_native_index = obj_raw_syment_count (abfd); | 4669 | 158 | unsigned int this_index = 0; | 4670 | | | 4671 | 18.3k | while (this_index < last_native_index) | 4672 | 18.1k | { | 4673 | 18.1k | combined_entry_type *src = native_symbols + this_index; | 4674 | 18.1k | table_ptr[this_index] = number_of_symbols; | 4675 | | | 4676 | 18.1k | dst->symbol.the_bfd = abfd; | 4677 | 18.1k | BFD_ASSERT (src->is_sym); | 4678 | 18.1k | dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset); | 4679 | | /* We use the native name field to point to the cached field. */ | 4680 | 18.1k | src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; | 4681 | 18.1k | dst->symbol.section = coff_section_from_bfd_index (abfd, | 4682 | 18.1k | src->u.syment.n_scnum); | 4683 | 18.1k | dst->symbol.flags = 0; | 4684 | | /* PR 17512: file: 079-7098-0.001:0.1. */ | 4685 | 18.1k | dst->symbol.value = 0; | 4686 | 18.1k | dst->done_lineno = false; | 4687 | | | 4688 | 18.1k | switch (src->u.syment.n_sclass) | 4689 | 18.1k | { | 4690 | 138 | case C_EXT: | 4691 | 148 | case C_WEAKEXT: | 4692 | | #if defined ARM | 4693 | | case C_THUMBEXT: | 4694 | | case C_THUMBEXTFUNC: | 4695 | | #endif | 4696 | | #ifdef RS6000COFF_C | 4697 | | case C_HIDEXT: | 4698 | | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 4699 | | case C_AIX_WEAKEXT: | 4700 | | #endif | 4701 | | #endif | 4702 | 148 | #ifdef C_SYSTEM | 4703 | 180 | case C_SYSTEM: /* System Wide variable. */ | 4704 | 180 | #endif | 4705 | 180 | #ifdef COFF_WITH_PE | 4706 | | /* In PE, 0x68 (104) denotes a section symbol. */ | 4707 | 197 | case C_SECTION: | 4708 | | /* In PE, 0x69 (105) denotes a weak external symbol. */ | 4709 | 235 | case C_NT_WEAK: | 4710 | 235 | #endif | 4711 | 235 | switch (coff_classify_symbol (abfd, &src->u.syment)) | 4712 | 235 | { | 4713 | 158 | case COFF_SYMBOL_GLOBAL: | 4714 | 158 | dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL; | 4715 | 158 | #if defined COFF_WITH_PE | 4716 | | /* PE sets the symbol to a value relative to the | 4717 | | start of the section. */ | 4718 | 158 | dst->symbol.value = src->u.syment.n_value; | 4719 | | #else | 4720 | | dst->symbol.value = (src->u.syment.n_value | 4721 | | - dst->symbol.section->vma); | 4722 | | #endif | 4723 | 158 | if (ISFCN ((src->u.syment.n_type))) | 4724 | | /* A function ext does not go at the end of a | 4725 | | file. */ | 4726 | 17 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4727 | 158 | break; | 4728 | | | 4729 | 40 | case COFF_SYMBOL_COMMON: | 4730 | 40 | dst->symbol.section = bfd_com_section_ptr; | 4731 | 40 | dst->symbol.value = src->u.syment.n_value; | 4732 | 40 | break; | 4733 | | | 4734 | 37 | case COFF_SYMBOL_UNDEFINED: | 4735 | 37 | dst->symbol.section = bfd_und_section_ptr; | 4736 | 37 | dst->symbol.value = 0; | 4737 | 37 | break; | 4738 | | | 4739 | 0 | case COFF_SYMBOL_PE_SECTION: | 4740 | 0 | dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM; | 4741 | 0 | dst->symbol.value = 0; | 4742 | 0 | break; | 4743 | | | 4744 | 0 | case COFF_SYMBOL_LOCAL: | 4745 | 0 | dst->symbol.flags = BSF_LOCAL; | 4746 | 0 | #if defined COFF_WITH_PE | 4747 | | /* PE sets the symbol to a value relative to the | 4748 | | start of the section. */ | 4749 | 0 | dst->symbol.value = src->u.syment.n_value; | 4750 | | #else | 4751 | | dst->symbol.value = (src->u.syment.n_value | 4752 | | - dst->symbol.section->vma); | 4753 | | #endif | 4754 | 0 | if (ISFCN ((src->u.syment.n_type))) | 4755 | 0 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4756 | 0 | break; | 4757 | 235 | } | 4758 | | | 4759 | | #ifdef RS6000COFF_C | 4760 | | /* A symbol with a csect entry should not go at the end. */ | 4761 | | if (src->u.syment.n_numaux > 0) | 4762 | | dst->symbol.flags |= BSF_NOT_AT_END; | 4763 | | #endif | 4764 | | | 4765 | 235 | #ifdef COFF_WITH_PE | 4766 | 235 | if (src->u.syment.n_sclass == C_NT_WEAK) | 4767 | 38 | dst->symbol.flags |= BSF_WEAK; | 4768 | | | 4769 | 235 | if (src->u.syment.n_sclass == C_SECTION | 4770 | 235 | && src->u.syment.n_scnum > 0) | 4771 | 0 | dst->symbol.flags = BSF_LOCAL; | 4772 | 235 | #endif | 4773 | 235 | if (src->u.syment.n_sclass == C_WEAKEXT | 4774 | | #ifdef RS6000COFF_C | 4775 | | || src->u.syment.n_sclass == C_AIX_WEAKEXT | 4776 | | #endif | 4777 | 235 | ) | 4778 | 10 | dst->symbol.flags |= BSF_WEAK; | 4779 | | | 4780 | 235 | break; | 4781 | | | 4782 | 102 | case C_STAT: /* Static. */ | 4783 | | #if defined ARM | 4784 | | case C_THUMBSTAT: /* Thumb static. */ | 4785 | | case C_THUMBLABEL: /* Thumb label. */ | 4786 | | case C_THUMBSTATFUNC:/* Thumb static function. */ | 4787 | | #endif | 4788 | | #ifdef RS6000COFF_C | 4789 | | case C_DWARF: /* A label in a dwarf section. */ | 4790 | | case C_INFO: /* A label in a comment section. */ | 4791 | | #endif | 4792 | 290 | case C_LABEL: /* Label. */ | 4793 | 290 | if (src->u.syment.n_scnum == N_DEBUG) | 4794 | 1 | dst->symbol.flags = BSF_DEBUGGING; | 4795 | 289 | else | 4796 | 289 | dst->symbol.flags = BSF_LOCAL; | 4797 | | | 4798 | | /* Base the value as an index from the base of the | 4799 | | section, if there is one. */ | 4800 | 290 | if (dst->symbol.section) | 4801 | 290 | { | 4802 | 290 | #if defined COFF_WITH_PE | 4803 | | /* PE sets the symbol to a value relative to the | 4804 | | start of the section. */ | 4805 | 290 | dst->symbol.value = src->u.syment.n_value; | 4806 | | #else | 4807 | | dst->symbol.value = (src->u.syment.n_value | 4808 | | - dst->symbol.section->vma); | 4809 | | #endif | 4810 | 290 | } | 4811 | 0 | else | 4812 | 0 | dst->symbol.value = src->u.syment.n_value; | 4813 | 290 | break; | 4814 | | | 4815 | 75 | case C_FILE: /* File name. */ | 4816 | 75 | dst->symbol.flags = BSF_FILE; | 4817 | | /* Fall through. */ | 4818 | 287 | case C_MOS: /* Member of structure. */ | 4819 | 308 | case C_EOS: /* End of structure. */ | 4820 | 423 | case C_REGPARM: /* Register parameter. */ | 4821 | 585 | case C_REG: /* register variable. */ | 4822 | | /* C_AUTOARG conflicts with TI COFF C_UEXT. */ | 4823 | 638 | case C_TPDEF: /* Type definition. */ | 4824 | 675 | case C_ARG: | 4825 | 1.58k | case C_AUTO: /* Automatic variable. */ | 4826 | 1.63k | case C_FIELD: /* Bit field. */ | 4827 | 1.70k | case C_ENTAG: /* Enumeration tag. */ | 4828 | 1.91k | case C_MOE: /* Member of enumeration. */ | 4829 | 1.94k | case C_MOU: /* Member of union. */ | 4830 | 2.08k | case C_UNTAG: /* Union tag. */ | 4831 | 2.19k | case C_STRTAG: /* Structure tag. */ | 4832 | | #ifdef RS6000COFF_C | 4833 | | case C_GSYM: | 4834 | | case C_LSYM: | 4835 | | case C_PSYM: | 4836 | | case C_RSYM: | 4837 | | case C_RPSYM: | 4838 | | case C_STSYM: | 4839 | | case C_TCSYM: | 4840 | | case C_BCOMM: | 4841 | | case C_ECOML: | 4842 | | case C_ECOMM: | 4843 | | case C_DECL: | 4844 | | case C_ENTRY: | 4845 | | case C_FUN: | 4846 | | case C_ESTAT: | 4847 | | #endif | 4848 | 2.19k | dst->symbol.flags |= BSF_DEBUGGING; | 4849 | 2.19k | dst->symbol.value = (src->u.syment.n_value); | 4850 | 2.19k | break; | 4851 | | | 4852 | | #ifdef RS6000COFF_C | 4853 | | case C_BINCL: /* Beginning of include file. */ | 4854 | | case C_EINCL: /* Ending of include file. */ | 4855 | | /* The value is actually a pointer into the line numbers | 4856 | | of the file. We locate the line number entry, and | 4857 | | set the section to the section which contains it, and | 4858 | | the value to the index in that section. */ | 4859 | | { | 4860 | | asection *sec; | 4861 | | | 4862 | | dst->symbol.flags = BSF_DEBUGGING; | 4863 | | for (sec = abfd->sections; sec != NULL; sec = sec->next) | 4864 | | if (sec->line_filepos <= (file_ptr) src->u.syment.n_value | 4865 | | && ((file_ptr) (sec->line_filepos | 4866 | | + sec->lineno_count * bfd_coff_linesz (abfd)) | 4867 | | > (file_ptr) src->u.syment.n_value)) | 4868 | | break; | 4869 | | if (sec == NULL) | 4870 | | dst->symbol.value = 0; | 4871 | | else | 4872 | | { | 4873 | | dst->symbol.section = sec; | 4874 | | dst->symbol.value = ((src->u.syment.n_value | 4875 | | - sec->line_filepos) | 4876 | | / bfd_coff_linesz (abfd)); | 4877 | | src->fix_line = 1; | 4878 | | } | 4879 | | } | 4880 | | break; | 4881 | | | 4882 | | case C_BSTAT: | 4883 | | dst->symbol.flags = BSF_DEBUGGING; | 4884 | | | 4885 | | if (src->u.syment.n_value >= obj_raw_syment_count (abfd)) | 4886 | | dst->symbol.value = 0; | 4887 | | else | 4888 | | { | 4889 | | /* The value is actually a symbol index. Save a pointer | 4890 | | to the symbol instead of the index. FIXME: This | 4891 | | should use a union. */ | 4892 | | src->u.syment.n_value | 4893 | | = (uintptr_t) (native_symbols + src->u.syment.n_value); | 4894 | | dst->symbol.value = src->u.syment.n_value; | 4895 | | src->fix_value = 1; | 4896 | | } | 4897 | | break; | 4898 | | #endif | 4899 | | | 4900 | 23 | case C_BLOCK: /* ".bb" or ".eb". */ | 4901 | 85 | case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */ | 4902 | 170 | case C_EFCN: /* Physical end of function. */ | 4903 | 170 | #if defined COFF_WITH_PE | 4904 | | /* PE sets the symbol to a value relative to the start | 4905 | | of the section. */ | 4906 | 170 | dst->symbol.value = src->u.syment.n_value; | 4907 | 170 | if (strcmp (dst->symbol.name, ".bf") != 0) | 4908 | 170 | { | 4909 | | /* PE uses funny values for .ef and .lf; don't | 4910 | | relocate them. */ | 4911 | 170 | dst->symbol.flags = BSF_DEBUGGING; | 4912 | 170 | } | 4913 | 0 | else | 4914 | 0 | dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC; | 4915 | | #else | 4916 | | /* Base the value as an index from the base of the | 4917 | | section. */ | 4918 | | dst->symbol.flags = BSF_LOCAL; | 4919 | | dst->symbol.value = (src->u.syment.n_value | 4920 | | - dst->symbol.section->vma); | 4921 | | #endif | 4922 | 170 | break; | 4923 | | | 4924 | 22 | case C_STATLAB: /* Static load time label. */ | 4925 | 22 | dst->symbol.value = src->u.syment.n_value; | 4926 | 22 | dst->symbol.flags = BSF_GLOBAL; | 4927 | 22 | break; | 4928 | | | 4929 | 12.7k | case C_NULL: | 4930 | | /* PE DLLs sometimes have zeroed out symbols for some | 4931 | | reason. Just ignore them without a warning. */ | 4932 | 12.7k | if (src->u.syment.n_type == 0 | 4933 | 12.7k | && src->u.syment.n_value == 0 | 4934 | 12.7k | && src->u.syment.n_scnum == 0) | 4935 | 5.49k | break; | 4936 | | #ifdef RS6000COFF_C | 4937 | | /* XCOFF specific: deleted entry. */ | 4938 | | if (src->u.syment.n_value == C_NULL_VALUE) | 4939 | | break; | 4940 | | #endif | 4941 | | /* Fall through. */ | 4942 | 7.34k | case C_EXTDEF: /* External definition. */ | 4943 | 7.43k | case C_ULABEL: /* Undefined label. */ | 4944 | 7.46k | case C_USTATIC: /* Undefined static. */ | 4945 | | #ifndef COFF_WITH_PE | 4946 | | /* C_LINE in regular coff is 0x68. NT has taken over this storage | 4947 | | class to represent a section symbol. */ | 4948 | | case C_LINE: /* line # reformatted as symbol table entry. */ | 4949 | | /* NT uses 0x67 for a weak symbol, not C_ALIAS. */ | 4950 | | case C_ALIAS: /* Duplicate tag. */ | 4951 | | #endif | 4952 | | /* New storage classes for TI COFF. */ | 4953 | | #ifdef TICOFF | 4954 | | case C_UEXT: /* Tentative external definition. */ | 4955 | | #endif | 4956 | 7.49k | case C_EXTLAB: /* External load time label. */ | 4957 | 9.77k | default: | 4958 | 9.77k | _bfd_error_handler | 4959 | | /* xgettext:c-format */ | 4960 | 9.77k | (_("%pB: unrecognized storage class %d for %s symbol `%s'"), | 4961 | 9.77k | abfd, src->u.syment.n_sclass, | 4962 | 9.77k | dst->symbol.section->name, dst->symbol.name); | 4963 | 9.77k | ret = false; | 4964 | | /* Fall through. */ | 4965 | 9.77k | case C_HIDDEN: /* Ext symbol in dmert public lib. */ | 4966 | | /* PR 20722: These symbols can also be generated by | 4967 | | building DLLs with --gc-sections enabled. */ | 4968 | 9.77k | dst->symbol.flags = BSF_DEBUGGING; | 4969 | 9.77k | dst->symbol.value = (src->u.syment.n_value); | 4970 | 9.77k | break; | 4971 | 18.1k | } | 4972 | | | 4973 | 18.1k | dst->native = src; | 4974 | 18.1k | dst->symbol.udata.i = 0; | 4975 | 18.1k | dst->lineno = NULL; | 4976 | | | 4977 | 18.1k | this_index += (src->u.syment.n_numaux) + 1; | 4978 | 18.1k | dst++; | 4979 | 18.1k | number_of_symbols++; | 4980 | 18.1k | } | 4981 | 158 | } | 4982 | | | 4983 | 158 | obj_symbols (abfd) = cached_area; | 4984 | 158 | obj_raw_syments (abfd) = native_symbols; | 4985 | | | 4986 | 158 | abfd->symcount = number_of_symbols; | 4987 | 158 | obj_convert (abfd) = table_ptr; | 4988 | | /* Slurp the line tables for each section too. */ | 4989 | 158 | { | 4990 | 158 | asection *p; | 4991 | | | 4992 | 158 | p = abfd->sections; | 4993 | 526 | while (p) | 4994 | 508 | { | 4995 | 508 | if (! coff_slurp_line_table (abfd, p)) | 4996 | 140 | return false; | 4997 | 368 | p = p->next; | 4998 | 368 | } | 4999 | 158 | } | 5000 | | | 5001 | 18 | return ret; | 5002 | 158 | } |
pe-x86_64.c:coff_slurp_symbol_table Line | Count | Source | 4630 | 688 | { | 4631 | 688 | combined_entry_type *native_symbols; | 4632 | 688 | coff_symbol_type *cached_area; | 4633 | 688 | unsigned int *table_ptr; | 4634 | 688 | unsigned int number_of_symbols = 0; | 4635 | 688 | bool ret = true; | 4636 | 688 | size_t amt; | 4637 | | | 4638 | 688 | if (obj_symbols (abfd)) | 4639 | 280 | return true; | 4640 | | | 4641 | | /* Read in the symbol table. */ | 4642 | 408 | if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) | 4643 | 159 | return false; | 4644 | | | 4645 | | /* Allocate enough room for all the symbols in cached form. */ | 4646 | 249 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4647 | 249 | sizeof (*cached_area), &amt)) | 4648 | 0 | { | 4649 | 0 | bfd_set_error (bfd_error_file_too_big); | 4650 | 0 | return false; | 4651 | 0 | } | 4652 | 249 | cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt); | 4653 | 249 | if (cached_area == NULL) | 4654 | 0 | return false; | 4655 | | | 4656 | 249 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4657 | 249 | sizeof (*table_ptr), &amt)) | 4658 | 0 | { | 4659 | 0 | bfd_set_error (bfd_error_file_too_big); | 4660 | 0 | return false; | 4661 | 0 | } | 4662 | 249 | table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); | 4663 | 249 | if (table_ptr == NULL) | 4664 | 0 | return false; | 4665 | 249 | else | 4666 | 249 | { | 4667 | 249 | coff_symbol_type *dst = cached_area; | 4668 | 249 | unsigned int last_native_index = obj_raw_syment_count (abfd); | 4669 | 249 | unsigned int this_index = 0; | 4670 | | | 4671 | 79.5k | while (this_index < last_native_index) | 4672 | 79.3k | { | 4673 | 79.3k | combined_entry_type *src = native_symbols + this_index; | 4674 | 79.3k | table_ptr[this_index] = number_of_symbols; | 4675 | | | 4676 | 79.3k | dst->symbol.the_bfd = abfd; | 4677 | 79.3k | BFD_ASSERT (src->is_sym); | 4678 | 79.3k | dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset); | 4679 | | /* We use the native name field to point to the cached field. */ | 4680 | 79.3k | src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; | 4681 | 79.3k | dst->symbol.section = coff_section_from_bfd_index (abfd, | 4682 | 79.3k | src->u.syment.n_scnum); | 4683 | 79.3k | dst->symbol.flags = 0; | 4684 | | /* PR 17512: file: 079-7098-0.001:0.1. */ | 4685 | 79.3k | dst->symbol.value = 0; | 4686 | 79.3k | dst->done_lineno = false; | 4687 | | | 4688 | 79.3k | switch (src->u.syment.n_sclass) | 4689 | 79.3k | { | 4690 | 2.53k | case C_EXT: | 4691 | 2.66k | case C_WEAKEXT: | 4692 | | #if defined ARM | 4693 | | case C_THUMBEXT: | 4694 | | case C_THUMBEXTFUNC: | 4695 | | #endif | 4696 | | #ifdef RS6000COFF_C | 4697 | | case C_HIDEXT: | 4698 | | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 4699 | | case C_AIX_WEAKEXT: | 4700 | | #endif | 4701 | | #endif | 4702 | 2.66k | #ifdef C_SYSTEM | 4703 | 2.70k | case C_SYSTEM: /* System Wide variable. */ | 4704 | 2.70k | #endif | 4705 | 2.70k | #ifdef COFF_WITH_PE | 4706 | | /* In PE, 0x68 (104) denotes a section symbol. */ | 4707 | 2.77k | case C_SECTION: | 4708 | | /* In PE, 0x69 (105) denotes a weak external symbol. */ | 4709 | 2.86k | case C_NT_WEAK: | 4710 | 2.86k | #endif | 4711 | 2.86k | switch (coff_classify_symbol (abfd, &src->u.syment)) | 4712 | 2.86k | { | 4713 | 2.54k | case COFF_SYMBOL_GLOBAL: | 4714 | 2.54k | dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL; | 4715 | 2.54k | #if defined COFF_WITH_PE | 4716 | | /* PE sets the symbol to a value relative to the | 4717 | | start of the section. */ | 4718 | 2.54k | dst->symbol.value = src->u.syment.n_value; | 4719 | | #else | 4720 | | dst->symbol.value = (src->u.syment.n_value | 4721 | | - dst->symbol.section->vma); | 4722 | | #endif | 4723 | 2.54k | if (ISFCN ((src->u.syment.n_type))) | 4724 | | /* A function ext does not go at the end of a | 4725 | | file. */ | 4726 | 41 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4727 | 2.54k | break; | 4728 | | | 4729 | 177 | case COFF_SYMBOL_COMMON: | 4730 | 177 | dst->symbol.section = bfd_com_section_ptr; | 4731 | 177 | dst->symbol.value = src->u.syment.n_value; | 4732 | 177 | break; | 4733 | | | 4734 | 118 | case COFF_SYMBOL_UNDEFINED: | 4735 | 118 | dst->symbol.section = bfd_und_section_ptr; | 4736 | 118 | dst->symbol.value = 0; | 4737 | 118 | break; | 4738 | | | 4739 | 19 | case COFF_SYMBOL_PE_SECTION: | 4740 | 19 | dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM; | 4741 | 19 | dst->symbol.value = 0; | 4742 | 19 | break; | 4743 | | | 4744 | 0 | case COFF_SYMBOL_LOCAL: | 4745 | 0 | dst->symbol.flags = BSF_LOCAL; | 4746 | 0 | #if defined COFF_WITH_PE | 4747 | | /* PE sets the symbol to a value relative to the | 4748 | | start of the section. */ | 4749 | 0 | dst->symbol.value = src->u.syment.n_value; | 4750 | | #else | 4751 | | dst->symbol.value = (src->u.syment.n_value | 4752 | | - dst->symbol.section->vma); | 4753 | | #endif | 4754 | 0 | if (ISFCN ((src->u.syment.n_type))) | 4755 | 0 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4756 | 0 | break; | 4757 | 2.86k | } | 4758 | | | 4759 | | #ifdef RS6000COFF_C | 4760 | | /* A symbol with a csect entry should not go at the end. */ | 4761 | | if (src->u.syment.n_numaux > 0) | 4762 | | dst->symbol.flags |= BSF_NOT_AT_END; | 4763 | | #endif | 4764 | | | 4765 | 2.86k | #ifdef COFF_WITH_PE | 4766 | 2.86k | if (src->u.syment.n_sclass == C_NT_WEAK) | 4767 | 90 | dst->symbol.flags |= BSF_WEAK; | 4768 | | | 4769 | 2.86k | if (src->u.syment.n_sclass == C_SECTION | 4770 | 2.86k | && src->u.syment.n_scnum > 0) | 4771 | 18 | dst->symbol.flags = BSF_LOCAL; | 4772 | 2.86k | #endif | 4773 | 2.86k | if (src->u.syment.n_sclass == C_WEAKEXT | 4774 | | #ifdef RS6000COFF_C | 4775 | | || src->u.syment.n_sclass == C_AIX_WEAKEXT | 4776 | | #endif | 4777 | 2.86k | ) | 4778 | 123 | dst->symbol.flags |= BSF_WEAK; | 4779 | | | 4780 | 2.86k | break; | 4781 | | | 4782 | 621 | case C_STAT: /* Static. */ | 4783 | | #if defined ARM | 4784 | | case C_THUMBSTAT: /* Thumb static. */ | 4785 | | case C_THUMBLABEL: /* Thumb label. */ | 4786 | | case C_THUMBSTATFUNC:/* Thumb static function. */ | 4787 | | #endif | 4788 | | #ifdef RS6000COFF_C | 4789 | | case C_DWARF: /* A label in a dwarf section. */ | 4790 | | case C_INFO: /* A label in a comment section. */ | 4791 | | #endif | 4792 | 1.06k | case C_LABEL: /* Label. */ | 4793 | 1.06k | if (src->u.syment.n_scnum == N_DEBUG) | 4794 | 3 | dst->symbol.flags = BSF_DEBUGGING; | 4795 | 1.06k | else | 4796 | 1.06k | dst->symbol.flags = BSF_LOCAL; | 4797 | | | 4798 | | /* Base the value as an index from the base of the | 4799 | | section, if there is one. */ | 4800 | 1.06k | if (dst->symbol.section) | 4801 | 1.06k | { | 4802 | 1.06k | #if defined COFF_WITH_PE | 4803 | | /* PE sets the symbol to a value relative to the | 4804 | | start of the section. */ | 4805 | 1.06k | dst->symbol.value = src->u.syment.n_value; | 4806 | | #else | 4807 | | dst->symbol.value = (src->u.syment.n_value | 4808 | | - dst->symbol.section->vma); | 4809 | | #endif | 4810 | 1.06k | } | 4811 | 0 | else | 4812 | 0 | dst->symbol.value = src->u.syment.n_value; | 4813 | 1.06k | break; | 4814 | | | 4815 | 140 | case C_FILE: /* File name. */ | 4816 | 140 | dst->symbol.flags = BSF_FILE; | 4817 | | /* Fall through. */ | 4818 | 500 | case C_MOS: /* Member of structure. */ | 4819 | 672 | case C_EOS: /* End of structure. */ | 4820 | 826 | case C_REGPARM: /* Register parameter. */ | 4821 | 1.08k | case C_REG: /* register variable. */ | 4822 | | /* C_AUTOARG conflicts with TI COFF C_UEXT. */ | 4823 | 1.32k | case C_TPDEF: /* Type definition. */ | 4824 | 1.53k | case C_ARG: | 4825 | 4.92k | case C_AUTO: /* Automatic variable. */ | 4826 | 5.21k | case C_FIELD: /* Bit field. */ | 4827 | 5.48k | case C_ENTAG: /* Enumeration tag. */ | 4828 | 5.79k | case C_MOE: /* Member of enumeration. */ | 4829 | 6.09k | case C_MOU: /* Member of union. */ | 4830 | 6.75k | case C_UNTAG: /* Union tag. */ | 4831 | 7.23k | case C_STRTAG: /* Structure tag. */ | 4832 | | #ifdef RS6000COFF_C | 4833 | | case C_GSYM: | 4834 | | case C_LSYM: | 4835 | | case C_PSYM: | 4836 | | case C_RSYM: | 4837 | | case C_RPSYM: | 4838 | | case C_STSYM: | 4839 | | case C_TCSYM: | 4840 | | case C_BCOMM: | 4841 | | case C_ECOML: | 4842 | | case C_ECOMM: | 4843 | | case C_DECL: | 4844 | | case C_ENTRY: | 4845 | | case C_FUN: | 4846 | | case C_ESTAT: | 4847 | | #endif | 4848 | 7.23k | dst->symbol.flags |= BSF_DEBUGGING; | 4849 | 7.23k | dst->symbol.value = (src->u.syment.n_value); | 4850 | 7.23k | break; | 4851 | | | 4852 | | #ifdef RS6000COFF_C | 4853 | | case C_BINCL: /* Beginning of include file. */ | 4854 | | case C_EINCL: /* Ending of include file. */ | 4855 | | /* The value is actually a pointer into the line numbers | 4856 | | of the file. We locate the line number entry, and | 4857 | | set the section to the section which contains it, and | 4858 | | the value to the index in that section. */ | 4859 | | { | 4860 | | asection *sec; | 4861 | | | 4862 | | dst->symbol.flags = BSF_DEBUGGING; | 4863 | | for (sec = abfd->sections; sec != NULL; sec = sec->next) | 4864 | | if (sec->line_filepos <= (file_ptr) src->u.syment.n_value | 4865 | | && ((file_ptr) (sec->line_filepos | 4866 | | + sec->lineno_count * bfd_coff_linesz (abfd)) | 4867 | | > (file_ptr) src->u.syment.n_value)) | 4868 | | break; | 4869 | | if (sec == NULL) | 4870 | | dst->symbol.value = 0; | 4871 | | else | 4872 | | { | 4873 | | dst->symbol.section = sec; | 4874 | | dst->symbol.value = ((src->u.syment.n_value | 4875 | | - sec->line_filepos) | 4876 | | / bfd_coff_linesz (abfd)); | 4877 | | src->fix_line = 1; | 4878 | | } | 4879 | | } | 4880 | | break; | 4881 | | | 4882 | | case C_BSTAT: | 4883 | | dst->symbol.flags = BSF_DEBUGGING; | 4884 | | | 4885 | | if (src->u.syment.n_value >= obj_raw_syment_count (abfd)) | 4886 | | dst->symbol.value = 0; | 4887 | | else | 4888 | | { | 4889 | | /* The value is actually a symbol index. Save a pointer | 4890 | | to the symbol instead of the index. FIXME: This | 4891 | | should use a union. */ | 4892 | | src->u.syment.n_value | 4893 | | = (uintptr_t) (native_symbols + src->u.syment.n_value); | 4894 | | dst->symbol.value = src->u.syment.n_value; | 4895 | | src->fix_value = 1; | 4896 | | } | 4897 | | break; | 4898 | | #endif | 4899 | | | 4900 | 71 | case C_BLOCK: /* ".bb" or ".eb". */ | 4901 | 144 | case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */ | 4902 | 395 | case C_EFCN: /* Physical end of function. */ | 4903 | 395 | #if defined COFF_WITH_PE | 4904 | | /* PE sets the symbol to a value relative to the start | 4905 | | of the section. */ | 4906 | 395 | dst->symbol.value = src->u.syment.n_value; | 4907 | 395 | if (strcmp (dst->symbol.name, ".bf") != 0) | 4908 | 395 | { | 4909 | | /* PE uses funny values for .ef and .lf; don't | 4910 | | relocate them. */ | 4911 | 395 | dst->symbol.flags = BSF_DEBUGGING; | 4912 | 395 | } | 4913 | 0 | else | 4914 | 0 | dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC; | 4915 | | #else | 4916 | | /* Base the value as an index from the base of the | 4917 | | section. */ | 4918 | | dst->symbol.flags = BSF_LOCAL; | 4919 | | dst->symbol.value = (src->u.syment.n_value | 4920 | | - dst->symbol.section->vma); | 4921 | | #endif | 4922 | 395 | break; | 4923 | | | 4924 | 129 | case C_STATLAB: /* Static load time label. */ | 4925 | 129 | dst->symbol.value = src->u.syment.n_value; | 4926 | 129 | dst->symbol.flags = BSF_GLOBAL; | 4927 | 129 | break; | 4928 | | | 4929 | 59.0k | case C_NULL: | 4930 | | /* PE DLLs sometimes have zeroed out symbols for some | 4931 | | reason. Just ignore them without a warning. */ | 4932 | 59.0k | if (src->u.syment.n_type == 0 | 4933 | 59.0k | && src->u.syment.n_value == 0 | 4934 | 59.0k | && src->u.syment.n_scnum == 0) | 4935 | 31.9k | break; | 4936 | | #ifdef RS6000COFF_C | 4937 | | /* XCOFF specific: deleted entry. */ | 4938 | | if (src->u.syment.n_value == C_NULL_VALUE) | 4939 | | break; | 4940 | | #endif | 4941 | | /* Fall through. */ | 4942 | 27.2k | case C_EXTDEF: /* External definition. */ | 4943 | 27.4k | case C_ULABEL: /* Undefined label. */ | 4944 | 27.7k | case C_USTATIC: /* Undefined static. */ | 4945 | | #ifndef COFF_WITH_PE | 4946 | | /* C_LINE in regular coff is 0x68. NT has taken over this storage | 4947 | | class to represent a section symbol. */ | 4948 | | case C_LINE: /* line # reformatted as symbol table entry. */ | 4949 | | /* NT uses 0x67 for a weak symbol, not C_ALIAS. */ | 4950 | | case C_ALIAS: /* Duplicate tag. */ | 4951 | | #endif | 4952 | | /* New storage classes for TI COFF. */ | 4953 | | #ifdef TICOFF | 4954 | | case C_UEXT: /* Tentative external definition. */ | 4955 | | #endif | 4956 | 27.8k | case C_EXTLAB: /* External load time label. */ | 4957 | 35.4k | default: | 4958 | 35.4k | _bfd_error_handler | 4959 | | /* xgettext:c-format */ | 4960 | 35.4k | (_("%pB: unrecognized storage class %d for %s symbol `%s'"), | 4961 | 35.4k | abfd, src->u.syment.n_sclass, | 4962 | 35.4k | dst->symbol.section->name, dst->symbol.name); | 4963 | 35.4k | ret = false; | 4964 | | /* Fall through. */ | 4965 | 35.6k | case C_HIDDEN: /* Ext symbol in dmert public lib. */ | 4966 | | /* PR 20722: These symbols can also be generated by | 4967 | | building DLLs with --gc-sections enabled. */ | 4968 | 35.6k | dst->symbol.flags = BSF_DEBUGGING; | 4969 | 35.6k | dst->symbol.value = (src->u.syment.n_value); | 4970 | 35.6k | break; | 4971 | 79.3k | } | 4972 | | | 4973 | 79.3k | dst->native = src; | 4974 | 79.3k | dst->symbol.udata.i = 0; | 4975 | 79.3k | dst->lineno = NULL; | 4976 | | | 4977 | 79.3k | this_index += (src->u.syment.n_numaux) + 1; | 4978 | 79.3k | dst++; | 4979 | 79.3k | number_of_symbols++; | 4980 | 79.3k | } | 4981 | 249 | } | 4982 | | | 4983 | 249 | obj_symbols (abfd) = cached_area; | 4984 | 249 | obj_raw_syments (abfd) = native_symbols; | 4985 | | | 4986 | 249 | abfd->symcount = number_of_symbols; | 4987 | 249 | obj_convert (abfd) = table_ptr; | 4988 | | /* Slurp the line tables for each section too. */ | 4989 | 249 | { | 4990 | 249 | asection *p; | 4991 | | | 4992 | 249 | p = abfd->sections; | 4993 | 732 | while (p) | 4994 | 612 | { | 4995 | 612 | if (! coff_slurp_line_table (abfd, p)) | 4996 | 129 | return false; | 4997 | 483 | p = p->next; | 4998 | 483 | } | 4999 | 249 | } | 5000 | | | 5001 | 120 | return ret; | 5002 | 249 | } |
pei-x86_64.c:coff_slurp_symbol_table Line | Count | Source | 4630 | 253 | { | 4631 | 253 | combined_entry_type *native_symbols; | 4632 | 253 | coff_symbol_type *cached_area; | 4633 | 253 | unsigned int *table_ptr; | 4634 | 253 | unsigned int number_of_symbols = 0; | 4635 | 253 | bool ret = true; | 4636 | 253 | size_t amt; | 4637 | | | 4638 | 253 | if (obj_symbols (abfd)) | 4639 | 43 | return true; | 4640 | | | 4641 | | /* Read in the symbol table. */ | 4642 | 210 | if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) | 4643 | 82 | return false; | 4644 | | | 4645 | | /* Allocate enough room for all the symbols in cached form. */ | 4646 | 128 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4647 | 128 | sizeof (*cached_area), &amt)) | 4648 | 0 | { | 4649 | 0 | bfd_set_error (bfd_error_file_too_big); | 4650 | 0 | return false; | 4651 | 0 | } | 4652 | 128 | cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt); | 4653 | 128 | if (cached_area == NULL) | 4654 | 0 | return false; | 4655 | | | 4656 | 128 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4657 | 128 | sizeof (*table_ptr), &amt)) | 4658 | 0 | { | 4659 | 0 | bfd_set_error (bfd_error_file_too_big); | 4660 | 0 | return false; | 4661 | 0 | } | 4662 | 128 | table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); | 4663 | 128 | if (table_ptr == NULL) | 4664 | 0 | return false; | 4665 | 128 | else | 4666 | 128 | { | 4667 | 128 | coff_symbol_type *dst = cached_area; | 4668 | 128 | unsigned int last_native_index = obj_raw_syment_count (abfd); | 4669 | 128 | unsigned int this_index = 0; | 4670 | | | 4671 | 13.1k | while (this_index < last_native_index) | 4672 | 13.0k | { | 4673 | 13.0k | combined_entry_type *src = native_symbols + this_index; | 4674 | 13.0k | table_ptr[this_index] = number_of_symbols; | 4675 | | | 4676 | 13.0k | dst->symbol.the_bfd = abfd; | 4677 | 13.0k | BFD_ASSERT (src->is_sym); | 4678 | 13.0k | dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset); | 4679 | | /* We use the native name field to point to the cached field. */ | 4680 | 13.0k | src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; | 4681 | 13.0k | dst->symbol.section = coff_section_from_bfd_index (abfd, | 4682 | 13.0k | src->u.syment.n_scnum); | 4683 | 13.0k | dst->symbol.flags = 0; | 4684 | | /* PR 17512: file: 079-7098-0.001:0.1. */ | 4685 | 13.0k | dst->symbol.value = 0; | 4686 | 13.0k | dst->done_lineno = false; | 4687 | | | 4688 | 13.0k | switch (src->u.syment.n_sclass) | 4689 | 13.0k | { | 4690 | 436 | case C_EXT: | 4691 | 448 | case C_WEAKEXT: | 4692 | | #if defined ARM | 4693 | | case C_THUMBEXT: | 4694 | | case C_THUMBEXTFUNC: | 4695 | | #endif | 4696 | | #ifdef RS6000COFF_C | 4697 | | case C_HIDEXT: | 4698 | | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 4699 | | case C_AIX_WEAKEXT: | 4700 | | #endif | 4701 | | #endif | 4702 | 448 | #ifdef C_SYSTEM | 4703 | 475 | case C_SYSTEM: /* System Wide variable. */ | 4704 | 475 | #endif | 4705 | 475 | #ifdef COFF_WITH_PE | 4706 | | /* In PE, 0x68 (104) denotes a section symbol. */ | 4707 | 480 | case C_SECTION: | 4708 | | /* In PE, 0x69 (105) denotes a weak external symbol. */ | 4709 | 527 | case C_NT_WEAK: | 4710 | 527 | #endif | 4711 | 527 | switch (coff_classify_symbol (abfd, &src->u.syment)) | 4712 | 527 | { | 4713 | 485 | case COFF_SYMBOL_GLOBAL: | 4714 | 485 | dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL; | 4715 | 485 | #if defined COFF_WITH_PE | 4716 | | /* PE sets the symbol to a value relative to the | 4717 | | start of the section. */ | 4718 | 485 | dst->symbol.value = src->u.syment.n_value; | 4719 | | #else | 4720 | | dst->symbol.value = (src->u.syment.n_value | 4721 | | - dst->symbol.section->vma); | 4722 | | #endif | 4723 | 485 | if (ISFCN ((src->u.syment.n_type))) | 4724 | | /* A function ext does not go at the end of a | 4725 | | file. */ | 4726 | 35 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4727 | 485 | break; | 4728 | | | 4729 | 19 | case COFF_SYMBOL_COMMON: | 4730 | 19 | dst->symbol.section = bfd_com_section_ptr; | 4731 | 19 | dst->symbol.value = src->u.syment.n_value; | 4732 | 19 | break; | 4733 | | | 4734 | 23 | case COFF_SYMBOL_UNDEFINED: | 4735 | 23 | dst->symbol.section = bfd_und_section_ptr; | 4736 | 23 | dst->symbol.value = 0; | 4737 | 23 | break; | 4738 | | | 4739 | 0 | case COFF_SYMBOL_PE_SECTION: | 4740 | 0 | dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM; | 4741 | 0 | dst->symbol.value = 0; | 4742 | 0 | break; | 4743 | | | 4744 | 0 | case COFF_SYMBOL_LOCAL: | 4745 | 0 | dst->symbol.flags = BSF_LOCAL; | 4746 | 0 | #if defined COFF_WITH_PE | 4747 | | /* PE sets the symbol to a value relative to the | 4748 | | start of the section. */ | 4749 | 0 | dst->symbol.value = src->u.syment.n_value; | 4750 | | #else | 4751 | | dst->symbol.value = (src->u.syment.n_value | 4752 | | - dst->symbol.section->vma); | 4753 | | #endif | 4754 | 0 | if (ISFCN ((src->u.syment.n_type))) | 4755 | 0 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4756 | 0 | break; | 4757 | 527 | } | 4758 | | | 4759 | | #ifdef RS6000COFF_C | 4760 | | /* A symbol with a csect entry should not go at the end. */ | 4761 | | if (src->u.syment.n_numaux > 0) | 4762 | | dst->symbol.flags |= BSF_NOT_AT_END; | 4763 | | #endif | 4764 | | | 4765 | 527 | #ifdef COFF_WITH_PE | 4766 | 527 | if (src->u.syment.n_sclass == C_NT_WEAK) | 4767 | 47 | dst->symbol.flags |= BSF_WEAK; | 4768 | | | 4769 | 527 | if (src->u.syment.n_sclass == C_SECTION | 4770 | 527 | && src->u.syment.n_scnum > 0) | 4771 | 0 | dst->symbol.flags = BSF_LOCAL; | 4772 | 527 | #endif | 4773 | 527 | if (src->u.syment.n_sclass == C_WEAKEXT | 4774 | | #ifdef RS6000COFF_C | 4775 | | || src->u.syment.n_sclass == C_AIX_WEAKEXT | 4776 | | #endif | 4777 | 527 | ) | 4778 | 12 | dst->symbol.flags |= BSF_WEAK; | 4779 | | | 4780 | 527 | break; | 4781 | | | 4782 | 508 | case C_STAT: /* Static. */ | 4783 | | #if defined ARM | 4784 | | case C_THUMBSTAT: /* Thumb static. */ | 4785 | | case C_THUMBLABEL: /* Thumb label. */ | 4786 | | case C_THUMBSTATFUNC:/* Thumb static function. */ | 4787 | | #endif | 4788 | | #ifdef RS6000COFF_C | 4789 | | case C_DWARF: /* A label in a dwarf section. */ | 4790 | | case C_INFO: /* A label in a comment section. */ | 4791 | | #endif | 4792 | 528 | case C_LABEL: /* Label. */ | 4793 | 528 | if (src->u.syment.n_scnum == N_DEBUG) | 4794 | 0 | dst->symbol.flags = BSF_DEBUGGING; | 4795 | 528 | else | 4796 | 528 | dst->symbol.flags = BSF_LOCAL; | 4797 | | | 4798 | | /* Base the value as an index from the base of the | 4799 | | section, if there is one. */ | 4800 | 528 | if (dst->symbol.section) | 4801 | 528 | { | 4802 | 528 | #if defined COFF_WITH_PE | 4803 | | /* PE sets the symbol to a value relative to the | 4804 | | start of the section. */ | 4805 | 528 | dst->symbol.value = src->u.syment.n_value; | 4806 | | #else | 4807 | | dst->symbol.value = (src->u.syment.n_value | 4808 | | - dst->symbol.section->vma); | 4809 | | #endif | 4810 | 528 | } | 4811 | 0 | else | 4812 | 0 | dst->symbol.value = src->u.syment.n_value; | 4813 | 528 | break; | 4814 | | | 4815 | 46 | case C_FILE: /* File name. */ | 4816 | 46 | dst->symbol.flags = BSF_FILE; | 4817 | | /* Fall through. */ | 4818 | 178 | case C_MOS: /* Member of structure. */ | 4819 | 200 | case C_EOS: /* End of structure. */ | 4820 | 300 | case C_REGPARM: /* Register parameter. */ | 4821 | 358 | case C_REG: /* register variable. */ | 4822 | | /* C_AUTOARG conflicts with TI COFF C_UEXT. */ | 4823 | 547 | case C_TPDEF: /* Type definition. */ | 4824 | 561 | case C_ARG: | 4825 | 1.07k | case C_AUTO: /* Automatic variable. */ | 4826 | 1.09k | case C_FIELD: /* Bit field. */ | 4827 | 1.12k | case C_ENTAG: /* Enumeration tag. */ | 4828 | 1.22k | case C_MOE: /* Member of enumeration. */ | 4829 | 1.24k | case C_MOU: /* Member of union. */ | 4830 | 1.34k | case C_UNTAG: /* Union tag. */ | 4831 | 1.45k | case C_STRTAG: /* Structure tag. */ | 4832 | | #ifdef RS6000COFF_C | 4833 | | case C_GSYM: | 4834 | | case C_LSYM: | 4835 | | case C_PSYM: | 4836 | | case C_RSYM: | 4837 | | case C_RPSYM: | 4838 | | case C_STSYM: | 4839 | | case C_TCSYM: | 4840 | | case C_BCOMM: | 4841 | | case C_ECOML: | 4842 | | case C_ECOMM: | 4843 | | case C_DECL: | 4844 | | case C_ENTRY: | 4845 | | case C_FUN: | 4846 | | case C_ESTAT: | 4847 | | #endif | 4848 | 1.45k | dst->symbol.flags |= BSF_DEBUGGING; | 4849 | 1.45k | dst->symbol.value = (src->u.syment.n_value); | 4850 | 1.45k | break; | 4851 | | | 4852 | | #ifdef RS6000COFF_C | 4853 | | case C_BINCL: /* Beginning of include file. */ | 4854 | | case C_EINCL: /* Ending of include file. */ | 4855 | | /* The value is actually a pointer into the line numbers | 4856 | | of the file. We locate the line number entry, and | 4857 | | set the section to the section which contains it, and | 4858 | | the value to the index in that section. */ | 4859 | | { | 4860 | | asection *sec; | 4861 | | | 4862 | | dst->symbol.flags = BSF_DEBUGGING; | 4863 | | for (sec = abfd->sections; sec != NULL; sec = sec->next) | 4864 | | if (sec->line_filepos <= (file_ptr) src->u.syment.n_value | 4865 | | && ((file_ptr) (sec->line_filepos | 4866 | | + sec->lineno_count * bfd_coff_linesz (abfd)) | 4867 | | > (file_ptr) src->u.syment.n_value)) | 4868 | | break; | 4869 | | if (sec == NULL) | 4870 | | dst->symbol.value = 0; | 4871 | | else | 4872 | | { | 4873 | | dst->symbol.section = sec; | 4874 | | dst->symbol.value = ((src->u.syment.n_value | 4875 | | - sec->line_filepos) | 4876 | | / bfd_coff_linesz (abfd)); | 4877 | | src->fix_line = 1; | 4878 | | } | 4879 | | } | 4880 | | break; | 4881 | | | 4882 | | case C_BSTAT: | 4883 | | dst->symbol.flags = BSF_DEBUGGING; | 4884 | | | 4885 | | if (src->u.syment.n_value >= obj_raw_syment_count (abfd)) | 4886 | | dst->symbol.value = 0; | 4887 | | else | 4888 | | { | 4889 | | /* The value is actually a symbol index. Save a pointer | 4890 | | to the symbol instead of the index. FIXME: This | 4891 | | should use a union. */ | 4892 | | src->u.syment.n_value | 4893 | | = (uintptr_t) (native_symbols + src->u.syment.n_value); | 4894 | | dst->symbol.value = src->u.syment.n_value; | 4895 | | src->fix_value = 1; | 4896 | | } | 4897 | | break; | 4898 | | #endif | 4899 | | | 4900 | 19 | case C_BLOCK: /* ".bb" or ".eb". */ | 4901 | 105 | case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */ | 4902 | 190 | case C_EFCN: /* Physical end of function. */ | 4903 | 190 | #if defined COFF_WITH_PE | 4904 | | /* PE sets the symbol to a value relative to the start | 4905 | | of the section. */ | 4906 | 190 | dst->symbol.value = src->u.syment.n_value; | 4907 | 190 | if (strcmp (dst->symbol.name, ".bf") != 0) | 4908 | 190 | { | 4909 | | /* PE uses funny values for .ef and .lf; don't | 4910 | | relocate them. */ | 4911 | 190 | dst->symbol.flags = BSF_DEBUGGING; | 4912 | 190 | } | 4913 | 0 | else | 4914 | 0 | dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC; | 4915 | | #else | 4916 | | /* Base the value as an index from the base of the | 4917 | | section. */ | 4918 | | dst->symbol.flags = BSF_LOCAL; | 4919 | | dst->symbol.value = (src->u.syment.n_value | 4920 | | - dst->symbol.section->vma); | 4921 | | #endif | 4922 | 190 | break; | 4923 | | | 4924 | 18 | case C_STATLAB: /* Static load time label. */ | 4925 | 18 | dst->symbol.value = src->u.syment.n_value; | 4926 | 18 | dst->symbol.flags = BSF_GLOBAL; | 4927 | 18 | break; | 4928 | | | 4929 | 8.51k | case C_NULL: | 4930 | | /* PE DLLs sometimes have zeroed out symbols for some | 4931 | | reason. Just ignore them without a warning. */ | 4932 | 8.51k | if (src->u.syment.n_type == 0 | 4933 | 8.51k | && src->u.syment.n_value == 0 | 4934 | 8.51k | && src->u.syment.n_scnum == 0) | 4935 | 2.66k | break; | 4936 | | #ifdef RS6000COFF_C | 4937 | | /* XCOFF specific: deleted entry. */ | 4938 | | if (src->u.syment.n_value == C_NULL_VALUE) | 4939 | | break; | 4940 | | #endif | 4941 | | /* Fall through. */ | 4942 | 5.86k | case C_EXTDEF: /* External definition. */ | 4943 | 5.89k | case C_ULABEL: /* Undefined label. */ | 4944 | 5.91k | case C_USTATIC: /* Undefined static. */ | 4945 | | #ifndef COFF_WITH_PE | 4946 | | /* C_LINE in regular coff is 0x68. NT has taken over this storage | 4947 | | class to represent a section symbol. */ | 4948 | | case C_LINE: /* line # reformatted as symbol table entry. */ | 4949 | | /* NT uses 0x67 for a weak symbol, not C_ALIAS. */ | 4950 | | case C_ALIAS: /* Duplicate tag. */ | 4951 | | #endif | 4952 | | /* New storage classes for TI COFF. */ | 4953 | | #ifdef TICOFF | 4954 | | case C_UEXT: /* Tentative external definition. */ | 4955 | | #endif | 4956 | 5.92k | case C_EXTLAB: /* External load time label. */ | 4957 | 7.65k | default: | 4958 | 7.65k | _bfd_error_handler | 4959 | | /* xgettext:c-format */ | 4960 | 7.65k | (_("%pB: unrecognized storage class %d for %s symbol `%s'"), | 4961 | 7.65k | abfd, src->u.syment.n_sclass, | 4962 | 7.65k | dst->symbol.section->name, dst->symbol.name); | 4963 | 7.65k | ret = false; | 4964 | | /* Fall through. */ | 4965 | 7.66k | case C_HIDDEN: /* Ext symbol in dmert public lib. */ | 4966 | | /* PR 20722: These symbols can also be generated by | 4967 | | building DLLs with --gc-sections enabled. */ | 4968 | 7.66k | dst->symbol.flags = BSF_DEBUGGING; | 4969 | 7.66k | dst->symbol.value = (src->u.syment.n_value); | 4970 | 7.66k | break; | 4971 | 13.0k | } | 4972 | | | 4973 | 13.0k | dst->native = src; | 4974 | 13.0k | dst->symbol.udata.i = 0; | 4975 | 13.0k | dst->lineno = NULL; | 4976 | | | 4977 | 13.0k | this_index += (src->u.syment.n_numaux) + 1; | 4978 | 13.0k | dst++; | 4979 | 13.0k | number_of_symbols++; | 4980 | 13.0k | } | 4981 | 128 | } | 4982 | | | 4983 | 128 | obj_symbols (abfd) = cached_area; | 4984 | 128 | obj_raw_syments (abfd) = native_symbols; | 4985 | | | 4986 | 128 | abfd->symcount = number_of_symbols; | 4987 | 128 | obj_convert (abfd) = table_ptr; | 4988 | | /* Slurp the line tables for each section too. */ | 4989 | 128 | { | 4990 | 128 | asection *p; | 4991 | | | 4992 | 128 | p = abfd->sections; | 4993 | 231 | while (p) | 4994 | 209 | { | 4995 | 209 | if (! coff_slurp_line_table (abfd, p)) | 4996 | 106 | return false; | 4997 | 103 | p = p->next; | 4998 | 103 | } | 4999 | 128 | } | 5000 | | | 5001 | 22 | return ret; | 5002 | 128 | } |
coff-x86_64.c:coff_slurp_symbol_table Line | Count | Source | 4630 | 985 | { | 4631 | 985 | combined_entry_type *native_symbols; | 4632 | 985 | coff_symbol_type *cached_area; | 4633 | 985 | unsigned int *table_ptr; | 4634 | 985 | unsigned int number_of_symbols = 0; | 4635 | 985 | bool ret = true; | 4636 | 985 | size_t amt; | 4637 | | | 4638 | 985 | if (obj_symbols (abfd)) | 4639 | 375 | return true; | 4640 | | | 4641 | | /* Read in the symbol table. */ | 4642 | 610 | if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) | 4643 | 271 | return false; | 4644 | | | 4645 | | /* Allocate enough room for all the symbols in cached form. */ | 4646 | 339 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4647 | 339 | sizeof (*cached_area), &amt)) | 4648 | 0 | { | 4649 | 0 | bfd_set_error (bfd_error_file_too_big); | 4650 | 0 | return false; | 4651 | 0 | } | 4652 | 339 | cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt); | 4653 | 339 | if (cached_area == NULL) | 4654 | 0 | return false; | 4655 | | | 4656 | 339 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4657 | 339 | sizeof (*table_ptr), &amt)) | 4658 | 0 | { | 4659 | 0 | bfd_set_error (bfd_error_file_too_big); | 4660 | 0 | return false; | 4661 | 0 | } | 4662 | 339 | table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); | 4663 | 339 | if (table_ptr == NULL) | 4664 | 0 | return false; | 4665 | 339 | else | 4666 | 339 | { | 4667 | 339 | coff_symbol_type *dst = cached_area; | 4668 | 339 | unsigned int last_native_index = obj_raw_syment_count (abfd); | 4669 | 339 | unsigned int this_index = 0; | 4670 | | | 4671 | 36.7k | while (this_index < last_native_index) | 4672 | 36.4k | { | 4673 | 36.4k | combined_entry_type *src = native_symbols + this_index; | 4674 | 36.4k | table_ptr[this_index] = number_of_symbols; | 4675 | | | 4676 | 36.4k | dst->symbol.the_bfd = abfd; | 4677 | 36.4k | BFD_ASSERT (src->is_sym); | 4678 | 36.4k | dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset); | 4679 | | /* We use the native name field to point to the cached field. */ | 4680 | 36.4k | src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; | 4681 | 36.4k | dst->symbol.section = coff_section_from_bfd_index (abfd, | 4682 | 36.4k | src->u.syment.n_scnum); | 4683 | 36.4k | dst->symbol.flags = 0; | 4684 | | /* PR 17512: file: 079-7098-0.001:0.1. */ | 4685 | 36.4k | dst->symbol.value = 0; | 4686 | 36.4k | dst->done_lineno = false; | 4687 | | | 4688 | 36.4k | switch (src->u.syment.n_sclass) | 4689 | 36.4k | { | 4690 | 706 | case C_EXT: | 4691 | 781 | case C_WEAKEXT: | 4692 | | #if defined ARM | 4693 | | case C_THUMBEXT: | 4694 | | case C_THUMBEXTFUNC: | 4695 | | #endif | 4696 | | #ifdef RS6000COFF_C | 4697 | | case C_HIDEXT: | 4698 | | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 4699 | | case C_AIX_WEAKEXT: | 4700 | | #endif | 4701 | | #endif | 4702 | 781 | #ifdef C_SYSTEM | 4703 | 867 | case C_SYSTEM: /* System Wide variable. */ | 4704 | 867 | #endif | 4705 | | #ifdef COFF_WITH_PE | 4706 | | /* In PE, 0x68 (104) denotes a section symbol. */ | 4707 | | case C_SECTION: | 4708 | | /* In PE, 0x69 (105) denotes a weak external symbol. */ | 4709 | | case C_NT_WEAK: | 4710 | | #endif | 4711 | 867 | switch (coff_classify_symbol (abfd, &src->u.syment)) | 4712 | 867 | { | 4713 | 774 | case COFF_SYMBOL_GLOBAL: | 4714 | 774 | dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL; | 4715 | | #if defined COFF_WITH_PE | 4716 | | /* PE sets the symbol to a value relative to the | 4717 | | start of the section. */ | 4718 | | dst->symbol.value = src->u.syment.n_value; | 4719 | | #else | 4720 | 774 | dst->symbol.value = (src->u.syment.n_value | 4721 | 774 | - dst->symbol.section->vma); | 4722 | 774 | #endif | 4723 | 774 | if (ISFCN ((src->u.syment.n_type))) | 4724 | | /* A function ext does not go at the end of a | 4725 | | file. */ | 4726 | 7 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4727 | 774 | break; | 4728 | | | 4729 | 72 | case COFF_SYMBOL_COMMON: | 4730 | 72 | dst->symbol.section = bfd_com_section_ptr; | 4731 | 72 | dst->symbol.value = src->u.syment.n_value; | 4732 | 72 | break; | 4733 | | | 4734 | 21 | case COFF_SYMBOL_UNDEFINED: | 4735 | 21 | dst->symbol.section = bfd_und_section_ptr; | 4736 | 21 | dst->symbol.value = 0; | 4737 | 21 | break; | 4738 | | | 4739 | 0 | case COFF_SYMBOL_PE_SECTION: | 4740 | 0 | dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM; | 4741 | 0 | dst->symbol.value = 0; | 4742 | 0 | break; | 4743 | | | 4744 | 0 | case COFF_SYMBOL_LOCAL: | 4745 | 0 | dst->symbol.flags = BSF_LOCAL; | 4746 | | #if defined COFF_WITH_PE | 4747 | | /* PE sets the symbol to a value relative to the | 4748 | | start of the section. */ | 4749 | | dst->symbol.value = src->u.syment.n_value; | 4750 | | #else | 4751 | 0 | dst->symbol.value = (src->u.syment.n_value | 4752 | 0 | - dst->symbol.section->vma); | 4753 | 0 | #endif | 4754 | 0 | if (ISFCN ((src->u.syment.n_type))) | 4755 | 0 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4756 | 0 | break; | 4757 | 867 | } | 4758 | | | 4759 | | #ifdef RS6000COFF_C | 4760 | | /* A symbol with a csect entry should not go at the end. */ | 4761 | | if (src->u.syment.n_numaux > 0) | 4762 | | dst->symbol.flags |= BSF_NOT_AT_END; | 4763 | | #endif | 4764 | | | 4765 | | #ifdef COFF_WITH_PE | 4766 | | if (src->u.syment.n_sclass == C_NT_WEAK) | 4767 | | dst->symbol.flags |= BSF_WEAK; | 4768 | | | 4769 | | if (src->u.syment.n_sclass == C_SECTION | 4770 | | && src->u.syment.n_scnum > 0) | 4771 | | dst->symbol.flags = BSF_LOCAL; | 4772 | | #endif | 4773 | 867 | if (src->u.syment.n_sclass == C_WEAKEXT | 4774 | | #ifdef RS6000COFF_C | 4775 | | || src->u.syment.n_sclass == C_AIX_WEAKEXT | 4776 | | #endif | 4777 | 867 | ) | 4778 | 75 | dst->symbol.flags |= BSF_WEAK; | 4779 | | | 4780 | 867 | break; | 4781 | | | 4782 | 219 | case C_STAT: /* Static. */ | 4783 | | #if defined ARM | 4784 | | case C_THUMBSTAT: /* Thumb static. */ | 4785 | | case C_THUMBLABEL: /* Thumb label. */ | 4786 | | case C_THUMBSTATFUNC:/* Thumb static function. */ | 4787 | | #endif | 4788 | | #ifdef RS6000COFF_C | 4789 | | case C_DWARF: /* A label in a dwarf section. */ | 4790 | | case C_INFO: /* A label in a comment section. */ | 4791 | | #endif | 4792 | 266 | case C_LABEL: /* Label. */ | 4793 | 266 | if (src->u.syment.n_scnum == N_DEBUG) | 4794 | 1 | dst->symbol.flags = BSF_DEBUGGING; | 4795 | 265 | else | 4796 | 265 | dst->symbol.flags = BSF_LOCAL; | 4797 | | | 4798 | | /* Base the value as an index from the base of the | 4799 | | section, if there is one. */ | 4800 | 266 | if (dst->symbol.section) | 4801 | 266 | { | 4802 | | #if defined COFF_WITH_PE | 4803 | | /* PE sets the symbol to a value relative to the | 4804 | | start of the section. */ | 4805 | | dst->symbol.value = src->u.syment.n_value; | 4806 | | #else | 4807 | 266 | dst->symbol.value = (src->u.syment.n_value | 4808 | 266 | - dst->symbol.section->vma); | 4809 | 266 | #endif | 4810 | 266 | } | 4811 | 0 | else | 4812 | 0 | dst->symbol.value = src->u.syment.n_value; | 4813 | 266 | break; | 4814 | | | 4815 | 76 | case C_FILE: /* File name. */ | 4816 | 76 | dst->symbol.flags = BSF_FILE; | 4817 | | /* Fall through. */ | 4818 | 263 | case C_MOS: /* Member of structure. */ | 4819 | 310 | case C_EOS: /* End of structure. */ | 4820 | 393 | case C_REGPARM: /* Register parameter. */ | 4821 | 535 | case C_REG: /* register variable. */ | 4822 | | /* C_AUTOARG conflicts with TI COFF C_UEXT. */ | 4823 | 654 | case C_TPDEF: /* Type definition. */ | 4824 | 960 | case C_ARG: | 4825 | 2.94k | case C_AUTO: /* Automatic variable. */ | 4826 | 3.08k | case C_FIELD: /* Bit field. */ | 4827 | 3.20k | case C_ENTAG: /* Enumeration tag. */ | 4828 | 3.41k | case C_MOE: /* Member of enumeration. */ | 4829 | 3.49k | case C_MOU: /* Member of union. */ | 4830 | 3.99k | case C_UNTAG: /* Union tag. */ | 4831 | 4.18k | case C_STRTAG: /* Structure tag. */ | 4832 | | #ifdef RS6000COFF_C | 4833 | | case C_GSYM: | 4834 | | case C_LSYM: | 4835 | | case C_PSYM: | 4836 | | case C_RSYM: | 4837 | | case C_RPSYM: | 4838 | | case C_STSYM: | 4839 | | case C_TCSYM: | 4840 | | case C_BCOMM: | 4841 | | case C_ECOML: | 4842 | | case C_ECOMM: | 4843 | | case C_DECL: | 4844 | | case C_ENTRY: | 4845 | | case C_FUN: | 4846 | | case C_ESTAT: | 4847 | | #endif | 4848 | 4.18k | dst->symbol.flags |= BSF_DEBUGGING; | 4849 | 4.18k | dst->symbol.value = (src->u.syment.n_value); | 4850 | 4.18k | break; | 4851 | | | 4852 | | #ifdef RS6000COFF_C | 4853 | | case C_BINCL: /* Beginning of include file. */ | 4854 | | case C_EINCL: /* Ending of include file. */ | 4855 | | /* The value is actually a pointer into the line numbers | 4856 | | of the file. We locate the line number entry, and | 4857 | | set the section to the section which contains it, and | 4858 | | the value to the index in that section. */ | 4859 | | { | 4860 | | asection *sec; | 4861 | | | 4862 | | dst->symbol.flags = BSF_DEBUGGING; | 4863 | | for (sec = abfd->sections; sec != NULL; sec = sec->next) | 4864 | | if (sec->line_filepos <= (file_ptr) src->u.syment.n_value | 4865 | | && ((file_ptr) (sec->line_filepos | 4866 | | + sec->lineno_count * bfd_coff_linesz (abfd)) | 4867 | | > (file_ptr) src->u.syment.n_value)) | 4868 | | break; | 4869 | | if (sec == NULL) | 4870 | | dst->symbol.value = 0; | 4871 | | else | 4872 | | { | 4873 | | dst->symbol.section = sec; | 4874 | | dst->symbol.value = ((src->u.syment.n_value | 4875 | | - sec->line_filepos) | 4876 | | / bfd_coff_linesz (abfd)); | 4877 | | src->fix_line = 1; | 4878 | | } | 4879 | | } | 4880 | | break; | 4881 | | | 4882 | | case C_BSTAT: | 4883 | | dst->symbol.flags = BSF_DEBUGGING; | 4884 | | | 4885 | | if (src->u.syment.n_value >= obj_raw_syment_count (abfd)) | 4886 | | dst->symbol.value = 0; | 4887 | | else | 4888 | | { | 4889 | | /* The value is actually a symbol index. Save a pointer | 4890 | | to the symbol instead of the index. FIXME: This | 4891 | | should use a union. */ | 4892 | | src->u.syment.n_value | 4893 | | = (uintptr_t) (native_symbols + src->u.syment.n_value); | 4894 | | dst->symbol.value = src->u.syment.n_value; | 4895 | | src->fix_value = 1; | 4896 | | } | 4897 | | break; | 4898 | | #endif | 4899 | | | 4900 | 71 | case C_BLOCK: /* ".bb" or ".eb". */ | 4901 | 132 | case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */ | 4902 | 244 | case C_EFCN: /* Physical end of function. */ | 4903 | | #if defined COFF_WITH_PE | 4904 | | /* PE sets the symbol to a value relative to the start | 4905 | | of the section. */ | 4906 | | dst->symbol.value = src->u.syment.n_value; | 4907 | | if (strcmp (dst->symbol.name, ".bf") != 0) | 4908 | | { | 4909 | | /* PE uses funny values for .ef and .lf; don't | 4910 | | relocate them. */ | 4911 | | dst->symbol.flags = BSF_DEBUGGING; | 4912 | | } | 4913 | | else | 4914 | | dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC; | 4915 | | #else | 4916 | | /* Base the value as an index from the base of the | 4917 | | section. */ | 4918 | 244 | dst->symbol.flags = BSF_LOCAL; | 4919 | 244 | dst->symbol.value = (src->u.syment.n_value | 4920 | 244 | - dst->symbol.section->vma); | 4921 | 244 | #endif | 4922 | 244 | break; | 4923 | | | 4924 | 158 | case C_STATLAB: /* Static load time label. */ | 4925 | 158 | dst->symbol.value = src->u.syment.n_value; | 4926 | 158 | dst->symbol.flags = BSF_GLOBAL; | 4927 | 158 | break; | 4928 | | | 4929 | 25.2k | case C_NULL: | 4930 | | /* PE DLLs sometimes have zeroed out symbols for some | 4931 | | reason. Just ignore them without a warning. */ | 4932 | 25.2k | if (src->u.syment.n_type == 0 | 4933 | 25.2k | && src->u.syment.n_value == 0 | 4934 | 25.2k | && src->u.syment.n_scnum == 0) | 4935 | 9.98k | break; | 4936 | | #ifdef RS6000COFF_C | 4937 | | /* XCOFF specific: deleted entry. */ | 4938 | | if (src->u.syment.n_value == C_NULL_VALUE) | 4939 | | break; | 4940 | | #endif | 4941 | | /* Fall through. */ | 4942 | 15.3k | case C_EXTDEF: /* External definition. */ | 4943 | 15.4k | case C_ULABEL: /* Undefined label. */ | 4944 | 15.5k | case C_USTATIC: /* Undefined static. */ | 4945 | 15.5k | #ifndef COFF_WITH_PE | 4946 | | /* C_LINE in regular coff is 0x68. NT has taken over this storage | 4947 | | class to represent a section symbol. */ | 4948 | 15.5k | case C_LINE: /* line # reformatted as symbol table entry. */ | 4949 | | /* NT uses 0x67 for a weak symbol, not C_ALIAS. */ | 4950 | 15.6k | case C_ALIAS: /* Duplicate tag. */ | 4951 | 15.6k | #endif | 4952 | | /* New storage classes for TI COFF. */ | 4953 | | #ifdef TICOFF | 4954 | | case C_UEXT: /* Tentative external definition. */ | 4955 | | #endif | 4956 | 15.6k | case C_EXTLAB: /* External load time label. */ | 4957 | 20.6k | default: | 4958 | 20.6k | _bfd_error_handler | 4959 | | /* xgettext:c-format */ | 4960 | 20.6k | (_("%pB: unrecognized storage class %d for %s symbol `%s'"), | 4961 | 20.6k | abfd, src->u.syment.n_sclass, | 4962 | 20.6k | dst->symbol.section->name, dst->symbol.name); | 4963 | 20.6k | ret = false; | 4964 | | /* Fall through. */ | 4965 | 20.7k | case C_HIDDEN: /* Ext symbol in dmert public lib. */ | 4966 | | /* PR 20722: These symbols can also be generated by | 4967 | | building DLLs with --gc-sections enabled. */ | 4968 | 20.7k | dst->symbol.flags = BSF_DEBUGGING; | 4969 | 20.7k | dst->symbol.value = (src->u.syment.n_value); | 4970 | 20.7k | break; | 4971 | 36.4k | } | 4972 | | | 4973 | 36.4k | dst->native = src; | 4974 | 36.4k | dst->symbol.udata.i = 0; | 4975 | 36.4k | dst->lineno = NULL; | 4976 | | | 4977 | 36.4k | this_index += (src->u.syment.n_numaux) + 1; | 4978 | 36.4k | dst++; | 4979 | 36.4k | number_of_symbols++; | 4980 | 36.4k | } | 4981 | 339 | } | 4982 | | | 4983 | 339 | obj_symbols (abfd) = cached_area; | 4984 | 339 | obj_raw_syments (abfd) = native_symbols; | 4985 | | | 4986 | 339 | abfd->symcount = number_of_symbols; | 4987 | 339 | obj_convert (abfd) = table_ptr; | 4988 | | /* Slurp the line tables for each section too. */ | 4989 | 339 | { | 4990 | 339 | asection *p; | 4991 | | | 4992 | 339 | p = abfd->sections; | 4993 | 1.47k | while (p) | 4994 | 1.37k | { | 4995 | 1.37k | if (! coff_slurp_line_table (abfd, p)) | 4996 | 234 | return false; | 4997 | 1.13k | p = p->next; | 4998 | 1.13k | } | 4999 | 339 | } | 5000 | | | 5001 | 105 | return ret; | 5002 | 339 | } |
coff64-rs6000.c:coff_slurp_symbol_table Line | Count | Source | 4630 | 658 | { | 4631 | 658 | combined_entry_type *native_symbols; | 4632 | 658 | coff_symbol_type *cached_area; | 4633 | 658 | unsigned int *table_ptr; | 4634 | 658 | unsigned int number_of_symbols = 0; | 4635 | 658 | bool ret = true; | 4636 | 658 | size_t amt; | 4637 | | | 4638 | 658 | if (obj_symbols (abfd)) | 4639 | 94 | return true; | 4640 | | | 4641 | | /* Read in the symbol table. */ | 4642 | 564 | if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) | 4643 | 229 | return false; | 4644 | | | 4645 | | /* Allocate enough room for all the symbols in cached form. */ | 4646 | 335 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4647 | 335 | sizeof (*cached_area), &amt)) | 4648 | 0 | { | 4649 | 0 | bfd_set_error (bfd_error_file_too_big); | 4650 | 0 | return false; | 4651 | 0 | } | 4652 | 335 | cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt); | 4653 | 335 | if (cached_area == NULL) | 4654 | 0 | return false; | 4655 | | | 4656 | 335 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4657 | 335 | sizeof (*table_ptr), &amt)) | 4658 | 0 | { | 4659 | 0 | bfd_set_error (bfd_error_file_too_big); | 4660 | 0 | return false; | 4661 | 0 | } | 4662 | 335 | table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); | 4663 | 335 | if (table_ptr == NULL) | 4664 | 0 | return false; | 4665 | 335 | else | 4666 | 335 | { | 4667 | 335 | coff_symbol_type *dst = cached_area; | 4668 | 335 | unsigned int last_native_index = obj_raw_syment_count (abfd); | 4669 | 335 | unsigned int this_index = 0; | 4670 | | | 4671 | 132k | while (this_index < last_native_index) | 4672 | 131k | { | 4673 | 131k | combined_entry_type *src = native_symbols + this_index; | 4674 | 131k | table_ptr[this_index] = number_of_symbols; | 4675 | | | 4676 | 131k | dst->symbol.the_bfd = abfd; | 4677 | 131k | BFD_ASSERT (src->is_sym); | 4678 | 131k | dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset); | 4679 | | /* We use the native name field to point to the cached field. */ | 4680 | 131k | src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; | 4681 | 131k | dst->symbol.section = coff_section_from_bfd_index (abfd, | 4682 | 131k | src->u.syment.n_scnum); | 4683 | 131k | dst->symbol.flags = 0; | 4684 | | /* PR 17512: file: 079-7098-0.001:0.1. */ | 4685 | 131k | dst->symbol.value = 0; | 4686 | 131k | dst->done_lineno = false; | 4687 | | | 4688 | 131k | switch (src->u.syment.n_sclass) | 4689 | 131k | { | 4690 | 4.57k | case C_EXT: | 4691 | 4.61k | case C_WEAKEXT: | 4692 | | #if defined ARM | 4693 | | case C_THUMBEXT: | 4694 | | case C_THUMBEXTFUNC: | 4695 | | #endif | 4696 | 4.61k | #ifdef RS6000COFF_C | 4697 | 4.72k | case C_HIDEXT: | 4698 | 4.72k | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 4699 | 4.79k | case C_AIX_WEAKEXT: | 4700 | 4.79k | #endif | 4701 | 4.79k | #endif | 4702 | 4.79k | #ifdef C_SYSTEM | 4703 | 5.10k | case C_SYSTEM: /* System Wide variable. */ | 4704 | 5.10k | #endif | 4705 | | #ifdef COFF_WITH_PE | 4706 | | /* In PE, 0x68 (104) denotes a section symbol. */ | 4707 | | case C_SECTION: | 4708 | | /* In PE, 0x69 (105) denotes a weak external symbol. */ | 4709 | | case C_NT_WEAK: | 4710 | | #endif | 4711 | 5.10k | switch (coff_classify_symbol (abfd, &src->u.syment)) | 4712 | 5.10k | { | 4713 | 4.74k | case COFF_SYMBOL_GLOBAL: | 4714 | 4.74k | dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL; | 4715 | | #if defined COFF_WITH_PE | 4716 | | /* PE sets the symbol to a value relative to the | 4717 | | start of the section. */ | 4718 | | dst->symbol.value = src->u.syment.n_value; | 4719 | | #else | 4720 | 4.74k | dst->symbol.value = (src->u.syment.n_value | 4721 | 4.74k | - dst->symbol.section->vma); | 4722 | 4.74k | #endif | 4723 | 4.74k | if (ISFCN ((src->u.syment.n_type))) | 4724 | | /* A function ext does not go at the end of a | 4725 | | file. */ | 4726 | 23 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4727 | 4.74k | break; | 4728 | | | 4729 | 167 | case COFF_SYMBOL_COMMON: | 4730 | 167 | dst->symbol.section = bfd_com_section_ptr; | 4731 | 167 | dst->symbol.value = src->u.syment.n_value; | 4732 | 167 | break; | 4733 | | | 4734 | 85 | case COFF_SYMBOL_UNDEFINED: | 4735 | 85 | dst->symbol.section = bfd_und_section_ptr; | 4736 | 85 | dst->symbol.value = 0; | 4737 | 85 | break; | 4738 | | | 4739 | 0 | case COFF_SYMBOL_PE_SECTION: | 4740 | 0 | dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM; | 4741 | 0 | dst->symbol.value = 0; | 4742 | 0 | break; | 4743 | | | 4744 | 103 | case COFF_SYMBOL_LOCAL: | 4745 | 103 | dst->symbol.flags = BSF_LOCAL; | 4746 | | #if defined COFF_WITH_PE | 4747 | | /* PE sets the symbol to a value relative to the | 4748 | | start of the section. */ | 4749 | | dst->symbol.value = src->u.syment.n_value; | 4750 | | #else | 4751 | 103 | dst->symbol.value = (src->u.syment.n_value | 4752 | 103 | - dst->symbol.section->vma); | 4753 | 103 | #endif | 4754 | 103 | if (ISFCN ((src->u.syment.n_type))) | 4755 | 68 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4756 | 103 | break; | 4757 | 5.10k | } | 4758 | | | 4759 | 5.10k | #ifdef RS6000COFF_C | 4760 | | /* A symbol with a csect entry should not go at the end. */ | 4761 | 5.10k | if (src->u.syment.n_numaux > 0) | 4762 | 4.51k | dst->symbol.flags |= BSF_NOT_AT_END; | 4763 | 5.10k | #endif | 4764 | | | 4765 | | #ifdef COFF_WITH_PE | 4766 | | if (src->u.syment.n_sclass == C_NT_WEAK) | 4767 | | dst->symbol.flags |= BSF_WEAK; | 4768 | | | 4769 | | if (src->u.syment.n_sclass == C_SECTION | 4770 | | && src->u.syment.n_scnum > 0) | 4771 | | dst->symbol.flags = BSF_LOCAL; | 4772 | | #endif | 4773 | 5.10k | if (src->u.syment.n_sclass == C_WEAKEXT | 4774 | 5.10k | #ifdef RS6000COFF_C | 4775 | 5.10k | || src->u.syment.n_sclass == C_AIX_WEAKEXT | 4776 | 5.10k | #endif | 4777 | 5.10k | ) | 4778 | 103 | dst->symbol.flags |= BSF_WEAK; | 4779 | | | 4780 | 5.10k | break; | 4781 | | | 4782 | 430 | case C_STAT: /* Static. */ | 4783 | | #if defined ARM | 4784 | | case C_THUMBSTAT: /* Thumb static. */ | 4785 | | case C_THUMBLABEL: /* Thumb label. */ | 4786 | | case C_THUMBSTATFUNC:/* Thumb static function. */ | 4787 | | #endif | 4788 | 430 | #ifdef RS6000COFF_C | 4789 | 699 | case C_DWARF: /* A label in a dwarf section. */ | 4790 | 936 | case C_INFO: /* A label in a comment section. */ | 4791 | 936 | #endif | 4792 | 1.25k | case C_LABEL: /* Label. */ | 4793 | 1.25k | if (src->u.syment.n_scnum == N_DEBUG) | 4794 | 0 | dst->symbol.flags = BSF_DEBUGGING; | 4795 | 1.25k | else | 4796 | 1.25k | dst->symbol.flags = BSF_LOCAL; | 4797 | | | 4798 | | /* Base the value as an index from the base of the | 4799 | | section, if there is one. */ | 4800 | 1.25k | if (dst->symbol.section) | 4801 | 1.25k | { | 4802 | | #if defined COFF_WITH_PE | 4803 | | /* PE sets the symbol to a value relative to the | 4804 | | start of the section. */ | 4805 | | dst->symbol.value = src->u.syment.n_value; | 4806 | | #else | 4807 | 1.25k | dst->symbol.value = (src->u.syment.n_value | 4808 | 1.25k | - dst->symbol.section->vma); | 4809 | 1.25k | #endif | 4810 | 1.25k | } | 4811 | 0 | else | 4812 | 0 | dst->symbol.value = src->u.syment.n_value; | 4813 | 1.25k | break; | 4814 | | | 4815 | 505 | case C_FILE: /* File name. */ | 4816 | 505 | dst->symbol.flags = BSF_FILE; | 4817 | | /* Fall through. */ | 4818 | 758 | case C_MOS: /* Member of structure. */ | 4819 | 849 | case C_EOS: /* End of structure. */ | 4820 | 918 | case C_REGPARM: /* Register parameter. */ | 4821 | 1.32k | case C_REG: /* register variable. */ | 4822 | | /* C_AUTOARG conflicts with TI COFF C_UEXT. */ | 4823 | 1.88k | case C_TPDEF: /* Type definition. */ | 4824 | 2.21k | case C_ARG: | 4825 | 9.71k | case C_AUTO: /* Automatic variable. */ | 4826 | 9.92k | case C_FIELD: /* Bit field. */ | 4827 | 10.2k | case C_ENTAG: /* Enumeration tag. */ | 4828 | 10.9k | case C_MOE: /* Member of enumeration. */ | 4829 | 11.1k | case C_MOU: /* Member of union. */ | 4830 | 11.7k | case C_UNTAG: /* Union tag. */ | 4831 | 13.1k | case C_STRTAG: /* Structure tag. */ | 4832 | 13.1k | #ifdef RS6000COFF_C | 4833 | 13.4k | case C_GSYM: | 4834 | 13.5k | case C_LSYM: | 4835 | 13.6k | case C_PSYM: | 4836 | 13.7k | case C_RSYM: | 4837 | 13.9k | case C_RPSYM: | 4838 | 14.0k | case C_STSYM: | 4839 | 14.0k | case C_TCSYM: | 4840 | 14.0k | case C_BCOMM: | 4841 | 14.2k | case C_ECOML: | 4842 | 14.4k | case C_ECOMM: | 4843 | 14.6k | case C_DECL: | 4844 | 14.7k | case C_ENTRY: | 4845 | 14.7k | case C_FUN: | 4846 | 15.3k | case C_ESTAT: | 4847 | 15.3k | #endif | 4848 | 15.3k | dst->symbol.flags |= BSF_DEBUGGING; | 4849 | 15.3k | dst->symbol.value = (src->u.syment.n_value); | 4850 | 15.3k | break; | 4851 | | | 4852 | 0 | #ifdef RS6000COFF_C | 4853 | 384 | case C_BINCL: /* Beginning of include file. */ | 4854 | 469 | case C_EINCL: /* Ending of include file. */ | 4855 | | /* The value is actually a pointer into the line numbers | 4856 | | of the file. We locate the line number entry, and | 4857 | | set the section to the section which contains it, and | 4858 | | the value to the index in that section. */ | 4859 | 469 | { | 4860 | 469 | asection *sec; | 4861 | | | 4862 | 469 | dst->symbol.flags = BSF_DEBUGGING; | 4863 | 27.7k | for (sec = abfd->sections; sec != NULL; sec = sec->next) | 4864 | 27.5k | if (sec->line_filepos <= (file_ptr) src->u.syment.n_value | 4865 | 27.5k | && ((file_ptr) (sec->line_filepos | 4866 | 16.8k | + sec->lineno_count * bfd_coff_linesz (abfd)) | 4867 | 16.8k | > (file_ptr) src->u.syment.n_value)) | 4868 | 215 | break; | 4869 | 469 | if (sec == NULL) | 4870 | 254 | dst->symbol.value = 0; | 4871 | 215 | else | 4872 | 215 | { | 4873 | 215 | dst->symbol.section = sec; | 4874 | 215 | dst->symbol.value = ((src->u.syment.n_value | 4875 | 215 | - sec->line_filepos) | 4876 | 215 | / bfd_coff_linesz (abfd)); | 4877 | 215 | src->fix_line = 1; | 4878 | 215 | } | 4879 | 469 | } | 4880 | 469 | break; | 4881 | | | 4882 | 24 | case C_BSTAT: | 4883 | 24 | dst->symbol.flags = BSF_DEBUGGING; | 4884 | | | 4885 | 24 | if (src->u.syment.n_value >= obj_raw_syment_count (abfd)) | 4886 | 22 | dst->symbol.value = 0; | 4887 | 2 | else | 4888 | 2 | { | 4889 | | /* The value is actually a symbol index. Save a pointer | 4890 | | to the symbol instead of the index. FIXME: This | 4891 | | should use a union. */ | 4892 | 2 | src->u.syment.n_value | 4893 | 2 | = (uintptr_t) (native_symbols + src->u.syment.n_value); | 4894 | 2 | dst->symbol.value = src->u.syment.n_value; | 4895 | 2 | src->fix_value = 1; | 4896 | 2 | } | 4897 | 24 | break; | 4898 | 0 | #endif | 4899 | | | 4900 | 78 | case C_BLOCK: /* ".bb" or ".eb". */ | 4901 | 231 | case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */ | 4902 | 551 | case C_EFCN: /* Physical end of function. */ | 4903 | | #if defined COFF_WITH_PE | 4904 | | /* PE sets the symbol to a value relative to the start | 4905 | | of the section. */ | 4906 | | dst->symbol.value = src->u.syment.n_value; | 4907 | | if (strcmp (dst->symbol.name, ".bf") != 0) | 4908 | | { | 4909 | | /* PE uses funny values for .ef and .lf; don't | 4910 | | relocate them. */ | 4911 | | dst->symbol.flags = BSF_DEBUGGING; | 4912 | | } | 4913 | | else | 4914 | | dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC; | 4915 | | #else | 4916 | | /* Base the value as an index from the base of the | 4917 | | section. */ | 4918 | 551 | dst->symbol.flags = BSF_LOCAL; | 4919 | 551 | dst->symbol.value = (src->u.syment.n_value | 4920 | 551 | - dst->symbol.section->vma); | 4921 | 551 | #endif | 4922 | 551 | break; | 4923 | | | 4924 | 102 | case C_STATLAB: /* Static load time label. */ | 4925 | 102 | dst->symbol.value = src->u.syment.n_value; | 4926 | 102 | dst->symbol.flags = BSF_GLOBAL; | 4927 | 102 | break; | 4928 | | | 4929 | 93.6k | case C_NULL: | 4930 | | /* PE DLLs sometimes have zeroed out symbols for some | 4931 | | reason. Just ignore them without a warning. */ | 4932 | 93.6k | if (src->u.syment.n_type == 0 | 4933 | 93.6k | && src->u.syment.n_value == 0 | 4934 | 93.6k | && src->u.syment.n_scnum == 0) | 4935 | 23.2k | break; | 4936 | 70.4k | #ifdef RS6000COFF_C | 4937 | | /* XCOFF specific: deleted entry. */ | 4938 | 70.4k | if (src->u.syment.n_value == C_NULL_VALUE) | 4939 | 1 | break; | 4940 | 70.4k | #endif | 4941 | | /* Fall through. */ | 4942 | 70.5k | case C_EXTDEF: /* External definition. */ | 4943 | 70.8k | case C_ULABEL: /* Undefined label. */ | 4944 | 70.9k | case C_USTATIC: /* Undefined static. */ | 4945 | 70.9k | #ifndef COFF_WITH_PE | 4946 | | /* C_LINE in regular coff is 0x68. NT has taken over this storage | 4947 | | class to represent a section symbol. */ | 4948 | 71.0k | case C_LINE: /* line # reformatted as symbol table entry. */ | 4949 | | /* NT uses 0x67 for a weak symbol, not C_ALIAS. */ | 4950 | 71.0k | case C_ALIAS: /* Duplicate tag. */ | 4951 | 71.0k | #endif | 4952 | | /* New storage classes for TI COFF. */ | 4953 | | #ifdef TICOFF | 4954 | | case C_UEXT: /* Tentative external definition. */ | 4955 | | #endif | 4956 | 71.1k | case C_EXTLAB: /* External load time label. */ | 4957 | 85.6k | default: | 4958 | 85.6k | _bfd_error_handler | 4959 | | /* xgettext:c-format */ | 4960 | 85.6k | (_("%pB: unrecognized storage class %d for %s symbol `%s'"), | 4961 | 85.6k | abfd, src->u.syment.n_sclass, | 4962 | 85.6k | dst->symbol.section->name, dst->symbol.name); | 4963 | 85.6k | ret = false; | 4964 | | /* Fall through. */ | 4965 | 85.8k | case C_HIDDEN: /* Ext symbol in dmert public lib. */ | 4966 | | /* PR 20722: These symbols can also be generated by | 4967 | | building DLLs with --gc-sections enabled. */ | 4968 | 85.8k | dst->symbol.flags = BSF_DEBUGGING; | 4969 | 85.8k | dst->symbol.value = (src->u.syment.n_value); | 4970 | 85.8k | break; | 4971 | 131k | } | 4972 | | | 4973 | 131k | dst->native = src; | 4974 | 131k | dst->symbol.udata.i = 0; | 4975 | 131k | dst->lineno = NULL; | 4976 | | | 4977 | 131k | this_index += (src->u.syment.n_numaux) + 1; | 4978 | 131k | dst++; | 4979 | 131k | number_of_symbols++; | 4980 | 131k | } | 4981 | 335 | } | 4982 | | | 4983 | 335 | obj_symbols (abfd) = cached_area; | 4984 | 335 | obj_raw_syments (abfd) = native_symbols; | 4985 | | | 4986 | 335 | abfd->symcount = number_of_symbols; | 4987 | 335 | obj_convert (abfd) = table_ptr; | 4988 | | /* Slurp the line tables for each section too. */ | 4989 | 335 | { | 4990 | 335 | asection *p; | 4991 | | | 4992 | 335 | p = abfd->sections; | 4993 | 1.27k | while (p) | 4994 | 1.22k | { | 4995 | 1.22k | if (! coff_slurp_line_table (abfd, p)) | 4996 | 288 | return false; | 4997 | 936 | p = p->next; | 4998 | 936 | } | 4999 | 335 | } | 5000 | | | 5001 | 47 | return ret; | 5002 | 335 | } |
pei-aarch64.c:coff_slurp_symbol_table Line | Count | Source | 4630 | 236 | { | 4631 | 236 | combined_entry_type *native_symbols; | 4632 | 236 | coff_symbol_type *cached_area; | 4633 | 236 | unsigned int *table_ptr; | 4634 | 236 | unsigned int number_of_symbols = 0; | 4635 | 236 | bool ret = true; | 4636 | 236 | size_t amt; | 4637 | | | 4638 | 236 | if (obj_symbols (abfd)) | 4639 | 38 | return true; | 4640 | | | 4641 | | /* Read in the symbol table. */ | 4642 | 198 | if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) | 4643 | 86 | return false; | 4644 | | | 4645 | | /* Allocate enough room for all the symbols in cached form. */ | 4646 | 112 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4647 | 112 | sizeof (*cached_area), &amt)) | 4648 | 0 | { | 4649 | 0 | bfd_set_error (bfd_error_file_too_big); | 4650 | 0 | return false; | 4651 | 0 | } | 4652 | 112 | cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt); | 4653 | 112 | if (cached_area == NULL) | 4654 | 0 | return false; | 4655 | | | 4656 | 112 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4657 | 112 | sizeof (*table_ptr), &amt)) | 4658 | 0 | { | 4659 | 0 | bfd_set_error (bfd_error_file_too_big); | 4660 | 0 | return false; | 4661 | 0 | } | 4662 | 112 | table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); | 4663 | 112 | if (table_ptr == NULL) | 4664 | 0 | return false; | 4665 | 112 | else | 4666 | 112 | { | 4667 | 112 | coff_symbol_type *dst = cached_area; | 4668 | 112 | unsigned int last_native_index = obj_raw_syment_count (abfd); | 4669 | 112 | unsigned int this_index = 0; | 4670 | | | 4671 | 4.12k | while (this_index < last_native_index) | 4672 | 4.01k | { | 4673 | 4.01k | combined_entry_type *src = native_symbols + this_index; | 4674 | 4.01k | table_ptr[this_index] = number_of_symbols; | 4675 | | | 4676 | 4.01k | dst->symbol.the_bfd = abfd; | 4677 | 4.01k | BFD_ASSERT (src->is_sym); | 4678 | 4.01k | dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset); | 4679 | | /* We use the native name field to point to the cached field. */ | 4680 | 4.01k | src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; | 4681 | 4.01k | dst->symbol.section = coff_section_from_bfd_index (abfd, | 4682 | 4.01k | src->u.syment.n_scnum); | 4683 | 4.01k | dst->symbol.flags = 0; | 4684 | | /* PR 17512: file: 079-7098-0.001:0.1. */ | 4685 | 4.01k | dst->symbol.value = 0; | 4686 | 4.01k | dst->done_lineno = false; | 4687 | | | 4688 | 4.01k | switch (src->u.syment.n_sclass) | 4689 | 4.01k | { | 4690 | 89 | case C_EXT: | 4691 | 90 | case C_WEAKEXT: | 4692 | | #if defined ARM | 4693 | | case C_THUMBEXT: | 4694 | | case C_THUMBEXTFUNC: | 4695 | | #endif | 4696 | | #ifdef RS6000COFF_C | 4697 | | case C_HIDEXT: | 4698 | | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 4699 | | case C_AIX_WEAKEXT: | 4700 | | #endif | 4701 | | #endif | 4702 | 90 | #ifdef C_SYSTEM | 4703 | 123 | case C_SYSTEM: /* System Wide variable. */ | 4704 | 123 | #endif | 4705 | 123 | #ifdef COFF_WITH_PE | 4706 | | /* In PE, 0x68 (104) denotes a section symbol. */ | 4707 | 128 | case C_SECTION: | 4708 | | /* In PE, 0x69 (105) denotes a weak external symbol. */ | 4709 | 137 | case C_NT_WEAK: | 4710 | 137 | #endif | 4711 | 137 | switch (coff_classify_symbol (abfd, &src->u.syment)) | 4712 | 137 | { | 4713 | 110 | case COFF_SYMBOL_GLOBAL: | 4714 | 110 | dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL; | 4715 | 110 | #if defined COFF_WITH_PE | 4716 | | /* PE sets the symbol to a value relative to the | 4717 | | start of the section. */ | 4718 | 110 | dst->symbol.value = src->u.syment.n_value; | 4719 | | #else | 4720 | | dst->symbol.value = (src->u.syment.n_value | 4721 | | - dst->symbol.section->vma); | 4722 | | #endif | 4723 | 110 | if (ISFCN ((src->u.syment.n_type))) | 4724 | | /* A function ext does not go at the end of a | 4725 | | file. */ | 4726 | 19 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4727 | 110 | break; | 4728 | | | 4729 | 10 | case COFF_SYMBOL_COMMON: | 4730 | 10 | dst->symbol.section = bfd_com_section_ptr; | 4731 | 10 | dst->symbol.value = src->u.syment.n_value; | 4732 | 10 | break; | 4733 | | | 4734 | 17 | case COFF_SYMBOL_UNDEFINED: | 4735 | 17 | dst->symbol.section = bfd_und_section_ptr; | 4736 | 17 | dst->symbol.value = 0; | 4737 | 17 | break; | 4738 | | | 4739 | 0 | case COFF_SYMBOL_PE_SECTION: | 4740 | 0 | dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM; | 4741 | 0 | dst->symbol.value = 0; | 4742 | 0 | break; | 4743 | | | 4744 | 0 | case COFF_SYMBOL_LOCAL: | 4745 | 0 | dst->symbol.flags = BSF_LOCAL; | 4746 | 0 | #if defined COFF_WITH_PE | 4747 | | /* PE sets the symbol to a value relative to the | 4748 | | start of the section. */ | 4749 | 0 | dst->symbol.value = src->u.syment.n_value; | 4750 | | #else | 4751 | | dst->symbol.value = (src->u.syment.n_value | 4752 | | - dst->symbol.section->vma); | 4753 | | #endif | 4754 | 0 | if (ISFCN ((src->u.syment.n_type))) | 4755 | 0 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4756 | 0 | break; | 4757 | 137 | } | 4758 | | | 4759 | | #ifdef RS6000COFF_C | 4760 | | /* A symbol with a csect entry should not go at the end. */ | 4761 | | if (src->u.syment.n_numaux > 0) | 4762 | | dst->symbol.flags |= BSF_NOT_AT_END; | 4763 | | #endif | 4764 | | | 4765 | 137 | #ifdef COFF_WITH_PE | 4766 | 137 | if (src->u.syment.n_sclass == C_NT_WEAK) | 4767 | 9 | dst->symbol.flags |= BSF_WEAK; | 4768 | | | 4769 | 137 | if (src->u.syment.n_sclass == C_SECTION | 4770 | 137 | && src->u.syment.n_scnum > 0) | 4771 | 0 | dst->symbol.flags = BSF_LOCAL; | 4772 | 137 | #endif | 4773 | 137 | if (src->u.syment.n_sclass == C_WEAKEXT | 4774 | | #ifdef RS6000COFF_C | 4775 | | || src->u.syment.n_sclass == C_AIX_WEAKEXT | 4776 | | #endif | 4777 | 137 | ) | 4778 | 1 | dst->symbol.flags |= BSF_WEAK; | 4779 | | | 4780 | 137 | break; | 4781 | | | 4782 | 59 | case C_STAT: /* Static. */ | 4783 | | #if defined ARM | 4784 | | case C_THUMBSTAT: /* Thumb static. */ | 4785 | | case C_THUMBLABEL: /* Thumb label. */ | 4786 | | case C_THUMBSTATFUNC:/* Thumb static function. */ | 4787 | | #endif | 4788 | | #ifdef RS6000COFF_C | 4789 | | case C_DWARF: /* A label in a dwarf section. */ | 4790 | | case C_INFO: /* A label in a comment section. */ | 4791 | | #endif | 4792 | 83 | case C_LABEL: /* Label. */ | 4793 | 83 | if (src->u.syment.n_scnum == N_DEBUG) | 4794 | 0 | dst->symbol.flags = BSF_DEBUGGING; | 4795 | 83 | else | 4796 | 83 | dst->symbol.flags = BSF_LOCAL; | 4797 | | | 4798 | | /* Base the value as an index from the base of the | 4799 | | section, if there is one. */ | 4800 | 83 | if (dst->symbol.section) | 4801 | 83 | { | 4802 | 83 | #if defined COFF_WITH_PE | 4803 | | /* PE sets the symbol to a value relative to the | 4804 | | start of the section. */ | 4805 | 83 | dst->symbol.value = src->u.syment.n_value; | 4806 | | #else | 4807 | | dst->symbol.value = (src->u.syment.n_value | 4808 | | - dst->symbol.section->vma); | 4809 | | #endif | 4810 | 83 | } | 4811 | 0 | else | 4812 | 0 | dst->symbol.value = src->u.syment.n_value; | 4813 | 83 | break; | 4814 | | | 4815 | 43 | case C_FILE: /* File name. */ | 4816 | 43 | dst->symbol.flags = BSF_FILE; | 4817 | | /* Fall through. */ | 4818 | 98 | case C_MOS: /* Member of structure. */ | 4819 | 104 | case C_EOS: /* End of structure. */ | 4820 | 132 | case C_REGPARM: /* Register parameter. */ | 4821 | 164 | case C_REG: /* register variable. */ | 4822 | | /* C_AUTOARG conflicts with TI COFF C_UEXT. */ | 4823 | 200 | case C_TPDEF: /* Type definition. */ | 4824 | 219 | case C_ARG: | 4825 | 601 | case C_AUTO: /* Automatic variable. */ | 4826 | 625 | case C_FIELD: /* Bit field. */ | 4827 | 629 | case C_ENTAG: /* Enumeration tag. */ | 4828 | 662 | case C_MOE: /* Member of enumeration. */ | 4829 | 665 | case C_MOU: /* Member of union. */ | 4830 | 686 | case C_UNTAG: /* Union tag. */ | 4831 | 713 | case C_STRTAG: /* Structure tag. */ | 4832 | | #ifdef RS6000COFF_C | 4833 | | case C_GSYM: | 4834 | | case C_LSYM: | 4835 | | case C_PSYM: | 4836 | | case C_RSYM: | 4837 | | case C_RPSYM: | 4838 | | case C_STSYM: | 4839 | | case C_TCSYM: | 4840 | | case C_BCOMM: | 4841 | | case C_ECOML: | 4842 | | case C_ECOMM: | 4843 | | case C_DECL: | 4844 | | case C_ENTRY: | 4845 | | case C_FUN: | 4846 | | case C_ESTAT: | 4847 | | #endif | 4848 | 713 | dst->symbol.flags |= BSF_DEBUGGING; | 4849 | 713 | dst->symbol.value = (src->u.syment.n_value); | 4850 | 713 | break; | 4851 | | | 4852 | | #ifdef RS6000COFF_C | 4853 | | case C_BINCL: /* Beginning of include file. */ | 4854 | | case C_EINCL: /* Ending of include file. */ | 4855 | | /* The value is actually a pointer into the line numbers | 4856 | | of the file. We locate the line number entry, and | 4857 | | set the section to the section which contains it, and | 4858 | | the value to the index in that section. */ | 4859 | | { | 4860 | | asection *sec; | 4861 | | | 4862 | | dst->symbol.flags = BSF_DEBUGGING; | 4863 | | for (sec = abfd->sections; sec != NULL; sec = sec->next) | 4864 | | if (sec->line_filepos <= (file_ptr) src->u.syment.n_value | 4865 | | && ((file_ptr) (sec->line_filepos | 4866 | | + sec->lineno_count * bfd_coff_linesz (abfd)) | 4867 | | > (file_ptr) src->u.syment.n_value)) | 4868 | | break; | 4869 | | if (sec == NULL) | 4870 | | dst->symbol.value = 0; | 4871 | | else | 4872 | | { | 4873 | | dst->symbol.section = sec; | 4874 | | dst->symbol.value = ((src->u.syment.n_value | 4875 | | - sec->line_filepos) | 4876 | | / bfd_coff_linesz (abfd)); | 4877 | | src->fix_line = 1; | 4878 | | } | 4879 | | } | 4880 | | break; | 4881 | | | 4882 | | case C_BSTAT: | 4883 | | dst->symbol.flags = BSF_DEBUGGING; | 4884 | | | 4885 | | if (src->u.syment.n_value >= obj_raw_syment_count (abfd)) | 4886 | | dst->symbol.value = 0; | 4887 | | else | 4888 | | { | 4889 | | /* The value is actually a symbol index. Save a pointer | 4890 | | to the symbol instead of the index. FIXME: This | 4891 | | should use a union. */ | 4892 | | src->u.syment.n_value | 4893 | | = (uintptr_t) (native_symbols + src->u.syment.n_value); | 4894 | | dst->symbol.value = src->u.syment.n_value; | 4895 | | src->fix_value = 1; | 4896 | | } | 4897 | | break; | 4898 | | #endif | 4899 | | | 4900 | 2 | case C_BLOCK: /* ".bb" or ".eb". */ | 4901 | 31 | case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */ | 4902 | 47 | case C_EFCN: /* Physical end of function. */ | 4903 | 47 | #if defined COFF_WITH_PE | 4904 | | /* PE sets the symbol to a value relative to the start | 4905 | | of the section. */ | 4906 | 47 | dst->symbol.value = src->u.syment.n_value; | 4907 | 47 | if (strcmp (dst->symbol.name, ".bf") != 0) | 4908 | 47 | { | 4909 | | /* PE uses funny values for .ef and .lf; don't | 4910 | | relocate them. */ | 4911 | 47 | dst->symbol.flags = BSF_DEBUGGING; | 4912 | 47 | } | 4913 | 0 | else | 4914 | 0 | dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC; | 4915 | | #else | 4916 | | /* Base the value as an index from the base of the | 4917 | | section. */ | 4918 | | dst->symbol.flags = BSF_LOCAL; | 4919 | | dst->symbol.value = (src->u.syment.n_value | 4920 | | - dst->symbol.section->vma); | 4921 | | #endif | 4922 | 47 | break; | 4923 | | | 4924 | 10 | case C_STATLAB: /* Static load time label. */ | 4925 | 10 | dst->symbol.value = src->u.syment.n_value; | 4926 | 10 | dst->symbol.flags = BSF_GLOBAL; | 4927 | 10 | break; | 4928 | | | 4929 | 2.47k | case C_NULL: | 4930 | | /* PE DLLs sometimes have zeroed out symbols for some | 4931 | | reason. Just ignore them without a warning. */ | 4932 | 2.47k | if (src->u.syment.n_type == 0 | 4933 | 2.47k | && src->u.syment.n_value == 0 | 4934 | 2.47k | && src->u.syment.n_scnum == 0) | 4935 | 949 | break; | 4936 | | #ifdef RS6000COFF_C | 4937 | | /* XCOFF specific: deleted entry. */ | 4938 | | if (src->u.syment.n_value == C_NULL_VALUE) | 4939 | | break; | 4940 | | #endif | 4941 | | /* Fall through. */ | 4942 | 1.53k | case C_EXTDEF: /* External definition. */ | 4943 | 1.55k | case C_ULABEL: /* Undefined label. */ | 4944 | 1.55k | case C_USTATIC: /* Undefined static. */ | 4945 | | #ifndef COFF_WITH_PE | 4946 | | /* C_LINE in regular coff is 0x68. NT has taken over this storage | 4947 | | class to represent a section symbol. */ | 4948 | | case C_LINE: /* line # reformatted as symbol table entry. */ | 4949 | | /* NT uses 0x67 for a weak symbol, not C_ALIAS. */ | 4950 | | case C_ALIAS: /* Duplicate tag. */ | 4951 | | #endif | 4952 | | /* New storage classes for TI COFF. */ | 4953 | | #ifdef TICOFF | 4954 | | case C_UEXT: /* Tentative external definition. */ | 4955 | | #endif | 4956 | 1.55k | case C_EXTLAB: /* External load time label. */ | 4957 | 2.06k | default: | 4958 | 2.06k | _bfd_error_handler | 4959 | | /* xgettext:c-format */ | 4960 | 2.06k | (_("%pB: unrecognized storage class %d for %s symbol `%s'"), | 4961 | 2.06k | abfd, src->u.syment.n_sclass, | 4962 | 2.06k | dst->symbol.section->name, dst->symbol.name); | 4963 | 2.06k | ret = false; | 4964 | | /* Fall through. */ | 4965 | 2.07k | case C_HIDDEN: /* Ext symbol in dmert public lib. */ | 4966 | | /* PR 20722: These symbols can also be generated by | 4967 | | building DLLs with --gc-sections enabled. */ | 4968 | 2.07k | dst->symbol.flags = BSF_DEBUGGING; | 4969 | 2.07k | dst->symbol.value = (src->u.syment.n_value); | 4970 | 2.07k | break; | 4971 | 4.01k | } | 4972 | | | 4973 | 4.01k | dst->native = src; | 4974 | 4.01k | dst->symbol.udata.i = 0; | 4975 | 4.01k | dst->lineno = NULL; | 4976 | | | 4977 | 4.01k | this_index += (src->u.syment.n_numaux) + 1; | 4978 | 4.01k | dst++; | 4979 | 4.01k | number_of_symbols++; | 4980 | 4.01k | } | 4981 | 112 | } | 4982 | | | 4983 | 112 | obj_symbols (abfd) = cached_area; | 4984 | 112 | obj_raw_syments (abfd) = native_symbols; | 4985 | | | 4986 | 112 | abfd->symcount = number_of_symbols; | 4987 | 112 | obj_convert (abfd) = table_ptr; | 4988 | | /* Slurp the line tables for each section too. */ | 4989 | 112 | { | 4990 | 112 | asection *p; | 4991 | | | 4992 | 112 | p = abfd->sections; | 4993 | 331 | while (p) | 4994 | 303 | { | 4995 | 303 | if (! coff_slurp_line_table (abfd, p)) | 4996 | 84 | return false; | 4997 | 219 | p = p->next; | 4998 | 219 | } | 4999 | 112 | } | 5000 | | | 5001 | 28 | return ret; | 5002 | 112 | } |
pe-aarch64.c:coff_slurp_symbol_table Line | Count | Source | 4630 | 1.90k | { | 4631 | 1.90k | combined_entry_type *native_symbols; | 4632 | 1.90k | coff_symbol_type *cached_area; | 4633 | 1.90k | unsigned int *table_ptr; | 4634 | 1.90k | unsigned int number_of_symbols = 0; | 4635 | 1.90k | bool ret = true; | 4636 | 1.90k | size_t amt; | 4637 | | | 4638 | 1.90k | if (obj_symbols (abfd)) | 4639 | 1.55k | return true; | 4640 | | | 4641 | | /* Read in the symbol table. */ | 4642 | 348 | if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) | 4643 | 81 | return false; | 4644 | | | 4645 | | /* Allocate enough room for all the symbols in cached form. */ | 4646 | 267 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4647 | 267 | sizeof (*cached_area), &amt)) | 4648 | 0 | { | 4649 | 0 | bfd_set_error (bfd_error_file_too_big); | 4650 | 0 | return false; | 4651 | 0 | } | 4652 | 267 | cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt); | 4653 | 267 | if (cached_area == NULL) | 4654 | 0 | return false; | 4655 | | | 4656 | 267 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4657 | 267 | sizeof (*table_ptr), &amt)) | 4658 | 0 | { | 4659 | 0 | bfd_set_error (bfd_error_file_too_big); | 4660 | 0 | return false; | 4661 | 0 | } | 4662 | 267 | table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); | 4663 | 267 | if (table_ptr == NULL) | 4664 | 0 | return false; | 4665 | 267 | else | 4666 | 267 | { | 4667 | 267 | coff_symbol_type *dst = cached_area; | 4668 | 267 | unsigned int last_native_index = obj_raw_syment_count (abfd); | 4669 | 267 | unsigned int this_index = 0; | 4670 | | | 4671 | 56.5k | while (this_index < last_native_index) | 4672 | 56.3k | { | 4673 | 56.3k | combined_entry_type *src = native_symbols + this_index; | 4674 | 56.3k | table_ptr[this_index] = number_of_symbols; | 4675 | | | 4676 | 56.3k | dst->symbol.the_bfd = abfd; | 4677 | 56.3k | BFD_ASSERT (src->is_sym); | 4678 | 56.3k | dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset); | 4679 | | /* We use the native name field to point to the cached field. */ | 4680 | 56.3k | src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; | 4681 | 56.3k | dst->symbol.section = coff_section_from_bfd_index (abfd, | 4682 | 56.3k | src->u.syment.n_scnum); | 4683 | 56.3k | dst->symbol.flags = 0; | 4684 | | /* PR 17512: file: 079-7098-0.001:0.1. */ | 4685 | 56.3k | dst->symbol.value = 0; | 4686 | 56.3k | dst->done_lineno = false; | 4687 | | | 4688 | 56.3k | switch (src->u.syment.n_sclass) | 4689 | 56.3k | { | 4690 | 526 | case C_EXT: | 4691 | 543 | case C_WEAKEXT: | 4692 | | #if defined ARM | 4693 | | case C_THUMBEXT: | 4694 | | case C_THUMBEXTFUNC: | 4695 | | #endif | 4696 | | #ifdef RS6000COFF_C | 4697 | | case C_HIDEXT: | 4698 | | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 4699 | | case C_AIX_WEAKEXT: | 4700 | | #endif | 4701 | | #endif | 4702 | 543 | #ifdef C_SYSTEM | 4703 | 605 | case C_SYSTEM: /* System Wide variable. */ | 4704 | 605 | #endif | 4705 | 605 | #ifdef COFF_WITH_PE | 4706 | | /* In PE, 0x68 (104) denotes a section symbol. */ | 4707 | 621 | case C_SECTION: | 4708 | | /* In PE, 0x69 (105) denotes a weak external symbol. */ | 4709 | 680 | case C_NT_WEAK: | 4710 | 680 | #endif | 4711 | 680 | switch (coff_classify_symbol (abfd, &src->u.syment)) | 4712 | 680 | { | 4713 | 554 | case COFF_SYMBOL_GLOBAL: | 4714 | 554 | dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL; | 4715 | 554 | #if defined COFF_WITH_PE | 4716 | | /* PE sets the symbol to a value relative to the | 4717 | | start of the section. */ | 4718 | 554 | dst->symbol.value = src->u.syment.n_value; | 4719 | | #else | 4720 | | dst->symbol.value = (src->u.syment.n_value | 4721 | | - dst->symbol.section->vma); | 4722 | | #endif | 4723 | 554 | if (ISFCN ((src->u.syment.n_type))) | 4724 | | /* A function ext does not go at the end of a | 4725 | | file. */ | 4726 | 28 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4727 | 554 | break; | 4728 | | | 4729 | 95 | case COFF_SYMBOL_COMMON: | 4730 | 95 | dst->symbol.section = bfd_com_section_ptr; | 4731 | 95 | dst->symbol.value = src->u.syment.n_value; | 4732 | 95 | break; | 4733 | | | 4734 | 31 | case COFF_SYMBOL_UNDEFINED: | 4735 | 31 | dst->symbol.section = bfd_und_section_ptr; | 4736 | 31 | dst->symbol.value = 0; | 4737 | 31 | break; | 4738 | | | 4739 | 0 | case COFF_SYMBOL_PE_SECTION: | 4740 | 0 | dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM; | 4741 | 0 | dst->symbol.value = 0; | 4742 | 0 | break; | 4743 | | | 4744 | 0 | case COFF_SYMBOL_LOCAL: | 4745 | 0 | dst->symbol.flags = BSF_LOCAL; | 4746 | 0 | #if defined COFF_WITH_PE | 4747 | | /* PE sets the symbol to a value relative to the | 4748 | | start of the section. */ | 4749 | 0 | dst->symbol.value = src->u.syment.n_value; | 4750 | | #else | 4751 | | dst->symbol.value = (src->u.syment.n_value | 4752 | | - dst->symbol.section->vma); | 4753 | | #endif | 4754 | 0 | if (ISFCN ((src->u.syment.n_type))) | 4755 | 0 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4756 | 0 | break; | 4757 | 680 | } | 4758 | | | 4759 | | #ifdef RS6000COFF_C | 4760 | | /* A symbol with a csect entry should not go at the end. */ | 4761 | | if (src->u.syment.n_numaux > 0) | 4762 | | dst->symbol.flags |= BSF_NOT_AT_END; | 4763 | | #endif | 4764 | | | 4765 | 680 | #ifdef COFF_WITH_PE | 4766 | 680 | if (src->u.syment.n_sclass == C_NT_WEAK) | 4767 | 59 | dst->symbol.flags |= BSF_WEAK; | 4768 | | | 4769 | 680 | if (src->u.syment.n_sclass == C_SECTION | 4770 | 680 | && src->u.syment.n_scnum > 0) | 4771 | 0 | dst->symbol.flags = BSF_LOCAL; | 4772 | 680 | #endif | 4773 | 680 | if (src->u.syment.n_sclass == C_WEAKEXT | 4774 | | #ifdef RS6000COFF_C | 4775 | | || src->u.syment.n_sclass == C_AIX_WEAKEXT | 4776 | | #endif | 4777 | 680 | ) | 4778 | 17 | dst->symbol.flags |= BSF_WEAK; | 4779 | | | 4780 | 680 | break; | 4781 | | | 4782 | 196 | case C_STAT: /* Static. */ | 4783 | | #if defined ARM | 4784 | | case C_THUMBSTAT: /* Thumb static. */ | 4785 | | case C_THUMBLABEL: /* Thumb label. */ | 4786 | | case C_THUMBSTATFUNC:/* Thumb static function. */ | 4787 | | #endif | 4788 | | #ifdef RS6000COFF_C | 4789 | | case C_DWARF: /* A label in a dwarf section. */ | 4790 | | case C_INFO: /* A label in a comment section. */ | 4791 | | #endif | 4792 | 414 | case C_LABEL: /* Label. */ | 4793 | 414 | if (src->u.syment.n_scnum == N_DEBUG) | 4794 | 0 | dst->symbol.flags = BSF_DEBUGGING; | 4795 | 414 | else | 4796 | 414 | dst->symbol.flags = BSF_LOCAL; | 4797 | | | 4798 | | /* Base the value as an index from the base of the | 4799 | | section, if there is one. */ | 4800 | 414 | if (dst->symbol.section) | 4801 | 414 | { | 4802 | 414 | #if defined COFF_WITH_PE | 4803 | | /* PE sets the symbol to a value relative to the | 4804 | | start of the section. */ | 4805 | 414 | dst->symbol.value = src->u.syment.n_value; | 4806 | | #else | 4807 | | dst->symbol.value = (src->u.syment.n_value | 4808 | | - dst->symbol.section->vma); | 4809 | | #endif | 4810 | 414 | } | 4811 | 0 | else | 4812 | 0 | dst->symbol.value = src->u.syment.n_value; | 4813 | 414 | break; | 4814 | | | 4815 | 140 | case C_FILE: /* File name. */ | 4816 | 140 | dst->symbol.flags = BSF_FILE; | 4817 | | /* Fall through. */ | 4818 | 309 | case C_MOS: /* Member of structure. */ | 4819 | 337 | case C_EOS: /* End of structure. */ | 4820 | 592 | case C_REGPARM: /* Register parameter. */ | 4821 | 1.89k | case C_REG: /* register variable. */ | 4822 | | /* C_AUTOARG conflicts with TI COFF C_UEXT. */ | 4823 | 1.94k | case C_TPDEF: /* Type definition. */ | 4824 | 2.53k | case C_ARG: | 4825 | 4.64k | case C_AUTO: /* Automatic variable. */ | 4826 | 4.71k | case C_FIELD: /* Bit field. */ | 4827 | 4.76k | case C_ENTAG: /* Enumeration tag. */ | 4828 | 5.42k | case C_MOE: /* Member of enumeration. */ | 4829 | 5.47k | case C_MOU: /* Member of union. */ | 4830 | 5.74k | case C_UNTAG: /* Union tag. */ | 4831 | 6.14k | case C_STRTAG: /* Structure tag. */ | 4832 | | #ifdef RS6000COFF_C | 4833 | | case C_GSYM: | 4834 | | case C_LSYM: | 4835 | | case C_PSYM: | 4836 | | case C_RSYM: | 4837 | | case C_RPSYM: | 4838 | | case C_STSYM: | 4839 | | case C_TCSYM: | 4840 | | case C_BCOMM: | 4841 | | case C_ECOML: | 4842 | | case C_ECOMM: | 4843 | | case C_DECL: | 4844 | | case C_ENTRY: | 4845 | | case C_FUN: | 4846 | | case C_ESTAT: | 4847 | | #endif | 4848 | 6.14k | dst->symbol.flags |= BSF_DEBUGGING; | 4849 | 6.14k | dst->symbol.value = (src->u.syment.n_value); | 4850 | 6.14k | break; | 4851 | | | 4852 | | #ifdef RS6000COFF_C | 4853 | | case C_BINCL: /* Beginning of include file. */ | 4854 | | case C_EINCL: /* Ending of include file. */ | 4855 | | /* The value is actually a pointer into the line numbers | 4856 | | of the file. We locate the line number entry, and | 4857 | | set the section to the section which contains it, and | 4858 | | the value to the index in that section. */ | 4859 | | { | 4860 | | asection *sec; | 4861 | | | 4862 | | dst->symbol.flags = BSF_DEBUGGING; | 4863 | | for (sec = abfd->sections; sec != NULL; sec = sec->next) | 4864 | | if (sec->line_filepos <= (file_ptr) src->u.syment.n_value | 4865 | | && ((file_ptr) (sec->line_filepos | 4866 | | + sec->lineno_count * bfd_coff_linesz (abfd)) | 4867 | | > (file_ptr) src->u.syment.n_value)) | 4868 | | break; | 4869 | | if (sec == NULL) | 4870 | | dst->symbol.value = 0; | 4871 | | else | 4872 | | { | 4873 | | dst->symbol.section = sec; | 4874 | | dst->symbol.value = ((src->u.syment.n_value | 4875 | | - sec->line_filepos) | 4876 | | / bfd_coff_linesz (abfd)); | 4877 | | src->fix_line = 1; | 4878 | | } | 4879 | | } | 4880 | | break; | 4881 | | | 4882 | | case C_BSTAT: | 4883 | | dst->symbol.flags = BSF_DEBUGGING; | 4884 | | | 4885 | | if (src->u.syment.n_value >= obj_raw_syment_count (abfd)) | 4886 | | dst->symbol.value = 0; | 4887 | | else | 4888 | | { | 4889 | | /* The value is actually a symbol index. Save a pointer | 4890 | | to the symbol instead of the index. FIXME: This | 4891 | | should use a union. */ | 4892 | | src->u.syment.n_value | 4893 | | = (uintptr_t) (native_symbols + src->u.syment.n_value); | 4894 | | dst->symbol.value = src->u.syment.n_value; | 4895 | | src->fix_value = 1; | 4896 | | } | 4897 | | break; | 4898 | | #endif | 4899 | | | 4900 | 33 | case C_BLOCK: /* ".bb" or ".eb". */ | 4901 | 123 | case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */ | 4902 | 265 | case C_EFCN: /* Physical end of function. */ | 4903 | 265 | #if defined COFF_WITH_PE | 4904 | | /* PE sets the symbol to a value relative to the start | 4905 | | of the section. */ | 4906 | 265 | dst->symbol.value = src->u.syment.n_value; | 4907 | 265 | if (strcmp (dst->symbol.name, ".bf") != 0) | 4908 | 265 | { | 4909 | | /* PE uses funny values for .ef and .lf; don't | 4910 | | relocate them. */ | 4911 | 265 | dst->symbol.flags = BSF_DEBUGGING; | 4912 | 265 | } | 4913 | 0 | else | 4914 | 0 | dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC; | 4915 | | #else | 4916 | | /* Base the value as an index from the base of the | 4917 | | section. */ | 4918 | | dst->symbol.flags = BSF_LOCAL; | 4919 | | dst->symbol.value = (src->u.syment.n_value | 4920 | | - dst->symbol.section->vma); | 4921 | | #endif | 4922 | 265 | break; | 4923 | | | 4924 | 68 | case C_STATLAB: /* Static load time label. */ | 4925 | 68 | dst->symbol.value = src->u.syment.n_value; | 4926 | 68 | dst->symbol.flags = BSF_GLOBAL; | 4927 | 68 | break; | 4928 | | | 4929 | 43.4k | case C_NULL: | 4930 | | /* PE DLLs sometimes have zeroed out symbols for some | 4931 | | reason. Just ignore them without a warning. */ | 4932 | 43.4k | if (src->u.syment.n_type == 0 | 4933 | 43.4k | && src->u.syment.n_value == 0 | 4934 | 43.4k | && src->u.syment.n_scnum == 0) | 4935 | 27.2k | break; | 4936 | | #ifdef RS6000COFF_C | 4937 | | /* XCOFF specific: deleted entry. */ | 4938 | | if (src->u.syment.n_value == C_NULL_VALUE) | 4939 | | break; | 4940 | | #endif | 4941 | | /* Fall through. */ | 4942 | 16.2k | case C_EXTDEF: /* External definition. */ | 4943 | 16.4k | case C_ULABEL: /* Undefined label. */ | 4944 | 16.5k | case C_USTATIC: /* Undefined static. */ | 4945 | | #ifndef COFF_WITH_PE | 4946 | | /* C_LINE in regular coff is 0x68. NT has taken over this storage | 4947 | | class to represent a section symbol. */ | 4948 | | case C_LINE: /* line # reformatted as symbol table entry. */ | 4949 | | /* NT uses 0x67 for a weak symbol, not C_ALIAS. */ | 4950 | | case C_ALIAS: /* Duplicate tag. */ | 4951 | | #endif | 4952 | | /* New storage classes for TI COFF. */ | 4953 | | #ifdef TICOFF | 4954 | | case C_UEXT: /* Tentative external definition. */ | 4955 | | #endif | 4956 | 16.5k | case C_EXTLAB: /* External load time label. */ | 4957 | 21.3k | default: | 4958 | 21.3k | _bfd_error_handler | 4959 | | /* xgettext:c-format */ | 4960 | 21.3k | (_("%pB: unrecognized storage class %d for %s symbol `%s'"), | 4961 | 21.3k | abfd, src->u.syment.n_sclass, | 4962 | 21.3k | dst->symbol.section->name, dst->symbol.name); | 4963 | 21.3k | ret = false; | 4964 | | /* Fall through. */ | 4965 | 21.4k | case C_HIDDEN: /* Ext symbol in dmert public lib. */ | 4966 | | /* PR 20722: These symbols can also be generated by | 4967 | | building DLLs with --gc-sections enabled. */ | 4968 | 21.4k | dst->symbol.flags = BSF_DEBUGGING; | 4969 | 21.4k | dst->symbol.value = (src->u.syment.n_value); | 4970 | 21.4k | break; | 4971 | 56.3k | } | 4972 | | | 4973 | 56.3k | dst->native = src; | 4974 | 56.3k | dst->symbol.udata.i = 0; | 4975 | 56.3k | dst->lineno = NULL; | 4976 | | | 4977 | 56.3k | this_index += (src->u.syment.n_numaux) + 1; | 4978 | 56.3k | dst++; | 4979 | 56.3k | number_of_symbols++; | 4980 | 56.3k | } | 4981 | 267 | } | 4982 | | | 4983 | 267 | obj_symbols (abfd) = cached_area; | 4984 | 267 | obj_raw_syments (abfd) = native_symbols; | 4985 | | | 4986 | 267 | abfd->symcount = number_of_symbols; | 4987 | 267 | obj_convert (abfd) = table_ptr; | 4988 | | /* Slurp the line tables for each section too. */ | 4989 | 267 | { | 4990 | 267 | asection *p; | 4991 | | | 4992 | 267 | p = abfd->sections; | 4993 | 3.52k | while (p) | 4994 | 3.35k | { | 4995 | 3.35k | if (! coff_slurp_line_table (abfd, p)) | 4996 | 102 | return false; | 4997 | 3.25k | p = p->next; | 4998 | 3.25k | } | 4999 | 267 | } | 5000 | | | 5001 | 165 | return ret; | 5002 | 267 | } |
pei-ia64.c:coff_slurp_symbol_table Line | Count | Source | 4630 | 298 | { | 4631 | 298 | combined_entry_type *native_symbols; | 4632 | 298 | coff_symbol_type *cached_area; | 4633 | 298 | unsigned int *table_ptr; | 4634 | 298 | unsigned int number_of_symbols = 0; | 4635 | 298 | bool ret = true; | 4636 | 298 | size_t amt; | 4637 | | | 4638 | 298 | if (obj_symbols (abfd)) | 4639 | 31 | return true; | 4640 | | | 4641 | | /* Read in the symbol table. */ | 4642 | 267 | if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) | 4643 | 114 | return false; | 4644 | | | 4645 | | /* Allocate enough room for all the symbols in cached form. */ | 4646 | 153 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4647 | 153 | sizeof (*cached_area), &amt)) | 4648 | 0 | { | 4649 | 0 | bfd_set_error (bfd_error_file_too_big); | 4650 | 0 | return false; | 4651 | 0 | } | 4652 | 153 | cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt); | 4653 | 153 | if (cached_area == NULL) | 4654 | 0 | return false; | 4655 | | | 4656 | 153 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4657 | 153 | sizeof (*table_ptr), &amt)) | 4658 | 0 | { | 4659 | 0 | bfd_set_error (bfd_error_file_too_big); | 4660 | 0 | return false; | 4661 | 0 | } | 4662 | 153 | table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); | 4663 | 153 | if (table_ptr == NULL) | 4664 | 0 | return false; | 4665 | 153 | else | 4666 | 153 | { | 4667 | 153 | coff_symbol_type *dst = cached_area; | 4668 | 153 | unsigned int last_native_index = obj_raw_syment_count (abfd); | 4669 | 153 | unsigned int this_index = 0; | 4670 | | | 4671 | 10.9k | while (this_index < last_native_index) | 4672 | 10.8k | { | 4673 | 10.8k | combined_entry_type *src = native_symbols + this_index; | 4674 | 10.8k | table_ptr[this_index] = number_of_symbols; | 4675 | | | 4676 | 10.8k | dst->symbol.the_bfd = abfd; | 4677 | 10.8k | BFD_ASSERT (src->is_sym); | 4678 | 10.8k | dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset); | 4679 | | /* We use the native name field to point to the cached field. */ | 4680 | 10.8k | src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; | 4681 | 10.8k | dst->symbol.section = coff_section_from_bfd_index (abfd, | 4682 | 10.8k | src->u.syment.n_scnum); | 4683 | 10.8k | dst->symbol.flags = 0; | 4684 | | /* PR 17512: file: 079-7098-0.001:0.1. */ | 4685 | 10.8k | dst->symbol.value = 0; | 4686 | 10.8k | dst->done_lineno = false; | 4687 | | | 4688 | 10.8k | switch (src->u.syment.n_sclass) | 4689 | 10.8k | { | 4690 | 296 | case C_EXT: | 4691 | 319 | case C_WEAKEXT: | 4692 | | #if defined ARM | 4693 | | case C_THUMBEXT: | 4694 | | case C_THUMBEXTFUNC: | 4695 | | #endif | 4696 | | #ifdef RS6000COFF_C | 4697 | | case C_HIDEXT: | 4698 | | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 4699 | | case C_AIX_WEAKEXT: | 4700 | | #endif | 4701 | | #endif | 4702 | 319 | #ifdef C_SYSTEM | 4703 | 347 | case C_SYSTEM: /* System Wide variable. */ | 4704 | 347 | #endif | 4705 | 347 | #ifdef COFF_WITH_PE | 4706 | | /* In PE, 0x68 (104) denotes a section symbol. */ | 4707 | 363 | case C_SECTION: | 4708 | | /* In PE, 0x69 (105) denotes a weak external symbol. */ | 4709 | 386 | case C_NT_WEAK: | 4710 | 386 | #endif | 4711 | 386 | switch (coff_classify_symbol (abfd, &src->u.syment)) | 4712 | 386 | { | 4713 | 338 | case COFF_SYMBOL_GLOBAL: | 4714 | 338 | dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL; | 4715 | 338 | #if defined COFF_WITH_PE | 4716 | | /* PE sets the symbol to a value relative to the | 4717 | | start of the section. */ | 4718 | 338 | dst->symbol.value = src->u.syment.n_value; | 4719 | | #else | 4720 | | dst->symbol.value = (src->u.syment.n_value | 4721 | | - dst->symbol.section->vma); | 4722 | | #endif | 4723 | 338 | if (ISFCN ((src->u.syment.n_type))) | 4724 | | /* A function ext does not go at the end of a | 4725 | | file. */ | 4726 | 19 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4727 | 338 | break; | 4728 | | | 4729 | 25 | case COFF_SYMBOL_COMMON: | 4730 | 25 | dst->symbol.section = bfd_com_section_ptr; | 4731 | 25 | dst->symbol.value = src->u.syment.n_value; | 4732 | 25 | break; | 4733 | | | 4734 | 23 | case COFF_SYMBOL_UNDEFINED: | 4735 | 23 | dst->symbol.section = bfd_und_section_ptr; | 4736 | 23 | dst->symbol.value = 0; | 4737 | 23 | break; | 4738 | | | 4739 | 0 | case COFF_SYMBOL_PE_SECTION: | 4740 | 0 | dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM; | 4741 | 0 | dst->symbol.value = 0; | 4742 | 0 | break; | 4743 | | | 4744 | 0 | case COFF_SYMBOL_LOCAL: | 4745 | 0 | dst->symbol.flags = BSF_LOCAL; | 4746 | 0 | #if defined COFF_WITH_PE | 4747 | | /* PE sets the symbol to a value relative to the | 4748 | | start of the section. */ | 4749 | 0 | dst->symbol.value = src->u.syment.n_value; | 4750 | | #else | 4751 | | dst->symbol.value = (src->u.syment.n_value | 4752 | | - dst->symbol.section->vma); | 4753 | | #endif | 4754 | 0 | if (ISFCN ((src->u.syment.n_type))) | 4755 | 0 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4756 | 0 | break; | 4757 | 386 | } | 4758 | | | 4759 | | #ifdef RS6000COFF_C | 4760 | | /* A symbol with a csect entry should not go at the end. */ | 4761 | | if (src->u.syment.n_numaux > 0) | 4762 | | dst->symbol.flags |= BSF_NOT_AT_END; | 4763 | | #endif | 4764 | | | 4765 | 386 | #ifdef COFF_WITH_PE | 4766 | 386 | if (src->u.syment.n_sclass == C_NT_WEAK) | 4767 | 23 | dst->symbol.flags |= BSF_WEAK; | 4768 | | | 4769 | 386 | if (src->u.syment.n_sclass == C_SECTION | 4770 | 386 | && src->u.syment.n_scnum > 0) | 4771 | 0 | dst->symbol.flags = BSF_LOCAL; | 4772 | 386 | #endif | 4773 | 386 | if (src->u.syment.n_sclass == C_WEAKEXT | 4774 | | #ifdef RS6000COFF_C | 4775 | | || src->u.syment.n_sclass == C_AIX_WEAKEXT | 4776 | | #endif | 4777 | 386 | ) | 4778 | 23 | dst->symbol.flags |= BSF_WEAK; | 4779 | | | 4780 | 386 | break; | 4781 | | | 4782 | 170 | case C_STAT: /* Static. */ | 4783 | | #if defined ARM | 4784 | | case C_THUMBSTAT: /* Thumb static. */ | 4785 | | case C_THUMBLABEL: /* Thumb label. */ | 4786 | | case C_THUMBSTATFUNC:/* Thumb static function. */ | 4787 | | #endif | 4788 | | #ifdef RS6000COFF_C | 4789 | | case C_DWARF: /* A label in a dwarf section. */ | 4790 | | case C_INFO: /* A label in a comment section. */ | 4791 | | #endif | 4792 | 208 | case C_LABEL: /* Label. */ | 4793 | 208 | if (src->u.syment.n_scnum == N_DEBUG) | 4794 | 1 | dst->symbol.flags = BSF_DEBUGGING; | 4795 | 207 | else | 4796 | 207 | dst->symbol.flags = BSF_LOCAL; | 4797 | | | 4798 | | /* Base the value as an index from the base of the | 4799 | | section, if there is one. */ | 4800 | 208 | if (dst->symbol.section) | 4801 | 208 | { | 4802 | 208 | #if defined COFF_WITH_PE | 4803 | | /* PE sets the symbol to a value relative to the | 4804 | | start of the section. */ | 4805 | 208 | dst->symbol.value = src->u.syment.n_value; | 4806 | | #else | 4807 | | dst->symbol.value = (src->u.syment.n_value | 4808 | | - dst->symbol.section->vma); | 4809 | | #endif | 4810 | 208 | } | 4811 | 0 | else | 4812 | 0 | dst->symbol.value = src->u.syment.n_value; | 4813 | 208 | break; | 4814 | | | 4815 | 23 | case C_FILE: /* File name. */ | 4816 | 23 | dst->symbol.flags = BSF_FILE; | 4817 | | /* Fall through. */ | 4818 | 107 | case C_MOS: /* Member of structure. */ | 4819 | 110 | case C_EOS: /* End of structure. */ | 4820 | 125 | case C_REGPARM: /* Register parameter. */ | 4821 | 177 | case C_REG: /* register variable. */ | 4822 | | /* C_AUTOARG conflicts with TI COFF C_UEXT. */ | 4823 | 187 | case C_TPDEF: /* Type definition. */ | 4824 | 206 | case C_ARG: | 4825 | 1.88k | case C_AUTO: /* Automatic variable. */ | 4826 | 1.98k | case C_FIELD: /* Bit field. */ | 4827 | 2.16k | case C_ENTAG: /* Enumeration tag. */ | 4828 | 2.22k | case C_MOE: /* Member of enumeration. */ | 4829 | 2.26k | case C_MOU: /* Member of union. */ | 4830 | 2.52k | case C_UNTAG: /* Union tag. */ | 4831 | 2.59k | case C_STRTAG: /* Structure tag. */ | 4832 | | #ifdef RS6000COFF_C | 4833 | | case C_GSYM: | 4834 | | case C_LSYM: | 4835 | | case C_PSYM: | 4836 | | case C_RSYM: | 4837 | | case C_RPSYM: | 4838 | | case C_STSYM: | 4839 | | case C_TCSYM: | 4840 | | case C_BCOMM: | 4841 | | case C_ECOML: | 4842 | | case C_ECOMM: | 4843 | | case C_DECL: | 4844 | | case C_ENTRY: | 4845 | | case C_FUN: | 4846 | | case C_ESTAT: | 4847 | | #endif | 4848 | 2.59k | dst->symbol.flags |= BSF_DEBUGGING; | 4849 | 2.59k | dst->symbol.value = (src->u.syment.n_value); | 4850 | 2.59k | break; | 4851 | | | 4852 | | #ifdef RS6000COFF_C | 4853 | | case C_BINCL: /* Beginning of include file. */ | 4854 | | case C_EINCL: /* Ending of include file. */ | 4855 | | /* The value is actually a pointer into the line numbers | 4856 | | of the file. We locate the line number entry, and | 4857 | | set the section to the section which contains it, and | 4858 | | the value to the index in that section. */ | 4859 | | { | 4860 | | asection *sec; | 4861 | | | 4862 | | dst->symbol.flags = BSF_DEBUGGING; | 4863 | | for (sec = abfd->sections; sec != NULL; sec = sec->next) | 4864 | | if (sec->line_filepos <= (file_ptr) src->u.syment.n_value | 4865 | | && ((file_ptr) (sec->line_filepos | 4866 | | + sec->lineno_count * bfd_coff_linesz (abfd)) | 4867 | | > (file_ptr) src->u.syment.n_value)) | 4868 | | break; | 4869 | | if (sec == NULL) | 4870 | | dst->symbol.value = 0; | 4871 | | else | 4872 | | { | 4873 | | dst->symbol.section = sec; | 4874 | | dst->symbol.value = ((src->u.syment.n_value | 4875 | | - sec->line_filepos) | 4876 | | / bfd_coff_linesz (abfd)); | 4877 | | src->fix_line = 1; | 4878 | | } | 4879 | | } | 4880 | | break; | 4881 | | | 4882 | | case C_BSTAT: | 4883 | | dst->symbol.flags = BSF_DEBUGGING; | 4884 | | | 4885 | | if (src->u.syment.n_value >= obj_raw_syment_count (abfd)) | 4886 | | dst->symbol.value = 0; | 4887 | | else | 4888 | | { | 4889 | | /* The value is actually a symbol index. Save a pointer | 4890 | | to the symbol instead of the index. FIXME: This | 4891 | | should use a union. */ | 4892 | | src->u.syment.n_value | 4893 | | = (uintptr_t) (native_symbols + src->u.syment.n_value); | 4894 | | dst->symbol.value = src->u.syment.n_value; | 4895 | | src->fix_value = 1; | 4896 | | } | 4897 | | break; | 4898 | | #endif | 4899 | | | 4900 | 35 | case C_BLOCK: /* ".bb" or ".eb". */ | 4901 | 49 | case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */ | 4902 | 76 | case C_EFCN: /* Physical end of function. */ | 4903 | 76 | #if defined COFF_WITH_PE | 4904 | | /* PE sets the symbol to a value relative to the start | 4905 | | of the section. */ | 4906 | 76 | dst->symbol.value = src->u.syment.n_value; | 4907 | 76 | if (strcmp (dst->symbol.name, ".bf") != 0) | 4908 | 76 | { | 4909 | | /* PE uses funny values for .ef and .lf; don't | 4910 | | relocate them. */ | 4911 | 76 | dst->symbol.flags = BSF_DEBUGGING; | 4912 | 76 | } | 4913 | 0 | else | 4914 | 0 | dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC; | 4915 | | #else | 4916 | | /* Base the value as an index from the base of the | 4917 | | section. */ | 4918 | | dst->symbol.flags = BSF_LOCAL; | 4919 | | dst->symbol.value = (src->u.syment.n_value | 4920 | | - dst->symbol.section->vma); | 4921 | | #endif | 4922 | 76 | break; | 4923 | | | 4924 | 45 | case C_STATLAB: /* Static load time label. */ | 4925 | 45 | dst->symbol.value = src->u.syment.n_value; | 4926 | 45 | dst->symbol.flags = BSF_GLOBAL; | 4927 | 45 | break; | 4928 | | | 4929 | 5.82k | case C_NULL: | 4930 | | /* PE DLLs sometimes have zeroed out symbols for some | 4931 | | reason. Just ignore them without a warning. */ | 4932 | 5.82k | if (src->u.syment.n_type == 0 | 4933 | 5.82k | && src->u.syment.n_value == 0 | 4934 | 5.82k | && src->u.syment.n_scnum == 0) | 4935 | 1.75k | break; | 4936 | | #ifdef RS6000COFF_C | 4937 | | /* XCOFF specific: deleted entry. */ | 4938 | | if (src->u.syment.n_value == C_NULL_VALUE) | 4939 | | break; | 4940 | | #endif | 4941 | | /* Fall through. */ | 4942 | 4.08k | case C_EXTDEF: /* External definition. */ | 4943 | 4.30k | case C_ULABEL: /* Undefined label. */ | 4944 | 4.32k | case C_USTATIC: /* Undefined static. */ | 4945 | | #ifndef COFF_WITH_PE | 4946 | | /* C_LINE in regular coff is 0x68. NT has taken over this storage | 4947 | | class to represent a section symbol. */ | 4948 | | case C_LINE: /* line # reformatted as symbol table entry. */ | 4949 | | /* NT uses 0x67 for a weak symbol, not C_ALIAS. */ | 4950 | | case C_ALIAS: /* Duplicate tag. */ | 4951 | | #endif | 4952 | | /* New storage classes for TI COFF. */ | 4953 | | #ifdef TICOFF | 4954 | | case C_UEXT: /* Tentative external definition. */ | 4955 | | #endif | 4956 | 4.32k | case C_EXTLAB: /* External load time label. */ | 4957 | 5.71k | default: | 4958 | 5.71k | _bfd_error_handler | 4959 | | /* xgettext:c-format */ | 4960 | 5.71k | (_("%pB: unrecognized storage class %d for %s symbol `%s'"), | 4961 | 5.71k | abfd, src->u.syment.n_sclass, | 4962 | 5.71k | dst->symbol.section->name, dst->symbol.name); | 4963 | 5.71k | ret = false; | 4964 | | /* Fall through. */ | 4965 | 5.73k | case C_HIDDEN: /* Ext symbol in dmert public lib. */ | 4966 | | /* PR 20722: These symbols can also be generated by | 4967 | | building DLLs with --gc-sections enabled. */ | 4968 | 5.73k | dst->symbol.flags = BSF_DEBUGGING; | 4969 | 5.73k | dst->symbol.value = (src->u.syment.n_value); | 4970 | 5.73k | break; | 4971 | 10.8k | } | 4972 | | | 4973 | 10.8k | dst->native = src; | 4974 | 10.8k | dst->symbol.udata.i = 0; | 4975 | 10.8k | dst->lineno = NULL; | 4976 | | | 4977 | 10.8k | this_index += (src->u.syment.n_numaux) + 1; | 4978 | 10.8k | dst++; | 4979 | 10.8k | number_of_symbols++; | 4980 | 10.8k | } | 4981 | 153 | } | 4982 | | | 4983 | 153 | obj_symbols (abfd) = cached_area; | 4984 | 153 | obj_raw_syments (abfd) = native_symbols; | 4985 | | | 4986 | 153 | abfd->symcount = number_of_symbols; | 4987 | 153 | obj_convert (abfd) = table_ptr; | 4988 | | /* Slurp the line tables for each section too. */ | 4989 | 153 | { | 4990 | 153 | asection *p; | 4991 | | | 4992 | 153 | p = abfd->sections; | 4993 | 353 | while (p) | 4994 | 308 | { | 4995 | 308 | if (! coff_slurp_line_table (abfd, p)) | 4996 | 108 | return false; | 4997 | 200 | p = p->next; | 4998 | 200 | } | 4999 | 153 | } | 5000 | | | 5001 | 45 | return ret; | 5002 | 153 | } |
pei-loongarch64.c:coff_slurp_symbol_table Line | Count | Source | 4630 | 357 | { | 4631 | 357 | combined_entry_type *native_symbols; | 4632 | 357 | coff_symbol_type *cached_area; | 4633 | 357 | unsigned int *table_ptr; | 4634 | 357 | unsigned int number_of_symbols = 0; | 4635 | 357 | bool ret = true; | 4636 | 357 | size_t amt; | 4637 | | | 4638 | 357 | if (obj_symbols (abfd)) | 4639 | 59 | return true; | 4640 | | | 4641 | | /* Read in the symbol table. */ | 4642 | 298 | if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) | 4643 | 144 | return false; | 4644 | | | 4645 | | /* Allocate enough room for all the symbols in cached form. */ | 4646 | 154 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4647 | 154 | sizeof (*cached_area), &amt)) | 4648 | 0 | { | 4649 | 0 | bfd_set_error (bfd_error_file_too_big); | 4650 | 0 | return false; | 4651 | 0 | } | 4652 | 154 | cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt); | 4653 | 154 | if (cached_area == NULL) | 4654 | 0 | return false; | 4655 | | | 4656 | 154 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4657 | 154 | sizeof (*table_ptr), &amt)) | 4658 | 0 | { | 4659 | 0 | bfd_set_error (bfd_error_file_too_big); | 4660 | 0 | return false; | 4661 | 0 | } | 4662 | 154 | table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); | 4663 | 154 | if (table_ptr == NULL) | 4664 | 0 | return false; | 4665 | 154 | else | 4666 | 154 | { | 4667 | 154 | coff_symbol_type *dst = cached_area; | 4668 | 154 | unsigned int last_native_index = obj_raw_syment_count (abfd); | 4669 | 154 | unsigned int this_index = 0; | 4670 | | | 4671 | 75.7k | while (this_index < last_native_index) | 4672 | 75.6k | { | 4673 | 75.6k | combined_entry_type *src = native_symbols + this_index; | 4674 | 75.6k | table_ptr[this_index] = number_of_symbols; | 4675 | | | 4676 | 75.6k | dst->symbol.the_bfd = abfd; | 4677 | 75.6k | BFD_ASSERT (src->is_sym); | 4678 | 75.6k | dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset); | 4679 | | /* We use the native name field to point to the cached field. */ | 4680 | 75.6k | src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; | 4681 | 75.6k | dst->symbol.section = coff_section_from_bfd_index (abfd, | 4682 | 75.6k | src->u.syment.n_scnum); | 4683 | 75.6k | dst->symbol.flags = 0; | 4684 | | /* PR 17512: file: 079-7098-0.001:0.1. */ | 4685 | 75.6k | dst->symbol.value = 0; | 4686 | 75.6k | dst->done_lineno = false; | 4687 | | | 4688 | 75.6k | switch (src->u.syment.n_sclass) | 4689 | 75.6k | { | 4690 | 560 | case C_EXT: | 4691 | 624 | case C_WEAKEXT: | 4692 | | #if defined ARM | 4693 | | case C_THUMBEXT: | 4694 | | case C_THUMBEXTFUNC: | 4695 | | #endif | 4696 | | #ifdef RS6000COFF_C | 4697 | | case C_HIDEXT: | 4698 | | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 4699 | | case C_AIX_WEAKEXT: | 4700 | | #endif | 4701 | | #endif | 4702 | 624 | #ifdef C_SYSTEM | 4703 | 674 | case C_SYSTEM: /* System Wide variable. */ | 4704 | 674 | #endif | 4705 | 674 | #ifdef COFF_WITH_PE | 4706 | | /* In PE, 0x68 (104) denotes a section symbol. */ | 4707 | 685 | case C_SECTION: | 4708 | | /* In PE, 0x69 (105) denotes a weak external symbol. */ | 4709 | 744 | case C_NT_WEAK: | 4710 | 744 | #endif | 4711 | 744 | switch (coff_classify_symbol (abfd, &src->u.syment)) | 4712 | 744 | { | 4713 | 572 | case COFF_SYMBOL_GLOBAL: | 4714 | 572 | dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL; | 4715 | 572 | #if defined COFF_WITH_PE | 4716 | | /* PE sets the symbol to a value relative to the | 4717 | | start of the section. */ | 4718 | 572 | dst->symbol.value = src->u.syment.n_value; | 4719 | | #else | 4720 | | dst->symbol.value = (src->u.syment.n_value | 4721 | | - dst->symbol.section->vma); | 4722 | | #endif | 4723 | 572 | if (ISFCN ((src->u.syment.n_type))) | 4724 | | /* A function ext does not go at the end of a | 4725 | | file. */ | 4726 | 12 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4727 | 572 | break; | 4728 | | | 4729 | 114 | case COFF_SYMBOL_COMMON: | 4730 | 114 | dst->symbol.section = bfd_com_section_ptr; | 4731 | 114 | dst->symbol.value = src->u.syment.n_value; | 4732 | 114 | break; | 4733 | | | 4734 | 58 | case COFF_SYMBOL_UNDEFINED: | 4735 | 58 | dst->symbol.section = bfd_und_section_ptr; | 4736 | 58 | dst->symbol.value = 0; | 4737 | 58 | break; | 4738 | | | 4739 | 0 | case COFF_SYMBOL_PE_SECTION: | 4740 | 0 | dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM; | 4741 | 0 | dst->symbol.value = 0; | 4742 | 0 | break; | 4743 | | | 4744 | 0 | case COFF_SYMBOL_LOCAL: | 4745 | 0 | dst->symbol.flags = BSF_LOCAL; | 4746 | 0 | #if defined COFF_WITH_PE | 4747 | | /* PE sets the symbol to a value relative to the | 4748 | | start of the section. */ | 4749 | 0 | dst->symbol.value = src->u.syment.n_value; | 4750 | | #else | 4751 | | dst->symbol.value = (src->u.syment.n_value | 4752 | | - dst->symbol.section->vma); | 4753 | | #endif | 4754 | 0 | if (ISFCN ((src->u.syment.n_type))) | 4755 | 0 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4756 | 0 | break; | 4757 | 744 | } | 4758 | | | 4759 | | #ifdef RS6000COFF_C | 4760 | | /* A symbol with a csect entry should not go at the end. */ | 4761 | | if (src->u.syment.n_numaux > 0) | 4762 | | dst->symbol.flags |= BSF_NOT_AT_END; | 4763 | | #endif | 4764 | | | 4765 | 744 | #ifdef COFF_WITH_PE | 4766 | 744 | if (src->u.syment.n_sclass == C_NT_WEAK) | 4767 | 59 | dst->symbol.flags |= BSF_WEAK; | 4768 | | | 4769 | 744 | if (src->u.syment.n_sclass == C_SECTION | 4770 | 744 | && src->u.syment.n_scnum > 0) | 4771 | 0 | dst->symbol.flags = BSF_LOCAL; | 4772 | 744 | #endif | 4773 | 744 | if (src->u.syment.n_sclass == C_WEAKEXT | 4774 | | #ifdef RS6000COFF_C | 4775 | | || src->u.syment.n_sclass == C_AIX_WEAKEXT | 4776 | | #endif | 4777 | 744 | ) | 4778 | 64 | dst->symbol.flags |= BSF_WEAK; | 4779 | | | 4780 | 744 | break; | 4781 | | | 4782 | 423 | case C_STAT: /* Static. */ | 4783 | | #if defined ARM | 4784 | | case C_THUMBSTAT: /* Thumb static. */ | 4785 | | case C_THUMBLABEL: /* Thumb label. */ | 4786 | | case C_THUMBSTATFUNC:/* Thumb static function. */ | 4787 | | #endif | 4788 | | #ifdef RS6000COFF_C | 4789 | | case C_DWARF: /* A label in a dwarf section. */ | 4790 | | case C_INFO: /* A label in a comment section. */ | 4791 | | #endif | 4792 | 500 | case C_LABEL: /* Label. */ | 4793 | 500 | if (src->u.syment.n_scnum == N_DEBUG) | 4794 | 1 | dst->symbol.flags = BSF_DEBUGGING; | 4795 | 499 | else | 4796 | 499 | dst->symbol.flags = BSF_LOCAL; | 4797 | | | 4798 | | /* Base the value as an index from the base of the | 4799 | | section, if there is one. */ | 4800 | 500 | if (dst->symbol.section) | 4801 | 500 | { | 4802 | 500 | #if defined COFF_WITH_PE | 4803 | | /* PE sets the symbol to a value relative to the | 4804 | | start of the section. */ | 4805 | 500 | dst->symbol.value = src->u.syment.n_value; | 4806 | | #else | 4807 | | dst->symbol.value = (src->u.syment.n_value | 4808 | | - dst->symbol.section->vma); | 4809 | | #endif | 4810 | 500 | } | 4811 | 0 | else | 4812 | 0 | dst->symbol.value = src->u.syment.n_value; | 4813 | 500 | break; | 4814 | | | 4815 | 76 | case C_FILE: /* File name. */ | 4816 | 76 | dst->symbol.flags = BSF_FILE; | 4817 | | /* Fall through. */ | 4818 | 350 | case C_MOS: /* Member of structure. */ | 4819 | 414 | case C_EOS: /* End of structure. */ | 4820 | 497 | case C_REGPARM: /* Register parameter. */ | 4821 | 732 | case C_REG: /* register variable. */ | 4822 | | /* C_AUTOARG conflicts with TI COFF C_UEXT. */ | 4823 | 809 | case C_TPDEF: /* Type definition. */ | 4824 | 899 | case C_ARG: | 4825 | 4.46k | case C_AUTO: /* Automatic variable. */ | 4826 | 4.92k | case C_FIELD: /* Bit field. */ | 4827 | 5.07k | case C_ENTAG: /* Enumeration tag. */ | 4828 | 5.47k | case C_MOE: /* Member of enumeration. */ | 4829 | 5.95k | case C_MOU: /* Member of union. */ | 4830 | 6.10k | case C_UNTAG: /* Union tag. */ | 4831 | 6.81k | case C_STRTAG: /* Structure tag. */ | 4832 | | #ifdef RS6000COFF_C | 4833 | | case C_GSYM: | 4834 | | case C_LSYM: | 4835 | | case C_PSYM: | 4836 | | case C_RSYM: | 4837 | | case C_RPSYM: | 4838 | | case C_STSYM: | 4839 | | case C_TCSYM: | 4840 | | case C_BCOMM: | 4841 | | case C_ECOML: | 4842 | | case C_ECOMM: | 4843 | | case C_DECL: | 4844 | | case C_ENTRY: | 4845 | | case C_FUN: | 4846 | | case C_ESTAT: | 4847 | | #endif | 4848 | 6.81k | dst->symbol.flags |= BSF_DEBUGGING; | 4849 | 6.81k | dst->symbol.value = (src->u.syment.n_value); | 4850 | 6.81k | break; | 4851 | | | 4852 | | #ifdef RS6000COFF_C | 4853 | | case C_BINCL: /* Beginning of include file. */ | 4854 | | case C_EINCL: /* Ending of include file. */ | 4855 | | /* The value is actually a pointer into the line numbers | 4856 | | of the file. We locate the line number entry, and | 4857 | | set the section to the section which contains it, and | 4858 | | the value to the index in that section. */ | 4859 | | { | 4860 | | asection *sec; | 4861 | | | 4862 | | dst->symbol.flags = BSF_DEBUGGING; | 4863 | | for (sec = abfd->sections; sec != NULL; sec = sec->next) | 4864 | | if (sec->line_filepos <= (file_ptr) src->u.syment.n_value | 4865 | | && ((file_ptr) (sec->line_filepos | 4866 | | + sec->lineno_count * bfd_coff_linesz (abfd)) | 4867 | | > (file_ptr) src->u.syment.n_value)) | 4868 | | break; | 4869 | | if (sec == NULL) | 4870 | | dst->symbol.value = 0; | 4871 | | else | 4872 | | { | 4873 | | dst->symbol.section = sec; | 4874 | | dst->symbol.value = ((src->u.syment.n_value | 4875 | | - sec->line_filepos) | 4876 | | / bfd_coff_linesz (abfd)); | 4877 | | src->fix_line = 1; | 4878 | | } | 4879 | | } | 4880 | | break; | 4881 | | | 4882 | | case C_BSTAT: | 4883 | | dst->symbol.flags = BSF_DEBUGGING; | 4884 | | | 4885 | | if (src->u.syment.n_value >= obj_raw_syment_count (abfd)) | 4886 | | dst->symbol.value = 0; | 4887 | | else | 4888 | | { | 4889 | | /* The value is actually a symbol index. Save a pointer | 4890 | | to the symbol instead of the index. FIXME: This | 4891 | | should use a union. */ | 4892 | | src->u.syment.n_value | 4893 | | = (uintptr_t) (native_symbols + src->u.syment.n_value); | 4894 | | dst->symbol.value = src->u.syment.n_value; | 4895 | | src->fix_value = 1; | 4896 | | } | 4897 | | break; | 4898 | | #endif | 4899 | | | 4900 | 35 | case C_BLOCK: /* ".bb" or ".eb". */ | 4901 | 193 | case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */ | 4902 | 492 | case C_EFCN: /* Physical end of function. */ | 4903 | 492 | #if defined COFF_WITH_PE | 4904 | | /* PE sets the symbol to a value relative to the start | 4905 | | of the section. */ | 4906 | 492 | dst->symbol.value = src->u.syment.n_value; | 4907 | 492 | if (strcmp (dst->symbol.name, ".bf") != 0) | 4908 | 492 | { | 4909 | | /* PE uses funny values for .ef and .lf; don't | 4910 | | relocate them. */ | 4911 | 492 | dst->symbol.flags = BSF_DEBUGGING; | 4912 | 492 | } | 4913 | 0 | else | 4914 | 0 | dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC; | 4915 | | #else | 4916 | | /* Base the value as an index from the base of the | 4917 | | section. */ | 4918 | | dst->symbol.flags = BSF_LOCAL; | 4919 | | dst->symbol.value = (src->u.syment.n_value | 4920 | | - dst->symbol.section->vma); | 4921 | | #endif | 4922 | 492 | break; | 4923 | | | 4924 | 64 | case C_STATLAB: /* Static load time label. */ | 4925 | 64 | dst->symbol.value = src->u.syment.n_value; | 4926 | 64 | dst->symbol.flags = BSF_GLOBAL; | 4927 | 64 | break; | 4928 | | | 4929 | 56.7k | case C_NULL: | 4930 | | /* PE DLLs sometimes have zeroed out symbols for some | 4931 | | reason. Just ignore them without a warning. */ | 4932 | 56.7k | if (src->u.syment.n_type == 0 | 4933 | 56.7k | && src->u.syment.n_value == 0 | 4934 | 56.7k | && src->u.syment.n_scnum == 0) | 4935 | 19.8k | break; | 4936 | | #ifdef RS6000COFF_C | 4937 | | /* XCOFF specific: deleted entry. */ | 4938 | | if (src->u.syment.n_value == C_NULL_VALUE) | 4939 | | break; | 4940 | | #endif | 4941 | | /* Fall through. */ | 4942 | 37.1k | case C_EXTDEF: /* External definition. */ | 4943 | 37.2k | case C_ULABEL: /* Undefined label. */ | 4944 | 37.3k | case C_USTATIC: /* Undefined static. */ | 4945 | | #ifndef COFF_WITH_PE | 4946 | | /* C_LINE in regular coff is 0x68. NT has taken over this storage | 4947 | | class to represent a section symbol. */ | 4948 | | case C_LINE: /* line # reformatted as symbol table entry. */ | 4949 | | /* NT uses 0x67 for a weak symbol, not C_ALIAS. */ | 4950 | | case C_ALIAS: /* Duplicate tag. */ | 4951 | | #endif | 4952 | | /* New storage classes for TI COFF. */ | 4953 | | #ifdef TICOFF | 4954 | | case C_UEXT: /* Tentative external definition. */ | 4955 | | #endif | 4956 | 37.3k | case C_EXTLAB: /* External load time label. */ | 4957 | 47.1k | default: | 4958 | 47.1k | _bfd_error_handler | 4959 | | /* xgettext:c-format */ | 4960 | 47.1k | (_("%pB: unrecognized storage class %d for %s symbol `%s'"), | 4961 | 47.1k | abfd, src->u.syment.n_sclass, | 4962 | 47.1k | dst->symbol.section->name, dst->symbol.name); | 4963 | 47.1k | ret = false; | 4964 | | /* Fall through. */ | 4965 | 47.1k | case C_HIDDEN: /* Ext symbol in dmert public lib. */ | 4966 | | /* PR 20722: These symbols can also be generated by | 4967 | | building DLLs with --gc-sections enabled. */ | 4968 | 47.1k | dst->symbol.flags = BSF_DEBUGGING; | 4969 | 47.1k | dst->symbol.value = (src->u.syment.n_value); | 4970 | 47.1k | break; | 4971 | 75.6k | } | 4972 | | | 4973 | 75.6k | dst->native = src; | 4974 | 75.6k | dst->symbol.udata.i = 0; | 4975 | 75.6k | dst->lineno = NULL; | 4976 | | | 4977 | 75.6k | this_index += (src->u.syment.n_numaux) + 1; | 4978 | 75.6k | dst++; | 4979 | 75.6k | number_of_symbols++; | 4980 | 75.6k | } | 4981 | 154 | } | 4982 | | | 4983 | 154 | obj_symbols (abfd) = cached_area; | 4984 | 154 | obj_raw_syments (abfd) = native_symbols; | 4985 | | | 4986 | 154 | abfd->symcount = number_of_symbols; | 4987 | 154 | obj_convert (abfd) = table_ptr; | 4988 | | /* Slurp the line tables for each section too. */ | 4989 | 154 | { | 4990 | 154 | asection *p; | 4991 | | | 4992 | 154 | p = abfd->sections; | 4993 | 349 | while (p) | 4994 | 327 | { | 4995 | 327 | if (! coff_slurp_line_table (abfd, p)) | 4996 | 132 | return false; | 4997 | 195 | p = p->next; | 4998 | 195 | } | 4999 | 154 | } | 5000 | | | 5001 | 22 | return ret; | 5002 | 154 | } |
Unexecuted instantiation: cf-i386lynx.c:coff_slurp_symbol_table Unexecuted instantiation: coff-go32.c:coff_slurp_symbol_table Unexecuted instantiation: coff-i386.c:coff_slurp_symbol_table coff-rs6000.c:coff_slurp_symbol_table Line | Count | Source | 4630 | 653 | { | 4631 | 653 | combined_entry_type *native_symbols; | 4632 | 653 | coff_symbol_type *cached_area; | 4633 | 653 | unsigned int *table_ptr; | 4634 | 653 | unsigned int number_of_symbols = 0; | 4635 | 653 | bool ret = true; | 4636 | 653 | size_t amt; | 4637 | | | 4638 | 653 | if (obj_symbols (abfd)) | 4639 | 74 | return true; | 4640 | | | 4641 | | /* Read in the symbol table. */ | 4642 | 579 | if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) | 4643 | 236 | return false; | 4644 | | | 4645 | | /* Allocate enough room for all the symbols in cached form. */ | 4646 | 343 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4647 | 343 | sizeof (*cached_area), &amt)) | 4648 | 0 | { | 4649 | 0 | bfd_set_error (bfd_error_file_too_big); | 4650 | 0 | return false; | 4651 | 0 | } | 4652 | 343 | cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt); | 4653 | 343 | if (cached_area == NULL) | 4654 | 0 | return false; | 4655 | | | 4656 | 343 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4657 | 343 | sizeof (*table_ptr), &amt)) | 4658 | 0 | { | 4659 | 0 | bfd_set_error (bfd_error_file_too_big); | 4660 | 0 | return false; | 4661 | 0 | } | 4662 | 343 | table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); | 4663 | 343 | if (table_ptr == NULL) | 4664 | 0 | return false; | 4665 | 343 | else | 4666 | 343 | { | 4667 | 343 | coff_symbol_type *dst = cached_area; | 4668 | 343 | unsigned int last_native_index = obj_raw_syment_count (abfd); | 4669 | 343 | unsigned int this_index = 0; | 4670 | | | 4671 | 101k | while (this_index < last_native_index) | 4672 | 100k | { | 4673 | 100k | combined_entry_type *src = native_symbols + this_index; | 4674 | 100k | table_ptr[this_index] = number_of_symbols; | 4675 | | | 4676 | 100k | dst->symbol.the_bfd = abfd; | 4677 | 100k | BFD_ASSERT (src->is_sym); | 4678 | 100k | dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset); | 4679 | | /* We use the native name field to point to the cached field. */ | 4680 | 100k | src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; | 4681 | 100k | dst->symbol.section = coff_section_from_bfd_index (abfd, | 4682 | 100k | src->u.syment.n_scnum); | 4683 | 100k | dst->symbol.flags = 0; | 4684 | | /* PR 17512: file: 079-7098-0.001:0.1. */ | 4685 | 100k | dst->symbol.value = 0; | 4686 | 100k | dst->done_lineno = false; | 4687 | | | 4688 | 100k | switch (src->u.syment.n_sclass) | 4689 | 100k | { | 4690 | 3.04k | case C_EXT: | 4691 | 3.26k | case C_WEAKEXT: | 4692 | | #if defined ARM | 4693 | | case C_THUMBEXT: | 4694 | | case C_THUMBEXTFUNC: | 4695 | | #endif | 4696 | 3.26k | #ifdef RS6000COFF_C | 4697 | 3.52k | case C_HIDEXT: | 4698 | 3.52k | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 4699 | 3.62k | case C_AIX_WEAKEXT: | 4700 | 3.62k | #endif | 4701 | 3.62k | #endif | 4702 | 3.62k | #ifdef C_SYSTEM | 4703 | 3.90k | case C_SYSTEM: /* System Wide variable. */ | 4704 | 3.90k | #endif | 4705 | | #ifdef COFF_WITH_PE | 4706 | | /* In PE, 0x68 (104) denotes a section symbol. */ | 4707 | | case C_SECTION: | 4708 | | /* In PE, 0x69 (105) denotes a weak external symbol. */ | 4709 | | case C_NT_WEAK: | 4710 | | #endif | 4711 | 3.90k | switch (coff_classify_symbol (abfd, &src->u.syment)) | 4712 | 3.90k | { | 4713 | 3.40k | case COFF_SYMBOL_GLOBAL: | 4714 | 3.40k | dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL; | 4715 | | #if defined COFF_WITH_PE | 4716 | | /* PE sets the symbol to a value relative to the | 4717 | | start of the section. */ | 4718 | | dst->symbol.value = src->u.syment.n_value; | 4719 | | #else | 4720 | 3.40k | dst->symbol.value = (src->u.syment.n_value | 4721 | 3.40k | - dst->symbol.section->vma); | 4722 | 3.40k | #endif | 4723 | 3.40k | if (ISFCN ((src->u.syment.n_type))) | 4724 | | /* A function ext does not go at the end of a | 4725 | | file. */ | 4726 | 62 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4727 | 3.40k | break; | 4728 | | | 4729 | 202 | case COFF_SYMBOL_COMMON: | 4730 | 202 | dst->symbol.section = bfd_com_section_ptr; | 4731 | 202 | dst->symbol.value = src->u.syment.n_value; | 4732 | 202 | break; | 4733 | | | 4734 | 58 | case COFF_SYMBOL_UNDEFINED: | 4735 | 58 | dst->symbol.section = bfd_und_section_ptr; | 4736 | 58 | dst->symbol.value = 0; | 4737 | 58 | break; | 4738 | | | 4739 | 0 | case COFF_SYMBOL_PE_SECTION: | 4740 | 0 | dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM; | 4741 | 0 | dst->symbol.value = 0; | 4742 | 0 | break; | 4743 | | | 4744 | 246 | case COFF_SYMBOL_LOCAL: | 4745 | 246 | dst->symbol.flags = BSF_LOCAL; | 4746 | | #if defined COFF_WITH_PE | 4747 | | /* PE sets the symbol to a value relative to the | 4748 | | start of the section. */ | 4749 | | dst->symbol.value = src->u.syment.n_value; | 4750 | | #else | 4751 | 246 | dst->symbol.value = (src->u.syment.n_value | 4752 | 246 | - dst->symbol.section->vma); | 4753 | 246 | #endif | 4754 | 246 | if (ISFCN ((src->u.syment.n_type))) | 4755 | 216 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4756 | 246 | break; | 4757 | 3.90k | } | 4758 | | | 4759 | 3.90k | #ifdef RS6000COFF_C | 4760 | | /* A symbol with a csect entry should not go at the end. */ | 4761 | 3.90k | if (src->u.syment.n_numaux > 0) | 4762 | 3.33k | dst->symbol.flags |= BSF_NOT_AT_END; | 4763 | 3.90k | #endif | 4764 | | | 4765 | | #ifdef COFF_WITH_PE | 4766 | | if (src->u.syment.n_sclass == C_NT_WEAK) | 4767 | | dst->symbol.flags |= BSF_WEAK; | 4768 | | | 4769 | | if (src->u.syment.n_sclass == C_SECTION | 4770 | | && src->u.syment.n_scnum > 0) | 4771 | | dst->symbol.flags = BSF_LOCAL; | 4772 | | #endif | 4773 | 3.90k | if (src->u.syment.n_sclass == C_WEAKEXT | 4774 | 3.90k | #ifdef RS6000COFF_C | 4775 | 3.90k | || src->u.syment.n_sclass == C_AIX_WEAKEXT | 4776 | 3.90k | #endif | 4777 | 3.90k | ) | 4778 | 327 | dst->symbol.flags |= BSF_WEAK; | 4779 | | | 4780 | 3.90k | break; | 4781 | | | 4782 | 491 | case C_STAT: /* Static. */ | 4783 | | #if defined ARM | 4784 | | case C_THUMBSTAT: /* Thumb static. */ | 4785 | | case C_THUMBLABEL: /* Thumb label. */ | 4786 | | case C_THUMBSTATFUNC:/* Thumb static function. */ | 4787 | | #endif | 4788 | 491 | #ifdef RS6000COFF_C | 4789 | 717 | case C_DWARF: /* A label in a dwarf section. */ | 4790 | 796 | case C_INFO: /* A label in a comment section. */ | 4791 | 796 | #endif | 4792 | 1.01k | case C_LABEL: /* Label. */ | 4793 | 1.01k | if (src->u.syment.n_scnum == N_DEBUG) | 4794 | 1 | dst->symbol.flags = BSF_DEBUGGING; | 4795 | 1.01k | else | 4796 | 1.01k | dst->symbol.flags = BSF_LOCAL; | 4797 | | | 4798 | | /* Base the value as an index from the base of the | 4799 | | section, if there is one. */ | 4800 | 1.01k | if (dst->symbol.section) | 4801 | 1.01k | { | 4802 | | #if defined COFF_WITH_PE | 4803 | | /* PE sets the symbol to a value relative to the | 4804 | | start of the section. */ | 4805 | | dst->symbol.value = src->u.syment.n_value; | 4806 | | #else | 4807 | 1.01k | dst->symbol.value = (src->u.syment.n_value | 4808 | 1.01k | - dst->symbol.section->vma); | 4809 | 1.01k | #endif | 4810 | 1.01k | } | 4811 | 0 | else | 4812 | 0 | dst->symbol.value = src->u.syment.n_value; | 4813 | 1.01k | break; | 4814 | | | 4815 | 224 | case C_FILE: /* File name. */ | 4816 | 224 | dst->symbol.flags = BSF_FILE; | 4817 | | /* Fall through. */ | 4818 | 5.25k | case C_MOS: /* Member of structure. */ | 4819 | 5.67k | case C_EOS: /* End of structure. */ | 4820 | 5.78k | case C_REGPARM: /* Register parameter. */ | 4821 | 6.27k | case C_REG: /* register variable. */ | 4822 | | /* C_AUTOARG conflicts with TI COFF C_UEXT. */ | 4823 | 6.55k | case C_TPDEF: /* Type definition. */ | 4824 | 8.71k | case C_ARG: | 4825 | 13.7k | case C_AUTO: /* Automatic variable. */ | 4826 | 14.0k | case C_FIELD: /* Bit field. */ | 4827 | 14.2k | case C_ENTAG: /* Enumeration tag. */ | 4828 | 14.6k | case C_MOE: /* Member of enumeration. */ | 4829 | 14.7k | case C_MOU: /* Member of union. */ | 4830 | 15.3k | case C_UNTAG: /* Union tag. */ | 4831 | 15.9k | case C_STRTAG: /* Structure tag. */ | 4832 | 15.9k | #ifdef RS6000COFF_C | 4833 | 16.4k | case C_GSYM: | 4834 | 16.9k | case C_LSYM: | 4835 | 17.0k | case C_PSYM: | 4836 | 17.0k | case C_RSYM: | 4837 | 17.2k | case C_RPSYM: | 4838 | 17.3k | case C_STSYM: | 4839 | 17.5k | case C_TCSYM: | 4840 | 17.6k | case C_BCOMM: | 4841 | 17.7k | case C_ECOML: | 4842 | 17.8k | case C_ECOMM: | 4843 | 18.1k | case C_DECL: | 4844 | 18.2k | case C_ENTRY: | 4845 | 18.3k | case C_FUN: | 4846 | 18.6k | case C_ESTAT: | 4847 | 18.6k | #endif | 4848 | 18.6k | dst->symbol.flags |= BSF_DEBUGGING; | 4849 | 18.6k | dst->symbol.value = (src->u.syment.n_value); | 4850 | 18.6k | break; | 4851 | | | 4852 | 0 | #ifdef RS6000COFF_C | 4853 | 172 | case C_BINCL: /* Beginning of include file. */ | 4854 | 310 | case C_EINCL: /* Ending of include file. */ | 4855 | | /* The value is actually a pointer into the line numbers | 4856 | | of the file. We locate the line number entry, and | 4857 | | set the section to the section which contains it, and | 4858 | | the value to the index in that section. */ | 4859 | 310 | { | 4860 | 310 | asection *sec; | 4861 | | | 4862 | 310 | dst->symbol.flags = BSF_DEBUGGING; | 4863 | 47.6k | for (sec = abfd->sections; sec != NULL; sec = sec->next) | 4864 | 47.3k | if (sec->line_filepos <= (file_ptr) src->u.syment.n_value | 4865 | 47.3k | && ((file_ptr) (sec->line_filepos | 4866 | 43.7k | + sec->lineno_count * bfd_coff_linesz (abfd)) | 4867 | 43.7k | > (file_ptr) src->u.syment.n_value)) | 4868 | 74 | break; | 4869 | 310 | if (sec == NULL) | 4870 | 236 | dst->symbol.value = 0; | 4871 | 74 | else | 4872 | 74 | { | 4873 | 74 | dst->symbol.section = sec; | 4874 | 74 | dst->symbol.value = ((src->u.syment.n_value | 4875 | 74 | - sec->line_filepos) | 4876 | 74 | / bfd_coff_linesz (abfd)); | 4877 | 74 | src->fix_line = 1; | 4878 | 74 | } | 4879 | 310 | } | 4880 | 310 | break; | 4881 | | | 4882 | 143 | case C_BSTAT: | 4883 | 143 | dst->symbol.flags = BSF_DEBUGGING; | 4884 | | | 4885 | 143 | if (src->u.syment.n_value >= obj_raw_syment_count (abfd)) | 4886 | 129 | dst->symbol.value = 0; | 4887 | 14 | else | 4888 | 14 | { | 4889 | | /* The value is actually a symbol index. Save a pointer | 4890 | | to the symbol instead of the index. FIXME: This | 4891 | | should use a union. */ | 4892 | 14 | src->u.syment.n_value | 4893 | 14 | = (uintptr_t) (native_symbols + src->u.syment.n_value); | 4894 | 14 | dst->symbol.value = src->u.syment.n_value; | 4895 | 14 | src->fix_value = 1; | 4896 | 14 | } | 4897 | 143 | break; | 4898 | 0 | #endif | 4899 | | | 4900 | 76 | case C_BLOCK: /* ".bb" or ".eb". */ | 4901 | 280 | case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */ | 4902 | 707 | case C_EFCN: /* Physical end of function. */ | 4903 | | #if defined COFF_WITH_PE | 4904 | | /* PE sets the symbol to a value relative to the start | 4905 | | of the section. */ | 4906 | | dst->symbol.value = src->u.syment.n_value; | 4907 | | if (strcmp (dst->symbol.name, ".bf") != 0) | 4908 | | { | 4909 | | /* PE uses funny values for .ef and .lf; don't | 4910 | | relocate them. */ | 4911 | | dst->symbol.flags = BSF_DEBUGGING; | 4912 | | } | 4913 | | else | 4914 | | dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC; | 4915 | | #else | 4916 | | /* Base the value as an index from the base of the | 4917 | | section. */ | 4918 | 707 | dst->symbol.flags = BSF_LOCAL; | 4919 | 707 | dst->symbol.value = (src->u.syment.n_value | 4920 | 707 | - dst->symbol.section->vma); | 4921 | 707 | #endif | 4922 | 707 | break; | 4923 | | | 4924 | 643 | case C_STATLAB: /* Static load time label. */ | 4925 | 643 | dst->symbol.value = src->u.syment.n_value; | 4926 | 643 | dst->symbol.flags = BSF_GLOBAL; | 4927 | 643 | break; | 4928 | | | 4929 | 62.9k | case C_NULL: | 4930 | | /* PE DLLs sometimes have zeroed out symbols for some | 4931 | | reason. Just ignore them without a warning. */ | 4932 | 62.9k | if (src->u.syment.n_type == 0 | 4933 | 62.9k | && src->u.syment.n_value == 0 | 4934 | 62.9k | && src->u.syment.n_scnum == 0) | 4935 | 28.8k | break; | 4936 | 34.1k | #ifdef RS6000COFF_C | 4937 | | /* XCOFF specific: deleted entry. */ | 4938 | 34.1k | if (src->u.syment.n_value == C_NULL_VALUE) | 4939 | 0 | break; | 4940 | 34.1k | #endif | 4941 | | /* Fall through. */ | 4942 | 34.2k | case C_EXTDEF: /* External definition. */ | 4943 | 34.5k | case C_ULABEL: /* Undefined label. */ | 4944 | 34.7k | case C_USTATIC: /* Undefined static. */ | 4945 | 34.7k | #ifndef COFF_WITH_PE | 4946 | | /* C_LINE in regular coff is 0x68. NT has taken over this storage | 4947 | | class to represent a section symbol. */ | 4948 | 34.8k | case C_LINE: /* line # reformatted as symbol table entry. */ | 4949 | | /* NT uses 0x67 for a weak symbol, not C_ALIAS. */ | 4950 | 34.8k | case C_ALIAS: /* Duplicate tag. */ | 4951 | 34.8k | #endif | 4952 | | /* New storage classes for TI COFF. */ | 4953 | | #ifdef TICOFF | 4954 | | case C_UEXT: /* Tentative external definition. */ | 4955 | | #endif | 4956 | 34.9k | case C_EXTLAB: /* External load time label. */ | 4957 | 46.5k | default: | 4958 | 46.5k | _bfd_error_handler | 4959 | | /* xgettext:c-format */ | 4960 | 46.5k | (_("%pB: unrecognized storage class %d for %s symbol `%s'"), | 4961 | 46.5k | abfd, src->u.syment.n_sclass, | 4962 | 46.5k | dst->symbol.section->name, dst->symbol.name); | 4963 | 46.5k | ret = false; | 4964 | | /* Fall through. */ | 4965 | 46.6k | case C_HIDDEN: /* Ext symbol in dmert public lib. */ | 4966 | | /* PR 20722: These symbols can also be generated by | 4967 | | building DLLs with --gc-sections enabled. */ | 4968 | 46.6k | dst->symbol.flags = BSF_DEBUGGING; | 4969 | 46.6k | dst->symbol.value = (src->u.syment.n_value); | 4970 | 46.6k | break; | 4971 | 100k | } | 4972 | | | 4973 | 100k | dst->native = src; | 4974 | 100k | dst->symbol.udata.i = 0; | 4975 | 100k | dst->lineno = NULL; | 4976 | | | 4977 | 100k | this_index += (src->u.syment.n_numaux) + 1; | 4978 | 100k | dst++; | 4979 | 100k | number_of_symbols++; | 4980 | 100k | } | 4981 | 343 | } | 4982 | | | 4983 | 343 | obj_symbols (abfd) = cached_area; | 4984 | 343 | obj_raw_syments (abfd) = native_symbols; | 4985 | | | 4986 | 343 | abfd->symcount = number_of_symbols; | 4987 | 343 | obj_convert (abfd) = table_ptr; | 4988 | | /* Slurp the line tables for each section too. */ | 4989 | 343 | { | 4990 | 343 | asection *p; | 4991 | | | 4992 | 343 | p = abfd->sections; | 4993 | 2.03k | while (p) | 4994 | 1.90k | { | 4995 | 1.90k | if (! coff_slurp_line_table (abfd, p)) | 4996 | 217 | return false; | 4997 | 1.69k | p = p->next; | 4998 | 1.69k | } | 4999 | 343 | } | 5000 | | | 5001 | 126 | return ret; | 5002 | 343 | } |
Unexecuted instantiation: coff-sh.c:coff_slurp_symbol_table Unexecuted instantiation: coff-stgo32.c:coff_slurp_symbol_table coff-tic30.c:coff_slurp_symbol_table Line | Count | Source | 4630 | 1.24k | { | 4631 | 1.24k | combined_entry_type *native_symbols; | 4632 | 1.24k | coff_symbol_type *cached_area; | 4633 | 1.24k | unsigned int *table_ptr; | 4634 | 1.24k | unsigned int number_of_symbols = 0; | 4635 | 1.24k | bool ret = true; | 4636 | 1.24k | size_t amt; | 4637 | | | 4638 | 1.24k | if (obj_symbols (abfd)) | 4639 | 820 | return true; | 4640 | | | 4641 | | /* Read in the symbol table. */ | 4642 | 424 | if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) | 4643 | 159 | return false; | 4644 | | | 4645 | | /* Allocate enough room for all the symbols in cached form. */ | 4646 | 265 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4647 | 265 | sizeof (*cached_area), &amt)) | 4648 | 0 | { | 4649 | 0 | bfd_set_error (bfd_error_file_too_big); | 4650 | 0 | return false; | 4651 | 0 | } | 4652 | 265 | cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt); | 4653 | 265 | if (cached_area == NULL) | 4654 | 0 | return false; | 4655 | | | 4656 | 265 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4657 | 265 | sizeof (*table_ptr), &amt)) | 4658 | 0 | { | 4659 | 0 | bfd_set_error (bfd_error_file_too_big); | 4660 | 0 | return false; | 4661 | 0 | } | 4662 | 265 | table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); | 4663 | 265 | if (table_ptr == NULL) | 4664 | 0 | return false; | 4665 | 265 | else | 4666 | 265 | { | 4667 | 265 | coff_symbol_type *dst = cached_area; | 4668 | 265 | unsigned int last_native_index = obj_raw_syment_count (abfd); | 4669 | 265 | unsigned int this_index = 0; | 4670 | | | 4671 | 16.9k | while (this_index < last_native_index) | 4672 | 16.7k | { | 4673 | 16.7k | combined_entry_type *src = native_symbols + this_index; | 4674 | 16.7k | table_ptr[this_index] = number_of_symbols; | 4675 | | | 4676 | 16.7k | dst->symbol.the_bfd = abfd; | 4677 | 16.7k | BFD_ASSERT (src->is_sym); | 4678 | 16.7k | dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset); | 4679 | | /* We use the native name field to point to the cached field. */ | 4680 | 16.7k | src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; | 4681 | 16.7k | dst->symbol.section = coff_section_from_bfd_index (abfd, | 4682 | 16.7k | src->u.syment.n_scnum); | 4683 | 16.7k | dst->symbol.flags = 0; | 4684 | | /* PR 17512: file: 079-7098-0.001:0.1. */ | 4685 | 16.7k | dst->symbol.value = 0; | 4686 | 16.7k | dst->done_lineno = false; | 4687 | | | 4688 | 16.7k | switch (src->u.syment.n_sclass) | 4689 | 16.7k | { | 4690 | 768 | case C_EXT: | 4691 | 778 | case C_WEAKEXT: | 4692 | | #if defined ARM | 4693 | | case C_THUMBEXT: | 4694 | | case C_THUMBEXTFUNC: | 4695 | | #endif | 4696 | | #ifdef RS6000COFF_C | 4697 | | case C_HIDEXT: | 4698 | | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 4699 | | case C_AIX_WEAKEXT: | 4700 | | #endif | 4701 | | #endif | 4702 | 778 | #ifdef C_SYSTEM | 4703 | 791 | case C_SYSTEM: /* System Wide variable. */ | 4704 | 791 | #endif | 4705 | | #ifdef COFF_WITH_PE | 4706 | | /* In PE, 0x68 (104) denotes a section symbol. */ | 4707 | | case C_SECTION: | 4708 | | /* In PE, 0x69 (105) denotes a weak external symbol. */ | 4709 | | case C_NT_WEAK: | 4710 | | #endif | 4711 | 791 | switch (coff_classify_symbol (abfd, &src->u.syment)) | 4712 | 791 | { | 4713 | 719 | case COFF_SYMBOL_GLOBAL: | 4714 | 719 | dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL; | 4715 | | #if defined COFF_WITH_PE | 4716 | | /* PE sets the symbol to a value relative to the | 4717 | | start of the section. */ | 4718 | | dst->symbol.value = src->u.syment.n_value; | 4719 | | #else | 4720 | 719 | dst->symbol.value = (src->u.syment.n_value | 4721 | 719 | - dst->symbol.section->vma); | 4722 | 719 | #endif | 4723 | 719 | if (ISFCN ((src->u.syment.n_type))) | 4724 | | /* A function ext does not go at the end of a | 4725 | | file. */ | 4726 | 3 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4727 | 719 | break; | 4728 | | | 4729 | 26 | case COFF_SYMBOL_COMMON: | 4730 | 26 | dst->symbol.section = bfd_com_section_ptr; | 4731 | 26 | dst->symbol.value = src->u.syment.n_value; | 4732 | 26 | break; | 4733 | | | 4734 | 46 | case COFF_SYMBOL_UNDEFINED: | 4735 | 46 | dst->symbol.section = bfd_und_section_ptr; | 4736 | 46 | dst->symbol.value = 0; | 4737 | 46 | break; | 4738 | | | 4739 | 0 | case COFF_SYMBOL_PE_SECTION: | 4740 | 0 | dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM; | 4741 | 0 | dst->symbol.value = 0; | 4742 | 0 | break; | 4743 | | | 4744 | 0 | case COFF_SYMBOL_LOCAL: | 4745 | 0 | dst->symbol.flags = BSF_LOCAL; | 4746 | | #if defined COFF_WITH_PE | 4747 | | /* PE sets the symbol to a value relative to the | 4748 | | start of the section. */ | 4749 | | dst->symbol.value = src->u.syment.n_value; | 4750 | | #else | 4751 | 0 | dst->symbol.value = (src->u.syment.n_value | 4752 | 0 | - dst->symbol.section->vma); | 4753 | 0 | #endif | 4754 | 0 | if (ISFCN ((src->u.syment.n_type))) | 4755 | 0 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4756 | 0 | break; | 4757 | 791 | } | 4758 | | | 4759 | | #ifdef RS6000COFF_C | 4760 | | /* A symbol with a csect entry should not go at the end. */ | 4761 | | if (src->u.syment.n_numaux > 0) | 4762 | | dst->symbol.flags |= BSF_NOT_AT_END; | 4763 | | #endif | 4764 | | | 4765 | | #ifdef COFF_WITH_PE | 4766 | | if (src->u.syment.n_sclass == C_NT_WEAK) | 4767 | | dst->symbol.flags |= BSF_WEAK; | 4768 | | | 4769 | | if (src->u.syment.n_sclass == C_SECTION | 4770 | | && src->u.syment.n_scnum > 0) | 4771 | | dst->symbol.flags = BSF_LOCAL; | 4772 | | #endif | 4773 | 791 | if (src->u.syment.n_sclass == C_WEAKEXT | 4774 | | #ifdef RS6000COFF_C | 4775 | | || src->u.syment.n_sclass == C_AIX_WEAKEXT | 4776 | | #endif | 4777 | 791 | ) | 4778 | 10 | dst->symbol.flags |= BSF_WEAK; | 4779 | | | 4780 | 791 | break; | 4781 | | | 4782 | 247 | case C_STAT: /* Static. */ | 4783 | | #if defined ARM | 4784 | | case C_THUMBSTAT: /* Thumb static. */ | 4785 | | case C_THUMBLABEL: /* Thumb label. */ | 4786 | | case C_THUMBSTATFUNC:/* Thumb static function. */ | 4787 | | #endif | 4788 | | #ifdef RS6000COFF_C | 4789 | | case C_DWARF: /* A label in a dwarf section. */ | 4790 | | case C_INFO: /* A label in a comment section. */ | 4791 | | #endif | 4792 | 293 | case C_LABEL: /* Label. */ | 4793 | 293 | if (src->u.syment.n_scnum == N_DEBUG) | 4794 | 0 | dst->symbol.flags = BSF_DEBUGGING; | 4795 | 293 | else | 4796 | 293 | dst->symbol.flags = BSF_LOCAL; | 4797 | | | 4798 | | /* Base the value as an index from the base of the | 4799 | | section, if there is one. */ | 4800 | 293 | if (dst->symbol.section) | 4801 | 293 | { | 4802 | | #if defined COFF_WITH_PE | 4803 | | /* PE sets the symbol to a value relative to the | 4804 | | start of the section. */ | 4805 | | dst->symbol.value = src->u.syment.n_value; | 4806 | | #else | 4807 | 293 | dst->symbol.value = (src->u.syment.n_value | 4808 | 293 | - dst->symbol.section->vma); | 4809 | 293 | #endif | 4810 | 293 | } | 4811 | 0 | else | 4812 | 0 | dst->symbol.value = src->u.syment.n_value; | 4813 | 293 | break; | 4814 | | | 4815 | 85 | case C_FILE: /* File name. */ | 4816 | 85 | dst->symbol.flags = BSF_FILE; | 4817 | | /* Fall through. */ | 4818 | 163 | case C_MOS: /* Member of structure. */ | 4819 | 165 | case C_EOS: /* End of structure. */ | 4820 | 213 | case C_REGPARM: /* Register parameter. */ | 4821 | 288 | case C_REG: /* register variable. */ | 4822 | | /* C_AUTOARG conflicts with TI COFF C_UEXT. */ | 4823 | 353 | case C_TPDEF: /* Type definition. */ | 4824 | 397 | case C_ARG: | 4825 | 1.02k | case C_AUTO: /* Automatic variable. */ | 4826 | 1.20k | case C_FIELD: /* Bit field. */ | 4827 | 1.27k | case C_ENTAG: /* Enumeration tag. */ | 4828 | 1.40k | case C_MOE: /* Member of enumeration. */ | 4829 | 1.50k | case C_MOU: /* Member of union. */ | 4830 | 1.67k | case C_UNTAG: /* Union tag. */ | 4831 | 1.82k | case C_STRTAG: /* Structure tag. */ | 4832 | | #ifdef RS6000COFF_C | 4833 | | case C_GSYM: | 4834 | | case C_LSYM: | 4835 | | case C_PSYM: | 4836 | | case C_RSYM: | 4837 | | case C_RPSYM: | 4838 | | case C_STSYM: | 4839 | | case C_TCSYM: | 4840 | | case C_BCOMM: | 4841 | | case C_ECOML: | 4842 | | case C_ECOMM: | 4843 | | case C_DECL: | 4844 | | case C_ENTRY: | 4845 | | case C_FUN: | 4846 | | case C_ESTAT: | 4847 | | #endif | 4848 | 1.82k | dst->symbol.flags |= BSF_DEBUGGING; | 4849 | 1.82k | dst->symbol.value = (src->u.syment.n_value); | 4850 | 1.82k | break; | 4851 | | | 4852 | | #ifdef RS6000COFF_C | 4853 | | case C_BINCL: /* Beginning of include file. */ | 4854 | | case C_EINCL: /* Ending of include file. */ | 4855 | | /* The value is actually a pointer into the line numbers | 4856 | | of the file. We locate the line number entry, and | 4857 | | set the section to the section which contains it, and | 4858 | | the value to the index in that section. */ | 4859 | | { | 4860 | | asection *sec; | 4861 | | | 4862 | | dst->symbol.flags = BSF_DEBUGGING; | 4863 | | for (sec = abfd->sections; sec != NULL; sec = sec->next) | 4864 | | if (sec->line_filepos <= (file_ptr) src->u.syment.n_value | 4865 | | && ((file_ptr) (sec->line_filepos | 4866 | | + sec->lineno_count * bfd_coff_linesz (abfd)) | 4867 | | > (file_ptr) src->u.syment.n_value)) | 4868 | | break; | 4869 | | if (sec == NULL) | 4870 | | dst->symbol.value = 0; | 4871 | | else | 4872 | | { | 4873 | | dst->symbol.section = sec; | 4874 | | dst->symbol.value = ((src->u.syment.n_value | 4875 | | - sec->line_filepos) | 4876 | | / bfd_coff_linesz (abfd)); | 4877 | | src->fix_line = 1; | 4878 | | } | 4879 | | } | 4880 | | break; | 4881 | | | 4882 | | case C_BSTAT: | 4883 | | dst->symbol.flags = BSF_DEBUGGING; | 4884 | | | 4885 | | if (src->u.syment.n_value >= obj_raw_syment_count (abfd)) | 4886 | | dst->symbol.value = 0; | 4887 | | else | 4888 | | { | 4889 | | /* The value is actually a symbol index. Save a pointer | 4890 | | to the symbol instead of the index. FIXME: This | 4891 | | should use a union. */ | 4892 | | src->u.syment.n_value | 4893 | | = (uintptr_t) (native_symbols + src->u.syment.n_value); | 4894 | | dst->symbol.value = src->u.syment.n_value; | 4895 | | src->fix_value = 1; | 4896 | | } | 4897 | | break; | 4898 | | #endif | 4899 | | | 4900 | 11 | case C_BLOCK: /* ".bb" or ".eb". */ | 4901 | 34 | case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */ | 4902 | 95 | case C_EFCN: /* Physical end of function. */ | 4903 | | #if defined COFF_WITH_PE | 4904 | | /* PE sets the symbol to a value relative to the start | 4905 | | of the section. */ | 4906 | | dst->symbol.value = src->u.syment.n_value; | 4907 | | if (strcmp (dst->symbol.name, ".bf") != 0) | 4908 | | { | 4909 | | /* PE uses funny values for .ef and .lf; don't | 4910 | | relocate them. */ | 4911 | | dst->symbol.flags = BSF_DEBUGGING; | 4912 | | } | 4913 | | else | 4914 | | dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC; | 4915 | | #else | 4916 | | /* Base the value as an index from the base of the | 4917 | | section. */ | 4918 | 95 | dst->symbol.flags = BSF_LOCAL; | 4919 | 95 | dst->symbol.value = (src->u.syment.n_value | 4920 | 95 | - dst->symbol.section->vma); | 4921 | 95 | #endif | 4922 | 95 | break; | 4923 | | | 4924 | 82 | case C_STATLAB: /* Static load time label. */ | 4925 | 82 | dst->symbol.value = src->u.syment.n_value; | 4926 | 82 | dst->symbol.flags = BSF_GLOBAL; | 4927 | 82 | break; | 4928 | | | 4929 | 11.9k | case C_NULL: | 4930 | | /* PE DLLs sometimes have zeroed out symbols for some | 4931 | | reason. Just ignore them without a warning. */ | 4932 | 11.9k | if (src->u.syment.n_type == 0 | 4933 | 11.9k | && src->u.syment.n_value == 0 | 4934 | 11.9k | && src->u.syment.n_scnum == 0) | 4935 | 6.20k | break; | 4936 | | #ifdef RS6000COFF_C | 4937 | | /* XCOFF specific: deleted entry. */ | 4938 | | if (src->u.syment.n_value == C_NULL_VALUE) | 4939 | | break; | 4940 | | #endif | 4941 | | /* Fall through. */ | 4942 | 5.78k | case C_EXTDEF: /* External definition. */ | 4943 | 5.81k | case C_ULABEL: /* Undefined label. */ | 4944 | 5.82k | case C_USTATIC: /* Undefined static. */ | 4945 | 5.82k | #ifndef COFF_WITH_PE | 4946 | | /* C_LINE in regular coff is 0x68. NT has taken over this storage | 4947 | | class to represent a section symbol. */ | 4948 | 5.83k | case C_LINE: /* line # reformatted as symbol table entry. */ | 4949 | | /* NT uses 0x67 for a weak symbol, not C_ALIAS. */ | 4950 | 5.84k | case C_ALIAS: /* Duplicate tag. */ | 4951 | 5.84k | #endif | 4952 | | /* New storage classes for TI COFF. */ | 4953 | | #ifdef TICOFF | 4954 | | case C_UEXT: /* Tentative external definition. */ | 4955 | | #endif | 4956 | 5.88k | case C_EXTLAB: /* External load time label. */ | 4957 | 7.41k | default: | 4958 | 7.41k | _bfd_error_handler | 4959 | | /* xgettext:c-format */ | 4960 | 7.41k | (_("%pB: unrecognized storage class %d for %s symbol `%s'"), | 4961 | 7.41k | abfd, src->u.syment.n_sclass, | 4962 | 7.41k | dst->symbol.section->name, dst->symbol.name); | 4963 | 7.41k | ret = false; | 4964 | | /* Fall through. */ | 4965 | 7.42k | case C_HIDDEN: /* Ext symbol in dmert public lib. */ | 4966 | | /* PR 20722: These symbols can also be generated by | 4967 | | building DLLs with --gc-sections enabled. */ | 4968 | 7.42k | dst->symbol.flags = BSF_DEBUGGING; | 4969 | 7.42k | dst->symbol.value = (src->u.syment.n_value); | 4970 | 7.42k | break; | 4971 | 16.7k | } | 4972 | | | 4973 | 16.7k | dst->native = src; | 4974 | 16.7k | dst->symbol.udata.i = 0; | 4975 | 16.7k | dst->lineno = NULL; | 4976 | | | 4977 | 16.7k | this_index += (src->u.syment.n_numaux) + 1; | 4978 | 16.7k | dst++; | 4979 | 16.7k | number_of_symbols++; | 4980 | 16.7k | } | 4981 | 265 | } | 4982 | | | 4983 | 265 | obj_symbols (abfd) = cached_area; | 4984 | 265 | obj_raw_syments (abfd) = native_symbols; | 4985 | | | 4986 | 265 | abfd->symcount = number_of_symbols; | 4987 | 265 | obj_convert (abfd) = table_ptr; | 4988 | | /* Slurp the line tables for each section too. */ | 4989 | 265 | { | 4990 | 265 | asection *p; | 4991 | | | 4992 | 265 | p = abfd->sections; | 4993 | 4.13k | while (p) | 4994 | 4.06k | { | 4995 | 4.06k | if (! coff_slurp_line_table (abfd, p)) | 4996 | 191 | return false; | 4997 | 3.87k | p = p->next; | 4998 | 3.87k | } | 4999 | 265 | } | 5000 | | | 5001 | 74 | return ret; | 5002 | 265 | } |
Unexecuted instantiation: coff-tic4x.c:coff_slurp_symbol_table coff-tic54x.c:coff_slurp_symbol_table Line | Count | Source | 4630 | 571 | { | 4631 | 571 | combined_entry_type *native_symbols; | 4632 | 571 | coff_symbol_type *cached_area; | 4633 | 571 | unsigned int *table_ptr; | 4634 | 571 | unsigned int number_of_symbols = 0; | 4635 | 571 | bool ret = true; | 4636 | 571 | size_t amt; | 4637 | | | 4638 | 571 | if (obj_symbols (abfd)) | 4639 | 176 | return true; | 4640 | | | 4641 | | /* Read in the symbol table. */ | 4642 | 395 | if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) | 4643 | 180 | return false; | 4644 | | | 4645 | | /* Allocate enough room for all the symbols in cached form. */ | 4646 | 215 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4647 | 215 | sizeof (*cached_area), &amt)) | 4648 | 0 | { | 4649 | 0 | bfd_set_error (bfd_error_file_too_big); | 4650 | 0 | return false; | 4651 | 0 | } | 4652 | 215 | cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt); | 4653 | 215 | if (cached_area == NULL) | 4654 | 0 | return false; | 4655 | | | 4656 | 215 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4657 | 215 | sizeof (*table_ptr), &amt)) | 4658 | 0 | { | 4659 | 0 | bfd_set_error (bfd_error_file_too_big); | 4660 | 0 | return false; | 4661 | 0 | } | 4662 | 215 | table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); | 4663 | 215 | if (table_ptr == NULL) | 4664 | 0 | return false; | 4665 | 215 | else | 4666 | 215 | { | 4667 | 215 | coff_symbol_type *dst = cached_area; | 4668 | 215 | unsigned int last_native_index = obj_raw_syment_count (abfd); | 4669 | 215 | unsigned int this_index = 0; | 4670 | | | 4671 | 31.7k | while (this_index < last_native_index) | 4672 | 31.5k | { | 4673 | 31.5k | combined_entry_type *src = native_symbols + this_index; | 4674 | 31.5k | table_ptr[this_index] = number_of_symbols; | 4675 | | | 4676 | 31.5k | dst->symbol.the_bfd = abfd; | 4677 | 31.5k | BFD_ASSERT (src->is_sym); | 4678 | 31.5k | dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset); | 4679 | | /* We use the native name field to point to the cached field. */ | 4680 | 31.5k | src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; | 4681 | 31.5k | dst->symbol.section = coff_section_from_bfd_index (abfd, | 4682 | 31.5k | src->u.syment.n_scnum); | 4683 | 31.5k | dst->symbol.flags = 0; | 4684 | | /* PR 17512: file: 079-7098-0.001:0.1. */ | 4685 | 31.5k | dst->symbol.value = 0; | 4686 | 31.5k | dst->done_lineno = false; | 4687 | | | 4688 | 31.5k | switch (src->u.syment.n_sclass) | 4689 | 31.5k | { | 4690 | 798 | case C_EXT: | 4691 | 813 | case C_WEAKEXT: | 4692 | | #if defined ARM | 4693 | | case C_THUMBEXT: | 4694 | | case C_THUMBEXTFUNC: | 4695 | | #endif | 4696 | | #ifdef RS6000COFF_C | 4697 | | case C_HIDEXT: | 4698 | | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 4699 | | case C_AIX_WEAKEXT: | 4700 | | #endif | 4701 | | #endif | 4702 | 813 | #ifdef C_SYSTEM | 4703 | 836 | case C_SYSTEM: /* System Wide variable. */ | 4704 | 836 | #endif | 4705 | | #ifdef COFF_WITH_PE | 4706 | | /* In PE, 0x68 (104) denotes a section symbol. */ | 4707 | | case C_SECTION: | 4708 | | /* In PE, 0x69 (105) denotes a weak external symbol. */ | 4709 | | case C_NT_WEAK: | 4710 | | #endif | 4711 | 836 | switch (coff_classify_symbol (abfd, &src->u.syment)) | 4712 | 836 | { | 4713 | 759 | case COFF_SYMBOL_GLOBAL: | 4714 | 759 | dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL; | 4715 | | #if defined COFF_WITH_PE | 4716 | | /* PE sets the symbol to a value relative to the | 4717 | | start of the section. */ | 4718 | | dst->symbol.value = src->u.syment.n_value; | 4719 | | #else | 4720 | 759 | dst->symbol.value = (src->u.syment.n_value | 4721 | 759 | - dst->symbol.section->vma); | 4722 | 759 | #endif | 4723 | 759 | if (ISFCN ((src->u.syment.n_type))) | 4724 | | /* A function ext does not go at the end of a | 4725 | | file. */ | 4726 | 7 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4727 | 759 | break; | 4728 | | | 4729 | 42 | case COFF_SYMBOL_COMMON: | 4730 | 42 | dst->symbol.section = bfd_com_section_ptr; | 4731 | 42 | dst->symbol.value = src->u.syment.n_value; | 4732 | 42 | break; | 4733 | | | 4734 | 35 | case COFF_SYMBOL_UNDEFINED: | 4735 | 35 | dst->symbol.section = bfd_und_section_ptr; | 4736 | 35 | dst->symbol.value = 0; | 4737 | 35 | break; | 4738 | | | 4739 | 0 | case COFF_SYMBOL_PE_SECTION: | 4740 | 0 | dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM; | 4741 | 0 | dst->symbol.value = 0; | 4742 | 0 | break; | 4743 | | | 4744 | 0 | case COFF_SYMBOL_LOCAL: | 4745 | 0 | dst->symbol.flags = BSF_LOCAL; | 4746 | | #if defined COFF_WITH_PE | 4747 | | /* PE sets the symbol to a value relative to the | 4748 | | start of the section. */ | 4749 | | dst->symbol.value = src->u.syment.n_value; | 4750 | | #else | 4751 | 0 | dst->symbol.value = (src->u.syment.n_value | 4752 | 0 | - dst->symbol.section->vma); | 4753 | 0 | #endif | 4754 | 0 | if (ISFCN ((src->u.syment.n_type))) | 4755 | 0 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4756 | 0 | break; | 4757 | 836 | } | 4758 | | | 4759 | | #ifdef RS6000COFF_C | 4760 | | /* A symbol with a csect entry should not go at the end. */ | 4761 | | if (src->u.syment.n_numaux > 0) | 4762 | | dst->symbol.flags |= BSF_NOT_AT_END; | 4763 | | #endif | 4764 | | | 4765 | | #ifdef COFF_WITH_PE | 4766 | | if (src->u.syment.n_sclass == C_NT_WEAK) | 4767 | | dst->symbol.flags |= BSF_WEAK; | 4768 | | | 4769 | | if (src->u.syment.n_sclass == C_SECTION | 4770 | | && src->u.syment.n_scnum > 0) | 4771 | | dst->symbol.flags = BSF_LOCAL; | 4772 | | #endif | 4773 | 836 | if (src->u.syment.n_sclass == C_WEAKEXT | 4774 | | #ifdef RS6000COFF_C | 4775 | | || src->u.syment.n_sclass == C_AIX_WEAKEXT | 4776 | | #endif | 4777 | 836 | ) | 4778 | 15 | dst->symbol.flags |= BSF_WEAK; | 4779 | | | 4780 | 836 | break; | 4781 | | | 4782 | 328 | case C_STAT: /* Static. */ | 4783 | | #if defined ARM | 4784 | | case C_THUMBSTAT: /* Thumb static. */ | 4785 | | case C_THUMBLABEL: /* Thumb label. */ | 4786 | | case C_THUMBSTATFUNC:/* Thumb static function. */ | 4787 | | #endif | 4788 | | #ifdef RS6000COFF_C | 4789 | | case C_DWARF: /* A label in a dwarf section. */ | 4790 | | case C_INFO: /* A label in a comment section. */ | 4791 | | #endif | 4792 | 557 | case C_LABEL: /* Label. */ | 4793 | 557 | if (src->u.syment.n_scnum == N_DEBUG) | 4794 | 1 | dst->symbol.flags = BSF_DEBUGGING; | 4795 | 556 | else | 4796 | 556 | dst->symbol.flags = BSF_LOCAL; | 4797 | | | 4798 | | /* Base the value as an index from the base of the | 4799 | | section, if there is one. */ | 4800 | 557 | if (dst->symbol.section) | 4801 | 557 | { | 4802 | | #if defined COFF_WITH_PE | 4803 | | /* PE sets the symbol to a value relative to the | 4804 | | start of the section. */ | 4805 | | dst->symbol.value = src->u.syment.n_value; | 4806 | | #else | 4807 | 557 | dst->symbol.value = (src->u.syment.n_value | 4808 | 557 | - dst->symbol.section->vma); | 4809 | 557 | #endif | 4810 | 557 | } | 4811 | 0 | else | 4812 | 0 | dst->symbol.value = src->u.syment.n_value; | 4813 | 557 | break; | 4814 | | | 4815 | 57 | case C_FILE: /* File name. */ | 4816 | 57 | dst->symbol.flags = BSF_FILE; | 4817 | | /* Fall through. */ | 4818 | 267 | case C_MOS: /* Member of structure. */ | 4819 | 286 | case C_EOS: /* End of structure. */ | 4820 | 311 | case C_REGPARM: /* Register parameter. */ | 4821 | 550 | case C_REG: /* register variable. */ | 4822 | | /* C_AUTOARG conflicts with TI COFF C_UEXT. */ | 4823 | 696 | case C_TPDEF: /* Type definition. */ | 4824 | 775 | case C_ARG: | 4825 | 2.08k | case C_AUTO: /* Automatic variable. */ | 4826 | 2.15k | case C_FIELD: /* Bit field. */ | 4827 | 2.27k | case C_ENTAG: /* Enumeration tag. */ | 4828 | 2.45k | case C_MOE: /* Member of enumeration. */ | 4829 | 2.50k | case C_MOU: /* Member of union. */ | 4830 | 2.67k | case C_UNTAG: /* Union tag. */ | 4831 | 2.99k | case C_STRTAG: /* Structure tag. */ | 4832 | | #ifdef RS6000COFF_C | 4833 | | case C_GSYM: | 4834 | | case C_LSYM: | 4835 | | case C_PSYM: | 4836 | | case C_RSYM: | 4837 | | case C_RPSYM: | 4838 | | case C_STSYM: | 4839 | | case C_TCSYM: | 4840 | | case C_BCOMM: | 4841 | | case C_ECOML: | 4842 | | case C_ECOMM: | 4843 | | case C_DECL: | 4844 | | case C_ENTRY: | 4845 | | case C_FUN: | 4846 | | case C_ESTAT: | 4847 | | #endif | 4848 | 2.99k | dst->symbol.flags |= BSF_DEBUGGING; | 4849 | 2.99k | dst->symbol.value = (src->u.syment.n_value); | 4850 | 2.99k | break; | 4851 | | | 4852 | | #ifdef RS6000COFF_C | 4853 | | case C_BINCL: /* Beginning of include file. */ | 4854 | | case C_EINCL: /* Ending of include file. */ | 4855 | | /* The value is actually a pointer into the line numbers | 4856 | | of the file. We locate the line number entry, and | 4857 | | set the section to the section which contains it, and | 4858 | | the value to the index in that section. */ | 4859 | | { | 4860 | | asection *sec; | 4861 | | | 4862 | | dst->symbol.flags = BSF_DEBUGGING; | 4863 | | for (sec = abfd->sections; sec != NULL; sec = sec->next) | 4864 | | if (sec->line_filepos <= (file_ptr) src->u.syment.n_value | 4865 | | && ((file_ptr) (sec->line_filepos | 4866 | | + sec->lineno_count * bfd_coff_linesz (abfd)) | 4867 | | > (file_ptr) src->u.syment.n_value)) | 4868 | | break; | 4869 | | if (sec == NULL) | 4870 | | dst->symbol.value = 0; | 4871 | | else | 4872 | | { | 4873 | | dst->symbol.section = sec; | 4874 | | dst->symbol.value = ((src->u.syment.n_value | 4875 | | - sec->line_filepos) | 4876 | | / bfd_coff_linesz (abfd)); | 4877 | | src->fix_line = 1; | 4878 | | } | 4879 | | } | 4880 | | break; | 4881 | | | 4882 | | case C_BSTAT: | 4883 | | dst->symbol.flags = BSF_DEBUGGING; | 4884 | | | 4885 | | if (src->u.syment.n_value >= obj_raw_syment_count (abfd)) | 4886 | | dst->symbol.value = 0; | 4887 | | else | 4888 | | { | 4889 | | /* The value is actually a symbol index. Save a pointer | 4890 | | to the symbol instead of the index. FIXME: This | 4891 | | should use a union. */ | 4892 | | src->u.syment.n_value | 4893 | | = (uintptr_t) (native_symbols + src->u.syment.n_value); | 4894 | | dst->symbol.value = src->u.syment.n_value; | 4895 | | src->fix_value = 1; | 4896 | | } | 4897 | | break; | 4898 | | #endif | 4899 | | | 4900 | 38 | case C_BLOCK: /* ".bb" or ".eb". */ | 4901 | 73 | case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */ | 4902 | 318 | case C_EFCN: /* Physical end of function. */ | 4903 | | #if defined COFF_WITH_PE | 4904 | | /* PE sets the symbol to a value relative to the start | 4905 | | of the section. */ | 4906 | | dst->symbol.value = src->u.syment.n_value; | 4907 | | if (strcmp (dst->symbol.name, ".bf") != 0) | 4908 | | { | 4909 | | /* PE uses funny values for .ef and .lf; don't | 4910 | | relocate them. */ | 4911 | | dst->symbol.flags = BSF_DEBUGGING; | 4912 | | } | 4913 | | else | 4914 | | dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC; | 4915 | | #else | 4916 | | /* Base the value as an index from the base of the | 4917 | | section. */ | 4918 | 318 | dst->symbol.flags = BSF_LOCAL; | 4919 | 318 | dst->symbol.value = (src->u.syment.n_value | 4920 | 318 | - dst->symbol.section->vma); | 4921 | 318 | #endif | 4922 | 318 | break; | 4923 | | | 4924 | 40 | case C_STATLAB: /* Static load time label. */ | 4925 | 40 | dst->symbol.value = src->u.syment.n_value; | 4926 | 40 | dst->symbol.flags = BSF_GLOBAL; | 4927 | 40 | break; | 4928 | | | 4929 | 23.4k | case C_NULL: | 4930 | | /* PE DLLs sometimes have zeroed out symbols for some | 4931 | | reason. Just ignore them without a warning. */ | 4932 | 23.4k | if (src->u.syment.n_type == 0 | 4933 | 23.4k | && src->u.syment.n_value == 0 | 4934 | 23.4k | && src->u.syment.n_scnum == 0) | 4935 | 12.7k | break; | 4936 | | #ifdef RS6000COFF_C | 4937 | | /* XCOFF specific: deleted entry. */ | 4938 | | if (src->u.syment.n_value == C_NULL_VALUE) | 4939 | | break; | 4940 | | #endif | 4941 | | /* Fall through. */ | 4942 | 10.8k | case C_EXTDEF: /* External definition. */ | 4943 | 10.9k | case C_ULABEL: /* Undefined label. */ | 4944 | 11.0k | case C_USTATIC: /* Undefined static. */ | 4945 | 11.0k | #ifndef COFF_WITH_PE | 4946 | | /* C_LINE in regular coff is 0x68. NT has taken over this storage | 4947 | | class to represent a section symbol. */ | 4948 | 11.0k | case C_LINE: /* line # reformatted as symbol table entry. */ | 4949 | | /* NT uses 0x67 for a weak symbol, not C_ALIAS. */ | 4950 | 11.0k | case C_ALIAS: /* Duplicate tag. */ | 4951 | 11.0k | #endif | 4952 | | /* New storage classes for TI COFF. */ | 4953 | 11.0k | #ifdef TICOFF | 4954 | 11.1k | case C_UEXT: /* Tentative external definition. */ | 4955 | 11.1k | #endif | 4956 | 11.1k | case C_EXTLAB: /* External load time label. */ | 4957 | 14.0k | default: | 4958 | 14.0k | _bfd_error_handler | 4959 | | /* xgettext:c-format */ | 4960 | 14.0k | (_("%pB: unrecognized storage class %d for %s symbol `%s'"), | 4961 | 14.0k | abfd, src->u.syment.n_sclass, | 4962 | 14.0k | dst->symbol.section->name, dst->symbol.name); | 4963 | 14.0k | ret = false; | 4964 | | /* Fall through. */ | 4965 | 14.0k | case C_HIDDEN: /* Ext symbol in dmert public lib. */ | 4966 | | /* PR 20722: These symbols can also be generated by | 4967 | | building DLLs with --gc-sections enabled. */ | 4968 | 14.0k | dst->symbol.flags = BSF_DEBUGGING; | 4969 | 14.0k | dst->symbol.value = (src->u.syment.n_value); | 4970 | 14.0k | break; | 4971 | 31.5k | } | 4972 | | | 4973 | 31.5k | dst->native = src; | 4974 | 31.5k | dst->symbol.udata.i = 0; | 4975 | 31.5k | dst->lineno = NULL; | 4976 | | | 4977 | 31.5k | this_index += (src->u.syment.n_numaux) + 1; | 4978 | 31.5k | dst++; | 4979 | 31.5k | number_of_symbols++; | 4980 | 31.5k | } | 4981 | 215 | } | 4982 | | | 4983 | 215 | obj_symbols (abfd) = cached_area; | 4984 | 215 | obj_raw_syments (abfd) = native_symbols; | 4985 | | | 4986 | 215 | abfd->symcount = number_of_symbols; | 4987 | 215 | obj_convert (abfd) = table_ptr; | 4988 | | /* Slurp the line tables for each section too. */ | 4989 | 215 | { | 4990 | 215 | asection *p; | 4991 | | | 4992 | 215 | p = abfd->sections; | 4993 | 3.37k | while (p) | 4994 | 3.32k | { | 4995 | 3.32k | if (! coff_slurp_line_table (abfd, p)) | 4996 | 170 | return false; | 4997 | 3.15k | p = p->next; | 4998 | 3.15k | } | 4999 | 215 | } | 5000 | | | 5001 | 45 | return ret; | 5002 | 215 | } |
coff-z80.c:coff_slurp_symbol_table Line | Count | Source | 4630 | 774 | { | 4631 | 774 | combined_entry_type *native_symbols; | 4632 | 774 | coff_symbol_type *cached_area; | 4633 | 774 | unsigned int *table_ptr; | 4634 | 774 | unsigned int number_of_symbols = 0; | 4635 | 774 | bool ret = true; | 4636 | 774 | size_t amt; | 4637 | | | 4638 | 774 | if (obj_symbols (abfd)) | 4639 | 415 | return true; | 4640 | | | 4641 | | /* Read in the symbol table. */ | 4642 | 359 | if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) | 4643 | 129 | return false; | 4644 | | | 4645 | | /* Allocate enough room for all the symbols in cached form. */ | 4646 | 230 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4647 | 230 | sizeof (*cached_area), &amt)) | 4648 | 0 | { | 4649 | 0 | bfd_set_error (bfd_error_file_too_big); | 4650 | 0 | return false; | 4651 | 0 | } | 4652 | 230 | cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt); | 4653 | 230 | if (cached_area == NULL) | 4654 | 0 | return false; | 4655 | | | 4656 | 230 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4657 | 230 | sizeof (*table_ptr), &amt)) | 4658 | 0 | { | 4659 | 0 | bfd_set_error (bfd_error_file_too_big); | 4660 | 0 | return false; | 4661 | 0 | } | 4662 | 230 | table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); | 4663 | 230 | if (table_ptr == NULL) | 4664 | 0 | return false; | 4665 | 230 | else | 4666 | 230 | { | 4667 | 230 | coff_symbol_type *dst = cached_area; | 4668 | 230 | unsigned int last_native_index = obj_raw_syment_count (abfd); | 4669 | 230 | unsigned int this_index = 0; | 4670 | | | 4671 | 32.3k | while (this_index < last_native_index) | 4672 | 32.1k | { | 4673 | 32.1k | combined_entry_type *src = native_symbols + this_index; | 4674 | 32.1k | table_ptr[this_index] = number_of_symbols; | 4675 | | | 4676 | 32.1k | dst->symbol.the_bfd = abfd; | 4677 | 32.1k | BFD_ASSERT (src->is_sym); | 4678 | 32.1k | dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset); | 4679 | | /* We use the native name field to point to the cached field. */ | 4680 | 32.1k | src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; | 4681 | 32.1k | dst->symbol.section = coff_section_from_bfd_index (abfd, | 4682 | 32.1k | src->u.syment.n_scnum); | 4683 | 32.1k | dst->symbol.flags = 0; | 4684 | | /* PR 17512: file: 079-7098-0.001:0.1. */ | 4685 | 32.1k | dst->symbol.value = 0; | 4686 | 32.1k | dst->done_lineno = false; | 4687 | | | 4688 | 32.1k | switch (src->u.syment.n_sclass) | 4689 | 32.1k | { | 4690 | 737 | case C_EXT: | 4691 | 776 | case C_WEAKEXT: | 4692 | | #if defined ARM | 4693 | | case C_THUMBEXT: | 4694 | | case C_THUMBEXTFUNC: | 4695 | | #endif | 4696 | | #ifdef RS6000COFF_C | 4697 | | case C_HIDEXT: | 4698 | | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 4699 | | case C_AIX_WEAKEXT: | 4700 | | #endif | 4701 | | #endif | 4702 | 776 | #ifdef C_SYSTEM | 4703 | 931 | case C_SYSTEM: /* System Wide variable. */ | 4704 | 931 | #endif | 4705 | | #ifdef COFF_WITH_PE | 4706 | | /* In PE, 0x68 (104) denotes a section symbol. */ | 4707 | | case C_SECTION: | 4708 | | /* In PE, 0x69 (105) denotes a weak external symbol. */ | 4709 | | case C_NT_WEAK: | 4710 | | #endif | 4711 | 931 | switch (coff_classify_symbol (abfd, &src->u.syment)) | 4712 | 931 | { | 4713 | 829 | case COFF_SYMBOL_GLOBAL: | 4714 | 829 | dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL; | 4715 | | #if defined COFF_WITH_PE | 4716 | | /* PE sets the symbol to a value relative to the | 4717 | | start of the section. */ | 4718 | | dst->symbol.value = src->u.syment.n_value; | 4719 | | #else | 4720 | 829 | dst->symbol.value = (src->u.syment.n_value | 4721 | 829 | - dst->symbol.section->vma); | 4722 | 829 | #endif | 4723 | 829 | if (ISFCN ((src->u.syment.n_type))) | 4724 | | /* A function ext does not go at the end of a | 4725 | | file. */ | 4726 | 15 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4727 | 829 | break; | 4728 | | | 4729 | 64 | case COFF_SYMBOL_COMMON: | 4730 | 64 | dst->symbol.section = bfd_com_section_ptr; | 4731 | 64 | dst->symbol.value = src->u.syment.n_value; | 4732 | 64 | break; | 4733 | | | 4734 | 38 | case COFF_SYMBOL_UNDEFINED: | 4735 | 38 | dst->symbol.section = bfd_und_section_ptr; | 4736 | 38 | dst->symbol.value = 0; | 4737 | 38 | break; | 4738 | | | 4739 | 0 | case COFF_SYMBOL_PE_SECTION: | 4740 | 0 | dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM; | 4741 | 0 | dst->symbol.value = 0; | 4742 | 0 | break; | 4743 | | | 4744 | 0 | case COFF_SYMBOL_LOCAL: | 4745 | 0 | dst->symbol.flags = BSF_LOCAL; | 4746 | | #if defined COFF_WITH_PE | 4747 | | /* PE sets the symbol to a value relative to the | 4748 | | start of the section. */ | 4749 | | dst->symbol.value = src->u.syment.n_value; | 4750 | | #else | 4751 | 0 | dst->symbol.value = (src->u.syment.n_value | 4752 | 0 | - dst->symbol.section->vma); | 4753 | 0 | #endif | 4754 | 0 | if (ISFCN ((src->u.syment.n_type))) | 4755 | 0 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4756 | 0 | break; | 4757 | 931 | } | 4758 | | | 4759 | | #ifdef RS6000COFF_C | 4760 | | /* A symbol with a csect entry should not go at the end. */ | 4761 | | if (src->u.syment.n_numaux > 0) | 4762 | | dst->symbol.flags |= BSF_NOT_AT_END; | 4763 | | #endif | 4764 | | | 4765 | | #ifdef COFF_WITH_PE | 4766 | | if (src->u.syment.n_sclass == C_NT_WEAK) | 4767 | | dst->symbol.flags |= BSF_WEAK; | 4768 | | | 4769 | | if (src->u.syment.n_sclass == C_SECTION | 4770 | | && src->u.syment.n_scnum > 0) | 4771 | | dst->symbol.flags = BSF_LOCAL; | 4772 | | #endif | 4773 | 931 | if (src->u.syment.n_sclass == C_WEAKEXT | 4774 | | #ifdef RS6000COFF_C | 4775 | | || src->u.syment.n_sclass == C_AIX_WEAKEXT | 4776 | | #endif | 4777 | 931 | ) | 4778 | 39 | dst->symbol.flags |= BSF_WEAK; | 4779 | | | 4780 | 931 | break; | 4781 | | | 4782 | 395 | case C_STAT: /* Static. */ | 4783 | | #if defined ARM | 4784 | | case C_THUMBSTAT: /* Thumb static. */ | 4785 | | case C_THUMBLABEL: /* Thumb label. */ | 4786 | | case C_THUMBSTATFUNC:/* Thumb static function. */ | 4787 | | #endif | 4788 | | #ifdef RS6000COFF_C | 4789 | | case C_DWARF: /* A label in a dwarf section. */ | 4790 | | case C_INFO: /* A label in a comment section. */ | 4791 | | #endif | 4792 | 701 | case C_LABEL: /* Label. */ | 4793 | 701 | if (src->u.syment.n_scnum == N_DEBUG) | 4794 | 0 | dst->symbol.flags = BSF_DEBUGGING; | 4795 | 701 | else | 4796 | 701 | dst->symbol.flags = BSF_LOCAL; | 4797 | | | 4798 | | /* Base the value as an index from the base of the | 4799 | | section, if there is one. */ | 4800 | 701 | if (dst->symbol.section) | 4801 | 701 | { | 4802 | | #if defined COFF_WITH_PE | 4803 | | /* PE sets the symbol to a value relative to the | 4804 | | start of the section. */ | 4805 | | dst->symbol.value = src->u.syment.n_value; | 4806 | | #else | 4807 | 701 | dst->symbol.value = (src->u.syment.n_value | 4808 | 701 | - dst->symbol.section->vma); | 4809 | 701 | #endif | 4810 | 701 | } | 4811 | 0 | else | 4812 | 0 | dst->symbol.value = src->u.syment.n_value; | 4813 | 701 | break; | 4814 | | | 4815 | 115 | case C_FILE: /* File name. */ | 4816 | 115 | dst->symbol.flags = BSF_FILE; | 4817 | | /* Fall through. */ | 4818 | 298 | case C_MOS: /* Member of structure. */ | 4819 | 329 | case C_EOS: /* End of structure. */ | 4820 | 654 | case C_REGPARM: /* Register parameter. */ | 4821 | 771 | case C_REG: /* register variable. */ | 4822 | | /* C_AUTOARG conflicts with TI COFF C_UEXT. */ | 4823 | 1.16k | case C_TPDEF: /* Type definition. */ | 4824 | 1.24k | case C_ARG: | 4825 | 2.87k | case C_AUTO: /* Automatic variable. */ | 4826 | 2.95k | case C_FIELD: /* Bit field. */ | 4827 | 3.10k | case C_ENTAG: /* Enumeration tag. */ | 4828 | 3.85k | case C_MOE: /* Member of enumeration. */ | 4829 | 3.93k | case C_MOU: /* Member of union. */ | 4830 | 4.22k | case C_UNTAG: /* Union tag. */ | 4831 | 4.47k | case C_STRTAG: /* Structure tag. */ | 4832 | | #ifdef RS6000COFF_C | 4833 | | case C_GSYM: | 4834 | | case C_LSYM: | 4835 | | case C_PSYM: | 4836 | | case C_RSYM: | 4837 | | case C_RPSYM: | 4838 | | case C_STSYM: | 4839 | | case C_TCSYM: | 4840 | | case C_BCOMM: | 4841 | | case C_ECOML: | 4842 | | case C_ECOMM: | 4843 | | case C_DECL: | 4844 | | case C_ENTRY: | 4845 | | case C_FUN: | 4846 | | case C_ESTAT: | 4847 | | #endif | 4848 | 4.47k | dst->symbol.flags |= BSF_DEBUGGING; | 4849 | 4.47k | dst->symbol.value = (src->u.syment.n_value); | 4850 | 4.47k | break; | 4851 | | | 4852 | | #ifdef RS6000COFF_C | 4853 | | case C_BINCL: /* Beginning of include file. */ | 4854 | | case C_EINCL: /* Ending of include file. */ | 4855 | | /* The value is actually a pointer into the line numbers | 4856 | | of the file. We locate the line number entry, and | 4857 | | set the section to the section which contains it, and | 4858 | | the value to the index in that section. */ | 4859 | | { | 4860 | | asection *sec; | 4861 | | | 4862 | | dst->symbol.flags = BSF_DEBUGGING; | 4863 | | for (sec = abfd->sections; sec != NULL; sec = sec->next) | 4864 | | if (sec->line_filepos <= (file_ptr) src->u.syment.n_value | 4865 | | && ((file_ptr) (sec->line_filepos | 4866 | | + sec->lineno_count * bfd_coff_linesz (abfd)) | 4867 | | > (file_ptr) src->u.syment.n_value)) | 4868 | | break; | 4869 | | if (sec == NULL) | 4870 | | dst->symbol.value = 0; | 4871 | | else | 4872 | | { | 4873 | | dst->symbol.section = sec; | 4874 | | dst->symbol.value = ((src->u.syment.n_value | 4875 | | - sec->line_filepos) | 4876 | | / bfd_coff_linesz (abfd)); | 4877 | | src->fix_line = 1; | 4878 | | } | 4879 | | } | 4880 | | break; | 4881 | | | 4882 | | case C_BSTAT: | 4883 | | dst->symbol.flags = BSF_DEBUGGING; | 4884 | | | 4885 | | if (src->u.syment.n_value >= obj_raw_syment_count (abfd)) | 4886 | | dst->symbol.value = 0; | 4887 | | else | 4888 | | { | 4889 | | /* The value is actually a symbol index. Save a pointer | 4890 | | to the symbol instead of the index. FIXME: This | 4891 | | should use a union. */ | 4892 | | src->u.syment.n_value | 4893 | | = (uintptr_t) (native_symbols + src->u.syment.n_value); | 4894 | | dst->symbol.value = src->u.syment.n_value; | 4895 | | src->fix_value = 1; | 4896 | | } | 4897 | | break; | 4898 | | #endif | 4899 | | | 4900 | 31 | case C_BLOCK: /* ".bb" or ".eb". */ | 4901 | 73 | case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */ | 4902 | 247 | case C_EFCN: /* Physical end of function. */ | 4903 | | #if defined COFF_WITH_PE | 4904 | | /* PE sets the symbol to a value relative to the start | 4905 | | of the section. */ | 4906 | | dst->symbol.value = src->u.syment.n_value; | 4907 | | if (strcmp (dst->symbol.name, ".bf") != 0) | 4908 | | { | 4909 | | /* PE uses funny values for .ef and .lf; don't | 4910 | | relocate them. */ | 4911 | | dst->symbol.flags = BSF_DEBUGGING; | 4912 | | } | 4913 | | else | 4914 | | dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC; | 4915 | | #else | 4916 | | /* Base the value as an index from the base of the | 4917 | | section. */ | 4918 | 247 | dst->symbol.flags = BSF_LOCAL; | 4919 | 247 | dst->symbol.value = (src->u.syment.n_value | 4920 | 247 | - dst->symbol.section->vma); | 4921 | 247 | #endif | 4922 | 247 | break; | 4923 | | | 4924 | 41 | case C_STATLAB: /* Static load time label. */ | 4925 | 41 | dst->symbol.value = src->u.syment.n_value; | 4926 | 41 | dst->symbol.flags = BSF_GLOBAL; | 4927 | 41 | break; | 4928 | | | 4929 | 21.1k | case C_NULL: | 4930 | | /* PE DLLs sometimes have zeroed out symbols for some | 4931 | | reason. Just ignore them without a warning. */ | 4932 | 21.1k | if (src->u.syment.n_type == 0 | 4933 | 21.1k | && src->u.syment.n_value == 0 | 4934 | 21.1k | && src->u.syment.n_scnum == 0) | 4935 | 5.94k | break; | 4936 | | #ifdef RS6000COFF_C | 4937 | | /* XCOFF specific: deleted entry. */ | 4938 | | if (src->u.syment.n_value == C_NULL_VALUE) | 4939 | | break; | 4940 | | #endif | 4941 | | /* Fall through. */ | 4942 | 15.2k | case C_EXTDEF: /* External definition. */ | 4943 | 15.3k | case C_ULABEL: /* Undefined label. */ | 4944 | 15.4k | case C_USTATIC: /* Undefined static. */ | 4945 | 15.4k | #ifndef COFF_WITH_PE | 4946 | | /* C_LINE in regular coff is 0x68. NT has taken over this storage | 4947 | | class to represent a section symbol. */ | 4948 | 15.4k | case C_LINE: /* line # reformatted as symbol table entry. */ | 4949 | | /* NT uses 0x67 for a weak symbol, not C_ALIAS. */ | 4950 | 15.5k | case C_ALIAS: /* Duplicate tag. */ | 4951 | 15.5k | #endif | 4952 | | /* New storage classes for TI COFF. */ | 4953 | | #ifdef TICOFF | 4954 | | case C_UEXT: /* Tentative external definition. */ | 4955 | | #endif | 4956 | 15.5k | case C_EXTLAB: /* External load time label. */ | 4957 | 19.7k | default: | 4958 | 19.7k | _bfd_error_handler | 4959 | | /* xgettext:c-format */ | 4960 | 19.7k | (_("%pB: unrecognized storage class %d for %s symbol `%s'"), | 4961 | 19.7k | abfd, src->u.syment.n_sclass, | 4962 | 19.7k | dst->symbol.section->name, dst->symbol.name); | 4963 | 19.7k | ret = false; | 4964 | | /* Fall through. */ | 4965 | 19.7k | case C_HIDDEN: /* Ext symbol in dmert public lib. */ | 4966 | | /* PR 20722: These symbols can also be generated by | 4967 | | building DLLs with --gc-sections enabled. */ | 4968 | 19.7k | dst->symbol.flags = BSF_DEBUGGING; | 4969 | 19.7k | dst->symbol.value = (src->u.syment.n_value); | 4970 | 19.7k | break; | 4971 | 32.1k | } | 4972 | | | 4973 | 32.1k | dst->native = src; | 4974 | 32.1k | dst->symbol.udata.i = 0; | 4975 | 32.1k | dst->lineno = NULL; | 4976 | | | 4977 | 32.1k | this_index += (src->u.syment.n_numaux) + 1; | 4978 | 32.1k | dst++; | 4979 | 32.1k | number_of_symbols++; | 4980 | 32.1k | } | 4981 | 230 | } | 4982 | | | 4983 | 230 | obj_symbols (abfd) = cached_area; | 4984 | 230 | obj_raw_syments (abfd) = native_symbols; | 4985 | | | 4986 | 230 | abfd->symcount = number_of_symbols; | 4987 | 230 | obj_convert (abfd) = table_ptr; | 4988 | | /* Slurp the line tables for each section too. */ | 4989 | 230 | { | 4990 | 230 | asection *p; | 4991 | | | 4992 | 230 | p = abfd->sections; | 4993 | 2.34k | while (p) | 4994 | 2.27k | { | 4995 | 2.27k | if (! coff_slurp_line_table (abfd, p)) | 4996 | 152 | return false; | 4997 | 2.11k | p = p->next; | 4998 | 2.11k | } | 4999 | 230 | } | 5000 | | | 5001 | 78 | return ret; | 5002 | 230 | } |
coff-z8k.c:coff_slurp_symbol_table Line | Count | Source | 4630 | 513 | { | 4631 | 513 | combined_entry_type *native_symbols; | 4632 | 513 | coff_symbol_type *cached_area; | 4633 | 513 | unsigned int *table_ptr; | 4634 | 513 | unsigned int number_of_symbols = 0; | 4635 | 513 | bool ret = true; | 4636 | 513 | size_t amt; | 4637 | | | 4638 | 513 | if (obj_symbols (abfd)) | 4639 | 168 | return true; | 4640 | | | 4641 | | /* Read in the symbol table. */ | 4642 | 345 | if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) | 4643 | 137 | return false; | 4644 | | | 4645 | | /* Allocate enough room for all the symbols in cached form. */ | 4646 | 208 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4647 | 208 | sizeof (*cached_area), &amt)) | 4648 | 0 | { | 4649 | 0 | bfd_set_error (bfd_error_file_too_big); | 4650 | 0 | return false; | 4651 | 0 | } | 4652 | 208 | cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt); | 4653 | 208 | if (cached_area == NULL) | 4654 | 0 | return false; | 4655 | | | 4656 | 208 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4657 | 208 | sizeof (*table_ptr), &amt)) | 4658 | 0 | { | 4659 | 0 | bfd_set_error (bfd_error_file_too_big); | 4660 | 0 | return false; | 4661 | 0 | } | 4662 | 208 | table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); | 4663 | 208 | if (table_ptr == NULL) | 4664 | 0 | return false; | 4665 | 208 | else | 4666 | 208 | { | 4667 | 208 | coff_symbol_type *dst = cached_area; | 4668 | 208 | unsigned int last_native_index = obj_raw_syment_count (abfd); | 4669 | 208 | unsigned int this_index = 0; | 4670 | | | 4671 | 27.3k | while (this_index < last_native_index) | 4672 | 27.1k | { | 4673 | 27.1k | combined_entry_type *src = native_symbols + this_index; | 4674 | 27.1k | table_ptr[this_index] = number_of_symbols; | 4675 | | | 4676 | 27.1k | dst->symbol.the_bfd = abfd; | 4677 | 27.1k | BFD_ASSERT (src->is_sym); | 4678 | 27.1k | dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset); | 4679 | | /* We use the native name field to point to the cached field. */ | 4680 | 27.1k | src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; | 4681 | 27.1k | dst->symbol.section = coff_section_from_bfd_index (abfd, | 4682 | 27.1k | src->u.syment.n_scnum); | 4683 | 27.1k | dst->symbol.flags = 0; | 4684 | | /* PR 17512: file: 079-7098-0.001:0.1. */ | 4685 | 27.1k | dst->symbol.value = 0; | 4686 | 27.1k | dst->done_lineno = false; | 4687 | | | 4688 | 27.1k | switch (src->u.syment.n_sclass) | 4689 | 27.1k | { | 4690 | 517 | case C_EXT: | 4691 | 532 | case C_WEAKEXT: | 4692 | | #if defined ARM | 4693 | | case C_THUMBEXT: | 4694 | | case C_THUMBEXTFUNC: | 4695 | | #endif | 4696 | | #ifdef RS6000COFF_C | 4697 | | case C_HIDEXT: | 4698 | | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 4699 | | case C_AIX_WEAKEXT: | 4700 | | #endif | 4701 | | #endif | 4702 | 532 | #ifdef C_SYSTEM | 4703 | 562 | case C_SYSTEM: /* System Wide variable. */ | 4704 | 562 | #endif | 4705 | | #ifdef COFF_WITH_PE | 4706 | | /* In PE, 0x68 (104) denotes a section symbol. */ | 4707 | | case C_SECTION: | 4708 | | /* In PE, 0x69 (105) denotes a weak external symbol. */ | 4709 | | case C_NT_WEAK: | 4710 | | #endif | 4711 | 562 | switch (coff_classify_symbol (abfd, &src->u.syment)) | 4712 | 562 | { | 4713 | 505 | case COFF_SYMBOL_GLOBAL: | 4714 | 505 | dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL; | 4715 | | #if defined COFF_WITH_PE | 4716 | | /* PE sets the symbol to a value relative to the | 4717 | | start of the section. */ | 4718 | | dst->symbol.value = src->u.syment.n_value; | 4719 | | #else | 4720 | 505 | dst->symbol.value = (src->u.syment.n_value | 4721 | 505 | - dst->symbol.section->vma); | 4722 | 505 | #endif | 4723 | 505 | if (ISFCN ((src->u.syment.n_type))) | 4724 | | /* A function ext does not go at the end of a | 4725 | | file. */ | 4726 | 2 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4727 | 505 | break; | 4728 | | | 4729 | 44 | case COFF_SYMBOL_COMMON: | 4730 | 44 | dst->symbol.section = bfd_com_section_ptr; | 4731 | 44 | dst->symbol.value = src->u.syment.n_value; | 4732 | 44 | break; | 4733 | | | 4734 | 13 | case COFF_SYMBOL_UNDEFINED: | 4735 | 13 | dst->symbol.section = bfd_und_section_ptr; | 4736 | 13 | dst->symbol.value = 0; | 4737 | 13 | break; | 4738 | | | 4739 | 0 | case COFF_SYMBOL_PE_SECTION: | 4740 | 0 | dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM; | 4741 | 0 | dst->symbol.value = 0; | 4742 | 0 | break; | 4743 | | | 4744 | 0 | case COFF_SYMBOL_LOCAL: | 4745 | 0 | dst->symbol.flags = BSF_LOCAL; | 4746 | | #if defined COFF_WITH_PE | 4747 | | /* PE sets the symbol to a value relative to the | 4748 | | start of the section. */ | 4749 | | dst->symbol.value = src->u.syment.n_value; | 4750 | | #else | 4751 | 0 | dst->symbol.value = (src->u.syment.n_value | 4752 | 0 | - dst->symbol.section->vma); | 4753 | 0 | #endif | 4754 | 0 | if (ISFCN ((src->u.syment.n_type))) | 4755 | 0 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4756 | 0 | break; | 4757 | 562 | } | 4758 | | | 4759 | | #ifdef RS6000COFF_C | 4760 | | /* A symbol with a csect entry should not go at the end. */ | 4761 | | if (src->u.syment.n_numaux > 0) | 4762 | | dst->symbol.flags |= BSF_NOT_AT_END; | 4763 | | #endif | 4764 | | | 4765 | | #ifdef COFF_WITH_PE | 4766 | | if (src->u.syment.n_sclass == C_NT_WEAK) | 4767 | | dst->symbol.flags |= BSF_WEAK; | 4768 | | | 4769 | | if (src->u.syment.n_sclass == C_SECTION | 4770 | | && src->u.syment.n_scnum > 0) | 4771 | | dst->symbol.flags = BSF_LOCAL; | 4772 | | #endif | 4773 | 562 | if (src->u.syment.n_sclass == C_WEAKEXT | 4774 | | #ifdef RS6000COFF_C | 4775 | | || src->u.syment.n_sclass == C_AIX_WEAKEXT | 4776 | | #endif | 4777 | 562 | ) | 4778 | 15 | dst->symbol.flags |= BSF_WEAK; | 4779 | | | 4780 | 562 | break; | 4781 | | | 4782 | 213 | case C_STAT: /* Static. */ | 4783 | | #if defined ARM | 4784 | | case C_THUMBSTAT: /* Thumb static. */ | 4785 | | case C_THUMBLABEL: /* Thumb label. */ | 4786 | | case C_THUMBSTATFUNC:/* Thumb static function. */ | 4787 | | #endif | 4788 | | #ifdef RS6000COFF_C | 4789 | | case C_DWARF: /* A label in a dwarf section. */ | 4790 | | case C_INFO: /* A label in a comment section. */ | 4791 | | #endif | 4792 | 271 | case C_LABEL: /* Label. */ | 4793 | 271 | if (src->u.syment.n_scnum == N_DEBUG) | 4794 | 1 | dst->symbol.flags = BSF_DEBUGGING; | 4795 | 270 | else | 4796 | 270 | dst->symbol.flags = BSF_LOCAL; | 4797 | | | 4798 | | /* Base the value as an index from the base of the | 4799 | | section, if there is one. */ | 4800 | 271 | if (dst->symbol.section) | 4801 | 271 | { | 4802 | | #if defined COFF_WITH_PE | 4803 | | /* PE sets the symbol to a value relative to the | 4804 | | start of the section. */ | 4805 | | dst->symbol.value = src->u.syment.n_value; | 4806 | | #else | 4807 | 271 | dst->symbol.value = (src->u.syment.n_value | 4808 | 271 | - dst->symbol.section->vma); | 4809 | 271 | #endif | 4810 | 271 | } | 4811 | 0 | else | 4812 | 0 | dst->symbol.value = src->u.syment.n_value; | 4813 | 271 | break; | 4814 | | | 4815 | 115 | case C_FILE: /* File name. */ | 4816 | 115 | dst->symbol.flags = BSF_FILE; | 4817 | | /* Fall through. */ | 4818 | 198 | case C_MOS: /* Member of structure. */ | 4819 | 264 | case C_EOS: /* End of structure. */ | 4820 | 366 | case C_REGPARM: /* Register parameter. */ | 4821 | 650 | case C_REG: /* register variable. */ | 4822 | | /* C_AUTOARG conflicts with TI COFF C_UEXT. */ | 4823 | 814 | case C_TPDEF: /* Type definition. */ | 4824 | 912 | case C_ARG: | 4825 | 2.60k | case C_AUTO: /* Automatic variable. */ | 4826 | 2.67k | case C_FIELD: /* Bit field. */ | 4827 | 2.78k | case C_ENTAG: /* Enumeration tag. */ | 4828 | 2.95k | case C_MOE: /* Member of enumeration. */ | 4829 | 3.21k | case C_MOU: /* Member of union. */ | 4830 | 3.51k | case C_UNTAG: /* Union tag. */ | 4831 | 3.67k | case C_STRTAG: /* Structure tag. */ | 4832 | | #ifdef RS6000COFF_C | 4833 | | case C_GSYM: | 4834 | | case C_LSYM: | 4835 | | case C_PSYM: | 4836 | | case C_RSYM: | 4837 | | case C_RPSYM: | 4838 | | case C_STSYM: | 4839 | | case C_TCSYM: | 4840 | | case C_BCOMM: | 4841 | | case C_ECOML: | 4842 | | case C_ECOMM: | 4843 | | case C_DECL: | 4844 | | case C_ENTRY: | 4845 | | case C_FUN: | 4846 | | case C_ESTAT: | 4847 | | #endif | 4848 | 3.67k | dst->symbol.flags |= BSF_DEBUGGING; | 4849 | 3.67k | dst->symbol.value = (src->u.syment.n_value); | 4850 | 3.67k | break; | 4851 | | | 4852 | | #ifdef RS6000COFF_C | 4853 | | case C_BINCL: /* Beginning of include file. */ | 4854 | | case C_EINCL: /* Ending of include file. */ | 4855 | | /* The value is actually a pointer into the line numbers | 4856 | | of the file. We locate the line number entry, and | 4857 | | set the section to the section which contains it, and | 4858 | | the value to the index in that section. */ | 4859 | | { | 4860 | | asection *sec; | 4861 | | | 4862 | | dst->symbol.flags = BSF_DEBUGGING; | 4863 | | for (sec = abfd->sections; sec != NULL; sec = sec->next) | 4864 | | if (sec->line_filepos <= (file_ptr) src->u.syment.n_value | 4865 | | && ((file_ptr) (sec->line_filepos | 4866 | | + sec->lineno_count * bfd_coff_linesz (abfd)) | 4867 | | > (file_ptr) src->u.syment.n_value)) | 4868 | | break; | 4869 | | if (sec == NULL) | 4870 | | dst->symbol.value = 0; | 4871 | | else | 4872 | | { | 4873 | | dst->symbol.section = sec; | 4874 | | dst->symbol.value = ((src->u.syment.n_value | 4875 | | - sec->line_filepos) | 4876 | | / bfd_coff_linesz (abfd)); | 4877 | | src->fix_line = 1; | 4878 | | } | 4879 | | } | 4880 | | break; | 4881 | | | 4882 | | case C_BSTAT: | 4883 | | dst->symbol.flags = BSF_DEBUGGING; | 4884 | | | 4885 | | if (src->u.syment.n_value >= obj_raw_syment_count (abfd)) | 4886 | | dst->symbol.value = 0; | 4887 | | else | 4888 | | { | 4889 | | /* The value is actually a symbol index. Save a pointer | 4890 | | to the symbol instead of the index. FIXME: This | 4891 | | should use a union. */ | 4892 | | src->u.syment.n_value | 4893 | | = (uintptr_t) (native_symbols + src->u.syment.n_value); | 4894 | | dst->symbol.value = src->u.syment.n_value; | 4895 | | src->fix_value = 1; | 4896 | | } | 4897 | | break; | 4898 | | #endif | 4899 | | | 4900 | 80 | case C_BLOCK: /* ".bb" or ".eb". */ | 4901 | 137 | case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */ | 4902 | 291 | case C_EFCN: /* Physical end of function. */ | 4903 | | #if defined COFF_WITH_PE | 4904 | | /* PE sets the symbol to a value relative to the start | 4905 | | of the section. */ | 4906 | | dst->symbol.value = src->u.syment.n_value; | 4907 | | if (strcmp (dst->symbol.name, ".bf") != 0) | 4908 | | { | 4909 | | /* PE uses funny values for .ef and .lf; don't | 4910 | | relocate them. */ | 4911 | | dst->symbol.flags = BSF_DEBUGGING; | 4912 | | } | 4913 | | else | 4914 | | dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC; | 4915 | | #else | 4916 | | /* Base the value as an index from the base of the | 4917 | | section. */ | 4918 | 291 | dst->symbol.flags = BSF_LOCAL; | 4919 | 291 | dst->symbol.value = (src->u.syment.n_value | 4920 | 291 | - dst->symbol.section->vma); | 4921 | 291 | #endif | 4922 | 291 | break; | 4923 | | | 4924 | 51 | case C_STATLAB: /* Static load time label. */ | 4925 | 51 | dst->symbol.value = src->u.syment.n_value; | 4926 | 51 | dst->symbol.flags = BSF_GLOBAL; | 4927 | 51 | break; | 4928 | | | 4929 | 18.0k | case C_NULL: | 4930 | | /* PE DLLs sometimes have zeroed out symbols for some | 4931 | | reason. Just ignore them without a warning. */ | 4932 | 18.0k | if (src->u.syment.n_type == 0 | 4933 | 18.0k | && src->u.syment.n_value == 0 | 4934 | 18.0k | && src->u.syment.n_scnum == 0) | 4935 | 7.08k | break; | 4936 | | #ifdef RS6000COFF_C | 4937 | | /* XCOFF specific: deleted entry. */ | 4938 | | if (src->u.syment.n_value == C_NULL_VALUE) | 4939 | | break; | 4940 | | #endif | 4941 | | /* Fall through. */ | 4942 | 11.0k | case C_EXTDEF: /* External definition. */ | 4943 | 11.4k | case C_ULABEL: /* Undefined label. */ | 4944 | 11.4k | case C_USTATIC: /* Undefined static. */ | 4945 | 11.4k | #ifndef COFF_WITH_PE | 4946 | | /* C_LINE in regular coff is 0x68. NT has taken over this storage | 4947 | | class to represent a section symbol. */ | 4948 | 11.5k | case C_LINE: /* line # reformatted as symbol table entry. */ | 4949 | | /* NT uses 0x67 for a weak symbol, not C_ALIAS. */ | 4950 | 11.5k | case C_ALIAS: /* Duplicate tag. */ | 4951 | 11.5k | #endif | 4952 | | /* New storage classes for TI COFF. */ | 4953 | | #ifdef TICOFF | 4954 | | case C_UEXT: /* Tentative external definition. */ | 4955 | | #endif | 4956 | 11.5k | case C_EXTLAB: /* External load time label. */ | 4957 | 15.2k | default: | 4958 | 15.2k | _bfd_error_handler | 4959 | | /* xgettext:c-format */ | 4960 | 15.2k | (_("%pB: unrecognized storage class %d for %s symbol `%s'"), | 4961 | 15.2k | abfd, src->u.syment.n_sclass, | 4962 | 15.2k | dst->symbol.section->name, dst->symbol.name); | 4963 | 15.2k | ret = false; | 4964 | | /* Fall through. */ | 4965 | 15.2k | case C_HIDDEN: /* Ext symbol in dmert public lib. */ | 4966 | | /* PR 20722: These symbols can also be generated by | 4967 | | building DLLs with --gc-sections enabled. */ | 4968 | 15.2k | dst->symbol.flags = BSF_DEBUGGING; | 4969 | 15.2k | dst->symbol.value = (src->u.syment.n_value); | 4970 | 15.2k | break; | 4971 | 27.1k | } | 4972 | | | 4973 | 27.1k | dst->native = src; | 4974 | 27.1k | dst->symbol.udata.i = 0; | 4975 | 27.1k | dst->lineno = NULL; | 4976 | | | 4977 | 27.1k | this_index += (src->u.syment.n_numaux) + 1; | 4978 | 27.1k | dst++; | 4979 | 27.1k | number_of_symbols++; | 4980 | 27.1k | } | 4981 | 208 | } | 4982 | | | 4983 | 208 | obj_symbols (abfd) = cached_area; | 4984 | 208 | obj_raw_syments (abfd) = native_symbols; | 4985 | | | 4986 | 208 | abfd->symcount = number_of_symbols; | 4987 | 208 | obj_convert (abfd) = table_ptr; | 4988 | | /* Slurp the line tables for each section too. */ | 4989 | 208 | { | 4990 | 208 | asection *p; | 4991 | | | 4992 | 208 | p = abfd->sections; | 4993 | 1.59k | while (p) | 4994 | 1.54k | { | 4995 | 1.54k | if (! coff_slurp_line_table (abfd, p)) | 4996 | 159 | return false; | 4997 | 1.38k | p = p->next; | 4998 | 1.38k | } | 4999 | 208 | } | 5000 | | | 5001 | 49 | return ret; | 5002 | 208 | } |
Unexecuted instantiation: pe-arm-wince.c:coff_slurp_symbol_table Unexecuted instantiation: pe-arm.c:coff_slurp_symbol_table pe-i386.c:coff_slurp_symbol_table Line | Count | Source | 4630 | 488 | { | 4631 | 488 | combined_entry_type *native_symbols; | 4632 | 488 | coff_symbol_type *cached_area; | 4633 | 488 | unsigned int *table_ptr; | 4634 | 488 | unsigned int number_of_symbols = 0; | 4635 | 488 | bool ret = true; | 4636 | 488 | size_t amt; | 4637 | | | 4638 | 488 | if (obj_symbols (abfd)) | 4639 | 262 | return true; | 4640 | | | 4641 | | /* Read in the symbol table. */ | 4642 | 226 | if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) | 4643 | 28 | return false; | 4644 | | | 4645 | | /* Allocate enough room for all the symbols in cached form. */ | 4646 | 198 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4647 | 198 | sizeof (*cached_area), &amt)) | 4648 | 0 | { | 4649 | 0 | bfd_set_error (bfd_error_file_too_big); | 4650 | 0 | return false; | 4651 | 0 | } | 4652 | 198 | cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt); | 4653 | 198 | if (cached_area == NULL) | 4654 | 0 | return false; | 4655 | | | 4656 | 198 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4657 | 198 | sizeof (*table_ptr), &amt)) | 4658 | 0 | { | 4659 | 0 | bfd_set_error (bfd_error_file_too_big); | 4660 | 0 | return false; | 4661 | 0 | } | 4662 | 198 | table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); | 4663 | 198 | if (table_ptr == NULL) | 4664 | 0 | return false; | 4665 | 198 | else | 4666 | 198 | { | 4667 | 198 | coff_symbol_type *dst = cached_area; | 4668 | 198 | unsigned int last_native_index = obj_raw_syment_count (abfd); | 4669 | 198 | unsigned int this_index = 0; | 4670 | | | 4671 | 41.7k | while (this_index < last_native_index) | 4672 | 41.5k | { | 4673 | 41.5k | combined_entry_type *src = native_symbols + this_index; | 4674 | 41.5k | table_ptr[this_index] = number_of_symbols; | 4675 | | | 4676 | 41.5k | dst->symbol.the_bfd = abfd; | 4677 | 41.5k | BFD_ASSERT (src->is_sym); | 4678 | 41.5k | dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset); | 4679 | | /* We use the native name field to point to the cached field. */ | 4680 | 41.5k | src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; | 4681 | 41.5k | dst->symbol.section = coff_section_from_bfd_index (abfd, | 4682 | 41.5k | src->u.syment.n_scnum); | 4683 | 41.5k | dst->symbol.flags = 0; | 4684 | | /* PR 17512: file: 079-7098-0.001:0.1. */ | 4685 | 41.5k | dst->symbol.value = 0; | 4686 | 41.5k | dst->done_lineno = false; | 4687 | | | 4688 | 41.5k | switch (src->u.syment.n_sclass) | 4689 | 41.5k | { | 4690 | 486 | case C_EXT: | 4691 | 508 | case C_WEAKEXT: | 4692 | | #if defined ARM | 4693 | | case C_THUMBEXT: | 4694 | | case C_THUMBEXTFUNC: | 4695 | | #endif | 4696 | | #ifdef RS6000COFF_C | 4697 | | case C_HIDEXT: | 4698 | | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 4699 | | case C_AIX_WEAKEXT: | 4700 | | #endif | 4701 | | #endif | 4702 | 508 | #ifdef C_SYSTEM | 4703 | 536 | case C_SYSTEM: /* System Wide variable. */ | 4704 | 536 | #endif | 4705 | 536 | #ifdef COFF_WITH_PE | 4706 | | /* In PE, 0x68 (104) denotes a section symbol. */ | 4707 | 551 | case C_SECTION: | 4708 | | /* In PE, 0x69 (105) denotes a weak external symbol. */ | 4709 | 636 | case C_NT_WEAK: | 4710 | 636 | #endif | 4711 | 636 | switch (coff_classify_symbol (abfd, &src->u.syment)) | 4712 | 636 | { | 4713 | 545 | case COFF_SYMBOL_GLOBAL: | 4714 | 545 | dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL; | 4715 | 545 | #if defined COFF_WITH_PE | 4716 | | /* PE sets the symbol to a value relative to the | 4717 | | start of the section. */ | 4718 | 545 | dst->symbol.value = src->u.syment.n_value; | 4719 | | #else | 4720 | | dst->symbol.value = (src->u.syment.n_value | 4721 | | - dst->symbol.section->vma); | 4722 | | #endif | 4723 | 545 | if (ISFCN ((src->u.syment.n_type))) | 4724 | | /* A function ext does not go at the end of a | 4725 | | file. */ | 4726 | 31 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4727 | 545 | break; | 4728 | | | 4729 | 50 | case COFF_SYMBOL_COMMON: | 4730 | 50 | dst->symbol.section = bfd_com_section_ptr; | 4731 | 50 | dst->symbol.value = src->u.syment.n_value; | 4732 | 50 | break; | 4733 | | | 4734 | 41 | case COFF_SYMBOL_UNDEFINED: | 4735 | 41 | dst->symbol.section = bfd_und_section_ptr; | 4736 | 41 | dst->symbol.value = 0; | 4737 | 41 | break; | 4738 | | | 4739 | 0 | case COFF_SYMBOL_PE_SECTION: | 4740 | 0 | dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM; | 4741 | 0 | dst->symbol.value = 0; | 4742 | 0 | break; | 4743 | | | 4744 | 0 | case COFF_SYMBOL_LOCAL: | 4745 | 0 | dst->symbol.flags = BSF_LOCAL; | 4746 | 0 | #if defined COFF_WITH_PE | 4747 | | /* PE sets the symbol to a value relative to the | 4748 | | start of the section. */ | 4749 | 0 | dst->symbol.value = src->u.syment.n_value; | 4750 | | #else | 4751 | | dst->symbol.value = (src->u.syment.n_value | 4752 | | - dst->symbol.section->vma); | 4753 | | #endif | 4754 | 0 | if (ISFCN ((src->u.syment.n_type))) | 4755 | 0 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4756 | 0 | break; | 4757 | 636 | } | 4758 | | | 4759 | | #ifdef RS6000COFF_C | 4760 | | /* A symbol with a csect entry should not go at the end. */ | 4761 | | if (src->u.syment.n_numaux > 0) | 4762 | | dst->symbol.flags |= BSF_NOT_AT_END; | 4763 | | #endif | 4764 | | | 4765 | 636 | #ifdef COFF_WITH_PE | 4766 | 636 | if (src->u.syment.n_sclass == C_NT_WEAK) | 4767 | 85 | dst->symbol.flags |= BSF_WEAK; | 4768 | | | 4769 | 636 | if (src->u.syment.n_sclass == C_SECTION | 4770 | 636 | && src->u.syment.n_scnum > 0) | 4771 | 0 | dst->symbol.flags = BSF_LOCAL; | 4772 | 636 | #endif | 4773 | 636 | if (src->u.syment.n_sclass == C_WEAKEXT | 4774 | | #ifdef RS6000COFF_C | 4775 | | || src->u.syment.n_sclass == C_AIX_WEAKEXT | 4776 | | #endif | 4777 | 636 | ) | 4778 | 22 | dst->symbol.flags |= BSF_WEAK; | 4779 | | | 4780 | 636 | break; | 4781 | | | 4782 | 167 | case C_STAT: /* Static. */ | 4783 | | #if defined ARM | 4784 | | case C_THUMBSTAT: /* Thumb static. */ | 4785 | | case C_THUMBLABEL: /* Thumb label. */ | 4786 | | case C_THUMBSTATFUNC:/* Thumb static function. */ | 4787 | | #endif | 4788 | | #ifdef RS6000COFF_C | 4789 | | case C_DWARF: /* A label in a dwarf section. */ | 4790 | | case C_INFO: /* A label in a comment section. */ | 4791 | | #endif | 4792 | 364 | case C_LABEL: /* Label. */ | 4793 | 364 | if (src->u.syment.n_scnum == N_DEBUG) | 4794 | 0 | dst->symbol.flags = BSF_DEBUGGING; | 4795 | 364 | else | 4796 | 364 | dst->symbol.flags = BSF_LOCAL; | 4797 | | | 4798 | | /* Base the value as an index from the base of the | 4799 | | section, if there is one. */ | 4800 | 364 | if (dst->symbol.section) | 4801 | 364 | { | 4802 | 364 | #if defined COFF_WITH_PE | 4803 | | /* PE sets the symbol to a value relative to the | 4804 | | start of the section. */ | 4805 | 364 | dst->symbol.value = src->u.syment.n_value; | 4806 | | #else | 4807 | | dst->symbol.value = (src->u.syment.n_value | 4808 | | - dst->symbol.section->vma); | 4809 | | #endif | 4810 | 364 | } | 4811 | 0 | else | 4812 | 0 | dst->symbol.value = src->u.syment.n_value; | 4813 | 364 | break; | 4814 | | | 4815 | 53 | case C_FILE: /* File name. */ | 4816 | 53 | dst->symbol.flags = BSF_FILE; | 4817 | | /* Fall through. */ | 4818 | 377 | case C_MOS: /* Member of structure. */ | 4819 | 492 | case C_EOS: /* End of structure. */ | 4820 | 539 | case C_REGPARM: /* Register parameter. */ | 4821 | 594 | case C_REG: /* register variable. */ | 4822 | | /* C_AUTOARG conflicts with TI COFF C_UEXT. */ | 4823 | 657 | case C_TPDEF: /* Type definition. */ | 4824 | 1.09k | case C_ARG: | 4825 | 2.15k | case C_AUTO: /* Automatic variable. */ | 4826 | 2.22k | case C_FIELD: /* Bit field. */ | 4827 | 2.30k | case C_ENTAG: /* Enumeration tag. */ | 4828 | 2.39k | case C_MOE: /* Member of enumeration. */ | 4829 | 2.48k | case C_MOU: /* Member of union. */ | 4830 | 2.70k | case C_UNTAG: /* Union tag. */ | 4831 | 2.95k | case C_STRTAG: /* Structure tag. */ | 4832 | | #ifdef RS6000COFF_C | 4833 | | case C_GSYM: | 4834 | | case C_LSYM: | 4835 | | case C_PSYM: | 4836 | | case C_RSYM: | 4837 | | case C_RPSYM: | 4838 | | case C_STSYM: | 4839 | | case C_TCSYM: | 4840 | | case C_BCOMM: | 4841 | | case C_ECOML: | 4842 | | case C_ECOMM: | 4843 | | case C_DECL: | 4844 | | case C_ENTRY: | 4845 | | case C_FUN: | 4846 | | case C_ESTAT: | 4847 | | #endif | 4848 | 2.95k | dst->symbol.flags |= BSF_DEBUGGING; | 4849 | 2.95k | dst->symbol.value = (src->u.syment.n_value); | 4850 | 2.95k | break; | 4851 | | | 4852 | | #ifdef RS6000COFF_C | 4853 | | case C_BINCL: /* Beginning of include file. */ | 4854 | | case C_EINCL: /* Ending of include file. */ | 4855 | | /* The value is actually a pointer into the line numbers | 4856 | | of the file. We locate the line number entry, and | 4857 | | set the section to the section which contains it, and | 4858 | | the value to the index in that section. */ | 4859 | | { | 4860 | | asection *sec; | 4861 | | | 4862 | | dst->symbol.flags = BSF_DEBUGGING; | 4863 | | for (sec = abfd->sections; sec != NULL; sec = sec->next) | 4864 | | if (sec->line_filepos <= (file_ptr) src->u.syment.n_value | 4865 | | && ((file_ptr) (sec->line_filepos | 4866 | | + sec->lineno_count * bfd_coff_linesz (abfd)) | 4867 | | > (file_ptr) src->u.syment.n_value)) | 4868 | | break; | 4869 | | if (sec == NULL) | 4870 | | dst->symbol.value = 0; | 4871 | | else | 4872 | | { | 4873 | | dst->symbol.section = sec; | 4874 | | dst->symbol.value = ((src->u.syment.n_value | 4875 | | - sec->line_filepos) | 4876 | | / bfd_coff_linesz (abfd)); | 4877 | | src->fix_line = 1; | 4878 | | } | 4879 | | } | 4880 | | break; | 4881 | | | 4882 | | case C_BSTAT: | 4883 | | dst->symbol.flags = BSF_DEBUGGING; | 4884 | | | 4885 | | if (src->u.syment.n_value >= obj_raw_syment_count (abfd)) | 4886 | | dst->symbol.value = 0; | 4887 | | else | 4888 | | { | 4889 | | /* The value is actually a symbol index. Save a pointer | 4890 | | to the symbol instead of the index. FIXME: This | 4891 | | should use a union. */ | 4892 | | src->u.syment.n_value | 4893 | | = (uintptr_t) (native_symbols + src->u.syment.n_value); | 4894 | | dst->symbol.value = src->u.syment.n_value; | 4895 | | src->fix_value = 1; | 4896 | | } | 4897 | | break; | 4898 | | #endif | 4899 | | | 4900 | 27 | case C_BLOCK: /* ".bb" or ".eb". */ | 4901 | 251 | case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */ | 4902 | 350 | case C_EFCN: /* Physical end of function. */ | 4903 | 350 | #if defined COFF_WITH_PE | 4904 | | /* PE sets the symbol to a value relative to the start | 4905 | | of the section. */ | 4906 | 350 | dst->symbol.value = src->u.syment.n_value; | 4907 | 350 | if (strcmp (dst->symbol.name, ".bf") != 0) | 4908 | 350 | { | 4909 | | /* PE uses funny values for .ef and .lf; don't | 4910 | | relocate them. */ | 4911 | 350 | dst->symbol.flags = BSF_DEBUGGING; | 4912 | 350 | } | 4913 | 0 | else | 4914 | 0 | dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC; | 4915 | | #else | 4916 | | /* Base the value as an index from the base of the | 4917 | | section. */ | 4918 | | dst->symbol.flags = BSF_LOCAL; | 4919 | | dst->symbol.value = (src->u.syment.n_value | 4920 | | - dst->symbol.section->vma); | 4921 | | #endif | 4922 | 350 | break; | 4923 | | | 4924 | 104 | case C_STATLAB: /* Static load time label. */ | 4925 | 104 | dst->symbol.value = src->u.syment.n_value; | 4926 | 104 | dst->symbol.flags = BSF_GLOBAL; | 4927 | 104 | break; | 4928 | | | 4929 | 33.8k | case C_NULL: | 4930 | | /* PE DLLs sometimes have zeroed out symbols for some | 4931 | | reason. Just ignore them without a warning. */ | 4932 | 33.8k | if (src->u.syment.n_type == 0 | 4933 | 33.8k | && src->u.syment.n_value == 0 | 4934 | 33.8k | && src->u.syment.n_scnum == 0) | 4935 | 23.5k | break; | 4936 | | #ifdef RS6000COFF_C | 4937 | | /* XCOFF specific: deleted entry. */ | 4938 | | if (src->u.syment.n_value == C_NULL_VALUE) | 4939 | | break; | 4940 | | #endif | 4941 | | /* Fall through. */ | 4942 | 10.3k | case C_EXTDEF: /* External definition. */ | 4943 | 10.3k | case C_ULABEL: /* Undefined label. */ | 4944 | 10.3k | case C_USTATIC: /* Undefined static. */ | 4945 | | #ifndef COFF_WITH_PE | 4946 | | /* C_LINE in regular coff is 0x68. NT has taken over this storage | 4947 | | class to represent a section symbol. */ | 4948 | | case C_LINE: /* line # reformatted as symbol table entry. */ | 4949 | | /* NT uses 0x67 for a weak symbol, not C_ALIAS. */ | 4950 | | case C_ALIAS: /* Duplicate tag. */ | 4951 | | #endif | 4952 | | /* New storage classes for TI COFF. */ | 4953 | | #ifdef TICOFF | 4954 | | case C_UEXT: /* Tentative external definition. */ | 4955 | | #endif | 4956 | 10.3k | case C_EXTLAB: /* External load time label. */ | 4957 | 13.5k | default: | 4958 | 13.5k | _bfd_error_handler | 4959 | | /* xgettext:c-format */ | 4960 | 13.5k | (_("%pB: unrecognized storage class %d for %s symbol `%s'"), | 4961 | 13.5k | abfd, src->u.syment.n_sclass, | 4962 | 13.5k | dst->symbol.section->name, dst->symbol.name); | 4963 | 13.5k | ret = false; | 4964 | | /* Fall through. */ | 4965 | 13.5k | case C_HIDDEN: /* Ext symbol in dmert public lib. */ | 4966 | | /* PR 20722: These symbols can also be generated by | 4967 | | building DLLs with --gc-sections enabled. */ | 4968 | 13.5k | dst->symbol.flags = BSF_DEBUGGING; | 4969 | 13.5k | dst->symbol.value = (src->u.syment.n_value); | 4970 | 13.5k | break; | 4971 | 41.5k | } | 4972 | | | 4973 | 41.5k | dst->native = src; | 4974 | 41.5k | dst->symbol.udata.i = 0; | 4975 | 41.5k | dst->lineno = NULL; | 4976 | | | 4977 | 41.5k | this_index += (src->u.syment.n_numaux) + 1; | 4978 | 41.5k | dst++; | 4979 | 41.5k | number_of_symbols++; | 4980 | 41.5k | } | 4981 | 198 | } | 4982 | | | 4983 | 198 | obj_symbols (abfd) = cached_area; | 4984 | 198 | obj_raw_syments (abfd) = native_symbols; | 4985 | | | 4986 | 198 | abfd->symcount = number_of_symbols; | 4987 | 198 | obj_convert (abfd) = table_ptr; | 4988 | | /* Slurp the line tables for each section too. */ | 4989 | 198 | { | 4990 | 198 | asection *p; | 4991 | | | 4992 | 198 | p = abfd->sections; | 4993 | 785 | while (p) | 4994 | 712 | { | 4995 | 712 | if (! coff_slurp_line_table (abfd, p)) | 4996 | 125 | return false; | 4997 | 587 | p = p->next; | 4998 | 587 | } | 4999 | 198 | } | 5000 | | | 5001 | 73 | return ret; | 5002 | 198 | } |
pe-mcore.c:coff_slurp_symbol_table Line | Count | Source | 4630 | 684 | { | 4631 | 684 | combined_entry_type *native_symbols; | 4632 | 684 | coff_symbol_type *cached_area; | 4633 | 684 | unsigned int *table_ptr; | 4634 | 684 | unsigned int number_of_symbols = 0; | 4635 | 684 | bool ret = true; | 4636 | 684 | size_t amt; | 4637 | | | 4638 | 684 | if (obj_symbols (abfd)) | 4639 | 409 | return true; | 4640 | | | 4641 | | /* Read in the symbol table. */ | 4642 | 275 | if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) | 4643 | 49 | return false; | 4644 | | | 4645 | | /* Allocate enough room for all the symbols in cached form. */ | 4646 | 226 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4647 | 226 | sizeof (*cached_area), &amt)) | 4648 | 0 | { | 4649 | 0 | bfd_set_error (bfd_error_file_too_big); | 4650 | 0 | return false; | 4651 | 0 | } | 4652 | 226 | cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt); | 4653 | 226 | if (cached_area == NULL) | 4654 | 0 | return false; | 4655 | | | 4656 | 226 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4657 | 226 | sizeof (*table_ptr), &amt)) | 4658 | 0 | { | 4659 | 0 | bfd_set_error (bfd_error_file_too_big); | 4660 | 0 | return false; | 4661 | 0 | } | 4662 | 226 | table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); | 4663 | 226 | if (table_ptr == NULL) | 4664 | 0 | return false; | 4665 | 226 | else | 4666 | 226 | { | 4667 | 226 | coff_symbol_type *dst = cached_area; | 4668 | 226 | unsigned int last_native_index = obj_raw_syment_count (abfd); | 4669 | 226 | unsigned int this_index = 0; | 4670 | | | 4671 | 43.3k | while (this_index < last_native_index) | 4672 | 43.0k | { | 4673 | 43.0k | combined_entry_type *src = native_symbols + this_index; | 4674 | 43.0k | table_ptr[this_index] = number_of_symbols; | 4675 | | | 4676 | 43.0k | dst->symbol.the_bfd = abfd; | 4677 | 43.0k | BFD_ASSERT (src->is_sym); | 4678 | 43.0k | dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset); | 4679 | | /* We use the native name field to point to the cached field. */ | 4680 | 43.0k | src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; | 4681 | 43.0k | dst->symbol.section = coff_section_from_bfd_index (abfd, | 4682 | 43.0k | src->u.syment.n_scnum); | 4683 | 43.0k | dst->symbol.flags = 0; | 4684 | | /* PR 17512: file: 079-7098-0.001:0.1. */ | 4685 | 43.0k | dst->symbol.value = 0; | 4686 | 43.0k | dst->done_lineno = false; | 4687 | | | 4688 | 43.0k | switch (src->u.syment.n_sclass) | 4689 | 43.0k | { | 4690 | 842 | case C_EXT: | 4691 | 923 | case C_WEAKEXT: | 4692 | | #if defined ARM | 4693 | | case C_THUMBEXT: | 4694 | | case C_THUMBEXTFUNC: | 4695 | | #endif | 4696 | | #ifdef RS6000COFF_C | 4697 | | case C_HIDEXT: | 4698 | | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 4699 | | case C_AIX_WEAKEXT: | 4700 | | #endif | 4701 | | #endif | 4702 | 923 | #ifdef C_SYSTEM | 4703 | 961 | case C_SYSTEM: /* System Wide variable. */ | 4704 | 961 | #endif | 4705 | 961 | #ifdef COFF_WITH_PE | 4706 | | /* In PE, 0x68 (104) denotes a section symbol. */ | 4707 | 976 | case C_SECTION: | 4708 | | /* In PE, 0x69 (105) denotes a weak external symbol. */ | 4709 | 1.06k | case C_NT_WEAK: | 4710 | 1.06k | #endif | 4711 | 1.06k | switch (coff_classify_symbol (abfd, &src->u.syment)) | 4712 | 1.06k | { | 4713 | 964 | case COFF_SYMBOL_GLOBAL: | 4714 | 964 | dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL; | 4715 | 964 | #if defined COFF_WITH_PE | 4716 | | /* PE sets the symbol to a value relative to the | 4717 | | start of the section. */ | 4718 | 964 | dst->symbol.value = src->u.syment.n_value; | 4719 | | #else | 4720 | | dst->symbol.value = (src->u.syment.n_value | 4721 | | - dst->symbol.section->vma); | 4722 | | #endif | 4723 | 964 | if (ISFCN ((src->u.syment.n_type))) | 4724 | | /* A function ext does not go at the end of a | 4725 | | file. */ | 4726 | 79 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4727 | 964 | break; | 4728 | | | 4729 | 69 | case COFF_SYMBOL_COMMON: | 4730 | 69 | dst->symbol.section = bfd_com_section_ptr; | 4731 | 69 | dst->symbol.value = src->u.syment.n_value; | 4732 | 69 | break; | 4733 | | | 4734 | 35 | case COFF_SYMBOL_UNDEFINED: | 4735 | 35 | dst->symbol.section = bfd_und_section_ptr; | 4736 | 35 | dst->symbol.value = 0; | 4737 | 35 | break; | 4738 | | | 4739 | 0 | case COFF_SYMBOL_PE_SECTION: | 4740 | 0 | dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM; | 4741 | 0 | dst->symbol.value = 0; | 4742 | 0 | break; | 4743 | | | 4744 | 0 | case COFF_SYMBOL_LOCAL: | 4745 | 0 | dst->symbol.flags = BSF_LOCAL; | 4746 | 0 | #if defined COFF_WITH_PE | 4747 | | /* PE sets the symbol to a value relative to the | 4748 | | start of the section. */ | 4749 | 0 | dst->symbol.value = src->u.syment.n_value; | 4750 | | #else | 4751 | | dst->symbol.value = (src->u.syment.n_value | 4752 | | - dst->symbol.section->vma); | 4753 | | #endif | 4754 | 0 | if (ISFCN ((src->u.syment.n_type))) | 4755 | 0 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4756 | 0 | break; | 4757 | 1.06k | } | 4758 | | | 4759 | | #ifdef RS6000COFF_C | 4760 | | /* A symbol with a csect entry should not go at the end. */ | 4761 | | if (src->u.syment.n_numaux > 0) | 4762 | | dst->symbol.flags |= BSF_NOT_AT_END; | 4763 | | #endif | 4764 | | | 4765 | 1.06k | #ifdef COFF_WITH_PE | 4766 | 1.06k | if (src->u.syment.n_sclass == C_NT_WEAK) | 4767 | 92 | dst->symbol.flags |= BSF_WEAK; | 4768 | | | 4769 | 1.06k | if (src->u.syment.n_sclass == C_SECTION | 4770 | 1.06k | && src->u.syment.n_scnum > 0) | 4771 | 0 | dst->symbol.flags = BSF_LOCAL; | 4772 | 1.06k | #endif | 4773 | 1.06k | if (src->u.syment.n_sclass == C_WEAKEXT | 4774 | | #ifdef RS6000COFF_C | 4775 | | || src->u.syment.n_sclass == C_AIX_WEAKEXT | 4776 | | #endif | 4777 | 1.06k | ) | 4778 | 81 | dst->symbol.flags |= BSF_WEAK; | 4779 | | | 4780 | 1.06k | break; | 4781 | | | 4782 | 611 | case C_STAT: /* Static. */ | 4783 | | #if defined ARM | 4784 | | case C_THUMBSTAT: /* Thumb static. */ | 4785 | | case C_THUMBLABEL: /* Thumb label. */ | 4786 | | case C_THUMBSTATFUNC:/* Thumb static function. */ | 4787 | | #endif | 4788 | | #ifdef RS6000COFF_C | 4789 | | case C_DWARF: /* A label in a dwarf section. */ | 4790 | | case C_INFO: /* A label in a comment section. */ | 4791 | | #endif | 4792 | 1.12k | case C_LABEL: /* Label. */ | 4793 | 1.12k | if (src->u.syment.n_scnum == N_DEBUG) | 4794 | 6 | dst->symbol.flags = BSF_DEBUGGING; | 4795 | 1.11k | else | 4796 | 1.11k | dst->symbol.flags = BSF_LOCAL; | 4797 | | | 4798 | | /* Base the value as an index from the base of the | 4799 | | section, if there is one. */ | 4800 | 1.12k | if (dst->symbol.section) | 4801 | 1.12k | { | 4802 | 1.12k | #if defined COFF_WITH_PE | 4803 | | /* PE sets the symbol to a value relative to the | 4804 | | start of the section. */ | 4805 | 1.12k | dst->symbol.value = src->u.syment.n_value; | 4806 | | #else | 4807 | | dst->symbol.value = (src->u.syment.n_value | 4808 | | - dst->symbol.section->vma); | 4809 | | #endif | 4810 | 1.12k | } | 4811 | 0 | else | 4812 | 0 | dst->symbol.value = src->u.syment.n_value; | 4813 | 1.12k | break; | 4814 | | | 4815 | 377 | case C_FILE: /* File name. */ | 4816 | 377 | dst->symbol.flags = BSF_FILE; | 4817 | | /* Fall through. */ | 4818 | 535 | case C_MOS: /* Member of structure. */ | 4819 | 580 | case C_EOS: /* End of structure. */ | 4820 | 625 | case C_REGPARM: /* Register parameter. */ | 4821 | 794 | case C_REG: /* register variable. */ | 4822 | | /* C_AUTOARG conflicts with TI COFF C_UEXT. */ | 4823 | 884 | case C_TPDEF: /* Type definition. */ | 4824 | 921 | case C_ARG: | 4825 | 2.71k | case C_AUTO: /* Automatic variable. */ | 4826 | 3.01k | case C_FIELD: /* Bit field. */ | 4827 | 3.11k | case C_ENTAG: /* Enumeration tag. */ | 4828 | 3.31k | case C_MOE: /* Member of enumeration. */ | 4829 | 3.37k | case C_MOU: /* Member of union. */ | 4830 | 4.57k | case C_UNTAG: /* Union tag. */ | 4831 | 4.77k | case C_STRTAG: /* Structure tag. */ | 4832 | | #ifdef RS6000COFF_C | 4833 | | case C_GSYM: | 4834 | | case C_LSYM: | 4835 | | case C_PSYM: | 4836 | | case C_RSYM: | 4837 | | case C_RPSYM: | 4838 | | case C_STSYM: | 4839 | | case C_TCSYM: | 4840 | | case C_BCOMM: | 4841 | | case C_ECOML: | 4842 | | case C_ECOMM: | 4843 | | case C_DECL: | 4844 | | case C_ENTRY: | 4845 | | case C_FUN: | 4846 | | case C_ESTAT: | 4847 | | #endif | 4848 | 4.77k | dst->symbol.flags |= BSF_DEBUGGING; | 4849 | 4.77k | dst->symbol.value = (src->u.syment.n_value); | 4850 | 4.77k | break; | 4851 | | | 4852 | | #ifdef RS6000COFF_C | 4853 | | case C_BINCL: /* Beginning of include file. */ | 4854 | | case C_EINCL: /* Ending of include file. */ | 4855 | | /* The value is actually a pointer into the line numbers | 4856 | | of the file. We locate the line number entry, and | 4857 | | set the section to the section which contains it, and | 4858 | | the value to the index in that section. */ | 4859 | | { | 4860 | | asection *sec; | 4861 | | | 4862 | | dst->symbol.flags = BSF_DEBUGGING; | 4863 | | for (sec = abfd->sections; sec != NULL; sec = sec->next) | 4864 | | if (sec->line_filepos <= (file_ptr) src->u.syment.n_value | 4865 | | && ((file_ptr) (sec->line_filepos | 4866 | | + sec->lineno_count * bfd_coff_linesz (abfd)) | 4867 | | > (file_ptr) src->u.syment.n_value)) | 4868 | | break; | 4869 | | if (sec == NULL) | 4870 | | dst->symbol.value = 0; | 4871 | | else | 4872 | | { | 4873 | | dst->symbol.section = sec; | 4874 | | dst->symbol.value = ((src->u.syment.n_value | 4875 | | - sec->line_filepos) | 4876 | | / bfd_coff_linesz (abfd)); | 4877 | | src->fix_line = 1; | 4878 | | } | 4879 | | } | 4880 | | break; | 4881 | | | 4882 | | case C_BSTAT: | 4883 | | dst->symbol.flags = BSF_DEBUGGING; | 4884 | | | 4885 | | if (src->u.syment.n_value >= obj_raw_syment_count (abfd)) | 4886 | | dst->symbol.value = 0; | 4887 | | else | 4888 | | { | 4889 | | /* The value is actually a symbol index. Save a pointer | 4890 | | to the symbol instead of the index. FIXME: This | 4891 | | should use a union. */ | 4892 | | src->u.syment.n_value | 4893 | | = (uintptr_t) (native_symbols + src->u.syment.n_value); | 4894 | | dst->symbol.value = src->u.syment.n_value; | 4895 | | src->fix_value = 1; | 4896 | | } | 4897 | | break; | 4898 | | #endif | 4899 | | | 4900 | 26 | case C_BLOCK: /* ".bb" or ".eb". */ | 4901 | 294 | case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */ | 4902 | 498 | case C_EFCN: /* Physical end of function. */ | 4903 | 498 | #if defined COFF_WITH_PE | 4904 | | /* PE sets the symbol to a value relative to the start | 4905 | | of the section. */ | 4906 | 498 | dst->symbol.value = src->u.syment.n_value; | 4907 | 498 | if (strcmp (dst->symbol.name, ".bf") != 0) | 4908 | 498 | { | 4909 | | /* PE uses funny values for .ef and .lf; don't | 4910 | | relocate them. */ | 4911 | 498 | dst->symbol.flags = BSF_DEBUGGING; | 4912 | 498 | } | 4913 | 0 | else | 4914 | 0 | dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC; | 4915 | | #else | 4916 | | /* Base the value as an index from the base of the | 4917 | | section. */ | 4918 | | dst->symbol.flags = BSF_LOCAL; | 4919 | | dst->symbol.value = (src->u.syment.n_value | 4920 | | - dst->symbol.section->vma); | 4921 | | #endif | 4922 | 498 | break; | 4923 | | | 4924 | 68 | case C_STATLAB: /* Static load time label. */ | 4925 | 68 | dst->symbol.value = src->u.syment.n_value; | 4926 | 68 | dst->symbol.flags = BSF_GLOBAL; | 4927 | 68 | break; | 4928 | | | 4929 | 30.6k | case C_NULL: | 4930 | | /* PE DLLs sometimes have zeroed out symbols for some | 4931 | | reason. Just ignore them without a warning. */ | 4932 | 30.6k | if (src->u.syment.n_type == 0 | 4933 | 30.6k | && src->u.syment.n_value == 0 | 4934 | 30.6k | && src->u.syment.n_scnum == 0) | 4935 | 15.8k | break; | 4936 | | #ifdef RS6000COFF_C | 4937 | | /* XCOFF specific: deleted entry. */ | 4938 | | if (src->u.syment.n_value == C_NULL_VALUE) | 4939 | | break; | 4940 | | #endif | 4941 | | /* Fall through. */ | 4942 | 14.8k | case C_EXTDEF: /* External definition. */ | 4943 | 14.9k | case C_ULABEL: /* Undefined label. */ | 4944 | 15.0k | case C_USTATIC: /* Undefined static. */ | 4945 | | #ifndef COFF_WITH_PE | 4946 | | /* C_LINE in regular coff is 0x68. NT has taken over this storage | 4947 | | class to represent a section symbol. */ | 4948 | | case C_LINE: /* line # reformatted as symbol table entry. */ | 4949 | | /* NT uses 0x67 for a weak symbol, not C_ALIAS. */ | 4950 | | case C_ALIAS: /* Duplicate tag. */ | 4951 | | #endif | 4952 | | /* New storage classes for TI COFF. */ | 4953 | | #ifdef TICOFF | 4954 | | case C_UEXT: /* Tentative external definition. */ | 4955 | | #endif | 4956 | 15.0k | case C_EXTLAB: /* External load time label. */ | 4957 | 19.6k | default: | 4958 | 19.6k | _bfd_error_handler | 4959 | | /* xgettext:c-format */ | 4960 | 19.6k | (_("%pB: unrecognized storage class %d for %s symbol `%s'"), | 4961 | 19.6k | abfd, src->u.syment.n_sclass, | 4962 | 19.6k | dst->symbol.section->name, dst->symbol.name); | 4963 | 19.6k | ret = false; | 4964 | | /* Fall through. */ | 4965 | 19.6k | case C_HIDDEN: /* Ext symbol in dmert public lib. */ | 4966 | | /* PR 20722: These symbols can also be generated by | 4967 | | building DLLs with --gc-sections enabled. */ | 4968 | 19.6k | dst->symbol.flags = BSF_DEBUGGING; | 4969 | 19.6k | dst->symbol.value = (src->u.syment.n_value); | 4970 | 19.6k | break; | 4971 | 43.0k | } | 4972 | | | 4973 | 43.0k | dst->native = src; | 4974 | 43.0k | dst->symbol.udata.i = 0; | 4975 | 43.0k | dst->lineno = NULL; | 4976 | | | 4977 | 43.0k | this_index += (src->u.syment.n_numaux) + 1; | 4978 | 43.0k | dst++; | 4979 | 43.0k | number_of_symbols++; | 4980 | 43.0k | } | 4981 | 226 | } | 4982 | | | 4983 | 226 | obj_symbols (abfd) = cached_area; | 4984 | 226 | obj_raw_syments (abfd) = native_symbols; | 4985 | | | 4986 | 226 | abfd->symcount = number_of_symbols; | 4987 | 226 | obj_convert (abfd) = table_ptr; | 4988 | | /* Slurp the line tables for each section too. */ | 4989 | 226 | { | 4990 | 226 | asection *p; | 4991 | | | 4992 | 226 | p = abfd->sections; | 4993 | 1.19k | while (p) | 4994 | 1.07k | { | 4995 | 1.07k | if (! coff_slurp_line_table (abfd, p)) | 4996 | 105 | return false; | 4997 | 970 | p = p->next; | 4998 | 970 | } | 4999 | 226 | } | 5000 | | | 5001 | 121 | return ret; | 5002 | 226 | } |
pe-sh.c:coff_slurp_symbol_table Line | Count | Source | 4630 | 611 | { | 4631 | 611 | combined_entry_type *native_symbols; | 4632 | 611 | coff_symbol_type *cached_area; | 4633 | 611 | unsigned int *table_ptr; | 4634 | 611 | unsigned int number_of_symbols = 0; | 4635 | 611 | bool ret = true; | 4636 | 611 | size_t amt; | 4637 | | | 4638 | 611 | if (obj_symbols (abfd)) | 4639 | 371 | return true; | 4640 | | | 4641 | | /* Read in the symbol table. */ | 4642 | 240 | if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) | 4643 | 9 | return false; | 4644 | | | 4645 | | /* Allocate enough room for all the symbols in cached form. */ | 4646 | 231 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4647 | 231 | sizeof (*cached_area), &amt)) | 4648 | 0 | { | 4649 | 0 | bfd_set_error (bfd_error_file_too_big); | 4650 | 0 | return false; | 4651 | 0 | } | 4652 | 231 | cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt); | 4653 | 231 | if (cached_area == NULL) | 4654 | 0 | return false; | 4655 | | | 4656 | 231 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4657 | 231 | sizeof (*table_ptr), &amt)) | 4658 | 0 | { | 4659 | 0 | bfd_set_error (bfd_error_file_too_big); | 4660 | 0 | return false; | 4661 | 0 | } | 4662 | 231 | table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); | 4663 | 231 | if (table_ptr == NULL) | 4664 | 0 | return false; | 4665 | 231 | else | 4666 | 231 | { | 4667 | 231 | coff_symbol_type *dst = cached_area; | 4668 | 231 | unsigned int last_native_index = obj_raw_syment_count (abfd); | 4669 | 231 | unsigned int this_index = 0; | 4670 | | | 4671 | 24.3k | while (this_index < last_native_index) | 4672 | 24.1k | { | 4673 | 24.1k | combined_entry_type *src = native_symbols + this_index; | 4674 | 24.1k | table_ptr[this_index] = number_of_symbols; | 4675 | | | 4676 | 24.1k | dst->symbol.the_bfd = abfd; | 4677 | 24.1k | BFD_ASSERT (src->is_sym); | 4678 | 24.1k | dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset); | 4679 | | /* We use the native name field to point to the cached field. */ | 4680 | 24.1k | src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; | 4681 | 24.1k | dst->symbol.section = coff_section_from_bfd_index (abfd, | 4682 | 24.1k | src->u.syment.n_scnum); | 4683 | 24.1k | dst->symbol.flags = 0; | 4684 | | /* PR 17512: file: 079-7098-0.001:0.1. */ | 4685 | 24.1k | dst->symbol.value = 0; | 4686 | 24.1k | dst->done_lineno = false; | 4687 | | | 4688 | 24.1k | switch (src->u.syment.n_sclass) | 4689 | 24.1k | { | 4690 | 769 | case C_EXT: | 4691 | 863 | case C_WEAKEXT: | 4692 | | #if defined ARM | 4693 | | case C_THUMBEXT: | 4694 | | case C_THUMBEXTFUNC: | 4695 | | #endif | 4696 | | #ifdef RS6000COFF_C | 4697 | | case C_HIDEXT: | 4698 | | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 4699 | | case C_AIX_WEAKEXT: | 4700 | | #endif | 4701 | | #endif | 4702 | 863 | #ifdef C_SYSTEM | 4703 | 897 | case C_SYSTEM: /* System Wide variable. */ | 4704 | 897 | #endif | 4705 | 897 | #ifdef COFF_WITH_PE | 4706 | | /* In PE, 0x68 (104) denotes a section symbol. */ | 4707 | 899 | case C_SECTION: | 4708 | | /* In PE, 0x69 (105) denotes a weak external symbol. */ | 4709 | 952 | case C_NT_WEAK: | 4710 | 952 | #endif | 4711 | 952 | switch (coff_classify_symbol (abfd, &src->u.syment)) | 4712 | 952 | { | 4713 | 895 | case COFF_SYMBOL_GLOBAL: | 4714 | 895 | dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL; | 4715 | 895 | #if defined COFF_WITH_PE | 4716 | | /* PE sets the symbol to a value relative to the | 4717 | | start of the section. */ | 4718 | 895 | dst->symbol.value = src->u.syment.n_value; | 4719 | | #else | 4720 | | dst->symbol.value = (src->u.syment.n_value | 4721 | | - dst->symbol.section->vma); | 4722 | | #endif | 4723 | 895 | if (ISFCN ((src->u.syment.n_type))) | 4724 | | /* A function ext does not go at the end of a | 4725 | | file. */ | 4726 | 124 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4727 | 895 | break; | 4728 | | | 4729 | 34 | case COFF_SYMBOL_COMMON: | 4730 | 34 | dst->symbol.section = bfd_com_section_ptr; | 4731 | 34 | dst->symbol.value = src->u.syment.n_value; | 4732 | 34 | break; | 4733 | | | 4734 | 23 | case COFF_SYMBOL_UNDEFINED: | 4735 | 23 | dst->symbol.section = bfd_und_section_ptr; | 4736 | 23 | dst->symbol.value = 0; | 4737 | 23 | break; | 4738 | | | 4739 | 0 | case COFF_SYMBOL_PE_SECTION: | 4740 | 0 | dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM; | 4741 | 0 | dst->symbol.value = 0; | 4742 | 0 | break; | 4743 | | | 4744 | 0 | case COFF_SYMBOL_LOCAL: | 4745 | 0 | dst->symbol.flags = BSF_LOCAL; | 4746 | 0 | #if defined COFF_WITH_PE | 4747 | | /* PE sets the symbol to a value relative to the | 4748 | | start of the section. */ | 4749 | 0 | dst->symbol.value = src->u.syment.n_value; | 4750 | | #else | 4751 | | dst->symbol.value = (src->u.syment.n_value | 4752 | | - dst->symbol.section->vma); | 4753 | | #endif | 4754 | 0 | if (ISFCN ((src->u.syment.n_type))) | 4755 | 0 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4756 | 0 | break; | 4757 | 952 | } | 4758 | | | 4759 | | #ifdef RS6000COFF_C | 4760 | | /* A symbol with a csect entry should not go at the end. */ | 4761 | | if (src->u.syment.n_numaux > 0) | 4762 | | dst->symbol.flags |= BSF_NOT_AT_END; | 4763 | | #endif | 4764 | | | 4765 | 952 | #ifdef COFF_WITH_PE | 4766 | 952 | if (src->u.syment.n_sclass == C_NT_WEAK) | 4767 | 53 | dst->symbol.flags |= BSF_WEAK; | 4768 | | | 4769 | 952 | if (src->u.syment.n_sclass == C_SECTION | 4770 | 952 | && src->u.syment.n_scnum > 0) | 4771 | 0 | dst->symbol.flags = BSF_LOCAL; | 4772 | 952 | #endif | 4773 | 952 | if (src->u.syment.n_sclass == C_WEAKEXT | 4774 | | #ifdef RS6000COFF_C | 4775 | | || src->u.syment.n_sclass == C_AIX_WEAKEXT | 4776 | | #endif | 4777 | 952 | ) | 4778 | 94 | dst->symbol.flags |= BSF_WEAK; | 4779 | | | 4780 | 952 | break; | 4781 | | | 4782 | 135 | case C_STAT: /* Static. */ | 4783 | | #if defined ARM | 4784 | | case C_THUMBSTAT: /* Thumb static. */ | 4785 | | case C_THUMBLABEL: /* Thumb label. */ | 4786 | | case C_THUMBSTATFUNC:/* Thumb static function. */ | 4787 | | #endif | 4788 | | #ifdef RS6000COFF_C | 4789 | | case C_DWARF: /* A label in a dwarf section. */ | 4790 | | case C_INFO: /* A label in a comment section. */ | 4791 | | #endif | 4792 | 284 | case C_LABEL: /* Label. */ | 4793 | 284 | if (src->u.syment.n_scnum == N_DEBUG) | 4794 | 6 | dst->symbol.flags = BSF_DEBUGGING; | 4795 | 278 | else | 4796 | 278 | dst->symbol.flags = BSF_LOCAL; | 4797 | | | 4798 | | /* Base the value as an index from the base of the | 4799 | | section, if there is one. */ | 4800 | 284 | if (dst->symbol.section) | 4801 | 284 | { | 4802 | 284 | #if defined COFF_WITH_PE | 4803 | | /* PE sets the symbol to a value relative to the | 4804 | | start of the section. */ | 4805 | 284 | dst->symbol.value = src->u.syment.n_value; | 4806 | | #else | 4807 | | dst->symbol.value = (src->u.syment.n_value | 4808 | | - dst->symbol.section->vma); | 4809 | | #endif | 4810 | 284 | } | 4811 | 0 | else | 4812 | 0 | dst->symbol.value = src->u.syment.n_value; | 4813 | 284 | break; | 4814 | | | 4815 | 150 | case C_FILE: /* File name. */ | 4816 | 150 | dst->symbol.flags = BSF_FILE; | 4817 | | /* Fall through. */ | 4818 | 232 | case C_MOS: /* Member of structure. */ | 4819 | 255 | case C_EOS: /* End of structure. */ | 4820 | 428 | case C_REGPARM: /* Register parameter. */ | 4821 | 509 | case C_REG: /* register variable. */ | 4822 | | /* C_AUTOARG conflicts with TI COFF C_UEXT. */ | 4823 | 656 | case C_TPDEF: /* Type definition. */ | 4824 | 2.13k | case C_ARG: | 4825 | 3.11k | case C_AUTO: /* Automatic variable. */ | 4826 | 3.33k | case C_FIELD: /* Bit field. */ | 4827 | 3.44k | case C_ENTAG: /* Enumeration tag. */ | 4828 | 3.78k | case C_MOE: /* Member of enumeration. */ | 4829 | 3.91k | case C_MOU: /* Member of union. */ | 4830 | 4.01k | case C_UNTAG: /* Union tag. */ | 4831 | 4.21k | case C_STRTAG: /* Structure tag. */ | 4832 | | #ifdef RS6000COFF_C | 4833 | | case C_GSYM: | 4834 | | case C_LSYM: | 4835 | | case C_PSYM: | 4836 | | case C_RSYM: | 4837 | | case C_RPSYM: | 4838 | | case C_STSYM: | 4839 | | case C_TCSYM: | 4840 | | case C_BCOMM: | 4841 | | case C_ECOML: | 4842 | | case C_ECOMM: | 4843 | | case C_DECL: | 4844 | | case C_ENTRY: | 4845 | | case C_FUN: | 4846 | | case C_ESTAT: | 4847 | | #endif | 4848 | 4.21k | dst->symbol.flags |= BSF_DEBUGGING; | 4849 | 4.21k | dst->symbol.value = (src->u.syment.n_value); | 4850 | 4.21k | break; | 4851 | | | 4852 | | #ifdef RS6000COFF_C | 4853 | | case C_BINCL: /* Beginning of include file. */ | 4854 | | case C_EINCL: /* Ending of include file. */ | 4855 | | /* The value is actually a pointer into the line numbers | 4856 | | of the file. We locate the line number entry, and | 4857 | | set the section to the section which contains it, and | 4858 | | the value to the index in that section. */ | 4859 | | { | 4860 | | asection *sec; | 4861 | | | 4862 | | dst->symbol.flags = BSF_DEBUGGING; | 4863 | | for (sec = abfd->sections; sec != NULL; sec = sec->next) | 4864 | | if (sec->line_filepos <= (file_ptr) src->u.syment.n_value | 4865 | | && ((file_ptr) (sec->line_filepos | 4866 | | + sec->lineno_count * bfd_coff_linesz (abfd)) | 4867 | | > (file_ptr) src->u.syment.n_value)) | 4868 | | break; | 4869 | | if (sec == NULL) | 4870 | | dst->symbol.value = 0; | 4871 | | else | 4872 | | { | 4873 | | dst->symbol.section = sec; | 4874 | | dst->symbol.value = ((src->u.syment.n_value | 4875 | | - sec->line_filepos) | 4876 | | / bfd_coff_linesz (abfd)); | 4877 | | src->fix_line = 1; | 4878 | | } | 4879 | | } | 4880 | | break; | 4881 | | | 4882 | | case C_BSTAT: | 4883 | | dst->symbol.flags = BSF_DEBUGGING; | 4884 | | | 4885 | | if (src->u.syment.n_value >= obj_raw_syment_count (abfd)) | 4886 | | dst->symbol.value = 0; | 4887 | | else | 4888 | | { | 4889 | | /* The value is actually a symbol index. Save a pointer | 4890 | | to the symbol instead of the index. FIXME: This | 4891 | | should use a union. */ | 4892 | | src->u.syment.n_value | 4893 | | = (uintptr_t) (native_symbols + src->u.syment.n_value); | 4894 | | dst->symbol.value = src->u.syment.n_value; | 4895 | | src->fix_value = 1; | 4896 | | } | 4897 | | break; | 4898 | | #endif | 4899 | | | 4900 | 8 | case C_BLOCK: /* ".bb" or ".eb". */ | 4901 | 58 | case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */ | 4902 | 144 | case C_EFCN: /* Physical end of function. */ | 4903 | 144 | #if defined COFF_WITH_PE | 4904 | | /* PE sets the symbol to a value relative to the start | 4905 | | of the section. */ | 4906 | 144 | dst->symbol.value = src->u.syment.n_value; | 4907 | 144 | if (strcmp (dst->symbol.name, ".bf") != 0) | 4908 | 144 | { | 4909 | | /* PE uses funny values for .ef and .lf; don't | 4910 | | relocate them. */ | 4911 | 144 | dst->symbol.flags = BSF_DEBUGGING; | 4912 | 144 | } | 4913 | 0 | else | 4914 | 0 | dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC; | 4915 | | #else | 4916 | | /* Base the value as an index from the base of the | 4917 | | section. */ | 4918 | | dst->symbol.flags = BSF_LOCAL; | 4919 | | dst->symbol.value = (src->u.syment.n_value | 4920 | | - dst->symbol.section->vma); | 4921 | | #endif | 4922 | 144 | break; | 4923 | | | 4924 | 95 | case C_STATLAB: /* Static load time label. */ | 4925 | 95 | dst->symbol.value = src->u.syment.n_value; | 4926 | 95 | dst->symbol.flags = BSF_GLOBAL; | 4927 | 95 | break; | 4928 | | | 4929 | 15.2k | case C_NULL: | 4930 | | /* PE DLLs sometimes have zeroed out symbols for some | 4931 | | reason. Just ignore them without a warning. */ | 4932 | 15.2k | if (src->u.syment.n_type == 0 | 4933 | 15.2k | && src->u.syment.n_value == 0 | 4934 | 15.2k | && src->u.syment.n_scnum == 0) | 4935 | 5.78k | break; | 4936 | | #ifdef RS6000COFF_C | 4937 | | /* XCOFF specific: deleted entry. */ | 4938 | | if (src->u.syment.n_value == C_NULL_VALUE) | 4939 | | break; | 4940 | | #endif | 4941 | | /* Fall through. */ | 4942 | 9.54k | case C_EXTDEF: /* External definition. */ | 4943 | 9.57k | case C_ULABEL: /* Undefined label. */ | 4944 | 9.61k | case C_USTATIC: /* Undefined static. */ | 4945 | | #ifndef COFF_WITH_PE | 4946 | | /* C_LINE in regular coff is 0x68. NT has taken over this storage | 4947 | | class to represent a section symbol. */ | 4948 | | case C_LINE: /* line # reformatted as symbol table entry. */ | 4949 | | /* NT uses 0x67 for a weak symbol, not C_ALIAS. */ | 4950 | | case C_ALIAS: /* Duplicate tag. */ | 4951 | | #endif | 4952 | | /* New storage classes for TI COFF. */ | 4953 | | #ifdef TICOFF | 4954 | | case C_UEXT: /* Tentative external definition. */ | 4955 | | #endif | 4956 | 9.61k | case C_EXTLAB: /* External load time label. */ | 4957 | 12.6k | default: | 4958 | 12.6k | _bfd_error_handler | 4959 | | /* xgettext:c-format */ | 4960 | 12.6k | (_("%pB: unrecognized storage class %d for %s symbol `%s'"), | 4961 | 12.6k | abfd, src->u.syment.n_sclass, | 4962 | 12.6k | dst->symbol.section->name, dst->symbol.name); | 4963 | 12.6k | ret = false; | 4964 | | /* Fall through. */ | 4965 | 12.6k | case C_HIDDEN: /* Ext symbol in dmert public lib. */ | 4966 | | /* PR 20722: These symbols can also be generated by | 4967 | | building DLLs with --gc-sections enabled. */ | 4968 | 12.6k | dst->symbol.flags = BSF_DEBUGGING; | 4969 | 12.6k | dst->symbol.value = (src->u.syment.n_value); | 4970 | 12.6k | break; | 4971 | 24.1k | } | 4972 | | | 4973 | 24.1k | dst->native = src; | 4974 | 24.1k | dst->symbol.udata.i = 0; | 4975 | 24.1k | dst->lineno = NULL; | 4976 | | | 4977 | 24.1k | this_index += (src->u.syment.n_numaux) + 1; | 4978 | 24.1k | dst++; | 4979 | 24.1k | number_of_symbols++; | 4980 | 24.1k | } | 4981 | 231 | } | 4982 | | | 4983 | 231 | obj_symbols (abfd) = cached_area; | 4984 | 231 | obj_raw_syments (abfd) = native_symbols; | 4985 | | | 4986 | 231 | abfd->symcount = number_of_symbols; | 4987 | 231 | obj_convert (abfd) = table_ptr; | 4988 | | /* Slurp the line tables for each section too. */ | 4989 | 231 | { | 4990 | 231 | asection *p; | 4991 | | | 4992 | 231 | p = abfd->sections; | 4993 | 783 | while (p) | 4994 | 642 | { | 4995 | 642 | if (! coff_slurp_line_table (abfd, p)) | 4996 | 90 | return false; | 4997 | 552 | p = p->next; | 4998 | 552 | } | 4999 | 231 | } | 5000 | | | 5001 | 141 | return ret; | 5002 | 231 | } |
pei-arm-wince.c:coff_slurp_symbol_table Line | Count | Source | 4630 | 177 | { | 4631 | 177 | combined_entry_type *native_symbols; | 4632 | 177 | coff_symbol_type *cached_area; | 4633 | 177 | unsigned int *table_ptr; | 4634 | 177 | unsigned int number_of_symbols = 0; | 4635 | 177 | bool ret = true; | 4636 | 177 | size_t amt; | 4637 | | | 4638 | 177 | if (obj_symbols (abfd)) | 4639 | 28 | return true; | 4640 | | | 4641 | | /* Read in the symbol table. */ | 4642 | 149 | if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) | 4643 | 28 | return false; | 4644 | | | 4645 | | /* Allocate enough room for all the symbols in cached form. */ | 4646 | 121 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4647 | 121 | sizeof (*cached_area), &amt)) | 4648 | 0 | { | 4649 | 0 | bfd_set_error (bfd_error_file_too_big); | 4650 | 0 | return false; | 4651 | 0 | } | 4652 | 121 | cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt); | 4653 | 121 | if (cached_area == NULL) | 4654 | 0 | return false; | 4655 | | | 4656 | 121 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4657 | 121 | sizeof (*table_ptr), &amt)) | 4658 | 0 | { | 4659 | 0 | bfd_set_error (bfd_error_file_too_big); | 4660 | 0 | return false; | 4661 | 0 | } | 4662 | 121 | table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); | 4663 | 121 | if (table_ptr == NULL) | 4664 | 0 | return false; | 4665 | 121 | else | 4666 | 121 | { | 4667 | 121 | coff_symbol_type *dst = cached_area; | 4668 | 121 | unsigned int last_native_index = obj_raw_syment_count (abfd); | 4669 | 121 | unsigned int this_index = 0; | 4670 | | | 4671 | 18.4k | while (this_index < last_native_index) | 4672 | 18.3k | { | 4673 | 18.3k | combined_entry_type *src = native_symbols + this_index; | 4674 | 18.3k | table_ptr[this_index] = number_of_symbols; | 4675 | | | 4676 | 18.3k | dst->symbol.the_bfd = abfd; | 4677 | 18.3k | BFD_ASSERT (src->is_sym); | 4678 | 18.3k | dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset); | 4679 | | /* We use the native name field to point to the cached field. */ | 4680 | 18.3k | src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; | 4681 | 18.3k | dst->symbol.section = coff_section_from_bfd_index (abfd, | 4682 | 18.3k | src->u.syment.n_scnum); | 4683 | 18.3k | dst->symbol.flags = 0; | 4684 | | /* PR 17512: file: 079-7098-0.001:0.1. */ | 4685 | 18.3k | dst->symbol.value = 0; | 4686 | 18.3k | dst->done_lineno = false; | 4687 | | | 4688 | 18.3k | switch (src->u.syment.n_sclass) | 4689 | 18.3k | { | 4690 | 267 | case C_EXT: | 4691 | 278 | case C_WEAKEXT: | 4692 | 278 | #if defined ARM | 4693 | 293 | case C_THUMBEXT: | 4694 | 332 | case C_THUMBEXTFUNC: | 4695 | 332 | #endif | 4696 | | #ifdef RS6000COFF_C | 4697 | | case C_HIDEXT: | 4698 | | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 4699 | | case C_AIX_WEAKEXT: | 4700 | | #endif | 4701 | | #endif | 4702 | 332 | #ifdef C_SYSTEM | 4703 | 418 | case C_SYSTEM: /* System Wide variable. */ | 4704 | 418 | #endif | 4705 | 418 | #ifdef COFF_WITH_PE | 4706 | | /* In PE, 0x68 (104) denotes a section symbol. */ | 4707 | 421 | case C_SECTION: | 4708 | | /* In PE, 0x69 (105) denotes a weak external symbol. */ | 4709 | 448 | case C_NT_WEAK: | 4710 | 448 | #endif | 4711 | 448 | switch (coff_classify_symbol (abfd, &src->u.syment)) | 4712 | 448 | { | 4713 | 383 | case COFF_SYMBOL_GLOBAL: | 4714 | 383 | dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL; | 4715 | 383 | #if defined COFF_WITH_PE | 4716 | | /* PE sets the symbol to a value relative to the | 4717 | | start of the section. */ | 4718 | 383 | dst->symbol.value = src->u.syment.n_value; | 4719 | | #else | 4720 | | dst->symbol.value = (src->u.syment.n_value | 4721 | | - dst->symbol.section->vma); | 4722 | | #endif | 4723 | 383 | if (ISFCN ((src->u.syment.n_type))) | 4724 | | /* A function ext does not go at the end of a | 4725 | | file. */ | 4726 | 19 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4727 | 383 | break; | 4728 | | | 4729 | 45 | case COFF_SYMBOL_COMMON: | 4730 | 45 | dst->symbol.section = bfd_com_section_ptr; | 4731 | 45 | dst->symbol.value = src->u.syment.n_value; | 4732 | 45 | break; | 4733 | | | 4734 | 20 | case COFF_SYMBOL_UNDEFINED: | 4735 | 20 | dst->symbol.section = bfd_und_section_ptr; | 4736 | 20 | dst->symbol.value = 0; | 4737 | 20 | break; | 4738 | | | 4739 | 0 | case COFF_SYMBOL_PE_SECTION: | 4740 | 0 | dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM; | 4741 | 0 | dst->symbol.value = 0; | 4742 | 0 | break; | 4743 | | | 4744 | 0 | case COFF_SYMBOL_LOCAL: | 4745 | 0 | dst->symbol.flags = BSF_LOCAL; | 4746 | 0 | #if defined COFF_WITH_PE | 4747 | | /* PE sets the symbol to a value relative to the | 4748 | | start of the section. */ | 4749 | 0 | dst->symbol.value = src->u.syment.n_value; | 4750 | | #else | 4751 | | dst->symbol.value = (src->u.syment.n_value | 4752 | | - dst->symbol.section->vma); | 4753 | | #endif | 4754 | 0 | if (ISFCN ((src->u.syment.n_type))) | 4755 | 0 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4756 | 0 | break; | 4757 | 448 | } | 4758 | | | 4759 | | #ifdef RS6000COFF_C | 4760 | | /* A symbol with a csect entry should not go at the end. */ | 4761 | | if (src->u.syment.n_numaux > 0) | 4762 | | dst->symbol.flags |= BSF_NOT_AT_END; | 4763 | | #endif | 4764 | | | 4765 | 448 | #ifdef COFF_WITH_PE | 4766 | 448 | if (src->u.syment.n_sclass == C_NT_WEAK) | 4767 | 27 | dst->symbol.flags |= BSF_WEAK; | 4768 | | | 4769 | 448 | if (src->u.syment.n_sclass == C_SECTION | 4770 | 448 | && src->u.syment.n_scnum > 0) | 4771 | 0 | dst->symbol.flags = BSF_LOCAL; | 4772 | 448 | #endif | 4773 | 448 | if (src->u.syment.n_sclass == C_WEAKEXT | 4774 | | #ifdef RS6000COFF_C | 4775 | | || src->u.syment.n_sclass == C_AIX_WEAKEXT | 4776 | | #endif | 4777 | 448 | ) | 4778 | 11 | dst->symbol.flags |= BSF_WEAK; | 4779 | | | 4780 | 448 | break; | 4781 | | | 4782 | 244 | case C_STAT: /* Static. */ | 4783 | 244 | #if defined ARM | 4784 | 265 | case C_THUMBSTAT: /* Thumb static. */ | 4785 | 273 | case C_THUMBLABEL: /* Thumb label. */ | 4786 | 336 | case C_THUMBSTATFUNC:/* Thumb static function. */ | 4787 | 336 | #endif | 4788 | | #ifdef RS6000COFF_C | 4789 | | case C_DWARF: /* A label in a dwarf section. */ | 4790 | | case C_INFO: /* A label in a comment section. */ | 4791 | | #endif | 4792 | 1.33k | case C_LABEL: /* Label. */ | 4793 | 1.33k | if (src->u.syment.n_scnum == N_DEBUG) | 4794 | 1 | dst->symbol.flags = BSF_DEBUGGING; | 4795 | 1.33k | else | 4796 | 1.33k | dst->symbol.flags = BSF_LOCAL; | 4797 | | | 4798 | | /* Base the value as an index from the base of the | 4799 | | section, if there is one. */ | 4800 | 1.33k | if (dst->symbol.section) | 4801 | 1.33k | { | 4802 | 1.33k | #if defined COFF_WITH_PE | 4803 | | /* PE sets the symbol to a value relative to the | 4804 | | start of the section. */ | 4805 | 1.33k | dst->symbol.value = src->u.syment.n_value; | 4806 | | #else | 4807 | | dst->symbol.value = (src->u.syment.n_value | 4808 | | - dst->symbol.section->vma); | 4809 | | #endif | 4810 | 1.33k | } | 4811 | 0 | else | 4812 | 0 | dst->symbol.value = src->u.syment.n_value; | 4813 | 1.33k | break; | 4814 | | | 4815 | 61 | case C_FILE: /* File name. */ | 4816 | 61 | dst->symbol.flags = BSF_FILE; | 4817 | | /* Fall through. */ | 4818 | 850 | case C_MOS: /* Member of structure. */ | 4819 | 873 | case C_EOS: /* End of structure. */ | 4820 | 891 | case C_REGPARM: /* Register parameter. */ | 4821 | 978 | case C_REG: /* register variable. */ | 4822 | | /* C_AUTOARG conflicts with TI COFF C_UEXT. */ | 4823 | 1.25k | case C_TPDEF: /* Type definition. */ | 4824 | 1.30k | case C_ARG: | 4825 | 1.88k | case C_AUTO: /* Automatic variable. */ | 4826 | 1.92k | case C_FIELD: /* Bit field. */ | 4827 | 2.02k | case C_ENTAG: /* Enumeration tag. */ | 4828 | 2.09k | case C_MOE: /* Member of enumeration. */ | 4829 | 2.13k | case C_MOU: /* Member of union. */ | 4830 | 2.25k | case C_UNTAG: /* Union tag. */ | 4831 | 2.60k | case C_STRTAG: /* Structure tag. */ | 4832 | | #ifdef RS6000COFF_C | 4833 | | case C_GSYM: | 4834 | | case C_LSYM: | 4835 | | case C_PSYM: | 4836 | | case C_RSYM: | 4837 | | case C_RPSYM: | 4838 | | case C_STSYM: | 4839 | | case C_TCSYM: | 4840 | | case C_BCOMM: | 4841 | | case C_ECOML: | 4842 | | case C_ECOMM: | 4843 | | case C_DECL: | 4844 | | case C_ENTRY: | 4845 | | case C_FUN: | 4846 | | case C_ESTAT: | 4847 | | #endif | 4848 | 2.60k | dst->symbol.flags |= BSF_DEBUGGING; | 4849 | 2.60k | dst->symbol.value = (src->u.syment.n_value); | 4850 | 2.60k | break; | 4851 | | | 4852 | | #ifdef RS6000COFF_C | 4853 | | case C_BINCL: /* Beginning of include file. */ | 4854 | | case C_EINCL: /* Ending of include file. */ | 4855 | | /* The value is actually a pointer into the line numbers | 4856 | | of the file. We locate the line number entry, and | 4857 | | set the section to the section which contains it, and | 4858 | | the value to the index in that section. */ | 4859 | | { | 4860 | | asection *sec; | 4861 | | | 4862 | | dst->symbol.flags = BSF_DEBUGGING; | 4863 | | for (sec = abfd->sections; sec != NULL; sec = sec->next) | 4864 | | if (sec->line_filepos <= (file_ptr) src->u.syment.n_value | 4865 | | && ((file_ptr) (sec->line_filepos | 4866 | | + sec->lineno_count * bfd_coff_linesz (abfd)) | 4867 | | > (file_ptr) src->u.syment.n_value)) | 4868 | | break; | 4869 | | if (sec == NULL) | 4870 | | dst->symbol.value = 0; | 4871 | | else | 4872 | | { | 4873 | | dst->symbol.section = sec; | 4874 | | dst->symbol.value = ((src->u.syment.n_value | 4875 | | - sec->line_filepos) | 4876 | | / bfd_coff_linesz (abfd)); | 4877 | | src->fix_line = 1; | 4878 | | } | 4879 | | } | 4880 | | break; | 4881 | | | 4882 | | case C_BSTAT: | 4883 | | dst->symbol.flags = BSF_DEBUGGING; | 4884 | | | 4885 | | if (src->u.syment.n_value >= obj_raw_syment_count (abfd)) | 4886 | | dst->symbol.value = 0; | 4887 | | else | 4888 | | { | 4889 | | /* The value is actually a symbol index. Save a pointer | 4890 | | to the symbol instead of the index. FIXME: This | 4891 | | should use a union. */ | 4892 | | src->u.syment.n_value | 4893 | | = (uintptr_t) (native_symbols + src->u.syment.n_value); | 4894 | | dst->symbol.value = src->u.syment.n_value; | 4895 | | src->fix_value = 1; | 4896 | | } | 4897 | | break; | 4898 | | #endif | 4899 | | | 4900 | 26 | case C_BLOCK: /* ".bb" or ".eb". */ | 4901 | 53 | case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */ | 4902 | 99 | case C_EFCN: /* Physical end of function. */ | 4903 | 99 | #if defined COFF_WITH_PE | 4904 | | /* PE sets the symbol to a value relative to the start | 4905 | | of the section. */ | 4906 | 99 | dst->symbol.value = src->u.syment.n_value; | 4907 | 99 | if (strcmp (dst->symbol.name, ".bf") != 0) | 4908 | 99 | { | 4909 | | /* PE uses funny values for .ef and .lf; don't | 4910 | | relocate them. */ | 4911 | 99 | dst->symbol.flags = BSF_DEBUGGING; | 4912 | 99 | } | 4913 | 0 | else | 4914 | 0 | dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC; | 4915 | | #else | 4916 | | /* Base the value as an index from the base of the | 4917 | | section. */ | 4918 | | dst->symbol.flags = BSF_LOCAL; | 4919 | | dst->symbol.value = (src->u.syment.n_value | 4920 | | - dst->symbol.section->vma); | 4921 | | #endif | 4922 | 99 | break; | 4923 | | | 4924 | 35 | case C_STATLAB: /* Static load time label. */ | 4925 | 35 | dst->symbol.value = src->u.syment.n_value; | 4926 | 35 | dst->symbol.flags = BSF_GLOBAL; | 4927 | 35 | break; | 4928 | | | 4929 | 11.3k | case C_NULL: | 4930 | | /* PE DLLs sometimes have zeroed out symbols for some | 4931 | | reason. Just ignore them without a warning. */ | 4932 | 11.3k | if (src->u.syment.n_type == 0 | 4933 | 11.3k | && src->u.syment.n_value == 0 | 4934 | 11.3k | && src->u.syment.n_scnum == 0) | 4935 | 4.02k | break; | 4936 | | #ifdef RS6000COFF_C | 4937 | | /* XCOFF specific: deleted entry. */ | 4938 | | if (src->u.syment.n_value == C_NULL_VALUE) | 4939 | | break; | 4940 | | #endif | 4941 | | /* Fall through. */ | 4942 | 7.33k | case C_EXTDEF: /* External definition. */ | 4943 | 7.35k | case C_ULABEL: /* Undefined label. */ | 4944 | 7.36k | case C_USTATIC: /* Undefined static. */ | 4945 | | #ifndef COFF_WITH_PE | 4946 | | /* C_LINE in regular coff is 0x68. NT has taken over this storage | 4947 | | class to represent a section symbol. */ | 4948 | | case C_LINE: /* line # reformatted as symbol table entry. */ | 4949 | | /* NT uses 0x67 for a weak symbol, not C_ALIAS. */ | 4950 | | case C_ALIAS: /* Duplicate tag. */ | 4951 | | #endif | 4952 | | /* New storage classes for TI COFF. */ | 4953 | | #ifdef TICOFF | 4954 | | case C_UEXT: /* Tentative external definition. */ | 4955 | | #endif | 4956 | 7.36k | case C_EXTLAB: /* External load time label. */ | 4957 | 9.75k | default: | 4958 | 9.75k | _bfd_error_handler | 4959 | | /* xgettext:c-format */ | 4960 | 9.75k | (_("%pB: unrecognized storage class %d for %s symbol `%s'"), | 4961 | 9.75k | abfd, src->u.syment.n_sclass, | 4962 | 9.75k | dst->symbol.section->name, dst->symbol.name); | 4963 | 9.75k | ret = false; | 4964 | | /* Fall through. */ | 4965 | 9.81k | case C_HIDDEN: /* Ext symbol in dmert public lib. */ | 4966 | | /* PR 20722: These symbols can also be generated by | 4967 | | building DLLs with --gc-sections enabled. */ | 4968 | 9.81k | dst->symbol.flags = BSF_DEBUGGING; | 4969 | 9.81k | dst->symbol.value = (src->u.syment.n_value); | 4970 | 9.81k | break; | 4971 | 18.3k | } | 4972 | | | 4973 | 18.3k | dst->native = src; | 4974 | 18.3k | dst->symbol.udata.i = 0; | 4975 | 18.3k | dst->lineno = NULL; | 4976 | | | 4977 | 18.3k | this_index += (src->u.syment.n_numaux) + 1; | 4978 | 18.3k | dst++; | 4979 | 18.3k | number_of_symbols++; | 4980 | 18.3k | } | 4981 | 121 | } | 4982 | | | 4983 | 121 | obj_symbols (abfd) = cached_area; | 4984 | 121 | obj_raw_syments (abfd) = native_symbols; | 4985 | | | 4986 | 121 | abfd->symcount = number_of_symbols; | 4987 | 121 | obj_convert (abfd) = table_ptr; | 4988 | | /* Slurp the line tables for each section too. */ | 4989 | 121 | { | 4990 | 121 | asection *p; | 4991 | | | 4992 | 121 | p = abfd->sections; | 4993 | 184 | while (p) | 4994 | 170 | { | 4995 | 170 | if (! coff_slurp_line_table (abfd, p)) | 4996 | 107 | return false; | 4997 | 63 | p = p->next; | 4998 | 63 | } | 4999 | 121 | } | 5000 | | | 5001 | 14 | return ret; | 5002 | 121 | } |
pei-arm.c:coff_slurp_symbol_table Line | Count | Source | 4630 | 295 | { | 4631 | 295 | combined_entry_type *native_symbols; | 4632 | 295 | coff_symbol_type *cached_area; | 4633 | 295 | unsigned int *table_ptr; | 4634 | 295 | unsigned int number_of_symbols = 0; | 4635 | 295 | bool ret = true; | 4636 | 295 | size_t amt; | 4637 | | | 4638 | 295 | if (obj_symbols (abfd)) | 4639 | 55 | return true; | 4640 | | | 4641 | | /* Read in the symbol table. */ | 4642 | 240 | if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) | 4643 | 68 | return false; | 4644 | | | 4645 | | /* Allocate enough room for all the symbols in cached form. */ | 4646 | 172 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4647 | 172 | sizeof (*cached_area), &amt)) | 4648 | 0 | { | 4649 | 0 | bfd_set_error (bfd_error_file_too_big); | 4650 | 0 | return false; | 4651 | 0 | } | 4652 | 172 | cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt); | 4653 | 172 | if (cached_area == NULL) | 4654 | 0 | return false; | 4655 | | | 4656 | 172 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4657 | 172 | sizeof (*table_ptr), &amt)) | 4658 | 0 | { | 4659 | 0 | bfd_set_error (bfd_error_file_too_big); | 4660 | 0 | return false; | 4661 | 0 | } | 4662 | 172 | table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); | 4663 | 172 | if (table_ptr == NULL) | 4664 | 0 | return false; | 4665 | 172 | else | 4666 | 172 | { | 4667 | 172 | coff_symbol_type *dst = cached_area; | 4668 | 172 | unsigned int last_native_index = obj_raw_syment_count (abfd); | 4669 | 172 | unsigned int this_index = 0; | 4670 | | | 4671 | 28.1k | while (this_index < last_native_index) | 4672 | 27.9k | { | 4673 | 27.9k | combined_entry_type *src = native_symbols + this_index; | 4674 | 27.9k | table_ptr[this_index] = number_of_symbols; | 4675 | | | 4676 | 27.9k | dst->symbol.the_bfd = abfd; | 4677 | 27.9k | BFD_ASSERT (src->is_sym); | 4678 | 27.9k | dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset); | 4679 | | /* We use the native name field to point to the cached field. */ | 4680 | 27.9k | src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; | 4681 | 27.9k | dst->symbol.section = coff_section_from_bfd_index (abfd, | 4682 | 27.9k | src->u.syment.n_scnum); | 4683 | 27.9k | dst->symbol.flags = 0; | 4684 | | /* PR 17512: file: 079-7098-0.001:0.1. */ | 4685 | 27.9k | dst->symbol.value = 0; | 4686 | 27.9k | dst->done_lineno = false; | 4687 | | | 4688 | 27.9k | switch (src->u.syment.n_sclass) | 4689 | 27.9k | { | 4690 | 347 | case C_EXT: | 4691 | 359 | case C_WEAKEXT: | 4692 | 359 | #if defined ARM | 4693 | 374 | case C_THUMBEXT: | 4694 | 422 | case C_THUMBEXTFUNC: | 4695 | 422 | #endif | 4696 | | #ifdef RS6000COFF_C | 4697 | | case C_HIDEXT: | 4698 | | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 4699 | | case C_AIX_WEAKEXT: | 4700 | | #endif | 4701 | | #endif | 4702 | 422 | #ifdef C_SYSTEM | 4703 | 539 | case C_SYSTEM: /* System Wide variable. */ | 4704 | 539 | #endif | 4705 | 539 | #ifdef COFF_WITH_PE | 4706 | | /* In PE, 0x68 (104) denotes a section symbol. */ | 4707 | 545 | case C_SECTION: | 4708 | | /* In PE, 0x69 (105) denotes a weak external symbol. */ | 4709 | 587 | case C_NT_WEAK: | 4710 | 587 | #endif | 4711 | 587 | switch (coff_classify_symbol (abfd, &src->u.syment)) | 4712 | 587 | { | 4713 | 475 | case COFF_SYMBOL_GLOBAL: | 4714 | 475 | dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL; | 4715 | 475 | #if defined COFF_WITH_PE | 4716 | | /* PE sets the symbol to a value relative to the | 4717 | | start of the section. */ | 4718 | 475 | dst->symbol.value = src->u.syment.n_value; | 4719 | | #else | 4720 | | dst->symbol.value = (src->u.syment.n_value | 4721 | | - dst->symbol.section->vma); | 4722 | | #endif | 4723 | 475 | if (ISFCN ((src->u.syment.n_type))) | 4724 | | /* A function ext does not go at the end of a | 4725 | | file. */ | 4726 | 25 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4727 | 475 | break; | 4728 | | | 4729 | 45 | case COFF_SYMBOL_COMMON: | 4730 | 45 | dst->symbol.section = bfd_com_section_ptr; | 4731 | 45 | dst->symbol.value = src->u.syment.n_value; | 4732 | 45 | break; | 4733 | | | 4734 | 67 | case COFF_SYMBOL_UNDEFINED: | 4735 | 67 | dst->symbol.section = bfd_und_section_ptr; | 4736 | 67 | dst->symbol.value = 0; | 4737 | 67 | break; | 4738 | | | 4739 | 0 | case COFF_SYMBOL_PE_SECTION: | 4740 | 0 | dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM; | 4741 | 0 | dst->symbol.value = 0; | 4742 | 0 | break; | 4743 | | | 4744 | 0 | case COFF_SYMBOL_LOCAL: | 4745 | 0 | dst->symbol.flags = BSF_LOCAL; | 4746 | 0 | #if defined COFF_WITH_PE | 4747 | | /* PE sets the symbol to a value relative to the | 4748 | | start of the section. */ | 4749 | 0 | dst->symbol.value = src->u.syment.n_value; | 4750 | | #else | 4751 | | dst->symbol.value = (src->u.syment.n_value | 4752 | | - dst->symbol.section->vma); | 4753 | | #endif | 4754 | 0 | if (ISFCN ((src->u.syment.n_type))) | 4755 | 0 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4756 | 0 | break; | 4757 | 587 | } | 4758 | | | 4759 | | #ifdef RS6000COFF_C | 4760 | | /* A symbol with a csect entry should not go at the end. */ | 4761 | | if (src->u.syment.n_numaux > 0) | 4762 | | dst->symbol.flags |= BSF_NOT_AT_END; | 4763 | | #endif | 4764 | | | 4765 | 587 | #ifdef COFF_WITH_PE | 4766 | 587 | if (src->u.syment.n_sclass == C_NT_WEAK) | 4767 | 42 | dst->symbol.flags |= BSF_WEAK; | 4768 | | | 4769 | 587 | if (src->u.syment.n_sclass == C_SECTION | 4770 | 587 | && src->u.syment.n_scnum > 0) | 4771 | 0 | dst->symbol.flags = BSF_LOCAL; | 4772 | 587 | #endif | 4773 | 587 | if (src->u.syment.n_sclass == C_WEAKEXT | 4774 | | #ifdef RS6000COFF_C | 4775 | | || src->u.syment.n_sclass == C_AIX_WEAKEXT | 4776 | | #endif | 4777 | 587 | ) | 4778 | 12 | dst->symbol.flags |= BSF_WEAK; | 4779 | | | 4780 | 587 | break; | 4781 | | | 4782 | 389 | case C_STAT: /* Static. */ | 4783 | 389 | #if defined ARM | 4784 | 412 | case C_THUMBSTAT: /* Thumb static. */ | 4785 | 417 | case C_THUMBLABEL: /* Thumb label. */ | 4786 | 462 | case C_THUMBSTATFUNC:/* Thumb static function. */ | 4787 | 462 | #endif | 4788 | | #ifdef RS6000COFF_C | 4789 | | case C_DWARF: /* A label in a dwarf section. */ | 4790 | | case C_INFO: /* A label in a comment section. */ | 4791 | | #endif | 4792 | 669 | case C_LABEL: /* Label. */ | 4793 | 669 | if (src->u.syment.n_scnum == N_DEBUG) | 4794 | 2 | dst->symbol.flags = BSF_DEBUGGING; | 4795 | 667 | else | 4796 | 667 | dst->symbol.flags = BSF_LOCAL; | 4797 | | | 4798 | | /* Base the value as an index from the base of the | 4799 | | section, if there is one. */ | 4800 | 669 | if (dst->symbol.section) | 4801 | 669 | { | 4802 | 669 | #if defined COFF_WITH_PE | 4803 | | /* PE sets the symbol to a value relative to the | 4804 | | start of the section. */ | 4805 | 669 | dst->symbol.value = src->u.syment.n_value; | 4806 | | #else | 4807 | | dst->symbol.value = (src->u.syment.n_value | 4808 | | - dst->symbol.section->vma); | 4809 | | #endif | 4810 | 669 | } | 4811 | 0 | else | 4812 | 0 | dst->symbol.value = src->u.syment.n_value; | 4813 | 669 | break; | 4814 | | | 4815 | 76 | case C_FILE: /* File name. */ | 4816 | 76 | dst->symbol.flags = BSF_FILE; | 4817 | | /* Fall through. */ | 4818 | 209 | case C_MOS: /* Member of structure. */ | 4819 | 228 | case C_EOS: /* End of structure. */ | 4820 | 364 | case C_REGPARM: /* Register parameter. */ | 4821 | 516 | case C_REG: /* register variable. */ | 4822 | | /* C_AUTOARG conflicts with TI COFF C_UEXT. */ | 4823 | 863 | case C_TPDEF: /* Type definition. */ | 4824 | 1.00k | case C_ARG: | 4825 | 2.12k | case C_AUTO: /* Automatic variable. */ | 4826 | 2.31k | case C_FIELD: /* Bit field. */ | 4827 | 2.47k | case C_ENTAG: /* Enumeration tag. */ | 4828 | 2.70k | case C_MOE: /* Member of enumeration. */ | 4829 | 2.92k | case C_MOU: /* Member of union. */ | 4830 | 2.99k | case C_UNTAG: /* Union tag. */ | 4831 | 3.40k | case C_STRTAG: /* Structure tag. */ | 4832 | | #ifdef RS6000COFF_C | 4833 | | case C_GSYM: | 4834 | | case C_LSYM: | 4835 | | case C_PSYM: | 4836 | | case C_RSYM: | 4837 | | case C_RPSYM: | 4838 | | case C_STSYM: | 4839 | | case C_TCSYM: | 4840 | | case C_BCOMM: | 4841 | | case C_ECOML: | 4842 | | case C_ECOMM: | 4843 | | case C_DECL: | 4844 | | case C_ENTRY: | 4845 | | case C_FUN: | 4846 | | case C_ESTAT: | 4847 | | #endif | 4848 | 3.40k | dst->symbol.flags |= BSF_DEBUGGING; | 4849 | 3.40k | dst->symbol.value = (src->u.syment.n_value); | 4850 | 3.40k | break; | 4851 | | | 4852 | | #ifdef RS6000COFF_C | 4853 | | case C_BINCL: /* Beginning of include file. */ | 4854 | | case C_EINCL: /* Ending of include file. */ | 4855 | | /* The value is actually a pointer into the line numbers | 4856 | | of the file. We locate the line number entry, and | 4857 | | set the section to the section which contains it, and | 4858 | | the value to the index in that section. */ | 4859 | | { | 4860 | | asection *sec; | 4861 | | | 4862 | | dst->symbol.flags = BSF_DEBUGGING; | 4863 | | for (sec = abfd->sections; sec != NULL; sec = sec->next) | 4864 | | if (sec->line_filepos <= (file_ptr) src->u.syment.n_value | 4865 | | && ((file_ptr) (sec->line_filepos | 4866 | | + sec->lineno_count * bfd_coff_linesz (abfd)) | 4867 | | > (file_ptr) src->u.syment.n_value)) | 4868 | | break; | 4869 | | if (sec == NULL) | 4870 | | dst->symbol.value = 0; | 4871 | | else | 4872 | | { | 4873 | | dst->symbol.section = sec; | 4874 | | dst->symbol.value = ((src->u.syment.n_value | 4875 | | - sec->line_filepos) | 4876 | | / bfd_coff_linesz (abfd)); | 4877 | | src->fix_line = 1; | 4878 | | } | 4879 | | } | 4880 | | break; | 4881 | | | 4882 | | case C_BSTAT: | 4883 | | dst->symbol.flags = BSF_DEBUGGING; | 4884 | | | 4885 | | if (src->u.syment.n_value >= obj_raw_syment_count (abfd)) | 4886 | | dst->symbol.value = 0; | 4887 | | else | 4888 | | { | 4889 | | /* The value is actually a symbol index. Save a pointer | 4890 | | to the symbol instead of the index. FIXME: This | 4891 | | should use a union. */ | 4892 | | src->u.syment.n_value | 4893 | | = (uintptr_t) (native_symbols + src->u.syment.n_value); | 4894 | | dst->symbol.value = src->u.syment.n_value; | 4895 | | src->fix_value = 1; | 4896 | | } | 4897 | | break; | 4898 | | #endif | 4899 | | | 4900 | 13 | case C_BLOCK: /* ".bb" or ".eb". */ | 4901 | 58 | case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */ | 4902 | 133 | case C_EFCN: /* Physical end of function. */ | 4903 | 133 | #if defined COFF_WITH_PE | 4904 | | /* PE sets the symbol to a value relative to the start | 4905 | | of the section. */ | 4906 | 133 | dst->symbol.value = src->u.syment.n_value; | 4907 | 133 | if (strcmp (dst->symbol.name, ".bf") != 0) | 4908 | 133 | { | 4909 | | /* PE uses funny values for .ef and .lf; don't | 4910 | | relocate them. */ | 4911 | 133 | dst->symbol.flags = BSF_DEBUGGING; | 4912 | 133 | } | 4913 | 0 | else | 4914 | 0 | dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC; | 4915 | | #else | 4916 | | /* Base the value as an index from the base of the | 4917 | | section. */ | 4918 | | dst->symbol.flags = BSF_LOCAL; | 4919 | | dst->symbol.value = (src->u.syment.n_value | 4920 | | - dst->symbol.section->vma); | 4921 | | #endif | 4922 | 133 | break; | 4923 | | | 4924 | 17 | case C_STATLAB: /* Static load time label. */ | 4925 | 17 | dst->symbol.value = src->u.syment.n_value; | 4926 | 17 | dst->symbol.flags = BSF_GLOBAL; | 4927 | 17 | break; | 4928 | | | 4929 | 19.4k | case C_NULL: | 4930 | | /* PE DLLs sometimes have zeroed out symbols for some | 4931 | | reason. Just ignore them without a warning. */ | 4932 | 19.4k | if (src->u.syment.n_type == 0 | 4933 | 19.4k | && src->u.syment.n_value == 0 | 4934 | 19.4k | && src->u.syment.n_scnum == 0) | 4935 | 8.46k | break; | 4936 | | #ifdef RS6000COFF_C | 4937 | | /* XCOFF specific: deleted entry. */ | 4938 | | if (src->u.syment.n_value == C_NULL_VALUE) | 4939 | | break; | 4940 | | #endif | 4941 | | /* Fall through. */ | 4942 | 10.9k | case C_EXTDEF: /* External definition. */ | 4943 | 11.0k | case C_ULABEL: /* Undefined label. */ | 4944 | 11.0k | case C_USTATIC: /* Undefined static. */ | 4945 | | #ifndef COFF_WITH_PE | 4946 | | /* C_LINE in regular coff is 0x68. NT has taken over this storage | 4947 | | class to represent a section symbol. */ | 4948 | | case C_LINE: /* line # reformatted as symbol table entry. */ | 4949 | | /* NT uses 0x67 for a weak symbol, not C_ALIAS. */ | 4950 | | case C_ALIAS: /* Duplicate tag. */ | 4951 | | #endif | 4952 | | /* New storage classes for TI COFF. */ | 4953 | | #ifdef TICOFF | 4954 | | case C_UEXT: /* Tentative external definition. */ | 4955 | | #endif | 4956 | 11.0k | case C_EXTLAB: /* External load time label. */ | 4957 | 14.6k | default: | 4958 | 14.6k | _bfd_error_handler | 4959 | | /* xgettext:c-format */ | 4960 | 14.6k | (_("%pB: unrecognized storage class %d for %s symbol `%s'"), | 4961 | 14.6k | abfd, src->u.syment.n_sclass, | 4962 | 14.6k | dst->symbol.section->name, dst->symbol.name); | 4963 | 14.6k | ret = false; | 4964 | | /* Fall through. */ | 4965 | 14.6k | case C_HIDDEN: /* Ext symbol in dmert public lib. */ | 4966 | | /* PR 20722: These symbols can also be generated by | 4967 | | building DLLs with --gc-sections enabled. */ | 4968 | 14.6k | dst->symbol.flags = BSF_DEBUGGING; | 4969 | 14.6k | dst->symbol.value = (src->u.syment.n_value); | 4970 | 14.6k | break; | 4971 | 27.9k | } | 4972 | | | 4973 | 27.9k | dst->native = src; | 4974 | 27.9k | dst->symbol.udata.i = 0; | 4975 | 27.9k | dst->lineno = NULL; | 4976 | | | 4977 | 27.9k | this_index += (src->u.syment.n_numaux) + 1; | 4978 | 27.9k | dst++; | 4979 | 27.9k | number_of_symbols++; | 4980 | 27.9k | } | 4981 | 172 | } | 4982 | | | 4983 | 172 | obj_symbols (abfd) = cached_area; | 4984 | 172 | obj_raw_syments (abfd) = native_symbols; | 4985 | | | 4986 | 172 | abfd->symcount = number_of_symbols; | 4987 | 172 | obj_convert (abfd) = table_ptr; | 4988 | | /* Slurp the line tables for each section too. */ | 4989 | 172 | { | 4990 | 172 | asection *p; | 4991 | | | 4992 | 172 | p = abfd->sections; | 4993 | 380 | while (p) | 4994 | 348 | { | 4995 | 348 | if (! coff_slurp_line_table (abfd, p)) | 4996 | 140 | return false; | 4997 | 208 | p = p->next; | 4998 | 208 | } | 4999 | 172 | } | 5000 | | | 5001 | 32 | return ret; | 5002 | 172 | } |
pei-mcore.c:coff_slurp_symbol_table Line | Count | Source | 4630 | 191 | { | 4631 | 191 | combined_entry_type *native_symbols; | 4632 | 191 | coff_symbol_type *cached_area; | 4633 | 191 | unsigned int *table_ptr; | 4634 | 191 | unsigned int number_of_symbols = 0; | 4635 | 191 | bool ret = true; | 4636 | 191 | size_t amt; | 4637 | | | 4638 | 191 | if (obj_symbols (abfd)) | 4639 | 4 | return true; | 4640 | | | 4641 | | /* Read in the symbol table. */ | 4642 | 187 | if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) | 4643 | 70 | return false; | 4644 | | | 4645 | | /* Allocate enough room for all the symbols in cached form. */ | 4646 | 117 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4647 | 117 | sizeof (*cached_area), &amt)) | 4648 | 0 | { | 4649 | 0 | bfd_set_error (bfd_error_file_too_big); | 4650 | 0 | return false; | 4651 | 0 | } | 4652 | 117 | cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt); | 4653 | 117 | if (cached_area == NULL) | 4654 | 0 | return false; | 4655 | | | 4656 | 117 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4657 | 117 | sizeof (*table_ptr), &amt)) | 4658 | 0 | { | 4659 | 0 | bfd_set_error (bfd_error_file_too_big); | 4660 | 0 | return false; | 4661 | 0 | } | 4662 | 117 | table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); | 4663 | 117 | if (table_ptr == NULL) | 4664 | 0 | return false; | 4665 | 117 | else | 4666 | 117 | { | 4667 | 117 | coff_symbol_type *dst = cached_area; | 4668 | 117 | unsigned int last_native_index = obj_raw_syment_count (abfd); | 4669 | 117 | unsigned int this_index = 0; | 4670 | | | 4671 | 29.0k | while (this_index < last_native_index) | 4672 | 28.8k | { | 4673 | 28.8k | combined_entry_type *src = native_symbols + this_index; | 4674 | 28.8k | table_ptr[this_index] = number_of_symbols; | 4675 | | | 4676 | 28.8k | dst->symbol.the_bfd = abfd; | 4677 | 28.8k | BFD_ASSERT (src->is_sym); | 4678 | 28.8k | dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset); | 4679 | | /* We use the native name field to point to the cached field. */ | 4680 | 28.8k | src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; | 4681 | 28.8k | dst->symbol.section = coff_section_from_bfd_index (abfd, | 4682 | 28.8k | src->u.syment.n_scnum); | 4683 | 28.8k | dst->symbol.flags = 0; | 4684 | | /* PR 17512: file: 079-7098-0.001:0.1. */ | 4685 | 28.8k | dst->symbol.value = 0; | 4686 | 28.8k | dst->done_lineno = false; | 4687 | | | 4688 | 28.8k | switch (src->u.syment.n_sclass) | 4689 | 28.8k | { | 4690 | 4.17k | case C_EXT: | 4691 | 4.19k | case C_WEAKEXT: | 4692 | | #if defined ARM | 4693 | | case C_THUMBEXT: | 4694 | | case C_THUMBEXTFUNC: | 4695 | | #endif | 4696 | | #ifdef RS6000COFF_C | 4697 | | case C_HIDEXT: | 4698 | | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 4699 | | case C_AIX_WEAKEXT: | 4700 | | #endif | 4701 | | #endif | 4702 | 4.19k | #ifdef C_SYSTEM | 4703 | 4.26k | case C_SYSTEM: /* System Wide variable. */ | 4704 | 4.26k | #endif | 4705 | 4.26k | #ifdef COFF_WITH_PE | 4706 | | /* In PE, 0x68 (104) denotes a section symbol. */ | 4707 | 4.30k | case C_SECTION: | 4708 | | /* In PE, 0x69 (105) denotes a weak external symbol. */ | 4709 | 4.33k | case C_NT_WEAK: | 4710 | 4.33k | #endif | 4711 | 4.33k | switch (coff_classify_symbol (abfd, &src->u.syment)) | 4712 | 4.33k | { | 4713 | 4.20k | case COFF_SYMBOL_GLOBAL: | 4714 | 4.20k | dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL; | 4715 | 4.20k | #if defined COFF_WITH_PE | 4716 | | /* PE sets the symbol to a value relative to the | 4717 | | start of the section. */ | 4718 | 4.20k | dst->symbol.value = src->u.syment.n_value; | 4719 | | #else | 4720 | | dst->symbol.value = (src->u.syment.n_value | 4721 | | - dst->symbol.section->vma); | 4722 | | #endif | 4723 | 4.20k | if (ISFCN ((src->u.syment.n_type))) | 4724 | | /* A function ext does not go at the end of a | 4725 | | file. */ | 4726 | 20 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4727 | 4.20k | break; | 4728 | | | 4729 | 61 | case COFF_SYMBOL_COMMON: | 4730 | 61 | dst->symbol.section = bfd_com_section_ptr; | 4731 | 61 | dst->symbol.value = src->u.syment.n_value; | 4732 | 61 | break; | 4733 | | | 4734 | 66 | case COFF_SYMBOL_UNDEFINED: | 4735 | 66 | dst->symbol.section = bfd_und_section_ptr; | 4736 | 66 | dst->symbol.value = 0; | 4737 | 66 | break; | 4738 | | | 4739 | 0 | case COFF_SYMBOL_PE_SECTION: | 4740 | 0 | dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM; | 4741 | 0 | dst->symbol.value = 0; | 4742 | 0 | break; | 4743 | | | 4744 | 0 | case COFF_SYMBOL_LOCAL: | 4745 | 0 | dst->symbol.flags = BSF_LOCAL; | 4746 | 0 | #if defined COFF_WITH_PE | 4747 | | /* PE sets the symbol to a value relative to the | 4748 | | start of the section. */ | 4749 | 0 | dst->symbol.value = src->u.syment.n_value; | 4750 | | #else | 4751 | | dst->symbol.value = (src->u.syment.n_value | 4752 | | - dst->symbol.section->vma); | 4753 | | #endif | 4754 | 0 | if (ISFCN ((src->u.syment.n_type))) | 4755 | 0 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4756 | 0 | break; | 4757 | 4.33k | } | 4758 | | | 4759 | | #ifdef RS6000COFF_C | 4760 | | /* A symbol with a csect entry should not go at the end. */ | 4761 | | if (src->u.syment.n_numaux > 0) | 4762 | | dst->symbol.flags |= BSF_NOT_AT_END; | 4763 | | #endif | 4764 | | | 4765 | 4.33k | #ifdef COFF_WITH_PE | 4766 | 4.33k | if (src->u.syment.n_sclass == C_NT_WEAK) | 4767 | 33 | dst->symbol.flags |= BSF_WEAK; | 4768 | | | 4769 | 4.33k | if (src->u.syment.n_sclass == C_SECTION | 4770 | 4.33k | && src->u.syment.n_scnum > 0) | 4771 | 0 | dst->symbol.flags = BSF_LOCAL; | 4772 | 4.33k | #endif | 4773 | 4.33k | if (src->u.syment.n_sclass == C_WEAKEXT | 4774 | | #ifdef RS6000COFF_C | 4775 | | || src->u.syment.n_sclass == C_AIX_WEAKEXT | 4776 | | #endif | 4777 | 4.33k | ) | 4778 | 19 | dst->symbol.flags |= BSF_WEAK; | 4779 | | | 4780 | 4.33k | break; | 4781 | | | 4782 | 2.46k | case C_STAT: /* Static. */ | 4783 | | #if defined ARM | 4784 | | case C_THUMBSTAT: /* Thumb static. */ | 4785 | | case C_THUMBLABEL: /* Thumb label. */ | 4786 | | case C_THUMBSTATFUNC:/* Thumb static function. */ | 4787 | | #endif | 4788 | | #ifdef RS6000COFF_C | 4789 | | case C_DWARF: /* A label in a dwarf section. */ | 4790 | | case C_INFO: /* A label in a comment section. */ | 4791 | | #endif | 4792 | 2.75k | case C_LABEL: /* Label. */ | 4793 | 2.75k | if (src->u.syment.n_scnum == N_DEBUG) | 4794 | 1 | dst->symbol.flags = BSF_DEBUGGING; | 4795 | 2.75k | else | 4796 | 2.75k | dst->symbol.flags = BSF_LOCAL; | 4797 | | | 4798 | | /* Base the value as an index from the base of the | 4799 | | section, if there is one. */ | 4800 | 2.75k | if (dst->symbol.section) | 4801 | 2.75k | { | 4802 | 2.75k | #if defined COFF_WITH_PE | 4803 | | /* PE sets the symbol to a value relative to the | 4804 | | start of the section. */ | 4805 | 2.75k | dst->symbol.value = src->u.syment.n_value; | 4806 | | #else | 4807 | | dst->symbol.value = (src->u.syment.n_value | 4808 | | - dst->symbol.section->vma); | 4809 | | #endif | 4810 | 2.75k | } | 4811 | 0 | else | 4812 | 0 | dst->symbol.value = src->u.syment.n_value; | 4813 | 2.75k | break; | 4814 | | | 4815 | 21 | case C_FILE: /* File name. */ | 4816 | 21 | dst->symbol.flags = BSF_FILE; | 4817 | | /* Fall through. */ | 4818 | 101 | case C_MOS: /* Member of structure. */ | 4819 | 114 | case C_EOS: /* End of structure. */ | 4820 | 286 | case C_REGPARM: /* Register parameter. */ | 4821 | 432 | case C_REG: /* register variable. */ | 4822 | | /* C_AUTOARG conflicts with TI COFF C_UEXT. */ | 4823 | 548 | case C_TPDEF: /* Type definition. */ | 4824 | 577 | case C_ARG: | 4825 | 1.53k | case C_AUTO: /* Automatic variable. */ | 4826 | 1.79k | case C_FIELD: /* Bit field. */ | 4827 | 1.85k | case C_ENTAG: /* Enumeration tag. */ | 4828 | 2.20k | case C_MOE: /* Member of enumeration. */ | 4829 | 2.21k | case C_MOU: /* Member of union. */ | 4830 | 2.26k | case C_UNTAG: /* Union tag. */ | 4831 | 2.37k | case C_STRTAG: /* Structure tag. */ | 4832 | | #ifdef RS6000COFF_C | 4833 | | case C_GSYM: | 4834 | | case C_LSYM: | 4835 | | case C_PSYM: | 4836 | | case C_RSYM: | 4837 | | case C_RPSYM: | 4838 | | case C_STSYM: | 4839 | | case C_TCSYM: | 4840 | | case C_BCOMM: | 4841 | | case C_ECOML: | 4842 | | case C_ECOMM: | 4843 | | case C_DECL: | 4844 | | case C_ENTRY: | 4845 | | case C_FUN: | 4846 | | case C_ESTAT: | 4847 | | #endif | 4848 | 2.37k | dst->symbol.flags |= BSF_DEBUGGING; | 4849 | 2.37k | dst->symbol.value = (src->u.syment.n_value); | 4850 | 2.37k | break; | 4851 | | | 4852 | | #ifdef RS6000COFF_C | 4853 | | case C_BINCL: /* Beginning of include file. */ | 4854 | | case C_EINCL: /* Ending of include file. */ | 4855 | | /* The value is actually a pointer into the line numbers | 4856 | | of the file. We locate the line number entry, and | 4857 | | set the section to the section which contains it, and | 4858 | | the value to the index in that section. */ | 4859 | | { | 4860 | | asection *sec; | 4861 | | | 4862 | | dst->symbol.flags = BSF_DEBUGGING; | 4863 | | for (sec = abfd->sections; sec != NULL; sec = sec->next) | 4864 | | if (sec->line_filepos <= (file_ptr) src->u.syment.n_value | 4865 | | && ((file_ptr) (sec->line_filepos | 4866 | | + sec->lineno_count * bfd_coff_linesz (abfd)) | 4867 | | > (file_ptr) src->u.syment.n_value)) | 4868 | | break; | 4869 | | if (sec == NULL) | 4870 | | dst->symbol.value = 0; | 4871 | | else | 4872 | | { | 4873 | | dst->symbol.section = sec; | 4874 | | dst->symbol.value = ((src->u.syment.n_value | 4875 | | - sec->line_filepos) | 4876 | | / bfd_coff_linesz (abfd)); | 4877 | | src->fix_line = 1; | 4878 | | } | 4879 | | } | 4880 | | break; | 4881 | | | 4882 | | case C_BSTAT: | 4883 | | dst->symbol.flags = BSF_DEBUGGING; | 4884 | | | 4885 | | if (src->u.syment.n_value >= obj_raw_syment_count (abfd)) | 4886 | | dst->symbol.value = 0; | 4887 | | else | 4888 | | { | 4889 | | /* The value is actually a symbol index. Save a pointer | 4890 | | to the symbol instead of the index. FIXME: This | 4891 | | should use a union. */ | 4892 | | src->u.syment.n_value | 4893 | | = (uintptr_t) (native_symbols + src->u.syment.n_value); | 4894 | | dst->symbol.value = src->u.syment.n_value; | 4895 | | src->fix_value = 1; | 4896 | | } | 4897 | | break; | 4898 | | #endif | 4899 | | | 4900 | 13 | case C_BLOCK: /* ".bb" or ".eb". */ | 4901 | 34 | case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */ | 4902 | 153 | case C_EFCN: /* Physical end of function. */ | 4903 | 153 | #if defined COFF_WITH_PE | 4904 | | /* PE sets the symbol to a value relative to the start | 4905 | | of the section. */ | 4906 | 153 | dst->symbol.value = src->u.syment.n_value; | 4907 | 153 | if (strcmp (dst->symbol.name, ".bf") != 0) | 4908 | 153 | { | 4909 | | /* PE uses funny values for .ef and .lf; don't | 4910 | | relocate them. */ | 4911 | 153 | dst->symbol.flags = BSF_DEBUGGING; | 4912 | 153 | } | 4913 | 0 | else | 4914 | 0 | dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC; | 4915 | | #else | 4916 | | /* Base the value as an index from the base of the | 4917 | | section. */ | 4918 | | dst->symbol.flags = BSF_LOCAL; | 4919 | | dst->symbol.value = (src->u.syment.n_value | 4920 | | - dst->symbol.section->vma); | 4921 | | #endif | 4922 | 153 | break; | 4923 | | | 4924 | 18 | case C_STATLAB: /* Static load time label. */ | 4925 | 18 | dst->symbol.value = src->u.syment.n_value; | 4926 | 18 | dst->symbol.flags = BSF_GLOBAL; | 4927 | 18 | break; | 4928 | | | 4929 | 16.4k | case C_NULL: | 4930 | | /* PE DLLs sometimes have zeroed out symbols for some | 4931 | | reason. Just ignore them without a warning. */ | 4932 | 16.4k | if (src->u.syment.n_type == 0 | 4933 | 16.4k | && src->u.syment.n_value == 0 | 4934 | 16.4k | && src->u.syment.n_scnum == 0) | 4935 | 8.45k | break; | 4936 | | #ifdef RS6000COFF_C | 4937 | | /* XCOFF specific: deleted entry. */ | 4938 | | if (src->u.syment.n_value == C_NULL_VALUE) | 4939 | | break; | 4940 | | #endif | 4941 | | /* Fall through. */ | 4942 | 8.04k | case C_EXTDEF: /* External definition. */ | 4943 | 8.07k | case C_ULABEL: /* Undefined label. */ | 4944 | 8.08k | case C_USTATIC: /* Undefined static. */ | 4945 | | #ifndef COFF_WITH_PE | 4946 | | /* C_LINE in regular coff is 0x68. NT has taken over this storage | 4947 | | class to represent a section symbol. */ | 4948 | | case C_LINE: /* line # reformatted as symbol table entry. */ | 4949 | | /* NT uses 0x67 for a weak symbol, not C_ALIAS. */ | 4950 | | case C_ALIAS: /* Duplicate tag. */ | 4951 | | #endif | 4952 | | /* New storage classes for TI COFF. */ | 4953 | | #ifdef TICOFF | 4954 | | case C_UEXT: /* Tentative external definition. */ | 4955 | | #endif | 4956 | 8.10k | case C_EXTLAB: /* External load time label. */ | 4957 | 10.7k | default: | 4958 | 10.7k | _bfd_error_handler | 4959 | | /* xgettext:c-format */ | 4960 | 10.7k | (_("%pB: unrecognized storage class %d for %s symbol `%s'"), | 4961 | 10.7k | abfd, src->u.syment.n_sclass, | 4962 | 10.7k | dst->symbol.section->name, dst->symbol.name); | 4963 | 10.7k | ret = false; | 4964 | | /* Fall through. */ | 4965 | 10.8k | case C_HIDDEN: /* Ext symbol in dmert public lib. */ | 4966 | | /* PR 20722: These symbols can also be generated by | 4967 | | building DLLs with --gc-sections enabled. */ | 4968 | 10.8k | dst->symbol.flags = BSF_DEBUGGING; | 4969 | 10.8k | dst->symbol.value = (src->u.syment.n_value); | 4970 | 10.8k | break; | 4971 | 28.8k | } | 4972 | | | 4973 | 28.8k | dst->native = src; | 4974 | 28.8k | dst->symbol.udata.i = 0; | 4975 | 28.8k | dst->lineno = NULL; | 4976 | | | 4977 | 28.8k | this_index += (src->u.syment.n_numaux) + 1; | 4978 | 28.8k | dst++; | 4979 | 28.8k | number_of_symbols++; | 4980 | 28.8k | } | 4981 | 117 | } | 4982 | | | 4983 | 117 | obj_symbols (abfd) = cached_area; | 4984 | 117 | obj_raw_syments (abfd) = native_symbols; | 4985 | | | 4986 | 117 | abfd->symcount = number_of_symbols; | 4987 | 117 | obj_convert (abfd) = table_ptr; | 4988 | | /* Slurp the line tables for each section too. */ | 4989 | 117 | { | 4990 | 117 | asection *p; | 4991 | | | 4992 | 117 | p = abfd->sections; | 4993 | 359 | while (p) | 4994 | 331 | { | 4995 | 331 | if (! coff_slurp_line_table (abfd, p)) | 4996 | 89 | return false; | 4997 | 242 | p = p->next; | 4998 | 242 | } | 4999 | 117 | } | 5000 | | | 5001 | 28 | return ret; | 5002 | 117 | } |
pei-sh.c:coff_slurp_symbol_table Line | Count | Source | 4630 | 365 | { | 4631 | 365 | combined_entry_type *native_symbols; | 4632 | 365 | coff_symbol_type *cached_area; | 4633 | 365 | unsigned int *table_ptr; | 4634 | 365 | unsigned int number_of_symbols = 0; | 4635 | 365 | bool ret = true; | 4636 | 365 | size_t amt; | 4637 | | | 4638 | 365 | if (obj_symbols (abfd)) | 4639 | 201 | return true; | 4640 | | | 4641 | | /* Read in the symbol table. */ | 4642 | 164 | if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) | 4643 | 32 | return false; | 4644 | | | 4645 | | /* Allocate enough room for all the symbols in cached form. */ | 4646 | 132 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4647 | 132 | sizeof (*cached_area), &amt)) | 4648 | 0 | { | 4649 | 0 | bfd_set_error (bfd_error_file_too_big); | 4650 | 0 | return false; | 4651 | 0 | } | 4652 | 132 | cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt); | 4653 | 132 | if (cached_area == NULL) | 4654 | 0 | return false; | 4655 | | | 4656 | 132 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4657 | 132 | sizeof (*table_ptr), &amt)) | 4658 | 0 | { | 4659 | 0 | bfd_set_error (bfd_error_file_too_big); | 4660 | 0 | return false; | 4661 | 0 | } | 4662 | 132 | table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); | 4663 | 132 | if (table_ptr == NULL) | 4664 | 0 | return false; | 4665 | 132 | else | 4666 | 132 | { | 4667 | 132 | coff_symbol_type *dst = cached_area; | 4668 | 132 | unsigned int last_native_index = obj_raw_syment_count (abfd); | 4669 | 132 | unsigned int this_index = 0; | 4670 | | | 4671 | 140k | while (this_index < last_native_index) | 4672 | 140k | { | 4673 | 140k | combined_entry_type *src = native_symbols + this_index; | 4674 | 140k | table_ptr[this_index] = number_of_symbols; | 4675 | | | 4676 | 140k | dst->symbol.the_bfd = abfd; | 4677 | 140k | BFD_ASSERT (src->is_sym); | 4678 | 140k | dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset); | 4679 | | /* We use the native name field to point to the cached field. */ | 4680 | 140k | src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; | 4681 | 140k | dst->symbol.section = coff_section_from_bfd_index (abfd, | 4682 | 140k | src->u.syment.n_scnum); | 4683 | 140k | dst->symbol.flags = 0; | 4684 | | /* PR 17512: file: 079-7098-0.001:0.1. */ | 4685 | 140k | dst->symbol.value = 0; | 4686 | 140k | dst->done_lineno = false; | 4687 | | | 4688 | 140k | switch (src->u.syment.n_sclass) | 4689 | 140k | { | 4690 | 2.97k | case C_EXT: | 4691 | 3.01k | case C_WEAKEXT: | 4692 | | #if defined ARM | 4693 | | case C_THUMBEXT: | 4694 | | case C_THUMBEXTFUNC: | 4695 | | #endif | 4696 | | #ifdef RS6000COFF_C | 4697 | | case C_HIDEXT: | 4698 | | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 4699 | | case C_AIX_WEAKEXT: | 4700 | | #endif | 4701 | | #endif | 4702 | 3.01k | #ifdef C_SYSTEM | 4703 | 3.09k | case C_SYSTEM: /* System Wide variable. */ | 4704 | 3.09k | #endif | 4705 | 3.09k | #ifdef COFF_WITH_PE | 4706 | | /* In PE, 0x68 (104) denotes a section symbol. */ | 4707 | 3.11k | case C_SECTION: | 4708 | | /* In PE, 0x69 (105) denotes a weak external symbol. */ | 4709 | 3.19k | case C_NT_WEAK: | 4710 | 3.19k | #endif | 4711 | 3.19k | switch (coff_classify_symbol (abfd, &src->u.syment)) | 4712 | 3.19k | { | 4713 | 3.01k | case COFF_SYMBOL_GLOBAL: | 4714 | 3.01k | dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL; | 4715 | 3.01k | #if defined COFF_WITH_PE | 4716 | | /* PE sets the symbol to a value relative to the | 4717 | | start of the section. */ | 4718 | 3.01k | dst->symbol.value = src->u.syment.n_value; | 4719 | | #else | 4720 | | dst->symbol.value = (src->u.syment.n_value | 4721 | | - dst->symbol.section->vma); | 4722 | | #endif | 4723 | 3.01k | if (ISFCN ((src->u.syment.n_type))) | 4724 | | /* A function ext does not go at the end of a | 4725 | | file. */ | 4726 | 41 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4727 | 3.01k | break; | 4728 | | | 4729 | 123 | case COFF_SYMBOL_COMMON: | 4730 | 123 | dst->symbol.section = bfd_com_section_ptr; | 4731 | 123 | dst->symbol.value = src->u.syment.n_value; | 4732 | 123 | break; | 4733 | | | 4734 | 50 | case COFF_SYMBOL_UNDEFINED: | 4735 | 50 | dst->symbol.section = bfd_und_section_ptr; | 4736 | 50 | dst->symbol.value = 0; | 4737 | 50 | break; | 4738 | | | 4739 | 0 | case COFF_SYMBOL_PE_SECTION: | 4740 | 0 | dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM; | 4741 | 0 | dst->symbol.value = 0; | 4742 | 0 | break; | 4743 | | | 4744 | 0 | case COFF_SYMBOL_LOCAL: | 4745 | 0 | dst->symbol.flags = BSF_LOCAL; | 4746 | 0 | #if defined COFF_WITH_PE | 4747 | | /* PE sets the symbol to a value relative to the | 4748 | | start of the section. */ | 4749 | 0 | dst->symbol.value = src->u.syment.n_value; | 4750 | | #else | 4751 | | dst->symbol.value = (src->u.syment.n_value | 4752 | | - dst->symbol.section->vma); | 4753 | | #endif | 4754 | 0 | if (ISFCN ((src->u.syment.n_type))) | 4755 | 0 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4756 | 0 | break; | 4757 | 3.19k | } | 4758 | | | 4759 | | #ifdef RS6000COFF_C | 4760 | | /* A symbol with a csect entry should not go at the end. */ | 4761 | | if (src->u.syment.n_numaux > 0) | 4762 | | dst->symbol.flags |= BSF_NOT_AT_END; | 4763 | | #endif | 4764 | | | 4765 | 3.19k | #ifdef COFF_WITH_PE | 4766 | 3.19k | if (src->u.syment.n_sclass == C_NT_WEAK) | 4767 | 78 | dst->symbol.flags |= BSF_WEAK; | 4768 | | | 4769 | 3.19k | if (src->u.syment.n_sclass == C_SECTION | 4770 | 3.19k | && src->u.syment.n_scnum > 0) | 4771 | 0 | dst->symbol.flags = BSF_LOCAL; | 4772 | 3.19k | #endif | 4773 | 3.19k | if (src->u.syment.n_sclass == C_WEAKEXT | 4774 | | #ifdef RS6000COFF_C | 4775 | | || src->u.syment.n_sclass == C_AIX_WEAKEXT | 4776 | | #endif | 4777 | 3.19k | ) | 4778 | 38 | dst->symbol.flags |= BSF_WEAK; | 4779 | | | 4780 | 3.19k | break; | 4781 | | | 4782 | 367 | case C_STAT: /* Static. */ | 4783 | | #if defined ARM | 4784 | | case C_THUMBSTAT: /* Thumb static. */ | 4785 | | case C_THUMBLABEL: /* Thumb label. */ | 4786 | | case C_THUMBSTATFUNC:/* Thumb static function. */ | 4787 | | #endif | 4788 | | #ifdef RS6000COFF_C | 4789 | | case C_DWARF: /* A label in a dwarf section. */ | 4790 | | case C_INFO: /* A label in a comment section. */ | 4791 | | #endif | 4792 | 3.53k | case C_LABEL: /* Label. */ | 4793 | 3.53k | if (src->u.syment.n_scnum == N_DEBUG) | 4794 | 0 | dst->symbol.flags = BSF_DEBUGGING; | 4795 | 3.53k | else | 4796 | 3.53k | dst->symbol.flags = BSF_LOCAL; | 4797 | | | 4798 | | /* Base the value as an index from the base of the | 4799 | | section, if there is one. */ | 4800 | 3.53k | if (dst->symbol.section) | 4801 | 3.53k | { | 4802 | 3.53k | #if defined COFF_WITH_PE | 4803 | | /* PE sets the symbol to a value relative to the | 4804 | | start of the section. */ | 4805 | 3.53k | dst->symbol.value = src->u.syment.n_value; | 4806 | | #else | 4807 | | dst->symbol.value = (src->u.syment.n_value | 4808 | | - dst->symbol.section->vma); | 4809 | | #endif | 4810 | 3.53k | } | 4811 | 0 | else | 4812 | 0 | dst->symbol.value = src->u.syment.n_value; | 4813 | 3.53k | break; | 4814 | | | 4815 | 481 | case C_FILE: /* File name. */ | 4816 | 481 | dst->symbol.flags = BSF_FILE; | 4817 | | /* Fall through. */ | 4818 | 643 | case C_MOS: /* Member of structure. */ | 4819 | 748 | case C_EOS: /* End of structure. */ | 4820 | 821 | case C_REGPARM: /* Register parameter. */ | 4821 | 1.03k | case C_REG: /* register variable. */ | 4822 | | /* C_AUTOARG conflicts with TI COFF C_UEXT. */ | 4823 | 1.80k | case C_TPDEF: /* Type definition. */ | 4824 | 1.92k | case C_ARG: | 4825 | 4.38k | case C_AUTO: /* Automatic variable. */ | 4826 | 5.25k | case C_FIELD: /* Bit field. */ | 4827 | 5.36k | case C_ENTAG: /* Enumeration tag. */ | 4828 | 6.86k | case C_MOE: /* Member of enumeration. */ | 4829 | 6.93k | case C_MOU: /* Member of union. */ | 4830 | 7.21k | case C_UNTAG: /* Union tag. */ | 4831 | 15.0k | case C_STRTAG: /* Structure tag. */ | 4832 | | #ifdef RS6000COFF_C | 4833 | | case C_GSYM: | 4834 | | case C_LSYM: | 4835 | | case C_PSYM: | 4836 | | case C_RSYM: | 4837 | | case C_RPSYM: | 4838 | | case C_STSYM: | 4839 | | case C_TCSYM: | 4840 | | case C_BCOMM: | 4841 | | case C_ECOML: | 4842 | | case C_ECOMM: | 4843 | | case C_DECL: | 4844 | | case C_ENTRY: | 4845 | | case C_FUN: | 4846 | | case C_ESTAT: | 4847 | | #endif | 4848 | 15.0k | dst->symbol.flags |= BSF_DEBUGGING; | 4849 | 15.0k | dst->symbol.value = (src->u.syment.n_value); | 4850 | 15.0k | break; | 4851 | | | 4852 | | #ifdef RS6000COFF_C | 4853 | | case C_BINCL: /* Beginning of include file. */ | 4854 | | case C_EINCL: /* Ending of include file. */ | 4855 | | /* The value is actually a pointer into the line numbers | 4856 | | of the file. We locate the line number entry, and | 4857 | | set the section to the section which contains it, and | 4858 | | the value to the index in that section. */ | 4859 | | { | 4860 | | asection *sec; | 4861 | | | 4862 | | dst->symbol.flags = BSF_DEBUGGING; | 4863 | | for (sec = abfd->sections; sec != NULL; sec = sec->next) | 4864 | | if (sec->line_filepos <= (file_ptr) src->u.syment.n_value | 4865 | | && ((file_ptr) (sec->line_filepos | 4866 | | + sec->lineno_count * bfd_coff_linesz (abfd)) | 4867 | | > (file_ptr) src->u.syment.n_value)) | 4868 | | break; | 4869 | | if (sec == NULL) | 4870 | | dst->symbol.value = 0; | 4871 | | else | 4872 | | { | 4873 | | dst->symbol.section = sec; | 4874 | | dst->symbol.value = ((src->u.syment.n_value | 4875 | | - sec->line_filepos) | 4876 | | / bfd_coff_linesz (abfd)); | 4877 | | src->fix_line = 1; | 4878 | | } | 4879 | | } | 4880 | | break; | 4881 | | | 4882 | | case C_BSTAT: | 4883 | | dst->symbol.flags = BSF_DEBUGGING; | 4884 | | | 4885 | | if (src->u.syment.n_value >= obj_raw_syment_count (abfd)) | 4886 | | dst->symbol.value = 0; | 4887 | | else | 4888 | | { | 4889 | | /* The value is actually a symbol index. Save a pointer | 4890 | | to the symbol instead of the index. FIXME: This | 4891 | | should use a union. */ | 4892 | | src->u.syment.n_value | 4893 | | = (uintptr_t) (native_symbols + src->u.syment.n_value); | 4894 | | dst->symbol.value = src->u.syment.n_value; | 4895 | | src->fix_value = 1; | 4896 | | } | 4897 | | break; | 4898 | | #endif | 4899 | | | 4900 | 165 | case C_BLOCK: /* ".bb" or ".eb". */ | 4901 | 309 | case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */ | 4902 | 713 | case C_EFCN: /* Physical end of function. */ | 4903 | 713 | #if defined COFF_WITH_PE | 4904 | | /* PE sets the symbol to a value relative to the start | 4905 | | of the section. */ | 4906 | 713 | dst->symbol.value = src->u.syment.n_value; | 4907 | 713 | if (strcmp (dst->symbol.name, ".bf") != 0) | 4908 | 713 | { | 4909 | | /* PE uses funny values for .ef and .lf; don't | 4910 | | relocate them. */ | 4911 | 713 | dst->symbol.flags = BSF_DEBUGGING; | 4912 | 713 | } | 4913 | 0 | else | 4914 | 0 | dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC; | 4915 | | #else | 4916 | | /* Base the value as an index from the base of the | 4917 | | section. */ | 4918 | | dst->symbol.flags = BSF_LOCAL; | 4919 | | dst->symbol.value = (src->u.syment.n_value | 4920 | | - dst->symbol.section->vma); | 4921 | | #endif | 4922 | 713 | break; | 4923 | | | 4924 | 46 | case C_STATLAB: /* Static load time label. */ | 4925 | 46 | dst->symbol.value = src->u.syment.n_value; | 4926 | 46 | dst->symbol.flags = BSF_GLOBAL; | 4927 | 46 | break; | 4928 | | | 4929 | 107k | case C_NULL: | 4930 | | /* PE DLLs sometimes have zeroed out symbols for some | 4931 | | reason. Just ignore them without a warning. */ | 4932 | 107k | if (src->u.syment.n_type == 0 | 4933 | 107k | && src->u.syment.n_value == 0 | 4934 | 107k | && src->u.syment.n_scnum == 0) | 4935 | 83.6k | break; | 4936 | | #ifdef RS6000COFF_C | 4937 | | /* XCOFF specific: deleted entry. */ | 4938 | | if (src->u.syment.n_value == C_NULL_VALUE) | 4939 | | break; | 4940 | | #endif | 4941 | | /* Fall through. */ | 4942 | 23.8k | case C_EXTDEF: /* External definition. */ | 4943 | 24.0k | case C_ULABEL: /* Undefined label. */ | 4944 | 24.0k | case C_USTATIC: /* Undefined static. */ | 4945 | | #ifndef COFF_WITH_PE | 4946 | | /* C_LINE in regular coff is 0x68. NT has taken over this storage | 4947 | | class to represent a section symbol. */ | 4948 | | case C_LINE: /* line # reformatted as symbol table entry. */ | 4949 | | /* NT uses 0x67 for a weak symbol, not C_ALIAS. */ | 4950 | | case C_ALIAS: /* Duplicate tag. */ | 4951 | | #endif | 4952 | | /* New storage classes for TI COFF. */ | 4953 | | #ifdef TICOFF | 4954 | | case C_UEXT: /* Tentative external definition. */ | 4955 | | #endif | 4956 | 24.0k | case C_EXTLAB: /* External load time label. */ | 4957 | 34.4k | default: | 4958 | 34.4k | _bfd_error_handler | 4959 | | /* xgettext:c-format */ | 4960 | 34.4k | (_("%pB: unrecognized storage class %d for %s symbol `%s'"), | 4961 | 34.4k | abfd, src->u.syment.n_sclass, | 4962 | 34.4k | dst->symbol.section->name, dst->symbol.name); | 4963 | 34.4k | ret = false; | 4964 | | /* Fall through. */ | 4965 | 34.5k | case C_HIDDEN: /* Ext symbol in dmert public lib. */ | 4966 | | /* PR 20722: These symbols can also be generated by | 4967 | | building DLLs with --gc-sections enabled. */ | 4968 | 34.5k | dst->symbol.flags = BSF_DEBUGGING; | 4969 | 34.5k | dst->symbol.value = (src->u.syment.n_value); | 4970 | 34.5k | break; | 4971 | 140k | } | 4972 | | | 4973 | 140k | dst->native = src; | 4974 | 140k | dst->symbol.udata.i = 0; | 4975 | 140k | dst->lineno = NULL; | 4976 | | | 4977 | 140k | this_index += (src->u.syment.n_numaux) + 1; | 4978 | 140k | dst++; | 4979 | 140k | number_of_symbols++; | 4980 | 140k | } | 4981 | 132 | } | 4982 | | | 4983 | 132 | obj_symbols (abfd) = cached_area; | 4984 | 132 | obj_raw_syments (abfd) = native_symbols; | 4985 | | | 4986 | 132 | abfd->symcount = number_of_symbols; | 4987 | 132 | obj_convert (abfd) = table_ptr; | 4988 | | /* Slurp the line tables for each section too. */ | 4989 | 132 | { | 4990 | 132 | asection *p; | 4991 | | | 4992 | 132 | p = abfd->sections; | 4993 | 413 | while (p) | 4994 | 369 | { | 4995 | 369 | if (! coff_slurp_line_table (abfd, p)) | 4996 | 88 | return false; | 4997 | 281 | p = p->next; | 4998 | 281 | } | 4999 | 132 | } | 5000 | | | 5001 | 44 | return ret; | 5002 | 132 | } |
|
5003 | | |
5004 | | /* Classify a COFF symbol. A couple of targets have globally visible |
5005 | | symbols which are not class C_EXT, and this handles those. It also |
5006 | | recognizes some special PE cases. */ |
5007 | | |
5008 | | static enum coff_symbol_classification |
5009 | | coff_classify_symbol (bfd *abfd, |
5010 | | struct internal_syment *syment) |
5011 | 29.7k | { |
5012 | | /* FIXME: This partially duplicates the switch in |
5013 | | coff_slurp_symbol_table. */ |
5014 | 29.7k | switch (syment->n_sclass) |
5015 | 29.7k | { |
5016 | 25.5k | case C_EXT: |
5017 | 26.5k | case C_WEAKEXT: |
5018 | | #ifdef ARM |
5019 | 667 | case C_THUMBEXT: |
5020 | 754 | case C_THUMBEXTFUNC: |
5021 | | #endif |
5022 | | #ifdef RS6000COFF_C |
5023 | 8.25k | case C_HIDEXT: |
5024 | 8.25k | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT |
5025 | 8.41k | case C_AIX_WEAKEXT: |
5026 | | #endif |
5027 | | #endif |
5028 | 8.41k | #ifdef C_SYSTEM |
5029 | 28.8k | case C_SYSTEM: |
5030 | 28.8k | #endif |
5031 | | #ifdef COFF_WITH_PE |
5032 | 16.5k | case C_NT_WEAK: |
5033 | | #endif |
5034 | 29.5k | if (syment->n_scnum == 0) |
5035 | 2.21k | { |
5036 | 2.21k | if (syment->n_value == 0) |
5037 | 694 | return COFF_SYMBOL_UNDEFINED; |
5038 | 1.52k | else |
5039 | 1.52k | return COFF_SYMBOL_COMMON; |
5040 | 2.21k | } |
5041 | | #ifdef RS6000COFF_C |
5042 | 8.49k | if (syment->n_sclass == C_HIDEXT) |
5043 | 349 | return COFF_SYMBOL_LOCAL; |
5044 | 8.14k | #endif |
5045 | 26.9k | return COFF_SYMBOL_GLOBAL; |
5046 | | |
5047 | 230 | default: |
5048 | 230 | break; |
5049 | 29.7k | } |
5050 | | |
5051 | | #ifdef COFF_WITH_PE |
5052 | 230 | if (syment->n_sclass == C_STAT) |
5053 | 0 | { |
5054 | 0 | if (syment->n_scnum == 0) |
5055 | | /* The Microsoft compiler sometimes generates these if a |
5056 | | small static function is inlined every time it is used. |
5057 | | The function is discarded, but the symbol table entry |
5058 | | remains. */ |
5059 | 0 | return COFF_SYMBOL_LOCAL; |
5060 | | |
5061 | | #ifdef STRICT_PE_FORMAT |
5062 | | /* This is correct for Microsoft generated objects, but it |
5063 | | breaks gas generated objects. */ |
5064 | | if (syment->n_value == 0) |
5065 | | { |
5066 | | const asection *sec; |
5067 | | const char *name; |
5068 | | char buf[SYMNMLEN + 1]; |
5069 | | |
5070 | | name = _bfd_coff_internal_syment_name (abfd, syment, buf); |
5071 | | sec = coff_section_from_bfd_index (abfd, syment->n_scnum); |
5072 | | if (sec != NULL && name != NULL |
5073 | | && (strcmp (bfd_section_name (sec), name) == 0)) |
5074 | | return COFF_SYMBOL_PE_SECTION; |
5075 | | } |
5076 | | #endif |
5077 | | |
5078 | 0 | return COFF_SYMBOL_LOCAL; |
5079 | 0 | } |
5080 | | |
5081 | 230 | if (syment->n_sclass == C_SECTION) |
5082 | 230 | { |
5083 | | /* In some cases in a DLL generated by the Microsoft linker, the |
5084 | | n_value field will contain garbage. FIXME: This should |
5085 | | probably be handled by the swapping function instead. */ |
5086 | 230 | syment->n_value = 0; |
5087 | 230 | if (syment->n_scnum == 0) |
5088 | 211 | return COFF_SYMBOL_UNDEFINED; |
5089 | 19 | return COFF_SYMBOL_PE_SECTION; |
5090 | 230 | } |
5091 | 0 | #endif /* COFF_WITH_PE */ |
5092 | | |
5093 | | /* If it is not a global symbol, we presume it is a local symbol. */ |
5094 | 0 | if (syment->n_scnum == 0) |
5095 | 0 | { |
5096 | 0 | char buf[SYMNMLEN + 1]; |
5097 | |
|
5098 | 0 | _bfd_error_handler |
5099 | | /* xgettext:c-format */ |
5100 | 0 | (_("warning: %pB: local symbol `%s' has no section"), |
5101 | 0 | abfd, _bfd_coff_internal_syment_name (abfd, syment, buf)); |
5102 | 0 | } |
5103 | |
|
5104 | 0 | return COFF_SYMBOL_LOCAL; |
5105 | 230 | } pei-i386.c:coff_classify_symbol Line | Count | Source | 5011 | 235 | { | 5012 | | /* FIXME: This partially duplicates the switch in | 5013 | | coff_slurp_symbol_table. */ | 5014 | 235 | switch (syment->n_sclass) | 5015 | 235 | { | 5016 | 138 | case C_EXT: | 5017 | 148 | case C_WEAKEXT: | 5018 | | #ifdef ARM | 5019 | | case C_THUMBEXT: | 5020 | | case C_THUMBEXTFUNC: | 5021 | | #endif | 5022 | | #ifdef RS6000COFF_C | 5023 | | case C_HIDEXT: | 5024 | | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 5025 | | case C_AIX_WEAKEXT: | 5026 | | #endif | 5027 | | #endif | 5028 | 148 | #ifdef C_SYSTEM | 5029 | 180 | case C_SYSTEM: | 5030 | 180 | #endif | 5031 | 180 | #ifdef COFF_WITH_PE | 5032 | 218 | case C_NT_WEAK: | 5033 | 218 | #endif | 5034 | 218 | if (syment->n_scnum == 0) | 5035 | 60 | { | 5036 | 60 | if (syment->n_value == 0) | 5037 | 20 | return COFF_SYMBOL_UNDEFINED; | 5038 | 40 | else | 5039 | 40 | return COFF_SYMBOL_COMMON; | 5040 | 60 | } | 5041 | | #ifdef RS6000COFF_C | 5042 | | if (syment->n_sclass == C_HIDEXT) | 5043 | | return COFF_SYMBOL_LOCAL; | 5044 | | #endif | 5045 | 158 | return COFF_SYMBOL_GLOBAL; | 5046 | | | 5047 | 17 | default: | 5048 | 17 | break; | 5049 | 235 | } | 5050 | | | 5051 | 17 | #ifdef COFF_WITH_PE | 5052 | 17 | if (syment->n_sclass == C_STAT) | 5053 | 0 | { | 5054 | 0 | if (syment->n_scnum == 0) | 5055 | | /* The Microsoft compiler sometimes generates these if a | 5056 | | small static function is inlined every time it is used. | 5057 | | The function is discarded, but the symbol table entry | 5058 | | remains. */ | 5059 | 0 | return COFF_SYMBOL_LOCAL; | 5060 | | | 5061 | | #ifdef STRICT_PE_FORMAT | 5062 | | /* This is correct for Microsoft generated objects, but it | 5063 | | breaks gas generated objects. */ | 5064 | | if (syment->n_value == 0) | 5065 | | { | 5066 | | const asection *sec; | 5067 | | const char *name; | 5068 | | char buf[SYMNMLEN + 1]; | 5069 | | | 5070 | | name = _bfd_coff_internal_syment_name (abfd, syment, buf); | 5071 | | sec = coff_section_from_bfd_index (abfd, syment->n_scnum); | 5072 | | if (sec != NULL && name != NULL | 5073 | | && (strcmp (bfd_section_name (sec), name) == 0)) | 5074 | | return COFF_SYMBOL_PE_SECTION; | 5075 | | } | 5076 | | #endif | 5077 | | | 5078 | 0 | return COFF_SYMBOL_LOCAL; | 5079 | 0 | } | 5080 | | | 5081 | 17 | if (syment->n_sclass == C_SECTION) | 5082 | 17 | { | 5083 | | /* In some cases in a DLL generated by the Microsoft linker, the | 5084 | | n_value field will contain garbage. FIXME: This should | 5085 | | probably be handled by the swapping function instead. */ | 5086 | 17 | syment->n_value = 0; | 5087 | 17 | if (syment->n_scnum == 0) | 5088 | 17 | return COFF_SYMBOL_UNDEFINED; | 5089 | 0 | return COFF_SYMBOL_PE_SECTION; | 5090 | 17 | } | 5091 | 0 | #endif /* COFF_WITH_PE */ | 5092 | | | 5093 | | /* If it is not a global symbol, we presume it is a local symbol. */ | 5094 | 0 | if (syment->n_scnum == 0) | 5095 | 0 | { | 5096 | 0 | char buf[SYMNMLEN + 1]; | 5097 | |
| 5098 | 0 | _bfd_error_handler | 5099 | | /* xgettext:c-format */ | 5100 | 0 | (_("warning: %pB: local symbol `%s' has no section"), | 5101 | 0 | abfd, _bfd_coff_internal_syment_name (abfd, syment, buf)); | 5102 | 0 | } | 5103 | |
| 5104 | 0 | return COFF_SYMBOL_LOCAL; | 5105 | 17 | } |
pe-x86_64.c:coff_classify_symbol Line | Count | Source | 5011 | 2.86k | { | 5012 | | /* FIXME: This partially duplicates the switch in | 5013 | | coff_slurp_symbol_table. */ | 5014 | 2.86k | switch (syment->n_sclass) | 5015 | 2.86k | { | 5016 | 2.53k | case C_EXT: | 5017 | 2.66k | case C_WEAKEXT: | 5018 | | #ifdef ARM | 5019 | | case C_THUMBEXT: | 5020 | | case C_THUMBEXTFUNC: | 5021 | | #endif | 5022 | | #ifdef RS6000COFF_C | 5023 | | case C_HIDEXT: | 5024 | | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 5025 | | case C_AIX_WEAKEXT: | 5026 | | #endif | 5027 | | #endif | 5028 | 2.66k | #ifdef C_SYSTEM | 5029 | 2.70k | case C_SYSTEM: | 5030 | 2.70k | #endif | 5031 | 2.70k | #ifdef COFF_WITH_PE | 5032 | 2.79k | case C_NT_WEAK: | 5033 | 2.79k | #endif | 5034 | 2.79k | if (syment->n_scnum == 0) | 5035 | 245 | { | 5036 | 245 | if (syment->n_value == 0) | 5037 | 68 | return COFF_SYMBOL_UNDEFINED; | 5038 | 177 | else | 5039 | 177 | return COFF_SYMBOL_COMMON; | 5040 | 245 | } | 5041 | | #ifdef RS6000COFF_C | 5042 | | if (syment->n_sclass == C_HIDEXT) | 5043 | | return COFF_SYMBOL_LOCAL; | 5044 | | #endif | 5045 | 2.54k | return COFF_SYMBOL_GLOBAL; | 5046 | | | 5047 | 69 | default: | 5048 | 69 | break; | 5049 | 2.86k | } | 5050 | | | 5051 | 69 | #ifdef COFF_WITH_PE | 5052 | 69 | if (syment->n_sclass == C_STAT) | 5053 | 0 | { | 5054 | 0 | if (syment->n_scnum == 0) | 5055 | | /* The Microsoft compiler sometimes generates these if a | 5056 | | small static function is inlined every time it is used. | 5057 | | The function is discarded, but the symbol table entry | 5058 | | remains. */ | 5059 | 0 | return COFF_SYMBOL_LOCAL; | 5060 | | | 5061 | | #ifdef STRICT_PE_FORMAT | 5062 | | /* This is correct for Microsoft generated objects, but it | 5063 | | breaks gas generated objects. */ | 5064 | | if (syment->n_value == 0) | 5065 | | { | 5066 | | const asection *sec; | 5067 | | const char *name; | 5068 | | char buf[SYMNMLEN + 1]; | 5069 | | | 5070 | | name = _bfd_coff_internal_syment_name (abfd, syment, buf); | 5071 | | sec = coff_section_from_bfd_index (abfd, syment->n_scnum); | 5072 | | if (sec != NULL && name != NULL | 5073 | | && (strcmp (bfd_section_name (sec), name) == 0)) | 5074 | | return COFF_SYMBOL_PE_SECTION; | 5075 | | } | 5076 | | #endif | 5077 | | | 5078 | 0 | return COFF_SYMBOL_LOCAL; | 5079 | 0 | } | 5080 | | | 5081 | 69 | if (syment->n_sclass == C_SECTION) | 5082 | 69 | { | 5083 | | /* In some cases in a DLL generated by the Microsoft linker, the | 5084 | | n_value field will contain garbage. FIXME: This should | 5085 | | probably be handled by the swapping function instead. */ | 5086 | 69 | syment->n_value = 0; | 5087 | 69 | if (syment->n_scnum == 0) | 5088 | 50 | return COFF_SYMBOL_UNDEFINED; | 5089 | 19 | return COFF_SYMBOL_PE_SECTION; | 5090 | 69 | } | 5091 | 0 | #endif /* COFF_WITH_PE */ | 5092 | | | 5093 | | /* If it is not a global symbol, we presume it is a local symbol. */ | 5094 | 0 | if (syment->n_scnum == 0) | 5095 | 0 | { | 5096 | 0 | char buf[SYMNMLEN + 1]; | 5097 | |
| 5098 | 0 | _bfd_error_handler | 5099 | | /* xgettext:c-format */ | 5100 | 0 | (_("warning: %pB: local symbol `%s' has no section"), | 5101 | 0 | abfd, _bfd_coff_internal_syment_name (abfd, syment, buf)); | 5102 | 0 | } | 5103 | |
| 5104 | 0 | return COFF_SYMBOL_LOCAL; | 5105 | 69 | } |
pei-x86_64.c:coff_classify_symbol Line | Count | Source | 5011 | 527 | { | 5012 | | /* FIXME: This partially duplicates the switch in | 5013 | | coff_slurp_symbol_table. */ | 5014 | 527 | switch (syment->n_sclass) | 5015 | 527 | { | 5016 | 436 | case C_EXT: | 5017 | 448 | case C_WEAKEXT: | 5018 | | #ifdef ARM | 5019 | | case C_THUMBEXT: | 5020 | | case C_THUMBEXTFUNC: | 5021 | | #endif | 5022 | | #ifdef RS6000COFF_C | 5023 | | case C_HIDEXT: | 5024 | | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 5025 | | case C_AIX_WEAKEXT: | 5026 | | #endif | 5027 | | #endif | 5028 | 448 | #ifdef C_SYSTEM | 5029 | 475 | case C_SYSTEM: | 5030 | 475 | #endif | 5031 | 475 | #ifdef COFF_WITH_PE | 5032 | 522 | case C_NT_WEAK: | 5033 | 522 | #endif | 5034 | 522 | if (syment->n_scnum == 0) | 5035 | 37 | { | 5036 | 37 | if (syment->n_value == 0) | 5037 | 18 | return COFF_SYMBOL_UNDEFINED; | 5038 | 19 | else | 5039 | 19 | return COFF_SYMBOL_COMMON; | 5040 | 37 | } | 5041 | | #ifdef RS6000COFF_C | 5042 | | if (syment->n_sclass == C_HIDEXT) | 5043 | | return COFF_SYMBOL_LOCAL; | 5044 | | #endif | 5045 | 485 | return COFF_SYMBOL_GLOBAL; | 5046 | | | 5047 | 5 | default: | 5048 | 5 | break; | 5049 | 527 | } | 5050 | | | 5051 | 5 | #ifdef COFF_WITH_PE | 5052 | 5 | if (syment->n_sclass == C_STAT) | 5053 | 0 | { | 5054 | 0 | if (syment->n_scnum == 0) | 5055 | | /* The Microsoft compiler sometimes generates these if a | 5056 | | small static function is inlined every time it is used. | 5057 | | The function is discarded, but the symbol table entry | 5058 | | remains. */ | 5059 | 0 | return COFF_SYMBOL_LOCAL; | 5060 | | | 5061 | | #ifdef STRICT_PE_FORMAT | 5062 | | /* This is correct for Microsoft generated objects, but it | 5063 | | breaks gas generated objects. */ | 5064 | | if (syment->n_value == 0) | 5065 | | { | 5066 | | const asection *sec; | 5067 | | const char *name; | 5068 | | char buf[SYMNMLEN + 1]; | 5069 | | | 5070 | | name = _bfd_coff_internal_syment_name (abfd, syment, buf); | 5071 | | sec = coff_section_from_bfd_index (abfd, syment->n_scnum); | 5072 | | if (sec != NULL && name != NULL | 5073 | | && (strcmp (bfd_section_name (sec), name) == 0)) | 5074 | | return COFF_SYMBOL_PE_SECTION; | 5075 | | } | 5076 | | #endif | 5077 | | | 5078 | 0 | return COFF_SYMBOL_LOCAL; | 5079 | 0 | } | 5080 | | | 5081 | 5 | if (syment->n_sclass == C_SECTION) | 5082 | 5 | { | 5083 | | /* In some cases in a DLL generated by the Microsoft linker, the | 5084 | | n_value field will contain garbage. FIXME: This should | 5085 | | probably be handled by the swapping function instead. */ | 5086 | 5 | syment->n_value = 0; | 5087 | 5 | if (syment->n_scnum == 0) | 5088 | 5 | return COFF_SYMBOL_UNDEFINED; | 5089 | 0 | return COFF_SYMBOL_PE_SECTION; | 5090 | 5 | } | 5091 | 0 | #endif /* COFF_WITH_PE */ | 5092 | | | 5093 | | /* If it is not a global symbol, we presume it is a local symbol. */ | 5094 | 0 | if (syment->n_scnum == 0) | 5095 | 0 | { | 5096 | 0 | char buf[SYMNMLEN + 1]; | 5097 | |
| 5098 | 0 | _bfd_error_handler | 5099 | | /* xgettext:c-format */ | 5100 | 0 | (_("warning: %pB: local symbol `%s' has no section"), | 5101 | 0 | abfd, _bfd_coff_internal_syment_name (abfd, syment, buf)); | 5102 | 0 | } | 5103 | |
| 5104 | 0 | return COFF_SYMBOL_LOCAL; | 5105 | 5 | } |
coff-x86_64.c:coff_classify_symbol Line | Count | Source | 5011 | 867 | { | 5012 | | /* FIXME: This partially duplicates the switch in | 5013 | | coff_slurp_symbol_table. */ | 5014 | 867 | switch (syment->n_sclass) | 5015 | 867 | { | 5016 | 706 | case C_EXT: | 5017 | 781 | case C_WEAKEXT: | 5018 | | #ifdef ARM | 5019 | | case C_THUMBEXT: | 5020 | | case C_THUMBEXTFUNC: | 5021 | | #endif | 5022 | | #ifdef RS6000COFF_C | 5023 | | case C_HIDEXT: | 5024 | | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 5025 | | case C_AIX_WEAKEXT: | 5026 | | #endif | 5027 | | #endif | 5028 | 781 | #ifdef C_SYSTEM | 5029 | 867 | case C_SYSTEM: | 5030 | 867 | #endif | 5031 | | #ifdef COFF_WITH_PE | 5032 | | case C_NT_WEAK: | 5033 | | #endif | 5034 | 867 | if (syment->n_scnum == 0) | 5035 | 93 | { | 5036 | 93 | if (syment->n_value == 0) | 5037 | 21 | return COFF_SYMBOL_UNDEFINED; | 5038 | 72 | else | 5039 | 72 | return COFF_SYMBOL_COMMON; | 5040 | 93 | } | 5041 | | #ifdef RS6000COFF_C | 5042 | | if (syment->n_sclass == C_HIDEXT) | 5043 | | return COFF_SYMBOL_LOCAL; | 5044 | | #endif | 5045 | 774 | return COFF_SYMBOL_GLOBAL; | 5046 | | | 5047 | 0 | default: | 5048 | 0 | break; | 5049 | 867 | } | 5050 | | | 5051 | | #ifdef COFF_WITH_PE | 5052 | | if (syment->n_sclass == C_STAT) | 5053 | | { | 5054 | | if (syment->n_scnum == 0) | 5055 | | /* The Microsoft compiler sometimes generates these if a | 5056 | | small static function is inlined every time it is used. | 5057 | | The function is discarded, but the symbol table entry | 5058 | | remains. */ | 5059 | | return COFF_SYMBOL_LOCAL; | 5060 | | | 5061 | | #ifdef STRICT_PE_FORMAT | 5062 | | /* This is correct for Microsoft generated objects, but it | 5063 | | breaks gas generated objects. */ | 5064 | | if (syment->n_value == 0) | 5065 | | { | 5066 | | const asection *sec; | 5067 | | const char *name; | 5068 | | char buf[SYMNMLEN + 1]; | 5069 | | | 5070 | | name = _bfd_coff_internal_syment_name (abfd, syment, buf); | 5071 | | sec = coff_section_from_bfd_index (abfd, syment->n_scnum); | 5072 | | if (sec != NULL && name != NULL | 5073 | | && (strcmp (bfd_section_name (sec), name) == 0)) | 5074 | | return COFF_SYMBOL_PE_SECTION; | 5075 | | } | 5076 | | #endif | 5077 | | | 5078 | | return COFF_SYMBOL_LOCAL; | 5079 | | } | 5080 | | | 5081 | | if (syment->n_sclass == C_SECTION) | 5082 | | { | 5083 | | /* In some cases in a DLL generated by the Microsoft linker, the | 5084 | | n_value field will contain garbage. FIXME: This should | 5085 | | probably be handled by the swapping function instead. */ | 5086 | | syment->n_value = 0; | 5087 | | if (syment->n_scnum == 0) | 5088 | | return COFF_SYMBOL_UNDEFINED; | 5089 | | return COFF_SYMBOL_PE_SECTION; | 5090 | | } | 5091 | | #endif /* COFF_WITH_PE */ | 5092 | | | 5093 | | /* If it is not a global symbol, we presume it is a local symbol. */ | 5094 | 0 | if (syment->n_scnum == 0) | 5095 | 0 | { | 5096 | 0 | char buf[SYMNMLEN + 1]; | 5097 | |
| 5098 | 0 | _bfd_error_handler | 5099 | | /* xgettext:c-format */ | 5100 | 0 | (_("warning: %pB: local symbol `%s' has no section"), | 5101 | 0 | abfd, _bfd_coff_internal_syment_name (abfd, syment, buf)); | 5102 | 0 | } | 5103 | |
| 5104 | 0 | return COFF_SYMBOL_LOCAL; | 5105 | 867 | } |
coff64-rs6000.c:coff_classify_symbol Line | Count | Source | 5011 | 5.10k | { | 5012 | | /* FIXME: This partially duplicates the switch in | 5013 | | coff_slurp_symbol_table. */ | 5014 | 5.10k | switch (syment->n_sclass) | 5015 | 5.10k | { | 5016 | 4.57k | case C_EXT: | 5017 | 4.61k | case C_WEAKEXT: | 5018 | | #ifdef ARM | 5019 | | case C_THUMBEXT: | 5020 | | case C_THUMBEXTFUNC: | 5021 | | #endif | 5022 | 4.61k | #ifdef RS6000COFF_C | 5023 | 4.72k | case C_HIDEXT: | 5024 | 4.72k | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 5025 | 4.79k | case C_AIX_WEAKEXT: | 5026 | 4.79k | #endif | 5027 | 4.79k | #endif | 5028 | 4.79k | #ifdef C_SYSTEM | 5029 | 5.10k | case C_SYSTEM: | 5030 | 5.10k | #endif | 5031 | | #ifdef COFF_WITH_PE | 5032 | | case C_NT_WEAK: | 5033 | | #endif | 5034 | 5.10k | if (syment->n_scnum == 0) | 5035 | 252 | { | 5036 | 252 | if (syment->n_value == 0) | 5037 | 85 | return COFF_SYMBOL_UNDEFINED; | 5038 | 167 | else | 5039 | 167 | return COFF_SYMBOL_COMMON; | 5040 | 252 | } | 5041 | 4.85k | #ifdef RS6000COFF_C | 5042 | 4.85k | if (syment->n_sclass == C_HIDEXT) | 5043 | 103 | return COFF_SYMBOL_LOCAL; | 5044 | 4.74k | #endif | 5045 | 4.74k | return COFF_SYMBOL_GLOBAL; | 5046 | | | 5047 | 0 | default: | 5048 | 0 | break; | 5049 | 5.10k | } | 5050 | | | 5051 | | #ifdef COFF_WITH_PE | 5052 | | if (syment->n_sclass == C_STAT) | 5053 | | { | 5054 | | if (syment->n_scnum == 0) | 5055 | | /* The Microsoft compiler sometimes generates these if a | 5056 | | small static function is inlined every time it is used. | 5057 | | The function is discarded, but the symbol table entry | 5058 | | remains. */ | 5059 | | return COFF_SYMBOL_LOCAL; | 5060 | | | 5061 | | #ifdef STRICT_PE_FORMAT | 5062 | | /* This is correct for Microsoft generated objects, but it | 5063 | | breaks gas generated objects. */ | 5064 | | if (syment->n_value == 0) | 5065 | | { | 5066 | | const asection *sec; | 5067 | | const char *name; | 5068 | | char buf[SYMNMLEN + 1]; | 5069 | | | 5070 | | name = _bfd_coff_internal_syment_name (abfd, syment, buf); | 5071 | | sec = coff_section_from_bfd_index (abfd, syment->n_scnum); | 5072 | | if (sec != NULL && name != NULL | 5073 | | && (strcmp (bfd_section_name (sec), name) == 0)) | 5074 | | return COFF_SYMBOL_PE_SECTION; | 5075 | | } | 5076 | | #endif | 5077 | | | 5078 | | return COFF_SYMBOL_LOCAL; | 5079 | | } | 5080 | | | 5081 | | if (syment->n_sclass == C_SECTION) | 5082 | | { | 5083 | | /* In some cases in a DLL generated by the Microsoft linker, the | 5084 | | n_value field will contain garbage. FIXME: This should | 5085 | | probably be handled by the swapping function instead. */ | 5086 | | syment->n_value = 0; | 5087 | | if (syment->n_scnum == 0) | 5088 | | return COFF_SYMBOL_UNDEFINED; | 5089 | | return COFF_SYMBOL_PE_SECTION; | 5090 | | } | 5091 | | #endif /* COFF_WITH_PE */ | 5092 | | | 5093 | | /* If it is not a global symbol, we presume it is a local symbol. */ | 5094 | 0 | if (syment->n_scnum == 0) | 5095 | 0 | { | 5096 | 0 | char buf[SYMNMLEN + 1]; | 5097 | |
| 5098 | 0 | _bfd_error_handler | 5099 | | /* xgettext:c-format */ | 5100 | 0 | (_("warning: %pB: local symbol `%s' has no section"), | 5101 | 0 | abfd, _bfd_coff_internal_syment_name (abfd, syment, buf)); | 5102 | 0 | } | 5103 | |
| 5104 | 0 | return COFF_SYMBOL_LOCAL; | 5105 | 5.10k | } |
pei-aarch64.c:coff_classify_symbol Line | Count | Source | 5011 | 137 | { | 5012 | | /* FIXME: This partially duplicates the switch in | 5013 | | coff_slurp_symbol_table. */ | 5014 | 137 | switch (syment->n_sclass) | 5015 | 137 | { | 5016 | 89 | case C_EXT: | 5017 | 90 | case C_WEAKEXT: | 5018 | | #ifdef ARM | 5019 | | case C_THUMBEXT: | 5020 | | case C_THUMBEXTFUNC: | 5021 | | #endif | 5022 | | #ifdef RS6000COFF_C | 5023 | | case C_HIDEXT: | 5024 | | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 5025 | | case C_AIX_WEAKEXT: | 5026 | | #endif | 5027 | | #endif | 5028 | 90 | #ifdef C_SYSTEM | 5029 | 123 | case C_SYSTEM: | 5030 | 123 | #endif | 5031 | 123 | #ifdef COFF_WITH_PE | 5032 | 132 | case C_NT_WEAK: | 5033 | 132 | #endif | 5034 | 132 | if (syment->n_scnum == 0) | 5035 | 22 | { | 5036 | 22 | if (syment->n_value == 0) | 5037 | 12 | return COFF_SYMBOL_UNDEFINED; | 5038 | 10 | else | 5039 | 10 | return COFF_SYMBOL_COMMON; | 5040 | 22 | } | 5041 | | #ifdef RS6000COFF_C | 5042 | | if (syment->n_sclass == C_HIDEXT) | 5043 | | return COFF_SYMBOL_LOCAL; | 5044 | | #endif | 5045 | 110 | return COFF_SYMBOL_GLOBAL; | 5046 | | | 5047 | 5 | default: | 5048 | 5 | break; | 5049 | 137 | } | 5050 | | | 5051 | 5 | #ifdef COFF_WITH_PE | 5052 | 5 | if (syment->n_sclass == C_STAT) | 5053 | 0 | { | 5054 | 0 | if (syment->n_scnum == 0) | 5055 | | /* The Microsoft compiler sometimes generates these if a | 5056 | | small static function is inlined every time it is used. | 5057 | | The function is discarded, but the symbol table entry | 5058 | | remains. */ | 5059 | 0 | return COFF_SYMBOL_LOCAL; | 5060 | | | 5061 | | #ifdef STRICT_PE_FORMAT | 5062 | | /* This is correct for Microsoft generated objects, but it | 5063 | | breaks gas generated objects. */ | 5064 | | if (syment->n_value == 0) | 5065 | | { | 5066 | | const asection *sec; | 5067 | | const char *name; | 5068 | | char buf[SYMNMLEN + 1]; | 5069 | | | 5070 | | name = _bfd_coff_internal_syment_name (abfd, syment, buf); | 5071 | | sec = coff_section_from_bfd_index (abfd, syment->n_scnum); | 5072 | | if (sec != NULL && name != NULL | 5073 | | && (strcmp (bfd_section_name (sec), name) == 0)) | 5074 | | return COFF_SYMBOL_PE_SECTION; | 5075 | | } | 5076 | | #endif | 5077 | | | 5078 | 0 | return COFF_SYMBOL_LOCAL; | 5079 | 0 | } | 5080 | | | 5081 | 5 | if (syment->n_sclass == C_SECTION) | 5082 | 5 | { | 5083 | | /* In some cases in a DLL generated by the Microsoft linker, the | 5084 | | n_value field will contain garbage. FIXME: This should | 5085 | | probably be handled by the swapping function instead. */ | 5086 | 5 | syment->n_value = 0; | 5087 | 5 | if (syment->n_scnum == 0) | 5088 | 5 | return COFF_SYMBOL_UNDEFINED; | 5089 | 0 | return COFF_SYMBOL_PE_SECTION; | 5090 | 5 | } | 5091 | 0 | #endif /* COFF_WITH_PE */ | 5092 | | | 5093 | | /* If it is not a global symbol, we presume it is a local symbol. */ | 5094 | 0 | if (syment->n_scnum == 0) | 5095 | 0 | { | 5096 | 0 | char buf[SYMNMLEN + 1]; | 5097 | |
| 5098 | 0 | _bfd_error_handler | 5099 | | /* xgettext:c-format */ | 5100 | 0 | (_("warning: %pB: local symbol `%s' has no section"), | 5101 | 0 | abfd, _bfd_coff_internal_syment_name (abfd, syment, buf)); | 5102 | 0 | } | 5103 | |
| 5104 | 0 | return COFF_SYMBOL_LOCAL; | 5105 | 5 | } |
pe-aarch64.c:coff_classify_symbol Line | Count | Source | 5011 | 680 | { | 5012 | | /* FIXME: This partially duplicates the switch in | 5013 | | coff_slurp_symbol_table. */ | 5014 | 680 | switch (syment->n_sclass) | 5015 | 680 | { | 5016 | 526 | case C_EXT: | 5017 | 543 | case C_WEAKEXT: | 5018 | | #ifdef ARM | 5019 | | case C_THUMBEXT: | 5020 | | case C_THUMBEXTFUNC: | 5021 | | #endif | 5022 | | #ifdef RS6000COFF_C | 5023 | | case C_HIDEXT: | 5024 | | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 5025 | | case C_AIX_WEAKEXT: | 5026 | | #endif | 5027 | | #endif | 5028 | 543 | #ifdef C_SYSTEM | 5029 | 605 | case C_SYSTEM: | 5030 | 605 | #endif | 5031 | 605 | #ifdef COFF_WITH_PE | 5032 | 664 | case C_NT_WEAK: | 5033 | 664 | #endif | 5034 | 664 | if (syment->n_scnum == 0) | 5035 | 110 | { | 5036 | 110 | if (syment->n_value == 0) | 5037 | 15 | return COFF_SYMBOL_UNDEFINED; | 5038 | 95 | else | 5039 | 95 | return COFF_SYMBOL_COMMON; | 5040 | 110 | } | 5041 | | #ifdef RS6000COFF_C | 5042 | | if (syment->n_sclass == C_HIDEXT) | 5043 | | return COFF_SYMBOL_LOCAL; | 5044 | | #endif | 5045 | 554 | return COFF_SYMBOL_GLOBAL; | 5046 | | | 5047 | 16 | default: | 5048 | 16 | break; | 5049 | 680 | } | 5050 | | | 5051 | 16 | #ifdef COFF_WITH_PE | 5052 | 16 | if (syment->n_sclass == C_STAT) | 5053 | 0 | { | 5054 | 0 | if (syment->n_scnum == 0) | 5055 | | /* The Microsoft compiler sometimes generates these if a | 5056 | | small static function is inlined every time it is used. | 5057 | | The function is discarded, but the symbol table entry | 5058 | | remains. */ | 5059 | 0 | return COFF_SYMBOL_LOCAL; | 5060 | | | 5061 | | #ifdef STRICT_PE_FORMAT | 5062 | | /* This is correct for Microsoft generated objects, but it | 5063 | | breaks gas generated objects. */ | 5064 | | if (syment->n_value == 0) | 5065 | | { | 5066 | | const asection *sec; | 5067 | | const char *name; | 5068 | | char buf[SYMNMLEN + 1]; | 5069 | | | 5070 | | name = _bfd_coff_internal_syment_name (abfd, syment, buf); | 5071 | | sec = coff_section_from_bfd_index (abfd, syment->n_scnum); | 5072 | | if (sec != NULL && name != NULL | 5073 | | && (strcmp (bfd_section_name (sec), name) == 0)) | 5074 | | return COFF_SYMBOL_PE_SECTION; | 5075 | | } | 5076 | | #endif | 5077 | | | 5078 | 0 | return COFF_SYMBOL_LOCAL; | 5079 | 0 | } | 5080 | | | 5081 | 16 | if (syment->n_sclass == C_SECTION) | 5082 | 16 | { | 5083 | | /* In some cases in a DLL generated by the Microsoft linker, the | 5084 | | n_value field will contain garbage. FIXME: This should | 5085 | | probably be handled by the swapping function instead. */ | 5086 | 16 | syment->n_value = 0; | 5087 | 16 | if (syment->n_scnum == 0) | 5088 | 16 | return COFF_SYMBOL_UNDEFINED; | 5089 | 0 | return COFF_SYMBOL_PE_SECTION; | 5090 | 16 | } | 5091 | 0 | #endif /* COFF_WITH_PE */ | 5092 | | | 5093 | | /* If it is not a global symbol, we presume it is a local symbol. */ | 5094 | 0 | if (syment->n_scnum == 0) | 5095 | 0 | { | 5096 | 0 | char buf[SYMNMLEN + 1]; | 5097 | |
| 5098 | 0 | _bfd_error_handler | 5099 | | /* xgettext:c-format */ | 5100 | 0 | (_("warning: %pB: local symbol `%s' has no section"), | 5101 | 0 | abfd, _bfd_coff_internal_syment_name (abfd, syment, buf)); | 5102 | 0 | } | 5103 | |
| 5104 | 0 | return COFF_SYMBOL_LOCAL; | 5105 | 16 | } |
pei-ia64.c:coff_classify_symbol Line | Count | Source | 5011 | 386 | { | 5012 | | /* FIXME: This partially duplicates the switch in | 5013 | | coff_slurp_symbol_table. */ | 5014 | 386 | switch (syment->n_sclass) | 5015 | 386 | { | 5016 | 296 | case C_EXT: | 5017 | 319 | case C_WEAKEXT: | 5018 | | #ifdef ARM | 5019 | | case C_THUMBEXT: | 5020 | | case C_THUMBEXTFUNC: | 5021 | | #endif | 5022 | | #ifdef RS6000COFF_C | 5023 | | case C_HIDEXT: | 5024 | | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 5025 | | case C_AIX_WEAKEXT: | 5026 | | #endif | 5027 | | #endif | 5028 | 319 | #ifdef C_SYSTEM | 5029 | 347 | case C_SYSTEM: | 5030 | 347 | #endif | 5031 | 347 | #ifdef COFF_WITH_PE | 5032 | 370 | case C_NT_WEAK: | 5033 | 370 | #endif | 5034 | 370 | if (syment->n_scnum == 0) | 5035 | 32 | { | 5036 | 32 | if (syment->n_value == 0) | 5037 | 7 | return COFF_SYMBOL_UNDEFINED; | 5038 | 25 | else | 5039 | 25 | return COFF_SYMBOL_COMMON; | 5040 | 32 | } | 5041 | | #ifdef RS6000COFF_C | 5042 | | if (syment->n_sclass == C_HIDEXT) | 5043 | | return COFF_SYMBOL_LOCAL; | 5044 | | #endif | 5045 | 338 | return COFF_SYMBOL_GLOBAL; | 5046 | | | 5047 | 16 | default: | 5048 | 16 | break; | 5049 | 386 | } | 5050 | | | 5051 | 16 | #ifdef COFF_WITH_PE | 5052 | 16 | if (syment->n_sclass == C_STAT) | 5053 | 0 | { | 5054 | 0 | if (syment->n_scnum == 0) | 5055 | | /* The Microsoft compiler sometimes generates these if a | 5056 | | small static function is inlined every time it is used. | 5057 | | The function is discarded, but the symbol table entry | 5058 | | remains. */ | 5059 | 0 | return COFF_SYMBOL_LOCAL; | 5060 | | | 5061 | | #ifdef STRICT_PE_FORMAT | 5062 | | /* This is correct for Microsoft generated objects, but it | 5063 | | breaks gas generated objects. */ | 5064 | | if (syment->n_value == 0) | 5065 | | { | 5066 | | const asection *sec; | 5067 | | const char *name; | 5068 | | char buf[SYMNMLEN + 1]; | 5069 | | | 5070 | | name = _bfd_coff_internal_syment_name (abfd, syment, buf); | 5071 | | sec = coff_section_from_bfd_index (abfd, syment->n_scnum); | 5072 | | if (sec != NULL && name != NULL | 5073 | | && (strcmp (bfd_section_name (sec), name) == 0)) | 5074 | | return COFF_SYMBOL_PE_SECTION; | 5075 | | } | 5076 | | #endif | 5077 | | | 5078 | 0 | return COFF_SYMBOL_LOCAL; | 5079 | 0 | } | 5080 | | | 5081 | 16 | if (syment->n_sclass == C_SECTION) | 5082 | 16 | { | 5083 | | /* In some cases in a DLL generated by the Microsoft linker, the | 5084 | | n_value field will contain garbage. FIXME: This should | 5085 | | probably be handled by the swapping function instead. */ | 5086 | 16 | syment->n_value = 0; | 5087 | 16 | if (syment->n_scnum == 0) | 5088 | 16 | return COFF_SYMBOL_UNDEFINED; | 5089 | 0 | return COFF_SYMBOL_PE_SECTION; | 5090 | 16 | } | 5091 | 0 | #endif /* COFF_WITH_PE */ | 5092 | | | 5093 | | /* If it is not a global symbol, we presume it is a local symbol. */ | 5094 | 0 | if (syment->n_scnum == 0) | 5095 | 0 | { | 5096 | 0 | char buf[SYMNMLEN + 1]; | 5097 | |
| 5098 | 0 | _bfd_error_handler | 5099 | | /* xgettext:c-format */ | 5100 | 0 | (_("warning: %pB: local symbol `%s' has no section"), | 5101 | 0 | abfd, _bfd_coff_internal_syment_name (abfd, syment, buf)); | 5102 | 0 | } | 5103 | |
| 5104 | 0 | return COFF_SYMBOL_LOCAL; | 5105 | 16 | } |
pei-loongarch64.c:coff_classify_symbol Line | Count | Source | 5011 | 744 | { | 5012 | | /* FIXME: This partially duplicates the switch in | 5013 | | coff_slurp_symbol_table. */ | 5014 | 744 | switch (syment->n_sclass) | 5015 | 744 | { | 5016 | 560 | case C_EXT: | 5017 | 624 | case C_WEAKEXT: | 5018 | | #ifdef ARM | 5019 | | case C_THUMBEXT: | 5020 | | case C_THUMBEXTFUNC: | 5021 | | #endif | 5022 | | #ifdef RS6000COFF_C | 5023 | | case C_HIDEXT: | 5024 | | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 5025 | | case C_AIX_WEAKEXT: | 5026 | | #endif | 5027 | | #endif | 5028 | 624 | #ifdef C_SYSTEM | 5029 | 674 | case C_SYSTEM: | 5030 | 674 | #endif | 5031 | 674 | #ifdef COFF_WITH_PE | 5032 | 733 | case C_NT_WEAK: | 5033 | 733 | #endif | 5034 | 733 | if (syment->n_scnum == 0) | 5035 | 161 | { | 5036 | 161 | if (syment->n_value == 0) | 5037 | 47 | return COFF_SYMBOL_UNDEFINED; | 5038 | 114 | else | 5039 | 114 | return COFF_SYMBOL_COMMON; | 5040 | 161 | } | 5041 | | #ifdef RS6000COFF_C | 5042 | | if (syment->n_sclass == C_HIDEXT) | 5043 | | return COFF_SYMBOL_LOCAL; | 5044 | | #endif | 5045 | 572 | return COFF_SYMBOL_GLOBAL; | 5046 | | | 5047 | 11 | default: | 5048 | 11 | break; | 5049 | 744 | } | 5050 | | | 5051 | 11 | #ifdef COFF_WITH_PE | 5052 | 11 | if (syment->n_sclass == C_STAT) | 5053 | 0 | { | 5054 | 0 | if (syment->n_scnum == 0) | 5055 | | /* The Microsoft compiler sometimes generates these if a | 5056 | | small static function is inlined every time it is used. | 5057 | | The function is discarded, but the symbol table entry | 5058 | | remains. */ | 5059 | 0 | return COFF_SYMBOL_LOCAL; | 5060 | | | 5061 | | #ifdef STRICT_PE_FORMAT | 5062 | | /* This is correct for Microsoft generated objects, but it | 5063 | | breaks gas generated objects. */ | 5064 | | if (syment->n_value == 0) | 5065 | | { | 5066 | | const asection *sec; | 5067 | | const char *name; | 5068 | | char buf[SYMNMLEN + 1]; | 5069 | | | 5070 | | name = _bfd_coff_internal_syment_name (abfd, syment, buf); | 5071 | | sec = coff_section_from_bfd_index (abfd, syment->n_scnum); | 5072 | | if (sec != NULL && name != NULL | 5073 | | && (strcmp (bfd_section_name (sec), name) == 0)) | 5074 | | return COFF_SYMBOL_PE_SECTION; | 5075 | | } | 5076 | | #endif | 5077 | | | 5078 | 0 | return COFF_SYMBOL_LOCAL; | 5079 | 0 | } | 5080 | | | 5081 | 11 | if (syment->n_sclass == C_SECTION) | 5082 | 11 | { | 5083 | | /* In some cases in a DLL generated by the Microsoft linker, the | 5084 | | n_value field will contain garbage. FIXME: This should | 5085 | | probably be handled by the swapping function instead. */ | 5086 | 11 | syment->n_value = 0; | 5087 | 11 | if (syment->n_scnum == 0) | 5088 | 11 | return COFF_SYMBOL_UNDEFINED; | 5089 | 0 | return COFF_SYMBOL_PE_SECTION; | 5090 | 11 | } | 5091 | 0 | #endif /* COFF_WITH_PE */ | 5092 | | | 5093 | | /* If it is not a global symbol, we presume it is a local symbol. */ | 5094 | 0 | if (syment->n_scnum == 0) | 5095 | 0 | { | 5096 | 0 | char buf[SYMNMLEN + 1]; | 5097 | |
| 5098 | 0 | _bfd_error_handler | 5099 | | /* xgettext:c-format */ | 5100 | 0 | (_("warning: %pB: local symbol `%s' has no section"), | 5101 | 0 | abfd, _bfd_coff_internal_syment_name (abfd, syment, buf)); | 5102 | 0 | } | 5103 | |
| 5104 | 0 | return COFF_SYMBOL_LOCAL; | 5105 | 11 | } |
Unexecuted instantiation: cf-i386lynx.c:coff_classify_symbol Unexecuted instantiation: coff-go32.c:coff_classify_symbol Unexecuted instantiation: coff-i386.c:coff_classify_symbol coff-rs6000.c:coff_classify_symbol Line | Count | Source | 5011 | 3.90k | { | 5012 | | /* FIXME: This partially duplicates the switch in | 5013 | | coff_slurp_symbol_table. */ | 5014 | 3.90k | switch (syment->n_sclass) | 5015 | 3.90k | { | 5016 | 3.04k | case C_EXT: | 5017 | 3.26k | case C_WEAKEXT: | 5018 | | #ifdef ARM | 5019 | | case C_THUMBEXT: | 5020 | | case C_THUMBEXTFUNC: | 5021 | | #endif | 5022 | 3.26k | #ifdef RS6000COFF_C | 5023 | 3.52k | case C_HIDEXT: | 5024 | 3.52k | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 5025 | 3.62k | case C_AIX_WEAKEXT: | 5026 | 3.62k | #endif | 5027 | 3.62k | #endif | 5028 | 3.62k | #ifdef C_SYSTEM | 5029 | 3.90k | case C_SYSTEM: | 5030 | 3.90k | #endif | 5031 | | #ifdef COFF_WITH_PE | 5032 | | case C_NT_WEAK: | 5033 | | #endif | 5034 | 3.90k | if (syment->n_scnum == 0) | 5035 | 260 | { | 5036 | 260 | if (syment->n_value == 0) | 5037 | 58 | return COFF_SYMBOL_UNDEFINED; | 5038 | 202 | else | 5039 | 202 | return COFF_SYMBOL_COMMON; | 5040 | 260 | } | 5041 | 3.64k | #ifdef RS6000COFF_C | 5042 | 3.64k | if (syment->n_sclass == C_HIDEXT) | 5043 | 246 | return COFF_SYMBOL_LOCAL; | 5044 | 3.40k | #endif | 5045 | 3.40k | return COFF_SYMBOL_GLOBAL; | 5046 | | | 5047 | 0 | default: | 5048 | 0 | break; | 5049 | 3.90k | } | 5050 | | | 5051 | | #ifdef COFF_WITH_PE | 5052 | | if (syment->n_sclass == C_STAT) | 5053 | | { | 5054 | | if (syment->n_scnum == 0) | 5055 | | /* The Microsoft compiler sometimes generates these if a | 5056 | | small static function is inlined every time it is used. | 5057 | | The function is discarded, but the symbol table entry | 5058 | | remains. */ | 5059 | | return COFF_SYMBOL_LOCAL; | 5060 | | | 5061 | | #ifdef STRICT_PE_FORMAT | 5062 | | /* This is correct for Microsoft generated objects, but it | 5063 | | breaks gas generated objects. */ | 5064 | | if (syment->n_value == 0) | 5065 | | { | 5066 | | const asection *sec; | 5067 | | const char *name; | 5068 | | char buf[SYMNMLEN + 1]; | 5069 | | | 5070 | | name = _bfd_coff_internal_syment_name (abfd, syment, buf); | 5071 | | sec = coff_section_from_bfd_index (abfd, syment->n_scnum); | 5072 | | if (sec != NULL && name != NULL | 5073 | | && (strcmp (bfd_section_name (sec), name) == 0)) | 5074 | | return COFF_SYMBOL_PE_SECTION; | 5075 | | } | 5076 | | #endif | 5077 | | | 5078 | | return COFF_SYMBOL_LOCAL; | 5079 | | } | 5080 | | | 5081 | | if (syment->n_sclass == C_SECTION) | 5082 | | { | 5083 | | /* In some cases in a DLL generated by the Microsoft linker, the | 5084 | | n_value field will contain garbage. FIXME: This should | 5085 | | probably be handled by the swapping function instead. */ | 5086 | | syment->n_value = 0; | 5087 | | if (syment->n_scnum == 0) | 5088 | | return COFF_SYMBOL_UNDEFINED; | 5089 | | return COFF_SYMBOL_PE_SECTION; | 5090 | | } | 5091 | | #endif /* COFF_WITH_PE */ | 5092 | | | 5093 | | /* If it is not a global symbol, we presume it is a local symbol. */ | 5094 | 0 | if (syment->n_scnum == 0) | 5095 | 0 | { | 5096 | 0 | char buf[SYMNMLEN + 1]; | 5097 | |
| 5098 | 0 | _bfd_error_handler | 5099 | | /* xgettext:c-format */ | 5100 | 0 | (_("warning: %pB: local symbol `%s' has no section"), | 5101 | 0 | abfd, _bfd_coff_internal_syment_name (abfd, syment, buf)); | 5102 | 0 | } | 5103 | |
| 5104 | 0 | return COFF_SYMBOL_LOCAL; | 5105 | 3.90k | } |
Unexecuted instantiation: coff-sh.c:coff_classify_symbol Unexecuted instantiation: coff-stgo32.c:coff_classify_symbol coff-tic30.c:coff_classify_symbol Line | Count | Source | 5011 | 791 | { | 5012 | | /* FIXME: This partially duplicates the switch in | 5013 | | coff_slurp_symbol_table. */ | 5014 | 791 | switch (syment->n_sclass) | 5015 | 791 | { | 5016 | 768 | case C_EXT: | 5017 | 778 | case C_WEAKEXT: | 5018 | | #ifdef ARM | 5019 | | case C_THUMBEXT: | 5020 | | case C_THUMBEXTFUNC: | 5021 | | #endif | 5022 | | #ifdef RS6000COFF_C | 5023 | | case C_HIDEXT: | 5024 | | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 5025 | | case C_AIX_WEAKEXT: | 5026 | | #endif | 5027 | | #endif | 5028 | 778 | #ifdef C_SYSTEM | 5029 | 791 | case C_SYSTEM: | 5030 | 791 | #endif | 5031 | | #ifdef COFF_WITH_PE | 5032 | | case C_NT_WEAK: | 5033 | | #endif | 5034 | 791 | if (syment->n_scnum == 0) | 5035 | 72 | { | 5036 | 72 | if (syment->n_value == 0) | 5037 | 46 | return COFF_SYMBOL_UNDEFINED; | 5038 | 26 | else | 5039 | 26 | return COFF_SYMBOL_COMMON; | 5040 | 72 | } | 5041 | | #ifdef RS6000COFF_C | 5042 | | if (syment->n_sclass == C_HIDEXT) | 5043 | | return COFF_SYMBOL_LOCAL; | 5044 | | #endif | 5045 | 719 | return COFF_SYMBOL_GLOBAL; | 5046 | | | 5047 | 0 | default: | 5048 | 0 | break; | 5049 | 791 | } | 5050 | | | 5051 | | #ifdef COFF_WITH_PE | 5052 | | if (syment->n_sclass == C_STAT) | 5053 | | { | 5054 | | if (syment->n_scnum == 0) | 5055 | | /* The Microsoft compiler sometimes generates these if a | 5056 | | small static function is inlined every time it is used. | 5057 | | The function is discarded, but the symbol table entry | 5058 | | remains. */ | 5059 | | return COFF_SYMBOL_LOCAL; | 5060 | | | 5061 | | #ifdef STRICT_PE_FORMAT | 5062 | | /* This is correct for Microsoft generated objects, but it | 5063 | | breaks gas generated objects. */ | 5064 | | if (syment->n_value == 0) | 5065 | | { | 5066 | | const asection *sec; | 5067 | | const char *name; | 5068 | | char buf[SYMNMLEN + 1]; | 5069 | | | 5070 | | name = _bfd_coff_internal_syment_name (abfd, syment, buf); | 5071 | | sec = coff_section_from_bfd_index (abfd, syment->n_scnum); | 5072 | | if (sec != NULL && name != NULL | 5073 | | && (strcmp (bfd_section_name (sec), name) == 0)) | 5074 | | return COFF_SYMBOL_PE_SECTION; | 5075 | | } | 5076 | | #endif | 5077 | | | 5078 | | return COFF_SYMBOL_LOCAL; | 5079 | | } | 5080 | | | 5081 | | if (syment->n_sclass == C_SECTION) | 5082 | | { | 5083 | | /* In some cases in a DLL generated by the Microsoft linker, the | 5084 | | n_value field will contain garbage. FIXME: This should | 5085 | | probably be handled by the swapping function instead. */ | 5086 | | syment->n_value = 0; | 5087 | | if (syment->n_scnum == 0) | 5088 | | return COFF_SYMBOL_UNDEFINED; | 5089 | | return COFF_SYMBOL_PE_SECTION; | 5090 | | } | 5091 | | #endif /* COFF_WITH_PE */ | 5092 | | | 5093 | | /* If it is not a global symbol, we presume it is a local symbol. */ | 5094 | 0 | if (syment->n_scnum == 0) | 5095 | 0 | { | 5096 | 0 | char buf[SYMNMLEN + 1]; | 5097 | |
| 5098 | 0 | _bfd_error_handler | 5099 | | /* xgettext:c-format */ | 5100 | 0 | (_("warning: %pB: local symbol `%s' has no section"), | 5101 | 0 | abfd, _bfd_coff_internal_syment_name (abfd, syment, buf)); | 5102 | 0 | } | 5103 | |
| 5104 | 0 | return COFF_SYMBOL_LOCAL; | 5105 | 791 | } |
Unexecuted instantiation: coff-tic4x.c:coff_classify_symbol coff-tic54x.c:coff_classify_symbol Line | Count | Source | 5011 | 836 | { | 5012 | | /* FIXME: This partially duplicates the switch in | 5013 | | coff_slurp_symbol_table. */ | 5014 | 836 | switch (syment->n_sclass) | 5015 | 836 | { | 5016 | 798 | case C_EXT: | 5017 | 813 | case C_WEAKEXT: | 5018 | | #ifdef ARM | 5019 | | case C_THUMBEXT: | 5020 | | case C_THUMBEXTFUNC: | 5021 | | #endif | 5022 | | #ifdef RS6000COFF_C | 5023 | | case C_HIDEXT: | 5024 | | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 5025 | | case C_AIX_WEAKEXT: | 5026 | | #endif | 5027 | | #endif | 5028 | 813 | #ifdef C_SYSTEM | 5029 | 836 | case C_SYSTEM: | 5030 | 836 | #endif | 5031 | | #ifdef COFF_WITH_PE | 5032 | | case C_NT_WEAK: | 5033 | | #endif | 5034 | 836 | if (syment->n_scnum == 0) | 5035 | 77 | { | 5036 | 77 | if (syment->n_value == 0) | 5037 | 35 | return COFF_SYMBOL_UNDEFINED; | 5038 | 42 | else | 5039 | 42 | return COFF_SYMBOL_COMMON; | 5040 | 77 | } | 5041 | | #ifdef RS6000COFF_C | 5042 | | if (syment->n_sclass == C_HIDEXT) | 5043 | | return COFF_SYMBOL_LOCAL; | 5044 | | #endif | 5045 | 759 | return COFF_SYMBOL_GLOBAL; | 5046 | | | 5047 | 0 | default: | 5048 | 0 | break; | 5049 | 836 | } | 5050 | | | 5051 | | #ifdef COFF_WITH_PE | 5052 | | if (syment->n_sclass == C_STAT) | 5053 | | { | 5054 | | if (syment->n_scnum == 0) | 5055 | | /* The Microsoft compiler sometimes generates these if a | 5056 | | small static function is inlined every time it is used. | 5057 | | The function is discarded, but the symbol table entry | 5058 | | remains. */ | 5059 | | return COFF_SYMBOL_LOCAL; | 5060 | | | 5061 | | #ifdef STRICT_PE_FORMAT | 5062 | | /* This is correct for Microsoft generated objects, but it | 5063 | | breaks gas generated objects. */ | 5064 | | if (syment->n_value == 0) | 5065 | | { | 5066 | | const asection *sec; | 5067 | | const char *name; | 5068 | | char buf[SYMNMLEN + 1]; | 5069 | | | 5070 | | name = _bfd_coff_internal_syment_name (abfd, syment, buf); | 5071 | | sec = coff_section_from_bfd_index (abfd, syment->n_scnum); | 5072 | | if (sec != NULL && name != NULL | 5073 | | && (strcmp (bfd_section_name (sec), name) == 0)) | 5074 | | return COFF_SYMBOL_PE_SECTION; | 5075 | | } | 5076 | | #endif | 5077 | | | 5078 | | return COFF_SYMBOL_LOCAL; | 5079 | | } | 5080 | | | 5081 | | if (syment->n_sclass == C_SECTION) | 5082 | | { | 5083 | | /* In some cases in a DLL generated by the Microsoft linker, the | 5084 | | n_value field will contain garbage. FIXME: This should | 5085 | | probably be handled by the swapping function instead. */ | 5086 | | syment->n_value = 0; | 5087 | | if (syment->n_scnum == 0) | 5088 | | return COFF_SYMBOL_UNDEFINED; | 5089 | | return COFF_SYMBOL_PE_SECTION; | 5090 | | } | 5091 | | #endif /* COFF_WITH_PE */ | 5092 | | | 5093 | | /* If it is not a global symbol, we presume it is a local symbol. */ | 5094 | 0 | if (syment->n_scnum == 0) | 5095 | 0 | { | 5096 | 0 | char buf[SYMNMLEN + 1]; | 5097 | |
| 5098 | 0 | _bfd_error_handler | 5099 | | /* xgettext:c-format */ | 5100 | 0 | (_("warning: %pB: local symbol `%s' has no section"), | 5101 | 0 | abfd, _bfd_coff_internal_syment_name (abfd, syment, buf)); | 5102 | 0 | } | 5103 | |
| 5104 | 0 | return COFF_SYMBOL_LOCAL; | 5105 | 836 | } |
coff-z80.c:coff_classify_symbol Line | Count | Source | 5011 | 931 | { | 5012 | | /* FIXME: This partially duplicates the switch in | 5013 | | coff_slurp_symbol_table. */ | 5014 | 931 | switch (syment->n_sclass) | 5015 | 931 | { | 5016 | 737 | case C_EXT: | 5017 | 776 | case C_WEAKEXT: | 5018 | | #ifdef ARM | 5019 | | case C_THUMBEXT: | 5020 | | case C_THUMBEXTFUNC: | 5021 | | #endif | 5022 | | #ifdef RS6000COFF_C | 5023 | | case C_HIDEXT: | 5024 | | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 5025 | | case C_AIX_WEAKEXT: | 5026 | | #endif | 5027 | | #endif | 5028 | 776 | #ifdef C_SYSTEM | 5029 | 931 | case C_SYSTEM: | 5030 | 931 | #endif | 5031 | | #ifdef COFF_WITH_PE | 5032 | | case C_NT_WEAK: | 5033 | | #endif | 5034 | 931 | if (syment->n_scnum == 0) | 5035 | 102 | { | 5036 | 102 | if (syment->n_value == 0) | 5037 | 38 | return COFF_SYMBOL_UNDEFINED; | 5038 | 64 | else | 5039 | 64 | return COFF_SYMBOL_COMMON; | 5040 | 102 | } | 5041 | | #ifdef RS6000COFF_C | 5042 | | if (syment->n_sclass == C_HIDEXT) | 5043 | | return COFF_SYMBOL_LOCAL; | 5044 | | #endif | 5045 | 829 | return COFF_SYMBOL_GLOBAL; | 5046 | | | 5047 | 0 | default: | 5048 | 0 | break; | 5049 | 931 | } | 5050 | | | 5051 | | #ifdef COFF_WITH_PE | 5052 | | if (syment->n_sclass == C_STAT) | 5053 | | { | 5054 | | if (syment->n_scnum == 0) | 5055 | | /* The Microsoft compiler sometimes generates these if a | 5056 | | small static function is inlined every time it is used. | 5057 | | The function is discarded, but the symbol table entry | 5058 | | remains. */ | 5059 | | return COFF_SYMBOL_LOCAL; | 5060 | | | 5061 | | #ifdef STRICT_PE_FORMAT | 5062 | | /* This is correct for Microsoft generated objects, but it | 5063 | | breaks gas generated objects. */ | 5064 | | if (syment->n_value == 0) | 5065 | | { | 5066 | | const asection *sec; | 5067 | | const char *name; | 5068 | | char buf[SYMNMLEN + 1]; | 5069 | | | 5070 | | name = _bfd_coff_internal_syment_name (abfd, syment, buf); | 5071 | | sec = coff_section_from_bfd_index (abfd, syment->n_scnum); | 5072 | | if (sec != NULL && name != NULL | 5073 | | && (strcmp (bfd_section_name (sec), name) == 0)) | 5074 | | return COFF_SYMBOL_PE_SECTION; | 5075 | | } | 5076 | | #endif | 5077 | | | 5078 | | return COFF_SYMBOL_LOCAL; | 5079 | | } | 5080 | | | 5081 | | if (syment->n_sclass == C_SECTION) | 5082 | | { | 5083 | | /* In some cases in a DLL generated by the Microsoft linker, the | 5084 | | n_value field will contain garbage. FIXME: This should | 5085 | | probably be handled by the swapping function instead. */ | 5086 | | syment->n_value = 0; | 5087 | | if (syment->n_scnum == 0) | 5088 | | return COFF_SYMBOL_UNDEFINED; | 5089 | | return COFF_SYMBOL_PE_SECTION; | 5090 | | } | 5091 | | #endif /* COFF_WITH_PE */ | 5092 | | | 5093 | | /* If it is not a global symbol, we presume it is a local symbol. */ | 5094 | 0 | if (syment->n_scnum == 0) | 5095 | 0 | { | 5096 | 0 | char buf[SYMNMLEN + 1]; | 5097 | |
| 5098 | 0 | _bfd_error_handler | 5099 | | /* xgettext:c-format */ | 5100 | 0 | (_("warning: %pB: local symbol `%s' has no section"), | 5101 | 0 | abfd, _bfd_coff_internal_syment_name (abfd, syment, buf)); | 5102 | 0 | } | 5103 | |
| 5104 | 0 | return COFF_SYMBOL_LOCAL; | 5105 | 931 | } |
coff-z8k.c:coff_classify_symbol Line | Count | Source | 5011 | 562 | { | 5012 | | /* FIXME: This partially duplicates the switch in | 5013 | | coff_slurp_symbol_table. */ | 5014 | 562 | switch (syment->n_sclass) | 5015 | 562 | { | 5016 | 517 | case C_EXT: | 5017 | 532 | case C_WEAKEXT: | 5018 | | #ifdef ARM | 5019 | | case C_THUMBEXT: | 5020 | | case C_THUMBEXTFUNC: | 5021 | | #endif | 5022 | | #ifdef RS6000COFF_C | 5023 | | case C_HIDEXT: | 5024 | | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 5025 | | case C_AIX_WEAKEXT: | 5026 | | #endif | 5027 | | #endif | 5028 | 532 | #ifdef C_SYSTEM | 5029 | 562 | case C_SYSTEM: | 5030 | 562 | #endif | 5031 | | #ifdef COFF_WITH_PE | 5032 | | case C_NT_WEAK: | 5033 | | #endif | 5034 | 562 | if (syment->n_scnum == 0) | 5035 | 57 | { | 5036 | 57 | if (syment->n_value == 0) | 5037 | 13 | return COFF_SYMBOL_UNDEFINED; | 5038 | 44 | else | 5039 | 44 | return COFF_SYMBOL_COMMON; | 5040 | 57 | } | 5041 | | #ifdef RS6000COFF_C | 5042 | | if (syment->n_sclass == C_HIDEXT) | 5043 | | return COFF_SYMBOL_LOCAL; | 5044 | | #endif | 5045 | 505 | return COFF_SYMBOL_GLOBAL; | 5046 | | | 5047 | 0 | default: | 5048 | 0 | break; | 5049 | 562 | } | 5050 | | | 5051 | | #ifdef COFF_WITH_PE | 5052 | | if (syment->n_sclass == C_STAT) | 5053 | | { | 5054 | | if (syment->n_scnum == 0) | 5055 | | /* The Microsoft compiler sometimes generates these if a | 5056 | | small static function is inlined every time it is used. | 5057 | | The function is discarded, but the symbol table entry | 5058 | | remains. */ | 5059 | | return COFF_SYMBOL_LOCAL; | 5060 | | | 5061 | | #ifdef STRICT_PE_FORMAT | 5062 | | /* This is correct for Microsoft generated objects, but it | 5063 | | breaks gas generated objects. */ | 5064 | | if (syment->n_value == 0) | 5065 | | { | 5066 | | const asection *sec; | 5067 | | const char *name; | 5068 | | char buf[SYMNMLEN + 1]; | 5069 | | | 5070 | | name = _bfd_coff_internal_syment_name (abfd, syment, buf); | 5071 | | sec = coff_section_from_bfd_index (abfd, syment->n_scnum); | 5072 | | if (sec != NULL && name != NULL | 5073 | | && (strcmp (bfd_section_name (sec), name) == 0)) | 5074 | | return COFF_SYMBOL_PE_SECTION; | 5075 | | } | 5076 | | #endif | 5077 | | | 5078 | | return COFF_SYMBOL_LOCAL; | 5079 | | } | 5080 | | | 5081 | | if (syment->n_sclass == C_SECTION) | 5082 | | { | 5083 | | /* In some cases in a DLL generated by the Microsoft linker, the | 5084 | | n_value field will contain garbage. FIXME: This should | 5085 | | probably be handled by the swapping function instead. */ | 5086 | | syment->n_value = 0; | 5087 | | if (syment->n_scnum == 0) | 5088 | | return COFF_SYMBOL_UNDEFINED; | 5089 | | return COFF_SYMBOL_PE_SECTION; | 5090 | | } | 5091 | | #endif /* COFF_WITH_PE */ | 5092 | | | 5093 | | /* If it is not a global symbol, we presume it is a local symbol. */ | 5094 | 0 | if (syment->n_scnum == 0) | 5095 | 0 | { | 5096 | 0 | char buf[SYMNMLEN + 1]; | 5097 | |
| 5098 | 0 | _bfd_error_handler | 5099 | | /* xgettext:c-format */ | 5100 | 0 | (_("warning: %pB: local symbol `%s' has no section"), | 5101 | 0 | abfd, _bfd_coff_internal_syment_name (abfd, syment, buf)); | 5102 | 0 | } | 5103 | |
| 5104 | 0 | return COFF_SYMBOL_LOCAL; | 5105 | 562 | } |
Unexecuted instantiation: pe-arm-wince.c:coff_classify_symbol Unexecuted instantiation: pe-arm.c:coff_classify_symbol pe-i386.c:coff_classify_symbol Line | Count | Source | 5011 | 636 | { | 5012 | | /* FIXME: This partially duplicates the switch in | 5013 | | coff_slurp_symbol_table. */ | 5014 | 636 | switch (syment->n_sclass) | 5015 | 636 | { | 5016 | 486 | case C_EXT: | 5017 | 508 | case C_WEAKEXT: | 5018 | | #ifdef ARM | 5019 | | case C_THUMBEXT: | 5020 | | case C_THUMBEXTFUNC: | 5021 | | #endif | 5022 | | #ifdef RS6000COFF_C | 5023 | | case C_HIDEXT: | 5024 | | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 5025 | | case C_AIX_WEAKEXT: | 5026 | | #endif | 5027 | | #endif | 5028 | 508 | #ifdef C_SYSTEM | 5029 | 536 | case C_SYSTEM: | 5030 | 536 | #endif | 5031 | 536 | #ifdef COFF_WITH_PE | 5032 | 621 | case C_NT_WEAK: | 5033 | 621 | #endif | 5034 | 621 | if (syment->n_scnum == 0) | 5035 | 76 | { | 5036 | 76 | if (syment->n_value == 0) | 5037 | 26 | return COFF_SYMBOL_UNDEFINED; | 5038 | 50 | else | 5039 | 50 | return COFF_SYMBOL_COMMON; | 5040 | 76 | } | 5041 | | #ifdef RS6000COFF_C | 5042 | | if (syment->n_sclass == C_HIDEXT) | 5043 | | return COFF_SYMBOL_LOCAL; | 5044 | | #endif | 5045 | 545 | return COFF_SYMBOL_GLOBAL; | 5046 | | | 5047 | 15 | default: | 5048 | 15 | break; | 5049 | 636 | } | 5050 | | | 5051 | 15 | #ifdef COFF_WITH_PE | 5052 | 15 | if (syment->n_sclass == C_STAT) | 5053 | 0 | { | 5054 | 0 | if (syment->n_scnum == 0) | 5055 | | /* The Microsoft compiler sometimes generates these if a | 5056 | | small static function is inlined every time it is used. | 5057 | | The function is discarded, but the symbol table entry | 5058 | | remains. */ | 5059 | 0 | return COFF_SYMBOL_LOCAL; | 5060 | | | 5061 | | #ifdef STRICT_PE_FORMAT | 5062 | | /* This is correct for Microsoft generated objects, but it | 5063 | | breaks gas generated objects. */ | 5064 | | if (syment->n_value == 0) | 5065 | | { | 5066 | | const asection *sec; | 5067 | | const char *name; | 5068 | | char buf[SYMNMLEN + 1]; | 5069 | | | 5070 | | name = _bfd_coff_internal_syment_name (abfd, syment, buf); | 5071 | | sec = coff_section_from_bfd_index (abfd, syment->n_scnum); | 5072 | | if (sec != NULL && name != NULL | 5073 | | && (strcmp (bfd_section_name (sec), name) == 0)) | 5074 | | return COFF_SYMBOL_PE_SECTION; | 5075 | | } | 5076 | | #endif | 5077 | | | 5078 | 0 | return COFF_SYMBOL_LOCAL; | 5079 | 0 | } | 5080 | | | 5081 | 15 | if (syment->n_sclass == C_SECTION) | 5082 | 15 | { | 5083 | | /* In some cases in a DLL generated by the Microsoft linker, the | 5084 | | n_value field will contain garbage. FIXME: This should | 5085 | | probably be handled by the swapping function instead. */ | 5086 | 15 | syment->n_value = 0; | 5087 | 15 | if (syment->n_scnum == 0) | 5088 | 15 | return COFF_SYMBOL_UNDEFINED; | 5089 | 0 | return COFF_SYMBOL_PE_SECTION; | 5090 | 15 | } | 5091 | 0 | #endif /* COFF_WITH_PE */ | 5092 | | | 5093 | | /* If it is not a global symbol, we presume it is a local symbol. */ | 5094 | 0 | if (syment->n_scnum == 0) | 5095 | 0 | { | 5096 | 0 | char buf[SYMNMLEN + 1]; | 5097 | |
| 5098 | 0 | _bfd_error_handler | 5099 | | /* xgettext:c-format */ | 5100 | 0 | (_("warning: %pB: local symbol `%s' has no section"), | 5101 | 0 | abfd, _bfd_coff_internal_syment_name (abfd, syment, buf)); | 5102 | 0 | } | 5103 | |
| 5104 | 0 | return COFF_SYMBOL_LOCAL; | 5105 | 15 | } |
pe-mcore.c:coff_classify_symbol Line | Count | Source | 5011 | 1.06k | { | 5012 | | /* FIXME: This partially duplicates the switch in | 5013 | | coff_slurp_symbol_table. */ | 5014 | 1.06k | switch (syment->n_sclass) | 5015 | 1.06k | { | 5016 | 842 | case C_EXT: | 5017 | 923 | case C_WEAKEXT: | 5018 | | #ifdef ARM | 5019 | | case C_THUMBEXT: | 5020 | | case C_THUMBEXTFUNC: | 5021 | | #endif | 5022 | | #ifdef RS6000COFF_C | 5023 | | case C_HIDEXT: | 5024 | | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 5025 | | case C_AIX_WEAKEXT: | 5026 | | #endif | 5027 | | #endif | 5028 | 923 | #ifdef C_SYSTEM | 5029 | 961 | case C_SYSTEM: | 5030 | 961 | #endif | 5031 | 961 | #ifdef COFF_WITH_PE | 5032 | 1.05k | case C_NT_WEAK: | 5033 | 1.05k | #endif | 5034 | 1.05k | if (syment->n_scnum == 0) | 5035 | 89 | { | 5036 | 89 | if (syment->n_value == 0) | 5037 | 20 | return COFF_SYMBOL_UNDEFINED; | 5038 | 69 | else | 5039 | 69 | return COFF_SYMBOL_COMMON; | 5040 | 89 | } | 5041 | | #ifdef RS6000COFF_C | 5042 | | if (syment->n_sclass == C_HIDEXT) | 5043 | | return COFF_SYMBOL_LOCAL; | 5044 | | #endif | 5045 | 964 | return COFF_SYMBOL_GLOBAL; | 5046 | | | 5047 | 15 | default: | 5048 | 15 | break; | 5049 | 1.06k | } | 5050 | | | 5051 | 15 | #ifdef COFF_WITH_PE | 5052 | 15 | if (syment->n_sclass == C_STAT) | 5053 | 0 | { | 5054 | 0 | if (syment->n_scnum == 0) | 5055 | | /* The Microsoft compiler sometimes generates these if a | 5056 | | small static function is inlined every time it is used. | 5057 | | The function is discarded, but the symbol table entry | 5058 | | remains. */ | 5059 | 0 | return COFF_SYMBOL_LOCAL; | 5060 | | | 5061 | | #ifdef STRICT_PE_FORMAT | 5062 | | /* This is correct for Microsoft generated objects, but it | 5063 | | breaks gas generated objects. */ | 5064 | | if (syment->n_value == 0) | 5065 | | { | 5066 | | const asection *sec; | 5067 | | const char *name; | 5068 | | char buf[SYMNMLEN + 1]; | 5069 | | | 5070 | | name = _bfd_coff_internal_syment_name (abfd, syment, buf); | 5071 | | sec = coff_section_from_bfd_index (abfd, syment->n_scnum); | 5072 | | if (sec != NULL && name != NULL | 5073 | | && (strcmp (bfd_section_name (sec), name) == 0)) | 5074 | | return COFF_SYMBOL_PE_SECTION; | 5075 | | } | 5076 | | #endif | 5077 | | | 5078 | 0 | return COFF_SYMBOL_LOCAL; | 5079 | 0 | } | 5080 | | | 5081 | 15 | if (syment->n_sclass == C_SECTION) | 5082 | 15 | { | 5083 | | /* In some cases in a DLL generated by the Microsoft linker, the | 5084 | | n_value field will contain garbage. FIXME: This should | 5085 | | probably be handled by the swapping function instead. */ | 5086 | 15 | syment->n_value = 0; | 5087 | 15 | if (syment->n_scnum == 0) | 5088 | 15 | return COFF_SYMBOL_UNDEFINED; | 5089 | 0 | return COFF_SYMBOL_PE_SECTION; | 5090 | 15 | } | 5091 | 0 | #endif /* COFF_WITH_PE */ | 5092 | | | 5093 | | /* If it is not a global symbol, we presume it is a local symbol. */ | 5094 | 0 | if (syment->n_scnum == 0) | 5095 | 0 | { | 5096 | 0 | char buf[SYMNMLEN + 1]; | 5097 | |
| 5098 | 0 | _bfd_error_handler | 5099 | | /* xgettext:c-format */ | 5100 | 0 | (_("warning: %pB: local symbol `%s' has no section"), | 5101 | 0 | abfd, _bfd_coff_internal_syment_name (abfd, syment, buf)); | 5102 | 0 | } | 5103 | |
| 5104 | 0 | return COFF_SYMBOL_LOCAL; | 5105 | 15 | } |
pe-sh.c:coff_classify_symbol Line | Count | Source | 5011 | 952 | { | 5012 | | /* FIXME: This partially duplicates the switch in | 5013 | | coff_slurp_symbol_table. */ | 5014 | 952 | switch (syment->n_sclass) | 5015 | 952 | { | 5016 | 769 | case C_EXT: | 5017 | 863 | case C_WEAKEXT: | 5018 | | #ifdef ARM | 5019 | | case C_THUMBEXT: | 5020 | | case C_THUMBEXTFUNC: | 5021 | | #endif | 5022 | | #ifdef RS6000COFF_C | 5023 | | case C_HIDEXT: | 5024 | | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 5025 | | case C_AIX_WEAKEXT: | 5026 | | #endif | 5027 | | #endif | 5028 | 863 | #ifdef C_SYSTEM | 5029 | 897 | case C_SYSTEM: | 5030 | 897 | #endif | 5031 | 897 | #ifdef COFF_WITH_PE | 5032 | 950 | case C_NT_WEAK: | 5033 | 950 | #endif | 5034 | 950 | if (syment->n_scnum == 0) | 5035 | 55 | { | 5036 | 55 | if (syment->n_value == 0) | 5037 | 21 | return COFF_SYMBOL_UNDEFINED; | 5038 | 34 | else | 5039 | 34 | return COFF_SYMBOL_COMMON; | 5040 | 55 | } | 5041 | | #ifdef RS6000COFF_C | 5042 | | if (syment->n_sclass == C_HIDEXT) | 5043 | | return COFF_SYMBOL_LOCAL; | 5044 | | #endif | 5045 | 895 | return COFF_SYMBOL_GLOBAL; | 5046 | | | 5047 | 2 | default: | 5048 | 2 | break; | 5049 | 952 | } | 5050 | | | 5051 | 2 | #ifdef COFF_WITH_PE | 5052 | 2 | if (syment->n_sclass == C_STAT) | 5053 | 0 | { | 5054 | 0 | if (syment->n_scnum == 0) | 5055 | | /* The Microsoft compiler sometimes generates these if a | 5056 | | small static function is inlined every time it is used. | 5057 | | The function is discarded, but the symbol table entry | 5058 | | remains. */ | 5059 | 0 | return COFF_SYMBOL_LOCAL; | 5060 | | | 5061 | | #ifdef STRICT_PE_FORMAT | 5062 | | /* This is correct for Microsoft generated objects, but it | 5063 | | breaks gas generated objects. */ | 5064 | | if (syment->n_value == 0) | 5065 | | { | 5066 | | const asection *sec; | 5067 | | const char *name; | 5068 | | char buf[SYMNMLEN + 1]; | 5069 | | | 5070 | | name = _bfd_coff_internal_syment_name (abfd, syment, buf); | 5071 | | sec = coff_section_from_bfd_index (abfd, syment->n_scnum); | 5072 | | if (sec != NULL && name != NULL | 5073 | | && (strcmp (bfd_section_name (sec), name) == 0)) | 5074 | | return COFF_SYMBOL_PE_SECTION; | 5075 | | } | 5076 | | #endif | 5077 | | | 5078 | 0 | return COFF_SYMBOL_LOCAL; | 5079 | 0 | } | 5080 | | | 5081 | 2 | if (syment->n_sclass == C_SECTION) | 5082 | 2 | { | 5083 | | /* In some cases in a DLL generated by the Microsoft linker, the | 5084 | | n_value field will contain garbage. FIXME: This should | 5085 | | probably be handled by the swapping function instead. */ | 5086 | 2 | syment->n_value = 0; | 5087 | 2 | if (syment->n_scnum == 0) | 5088 | 2 | return COFF_SYMBOL_UNDEFINED; | 5089 | 0 | return COFF_SYMBOL_PE_SECTION; | 5090 | 2 | } | 5091 | 0 | #endif /* COFF_WITH_PE */ | 5092 | | | 5093 | | /* If it is not a global symbol, we presume it is a local symbol. */ | 5094 | 0 | if (syment->n_scnum == 0) | 5095 | 0 | { | 5096 | 0 | char buf[SYMNMLEN + 1]; | 5097 | |
| 5098 | 0 | _bfd_error_handler | 5099 | | /* xgettext:c-format */ | 5100 | 0 | (_("warning: %pB: local symbol `%s' has no section"), | 5101 | 0 | abfd, _bfd_coff_internal_syment_name (abfd, syment, buf)); | 5102 | 0 | } | 5103 | |
| 5104 | 0 | return COFF_SYMBOL_LOCAL; | 5105 | 2 | } |
pei-arm-wince.c:coff_classify_symbol Line | Count | Source | 5011 | 448 | { | 5012 | | /* FIXME: This partially duplicates the switch in | 5013 | | coff_slurp_symbol_table. */ | 5014 | 448 | switch (syment->n_sclass) | 5015 | 448 | { | 5016 | 267 | case C_EXT: | 5017 | 278 | case C_WEAKEXT: | 5018 | 278 | #ifdef ARM | 5019 | 293 | case C_THUMBEXT: | 5020 | 332 | case C_THUMBEXTFUNC: | 5021 | 332 | #endif | 5022 | | #ifdef RS6000COFF_C | 5023 | | case C_HIDEXT: | 5024 | | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 5025 | | case C_AIX_WEAKEXT: | 5026 | | #endif | 5027 | | #endif | 5028 | 332 | #ifdef C_SYSTEM | 5029 | 418 | case C_SYSTEM: | 5030 | 418 | #endif | 5031 | 418 | #ifdef COFF_WITH_PE | 5032 | 445 | case C_NT_WEAK: | 5033 | 445 | #endif | 5034 | 445 | if (syment->n_scnum == 0) | 5035 | 62 | { | 5036 | 62 | if (syment->n_value == 0) | 5037 | 17 | return COFF_SYMBOL_UNDEFINED; | 5038 | 45 | else | 5039 | 45 | return COFF_SYMBOL_COMMON; | 5040 | 62 | } | 5041 | | #ifdef RS6000COFF_C | 5042 | | if (syment->n_sclass == C_HIDEXT) | 5043 | | return COFF_SYMBOL_LOCAL; | 5044 | | #endif | 5045 | 383 | return COFF_SYMBOL_GLOBAL; | 5046 | | | 5047 | 3 | default: | 5048 | 3 | break; | 5049 | 448 | } | 5050 | | | 5051 | 3 | #ifdef COFF_WITH_PE | 5052 | 3 | if (syment->n_sclass == C_STAT) | 5053 | 0 | { | 5054 | 0 | if (syment->n_scnum == 0) | 5055 | | /* The Microsoft compiler sometimes generates these if a | 5056 | | small static function is inlined every time it is used. | 5057 | | The function is discarded, but the symbol table entry | 5058 | | remains. */ | 5059 | 0 | return COFF_SYMBOL_LOCAL; | 5060 | | | 5061 | | #ifdef STRICT_PE_FORMAT | 5062 | | /* This is correct for Microsoft generated objects, but it | 5063 | | breaks gas generated objects. */ | 5064 | | if (syment->n_value == 0) | 5065 | | { | 5066 | | const asection *sec; | 5067 | | const char *name; | 5068 | | char buf[SYMNMLEN + 1]; | 5069 | | | 5070 | | name = _bfd_coff_internal_syment_name (abfd, syment, buf); | 5071 | | sec = coff_section_from_bfd_index (abfd, syment->n_scnum); | 5072 | | if (sec != NULL && name != NULL | 5073 | | && (strcmp (bfd_section_name (sec), name) == 0)) | 5074 | | return COFF_SYMBOL_PE_SECTION; | 5075 | | } | 5076 | | #endif | 5077 | | | 5078 | 0 | return COFF_SYMBOL_LOCAL; | 5079 | 0 | } | 5080 | | | 5081 | 3 | if (syment->n_sclass == C_SECTION) | 5082 | 3 | { | 5083 | | /* In some cases in a DLL generated by the Microsoft linker, the | 5084 | | n_value field will contain garbage. FIXME: This should | 5085 | | probably be handled by the swapping function instead. */ | 5086 | 3 | syment->n_value = 0; | 5087 | 3 | if (syment->n_scnum == 0) | 5088 | 3 | return COFF_SYMBOL_UNDEFINED; | 5089 | 0 | return COFF_SYMBOL_PE_SECTION; | 5090 | 3 | } | 5091 | 0 | #endif /* COFF_WITH_PE */ | 5092 | | | 5093 | | /* If it is not a global symbol, we presume it is a local symbol. */ | 5094 | 0 | if (syment->n_scnum == 0) | 5095 | 0 | { | 5096 | 0 | char buf[SYMNMLEN + 1]; | 5097 | |
| 5098 | 0 | _bfd_error_handler | 5099 | | /* xgettext:c-format */ | 5100 | 0 | (_("warning: %pB: local symbol `%s' has no section"), | 5101 | 0 | abfd, _bfd_coff_internal_syment_name (abfd, syment, buf)); | 5102 | 0 | } | 5103 | |
| 5104 | 0 | return COFF_SYMBOL_LOCAL; | 5105 | 3 | } |
pei-arm.c:coff_classify_symbol Line | Count | Source | 5011 | 587 | { | 5012 | | /* FIXME: This partially duplicates the switch in | 5013 | | coff_slurp_symbol_table. */ | 5014 | 587 | switch (syment->n_sclass) | 5015 | 587 | { | 5016 | 347 | case C_EXT: | 5017 | 359 | case C_WEAKEXT: | 5018 | 359 | #ifdef ARM | 5019 | 374 | case C_THUMBEXT: | 5020 | 422 | case C_THUMBEXTFUNC: | 5021 | 422 | #endif | 5022 | | #ifdef RS6000COFF_C | 5023 | | case C_HIDEXT: | 5024 | | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 5025 | | case C_AIX_WEAKEXT: | 5026 | | #endif | 5027 | | #endif | 5028 | 422 | #ifdef C_SYSTEM | 5029 | 539 | case C_SYSTEM: | 5030 | 539 | #endif | 5031 | 539 | #ifdef COFF_WITH_PE | 5032 | 581 | case C_NT_WEAK: | 5033 | 581 | #endif | 5034 | 581 | if (syment->n_scnum == 0) | 5035 | 106 | { | 5036 | 106 | if (syment->n_value == 0) | 5037 | 61 | return COFF_SYMBOL_UNDEFINED; | 5038 | 45 | else | 5039 | 45 | return COFF_SYMBOL_COMMON; | 5040 | 106 | } | 5041 | | #ifdef RS6000COFF_C | 5042 | | if (syment->n_sclass == C_HIDEXT) | 5043 | | return COFF_SYMBOL_LOCAL; | 5044 | | #endif | 5045 | 475 | return COFF_SYMBOL_GLOBAL; | 5046 | | | 5047 | 6 | default: | 5048 | 6 | break; | 5049 | 587 | } | 5050 | | | 5051 | 6 | #ifdef COFF_WITH_PE | 5052 | 6 | if (syment->n_sclass == C_STAT) | 5053 | 0 | { | 5054 | 0 | if (syment->n_scnum == 0) | 5055 | | /* The Microsoft compiler sometimes generates these if a | 5056 | | small static function is inlined every time it is used. | 5057 | | The function is discarded, but the symbol table entry | 5058 | | remains. */ | 5059 | 0 | return COFF_SYMBOL_LOCAL; | 5060 | | | 5061 | | #ifdef STRICT_PE_FORMAT | 5062 | | /* This is correct for Microsoft generated objects, but it | 5063 | | breaks gas generated objects. */ | 5064 | | if (syment->n_value == 0) | 5065 | | { | 5066 | | const asection *sec; | 5067 | | const char *name; | 5068 | | char buf[SYMNMLEN + 1]; | 5069 | | | 5070 | | name = _bfd_coff_internal_syment_name (abfd, syment, buf); | 5071 | | sec = coff_section_from_bfd_index (abfd, syment->n_scnum); | 5072 | | if (sec != NULL && name != NULL | 5073 | | && (strcmp (bfd_section_name (sec), name) == 0)) | 5074 | | return COFF_SYMBOL_PE_SECTION; | 5075 | | } | 5076 | | #endif | 5077 | | | 5078 | 0 | return COFF_SYMBOL_LOCAL; | 5079 | 0 | } | 5080 | | | 5081 | 6 | if (syment->n_sclass == C_SECTION) | 5082 | 6 | { | 5083 | | /* In some cases in a DLL generated by the Microsoft linker, the | 5084 | | n_value field will contain garbage. FIXME: This should | 5085 | | probably be handled by the swapping function instead. */ | 5086 | 6 | syment->n_value = 0; | 5087 | 6 | if (syment->n_scnum == 0) | 5088 | 6 | return COFF_SYMBOL_UNDEFINED; | 5089 | 0 | return COFF_SYMBOL_PE_SECTION; | 5090 | 6 | } | 5091 | 0 | #endif /* COFF_WITH_PE */ | 5092 | | | 5093 | | /* If it is not a global symbol, we presume it is a local symbol. */ | 5094 | 0 | if (syment->n_scnum == 0) | 5095 | 0 | { | 5096 | 0 | char buf[SYMNMLEN + 1]; | 5097 | |
| 5098 | 0 | _bfd_error_handler | 5099 | | /* xgettext:c-format */ | 5100 | 0 | (_("warning: %pB: local symbol `%s' has no section"), | 5101 | 0 | abfd, _bfd_coff_internal_syment_name (abfd, syment, buf)); | 5102 | 0 | } | 5103 | |
| 5104 | 0 | return COFF_SYMBOL_LOCAL; | 5105 | 6 | } |
pei-mcore.c:coff_classify_symbol Line | Count | Source | 5011 | 4.33k | { | 5012 | | /* FIXME: This partially duplicates the switch in | 5013 | | coff_slurp_symbol_table. */ | 5014 | 4.33k | switch (syment->n_sclass) | 5015 | 4.33k | { | 5016 | 4.17k | case C_EXT: | 5017 | 4.19k | case C_WEAKEXT: | 5018 | | #ifdef ARM | 5019 | | case C_THUMBEXT: | 5020 | | case C_THUMBEXTFUNC: | 5021 | | #endif | 5022 | | #ifdef RS6000COFF_C | 5023 | | case C_HIDEXT: | 5024 | | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 5025 | | case C_AIX_WEAKEXT: | 5026 | | #endif | 5027 | | #endif | 5028 | 4.19k | #ifdef C_SYSTEM | 5029 | 4.26k | case C_SYSTEM: | 5030 | 4.26k | #endif | 5031 | 4.26k | #ifdef COFF_WITH_PE | 5032 | 4.30k | case C_NT_WEAK: | 5033 | 4.30k | #endif | 5034 | 4.30k | if (syment->n_scnum == 0) | 5035 | 93 | { | 5036 | 93 | if (syment->n_value == 0) | 5037 | 32 | return COFF_SYMBOL_UNDEFINED; | 5038 | 61 | else | 5039 | 61 | return COFF_SYMBOL_COMMON; | 5040 | 93 | } | 5041 | | #ifdef RS6000COFF_C | 5042 | | if (syment->n_sclass == C_HIDEXT) | 5043 | | return COFF_SYMBOL_LOCAL; | 5044 | | #endif | 5045 | 4.20k | return COFF_SYMBOL_GLOBAL; | 5046 | | | 5047 | 34 | default: | 5048 | 34 | break; | 5049 | 4.33k | } | 5050 | | | 5051 | 34 | #ifdef COFF_WITH_PE | 5052 | 34 | if (syment->n_sclass == C_STAT) | 5053 | 0 | { | 5054 | 0 | if (syment->n_scnum == 0) | 5055 | | /* The Microsoft compiler sometimes generates these if a | 5056 | | small static function is inlined every time it is used. | 5057 | | The function is discarded, but the symbol table entry | 5058 | | remains. */ | 5059 | 0 | return COFF_SYMBOL_LOCAL; | 5060 | | | 5061 | | #ifdef STRICT_PE_FORMAT | 5062 | | /* This is correct for Microsoft generated objects, but it | 5063 | | breaks gas generated objects. */ | 5064 | | if (syment->n_value == 0) | 5065 | | { | 5066 | | const asection *sec; | 5067 | | const char *name; | 5068 | | char buf[SYMNMLEN + 1]; | 5069 | | | 5070 | | name = _bfd_coff_internal_syment_name (abfd, syment, buf); | 5071 | | sec = coff_section_from_bfd_index (abfd, syment->n_scnum); | 5072 | | if (sec != NULL && name != NULL | 5073 | | && (strcmp (bfd_section_name (sec), name) == 0)) | 5074 | | return COFF_SYMBOL_PE_SECTION; | 5075 | | } | 5076 | | #endif | 5077 | | | 5078 | 0 | return COFF_SYMBOL_LOCAL; | 5079 | 0 | } | 5080 | | | 5081 | 34 | if (syment->n_sclass == C_SECTION) | 5082 | 34 | { | 5083 | | /* In some cases in a DLL generated by the Microsoft linker, the | 5084 | | n_value field will contain garbage. FIXME: This should | 5085 | | probably be handled by the swapping function instead. */ | 5086 | 34 | syment->n_value = 0; | 5087 | 34 | if (syment->n_scnum == 0) | 5088 | 34 | return COFF_SYMBOL_UNDEFINED; | 5089 | 0 | return COFF_SYMBOL_PE_SECTION; | 5090 | 34 | } | 5091 | 0 | #endif /* COFF_WITH_PE */ | 5092 | | | 5093 | | /* If it is not a global symbol, we presume it is a local symbol. */ | 5094 | 0 | if (syment->n_scnum == 0) | 5095 | 0 | { | 5096 | 0 | char buf[SYMNMLEN + 1]; | 5097 | |
| 5098 | 0 | _bfd_error_handler | 5099 | | /* xgettext:c-format */ | 5100 | 0 | (_("warning: %pB: local symbol `%s' has no section"), | 5101 | 0 | abfd, _bfd_coff_internal_syment_name (abfd, syment, buf)); | 5102 | 0 | } | 5103 | |
| 5104 | 0 | return COFF_SYMBOL_LOCAL; | 5105 | 34 | } |
pei-sh.c:coff_classify_symbol Line | Count | Source | 5011 | 3.19k | { | 5012 | | /* FIXME: This partially duplicates the switch in | 5013 | | coff_slurp_symbol_table. */ | 5014 | 3.19k | switch (syment->n_sclass) | 5015 | 3.19k | { | 5016 | 2.97k | case C_EXT: | 5017 | 3.01k | case C_WEAKEXT: | 5018 | | #ifdef ARM | 5019 | | case C_THUMBEXT: | 5020 | | case C_THUMBEXTFUNC: | 5021 | | #endif | 5022 | | #ifdef RS6000COFF_C | 5023 | | case C_HIDEXT: | 5024 | | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 5025 | | case C_AIX_WEAKEXT: | 5026 | | #endif | 5027 | | #endif | 5028 | 3.01k | #ifdef C_SYSTEM | 5029 | 3.09k | case C_SYSTEM: | 5030 | 3.09k | #endif | 5031 | 3.09k | #ifdef COFF_WITH_PE | 5032 | 3.17k | case C_NT_WEAK: | 5033 | 3.17k | #endif | 5034 | 3.17k | if (syment->n_scnum == 0) | 5035 | 157 | { | 5036 | 157 | if (syment->n_value == 0) | 5037 | 34 | return COFF_SYMBOL_UNDEFINED; | 5038 | 123 | else | 5039 | 123 | return COFF_SYMBOL_COMMON; | 5040 | 157 | } | 5041 | | #ifdef RS6000COFF_C | 5042 | | if (syment->n_sclass == C_HIDEXT) | 5043 | | return COFF_SYMBOL_LOCAL; | 5044 | | #endif | 5045 | 3.01k | return COFF_SYMBOL_GLOBAL; | 5046 | | | 5047 | 16 | default: | 5048 | 16 | break; | 5049 | 3.19k | } | 5050 | | | 5051 | 16 | #ifdef COFF_WITH_PE | 5052 | 16 | if (syment->n_sclass == C_STAT) | 5053 | 0 | { | 5054 | 0 | if (syment->n_scnum == 0) | 5055 | | /* The Microsoft compiler sometimes generates these if a | 5056 | | small static function is inlined every time it is used. | 5057 | | The function is discarded, but the symbol table entry | 5058 | | remains. */ | 5059 | 0 | return COFF_SYMBOL_LOCAL; | 5060 | | | 5061 | | #ifdef STRICT_PE_FORMAT | 5062 | | /* This is correct for Microsoft generated objects, but it | 5063 | | breaks gas generated objects. */ | 5064 | | if (syment->n_value == 0) | 5065 | | { | 5066 | | const asection *sec; | 5067 | | const char *name; | 5068 | | char buf[SYMNMLEN + 1]; | 5069 | | | 5070 | | name = _bfd_coff_internal_syment_name (abfd, syment, buf); | 5071 | | sec = coff_section_from_bfd_index (abfd, syment->n_scnum); | 5072 | | if (sec != NULL && name != NULL | 5073 | | && (strcmp (bfd_section_name (sec), name) == 0)) | 5074 | | return COFF_SYMBOL_PE_SECTION; | 5075 | | } | 5076 | | #endif | 5077 | | | 5078 | 0 | return COFF_SYMBOL_LOCAL; | 5079 | 0 | } | 5080 | | | 5081 | 16 | if (syment->n_sclass == C_SECTION) | 5082 | 16 | { | 5083 | | /* In some cases in a DLL generated by the Microsoft linker, the | 5084 | | n_value field will contain garbage. FIXME: This should | 5085 | | probably be handled by the swapping function instead. */ | 5086 | 16 | syment->n_value = 0; | 5087 | 16 | if (syment->n_scnum == 0) | 5088 | 16 | return COFF_SYMBOL_UNDEFINED; | 5089 | 0 | return COFF_SYMBOL_PE_SECTION; | 5090 | 16 | } | 5091 | 0 | #endif /* COFF_WITH_PE */ | 5092 | | | 5093 | | /* If it is not a global symbol, we presume it is a local symbol. */ | 5094 | 0 | if (syment->n_scnum == 0) | 5095 | 0 | { | 5096 | 0 | char buf[SYMNMLEN + 1]; | 5097 | |
| 5098 | 0 | _bfd_error_handler | 5099 | | /* xgettext:c-format */ | 5100 | 0 | (_("warning: %pB: local symbol `%s' has no section"), | 5101 | 0 | abfd, _bfd_coff_internal_syment_name (abfd, syment, buf)); | 5102 | 0 | } | 5103 | |
| 5104 | 0 | return COFF_SYMBOL_LOCAL; | 5105 | 16 | } |
|
5106 | | |
5107 | | /* |
5108 | | SUBSUBSECTION |
5109 | | Reading relocations |
5110 | | |
5111 | | Coff relocations are easily transformed into the internal BFD form |
5112 | | (@code{arelent}). |
5113 | | |
5114 | | Reading a coff relocation table is done in the following stages: |
5115 | | |
5116 | | o Read the entire coff relocation table into memory. |
5117 | | |
5118 | | o Process each relocation in turn; first swap it from the |
5119 | | external to the internal form. |
5120 | | |
5121 | | o Turn the symbol referenced in the relocation's symbol index |
5122 | | into a pointer into the canonical symbol table. |
5123 | | This table is the same as the one returned by a call to |
5124 | | @code{bfd_canonicalize_symtab}. The back end will call that |
5125 | | routine and save the result if a canonicalization hasn't been done. |
5126 | | |
5127 | | o The reloc index is turned into a pointer to a howto |
5128 | | structure, in a back end specific way. For instance, the 386 |
5129 | | uses the @code{r_type} to directly produce an index |
5130 | | into a howto table vector. |
5131 | | |
5132 | | o Note that @code{arelent.addend} for COFF is often not what |
5133 | | most people understand as a relocation addend, but rather an |
5134 | | adjustment to the relocation addend stored in section contents |
5135 | | of relocatable object files. The value found in section |
5136 | | contents may also be confusing, depending on both symbol value |
5137 | | and addend somewhat similar to the field value for a |
5138 | | final-linked object. See @code{CALC_ADDEND}. |
5139 | | */ |
5140 | | |
5141 | | #ifndef CALC_ADDEND |
5142 | | #define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \ |
5143 | 15.9k | { \ |
5144 | 15.9k | coff_symbol_type *coffsym = NULL; \ |
5145 | 15.9k | \ |
5146 | 15.9k | if (ptr && bfd_asymbol_bfd (ptr) != abfd) \ |
5147 | 15.9k | coffsym = (obj_symbols (abfd) \ |
5148 | 0 | + (cache_ptr->sym_ptr_ptr - symbols)); \ |
5149 | 15.9k | else if (ptr) \ |
5150 | 15.9k | coffsym = coff_symbol_from (ptr); \ |
5151 | 15.9k | if (coffsym != NULL \ |
5152 | 15.9k | && coffsym->native->is_sym \ |
5153 | 15.9k | && coffsym->native->u.syment.n_scnum == 0) \ |
5154 | 15.9k | cache_ptr->addend = 0; \ |
5155 | 15.9k | else if (ptr && bfd_asymbol_bfd (ptr) == abfd \ |
5156 | 1.09k | && ptr->section != NULL) \ |
5157 | 1.09k | cache_ptr->addend = - (ptr->section->vma + ptr->value); \ |
5158 | 1.09k | else \ |
5159 | 1.09k | cache_ptr->addend = 0; \ |
5160 | 15.9k | } |
5161 | | #endif |
5162 | | |
5163 | | static bool |
5164 | | coff_slurp_reloc_table (bfd * abfd, sec_ptr asect, asymbol ** symbols) |
5165 | 3.21k | { |
5166 | 3.21k | bfd_byte *native_relocs; |
5167 | 3.21k | arelent *reloc_cache; |
5168 | 3.21k | arelent *cache_ptr; |
5169 | 3.21k | unsigned int idx; |
5170 | 3.21k | size_t amt; |
5171 | | |
5172 | 3.21k | if (asect->relocation) |
5173 | 145 | return true; |
5174 | 3.06k | if (asect->reloc_count == 0) |
5175 | 0 | return true; |
5176 | 3.06k | if (asect->flags & SEC_CONSTRUCTOR) |
5177 | 0 | return true; |
5178 | 3.06k | if (!coff_slurp_symbol_table (abfd)) |
5179 | 0 | return false; |
5180 | | |
5181 | 3.06k | native_relocs = (bfd_byte *) buy_and_read (abfd, asect->rel_filepos, |
5182 | 3.06k | asect->reloc_count, |
5183 | 3.06k | bfd_coff_relsz (abfd)); |
5184 | 3.06k | if (native_relocs == NULL) |
5185 | 692 | return false; |
5186 | | |
5187 | 2.37k | if (_bfd_mul_overflow (asect->reloc_count, sizeof (arelent), &amt)) |
5188 | 0 | { |
5189 | 0 | bfd_set_error (bfd_error_file_too_big); |
5190 | 0 | return false; |
5191 | 0 | } |
5192 | 2.37k | reloc_cache = (arelent *) bfd_alloc (abfd, amt); |
5193 | 2.37k | if (reloc_cache == NULL) |
5194 | 0 | { |
5195 | 0 | free (native_relocs); |
5196 | 0 | return false; |
5197 | 0 | } |
5198 | | |
5199 | 233k | for (idx = 0; idx < asect->reloc_count; idx++) |
5200 | 232k | { |
5201 | 232k | struct internal_reloc dst; |
5202 | 232k | void *src; |
5203 | | #ifndef RELOC_PROCESSING |
5204 | | asymbol *ptr; |
5205 | | #endif |
5206 | | |
5207 | 232k | cache_ptr = reloc_cache + idx; |
5208 | 232k | src = native_relocs + idx * (size_t) bfd_coff_relsz (abfd); |
5209 | | |
5210 | 232k | dst.r_offset = 0; |
5211 | 232k | bfd_coff_swap_reloc_in (abfd, src, &dst); |
5212 | | |
5213 | | #ifdef RELOC_PROCESSING |
5214 | 14.7k | RELOC_PROCESSING (cache_ptr, &dst, symbols, abfd, asect); |
5215 | | #else |
5216 | | cache_ptr->address = dst.r_vaddr; |
5217 | | |
5218 | 218k | if (dst.r_symndx != -1 && symbols != NULL) |
5219 | 218k | { |
5220 | 218k | if (dst.r_symndx < 0 || dst.r_symndx >= obj_conv_table_size (abfd)) |
5221 | 3.17k | { |
5222 | 3.17k | _bfd_error_handler |
5223 | | /* xgettext:c-format */ |
5224 | 3.17k | (_("%pB: warning: illegal symbol index %ld in relocs"), |
5225 | 3.17k | abfd, dst.r_symndx); |
5226 | 3.17k | cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; |
5227 | 3.17k | ptr = NULL; |
5228 | 3.17k | } |
5229 | 214k | else |
5230 | 214k | { |
5231 | 214k | cache_ptr->sym_ptr_ptr = (symbols |
5232 | 214k | + obj_convert (abfd)[dst.r_symndx]); |
5233 | 214k | ptr = *(cache_ptr->sym_ptr_ptr); |
5234 | 214k | } |
5235 | 218k | } |
5236 | 154 | else |
5237 | 154 | { |
5238 | 154 | cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; |
5239 | 154 | ptr = NULL; |
5240 | 154 | } |
5241 | | |
5242 | | /* The symbols definitions that we have read in have been |
5243 | | relocated as if their sections started at 0. But the offsets |
5244 | | refering to the symbols in the raw data have not been |
5245 | | modified, so we have to have a negative addend to compensate. |
5246 | | |
5247 | | Note that symbols which used to be common must be left alone. */ |
5248 | | |
5249 | | /* Calculate any reloc addend by looking at the symbol. */ |
5250 | 218k | CALC_ADDEND (abfd, ptr, dst, cache_ptr); |
5251 | | (void) ptr; |
5252 | | |
5253 | | cache_ptr->address -= asect->vma; |
5254 | | /* !! cache_ptr->section = NULL;*/ |
5255 | | |
5256 | | /* Fill in the cache_ptr->howto field from dst.r_type. */ |
5257 | 218k | RTYPE2HOWTO (cache_ptr, &dst); |
5258 | | #endif /* RELOC_PROCESSING */ |
5259 | | |
5260 | 232k | if (cache_ptr->howto == NULL) |
5261 | 1.59k | { |
5262 | 1.59k | _bfd_error_handler |
5263 | | /* xgettext:c-format */ |
5264 | 1.59k | (_("%pB: illegal relocation type %d at address %#" PRIx64), |
5265 | 1.59k | abfd, dst.r_type, (uint64_t) dst.r_vaddr); |
5266 | 1.59k | bfd_set_error (bfd_error_bad_value); |
5267 | 1.59k | free (native_relocs); |
5268 | 1.59k | return false; |
5269 | 1.59k | } |
5270 | 232k | } |
5271 | | |
5272 | 784 | free (native_relocs); |
5273 | 784 | asect->relocation = reloc_cache; |
5274 | 784 | return true; |
5275 | 2.37k | } pei-i386.c:coff_slurp_reloc_table Line | Count | Source | 5165 | 23 | { | 5166 | 23 | bfd_byte *native_relocs; | 5167 | 23 | arelent *reloc_cache; | 5168 | 23 | arelent *cache_ptr; | 5169 | 23 | unsigned int idx; | 5170 | 23 | size_t amt; | 5171 | | | 5172 | 23 | if (asect->relocation) | 5173 | 23 | return true; | 5174 | 0 | if (asect->reloc_count == 0) | 5175 | 0 | return true; | 5176 | 0 | if (asect->flags & SEC_CONSTRUCTOR) | 5177 | 0 | return true; | 5178 | 0 | if (!coff_slurp_symbol_table (abfd)) | 5179 | 0 | return false; | 5180 | | | 5181 | 0 | native_relocs = (bfd_byte *) buy_and_read (abfd, asect->rel_filepos, | 5182 | 0 | asect->reloc_count, | 5183 | 0 | bfd_coff_relsz (abfd)); | 5184 | 0 | if (native_relocs == NULL) | 5185 | 0 | return false; | 5186 | | | 5187 | 0 | if (_bfd_mul_overflow (asect->reloc_count, sizeof (arelent), &amt)) | 5188 | 0 | { | 5189 | 0 | bfd_set_error (bfd_error_file_too_big); | 5190 | 0 | return false; | 5191 | 0 | } | 5192 | 0 | reloc_cache = (arelent *) bfd_alloc (abfd, amt); | 5193 | 0 | if (reloc_cache == NULL) | 5194 | 0 | { | 5195 | 0 | free (native_relocs); | 5196 | 0 | return false; | 5197 | 0 | } | 5198 | | | 5199 | 0 | for (idx = 0; idx < asect->reloc_count; idx++) | 5200 | 0 | { | 5201 | 0 | struct internal_reloc dst; | 5202 | 0 | void *src; | 5203 | 0 | #ifndef RELOC_PROCESSING | 5204 | 0 | asymbol *ptr; | 5205 | 0 | #endif | 5206 | |
| 5207 | 0 | cache_ptr = reloc_cache + idx; | 5208 | 0 | src = native_relocs + idx * (size_t) bfd_coff_relsz (abfd); | 5209 | |
| 5210 | 0 | dst.r_offset = 0; | 5211 | 0 | bfd_coff_swap_reloc_in (abfd, src, &dst); | 5212 | |
| 5213 | | #ifdef RELOC_PROCESSING | 5214 | | RELOC_PROCESSING (cache_ptr, &dst, symbols, abfd, asect); | 5215 | | #else | 5216 | 0 | cache_ptr->address = dst.r_vaddr; | 5217 | |
| 5218 | 0 | if (dst.r_symndx != -1 && symbols != NULL) | 5219 | 0 | { | 5220 | 0 | if (dst.r_symndx < 0 || dst.r_symndx >= obj_conv_table_size (abfd)) | 5221 | 0 | { | 5222 | 0 | _bfd_error_handler | 5223 | | /* xgettext:c-format */ | 5224 | 0 | (_("%pB: warning: illegal symbol index %ld in relocs"), | 5225 | 0 | abfd, dst.r_symndx); | 5226 | 0 | cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; | 5227 | 0 | ptr = NULL; | 5228 | 0 | } | 5229 | 0 | else | 5230 | 0 | { | 5231 | 0 | cache_ptr->sym_ptr_ptr = (symbols | 5232 | 0 | + obj_convert (abfd)[dst.r_symndx]); | 5233 | 0 | ptr = *(cache_ptr->sym_ptr_ptr); | 5234 | 0 | } | 5235 | 0 | } | 5236 | 0 | else | 5237 | 0 | { | 5238 | 0 | cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; | 5239 | 0 | ptr = NULL; | 5240 | 0 | } | 5241 | | | 5242 | | /* The symbols definitions that we have read in have been | 5243 | | relocated as if their sections started at 0. But the offsets | 5244 | | refering to the symbols in the raw data have not been | 5245 | | modified, so we have to have a negative addend to compensate. | 5246 | | | 5247 | | Note that symbols which used to be common must be left alone. */ | 5248 | | | 5249 | | /* Calculate any reloc addend by looking at the symbol. */ | 5250 | 0 | CALC_ADDEND (abfd, ptr, dst, cache_ptr); | 5251 | 0 | (void) ptr; | 5252 | |
| 5253 | 0 | cache_ptr->address -= asect->vma; | 5254 | | /* !! cache_ptr->section = NULL;*/ | 5255 | | | 5256 | | /* Fill in the cache_ptr->howto field from dst.r_type. */ | 5257 | 0 | RTYPE2HOWTO (cache_ptr, &dst); | 5258 | 0 | #endif /* RELOC_PROCESSING */ | 5259 | |
| 5260 | 0 | if (cache_ptr->howto == NULL) | 5261 | 0 | { | 5262 | 0 | _bfd_error_handler | 5263 | | /* xgettext:c-format */ | 5264 | 0 | (_("%pB: illegal relocation type %d at address %#" PRIx64), | 5265 | 0 | abfd, dst.r_type, (uint64_t) dst.r_vaddr); | 5266 | 0 | bfd_set_error (bfd_error_bad_value); | 5267 | 0 | free (native_relocs); | 5268 | 0 | return false; | 5269 | 0 | } | 5270 | 0 | } | 5271 | | | 5272 | 0 | free (native_relocs); | 5273 | 0 | asect->relocation = reloc_cache; | 5274 | 0 | return true; | 5275 | 0 | } |
pe-x86_64.c:coff_slurp_reloc_table Line | Count | Source | 5165 | 98 | { | 5166 | 98 | bfd_byte *native_relocs; | 5167 | 98 | arelent *reloc_cache; | 5168 | 98 | arelent *cache_ptr; | 5169 | 98 | unsigned int idx; | 5170 | 98 | size_t amt; | 5171 | | | 5172 | 98 | if (asect->relocation) | 5173 | 0 | return true; | 5174 | 98 | if (asect->reloc_count == 0) | 5175 | 0 | return true; | 5176 | 98 | if (asect->flags & SEC_CONSTRUCTOR) | 5177 | 0 | return true; | 5178 | 98 | if (!coff_slurp_symbol_table (abfd)) | 5179 | 0 | return false; | 5180 | | | 5181 | 98 | native_relocs = (bfd_byte *) buy_and_read (abfd, asect->rel_filepos, | 5182 | 98 | asect->reloc_count, | 5183 | 98 | bfd_coff_relsz (abfd)); | 5184 | 98 | if (native_relocs == NULL) | 5185 | 15 | return false; | 5186 | | | 5187 | 83 | if (_bfd_mul_overflow (asect->reloc_count, sizeof (arelent), &amt)) | 5188 | 0 | { | 5189 | 0 | bfd_set_error (bfd_error_file_too_big); | 5190 | 0 | return false; | 5191 | 0 | } | 5192 | 83 | reloc_cache = (arelent *) bfd_alloc (abfd, amt); | 5193 | 83 | if (reloc_cache == NULL) | 5194 | 0 | { | 5195 | 0 | free (native_relocs); | 5196 | 0 | return false; | 5197 | 0 | } | 5198 | | | 5199 | 4.39k | for (idx = 0; idx < asect->reloc_count; idx++) | 5200 | 4.35k | { | 5201 | 4.35k | struct internal_reloc dst; | 5202 | 4.35k | void *src; | 5203 | 4.35k | #ifndef RELOC_PROCESSING | 5204 | 4.35k | asymbol *ptr; | 5205 | 4.35k | #endif | 5206 | | | 5207 | 4.35k | cache_ptr = reloc_cache + idx; | 5208 | 4.35k | src = native_relocs + idx * (size_t) bfd_coff_relsz (abfd); | 5209 | | | 5210 | 4.35k | dst.r_offset = 0; | 5211 | 4.35k | bfd_coff_swap_reloc_in (abfd, src, &dst); | 5212 | | | 5213 | | #ifdef RELOC_PROCESSING | 5214 | | RELOC_PROCESSING (cache_ptr, &dst, symbols, abfd, asect); | 5215 | | #else | 5216 | 4.35k | cache_ptr->address = dst.r_vaddr; | 5217 | | | 5218 | 4.35k | if (dst.r_symndx != -1 && symbols != NULL) | 5219 | 4.32k | { | 5220 | 4.32k | if (dst.r_symndx < 0 || dst.r_symndx >= obj_conv_table_size (abfd)) | 5221 | 320 | { | 5222 | 320 | _bfd_error_handler | 5223 | | /* xgettext:c-format */ | 5224 | 320 | (_("%pB: warning: illegal symbol index %ld in relocs"), | 5225 | 320 | abfd, dst.r_symndx); | 5226 | 320 | cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; | 5227 | 320 | ptr = NULL; | 5228 | 320 | } | 5229 | 4.00k | else | 5230 | 4.00k | { | 5231 | 4.00k | cache_ptr->sym_ptr_ptr = (symbols | 5232 | 4.00k | + obj_convert (abfd)[dst.r_symndx]); | 5233 | 4.00k | ptr = *(cache_ptr->sym_ptr_ptr); | 5234 | 4.00k | } | 5235 | 4.32k | } | 5236 | 26 | else | 5237 | 26 | { | 5238 | 26 | cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; | 5239 | 26 | ptr = NULL; | 5240 | 26 | } | 5241 | | | 5242 | | /* The symbols definitions that we have read in have been | 5243 | | relocated as if their sections started at 0. But the offsets | 5244 | | refering to the symbols in the raw data have not been | 5245 | | modified, so we have to have a negative addend to compensate. | 5246 | | | 5247 | | Note that symbols which used to be common must be left alone. */ | 5248 | | | 5249 | | /* Calculate any reloc addend by looking at the symbol. */ | 5250 | 4.35k | CALC_ADDEND (abfd, ptr, dst, cache_ptr); | 5251 | 4.35k | (void) ptr; | 5252 | | | 5253 | 4.35k | cache_ptr->address -= asect->vma; | 5254 | | /* !! cache_ptr->section = NULL;*/ | 5255 | | | 5256 | | /* Fill in the cache_ptr->howto field from dst.r_type. */ | 5257 | 4.35k | RTYPE2HOWTO (cache_ptr, &dst); | 5258 | 4.35k | #endif /* RELOC_PROCESSING */ | 5259 | | | 5260 | 4.35k | if (cache_ptr->howto == NULL) | 5261 | 36 | { | 5262 | 36 | _bfd_error_handler | 5263 | | /* xgettext:c-format */ | 5264 | 36 | (_("%pB: illegal relocation type %d at address %#" PRIx64), | 5265 | 36 | abfd, dst.r_type, (uint64_t) dst.r_vaddr); | 5266 | 36 | bfd_set_error (bfd_error_bad_value); | 5267 | 36 | free (native_relocs); | 5268 | 36 | return false; | 5269 | 36 | } | 5270 | 4.35k | } | 5271 | | | 5272 | 47 | free (native_relocs); | 5273 | 47 | asect->relocation = reloc_cache; | 5274 | 47 | return true; | 5275 | 83 | } |
pei-x86_64.c:coff_slurp_reloc_table Line | Count | Source | 5165 | 17 | { | 5166 | 17 | bfd_byte *native_relocs; | 5167 | 17 | arelent *reloc_cache; | 5168 | 17 | arelent *cache_ptr; | 5169 | 17 | unsigned int idx; | 5170 | 17 | size_t amt; | 5171 | | | 5172 | 17 | if (asect->relocation) | 5173 | 17 | return true; | 5174 | 0 | if (asect->reloc_count == 0) | 5175 | 0 | return true; | 5176 | 0 | if (asect->flags & SEC_CONSTRUCTOR) | 5177 | 0 | return true; | 5178 | 0 | if (!coff_slurp_symbol_table (abfd)) | 5179 | 0 | return false; | 5180 | | | 5181 | 0 | native_relocs = (bfd_byte *) buy_and_read (abfd, asect->rel_filepos, | 5182 | 0 | asect->reloc_count, | 5183 | 0 | bfd_coff_relsz (abfd)); | 5184 | 0 | if (native_relocs == NULL) | 5185 | 0 | return false; | 5186 | | | 5187 | 0 | if (_bfd_mul_overflow (asect->reloc_count, sizeof (arelent), &amt)) | 5188 | 0 | { | 5189 | 0 | bfd_set_error (bfd_error_file_too_big); | 5190 | 0 | return false; | 5191 | 0 | } | 5192 | 0 | reloc_cache = (arelent *) bfd_alloc (abfd, amt); | 5193 | 0 | if (reloc_cache == NULL) | 5194 | 0 | { | 5195 | 0 | free (native_relocs); | 5196 | 0 | return false; | 5197 | 0 | } | 5198 | | | 5199 | 0 | for (idx = 0; idx < asect->reloc_count; idx++) | 5200 | 0 | { | 5201 | 0 | struct internal_reloc dst; | 5202 | 0 | void *src; | 5203 | 0 | #ifndef RELOC_PROCESSING | 5204 | 0 | asymbol *ptr; | 5205 | 0 | #endif | 5206 | |
| 5207 | 0 | cache_ptr = reloc_cache + idx; | 5208 | 0 | src = native_relocs + idx * (size_t) bfd_coff_relsz (abfd); | 5209 | |
| 5210 | 0 | dst.r_offset = 0; | 5211 | 0 | bfd_coff_swap_reloc_in (abfd, src, &dst); | 5212 | |
| 5213 | | #ifdef RELOC_PROCESSING | 5214 | | RELOC_PROCESSING (cache_ptr, &dst, symbols, abfd, asect); | 5215 | | #else | 5216 | 0 | cache_ptr->address = dst.r_vaddr; | 5217 | |
| 5218 | 0 | if (dst.r_symndx != -1 && symbols != NULL) | 5219 | 0 | { | 5220 | 0 | if (dst.r_symndx < 0 || dst.r_symndx >= obj_conv_table_size (abfd)) | 5221 | 0 | { | 5222 | 0 | _bfd_error_handler | 5223 | | /* xgettext:c-format */ | 5224 | 0 | (_("%pB: warning: illegal symbol index %ld in relocs"), | 5225 | 0 | abfd, dst.r_symndx); | 5226 | 0 | cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; | 5227 | 0 | ptr = NULL; | 5228 | 0 | } | 5229 | 0 | else | 5230 | 0 | { | 5231 | 0 | cache_ptr->sym_ptr_ptr = (symbols | 5232 | 0 | + obj_convert (abfd)[dst.r_symndx]); | 5233 | 0 | ptr = *(cache_ptr->sym_ptr_ptr); | 5234 | 0 | } | 5235 | 0 | } | 5236 | 0 | else | 5237 | 0 | { | 5238 | 0 | cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; | 5239 | 0 | ptr = NULL; | 5240 | 0 | } | 5241 | | | 5242 | | /* The symbols definitions that we have read in have been | 5243 | | relocated as if their sections started at 0. But the offsets | 5244 | | refering to the symbols in the raw data have not been | 5245 | | modified, so we have to have a negative addend to compensate. | 5246 | | | 5247 | | Note that symbols which used to be common must be left alone. */ | 5248 | | | 5249 | | /* Calculate any reloc addend by looking at the symbol. */ | 5250 | 0 | CALC_ADDEND (abfd, ptr, dst, cache_ptr); | 5251 | 0 | (void) ptr; | 5252 | |
| 5253 | 0 | cache_ptr->address -= asect->vma; | 5254 | | /* !! cache_ptr->section = NULL;*/ | 5255 | | | 5256 | | /* Fill in the cache_ptr->howto field from dst.r_type. */ | 5257 | 0 | RTYPE2HOWTO (cache_ptr, &dst); | 5258 | 0 | #endif /* RELOC_PROCESSING */ | 5259 | |
| 5260 | 0 | if (cache_ptr->howto == NULL) | 5261 | 0 | { | 5262 | 0 | _bfd_error_handler | 5263 | | /* xgettext:c-format */ | 5264 | 0 | (_("%pB: illegal relocation type %d at address %#" PRIx64), | 5265 | 0 | abfd, dst.r_type, (uint64_t) dst.r_vaddr); | 5266 | 0 | bfd_set_error (bfd_error_bad_value); | 5267 | 0 | free (native_relocs); | 5268 | 0 | return false; | 5269 | 0 | } | 5270 | 0 | } | 5271 | | | 5272 | 0 | free (native_relocs); | 5273 | 0 | asect->relocation = reloc_cache; | 5274 | 0 | return true; | 5275 | 0 | } |
coff-x86_64.c:coff_slurp_reloc_table Line | Count | Source | 5165 | 148 | { | 5166 | 148 | bfd_byte *native_relocs; | 5167 | 148 | arelent *reloc_cache; | 5168 | 148 | arelent *cache_ptr; | 5169 | 148 | unsigned int idx; | 5170 | 148 | size_t amt; | 5171 | | | 5172 | 148 | if (asect->relocation) | 5173 | 0 | return true; | 5174 | 148 | if (asect->reloc_count == 0) | 5175 | 0 | return true; | 5176 | 148 | if (asect->flags & SEC_CONSTRUCTOR) | 5177 | 0 | return true; | 5178 | 148 | if (!coff_slurp_symbol_table (abfd)) | 5179 | 0 | return false; | 5180 | | | 5181 | 148 | native_relocs = (bfd_byte *) buy_and_read (abfd, asect->rel_filepos, | 5182 | 148 | asect->reloc_count, | 5183 | 148 | bfd_coff_relsz (abfd)); | 5184 | 148 | if (native_relocs == NULL) | 5185 | 33 | return false; | 5186 | | | 5187 | 115 | if (_bfd_mul_overflow (asect->reloc_count, sizeof (arelent), &amt)) | 5188 | 0 | { | 5189 | 0 | bfd_set_error (bfd_error_file_too_big); | 5190 | 0 | return false; | 5191 | 0 | } | 5192 | 115 | reloc_cache = (arelent *) bfd_alloc (abfd, amt); | 5193 | 115 | if (reloc_cache == NULL) | 5194 | 0 | { | 5195 | 0 | free (native_relocs); | 5196 | 0 | return false; | 5197 | 0 | } | 5198 | | | 5199 | 4.88k | for (idx = 0; idx < asect->reloc_count; idx++) | 5200 | 4.83k | { | 5201 | 4.83k | struct internal_reloc dst; | 5202 | 4.83k | void *src; | 5203 | 4.83k | #ifndef RELOC_PROCESSING | 5204 | 4.83k | asymbol *ptr; | 5205 | 4.83k | #endif | 5206 | | | 5207 | 4.83k | cache_ptr = reloc_cache + idx; | 5208 | 4.83k | src = native_relocs + idx * (size_t) bfd_coff_relsz (abfd); | 5209 | | | 5210 | 4.83k | dst.r_offset = 0; | 5211 | 4.83k | bfd_coff_swap_reloc_in (abfd, src, &dst); | 5212 | | | 5213 | | #ifdef RELOC_PROCESSING | 5214 | | RELOC_PROCESSING (cache_ptr, &dst, symbols, abfd, asect); | 5215 | | #else | 5216 | 4.83k | cache_ptr->address = dst.r_vaddr; | 5217 | | | 5218 | 4.83k | if (dst.r_symndx != -1 && symbols != NULL) | 5219 | 4.81k | { | 5220 | 4.81k | if (dst.r_symndx < 0 || dst.r_symndx >= obj_conv_table_size (abfd)) | 5221 | 383 | { | 5222 | 383 | _bfd_error_handler | 5223 | | /* xgettext:c-format */ | 5224 | 383 | (_("%pB: warning: illegal symbol index %ld in relocs"), | 5225 | 383 | abfd, dst.r_symndx); | 5226 | 383 | cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; | 5227 | 383 | ptr = NULL; | 5228 | 383 | } | 5229 | 4.43k | else | 5230 | 4.43k | { | 5231 | 4.43k | cache_ptr->sym_ptr_ptr = (symbols | 5232 | 4.43k | + obj_convert (abfd)[dst.r_symndx]); | 5233 | 4.43k | ptr = *(cache_ptr->sym_ptr_ptr); | 5234 | 4.43k | } | 5235 | 4.81k | } | 5236 | 14 | else | 5237 | 14 | { | 5238 | 14 | cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; | 5239 | 14 | ptr = NULL; | 5240 | 14 | } | 5241 | | | 5242 | | /* The symbols definitions that we have read in have been | 5243 | | relocated as if their sections started at 0. But the offsets | 5244 | | refering to the symbols in the raw data have not been | 5245 | | modified, so we have to have a negative addend to compensate. | 5246 | | | 5247 | | Note that symbols which used to be common must be left alone. */ | 5248 | | | 5249 | | /* Calculate any reloc addend by looking at the symbol. */ | 5250 | 4.83k | CALC_ADDEND (abfd, ptr, dst, cache_ptr); | 5251 | 4.83k | (void) ptr; | 5252 | | | 5253 | 4.83k | cache_ptr->address -= asect->vma; | 5254 | | /* !! cache_ptr->section = NULL;*/ | 5255 | | | 5256 | | /* Fill in the cache_ptr->howto field from dst.r_type. */ | 5257 | 4.83k | RTYPE2HOWTO (cache_ptr, &dst); | 5258 | 4.83k | #endif /* RELOC_PROCESSING */ | 5259 | | | 5260 | 4.83k | if (cache_ptr->howto == NULL) | 5261 | 59 | { | 5262 | 59 | _bfd_error_handler | 5263 | | /* xgettext:c-format */ | 5264 | 59 | (_("%pB: illegal relocation type %d at address %#" PRIx64), | 5265 | 59 | abfd, dst.r_type, (uint64_t) dst.r_vaddr); | 5266 | 59 | bfd_set_error (bfd_error_bad_value); | 5267 | 59 | free (native_relocs); | 5268 | 59 | return false; | 5269 | 59 | } | 5270 | 4.83k | } | 5271 | | | 5272 | 56 | free (native_relocs); | 5273 | 56 | asect->relocation = reloc_cache; | 5274 | 56 | return true; | 5275 | 115 | } |
coff64-rs6000.c:coff_slurp_reloc_table Line | Count | Source | 5165 | 19 | { | 5166 | 19 | bfd_byte *native_relocs; | 5167 | 19 | arelent *reloc_cache; | 5168 | 19 | arelent *cache_ptr; | 5169 | 19 | unsigned int idx; | 5170 | 19 | size_t amt; | 5171 | | | 5172 | 19 | if (asect->relocation) | 5173 | 0 | return true; | 5174 | 19 | if (asect->reloc_count == 0) | 5175 | 0 | return true; | 5176 | 19 | if (asect->flags & SEC_CONSTRUCTOR) | 5177 | 0 | return true; | 5178 | 19 | if (!coff_slurp_symbol_table (abfd)) | 5179 | 0 | return false; | 5180 | | | 5181 | 19 | native_relocs = (bfd_byte *) buy_and_read (abfd, asect->rel_filepos, | 5182 | 19 | asect->reloc_count, | 5183 | 19 | bfd_coff_relsz (abfd)); | 5184 | 19 | if (native_relocs == NULL) | 5185 | 1 | return false; | 5186 | | | 5187 | 18 | if (_bfd_mul_overflow (asect->reloc_count, sizeof (arelent), &amt)) | 5188 | 0 | { | 5189 | 0 | bfd_set_error (bfd_error_file_too_big); | 5190 | 0 | return false; | 5191 | 0 | } | 5192 | 18 | reloc_cache = (arelent *) bfd_alloc (abfd, amt); | 5193 | 18 | if (reloc_cache == NULL) | 5194 | 0 | { | 5195 | 0 | free (native_relocs); | 5196 | 0 | return false; | 5197 | 0 | } | 5198 | | | 5199 | 90 | for (idx = 0; idx < asect->reloc_count; idx++) | 5200 | 72 | { | 5201 | 72 | struct internal_reloc dst; | 5202 | 72 | void *src; | 5203 | 72 | #ifndef RELOC_PROCESSING | 5204 | 72 | asymbol *ptr; | 5205 | 72 | #endif | 5206 | | | 5207 | 72 | cache_ptr = reloc_cache + idx; | 5208 | 72 | src = native_relocs + idx * (size_t) bfd_coff_relsz (abfd); | 5209 | | | 5210 | 72 | dst.r_offset = 0; | 5211 | 72 | bfd_coff_swap_reloc_in (abfd, src, &dst); | 5212 | | | 5213 | | #ifdef RELOC_PROCESSING | 5214 | | RELOC_PROCESSING (cache_ptr, &dst, symbols, abfd, asect); | 5215 | | #else | 5216 | 72 | cache_ptr->address = dst.r_vaddr; | 5217 | | | 5218 | 72 | if (dst.r_symndx != -1 && symbols != NULL) | 5219 | 72 | { | 5220 | 72 | if (dst.r_symndx < 0 || dst.r_symndx >= obj_conv_table_size (abfd)) | 5221 | 68 | { | 5222 | 68 | _bfd_error_handler | 5223 | | /* xgettext:c-format */ | 5224 | 68 | (_("%pB: warning: illegal symbol index %ld in relocs"), | 5225 | 68 | abfd, dst.r_symndx); | 5226 | 68 | cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; | 5227 | 68 | ptr = NULL; | 5228 | 68 | } | 5229 | 4 | else | 5230 | 4 | { | 5231 | 4 | cache_ptr->sym_ptr_ptr = (symbols | 5232 | 4 | + obj_convert (abfd)[dst.r_symndx]); | 5233 | 4 | ptr = *(cache_ptr->sym_ptr_ptr); | 5234 | 4 | } | 5235 | 72 | } | 5236 | 0 | else | 5237 | 0 | { | 5238 | 0 | cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; | 5239 | 0 | ptr = NULL; | 5240 | 0 | } | 5241 | | | 5242 | | /* The symbols definitions that we have read in have been | 5243 | | relocated as if their sections started at 0. But the offsets | 5244 | | refering to the symbols in the raw data have not been | 5245 | | modified, so we have to have a negative addend to compensate. | 5246 | | | 5247 | | Note that symbols which used to be common must be left alone. */ | 5248 | | | 5249 | | /* Calculate any reloc addend by looking at the symbol. */ | 5250 | 72 | CALC_ADDEND (abfd, ptr, dst, cache_ptr); | 5251 | 72 | (void) ptr; | 5252 | | | 5253 | 72 | cache_ptr->address -= asect->vma; | 5254 | | /* !! cache_ptr->section = NULL;*/ | 5255 | | | 5256 | | /* Fill in the cache_ptr->howto field from dst.r_type. */ | 5257 | 72 | RTYPE2HOWTO (cache_ptr, &dst); | 5258 | 72 | #endif /* RELOC_PROCESSING */ | 5259 | | | 5260 | 72 | if (cache_ptr->howto == NULL) | 5261 | 0 | { | 5262 | 0 | _bfd_error_handler | 5263 | | /* xgettext:c-format */ | 5264 | 0 | (_("%pB: illegal relocation type %d at address %#" PRIx64), | 5265 | 0 | abfd, dst.r_type, (uint64_t) dst.r_vaddr); | 5266 | 0 | bfd_set_error (bfd_error_bad_value); | 5267 | 0 | free (native_relocs); | 5268 | 0 | return false; | 5269 | 0 | } | 5270 | 72 | } | 5271 | | | 5272 | 18 | free (native_relocs); | 5273 | 18 | asect->relocation = reloc_cache; | 5274 | 18 | return true; | 5275 | 18 | } |
pei-aarch64.c:coff_slurp_reloc_table Line | Count | Source | 5165 | 15 | { | 5166 | 15 | bfd_byte *native_relocs; | 5167 | 15 | arelent *reloc_cache; | 5168 | 15 | arelent *cache_ptr; | 5169 | 15 | unsigned int idx; | 5170 | 15 | size_t amt; | 5171 | | | 5172 | 15 | if (asect->relocation) | 5173 | 15 | return true; | 5174 | 0 | if (asect->reloc_count == 0) | 5175 | 0 | return true; | 5176 | 0 | if (asect->flags & SEC_CONSTRUCTOR) | 5177 | 0 | return true; | 5178 | 0 | if (!coff_slurp_symbol_table (abfd)) | 5179 | 0 | return false; | 5180 | | | 5181 | 0 | native_relocs = (bfd_byte *) buy_and_read (abfd, asect->rel_filepos, | 5182 | 0 | asect->reloc_count, | 5183 | 0 | bfd_coff_relsz (abfd)); | 5184 | 0 | if (native_relocs == NULL) | 5185 | 0 | return false; | 5186 | | | 5187 | 0 | if (_bfd_mul_overflow (asect->reloc_count, sizeof (arelent), &amt)) | 5188 | 0 | { | 5189 | 0 | bfd_set_error (bfd_error_file_too_big); | 5190 | 0 | return false; | 5191 | 0 | } | 5192 | 0 | reloc_cache = (arelent *) bfd_alloc (abfd, amt); | 5193 | 0 | if (reloc_cache == NULL) | 5194 | 0 | { | 5195 | 0 | free (native_relocs); | 5196 | 0 | return false; | 5197 | 0 | } | 5198 | | | 5199 | 0 | for (idx = 0; idx < asect->reloc_count; idx++) | 5200 | 0 | { | 5201 | 0 | struct internal_reloc dst; | 5202 | 0 | void *src; | 5203 | 0 | #ifndef RELOC_PROCESSING | 5204 | 0 | asymbol *ptr; | 5205 | 0 | #endif | 5206 | |
| 5207 | 0 | cache_ptr = reloc_cache + idx; | 5208 | 0 | src = native_relocs + idx * (size_t) bfd_coff_relsz (abfd); | 5209 | |
| 5210 | 0 | dst.r_offset = 0; | 5211 | 0 | bfd_coff_swap_reloc_in (abfd, src, &dst); | 5212 | |
| 5213 | | #ifdef RELOC_PROCESSING | 5214 | | RELOC_PROCESSING (cache_ptr, &dst, symbols, abfd, asect); | 5215 | | #else | 5216 | 0 | cache_ptr->address = dst.r_vaddr; | 5217 | |
| 5218 | 0 | if (dst.r_symndx != -1 && symbols != NULL) | 5219 | 0 | { | 5220 | 0 | if (dst.r_symndx < 0 || dst.r_symndx >= obj_conv_table_size (abfd)) | 5221 | 0 | { | 5222 | 0 | _bfd_error_handler | 5223 | | /* xgettext:c-format */ | 5224 | 0 | (_("%pB: warning: illegal symbol index %ld in relocs"), | 5225 | 0 | abfd, dst.r_symndx); | 5226 | 0 | cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; | 5227 | 0 | ptr = NULL; | 5228 | 0 | } | 5229 | 0 | else | 5230 | 0 | { | 5231 | 0 | cache_ptr->sym_ptr_ptr = (symbols | 5232 | 0 | + obj_convert (abfd)[dst.r_symndx]); | 5233 | 0 | ptr = *(cache_ptr->sym_ptr_ptr); | 5234 | 0 | } | 5235 | 0 | } | 5236 | 0 | else | 5237 | 0 | { | 5238 | 0 | cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; | 5239 | 0 | ptr = NULL; | 5240 | 0 | } | 5241 | | | 5242 | | /* The symbols definitions that we have read in have been | 5243 | | relocated as if their sections started at 0. But the offsets | 5244 | | refering to the symbols in the raw data have not been | 5245 | | modified, so we have to have a negative addend to compensate. | 5246 | | | 5247 | | Note that symbols which used to be common must be left alone. */ | 5248 | | | 5249 | | /* Calculate any reloc addend by looking at the symbol. */ | 5250 | 0 | CALC_ADDEND (abfd, ptr, dst, cache_ptr); | 5251 | 0 | (void) ptr; | 5252 | |
| 5253 | 0 | cache_ptr->address -= asect->vma; | 5254 | | /* !! cache_ptr->section = NULL;*/ | 5255 | | | 5256 | | /* Fill in the cache_ptr->howto field from dst.r_type. */ | 5257 | 0 | RTYPE2HOWTO (cache_ptr, &dst); | 5258 | 0 | #endif /* RELOC_PROCESSING */ | 5259 | |
| 5260 | 0 | if (cache_ptr->howto == NULL) | 5261 | 0 | { | 5262 | 0 | _bfd_error_handler | 5263 | | /* xgettext:c-format */ | 5264 | 0 | (_("%pB: illegal relocation type %d at address %#" PRIx64), | 5265 | 0 | abfd, dst.r_type, (uint64_t) dst.r_vaddr); | 5266 | 0 | bfd_set_error (bfd_error_bad_value); | 5267 | 0 | free (native_relocs); | 5268 | 0 | return false; | 5269 | 0 | } | 5270 | 0 | } | 5271 | | | 5272 | 0 | free (native_relocs); | 5273 | 0 | asect->relocation = reloc_cache; | 5274 | 0 | return true; | 5275 | 0 | } |
pe-aarch64.c:coff_slurp_reloc_table Line | Count | Source | 5165 | 1.29k | { | 5166 | 1.29k | bfd_byte *native_relocs; | 5167 | 1.29k | arelent *reloc_cache; | 5168 | 1.29k | arelent *cache_ptr; | 5169 | 1.29k | unsigned int idx; | 5170 | 1.29k | size_t amt; | 5171 | | | 5172 | 1.29k | if (asect->relocation) | 5173 | 0 | return true; | 5174 | 1.29k | if (asect->reloc_count == 0) | 5175 | 0 | return true; | 5176 | 1.29k | if (asect->flags & SEC_CONSTRUCTOR) | 5177 | 0 | return true; | 5178 | 1.29k | if (!coff_slurp_symbol_table (abfd)) | 5179 | 0 | return false; | 5180 | | | 5181 | 1.29k | native_relocs = (bfd_byte *) buy_and_read (abfd, asect->rel_filepos, | 5182 | 1.29k | asect->reloc_count, | 5183 | 1.29k | bfd_coff_relsz (abfd)); | 5184 | 1.29k | if (native_relocs == NULL) | 5185 | 267 | return false; | 5186 | | | 5187 | 1.03k | if (_bfd_mul_overflow (asect->reloc_count, sizeof (arelent), &amt)) | 5188 | 0 | { | 5189 | 0 | bfd_set_error (bfd_error_file_too_big); | 5190 | 0 | return false; | 5191 | 0 | } | 5192 | 1.03k | reloc_cache = (arelent *) bfd_alloc (abfd, amt); | 5193 | 1.03k | if (reloc_cache == NULL) | 5194 | 0 | { | 5195 | 0 | free (native_relocs); | 5196 | 0 | return false; | 5197 | 0 | } | 5198 | | | 5199 | 11.3k | for (idx = 0; idx < asect->reloc_count; idx++) | 5200 | 10.9k | { | 5201 | 10.9k | struct internal_reloc dst; | 5202 | 10.9k | void *src; | 5203 | 10.9k | #ifndef RELOC_PROCESSING | 5204 | 10.9k | asymbol *ptr; | 5205 | 10.9k | #endif | 5206 | | | 5207 | 10.9k | cache_ptr = reloc_cache + idx; | 5208 | 10.9k | src = native_relocs + idx * (size_t) bfd_coff_relsz (abfd); | 5209 | | | 5210 | 10.9k | dst.r_offset = 0; | 5211 | 10.9k | bfd_coff_swap_reloc_in (abfd, src, &dst); | 5212 | | | 5213 | | #ifdef RELOC_PROCESSING | 5214 | | RELOC_PROCESSING (cache_ptr, &dst, symbols, abfd, asect); | 5215 | | #else | 5216 | 10.9k | cache_ptr->address = dst.r_vaddr; | 5217 | | | 5218 | 10.9k | if (dst.r_symndx != -1 && symbols != NULL) | 5219 | 10.9k | { | 5220 | 10.9k | if (dst.r_symndx < 0 || dst.r_symndx >= obj_conv_table_size (abfd)) | 5221 | 1.32k | { | 5222 | 1.32k | _bfd_error_handler | 5223 | | /* xgettext:c-format */ | 5224 | 1.32k | (_("%pB: warning: illegal symbol index %ld in relocs"), | 5225 | 1.32k | abfd, dst.r_symndx); | 5226 | 1.32k | cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; | 5227 | 1.32k | ptr = NULL; | 5228 | 1.32k | } | 5229 | 9.60k | else | 5230 | 9.60k | { | 5231 | 9.60k | cache_ptr->sym_ptr_ptr = (symbols | 5232 | 9.60k | + obj_convert (abfd)[dst.r_symndx]); | 5233 | 9.60k | ptr = *(cache_ptr->sym_ptr_ptr); | 5234 | 9.60k | } | 5235 | 10.9k | } | 5236 | 62 | else | 5237 | 62 | { | 5238 | 62 | cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; | 5239 | 62 | ptr = NULL; | 5240 | 62 | } | 5241 | | | 5242 | | /* The symbols definitions that we have read in have been | 5243 | | relocated as if their sections started at 0. But the offsets | 5244 | | refering to the symbols in the raw data have not been | 5245 | | modified, so we have to have a negative addend to compensate. | 5246 | | | 5247 | | Note that symbols which used to be common must be left alone. */ | 5248 | | | 5249 | | /* Calculate any reloc addend by looking at the symbol. */ | 5250 | 10.9k | CALC_ADDEND (abfd, ptr, dst, cache_ptr); | 5251 | 10.9k | (void) ptr; | 5252 | | | 5253 | 10.9k | cache_ptr->address -= asect->vma; | 5254 | | /* !! cache_ptr->section = NULL;*/ | 5255 | | | 5256 | | /* Fill in the cache_ptr->howto field from dst.r_type. */ | 5257 | 10.9k | RTYPE2HOWTO (cache_ptr, &dst); | 5258 | 10.9k | #endif /* RELOC_PROCESSING */ | 5259 | | | 5260 | 10.9k | if (cache_ptr->howto == NULL) | 5261 | 624 | { | 5262 | 624 | _bfd_error_handler | 5263 | | /* xgettext:c-format */ | 5264 | 624 | (_("%pB: illegal relocation type %d at address %#" PRIx64), | 5265 | 624 | abfd, dst.r_type, (uint64_t) dst.r_vaddr); | 5266 | 624 | bfd_set_error (bfd_error_bad_value); | 5267 | 624 | free (native_relocs); | 5268 | 624 | return false; | 5269 | 624 | } | 5270 | 10.9k | } | 5271 | | | 5272 | 406 | free (native_relocs); | 5273 | 406 | asect->relocation = reloc_cache; | 5274 | 406 | return true; | 5275 | 1.03k | } |
Unexecuted instantiation: pei-ia64.c:coff_slurp_reloc_table pei-loongarch64.c:coff_slurp_reloc_table Line | Count | Source | 5165 | 12 | { | 5166 | 12 | bfd_byte *native_relocs; | 5167 | 12 | arelent *reloc_cache; | 5168 | 12 | arelent *cache_ptr; | 5169 | 12 | unsigned int idx; | 5170 | 12 | size_t amt; | 5171 | | | 5172 | 12 | if (asect->relocation) | 5173 | 12 | return true; | 5174 | 0 | if (asect->reloc_count == 0) | 5175 | 0 | return true; | 5176 | 0 | if (asect->flags & SEC_CONSTRUCTOR) | 5177 | 0 | return true; | 5178 | 0 | if (!coff_slurp_symbol_table (abfd)) | 5179 | 0 | return false; | 5180 | | | 5181 | 0 | native_relocs = (bfd_byte *) buy_and_read (abfd, asect->rel_filepos, | 5182 | 0 | asect->reloc_count, | 5183 | 0 | bfd_coff_relsz (abfd)); | 5184 | 0 | if (native_relocs == NULL) | 5185 | 0 | return false; | 5186 | | | 5187 | 0 | if (_bfd_mul_overflow (asect->reloc_count, sizeof (arelent), &amt)) | 5188 | 0 | { | 5189 | 0 | bfd_set_error (bfd_error_file_too_big); | 5190 | 0 | return false; | 5191 | 0 | } | 5192 | 0 | reloc_cache = (arelent *) bfd_alloc (abfd, amt); | 5193 | 0 | if (reloc_cache == NULL) | 5194 | 0 | { | 5195 | 0 | free (native_relocs); | 5196 | 0 | return false; | 5197 | 0 | } | 5198 | | | 5199 | 0 | for (idx = 0; idx < asect->reloc_count; idx++) | 5200 | 0 | { | 5201 | 0 | struct internal_reloc dst; | 5202 | 0 | void *src; | 5203 | 0 | #ifndef RELOC_PROCESSING | 5204 | 0 | asymbol *ptr; | 5205 | 0 | #endif | 5206 | |
| 5207 | 0 | cache_ptr = reloc_cache + idx; | 5208 | 0 | src = native_relocs + idx * (size_t) bfd_coff_relsz (abfd); | 5209 | |
| 5210 | 0 | dst.r_offset = 0; | 5211 | 0 | bfd_coff_swap_reloc_in (abfd, src, &dst); | 5212 | |
| 5213 | | #ifdef RELOC_PROCESSING | 5214 | | RELOC_PROCESSING (cache_ptr, &dst, symbols, abfd, asect); | 5215 | | #else | 5216 | 0 | cache_ptr->address = dst.r_vaddr; | 5217 | |
| 5218 | 0 | if (dst.r_symndx != -1 && symbols != NULL) | 5219 | 0 | { | 5220 | 0 | if (dst.r_symndx < 0 || dst.r_symndx >= obj_conv_table_size (abfd)) | 5221 | 0 | { | 5222 | 0 | _bfd_error_handler | 5223 | | /* xgettext:c-format */ | 5224 | 0 | (_("%pB: warning: illegal symbol index %ld in relocs"), | 5225 | 0 | abfd, dst.r_symndx); | 5226 | 0 | cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; | 5227 | 0 | ptr = NULL; | 5228 | 0 | } | 5229 | 0 | else | 5230 | 0 | { | 5231 | 0 | cache_ptr->sym_ptr_ptr = (symbols | 5232 | 0 | + obj_convert (abfd)[dst.r_symndx]); | 5233 | 0 | ptr = *(cache_ptr->sym_ptr_ptr); | 5234 | 0 | } | 5235 | 0 | } | 5236 | 0 | else | 5237 | 0 | { | 5238 | 0 | cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; | 5239 | 0 | ptr = NULL; | 5240 | 0 | } | 5241 | | | 5242 | | /* The symbols definitions that we have read in have been | 5243 | | relocated as if their sections started at 0. But the offsets | 5244 | | refering to the symbols in the raw data have not been | 5245 | | modified, so we have to have a negative addend to compensate. | 5246 | | | 5247 | | Note that symbols which used to be common must be left alone. */ | 5248 | | | 5249 | | /* Calculate any reloc addend by looking at the symbol. */ | 5250 | 0 | CALC_ADDEND (abfd, ptr, dst, cache_ptr); | 5251 | 0 | (void) ptr; | 5252 | |
| 5253 | 0 | cache_ptr->address -= asect->vma; | 5254 | | /* !! cache_ptr->section = NULL;*/ | 5255 | | | 5256 | | /* Fill in the cache_ptr->howto field from dst.r_type. */ | 5257 | 0 | RTYPE2HOWTO (cache_ptr, &dst); | 5258 | 0 | #endif /* RELOC_PROCESSING */ | 5259 | |
| 5260 | 0 | if (cache_ptr->howto == NULL) | 5261 | 0 | { | 5262 | 0 | _bfd_error_handler | 5263 | | /* xgettext:c-format */ | 5264 | 0 | (_("%pB: illegal relocation type %d at address %#" PRIx64), | 5265 | 0 | abfd, dst.r_type, (uint64_t) dst.r_vaddr); | 5266 | 0 | bfd_set_error (bfd_error_bad_value); | 5267 | 0 | free (native_relocs); | 5268 | 0 | return false; | 5269 | 0 | } | 5270 | 0 | } | 5271 | | | 5272 | 0 | free (native_relocs); | 5273 | 0 | asect->relocation = reloc_cache; | 5274 | 0 | return true; | 5275 | 0 | } |
Unexecuted instantiation: cf-i386lynx.c:coff_slurp_reloc_table Unexecuted instantiation: coff-go32.c:coff_slurp_reloc_table Unexecuted instantiation: coff-i386.c:coff_slurp_reloc_table coff-rs6000.c:coff_slurp_reloc_table Line | Count | Source | 5165 | 13 | { | 5166 | 13 | bfd_byte *native_relocs; | 5167 | 13 | arelent *reloc_cache; | 5168 | 13 | arelent *cache_ptr; | 5169 | 13 | unsigned int idx; | 5170 | 13 | size_t amt; | 5171 | | | 5172 | 13 | if (asect->relocation) | 5173 | 0 | return true; | 5174 | 13 | if (asect->reloc_count == 0) | 5175 | 0 | return true; | 5176 | 13 | if (asect->flags & SEC_CONSTRUCTOR) | 5177 | 0 | return true; | 5178 | 13 | if (!coff_slurp_symbol_table (abfd)) | 5179 | 0 | return false; | 5180 | | | 5181 | 13 | native_relocs = (bfd_byte *) buy_and_read (abfd, asect->rel_filepos, | 5182 | 13 | asect->reloc_count, | 5183 | 13 | bfd_coff_relsz (abfd)); | 5184 | 13 | if (native_relocs == NULL) | 5185 | 1 | return false; | 5186 | | | 5187 | 12 | if (_bfd_mul_overflow (asect->reloc_count, sizeof (arelent), &amt)) | 5188 | 0 | { | 5189 | 0 | bfd_set_error (bfd_error_file_too_big); | 5190 | 0 | return false; | 5191 | 0 | } | 5192 | 12 | reloc_cache = (arelent *) bfd_alloc (abfd, amt); | 5193 | 12 | if (reloc_cache == NULL) | 5194 | 0 | { | 5195 | 0 | free (native_relocs); | 5196 | 0 | return false; | 5197 | 0 | } | 5198 | | | 5199 | 213 | for (idx = 0; idx < asect->reloc_count; idx++) | 5200 | 201 | { | 5201 | 201 | struct internal_reloc dst; | 5202 | 201 | void *src; | 5203 | 201 | #ifndef RELOC_PROCESSING | 5204 | 201 | asymbol *ptr; | 5205 | 201 | #endif | 5206 | | | 5207 | 201 | cache_ptr = reloc_cache + idx; | 5208 | 201 | src = native_relocs + idx * (size_t) bfd_coff_relsz (abfd); | 5209 | | | 5210 | 201 | dst.r_offset = 0; | 5211 | 201 | bfd_coff_swap_reloc_in (abfd, src, &dst); | 5212 | | | 5213 | | #ifdef RELOC_PROCESSING | 5214 | | RELOC_PROCESSING (cache_ptr, &dst, symbols, abfd, asect); | 5215 | | #else | 5216 | 201 | cache_ptr->address = dst.r_vaddr; | 5217 | | | 5218 | 201 | if (dst.r_symndx != -1 && symbols != NULL) | 5219 | 201 | { | 5220 | 201 | if (dst.r_symndx < 0 || dst.r_symndx >= obj_conv_table_size (abfd)) | 5221 | 194 | { | 5222 | 194 | _bfd_error_handler | 5223 | | /* xgettext:c-format */ | 5224 | 194 | (_("%pB: warning: illegal symbol index %ld in relocs"), | 5225 | 194 | abfd, dst.r_symndx); | 5226 | 194 | cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; | 5227 | 194 | ptr = NULL; | 5228 | 194 | } | 5229 | 7 | else | 5230 | 7 | { | 5231 | 7 | cache_ptr->sym_ptr_ptr = (symbols | 5232 | 7 | + obj_convert (abfd)[dst.r_symndx]); | 5233 | 7 | ptr = *(cache_ptr->sym_ptr_ptr); | 5234 | 7 | } | 5235 | 201 | } | 5236 | 0 | else | 5237 | 0 | { | 5238 | 0 | cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; | 5239 | 0 | ptr = NULL; | 5240 | 0 | } | 5241 | | | 5242 | | /* The symbols definitions that we have read in have been | 5243 | | relocated as if their sections started at 0. But the offsets | 5244 | | refering to the symbols in the raw data have not been | 5245 | | modified, so we have to have a negative addend to compensate. | 5246 | | | 5247 | | Note that symbols which used to be common must be left alone. */ | 5248 | | | 5249 | | /* Calculate any reloc addend by looking at the symbol. */ | 5250 | 201 | CALC_ADDEND (abfd, ptr, dst, cache_ptr); | 5251 | 201 | (void) ptr; | 5252 | | | 5253 | 201 | cache_ptr->address -= asect->vma; | 5254 | | /* !! cache_ptr->section = NULL;*/ | 5255 | | | 5256 | | /* Fill in the cache_ptr->howto field from dst.r_type. */ | 5257 | 201 | RTYPE2HOWTO (cache_ptr, &dst); | 5258 | 201 | #endif /* RELOC_PROCESSING */ | 5259 | | | 5260 | 201 | if (cache_ptr->howto == NULL) | 5261 | 0 | { | 5262 | 0 | _bfd_error_handler | 5263 | | /* xgettext:c-format */ | 5264 | 0 | (_("%pB: illegal relocation type %d at address %#" PRIx64), | 5265 | 0 | abfd, dst.r_type, (uint64_t) dst.r_vaddr); | 5266 | 0 | bfd_set_error (bfd_error_bad_value); | 5267 | 0 | free (native_relocs); | 5268 | 0 | return false; | 5269 | 0 | } | 5270 | 201 | } | 5271 | | | 5272 | 12 | free (native_relocs); | 5273 | 12 | asect->relocation = reloc_cache; | 5274 | 12 | return true; | 5275 | 12 | } |
Unexecuted instantiation: coff-sh.c:coff_slurp_reloc_table Unexecuted instantiation: coff-stgo32.c:coff_slurp_reloc_table coff-tic30.c:coff_slurp_reloc_table Line | Count | Source | 5165 | 663 | { | 5166 | 663 | bfd_byte *native_relocs; | 5167 | 663 | arelent *reloc_cache; | 5168 | 663 | arelent *cache_ptr; | 5169 | 663 | unsigned int idx; | 5170 | 663 | size_t amt; | 5171 | | | 5172 | 663 | if (asect->relocation) | 5173 | 0 | return true; | 5174 | 663 | if (asect->reloc_count == 0) | 5175 | 0 | return true; | 5176 | 663 | if (asect->flags & SEC_CONSTRUCTOR) | 5177 | 0 | return true; | 5178 | 663 | if (!coff_slurp_symbol_table (abfd)) | 5179 | 0 | return false; | 5180 | | | 5181 | 663 | native_relocs = (bfd_byte *) buy_and_read (abfd, asect->rel_filepos, | 5182 | 663 | asect->reloc_count, | 5183 | 663 | bfd_coff_relsz (abfd)); | 5184 | 663 | if (native_relocs == NULL) | 5185 | 167 | return false; | 5186 | | | 5187 | 496 | if (_bfd_mul_overflow (asect->reloc_count, sizeof (arelent), &amt)) | 5188 | 0 | { | 5189 | 0 | bfd_set_error (bfd_error_file_too_big); | 5190 | 0 | return false; | 5191 | 0 | } | 5192 | 496 | reloc_cache = (arelent *) bfd_alloc (abfd, amt); | 5193 | 496 | if (reloc_cache == NULL) | 5194 | 0 | { | 5195 | 0 | free (native_relocs); | 5196 | 0 | return false; | 5197 | 0 | } | 5198 | | | 5199 | 10.8k | for (idx = 0; idx < asect->reloc_count; idx++) | 5200 | 10.7k | { | 5201 | 10.7k | struct internal_reloc dst; | 5202 | 10.7k | void *src; | 5203 | | #ifndef RELOC_PROCESSING | 5204 | | asymbol *ptr; | 5205 | | #endif | 5206 | | | 5207 | 10.7k | cache_ptr = reloc_cache + idx; | 5208 | 10.7k | src = native_relocs + idx * (size_t) bfd_coff_relsz (abfd); | 5209 | | | 5210 | 10.7k | dst.r_offset = 0; | 5211 | 10.7k | bfd_coff_swap_reloc_in (abfd, src, &dst); | 5212 | | | 5213 | 10.7k | #ifdef RELOC_PROCESSING | 5214 | 10.7k | RELOC_PROCESSING (cache_ptr, &dst, symbols, abfd, asect); | 5215 | | #else | 5216 | | cache_ptr->address = dst.r_vaddr; | 5217 | | | 5218 | | if (dst.r_symndx != -1 && symbols != NULL) | 5219 | | { | 5220 | | if (dst.r_symndx < 0 || dst.r_symndx >= obj_conv_table_size (abfd)) | 5221 | | { | 5222 | | _bfd_error_handler | 5223 | | /* xgettext:c-format */ | 5224 | | (_("%pB: warning: illegal symbol index %ld in relocs"), | 5225 | | abfd, dst.r_symndx); | 5226 | | cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; | 5227 | | ptr = NULL; | 5228 | | } | 5229 | | else | 5230 | | { | 5231 | | cache_ptr->sym_ptr_ptr = (symbols | 5232 | | + obj_convert (abfd)[dst.r_symndx]); | 5233 | | ptr = *(cache_ptr->sym_ptr_ptr); | 5234 | | } | 5235 | | } | 5236 | | else | 5237 | | { | 5238 | | cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; | 5239 | | ptr = NULL; | 5240 | | } | 5241 | | | 5242 | | /* The symbols definitions that we have read in have been | 5243 | | relocated as if their sections started at 0. But the offsets | 5244 | | refering to the symbols in the raw data have not been | 5245 | | modified, so we have to have a negative addend to compensate. | 5246 | | | 5247 | | Note that symbols which used to be common must be left alone. */ | 5248 | | | 5249 | | /* Calculate any reloc addend by looking at the symbol. */ | 5250 | | CALC_ADDEND (abfd, ptr, dst, cache_ptr); | 5251 | | (void) ptr; | 5252 | | | 5253 | | cache_ptr->address -= asect->vma; | 5254 | | /* !! cache_ptr->section = NULL;*/ | 5255 | | | 5256 | | /* Fill in the cache_ptr->howto field from dst.r_type. */ | 5257 | | RTYPE2HOWTO (cache_ptr, &dst); | 5258 | | #endif /* RELOC_PROCESSING */ | 5259 | | | 5260 | 10.7k | if (cache_ptr->howto == NULL) | 5261 | 468 | { | 5262 | 468 | _bfd_error_handler | 5263 | | /* xgettext:c-format */ | 5264 | 468 | (_("%pB: illegal relocation type %d at address %#" PRIx64), | 5265 | 468 | abfd, dst.r_type, (uint64_t) dst.r_vaddr); | 5266 | 468 | bfd_set_error (bfd_error_bad_value); | 5267 | 468 | free (native_relocs); | 5268 | 468 | return false; | 5269 | 468 | } | 5270 | 10.7k | } | 5271 | | | 5272 | 28 | free (native_relocs); | 5273 | 28 | asect->relocation = reloc_cache; | 5274 | 28 | return true; | 5275 | 496 | } |
Unexecuted instantiation: coff-tic4x.c:coff_slurp_reloc_table coff-tic54x.c:coff_slurp_reloc_table Line | Count | Source | 5165 | 75 | { | 5166 | 75 | bfd_byte *native_relocs; | 5167 | 75 | arelent *reloc_cache; | 5168 | 75 | arelent *cache_ptr; | 5169 | 75 | unsigned int idx; | 5170 | 75 | size_t amt; | 5171 | | | 5172 | 75 | if (asect->relocation) | 5173 | 0 | return true; | 5174 | 75 | if (asect->reloc_count == 0) | 5175 | 0 | return true; | 5176 | 75 | if (asect->flags & SEC_CONSTRUCTOR) | 5177 | 0 | return true; | 5178 | 75 | if (!coff_slurp_symbol_table (abfd)) | 5179 | 0 | return false; | 5180 | | | 5181 | 75 | native_relocs = (bfd_byte *) buy_and_read (abfd, asect->rel_filepos, | 5182 | 75 | asect->reloc_count, | 5183 | 75 | bfd_coff_relsz (abfd)); | 5184 | 75 | if (native_relocs == NULL) | 5185 | 23 | return false; | 5186 | | | 5187 | 52 | if (_bfd_mul_overflow (asect->reloc_count, sizeof (arelent), &amt)) | 5188 | 0 | { | 5189 | 0 | bfd_set_error (bfd_error_file_too_big); | 5190 | 0 | return false; | 5191 | 0 | } | 5192 | 52 | reloc_cache = (arelent *) bfd_alloc (abfd, amt); | 5193 | 52 | if (reloc_cache == NULL) | 5194 | 0 | { | 5195 | 0 | free (native_relocs); | 5196 | 0 | return false; | 5197 | 0 | } | 5198 | | | 5199 | 115 | for (idx = 0; idx < asect->reloc_count; idx++) | 5200 | 105 | { | 5201 | 105 | struct internal_reloc dst; | 5202 | 105 | void *src; | 5203 | | #ifndef RELOC_PROCESSING | 5204 | | asymbol *ptr; | 5205 | | #endif | 5206 | | | 5207 | 105 | cache_ptr = reloc_cache + idx; | 5208 | 105 | src = native_relocs + idx * (size_t) bfd_coff_relsz (abfd); | 5209 | | | 5210 | 105 | dst.r_offset = 0; | 5211 | 105 | bfd_coff_swap_reloc_in (abfd, src, &dst); | 5212 | | | 5213 | 105 | #ifdef RELOC_PROCESSING | 5214 | 105 | RELOC_PROCESSING (cache_ptr, &dst, symbols, abfd, asect); | 5215 | | #else | 5216 | | cache_ptr->address = dst.r_vaddr; | 5217 | | | 5218 | | if (dst.r_symndx != -1 && symbols != NULL) | 5219 | | { | 5220 | | if (dst.r_symndx < 0 || dst.r_symndx >= obj_conv_table_size (abfd)) | 5221 | | { | 5222 | | _bfd_error_handler | 5223 | | /* xgettext:c-format */ | 5224 | | (_("%pB: warning: illegal symbol index %ld in relocs"), | 5225 | | abfd, dst.r_symndx); | 5226 | | cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; | 5227 | | ptr = NULL; | 5228 | | } | 5229 | | else | 5230 | | { | 5231 | | cache_ptr->sym_ptr_ptr = (symbols | 5232 | | + obj_convert (abfd)[dst.r_symndx]); | 5233 | | ptr = *(cache_ptr->sym_ptr_ptr); | 5234 | | } | 5235 | | } | 5236 | | else | 5237 | | { | 5238 | | cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; | 5239 | | ptr = NULL; | 5240 | | } | 5241 | | | 5242 | | /* The symbols definitions that we have read in have been | 5243 | | relocated as if their sections started at 0. But the offsets | 5244 | | refering to the symbols in the raw data have not been | 5245 | | modified, so we have to have a negative addend to compensate. | 5246 | | | 5247 | | Note that symbols which used to be common must be left alone. */ | 5248 | | | 5249 | | /* Calculate any reloc addend by looking at the symbol. */ | 5250 | | CALC_ADDEND (abfd, ptr, dst, cache_ptr); | 5251 | | (void) ptr; | 5252 | | | 5253 | | cache_ptr->address -= asect->vma; | 5254 | | /* !! cache_ptr->section = NULL;*/ | 5255 | | | 5256 | | /* Fill in the cache_ptr->howto field from dst.r_type. */ | 5257 | | RTYPE2HOWTO (cache_ptr, &dst); | 5258 | | #endif /* RELOC_PROCESSING */ | 5259 | | | 5260 | 105 | if (cache_ptr->howto == NULL) | 5261 | 42 | { | 5262 | 42 | _bfd_error_handler | 5263 | | /* xgettext:c-format */ | 5264 | 42 | (_("%pB: illegal relocation type %d at address %#" PRIx64), | 5265 | 42 | abfd, dst.r_type, (uint64_t) dst.r_vaddr); | 5266 | 42 | bfd_set_error (bfd_error_bad_value); | 5267 | 42 | free (native_relocs); | 5268 | 42 | return false; | 5269 | 42 | } | 5270 | 105 | } | 5271 | | | 5272 | 10 | free (native_relocs); | 5273 | 10 | asect->relocation = reloc_cache; | 5274 | 10 | return true; | 5275 | 52 | } |
coff-z80.c:coff_slurp_reloc_table Line | Count | Source | 5165 | 282 | { | 5166 | 282 | bfd_byte *native_relocs; | 5167 | 282 | arelent *reloc_cache; | 5168 | 282 | arelent *cache_ptr; | 5169 | 282 | unsigned int idx; | 5170 | 282 | size_t amt; | 5171 | | | 5172 | 282 | if (asect->relocation) | 5173 | 0 | return true; | 5174 | 282 | if (asect->reloc_count == 0) | 5175 | 0 | return true; | 5176 | 282 | if (asect->flags & SEC_CONSTRUCTOR) | 5177 | 0 | return true; | 5178 | 282 | if (!coff_slurp_symbol_table (abfd)) | 5179 | 0 | return false; | 5180 | | | 5181 | 282 | native_relocs = (bfd_byte *) buy_and_read (abfd, asect->rel_filepos, | 5182 | 282 | asect->reloc_count, | 5183 | 282 | bfd_coff_relsz (abfd)); | 5184 | 282 | if (native_relocs == NULL) | 5185 | 100 | return false; | 5186 | | | 5187 | 182 | if (_bfd_mul_overflow (asect->reloc_count, sizeof (arelent), &amt)) | 5188 | 0 | { | 5189 | 0 | bfd_set_error (bfd_error_file_too_big); | 5190 | 0 | return false; | 5191 | 0 | } | 5192 | 182 | reloc_cache = (arelent *) bfd_alloc (abfd, amt); | 5193 | 182 | if (reloc_cache == NULL) | 5194 | 0 | { | 5195 | 0 | free (native_relocs); | 5196 | 0 | return false; | 5197 | 0 | } | 5198 | | | 5199 | 3.88k | for (idx = 0; idx < asect->reloc_count; idx++) | 5200 | 3.81k | { | 5201 | 3.81k | struct internal_reloc dst; | 5202 | 3.81k | void *src; | 5203 | | #ifndef RELOC_PROCESSING | 5204 | | asymbol *ptr; | 5205 | | #endif | 5206 | | | 5207 | 3.81k | cache_ptr = reloc_cache + idx; | 5208 | 3.81k | src = native_relocs + idx * (size_t) bfd_coff_relsz (abfd); | 5209 | | | 5210 | 3.81k | dst.r_offset = 0; | 5211 | 3.81k | bfd_coff_swap_reloc_in (abfd, src, &dst); | 5212 | | | 5213 | 3.81k | #ifdef RELOC_PROCESSING | 5214 | 3.81k | RELOC_PROCESSING (cache_ptr, &dst, symbols, abfd, asect); | 5215 | | #else | 5216 | | cache_ptr->address = dst.r_vaddr; | 5217 | | | 5218 | | if (dst.r_symndx != -1 && symbols != NULL) | 5219 | | { | 5220 | | if (dst.r_symndx < 0 || dst.r_symndx >= obj_conv_table_size (abfd)) | 5221 | | { | 5222 | | _bfd_error_handler | 5223 | | /* xgettext:c-format */ | 5224 | | (_("%pB: warning: illegal symbol index %ld in relocs"), | 5225 | | abfd, dst.r_symndx); | 5226 | | cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; | 5227 | | ptr = NULL; | 5228 | | } | 5229 | | else | 5230 | | { | 5231 | | cache_ptr->sym_ptr_ptr = (symbols | 5232 | | + obj_convert (abfd)[dst.r_symndx]); | 5233 | | ptr = *(cache_ptr->sym_ptr_ptr); | 5234 | | } | 5235 | | } | 5236 | | else | 5237 | | { | 5238 | | cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; | 5239 | | ptr = NULL; | 5240 | | } | 5241 | | | 5242 | | /* The symbols definitions that we have read in have been | 5243 | | relocated as if their sections started at 0. But the offsets | 5244 | | refering to the symbols in the raw data have not been | 5245 | | modified, so we have to have a negative addend to compensate. | 5246 | | | 5247 | | Note that symbols which used to be common must be left alone. */ | 5248 | | | 5249 | | /* Calculate any reloc addend by looking at the symbol. */ | 5250 | | CALC_ADDEND (abfd, ptr, dst, cache_ptr); | 5251 | | (void) ptr; | 5252 | | | 5253 | | cache_ptr->address -= asect->vma; | 5254 | | /* !! cache_ptr->section = NULL;*/ | 5255 | | | 5256 | | /* Fill in the cache_ptr->howto field from dst.r_type. */ | 5257 | | RTYPE2HOWTO (cache_ptr, &dst); | 5258 | | #endif /* RELOC_PROCESSING */ | 5259 | | | 5260 | 3.81k | if (cache_ptr->howto == NULL) | 5261 | 108 | { | 5262 | 108 | _bfd_error_handler | 5263 | | /* xgettext:c-format */ | 5264 | 108 | (_("%pB: illegal relocation type %d at address %#" PRIx64), | 5265 | 108 | abfd, dst.r_type, (uint64_t) dst.r_vaddr); | 5266 | 108 | bfd_set_error (bfd_error_bad_value); | 5267 | 108 | free (native_relocs); | 5268 | 108 | return false; | 5269 | 108 | } | 5270 | 3.81k | } | 5271 | | | 5272 | 74 | free (native_relocs); | 5273 | 74 | asect->relocation = reloc_cache; | 5274 | 74 | return true; | 5275 | 182 | } |
coff-z8k.c:coff_slurp_reloc_table Line | Count | Source | 5165 | 82 | { | 5166 | 82 | bfd_byte *native_relocs; | 5167 | 82 | arelent *reloc_cache; | 5168 | 82 | arelent *cache_ptr; | 5169 | 82 | unsigned int idx; | 5170 | 82 | size_t amt; | 5171 | | | 5172 | 82 | if (asect->relocation) | 5173 | 0 | return true; | 5174 | 82 | if (asect->reloc_count == 0) | 5175 | 0 | return true; | 5176 | 82 | if (asect->flags & SEC_CONSTRUCTOR) | 5177 | 0 | return true; | 5178 | 82 | if (!coff_slurp_symbol_table (abfd)) | 5179 | 0 | return false; | 5180 | | | 5181 | 82 | native_relocs = (bfd_byte *) buy_and_read (abfd, asect->rel_filepos, | 5182 | 82 | asect->reloc_count, | 5183 | 82 | bfd_coff_relsz (abfd)); | 5184 | 82 | if (native_relocs == NULL) | 5185 | 27 | return false; | 5186 | | | 5187 | 55 | if (_bfd_mul_overflow (asect->reloc_count, sizeof (arelent), &amt)) | 5188 | 0 | { | 5189 | 0 | bfd_set_error (bfd_error_file_too_big); | 5190 | 0 | return false; | 5191 | 0 | } | 5192 | 55 | reloc_cache = (arelent *) bfd_alloc (abfd, amt); | 5193 | 55 | if (reloc_cache == NULL) | 5194 | 0 | { | 5195 | 0 | free (native_relocs); | 5196 | 0 | return false; | 5197 | 0 | } | 5198 | | | 5199 | 78 | for (idx = 0; idx < asect->reloc_count; idx++) | 5200 | 71 | { | 5201 | 71 | struct internal_reloc dst; | 5202 | 71 | void *src; | 5203 | | #ifndef RELOC_PROCESSING | 5204 | | asymbol *ptr; | 5205 | | #endif | 5206 | | | 5207 | 71 | cache_ptr = reloc_cache + idx; | 5208 | 71 | src = native_relocs + idx * (size_t) bfd_coff_relsz (abfd); | 5209 | | | 5210 | 71 | dst.r_offset = 0; | 5211 | 71 | bfd_coff_swap_reloc_in (abfd, src, &dst); | 5212 | | | 5213 | 71 | #ifdef RELOC_PROCESSING | 5214 | 71 | RELOC_PROCESSING (cache_ptr, &dst, symbols, abfd, asect); | 5215 | | #else | 5216 | | cache_ptr->address = dst.r_vaddr; | 5217 | | | 5218 | | if (dst.r_symndx != -1 && symbols != NULL) | 5219 | | { | 5220 | | if (dst.r_symndx < 0 || dst.r_symndx >= obj_conv_table_size (abfd)) | 5221 | | { | 5222 | | _bfd_error_handler | 5223 | | /* xgettext:c-format */ | 5224 | | (_("%pB: warning: illegal symbol index %ld in relocs"), | 5225 | | abfd, dst.r_symndx); | 5226 | | cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; | 5227 | | ptr = NULL; | 5228 | | } | 5229 | | else | 5230 | | { | 5231 | | cache_ptr->sym_ptr_ptr = (symbols | 5232 | | + obj_convert (abfd)[dst.r_symndx]); | 5233 | | ptr = *(cache_ptr->sym_ptr_ptr); | 5234 | | } | 5235 | | } | 5236 | | else | 5237 | | { | 5238 | | cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; | 5239 | | ptr = NULL; | 5240 | | } | 5241 | | | 5242 | | /* The symbols definitions that we have read in have been | 5243 | | relocated as if their sections started at 0. But the offsets | 5244 | | refering to the symbols in the raw data have not been | 5245 | | modified, so we have to have a negative addend to compensate. | 5246 | | | 5247 | | Note that symbols which used to be common must be left alone. */ | 5248 | | | 5249 | | /* Calculate any reloc addend by looking at the symbol. */ | 5250 | | CALC_ADDEND (abfd, ptr, dst, cache_ptr); | 5251 | | (void) ptr; | 5252 | | | 5253 | | cache_ptr->address -= asect->vma; | 5254 | | /* !! cache_ptr->section = NULL;*/ | 5255 | | | 5256 | | /* Fill in the cache_ptr->howto field from dst.r_type. */ | 5257 | | RTYPE2HOWTO (cache_ptr, &dst); | 5258 | | #endif /* RELOC_PROCESSING */ | 5259 | | | 5260 | 71 | if (cache_ptr->howto == NULL) | 5261 | 48 | { | 5262 | 48 | _bfd_error_handler | 5263 | | /* xgettext:c-format */ | 5264 | 48 | (_("%pB: illegal relocation type %d at address %#" PRIx64), | 5265 | 48 | abfd, dst.r_type, (uint64_t) dst.r_vaddr); | 5266 | 48 | bfd_set_error (bfd_error_bad_value); | 5267 | 48 | free (native_relocs); | 5268 | 48 | return false; | 5269 | 48 | } | 5270 | 71 | } | 5271 | | | 5272 | 7 | free (native_relocs); | 5273 | 7 | asect->relocation = reloc_cache; | 5274 | 7 | return true; | 5275 | 55 | } |
Unexecuted instantiation: pe-arm-wince.c:coff_slurp_reloc_table Unexecuted instantiation: pe-arm.c:coff_slurp_reloc_table pe-i386.c:coff_slurp_reloc_table Line | Count | Source | 5165 | 122 | { | 5166 | 122 | bfd_byte *native_relocs; | 5167 | 122 | arelent *reloc_cache; | 5168 | 122 | arelent *cache_ptr; | 5169 | 122 | unsigned int idx; | 5170 | 122 | size_t amt; | 5171 | | | 5172 | 122 | if (asect->relocation) | 5173 | 0 | return true; | 5174 | 122 | if (asect->reloc_count == 0) | 5175 | 0 | return true; | 5176 | 122 | if (asect->flags & SEC_CONSTRUCTOR) | 5177 | 0 | return true; | 5178 | 122 | if (!coff_slurp_symbol_table (abfd)) | 5179 | 0 | return false; | 5180 | | | 5181 | 122 | native_relocs = (bfd_byte *) buy_and_read (abfd, asect->rel_filepos, | 5182 | 122 | asect->reloc_count, | 5183 | 122 | bfd_coff_relsz (abfd)); | 5184 | 122 | if (native_relocs == NULL) | 5185 | 20 | return false; | 5186 | | | 5187 | 102 | if (_bfd_mul_overflow (asect->reloc_count, sizeof (arelent), &amt)) | 5188 | 0 | { | 5189 | 0 | bfd_set_error (bfd_error_file_too_big); | 5190 | 0 | return false; | 5191 | 0 | } | 5192 | 102 | reloc_cache = (arelent *) bfd_alloc (abfd, amt); | 5193 | 102 | if (reloc_cache == NULL) | 5194 | 0 | { | 5195 | 0 | free (native_relocs); | 5196 | 0 | return false; | 5197 | 0 | } | 5198 | | | 5199 | 176k | for (idx = 0; idx < asect->reloc_count; idx++) | 5200 | 176k | { | 5201 | 176k | struct internal_reloc dst; | 5202 | 176k | void *src; | 5203 | 176k | #ifndef RELOC_PROCESSING | 5204 | 176k | asymbol *ptr; | 5205 | 176k | #endif | 5206 | | | 5207 | 176k | cache_ptr = reloc_cache + idx; | 5208 | 176k | src = native_relocs + idx * (size_t) bfd_coff_relsz (abfd); | 5209 | | | 5210 | 176k | dst.r_offset = 0; | 5211 | 176k | bfd_coff_swap_reloc_in (abfd, src, &dst); | 5212 | | | 5213 | | #ifdef RELOC_PROCESSING | 5214 | | RELOC_PROCESSING (cache_ptr, &dst, symbols, abfd, asect); | 5215 | | #else | 5216 | 176k | cache_ptr->address = dst.r_vaddr; | 5217 | | | 5218 | 176k | if (dst.r_symndx != -1 && symbols != NULL) | 5219 | 176k | { | 5220 | 176k | if (dst.r_symndx < 0 || dst.r_symndx >= obj_conv_table_size (abfd)) | 5221 | 341 | { | 5222 | 341 | _bfd_error_handler | 5223 | | /* xgettext:c-format */ | 5224 | 341 | (_("%pB: warning: illegal symbol index %ld in relocs"), | 5225 | 341 | abfd, dst.r_symndx); | 5226 | 341 | cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; | 5227 | 341 | ptr = NULL; | 5228 | 341 | } | 5229 | 176k | else | 5230 | 176k | { | 5231 | 176k | cache_ptr->sym_ptr_ptr = (symbols | 5232 | 176k | + obj_convert (abfd)[dst.r_symndx]); | 5233 | 176k | ptr = *(cache_ptr->sym_ptr_ptr); | 5234 | 176k | } | 5235 | 176k | } | 5236 | 7 | else | 5237 | 7 | { | 5238 | 7 | cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; | 5239 | 7 | ptr = NULL; | 5240 | 7 | } | 5241 | | | 5242 | | /* The symbols definitions that we have read in have been | 5243 | | relocated as if their sections started at 0. But the offsets | 5244 | | refering to the symbols in the raw data have not been | 5245 | | modified, so we have to have a negative addend to compensate. | 5246 | | | 5247 | | Note that symbols which used to be common must be left alone. */ | 5248 | | | 5249 | | /* Calculate any reloc addend by looking at the symbol. */ | 5250 | 176k | CALC_ADDEND (abfd, ptr, dst, cache_ptr); | 5251 | 176k | (void) ptr; | 5252 | | | 5253 | 176k | cache_ptr->address -= asect->vma; | 5254 | | /* !! cache_ptr->section = NULL;*/ | 5255 | | | 5256 | | /* Fill in the cache_ptr->howto field from dst.r_type. */ | 5257 | 176k | RTYPE2HOWTO (cache_ptr, &dst); | 5258 | 176k | #endif /* RELOC_PROCESSING */ | 5259 | | | 5260 | 176k | if (cache_ptr->howto == NULL) | 5261 | 79 | { | 5262 | 79 | _bfd_error_handler | 5263 | | /* xgettext:c-format */ | 5264 | 79 | (_("%pB: illegal relocation type %d at address %#" PRIx64), | 5265 | 79 | abfd, dst.r_type, (uint64_t) dst.r_vaddr); | 5266 | 79 | bfd_set_error (bfd_error_bad_value); | 5267 | 79 | free (native_relocs); | 5268 | 79 | return false; | 5269 | 79 | } | 5270 | 176k | } | 5271 | | | 5272 | 23 | free (native_relocs); | 5273 | 23 | asect->relocation = reloc_cache; | 5274 | 23 | return true; | 5275 | 102 | } |
pe-mcore.c:coff_slurp_reloc_table Line | Count | Source | 5165 | 159 | { | 5166 | 159 | bfd_byte *native_relocs; | 5167 | 159 | arelent *reloc_cache; | 5168 | 159 | arelent *cache_ptr; | 5169 | 159 | unsigned int idx; | 5170 | 159 | size_t amt; | 5171 | | | 5172 | 159 | if (asect->relocation) | 5173 | 0 | return true; | 5174 | 159 | if (asect->reloc_count == 0) | 5175 | 0 | return true; | 5176 | 159 | if (asect->flags & SEC_CONSTRUCTOR) | 5177 | 0 | return true; | 5178 | 159 | if (!coff_slurp_symbol_table (abfd)) | 5179 | 0 | return false; | 5180 | | | 5181 | 159 | native_relocs = (bfd_byte *) buy_and_read (abfd, asect->rel_filepos, | 5182 | 159 | asect->reloc_count, | 5183 | 159 | bfd_coff_relsz (abfd)); | 5184 | 159 | if (native_relocs == NULL) | 5185 | 28 | return false; | 5186 | | | 5187 | 131 | if (_bfd_mul_overflow (asect->reloc_count, sizeof (arelent), &amt)) | 5188 | 0 | { | 5189 | 0 | bfd_set_error (bfd_error_file_too_big); | 5190 | 0 | return false; | 5191 | 0 | } | 5192 | 131 | reloc_cache = (arelent *) bfd_alloc (abfd, amt); | 5193 | 131 | if (reloc_cache == NULL) | 5194 | 0 | { | 5195 | 0 | free (native_relocs); | 5196 | 0 | return false; | 5197 | 0 | } | 5198 | | | 5199 | 15.6k | for (idx = 0; idx < asect->reloc_count; idx++) | 5200 | 15.5k | { | 5201 | 15.5k | struct internal_reloc dst; | 5202 | 15.5k | void *src; | 5203 | 15.5k | #ifndef RELOC_PROCESSING | 5204 | 15.5k | asymbol *ptr; | 5205 | 15.5k | #endif | 5206 | | | 5207 | 15.5k | cache_ptr = reloc_cache + idx; | 5208 | 15.5k | src = native_relocs + idx * (size_t) bfd_coff_relsz (abfd); | 5209 | | | 5210 | 15.5k | dst.r_offset = 0; | 5211 | 15.5k | bfd_coff_swap_reloc_in (abfd, src, &dst); | 5212 | | | 5213 | | #ifdef RELOC_PROCESSING | 5214 | | RELOC_PROCESSING (cache_ptr, &dst, symbols, abfd, asect); | 5215 | | #else | 5216 | 15.5k | cache_ptr->address = dst.r_vaddr; | 5217 | | | 5218 | 15.5k | if (dst.r_symndx != -1 && symbols != NULL) | 5219 | 15.5k | { | 5220 | 15.5k | if (dst.r_symndx < 0 || dst.r_symndx >= obj_conv_table_size (abfd)) | 5221 | 232 | { | 5222 | 232 | _bfd_error_handler | 5223 | | /* xgettext:c-format */ | 5224 | 232 | (_("%pB: warning: illegal symbol index %ld in relocs"), | 5225 | 232 | abfd, dst.r_symndx); | 5226 | 232 | cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; | 5227 | 232 | ptr = NULL; | 5228 | 232 | } | 5229 | 15.3k | else | 5230 | 15.3k | { | 5231 | 15.3k | cache_ptr->sym_ptr_ptr = (symbols | 5232 | 15.3k | + obj_convert (abfd)[dst.r_symndx]); | 5233 | 15.3k | ptr = *(cache_ptr->sym_ptr_ptr); | 5234 | 15.3k | } | 5235 | 15.5k | } | 5236 | 21 | else | 5237 | 21 | { | 5238 | 21 | cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; | 5239 | 21 | ptr = NULL; | 5240 | 21 | } | 5241 | | | 5242 | | /* The symbols definitions that we have read in have been | 5243 | | relocated as if their sections started at 0. But the offsets | 5244 | | refering to the symbols in the raw data have not been | 5245 | | modified, so we have to have a negative addend to compensate. | 5246 | | | 5247 | | Note that symbols which used to be common must be left alone. */ | 5248 | | | 5249 | | /* Calculate any reloc addend by looking at the symbol. */ | 5250 | 15.5k | CALC_ADDEND (abfd, ptr, dst, cache_ptr); | 5251 | 15.5k | (void) ptr; | 5252 | | | 5253 | 15.5k | cache_ptr->address -= asect->vma; | 5254 | | /* !! cache_ptr->section = NULL;*/ | 5255 | | | 5256 | | /* Fill in the cache_ptr->howto field from dst.r_type. */ | 5257 | 15.5k | RTYPE2HOWTO (cache_ptr, &dst); | 5258 | 15.5k | #endif /* RELOC_PROCESSING */ | 5259 | | | 5260 | 15.5k | if (cache_ptr->howto == NULL) | 5261 | 62 | { | 5262 | 62 | _bfd_error_handler | 5263 | | /* xgettext:c-format */ | 5264 | 62 | (_("%pB: illegal relocation type %d at address %#" PRIx64), | 5265 | 62 | abfd, dst.r_type, (uint64_t) dst.r_vaddr); | 5266 | 62 | bfd_set_error (bfd_error_bad_value); | 5267 | 62 | free (native_relocs); | 5268 | 62 | return false; | 5269 | 62 | } | 5270 | 15.5k | } | 5271 | | | 5272 | 69 | free (native_relocs); | 5273 | 69 | asect->relocation = reloc_cache; | 5274 | 69 | return true; | 5275 | 131 | } |
pe-sh.c:coff_slurp_reloc_table Line | Count | Source | 5165 | 108 | { | 5166 | 108 | bfd_byte *native_relocs; | 5167 | 108 | arelent *reloc_cache; | 5168 | 108 | arelent *cache_ptr; | 5169 | 108 | unsigned int idx; | 5170 | 108 | size_t amt; | 5171 | | | 5172 | 108 | if (asect->relocation) | 5173 | 0 | return true; | 5174 | 108 | if (asect->reloc_count == 0) | 5175 | 0 | return true; | 5176 | 108 | if (asect->flags & SEC_CONSTRUCTOR) | 5177 | 0 | return true; | 5178 | 108 | if (!coff_slurp_symbol_table (abfd)) | 5179 | 0 | return false; | 5180 | | | 5181 | 108 | native_relocs = (bfd_byte *) buy_and_read (abfd, asect->rel_filepos, | 5182 | 108 | asect->reloc_count, | 5183 | 108 | bfd_coff_relsz (abfd)); | 5184 | 108 | if (native_relocs == NULL) | 5185 | 10 | return false; | 5186 | | | 5187 | 98 | if (_bfd_mul_overflow (asect->reloc_count, sizeof (arelent), &amt)) | 5188 | 0 | { | 5189 | 0 | bfd_set_error (bfd_error_file_too_big); | 5190 | 0 | return false; | 5191 | 0 | } | 5192 | 98 | reloc_cache = (arelent *) bfd_alloc (abfd, amt); | 5193 | 98 | if (reloc_cache == NULL) | 5194 | 0 | { | 5195 | 0 | free (native_relocs); | 5196 | 0 | return false; | 5197 | 0 | } | 5198 | | | 5199 | 5.75k | for (idx = 0; idx < asect->reloc_count; idx++) | 5200 | 5.72k | { | 5201 | 5.72k | struct internal_reloc dst; | 5202 | 5.72k | void *src; | 5203 | 5.72k | #ifndef RELOC_PROCESSING | 5204 | 5.72k | asymbol *ptr; | 5205 | 5.72k | #endif | 5206 | | | 5207 | 5.72k | cache_ptr = reloc_cache + idx; | 5208 | 5.72k | src = native_relocs + idx * (size_t) bfd_coff_relsz (abfd); | 5209 | | | 5210 | 5.72k | dst.r_offset = 0; | 5211 | 5.72k | bfd_coff_swap_reloc_in (abfd, src, &dst); | 5212 | | | 5213 | | #ifdef RELOC_PROCESSING | 5214 | | RELOC_PROCESSING (cache_ptr, &dst, symbols, abfd, asect); | 5215 | | #else | 5216 | 5.72k | cache_ptr->address = dst.r_vaddr; | 5217 | | | 5218 | 5.72k | if (dst.r_symndx != -1 && symbols != NULL) | 5219 | 5.70k | { | 5220 | 5.70k | if (dst.r_symndx < 0 || dst.r_symndx >= obj_conv_table_size (abfd)) | 5221 | 314 | { | 5222 | 314 | _bfd_error_handler | 5223 | | /* xgettext:c-format */ | 5224 | 314 | (_("%pB: warning: illegal symbol index %ld in relocs"), | 5225 | 314 | abfd, dst.r_symndx); | 5226 | 314 | cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; | 5227 | 314 | ptr = NULL; | 5228 | 314 | } | 5229 | 5.38k | else | 5230 | 5.38k | { | 5231 | 5.38k | cache_ptr->sym_ptr_ptr = (symbols | 5232 | 5.38k | + obj_convert (abfd)[dst.r_symndx]); | 5233 | 5.38k | ptr = *(cache_ptr->sym_ptr_ptr); | 5234 | 5.38k | } | 5235 | 5.70k | } | 5236 | 24 | else | 5237 | 24 | { | 5238 | 24 | cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; | 5239 | 24 | ptr = NULL; | 5240 | 24 | } | 5241 | | | 5242 | | /* The symbols definitions that we have read in have been | 5243 | | relocated as if their sections started at 0. But the offsets | 5244 | | refering to the symbols in the raw data have not been | 5245 | | modified, so we have to have a negative addend to compensate. | 5246 | | | 5247 | | Note that symbols which used to be common must be left alone. */ | 5248 | | | 5249 | | /* Calculate any reloc addend by looking at the symbol. */ | 5250 | 5.72k | CALC_ADDEND (abfd, ptr, dst, cache_ptr); | 5251 | 5.72k | (void) ptr; | 5252 | | | 5253 | 5.72k | cache_ptr->address -= asect->vma; | 5254 | | /* !! cache_ptr->section = NULL;*/ | 5255 | | | 5256 | | /* Fill in the cache_ptr->howto field from dst.r_type. */ | 5257 | 5.72k | RTYPE2HOWTO (cache_ptr, &dst); | 5258 | 5.72k | #endif /* RELOC_PROCESSING */ | 5259 | | | 5260 | 5.72k | if (cache_ptr->howto == NULL) | 5261 | 64 | { | 5262 | 64 | _bfd_error_handler | 5263 | | /* xgettext:c-format */ | 5264 | 64 | (_("%pB: illegal relocation type %d at address %#" PRIx64), | 5265 | 64 | abfd, dst.r_type, (uint64_t) dst.r_vaddr); | 5266 | 64 | bfd_set_error (bfd_error_bad_value); | 5267 | 64 | free (native_relocs); | 5268 | 64 | return false; | 5269 | 64 | } | 5270 | 5.72k | } | 5271 | | | 5272 | 34 | free (native_relocs); | 5273 | 34 | asect->relocation = reloc_cache; | 5274 | 34 | return true; | 5275 | 98 | } |
Unexecuted instantiation: pei-arm-wince.c:coff_slurp_reloc_table pei-arm.c:coff_slurp_reloc_table Line | Count | Source | 5165 | 8 | { | 5166 | 8 | bfd_byte *native_relocs; | 5167 | 8 | arelent *reloc_cache; | 5168 | 8 | arelent *cache_ptr; | 5169 | 8 | unsigned int idx; | 5170 | 8 | size_t amt; | 5171 | | | 5172 | 8 | if (asect->relocation) | 5173 | 8 | return true; | 5174 | 0 | if (asect->reloc_count == 0) | 5175 | 0 | return true; | 5176 | 0 | if (asect->flags & SEC_CONSTRUCTOR) | 5177 | 0 | return true; | 5178 | 0 | if (!coff_slurp_symbol_table (abfd)) | 5179 | 0 | return false; | 5180 | | | 5181 | 0 | native_relocs = (bfd_byte *) buy_and_read (abfd, asect->rel_filepos, | 5182 | 0 | asect->reloc_count, | 5183 | 0 | bfd_coff_relsz (abfd)); | 5184 | 0 | if (native_relocs == NULL) | 5185 | 0 | return false; | 5186 | | | 5187 | 0 | if (_bfd_mul_overflow (asect->reloc_count, sizeof (arelent), &amt)) | 5188 | 0 | { | 5189 | 0 | bfd_set_error (bfd_error_file_too_big); | 5190 | 0 | return false; | 5191 | 0 | } | 5192 | 0 | reloc_cache = (arelent *) bfd_alloc (abfd, amt); | 5193 | 0 | if (reloc_cache == NULL) | 5194 | 0 | { | 5195 | 0 | free (native_relocs); | 5196 | 0 | return false; | 5197 | 0 | } | 5198 | | | 5199 | 0 | for (idx = 0; idx < asect->reloc_count; idx++) | 5200 | 0 | { | 5201 | 0 | struct internal_reloc dst; | 5202 | 0 | void *src; | 5203 | 0 | #ifndef RELOC_PROCESSING | 5204 | 0 | asymbol *ptr; | 5205 | 0 | #endif | 5206 | |
| 5207 | 0 | cache_ptr = reloc_cache + idx; | 5208 | 0 | src = native_relocs + idx * (size_t) bfd_coff_relsz (abfd); | 5209 | |
| 5210 | 0 | dst.r_offset = 0; | 5211 | 0 | bfd_coff_swap_reloc_in (abfd, src, &dst); | 5212 | |
| 5213 | | #ifdef RELOC_PROCESSING | 5214 | | RELOC_PROCESSING (cache_ptr, &dst, symbols, abfd, asect); | 5215 | | #else | 5216 | 0 | cache_ptr->address = dst.r_vaddr; | 5217 | |
| 5218 | 0 | if (dst.r_symndx != -1 && symbols != NULL) | 5219 | 0 | { | 5220 | 0 | if (dst.r_symndx < 0 || dst.r_symndx >= obj_conv_table_size (abfd)) | 5221 | 0 | { | 5222 | 0 | _bfd_error_handler | 5223 | | /* xgettext:c-format */ | 5224 | 0 | (_("%pB: warning: illegal symbol index %ld in relocs"), | 5225 | 0 | abfd, dst.r_symndx); | 5226 | 0 | cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; | 5227 | 0 | ptr = NULL; | 5228 | 0 | } | 5229 | 0 | else | 5230 | 0 | { | 5231 | 0 | cache_ptr->sym_ptr_ptr = (symbols | 5232 | 0 | + obj_convert (abfd)[dst.r_symndx]); | 5233 | 0 | ptr = *(cache_ptr->sym_ptr_ptr); | 5234 | 0 | } | 5235 | 0 | } | 5236 | 0 | else | 5237 | 0 | { | 5238 | 0 | cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; | 5239 | 0 | ptr = NULL; | 5240 | 0 | } | 5241 | | | 5242 | | /* The symbols definitions that we have read in have been | 5243 | | relocated as if their sections started at 0. But the offsets | 5244 | | refering to the symbols in the raw data have not been | 5245 | | modified, so we have to have a negative addend to compensate. | 5246 | | | 5247 | | Note that symbols which used to be common must be left alone. */ | 5248 | | | 5249 | | /* Calculate any reloc addend by looking at the symbol. */ | 5250 | 0 | CALC_ADDEND (abfd, ptr, dst, cache_ptr); | 5251 | 0 | (void) ptr; | 5252 | |
| 5253 | 0 | cache_ptr->address -= asect->vma; | 5254 | | /* !! cache_ptr->section = NULL;*/ | 5255 | | | 5256 | | /* Fill in the cache_ptr->howto field from dst.r_type. */ | 5257 | 0 | RTYPE2HOWTO (cache_ptr, &dst); | 5258 | 0 | #endif /* RELOC_PROCESSING */ | 5259 | |
| 5260 | 0 | if (cache_ptr->howto == NULL) | 5261 | 0 | { | 5262 | 0 | _bfd_error_handler | 5263 | | /* xgettext:c-format */ | 5264 | 0 | (_("%pB: illegal relocation type %d at address %#" PRIx64), | 5265 | 0 | abfd, dst.r_type, (uint64_t) dst.r_vaddr); | 5266 | 0 | bfd_set_error (bfd_error_bad_value); | 5267 | 0 | free (native_relocs); | 5268 | 0 | return false; | 5269 | 0 | } | 5270 | 0 | } | 5271 | | | 5272 | 0 | free (native_relocs); | 5273 | 0 | asect->relocation = reloc_cache; | 5274 | 0 | return true; | 5275 | 0 | } |
Unexecuted instantiation: pei-mcore.c:coff_slurp_reloc_table pei-sh.c:coff_slurp_reloc_table Line | Count | Source | 5165 | 70 | { | 5166 | 70 | bfd_byte *native_relocs; | 5167 | 70 | arelent *reloc_cache; | 5168 | 70 | arelent *cache_ptr; | 5169 | 70 | unsigned int idx; | 5170 | 70 | size_t amt; | 5171 | | | 5172 | 70 | if (asect->relocation) | 5173 | 70 | return true; | 5174 | 0 | if (asect->reloc_count == 0) | 5175 | 0 | return true; | 5176 | 0 | if (asect->flags & SEC_CONSTRUCTOR) | 5177 | 0 | return true; | 5178 | 0 | if (!coff_slurp_symbol_table (abfd)) | 5179 | 0 | return false; | 5180 | | | 5181 | 0 | native_relocs = (bfd_byte *) buy_and_read (abfd, asect->rel_filepos, | 5182 | 0 | asect->reloc_count, | 5183 | 0 | bfd_coff_relsz (abfd)); | 5184 | 0 | if (native_relocs == NULL) | 5185 | 0 | return false; | 5186 | | | 5187 | 0 | if (_bfd_mul_overflow (asect->reloc_count, sizeof (arelent), &amt)) | 5188 | 0 | { | 5189 | 0 | bfd_set_error (bfd_error_file_too_big); | 5190 | 0 | return false; | 5191 | 0 | } | 5192 | 0 | reloc_cache = (arelent *) bfd_alloc (abfd, amt); | 5193 | 0 | if (reloc_cache == NULL) | 5194 | 0 | { | 5195 | 0 | free (native_relocs); | 5196 | 0 | return false; | 5197 | 0 | } | 5198 | | | 5199 | 0 | for (idx = 0; idx < asect->reloc_count; idx++) | 5200 | 0 | { | 5201 | 0 | struct internal_reloc dst; | 5202 | 0 | void *src; | 5203 | 0 | #ifndef RELOC_PROCESSING | 5204 | 0 | asymbol *ptr; | 5205 | 0 | #endif | 5206 | |
| 5207 | 0 | cache_ptr = reloc_cache + idx; | 5208 | 0 | src = native_relocs + idx * (size_t) bfd_coff_relsz (abfd); | 5209 | |
| 5210 | 0 | dst.r_offset = 0; | 5211 | 0 | bfd_coff_swap_reloc_in (abfd, src, &dst); | 5212 | |
| 5213 | | #ifdef RELOC_PROCESSING | 5214 | | RELOC_PROCESSING (cache_ptr, &dst, symbols, abfd, asect); | 5215 | | #else | 5216 | 0 | cache_ptr->address = dst.r_vaddr; | 5217 | |
| 5218 | 0 | if (dst.r_symndx != -1 && symbols != NULL) | 5219 | 0 | { | 5220 | 0 | if (dst.r_symndx < 0 || dst.r_symndx >= obj_conv_table_size (abfd)) | 5221 | 0 | { | 5222 | 0 | _bfd_error_handler | 5223 | | /* xgettext:c-format */ | 5224 | 0 | (_("%pB: warning: illegal symbol index %ld in relocs"), | 5225 | 0 | abfd, dst.r_symndx); | 5226 | 0 | cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; | 5227 | 0 | ptr = NULL; | 5228 | 0 | } | 5229 | 0 | else | 5230 | 0 | { | 5231 | 0 | cache_ptr->sym_ptr_ptr = (symbols | 5232 | 0 | + obj_convert (abfd)[dst.r_symndx]); | 5233 | 0 | ptr = *(cache_ptr->sym_ptr_ptr); | 5234 | 0 | } | 5235 | 0 | } | 5236 | 0 | else | 5237 | 0 | { | 5238 | 0 | cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; | 5239 | 0 | ptr = NULL; | 5240 | 0 | } | 5241 | | | 5242 | | /* The symbols definitions that we have read in have been | 5243 | | relocated as if their sections started at 0. But the offsets | 5244 | | refering to the symbols in the raw data have not been | 5245 | | modified, so we have to have a negative addend to compensate. | 5246 | | | 5247 | | Note that symbols which used to be common must be left alone. */ | 5248 | | | 5249 | | /* Calculate any reloc addend by looking at the symbol. */ | 5250 | 0 | CALC_ADDEND (abfd, ptr, dst, cache_ptr); | 5251 | 0 | (void) ptr; | 5252 | |
| 5253 | 0 | cache_ptr->address -= asect->vma; | 5254 | | /* !! cache_ptr->section = NULL;*/ | 5255 | | | 5256 | | /* Fill in the cache_ptr->howto field from dst.r_type. */ | 5257 | 0 | RTYPE2HOWTO (cache_ptr, &dst); | 5258 | 0 | #endif /* RELOC_PROCESSING */ | 5259 | |
| 5260 | 0 | if (cache_ptr->howto == NULL) | 5261 | 0 | { | 5262 | 0 | _bfd_error_handler | 5263 | | /* xgettext:c-format */ | 5264 | 0 | (_("%pB: illegal relocation type %d at address %#" PRIx64), | 5265 | 0 | abfd, dst.r_type, (uint64_t) dst.r_vaddr); | 5266 | 0 | bfd_set_error (bfd_error_bad_value); | 5267 | 0 | free (native_relocs); | 5268 | 0 | return false; | 5269 | 0 | } | 5270 | 0 | } | 5271 | | | 5272 | 0 | free (native_relocs); | 5273 | 0 | asect->relocation = reloc_cache; | 5274 | 0 | return true; | 5275 | 0 | } |
|
5276 | | |
5277 | | #ifndef coff_rtype_to_howto |
5278 | | #ifdef RTYPE2HOWTO |
5279 | | |
5280 | | /* Get the howto structure for a reloc. This is only used if the file |
5281 | | including this one defines coff_relocate_section to be |
5282 | | _bfd_coff_generic_relocate_section, so it is OK if it does not |
5283 | | always work. It is the responsibility of the including file to |
5284 | | make sure it is reasonable if it is needed. */ |
5285 | | |
5286 | | static reloc_howto_type * |
5287 | | coff_rtype_to_howto (bfd *abfd ATTRIBUTE_UNUSED, |
5288 | | asection *sec ATTRIBUTE_UNUSED, |
5289 | | struct internal_reloc *rel ATTRIBUTE_UNUSED, |
5290 | | struct coff_link_hash_entry *h ATTRIBUTE_UNUSED, |
5291 | | struct internal_syment *sym ATTRIBUTE_UNUSED, |
5292 | | bfd_vma *addendp ATTRIBUTE_UNUSED) |
5293 | 0 | { |
5294 | 0 | arelent genrel; |
5295 | |
|
5296 | 0 | genrel.howto = NULL; |
5297 | 0 | RTYPE2HOWTO (&genrel, rel); |
5298 | 0 | return genrel.howto; |
5299 | 0 | } Unexecuted instantiation: coff64-rs6000.c:coff_rtype_to_howto Unexecuted instantiation: pei-ia64.c:coff_rtype_to_howto Unexecuted instantiation: pei-loongarch64.c:coff_rtype_to_howto Unexecuted instantiation: coff-rs6000.c:coff_rtype_to_howto Unexecuted instantiation: coff-sh.c:coff_rtype_to_howto Unexecuted instantiation: coff-tic30.c:coff_rtype_to_howto Unexecuted instantiation: coff-z80.c:coff_rtype_to_howto Unexecuted instantiation: coff-z8k.c:coff_rtype_to_howto |
5300 | | |
5301 | | #else /* ! defined (RTYPE2HOWTO) */ |
5302 | | |
5303 | | #define coff_rtype_to_howto NULL |
5304 | | |
5305 | | #endif /* ! defined (RTYPE2HOWTO) */ |
5306 | | #endif /* ! defined (coff_rtype_to_howto) */ |
5307 | | |
5308 | | /* This is stupid. This function should be a boolean predicate. */ |
5309 | | |
5310 | | static long |
5311 | | coff_canonicalize_reloc (bfd * abfd, |
5312 | | sec_ptr section, |
5313 | | arelent ** relptr, |
5314 | | asymbol ** symbols) |
5315 | 3.21k | { |
5316 | 3.21k | arelent *tblptr = section->relocation; |
5317 | 3.21k | unsigned int count = 0; |
5318 | | |
5319 | 3.21k | if (section->flags & SEC_CONSTRUCTOR) |
5320 | 0 | { |
5321 | | /* This section has relocs made up by us, they are not in the |
5322 | | file, so take them out of their chain and place them into |
5323 | | the data area provided. */ |
5324 | 0 | arelent_chain *chain = section->constructor_chain; |
5325 | |
|
5326 | 0 | for (count = 0; count < section->reloc_count; count++) |
5327 | 0 | { |
5328 | 0 | *relptr++ = &chain->relent; |
5329 | 0 | chain = chain->next; |
5330 | 0 | } |
5331 | 0 | } |
5332 | 3.21k | else |
5333 | 3.21k | { |
5334 | 3.21k | if (! coff_slurp_reloc_table (abfd, section, symbols)) |
5335 | 2.28k | return -1; |
5336 | | |
5337 | 929 | tblptr = section->relocation; |
5338 | | |
5339 | 120k | for (; count++ < section->reloc_count;) |
5340 | 119k | *relptr++ = tblptr++; |
5341 | 929 | } |
5342 | 929 | *relptr = 0; |
5343 | 929 | return section->reloc_count; |
5344 | 3.21k | } pei-i386.c:coff_canonicalize_reloc Line | Count | Source | 5315 | 23 | { | 5316 | 23 | arelent *tblptr = section->relocation; | 5317 | 23 | unsigned int count = 0; | 5318 | | | 5319 | 23 | if (section->flags & SEC_CONSTRUCTOR) | 5320 | 0 | { | 5321 | | /* This section has relocs made up by us, they are not in the | 5322 | | file, so take them out of their chain and place them into | 5323 | | the data area provided. */ | 5324 | 0 | arelent_chain *chain = section->constructor_chain; | 5325 | |
| 5326 | 0 | for (count = 0; count < section->reloc_count; count++) | 5327 | 0 | { | 5328 | 0 | *relptr++ = &chain->relent; | 5329 | 0 | chain = chain->next; | 5330 | 0 | } | 5331 | 0 | } | 5332 | 23 | else | 5333 | 23 | { | 5334 | 23 | if (! coff_slurp_reloc_table (abfd, section, symbols)) | 5335 | 0 | return -1; | 5336 | | | 5337 | 23 | tblptr = section->relocation; | 5338 | | | 5339 | 46 | for (; count++ < section->reloc_count;) | 5340 | 23 | *relptr++ = tblptr++; | 5341 | 23 | } | 5342 | 23 | *relptr = 0; | 5343 | 23 | return section->reloc_count; | 5344 | 23 | } |
pe-x86_64.c:coff_canonicalize_reloc Line | Count | Source | 5315 | 98 | { | 5316 | 98 | arelent *tblptr = section->relocation; | 5317 | 98 | unsigned int count = 0; | 5318 | | | 5319 | 98 | if (section->flags & SEC_CONSTRUCTOR) | 5320 | 0 | { | 5321 | | /* This section has relocs made up by us, they are not in the | 5322 | | file, so take them out of their chain and place them into | 5323 | | the data area provided. */ | 5324 | 0 | arelent_chain *chain = section->constructor_chain; | 5325 | |
| 5326 | 0 | for (count = 0; count < section->reloc_count; count++) | 5327 | 0 | { | 5328 | 0 | *relptr++ = &chain->relent; | 5329 | 0 | chain = chain->next; | 5330 | 0 | } | 5331 | 0 | } | 5332 | 98 | else | 5333 | 98 | { | 5334 | 98 | if (! coff_slurp_reloc_table (abfd, section, symbols)) | 5335 | 51 | return -1; | 5336 | | | 5337 | 47 | tblptr = section->relocation; | 5338 | | | 5339 | 3.01k | for (; count++ < section->reloc_count;) | 5340 | 2.96k | *relptr++ = tblptr++; | 5341 | 47 | } | 5342 | 47 | *relptr = 0; | 5343 | 47 | return section->reloc_count; | 5344 | 98 | } |
pei-x86_64.c:coff_canonicalize_reloc Line | Count | Source | 5315 | 17 | { | 5316 | 17 | arelent *tblptr = section->relocation; | 5317 | 17 | unsigned int count = 0; | 5318 | | | 5319 | 17 | if (section->flags & SEC_CONSTRUCTOR) | 5320 | 0 | { | 5321 | | /* This section has relocs made up by us, they are not in the | 5322 | | file, so take them out of their chain and place them into | 5323 | | the data area provided. */ | 5324 | 0 | arelent_chain *chain = section->constructor_chain; | 5325 | |
| 5326 | 0 | for (count = 0; count < section->reloc_count; count++) | 5327 | 0 | { | 5328 | 0 | *relptr++ = &chain->relent; | 5329 | 0 | chain = chain->next; | 5330 | 0 | } | 5331 | 0 | } | 5332 | 17 | else | 5333 | 17 | { | 5334 | 17 | if (! coff_slurp_reloc_table (abfd, section, symbols)) | 5335 | 0 | return -1; | 5336 | | | 5337 | 17 | tblptr = section->relocation; | 5338 | | | 5339 | 34 | for (; count++ < section->reloc_count;) | 5340 | 17 | *relptr++ = tblptr++; | 5341 | 17 | } | 5342 | 17 | *relptr = 0; | 5343 | 17 | return section->reloc_count; | 5344 | 17 | } |
coff-x86_64.c:coff_canonicalize_reloc Line | Count | Source | 5315 | 148 | { | 5316 | 148 | arelent *tblptr = section->relocation; | 5317 | 148 | unsigned int count = 0; | 5318 | | | 5319 | 148 | if (section->flags & SEC_CONSTRUCTOR) | 5320 | 0 | { | 5321 | | /* This section has relocs made up by us, they are not in the | 5322 | | file, so take them out of their chain and place them into | 5323 | | the data area provided. */ | 5324 | 0 | arelent_chain *chain = section->constructor_chain; | 5325 | |
| 5326 | 0 | for (count = 0; count < section->reloc_count; count++) | 5327 | 0 | { | 5328 | 0 | *relptr++ = &chain->relent; | 5329 | 0 | chain = chain->next; | 5330 | 0 | } | 5331 | 0 | } | 5332 | 148 | else | 5333 | 148 | { | 5334 | 148 | if (! coff_slurp_reloc_table (abfd, section, symbols)) | 5335 | 92 | return -1; | 5336 | | | 5337 | 56 | tblptr = section->relocation; | 5338 | | | 5339 | 4.52k | for (; count++ < section->reloc_count;) | 5340 | 4.46k | *relptr++ = tblptr++; | 5341 | 56 | } | 5342 | 56 | *relptr = 0; | 5343 | 56 | return section->reloc_count; | 5344 | 148 | } |
coff64-rs6000.c:coff_canonicalize_reloc Line | Count | Source | 5315 | 19 | { | 5316 | 19 | arelent *tblptr = section->relocation; | 5317 | 19 | unsigned int count = 0; | 5318 | | | 5319 | 19 | if (section->flags & SEC_CONSTRUCTOR) | 5320 | 0 | { | 5321 | | /* This section has relocs made up by us, they are not in the | 5322 | | file, so take them out of their chain and place them into | 5323 | | the data area provided. */ | 5324 | 0 | arelent_chain *chain = section->constructor_chain; | 5325 | |
| 5326 | 0 | for (count = 0; count < section->reloc_count; count++) | 5327 | 0 | { | 5328 | 0 | *relptr++ = &chain->relent; | 5329 | 0 | chain = chain->next; | 5330 | 0 | } | 5331 | 0 | } | 5332 | 19 | else | 5333 | 19 | { | 5334 | 19 | if (! coff_slurp_reloc_table (abfd, section, symbols)) | 5335 | 1 | return -1; | 5336 | | | 5337 | 18 | tblptr = section->relocation; | 5338 | | | 5339 | 90 | for (; count++ < section->reloc_count;) | 5340 | 72 | *relptr++ = tblptr++; | 5341 | 18 | } | 5342 | 18 | *relptr = 0; | 5343 | 18 | return section->reloc_count; | 5344 | 19 | } |
pei-aarch64.c:coff_canonicalize_reloc Line | Count | Source | 5315 | 15 | { | 5316 | 15 | arelent *tblptr = section->relocation; | 5317 | 15 | unsigned int count = 0; | 5318 | | | 5319 | 15 | if (section->flags & SEC_CONSTRUCTOR) | 5320 | 0 | { | 5321 | | /* This section has relocs made up by us, they are not in the | 5322 | | file, so take them out of their chain and place them into | 5323 | | the data area provided. */ | 5324 | 0 | arelent_chain *chain = section->constructor_chain; | 5325 | |
| 5326 | 0 | for (count = 0; count < section->reloc_count; count++) | 5327 | 0 | { | 5328 | 0 | *relptr++ = &chain->relent; | 5329 | 0 | chain = chain->next; | 5330 | 0 | } | 5331 | 0 | } | 5332 | 15 | else | 5333 | 15 | { | 5334 | 15 | if (! coff_slurp_reloc_table (abfd, section, symbols)) | 5335 | 0 | return -1; | 5336 | | | 5337 | 15 | tblptr = section->relocation; | 5338 | | | 5339 | 30 | for (; count++ < section->reloc_count;) | 5340 | 15 | *relptr++ = tblptr++; | 5341 | 15 | } | 5342 | 15 | *relptr = 0; | 5343 | 15 | return section->reloc_count; | 5344 | 15 | } |
pe-aarch64.c:coff_canonicalize_reloc Line | Count | Source | 5315 | 1.29k | { | 5316 | 1.29k | arelent *tblptr = section->relocation; | 5317 | 1.29k | unsigned int count = 0; | 5318 | | | 5319 | 1.29k | if (section->flags & SEC_CONSTRUCTOR) | 5320 | 0 | { | 5321 | | /* This section has relocs made up by us, they are not in the | 5322 | | file, so take them out of their chain and place them into | 5323 | | the data area provided. */ | 5324 | 0 | arelent_chain *chain = section->constructor_chain; | 5325 | |
| 5326 | 0 | for (count = 0; count < section->reloc_count; count++) | 5327 | 0 | { | 5328 | 0 | *relptr++ = &chain->relent; | 5329 | 0 | chain = chain->next; | 5330 | 0 | } | 5331 | 0 | } | 5332 | 1.29k | else | 5333 | 1.29k | { | 5334 | 1.29k | if (! coff_slurp_reloc_table (abfd, section, symbols)) | 5335 | 891 | return -1; | 5336 | | | 5337 | 406 | tblptr = section->relocation; | 5338 | | | 5339 | 1.23k | for (; count++ < section->reloc_count;) | 5340 | 833 | *relptr++ = tblptr++; | 5341 | 406 | } | 5342 | 406 | *relptr = 0; | 5343 | 406 | return section->reloc_count; | 5344 | 1.29k | } |
Unexecuted instantiation: pei-ia64.c:coff_canonicalize_reloc pei-loongarch64.c:coff_canonicalize_reloc Line | Count | Source | 5315 | 12 | { | 5316 | 12 | arelent *tblptr = section->relocation; | 5317 | 12 | unsigned int count = 0; | 5318 | | | 5319 | 12 | if (section->flags & SEC_CONSTRUCTOR) | 5320 | 0 | { | 5321 | | /* This section has relocs made up by us, they are not in the | 5322 | | file, so take them out of their chain and place them into | 5323 | | the data area provided. */ | 5324 | 0 | arelent_chain *chain = section->constructor_chain; | 5325 | |
| 5326 | 0 | for (count = 0; count < section->reloc_count; count++) | 5327 | 0 | { | 5328 | 0 | *relptr++ = &chain->relent; | 5329 | 0 | chain = chain->next; | 5330 | 0 | } | 5331 | 0 | } | 5332 | 12 | else | 5333 | 12 | { | 5334 | 12 | if (! coff_slurp_reloc_table (abfd, section, symbols)) | 5335 | 0 | return -1; | 5336 | | | 5337 | 12 | tblptr = section->relocation; | 5338 | | | 5339 | 24 | for (; count++ < section->reloc_count;) | 5340 | 12 | *relptr++ = tblptr++; | 5341 | 12 | } | 5342 | 12 | *relptr = 0; | 5343 | 12 | return section->reloc_count; | 5344 | 12 | } |
Unexecuted instantiation: cf-i386lynx.c:coff_canonicalize_reloc Unexecuted instantiation: coff-go32.c:coff_canonicalize_reloc Unexecuted instantiation: coff-i386.c:coff_canonicalize_reloc coff-rs6000.c:coff_canonicalize_reloc Line | Count | Source | 5315 | 13 | { | 5316 | 13 | arelent *tblptr = section->relocation; | 5317 | 13 | unsigned int count = 0; | 5318 | | | 5319 | 13 | if (section->flags & SEC_CONSTRUCTOR) | 5320 | 0 | { | 5321 | | /* This section has relocs made up by us, they are not in the | 5322 | | file, so take them out of their chain and place them into | 5323 | | the data area provided. */ | 5324 | 0 | arelent_chain *chain = section->constructor_chain; | 5325 | |
| 5326 | 0 | for (count = 0; count < section->reloc_count; count++) | 5327 | 0 | { | 5328 | 0 | *relptr++ = &chain->relent; | 5329 | 0 | chain = chain->next; | 5330 | 0 | } | 5331 | 0 | } | 5332 | 13 | else | 5333 | 13 | { | 5334 | 13 | if (! coff_slurp_reloc_table (abfd, section, symbols)) | 5335 | 1 | return -1; | 5336 | | | 5337 | 12 | tblptr = section->relocation; | 5338 | | | 5339 | 213 | for (; count++ < section->reloc_count;) | 5340 | 201 | *relptr++ = tblptr++; | 5341 | 12 | } | 5342 | 12 | *relptr = 0; | 5343 | 12 | return section->reloc_count; | 5344 | 13 | } |
Unexecuted instantiation: coff-sh.c:coff_canonicalize_reloc Unexecuted instantiation: coff-stgo32.c:coff_canonicalize_reloc coff-tic30.c:coff_canonicalize_reloc Line | Count | Source | 5315 | 663 | { | 5316 | 663 | arelent *tblptr = section->relocation; | 5317 | 663 | unsigned int count = 0; | 5318 | | | 5319 | 663 | if (section->flags & SEC_CONSTRUCTOR) | 5320 | 0 | { | 5321 | | /* This section has relocs made up by us, they are not in the | 5322 | | file, so take them out of their chain and place them into | 5323 | | the data area provided. */ | 5324 | 0 | arelent_chain *chain = section->constructor_chain; | 5325 | |
| 5326 | 0 | for (count = 0; count < section->reloc_count; count++) | 5327 | 0 | { | 5328 | 0 | *relptr++ = &chain->relent; | 5329 | 0 | chain = chain->next; | 5330 | 0 | } | 5331 | 0 | } | 5332 | 663 | else | 5333 | 663 | { | 5334 | 663 | if (! coff_slurp_reloc_table (abfd, section, symbols)) | 5335 | 635 | return -1; | 5336 | | | 5337 | 28 | tblptr = section->relocation; | 5338 | | | 5339 | 6.68k | for (; count++ < section->reloc_count;) | 5340 | 6.66k | *relptr++ = tblptr++; | 5341 | 28 | } | 5342 | 28 | *relptr = 0; | 5343 | 28 | return section->reloc_count; | 5344 | 663 | } |
Unexecuted instantiation: coff-tic4x.c:coff_canonicalize_reloc coff-tic54x.c:coff_canonicalize_reloc Line | Count | Source | 5315 | 75 | { | 5316 | 75 | arelent *tblptr = section->relocation; | 5317 | 75 | unsigned int count = 0; | 5318 | | | 5319 | 75 | if (section->flags & SEC_CONSTRUCTOR) | 5320 | 0 | { | 5321 | | /* This section has relocs made up by us, they are not in the | 5322 | | file, so take them out of their chain and place them into | 5323 | | the data area provided. */ | 5324 | 0 | arelent_chain *chain = section->constructor_chain; | 5325 | |
| 5326 | 0 | for (count = 0; count < section->reloc_count; count++) | 5327 | 0 | { | 5328 | 0 | *relptr++ = &chain->relent; | 5329 | 0 | chain = chain->next; | 5330 | 0 | } | 5331 | 0 | } | 5332 | 75 | else | 5333 | 75 | { | 5334 | 75 | if (! coff_slurp_reloc_table (abfd, section, symbols)) | 5335 | 65 | return -1; | 5336 | | | 5337 | 10 | tblptr = section->relocation; | 5338 | | | 5339 | 22 | for (; count++ < section->reloc_count;) | 5340 | 12 | *relptr++ = tblptr++; | 5341 | 10 | } | 5342 | 10 | *relptr = 0; | 5343 | 10 | return section->reloc_count; | 5344 | 75 | } |
coff-z80.c:coff_canonicalize_reloc Line | Count | Source | 5315 | 282 | { | 5316 | 282 | arelent *tblptr = section->relocation; | 5317 | 282 | unsigned int count = 0; | 5318 | | | 5319 | 282 | if (section->flags & SEC_CONSTRUCTOR) | 5320 | 0 | { | 5321 | | /* This section has relocs made up by us, they are not in the | 5322 | | file, so take them out of their chain and place them into | 5323 | | the data area provided. */ | 5324 | 0 | arelent_chain *chain = section->constructor_chain; | 5325 | |
| 5326 | 0 | for (count = 0; count < section->reloc_count; count++) | 5327 | 0 | { | 5328 | 0 | *relptr++ = &chain->relent; | 5329 | 0 | chain = chain->next; | 5330 | 0 | } | 5331 | 0 | } | 5332 | 282 | else | 5333 | 282 | { | 5334 | 282 | if (! coff_slurp_reloc_table (abfd, section, symbols)) | 5335 | 208 | return -1; | 5336 | | | 5337 | 74 | tblptr = section->relocation; | 5338 | | | 5339 | 2.30k | for (; count++ < section->reloc_count;) | 5340 | 2.22k | *relptr++ = tblptr++; | 5341 | 74 | } | 5342 | 74 | *relptr = 0; | 5343 | 74 | return section->reloc_count; | 5344 | 282 | } |
coff-z8k.c:coff_canonicalize_reloc Line | Count | Source | 5315 | 82 | { | 5316 | 82 | arelent *tblptr = section->relocation; | 5317 | 82 | unsigned int count = 0; | 5318 | | | 5319 | 82 | if (section->flags & SEC_CONSTRUCTOR) | 5320 | 0 | { | 5321 | | /* This section has relocs made up by us, they are not in the | 5322 | | file, so take them out of their chain and place them into | 5323 | | the data area provided. */ | 5324 | 0 | arelent_chain *chain = section->constructor_chain; | 5325 | |
| 5326 | 0 | for (count = 0; count < section->reloc_count; count++) | 5327 | 0 | { | 5328 | 0 | *relptr++ = &chain->relent; | 5329 | 0 | chain = chain->next; | 5330 | 0 | } | 5331 | 0 | } | 5332 | 82 | else | 5333 | 82 | { | 5334 | 82 | if (! coff_slurp_reloc_table (abfd, section, symbols)) | 5335 | 75 | return -1; | 5336 | | | 5337 | 7 | tblptr = section->relocation; | 5338 | | | 5339 | 15 | for (; count++ < section->reloc_count;) | 5340 | 8 | *relptr++ = tblptr++; | 5341 | 7 | } | 5342 | 7 | *relptr = 0; | 5343 | 7 | return section->reloc_count; | 5344 | 82 | } |
Unexecuted instantiation: pe-arm-wince.c:coff_canonicalize_reloc Unexecuted instantiation: pe-arm.c:coff_canonicalize_reloc pe-i386.c:coff_canonicalize_reloc Line | Count | Source | 5315 | 122 | { | 5316 | 122 | arelent *tblptr = section->relocation; | 5317 | 122 | unsigned int count = 0; | 5318 | | | 5319 | 122 | if (section->flags & SEC_CONSTRUCTOR) | 5320 | 0 | { | 5321 | | /* This section has relocs made up by us, they are not in the | 5322 | | file, so take them out of their chain and place them into | 5323 | | the data area provided. */ | 5324 | 0 | arelent_chain *chain = section->constructor_chain; | 5325 | |
| 5326 | 0 | for (count = 0; count < section->reloc_count; count++) | 5327 | 0 | { | 5328 | 0 | *relptr++ = &chain->relent; | 5329 | 0 | chain = chain->next; | 5330 | 0 | } | 5331 | 0 | } | 5332 | 122 | else | 5333 | 122 | { | 5334 | 122 | if (! coff_slurp_reloc_table (abfd, section, symbols)) | 5335 | 99 | return -1; | 5336 | | | 5337 | 23 | tblptr = section->relocation; | 5338 | | | 5339 | 84.2k | for (; count++ < section->reloc_count;) | 5340 | 84.2k | *relptr++ = tblptr++; | 5341 | 23 | } | 5342 | 23 | *relptr = 0; | 5343 | 23 | return section->reloc_count; | 5344 | 122 | } |
pe-mcore.c:coff_canonicalize_reloc Line | Count | Source | 5315 | 159 | { | 5316 | 159 | arelent *tblptr = section->relocation; | 5317 | 159 | unsigned int count = 0; | 5318 | | | 5319 | 159 | if (section->flags & SEC_CONSTRUCTOR) | 5320 | 0 | { | 5321 | | /* This section has relocs made up by us, they are not in the | 5322 | | file, so take them out of their chain and place them into | 5323 | | the data area provided. */ | 5324 | 0 | arelent_chain *chain = section->constructor_chain; | 5325 | |
| 5326 | 0 | for (count = 0; count < section->reloc_count; count++) | 5327 | 0 | { | 5328 | 0 | *relptr++ = &chain->relent; | 5329 | 0 | chain = chain->next; | 5330 | 0 | } | 5331 | 0 | } | 5332 | 159 | else | 5333 | 159 | { | 5334 | 159 | if (! coff_slurp_reloc_table (abfd, section, symbols)) | 5335 | 90 | return -1; | 5336 | | | 5337 | 69 | tblptr = section->relocation; | 5338 | | | 5339 | 13.0k | for (; count++ < section->reloc_count;) | 5340 | 12.9k | *relptr++ = tblptr++; | 5341 | 69 | } | 5342 | 69 | *relptr = 0; | 5343 | 69 | return section->reloc_count; | 5344 | 159 | } |
pe-sh.c:coff_canonicalize_reloc Line | Count | Source | 5315 | 108 | { | 5316 | 108 | arelent *tblptr = section->relocation; | 5317 | 108 | unsigned int count = 0; | 5318 | | | 5319 | 108 | if (section->flags & SEC_CONSTRUCTOR) | 5320 | 0 | { | 5321 | | /* This section has relocs made up by us, they are not in the | 5322 | | file, so take them out of their chain and place them into | 5323 | | the data area provided. */ | 5324 | 0 | arelent_chain *chain = section->constructor_chain; | 5325 | |
| 5326 | 0 | for (count = 0; count < section->reloc_count; count++) | 5327 | 0 | { | 5328 | 0 | *relptr++ = &chain->relent; | 5329 | 0 | chain = chain->next; | 5330 | 0 | } | 5331 | 0 | } | 5332 | 108 | else | 5333 | 108 | { | 5334 | 108 | if (! coff_slurp_reloc_table (abfd, section, symbols)) | 5335 | 74 | return -1; | 5336 | | | 5337 | 34 | tblptr = section->relocation; | 5338 | | | 5339 | 4.53k | for (; count++ < section->reloc_count;) | 5340 | 4.50k | *relptr++ = tblptr++; | 5341 | 34 | } | 5342 | 34 | *relptr = 0; | 5343 | 34 | return section->reloc_count; | 5344 | 108 | } |
Unexecuted instantiation: pei-arm-wince.c:coff_canonicalize_reloc pei-arm.c:coff_canonicalize_reloc Line | Count | Source | 5315 | 8 | { | 5316 | 8 | arelent *tblptr = section->relocation; | 5317 | 8 | unsigned int count = 0; | 5318 | | | 5319 | 8 | if (section->flags & SEC_CONSTRUCTOR) | 5320 | 0 | { | 5321 | | /* This section has relocs made up by us, they are not in the | 5322 | | file, so take them out of their chain and place them into | 5323 | | the data area provided. */ | 5324 | 0 | arelent_chain *chain = section->constructor_chain; | 5325 | |
| 5326 | 0 | for (count = 0; count < section->reloc_count; count++) | 5327 | 0 | { | 5328 | 0 | *relptr++ = &chain->relent; | 5329 | 0 | chain = chain->next; | 5330 | 0 | } | 5331 | 0 | } | 5332 | 8 | else | 5333 | 8 | { | 5334 | 8 | if (! coff_slurp_reloc_table (abfd, section, symbols)) | 5335 | 0 | return -1; | 5336 | | | 5337 | 8 | tblptr = section->relocation; | 5338 | | | 5339 | 16 | for (; count++ < section->reloc_count;) | 5340 | 8 | *relptr++ = tblptr++; | 5341 | 8 | } | 5342 | 8 | *relptr = 0; | 5343 | 8 | return section->reloc_count; | 5344 | 8 | } |
Unexecuted instantiation: pei-mcore.c:coff_canonicalize_reloc pei-sh.c:coff_canonicalize_reloc Line | Count | Source | 5315 | 70 | { | 5316 | 70 | arelent *tblptr = section->relocation; | 5317 | 70 | unsigned int count = 0; | 5318 | | | 5319 | 70 | if (section->flags & SEC_CONSTRUCTOR) | 5320 | 0 | { | 5321 | | /* This section has relocs made up by us, they are not in the | 5322 | | file, so take them out of their chain and place them into | 5323 | | the data area provided. */ | 5324 | 0 | arelent_chain *chain = section->constructor_chain; | 5325 | |
| 5326 | 0 | for (count = 0; count < section->reloc_count; count++) | 5327 | 0 | { | 5328 | 0 | *relptr++ = &chain->relent; | 5329 | 0 | chain = chain->next; | 5330 | 0 | } | 5331 | 0 | } | 5332 | 70 | else | 5333 | 70 | { | 5334 | 70 | if (! coff_slurp_reloc_table (abfd, section, symbols)) | 5335 | 0 | return -1; | 5336 | | | 5337 | 70 | tblptr = section->relocation; | 5338 | | | 5339 | 140 | for (; count++ < section->reloc_count;) | 5340 | 70 | *relptr++ = tblptr++; | 5341 | 70 | } | 5342 | 70 | *relptr = 0; | 5343 | 70 | return section->reloc_count; | 5344 | 70 | } |
|
5345 | | |
5346 | | #ifndef coff_set_reloc |
5347 | | #define coff_set_reloc _bfd_generic_set_reloc |
5348 | | #endif |
5349 | | |
5350 | | #ifndef coff_reloc16_estimate |
5351 | | #define coff_reloc16_estimate dummy_reloc16_estimate |
5352 | | |
5353 | | static int |
5354 | | dummy_reloc16_estimate (bfd *abfd ATTRIBUTE_UNUSED, |
5355 | | asection *input_section ATTRIBUTE_UNUSED, |
5356 | | arelent *reloc ATTRIBUTE_UNUSED, |
5357 | | unsigned int shrink ATTRIBUTE_UNUSED, |
5358 | | struct bfd_link_info *link_info ATTRIBUTE_UNUSED) |
5359 | 0 | { |
5360 | 0 | abort (); |
5361 | 0 | return 0; |
5362 | 0 | } Unexecuted instantiation: pei-i386.c:dummy_reloc16_estimate Unexecuted instantiation: pe-x86_64.c:dummy_reloc16_estimate Unexecuted instantiation: pei-x86_64.c:dummy_reloc16_estimate Unexecuted instantiation: coff-x86_64.c:dummy_reloc16_estimate Unexecuted instantiation: coff64-rs6000.c:dummy_reloc16_estimate Unexecuted instantiation: pei-aarch64.c:dummy_reloc16_estimate Unexecuted instantiation: pe-aarch64.c:dummy_reloc16_estimate Unexecuted instantiation: pei-ia64.c:dummy_reloc16_estimate Unexecuted instantiation: pei-loongarch64.c:dummy_reloc16_estimate Unexecuted instantiation: cf-i386lynx.c:dummy_reloc16_estimate Unexecuted instantiation: coff-go32.c:dummy_reloc16_estimate Unexecuted instantiation: coff-i386.c:dummy_reloc16_estimate Unexecuted instantiation: coff-rs6000.c:dummy_reloc16_estimate Unexecuted instantiation: coff-sh.c:dummy_reloc16_estimate Unexecuted instantiation: coff-stgo32.c:dummy_reloc16_estimate Unexecuted instantiation: coff-tic30.c:dummy_reloc16_estimate Unexecuted instantiation: coff-tic4x.c:dummy_reloc16_estimate Unexecuted instantiation: coff-tic54x.c:dummy_reloc16_estimate Unexecuted instantiation: coff-z80.c:dummy_reloc16_estimate Unexecuted instantiation: coff-z8k.c:dummy_reloc16_estimate Unexecuted instantiation: pe-arm-wince.c:dummy_reloc16_estimate Unexecuted instantiation: pe-arm.c:dummy_reloc16_estimate Unexecuted instantiation: pe-i386.c:dummy_reloc16_estimate Unexecuted instantiation: pe-mcore.c:dummy_reloc16_estimate Unexecuted instantiation: pe-sh.c:dummy_reloc16_estimate Unexecuted instantiation: pei-arm-wince.c:dummy_reloc16_estimate Unexecuted instantiation: pei-arm.c:dummy_reloc16_estimate Unexecuted instantiation: pei-mcore.c:dummy_reloc16_estimate Unexecuted instantiation: pei-sh.c:dummy_reloc16_estimate |
5363 | | |
5364 | | #endif |
5365 | | |
5366 | | #ifndef coff_reloc16_extra_cases |
5367 | | |
5368 | | #define coff_reloc16_extra_cases dummy_reloc16_extra_cases |
5369 | | |
5370 | | static bool |
5371 | | dummy_reloc16_extra_cases (bfd *abfd ATTRIBUTE_UNUSED, |
5372 | | struct bfd_link_info *link_info ATTRIBUTE_UNUSED, |
5373 | | struct bfd_link_order *link_order ATTRIBUTE_UNUSED, |
5374 | | arelent *reloc ATTRIBUTE_UNUSED, |
5375 | | bfd_byte *data ATTRIBUTE_UNUSED, |
5376 | | size_t *src_ptr ATTRIBUTE_UNUSED, |
5377 | | size_t *dst_ptr ATTRIBUTE_UNUSED) |
5378 | 0 | { |
5379 | 0 | return false; |
5380 | 0 | } Unexecuted instantiation: pei-i386.c:dummy_reloc16_extra_cases Unexecuted instantiation: pe-x86_64.c:dummy_reloc16_extra_cases Unexecuted instantiation: pei-x86_64.c:dummy_reloc16_extra_cases Unexecuted instantiation: coff-x86_64.c:dummy_reloc16_extra_cases Unexecuted instantiation: coff64-rs6000.c:dummy_reloc16_extra_cases Unexecuted instantiation: pei-aarch64.c:dummy_reloc16_extra_cases Unexecuted instantiation: pe-aarch64.c:dummy_reloc16_extra_cases Unexecuted instantiation: pei-ia64.c:dummy_reloc16_extra_cases Unexecuted instantiation: pei-loongarch64.c:dummy_reloc16_extra_cases Unexecuted instantiation: cf-i386lynx.c:dummy_reloc16_extra_cases Unexecuted instantiation: coff-go32.c:dummy_reloc16_extra_cases Unexecuted instantiation: coff-i386.c:dummy_reloc16_extra_cases Unexecuted instantiation: coff-rs6000.c:dummy_reloc16_extra_cases Unexecuted instantiation: coff-sh.c:dummy_reloc16_extra_cases Unexecuted instantiation: coff-stgo32.c:dummy_reloc16_extra_cases Unexecuted instantiation: coff-tic30.c:dummy_reloc16_extra_cases Unexecuted instantiation: coff-tic4x.c:dummy_reloc16_extra_cases Unexecuted instantiation: coff-tic54x.c:dummy_reloc16_extra_cases Unexecuted instantiation: pe-arm-wince.c:dummy_reloc16_extra_cases Unexecuted instantiation: pe-arm.c:dummy_reloc16_extra_cases Unexecuted instantiation: pe-i386.c:dummy_reloc16_extra_cases Unexecuted instantiation: pe-mcore.c:dummy_reloc16_extra_cases Unexecuted instantiation: pe-sh.c:dummy_reloc16_extra_cases Unexecuted instantiation: pei-arm-wince.c:dummy_reloc16_extra_cases Unexecuted instantiation: pei-arm.c:dummy_reloc16_extra_cases Unexecuted instantiation: pei-mcore.c:dummy_reloc16_extra_cases Unexecuted instantiation: pei-sh.c:dummy_reloc16_extra_cases |
5381 | | #endif |
5382 | | |
5383 | | /* If coff_relocate_section is defined, we can use the optimized COFF |
5384 | | backend linker. Otherwise we must continue to use the old linker. */ |
5385 | | |
5386 | | #ifdef coff_relocate_section |
5387 | | |
5388 | | #ifndef coff_bfd_link_hash_table_create |
5389 | | #define coff_bfd_link_hash_table_create _bfd_coff_link_hash_table_create |
5390 | | #endif |
5391 | | #ifndef coff_bfd_link_add_symbols |
5392 | | #define coff_bfd_link_add_symbols _bfd_coff_link_add_symbols |
5393 | | #endif |
5394 | | #ifndef coff_bfd_final_link |
5395 | | #define coff_bfd_final_link _bfd_coff_final_link |
5396 | | #endif |
5397 | | |
5398 | | #else /* ! defined (coff_relocate_section) */ |
5399 | | |
5400 | | #define coff_relocate_section NULL |
5401 | | #ifndef coff_bfd_link_hash_table_create |
5402 | | #define coff_bfd_link_hash_table_create _bfd_generic_link_hash_table_create |
5403 | | #endif |
5404 | | #ifndef coff_bfd_link_add_symbols |
5405 | | #define coff_bfd_link_add_symbols _bfd_generic_link_add_symbols |
5406 | | #endif |
5407 | | #define coff_bfd_final_link _bfd_generic_final_link |
5408 | | |
5409 | | #endif /* ! defined (coff_relocate_section) */ |
5410 | | |
5411 | | #define coff_bfd_link_just_syms _bfd_generic_link_just_syms |
5412 | | #define coff_bfd_copy_link_hash_symbol_type \ |
5413 | | _bfd_generic_copy_link_hash_symbol_type |
5414 | | #define coff_bfd_link_split_section _bfd_generic_link_split_section |
5415 | | |
5416 | | #define coff_bfd_link_check_relocs _bfd_generic_link_check_relocs |
5417 | | |
5418 | | #ifndef coff_start_final_link |
5419 | | #define coff_start_final_link NULL |
5420 | | #endif |
5421 | | |
5422 | | #ifndef coff_adjust_symndx |
5423 | | #define coff_adjust_symndx NULL |
5424 | | #endif |
5425 | | |
5426 | | #ifndef coff_link_add_one_symbol |
5427 | | #define coff_link_add_one_symbol _bfd_generic_link_add_one_symbol |
5428 | | #endif |
5429 | | |
5430 | | #ifndef coff_link_output_has_begun |
5431 | | |
5432 | | static bool |
5433 | | coff_link_output_has_begun (bfd * abfd, |
5434 | | struct coff_final_link_info * info ATTRIBUTE_UNUSED) |
5435 | 0 | { |
5436 | 0 | return abfd->output_has_begun; |
5437 | 0 | } Unexecuted instantiation: pei-i386.c:coff_link_output_has_begun Unexecuted instantiation: pe-x86_64.c:coff_link_output_has_begun Unexecuted instantiation: pei-x86_64.c:coff_link_output_has_begun Unexecuted instantiation: coff-x86_64.c:coff_link_output_has_begun Unexecuted instantiation: coff64-rs6000.c:coff_link_output_has_begun Unexecuted instantiation: pei-aarch64.c:coff_link_output_has_begun Unexecuted instantiation: pe-aarch64.c:coff_link_output_has_begun Unexecuted instantiation: pei-ia64.c:coff_link_output_has_begun Unexecuted instantiation: pei-loongarch64.c:coff_link_output_has_begun Unexecuted instantiation: cf-i386lynx.c:coff_link_output_has_begun Unexecuted instantiation: coff-go32.c:coff_link_output_has_begun Unexecuted instantiation: coff-i386.c:coff_link_output_has_begun Unexecuted instantiation: coff-rs6000.c:coff_link_output_has_begun Unexecuted instantiation: coff-sh.c:coff_link_output_has_begun Unexecuted instantiation: coff-stgo32.c:coff_link_output_has_begun Unexecuted instantiation: coff-tic30.c:coff_link_output_has_begun Unexecuted instantiation: coff-tic4x.c:coff_link_output_has_begun Unexecuted instantiation: coff-tic54x.c:coff_link_output_has_begun Unexecuted instantiation: coff-z80.c:coff_link_output_has_begun Unexecuted instantiation: coff-z8k.c:coff_link_output_has_begun Unexecuted instantiation: pe-i386.c:coff_link_output_has_begun Unexecuted instantiation: pe-mcore.c:coff_link_output_has_begun Unexecuted instantiation: pe-sh.c:coff_link_output_has_begun Unexecuted instantiation: pei-mcore.c:coff_link_output_has_begun Unexecuted instantiation: pei-sh.c:coff_link_output_has_begun |
5438 | | #endif |
5439 | | |
5440 | | #ifndef coff_final_link_postscript |
5441 | | |
5442 | | static bool |
5443 | | coff_final_link_postscript (bfd * abfd ATTRIBUTE_UNUSED, |
5444 | | struct coff_final_link_info * pfinfo ATTRIBUTE_UNUSED) |
5445 | 0 | { |
5446 | 0 | return true; |
5447 | 0 | } Unexecuted instantiation: coff-x86_64.c:coff_final_link_postscript Unexecuted instantiation: coff64-rs6000.c:coff_final_link_postscript Unexecuted instantiation: cf-i386lynx.c:coff_final_link_postscript Unexecuted instantiation: coff-go32.c:coff_final_link_postscript Unexecuted instantiation: coff-i386.c:coff_final_link_postscript Unexecuted instantiation: coff-rs6000.c:coff_final_link_postscript Unexecuted instantiation: coff-sh.c:coff_final_link_postscript Unexecuted instantiation: coff-stgo32.c:coff_final_link_postscript Unexecuted instantiation: coff-tic30.c:coff_final_link_postscript Unexecuted instantiation: coff-tic4x.c:coff_final_link_postscript Unexecuted instantiation: coff-tic54x.c:coff_final_link_postscript Unexecuted instantiation: coff-z80.c:coff_final_link_postscript Unexecuted instantiation: coff-z8k.c:coff_final_link_postscript |
5448 | | #endif |
5449 | | |
5450 | | #ifndef coff_SWAP_aux_in |
5451 | | #define coff_SWAP_aux_in coff_swap_aux_in |
5452 | | #endif |
5453 | | #ifndef coff_SWAP_sym_in |
5454 | | #define coff_SWAP_sym_in coff_swap_sym_in |
5455 | | #endif |
5456 | | #ifndef coff_SWAP_lineno_in |
5457 | | #define coff_SWAP_lineno_in coff_swap_lineno_in |
5458 | | #endif |
5459 | | #ifndef coff_SWAP_aux_out |
5460 | | #define coff_SWAP_aux_out coff_swap_aux_out |
5461 | | #endif |
5462 | | #ifndef coff_SWAP_sym_out |
5463 | | #define coff_SWAP_sym_out coff_swap_sym_out |
5464 | | #endif |
5465 | | #ifndef coff_SWAP_lineno_out |
5466 | | #define coff_SWAP_lineno_out coff_swap_lineno_out |
5467 | | #endif |
5468 | | #ifndef coff_SWAP_reloc_out |
5469 | | #define coff_SWAP_reloc_out coff_swap_reloc_out |
5470 | | #endif |
5471 | | #ifndef coff_SWAP_filehdr_out |
5472 | | #define coff_SWAP_filehdr_out coff_swap_filehdr_out |
5473 | | #endif |
5474 | | #ifndef coff_SWAP_aouthdr_out |
5475 | | #define coff_SWAP_aouthdr_out coff_swap_aouthdr_out |
5476 | | #endif |
5477 | | #ifndef coff_SWAP_scnhdr_out |
5478 | | #define coff_SWAP_scnhdr_out coff_swap_scnhdr_out |
5479 | | #endif |
5480 | | #ifndef coff_SWAP_reloc_in |
5481 | | #define coff_SWAP_reloc_in coff_swap_reloc_in |
5482 | | #endif |
5483 | | #ifndef coff_SWAP_filehdr_in |
5484 | | #define coff_SWAP_filehdr_in coff_swap_filehdr_in |
5485 | | #endif |
5486 | | #ifndef coff_SWAP_aouthdr_in |
5487 | | #define coff_SWAP_aouthdr_in coff_swap_aouthdr_in |
5488 | | #endif |
5489 | | #ifndef coff_SWAP_scnhdr_in |
5490 | | #define coff_SWAP_scnhdr_in coff_swap_scnhdr_in |
5491 | | #endif |
5492 | | |
5493 | | #define COFF_SWAP_TABLE (void *) &bfd_coff_std_swap_table |
5494 | | |
5495 | | static const bfd_coff_backend_data bfd_coff_std_swap_table ATTRIBUTE_UNUSED = |
5496 | | { |
5497 | | coff_SWAP_aux_in, coff_SWAP_sym_in, coff_SWAP_lineno_in, |
5498 | | coff_SWAP_aux_out, coff_SWAP_sym_out, |
5499 | | coff_SWAP_lineno_out, coff_SWAP_reloc_out, |
5500 | | coff_SWAP_filehdr_out, coff_SWAP_aouthdr_out, |
5501 | | coff_SWAP_scnhdr_out, |
5502 | | FILHSZ, AOUTSZ, SCNHSZ, SYMESZ, AUXESZ, RELSZ, LINESZ, FILNMLEN, |
5503 | | #ifdef COFF_LONG_FILENAMES |
5504 | | true, |
5505 | | #else |
5506 | | false, |
5507 | | #endif |
5508 | | COFF_DEFAULT_LONG_SECTION_NAMES, |
5509 | | COFF_DEFAULT_SECTION_ALIGNMENT_POWER, |
5510 | | #ifdef COFF_FORCE_SYMBOLS_IN_STRINGS |
5511 | | true, |
5512 | | #else |
5513 | | false, |
5514 | | #endif |
5515 | | #ifdef COFF_DEBUG_STRING_WIDE_PREFIX |
5516 | | 4, |
5517 | | #else |
5518 | | 2, |
5519 | | #endif |
5520 | | 32768, |
5521 | | coff_SWAP_filehdr_in, coff_SWAP_aouthdr_in, coff_SWAP_scnhdr_in, |
5522 | | coff_SWAP_reloc_in, coff_bad_format_hook, coff_set_arch_mach_hook, |
5523 | | coff_mkobject_hook, styp_to_sec_flags, coff_set_alignment_hook, |
5524 | | coff_slurp_symbol_table, symname_in_debug_hook, coff_pointerize_aux_hook, |
5525 | | coff_print_aux, coff_reloc16_extra_cases, coff_reloc16_estimate, |
5526 | | coff_classify_symbol, coff_compute_section_file_positions, |
5527 | | coff_start_final_link, coff_relocate_section, coff_rtype_to_howto, |
5528 | | coff_adjust_symndx, coff_link_add_one_symbol, |
5529 | | coff_link_output_has_begun, coff_final_link_postscript, |
5530 | | bfd_pe_print_pdata |
5531 | | }; |
5532 | | |
5533 | | #ifdef TICOFF |
5534 | | /* COFF0 differs in file/section header size and relocation entry size. */ |
5535 | | |
5536 | | static const bfd_coff_backend_data ticoff0_swap_table = |
5537 | | { |
5538 | | coff_SWAP_aux_in, coff_SWAP_sym_in, coff_SWAP_lineno_in, |
5539 | | coff_SWAP_aux_out, coff_SWAP_sym_out, |
5540 | | coff_SWAP_lineno_out, coff_swap_reloc_v0_out, |
5541 | | coff_SWAP_filehdr_out, coff_SWAP_aouthdr_out, |
5542 | | coff_SWAP_scnhdr_out, |
5543 | | FILHSZ_V0, AOUTSZ, SCNHSZ_V01, SYMESZ, AUXESZ, RELSZ_V0, LINESZ, FILNMLEN, |
5544 | | #ifdef COFF_LONG_FILENAMES |
5545 | | true, |
5546 | | #else |
5547 | | false, |
5548 | | #endif |
5549 | | COFF_DEFAULT_LONG_SECTION_NAMES, |
5550 | | COFF_DEFAULT_SECTION_ALIGNMENT_POWER, |
5551 | | #ifdef COFF_FORCE_SYMBOLS_IN_STRINGS |
5552 | | true, |
5553 | | #else |
5554 | | false, |
5555 | | #endif |
5556 | | #ifdef COFF_DEBUG_STRING_WIDE_PREFIX |
5557 | | 4, |
5558 | | #else |
5559 | | 2, |
5560 | | #endif |
5561 | | 32768, |
5562 | | coff_SWAP_filehdr_in, coff_SWAP_aouthdr_in, coff_SWAP_scnhdr_in, |
5563 | | coff_swap_reloc_v0_in, ticoff0_bad_format_hook, coff_set_arch_mach_hook, |
5564 | | coff_mkobject_hook, styp_to_sec_flags, coff_set_alignment_hook, |
5565 | | coff_slurp_symbol_table, symname_in_debug_hook, coff_pointerize_aux_hook, |
5566 | | coff_print_aux, coff_reloc16_extra_cases, coff_reloc16_estimate, |
5567 | | coff_classify_symbol, coff_compute_section_file_positions, |
5568 | | coff_start_final_link, coff_relocate_section, coff_rtype_to_howto, |
5569 | | coff_adjust_symndx, coff_link_add_one_symbol, |
5570 | | coff_link_output_has_begun, coff_final_link_postscript, |
5571 | | bfd_pe_print_pdata |
5572 | | }; |
5573 | | #endif |
5574 | | |
5575 | | #ifdef TICOFF |
5576 | | /* COFF1 differs in section header size. */ |
5577 | | |
5578 | | static const bfd_coff_backend_data ticoff1_swap_table = |
5579 | | { |
5580 | | coff_SWAP_aux_in, coff_SWAP_sym_in, coff_SWAP_lineno_in, |
5581 | | coff_SWAP_aux_out, coff_SWAP_sym_out, |
5582 | | coff_SWAP_lineno_out, coff_SWAP_reloc_out, |
5583 | | coff_SWAP_filehdr_out, coff_SWAP_aouthdr_out, |
5584 | | coff_SWAP_scnhdr_out, |
5585 | | FILHSZ, AOUTSZ, SCNHSZ_V01, SYMESZ, AUXESZ, RELSZ, LINESZ, FILNMLEN, |
5586 | | #ifdef COFF_LONG_FILENAMES |
5587 | | true, |
5588 | | #else |
5589 | | false, |
5590 | | #endif |
5591 | | COFF_DEFAULT_LONG_SECTION_NAMES, |
5592 | | COFF_DEFAULT_SECTION_ALIGNMENT_POWER, |
5593 | | #ifdef COFF_FORCE_SYMBOLS_IN_STRINGS |
5594 | | true, |
5595 | | #else |
5596 | | false, |
5597 | | #endif |
5598 | | #ifdef COFF_DEBUG_STRING_WIDE_PREFIX |
5599 | | 4, |
5600 | | #else |
5601 | | 2, |
5602 | | #endif |
5603 | | 32768, |
5604 | | coff_SWAP_filehdr_in, coff_SWAP_aouthdr_in, coff_SWAP_scnhdr_in, |
5605 | | coff_SWAP_reloc_in, ticoff1_bad_format_hook, coff_set_arch_mach_hook, |
5606 | | coff_mkobject_hook, styp_to_sec_flags, coff_set_alignment_hook, |
5607 | | coff_slurp_symbol_table, symname_in_debug_hook, coff_pointerize_aux_hook, |
5608 | | coff_print_aux, coff_reloc16_extra_cases, coff_reloc16_estimate, |
5609 | | coff_classify_symbol, coff_compute_section_file_positions, |
5610 | | coff_start_final_link, coff_relocate_section, coff_rtype_to_howto, |
5611 | | coff_adjust_symndx, coff_link_add_one_symbol, |
5612 | | coff_link_output_has_begun, coff_final_link_postscript, |
5613 | | bfd_pe_print_pdata /* huh */ |
5614 | | }; |
5615 | | #endif |
5616 | | |
5617 | | #ifdef COFF_WITH_PE_BIGOBJ |
5618 | | /* The UID for bigobj files. */ |
5619 | | |
5620 | | static const char header_bigobj_classid[16] = |
5621 | | { |
5622 | | 0xC7, 0xA1, 0xBA, 0xD1, |
5623 | | 0xEE, 0xBA, |
5624 | | 0xa9, 0x4b, |
5625 | | 0xAF, 0x20, |
5626 | | 0xFA, 0xF6, 0x6A, 0xA4, 0xDC, 0xB8 |
5627 | | }; |
5628 | | |
5629 | | /* Swap routines. */ |
5630 | | |
5631 | | static void |
5632 | | coff_bigobj_swap_filehdr_in (bfd * abfd, void * src, void * dst) |
5633 | 38.4k | { |
5634 | 38.4k | struct external_ANON_OBJECT_HEADER_BIGOBJ *filehdr_src = |
5635 | 38.4k | (struct external_ANON_OBJECT_HEADER_BIGOBJ *) src; |
5636 | 38.4k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; |
5637 | | |
5638 | 38.4k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->Machine); |
5639 | 38.4k | filehdr_dst->f_nscns = H_GET_32 (abfd, filehdr_src->NumberOfSections); |
5640 | 38.4k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->TimeDateStamp); |
5641 | 38.4k | filehdr_dst->f_symptr = |
5642 | 38.4k | GET_FILEHDR_SYMPTR (abfd, filehdr_src->PointerToSymbolTable); |
5643 | 38.4k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->NumberOfSymbols); |
5644 | 38.4k | filehdr_dst->f_opthdr = 0; |
5645 | 38.4k | filehdr_dst->f_flags = 0; |
5646 | | |
5647 | | /* Check other magic numbers. */ |
5648 | 38.4k | if (H_GET_16 (abfd, filehdr_src->Sig1) != IMAGE_FILE_MACHINE_UNKNOWN |
5649 | 38.4k | || H_GET_16 (abfd, filehdr_src->Sig2) != 0xffff |
5650 | 38.4k | || H_GET_16 (abfd, filehdr_src->Version) != 2 |
5651 | 38.4k | || memcmp (filehdr_src->ClassID, header_bigobj_classid, 16) != 0) |
5652 | 38.3k | filehdr_dst->f_opthdr = 0xffff; |
5653 | | |
5654 | | /* Note that CLR metadata are ignored. */ |
5655 | 38.4k | } pe-x86_64.c:coff_bigobj_swap_filehdr_in Line | Count | Source | 5633 | 19.2k | { | 5634 | 19.2k | struct external_ANON_OBJECT_HEADER_BIGOBJ *filehdr_src = | 5635 | 19.2k | (struct external_ANON_OBJECT_HEADER_BIGOBJ *) src; | 5636 | 19.2k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 5637 | | | 5638 | 19.2k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->Machine); | 5639 | 19.2k | filehdr_dst->f_nscns = H_GET_32 (abfd, filehdr_src->NumberOfSections); | 5640 | 19.2k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->TimeDateStamp); | 5641 | 19.2k | filehdr_dst->f_symptr = | 5642 | 19.2k | GET_FILEHDR_SYMPTR (abfd, filehdr_src->PointerToSymbolTable); | 5643 | 19.2k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->NumberOfSymbols); | 5644 | 19.2k | filehdr_dst->f_opthdr = 0; | 5645 | 19.2k | filehdr_dst->f_flags = 0; | 5646 | | | 5647 | | /* Check other magic numbers. */ | 5648 | 19.2k | if (H_GET_16 (abfd, filehdr_src->Sig1) != IMAGE_FILE_MACHINE_UNKNOWN | 5649 | 19.2k | || H_GET_16 (abfd, filehdr_src->Sig2) != 0xffff | 5650 | 19.2k | || H_GET_16 (abfd, filehdr_src->Version) != 2 | 5651 | 19.2k | || memcmp (filehdr_src->ClassID, header_bigobj_classid, 16) != 0) | 5652 | 19.1k | filehdr_dst->f_opthdr = 0xffff; | 5653 | | | 5654 | | /* Note that CLR metadata are ignored. */ | 5655 | 19.2k | } |
pe-i386.c:coff_bigobj_swap_filehdr_in Line | Count | Source | 5633 | 19.2k | { | 5634 | 19.2k | struct external_ANON_OBJECT_HEADER_BIGOBJ *filehdr_src = | 5635 | 19.2k | (struct external_ANON_OBJECT_HEADER_BIGOBJ *) src; | 5636 | 19.2k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 5637 | | | 5638 | 19.2k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->Machine); | 5639 | 19.2k | filehdr_dst->f_nscns = H_GET_32 (abfd, filehdr_src->NumberOfSections); | 5640 | 19.2k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->TimeDateStamp); | 5641 | 19.2k | filehdr_dst->f_symptr = | 5642 | 19.2k | GET_FILEHDR_SYMPTR (abfd, filehdr_src->PointerToSymbolTable); | 5643 | 19.2k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->NumberOfSymbols); | 5644 | 19.2k | filehdr_dst->f_opthdr = 0; | 5645 | 19.2k | filehdr_dst->f_flags = 0; | 5646 | | | 5647 | | /* Check other magic numbers. */ | 5648 | 19.2k | if (H_GET_16 (abfd, filehdr_src->Sig1) != IMAGE_FILE_MACHINE_UNKNOWN | 5649 | 19.2k | || H_GET_16 (abfd, filehdr_src->Sig2) != 0xffff | 5650 | 19.2k | || H_GET_16 (abfd, filehdr_src->Version) != 2 | 5651 | 19.2k | || memcmp (filehdr_src->ClassID, header_bigobj_classid, 16) != 0) | 5652 | 19.1k | filehdr_dst->f_opthdr = 0xffff; | 5653 | | | 5654 | | /* Note that CLR metadata are ignored. */ | 5655 | 19.2k | } |
|
5656 | | |
5657 | | static unsigned int |
5658 | | coff_bigobj_swap_filehdr_out (bfd *abfd, void * in, void * out) |
5659 | 0 | { |
5660 | 0 | struct internal_filehdr *filehdr_in = (struct internal_filehdr *) in; |
5661 | 0 | struct external_ANON_OBJECT_HEADER_BIGOBJ *filehdr_out = |
5662 | 0 | (struct external_ANON_OBJECT_HEADER_BIGOBJ *) out; |
5663 | |
|
5664 | 0 | memset (filehdr_out, 0, sizeof (*filehdr_out)); |
5665 | |
|
5666 | 0 | H_PUT_16 (abfd, IMAGE_FILE_MACHINE_UNKNOWN, filehdr_out->Sig1); |
5667 | 0 | H_PUT_16 (abfd, 0xffff, filehdr_out->Sig2); |
5668 | 0 | H_PUT_16 (abfd, 2, filehdr_out->Version); |
5669 | 0 | memcpy (filehdr_out->ClassID, header_bigobj_classid, 16); |
5670 | 0 | H_PUT_16 (abfd, filehdr_in->f_magic, filehdr_out->Machine); |
5671 | 0 | H_PUT_32 (abfd, filehdr_in->f_nscns, filehdr_out->NumberOfSections); |
5672 | 0 | H_PUT_32 (abfd, filehdr_in->f_timdat, filehdr_out->TimeDateStamp); |
5673 | 0 | PUT_FILEHDR_SYMPTR (abfd, filehdr_in->f_symptr, |
5674 | 0 | filehdr_out->PointerToSymbolTable); |
5675 | 0 | H_PUT_32 (abfd, filehdr_in->f_nsyms, filehdr_out->NumberOfSymbols); |
5676 | |
|
5677 | 0 | return bfd_coff_filhsz (abfd); |
5678 | 0 | } Unexecuted instantiation: pe-x86_64.c:coff_bigobj_swap_filehdr_out Unexecuted instantiation: pe-i386.c:coff_bigobj_swap_filehdr_out |
5679 | | |
5680 | | static void |
5681 | | coff_bigobj_swap_sym_in (bfd * abfd, void * ext1, void * in1) |
5682 | 78.2k | { |
5683 | 78.2k | SYMENT_BIGOBJ *ext = (SYMENT_BIGOBJ *) ext1; |
5684 | 78.2k | struct internal_syment *in = (struct internal_syment *) in1; |
5685 | | |
5686 | 78.2k | if (ext->e.e_name[0] == 0) |
5687 | 61.3k | { |
5688 | 61.3k | in->_n._n_n._n_zeroes = 0; |
5689 | 61.3k | in->_n._n_n._n_offset = H_GET_32 (abfd, ext->e.e.e_offset); |
5690 | 61.3k | } |
5691 | 16.9k | else |
5692 | 16.9k | { |
5693 | | #if SYMNMLEN != E_SYMNMLEN |
5694 | | #error we need to cope with truncating or extending SYMNMLEN |
5695 | | #else |
5696 | 16.9k | memcpy (in->_n._n_name, ext->e.e_name, SYMNMLEN); |
5697 | 16.9k | #endif |
5698 | 16.9k | } |
5699 | | |
5700 | 78.2k | in->n_value = H_GET_32 (abfd, ext->e_value); |
5701 | 78.2k | BFD_ASSERT (sizeof (in->n_scnum) >= 4); |
5702 | 78.2k | in->n_scnum = H_GET_32 (abfd, ext->e_scnum); |
5703 | 78.2k | in->n_type = H_GET_16 (abfd, ext->e_type); |
5704 | 78.2k | in->n_sclass = H_GET_8 (abfd, ext->e_sclass); |
5705 | 78.2k | in->n_numaux = H_GET_8 (abfd, ext->e_numaux); |
5706 | 78.2k | } pe-x86_64.c:coff_bigobj_swap_sym_in Line | Count | Source | 5682 | 78.2k | { | 5683 | 78.2k | SYMENT_BIGOBJ *ext = (SYMENT_BIGOBJ *) ext1; | 5684 | 78.2k | struct internal_syment *in = (struct internal_syment *) in1; | 5685 | | | 5686 | 78.2k | if (ext->e.e_name[0] == 0) | 5687 | 61.3k | { | 5688 | 61.3k | in->_n._n_n._n_zeroes = 0; | 5689 | 61.3k | in->_n._n_n._n_offset = H_GET_32 (abfd, ext->e.e.e_offset); | 5690 | 61.3k | } | 5691 | 16.9k | else | 5692 | 16.9k | { | 5693 | | #if SYMNMLEN != E_SYMNMLEN | 5694 | | #error we need to cope with truncating or extending SYMNMLEN | 5695 | | #else | 5696 | 16.9k | memcpy (in->_n._n_name, ext->e.e_name, SYMNMLEN); | 5697 | 16.9k | #endif | 5698 | 16.9k | } | 5699 | | | 5700 | 78.2k | in->n_value = H_GET_32 (abfd, ext->e_value); | 5701 | 78.2k | BFD_ASSERT (sizeof (in->n_scnum) >= 4); | 5702 | 78.2k | in->n_scnum = H_GET_32 (abfd, ext->e_scnum); | 5703 | 78.2k | in->n_type = H_GET_16 (abfd, ext->e_type); | 5704 | 78.2k | in->n_sclass = H_GET_8 (abfd, ext->e_sclass); | 5705 | 78.2k | in->n_numaux = H_GET_8 (abfd, ext->e_numaux); | 5706 | 78.2k | } |
Unexecuted instantiation: pe-i386.c:coff_bigobj_swap_sym_in |
5707 | | |
5708 | | static unsigned int |
5709 | | coff_bigobj_swap_sym_out (bfd * abfd, void * inp, void * extp) |
5710 | 0 | { |
5711 | 0 | struct internal_syment *in = (struct internal_syment *) inp; |
5712 | 0 | SYMENT_BIGOBJ *ext = (SYMENT_BIGOBJ *) extp; |
5713 | |
|
5714 | 0 | if (in->_n._n_name[0] == 0) |
5715 | 0 | { |
5716 | 0 | H_PUT_32 (abfd, 0, ext->e.e.e_zeroes); |
5717 | 0 | H_PUT_32 (abfd, in->_n._n_n._n_offset, ext->e.e.e_offset); |
5718 | 0 | } |
5719 | 0 | else |
5720 | 0 | { |
5721 | | #if SYMNMLEN != E_SYMNMLEN |
5722 | | #error we need to cope with truncating or extending SYMNMLEN |
5723 | | #else |
5724 | 0 | memcpy (ext->e.e_name, in->_n._n_name, SYMNMLEN); |
5725 | 0 | #endif |
5726 | 0 | } |
5727 | |
|
5728 | 0 | H_PUT_32 (abfd, in->n_value, ext->e_value); |
5729 | 0 | H_PUT_32 (abfd, in->n_scnum, ext->e_scnum); |
5730 | |
|
5731 | 0 | H_PUT_16 (abfd, in->n_type, ext->e_type); |
5732 | 0 | H_PUT_8 (abfd, in->n_sclass, ext->e_sclass); |
5733 | 0 | H_PUT_8 (abfd, in->n_numaux, ext->e_numaux); |
5734 | |
|
5735 | 0 | return SYMESZ_BIGOBJ; |
5736 | 0 | } Unexecuted instantiation: pe-x86_64.c:coff_bigobj_swap_sym_out Unexecuted instantiation: pe-i386.c:coff_bigobj_swap_sym_out |
5737 | | |
5738 | | static void |
5739 | | coff_bigobj_swap_aux_in (bfd *abfd, |
5740 | | void * ext1, |
5741 | | int type, |
5742 | | int in_class, |
5743 | | int indx, |
5744 | | int numaux, |
5745 | | void * in1) |
5746 | 504k | { |
5747 | 504k | AUXENT_BIGOBJ *ext = (AUXENT_BIGOBJ *) ext1; |
5748 | 504k | union internal_auxent *in = (union internal_auxent *) in1; |
5749 | | |
5750 | | /* Make sure that all fields in the aux structure are |
5751 | | initialised. */ |
5752 | 504k | memset (in, 0, sizeof * in); |
5753 | 504k | switch (in_class) |
5754 | 504k | { |
5755 | 16.5k | case C_FILE: |
5756 | 16.5k | if (numaux > 1) |
5757 | 16.5k | { |
5758 | 16.5k | if (indx == 0) |
5759 | 163 | memcpy (in->x_file.x_n.x_fname, ext->File.Name, |
5760 | 163 | numaux * sizeof (AUXENT_BIGOBJ)); |
5761 | 16.5k | } |
5762 | 11 | else |
5763 | 11 | memcpy (in->x_file.x_n.x_fname, ext->File.Name, sizeof (ext->File.Name)); |
5764 | 16.5k | break; |
5765 | | |
5766 | 9.77k | case C_STAT: |
5767 | 10.3k | case C_LEAFSTAT: |
5768 | 12.9k | case C_HIDDEN: |
5769 | 12.9k | if (type == T_NULL) |
5770 | 1.11k | { |
5771 | 1.11k | in->x_scn.x_scnlen = H_GET_32 (abfd, ext->Section.Length); |
5772 | 1.11k | in->x_scn.x_nreloc = |
5773 | 1.11k | H_GET_16 (abfd, ext->Section.NumberOfRelocations); |
5774 | 1.11k | in->x_scn.x_nlinno = |
5775 | 1.11k | H_GET_16 (abfd, ext->Section.NumberOfLinenumbers); |
5776 | 1.11k | in->x_scn.x_checksum = H_GET_32 (abfd, ext->Section.Checksum); |
5777 | 1.11k | in->x_scn.x_associated = H_GET_16 (abfd, ext->Section.Number) |
5778 | 1.11k | | (H_GET_16 (abfd, ext->Section.HighNumber) << 16); |
5779 | 1.11k | in->x_scn.x_comdat = H_GET_8 (abfd, ext->Section.Selection); |
5780 | 1.11k | return; |
5781 | 1.11k | } |
5782 | 11.8k | break; |
5783 | | |
5784 | 474k | default: |
5785 | 474k | in->x_sym.x_tagndx.u32 = H_GET_32 (abfd, ext->Sym.WeakDefaultSymIndex); |
5786 | | /* Characteristics is ignored. */ |
5787 | 474k | break; |
5788 | 504k | } |
5789 | 504k | } pe-x86_64.c:coff_bigobj_swap_aux_in Line | Count | Source | 5746 | 504k | { | 5747 | 504k | AUXENT_BIGOBJ *ext = (AUXENT_BIGOBJ *) ext1; | 5748 | 504k | union internal_auxent *in = (union internal_auxent *) in1; | 5749 | | | 5750 | | /* Make sure that all fields in the aux structure are | 5751 | | initialised. */ | 5752 | 504k | memset (in, 0, sizeof * in); | 5753 | 504k | switch (in_class) | 5754 | 504k | { | 5755 | 16.5k | case C_FILE: | 5756 | 16.5k | if (numaux > 1) | 5757 | 16.5k | { | 5758 | 16.5k | if (indx == 0) | 5759 | 163 | memcpy (in->x_file.x_n.x_fname, ext->File.Name, | 5760 | 163 | numaux * sizeof (AUXENT_BIGOBJ)); | 5761 | 16.5k | } | 5762 | 11 | else | 5763 | 11 | memcpy (in->x_file.x_n.x_fname, ext->File.Name, sizeof (ext->File.Name)); | 5764 | 16.5k | break; | 5765 | | | 5766 | 9.77k | case C_STAT: | 5767 | 10.3k | case C_LEAFSTAT: | 5768 | 12.9k | case C_HIDDEN: | 5769 | 12.9k | if (type == T_NULL) | 5770 | 1.11k | { | 5771 | 1.11k | in->x_scn.x_scnlen = H_GET_32 (abfd, ext->Section.Length); | 5772 | 1.11k | in->x_scn.x_nreloc = | 5773 | 1.11k | H_GET_16 (abfd, ext->Section.NumberOfRelocations); | 5774 | 1.11k | in->x_scn.x_nlinno = | 5775 | 1.11k | H_GET_16 (abfd, ext->Section.NumberOfLinenumbers); | 5776 | 1.11k | in->x_scn.x_checksum = H_GET_32 (abfd, ext->Section.Checksum); | 5777 | 1.11k | in->x_scn.x_associated = H_GET_16 (abfd, ext->Section.Number) | 5778 | 1.11k | | (H_GET_16 (abfd, ext->Section.HighNumber) << 16); | 5779 | 1.11k | in->x_scn.x_comdat = H_GET_8 (abfd, ext->Section.Selection); | 5780 | 1.11k | return; | 5781 | 1.11k | } | 5782 | 11.8k | break; | 5783 | | | 5784 | 474k | default: | 5785 | 474k | in->x_sym.x_tagndx.u32 = H_GET_32 (abfd, ext->Sym.WeakDefaultSymIndex); | 5786 | | /* Characteristics is ignored. */ | 5787 | 474k | break; | 5788 | 504k | } | 5789 | 504k | } |
Unexecuted instantiation: pe-i386.c:coff_bigobj_swap_aux_in |
5790 | | |
5791 | | static unsigned int |
5792 | | coff_bigobj_swap_aux_out (bfd * abfd, |
5793 | | void * inp, |
5794 | | int type, |
5795 | | int in_class, |
5796 | | int indx ATTRIBUTE_UNUSED, |
5797 | | int numaux ATTRIBUTE_UNUSED, |
5798 | | void * extp) |
5799 | 0 | { |
5800 | 0 | union internal_auxent * in = (union internal_auxent *) inp; |
5801 | 0 | AUXENT_BIGOBJ *ext = (AUXENT_BIGOBJ *) extp; |
5802 | |
|
5803 | 0 | memset (ext, 0, AUXESZ); |
5804 | |
|
5805 | 0 | switch (in_class) |
5806 | 0 | { |
5807 | 0 | case C_FILE: |
5808 | 0 | memcpy (ext->File.Name, in->x_file.x_n.x_fname, sizeof (ext->File.Name)); |
5809 | |
|
5810 | 0 | return AUXESZ; |
5811 | | |
5812 | 0 | case C_STAT: |
5813 | 0 | case C_LEAFSTAT: |
5814 | 0 | case C_HIDDEN: |
5815 | 0 | if (type == T_NULL) |
5816 | 0 | { |
5817 | 0 | H_PUT_32 (abfd, in->x_scn.x_scnlen, ext->Section.Length); |
5818 | 0 | H_PUT_16 (abfd, in->x_scn.x_nreloc, |
5819 | 0 | ext->Section.NumberOfRelocations); |
5820 | 0 | H_PUT_16 (abfd, in->x_scn.x_nlinno, |
5821 | 0 | ext->Section.NumberOfLinenumbers); |
5822 | 0 | H_PUT_32 (abfd, in->x_scn.x_checksum, ext->Section.Checksum); |
5823 | 0 | H_PUT_16 (abfd, in->x_scn.x_associated & 0xffff, |
5824 | 0 | ext->Section.Number); |
5825 | 0 | H_PUT_16 (abfd, (in->x_scn.x_associated >> 16), |
5826 | 0 | ext->Section.HighNumber); |
5827 | 0 | H_PUT_8 (abfd, in->x_scn.x_comdat, ext->Section.Selection); |
5828 | 0 | return AUXESZ; |
5829 | 0 | } |
5830 | 0 | break; |
5831 | 0 | } |
5832 | | |
5833 | 0 | H_PUT_32 (abfd, in->x_sym.x_tagndx.u32, ext->Sym.WeakDefaultSymIndex); |
5834 | 0 | H_PUT_32 (abfd, 1, ext->Sym.WeakSearchType); |
5835 | |
|
5836 | 0 | return AUXESZ; |
5837 | 0 | } Unexecuted instantiation: pe-x86_64.c:coff_bigobj_swap_aux_out Unexecuted instantiation: pe-i386.c:coff_bigobj_swap_aux_out |
5838 | | |
5839 | | static const bfd_coff_backend_data bigobj_swap_table = |
5840 | | { |
5841 | | coff_bigobj_swap_aux_in, coff_bigobj_swap_sym_in, coff_SWAP_lineno_in, |
5842 | | coff_bigobj_swap_aux_out, coff_bigobj_swap_sym_out, |
5843 | | coff_SWAP_lineno_out, coff_SWAP_reloc_out, |
5844 | | coff_bigobj_swap_filehdr_out, coff_SWAP_aouthdr_out, |
5845 | | coff_SWAP_scnhdr_out, |
5846 | | FILHSZ_BIGOBJ, AOUTSZ, SCNHSZ, SYMESZ_BIGOBJ, AUXESZ_BIGOBJ, |
5847 | | RELSZ, LINESZ, FILNMLEN_BIGOBJ, |
5848 | | true, |
5849 | | COFF_DEFAULT_LONG_SECTION_NAMES, |
5850 | | COFF_DEFAULT_SECTION_ALIGNMENT_POWER, |
5851 | | false, |
5852 | | 2, |
5853 | | 1U << 31, |
5854 | | coff_bigobj_swap_filehdr_in, coff_SWAP_aouthdr_in, coff_SWAP_scnhdr_in, |
5855 | | coff_SWAP_reloc_in, coff_bad_format_hook, coff_set_arch_mach_hook, |
5856 | | coff_mkobject_hook, styp_to_sec_flags, coff_set_alignment_hook, |
5857 | | coff_slurp_symbol_table, symname_in_debug_hook, coff_pointerize_aux_hook, |
5858 | | coff_print_aux, coff_reloc16_extra_cases, coff_reloc16_estimate, |
5859 | | coff_classify_symbol, coff_compute_section_file_positions, |
5860 | | coff_start_final_link, coff_relocate_section, coff_rtype_to_howto, |
5861 | | coff_adjust_symndx, coff_link_add_one_symbol, |
5862 | | coff_link_output_has_begun, coff_final_link_postscript, |
5863 | | bfd_pe_print_pdata /* huh */ |
5864 | | }; |
5865 | | |
5866 | | #endif /* COFF_WITH_PE_BIGOBJ */ |
5867 | | |
5868 | | #ifndef coff_close_and_cleanup |
5869 | | #define coff_close_and_cleanup _bfd_generic_close_and_cleanup |
5870 | | #endif |
5871 | | |
5872 | | #ifndef coff_bfd_free_cached_info |
5873 | | #define coff_bfd_free_cached_info _bfd_coff_free_cached_info |
5874 | | #endif |
5875 | | |
5876 | | #ifndef coff_get_section_contents |
5877 | | #define coff_get_section_contents _bfd_generic_get_section_contents |
5878 | | #endif |
5879 | | |
5880 | | #ifndef coff_bfd_copy_private_symbol_data |
5881 | | #define coff_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data |
5882 | | #endif |
5883 | | |
5884 | | #ifndef coff_bfd_copy_private_header_data |
5885 | | #define coff_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data |
5886 | | #endif |
5887 | | |
5888 | | #ifndef coff_bfd_copy_private_section_data |
5889 | | #define coff_bfd_copy_private_section_data _bfd_generic_bfd_copy_private_section_data |
5890 | | #endif |
5891 | | |
5892 | | #ifndef coff_bfd_copy_private_bfd_data |
5893 | | #define coff_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data |
5894 | | #endif |
5895 | | |
5896 | | #ifndef coff_bfd_merge_private_bfd_data |
5897 | | #define coff_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data |
5898 | | #endif |
5899 | | |
5900 | | #ifndef coff_bfd_set_private_flags |
5901 | | #define coff_bfd_set_private_flags _bfd_generic_bfd_set_private_flags |
5902 | | #endif |
5903 | | |
5904 | | #ifndef coff_bfd_print_private_bfd_data |
5905 | | #define coff_bfd_print_private_bfd_data _bfd_generic_bfd_print_private_bfd_data |
5906 | | #endif |
5907 | | |
5908 | | #ifndef coff_bfd_is_local_label_name |
5909 | | #define coff_bfd_is_local_label_name _bfd_coff_is_local_label_name |
5910 | | #endif |
5911 | | |
5912 | | #ifndef coff_bfd_is_target_special_symbol |
5913 | | #define coff_bfd_is_target_special_symbol _bfd_bool_bfd_asymbol_false |
5914 | | #endif |
5915 | | |
5916 | | #ifndef coff_read_minisymbols |
5917 | | #define coff_read_minisymbols _bfd_generic_read_minisymbols |
5918 | | #endif |
5919 | | |
5920 | | #ifndef coff_minisymbol_to_symbol |
5921 | | #define coff_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol |
5922 | | #endif |
5923 | | |
5924 | | /* The reloc lookup routine must be supplied by each individual COFF |
5925 | | backend. */ |
5926 | | #ifndef coff_bfd_reloc_type_lookup |
5927 | | #define coff_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup |
5928 | | #endif |
5929 | | #ifndef coff_bfd_reloc_name_lookup |
5930 | | #define coff_bfd_reloc_name_lookup _bfd_norelocs_bfd_reloc_name_lookup |
5931 | | #endif |
5932 | | |
5933 | | #ifndef coff_bfd_get_relocated_section_contents |
5934 | | #define coff_bfd_get_relocated_section_contents \ |
5935 | | bfd_generic_get_relocated_section_contents |
5936 | | #endif |
5937 | | |
5938 | | #ifndef coff_bfd_relax_section |
5939 | | #define coff_bfd_relax_section bfd_generic_relax_section |
5940 | | #endif |
5941 | | |
5942 | | #ifndef coff_bfd_gc_sections |
5943 | | #define coff_bfd_gc_sections bfd_coff_gc_sections |
5944 | | #endif |
5945 | | |
5946 | | #ifndef coff_bfd_lookup_section_flags |
5947 | | #define coff_bfd_lookup_section_flags bfd_generic_lookup_section_flags |
5948 | | #endif |
5949 | | |
5950 | | #ifndef coff_bfd_merge_sections |
5951 | | #define coff_bfd_merge_sections bfd_generic_merge_sections |
5952 | | #endif |
5953 | | |
5954 | | #ifndef coff_bfd_is_group_section |
5955 | | #define coff_bfd_is_group_section bfd_generic_is_group_section |
5956 | | #endif |
5957 | | |
5958 | | #ifndef coff_bfd_group_name |
5959 | | #define coff_bfd_group_name bfd_coff_group_name |
5960 | | #endif |
5961 | | |
5962 | | #ifndef coff_bfd_discard_group |
5963 | | #define coff_bfd_discard_group bfd_generic_discard_group |
5964 | | #endif |
5965 | | |
5966 | | #ifndef coff_section_already_linked |
5967 | | #define coff_section_already_linked \ |
5968 | | _bfd_coff_section_already_linked |
5969 | | #endif |
5970 | | |
5971 | | #ifndef coff_bfd_define_common_symbol |
5972 | | #define coff_bfd_define_common_symbol bfd_generic_define_common_symbol |
5973 | | #endif |
5974 | | |
5975 | | #ifndef coff_bfd_link_hide_symbol |
5976 | | #define coff_bfd_link_hide_symbol _bfd_generic_link_hide_symbol |
5977 | | #endif |
5978 | | |
5979 | | #ifndef coff_bfd_define_start_stop |
5980 | | #define coff_bfd_define_start_stop bfd_generic_define_start_stop |
5981 | | #endif |
5982 | | |
5983 | | #define CREATE_BIG_COFF_TARGET_VEC(VAR, NAME, EXTRA_O_FLAGS, EXTRA_S_FLAGS, UNDER, ALTERNATIVE, SWAP_TABLE) \ |
5984 | | const bfd_target VAR = \ |
5985 | | { \ |
5986 | | NAME , \ |
5987 | | bfd_target_coff_flavour, \ |
5988 | | BFD_ENDIAN_BIG, /* Data byte order is big. */ \ |
5989 | | BFD_ENDIAN_BIG, /* Header byte order is big. */ \ |
5990 | | /* object flags */ \ |
5991 | | (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | \ |
5992 | | HAS_SYMS | HAS_LOCALS | WP_TEXT | EXTRA_O_FLAGS), \ |
5993 | | /* section flags */ \ |
5994 | | (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | EXTRA_S_FLAGS),\ |
5995 | | UNDER, /* Leading symbol underscore. */ \ |
5996 | | '/', /* AR_pad_char. */ \ |
5997 | | 15, /* AR_max_namelen. */ \ |
5998 | | 0, /* match priority. */ \ |
5999 | | TARGET_KEEP_UNUSED_SECTION_SYMBOLS, /* keep unused section symbols. */ \ |
6000 | | \ |
6001 | | /* Data conversion functions. */ \ |
6002 | | bfd_getb64, bfd_getb_signed_64, bfd_putb64, \ |
6003 | | bfd_getb32, bfd_getb_signed_32, bfd_putb32, \ |
6004 | | bfd_getb16, bfd_getb_signed_16, bfd_putb16, \ |
6005 | | \ |
6006 | | /* Header conversion functions. */ \ |
6007 | | bfd_getb64, bfd_getb_signed_64, bfd_putb64, \ |
6008 | | bfd_getb32, bfd_getb_signed_32, bfd_putb32, \ |
6009 | | bfd_getb16, bfd_getb_signed_16, bfd_putb16, \ |
6010 | | \ |
6011 | | { /* bfd_check_format. */ \ |
6012 | | _bfd_dummy_target, \ |
6013 | | coff_object_p, \ |
6014 | | bfd_generic_archive_p, \ |
6015 | | _bfd_dummy_target \ |
6016 | | }, \ |
6017 | | { /* bfd_set_format. */ \ |
6018 | | _bfd_bool_bfd_false_error, \ |
6019 | | coff_mkobject, \ |
6020 | | _bfd_generic_mkarchive, \ |
6021 | | _bfd_bool_bfd_false_error \ |
6022 | | }, \ |
6023 | | { /* bfd_write_contents. */ \ |
6024 | | _bfd_bool_bfd_false_error, \ |
6025 | | coff_write_object_contents, \ |
6026 | | _bfd_write_archive_contents, \ |
6027 | | _bfd_bool_bfd_false_error \ |
6028 | | }, \ |
6029 | | \ |
6030 | | BFD_JUMP_TABLE_GENERIC (coff), \ |
6031 | | BFD_JUMP_TABLE_COPY (coff), \ |
6032 | | BFD_JUMP_TABLE_CORE (_bfd_nocore), \ |
6033 | | BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff), \ |
6034 | | BFD_JUMP_TABLE_SYMBOLS (coff), \ |
6035 | | BFD_JUMP_TABLE_RELOCS (coff), \ |
6036 | | BFD_JUMP_TABLE_WRITE (coff), \ |
6037 | | BFD_JUMP_TABLE_LINK (coff), \ |
6038 | | BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), \ |
6039 | | \ |
6040 | | ALTERNATIVE, \ |
6041 | | \ |
6042 | | SWAP_TABLE \ |
6043 | | }; |
6044 | | |
6045 | | #define CREATE_BIGHDR_COFF_TARGET_VEC(VAR, NAME, EXTRA_O_FLAGS, EXTRA_S_FLAGS, UNDER, ALTERNATIVE, SWAP_TABLE) \ |
6046 | | const bfd_target VAR = \ |
6047 | | { \ |
6048 | | NAME , \ |
6049 | | bfd_target_coff_flavour, \ |
6050 | | BFD_ENDIAN_LITTLE, /* Data byte order is little. */ \ |
6051 | | BFD_ENDIAN_BIG, /* Header byte order is big. */ \ |
6052 | | /* object flags */ \ |
6053 | | (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | \ |
6054 | | HAS_SYMS | HAS_LOCALS | WP_TEXT | EXTRA_O_FLAGS), \ |
6055 | | /* section flags */ \ |
6056 | | (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | EXTRA_S_FLAGS),\ |
6057 | | UNDER, /* Leading symbol underscore. */ \ |
6058 | | '/', /* AR_pad_char. */ \ |
6059 | | 15, /* AR_max_namelen. */ \ |
6060 | | 0, /* match priority. */ \ |
6061 | | TARGET_KEEP_UNUSED_SECTION_SYMBOLS, /* keep unused section symbols. */ \ |
6062 | | \ |
6063 | | /* Data conversion functions. */ \ |
6064 | | bfd_getb64, bfd_getb_signed_64, bfd_putb64, \ |
6065 | | bfd_getb32, bfd_getb_signed_32, bfd_putb32, \ |
6066 | | bfd_getb16, bfd_getb_signed_16, bfd_putb16, \ |
6067 | | \ |
6068 | | /* Header conversion functions. */ \ |
6069 | | bfd_getb64, bfd_getb_signed_64, bfd_putb64, \ |
6070 | | bfd_getb32, bfd_getb_signed_32, bfd_putb32, \ |
6071 | | bfd_getb16, bfd_getb_signed_16, bfd_putb16, \ |
6072 | | \ |
6073 | | { /* bfd_check_format. */ \ |
6074 | | _bfd_dummy_target, \ |
6075 | | coff_object_p, \ |
6076 | | bfd_generic_archive_p, \ |
6077 | | _bfd_dummy_target \ |
6078 | | }, \ |
6079 | | { /* bfd_set_format. */ \ |
6080 | | _bfd_bool_bfd_false_error, \ |
6081 | | coff_mkobject, \ |
6082 | | _bfd_generic_mkarchive, \ |
6083 | | _bfd_bool_bfd_false_error \ |
6084 | | }, \ |
6085 | | { /* bfd_write_contents. */ \ |
6086 | | _bfd_bool_bfd_false_error, \ |
6087 | | coff_write_object_contents, \ |
6088 | | _bfd_write_archive_contents, \ |
6089 | | _bfd_bool_bfd_false_error \ |
6090 | | }, \ |
6091 | | \ |
6092 | | BFD_JUMP_TABLE_GENERIC (coff), \ |
6093 | | BFD_JUMP_TABLE_COPY (coff), \ |
6094 | | BFD_JUMP_TABLE_CORE (_bfd_nocore), \ |
6095 | | BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff), \ |
6096 | | BFD_JUMP_TABLE_SYMBOLS (coff), \ |
6097 | | BFD_JUMP_TABLE_RELOCS (coff), \ |
6098 | | BFD_JUMP_TABLE_WRITE (coff), \ |
6099 | | BFD_JUMP_TABLE_LINK (coff), \ |
6100 | | BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), \ |
6101 | | \ |
6102 | | ALTERNATIVE, \ |
6103 | | \ |
6104 | | SWAP_TABLE \ |
6105 | | }; |
6106 | | |
6107 | | #define CREATE_LITTLE_COFF_TARGET_VEC(VAR, NAME, EXTRA_O_FLAGS, EXTRA_S_FLAGS, UNDER, ALTERNATIVE, SWAP_TABLE) \ |
6108 | | const bfd_target VAR = \ |
6109 | | { \ |
6110 | | NAME , \ |
6111 | | bfd_target_coff_flavour, \ |
6112 | | BFD_ENDIAN_LITTLE, /* Data byte order is little. */ \ |
6113 | | BFD_ENDIAN_LITTLE, /* Header byte order is little. */ \ |
6114 | | /* object flags */ \ |
6115 | | (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | \ |
6116 | | HAS_SYMS | HAS_LOCALS | WP_TEXT | EXTRA_O_FLAGS), \ |
6117 | | /* section flags */ \ |
6118 | | (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | EXTRA_S_FLAGS),\ |
6119 | | UNDER, /* Leading symbol underscore. */ \ |
6120 | | '/', /* AR_pad_char. */ \ |
6121 | | 15, /* AR_max_namelen. */ \ |
6122 | | 0, /* match priority. */ \ |
6123 | | TARGET_KEEP_UNUSED_SECTION_SYMBOLS, /* keep unused section symbols. */ \ |
6124 | | \ |
6125 | | /* Data conversion functions. */ \ |
6126 | | bfd_getl64, bfd_getl_signed_64, bfd_putl64, \ |
6127 | | bfd_getl32, bfd_getl_signed_32, bfd_putl32, \ |
6128 | | bfd_getl16, bfd_getl_signed_16, bfd_putl16, \ |
6129 | | /* Header conversion functions. */ \ |
6130 | | bfd_getl64, bfd_getl_signed_64, bfd_putl64, \ |
6131 | | bfd_getl32, bfd_getl_signed_32, bfd_putl32, \ |
6132 | | bfd_getl16, bfd_getl_signed_16, bfd_putl16, \ |
6133 | | \ |
6134 | | { /* bfd_check_format. */ \ |
6135 | | _bfd_dummy_target, \ |
6136 | | coff_object_p, \ |
6137 | | bfd_generic_archive_p, \ |
6138 | | _bfd_dummy_target \ |
6139 | | }, \ |
6140 | | { /* bfd_set_format. */ \ |
6141 | | _bfd_bool_bfd_false_error, \ |
6142 | | coff_mkobject, \ |
6143 | | _bfd_generic_mkarchive, \ |
6144 | | _bfd_bool_bfd_false_error \ |
6145 | | }, \ |
6146 | | { /* bfd_write_contents. */ \ |
6147 | | _bfd_bool_bfd_false_error, \ |
6148 | | coff_write_object_contents, \ |
6149 | | _bfd_write_archive_contents, \ |
6150 | | _bfd_bool_bfd_false_error \ |
6151 | | }, \ |
6152 | | \ |
6153 | | BFD_JUMP_TABLE_GENERIC (coff), \ |
6154 | | BFD_JUMP_TABLE_COPY (coff), \ |
6155 | | BFD_JUMP_TABLE_CORE (_bfd_nocore), \ |
6156 | | BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff), \ |
6157 | | BFD_JUMP_TABLE_SYMBOLS (coff), \ |
6158 | | BFD_JUMP_TABLE_RELOCS (coff), \ |
6159 | | BFD_JUMP_TABLE_WRITE (coff), \ |
6160 | | BFD_JUMP_TABLE_LINK (coff), \ |
6161 | | BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), \ |
6162 | | \ |
6163 | | ALTERNATIVE, \ |
6164 | | \ |
6165 | | SWAP_TABLE \ |
6166 | | }; |