/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 | 1.19M | #define DOT_DEBUG ".debug" |
365 | 1.19M | #define DOT_ZDEBUG ".zdebug" |
366 | 915k | #define GNU_LINKONCE_WI ".gnu.linkonce.wi." |
367 | 915k | #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 | 1.08M | { |
410 | 1.08M | bfd_coff_long_section_names (abfd) = enable; |
411 | 1.08M | return true; |
412 | 1.08M | } pei-i386.c:bfd_coff_set_long_section_names_allowed Line | Count | Source | 409 | 12.0k | { | 410 | 12.0k | bfd_coff_long_section_names (abfd) = enable; | 411 | 12.0k | return true; | 412 | 12.0k | } |
pe-x86_64.c:bfd_coff_set_long_section_names_allowed Line | Count | Source | 409 | 86.6k | { | 410 | 86.6k | bfd_coff_long_section_names (abfd) = enable; | 411 | 86.6k | return true; | 412 | 86.6k | } |
pei-x86_64.c:bfd_coff_set_long_section_names_allowed Line | Count | Source | 409 | 3.23k | { | 410 | 3.23k | bfd_coff_long_section_names (abfd) = enable; | 411 | 3.23k | return true; | 412 | 3.23k | } |
pei-aarch64.c:bfd_coff_set_long_section_names_allowed Line | Count | Source | 409 | 9.96k | { | 410 | 9.96k | bfd_coff_long_section_names (abfd) = enable; | 411 | 9.96k | return true; | 412 | 9.96k | } |
pe-aarch64.c:bfd_coff_set_long_section_names_allowed Line | Count | Source | 409 | 4.05k | { | 410 | 4.05k | bfd_coff_long_section_names (abfd) = enable; | 411 | 4.05k | return true; | 412 | 4.05k | } |
pei-ia64.c:bfd_coff_set_long_section_names_allowed Line | Count | Source | 409 | 99.4k | { | 410 | 99.4k | bfd_coff_long_section_names (abfd) = enable; | 411 | 99.4k | return true; | 412 | 99.4k | } |
pei-loongarch64.c:bfd_coff_set_long_section_names_allowed Line | Count | Source | 409 | 2.10k | { | 410 | 2.10k | bfd_coff_long_section_names (abfd) = enable; | 411 | 2.10k | return true; | 412 | 2.10k | } |
coff-go32.c:bfd_coff_set_long_section_names_allowed Line | Count | Source | 409 | 190k | { | 410 | 190k | bfd_coff_long_section_names (abfd) = enable; | 411 | 190k | return true; | 412 | 190k | } |
Unexecuted instantiation: coff-stgo32.c:bfd_coff_set_long_section_names_allowed pe-arm-wince.c:bfd_coff_set_long_section_names_allowed Line | Count | Source | 409 | 2.76k | { | 410 | 2.76k | bfd_coff_long_section_names (abfd) = enable; | 411 | 2.76k | return true; | 412 | 2.76k | } |
pe-arm.c:bfd_coff_set_long_section_names_allowed Line | Count | Source | 409 | 2.76k | { | 410 | 2.76k | bfd_coff_long_section_names (abfd) = enable; | 411 | 2.76k | return true; | 412 | 2.76k | } |
pe-i386.c:bfd_coff_set_long_section_names_allowed Line | Count | Source | 409 | 3.98k | { | 410 | 3.98k | bfd_coff_long_section_names (abfd) = enable; | 411 | 3.98k | return true; | 412 | 3.98k | } |
pe-mcore.c:bfd_coff_set_long_section_names_allowed Line | Count | Source | 409 | 23.1k | { | 410 | 23.1k | bfd_coff_long_section_names (abfd) = enable; | 411 | 23.1k | return true; | 412 | 23.1k | } |
pe-sh.c:bfd_coff_set_long_section_names_allowed Line | Count | Source | 409 | 11.7k | { | 410 | 11.7k | bfd_coff_long_section_names (abfd) = enable; | 411 | 11.7k | return true; | 412 | 11.7k | } |
pei-arm-wince.c:bfd_coff_set_long_section_names_allowed Line | Count | Source | 409 | 38.9k | { | 410 | 38.9k | bfd_coff_long_section_names (abfd) = enable; | 411 | 38.9k | return true; | 412 | 38.9k | } |
pei-arm.c:bfd_coff_set_long_section_names_allowed Line | Count | Source | 409 | 480k | { | 410 | 480k | bfd_coff_long_section_names (abfd) = enable; | 411 | 480k | return true; | 412 | 480k | } |
pei-mcore.c:bfd_coff_set_long_section_names_allowed Line | Count | Source | 409 | 60.9k | { | 410 | 60.9k | bfd_coff_long_section_names (abfd) = enable; | 411 | 60.9k | return true; | 412 | 60.9k | } |
pei-sh.c:bfd_coff_set_long_section_names_allowed Line | Count | Source | 409 | 50.6k | { | 410 | 50.6k | bfd_coff_long_section_names (abfd) = enable; | 411 | 50.6k | return true; | 412 | 50.6k | } |
|
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 | 905k | { |
418 | 905k | return false; |
419 | 905k | } coff-x86_64.c:bfd_coff_set_long_section_names_disallowed Line | Count | Source | 417 | 304k | { | 418 | 304k | return false; | 419 | 304k | } |
coff64-rs6000.c:bfd_coff_set_long_section_names_disallowed Line | Count | Source | 417 | 71.0k | { | 418 | 71.0k | return false; | 419 | 71.0k | } |
cf-i386lynx.c:bfd_coff_set_long_section_names_disallowed Line | Count | Source | 417 | 193k | { | 418 | 193k | return false; | 419 | 193k | } |
coff-i386.c:bfd_coff_set_long_section_names_disallowed Line | Count | Source | 417 | 193k | { | 418 | 193k | return false; | 419 | 193k | } |
coff-rs6000.c:bfd_coff_set_long_section_names_disallowed Line | Count | Source | 417 | 31.3k | { | 418 | 31.3k | return false; | 419 | 31.3k | } |
coff-sh.c:bfd_coff_set_long_section_names_disallowed Line | Count | Source | 417 | 11.3k | { | 418 | 11.3k | return false; | 419 | 11.3k | } |
coff-tic30.c:bfd_coff_set_long_section_names_disallowed Line | Count | Source | 417 | 7.44k | { | 418 | 7.44k | return false; | 419 | 7.44k | } |
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 | 7.88k | { | 418 | 7.88k | return false; | 419 | 7.88k | } |
coff-z80.c:bfd_coff_set_long_section_names_disallowed Line | Count | Source | 417 | 80.3k | { | 418 | 80.3k | return false; | 419 | 80.3k | } |
coff-z8k.c:bfd_coff_set_long_section_names_disallowed Line | Count | Source | 417 | 3.97k | { | 418 | 3.97k | return false; | 419 | 3.97k | } |
|
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 | 1.09M | { |
687 | 1.09M | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; |
688 | 1.09M | unsigned long styp_flags = internal_s->s_flags; |
689 | 1.09M | flagword sec_flags = 0; |
690 | | |
691 | | #ifdef STYP_BLOCK |
692 | 7.88k | if (styp_flags & STYP_BLOCK) |
693 | 2.51k | sec_flags |= SEC_TIC54X_BLOCK; |
694 | | #endif |
695 | | |
696 | | #ifdef STYP_CLINK |
697 | 7.88k | if (styp_flags & STYP_CLINK) |
698 | 2.52k | sec_flags |= SEC_TIC54X_CLINK; |
699 | | #endif |
700 | | |
701 | 1.09M | #ifdef STYP_NOLOAD |
702 | 1.09M | if (styp_flags & STYP_NOLOAD) |
703 | 421k | sec_flags |= SEC_NEVER_LOAD; |
704 | 1.09M | #endif /* STYP_NOLOAD */ |
705 | | |
706 | | /* For 386 COFF, at least, an unloadable text or data section is |
707 | | actually a shared library section. */ |
708 | 1.09M | if (styp_flags & STYP_TEXT) |
709 | 412k | { |
710 | 412k | if (sec_flags & SEC_NEVER_LOAD) |
711 | 224k | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; |
712 | 188k | else |
713 | 188k | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; |
714 | 412k | } |
715 | 682k | else if (styp_flags & STYP_DATA) |
716 | 189k | { |
717 | 189k | if (sec_flags & SEC_NEVER_LOAD) |
718 | 95.0k | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; |
719 | 94.1k | else |
720 | 94.1k | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; |
721 | 189k | } |
722 | 492k | else if (styp_flags & STYP_BSS) |
723 | 93.2k | { |
724 | | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY |
725 | 79.7k | if (sec_flags & SEC_NEVER_LOAD) |
726 | 40.9k | sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY; |
727 | 38.7k | else |
728 | 38.7k | #endif |
729 | 52.2k | sec_flags |= SEC_ALLOC; |
730 | 93.2k | } |
731 | 399k | else if (styp_flags & STYP_INFO) |
732 | 54.5k | { |
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 | 44.1k | sec_flags |= SEC_DEBUGGING; |
741 | | #endif |
742 | 54.5k | } |
743 | 345k | else if (styp_flags & STYP_PAD) |
744 | 29.6k | sec_flags = 0; |
745 | | #ifdef RS6000COFF_C |
746 | 50.3k | else if (styp_flags & STYP_TDATA) |
747 | 1.95k | { |
748 | 1.95k | if (sec_flags & SEC_NEVER_LOAD) |
749 | 398 | sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY; |
750 | 1.55k | else |
751 | 1.55k | sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_LOAD | SEC_ALLOC; |
752 | 1.95k | } |
753 | 48.4k | else if (styp_flags & STYP_TBSS) |
754 | 598 | { |
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 | 598 | sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL; |
761 | 598 | } |
762 | 47.8k | else if (styp_flags & STYP_EXCEPT) |
763 | 4.35k | sec_flags |= SEC_LOAD; |
764 | 43.4k | else if (styp_flags & STYP_LOADER) |
765 | 846 | sec_flags |= SEC_LOAD; |
766 | 42.6k | else if (styp_flags & STYP_TYPCHK) |
767 | 164 | sec_flags |= SEC_LOAD; |
768 | 42.4k | else if (styp_flags & STYP_DWARF) |
769 | 196 | sec_flags |= SEC_DEBUGGING; |
770 | 42.2k | #endif |
771 | 307k | else if (strcmp (name, _TEXT) == 0) |
772 | 130 | { |
773 | 130 | if (sec_flags & SEC_NEVER_LOAD) |
774 | 44 | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; |
775 | 86 | else |
776 | 86 | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; |
777 | 130 | } |
778 | 307k | else if (strcmp (name, _DATA) == 0) |
779 | 130 | { |
780 | 130 | if (sec_flags & SEC_NEVER_LOAD) |
781 | 54 | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; |
782 | 76 | else |
783 | 76 | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; |
784 | 130 | } |
785 | 307k | else if (strcmp (name, _BSS) == 0) |
786 | 72 | { |
787 | | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY |
788 | 36 | if (sec_flags & SEC_NEVER_LOAD) |
789 | 8 | sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY; |
790 | 28 | else |
791 | 28 | #endif |
792 | 64 | sec_flags |= SEC_ALLOC; |
793 | 72 | } |
794 | 306k | else if (startswith (name, DOT_DEBUG) |
795 | 306k | || startswith (name, DOT_ZDEBUG) |
796 | | #ifdef _COMMENT |
797 | 261k | || strcmp (name, _COMMENT) == 0 |
798 | | #endif |
799 | | #ifdef COFF_LONG_SECTION_NAMES |
800 | 28.7k | || startswith (name, GNU_LINKONCE_WI) |
801 | 28.7k | || startswith (name, GNU_LINKONCE_WT) |
802 | | #endif |
803 | 306k | || startswith (name, ".stab")) |
804 | 664 | { |
805 | | #ifdef COFF_PAGE_SIZE |
806 | 324 | sec_flags |= SEC_DEBUGGING; |
807 | | #endif |
808 | 664 | } |
809 | | #ifdef _LIB |
810 | 261k | else if (strcmp (name, _LIB) == 0) |
811 | 12 | ; |
812 | 261k | #endif |
813 | | #ifdef _LIT |
814 | | else if (strcmp (name, _LIT) == 0) |
815 | | sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY; |
816 | | #endif |
817 | 261k | else |
818 | 306k | sec_flags |= SEC_ALLOC | SEC_LOAD; |
819 | | |
820 | 1.09M | #ifdef STYP_LIT /* A29k readonly text/data section type. */ |
821 | 1.09M | if ((styp_flags & STYP_LIT) == STYP_LIT) |
822 | 192k | sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY); |
823 | 1.09M | #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 | 1.09M | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 |
831 | 1.09M | && (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 | 189k | if (startswith (name, ".gnu.linkonce")) |
843 | 0 | sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; |
844 | | #endif |
845 | | |
846 | 1.09M | if (flags_ptr == NULL) |
847 | 0 | return false; |
848 | | |
849 | 1.09M | * flags_ptr = sec_flags; |
850 | 1.09M | return true; |
851 | 1.09M | } coff-x86_64.c:styp_to_sec_flags Line | Count | Source | 686 | 304k | { | 687 | 304k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 688 | 304k | unsigned long styp_flags = internal_s->s_flags; | 689 | 304k | 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 | 304k | #ifdef STYP_NOLOAD | 702 | 304k | if (styp_flags & STYP_NOLOAD) | 703 | 107k | sec_flags |= SEC_NEVER_LOAD; | 704 | 304k | #endif /* STYP_NOLOAD */ | 705 | | | 706 | | /* For 386 COFF, at least, an unloadable text or data section is | 707 | | actually a shared library section. */ | 708 | 304k | if (styp_flags & STYP_TEXT) | 709 | 108k | { | 710 | 108k | if (sec_flags & SEC_NEVER_LOAD) | 711 | 69.1k | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 712 | 39.2k | else | 713 | 39.2k | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 714 | 108k | } | 715 | 195k | else if (styp_flags & STYP_DATA) | 716 | 36.2k | { | 717 | 36.2k | if (sec_flags & SEC_NEVER_LOAD) | 718 | 19.2k | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; | 719 | 17.0k | else | 720 | 17.0k | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; | 721 | 36.2k | } | 722 | 159k | else if (styp_flags & STYP_BSS) | 723 | 17.8k | { | 724 | 17.8k | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY | 725 | 17.8k | if (sec_flags & SEC_NEVER_LOAD) | 726 | 9.10k | sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY; | 727 | 8.76k | else | 728 | 8.76k | #endif | 729 | 8.76k | sec_flags |= SEC_ALLOC; | 730 | 17.8k | } | 731 | 141k | else if (styp_flags & STYP_INFO) | 732 | 9.86k | { | 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 | 9.86k | #if defined (COFF_PAGE_SIZE) && !defined (COFF_ALIGN_IN_S_FLAGS) | 740 | 9.86k | sec_flags |= SEC_DEBUGGING; | 741 | 9.86k | #endif | 742 | 9.86k | } | 743 | 131k | else if (styp_flags & STYP_PAD) | 744 | 4.73k | 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 | 127k | else if (strcmp (name, _TEXT) == 0) | 772 | 8 | { | 773 | 8 | if (sec_flags & SEC_NEVER_LOAD) | 774 | 2 | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 775 | 6 | else | 776 | 6 | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 777 | 8 | } | 778 | 127k | 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 | 127k | else if (strcmp (name, _BSS) == 0) | 786 | 12 | { | 787 | 12 | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY | 788 | 12 | if (sec_flags & SEC_NEVER_LOAD) | 789 | 2 | sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY; | 790 | 10 | else | 791 | 10 | #endif | 792 | 10 | sec_flags |= SEC_ALLOC; | 793 | 12 | } | 794 | 127k | else if (startswith (name, DOT_DEBUG) | 795 | 127k | || startswith (name, DOT_ZDEBUG) | 796 | 127k | #ifdef _COMMENT | 797 | 127k | || strcmp (name, _COMMENT) == 0 | 798 | 127k | #endif | 799 | | #ifdef COFF_LONG_SECTION_NAMES | 800 | | || startswith (name, GNU_LINKONCE_WI) | 801 | | || startswith (name, GNU_LINKONCE_WT) | 802 | | #endif | 803 | 127k | || startswith (name, ".stab")) | 804 | 60 | { | 805 | 60 | #ifdef COFF_PAGE_SIZE | 806 | 60 | sec_flags |= SEC_DEBUGGING; | 807 | 60 | #endif | 808 | 60 | } | 809 | 127k | #ifdef _LIB | 810 | 127k | else if (strcmp (name, _LIB) == 0) | 811 | 2 | ; | 812 | 127k | #endif | 813 | | #ifdef _LIT | 814 | | else if (strcmp (name, _LIT) == 0) | 815 | | sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY; | 816 | | #endif | 817 | 127k | else | 818 | 127k | sec_flags |= SEC_ALLOC | SEC_LOAD; | 819 | | | 820 | 304k | #ifdef STYP_LIT /* A29k readonly text/data section type. */ | 821 | 304k | if ((styp_flags & STYP_LIT) == STYP_LIT) | 822 | 41.5k | sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY); | 823 | 304k | #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 | 304k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 831 | 304k | && (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 | 304k | if (flags_ptr == NULL) | 847 | 0 | return false; | 848 | | | 849 | 304k | * flags_ptr = sec_flags; | 850 | 304k | return true; | 851 | 304k | } |
coff64-rs6000.c:styp_to_sec_flags Line | Count | Source | 686 | 71.0k | { | 687 | 71.0k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 688 | 71.0k | unsigned long styp_flags = internal_s->s_flags; | 689 | 71.0k | 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 | 71.0k | #ifdef STYP_NOLOAD | 702 | 71.0k | if (styp_flags & STYP_NOLOAD) | 703 | 22.1k | sec_flags |= SEC_NEVER_LOAD; | 704 | 71.0k | #endif /* STYP_NOLOAD */ | 705 | | | 706 | | /* For 386 COFF, at least, an unloadable text or data section is | 707 | | actually a shared library section. */ | 708 | 71.0k | if (styp_flags & STYP_TEXT) | 709 | 22.2k | { | 710 | 22.2k | if (sec_flags & SEC_NEVER_LOAD) | 711 | 11.3k | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 712 | 10.8k | else | 713 | 10.8k | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 714 | 22.2k | } | 715 | 48.7k | else if (styp_flags & STYP_DATA) | 716 | 10.4k | { | 717 | 10.4k | if (sec_flags & SEC_NEVER_LOAD) | 718 | 5.16k | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; | 719 | 5.29k | else | 720 | 5.29k | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; | 721 | 10.4k | } | 722 | 38.3k | else if (styp_flags & STYP_BSS) | 723 | 5.11k | { | 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.11k | sec_flags |= SEC_ALLOC; | 730 | 5.11k | } | 731 | 33.1k | else if (styp_flags & STYP_INFO) | 732 | 2.95k | { | 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 | 2.95k | } | 743 | 30.2k | else if (styp_flags & STYP_PAD) | 744 | 1.81k | sec_flags = 0; | 745 | 28.4k | #ifdef RS6000COFF_C | 746 | 28.4k | else if (styp_flags & STYP_TDATA) | 747 | 1.34k | { | 748 | 1.34k | if (sec_flags & SEC_NEVER_LOAD) | 749 | 360 | sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY; | 750 | 982 | else | 751 | 982 | sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_LOAD | SEC_ALLOC; | 752 | 1.34k | } | 753 | 27.0k | else if (styp_flags & STYP_TBSS) | 754 | 390 | { | 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 | 390 | sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL; | 761 | 390 | } | 762 | 26.6k | else if (styp_flags & STYP_EXCEPT) | 763 | 3.70k | sec_flags |= SEC_LOAD; | 764 | 22.9k | else if (styp_flags & STYP_LOADER) | 765 | 672 | sec_flags |= SEC_LOAD; | 766 | 22.3k | else if (styp_flags & STYP_TYPCHK) | 767 | 76 | sec_flags |= SEC_LOAD; | 768 | 22.2k | else if (styp_flags & STYP_DWARF) | 769 | 42 | sec_flags |= SEC_DEBUGGING; | 770 | 22.1k | #endif | 771 | 22.1k | else if (strcmp (name, _TEXT) == 0) | 772 | 0 | { | 773 | 0 | if (sec_flags & SEC_NEVER_LOAD) | 774 | 0 | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 775 | 0 | else | 776 | 0 | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 777 | 0 | } | 778 | 22.1k | else if (strcmp (name, _DATA) == 0) | 779 | 14 | { | 780 | 14 | if (sec_flags & SEC_NEVER_LOAD) | 781 | 6 | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; | 782 | 8 | else | 783 | 8 | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; | 784 | 14 | } | 785 | 22.1k | else if (strcmp (name, _BSS) == 0) | 786 | 0 | { | 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 | 0 | sec_flags |= SEC_ALLOC; | 793 | 0 | } | 794 | 22.1k | else if (startswith (name, DOT_DEBUG) | 795 | 22.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 | 22.1k | || startswith (name, ".stab")) | 804 | 34 | { | 805 | | #ifdef COFF_PAGE_SIZE | 806 | | sec_flags |= SEC_DEBUGGING; | 807 | | #endif | 808 | 34 | } | 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 | 22.1k | else | 818 | 22.1k | sec_flags |= SEC_ALLOC | SEC_LOAD; | 819 | | | 820 | 71.0k | #ifdef STYP_LIT /* A29k readonly text/data section type. */ | 821 | 71.0k | if ((styp_flags & STYP_LIT) == STYP_LIT) | 822 | 10.8k | sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY); | 823 | 71.0k | #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 | 71.0k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 831 | 71.0k | && (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 | 71.0k | if (flags_ptr == NULL) | 847 | 0 | return false; | 848 | | | 849 | 71.0k | * flags_ptr = sec_flags; | 850 | 71.0k | return true; | 851 | 71.0k | } |
cf-i386lynx.c:styp_to_sec_flags Line | Count | Source | 686 | 193k | { | 687 | 193k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 688 | 193k | unsigned long styp_flags = internal_s->s_flags; | 689 | 193k | 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 | 193k | #ifdef STYP_NOLOAD | 702 | 193k | if (styp_flags & STYP_NOLOAD) | 703 | 85.8k | sec_flags |= SEC_NEVER_LOAD; | 704 | 193k | #endif /* STYP_NOLOAD */ | 705 | | | 706 | | /* For 386 COFF, at least, an unloadable text or data section is | 707 | | actually a shared library section. */ | 708 | 193k | if (styp_flags & STYP_TEXT) | 709 | 84.1k | { | 710 | 84.1k | if (sec_flags & SEC_NEVER_LOAD) | 711 | 42.7k | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 712 | 41.3k | else | 713 | 41.3k | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 714 | 84.1k | } | 715 | 109k | else if (styp_flags & STYP_DATA) | 716 | 41.7k | { | 717 | 41.7k | if (sec_flags & SEC_NEVER_LOAD) | 718 | 20.7k | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; | 719 | 20.9k | else | 720 | 20.9k | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; | 721 | 41.7k | } | 722 | 67.8k | else if (styp_flags & STYP_BSS) | 723 | 20.7k | { | 724 | 20.7k | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY | 725 | 20.7k | if (sec_flags & SEC_NEVER_LOAD) | 726 | 10.7k | sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY; | 727 | 10.0k | else | 728 | 10.0k | #endif | 729 | 10.0k | sec_flags |= SEC_ALLOC; | 730 | 20.7k | } | 731 | 47.0k | else if (styp_flags & STYP_INFO) | 732 | 11.5k | { | 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 | 11.5k | #if defined (COFF_PAGE_SIZE) && !defined (COFF_ALIGN_IN_S_FLAGS) | 740 | 11.5k | sec_flags |= SEC_DEBUGGING; | 741 | 11.5k | #endif | 742 | 11.5k | } | 743 | 35.5k | else if (styp_flags & STYP_PAD) | 744 | 6.30k | 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 | 29.2k | else if (strcmp (name, _TEXT) == 0) | 772 | 20 | { | 773 | 20 | if (sec_flags & SEC_NEVER_LOAD) | 774 | 4 | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 775 | 16 | else | 776 | 16 | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 777 | 20 | } | 778 | 29.2k | else if (strcmp (name, _DATA) == 0) | 779 | 14 | { | 780 | 14 | if (sec_flags & SEC_NEVER_LOAD) | 781 | 4 | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; | 782 | 10 | else | 783 | 10 | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; | 784 | 14 | } | 785 | 29.2k | else if (strcmp (name, _BSS) == 0) | 786 | 8 | { | 787 | 8 | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY | 788 | 8 | if (sec_flags & SEC_NEVER_LOAD) | 789 | 2 | sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY; | 790 | 6 | else | 791 | 6 | #endif | 792 | 6 | sec_flags |= SEC_ALLOC; | 793 | 8 | } | 794 | 29.2k | else if (startswith (name, DOT_DEBUG) | 795 | 29.2k | || startswith (name, DOT_ZDEBUG) | 796 | 29.2k | #ifdef _COMMENT | 797 | 29.2k | || strcmp (name, _COMMENT) == 0 | 798 | 29.2k | #endif | 799 | | #ifdef COFF_LONG_SECTION_NAMES | 800 | | || startswith (name, GNU_LINKONCE_WI) | 801 | | || startswith (name, GNU_LINKONCE_WT) | 802 | | #endif | 803 | 29.2k | || startswith (name, ".stab")) | 804 | 88 | { | 805 | 88 | #ifdef COFF_PAGE_SIZE | 806 | 88 | sec_flags |= SEC_DEBUGGING; | 807 | 88 | #endif | 808 | 88 | } | 809 | 29.1k | #ifdef _LIB | 810 | 29.1k | else if (strcmp (name, _LIB) == 0) | 811 | 2 | ; | 812 | 29.1k | #endif | 813 | | #ifdef _LIT | 814 | | else if (strcmp (name, _LIT) == 0) | 815 | | sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY; | 816 | | #endif | 817 | 29.1k | else | 818 | 29.1k | sec_flags |= SEC_ALLOC | SEC_LOAD; | 819 | | | 820 | 193k | #ifdef STYP_LIT /* A29k readonly text/data section type. */ | 821 | 193k | if ((styp_flags & STYP_LIT) == STYP_LIT) | 822 | 42.3k | sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY); | 823 | 193k | #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 | 193k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 831 | 193k | && (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 | 193k | if (flags_ptr == NULL) | 847 | 0 | return false; | 848 | | | 849 | 193k | * flags_ptr = sec_flags; | 850 | 193k | return true; | 851 | 193k | } |
coff-go32.c:styp_to_sec_flags Line | Count | Source | 686 | 189k | { | 687 | 189k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 688 | 189k | unsigned long styp_flags = internal_s->s_flags; | 689 | 189k | 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 | 189k | #ifdef STYP_NOLOAD | 702 | 189k | if (styp_flags & STYP_NOLOAD) | 703 | 84.0k | sec_flags |= SEC_NEVER_LOAD; | 704 | 189k | #endif /* STYP_NOLOAD */ | 705 | | | 706 | | /* For 386 COFF, at least, an unloadable text or data section is | 707 | | actually a shared library section. */ | 708 | 189k | if (styp_flags & STYP_TEXT) | 709 | 82.3k | { | 710 | 82.3k | if (sec_flags & SEC_NEVER_LOAD) | 711 | 41.9k | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 712 | 40.4k | else | 713 | 40.4k | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 714 | 82.3k | } | 715 | 107k | else if (styp_flags & STYP_DATA) | 716 | 40.7k | { | 717 | 40.7k | if (sec_flags & SEC_NEVER_LOAD) | 718 | 20.3k | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; | 719 | 20.4k | else | 720 | 20.4k | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; | 721 | 40.7k | } | 722 | 66.5k | else if (styp_flags & STYP_BSS) | 723 | 20.3k | { | 724 | 20.3k | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY | 725 | 20.3k | if (sec_flags & SEC_NEVER_LOAD) | 726 | 10.4k | sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY; | 727 | 9.85k | else | 728 | 9.85k | #endif | 729 | 9.85k | sec_flags |= SEC_ALLOC; | 730 | 20.3k | } | 731 | 46.2k | else if (styp_flags & STYP_INFO) | 732 | 11.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 | 11.2k | #if defined (COFF_PAGE_SIZE) && !defined (COFF_ALIGN_IN_S_FLAGS) | 740 | 11.2k | sec_flags |= SEC_DEBUGGING; | 741 | 11.2k | #endif | 742 | 11.2k | } | 743 | 34.9k | else if (styp_flags & STYP_PAD) | 744 | 6.18k | 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 | 28.7k | else if (strcmp (name, _TEXT) == 0) | 772 | 20 | { | 773 | 20 | if (sec_flags & SEC_NEVER_LOAD) | 774 | 4 | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 775 | 16 | else | 776 | 16 | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 777 | 20 | } | 778 | 28.7k | else if (strcmp (name, _DATA) == 0) | 779 | 14 | { | 780 | 14 | if (sec_flags & SEC_NEVER_LOAD) | 781 | 4 | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; | 782 | 10 | else | 783 | 10 | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; | 784 | 14 | } | 785 | 28.7k | else if (strcmp (name, _BSS) == 0) | 786 | 8 | { | 787 | 8 | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY | 788 | 8 | if (sec_flags & SEC_NEVER_LOAD) | 789 | 2 | sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY; | 790 | 6 | else | 791 | 6 | #endif | 792 | 6 | sec_flags |= SEC_ALLOC; | 793 | 8 | } | 794 | 28.7k | else if (startswith (name, DOT_DEBUG) | 795 | 28.7k | || startswith (name, DOT_ZDEBUG) | 796 | 28.7k | #ifdef _COMMENT | 797 | 28.7k | || strcmp (name, _COMMENT) == 0 | 798 | 28.7k | #endif | 799 | 28.7k | #ifdef COFF_LONG_SECTION_NAMES | 800 | 28.7k | || startswith (name, GNU_LINKONCE_WI) | 801 | 28.7k | || startswith (name, GNU_LINKONCE_WT) | 802 | 28.7k | #endif | 803 | 28.7k | || startswith (name, ".stab")) | 804 | 88 | { | 805 | 88 | #ifdef COFF_PAGE_SIZE | 806 | 88 | sec_flags |= SEC_DEBUGGING; | 807 | 88 | #endif | 808 | 88 | } | 809 | 28.6k | #ifdef _LIB | 810 | 28.6k | else if (strcmp (name, _LIB) == 0) | 811 | 2 | ; | 812 | 28.6k | #endif | 813 | | #ifdef _LIT | 814 | | else if (strcmp (name, _LIT) == 0) | 815 | | sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY; | 816 | | #endif | 817 | 28.6k | else | 818 | 28.6k | sec_flags |= SEC_ALLOC | SEC_LOAD; | 819 | | | 820 | 189k | #ifdef STYP_LIT /* A29k readonly text/data section type. */ | 821 | 189k | if ((styp_flags & STYP_LIT) == STYP_LIT) | 822 | 41.5k | sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY); | 823 | 189k | #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 | 189k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 831 | 189k | && (startswith (name, ".sbss") | 832 | 0 | || startswith (name, ".sdata"))) | 833 | 0 | sec_flags |= SEC_SMALL_DATA; | 834 | | | 835 | 189k | #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 | 189k | if (startswith (name, ".gnu.linkonce")) | 843 | 0 | sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; | 844 | 189k | #endif | 845 | | | 846 | 189k | if (flags_ptr == NULL) | 847 | 0 | return false; | 848 | | | 849 | 189k | * flags_ptr = sec_flags; | 850 | 189k | return true; | 851 | 189k | } |
coff-i386.c:styp_to_sec_flags Line | Count | Source | 686 | 193k | { | 687 | 193k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 688 | 193k | unsigned long styp_flags = internal_s->s_flags; | 689 | 193k | 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 | 193k | #ifdef STYP_NOLOAD | 702 | 193k | if (styp_flags & STYP_NOLOAD) | 703 | 85.8k | sec_flags |= SEC_NEVER_LOAD; | 704 | 193k | #endif /* STYP_NOLOAD */ | 705 | | | 706 | | /* For 386 COFF, at least, an unloadable text or data section is | 707 | | actually a shared library section. */ | 708 | 193k | if (styp_flags & STYP_TEXT) | 709 | 84.1k | { | 710 | 84.1k | if (sec_flags & SEC_NEVER_LOAD) | 711 | 42.7k | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 712 | 41.3k | else | 713 | 41.3k | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 714 | 84.1k | } | 715 | 109k | else if (styp_flags & STYP_DATA) | 716 | 41.7k | { | 717 | 41.7k | if (sec_flags & SEC_NEVER_LOAD) | 718 | 20.7k | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; | 719 | 20.9k | else | 720 | 20.9k | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; | 721 | 41.7k | } | 722 | 67.8k | else if (styp_flags & STYP_BSS) | 723 | 20.7k | { | 724 | 20.7k | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY | 725 | 20.7k | if (sec_flags & SEC_NEVER_LOAD) | 726 | 10.7k | sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY; | 727 | 10.0k | else | 728 | 10.0k | #endif | 729 | 10.0k | sec_flags |= SEC_ALLOC; | 730 | 20.7k | } | 731 | 47.0k | else if (styp_flags & STYP_INFO) | 732 | 11.5k | { | 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 | 11.5k | #if defined (COFF_PAGE_SIZE) && !defined (COFF_ALIGN_IN_S_FLAGS) | 740 | 11.5k | sec_flags |= SEC_DEBUGGING; | 741 | 11.5k | #endif | 742 | 11.5k | } | 743 | 35.5k | else if (styp_flags & STYP_PAD) | 744 | 6.30k | 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 | 29.2k | else if (strcmp (name, _TEXT) == 0) | 772 | 20 | { | 773 | 20 | if (sec_flags & SEC_NEVER_LOAD) | 774 | 4 | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 775 | 16 | else | 776 | 16 | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 777 | 20 | } | 778 | 29.2k | else if (strcmp (name, _DATA) == 0) | 779 | 14 | { | 780 | 14 | if (sec_flags & SEC_NEVER_LOAD) | 781 | 4 | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; | 782 | 10 | else | 783 | 10 | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; | 784 | 14 | } | 785 | 29.2k | else if (strcmp (name, _BSS) == 0) | 786 | 8 | { | 787 | 8 | #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY | 788 | 8 | if (sec_flags & SEC_NEVER_LOAD) | 789 | 2 | sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY; | 790 | 6 | else | 791 | 6 | #endif | 792 | 6 | sec_flags |= SEC_ALLOC; | 793 | 8 | } | 794 | 29.2k | else if (startswith (name, DOT_DEBUG) | 795 | 29.2k | || startswith (name, DOT_ZDEBUG) | 796 | 29.2k | #ifdef _COMMENT | 797 | 29.2k | || strcmp (name, _COMMENT) == 0 | 798 | 29.2k | #endif | 799 | | #ifdef COFF_LONG_SECTION_NAMES | 800 | | || startswith (name, GNU_LINKONCE_WI) | 801 | | || startswith (name, GNU_LINKONCE_WT) | 802 | | #endif | 803 | 29.2k | || startswith (name, ".stab")) | 804 | 88 | { | 805 | 88 | #ifdef COFF_PAGE_SIZE | 806 | 88 | sec_flags |= SEC_DEBUGGING; | 807 | 88 | #endif | 808 | 88 | } | 809 | 29.1k | #ifdef _LIB | 810 | 29.1k | else if (strcmp (name, _LIB) == 0) | 811 | 2 | ; | 812 | 29.1k | #endif | 813 | | #ifdef _LIT | 814 | | else if (strcmp (name, _LIT) == 0) | 815 | | sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY; | 816 | | #endif | 817 | 29.1k | else | 818 | 29.1k | sec_flags |= SEC_ALLOC | SEC_LOAD; | 819 | | | 820 | 193k | #ifdef STYP_LIT /* A29k readonly text/data section type. */ | 821 | 193k | if ((styp_flags & STYP_LIT) == STYP_LIT) | 822 | 42.3k | sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY); | 823 | 193k | #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 | 193k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 831 | 193k | && (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 | 193k | if (flags_ptr == NULL) | 847 | 0 | return false; | 848 | | | 849 | 193k | * flags_ptr = sec_flags; | 850 | 193k | return true; | 851 | 193k | } |
coff-rs6000.c:styp_to_sec_flags Line | Count | Source | 686 | 31.3k | { | 687 | 31.3k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 688 | 31.3k | unsigned long styp_flags = internal_s->s_flags; | 689 | 31.3k | 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 | 31.3k | #ifdef STYP_NOLOAD | 702 | 31.3k | if (styp_flags & STYP_NOLOAD) | 703 | 5.36k | sec_flags |= SEC_NEVER_LOAD; | 704 | 31.3k | #endif /* STYP_NOLOAD */ | 705 | | | 706 | | /* For 386 COFF, at least, an unloadable text or data section is | 707 | | actually a shared library section. */ | 708 | 31.3k | if (styp_flags & STYP_TEXT) | 709 | 3.94k | { | 710 | 3.94k | if (sec_flags & SEC_NEVER_LOAD) | 711 | 2.66k | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 712 | 1.28k | else | 713 | 1.28k | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 714 | 3.94k | } | 715 | 27.4k | else if (styp_flags & STYP_DATA) | 716 | 2.46k | { | 717 | 2.46k | if (sec_flags & SEC_NEVER_LOAD) | 718 | 746 | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; | 719 | 1.72k | else | 720 | 1.72k | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; | 721 | 2.46k | } | 722 | 24.9k | else if (styp_flags & STYP_BSS) | 723 | 1.04k | { | 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.04k | sec_flags |= SEC_ALLOC; | 730 | 1.04k | } | 731 | 23.8k | else if (styp_flags & STYP_INFO) | 732 | 1.51k | { | 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.51k | } | 743 | 22.3k | else if (styp_flags & STYP_PAD) | 744 | 428 | sec_flags = 0; | 745 | 21.9k | #ifdef RS6000COFF_C | 746 | 21.9k | else if (styp_flags & STYP_TDATA) | 747 | 608 | { | 748 | 608 | if (sec_flags & SEC_NEVER_LOAD) | 749 | 38 | sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY; | 750 | 570 | else | 751 | 570 | sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_LOAD | SEC_ALLOC; | 752 | 608 | } | 753 | 21.3k | else if (styp_flags & STYP_TBSS) | 754 | 208 | { | 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 | 208 | sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL; | 761 | 208 | } | 762 | 21.1k | else if (styp_flags & STYP_EXCEPT) | 763 | 650 | sec_flags |= SEC_LOAD; | 764 | 20.4k | else if (styp_flags & STYP_LOADER) | 765 | 174 | sec_flags |= SEC_LOAD; | 766 | 20.3k | else if (styp_flags & STYP_TYPCHK) | 767 | 88 | sec_flags |= SEC_LOAD; | 768 | 20.2k | else if (styp_flags & STYP_DWARF) | 769 | 154 | sec_flags |= SEC_DEBUGGING; | 770 | 20.0k | #endif | 771 | 20.0k | else if (strcmp (name, _TEXT) == 0) | 772 | 14 | { | 773 | 14 | if (sec_flags & SEC_NEVER_LOAD) | 774 | 6 | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 775 | 8 | else | 776 | 8 | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 777 | 14 | } | 778 | 20.0k | 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 | 20.0k | else if (strcmp (name, _BSS) == 0) | 786 | 12 | { | 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 | 12 | sec_flags |= SEC_ALLOC; | 793 | 12 | } | 794 | 20.0k | else if (startswith (name, DOT_DEBUG) | 795 | 20.0k | || 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.0k | || startswith (name, ".stab")) | 804 | 32 | { | 805 | | #ifdef COFF_PAGE_SIZE | 806 | | sec_flags |= SEC_DEBUGGING; | 807 | | #endif | 808 | 32 | } | 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.0k | else | 818 | 20.0k | sec_flags |= SEC_ALLOC | SEC_LOAD; | 819 | | | 820 | 31.3k | #ifdef STYP_LIT /* A29k readonly text/data section type. */ | 821 | 31.3k | if ((styp_flags & STYP_LIT) == STYP_LIT) | 822 | 1.41k | sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY); | 823 | 31.3k | #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 | 31.3k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 831 | 31.3k | && (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 | 31.3k | if (flags_ptr == NULL) | 847 | 0 | return false; | 848 | | | 849 | 31.3k | * flags_ptr = sec_flags; | 850 | 31.3k | return true; | 851 | 31.3k | } |
coff-sh.c:styp_to_sec_flags Line | Count | Source | 686 | 11.3k | { | 687 | 11.3k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 688 | 11.3k | unsigned long styp_flags = internal_s->s_flags; | 689 | 11.3k | 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 | 11.3k | #ifdef STYP_NOLOAD | 702 | 11.3k | if (styp_flags & STYP_NOLOAD) | 703 | 3.43k | sec_flags |= SEC_NEVER_LOAD; | 704 | 11.3k | #endif /* STYP_NOLOAD */ | 705 | | | 706 | | /* For 386 COFF, at least, an unloadable text or data section is | 707 | | actually a shared library section. */ | 708 | 11.3k | if (styp_flags & STYP_TEXT) | 709 | 2.33k | { | 710 | 2.33k | if (sec_flags & SEC_NEVER_LOAD) | 711 | 1.11k | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 712 | 1.21k | else | 713 | 1.21k | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 714 | 2.33k | } | 715 | 9.05k | else if (styp_flags & STYP_DATA) | 716 | 1.32k | { | 717 | 1.32k | if (sec_flags & SEC_NEVER_LOAD) | 718 | 1.00k | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; | 719 | 320 | else | 720 | 320 | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; | 721 | 1.32k | } | 722 | 7.73k | else if (styp_flags & STYP_BSS) | 723 | 716 | { | 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 | 716 | sec_flags |= SEC_ALLOC; | 730 | 716 | } | 731 | 7.01k | else if (styp_flags & STYP_INFO) | 732 | 752 | { | 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 | 752 | } | 743 | 6.26k | else if (styp_flags & STYP_PAD) | 744 | 256 | 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.01k | else if (strcmp (name, _TEXT) == 0) | 772 | 8 | { | 773 | 8 | if (sec_flags & SEC_NEVER_LOAD) | 774 | 2 | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 775 | 6 | else | 776 | 6 | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 777 | 8 | } | 778 | 6.00k | else if (strcmp (name, _DATA) == 0) | 779 | 18 | { | 780 | 18 | if (sec_flags & SEC_NEVER_LOAD) | 781 | 14 | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; | 782 | 4 | else | 783 | 4 | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; | 784 | 18 | } | 785 | 5.98k | else if (strcmp (name, _BSS) == 0) | 786 | 8 | { | 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 | 8 | sec_flags |= SEC_ALLOC; | 793 | 8 | } | 794 | 5.97k | else if (startswith (name, DOT_DEBUG) | 795 | 5.97k | || startswith (name, DOT_ZDEBUG) | 796 | 5.97k | #ifdef _COMMENT | 797 | 5.97k | || strcmp (name, _COMMENT) == 0 | 798 | 5.97k | #endif | 799 | | #ifdef COFF_LONG_SECTION_NAMES | 800 | | || startswith (name, GNU_LINKONCE_WI) | 801 | | || startswith (name, GNU_LINKONCE_WT) | 802 | | #endif | 803 | 5.97k | || startswith (name, ".stab")) | 804 | 60 | { | 805 | | #ifdef COFF_PAGE_SIZE | 806 | | sec_flags |= SEC_DEBUGGING; | 807 | | #endif | 808 | 60 | } | 809 | 5.91k | #ifdef _LIB | 810 | 5.91k | else if (strcmp (name, _LIB) == 0) | 811 | 0 | ; | 812 | 5.91k | #endif | 813 | | #ifdef _LIT | 814 | | else if (strcmp (name, _LIT) == 0) | 815 | | sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY; | 816 | | #endif | 817 | 5.91k | else | 818 | 5.91k | sec_flags |= SEC_ALLOC | SEC_LOAD; | 819 | | | 820 | 11.3k | #ifdef STYP_LIT /* A29k readonly text/data section type. */ | 821 | 11.3k | if ((styp_flags & STYP_LIT) == STYP_LIT) | 822 | 488 | sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY); | 823 | 11.3k | #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 | 11.3k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 831 | 11.3k | && (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 | 11.3k | if (flags_ptr == NULL) | 847 | 0 | return false; | 848 | | | 849 | 11.3k | * flags_ptr = sec_flags; | 850 | 11.3k | return true; | 851 | 11.3k | } |
Unexecuted instantiation: coff-stgo32.c:styp_to_sec_flags coff-tic30.c:styp_to_sec_flags Line | Count | Source | 686 | 7.44k | { | 687 | 7.44k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 688 | 7.44k | unsigned long styp_flags = internal_s->s_flags; | 689 | 7.44k | 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 | 7.44k | #ifdef STYP_NOLOAD | 702 | 7.44k | if (styp_flags & STYP_NOLOAD) | 703 | 2.40k | sec_flags |= SEC_NEVER_LOAD; | 704 | 7.44k | #endif /* STYP_NOLOAD */ | 705 | | | 706 | | /* For 386 COFF, at least, an unloadable text or data section is | 707 | | actually a shared library section. */ | 708 | 7.44k | if (styp_flags & STYP_TEXT) | 709 | 1.87k | { | 710 | 1.87k | if (sec_flags & SEC_NEVER_LOAD) | 711 | 896 | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 712 | 982 | else | 713 | 982 | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 714 | 1.87k | } | 715 | 5.56k | else if (styp_flags & STYP_DATA) | 716 | 1.10k | { | 717 | 1.10k | if (sec_flags & SEC_NEVER_LOAD) | 718 | 476 | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; | 719 | 630 | else | 720 | 630 | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; | 721 | 1.10k | } | 722 | 4.45k | else if (styp_flags & STYP_BSS) | 723 | 360 | { | 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 | 360 | sec_flags |= SEC_ALLOC; | 730 | 360 | } | 731 | 4.09k | else if (styp_flags & STYP_INFO) | 732 | 1.05k | { | 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.05k | } | 743 | 3.04k | else if (styp_flags & STYP_PAD) | 744 | 1.04k | 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 | 1.99k | else if (strcmp (name, _TEXT) == 0) | 772 | 4 | { | 773 | 4 | if (sec_flags & SEC_NEVER_LOAD) | 774 | 2 | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 775 | 2 | else | 776 | 2 | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 777 | 4 | } | 778 | 1.99k | 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 | 1.98k | 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 | 1.98k | else if (startswith (name, DOT_DEBUG) | 795 | 1.98k | || startswith (name, DOT_ZDEBUG) | 796 | 1.98k | #ifdef _COMMENT | 797 | 1.98k | || strcmp (name, _COMMENT) == 0 | 798 | 1.98k | #endif | 799 | | #ifdef COFF_LONG_SECTION_NAMES | 800 | | || startswith (name, GNU_LINKONCE_WI) | 801 | | || startswith (name, GNU_LINKONCE_WT) | 802 | | #endif | 803 | 1.98k | || startswith (name, ".stab")) | 804 | 168 | { | 805 | | #ifdef COFF_PAGE_SIZE | 806 | | sec_flags |= SEC_DEBUGGING; | 807 | | #endif | 808 | 168 | } | 809 | 1.81k | #ifdef _LIB | 810 | 1.81k | else if (strcmp (name, _LIB) == 0) | 811 | 0 | ; | 812 | 1.81k | #endif | 813 | | #ifdef _LIT | 814 | | else if (strcmp (name, _LIT) == 0) | 815 | | sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY; | 816 | | #endif | 817 | 1.81k | else | 818 | 1.81k | sec_flags |= SEC_ALLOC | SEC_LOAD; | 819 | | | 820 | 7.44k | #ifdef STYP_LIT /* A29k readonly text/data section type. */ | 821 | 7.44k | if ((styp_flags & STYP_LIT) == STYP_LIT) | 822 | 802 | sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY); | 823 | 7.44k | #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 | 7.44k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 831 | 7.44k | && (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 | 7.44k | if (flags_ptr == NULL) | 847 | 0 | return false; | 848 | | | 849 | 7.44k | * flags_ptr = sec_flags; | 850 | 7.44k | return true; | 851 | 7.44k | } |
Unexecuted instantiation: coff-tic4x.c:styp_to_sec_flags coff-tic54x.c:styp_to_sec_flags Line | Count | Source | 686 | 7.88k | { | 687 | 7.88k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 688 | 7.88k | unsigned long styp_flags = internal_s->s_flags; | 689 | 7.88k | flagword sec_flags = 0; | 690 | | | 691 | 7.88k | #ifdef STYP_BLOCK | 692 | 7.88k | if (styp_flags & STYP_BLOCK) | 693 | 2.51k | sec_flags |= SEC_TIC54X_BLOCK; | 694 | 7.88k | #endif | 695 | | | 696 | 7.88k | #ifdef STYP_CLINK | 697 | 7.88k | if (styp_flags & STYP_CLINK) | 698 | 2.52k | sec_flags |= SEC_TIC54X_CLINK; | 699 | 7.88k | #endif | 700 | | | 701 | 7.88k | #ifdef STYP_NOLOAD | 702 | 7.88k | if (styp_flags & STYP_NOLOAD) | 703 | 2.45k | sec_flags |= SEC_NEVER_LOAD; | 704 | 7.88k | #endif /* STYP_NOLOAD */ | 705 | | | 706 | | /* For 386 COFF, at least, an unloadable text or data section is | 707 | | actually a shared library section. */ | 708 | 7.88k | if (styp_flags & STYP_TEXT) | 709 | 1.60k | { | 710 | 1.60k | if (sec_flags & SEC_NEVER_LOAD) | 711 | 884 | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 712 | 716 | else | 713 | 716 | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 714 | 1.60k | } | 715 | 6.28k | else if (styp_flags & STYP_DATA) | 716 | 1.46k | { | 717 | 1.46k | if (sec_flags & SEC_NEVER_LOAD) | 718 | 1.13k | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; | 719 | 338 | else | 720 | 338 | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; | 721 | 1.46k | } | 722 | 4.81k | else if (styp_flags & STYP_BSS) | 723 | 758 | { | 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 | 758 | sec_flags |= SEC_ALLOC; | 730 | 758 | } | 731 | 4.05k | else if (styp_flags & STYP_INFO) | 732 | 538 | { | 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 | 538 | } | 743 | 3.51k | else if (styp_flags & STYP_PAD) | 744 | 634 | 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 | 2.88k | else if (strcmp (name, _TEXT) == 0) | 772 | 8 | { | 773 | 8 | if (sec_flags & SEC_NEVER_LOAD) | 774 | 4 | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 775 | 4 | else | 776 | 4 | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 777 | 8 | } | 778 | 2.87k | else if (strcmp (name, _DATA) == 0) | 779 | 14 | { | 780 | 14 | if (sec_flags & SEC_NEVER_LOAD) | 781 | 6 | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; | 782 | 8 | else | 783 | 8 | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; | 784 | 14 | } | 785 | 2.86k | 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 | 2.85k | else if (startswith (name, DOT_DEBUG) | 795 | 2.85k | || 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 | 2.85k | || startswith (name, ".stab")) | 804 | 8 | { | 805 | | #ifdef COFF_PAGE_SIZE | 806 | | sec_flags |= SEC_DEBUGGING; | 807 | | #endif | 808 | 8 | } | 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 | 2.84k | else | 818 | 2.84k | sec_flags |= SEC_ALLOC | SEC_LOAD; | 819 | | | 820 | 7.88k | #ifdef STYP_LIT /* A29k readonly text/data section type. */ | 821 | 7.88k | if ((styp_flags & STYP_LIT) == STYP_LIT) | 822 | 808 | sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY); | 823 | 7.88k | #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 | 7.88k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 831 | 7.88k | && (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 | 7.88k | if (flags_ptr == NULL) | 847 | 0 | return false; | 848 | | | 849 | 7.88k | * flags_ptr = sec_flags; | 850 | 7.88k | return true; | 851 | 7.88k | } |
coff-z80.c:styp_to_sec_flags Line | Count | Source | 686 | 80.3k | { | 687 | 80.3k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 688 | 80.3k | unsigned long styp_flags = internal_s->s_flags; | 689 | 80.3k | 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 | 80.3k | #ifdef STYP_NOLOAD | 702 | 80.3k | if (styp_flags & STYP_NOLOAD) | 703 | 21.5k | sec_flags |= SEC_NEVER_LOAD; | 704 | 80.3k | #endif /* STYP_NOLOAD */ | 705 | | | 706 | | /* For 386 COFF, at least, an unloadable text or data section is | 707 | | actually a shared library section. */ | 708 | 80.3k | if (styp_flags & STYP_TEXT) | 709 | 20.8k | { | 710 | 20.8k | if (sec_flags & SEC_NEVER_LOAD) | 711 | 10.4k | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 712 | 10.4k | else | 713 | 10.4k | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 714 | 20.8k | } | 715 | 59.4k | else if (styp_flags & STYP_DATA) | 716 | 11.3k | { | 717 | 11.3k | if (sec_flags & SEC_NEVER_LOAD) | 718 | 5.27k | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; | 719 | 6.11k | else | 720 | 6.11k | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; | 721 | 11.3k | } | 722 | 48.0k | else if (styp_flags & STYP_BSS) | 723 | 5.16k | { | 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.16k | sec_flags |= SEC_ALLOC; | 730 | 5.16k | } | 731 | 42.9k | else if (styp_flags & STYP_INFO) | 732 | 3.28k | { | 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.28k | } | 743 | 39.6k | else if (styp_flags & STYP_PAD) | 744 | 1.49k | 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 | 38.1k | else if (strcmp (name, _TEXT) == 0) | 772 | 12 | { | 773 | 12 | if (sec_flags & SEC_NEVER_LOAD) | 774 | 6 | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 775 | 6 | else | 776 | 6 | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 777 | 12 | } | 778 | 38.1k | 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 | 38.1k | else if (strcmp (name, _BSS) == 0) | 786 | 2 | { | 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 | 2 | sec_flags |= SEC_ALLOC; | 793 | 2 | } | 794 | 38.1k | else if (startswith (name, DOT_DEBUG) | 795 | 38.1k | || startswith (name, DOT_ZDEBUG) | 796 | 38.1k | #ifdef _COMMENT | 797 | 38.1k | || strcmp (name, _COMMENT) == 0 | 798 | 38.1k | #endif | 799 | | #ifdef COFF_LONG_SECTION_NAMES | 800 | | || startswith (name, GNU_LINKONCE_WI) | 801 | | || startswith (name, GNU_LINKONCE_WT) | 802 | | #endif | 803 | 38.1k | || startswith (name, ".stab")) | 804 | 18 | { | 805 | | #ifdef COFF_PAGE_SIZE | 806 | | sec_flags |= SEC_DEBUGGING; | 807 | | #endif | 808 | 18 | } | 809 | 38.1k | #ifdef _LIB | 810 | 38.1k | else if (strcmp (name, _LIB) == 0) | 811 | 4 | ; | 812 | 38.0k | #endif | 813 | | #ifdef _LIT | 814 | | else if (strcmp (name, _LIT) == 0) | 815 | | sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY; | 816 | | #endif | 817 | 38.0k | else | 818 | 38.0k | sec_flags |= SEC_ALLOC | SEC_LOAD; | 819 | | | 820 | 80.3k | #ifdef STYP_LIT /* A29k readonly text/data section type. */ | 821 | 80.3k | if ((styp_flags & STYP_LIT) == STYP_LIT) | 822 | 10.3k | sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY); | 823 | 80.3k | #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 | 80.3k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 831 | 80.3k | && (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 | 80.3k | if (flags_ptr == NULL) | 847 | 0 | return false; | 848 | | | 849 | 80.3k | * flags_ptr = sec_flags; | 850 | 80.3k | return true; | 851 | 80.3k | } |
coff-z8k.c:styp_to_sec_flags Line | Count | Source | 686 | 3.97k | { | 687 | 3.97k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 688 | 3.97k | unsigned long styp_flags = internal_s->s_flags; | 689 | 3.97k | 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 | 3.97k | #ifdef STYP_NOLOAD | 702 | 3.97k | if (styp_flags & STYP_NOLOAD) | 703 | 1.07k | sec_flags |= SEC_NEVER_LOAD; | 704 | 3.97k | #endif /* STYP_NOLOAD */ | 705 | | | 706 | | /* For 386 COFF, at least, an unloadable text or data section is | 707 | | actually a shared library section. */ | 708 | 3.97k | if (styp_flags & STYP_TEXT) | 709 | 790 | { | 710 | 790 | if (sec_flags & SEC_NEVER_LOAD) | 711 | 360 | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 712 | 430 | else | 713 | 430 | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 714 | 790 | } | 715 | 3.18k | else if (styp_flags & STYP_DATA) | 716 | 550 | { | 717 | 550 | if (sec_flags & SEC_NEVER_LOAD) | 718 | 208 | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; | 719 | 342 | else | 720 | 342 | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; | 721 | 550 | } | 722 | 2.63k | else if (styp_flags & STYP_BSS) | 723 | 348 | { | 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 | 348 | sec_flags |= SEC_ALLOC; | 730 | 348 | } | 731 | 2.28k | else if (styp_flags & STYP_INFO) | 732 | 352 | { | 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 | 352 | } | 743 | 1.93k | else if (styp_flags & STYP_PAD) | 744 | 452 | 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 | 1.48k | else if (strcmp (name, _TEXT) == 0) | 772 | 16 | { | 773 | 16 | if (sec_flags & SEC_NEVER_LOAD) | 774 | 10 | sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; | 775 | 6 | else | 776 | 6 | sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; | 777 | 16 | } | 778 | 1.46k | else if (strcmp (name, _DATA) == 0) | 779 | 10 | { | 780 | 10 | if (sec_flags & SEC_NEVER_LOAD) | 781 | 8 | sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; | 782 | 2 | else | 783 | 2 | sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; | 784 | 10 | } | 785 | 1.45k | else if (strcmp (name, _BSS) == 0) | 786 | 2 | { | 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 | 2 | sec_flags |= SEC_ALLOC; | 793 | 2 | } | 794 | 1.45k | else if (startswith (name, DOT_DEBUG) | 795 | 1.45k | || startswith (name, DOT_ZDEBUG) | 796 | 1.45k | #ifdef _COMMENT | 797 | 1.45k | || strcmp (name, _COMMENT) == 0 | 798 | 1.45k | #endif | 799 | | #ifdef COFF_LONG_SECTION_NAMES | 800 | | || startswith (name, GNU_LINKONCE_WI) | 801 | | || startswith (name, GNU_LINKONCE_WT) | 802 | | #endif | 803 | 1.45k | || startswith (name, ".stab")) | 804 | 20 | { | 805 | | #ifdef COFF_PAGE_SIZE | 806 | | sec_flags |= SEC_DEBUGGING; | 807 | | #endif | 808 | 20 | } | 809 | 1.43k | #ifdef _LIB | 810 | 1.43k | else if (strcmp (name, _LIB) == 0) | 811 | 0 | ; | 812 | 1.43k | #endif | 813 | | #ifdef _LIT | 814 | | else if (strcmp (name, _LIT) == 0) | 815 | | sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY; | 816 | | #endif | 817 | 1.43k | else | 818 | 1.43k | sec_flags |= SEC_ALLOC | SEC_LOAD; | 819 | | | 820 | 3.97k | #ifdef STYP_LIT /* A29k readonly text/data section type. */ | 821 | 3.97k | if ((styp_flags & STYP_LIT) == STYP_LIT) | 822 | 274 | sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY); | 823 | 3.97k | #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 | 3.97k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 831 | 3.97k | && (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 | 3.97k | if (flags_ptr == NULL) | 847 | 0 | return false; | 848 | | | 849 | 3.97k | * flags_ptr = sec_flags; | 850 | 3.97k | return true; | 851 | 3.97k | } |
|
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 | 26.3k | { |
862 | 26.3k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; |
863 | 26.3k | bfd_byte *esymstart, *esym, *esymend; |
864 | 26.3k | int seen_state = 0; |
865 | 26.3k | char *target_name = NULL; |
866 | | |
867 | 26.3k | *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 | 26.3k | if (! _bfd_coff_get_external_symbols (abfd)) |
887 | 10.2k | return true; |
888 | | |
889 | 16.1k | esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd); |
890 | 16.1k | esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd); |
891 | | |
892 | 16.1k | for (struct internal_syment isym; |
893 | 50.9k | esym < esymend; |
894 | 34.7k | esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd)) |
895 | 37.1k | { |
896 | 37.1k | char buf[SYMNMLEN + 1]; |
897 | 37.1k | const char *symname; |
898 | | |
899 | 37.1k | bfd_coff_swap_sym_in (abfd, esym, &isym); |
900 | | |
901 | 37.1k | BFD_ASSERT (sizeof (internal_s->s_name) <= SYMNMLEN); |
902 | | |
903 | 37.1k | if (isym.n_scnum == section->target_index) |
904 | 3.48k | { |
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 | 3.48k | symname = _bfd_coff_internal_syment_name (abfd, &isym, buf); |
931 | | |
932 | | /* PR 17512 file: 078-11867-0.004 */ |
933 | 3.48k | if (symname == NULL) |
934 | 88 | { |
935 | 88 | _bfd_error_handler (_("%pB: unable to load COMDAT section name"), |
936 | 88 | abfd); |
937 | 88 | return false; |
938 | 88 | } |
939 | | |
940 | 3.39k | switch (seen_state) |
941 | 3.39k | { |
942 | 2.93k | case 0: |
943 | 2.93k | { |
944 | | /* The first time we've seen the symbol. */ |
945 | 2.93k | 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 | 2.93k | if (! ((isym.n_sclass == C_STAT |
964 | 2.93k | || isym.n_sclass == C_EXT) |
965 | 2.93k | && BTYPE (isym.n_type) == T_NULL |
966 | 2.93k | && isym.n_value == 0)) |
967 | 2.14k | { |
968 | | /* Malformed input files can trigger this test. |
969 | | cf PR 21781. */ |
970 | 2.14k | _bfd_error_handler (_("%pB: error: unexpected symbol '%s' in COMDAT section"), |
971 | 2.14k | abfd, symname); |
972 | 2.14k | return false; |
973 | 2.14k | } |
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 | 792 | if (isym.n_sclass == C_STAT && strcmp (name, symname) != 0) |
981 | | /* xgettext:c-format */ |
982 | 426 | _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'" |
983 | 426 | " does not match section name '%s'"), |
984 | 426 | abfd, symname, name); |
985 | | |
986 | | /* This is the section symbol. */ |
987 | 792 | seen_state = 1; |
988 | 792 | target_name = strchr (name, '$'); |
989 | 792 | if (target_name != NULL) |
990 | 236 | { |
991 | | /* Gas mode. */ |
992 | 236 | seen_state = 2; |
993 | | /* Skip the `$'. */ |
994 | 236 | target_name += 1; |
995 | 236 | } |
996 | | |
997 | 792 | if (isym.n_numaux == 0) |
998 | 398 | aux.x_scn.x_comdat = 0; |
999 | 394 | else |
1000 | 394 | { |
1001 | | /* PR 17512: file: e2cfe54f. */ |
1002 | 394 | if (esym + bfd_coff_symesz (abfd) >= esymend) |
1003 | 22 | { |
1004 | | /* xgettext:c-format */ |
1005 | 22 | _bfd_error_handler (_("%pB: warning: no symbol for" |
1006 | 22 | " section '%s' found"), |
1007 | 22 | abfd, symname); |
1008 | 22 | break; |
1009 | 22 | } |
1010 | 372 | bfd_coff_swap_aux_in (abfd, esym + bfd_coff_symesz (abfd), |
1011 | 372 | isym.n_type, isym.n_sclass, |
1012 | 372 | 0, isym.n_numaux, &aux); |
1013 | 372 | } |
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 | 770 | switch (aux.x_scn.x_comdat) |
1032 | 770 | { |
1033 | 48 | case IMAGE_COMDAT_SELECT_NODUPLICATES: |
1034 | | #ifdef STRICT_PE_FORMAT |
1035 | | *sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY; |
1036 | | #else |
1037 | 48 | *sec_flags &= ~SEC_LINK_ONCE; |
1038 | 48 | #endif |
1039 | 48 | break; |
1040 | | |
1041 | 0 | case IMAGE_COMDAT_SELECT_ANY: |
1042 | 0 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; |
1043 | 0 | break; |
1044 | | |
1045 | 42 | case IMAGE_COMDAT_SELECT_SAME_SIZE: |
1046 | 42 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE; |
1047 | 42 | break; |
1048 | | |
1049 | 36 | case IMAGE_COMDAT_SELECT_EXACT_MATCH: |
1050 | | /* Not yet fully implemented ??? */ |
1051 | 36 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS; |
1052 | 36 | 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 | 46 | 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 | 46 | *sec_flags &= ~SEC_LINK_ONCE; |
1067 | 46 | #endif |
1068 | 46 | break; |
1069 | | |
1070 | 598 | default: /* 0 means "no symbol" */ |
1071 | | /* debug$F gets this case; other |
1072 | | implications ??? */ |
1073 | 598 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; |
1074 | 598 | break; |
1075 | 770 | } |
1076 | 770 | } |
1077 | 770 | break; |
1078 | | |
1079 | 770 | case 2: |
1080 | | /* Gas mode: the first matching on partial name. */ |
1081 | | |
1082 | | #ifndef TARGET_UNDERSCORE |
1083 | 48 | #define TARGET_UNDERSCORE 0 |
1084 | | #endif |
1085 | | /* Is this the name we're looking for ? */ |
1086 | 350 | if (strcmp (target_name, |
1087 | 350 | symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0) |
1088 | 294 | { |
1089 | | /* Not the name we're looking for */ |
1090 | 294 | continue; |
1091 | 294 | } |
1092 | | /* Fall through. */ |
1093 | 162 | case 1: |
1094 | | /* MSVC mode: the lexically second symbol (or |
1095 | | drop through from the above). */ |
1096 | 162 | { |
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 | 162 | struct coff_comdat_info *comdat; |
1103 | 162 | size_t len = strlen (symname) + 1; |
1104 | | |
1105 | 162 | comdat = bfd_alloc (abfd, sizeof (*comdat) + len); |
1106 | 162 | if (comdat == NULL) |
1107 | 0 | return false; |
1108 | | |
1109 | 162 | coff_section_data (abfd, section)->comdat = comdat; |
1110 | 162 | comdat->symbol = (esym - esymstart) / bfd_coff_symesz (abfd); |
1111 | 162 | char *newname = (char *) (comdat + 1); |
1112 | 162 | comdat->name = newname; |
1113 | 162 | memcpy (newname, symname, len); |
1114 | 162 | return true; |
1115 | 162 | } |
1116 | 3.39k | } |
1117 | 3.39k | } |
1118 | 37.1k | } |
1119 | | |
1120 | 13.7k | return true; |
1121 | 16.1k | } Line | Count | Source | 861 | 1.56k | { | 862 | 1.56k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 863 | 1.56k | bfd_byte *esymstart, *esym, *esymend; | 864 | 1.56k | int seen_state = 0; | 865 | 1.56k | char *target_name = NULL; | 866 | | | 867 | 1.56k | *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 | 1.56k | if (! _bfd_coff_get_external_symbols (abfd)) | 887 | 974 | return true; | 888 | | | 889 | 592 | esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd); | 890 | 592 | esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd); | 891 | | | 892 | 592 | for (struct internal_syment isym; | 893 | 840 | esym < esymend; | 894 | 592 | esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd)) | 895 | 270 | { | 896 | 270 | char buf[SYMNMLEN + 1]; | 897 | 270 | const char *symname; | 898 | | | 899 | 270 | bfd_coff_swap_sym_in (abfd, esym, &isym); | 900 | | | 901 | 270 | BFD_ASSERT (sizeof (internal_s->s_name) <= SYMNMLEN); | 902 | | | 903 | 270 | if (isym.n_scnum == section->target_index) | 904 | 46 | { | 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 | 46 | symname = _bfd_coff_internal_syment_name (abfd, &isym, buf); | 931 | | | 932 | | /* PR 17512 file: 078-11867-0.004 */ | 933 | 46 | if (symname == NULL) | 934 | 8 | { | 935 | 8 | _bfd_error_handler (_("%pB: unable to load COMDAT section name"), | 936 | 8 | abfd); | 937 | 8 | return false; | 938 | 8 | } | 939 | | | 940 | 38 | switch (seen_state) | 941 | 38 | { | 942 | 36 | case 0: | 943 | 36 | { | 944 | | /* The first time we've seen the symbol. */ | 945 | 36 | 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 | 36 | if (! ((isym.n_sclass == C_STAT | 964 | 36 | || isym.n_sclass == C_EXT) | 965 | 36 | && BTYPE (isym.n_type) == T_NULL | 966 | 36 | && isym.n_value == 0)) | 967 | 12 | { | 968 | | /* Malformed input files can trigger this test. | 969 | | cf PR 21781. */ | 970 | 12 | _bfd_error_handler (_("%pB: error: unexpected symbol '%s' in COMDAT section"), | 971 | 12 | abfd, symname); | 972 | 12 | return false; | 973 | 12 | } | 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 | 24 | if (isym.n_sclass == C_STAT && strcmp (name, symname) != 0) | 981 | | /* xgettext:c-format */ | 982 | 2 | _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'" | 983 | 2 | " does not match section name '%s'"), | 984 | 2 | abfd, symname, name); | 985 | | | 986 | | /* This is the section symbol. */ | 987 | 24 | seen_state = 1; | 988 | 24 | target_name = strchr (name, '$'); | 989 | 24 | 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 | 24 | if (isym.n_numaux == 0) | 998 | 8 | aux.x_scn.x_comdat = 0; | 999 | 16 | else | 1000 | 16 | { | 1001 | | /* PR 17512: file: e2cfe54f. */ | 1002 | 16 | if (esym + bfd_coff_symesz (abfd) >= esymend) | 1003 | 2 | { | 1004 | | /* xgettext:c-format */ | 1005 | 2 | _bfd_error_handler (_("%pB: warning: no symbol for" | 1006 | 2 | " section '%s' found"), | 1007 | 2 | abfd, symname); | 1008 | 2 | break; | 1009 | 2 | } | 1010 | 14 | bfd_coff_swap_aux_in (abfd, esym + bfd_coff_symesz (abfd), | 1011 | 14 | isym.n_type, isym.n_sclass, | 1012 | 14 | 0, isym.n_numaux, &aux); | 1013 | 14 | } | 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 | 4 | case IMAGE_COMDAT_SELECT_NODUPLICATES: | 1034 | | #ifdef STRICT_PE_FORMAT | 1035 | | *sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY; | 1036 | | #else | 1037 | 4 | *sec_flags &= ~SEC_LINK_ONCE; | 1038 | 4 | #endif | 1039 | 4 | break; | 1040 | | | 1041 | 0 | case IMAGE_COMDAT_SELECT_ANY: | 1042 | 0 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1043 | 0 | break; | 1044 | | | 1045 | 2 | case IMAGE_COMDAT_SELECT_SAME_SIZE: | 1046 | 2 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE; | 1047 | 2 | 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 | 2 | 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 | 2 | *sec_flags &= ~SEC_LINK_ONCE; | 1067 | 2 | #endif | 1068 | 2 | break; | 1069 | | | 1070 | 12 | default: /* 0 means "no symbol" */ | 1071 | | /* debug$F gets this case; other | 1072 | | implications ??? */ | 1073 | 12 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1074 | 12 | 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 | 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 | 38 | } | 1117 | 38 | } | 1118 | 270 | } | 1119 | | | 1120 | 570 | return true; | 1121 | 592 | } |
pe-x86_64.c:handle_COMDAT Line | Count | Source | 861 | 408 | { | 862 | 408 | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 863 | 408 | bfd_byte *esymstart, *esym, *esymend; | 864 | 408 | int seen_state = 0; | 865 | 408 | char *target_name = NULL; | 866 | | | 867 | 408 | *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 | 408 | if (! _bfd_coff_get_external_symbols (abfd)) | 887 | 10 | return true; | 888 | | | 889 | 398 | esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd); | 890 | 398 | esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd); | 891 | | | 892 | 398 | for (struct internal_syment isym; | 893 | 2.54k | esym < esymend; | 894 | 2.14k | esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd)) | 895 | 2.18k | { | 896 | 2.18k | char buf[SYMNMLEN + 1]; | 897 | 2.18k | const char *symname; | 898 | | | 899 | 2.18k | bfd_coff_swap_sym_in (abfd, esym, &isym); | 900 | | | 901 | 2.18k | BFD_ASSERT (sizeof (internal_s->s_name) <= SYMNMLEN); | 902 | | | 903 | 2.18k | if (isym.n_scnum == section->target_index) | 904 | 170 | { | 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 | 170 | symname = _bfd_coff_internal_syment_name (abfd, &isym, buf); | 931 | | | 932 | | /* PR 17512 file: 078-11867-0.004 */ | 933 | 170 | if (symname == NULL) | 934 | 4 | { | 935 | 4 | _bfd_error_handler (_("%pB: unable to load COMDAT section name"), | 936 | 4 | abfd); | 937 | 4 | return false; | 938 | 4 | } | 939 | | | 940 | 166 | switch (seen_state) | 941 | 166 | { | 942 | 132 | case 0: | 943 | 132 | { | 944 | | /* The first time we've seen the symbol. */ | 945 | 132 | 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 | 132 | if (! ((isym.n_sclass == C_STAT | 964 | 132 | || isym.n_sclass == C_EXT) | 965 | 132 | && BTYPE (isym.n_type) == T_NULL | 966 | 132 | && isym.n_value == 0)) | 967 | 20 | { | 968 | | /* Malformed input files can trigger this test. | 969 | | cf PR 21781. */ | 970 | 20 | _bfd_error_handler (_("%pB: error: unexpected symbol '%s' in COMDAT section"), | 971 | 20 | abfd, symname); | 972 | 20 | return false; | 973 | 20 | } | 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 | 112 | if (isym.n_sclass == C_STAT && strcmp (name, symname) != 0) | 981 | | /* xgettext:c-format */ | 982 | 80 | _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'" | 983 | 80 | " does not match section name '%s'"), | 984 | 80 | abfd, symname, name); | 985 | | | 986 | | /* This is the section symbol. */ | 987 | 112 | seen_state = 1; | 988 | 112 | target_name = strchr (name, '$'); | 989 | 112 | if (target_name != NULL) | 990 | 20 | { | 991 | | /* Gas mode. */ | 992 | 20 | seen_state = 2; | 993 | | /* Skip the `$'. */ | 994 | 20 | target_name += 1; | 995 | 20 | } | 996 | | | 997 | 112 | if (isym.n_numaux == 0) | 998 | 6 | aux.x_scn.x_comdat = 0; | 999 | 106 | else | 1000 | 106 | { | 1001 | | /* PR 17512: file: e2cfe54f. */ | 1002 | 106 | 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 | 106 | bfd_coff_swap_aux_in (abfd, esym + bfd_coff_symesz (abfd), | 1011 | 106 | isym.n_type, isym.n_sclass, | 1012 | 106 | 0, isym.n_numaux, &aux); | 1013 | 106 | } | 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 | 112 | switch (aux.x_scn.x_comdat) | 1032 | 112 | { | 1033 | 20 | case IMAGE_COMDAT_SELECT_NODUPLICATES: | 1034 | | #ifdef STRICT_PE_FORMAT | 1035 | | *sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY; | 1036 | | #else | 1037 | 20 | *sec_flags &= ~SEC_LINK_ONCE; | 1038 | 20 | #endif | 1039 | 20 | break; | 1040 | | | 1041 | 0 | case IMAGE_COMDAT_SELECT_ANY: | 1042 | 0 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1043 | 0 | break; | 1044 | | | 1045 | 10 | case IMAGE_COMDAT_SELECT_SAME_SIZE: | 1046 | 10 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE; | 1047 | 10 | break; | 1048 | | | 1049 | 6 | case IMAGE_COMDAT_SELECT_EXACT_MATCH: | 1050 | | /* Not yet fully implemented ??? */ | 1051 | 6 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS; | 1052 | 6 | 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 | 12 | 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 | 12 | *sec_flags &= ~SEC_LINK_ONCE; | 1067 | 12 | #endif | 1068 | 12 | break; | 1069 | | | 1070 | 64 | default: /* 0 means "no symbol" */ | 1071 | | /* debug$F gets this case; other | 1072 | | implications ??? */ | 1073 | 64 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1074 | 64 | break; | 1075 | 112 | } | 1076 | 112 | } | 1077 | 112 | break; | 1078 | | | 1079 | 112 | 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 | 24 | if (strcmp (target_name, | 1087 | 24 | symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0) | 1088 | 20 | { | 1089 | | /* Not the name we're looking for */ | 1090 | 20 | continue; | 1091 | 20 | } | 1092 | | /* Fall through. */ | 1093 | 14 | case 1: | 1094 | | /* MSVC mode: the lexically second symbol (or | 1095 | | drop through from the above). */ | 1096 | 14 | { | 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 | 14 | struct coff_comdat_info *comdat; | 1103 | 14 | size_t len = strlen (symname) + 1; | 1104 | | | 1105 | 14 | comdat = bfd_alloc (abfd, sizeof (*comdat) + len); | 1106 | 14 | if (comdat == NULL) | 1107 | 0 | return false; | 1108 | | | 1109 | 14 | coff_section_data (abfd, section)->comdat = comdat; | 1110 | 14 | comdat->symbol = (esym - esymstart) / bfd_coff_symesz (abfd); | 1111 | 14 | char *newname = (char *) (comdat + 1); | 1112 | 14 | comdat->name = newname; | 1113 | 14 | memcpy (newname, symname, len); | 1114 | 14 | return true; | 1115 | 14 | } | 1116 | 166 | } | 1117 | 166 | } | 1118 | 2.18k | } | 1119 | | | 1120 | 360 | return true; | 1121 | 398 | } |
pei-x86_64.c:handle_COMDAT Line | Count | Source | 861 | 274 | { | 862 | 274 | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 863 | 274 | bfd_byte *esymstart, *esym, *esymend; | 864 | 274 | int seen_state = 0; | 865 | 274 | char *target_name = NULL; | 866 | | | 867 | 274 | *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 | 274 | if (! _bfd_coff_get_external_symbols (abfd)) | 887 | 26 | return true; | 888 | | | 889 | 248 | esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd); | 890 | 248 | esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd); | 891 | | | 892 | 248 | for (struct internal_syment isym; | 893 | 3.47k | esym < esymend; | 894 | 3.23k | esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd)) | 895 | 3.26k | { | 896 | 3.26k | char buf[SYMNMLEN + 1]; | 897 | 3.26k | const char *symname; | 898 | | | 899 | 3.26k | bfd_coff_swap_sym_in (abfd, esym, &isym); | 900 | | | 901 | 3.26k | BFD_ASSERT (sizeof (internal_s->s_name) <= SYMNMLEN); | 902 | | | 903 | 3.26k | if (isym.n_scnum == section->target_index) | 904 | 74 | { | 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 | 74 | symname = _bfd_coff_internal_syment_name (abfd, &isym, buf); | 931 | | | 932 | | /* PR 17512 file: 078-11867-0.004 */ | 933 | 74 | if (symname == NULL) | 934 | 4 | { | 935 | 4 | _bfd_error_handler (_("%pB: unable to load COMDAT section name"), | 936 | 4 | abfd); | 937 | 4 | return false; | 938 | 4 | } | 939 | | | 940 | 70 | switch (seen_state) | 941 | 70 | { | 942 | 50 | case 0: | 943 | 50 | { | 944 | | /* The first time we've seen the symbol. */ | 945 | 50 | 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 | 50 | if (! ((isym.n_sclass == C_STAT | 964 | 50 | || isym.n_sclass == C_EXT) | 965 | 50 | && BTYPE (isym.n_type) == T_NULL | 966 | 50 | && isym.n_value == 0)) | 967 | 10 | { | 968 | | /* Malformed input files can trigger this test. | 969 | | cf PR 21781. */ | 970 | 10 | _bfd_error_handler (_("%pB: error: unexpected symbol '%s' in COMDAT section"), | 971 | 10 | abfd, symname); | 972 | 10 | return false; | 973 | 10 | } | 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 | 40 | 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 | 40 | seen_state = 1; | 988 | 40 | target_name = strchr (name, '$'); | 989 | 40 | 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 | 40 | if (isym.n_numaux == 0) | 998 | 30 | 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 | 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 | 10 | bfd_coff_swap_aux_in (abfd, esym + bfd_coff_symesz (abfd), | 1011 | 10 | isym.n_type, isym.n_sclass, | 1012 | 10 | 0, isym.n_numaux, &aux); | 1013 | 10 | } | 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 | 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 | 40 | default: /* 0 means "no symbol" */ | 1071 | | /* debug$F gets this case; other | 1072 | | implications ??? */ | 1073 | 40 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1074 | 40 | 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 | 4 | if (strcmp (target_name, | 1087 | 4 | symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0) | 1088 | 2 | { | 1089 | | /* Not the name we're looking for */ | 1090 | 2 | continue; | 1091 | 2 | } | 1092 | | /* Fall through. */ | 1093 | 18 | case 1: | 1094 | | /* MSVC mode: the lexically second symbol (or | 1095 | | drop through from the above). */ | 1096 | 18 | { | 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 | 18 | struct coff_comdat_info *comdat; | 1103 | 18 | size_t len = strlen (symname) + 1; | 1104 | | | 1105 | 18 | comdat = bfd_alloc (abfd, sizeof (*comdat) + len); | 1106 | 18 | if (comdat == NULL) | 1107 | 0 | return false; | 1108 | | | 1109 | 18 | coff_section_data (abfd, section)->comdat = comdat; | 1110 | 18 | comdat->symbol = (esym - esymstart) / bfd_coff_symesz (abfd); | 1111 | 18 | char *newname = (char *) (comdat + 1); | 1112 | 18 | comdat->name = newname; | 1113 | 18 | memcpy (newname, symname, len); | 1114 | 18 | return true; | 1115 | 18 | } | 1116 | 70 | } | 1117 | 70 | } | 1118 | 3.26k | } | 1119 | | | 1120 | 216 | return true; | 1121 | 248 | } |
pei-aarch64.c:handle_COMDAT Line | Count | Source | 861 | 668 | { | 862 | 668 | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 863 | 668 | bfd_byte *esymstart, *esym, *esymend; | 864 | 668 | int seen_state = 0; | 865 | 668 | char *target_name = NULL; | 866 | | | 867 | 668 | *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 | 668 | if (! _bfd_coff_get_external_symbols (abfd)) | 887 | 60 | return true; | 888 | | | 889 | 608 | esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd); | 890 | 608 | esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd); | 891 | | | 892 | 608 | for (struct internal_syment isym; | 893 | 1.47k | esym < esymend; | 894 | 866 | esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd)) | 895 | 890 | { | 896 | 890 | char buf[SYMNMLEN + 1]; | 897 | 890 | const char *symname; | 898 | | | 899 | 890 | bfd_coff_swap_sym_in (abfd, esym, &isym); | 900 | | | 901 | 890 | BFD_ASSERT (sizeof (internal_s->s_name) <= SYMNMLEN); | 902 | | | 903 | 890 | if (isym.n_scnum == section->target_index) | 904 | 62 | { | 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 | 62 | symname = _bfd_coff_internal_syment_name (abfd, &isym, buf); | 931 | | | 932 | | /* PR 17512 file: 078-11867-0.004 */ | 933 | 62 | 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 | 60 | switch (seen_state) | 941 | 60 | { | 942 | 50 | case 0: | 943 | 50 | { | 944 | | /* The first time we've seen the symbol. */ | 945 | 50 | 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 | 50 | if (! ((isym.n_sclass == C_STAT | 964 | 50 | || isym.n_sclass == C_EXT) | 965 | 50 | && BTYPE (isym.n_type) == T_NULL | 966 | 50 | && isym.n_value == 0)) | 967 | 14 | { | 968 | | /* Malformed input files can trigger this test. | 969 | | cf PR 21781. */ | 970 | 14 | _bfd_error_handler (_("%pB: error: unexpected symbol '%s' in COMDAT section"), | 971 | 14 | abfd, symname); | 972 | 14 | return false; | 973 | 14 | } | 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 | 36 | if (isym.n_sclass == C_STAT && strcmp (name, symname) != 0) | 981 | | /* xgettext:c-format */ | 982 | 22 | _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'" | 983 | 22 | " does not match section name '%s'"), | 984 | 22 | abfd, symname, name); | 985 | | | 986 | | /* This is the section symbol. */ | 987 | 36 | seen_state = 1; | 988 | 36 | target_name = strchr (name, '$'); | 989 | 36 | if (target_name != NULL) | 990 | 12 | { | 991 | | /* Gas mode. */ | 992 | 12 | seen_state = 2; | 993 | | /* Skip the `$'. */ | 994 | 12 | target_name += 1; | 995 | 12 | } | 996 | | | 997 | 36 | if (isym.n_numaux == 0) | 998 | 16 | 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 | 2 | { | 1004 | | /* xgettext:c-format */ | 1005 | 2 | _bfd_error_handler (_("%pB: warning: no symbol for" | 1006 | 2 | " section '%s' found"), | 1007 | 2 | abfd, symname); | 1008 | 2 | break; | 1009 | 2 | } | 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 | 34 | switch (aux.x_scn.x_comdat) | 1032 | 34 | { | 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 | 2 | case IMAGE_COMDAT_SELECT_SAME_SIZE: | 1046 | 2 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE; | 1047 | 2 | 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 | 2 | 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 | 2 | *sec_flags &= ~SEC_LINK_ONCE; | 1067 | 2 | #endif | 1068 | 2 | break; | 1069 | | | 1070 | 26 | default: /* 0 means "no symbol" */ | 1071 | | /* debug$F gets this case; other | 1072 | | implications ??? */ | 1073 | 26 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1074 | 26 | break; | 1075 | 34 | } | 1076 | 34 | } | 1077 | 34 | break; | 1078 | | | 1079 | 34 | case 2: | 1080 | | /* Gas mode: the first matching on partial name. */ | 1081 | | | 1082 | 4 | #ifndef TARGET_UNDERSCORE | 1083 | 4 | #define TARGET_UNDERSCORE 0 | 1084 | 4 | #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 | 2 | { | 1089 | | /* Not the name we're looking for */ | 1090 | 2 | continue; | 1091 | 2 | } | 1092 | | /* Fall through. */ | 1093 | 8 | case 1: | 1094 | | /* MSVC mode: the lexically second symbol (or | 1095 | | drop through from the above). */ | 1096 | 8 | { | 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 | 8 | struct coff_comdat_info *comdat; | 1103 | 8 | size_t len = strlen (symname) + 1; | 1104 | | | 1105 | 8 | comdat = bfd_alloc (abfd, sizeof (*comdat) + len); | 1106 | 8 | if (comdat == NULL) | 1107 | 0 | return false; | 1108 | | | 1109 | 8 | coff_section_data (abfd, section)->comdat = comdat; | 1110 | 8 | comdat->symbol = (esym - esymstart) / bfd_coff_symesz (abfd); | 1111 | 8 | char *newname = (char *) (comdat + 1); | 1112 | 8 | comdat->name = newname; | 1113 | 8 | memcpy (newname, symname, len); | 1114 | 8 | return true; | 1115 | 8 | } | 1116 | 60 | } | 1117 | 60 | } | 1118 | 890 | } | 1119 | | | 1120 | 584 | return true; | 1121 | 608 | } |
pe-aarch64.c:handle_COMDAT Line | Count | Source | 861 | 240 | { | 862 | 240 | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 863 | 240 | bfd_byte *esymstart, *esym, *esymend; | 864 | 240 | int seen_state = 0; | 865 | 240 | char *target_name = NULL; | 866 | | | 867 | 240 | *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 | 240 | if (! _bfd_coff_get_external_symbols (abfd)) | 887 | 32 | return true; | 888 | | | 889 | 208 | esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd); | 890 | 208 | esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd); | 891 | | | 892 | 208 | for (struct internal_syment isym; | 893 | 1.11k | esym < esymend; | 894 | 904 | esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd)) | 895 | 922 | { | 896 | 922 | char buf[SYMNMLEN + 1]; | 897 | 922 | const char *symname; | 898 | | | 899 | 922 | bfd_coff_swap_sym_in (abfd, esym, &isym); | 900 | | | 901 | 922 | BFD_ASSERT (sizeof (internal_s->s_name) <= SYMNMLEN); | 902 | | | 903 | 922 | if (isym.n_scnum == section->target_index) | 904 | 64 | { | 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 | 64 | symname = _bfd_coff_internal_syment_name (abfd, &isym, buf); | 931 | | | 932 | | /* PR 17512 file: 078-11867-0.004 */ | 933 | 64 | 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 | 62 | switch (seen_state) | 941 | 62 | { | 942 | 54 | case 0: | 943 | 54 | { | 944 | | /* The first time we've seen the symbol. */ | 945 | 54 | 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 | 54 | if (! ((isym.n_sclass == C_STAT | 964 | 54 | || isym.n_sclass == C_EXT) | 965 | 54 | && BTYPE (isym.n_type) == T_NULL | 966 | 54 | && 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 | 46 | if (isym.n_sclass == C_STAT && strcmp (name, symname) != 0) | 981 | | /* xgettext:c-format */ | 982 | 18 | _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'" | 983 | 18 | " does not match section name '%s'"), | 984 | 18 | abfd, symname, name); | 985 | | | 986 | | /* This is the section symbol. */ | 987 | 46 | seen_state = 1; | 988 | 46 | target_name = strchr (name, '$'); | 989 | 46 | 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 | 46 | if (isym.n_numaux == 0) | 998 | 32 | 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 | 2 | { | 1004 | | /* xgettext:c-format */ | 1005 | 2 | _bfd_error_handler (_("%pB: warning: no symbol for" | 1006 | 2 | " section '%s' found"), | 1007 | 2 | abfd, symname); | 1008 | 2 | break; | 1009 | 2 | } | 1010 | 12 | bfd_coff_swap_aux_in (abfd, esym + bfd_coff_symesz (abfd), | 1011 | 12 | isym.n_type, isym.n_sclass, | 1012 | 12 | 0, isym.n_numaux, &aux); | 1013 | 12 | } | 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 | 44 | switch (aux.x_scn.x_comdat) | 1032 | 44 | { | 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 | 2 | case IMAGE_COMDAT_SELECT_SAME_SIZE: | 1046 | 2 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE; | 1047 | 2 | 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 | 2 | 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 | 2 | *sec_flags &= ~SEC_LINK_ONCE; | 1067 | 2 | #endif | 1068 | 2 | break; | 1069 | | | 1070 | 36 | default: /* 0 means "no symbol" */ | 1071 | | /* debug$F gets this case; other | 1072 | | implications ??? */ | 1073 | 36 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1074 | 36 | break; | 1075 | 44 | } | 1076 | 44 | } | 1077 | 44 | break; | 1078 | | | 1079 | 44 | 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 | 8 | case 1: | 1094 | | /* MSVC mode: the lexically second symbol (or | 1095 | | drop through from the above). */ | 1096 | 8 | { | 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 | 8 | struct coff_comdat_info *comdat; | 1103 | 8 | size_t len = strlen (symname) + 1; | 1104 | | | 1105 | 8 | comdat = bfd_alloc (abfd, sizeof (*comdat) + len); | 1106 | 8 | if (comdat == NULL) | 1107 | 0 | return false; | 1108 | | | 1109 | 8 | coff_section_data (abfd, section)->comdat = comdat; | 1110 | 8 | comdat->symbol = (esym - esymstart) / bfd_coff_symesz (abfd); | 1111 | 8 | char *newname = (char *) (comdat + 1); | 1112 | 8 | comdat->name = newname; | 1113 | 8 | memcpy (newname, symname, len); | 1114 | 8 | return true; | 1115 | 8 | } | 1116 | 62 | } | 1117 | 62 | } | 1118 | 922 | } | 1119 | | | 1120 | 190 | return true; | 1121 | 208 | } |
Line | Count | Source | 861 | 4.97k | { | 862 | 4.97k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 863 | 4.97k | bfd_byte *esymstart, *esym, *esymend; | 864 | 4.97k | int seen_state = 0; | 865 | 4.97k | char *target_name = NULL; | 866 | | | 867 | 4.97k | *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 | 4.97k | if (! _bfd_coff_get_external_symbols (abfd)) | 887 | 2.88k | return true; | 888 | | | 889 | 2.09k | esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd); | 890 | 2.09k | esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd); | 891 | | | 892 | 2.09k | for (struct internal_syment isym; | 893 | 2.66k | esym < esymend; | 894 | 2.09k | esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd)) | 895 | 614 | { | 896 | 614 | char buf[SYMNMLEN + 1]; | 897 | 614 | const char *symname; | 898 | | | 899 | 614 | bfd_coff_swap_sym_in (abfd, esym, &isym); | 900 | | | 901 | 614 | BFD_ASSERT (sizeof (internal_s->s_name) <= SYMNMLEN); | 902 | | | 903 | 614 | if (isym.n_scnum == section->target_index) | 904 | 152 | { | 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 | 152 | symname = _bfd_coff_internal_syment_name (abfd, &isym, buf); | 931 | | | 932 | | /* PR 17512 file: 078-11867-0.004 */ | 933 | 152 | if (symname == NULL) | 934 | 8 | { | 935 | 8 | _bfd_error_handler (_("%pB: unable to load COMDAT section name"), | 936 | 8 | abfd); | 937 | 8 | return false; | 938 | 8 | } | 939 | | | 940 | 144 | switch (seen_state) | 941 | 144 | { | 942 | 84 | case 0: | 943 | 84 | { | 944 | | /* The first time we've seen the symbol. */ | 945 | 84 | 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 | 84 | if (! ((isym.n_sclass == C_STAT | 964 | 84 | || isym.n_sclass == C_EXT) | 965 | 84 | && BTYPE (isym.n_type) == T_NULL | 966 | 84 | && isym.n_value == 0)) | 967 | 22 | { | 968 | | /* Malformed input files can trigger this test. | 969 | | cf PR 21781. */ | 970 | 22 | _bfd_error_handler (_("%pB: error: unexpected symbol '%s' in COMDAT section"), | 971 | 22 | abfd, symname); | 972 | 22 | return false; | 973 | 22 | } | 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 | 62 | if (isym.n_sclass == C_STAT && strcmp (name, symname) != 0) | 981 | | /* xgettext:c-format */ | 982 | 36 | _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'" | 983 | 36 | " does not match section name '%s'"), | 984 | 36 | abfd, symname, name); | 985 | | | 986 | | /* This is the section symbol. */ | 987 | 62 | seen_state = 1; | 988 | 62 | target_name = strchr (name, '$'); | 989 | 62 | if (target_name != NULL) | 990 | 26 | { | 991 | | /* Gas mode. */ | 992 | 26 | seen_state = 2; | 993 | | /* Skip the `$'. */ | 994 | 26 | target_name += 1; | 995 | 26 | } | 996 | | | 997 | 62 | if (isym.n_numaux == 0) | 998 | 48 | 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 | 2 | { | 1004 | | /* xgettext:c-format */ | 1005 | 2 | _bfd_error_handler (_("%pB: warning: no symbol for" | 1006 | 2 | " section '%s' found"), | 1007 | 2 | abfd, symname); | 1008 | 2 | break; | 1009 | 2 | } | 1010 | 12 | bfd_coff_swap_aux_in (abfd, esym + bfd_coff_symesz (abfd), | 1011 | 12 | isym.n_type, isym.n_sclass, | 1012 | 12 | 0, isym.n_numaux, &aux); | 1013 | 12 | } | 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 | 60 | switch (aux.x_scn.x_comdat) | 1032 | 60 | { | 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 | 2 | case IMAGE_COMDAT_SELECT_SAME_SIZE: | 1046 | 2 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE; | 1047 | 2 | 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 | 58 | default: /* 0 means "no symbol" */ | 1071 | | /* debug$F gets this case; other | 1072 | | implications ??? */ | 1073 | 58 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1074 | 58 | break; | 1075 | 60 | } | 1076 | 60 | } | 1077 | 60 | break; | 1078 | | | 1079 | 60 | 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 | 52 | if (strcmp (target_name, | 1087 | 52 | symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0) | 1088 | 46 | { | 1089 | | /* Not the name we're looking for */ | 1090 | 46 | continue; | 1091 | 46 | } | 1092 | | /* Fall through. */ | 1093 | 14 | case 1: | 1094 | | /* MSVC mode: the lexically second symbol (or | 1095 | | drop through from the above). */ | 1096 | 14 | { | 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 | 14 | struct coff_comdat_info *comdat; | 1103 | 14 | size_t len = strlen (symname) + 1; | 1104 | | | 1105 | 14 | comdat = bfd_alloc (abfd, sizeof (*comdat) + len); | 1106 | 14 | if (comdat == NULL) | 1107 | 0 | return false; | 1108 | | | 1109 | 14 | coff_section_data (abfd, section)->comdat = comdat; | 1110 | 14 | comdat->symbol = (esym - esymstart) / bfd_coff_symesz (abfd); | 1111 | 14 | char *newname = (char *) (comdat + 1); | 1112 | 14 | comdat->name = newname; | 1113 | 14 | memcpy (newname, symname, len); | 1114 | 14 | return true; | 1115 | 14 | } | 1116 | 144 | } | 1117 | 144 | } | 1118 | 614 | } | 1119 | | | 1120 | 2.04k | return true; | 1121 | 2.09k | } |
pei-loongarch64.c:handle_COMDAT Line | Count | Source | 861 | 290 | { | 862 | 290 | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 863 | 290 | bfd_byte *esymstart, *esym, *esymend; | 864 | 290 | int seen_state = 0; | 865 | 290 | char *target_name = NULL; | 866 | | | 867 | 290 | *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 | 290 | if (! _bfd_coff_get_external_symbols (abfd)) | 887 | 50 | return true; | 888 | | | 889 | 240 | esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd); | 890 | 240 | esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd); | 891 | | | 892 | 240 | for (struct internal_syment isym; | 893 | 5.68k | esym < esymend; | 894 | 5.44k | esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd)) | 895 | 5.47k | { | 896 | 5.47k | char buf[SYMNMLEN + 1]; | 897 | 5.47k | const char *symname; | 898 | | | 899 | 5.47k | bfd_coff_swap_sym_in (abfd, esym, &isym); | 900 | | | 901 | 5.47k | BFD_ASSERT (sizeof (internal_s->s_name) <= SYMNMLEN); | 902 | | | 903 | 5.47k | if (isym.n_scnum == section->target_index) | 904 | 100 | { | 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 | 100 | symname = _bfd_coff_internal_syment_name (abfd, &isym, buf); | 931 | | | 932 | | /* PR 17512 file: 078-11867-0.004 */ | 933 | 100 | if (symname == NULL) | 934 | 4 | { | 935 | 4 | _bfd_error_handler (_("%pB: unable to load COMDAT section name"), | 936 | 4 | abfd); | 937 | 4 | return false; | 938 | 4 | } | 939 | | | 940 | 96 | switch (seen_state) | 941 | 96 | { | 942 | 80 | case 0: | 943 | 80 | { | 944 | | /* The first time we've seen the symbol. */ | 945 | 80 | 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 | 80 | if (! ((isym.n_sclass == C_STAT | 964 | 80 | || isym.n_sclass == C_EXT) | 965 | 80 | && BTYPE (isym.n_type) == T_NULL | 966 | 80 | && 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 | 72 | if (isym.n_sclass == C_STAT && strcmp (name, symname) != 0) | 981 | | /* xgettext:c-format */ | 982 | 20 | _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'" | 983 | 20 | " does not match section name '%s'"), | 984 | 20 | abfd, symname, name); | 985 | | | 986 | | /* This is the section symbol. */ | 987 | 72 | seen_state = 1; | 988 | 72 | target_name = strchr (name, '$'); | 989 | 72 | if (target_name != NULL) | 990 | 12 | { | 991 | | /* Gas mode. */ | 992 | 12 | seen_state = 2; | 993 | | /* Skip the `$'. */ | 994 | 12 | target_name += 1; | 995 | 12 | } | 996 | | | 997 | 72 | if (isym.n_numaux == 0) | 998 | 56 | aux.x_scn.x_comdat = 0; | 999 | 16 | else | 1000 | 16 | { | 1001 | | /* PR 17512: file: e2cfe54f. */ | 1002 | 16 | if (esym + bfd_coff_symesz (abfd) >= esymend) | 1003 | 2 | { | 1004 | | /* xgettext:c-format */ | 1005 | 2 | _bfd_error_handler (_("%pB: warning: no symbol for" | 1006 | 2 | " section '%s' found"), | 1007 | 2 | abfd, symname); | 1008 | 2 | break; | 1009 | 2 | } | 1010 | 14 | bfd_coff_swap_aux_in (abfd, esym + bfd_coff_symesz (abfd), | 1011 | 14 | isym.n_type, isym.n_sclass, | 1012 | 14 | 0, isym.n_numaux, &aux); | 1013 | 14 | } | 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 | 70 | switch (aux.x_scn.x_comdat) | 1032 | 70 | { | 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 | 2 | case IMAGE_COMDAT_SELECT_SAME_SIZE: | 1046 | 2 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE; | 1047 | 2 | 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 | 2 | 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 | 2 | *sec_flags &= ~SEC_LINK_ONCE; | 1067 | 2 | #endif | 1068 | 2 | break; | 1069 | | | 1070 | 62 | default: /* 0 means "no symbol" */ | 1071 | | /* debug$F gets this case; other | 1072 | | implications ??? */ | 1073 | 62 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1074 | 62 | break; | 1075 | 70 | } | 1076 | 70 | } | 1077 | 70 | break; | 1078 | | | 1079 | 70 | case 2: | 1080 | | /* Gas mode: the first matching on partial name. */ | 1081 | | | 1082 | 6 | #ifndef TARGET_UNDERSCORE | 1083 | 6 | #define TARGET_UNDERSCORE 0 | 1084 | 6 | #endif | 1085 | | /* Is this the name we're looking for ? */ | 1086 | 6 | if (strcmp (target_name, | 1087 | 6 | symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0) | 1088 | 2 | { | 1089 | | /* Not the name we're looking for */ | 1090 | 2 | continue; | 1091 | 2 | } | 1092 | | /* Fall through. */ | 1093 | 14 | case 1: | 1094 | | /* MSVC mode: the lexically second symbol (or | 1095 | | drop through from the above). */ | 1096 | 14 | { | 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 | 14 | struct coff_comdat_info *comdat; | 1103 | 14 | size_t len = strlen (symname) + 1; | 1104 | | | 1105 | 14 | comdat = bfd_alloc (abfd, sizeof (*comdat) + len); | 1106 | 14 | if (comdat == NULL) | 1107 | 0 | return false; | 1108 | | | 1109 | 14 | coff_section_data (abfd, section)->comdat = comdat; | 1110 | 14 | comdat->symbol = (esym - esymstart) / bfd_coff_symesz (abfd); | 1111 | 14 | char *newname = (char *) (comdat + 1); | 1112 | 14 | comdat->name = newname; | 1113 | 14 | memcpy (newname, symname, len); | 1114 | 14 | return true; | 1115 | 14 | } | 1116 | 96 | } | 1117 | 96 | } | 1118 | 5.47k | } | 1119 | | | 1120 | 214 | return true; | 1121 | 240 | } |
pe-arm-wince.c:handle_COMDAT Line | Count | Source | 861 | 256 | { | 862 | 256 | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 863 | 256 | bfd_byte *esymstart, *esym, *esymend; | 864 | 256 | int seen_state = 0; | 865 | 256 | char *target_name = NULL; | 866 | | | 867 | 256 | *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 | 256 | if (! _bfd_coff_get_external_symbols (abfd)) | 887 | 68 | return true; | 888 | | | 889 | 188 | esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd); | 890 | 188 | esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd); | 891 | | | 892 | 188 | for (struct internal_syment isym; | 893 | 1.43k | esym < esymend; | 894 | 1.25k | esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd)) | 895 | 1.28k | { | 896 | 1.28k | char buf[SYMNMLEN + 1]; | 897 | 1.28k | const char *symname; | 898 | | | 899 | 1.28k | bfd_coff_swap_sym_in (abfd, esym, &isym); | 900 | | | 901 | 1.28k | BFD_ASSERT (sizeof (internal_s->s_name) <= SYMNMLEN); | 902 | | | 903 | 1.28k | if (isym.n_scnum == section->target_index) | 904 | 112 | { | 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 | 112 | symname = _bfd_coff_internal_syment_name (abfd, &isym, buf); | 931 | | | 932 | | /* PR 17512 file: 078-11867-0.004 */ | 933 | 112 | if (symname == NULL) | 934 | 6 | { | 935 | 6 | _bfd_error_handler (_("%pB: unable to load COMDAT section name"), | 936 | 6 | abfd); | 937 | 6 | return false; | 938 | 6 | } | 939 | | | 940 | 106 | switch (seen_state) | 941 | 106 | { | 942 | 58 | case 0: | 943 | 58 | { | 944 | | /* The first time we've seen the symbol. */ | 945 | 58 | 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 | 58 | if (! ((isym.n_sclass == C_STAT | 964 | 58 | || isym.n_sclass == C_EXT) | 965 | 58 | && BTYPE (isym.n_type) == T_NULL | 966 | 58 | && isym.n_value == 0)) | 967 | 18 | { | 968 | | /* Malformed input files can trigger this test. | 969 | | cf PR 21781. */ | 970 | 18 | _bfd_error_handler (_("%pB: error: unexpected symbol '%s' in COMDAT section"), | 971 | 18 | abfd, symname); | 972 | 18 | return false; | 973 | 18 | } | 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 | 40 | if (isym.n_sclass == C_STAT && strcmp (name, symname) != 0) | 981 | | /* xgettext:c-format */ | 982 | 22 | _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'" | 983 | 22 | " does not match section name '%s'"), | 984 | 22 | abfd, symname, name); | 985 | | | 986 | | /* This is the section symbol. */ | 987 | 40 | seen_state = 1; | 988 | 40 | target_name = strchr (name, '$'); | 989 | 40 | if (target_name != NULL) | 990 | 14 | { | 991 | | /* Gas mode. */ | 992 | 14 | seen_state = 2; | 993 | | /* Skip the `$'. */ | 994 | 14 | target_name += 1; | 995 | 14 | } | 996 | | | 997 | 40 | if (isym.n_numaux == 0) | 998 | 8 | aux.x_scn.x_comdat = 0; | 999 | 32 | else | 1000 | 32 | { | 1001 | | /* PR 17512: file: e2cfe54f. */ | 1002 | 32 | if (esym + bfd_coff_symesz (abfd) >= esymend) | 1003 | 2 | { | 1004 | | /* xgettext:c-format */ | 1005 | 2 | _bfd_error_handler (_("%pB: warning: no symbol for" | 1006 | 2 | " section '%s' found"), | 1007 | 2 | abfd, symname); | 1008 | 2 | break; | 1009 | 2 | } | 1010 | 30 | bfd_coff_swap_aux_in (abfd, esym + bfd_coff_symesz (abfd), | 1011 | 30 | isym.n_type, isym.n_sclass, | 1012 | 30 | 0, isym.n_numaux, &aux); | 1013 | 30 | } | 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 | 38 | switch (aux.x_scn.x_comdat) | 1032 | 38 | { | 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 | 2 | case IMAGE_COMDAT_SELECT_SAME_SIZE: | 1046 | 2 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE; | 1047 | 2 | 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 | 8 | 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 | 8 | *sec_flags &= ~SEC_LINK_ONCE; | 1067 | 8 | #endif | 1068 | 8 | break; | 1069 | | | 1070 | 24 | default: /* 0 means "no symbol" */ | 1071 | | /* debug$F gets this case; other | 1072 | | implications ??? */ | 1073 | 24 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1074 | 24 | break; | 1075 | 38 | } | 1076 | 38 | } | 1077 | 38 | break; | 1078 | | | 1079 | 46 | 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 | 46 | if (strcmp (target_name, | 1087 | 46 | symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0) | 1088 | 42 | { | 1089 | | /* Not the name we're looking for */ | 1090 | 42 | continue; | 1091 | 42 | } | 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 | 106 | } | 1117 | 106 | } | 1118 | 1.28k | } | 1119 | | | 1120 | 158 | return true; | 1121 | 188 | } |
Line | Count | Source | 861 | 256 | { | 862 | 256 | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 863 | 256 | bfd_byte *esymstart, *esym, *esymend; | 864 | 256 | int seen_state = 0; | 865 | 256 | char *target_name = NULL; | 866 | | | 867 | 256 | *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 | 256 | if (! _bfd_coff_get_external_symbols (abfd)) | 887 | 68 | return true; | 888 | | | 889 | 188 | esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd); | 890 | 188 | esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd); | 891 | | | 892 | 188 | for (struct internal_syment isym; | 893 | 1.44k | esym < esymend; | 894 | 1.25k | esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd)) | 895 | 1.28k | { | 896 | 1.28k | char buf[SYMNMLEN + 1]; | 897 | 1.28k | const char *symname; | 898 | | | 899 | 1.28k | bfd_coff_swap_sym_in (abfd, esym, &isym); | 900 | | | 901 | 1.28k | BFD_ASSERT (sizeof (internal_s->s_name) <= SYMNMLEN); | 902 | | | 903 | 1.28k | if (isym.n_scnum == section->target_index) | 904 | 112 | { | 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 | 112 | symname = _bfd_coff_internal_syment_name (abfd, &isym, buf); | 931 | | | 932 | | /* PR 17512 file: 078-11867-0.004 */ | 933 | 112 | if (symname == NULL) | 934 | 6 | { | 935 | 6 | _bfd_error_handler (_("%pB: unable to load COMDAT section name"), | 936 | 6 | abfd); | 937 | 6 | return false; | 938 | 6 | } | 939 | | | 940 | 106 | switch (seen_state) | 941 | 106 | { | 942 | 58 | case 0: | 943 | 58 | { | 944 | | /* The first time we've seen the symbol. */ | 945 | 58 | 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 | 58 | if (! ((isym.n_sclass == C_STAT | 964 | 58 | || isym.n_sclass == C_EXT) | 965 | 58 | && BTYPE (isym.n_type) == T_NULL | 966 | 58 | && isym.n_value == 0)) | 967 | 18 | { | 968 | | /* Malformed input files can trigger this test. | 969 | | cf PR 21781. */ | 970 | 18 | _bfd_error_handler (_("%pB: error: unexpected symbol '%s' in COMDAT section"), | 971 | 18 | abfd, symname); | 972 | 18 | return false; | 973 | 18 | } | 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 | 40 | if (isym.n_sclass == C_STAT && strcmp (name, symname) != 0) | 981 | | /* xgettext:c-format */ | 982 | 22 | _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'" | 983 | 22 | " does not match section name '%s'"), | 984 | 22 | abfd, symname, name); | 985 | | | 986 | | /* This is the section symbol. */ | 987 | 40 | seen_state = 1; | 988 | 40 | target_name = strchr (name, '$'); | 989 | 40 | if (target_name != NULL) | 990 | 14 | { | 991 | | /* Gas mode. */ | 992 | 14 | seen_state = 2; | 993 | | /* Skip the `$'. */ | 994 | 14 | target_name += 1; | 995 | 14 | } | 996 | | | 997 | 40 | if (isym.n_numaux == 0) | 998 | 8 | aux.x_scn.x_comdat = 0; | 999 | 32 | else | 1000 | 32 | { | 1001 | | /* PR 17512: file: e2cfe54f. */ | 1002 | 32 | if (esym + bfd_coff_symesz (abfd) >= esymend) | 1003 | 2 | { | 1004 | | /* xgettext:c-format */ | 1005 | 2 | _bfd_error_handler (_("%pB: warning: no symbol for" | 1006 | 2 | " section '%s' found"), | 1007 | 2 | abfd, symname); | 1008 | 2 | break; | 1009 | 2 | } | 1010 | 30 | bfd_coff_swap_aux_in (abfd, esym + bfd_coff_symesz (abfd), | 1011 | 30 | isym.n_type, isym.n_sclass, | 1012 | 30 | 0, isym.n_numaux, &aux); | 1013 | 30 | } | 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 | 38 | switch (aux.x_scn.x_comdat) | 1032 | 38 | { | 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 | 2 | case IMAGE_COMDAT_SELECT_SAME_SIZE: | 1046 | 2 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE; | 1047 | 2 | 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 | 8 | 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 | 8 | *sec_flags &= ~SEC_LINK_ONCE; | 1067 | 8 | #endif | 1068 | 8 | break; | 1069 | | | 1070 | 24 | default: /* 0 means "no symbol" */ | 1071 | | /* debug$F gets this case; other | 1072 | | implications ??? */ | 1073 | 24 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1074 | 24 | break; | 1075 | 38 | } | 1076 | 38 | } | 1077 | 38 | break; | 1078 | | | 1079 | 46 | 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 | 46 | if (strcmp (target_name, | 1087 | 46 | symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0) | 1088 | 44 | { | 1089 | | /* Not the name we're looking for */ | 1090 | 44 | continue; | 1091 | 44 | } | 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 | 106 | } | 1117 | 106 | } | 1118 | 1.28k | } | 1119 | | | 1120 | 160 | return true; | 1121 | 188 | } |
Line | Count | Source | 861 | 252 | { | 862 | 252 | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 863 | 252 | bfd_byte *esymstart, *esym, *esymend; | 864 | 252 | int seen_state = 0; | 865 | 252 | char *target_name = NULL; | 866 | | | 867 | 252 | *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 | 252 | if (! _bfd_coff_get_external_symbols (abfd)) | 887 | 108 | return true; | 888 | | | 889 | 144 | esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd); | 890 | 144 | esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd); | 891 | | | 892 | 144 | for (struct internal_syment isym; | 893 | 1.68k | esym < esymend; | 894 | 1.54k | esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd)) | 895 | 1.55k | { | 896 | 1.55k | char buf[SYMNMLEN + 1]; | 897 | 1.55k | const char *symname; | 898 | | | 899 | 1.55k | bfd_coff_swap_sym_in (abfd, esym, &isym); | 900 | | | 901 | 1.55k | BFD_ASSERT (sizeof (internal_s->s_name) <= SYMNMLEN); | 902 | | | 903 | 1.55k | if (isym.n_scnum == section->target_index) | 904 | 54 | { | 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 | 54 | symname = _bfd_coff_internal_syment_name (abfd, &isym, buf); | 931 | | | 932 | | /* PR 17512 file: 078-11867-0.004 */ | 933 | 54 | if (symname == NULL) | 934 | 4 | { | 935 | 4 | _bfd_error_handler (_("%pB: unable to load COMDAT section name"), | 936 | 4 | abfd); | 937 | 4 | return false; | 938 | 4 | } | 939 | | | 940 | 50 | switch (seen_state) | 941 | 50 | { | 942 | 40 | case 0: | 943 | 40 | { | 944 | | /* The first time we've seen the symbol. */ | 945 | 40 | 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 | 40 | if (! ((isym.n_sclass == C_STAT | 964 | 40 | || isym.n_sclass == C_EXT) | 965 | 40 | && BTYPE (isym.n_type) == T_NULL | 966 | 40 | && 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 | 34 | if (isym.n_sclass == C_STAT && strcmp (name, symname) != 0) | 981 | | /* xgettext:c-format */ | 982 | 26 | _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'" | 983 | 26 | " does not match section name '%s'"), | 984 | 26 | abfd, symname, name); | 985 | | | 986 | | /* This is the section symbol. */ | 987 | 34 | seen_state = 1; | 988 | 34 | target_name = strchr (name, '$'); | 989 | 34 | 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 | 34 | if (isym.n_numaux == 0) | 998 | 8 | aux.x_scn.x_comdat = 0; | 999 | 26 | else | 1000 | 26 | { | 1001 | | /* PR 17512: file: e2cfe54f. */ | 1002 | 26 | if (esym + bfd_coff_symesz (abfd) >= esymend) | 1003 | 4 | { | 1004 | | /* xgettext:c-format */ | 1005 | 4 | _bfd_error_handler (_("%pB: warning: no symbol for" | 1006 | 4 | " section '%s' found"), | 1007 | 4 | abfd, symname); | 1008 | 4 | break; | 1009 | 4 | } | 1010 | 22 | bfd_coff_swap_aux_in (abfd, esym + bfd_coff_symesz (abfd), | 1011 | 22 | isym.n_type, isym.n_sclass, | 1012 | 22 | 0, isym.n_numaux, &aux); | 1013 | 22 | } | 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 | 30 | switch (aux.x_scn.x_comdat) | 1032 | 30 | { | 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 | 4 | case IMAGE_COMDAT_SELECT_SAME_SIZE: | 1046 | 4 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE; | 1047 | 4 | 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 | 2 | 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 | 2 | *sec_flags &= ~SEC_LINK_ONCE; | 1067 | 2 | #endif | 1068 | 2 | 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 | 30 | } | 1076 | 30 | } | 1077 | 30 | break; | 1078 | | | 1079 | 30 | 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 | 8 | if (strcmp (target_name, | 1087 | 8 | 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 | 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 | 50 | } | 1117 | 50 | } | 1118 | 1.55k | } | 1119 | | | 1120 | 130 | return true; | 1121 | 144 | } |
Line | Count | Source | 861 | 700 | { | 862 | 700 | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 863 | 700 | bfd_byte *esymstart, *esym, *esymend; | 864 | 700 | int seen_state = 0; | 865 | 700 | char *target_name = NULL; | 866 | | | 867 | 700 | *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 | 700 | if (! _bfd_coff_get_external_symbols (abfd)) | 887 | 32 | return true; | 888 | | | 889 | 668 | esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd); | 890 | 668 | esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd); | 891 | | | 892 | 668 | for (struct internal_syment isym; | 893 | 1.65k | esym < esymend; | 894 | 982 | esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd)) | 895 | 1.01k | { | 896 | 1.01k | char buf[SYMNMLEN + 1]; | 897 | 1.01k | const char *symname; | 898 | | | 899 | 1.01k | bfd_coff_swap_sym_in (abfd, esym, &isym); | 900 | | | 901 | 1.01k | BFD_ASSERT (sizeof (internal_s->s_name) <= SYMNMLEN); | 902 | | | 903 | 1.01k | if (isym.n_scnum == section->target_index) | 904 | 60 | { | 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 | 60 | symname = _bfd_coff_internal_syment_name (abfd, &isym, buf); | 931 | | | 932 | | /* PR 17512 file: 078-11867-0.004 */ | 933 | 60 | if (symname == NULL) | 934 | 8 | { | 935 | 8 | _bfd_error_handler (_("%pB: unable to load COMDAT section name"), | 936 | 8 | abfd); | 937 | 8 | return false; | 938 | 8 | } | 939 | | | 940 | 52 | switch (seen_state) | 941 | 52 | { | 942 | 40 | case 0: | 943 | 40 | { | 944 | | /* The first time we've seen the symbol. */ | 945 | 40 | 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 | 40 | if (! ((isym.n_sclass == C_STAT | 964 | 40 | || isym.n_sclass == C_EXT) | 965 | 40 | && BTYPE (isym.n_type) == T_NULL | 966 | 40 | && isym.n_value == 0)) | 967 | 18 | { | 968 | | /* Malformed input files can trigger this test. | 969 | | cf PR 21781. */ | 970 | 18 | _bfd_error_handler (_("%pB: error: unexpected symbol '%s' in COMDAT section"), | 971 | 18 | abfd, symname); | 972 | 18 | return false; | 973 | 18 | } | 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 | 8 | { | 991 | | /* Gas mode. */ | 992 | 8 | seen_state = 2; | 993 | | /* Skip the `$'. */ | 994 | 8 | target_name += 1; | 995 | 8 | } | 996 | | | 997 | 22 | if (isym.n_numaux == 0) | 998 | 10 | aux.x_scn.x_comdat = 0; | 999 | 12 | else | 1000 | 12 | { | 1001 | | /* PR 17512: file: e2cfe54f. */ | 1002 | 12 | if (esym + bfd_coff_symesz (abfd) >= esymend) | 1003 | 2 | { | 1004 | | /* xgettext:c-format */ | 1005 | 2 | _bfd_error_handler (_("%pB: warning: no symbol for" | 1006 | 2 | " section '%s' found"), | 1007 | 2 | abfd, symname); | 1008 | 2 | break; | 1009 | 2 | } | 1010 | 10 | bfd_coff_swap_aux_in (abfd, esym + bfd_coff_symesz (abfd), | 1011 | 10 | isym.n_type, isym.n_sclass, | 1012 | 10 | 0, isym.n_numaux, &aux); | 1013 | 10 | } | 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 | 20 | switch (aux.x_scn.x_comdat) | 1032 | 20 | { | 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 | 2 | case IMAGE_COMDAT_SELECT_SAME_SIZE: | 1046 | 2 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE; | 1047 | 2 | 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 | 2 | 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 | 2 | *sec_flags &= ~SEC_LINK_ONCE; | 1067 | 2 | #endif | 1068 | 2 | break; | 1069 | | | 1070 | 14 | default: /* 0 means "no symbol" */ | 1071 | | /* debug$F gets this case; other | 1072 | | implications ??? */ | 1073 | 14 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1074 | 14 | break; | 1075 | 20 | } | 1076 | 20 | } | 1077 | 20 | break; | 1078 | | | 1079 | 20 | case 2: | 1080 | | /* Gas mode: the first matching on partial name. */ | 1081 | | | 1082 | 10 | #ifndef TARGET_UNDERSCORE | 1083 | 10 | #define TARGET_UNDERSCORE 0 | 1084 | 10 | #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 | 8 | { | 1089 | | /* Not the name we're looking for */ | 1090 | 8 | continue; | 1091 | 8 | } | 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 | 52 | } | 1117 | 52 | } | 1118 | 1.01k | } | 1119 | | | 1120 | 638 | return true; | 1121 | 668 | } |
Line | Count | Source | 861 | 760 | { | 862 | 760 | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 863 | 760 | bfd_byte *esymstart, *esym, *esymend; | 864 | 760 | int seen_state = 0; | 865 | 760 | char *target_name = NULL; | 866 | | | 867 | 760 | *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 | 760 | if (! _bfd_coff_get_external_symbols (abfd)) | 887 | 18 | return true; | 888 | | | 889 | 742 | esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd); | 890 | 742 | esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd); | 891 | | | 892 | 742 | for (struct internal_syment isym; | 893 | 6.73k | esym < esymend; | 894 | 5.99k | esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd)) | 895 | 6.00k | { | 896 | 6.00k | char buf[SYMNMLEN + 1]; | 897 | 6.00k | const char *symname; | 898 | | | 899 | 6.00k | bfd_coff_swap_sym_in (abfd, esym, &isym); | 900 | | | 901 | 6.00k | BFD_ASSERT (sizeof (internal_s->s_name) <= SYMNMLEN); | 902 | | | 903 | 6.00k | if (isym.n_scnum == section->target_index) | 904 | 96 | { | 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 | 96 | symname = _bfd_coff_internal_syment_name (abfd, &isym, buf); | 931 | | | 932 | | /* PR 17512 file: 078-11867-0.004 */ | 933 | 96 | 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 | 94 | switch (seen_state) | 941 | 94 | { | 942 | 76 | case 0: | 943 | 76 | { | 944 | | /* The first time we've seen the symbol. */ | 945 | 76 | 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 | 76 | if (! ((isym.n_sclass == C_STAT | 964 | 76 | || isym.n_sclass == C_EXT) | 965 | 76 | && BTYPE (isym.n_type) == T_NULL | 966 | 76 | && 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 | 68 | if (isym.n_sclass == C_STAT && strcmp (name, symname) != 0) | 981 | | /* xgettext:c-format */ | 982 | 52 | _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'" | 983 | 52 | " does not match section name '%s'"), | 984 | 52 | abfd, symname, name); | 985 | | | 986 | | /* This is the section symbol. */ | 987 | 68 | seen_state = 1; | 988 | 68 | target_name = strchr (name, '$'); | 989 | 68 | if (target_name != NULL) | 990 | 12 | { | 991 | | /* Gas mode. */ | 992 | 12 | seen_state = 2; | 993 | | /* Skip the `$'. */ | 994 | 12 | target_name += 1; | 995 | 12 | } | 996 | | | 997 | 68 | if (isym.n_numaux == 0) | 998 | 8 | aux.x_scn.x_comdat = 0; | 999 | 60 | else | 1000 | 60 | { | 1001 | | /* PR 17512: file: e2cfe54f. */ | 1002 | 60 | if (esym + bfd_coff_symesz (abfd) >= esymend) | 1003 | 2 | { | 1004 | | /* xgettext:c-format */ | 1005 | 2 | _bfd_error_handler (_("%pB: warning: no symbol for" | 1006 | 2 | " section '%s' found"), | 1007 | 2 | abfd, symname); | 1008 | 2 | break; | 1009 | 2 | } | 1010 | 58 | bfd_coff_swap_aux_in (abfd, esym + bfd_coff_symesz (abfd), | 1011 | 58 | isym.n_type, isym.n_sclass, | 1012 | 58 | 0, isym.n_numaux, &aux); | 1013 | 58 | } | 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 | 66 | switch (aux.x_scn.x_comdat) | 1032 | 66 | { | 1033 | 10 | case IMAGE_COMDAT_SELECT_NODUPLICATES: | 1034 | | #ifdef STRICT_PE_FORMAT | 1035 | | *sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY; | 1036 | | #else | 1037 | 10 | *sec_flags &= ~SEC_LINK_ONCE; | 1038 | 10 | #endif | 1039 | 10 | break; | 1040 | | | 1041 | 0 | case IMAGE_COMDAT_SELECT_ANY: | 1042 | 0 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1043 | 0 | break; | 1044 | | | 1045 | 4 | case IMAGE_COMDAT_SELECT_SAME_SIZE: | 1046 | 4 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE; | 1047 | 4 | break; | 1048 | | | 1049 | 6 | case IMAGE_COMDAT_SELECT_EXACT_MATCH: | 1050 | | /* Not yet fully implemented ??? */ | 1051 | 6 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS; | 1052 | 6 | 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 | 4 | 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 | 4 | *sec_flags &= ~SEC_LINK_ONCE; | 1067 | 4 | #endif | 1068 | 4 | break; | 1069 | | | 1070 | 42 | default: /* 0 means "no symbol" */ | 1071 | | /* debug$F gets this case; other | 1072 | | implications ??? */ | 1073 | 42 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1074 | 42 | break; | 1075 | 66 | } | 1076 | 66 | } | 1077 | 66 | break; | 1078 | | | 1079 | 66 | 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 | 14 | if (strcmp (target_name, | 1087 | 14 | symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0) | 1088 | 12 | { | 1089 | | /* Not the name we're looking for */ | 1090 | 12 | continue; | 1091 | 12 | } | 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 | 94 | } | 1117 | 94 | } | 1118 | 6.00k | } | 1119 | | | 1120 | 726 | return true; | 1121 | 742 | } |
pei-arm-wince.c:handle_COMDAT Line | Count | Source | 861 | 3.55k | { | 862 | 3.55k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 863 | 3.55k | bfd_byte *esymstart, *esym, *esymend; | 864 | 3.55k | int seen_state = 0; | 865 | 3.55k | char *target_name = NULL; | 866 | | | 867 | 3.55k | *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.55k | if (! _bfd_coff_get_external_symbols (abfd)) | 887 | 1.47k | return true; | 888 | | | 889 | 2.07k | esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd); | 890 | 2.07k | esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd); | 891 | | | 892 | 2.07k | for (struct internal_syment isym; | 893 | 2.99k | esym < esymend; | 894 | 2.07k | esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd)) | 895 | 1.91k | { | 896 | 1.91k | char buf[SYMNMLEN + 1]; | 897 | 1.91k | const char *symname; | 898 | | | 899 | 1.91k | bfd_coff_swap_sym_in (abfd, esym, &isym); | 900 | | | 901 | 1.91k | BFD_ASSERT (sizeof (internal_s->s_name) <= SYMNMLEN); | 902 | | | 903 | 1.91k | if (isym.n_scnum == section->target_index) | 904 | 1.08k | { | 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 | 1.08k | symname = _bfd_coff_internal_syment_name (abfd, &isym, buf); | 931 | | | 932 | | /* PR 17512 file: 078-11867-0.004 */ | 933 | 1.08k | if (symname == NULL) | 934 | 6 | { | 935 | 6 | _bfd_error_handler (_("%pB: unable to load COMDAT section name"), | 936 | 6 | abfd); | 937 | 6 | return false; | 938 | 6 | } | 939 | | | 940 | 1.08k | switch (seen_state) | 941 | 1.08k | { | 942 | 1.03k | case 0: | 943 | 1.03k | { | 944 | | /* The first time we've seen the symbol. */ | 945 | 1.03k | 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 | 1.03k | if (! ((isym.n_sclass == C_STAT | 964 | 1.03k | || isym.n_sclass == C_EXT) | 965 | 1.03k | && BTYPE (isym.n_type) == T_NULL | 966 | 1.03k | && isym.n_value == 0)) | 967 | 976 | { | 968 | | /* Malformed input files can trigger this test. | 969 | | cf PR 21781. */ | 970 | 976 | _bfd_error_handler (_("%pB: error: unexpected symbol '%s' in COMDAT section"), | 971 | 976 | abfd, symname); | 972 | 976 | return false; | 973 | 976 | } | 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 | 56 | if (isym.n_sclass == C_STAT && strcmp (name, symname) != 0) | 981 | | /* xgettext:c-format */ | 982 | 28 | _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'" | 983 | 28 | " does not match section name '%s'"), | 984 | 28 | abfd, symname, name); | 985 | | | 986 | | /* This is the section symbol. */ | 987 | 56 | seen_state = 1; | 988 | 56 | target_name = strchr (name, '$'); | 989 | 56 | if (target_name != NULL) | 990 | 30 | { | 991 | | /* Gas mode. */ | 992 | 30 | seen_state = 2; | 993 | | /* Skip the `$'. */ | 994 | 30 | target_name += 1; | 995 | 30 | } | 996 | | | 997 | 56 | if (isym.n_numaux == 0) | 998 | 48 | aux.x_scn.x_comdat = 0; | 999 | 8 | else | 1000 | 8 | { | 1001 | | /* PR 17512: file: e2cfe54f. */ | 1002 | 8 | 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 | 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 | 56 | switch (aux.x_scn.x_comdat) | 1032 | 56 | { | 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 | 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 | 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 | 54 | default: /* 0 means "no symbol" */ | 1071 | | /* debug$F gets this case; other | 1072 | | implications ??? */ | 1073 | 54 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1074 | 54 | break; | 1075 | 56 | } | 1076 | 56 | } | 1077 | 56 | break; | 1078 | | | 1079 | 56 | 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 | 40 | if (strcmp (target_name, | 1087 | 40 | symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0) | 1088 | 32 | { | 1089 | | /* Not the name we're looking for */ | 1090 | 32 | continue; | 1091 | 32 | } | 1092 | | /* Fall through. */ | 1093 | 16 | case 1: | 1094 | | /* MSVC mode: the lexically second symbol (or | 1095 | | drop through from the above). */ | 1096 | 16 | { | 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 | 16 | struct coff_comdat_info *comdat; | 1103 | 16 | size_t len = strlen (symname) + 1; | 1104 | | | 1105 | 16 | comdat = bfd_alloc (abfd, sizeof (*comdat) + len); | 1106 | 16 | if (comdat == NULL) | 1107 | 0 | return false; | 1108 | | | 1109 | 16 | coff_section_data (abfd, section)->comdat = comdat; | 1110 | 16 | comdat->symbol = (esym - esymstart) / bfd_coff_symesz (abfd); | 1111 | 16 | char *newname = (char *) (comdat + 1); | 1112 | 16 | comdat->name = newname; | 1113 | 16 | memcpy (newname, symname, len); | 1114 | 16 | return true; | 1115 | 16 | } | 1116 | 1.08k | } | 1117 | 1.08k | } | 1118 | 1.91k | } | 1119 | | | 1120 | 1.08k | return true; | 1121 | 2.07k | } |
Line | Count | Source | 861 | 5.97k | { | 862 | 5.97k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 863 | 5.97k | bfd_byte *esymstart, *esym, *esymend; | 864 | 5.97k | int seen_state = 0; | 865 | 5.97k | char *target_name = NULL; | 866 | | | 867 | 5.97k | *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 | 5.97k | if (! _bfd_coff_get_external_symbols (abfd)) | 887 | 1.95k | return true; | 888 | | | 889 | 4.02k | esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd); | 890 | 4.02k | esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd); | 891 | | | 892 | 4.02k | for (struct internal_syment isym; | 893 | 5.26k | esym < esymend; | 894 | 4.02k | esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd)) | 895 | 2.25k | { | 896 | 2.25k | char buf[SYMNMLEN + 1]; | 897 | 2.25k | const char *symname; | 898 | | | 899 | 2.25k | bfd_coff_swap_sym_in (abfd, esym, &isym); | 900 | | | 901 | 2.25k | BFD_ASSERT (sizeof (internal_s->s_name) <= SYMNMLEN); | 902 | | | 903 | 2.25k | if (isym.n_scnum == section->target_index) | 904 | 1.09k | { | 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 | 1.09k | symname = _bfd_coff_internal_syment_name (abfd, &isym, buf); | 931 | | | 932 | | /* PR 17512 file: 078-11867-0.004 */ | 933 | 1.09k | if (symname == NULL) | 934 | 6 | { | 935 | 6 | _bfd_error_handler (_("%pB: unable to load COMDAT section name"), | 936 | 6 | abfd); | 937 | 6 | return false; | 938 | 6 | } | 939 | | | 940 | 1.08k | switch (seen_state) | 941 | 1.08k | { | 942 | 1.04k | case 0: | 943 | 1.04k | { | 944 | | /* The first time we've seen the symbol. */ | 945 | 1.04k | 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 | 1.04k | if (! ((isym.n_sclass == C_STAT | 964 | 1.04k | || isym.n_sclass == C_EXT) | 965 | 1.04k | && BTYPE (isym.n_type) == T_NULL | 966 | 1.04k | && isym.n_value == 0)) | 967 | 984 | { | 968 | | /* Malformed input files can trigger this test. | 969 | | cf PR 21781. */ | 970 | 984 | _bfd_error_handler (_("%pB: error: unexpected symbol '%s' in COMDAT section"), | 971 | 984 | abfd, symname); | 972 | 984 | return false; | 973 | 984 | } | 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 | 56 | if (isym.n_sclass == C_STAT && strcmp (name, symname) != 0) | 981 | | /* xgettext:c-format */ | 982 | 28 | _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'" | 983 | 28 | " does not match section name '%s'"), | 984 | 28 | abfd, symname, name); | 985 | | | 986 | | /* This is the section symbol. */ | 987 | 56 | seen_state = 1; | 988 | 56 | target_name = strchr (name, '$'); | 989 | 56 | if (target_name != NULL) | 990 | 30 | { | 991 | | /* Gas mode. */ | 992 | 30 | seen_state = 2; | 993 | | /* Skip the `$'. */ | 994 | 30 | target_name += 1; | 995 | 30 | } | 996 | | | 997 | 56 | if (isym.n_numaux == 0) | 998 | 48 | aux.x_scn.x_comdat = 0; | 999 | 8 | else | 1000 | 8 | { | 1001 | | /* PR 17512: file: e2cfe54f. */ | 1002 | 8 | 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 | 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 | 56 | switch (aux.x_scn.x_comdat) | 1032 | 56 | { | 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 | 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 | 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 | 54 | default: /* 0 means "no symbol" */ | 1071 | | /* debug$F gets this case; other | 1072 | | implications ??? */ | 1073 | 54 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1074 | 54 | break; | 1075 | 56 | } | 1076 | 56 | } | 1077 | 56 | break; | 1078 | | | 1079 | 56 | 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 | 40 | if (strcmp (target_name, | 1087 | 40 | symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0) | 1088 | 30 | { | 1089 | | /* Not the name we're looking for */ | 1090 | 30 | continue; | 1091 | 30 | } | 1092 | | /* Fall through. */ | 1093 | 18 | case 1: | 1094 | | /* MSVC mode: the lexically second symbol (or | 1095 | | drop through from the above). */ | 1096 | 18 | { | 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 | 18 | struct coff_comdat_info *comdat; | 1103 | 18 | size_t len = strlen (symname) + 1; | 1104 | | | 1105 | 18 | comdat = bfd_alloc (abfd, sizeof (*comdat) + len); | 1106 | 18 | if (comdat == NULL) | 1107 | 0 | return false; | 1108 | | | 1109 | 18 | coff_section_data (abfd, section)->comdat = comdat; | 1110 | 18 | comdat->symbol = (esym - esymstart) / bfd_coff_symesz (abfd); | 1111 | 18 | char *newname = (char *) (comdat + 1); | 1112 | 18 | comdat->name = newname; | 1113 | 18 | memcpy (newname, symname, len); | 1114 | 18 | return true; | 1115 | 18 | } | 1116 | 1.08k | } | 1117 | 1.08k | } | 1118 | 2.25k | } | 1119 | | | 1120 | 3.01k | return true; | 1121 | 4.02k | } |
pei-mcore.c:handle_COMDAT Line | Count | Source | 861 | 3.05k | { | 862 | 3.05k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 863 | 3.05k | bfd_byte *esymstart, *esym, *esymend; | 864 | 3.05k | int seen_state = 0; | 865 | 3.05k | char *target_name = NULL; | 866 | | | 867 | 3.05k | *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.05k | if (! _bfd_coff_get_external_symbols (abfd)) | 887 | 1.92k | return true; | 888 | | | 889 | 1.12k | esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd); | 890 | 1.12k | esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd); | 891 | | | 892 | 1.12k | for (struct internal_syment isym; | 893 | 8.66k | esym < esymend; | 894 | 7.54k | esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd)) | 895 | 7.57k | { | 896 | 7.57k | char buf[SYMNMLEN + 1]; | 897 | 7.57k | const char *symname; | 898 | | | 899 | 7.57k | bfd_coff_swap_sym_in (abfd, esym, &isym); | 900 | | | 901 | 7.57k | BFD_ASSERT (sizeof (internal_s->s_name) <= SYMNMLEN); | 902 | | | 903 | 7.57k | if (isym.n_scnum == section->target_index) | 904 | 96 | { | 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 | 96 | symname = _bfd_coff_internal_syment_name (abfd, &isym, buf); | 931 | | | 932 | | /* PR 17512 file: 078-11867-0.004 */ | 933 | 96 | if (symname == NULL) | 934 | 10 | { | 935 | 10 | _bfd_error_handler (_("%pB: unable to load COMDAT section name"), | 936 | 10 | abfd); | 937 | 10 | return false; | 938 | 10 | } | 939 | | | 940 | 86 | switch (seen_state) | 941 | 86 | { | 942 | 52 | case 0: | 943 | 52 | { | 944 | | /* The first time we've seen the symbol. */ | 945 | 52 | 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 | 52 | if (! ((isym.n_sclass == C_STAT | 964 | 52 | || isym.n_sclass == C_EXT) | 965 | 52 | && BTYPE (isym.n_type) == T_NULL | 966 | 52 | && isym.n_value == 0)) | 967 | 14 | { | 968 | | /* Malformed input files can trigger this test. | 969 | | cf PR 21781. */ | 970 | 14 | _bfd_error_handler (_("%pB: error: unexpected symbol '%s' in COMDAT section"), | 971 | 14 | abfd, symname); | 972 | 14 | return false; | 973 | 14 | } | 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 | 38 | if (isym.n_sclass == C_STAT && strcmp (name, symname) != 0) | 981 | | /* xgettext:c-format */ | 982 | 20 | _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'" | 983 | 20 | " does not match section name '%s'"), | 984 | 20 | abfd, symname, name); | 985 | | | 986 | | /* This is the section symbol. */ | 987 | 38 | seen_state = 1; | 988 | 38 | target_name = strchr (name, '$'); | 989 | 38 | if (target_name != NULL) | 990 | 20 | { | 991 | | /* Gas mode. */ | 992 | 20 | seen_state = 2; | 993 | | /* Skip the `$'. */ | 994 | 20 | target_name += 1; | 995 | 20 | } | 996 | | | 997 | 38 | if (isym.n_numaux == 0) | 998 | 30 | aux.x_scn.x_comdat = 0; | 999 | 8 | else | 1000 | 8 | { | 1001 | | /* PR 17512: file: e2cfe54f. */ | 1002 | 8 | 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 | 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 | 38 | switch (aux.x_scn.x_comdat) | 1032 | 38 | { | 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 | 2 | case IMAGE_COMDAT_SELECT_SAME_SIZE: | 1046 | 2 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE; | 1047 | 2 | 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 | 2 | 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 | 2 | *sec_flags &= ~SEC_LINK_ONCE; | 1067 | 2 | #endif | 1068 | 2 | break; | 1069 | | | 1070 | 32 | default: /* 0 means "no symbol" */ | 1071 | | /* debug$F gets this case; other | 1072 | | implications ??? */ | 1073 | 32 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1074 | 32 | break; | 1075 | 38 | } | 1076 | 38 | } | 1077 | 38 | break; | 1078 | | | 1079 | 38 | case 2: | 1080 | | /* Gas mode: the first matching on partial name. */ | 1081 | | | 1082 | 28 | #ifndef TARGET_UNDERSCORE | 1083 | 28 | #define TARGET_UNDERSCORE 0 | 1084 | 28 | #endif | 1085 | | /* Is this the name we're looking for ? */ | 1086 | 28 | if (strcmp (target_name, | 1087 | 28 | symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0) | 1088 | 26 | { | 1089 | | /* Not the name we're looking for */ | 1090 | 26 | continue; | 1091 | 26 | } | 1092 | | /* Fall through. */ | 1093 | 8 | case 1: | 1094 | | /* MSVC mode: the lexically second symbol (or | 1095 | | drop through from the above). */ | 1096 | 8 | { | 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 | 8 | struct coff_comdat_info *comdat; | 1103 | 8 | size_t len = strlen (symname) + 1; | 1104 | | | 1105 | 8 | comdat = bfd_alloc (abfd, sizeof (*comdat) + len); | 1106 | 8 | if (comdat == NULL) | 1107 | 0 | return false; | 1108 | | | 1109 | 8 | coff_section_data (abfd, section)->comdat = comdat; | 1110 | 8 | comdat->symbol = (esym - esymstart) / bfd_coff_symesz (abfd); | 1111 | 8 | char *newname = (char *) (comdat + 1); | 1112 | 8 | comdat->name = newname; | 1113 | 8 | memcpy (newname, symname, len); | 1114 | 8 | return true; | 1115 | 8 | } | 1116 | 86 | } | 1117 | 86 | } | 1118 | 7.57k | } | 1119 | | | 1120 | 1.09k | return true; | 1121 | 1.12k | } |
Line | Count | Source | 861 | 3.10k | { | 862 | 3.10k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 863 | 3.10k | bfd_byte *esymstart, *esym, *esymend; | 864 | 3.10k | int seen_state = 0; | 865 | 3.10k | char *target_name = NULL; | 866 | | | 867 | 3.10k | *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.10k | if (! _bfd_coff_get_external_symbols (abfd)) | 887 | 520 | return true; | 888 | | | 889 | 2.58k | esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd); | 890 | 2.58k | esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd); | 891 | | | 892 | 2.58k | for (struct internal_syment isym; | 893 | 3.23k | esym < esymend; | 894 | 2.58k | esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd)) | 895 | 688 | { | 896 | 688 | char buf[SYMNMLEN + 1]; | 897 | 688 | const char *symname; | 898 | | | 899 | 688 | bfd_coff_swap_sym_in (abfd, esym, &isym); | 900 | | | 901 | 688 | BFD_ASSERT (sizeof (internal_s->s_name) <= SYMNMLEN); | 902 | | | 903 | 688 | if (isym.n_scnum == section->target_index) | 904 | 102 | { | 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 | 102 | symname = _bfd_coff_internal_syment_name (abfd, &isym, buf); | 931 | | | 932 | | /* PR 17512 file: 078-11867-0.004 */ | 933 | 102 | if (symname == NULL) | 934 | 8 | { | 935 | 8 | _bfd_error_handler (_("%pB: unable to load COMDAT section name"), | 936 | 8 | abfd); | 937 | 8 | return false; | 938 | 8 | } | 939 | | | 940 | 94 | switch (seen_state) | 941 | 94 | { | 942 | 54 | case 0: | 943 | 54 | { | 944 | | /* The first time we've seen the symbol. */ | 945 | 54 | 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 | 54 | if (! ((isym.n_sclass == C_STAT | 964 | 54 | || isym.n_sclass == C_EXT) | 965 | 54 | && BTYPE (isym.n_type) == T_NULL | 966 | 54 | && 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 | 46 | 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 | 46 | seen_state = 1; | 988 | 46 | target_name = strchr (name, '$'); | 989 | 46 | if (target_name != NULL) | 990 | 22 | { | 991 | | /* Gas mode. */ | 992 | 22 | seen_state = 2; | 993 | | /* Skip the `$'. */ | 994 | 22 | target_name += 1; | 995 | 22 | } | 996 | | | 997 | 46 | if (isym.n_numaux == 0) | 998 | 34 | aux.x_scn.x_comdat = 0; | 999 | 12 | else | 1000 | 12 | { | 1001 | | /* PR 17512: file: e2cfe54f. */ | 1002 | 12 | 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 | 12 | bfd_coff_swap_aux_in (abfd, esym + bfd_coff_symesz (abfd), | 1011 | 12 | isym.n_type, isym.n_sclass, | 1012 | 12 | 0, isym.n_numaux, &aux); | 1013 | 12 | } | 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 | 46 | switch (aux.x_scn.x_comdat) | 1032 | 46 | { | 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 | 6 | case IMAGE_COMDAT_SELECT_SAME_SIZE: | 1046 | 6 | *sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE; | 1047 | 6 | 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 | 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 | 36 | default: /* 0 means "no symbol" */ | 1071 | | /* debug$F gets this case; other | 1072 | | implications ??? */ | 1073 | 36 | *sec_flags |= SEC_LINK_DUPLICATES_DISCARD; | 1074 | 36 | break; | 1075 | 46 | } | 1076 | 46 | } | 1077 | 46 | break; | 1078 | | | 1079 | 46 | 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 | 28 | if (strcmp (target_name, | 1087 | 28 | symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0) | 1088 | 22 | { | 1089 | | /* Not the name we're looking for */ | 1090 | 22 | continue; | 1091 | 22 | } | 1092 | | /* Fall through. */ | 1093 | 18 | case 1: | 1094 | | /* MSVC mode: the lexically second symbol (or | 1095 | | drop through from the above). */ | 1096 | 18 | { | 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 | 18 | struct coff_comdat_info *comdat; | 1103 | 18 | size_t len = strlen (symname) + 1; | 1104 | | | 1105 | 18 | comdat = bfd_alloc (abfd, sizeof (*comdat) + len); | 1106 | 18 | if (comdat == NULL) | 1107 | 0 | return false; | 1108 | | | 1109 | 18 | coff_section_data (abfd, section)->comdat = comdat; | 1110 | 18 | comdat->symbol = (esym - esymstart) / bfd_coff_symesz (abfd); | 1111 | 18 | char *newname = (char *) (comdat + 1); | 1112 | 18 | comdat->name = newname; | 1113 | 18 | memcpy (newname, symname, len); | 1114 | 18 | return true; | 1115 | 18 | } | 1116 | 94 | } | 1117 | 94 | } | 1118 | 688 | } | 1119 | | | 1120 | 2.54k | return true; | 1121 | 2.58k | } |
|
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 | 890k | { |
1140 | 890k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; |
1141 | 890k | unsigned long styp_flags = internal_s->s_flags; |
1142 | 890k | flagword sec_flags; |
1143 | 890k | bool result = true; |
1144 | 890k | bool is_dbg = false; |
1145 | | |
1146 | 890k | if (startswith (name, DOT_DEBUG) |
1147 | 890k | || startswith (name, DOT_ZDEBUG) |
1148 | 890k | #ifdef COFF_LONG_SECTION_NAMES |
1149 | 890k | || startswith (name, GNU_LINKONCE_WI) |
1150 | 890k | || startswith (name, GNU_LINKONCE_WT) |
1151 | | /* FIXME: These definitions ought to be in a header file. */ |
1152 | 890k | #define GNU_DEBUGLINK ".gnu_debuglink" |
1153 | 890k | #define GNU_DEBUGALTLINK ".gnu_debugaltlink" |
1154 | 890k | || startswith (name, GNU_DEBUGLINK) |
1155 | 890k | || startswith (name, GNU_DEBUGALTLINK) |
1156 | 890k | #endif |
1157 | 890k | || startswith (name, ".stab")) |
1158 | 5.01k | is_dbg = true; |
1159 | | /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified. */ |
1160 | 890k | sec_flags = SEC_READONLY; |
1161 | | |
1162 | | /* If section disallows read, then set the NOREAD flag. */ |
1163 | 890k | if ((styp_flags & IMAGE_SCN_MEM_READ) == 0) |
1164 | 840k | sec_flags |= SEC_COFF_NOREAD; |
1165 | | |
1166 | | /* Process each flag bit in styp_flags in turn. */ |
1167 | 2.17M | while (styp_flags) |
1168 | 1.28M | { |
1169 | 1.28M | unsigned long flag = styp_flags & - styp_flags; |
1170 | 1.28M | char * unhandled = NULL; |
1171 | | |
1172 | 1.28M | 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 | 1.28M | switch (flag) |
1179 | 1.28M | { |
1180 | 15.2k | case STYP_DSECT: |
1181 | 15.2k | unhandled = "STYP_DSECT"; |
1182 | 15.2k | break; |
1183 | 17.3k | case STYP_GROUP: |
1184 | 17.3k | unhandled = "STYP_GROUP"; |
1185 | 17.3k | break; |
1186 | 18.0k | case STYP_COPY: |
1187 | 18.0k | unhandled = "STYP_COPY"; |
1188 | 18.0k | break; |
1189 | 12.8k | case STYP_OVER: |
1190 | 12.8k | unhandled = "STYP_OVER"; |
1191 | 12.8k | break; |
1192 | 0 | #ifdef SEC_NEVER_LOAD |
1193 | 68.0k | case STYP_NOLOAD: |
1194 | 68.0k | sec_flags |= SEC_NEVER_LOAD; |
1195 | 68.0k | break; |
1196 | 0 | #endif |
1197 | 50.4k | case IMAGE_SCN_MEM_READ: |
1198 | 50.4k | sec_flags &= ~SEC_COFF_NOREAD; |
1199 | 50.4k | break; |
1200 | 51.6k | case IMAGE_SCN_TYPE_NO_PAD: |
1201 | | /* Skip. */ |
1202 | 51.6k | break; |
1203 | 17.7k | case IMAGE_SCN_LNK_OTHER: |
1204 | 17.7k | unhandled = "IMAGE_SCN_LNK_OTHER"; |
1205 | 17.7k | break; |
1206 | 16.1k | case IMAGE_SCN_MEM_NOT_CACHED: |
1207 | 16.1k | unhandled = "IMAGE_SCN_MEM_NOT_CACHED"; |
1208 | 16.1k | break; |
1209 | 63.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 | 63.9k | _bfd_error_handler (_("%pB: warning: ignoring section flag" |
1215 | 63.9k | " %s in section %s"), |
1216 | 63.9k | abfd, "IMAGE_SCN_MEM_NOT_PAGED", name); |
1217 | 63.9k | break; |
1218 | 44.9k | case IMAGE_SCN_MEM_EXECUTE: |
1219 | 44.9k | sec_flags |= SEC_CODE; |
1220 | 44.9k | break; |
1221 | 38.8k | case IMAGE_SCN_MEM_WRITE: |
1222 | 38.8k | sec_flags &= ~ SEC_READONLY; |
1223 | 38.8k | break; |
1224 | 82.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 | 82.9k | if (is_dbg |
1231 | 82.9k | #ifdef _COMMENT |
1232 | 82.9k | || strcmp (name, _COMMENT) == 0 |
1233 | 82.9k | #endif |
1234 | 82.9k | ) |
1235 | 3.03k | { |
1236 | 3.03k | sec_flags |= SEC_DEBUGGING | SEC_READONLY; |
1237 | 3.03k | } |
1238 | 82.9k | break; |
1239 | 38.7k | case IMAGE_SCN_MEM_SHARED: |
1240 | 38.7k | sec_flags |= SEC_COFF_SHARED; |
1241 | 38.7k | break; |
1242 | 50.1k | case IMAGE_SCN_LNK_REMOVE: |
1243 | 50.1k | if (!is_dbg) |
1244 | 48.1k | sec_flags |= SEC_EXCLUDE; |
1245 | 50.1k | break; |
1246 | 38.1k | case IMAGE_SCN_CNT_CODE: |
1247 | 38.1k | sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD; |
1248 | 38.1k | break; |
1249 | 48.1k | case IMAGE_SCN_CNT_INITIALIZED_DATA: |
1250 | 48.1k | if (is_dbg) |
1251 | 2.15k | sec_flags |= SEC_DEBUGGING; |
1252 | 46.0k | else |
1253 | 46.0k | sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD; |
1254 | 48.1k | break; |
1255 | 28.7k | case IMAGE_SCN_CNT_UNINITIALIZED_DATA: |
1256 | 28.7k | sec_flags |= SEC_ALLOC; |
1257 | 28.7k | break; |
1258 | 66.8k | 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 | 64.6k | sec_flags |= SEC_DEBUGGING; |
1267 | | #endif |
1268 | 66.8k | break; |
1269 | 26.3k | case IMAGE_SCN_LNK_COMDAT: |
1270 | | /* COMDAT gets very special treatment. */ |
1271 | 26.3k | if (!handle_COMDAT (abfd, &sec_flags, hdr, name, section)) |
1272 | 2.23k | result = false; |
1273 | 26.3k | break; |
1274 | 490k | default: |
1275 | | /* Silently ignore for now. */ |
1276 | 490k | break; |
1277 | 1.28M | } |
1278 | | |
1279 | | /* If the section flag was not handled, report it here. */ |
1280 | 1.28M | if (unhandled != NULL) |
1281 | 97.3k | { |
1282 | 97.3k | _bfd_error_handler |
1283 | | /* xgettext:c-format */ |
1284 | 97.3k | (_("%pB (%s): section flag %s (%#lx) ignored"), |
1285 | 97.3k | abfd, name, unhandled, flag); |
1286 | 97.3k | result = false; |
1287 | 97.3k | } |
1288 | 1.28M | } |
1289 | | |
1290 | 890k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 |
1291 | 890k | && (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 | 105k | if (startswith (name, ".gnu.linkonce")) |
1303 | 0 | sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; |
1304 | | #endif |
1305 | | |
1306 | 890k | if (flags_ptr) |
1307 | 890k | * flags_ptr = sec_flags; |
1308 | | |
1309 | 890k | return result; |
1310 | 890k | } pei-i386.c:styp_to_sec_flags Line | Count | Source | 1139 | 12.0k | { | 1140 | 12.0k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 1141 | 12.0k | unsigned long styp_flags = internal_s->s_flags; | 1142 | 12.0k | flagword sec_flags; | 1143 | 12.0k | bool result = true; | 1144 | 12.0k | bool is_dbg = false; | 1145 | | | 1146 | 12.0k | if (startswith (name, DOT_DEBUG) | 1147 | 12.0k | || startswith (name, DOT_ZDEBUG) | 1148 | 12.0k | #ifdef COFF_LONG_SECTION_NAMES | 1149 | 12.0k | || startswith (name, GNU_LINKONCE_WI) | 1150 | 12.0k | || startswith (name, GNU_LINKONCE_WT) | 1151 | | /* FIXME: These definitions ought to be in a header file. */ | 1152 | 12.0k | #define GNU_DEBUGLINK ".gnu_debuglink" | 1153 | 12.0k | #define GNU_DEBUGALTLINK ".gnu_debugaltlink" | 1154 | 12.0k | || startswith (name, GNU_DEBUGLINK) | 1155 | 12.0k | || startswith (name, GNU_DEBUGALTLINK) | 1156 | 12.0k | #endif | 1157 | 12.0k | || startswith (name, ".stab")) | 1158 | 44 | is_dbg = true; | 1159 | | /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified. */ | 1160 | 12.0k | sec_flags = SEC_READONLY; | 1161 | | | 1162 | | /* If section disallows read, then set the NOREAD flag. */ | 1163 | 12.0k | if ((styp_flags & IMAGE_SCN_MEM_READ) == 0) | 1164 | 11.1k | sec_flags |= SEC_COFF_NOREAD; | 1165 | | | 1166 | | /* Process each flag bit in styp_flags in turn. */ | 1167 | 58.0k | while (styp_flags) | 1168 | 46.0k | { | 1169 | 46.0k | unsigned long flag = styp_flags & - styp_flags; | 1170 | 46.0k | char * unhandled = NULL; | 1171 | | | 1172 | 46.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 | 46.0k | switch (flag) | 1179 | 46.0k | { | 1180 | 1.50k | case STYP_DSECT: | 1181 | 1.50k | unhandled = "STYP_DSECT"; | 1182 | 1.50k | break; | 1183 | 1.48k | case STYP_GROUP: | 1184 | 1.48k | unhandled = "STYP_GROUP"; | 1185 | 1.48k | break; | 1186 | 1.97k | case STYP_COPY: | 1187 | 1.97k | unhandled = "STYP_COPY"; | 1188 | 1.97k | break; | 1189 | 532 | case STYP_OVER: | 1190 | 532 | unhandled = "STYP_OVER"; | 1191 | 532 | break; | 1192 | 0 | #ifdef SEC_NEVER_LOAD | 1193 | 2.04k | case STYP_NOLOAD: | 1194 | 2.04k | sec_flags |= SEC_NEVER_LOAD; | 1195 | 2.04k | break; | 1196 | 0 | #endif | 1197 | 826 | case IMAGE_SCN_MEM_READ: | 1198 | 826 | sec_flags &= ~SEC_COFF_NOREAD; | 1199 | 826 | break; | 1200 | 2.01k | case IMAGE_SCN_TYPE_NO_PAD: | 1201 | | /* Skip. */ | 1202 | 2.01k | break; | 1203 | 1.01k | case IMAGE_SCN_LNK_OTHER: | 1204 | 1.01k | unhandled = "IMAGE_SCN_LNK_OTHER"; | 1205 | 1.01k | break; | 1206 | 536 | case IMAGE_SCN_MEM_NOT_CACHED: | 1207 | 536 | unhandled = "IMAGE_SCN_MEM_NOT_CACHED"; | 1208 | 536 | break; | 1209 | 2.03k | 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.03k | _bfd_error_handler (_("%pB: warning: ignoring section flag" | 1215 | 2.03k | " %s in section %s"), | 1216 | 2.03k | abfd, "IMAGE_SCN_MEM_NOT_PAGED", name); | 1217 | 2.03k | break; | 1218 | 1.80k | case IMAGE_SCN_MEM_EXECUTE: | 1219 | 1.80k | sec_flags |= SEC_CODE; | 1220 | 1.80k | break; | 1221 | 1.74k | case IMAGE_SCN_MEM_WRITE: | 1222 | 1.74k | sec_flags &= ~ SEC_READONLY; | 1223 | 1.74k | break; | 1224 | 2.55k | 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.55k | if (is_dbg | 1231 | 2.55k | #ifdef _COMMENT | 1232 | 2.55k | || strcmp (name, _COMMENT) == 0 | 1233 | 2.55k | #endif | 1234 | 2.55k | ) | 1235 | 14 | { | 1236 | 14 | sec_flags |= SEC_DEBUGGING | SEC_READONLY; | 1237 | 14 | } | 1238 | 2.55k | break; | 1239 | 2.01k | case IMAGE_SCN_MEM_SHARED: | 1240 | 2.01k | sec_flags |= SEC_COFF_SHARED; | 1241 | 2.01k | break; | 1242 | 2.03k | case IMAGE_SCN_LNK_REMOVE: | 1243 | 2.03k | if (!is_dbg) | 1244 | 2.01k | sec_flags |= SEC_EXCLUDE; | 1245 | 2.03k | break; | 1246 | 2.27k | case IMAGE_SCN_CNT_CODE: | 1247 | 2.27k | sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD; | 1248 | 2.27k | break; | 1249 | 1.28k | case IMAGE_SCN_CNT_INITIALIZED_DATA: | 1250 | 1.28k | if (is_dbg) | 1251 | 16 | sec_flags |= SEC_DEBUGGING; | 1252 | 1.26k | else | 1253 | 1.26k | sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD; | 1254 | 1.28k | break; | 1255 | 1.71k | case IMAGE_SCN_CNT_UNINITIALIZED_DATA: | 1256 | 1.71k | sec_flags |= SEC_ALLOC; | 1257 | 1.71k | break; | 1258 | 1.08k | 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.08k | #ifdef COFF_PAGE_SIZE | 1266 | 1.08k | sec_flags |= SEC_DEBUGGING; | 1267 | 1.08k | #endif | 1268 | 1.08k | break; | 1269 | 1.56k | case IMAGE_SCN_LNK_COMDAT: | 1270 | | /* COMDAT gets very special treatment. */ | 1271 | 1.56k | if (!handle_COMDAT (abfd, &sec_flags, hdr, name, section)) | 1272 | 20 | result = false; | 1273 | 1.56k | break; | 1274 | 14.0k | default: | 1275 | | /* Silently ignore for now. */ | 1276 | 14.0k | break; | 1277 | 46.0k | } | 1278 | | | 1279 | | /* If the section flag was not handled, report it here. */ | 1280 | 46.0k | if (unhandled != NULL) | 1281 | 7.04k | { | 1282 | 7.04k | _bfd_error_handler | 1283 | | /* xgettext:c-format */ | 1284 | 7.04k | (_("%pB (%s): section flag %s (%#lx) ignored"), | 1285 | 7.04k | abfd, name, unhandled, flag); | 1286 | 7.04k | result = false; | 1287 | 7.04k | } | 1288 | 46.0k | } | 1289 | | | 1290 | 12.0k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 1291 | 12.0k | && (startswith (name, ".sbss") | 1292 | 0 | || startswith (name, ".sdata"))) | 1293 | 0 | sec_flags |= SEC_SMALL_DATA; | 1294 | | | 1295 | 12.0k | #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 | 12.0k | if (startswith (name, ".gnu.linkonce")) | 1303 | 0 | sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; | 1304 | 12.0k | #endif | 1305 | | | 1306 | 12.0k | if (flags_ptr) | 1307 | 12.0k | * flags_ptr = sec_flags; | 1308 | | | 1309 | 12.0k | return result; | 1310 | 12.0k | } |
pe-x86_64.c:styp_to_sec_flags Line | Count | Source | 1139 | 86.6k | { | 1140 | 86.6k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 1141 | 86.6k | unsigned long styp_flags = internal_s->s_flags; | 1142 | 86.6k | flagword sec_flags; | 1143 | 86.6k | bool result = true; | 1144 | 86.6k | bool is_dbg = false; | 1145 | | | 1146 | 86.6k | if (startswith (name, DOT_DEBUG) | 1147 | 86.6k | || startswith (name, DOT_ZDEBUG) | 1148 | 86.6k | #ifdef COFF_LONG_SECTION_NAMES | 1149 | 86.6k | || startswith (name, GNU_LINKONCE_WI) | 1150 | 86.6k | || startswith (name, GNU_LINKONCE_WT) | 1151 | | /* FIXME: These definitions ought to be in a header file. */ | 1152 | 86.6k | #define GNU_DEBUGLINK ".gnu_debuglink" | 1153 | 86.6k | #define GNU_DEBUGALTLINK ".gnu_debugaltlink" | 1154 | 86.6k | || startswith (name, GNU_DEBUGLINK) | 1155 | 86.6k | || startswith (name, GNU_DEBUGALTLINK) | 1156 | 86.6k | #endif | 1157 | 86.6k | || startswith (name, ".stab")) | 1158 | 86 | is_dbg = true; | 1159 | | /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified. */ | 1160 | 86.6k | sec_flags = SEC_READONLY; | 1161 | | | 1162 | | /* If section disallows read, then set the NOREAD flag. */ | 1163 | 86.6k | if ((styp_flags & IMAGE_SCN_MEM_READ) == 0) | 1164 | 73.1k | sec_flags |= SEC_COFF_NOREAD; | 1165 | | | 1166 | | /* Process each flag bit in styp_flags in turn. */ | 1167 | 204k | while (styp_flags) | 1168 | 118k | { | 1169 | 118k | unsigned long flag = styp_flags & - styp_flags; | 1170 | 118k | char * unhandled = NULL; | 1171 | | | 1172 | 118k | 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 | 118k | switch (flag) | 1179 | 118k | { | 1180 | 110 | case STYP_DSECT: | 1181 | 110 | unhandled = "STYP_DSECT"; | 1182 | 110 | break; | 1183 | 74 | case STYP_GROUP: | 1184 | 74 | unhandled = "STYP_GROUP"; | 1185 | 74 | break; | 1186 | 128 | case STYP_COPY: | 1187 | 128 | unhandled = "STYP_COPY"; | 1188 | 128 | break; | 1189 | 132 | case STYP_OVER: | 1190 | 132 | unhandled = "STYP_OVER"; | 1191 | 132 | break; | 1192 | 0 | #ifdef SEC_NEVER_LOAD | 1193 | 13.9k | case STYP_NOLOAD: | 1194 | 13.9k | sec_flags |= SEC_NEVER_LOAD; | 1195 | 13.9k | break; | 1196 | 0 | #endif | 1197 | 13.4k | case IMAGE_SCN_MEM_READ: | 1198 | 13.4k | sec_flags &= ~SEC_COFF_NOREAD; | 1199 | 13.4k | break; | 1200 | 662 | case IMAGE_SCN_TYPE_NO_PAD: | 1201 | | /* Skip. */ | 1202 | 662 | break; | 1203 | 68 | case IMAGE_SCN_LNK_OTHER: | 1204 | 68 | unhandled = "IMAGE_SCN_LNK_OTHER"; | 1205 | 68 | break; | 1206 | 58 | case IMAGE_SCN_MEM_NOT_CACHED: | 1207 | 58 | unhandled = "IMAGE_SCN_MEM_NOT_CACHED"; | 1208 | 58 | break; | 1209 | 588 | 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 | 588 | _bfd_error_handler (_("%pB: warning: ignoring section flag" | 1215 | 588 | " %s in section %s"), | 1216 | 588 | abfd, "IMAGE_SCN_MEM_NOT_PAGED", name); | 1217 | 588 | break; | 1218 | 264 | case IMAGE_SCN_MEM_EXECUTE: | 1219 | 264 | sec_flags |= SEC_CODE; | 1220 | 264 | break; | 1221 | 576 | case IMAGE_SCN_MEM_WRITE: | 1222 | 576 | sec_flags &= ~ SEC_READONLY; | 1223 | 576 | break; | 1224 | 13.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 | 13.9k | if (is_dbg | 1231 | 13.9k | #ifdef _COMMENT | 1232 | 13.9k | || strcmp (name, _COMMENT) == 0 | 1233 | 13.9k | #endif | 1234 | 13.9k | ) | 1235 | 30 | { | 1236 | 30 | sec_flags |= SEC_DEBUGGING | SEC_READONLY; | 1237 | 30 | } | 1238 | 13.9k | break; | 1239 | 214 | case IMAGE_SCN_MEM_SHARED: | 1240 | 214 | sec_flags |= SEC_COFF_SHARED; | 1241 | 214 | break; | 1242 | 668 | case IMAGE_SCN_LNK_REMOVE: | 1243 | 668 | if (!is_dbg) | 1244 | 656 | sec_flags |= SEC_EXCLUDE; | 1245 | 668 | break; | 1246 | 268 | case IMAGE_SCN_CNT_CODE: | 1247 | 268 | sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD; | 1248 | 268 | break; | 1249 | 13.5k | case IMAGE_SCN_CNT_INITIALIZED_DATA: | 1250 | 13.5k | if (is_dbg) | 1251 | 36 | sec_flags |= SEC_DEBUGGING; | 1252 | 13.4k | else | 1253 | 13.4k | sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD; | 1254 | 13.5k | break; | 1255 | 562 | case IMAGE_SCN_CNT_UNINITIALIZED_DATA: | 1256 | 562 | sec_flags |= SEC_ALLOC; | 1257 | 562 | break; | 1258 | 13.9k | 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 | 13.9k | #ifdef COFF_PAGE_SIZE | 1266 | 13.9k | sec_flags |= SEC_DEBUGGING; | 1267 | 13.9k | #endif | 1268 | 13.9k | break; | 1269 | 408 | case IMAGE_SCN_LNK_COMDAT: | 1270 | | /* COMDAT gets very special treatment. */ | 1271 | 408 | if (!handle_COMDAT (abfd, &sec_flags, hdr, name, section)) | 1272 | 24 | result = false; | 1273 | 408 | break; | 1274 | 44.4k | default: | 1275 | | /* Silently ignore for now. */ | 1276 | 44.4k | break; | 1277 | 118k | } | 1278 | | | 1279 | | /* If the section flag was not handled, report it here. */ | 1280 | 118k | if (unhandled != NULL) | 1281 | 570 | { | 1282 | 570 | _bfd_error_handler | 1283 | | /* xgettext:c-format */ | 1284 | 570 | (_("%pB (%s): section flag %s (%#lx) ignored"), | 1285 | 570 | abfd, name, unhandled, flag); | 1286 | 570 | result = false; | 1287 | 570 | } | 1288 | 118k | } | 1289 | | | 1290 | 86.6k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 1291 | 86.6k | && (startswith (name, ".sbss") | 1292 | 0 | || startswith (name, ".sdata"))) | 1293 | 0 | sec_flags |= SEC_SMALL_DATA; | 1294 | | | 1295 | 86.6k | #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 | 86.6k | if (startswith (name, ".gnu.linkonce")) | 1303 | 0 | sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; | 1304 | 86.6k | #endif | 1305 | | | 1306 | 86.6k | if (flags_ptr) | 1307 | 86.6k | * flags_ptr = sec_flags; | 1308 | | | 1309 | 86.6k | return result; | 1310 | 86.6k | } |
pei-x86_64.c:styp_to_sec_flags Line | Count | Source | 1139 | 3.22k | { | 1140 | 3.22k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 1141 | 3.22k | unsigned long styp_flags = internal_s->s_flags; | 1142 | 3.22k | flagword sec_flags; | 1143 | 3.22k | bool result = true; | 1144 | 3.22k | bool is_dbg = false; | 1145 | | | 1146 | 3.22k | if (startswith (name, DOT_DEBUG) | 1147 | 3.22k | || startswith (name, DOT_ZDEBUG) | 1148 | 3.22k | #ifdef COFF_LONG_SECTION_NAMES | 1149 | 3.22k | || startswith (name, GNU_LINKONCE_WI) | 1150 | 3.22k | || startswith (name, GNU_LINKONCE_WT) | 1151 | | /* FIXME: These definitions ought to be in a header file. */ | 1152 | 3.22k | #define GNU_DEBUGLINK ".gnu_debuglink" | 1153 | 3.22k | #define GNU_DEBUGALTLINK ".gnu_debugaltlink" | 1154 | 3.22k | || startswith (name, GNU_DEBUGLINK) | 1155 | 3.22k | || startswith (name, GNU_DEBUGALTLINK) | 1156 | 3.22k | #endif | 1157 | 3.22k | || startswith (name, ".stab")) | 1158 | 46 | is_dbg = true; | 1159 | | /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified. */ | 1160 | 3.22k | sec_flags = SEC_READONLY; | 1161 | | | 1162 | | /* If section disallows read, then set the NOREAD flag. */ | 1163 | 3.22k | if ((styp_flags & IMAGE_SCN_MEM_READ) == 0) | 1164 | 2.40k | sec_flags |= SEC_COFF_NOREAD; | 1165 | | | 1166 | | /* Process each flag bit in styp_flags in turn. */ | 1167 | 18.9k | while (styp_flags) | 1168 | 15.7k | { | 1169 | 15.7k | unsigned long flag = styp_flags & - styp_flags; | 1170 | 15.7k | char * unhandled = NULL; | 1171 | | | 1172 | 15.7k | 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.7k | switch (flag) | 1179 | 15.7k | { | 1180 | 46 | case STYP_DSECT: | 1181 | 46 | unhandled = "STYP_DSECT"; | 1182 | 46 | break; | 1183 | 38 | case STYP_GROUP: | 1184 | 38 | unhandled = "STYP_GROUP"; | 1185 | 38 | break; | 1186 | 50 | case STYP_COPY: | 1187 | 50 | unhandled = "STYP_COPY"; | 1188 | 50 | break; | 1189 | 60 | case STYP_OVER: | 1190 | 60 | unhandled = "STYP_OVER"; | 1191 | 60 | break; | 1192 | 0 | #ifdef SEC_NEVER_LOAD | 1193 | 310 | case STYP_NOLOAD: | 1194 | 310 | sec_flags |= SEC_NEVER_LOAD; | 1195 | 310 | break; | 1196 | 0 | #endif | 1197 | 822 | case IMAGE_SCN_MEM_READ: | 1198 | 822 | sec_flags &= ~SEC_COFF_NOREAD; | 1199 | 822 | break; | 1200 | 822 | case IMAGE_SCN_TYPE_NO_PAD: | 1201 | | /* Skip. */ | 1202 | 822 | break; | 1203 | 58 | case IMAGE_SCN_LNK_OTHER: | 1204 | 58 | unhandled = "IMAGE_SCN_LNK_OTHER"; | 1205 | 58 | break; | 1206 | 38 | case IMAGE_SCN_MEM_NOT_CACHED: | 1207 | 38 | unhandled = "IMAGE_SCN_MEM_NOT_CACHED"; | 1208 | 38 | break; | 1209 | 1.00k | 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.00k | _bfd_error_handler (_("%pB: warning: ignoring section flag" | 1215 | 1.00k | " %s in section %s"), | 1216 | 1.00k | abfd, "IMAGE_SCN_MEM_NOT_PAGED", name); | 1217 | 1.00k | break; | 1218 | 978 | case IMAGE_SCN_MEM_EXECUTE: | 1219 | 978 | sec_flags |= SEC_CODE; | 1220 | 978 | break; | 1221 | 796 | case IMAGE_SCN_MEM_WRITE: | 1222 | 796 | sec_flags &= ~ SEC_READONLY; | 1223 | 796 | break; | 1224 | 386 | 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 | 386 | if (is_dbg | 1231 | 386 | #ifdef _COMMENT | 1232 | 386 | || strcmp (name, _COMMENT) == 0 | 1233 | 386 | #endif | 1234 | 386 | ) | 1235 | 20 | { | 1236 | 20 | sec_flags |= SEC_DEBUGGING | SEC_READONLY; | 1237 | 20 | } | 1238 | 386 | break; | 1239 | 138 | case IMAGE_SCN_MEM_SHARED: | 1240 | 138 | sec_flags |= SEC_COFF_SHARED; | 1241 | 138 | break; | 1242 | 900 | case IMAGE_SCN_LNK_REMOVE: | 1243 | 900 | if (!is_dbg) | 1244 | 888 | sec_flags |= SEC_EXCLUDE; | 1245 | 900 | break; | 1246 | 806 | case IMAGE_SCN_CNT_CODE: | 1247 | 806 | sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD; | 1248 | 806 | break; | 1249 | 636 | case IMAGE_SCN_CNT_INITIALIZED_DATA: | 1250 | 636 | if (is_dbg) | 1251 | 28 | sec_flags |= SEC_DEBUGGING; | 1252 | 608 | else | 1253 | 608 | sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD; | 1254 | 636 | break; | 1255 | 598 | case IMAGE_SCN_CNT_UNINITIALIZED_DATA: | 1256 | 598 | sec_flags |= SEC_ALLOC; | 1257 | 598 | break; | 1258 | 434 | 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 | 434 | #ifdef COFF_PAGE_SIZE | 1266 | 434 | sec_flags |= SEC_DEBUGGING; | 1267 | 434 | #endif | 1268 | 434 | break; | 1269 | 274 | case IMAGE_SCN_LNK_COMDAT: | 1270 | | /* COMDAT gets very special treatment. */ | 1271 | 274 | if (!handle_COMDAT (abfd, &sec_flags, hdr, name, section)) | 1272 | 14 | result = false; | 1273 | 274 | break; | 1274 | 6.55k | default: | 1275 | | /* Silently ignore for now. */ | 1276 | 6.55k | break; | 1277 | 15.7k | } | 1278 | | | 1279 | | /* If the section flag was not handled, report it here. */ | 1280 | 15.7k | if (unhandled != NULL) | 1281 | 290 | { | 1282 | 290 | _bfd_error_handler | 1283 | | /* xgettext:c-format */ | 1284 | 290 | (_("%pB (%s): section flag %s (%#lx) ignored"), | 1285 | 290 | abfd, name, unhandled, flag); | 1286 | 290 | result = false; | 1287 | 290 | } | 1288 | 15.7k | } | 1289 | | | 1290 | 3.22k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 1291 | 3.22k | && (startswith (name, ".sbss") | 1292 | 0 | || startswith (name, ".sdata"))) | 1293 | 0 | sec_flags |= SEC_SMALL_DATA; | 1294 | | | 1295 | 3.22k | #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.22k | if (startswith (name, ".gnu.linkonce")) | 1303 | 0 | sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; | 1304 | 3.22k | #endif | 1305 | | | 1306 | 3.22k | if (flags_ptr) | 1307 | 3.22k | * flags_ptr = sec_flags; | 1308 | | | 1309 | 3.22k | return result; | 1310 | 3.22k | } |
pei-aarch64.c:styp_to_sec_flags Line | Count | Source | 1139 | 9.93k | { | 1140 | 9.93k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 1141 | 9.93k | unsigned long styp_flags = internal_s->s_flags; | 1142 | 9.93k | flagword sec_flags; | 1143 | 9.93k | bool result = true; | 1144 | 9.93k | bool is_dbg = false; | 1145 | | | 1146 | 9.93k | if (startswith (name, DOT_DEBUG) | 1147 | 9.93k | || startswith (name, DOT_ZDEBUG) | 1148 | 9.93k | #ifdef COFF_LONG_SECTION_NAMES | 1149 | 9.93k | || startswith (name, GNU_LINKONCE_WI) | 1150 | 9.93k | || startswith (name, GNU_LINKONCE_WT) | 1151 | | /* FIXME: These definitions ought to be in a header file. */ | 1152 | 9.93k | #define GNU_DEBUGLINK ".gnu_debuglink" | 1153 | 9.93k | #define GNU_DEBUGALTLINK ".gnu_debugaltlink" | 1154 | 9.93k | || startswith (name, GNU_DEBUGLINK) | 1155 | 9.93k | || startswith (name, GNU_DEBUGALTLINK) | 1156 | 9.93k | #endif | 1157 | 9.93k | || startswith (name, ".stab")) | 1158 | 54 | is_dbg = true; | 1159 | | /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified. */ | 1160 | 9.93k | sec_flags = SEC_READONLY; | 1161 | | | 1162 | | /* If section disallows read, then set the NOREAD flag. */ | 1163 | 9.93k | if ((styp_flags & IMAGE_SCN_MEM_READ) == 0) | 1164 | 8.61k | sec_flags |= SEC_COFF_NOREAD; | 1165 | | | 1166 | | /* Process each flag bit in styp_flags in turn. */ | 1167 | 59.0k | while (styp_flags) | 1168 | 49.1k | { | 1169 | 49.1k | unsigned long flag = styp_flags & - styp_flags; | 1170 | 49.1k | char * unhandled = NULL; | 1171 | | | 1172 | 49.1k | 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 | 49.1k | switch (flag) | 1179 | 49.1k | { | 1180 | 1.51k | case STYP_DSECT: | 1181 | 1.51k | unhandled = "STYP_DSECT"; | 1182 | 1.51k | break; | 1183 | 1.49k | case STYP_GROUP: | 1184 | 1.49k | unhandled = "STYP_GROUP"; | 1185 | 1.49k | break; | 1186 | 1.48k | case STYP_COPY: | 1187 | 1.48k | unhandled = "STYP_COPY"; | 1188 | 1.48k | break; | 1189 | 560 | case STYP_OVER: | 1190 | 560 | unhandled = "STYP_OVER"; | 1191 | 560 | break; | 1192 | 0 | #ifdef SEC_NEVER_LOAD | 1193 | 2.92k | case STYP_NOLOAD: | 1194 | 2.92k | sec_flags |= SEC_NEVER_LOAD; | 1195 | 2.92k | break; | 1196 | 0 | #endif | 1197 | 1.32k | case IMAGE_SCN_MEM_READ: | 1198 | 1.32k | sec_flags &= ~SEC_COFF_NOREAD; | 1199 | 1.32k | break; | 1200 | 1.52k | case IMAGE_SCN_TYPE_NO_PAD: | 1201 | | /* Skip. */ | 1202 | 1.52k | break; | 1203 | 1.04k | case IMAGE_SCN_LNK_OTHER: | 1204 | 1.04k | unhandled = "IMAGE_SCN_LNK_OTHER"; | 1205 | 1.04k | break; | 1206 | 1.98k | case IMAGE_SCN_MEM_NOT_CACHED: | 1207 | 1.98k | unhandled = "IMAGE_SCN_MEM_NOT_CACHED"; | 1208 | 1.98k | break; | 1209 | 2.11k | 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.11k | _bfd_error_handler (_("%pB: warning: ignoring section flag" | 1215 | 2.11k | " %s in section %s"), | 1216 | 2.11k | abfd, "IMAGE_SCN_MEM_NOT_PAGED", name); | 1217 | 2.11k | break; | 1218 | 1.80k | case IMAGE_SCN_MEM_EXECUTE: | 1219 | 1.80k | sec_flags |= SEC_CODE; | 1220 | 1.80k | break; | 1221 | 684 | case IMAGE_SCN_MEM_WRITE: | 1222 | 684 | sec_flags &= ~ SEC_READONLY; | 1223 | 684 | break; | 1224 | 1.56k | 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.56k | if (is_dbg | 1231 | 1.56k | #ifdef _COMMENT | 1232 | 1.56k | || strcmp (name, _COMMENT) == 0 | 1233 | 1.56k | #endif | 1234 | 1.56k | ) | 1235 | 40 | { | 1236 | 40 | sec_flags |= SEC_DEBUGGING | SEC_READONLY; | 1237 | 40 | } | 1238 | 1.56k | break; | 1239 | 598 | case IMAGE_SCN_MEM_SHARED: | 1240 | 598 | sec_flags |= SEC_COFF_SHARED; | 1241 | 598 | break; | 1242 | 606 | case IMAGE_SCN_LNK_REMOVE: | 1243 | 606 | if (!is_dbg) | 1244 | 598 | sec_flags |= SEC_EXCLUDE; | 1245 | 606 | break; | 1246 | 2.67k | case IMAGE_SCN_CNT_CODE: | 1247 | 2.67k | sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD; | 1248 | 2.67k | break; | 1249 | 1.65k | case IMAGE_SCN_CNT_INITIALIZED_DATA: | 1250 | 1.65k | if (is_dbg) | 1251 | 44 | sec_flags |= SEC_DEBUGGING; | 1252 | 1.60k | else | 1253 | 1.60k | sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD; | 1254 | 1.65k | break; | 1255 | 1.56k | case IMAGE_SCN_CNT_UNINITIALIZED_DATA: | 1256 | 1.56k | sec_flags |= SEC_ALLOC; | 1257 | 1.56k | break; | 1258 | 1.07k | 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.07k | #ifdef COFF_PAGE_SIZE | 1266 | 1.07k | sec_flags |= SEC_DEBUGGING; | 1267 | 1.07k | #endif | 1268 | 1.07k | break; | 1269 | 668 | case IMAGE_SCN_LNK_COMDAT: | 1270 | | /* COMDAT gets very special treatment. */ | 1271 | 668 | if (!handle_COMDAT (abfd, &sec_flags, hdr, name, section)) | 1272 | 16 | result = false; | 1273 | 668 | break; | 1274 | 20.2k | default: | 1275 | | /* Silently ignore for now. */ | 1276 | 20.2k | break; | 1277 | 49.1k | } | 1278 | | | 1279 | | /* If the section flag was not handled, report it here. */ | 1280 | 49.1k | if (unhandled != NULL) | 1281 | 8.06k | { | 1282 | 8.06k | _bfd_error_handler | 1283 | | /* xgettext:c-format */ | 1284 | 8.06k | (_("%pB (%s): section flag %s (%#lx) ignored"), | 1285 | 8.06k | abfd, name, unhandled, flag); | 1286 | 8.06k | result = false; | 1287 | 8.06k | } | 1288 | 49.1k | } | 1289 | | | 1290 | 9.93k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 1291 | 9.93k | && (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 | 9.93k | if (flags_ptr) | 1307 | 9.93k | * flags_ptr = sec_flags; | 1308 | | | 1309 | 9.93k | return result; | 1310 | 9.93k | } |
pe-aarch64.c:styp_to_sec_flags Line | Count | Source | 1139 | 4.02k | { | 1140 | 4.02k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 1141 | 4.02k | unsigned long styp_flags = internal_s->s_flags; | 1142 | 4.02k | flagword sec_flags; | 1143 | 4.02k | bool result = true; | 1144 | 4.02k | bool is_dbg = false; | 1145 | | | 1146 | 4.02k | if (startswith (name, DOT_DEBUG) | 1147 | 4.02k | || startswith (name, DOT_ZDEBUG) | 1148 | 4.02k | #ifdef COFF_LONG_SECTION_NAMES | 1149 | 4.02k | || startswith (name, GNU_LINKONCE_WI) | 1150 | 4.02k | || startswith (name, GNU_LINKONCE_WT) | 1151 | | /* FIXME: These definitions ought to be in a header file. */ | 1152 | 4.02k | #define GNU_DEBUGLINK ".gnu_debuglink" | 1153 | 4.02k | #define GNU_DEBUGALTLINK ".gnu_debugaltlink" | 1154 | 4.02k | || startswith (name, GNU_DEBUGLINK) | 1155 | 4.02k | || startswith (name, GNU_DEBUGALTLINK) | 1156 | 4.02k | #endif | 1157 | 4.02k | || startswith (name, ".stab")) | 1158 | 48 | is_dbg = true; | 1159 | | /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified. */ | 1160 | 4.02k | sec_flags = SEC_READONLY; | 1161 | | | 1162 | | /* If section disallows read, then set the NOREAD flag. */ | 1163 | 4.02k | if ((styp_flags & IMAGE_SCN_MEM_READ) == 0) | 1164 | 3.59k | sec_flags |= SEC_COFF_NOREAD; | 1165 | | | 1166 | | /* Process each flag bit in styp_flags in turn. */ | 1167 | 13.7k | while (styp_flags) | 1168 | 9.68k | { | 1169 | 9.68k | unsigned long flag = styp_flags & - styp_flags; | 1170 | 9.68k | char * unhandled = NULL; | 1171 | | | 1172 | 9.68k | 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.68k | switch (flag) | 1179 | 9.68k | { | 1180 | 66 | case STYP_DSECT: | 1181 | 66 | unhandled = "STYP_DSECT"; | 1182 | 66 | break; | 1183 | 54 | case STYP_GROUP: | 1184 | 54 | unhandled = "STYP_GROUP"; | 1185 | 54 | break; | 1186 | 46 | case STYP_COPY: | 1187 | 46 | unhandled = "STYP_COPY"; | 1188 | 46 | break; | 1189 | 80 | case STYP_OVER: | 1190 | 80 | unhandled = "STYP_OVER"; | 1191 | 80 | break; | 1192 | 0 | #ifdef SEC_NEVER_LOAD | 1193 | 336 | case STYP_NOLOAD: | 1194 | 336 | sec_flags |= SEC_NEVER_LOAD; | 1195 | 336 | break; | 1196 | 0 | #endif | 1197 | 430 | case IMAGE_SCN_MEM_READ: | 1198 | 430 | sec_flags &= ~SEC_COFF_NOREAD; | 1199 | 430 | break; | 1200 | 474 | case IMAGE_SCN_TYPE_NO_PAD: | 1201 | | /* Skip. */ | 1202 | 474 | break; | 1203 | 76 | case IMAGE_SCN_LNK_OTHER: | 1204 | 76 | unhandled = "IMAGE_SCN_LNK_OTHER"; | 1205 | 76 | break; | 1206 | 56 | case IMAGE_SCN_MEM_NOT_CACHED: | 1207 | 56 | unhandled = "IMAGE_SCN_MEM_NOT_CACHED"; | 1208 | 56 | break; | 1209 | 682 | 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 | 682 | _bfd_error_handler (_("%pB: warning: ignoring section flag" | 1215 | 682 | " %s in section %s"), | 1216 | 682 | abfd, "IMAGE_SCN_MEM_NOT_PAGED", name); | 1217 | 682 | break; | 1218 | 572 | case IMAGE_SCN_MEM_EXECUTE: | 1219 | 572 | sec_flags |= SEC_CODE; | 1220 | 572 | break; | 1221 | 300 | case IMAGE_SCN_MEM_WRITE: | 1222 | 300 | sec_flags &= ~ SEC_READONLY; | 1223 | 300 | break; | 1224 | 404 | 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 | 404 | if (is_dbg | 1231 | 404 | #ifdef _COMMENT | 1232 | 404 | || strcmp (name, _COMMENT) == 0 | 1233 | 404 | #endif | 1234 | 404 | ) | 1235 | 20 | { | 1236 | 20 | sec_flags |= SEC_DEBUGGING | SEC_READONLY; | 1237 | 20 | } | 1238 | 404 | break; | 1239 | 126 | case IMAGE_SCN_MEM_SHARED: | 1240 | 126 | sec_flags |= SEC_COFF_SHARED; | 1241 | 126 | break; | 1242 | 514 | case IMAGE_SCN_LNK_REMOVE: | 1243 | 514 | if (!is_dbg) | 1244 | 492 | sec_flags |= SEC_EXCLUDE; | 1245 | 514 | break; | 1246 | 454 | case IMAGE_SCN_CNT_CODE: | 1247 | 454 | sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD; | 1248 | 454 | break; | 1249 | 270 | case IMAGE_SCN_CNT_INITIALIZED_DATA: | 1250 | 270 | if (is_dbg) | 1251 | 16 | sec_flags |= SEC_DEBUGGING; | 1252 | 254 | else | 1253 | 254 | sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD; | 1254 | 270 | break; | 1255 | 182 | case IMAGE_SCN_CNT_UNINITIALIZED_DATA: | 1256 | 182 | sec_flags |= SEC_ALLOC; | 1257 | 182 | break; | 1258 | 458 | 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 | 458 | #ifdef COFF_PAGE_SIZE | 1266 | 458 | sec_flags |= SEC_DEBUGGING; | 1267 | 458 | #endif | 1268 | 458 | break; | 1269 | 240 | case IMAGE_SCN_LNK_COMDAT: | 1270 | | /* COMDAT gets very special treatment. */ | 1271 | 240 | if (!handle_COMDAT (abfd, &sec_flags, hdr, name, section)) | 1272 | 10 | result = false; | 1273 | 240 | break; | 1274 | 3.86k | default: | 1275 | | /* Silently ignore for now. */ | 1276 | 3.86k | break; | 1277 | 9.68k | } | 1278 | | | 1279 | | /* If the section flag was not handled, report it here. */ | 1280 | 9.68k | if (unhandled != NULL) | 1281 | 378 | { | 1282 | 378 | _bfd_error_handler | 1283 | | /* xgettext:c-format */ | 1284 | 378 | (_("%pB (%s): section flag %s (%#lx) ignored"), | 1285 | 378 | abfd, name, unhandled, flag); | 1286 | 378 | result = false; | 1287 | 378 | } | 1288 | 9.68k | } | 1289 | | | 1290 | 4.02k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 1291 | 4.02k | && (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 | 4.02k | if (flags_ptr) | 1307 | 4.02k | * flags_ptr = sec_flags; | 1308 | | | 1309 | 4.02k | return result; | 1310 | 4.02k | } |
pei-ia64.c:styp_to_sec_flags Line | Count | Source | 1139 | 97.0k | { | 1140 | 97.0k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 1141 | 97.0k | unsigned long styp_flags = internal_s->s_flags; | 1142 | 97.0k | flagword sec_flags; | 1143 | 97.0k | bool result = true; | 1144 | 97.0k | bool is_dbg = false; | 1145 | | | 1146 | 97.0k | if (startswith (name, DOT_DEBUG) | 1147 | 97.0k | || startswith (name, DOT_ZDEBUG) | 1148 | 97.0k | #ifdef COFF_LONG_SECTION_NAMES | 1149 | 97.0k | || startswith (name, GNU_LINKONCE_WI) | 1150 | 97.0k | || startswith (name, GNU_LINKONCE_WT) | 1151 | | /* FIXME: These definitions ought to be in a header file. */ | 1152 | 97.0k | #define GNU_DEBUGLINK ".gnu_debuglink" | 1153 | 97.0k | #define GNU_DEBUGALTLINK ".gnu_debugaltlink" | 1154 | 97.0k | || startswith (name, GNU_DEBUGLINK) | 1155 | 97.0k | || startswith (name, GNU_DEBUGALTLINK) | 1156 | 97.0k | #endif | 1157 | 97.0k | || startswith (name, ".stab")) | 1158 | 1.44k | is_dbg = true; | 1159 | | /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified. */ | 1160 | 97.0k | sec_flags = SEC_READONLY; | 1161 | | | 1162 | | /* If section disallows read, then set the NOREAD flag. */ | 1163 | 97.0k | if ((styp_flags & IMAGE_SCN_MEM_READ) == 0) | 1164 | 93.1k | sec_flags |= SEC_COFF_NOREAD; | 1165 | | | 1166 | | /* Process each flag bit in styp_flags in turn. */ | 1167 | 421k | while (styp_flags) | 1168 | 324k | { | 1169 | 324k | unsigned long flag = styp_flags & - styp_flags; | 1170 | 324k | char * unhandled = NULL; | 1171 | | | 1172 | 324k | 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 | 324k | switch (flag) | 1179 | 324k | { | 1180 | 2.95k | case STYP_DSECT: | 1181 | 2.95k | unhandled = "STYP_DSECT"; | 1182 | 2.95k | break; | 1183 | 2.94k | case STYP_GROUP: | 1184 | 2.94k | unhandled = "STYP_GROUP"; | 1185 | 2.94k | break; | 1186 | 3.89k | case STYP_COPY: | 1187 | 3.89k | unhandled = "STYP_COPY"; | 1188 | 3.89k | break; | 1189 | 2.44k | case STYP_OVER: | 1190 | 2.44k | unhandled = "STYP_OVER"; | 1191 | 2.44k | break; | 1192 | 0 | #ifdef SEC_NEVER_LOAD | 1193 | 22.7k | case STYP_NOLOAD: | 1194 | 22.7k | sec_flags |= SEC_NEVER_LOAD; | 1195 | 22.7k | break; | 1196 | 0 | #endif | 1197 | 3.89k | case IMAGE_SCN_MEM_READ: | 1198 | 3.89k | sec_flags &= ~SEC_COFF_NOREAD; | 1199 | 3.89k | break; | 1200 | 21.3k | case IMAGE_SCN_TYPE_NO_PAD: | 1201 | | /* Skip. */ | 1202 | 21.3k | break; | 1203 | 4.37k | case IMAGE_SCN_LNK_OTHER: | 1204 | 4.37k | unhandled = "IMAGE_SCN_LNK_OTHER"; | 1205 | 4.37k | break; | 1206 | 3.39k | case IMAGE_SCN_MEM_NOT_CACHED: | 1207 | 3.39k | unhandled = "IMAGE_SCN_MEM_NOT_CACHED"; | 1208 | 3.39k | break; | 1209 | 26.2k | 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 | 26.2k | _bfd_error_handler (_("%pB: warning: ignoring section flag" | 1215 | 26.2k | " %s in section %s"), | 1216 | 26.2k | abfd, "IMAGE_SCN_MEM_NOT_PAGED", name); | 1217 | 26.2k | break; | 1218 | 7.39k | case IMAGE_SCN_MEM_EXECUTE: | 1219 | 7.39k | sec_flags |= SEC_CODE; | 1220 | 7.39k | break; | 1221 | 9.81k | case IMAGE_SCN_MEM_WRITE: | 1222 | 9.81k | sec_flags &= ~ SEC_READONLY; | 1223 | 9.81k | break; | 1224 | 26.1k | 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 | 26.1k | if (is_dbg | 1231 | 26.1k | #ifdef _COMMENT | 1232 | 26.1k | || strcmp (name, _COMMENT) == 0 | 1233 | 26.1k | #endif | 1234 | 26.1k | ) | 1235 | 958 | { | 1236 | 958 | sec_flags |= SEC_DEBUGGING | SEC_READONLY; | 1237 | 958 | } | 1238 | 26.1k | break; | 1239 | 7.36k | case IMAGE_SCN_MEM_SHARED: | 1240 | 7.36k | sec_flags |= SEC_COFF_SHARED; | 1241 | 7.36k | break; | 1242 | 21.3k | case IMAGE_SCN_LNK_REMOVE: | 1243 | 21.3k | if (!is_dbg) | 1244 | 20.3k | sec_flags |= SEC_EXCLUDE; | 1245 | 21.3k | break; | 1246 | 5.41k | case IMAGE_SCN_CNT_CODE: | 1247 | 5.41k | sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD; | 1248 | 5.41k | break; | 1249 | 3.88k | case IMAGE_SCN_CNT_INITIALIZED_DATA: | 1250 | 3.88k | if (is_dbg) | 1251 | 482 | sec_flags |= SEC_DEBUGGING; | 1252 | 3.40k | else | 1253 | 3.40k | sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD; | 1254 | 3.88k | break; | 1255 | 6.36k | case IMAGE_SCN_CNT_UNINITIALIZED_DATA: | 1256 | 6.36k | sec_flags |= SEC_ALLOC; | 1257 | 6.36k | break; | 1258 | 21.8k | 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 | 21.8k | #ifdef COFF_PAGE_SIZE | 1266 | 21.8k | sec_flags |= SEC_DEBUGGING; | 1267 | 21.8k | #endif | 1268 | 21.8k | break; | 1269 | 4.97k | case IMAGE_SCN_LNK_COMDAT: | 1270 | | /* COMDAT gets very special treatment. */ | 1271 | 4.97k | if (!handle_COMDAT (abfd, &sec_flags, hdr, name, section)) | 1272 | 30 | result = false; | 1273 | 4.97k | break; | 1274 | 116k | default: | 1275 | | /* Silently ignore for now. */ | 1276 | 116k | break; | 1277 | 324k | } | 1278 | | | 1279 | | /* If the section flag was not handled, report it here. */ | 1280 | 324k | if (unhandled != NULL) | 1281 | 20.0k | { | 1282 | 20.0k | _bfd_error_handler | 1283 | | /* xgettext:c-format */ | 1284 | 20.0k | (_("%pB (%s): section flag %s (%#lx) ignored"), | 1285 | 20.0k | abfd, name, unhandled, flag); | 1286 | 20.0k | result = false; | 1287 | 20.0k | } | 1288 | 324k | } | 1289 | | | 1290 | 97.0k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 1291 | 97.0k | && (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 | 97.0k | if (flags_ptr) | 1307 | 97.0k | * flags_ptr = sec_flags; | 1308 | | | 1309 | 97.0k | return result; | 1310 | 97.0k | } |
pei-loongarch64.c:styp_to_sec_flags Line | Count | Source | 1139 | 2.07k | { | 1140 | 2.07k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 1141 | 2.07k | unsigned long styp_flags = internal_s->s_flags; | 1142 | 2.07k | flagword sec_flags; | 1143 | 2.07k | bool result = true; | 1144 | 2.07k | bool is_dbg = false; | 1145 | | | 1146 | 2.07k | if (startswith (name, DOT_DEBUG) | 1147 | 2.07k | || startswith (name, DOT_ZDEBUG) | 1148 | 2.07k | #ifdef COFF_LONG_SECTION_NAMES | 1149 | 2.07k | || startswith (name, GNU_LINKONCE_WI) | 1150 | 2.07k | || startswith (name, GNU_LINKONCE_WT) | 1151 | | /* FIXME: These definitions ought to be in a header file. */ | 1152 | 2.07k | #define GNU_DEBUGLINK ".gnu_debuglink" | 1153 | 2.07k | #define GNU_DEBUGALTLINK ".gnu_debugaltlink" | 1154 | 2.07k | || startswith (name, GNU_DEBUGLINK) | 1155 | 2.07k | || startswith (name, GNU_DEBUGALTLINK) | 1156 | 2.07k | #endif | 1157 | 2.07k | || startswith (name, ".stab")) | 1158 | 28 | is_dbg = true; | 1159 | | /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified. */ | 1160 | 2.07k | sec_flags = SEC_READONLY; | 1161 | | | 1162 | | /* If section disallows read, then set the NOREAD flag. */ | 1163 | 2.07k | if ((styp_flags & IMAGE_SCN_MEM_READ) == 0) | 1164 | 1.65k | sec_flags |= SEC_COFF_NOREAD; | 1165 | | | 1166 | | /* Process each flag bit in styp_flags in turn. */ | 1167 | 10.3k | while (styp_flags) | 1168 | 8.26k | { | 1169 | 8.26k | unsigned long flag = styp_flags & - styp_flags; | 1170 | 8.26k | char * unhandled = NULL; | 1171 | | | 1172 | 8.26k | 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.26k | switch (flag) | 1179 | 8.26k | { | 1180 | 60 | case STYP_DSECT: | 1181 | 60 | unhandled = "STYP_DSECT"; | 1182 | 60 | break; | 1183 | 42 | case STYP_GROUP: | 1184 | 42 | unhandled = "STYP_GROUP"; | 1185 | 42 | break; | 1186 | 42 | case STYP_COPY: | 1187 | 42 | unhandled = "STYP_COPY"; | 1188 | 42 | break; | 1189 | 76 | case STYP_OVER: | 1190 | 76 | unhandled = "STYP_OVER"; | 1191 | 76 | break; | 1192 | 0 | #ifdef SEC_NEVER_LOAD | 1193 | 440 | case STYP_NOLOAD: | 1194 | 440 | sec_flags |= SEC_NEVER_LOAD; | 1195 | 440 | break; | 1196 | 0 | #endif | 1197 | 418 | case IMAGE_SCN_MEM_READ: | 1198 | 418 | sec_flags &= ~SEC_COFF_NOREAD; | 1199 | 418 | break; | 1200 | 208 | case IMAGE_SCN_TYPE_NO_PAD: | 1201 | | /* Skip. */ | 1202 | 208 | break; | 1203 | 88 | case IMAGE_SCN_LNK_OTHER: | 1204 | 88 | unhandled = "IMAGE_SCN_LNK_OTHER"; | 1205 | 88 | break; | 1206 | 40 | case IMAGE_SCN_MEM_NOT_CACHED: | 1207 | 40 | unhandled = "IMAGE_SCN_MEM_NOT_CACHED"; | 1208 | 40 | break; | 1209 | 294 | 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 | 294 | _bfd_error_handler (_("%pB: warning: ignoring section flag" | 1215 | 294 | " %s in section %s"), | 1216 | 294 | abfd, "IMAGE_SCN_MEM_NOT_PAGED", name); | 1217 | 294 | break; | 1218 | 270 | case IMAGE_SCN_MEM_EXECUTE: | 1219 | 270 | sec_flags |= SEC_CODE; | 1220 | 270 | break; | 1221 | 282 | case IMAGE_SCN_MEM_WRITE: | 1222 | 282 | sec_flags &= ~ SEC_READONLY; | 1223 | 282 | break; | 1224 | 456 | 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 | 456 | if (is_dbg | 1231 | 456 | #ifdef _COMMENT | 1232 | 456 | || strcmp (name, _COMMENT) == 0 | 1233 | 456 | #endif | 1234 | 456 | ) | 1235 | 24 | { | 1236 | 24 | sec_flags |= SEC_DEBUGGING | SEC_READONLY; | 1237 | 24 | } | 1238 | 456 | break; | 1239 | 86 | case IMAGE_SCN_MEM_SHARED: | 1240 | 86 | sec_flags |= SEC_COFF_SHARED; | 1241 | 86 | break; | 1242 | 286 | case IMAGE_SCN_LNK_REMOVE: | 1243 | 286 | if (!is_dbg) | 1244 | 282 | sec_flags |= SEC_EXCLUDE; | 1245 | 286 | break; | 1246 | 200 | case IMAGE_SCN_CNT_CODE: | 1247 | 200 | sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD; | 1248 | 200 | break; | 1249 | 362 | case IMAGE_SCN_CNT_INITIALIZED_DATA: | 1250 | 362 | if (is_dbg) | 1251 | 20 | sec_flags |= SEC_DEBUGGING; | 1252 | 342 | else | 1253 | 342 | sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD; | 1254 | 362 | break; | 1255 | 202 | case IMAGE_SCN_CNT_UNINITIALIZED_DATA: | 1256 | 202 | sec_flags |= SEC_ALLOC; | 1257 | 202 | break; | 1258 | 570 | 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 | 570 | #ifdef COFF_PAGE_SIZE | 1266 | 570 | sec_flags |= SEC_DEBUGGING; | 1267 | 570 | #endif | 1268 | 570 | break; | 1269 | 290 | case IMAGE_SCN_LNK_COMDAT: | 1270 | | /* COMDAT gets very special treatment. */ | 1271 | 290 | if (!handle_COMDAT (abfd, &sec_flags, hdr, name, section)) | 1272 | 12 | result = false; | 1273 | 290 | break; | 1274 | 3.55k | default: | 1275 | | /* Silently ignore for now. */ | 1276 | 3.55k | break; | 1277 | 8.26k | } | 1278 | | | 1279 | | /* If the section flag was not handled, report it here. */ | 1280 | 8.26k | if (unhandled != NULL) | 1281 | 348 | { | 1282 | 348 | _bfd_error_handler | 1283 | | /* xgettext:c-format */ | 1284 | 348 | (_("%pB (%s): section flag %s (%#lx) ignored"), | 1285 | 348 | abfd, name, unhandled, flag); | 1286 | 348 | result = false; | 1287 | 348 | } | 1288 | 8.26k | } | 1289 | | | 1290 | 2.07k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 1291 | 2.07k | && (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.07k | if (flags_ptr) | 1307 | 2.07k | * flags_ptr = sec_flags; | 1308 | | | 1309 | 2.07k | return result; | 1310 | 2.07k | } |
pe-arm-wince.c:styp_to_sec_flags Line | Count | Source | 1139 | 2.71k | { | 1140 | 2.71k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 1141 | 2.71k | unsigned long styp_flags = internal_s->s_flags; | 1142 | 2.71k | flagword sec_flags; | 1143 | 2.71k | bool result = true; | 1144 | 2.71k | bool is_dbg = false; | 1145 | | | 1146 | 2.71k | if (startswith (name, DOT_DEBUG) | 1147 | 2.71k | || startswith (name, DOT_ZDEBUG) | 1148 | 2.71k | #ifdef COFF_LONG_SECTION_NAMES | 1149 | 2.71k | || startswith (name, GNU_LINKONCE_WI) | 1150 | 2.71k | || startswith (name, GNU_LINKONCE_WT) | 1151 | | /* FIXME: These definitions ought to be in a header file. */ | 1152 | 2.71k | #define GNU_DEBUGLINK ".gnu_debuglink" | 1153 | 2.71k | #define GNU_DEBUGALTLINK ".gnu_debugaltlink" | 1154 | 2.71k | || startswith (name, GNU_DEBUGLINK) | 1155 | 2.71k | || startswith (name, GNU_DEBUGALTLINK) | 1156 | 2.71k | #endif | 1157 | 2.71k | || startswith (name, ".stab")) | 1158 | 236 | is_dbg = true; | 1159 | | /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified. */ | 1160 | 2.71k | sec_flags = SEC_READONLY; | 1161 | | | 1162 | | /* If section disallows read, then set the NOREAD flag. */ | 1163 | 2.71k | if ((styp_flags & IMAGE_SCN_MEM_READ) == 0) | 1164 | 1.93k | sec_flags |= SEC_COFF_NOREAD; | 1165 | | | 1166 | | /* Process each flag bit in styp_flags in turn. */ | 1167 | 23.3k | while (styp_flags) | 1168 | 20.6k | { | 1169 | 20.6k | unsigned long flag = styp_flags & - styp_flags; | 1170 | 20.6k | char * unhandled = NULL; | 1171 | | | 1172 | 20.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 | 20.6k | switch (flag) | 1179 | 20.6k | { | 1180 | 104 | case STYP_DSECT: | 1181 | 104 | unhandled = "STYP_DSECT"; | 1182 | 104 | break; | 1183 | 106 | case STYP_GROUP: | 1184 | 106 | unhandled = "STYP_GROUP"; | 1185 | 106 | break; | 1186 | 100 | case STYP_COPY: | 1187 | 100 | unhandled = "STYP_COPY"; | 1188 | 100 | break; | 1189 | 104 | case STYP_OVER: | 1190 | 104 | unhandled = "STYP_OVER"; | 1191 | 104 | break; | 1192 | 0 | #ifdef SEC_NEVER_LOAD | 1193 | 954 | case STYP_NOLOAD: | 1194 | 954 | sec_flags |= SEC_NEVER_LOAD; | 1195 | 954 | break; | 1196 | 0 | #endif | 1197 | 780 | case IMAGE_SCN_MEM_READ: | 1198 | 780 | sec_flags &= ~SEC_COFF_NOREAD; | 1199 | 780 | break; | 1200 | 1.39k | case IMAGE_SCN_TYPE_NO_PAD: | 1201 | | /* Skip. */ | 1202 | 1.39k | break; | 1203 | 106 | case IMAGE_SCN_LNK_OTHER: | 1204 | 106 | unhandled = "IMAGE_SCN_LNK_OTHER"; | 1205 | 106 | break; | 1206 | 130 | case IMAGE_SCN_MEM_NOT_CACHED: | 1207 | 130 | unhandled = "IMAGE_SCN_MEM_NOT_CACHED"; | 1208 | 130 | break; | 1209 | 1.32k | 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.32k | _bfd_error_handler (_("%pB: warning: ignoring section flag" | 1215 | 1.32k | " %s in section %s"), | 1216 | 1.32k | abfd, "IMAGE_SCN_MEM_NOT_PAGED", name); | 1217 | 1.32k | break; | 1218 | 984 | case IMAGE_SCN_MEM_EXECUTE: | 1219 | 984 | sec_flags |= SEC_CODE; | 1220 | 984 | break; | 1221 | 738 | case IMAGE_SCN_MEM_WRITE: | 1222 | 738 | sec_flags &= ~ SEC_READONLY; | 1223 | 738 | break; | 1224 | 986 | 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 | 986 | if (is_dbg | 1231 | 986 | #ifdef _COMMENT | 1232 | 986 | || strcmp (name, _COMMENT) == 0 | 1233 | 986 | #endif | 1234 | 986 | ) | 1235 | 138 | { | 1236 | 138 | sec_flags |= SEC_DEBUGGING | SEC_READONLY; | 1237 | 138 | } | 1238 | 986 | break; | 1239 | 238 | case IMAGE_SCN_MEM_SHARED: | 1240 | 238 | sec_flags |= SEC_COFF_SHARED; | 1241 | 238 | break; | 1242 | 1.43k | case IMAGE_SCN_LNK_REMOVE: | 1243 | 1.43k | if (!is_dbg) | 1244 | 1.28k | sec_flags |= SEC_EXCLUDE; | 1245 | 1.43k | break; | 1246 | 852 | case IMAGE_SCN_CNT_CODE: | 1247 | 852 | sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD; | 1248 | 852 | break; | 1249 | 652 | case IMAGE_SCN_CNT_INITIALIZED_DATA: | 1250 | 652 | if (is_dbg) | 1251 | 6 | sec_flags |= SEC_DEBUGGING; | 1252 | 646 | else | 1253 | 646 | sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD; | 1254 | 652 | break; | 1255 | 654 | case IMAGE_SCN_CNT_UNINITIALIZED_DATA: | 1256 | 654 | sec_flags |= SEC_ALLOC; | 1257 | 654 | break; | 1258 | 928 | 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 | 928 | #ifdef COFF_PAGE_SIZE | 1266 | 928 | sec_flags |= SEC_DEBUGGING; | 1267 | 928 | #endif | 1268 | 928 | break; | 1269 | 256 | case IMAGE_SCN_LNK_COMDAT: | 1270 | | /* COMDAT gets very special treatment. */ | 1271 | 256 | if (!handle_COMDAT (abfd, &sec_flags, hdr, name, section)) | 1272 | 24 | result = false; | 1273 | 256 | break; | 1274 | 7.80k | default: | 1275 | | /* Silently ignore for now. */ | 1276 | 7.80k | break; | 1277 | 20.6k | } | 1278 | | | 1279 | | /* If the section flag was not handled, report it here. */ | 1280 | 20.6k | if (unhandled != NULL) | 1281 | 650 | { | 1282 | 650 | _bfd_error_handler | 1283 | | /* xgettext:c-format */ | 1284 | 650 | (_("%pB (%s): section flag %s (%#lx) ignored"), | 1285 | 650 | abfd, name, unhandled, flag); | 1286 | 650 | result = false; | 1287 | 650 | } | 1288 | 20.6k | } | 1289 | | | 1290 | 2.71k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 1291 | 2.71k | && (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.71k | if (flags_ptr) | 1307 | 2.71k | * flags_ptr = sec_flags; | 1308 | | | 1309 | 2.71k | return result; | 1310 | 2.71k | } |
pe-arm.c:styp_to_sec_flags Line | Count | Source | 1139 | 2.71k | { | 1140 | 2.71k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 1141 | 2.71k | unsigned long styp_flags = internal_s->s_flags; | 1142 | 2.71k | flagword sec_flags; | 1143 | 2.71k | bool result = true; | 1144 | 2.71k | bool is_dbg = false; | 1145 | | | 1146 | 2.71k | if (startswith (name, DOT_DEBUG) | 1147 | 2.71k | || startswith (name, DOT_ZDEBUG) | 1148 | 2.71k | #ifdef COFF_LONG_SECTION_NAMES | 1149 | 2.71k | || startswith (name, GNU_LINKONCE_WI) | 1150 | 2.71k | || startswith (name, GNU_LINKONCE_WT) | 1151 | | /* FIXME: These definitions ought to be in a header file. */ | 1152 | 2.71k | #define GNU_DEBUGLINK ".gnu_debuglink" | 1153 | 2.71k | #define GNU_DEBUGALTLINK ".gnu_debugaltlink" | 1154 | 2.71k | || startswith (name, GNU_DEBUGLINK) | 1155 | 2.71k | || startswith (name, GNU_DEBUGALTLINK) | 1156 | 2.71k | #endif | 1157 | 2.71k | || startswith (name, ".stab")) | 1158 | 236 | is_dbg = true; | 1159 | | /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified. */ | 1160 | 2.71k | sec_flags = SEC_READONLY; | 1161 | | | 1162 | | /* If section disallows read, then set the NOREAD flag. */ | 1163 | 2.71k | if ((styp_flags & IMAGE_SCN_MEM_READ) == 0) | 1164 | 1.93k | sec_flags |= SEC_COFF_NOREAD; | 1165 | | | 1166 | | /* Process each flag bit in styp_flags in turn. */ | 1167 | 23.3k | while (styp_flags) | 1168 | 20.6k | { | 1169 | 20.6k | unsigned long flag = styp_flags & - styp_flags; | 1170 | 20.6k | char * unhandled = NULL; | 1171 | | | 1172 | 20.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 | 20.6k | switch (flag) | 1179 | 20.6k | { | 1180 | 104 | case STYP_DSECT: | 1181 | 104 | unhandled = "STYP_DSECT"; | 1182 | 104 | break; | 1183 | 106 | case STYP_GROUP: | 1184 | 106 | unhandled = "STYP_GROUP"; | 1185 | 106 | break; | 1186 | 100 | case STYP_COPY: | 1187 | 100 | unhandled = "STYP_COPY"; | 1188 | 100 | break; | 1189 | 104 | case STYP_OVER: | 1190 | 104 | unhandled = "STYP_OVER"; | 1191 | 104 | break; | 1192 | 0 | #ifdef SEC_NEVER_LOAD | 1193 | 954 | case STYP_NOLOAD: | 1194 | 954 | sec_flags |= SEC_NEVER_LOAD; | 1195 | 954 | break; | 1196 | 0 | #endif | 1197 | 780 | case IMAGE_SCN_MEM_READ: | 1198 | 780 | sec_flags &= ~SEC_COFF_NOREAD; | 1199 | 780 | break; | 1200 | 1.39k | case IMAGE_SCN_TYPE_NO_PAD: | 1201 | | /* Skip. */ | 1202 | 1.39k | break; | 1203 | 106 | case IMAGE_SCN_LNK_OTHER: | 1204 | 106 | unhandled = "IMAGE_SCN_LNK_OTHER"; | 1205 | 106 | break; | 1206 | 130 | case IMAGE_SCN_MEM_NOT_CACHED: | 1207 | 130 | unhandled = "IMAGE_SCN_MEM_NOT_CACHED"; | 1208 | 130 | break; | 1209 | 1.32k | 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.32k | _bfd_error_handler (_("%pB: warning: ignoring section flag" | 1215 | 1.32k | " %s in section %s"), | 1216 | 1.32k | abfd, "IMAGE_SCN_MEM_NOT_PAGED", name); | 1217 | 1.32k | break; | 1218 | 984 | case IMAGE_SCN_MEM_EXECUTE: | 1219 | 984 | sec_flags |= SEC_CODE; | 1220 | 984 | break; | 1221 | 738 | case IMAGE_SCN_MEM_WRITE: | 1222 | 738 | sec_flags &= ~ SEC_READONLY; | 1223 | 738 | break; | 1224 | 986 | 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 | 986 | if (is_dbg | 1231 | 986 | #ifdef _COMMENT | 1232 | 986 | || strcmp (name, _COMMENT) == 0 | 1233 | 986 | #endif | 1234 | 986 | ) | 1235 | 138 | { | 1236 | 138 | sec_flags |= SEC_DEBUGGING | SEC_READONLY; | 1237 | 138 | } | 1238 | 986 | break; | 1239 | 238 | case IMAGE_SCN_MEM_SHARED: | 1240 | 238 | sec_flags |= SEC_COFF_SHARED; | 1241 | 238 | break; | 1242 | 1.43k | case IMAGE_SCN_LNK_REMOVE: | 1243 | 1.43k | if (!is_dbg) | 1244 | 1.28k | sec_flags |= SEC_EXCLUDE; | 1245 | 1.43k | break; | 1246 | 852 | case IMAGE_SCN_CNT_CODE: | 1247 | 852 | sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD; | 1248 | 852 | break; | 1249 | 652 | case IMAGE_SCN_CNT_INITIALIZED_DATA: | 1250 | 652 | if (is_dbg) | 1251 | 6 | sec_flags |= SEC_DEBUGGING; | 1252 | 646 | else | 1253 | 646 | sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD; | 1254 | 652 | break; | 1255 | 654 | case IMAGE_SCN_CNT_UNINITIALIZED_DATA: | 1256 | 654 | sec_flags |= SEC_ALLOC; | 1257 | 654 | break; | 1258 | 928 | 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 | 928 | #ifdef COFF_PAGE_SIZE | 1266 | 928 | sec_flags |= SEC_DEBUGGING; | 1267 | 928 | #endif | 1268 | 928 | break; | 1269 | 256 | case IMAGE_SCN_LNK_COMDAT: | 1270 | | /* COMDAT gets very special treatment. */ | 1271 | 256 | if (!handle_COMDAT (abfd, &sec_flags, hdr, name, section)) | 1272 | 24 | result = false; | 1273 | 256 | break; | 1274 | 7.80k | default: | 1275 | | /* Silently ignore for now. */ | 1276 | 7.80k | break; | 1277 | 20.6k | } | 1278 | | | 1279 | | /* If the section flag was not handled, report it here. */ | 1280 | 20.6k | if (unhandled != NULL) | 1281 | 650 | { | 1282 | 650 | _bfd_error_handler | 1283 | | /* xgettext:c-format */ | 1284 | 650 | (_("%pB (%s): section flag %s (%#lx) ignored"), | 1285 | 650 | abfd, name, unhandled, flag); | 1286 | 650 | result = false; | 1287 | 650 | } | 1288 | 20.6k | } | 1289 | | | 1290 | 2.71k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 1291 | 2.71k | && (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.71k | if (flags_ptr) | 1307 | 2.71k | * flags_ptr = sec_flags; | 1308 | | | 1309 | 2.71k | return result; | 1310 | 2.71k | } |
pe-i386.c:styp_to_sec_flags Line | Count | Source | 1139 | 3.95k | { | 1140 | 3.95k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 1141 | 3.95k | unsigned long styp_flags = internal_s->s_flags; | 1142 | 3.95k | flagword sec_flags; | 1143 | 3.95k | bool result = true; | 1144 | 3.95k | bool is_dbg = false; | 1145 | | | 1146 | 3.95k | if (startswith (name, DOT_DEBUG) | 1147 | 3.95k | || startswith (name, DOT_ZDEBUG) | 1148 | 3.95k | #ifdef COFF_LONG_SECTION_NAMES | 1149 | 3.95k | || startswith (name, GNU_LINKONCE_WI) | 1150 | 3.95k | || startswith (name, GNU_LINKONCE_WT) | 1151 | | /* FIXME: These definitions ought to be in a header file. */ | 1152 | 3.95k | #define GNU_DEBUGLINK ".gnu_debuglink" | 1153 | 3.95k | #define GNU_DEBUGALTLINK ".gnu_debugaltlink" | 1154 | 3.95k | || startswith (name, GNU_DEBUGLINK) | 1155 | 3.95k | || startswith (name, GNU_DEBUGALTLINK) | 1156 | 3.95k | #endif | 1157 | 3.95k | || startswith (name, ".stab")) | 1158 | 86 | is_dbg = true; | 1159 | | /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified. */ | 1160 | 3.95k | sec_flags = SEC_READONLY; | 1161 | | | 1162 | | /* If section disallows read, then set the NOREAD flag. */ | 1163 | 3.95k | if ((styp_flags & IMAGE_SCN_MEM_READ) == 0) | 1164 | 3.31k | sec_flags |= SEC_COFF_NOREAD; | 1165 | | | 1166 | | /* Process each flag bit in styp_flags in turn. */ | 1167 | 21.0k | while (styp_flags) | 1168 | 17.0k | { | 1169 | 17.0k | unsigned long flag = styp_flags & - styp_flags; | 1170 | 17.0k | char * unhandled = NULL; | 1171 | | | 1172 | 17.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 | 17.0k | switch (flag) | 1179 | 17.0k | { | 1180 | 170 | case STYP_DSECT: | 1181 | 170 | unhandled = "STYP_DSECT"; | 1182 | 170 | break; | 1183 | 126 | case STYP_GROUP: | 1184 | 126 | unhandled = "STYP_GROUP"; | 1185 | 126 | break; | 1186 | 144 | case STYP_COPY: | 1187 | 144 | unhandled = "STYP_COPY"; | 1188 | 144 | break; | 1189 | 150 | case STYP_OVER: | 1190 | 150 | unhandled = "STYP_OVER"; | 1191 | 150 | break; | 1192 | 0 | #ifdef SEC_NEVER_LOAD | 1193 | 958 | case STYP_NOLOAD: | 1194 | 958 | sec_flags |= SEC_NEVER_LOAD; | 1195 | 958 | break; | 1196 | 0 | #endif | 1197 | 638 | case IMAGE_SCN_MEM_READ: | 1198 | 638 | sec_flags &= ~SEC_COFF_NOREAD; | 1199 | 638 | break; | 1200 | 914 | case IMAGE_SCN_TYPE_NO_PAD: | 1201 | | /* Skip. */ | 1202 | 914 | break; | 1203 | 170 | case IMAGE_SCN_LNK_OTHER: | 1204 | 170 | unhandled = "IMAGE_SCN_LNK_OTHER"; | 1205 | 170 | break; | 1206 | 192 | case IMAGE_SCN_MEM_NOT_CACHED: | 1207 | 192 | unhandled = "IMAGE_SCN_MEM_NOT_CACHED"; | 1208 | 192 | break; | 1209 | 942 | 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 | 942 | _bfd_error_handler (_("%pB: warning: ignoring section flag" | 1215 | 942 | " %s in section %s"), | 1216 | 942 | abfd, "IMAGE_SCN_MEM_NOT_PAGED", name); | 1217 | 942 | break; | 1218 | 660 | case IMAGE_SCN_MEM_EXECUTE: | 1219 | 660 | sec_flags |= SEC_CODE; | 1220 | 660 | break; | 1221 | 586 | case IMAGE_SCN_MEM_WRITE: | 1222 | 586 | sec_flags &= ~ SEC_READONLY; | 1223 | 586 | break; | 1224 | 994 | 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 | 994 | if (is_dbg | 1231 | 994 | #ifdef _COMMENT | 1232 | 994 | || strcmp (name, _COMMENT) == 0 | 1233 | 994 | #endif | 1234 | 994 | ) | 1235 | 46 | { | 1236 | 46 | sec_flags |= SEC_DEBUGGING | SEC_READONLY; | 1237 | 46 | } | 1238 | 994 | break; | 1239 | 232 | case IMAGE_SCN_MEM_SHARED: | 1240 | 232 | sec_flags |= SEC_COFF_SHARED; | 1241 | 232 | break; | 1242 | 956 | case IMAGE_SCN_LNK_REMOVE: | 1243 | 956 | if (!is_dbg) | 1244 | 924 | sec_flags |= SEC_EXCLUDE; | 1245 | 956 | break; | 1246 | 568 | case IMAGE_SCN_CNT_CODE: | 1247 | 568 | sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD; | 1248 | 568 | break; | 1249 | 536 | case IMAGE_SCN_CNT_INITIALIZED_DATA: | 1250 | 536 | if (is_dbg) | 1251 | 8 | sec_flags |= SEC_DEBUGGING; | 1252 | 528 | else | 1253 | 528 | sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD; | 1254 | 536 | break; | 1255 | 482 | case IMAGE_SCN_CNT_UNINITIALIZED_DATA: | 1256 | 482 | sec_flags |= SEC_ALLOC; | 1257 | 482 | break; | 1258 | 1.01k | 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.01k | #ifdef COFF_PAGE_SIZE | 1266 | 1.01k | sec_flags |= SEC_DEBUGGING; | 1267 | 1.01k | #endif | 1268 | 1.01k | break; | 1269 | 252 | case IMAGE_SCN_LNK_COMDAT: | 1270 | | /* COMDAT gets very special treatment. */ | 1271 | 252 | if (!handle_COMDAT (abfd, &sec_flags, hdr, name, section)) | 1272 | 10 | result = false; | 1273 | 252 | break; | 1274 | 6.41k | default: | 1275 | | /* Silently ignore for now. */ | 1276 | 6.41k | break; | 1277 | 17.0k | } | 1278 | | | 1279 | | /* If the section flag was not handled, report it here. */ | 1280 | 17.0k | if (unhandled != NULL) | 1281 | 952 | { | 1282 | 952 | _bfd_error_handler | 1283 | | /* xgettext:c-format */ | 1284 | 952 | (_("%pB (%s): section flag %s (%#lx) ignored"), | 1285 | 952 | abfd, name, unhandled, flag); | 1286 | 952 | result = false; | 1287 | 952 | } | 1288 | 17.0k | } | 1289 | | | 1290 | 3.95k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 1291 | 3.95k | && (startswith (name, ".sbss") | 1292 | 0 | || startswith (name, ".sdata"))) | 1293 | 0 | sec_flags |= SEC_SMALL_DATA; | 1294 | | | 1295 | 3.95k | #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.95k | if (startswith (name, ".gnu.linkonce")) | 1303 | 0 | sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; | 1304 | 3.95k | #endif | 1305 | | | 1306 | 3.95k | if (flags_ptr) | 1307 | 3.95k | * flags_ptr = sec_flags; | 1308 | | | 1309 | 3.95k | return result; | 1310 | 3.95k | } |
pe-mcore.c:styp_to_sec_flags Line | Count | Source | 1139 | 23.1k | { | 1140 | 23.1k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 1141 | 23.1k | unsigned long styp_flags = internal_s->s_flags; | 1142 | 23.1k | flagword sec_flags; | 1143 | 23.1k | bool result = true; | 1144 | 23.1k | bool is_dbg = false; | 1145 | | | 1146 | 23.1k | if (startswith (name, DOT_DEBUG) | 1147 | 23.1k | || startswith (name, DOT_ZDEBUG) | 1148 | 23.1k | #ifdef COFF_LONG_SECTION_NAMES | 1149 | 23.1k | || startswith (name, GNU_LINKONCE_WI) | 1150 | 23.1k | || startswith (name, GNU_LINKONCE_WT) | 1151 | | /* FIXME: These definitions ought to be in a header file. */ | 1152 | 23.1k | #define GNU_DEBUGLINK ".gnu_debuglink" | 1153 | 23.1k | #define GNU_DEBUGALTLINK ".gnu_debugaltlink" | 1154 | 23.1k | || startswith (name, GNU_DEBUGLINK) | 1155 | 23.1k | || startswith (name, GNU_DEBUGALTLINK) | 1156 | 23.1k | #endif | 1157 | 23.1k | || startswith (name, ".stab")) | 1158 | 1.08k | is_dbg = true; | 1159 | | /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified. */ | 1160 | 23.1k | sec_flags = SEC_READONLY; | 1161 | | | 1162 | | /* If section disallows read, then set the NOREAD flag. */ | 1163 | 23.1k | if ((styp_flags & IMAGE_SCN_MEM_READ) == 0) | 1164 | 20.2k | sec_flags |= SEC_COFF_NOREAD; | 1165 | | | 1166 | | /* Process each flag bit in styp_flags in turn. */ | 1167 | 76.1k | while (styp_flags) | 1168 | 53.0k | { | 1169 | 53.0k | unsigned long flag = styp_flags & - styp_flags; | 1170 | 53.0k | char * unhandled = NULL; | 1171 | | | 1172 | 53.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 | 53.0k | switch (flag) | 1179 | 53.0k | { | 1180 | 78 | case STYP_DSECT: | 1181 | 78 | unhandled = "STYP_DSECT"; | 1182 | 78 | break; | 1183 | 54 | case STYP_GROUP: | 1184 | 54 | unhandled = "STYP_GROUP"; | 1185 | 54 | break; | 1186 | 78 | case STYP_COPY: | 1187 | 78 | unhandled = "STYP_COPY"; | 1188 | 78 | break; | 1189 | 70 | case STYP_OVER: | 1190 | 70 | unhandled = "STYP_OVER"; | 1191 | 70 | break; | 1192 | 0 | #ifdef SEC_NEVER_LOAD | 1193 | 2.22k | case STYP_NOLOAD: | 1194 | 2.22k | sec_flags |= SEC_NEVER_LOAD; | 1195 | 2.22k | break; | 1196 | 0 | #endif | 1197 | 2.93k | case IMAGE_SCN_MEM_READ: | 1198 | 2.93k | sec_flags &= ~SEC_COFF_NOREAD; | 1199 | 2.93k | break; | 1200 | 1.03k | case IMAGE_SCN_TYPE_NO_PAD: | 1201 | | /* Skip. */ | 1202 | 1.03k | break; | 1203 | 68 | case IMAGE_SCN_LNK_OTHER: | 1204 | 68 | unhandled = "IMAGE_SCN_LNK_OTHER"; | 1205 | 68 | break; | 1206 | 80 | case IMAGE_SCN_MEM_NOT_CACHED: | 1207 | 80 | unhandled = "IMAGE_SCN_MEM_NOT_CACHED"; | 1208 | 80 | break; | 1209 | 1.50k | 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.50k | _bfd_error_handler (_("%pB: warning: ignoring section flag" | 1215 | 1.50k | " %s in section %s"), | 1216 | 1.50k | abfd, "IMAGE_SCN_MEM_NOT_PAGED", name); | 1217 | 1.50k | break; | 1218 | 1.65k | case IMAGE_SCN_MEM_EXECUTE: | 1219 | 1.65k | sec_flags |= SEC_CODE; | 1220 | 1.65k | break; | 1221 | 962 | case IMAGE_SCN_MEM_WRITE: | 1222 | 962 | sec_flags &= ~ SEC_READONLY; | 1223 | 962 | break; | 1224 | 4.14k | 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 | 4.14k | if (is_dbg | 1231 | 4.14k | #ifdef _COMMENT | 1232 | 4.14k | || strcmp (name, _COMMENT) == 0 | 1233 | 4.14k | #endif | 1234 | 4.14k | ) | 1235 | 546 | { | 1236 | 546 | sec_flags |= SEC_DEBUGGING | SEC_READONLY; | 1237 | 546 | } | 1238 | 4.14k | break; | 1239 | 642 | case IMAGE_SCN_MEM_SHARED: | 1240 | 642 | sec_flags |= SEC_COFF_SHARED; | 1241 | 642 | break; | 1242 | 1.04k | case IMAGE_SCN_LNK_REMOVE: | 1243 | 1.04k | if (!is_dbg) | 1244 | 972 | sec_flags |= SEC_EXCLUDE; | 1245 | 1.04k | break; | 1246 | 1.11k | case IMAGE_SCN_CNT_CODE: | 1247 | 1.11k | sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD; | 1248 | 1.11k | break; | 1249 | 2.87k | case IMAGE_SCN_CNT_INITIALIZED_DATA: | 1250 | 2.87k | if (is_dbg) | 1251 | 490 | sec_flags |= SEC_DEBUGGING; | 1252 | 2.38k | else | 1253 | 2.38k | sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD; | 1254 | 2.87k | break; | 1255 | 1.40k | case IMAGE_SCN_CNT_UNINITIALIZED_DATA: | 1256 | 1.40k | sec_flags |= SEC_ALLOC; | 1257 | 1.40k | break; | 1258 | 2.70k | 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.70k | #ifdef COFF_PAGE_SIZE | 1266 | 2.70k | sec_flags |= SEC_DEBUGGING; | 1267 | 2.70k | #endif | 1268 | 2.70k | break; | 1269 | 700 | case IMAGE_SCN_LNK_COMDAT: | 1270 | | /* COMDAT gets very special treatment. */ | 1271 | 700 | if (!handle_COMDAT (abfd, &sec_flags, hdr, name, section)) | 1272 | 26 | result = false; | 1273 | 700 | break; | 1274 | 27.6k | default: | 1275 | | /* Silently ignore for now. */ | 1276 | 27.6k | break; | 1277 | 53.0k | } | 1278 | | | 1279 | | /* If the section flag was not handled, report it here. */ | 1280 | 53.0k | if (unhandled != NULL) | 1281 | 428 | { | 1282 | 428 | _bfd_error_handler | 1283 | | /* xgettext:c-format */ | 1284 | 428 | (_("%pB (%s): section flag %s (%#lx) ignored"), | 1285 | 428 | abfd, name, unhandled, flag); | 1286 | 428 | result = false; | 1287 | 428 | } | 1288 | 53.0k | } | 1289 | | | 1290 | 23.1k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 1291 | 23.1k | && (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 | 23.1k | if (flags_ptr) | 1307 | 23.1k | * flags_ptr = sec_flags; | 1308 | | | 1309 | 23.1k | return result; | 1310 | 23.1k | } |
pe-sh.c:styp_to_sec_flags Line | Count | Source | 1139 | 11.7k | { | 1140 | 11.7k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 1141 | 11.7k | unsigned long styp_flags = internal_s->s_flags; | 1142 | 11.7k | flagword sec_flags; | 1143 | 11.7k | bool result = true; | 1144 | 11.7k | bool is_dbg = false; | 1145 | | | 1146 | 11.7k | if (startswith (name, DOT_DEBUG) | 1147 | 11.7k | || startswith (name, DOT_ZDEBUG) | 1148 | 11.7k | #ifdef COFF_LONG_SECTION_NAMES | 1149 | 11.7k | || startswith (name, GNU_LINKONCE_WI) | 1150 | 11.7k | || startswith (name, GNU_LINKONCE_WT) | 1151 | | /* FIXME: These definitions ought to be in a header file. */ | 1152 | 11.7k | #define GNU_DEBUGLINK ".gnu_debuglink" | 1153 | 11.7k | #define GNU_DEBUGALTLINK ".gnu_debugaltlink" | 1154 | 11.7k | || startswith (name, GNU_DEBUGLINK) | 1155 | 11.7k | || startswith (name, GNU_DEBUGALTLINK) | 1156 | 11.7k | #endif | 1157 | 11.7k | || startswith (name, ".stab")) | 1158 | 64 | is_dbg = true; | 1159 | | /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified. */ | 1160 | 11.7k | sec_flags = SEC_READONLY; | 1161 | | | 1162 | | /* If section disallows read, then set the NOREAD flag. */ | 1163 | 11.7k | if ((styp_flags & IMAGE_SCN_MEM_READ) == 0) | 1164 | 10.2k | sec_flags |= SEC_COFF_NOREAD; | 1165 | | | 1166 | | /* Process each flag bit in styp_flags in turn. */ | 1167 | 49.5k | while (styp_flags) | 1168 | 37.8k | { | 1169 | 37.8k | unsigned long flag = styp_flags & - styp_flags; | 1170 | 37.8k | char * unhandled = NULL; | 1171 | | | 1172 | 37.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 | 37.8k | switch (flag) | 1179 | 37.8k | { | 1180 | 114 | case STYP_DSECT: | 1181 | 114 | unhandled = "STYP_DSECT"; | 1182 | 114 | break; | 1183 | 116 | case STYP_GROUP: | 1184 | 116 | unhandled = "STYP_GROUP"; | 1185 | 116 | break; | 1186 | 122 | case STYP_COPY: | 1187 | 122 | unhandled = "STYP_COPY"; | 1188 | 122 | break; | 1189 | 184 | case STYP_OVER: | 1190 | 184 | unhandled = "STYP_OVER"; | 1191 | 184 | break; | 1192 | 0 | #ifdef SEC_NEVER_LOAD | 1193 | 2.00k | case STYP_NOLOAD: | 1194 | 2.00k | sec_flags |= SEC_NEVER_LOAD; | 1195 | 2.00k | break; | 1196 | 0 | #endif | 1197 | 1.46k | case IMAGE_SCN_MEM_READ: | 1198 | 1.46k | sec_flags &= ~SEC_COFF_NOREAD; | 1199 | 1.46k | break; | 1200 | 1.55k | case IMAGE_SCN_TYPE_NO_PAD: | 1201 | | /* Skip. */ | 1202 | 1.55k | break; | 1203 | 212 | case IMAGE_SCN_LNK_OTHER: | 1204 | 212 | unhandled = "IMAGE_SCN_LNK_OTHER"; | 1205 | 212 | break; | 1206 | 196 | case IMAGE_SCN_MEM_NOT_CACHED: | 1207 | 196 | unhandled = "IMAGE_SCN_MEM_NOT_CACHED"; | 1208 | 196 | break; | 1209 | 2.18k | 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.18k | _bfd_error_handler (_("%pB: warning: ignoring section flag" | 1215 | 2.18k | " %s in section %s"), | 1216 | 2.18k | abfd, "IMAGE_SCN_MEM_NOT_PAGED", name); | 1217 | 2.18k | break; | 1218 | 1.42k | case IMAGE_SCN_MEM_EXECUTE: | 1219 | 1.42k | sec_flags |= SEC_CODE; | 1220 | 1.42k | break; | 1221 | 1.33k | case IMAGE_SCN_MEM_WRITE: | 1222 | 1.33k | sec_flags &= ~ SEC_READONLY; | 1223 | 1.33k | break; | 1224 | 3.08k | 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 | 3.08k | if (is_dbg | 1231 | 3.08k | #ifdef _COMMENT | 1232 | 3.08k | || strcmp (name, _COMMENT) == 0 | 1233 | 3.08k | #endif | 1234 | 3.08k | ) | 1235 | 34 | { | 1236 | 34 | sec_flags |= SEC_DEBUGGING | SEC_READONLY; | 1237 | 34 | } | 1238 | 3.08k | break; | 1239 | 1.21k | case IMAGE_SCN_MEM_SHARED: | 1240 | 1.21k | sec_flags |= SEC_COFF_SHARED; | 1241 | 1.21k | break; | 1242 | 1.66k | case IMAGE_SCN_LNK_REMOVE: | 1243 | 1.66k | if (!is_dbg) | 1244 | 1.64k | sec_flags |= SEC_EXCLUDE; | 1245 | 1.66k | break; | 1246 | 1.26k | case IMAGE_SCN_CNT_CODE: | 1247 | 1.26k | sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD; | 1248 | 1.26k | break; | 1249 | 1.32k | case IMAGE_SCN_CNT_INITIALIZED_DATA: | 1250 | 1.32k | if (is_dbg) | 1251 | 14 | sec_flags |= SEC_DEBUGGING; | 1252 | 1.30k | else | 1253 | 1.30k | sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD; | 1254 | 1.32k | break; | 1255 | 724 | case IMAGE_SCN_CNT_UNINITIALIZED_DATA: | 1256 | 724 | sec_flags |= SEC_ALLOC; | 1257 | 724 | break; | 1258 | 2.11k | 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 | 2.11k | break; | 1269 | 760 | case IMAGE_SCN_LNK_COMDAT: | 1270 | | /* COMDAT gets very special treatment. */ | 1271 | 760 | if (!handle_COMDAT (abfd, &sec_flags, hdr, name, section)) | 1272 | 10 | result = false; | 1273 | 760 | break; | 1274 | 14.8k | default: | 1275 | | /* Silently ignore for now. */ | 1276 | 14.8k | break; | 1277 | 37.8k | } | 1278 | | | 1279 | | /* If the section flag was not handled, report it here. */ | 1280 | 37.8k | if (unhandled != NULL) | 1281 | 944 | { | 1282 | 944 | _bfd_error_handler | 1283 | | /* xgettext:c-format */ | 1284 | 944 | (_("%pB (%s): section flag %s (%#lx) ignored"), | 1285 | 944 | abfd, name, unhandled, flag); | 1286 | 944 | result = false; | 1287 | 944 | } | 1288 | 37.8k | } | 1289 | | | 1290 | 11.7k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 1291 | 11.7k | && (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 | 11.7k | if (flags_ptr) | 1307 | 11.7k | * flags_ptr = sec_flags; | 1308 | | | 1309 | 11.7k | return result; | 1310 | 11.7k | } |
pei-arm-wince.c:styp_to_sec_flags Line | Count | Source | 1139 | 38.9k | { | 1140 | 38.9k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 1141 | 38.9k | unsigned long styp_flags = internal_s->s_flags; | 1142 | 38.9k | flagword sec_flags; | 1143 | 38.9k | bool result = true; | 1144 | 38.9k | bool is_dbg = false; | 1145 | | | 1146 | 38.9k | if (startswith (name, DOT_DEBUG) | 1147 | 38.9k | || startswith (name, DOT_ZDEBUG) | 1148 | 38.9k | #ifdef COFF_LONG_SECTION_NAMES | 1149 | 38.9k | || startswith (name, GNU_LINKONCE_WI) | 1150 | 38.9k | || startswith (name, GNU_LINKONCE_WT) | 1151 | | /* FIXME: These definitions ought to be in a header file. */ | 1152 | 38.9k | #define GNU_DEBUGLINK ".gnu_debuglink" | 1153 | 38.9k | #define GNU_DEBUGALTLINK ".gnu_debugaltlink" | 1154 | 38.9k | || startswith (name, GNU_DEBUGLINK) | 1155 | 38.9k | || startswith (name, GNU_DEBUGALTLINK) | 1156 | 38.9k | #endif | 1157 | 38.9k | || startswith (name, ".stab")) | 1158 | 986 | is_dbg = true; | 1159 | | /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified. */ | 1160 | 38.9k | sec_flags = SEC_READONLY; | 1161 | | | 1162 | | /* If section disallows read, then set the NOREAD flag. */ | 1163 | 38.9k | if ((styp_flags & IMAGE_SCN_MEM_READ) == 0) | 1164 | 32.9k | sec_flags |= SEC_COFF_NOREAD; | 1165 | | | 1166 | | /* Process each flag bit in styp_flags in turn. */ | 1167 | 209k | while (styp_flags) | 1168 | 170k | { | 1169 | 170k | unsigned long flag = styp_flags & - styp_flags; | 1170 | 170k | char * unhandled = NULL; | 1171 | | | 1172 | 170k | 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 | 170k | switch (flag) | 1179 | 170k | { | 1180 | 2.95k | case STYP_DSECT: | 1181 | 2.95k | unhandled = "STYP_DSECT"; | 1182 | 2.95k | break; | 1183 | 3.87k | case STYP_GROUP: | 1184 | 3.87k | unhandled = "STYP_GROUP"; | 1185 | 3.87k | break; | 1186 | 3.42k | case STYP_COPY: | 1187 | 3.42k | unhandled = "STYP_COPY"; | 1188 | 3.42k | break; | 1189 | 1.96k | case STYP_OVER: | 1190 | 1.96k | unhandled = "STYP_OVER"; | 1191 | 1.96k | break; | 1192 | 0 | #ifdef SEC_NEVER_LOAD | 1193 | 5.59k | case STYP_NOLOAD: | 1194 | 5.59k | sec_flags |= SEC_NEVER_LOAD; | 1195 | 5.59k | break; | 1196 | 0 | #endif | 1197 | 6.01k | case IMAGE_SCN_MEM_READ: | 1198 | 6.01k | sec_flags &= ~SEC_COFF_NOREAD; | 1199 | 6.01k | break; | 1200 | 5.48k | case IMAGE_SCN_TYPE_NO_PAD: | 1201 | | /* Skip. */ | 1202 | 5.48k | break; | 1203 | 2.47k | case IMAGE_SCN_LNK_OTHER: | 1204 | 2.47k | unhandled = "IMAGE_SCN_LNK_OTHER"; | 1205 | 2.47k | break; | 1206 | 3.38k | case IMAGE_SCN_MEM_NOT_CACHED: | 1207 | 3.38k | unhandled = "IMAGE_SCN_MEM_NOT_CACHED"; | 1208 | 3.38k | break; | 1209 | 8.49k | 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 | 8.49k | _bfd_error_handler (_("%pB: warning: ignoring section flag" | 1215 | 8.49k | " %s in section %s"), | 1216 | 8.49k | abfd, "IMAGE_SCN_MEM_NOT_PAGED", name); | 1217 | 8.49k | break; | 1218 | 6.57k | case IMAGE_SCN_MEM_EXECUTE: | 1219 | 6.57k | sec_flags |= SEC_CODE; | 1220 | 6.57k | break; | 1221 | 6.52k | case IMAGE_SCN_MEM_WRITE: | 1222 | 6.52k | sec_flags &= ~ SEC_READONLY; | 1223 | 6.52k | 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 | 494 | { | 1236 | 494 | sec_flags |= SEC_DEBUGGING | SEC_READONLY; | 1237 | 494 | } | 1238 | 10.9k | break; | 1239 | 11.2k | case IMAGE_SCN_MEM_SHARED: | 1240 | 11.2k | sec_flags |= SEC_COFF_SHARED; | 1241 | 11.2k | break; | 1242 | 5.03k | case IMAGE_SCN_LNK_REMOVE: | 1243 | 5.03k | if (!is_dbg) | 1244 | 5.03k | sec_flags |= SEC_EXCLUDE; | 1245 | 5.03k | break; | 1246 | 5.03k | case IMAGE_SCN_CNT_CODE: | 1247 | 5.03k | sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD; | 1248 | 5.03k | break; | 1249 | 4.50k | case IMAGE_SCN_CNT_INITIALIZED_DATA: | 1250 | 4.50k | if (is_dbg) | 1251 | 478 | sec_flags |= SEC_DEBUGGING; | 1252 | 4.02k | else | 1253 | 4.02k | sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD; | 1254 | 4.50k | break; | 1255 | 3.99k | case IMAGE_SCN_CNT_UNINITIALIZED_DATA: | 1256 | 3.99k | sec_flags |= SEC_ALLOC; | 1257 | 3.99k | break; | 1258 | 4.72k | 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 | 4.72k | #ifdef COFF_PAGE_SIZE | 1266 | 4.72k | sec_flags |= SEC_DEBUGGING; | 1267 | 4.72k | #endif | 1268 | 4.72k | break; | 1269 | 3.55k | case IMAGE_SCN_LNK_COMDAT: | 1270 | | /* COMDAT gets very special treatment. */ | 1271 | 3.55k | if (!handle_COMDAT (abfd, &sec_flags, hdr, name, section)) | 1272 | 982 | result = false; | 1273 | 3.55k | break; | 1274 | 65.1k | default: | 1275 | | /* Silently ignore for now. */ | 1276 | 65.1k | break; | 1277 | 170k | } | 1278 | | | 1279 | | /* If the section flag was not handled, report it here. */ | 1280 | 170k | if (unhandled != NULL) | 1281 | 18.0k | { | 1282 | 18.0k | _bfd_error_handler | 1283 | | /* xgettext:c-format */ | 1284 | 18.0k | (_("%pB (%s): section flag %s (%#lx) ignored"), | 1285 | 18.0k | abfd, name, unhandled, flag); | 1286 | 18.0k | result = false; | 1287 | 18.0k | } | 1288 | 170k | } | 1289 | | | 1290 | 38.9k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 1291 | 38.9k | && (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 | 38.9k | if (flags_ptr) | 1307 | 38.9k | * flags_ptr = sec_flags; | 1308 | | | 1309 | 38.9k | return result; | 1310 | 38.9k | } |
pei-arm.c:styp_to_sec_flags Line | Count | Source | 1139 | 480k | { | 1140 | 480k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 1141 | 480k | unsigned long styp_flags = internal_s->s_flags; | 1142 | 480k | flagword sec_flags; | 1143 | 480k | bool result = true; | 1144 | 480k | bool is_dbg = false; | 1145 | | | 1146 | 480k | if (startswith (name, DOT_DEBUG) | 1147 | 480k | || startswith (name, DOT_ZDEBUG) | 1148 | 480k | #ifdef COFF_LONG_SECTION_NAMES | 1149 | 480k | || startswith (name, GNU_LINKONCE_WI) | 1150 | 480k | || startswith (name, GNU_LINKONCE_WT) | 1151 | | /* FIXME: These definitions ought to be in a header file. */ | 1152 | 480k | #define GNU_DEBUGLINK ".gnu_debuglink" | 1153 | 480k | #define GNU_DEBUGALTLINK ".gnu_debugaltlink" | 1154 | 480k | || startswith (name, GNU_DEBUGLINK) | 1155 | 480k | || startswith (name, GNU_DEBUGALTLINK) | 1156 | 480k | #endif | 1157 | 480k | || startswith (name, ".stab")) | 1158 | 502 | is_dbg = true; | 1159 | | /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified. */ | 1160 | 480k | sec_flags = SEC_READONLY; | 1161 | | | 1162 | | /* If section disallows read, then set the NOREAD flag. */ | 1163 | 480k | if ((styp_flags & IMAGE_SCN_MEM_READ) == 0) | 1164 | 468k | sec_flags |= SEC_COFF_NOREAD; | 1165 | | | 1166 | | /* Process each flag bit in styp_flags in turn. */ | 1167 | 684k | while (styp_flags) | 1168 | 203k | { | 1169 | 203k | unsigned long flag = styp_flags & - styp_flags; | 1170 | 203k | char * unhandled = NULL; | 1171 | | | 1172 | 203k | 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 | 203k | switch (flag) | 1179 | 203k | { | 1180 | 2.48k | case STYP_DSECT: | 1181 | 2.48k | unhandled = "STYP_DSECT"; | 1182 | 2.48k | break; | 1183 | 3.40k | case STYP_GROUP: | 1184 | 3.40k | unhandled = "STYP_GROUP"; | 1185 | 3.40k | break; | 1186 | 2.96k | case STYP_COPY: | 1187 | 2.96k | unhandled = "STYP_COPY"; | 1188 | 2.96k | break; | 1189 | 2.93k | case STYP_OVER: | 1190 | 2.93k | unhandled = "STYP_OVER"; | 1191 | 2.93k | break; | 1192 | 0 | #ifdef SEC_NEVER_LOAD | 1193 | 4.74k | case STYP_NOLOAD: | 1194 | 4.74k | sec_flags |= SEC_NEVER_LOAD; | 1195 | 4.74k | break; | 1196 | 0 | #endif | 1197 | 12.2k | case IMAGE_SCN_MEM_READ: | 1198 | 12.2k | sec_flags &= ~SEC_COFF_NOREAD; | 1199 | 12.2k | break; | 1200 | 4.14k | case IMAGE_SCN_TYPE_NO_PAD: | 1201 | | /* Skip. */ | 1202 | 4.14k | break; | 1203 | 3.92k | case IMAGE_SCN_LNK_OTHER: | 1204 | 3.92k | unhandled = "IMAGE_SCN_LNK_OTHER"; | 1205 | 3.92k | break; | 1206 | 2.91k | case IMAGE_SCN_MEM_NOT_CACHED: | 1207 | 2.91k | unhandled = "IMAGE_SCN_MEM_NOT_CACHED"; | 1208 | 2.91k | break; | 1209 | 5.70k | 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 | 5.70k | _bfd_error_handler (_("%pB: warning: ignoring section flag" | 1215 | 5.70k | " %s in section %s"), | 1216 | 5.70k | abfd, "IMAGE_SCN_MEM_NOT_PAGED", name); | 1217 | 5.70k | break; | 1218 | 13.2k | case IMAGE_SCN_MEM_EXECUTE: | 1219 | 13.2k | sec_flags |= SEC_CODE; | 1220 | 13.2k | break; | 1221 | 5.11k | case IMAGE_SCN_MEM_WRITE: | 1222 | 5.11k | sec_flags &= ~ SEC_READONLY; | 1223 | 5.11k | break; | 1224 | 7.21k | 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 | 7.21k | if (is_dbg | 1231 | 7.21k | #ifdef _COMMENT | 1232 | 7.21k | || strcmp (name, _COMMENT) == 0 | 1233 | 7.21k | #endif | 1234 | 7.21k | ) | 1235 | 484 | { | 1236 | 484 | sec_flags |= SEC_DEBUGGING | SEC_READONLY; | 1237 | 484 | } | 1238 | 7.21k | break; | 1239 | 5.99k | case IMAGE_SCN_MEM_SHARED: | 1240 | 5.99k | sec_flags |= SEC_COFF_SHARED; | 1241 | 5.99k | break; | 1242 | 3.70k | case IMAGE_SCN_LNK_REMOVE: | 1243 | 3.70k | if (!is_dbg) | 1244 | 3.22k | sec_flags |= SEC_EXCLUDE; | 1245 | 3.70k | break; | 1246 | 12.6k | case IMAGE_SCN_CNT_CODE: | 1247 | 12.6k | sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD; | 1248 | 12.6k | break; | 1249 | 11.6k | case IMAGE_SCN_CNT_INITIALIZED_DATA: | 1250 | 11.6k | if (is_dbg) | 1251 | 478 | sec_flags |= SEC_DEBUGGING; | 1252 | 11.1k | else | 1253 | 11.1k | sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD; | 1254 | 11.6k | break; | 1255 | 4.02k | case IMAGE_SCN_CNT_UNINITIALIZED_DATA: | 1256 | 4.02k | sec_flags |= SEC_ALLOC; | 1257 | 4.02k | break; | 1258 | 4.83k | 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 | 4.83k | #ifdef COFF_PAGE_SIZE | 1266 | 4.83k | sec_flags |= SEC_DEBUGGING; | 1267 | 4.83k | #endif | 1268 | 4.83k | break; | 1269 | 5.97k | case IMAGE_SCN_LNK_COMDAT: | 1270 | | /* COMDAT gets very special treatment. */ | 1271 | 5.97k | if (!handle_COMDAT (abfd, &sec_flags, hdr, name, section)) | 1272 | 990 | result = false; | 1273 | 5.97k | break; | 1274 | 83.2k | default: | 1275 | | /* Silently ignore for now. */ | 1276 | 83.2k | break; | 1277 | 203k | } | 1278 | | | 1279 | | /* If the section flag was not handled, report it here. */ | 1280 | 203k | if (unhandled != NULL) | 1281 | 18.6k | { | 1282 | 18.6k | _bfd_error_handler | 1283 | | /* xgettext:c-format */ | 1284 | 18.6k | (_("%pB (%s): section flag %s (%#lx) ignored"), | 1285 | 18.6k | abfd, name, unhandled, flag); | 1286 | 18.6k | result = false; | 1287 | 18.6k | } | 1288 | 203k | } | 1289 | | | 1290 | 480k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 1291 | 480k | && (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 | 480k | if (flags_ptr) | 1307 | 480k | * flags_ptr = sec_flags; | 1308 | | | 1309 | 480k | return result; | 1310 | 480k | } |
pei-mcore.c:styp_to_sec_flags Line | Count | Source | 1139 | 60.9k | { | 1140 | 60.9k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 1141 | 60.9k | unsigned long styp_flags = internal_s->s_flags; | 1142 | 60.9k | flagword sec_flags; | 1143 | 60.9k | bool result = true; | 1144 | 60.9k | bool is_dbg = false; | 1145 | | | 1146 | 60.9k | if (startswith (name, DOT_DEBUG) | 1147 | 60.9k | || startswith (name, DOT_ZDEBUG) | 1148 | 60.9k | #ifdef COFF_LONG_SECTION_NAMES | 1149 | 60.9k | || startswith (name, GNU_LINKONCE_WI) | 1150 | 60.9k | || startswith (name, GNU_LINKONCE_WT) | 1151 | | /* FIXME: These definitions ought to be in a header file. */ | 1152 | 60.9k | #define GNU_DEBUGLINK ".gnu_debuglink" | 1153 | 60.9k | #define GNU_DEBUGALTLINK ".gnu_debugaltlink" | 1154 | 60.9k | || startswith (name, GNU_DEBUGLINK) | 1155 | 60.9k | || startswith (name, GNU_DEBUGALTLINK) | 1156 | 60.9k | #endif | 1157 | 60.9k | || startswith (name, ".stab")) | 1158 | 28 | is_dbg = true; | 1159 | | /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified. */ | 1160 | 60.9k | sec_flags = SEC_READONLY; | 1161 | | | 1162 | | /* If section disallows read, then set the NOREAD flag. */ | 1163 | 60.9k | if ((styp_flags & IMAGE_SCN_MEM_READ) == 0) | 1164 | 57.5k | sec_flags |= SEC_COFF_NOREAD; | 1165 | | | 1166 | | /* Process each flag bit in styp_flags in turn. */ | 1167 | 153k | while (styp_flags) | 1168 | 93.0k | { | 1169 | 93.0k | unsigned long flag = styp_flags & - styp_flags; | 1170 | 93.0k | char * unhandled = NULL; | 1171 | | | 1172 | 93.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 | 93.0k | switch (flag) | 1179 | 93.0k | { | 1180 | 1.97k | case STYP_DSECT: | 1181 | 1.97k | unhandled = "STYP_DSECT"; | 1182 | 1.97k | break; | 1183 | 1.94k | case STYP_GROUP: | 1184 | 1.94k | unhandled = "STYP_GROUP"; | 1185 | 1.94k | break; | 1186 | 1.50k | case STYP_COPY: | 1187 | 1.50k | unhandled = "STYP_COPY"; | 1188 | 1.50k | break; | 1189 | 1.94k | case STYP_OVER: | 1190 | 1.94k | unhandled = "STYP_OVER"; | 1191 | 1.94k | break; | 1192 | 0 | #ifdef SEC_NEVER_LOAD | 1193 | 2.38k | case STYP_NOLOAD: | 1194 | 2.38k | sec_flags |= SEC_NEVER_LOAD; | 1195 | 2.38k | break; | 1196 | 0 | #endif | 1197 | 3.38k | case IMAGE_SCN_MEM_READ: | 1198 | 3.38k | sec_flags &= ~SEC_COFF_NOREAD; | 1199 | 3.38k | break; | 1200 | 4.25k | case IMAGE_SCN_TYPE_NO_PAD: | 1201 | | /* Skip. */ | 1202 | 4.25k | break; | 1203 | 2.45k | case IMAGE_SCN_LNK_OTHER: | 1204 | 2.45k | unhandled = "IMAGE_SCN_LNK_OTHER"; | 1205 | 2.45k | break; | 1206 | 1.48k | case IMAGE_SCN_MEM_NOT_CACHED: | 1207 | 1.48k | unhandled = "IMAGE_SCN_MEM_NOT_CACHED"; | 1208 | 1.48k | break; | 1209 | 4.48k | 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 | 4.48k | _bfd_error_handler (_("%pB: warning: ignoring section flag" | 1215 | 4.48k | " %s in section %s"), | 1216 | 4.48k | abfd, "IMAGE_SCN_MEM_NOT_PAGED", name); | 1217 | 4.48k | break; | 1218 | 3.66k | case IMAGE_SCN_MEM_EXECUTE: | 1219 | 3.66k | sec_flags |= SEC_CODE; | 1220 | 3.66k | break; | 1221 | 4.74k | case IMAGE_SCN_MEM_WRITE: | 1222 | 4.74k | sec_flags &= ~ SEC_READONLY; | 1223 | 4.74k | break; | 1224 | 3.53k | 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 | 3.53k | if (is_dbg | 1231 | 3.53k | #ifdef _COMMENT | 1232 | 3.53k | || strcmp (name, _COMMENT) == 0 | 1233 | 3.53k | #endif | 1234 | 3.53k | ) | 1235 | 26 | { | 1236 | 26 | sec_flags |= SEC_DEBUGGING | SEC_READONLY; | 1237 | 26 | } | 1238 | 3.53k | break; | 1239 | 5.41k | case IMAGE_SCN_MEM_SHARED: | 1240 | 5.41k | sec_flags |= SEC_COFF_SHARED; | 1241 | 5.41k | break; | 1242 | 3.02k | case IMAGE_SCN_LNK_REMOVE: | 1243 | 3.02k | if (!is_dbg) | 1244 | 3.01k | sec_flags |= SEC_EXCLUDE; | 1245 | 3.02k | break; | 1246 | 1.66k | case IMAGE_SCN_CNT_CODE: | 1247 | 1.66k | sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD; | 1248 | 1.66k | break; | 1249 | 2.32k | case IMAGE_SCN_CNT_INITIALIZED_DATA: | 1250 | 2.32k | if (is_dbg) | 1251 | 14 | sec_flags |= SEC_DEBUGGING; | 1252 | 2.30k | else | 1253 | 2.30k | sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD; | 1254 | 2.32k | break; | 1255 | 2.18k | case IMAGE_SCN_CNT_UNINITIALIZED_DATA: | 1256 | 2.18k | sec_flags |= SEC_ALLOC; | 1257 | 2.18k | break; | 1258 | 3.56k | 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 | 3.56k | #ifdef COFF_PAGE_SIZE | 1266 | 3.56k | sec_flags |= SEC_DEBUGGING; | 1267 | 3.56k | #endif | 1268 | 3.56k | break; | 1269 | 3.05k | case IMAGE_SCN_LNK_COMDAT: | 1270 | | /* COMDAT gets very special treatment. */ | 1271 | 3.05k | if (!handle_COMDAT (abfd, &sec_flags, hdr, name, section)) | 1272 | 24 | result = false; | 1273 | 3.05k | break; | 1274 | 34.0k | default: | 1275 | | /* Silently ignore for now. */ | 1276 | 34.0k | break; | 1277 | 93.0k | } | 1278 | | | 1279 | | /* If the section flag was not handled, report it here. */ | 1280 | 93.0k | if (unhandled != NULL) | 1281 | 11.3k | { | 1282 | 11.3k | _bfd_error_handler | 1283 | | /* xgettext:c-format */ | 1284 | 11.3k | (_("%pB (%s): section flag %s (%#lx) ignored"), | 1285 | 11.3k | abfd, name, unhandled, flag); | 1286 | 11.3k | result = false; | 1287 | 11.3k | } | 1288 | 93.0k | } | 1289 | | | 1290 | 60.9k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 1291 | 60.9k | && (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 | 60.9k | if (flags_ptr) | 1307 | 60.9k | * flags_ptr = sec_flags; | 1308 | | | 1309 | 60.9k | return result; | 1310 | 60.9k | } |
pei-sh.c:styp_to_sec_flags Line | Count | Source | 1139 | 50.6k | { | 1140 | 50.6k | struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; | 1141 | 50.6k | unsigned long styp_flags = internal_s->s_flags; | 1142 | 50.6k | flagword sec_flags; | 1143 | 50.6k | bool result = true; | 1144 | 50.6k | bool is_dbg = false; | 1145 | | | 1146 | 50.6k | if (startswith (name, DOT_DEBUG) | 1147 | 50.6k | || startswith (name, DOT_ZDEBUG) | 1148 | 50.6k | #ifdef COFF_LONG_SECTION_NAMES | 1149 | 50.6k | || startswith (name, GNU_LINKONCE_WI) | 1150 | 50.6k | || startswith (name, GNU_LINKONCE_WT) | 1151 | | /* FIXME: These definitions ought to be in a header file. */ | 1152 | 50.6k | #define GNU_DEBUGLINK ".gnu_debuglink" | 1153 | 50.6k | #define GNU_DEBUGALTLINK ".gnu_debugaltlink" | 1154 | 50.6k | || startswith (name, GNU_DEBUGLINK) | 1155 | 50.6k | || startswith (name, GNU_DEBUGALTLINK) | 1156 | 50.6k | #endif | 1157 | 50.6k | || startswith (name, ".stab")) | 1158 | 40 | is_dbg = true; | 1159 | | /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified. */ | 1160 | 50.6k | sec_flags = SEC_READONLY; | 1161 | | | 1162 | | /* If section disallows read, then set the NOREAD flag. */ | 1163 | 50.6k | if ((styp_flags & IMAGE_SCN_MEM_READ) == 0) | 1164 | 49.5k | sec_flags |= SEC_COFF_NOREAD; | 1165 | | | 1166 | | /* Process each flag bit in styp_flags in turn. */ | 1167 | 148k | while (styp_flags) | 1168 | 97.6k | { | 1169 | 97.6k | unsigned long flag = styp_flags & - styp_flags; | 1170 | 97.6k | char * unhandled = NULL; | 1171 | | | 1172 | 97.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 | 97.6k | switch (flag) | 1179 | 97.6k | { | 1180 | 1.02k | case STYP_DSECT: | 1181 | 1.02k | unhandled = "STYP_DSECT"; | 1182 | 1.02k | break; | 1183 | 1.48k | case STYP_GROUP: | 1184 | 1.48k | unhandled = "STYP_GROUP"; | 1185 | 1.48k | break; | 1186 | 1.96k | case STYP_COPY: | 1187 | 1.96k | unhandled = "STYP_COPY"; | 1188 | 1.96k | break; | 1189 | 1.50k | case STYP_OVER: | 1190 | 1.50k | unhandled = "STYP_OVER"; | 1191 | 1.50k | break; | 1192 | 0 | #ifdef SEC_NEVER_LOAD | 1193 | 5.48k | case STYP_NOLOAD: | 1194 | 5.48k | sec_flags |= SEC_NEVER_LOAD; | 1195 | 5.48k | break; | 1196 | 0 | #endif | 1197 | 1.10k | case IMAGE_SCN_MEM_READ: | 1198 | 1.10k | sec_flags &= ~SEC_COFF_NOREAD; | 1199 | 1.10k | break; | 1200 | 4.48k | case IMAGE_SCN_TYPE_NO_PAD: | 1201 | | /* Skip. */ | 1202 | 4.48k | break; | 1203 | 1.51k | case IMAGE_SCN_LNK_OTHER: | 1204 | 1.51k | unhandled = "IMAGE_SCN_LNK_OTHER"; | 1205 | 1.51k | break; | 1206 | 1.48k | case IMAGE_SCN_MEM_NOT_CACHED: | 1207 | 1.48k | unhandled = "IMAGE_SCN_MEM_NOT_CACHED"; | 1208 | 1.48k | break; | 1209 | 5.05k | 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 | 5.05k | _bfd_error_handler (_("%pB: warning: ignoring section flag" | 1215 | 5.05k | " %s in section %s"), | 1216 | 5.05k | abfd, "IMAGE_SCN_MEM_NOT_PAGED", name); | 1217 | 5.05k | break; | 1218 | 2.61k | case IMAGE_SCN_MEM_EXECUTE: | 1219 | 2.61k | sec_flags |= SEC_CODE; | 1220 | 2.61k | break; | 1221 | 3.95k | case IMAGE_SCN_MEM_WRITE: | 1222 | 3.95k | sec_flags &= ~ SEC_READONLY; | 1223 | 3.95k | break; | 1224 | 5.55k | 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 | 5.55k | if (is_dbg | 1231 | 5.55k | #ifdef _COMMENT | 1232 | 5.55k | || strcmp (name, _COMMENT) == 0 | 1233 | 5.55k | #endif | 1234 | 5.55k | ) | 1235 | 24 | { | 1236 | 24 | sec_flags |= SEC_DEBUGGING | SEC_READONLY; | 1237 | 24 | } | 1238 | 5.55k | break; | 1239 | 3.02k | case IMAGE_SCN_MEM_SHARED: | 1240 | 3.02k | sec_flags |= SEC_COFF_SHARED; | 1241 | 3.02k | break; | 1242 | 5.51k | case IMAGE_SCN_LNK_REMOVE: | 1243 | 5.51k | if (!is_dbg) | 1244 | 5.50k | sec_flags |= SEC_EXCLUDE; | 1245 | 5.51k | break; | 1246 | 2.06k | case IMAGE_SCN_CNT_CODE: | 1247 | 2.06k | sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD; | 1248 | 2.06k | break; | 1249 | 2.03k | case IMAGE_SCN_CNT_INITIALIZED_DATA: | 1250 | 2.03k | if (is_dbg) | 1251 | 20 | sec_flags |= SEC_DEBUGGING; | 1252 | 2.01k | else | 1253 | 2.01k | sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD; | 1254 | 2.03k | break; | 1255 | 3.44k | case IMAGE_SCN_CNT_UNINITIALIZED_DATA: | 1256 | 3.44k | sec_flags |= SEC_ALLOC; | 1257 | 3.44k | break; | 1258 | 6.54k | 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 | 6.54k | #ifdef COFF_PAGE_SIZE | 1266 | 6.54k | sec_flags |= SEC_DEBUGGING; | 1267 | 6.54k | #endif | 1268 | 6.54k | break; | 1269 | 3.10k | case IMAGE_SCN_LNK_COMDAT: | 1270 | | /* COMDAT gets very special treatment. */ | 1271 | 3.10k | if (!handle_COMDAT (abfd, &sec_flags, hdr, name, section)) | 1272 | 16 | result = false; | 1273 | 3.10k | break; | 1274 | 34.7k | default: | 1275 | | /* Silently ignore for now. */ | 1276 | 34.7k | break; | 1277 | 97.6k | } | 1278 | | | 1279 | | /* If the section flag was not handled, report it here. */ | 1280 | 97.6k | if (unhandled != NULL) | 1281 | 8.98k | { | 1282 | 8.98k | _bfd_error_handler | 1283 | | /* xgettext:c-format */ | 1284 | 8.98k | (_("%pB (%s): section flag %s (%#lx) ignored"), | 1285 | 8.98k | abfd, name, unhandled, flag); | 1286 | 8.98k | result = false; | 1287 | 8.98k | } | 1288 | 97.6k | } | 1289 | | | 1290 | 50.6k | if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0 | 1291 | 50.6k | && (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 | 50.6k | if (flags_ptr) | 1307 | 50.6k | * flags_ptr = sec_flags; | 1308 | | | 1309 | 50.6k | return result; | 1310 | 50.6k | } |
|
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 | 3.61M | { |
1635 | 3.61M | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; |
1636 | | |
1637 | 3.61M | if (BADMAG (*internal_f)) |
1638 | 3.49M | return false; |
1639 | | |
1640 | 117k | return true; |
1641 | 3.61M | } pei-i386.c:coff_bad_format_hook Line | Count | Source | 1634 | 74.0k | { | 1635 | 74.0k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 74.0k | if (BADMAG (*internal_f)) | 1638 | 68.3k | return false; | 1639 | | | 1640 | 5.69k | return true; | 1641 | 74.0k | } |
pe-x86_64.c:coff_bad_format_hook Line | Count | Source | 1634 | 227k | { | 1635 | 227k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 227k | if (BADMAG (*internal_f)) | 1638 | 226k | return false; | 1639 | | | 1640 | 874 | return true; | 1641 | 227k | } |
pei-x86_64.c:coff_bad_format_hook Line | Count | Source | 1634 | 74.0k | { | 1635 | 74.0k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 74.0k | if (BADMAG (*internal_f)) | 1638 | 73.5k | return false; | 1639 | | | 1640 | 534 | return true; | 1641 | 74.0k | } |
coff-x86_64.c:coff_bad_format_hook Line | Count | Source | 1634 | 114k | { | 1635 | 114k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 114k | if (BADMAG (*internal_f)) | 1638 | 114k | return false; | 1639 | | | 1640 | 594 | return true; | 1641 | 114k | } |
Unexecuted instantiation: coff64-rs6000.c:coff_bad_format_hook pei-aarch64.c:coff_bad_format_hook Line | Count | Source | 1634 | 74.0k | { | 1635 | 74.0k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 74.0k | if (BADMAG (*internal_f)) | 1638 | 67.4k | return false; | 1639 | | | 1640 | 6.60k | return true; | 1641 | 74.0k | } |
pe-aarch64.c:coff_bad_format_hook Line | Count | Source | 1634 | 114k | { | 1635 | 114k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 114k | if (BADMAG (*internal_f)) | 1638 | 113k | return false; | 1639 | | | 1640 | 1.28k | return true; | 1641 | 114k | } |
pei-ia64.c:coff_bad_format_hook Line | Count | Source | 1634 | 71.9k | { | 1635 | 71.9k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 71.9k | if (BADMAG (*internal_f)) | 1638 | 55.2k | return false; | 1639 | | | 1640 | 16.7k | return true; | 1641 | 71.9k | } |
pei-loongarch64.c:coff_bad_format_hook Line | Count | Source | 1634 | 73.9k | { | 1635 | 73.9k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 73.9k | if (BADMAG (*internal_f)) | 1638 | 73.6k | return false; | 1639 | | | 1640 | 382 | return true; | 1641 | 73.9k | } |
cf-i386lynx.c:coff_bad_format_hook Line | Count | Source | 1634 | 114k | { | 1635 | 114k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 114k | if (BADMAG (*internal_f)) | 1638 | 114k | return false; | 1639 | | | 1640 | 596 | return true; | 1641 | 114k | } |
coff-go32.c:coff_bad_format_hook Line | Count | Source | 1634 | 114k | { | 1635 | 114k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 114k | if (BADMAG (*internal_f)) | 1638 | 114k | return false; | 1639 | | | 1640 | 596 | return true; | 1641 | 114k | } |
coff-i386.c:coff_bad_format_hook Line | Count | Source | 1634 | 114k | { | 1635 | 114k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 114k | if (BADMAG (*internal_f)) | 1638 | 114k | return false; | 1639 | | | 1640 | 596 | return true; | 1641 | 114k | } |
coff-rs6000.c:coff_bad_format_hook Line | Count | Source | 1634 | 114k | { | 1635 | 114k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 114k | if (BADMAG (*internal_f)) | 1638 | 114k | return false; | 1639 | | | 1640 | 414 | return true; | 1641 | 114k | } |
coff-sh.c:coff_bad_format_hook Line | Count | Source | 1634 | 427k | { | 1635 | 427k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 427k | if (BADMAG (*internal_f)) | 1638 | 420k | return false; | 1639 | | | 1640 | 7.32k | return true; | 1641 | 427k | } |
Unexecuted instantiation: coff-stgo32.c:coff_bad_format_hook coff-tic30.c:coff_bad_format_hook Line | Count | Source | 1634 | 114k | { | 1635 | 114k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 114k | if (BADMAG (*internal_f)) | 1638 | 114k | return false; | 1639 | | | 1640 | 270 | return true; | 1641 | 114k | } |
Unexecuted instantiation: coff-tic4x.c:coff_bad_format_hook coff-tic54x.c:coff_bad_format_hook Line | Count | Source | 1634 | 229k | { | 1635 | 229k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 229k | if (BADMAG (*internal_f)) | 1638 | 229k | return false; | 1639 | | | 1640 | 4 | return true; | 1641 | 229k | } |
coff-z80.c:coff_bad_format_hook Line | Count | Source | 1634 | 114k | { | 1635 | 114k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 114k | if (BADMAG (*internal_f)) | 1638 | 114k | return false; | 1639 | | | 1640 | 296 | return true; | 1641 | 114k | } |
coff-z8k.c:coff_bad_format_hook Line | Count | Source | 1634 | 114k | { | 1635 | 114k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 114k | if (BADMAG (*internal_f)) | 1638 | 114k | return false; | 1639 | | | 1640 | 292 | return true; | 1641 | 114k | } |
pe-arm-wince.c:coff_bad_format_hook Line | Count | Source | 1634 | 229k | { | 1635 | 229k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 229k | if (BADMAG (*internal_f)) | 1638 | 228k | return false; | 1639 | | | 1640 | 362 | return true; | 1641 | 229k | } |
pe-arm.c:coff_bad_format_hook Line | Count | Source | 1634 | 229k | { | 1635 | 229k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 229k | if (BADMAG (*internal_f)) | 1638 | 228k | return false; | 1639 | | | 1640 | 362 | return true; | 1641 | 229k | } |
pe-i386.c:coff_bad_format_hook Line | Count | Source | 1634 | 227k | { | 1635 | 227k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 227k | if (BADMAG (*internal_f)) | 1638 | 226k | return false; | 1639 | | | 1640 | 630 | return true; | 1641 | 227k | } |
pe-mcore.c:coff_bad_format_hook Line | Count | Source | 1634 | 229k | { | 1635 | 229k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 229k | if (BADMAG (*internal_f)) | 1638 | 225k | return false; | 1639 | | | 1640 | 3.95k | return true; | 1641 | 229k | } |
pe-sh.c:coff_bad_format_hook Line | Count | Source | 1634 | 114k | { | 1635 | 114k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 114k | if (BADMAG (*internal_f)) | 1638 | 110k | return false; | 1639 | | | 1640 | 3.89k | return true; | 1641 | 114k | } |
pei-arm-wince.c:coff_bad_format_hook Line | Count | Source | 1634 | 74.0k | { | 1635 | 74.0k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 74.0k | if (BADMAG (*internal_f)) | 1638 | 53.3k | return false; | 1639 | | | 1640 | 20.6k | return true; | 1641 | 74.0k | } |
pei-arm.c:coff_bad_format_hook Line | Count | Source | 1634 | 74.0k | { | 1635 | 74.0k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 74.0k | if (BADMAG (*internal_f)) | 1638 | 53.3k | return false; | 1639 | | | 1640 | 20.6k | return true; | 1641 | 74.0k | } |
pei-mcore.c:coff_bad_format_hook Line | Count | Source | 1634 | 74.0k | { | 1635 | 74.0k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 74.0k | if (BADMAG (*internal_f)) | 1638 | 61.7k | return false; | 1639 | | | 1640 | 12.2k | return true; | 1641 | 74.0k | } |
pei-sh.c:coff_bad_format_hook Line | Count | Source | 1634 | 74.0k | { | 1635 | 74.0k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1636 | | | 1637 | 74.0k | if (BADMAG (*internal_f)) | 1638 | 62.6k | return false; | 1639 | | | 1640 | 11.3k | return true; | 1641 | 74.0k | } |
|
1642 | | |
1643 | | #ifdef TICOFF |
1644 | | static bool |
1645 | | ticoff0_bad_format_hook (bfd *abfd ATTRIBUTE_UNUSED, void * filehdr) |
1646 | 229k | { |
1647 | 229k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; |
1648 | | |
1649 | 229k | if (COFF0_BADMAG (*internal_f)) |
1650 | 228k | return false; |
1651 | | |
1652 | 516 | return true; |
1653 | 229k | } Unexecuted instantiation: coff-tic4x.c:ticoff0_bad_format_hook coff-tic54x.c:ticoff0_bad_format_hook Line | Count | Source | 1646 | 229k | { | 1647 | 229k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1648 | | | 1649 | 229k | if (COFF0_BADMAG (*internal_f)) | 1650 | 228k | return false; | 1651 | | | 1652 | 516 | return true; | 1653 | 229k | } |
|
1654 | | #endif |
1655 | | |
1656 | | #ifdef TICOFF |
1657 | | static bool |
1658 | | ticoff1_bad_format_hook (bfd *abfd ATTRIBUTE_UNUSED, void * filehdr) |
1659 | 229k | { |
1660 | 229k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; |
1661 | | |
1662 | 229k | if (COFF1_BADMAG (*internal_f)) |
1663 | 229k | return false; |
1664 | | |
1665 | 10 | return true; |
1666 | 229k | } Unexecuted instantiation: coff-tic4x.c:ticoff1_bad_format_hook coff-tic54x.c:ticoff1_bad_format_hook Line | Count | Source | 1659 | 229k | { | 1660 | 229k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 1661 | | | 1662 | 229k | if (COFF1_BADMAG (*internal_f)) | 1663 | 229k | return false; | 1664 | | | 1665 | 10 | return true; | 1666 | 229k | } |
|
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.98M | { |
1678 | 1.98M | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; |
1679 | 1.98M | unsigned int i; |
1680 | | |
1681 | 17.1M | for (i = 0; i < table_size; ++i) |
1682 | 15.2M | { |
1683 | 15.2M | const char *secname = bfd_section_name (section); |
1684 | | |
1685 | 15.2M | if (alignment_table[i].comparison_length == (unsigned int) -1 |
1686 | 15.2M | ? strcmp (alignment_table[i].name, secname) == 0 |
1687 | 15.2M | : strncmp (alignment_table[i].name, secname, |
1688 | 8.35M | alignment_table[i].comparison_length) == 0) |
1689 | 5.35k | break; |
1690 | 15.2M | } |
1691 | 1.98M | if (i >= table_size) |
1692 | 1.98M | return; |
1693 | | |
1694 | 5.35k | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY |
1695 | 5.35k | && default_alignment < alignment_table[i].default_alignment_min) |
1696 | 1.70k | return; |
1697 | | |
1698 | 3.65k | 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 | 3.65k | ) |
1703 | 0 | return; |
1704 | | |
1705 | 3.65k | section->alignment_power = alignment_table[i].alignment_power; |
1706 | 3.65k | } pei-i386.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 12.0k | { | 1678 | 12.0k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 12.0k | unsigned int i; | 1680 | | | 1681 | 107k | for (i = 0; i < table_size; ++i) | 1682 | 95.9k | { | 1683 | 95.9k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 95.9k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 95.9k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 95.9k | : strncmp (alignment_table[i].name, secname, | 1688 | 60.0k | alignment_table[i].comparison_length) == 0) | 1689 | 134 | break; | 1690 | 95.9k | } | 1691 | 12.0k | if (i >= table_size) | 1692 | 11.9k | return; | 1693 | | | 1694 | 134 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 134 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 72 | 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 | } |
pe-x86_64.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 86.6k | { | 1678 | 86.6k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 86.6k | unsigned int i; | 1680 | | | 1681 | 1.21M | for (i = 0; i < table_size; ++i) | 1682 | 1.12M | { | 1683 | 1.12M | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 1.12M | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 1.12M | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 1.12M | : strncmp (alignment_table[i].name, secname, | 1688 | 779k | alignment_table[i].comparison_length) == 0) | 1689 | 132 | break; | 1690 | 1.12M | } | 1691 | 86.6k | if (i >= table_size) | 1692 | 86.5k | return; | 1693 | | | 1694 | 132 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 132 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 26 | return; | 1697 | | | 1698 | 106 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 106 | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 106 | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 106 | #endif | 1702 | 106 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 106 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 106 | } |
pei-x86_64.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 3.28k | { | 1678 | 3.28k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 3.28k | unsigned int i; | 1680 | | | 1681 | 41.4k | for (i = 0; i < table_size; ++i) | 1682 | 38.3k | { | 1683 | 38.3k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 38.3k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 38.3k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 38.3k | : strncmp (alignment_table[i].name, secname, | 1688 | 25.6k | alignment_table[i].comparison_length) == 0) | 1689 | 154 | break; | 1690 | 38.3k | } | 1691 | 3.28k | if (i >= table_size) | 1692 | 3.13k | return; | 1693 | | | 1694 | 154 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 154 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 16 | return; | 1697 | | | 1698 | 138 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 138 | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 138 | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 138 | #endif | 1702 | 138 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 138 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 138 | } |
coff-x86_64.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 304k | { | 1678 | 304k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 304k | unsigned int i; | 1680 | | | 1681 | 1.52M | for (i = 0; i < table_size; ++i) | 1682 | 1.21M | { | 1683 | 1.21M | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 1.21M | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 1.21M | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 1.21M | : strncmp (alignment_table[i].name, secname, | 1688 | 608k | alignment_table[i].comparison_length) == 0) | 1689 | 64 | break; | 1690 | 1.21M | } | 1691 | 304k | if (i >= table_size) | 1692 | 304k | return; | 1693 | | | 1694 | 64 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 64 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 30 | 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 | } |
coff64-rs6000.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 71.0k | { | 1678 | 71.0k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 71.0k | unsigned int i; | 1680 | | | 1681 | 355k | for (i = 0; i < table_size; ++i) | 1682 | 284k | { | 1683 | 284k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 284k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 284k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 284k | : strncmp (alignment_table[i].name, secname, | 1688 | 142k | alignment_table[i].comparison_length) == 0) | 1689 | 24 | break; | 1690 | 284k | } | 1691 | 71.0k | if (i >= table_size) | 1692 | 71.0k | return; | 1693 | | | 1694 | 24 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 24 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 0 | return; | 1697 | | | 1698 | 24 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 24 | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 24 | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 24 | #endif | 1702 | 24 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 24 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 24 | } |
pei-aarch64.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 10.0k | { | 1678 | 10.0k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 10.0k | unsigned int i; | 1680 | | | 1681 | 129k | for (i = 0; i < table_size; ++i) | 1682 | 119k | { | 1683 | 119k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 119k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 119k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 119k | : strncmp (alignment_table[i].name, secname, | 1688 | 49.7k | alignment_table[i].comparison_length) == 0) | 1689 | 108 | break; | 1690 | 119k | } | 1691 | 10.0k | if (i >= table_size) | 1692 | 9.89k | return; | 1693 | | | 1694 | 108 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 108 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 34 | return; | 1697 | | | 1698 | 74 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 74 | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 74 | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 74 | #endif | 1702 | 74 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 74 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 74 | } |
pe-aarch64.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 4.04k | { | 1678 | 4.04k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 4.04k | unsigned int i; | 1680 | | | 1681 | 52.1k | for (i = 0; i < table_size; ++i) | 1682 | 48.1k | { | 1683 | 48.1k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 48.1k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 48.1k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 48.1k | : strncmp (alignment_table[i].name, secname, | 1688 | 20.0k | alignment_table[i].comparison_length) == 0) | 1689 | 54 | break; | 1690 | 48.1k | } | 1691 | 4.04k | if (i >= table_size) | 1692 | 3.98k | return; | 1693 | | | 1694 | 54 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 54 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 10 | return; | 1697 | | | 1698 | 44 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 44 | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 44 | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 44 | #endif | 1702 | 44 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 44 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 44 | } |
pei-ia64.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 97.1k | { | 1678 | 97.1k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 97.1k | unsigned int i; | 1680 | | | 1681 | 484k | for (i = 0; i < table_size; ++i) | 1682 | 388k | { | 1683 | 388k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 388k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 388k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 388k | : strncmp (alignment_table[i].name, secname, | 1688 | 194k | alignment_table[i].comparison_length) == 0) | 1689 | 484 | break; | 1690 | 388k | } | 1691 | 97.1k | if (i >= table_size) | 1692 | 96.6k | return; | 1693 | | | 1694 | 484 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 484 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 484 | 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 | 2.14k | { | 1678 | 2.14k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 2.14k | unsigned int i; | 1680 | | | 1681 | 27.3k | for (i = 0; i < table_size; ++i) | 1682 | 25.2k | { | 1683 | 25.2k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 25.2k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 25.2k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 25.2k | : strncmp (alignment_table[i].name, secname, | 1688 | 10.4k | alignment_table[i].comparison_length) == 0) | 1689 | 80 | break; | 1690 | 25.2k | } | 1691 | 2.14k | if (i >= table_size) | 1692 | 2.06k | return; | 1693 | | | 1694 | 80 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 80 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 22 | return; | 1697 | | | 1698 | 58 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 58 | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 58 | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 58 | #endif | 1702 | 58 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 58 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 58 | } |
cf-i386lynx.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 193k | { | 1678 | 193k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 193k | unsigned int i; | 1680 | | | 1681 | 968k | for (i = 0; i < table_size; ++i) | 1682 | 774k | { | 1683 | 774k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 774k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 774k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 774k | : strncmp (alignment_table[i].name, secname, | 1688 | 387k | alignment_table[i].comparison_length) == 0) | 1689 | 108 | break; | 1690 | 774k | } | 1691 | 193k | if (i >= table_size) | 1692 | 193k | return; | 1693 | | | 1694 | 108 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 108 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 54 | return; | 1697 | | | 1698 | 54 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 54 | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 54 | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 54 | #endif | 1702 | 54 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 54 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 54 | } |
coff-go32.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 189k | { | 1678 | 189k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 189k | unsigned int i; | 1680 | | | 1681 | 3.03M | for (i = 0; i < table_size; ++i) | 1682 | 2.84M | { | 1683 | 2.84M | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 2.84M | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 2.84M | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 2.84M | : strncmp (alignment_table[i].name, secname, | 1688 | 2.46M | alignment_table[i].comparison_length) == 0) | 1689 | 166 | break; | 1690 | 2.84M | } | 1691 | 189k | if (i >= table_size) | 1692 | 189k | return; | 1693 | | | 1694 | 166 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 166 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 54 | return; | 1697 | | | 1698 | 112 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 112 | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 112 | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 112 | #endif | 1702 | 112 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 112 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 112 | } |
coff-i386.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 193k | { | 1678 | 193k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 193k | unsigned int i; | 1680 | | | 1681 | 968k | for (i = 0; i < table_size; ++i) | 1682 | 774k | { | 1683 | 774k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 774k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 774k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 774k | : strncmp (alignment_table[i].name, secname, | 1688 | 387k | alignment_table[i].comparison_length) == 0) | 1689 | 108 | break; | 1690 | 774k | } | 1691 | 193k | if (i >= table_size) | 1692 | 193k | return; | 1693 | | | 1694 | 108 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 108 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 54 | return; | 1697 | | | 1698 | 54 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 54 | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 54 | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 54 | #endif | 1702 | 54 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 54 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 54 | } |
coff-rs6000.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 31.3k | { | 1678 | 31.3k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 31.3k | unsigned int i; | 1680 | | | 1681 | 156k | for (i = 0; i < table_size; ++i) | 1682 | 125k | { | 1683 | 125k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 125k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 125k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 125k | : strncmp (alignment_table[i].name, secname, | 1688 | 62.6k | alignment_table[i].comparison_length) == 0) | 1689 | 32 | break; | 1690 | 125k | } | 1691 | 31.3k | if (i >= table_size) | 1692 | 31.3k | return; | 1693 | | | 1694 | 32 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 32 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 0 | return; | 1697 | | | 1698 | 32 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 32 | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 32 | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 32 | #endif | 1702 | 32 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 32 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 32 | } |
coff-sh.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 11.3k | { | 1678 | 11.3k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 11.3k | unsigned int i; | 1680 | | | 1681 | 56.8k | for (i = 0; i < table_size; ++i) | 1682 | 45.4k | { | 1683 | 45.4k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 45.4k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 45.4k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 45.4k | : strncmp (alignment_table[i].name, secname, | 1688 | 22.7k | alignment_table[i].comparison_length) == 0) | 1689 | 42 | break; | 1690 | 45.4k | } | 1691 | 11.3k | if (i >= table_size) | 1692 | 11.3k | return; | 1693 | | | 1694 | 42 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 42 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 0 | return; | 1697 | | | 1698 | 42 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 42 | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 42 | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 42 | #endif | 1702 | 42 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 42 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 42 | } |
Unexecuted instantiation: coff-stgo32.c:coff_set_custom_section_alignment coff-tic30.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 7.44k | { | 1678 | 7.44k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 7.44k | unsigned int i; | 1680 | | | 1681 | 36.3k | for (i = 0; i < table_size; ++i) | 1682 | 29.1k | { | 1683 | 29.1k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 29.1k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 29.1k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 29.1k | : strncmp (alignment_table[i].name, secname, | 1688 | 14.7k | alignment_table[i].comparison_length) == 0) | 1689 | 220 | break; | 1690 | 29.1k | } | 1691 | 7.44k | if (i >= table_size) | 1692 | 7.22k | return; | 1693 | | | 1694 | 220 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 220 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 52 | return; | 1697 | | | 1698 | 168 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 168 | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 168 | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 168 | #endif | 1702 | 168 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 168 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 168 | } |
Unexecuted instantiation: coff-tic4x.c:coff_set_custom_section_alignment coff-tic54x.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 7.88k | { | 1678 | 7.88k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 7.88k | unsigned int i; | 1680 | | | 1681 | 39.3k | for (i = 0; i < table_size; ++i) | 1682 | 31.5k | { | 1683 | 31.5k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 31.5k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 31.5k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 31.5k | : strncmp (alignment_table[i].name, secname, | 1688 | 15.7k | alignment_table[i].comparison_length) == 0) | 1689 | 4 | break; | 1690 | 31.5k | } | 1691 | 7.88k | if (i >= table_size) | 1692 | 7.87k | 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 | 4 | 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 | 80.3k | { | 1678 | 80.3k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 80.3k | unsigned int i; | 1680 | | | 1681 | 401k | for (i = 0; i < table_size; ++i) | 1682 | 321k | { | 1683 | 321k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 321k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 321k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 321k | : strncmp (alignment_table[i].name, secname, | 1688 | 160k | alignment_table[i].comparison_length) == 0) | 1689 | 14 | break; | 1690 | 321k | } | 1691 | 80.3k | if (i >= table_size) | 1692 | 80.3k | return; | 1693 | | | 1694 | 14 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 14 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 14 | 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 | 3.97k | { | 1678 | 3.97k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 3.97k | unsigned int i; | 1680 | | | 1681 | 19.8k | for (i = 0; i < table_size; ++i) | 1682 | 15.8k | { | 1683 | 15.8k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 15.8k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 15.8k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 15.8k | : strncmp (alignment_table[i].name, secname, | 1688 | 7.93k | alignment_table[i].comparison_length) == 0) | 1689 | 22 | break; | 1690 | 15.8k | } | 1691 | 3.97k | if (i >= table_size) | 1692 | 3.95k | 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 | 8 | return; | 1697 | | | 1698 | 14 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 14 | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 14 | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 14 | #endif | 1702 | 14 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 14 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 14 | } |
pe-arm-wince.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 2.72k | { | 1678 | 2.72k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 2.72k | unsigned int i; | 1680 | | | 1681 | 37.1k | for (i = 0; i < table_size; ++i) | 1682 | 34.6k | { | 1683 | 34.6k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 34.6k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 34.6k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 34.6k | : strncmp (alignment_table[i].name, secname, | 1688 | 16.0k | alignment_table[i].comparison_length) == 0) | 1689 | 250 | break; | 1690 | 34.6k | } | 1691 | 2.72k | if (i >= table_size) | 1692 | 2.47k | return; | 1693 | | | 1694 | 250 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 250 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 68 | return; | 1697 | | | 1698 | 182 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 182 | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 182 | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 182 | #endif | 1702 | 182 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 182 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 182 | } |
pe-arm.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 2.72k | { | 1678 | 2.72k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 2.72k | unsigned int i; | 1680 | | | 1681 | 37.1k | for (i = 0; i < table_size; ++i) | 1682 | 34.6k | { | 1683 | 34.6k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 34.6k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 34.6k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 34.6k | : strncmp (alignment_table[i].name, secname, | 1688 | 16.0k | alignment_table[i].comparison_length) == 0) | 1689 | 250 | break; | 1690 | 34.6k | } | 1691 | 2.72k | if (i >= table_size) | 1692 | 2.47k | return; | 1693 | | | 1694 | 250 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 250 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 68 | return; | 1697 | | | 1698 | 182 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 182 | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 182 | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 182 | #endif | 1702 | 182 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 182 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 182 | } |
pe-i386.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 3.96k | { | 1678 | 3.96k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 3.96k | unsigned int i; | 1680 | | | 1681 | 39.2k | for (i = 0; i < table_size; ++i) | 1682 | 35.3k | { | 1683 | 35.3k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 35.3k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 35.3k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 35.3k | : strncmp (alignment_table[i].name, secname, | 1688 | 23.6k | alignment_table[i].comparison_length) == 0) | 1689 | 88 | break; | 1690 | 35.3k | } | 1691 | 3.96k | if (i >= table_size) | 1692 | 3.87k | return; | 1693 | | | 1694 | 88 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 88 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 42 | return; | 1697 | | | 1698 | 46 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 46 | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 46 | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 46 | #endif | 1702 | 46 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 46 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 46 | } |
pe-mcore.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 23.1k | { | 1678 | 23.1k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 23.1k | unsigned int i; | 1680 | | | 1681 | 115k | for (i = 0; i < table_size; ++i) | 1682 | 92.4k | { | 1683 | 92.4k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 92.4k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 92.4k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 92.4k | : strncmp (alignment_table[i].name, secname, | 1688 | 46.2k | alignment_table[i].comparison_length) == 0) | 1689 | 110 | break; | 1690 | 92.4k | } | 1691 | 23.1k | if (i >= table_size) | 1692 | 23.0k | 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 | 44 | return; | 1697 | | | 1698 | 66 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 66 | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 66 | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 66 | #endif | 1702 | 66 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 66 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 66 | } |
pe-sh.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 11.7k | { | 1678 | 11.7k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 11.7k | unsigned int i; | 1680 | | | 1681 | 58.4k | for (i = 0; i < table_size; ++i) | 1682 | 46.7k | { | 1683 | 46.7k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 46.7k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 46.7k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 46.7k | : strncmp (alignment_table[i].name, secname, | 1688 | 23.4k | alignment_table[i].comparison_length) == 0) | 1689 | 28 | break; | 1690 | 46.7k | } | 1691 | 11.7k | if (i >= table_size) | 1692 | 11.6k | return; | 1693 | | | 1694 | 28 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 28 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 18 | return; | 1697 | | | 1698 | 10 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 10 | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 10 | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 10 | #endif | 1702 | 10 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 10 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 10 | } |
pei-arm-wince.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 39.0k | { | 1678 | 39.0k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 39.0k | unsigned int i; | 1680 | | | 1681 | 495k | for (i = 0; i < table_size; ++i) | 1682 | 457k | { | 1683 | 457k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 457k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 457k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 457k | : strncmp (alignment_table[i].name, secname, | 1688 | 190k | alignment_table[i].comparison_length) == 0) | 1689 | 1.08k | break; | 1690 | 457k | } | 1691 | 39.0k | if (i >= table_size) | 1692 | 38.0k | return; | 1693 | | | 1694 | 1.08k | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 1.08k | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 8 | return; | 1697 | | | 1698 | 1.07k | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 1.07k | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 1.07k | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 1.07k | #endif | 1702 | 1.07k | ) | 1703 | 0 | return; | 1704 | | | 1705 | 1.07k | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 1.07k | } |
pei-arm.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 481k | { | 1678 | 481k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 481k | unsigned int i; | 1680 | | | 1681 | 6.24M | for (i = 0; i < table_size; ++i) | 1682 | 5.76M | { | 1683 | 5.76M | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 5.76M | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 5.76M | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 5.76M | : strncmp (alignment_table[i].name, secname, | 1688 | 2.40M | alignment_table[i].comparison_length) == 0) | 1689 | 1.07k | break; | 1690 | 5.76M | } | 1691 | 481k | if (i >= table_size) | 1692 | 479k | return; | 1693 | | | 1694 | 1.07k | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 1.07k | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 4 | return; | 1697 | | | 1698 | 1.07k | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 1.07k | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 1.07k | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 1.07k | #endif | 1702 | 1.07k | ) | 1703 | 0 | return; | 1704 | | | 1705 | 1.07k | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 1.07k | } |
pei-mcore.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 60.9k | { | 1678 | 60.9k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 60.9k | unsigned int i; | 1680 | | | 1681 | 303k | for (i = 0; i < table_size; ++i) | 1682 | 243k | { | 1683 | 243k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 243k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 243k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 243k | : strncmp (alignment_table[i].name, secname, | 1688 | 121k | alignment_table[i].comparison_length) == 0) | 1689 | 498 | break; | 1690 | 243k | } | 1691 | 60.9k | if (i >= table_size) | 1692 | 60.4k | return; | 1693 | | | 1694 | 498 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 498 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 492 | return; | 1697 | | | 1698 | 6 | if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY | 1699 | 6 | #if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0 | 1700 | 6 | && default_alignment > alignment_table[i].default_alignment_max | 1701 | 6 | #endif | 1702 | 6 | ) | 1703 | 0 | return; | 1704 | | | 1705 | 6 | section->alignment_power = alignment_table[i].alignment_power; | 1706 | 6 | } |
pei-sh.c:coff_set_custom_section_alignment Line | Count | Source | 1677 | 50.7k | { | 1678 | 50.7k | const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1679 | 50.7k | unsigned int i; | 1680 | | | 1681 | 253k | for (i = 0; i < table_size; ++i) | 1682 | 202k | { | 1683 | 202k | const char *secname = bfd_section_name (section); | 1684 | | | 1685 | 202k | if (alignment_table[i].comparison_length == (unsigned int) -1 | 1686 | 202k | ? strcmp (alignment_table[i].name, secname) == 0 | 1687 | 202k | : strncmp (alignment_table[i].name, secname, | 1688 | 101k | alignment_table[i].comparison_length) == 0) | 1689 | 24 | break; | 1690 | 202k | } | 1691 | 50.7k | if (i >= table_size) | 1692 | 50.7k | return; | 1693 | | | 1694 | 24 | if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY | 1695 | 24 | && default_alignment < alignment_table[i].default_alignment_min) | 1696 | 22 | 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.98M | { |
1738 | 1.98M | combined_entry_type *native; |
1739 | 1.98M | size_t amt; |
1740 | 1.98M | unsigned char sclass = C_STAT; |
1741 | | |
1742 | 1.98M | section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; |
1743 | | |
1744 | | #ifdef RS6000COFF_C |
1745 | 102k | if (bfd_xcoff_text_align_power (abfd) != 0 |
1746 | 102k | && strcmp (bfd_section_name (section), ".text") == 0) |
1747 | 16 | section->alignment_power = bfd_xcoff_text_align_power (abfd); |
1748 | 102k | else if (bfd_xcoff_data_align_power (abfd) != 0 |
1749 | 102k | && strcmp (bfd_section_name (section), ".data") == 0) |
1750 | 10 | section->alignment_power = bfd_xcoff_data_align_power (abfd); |
1751 | 102k | else |
1752 | 102k | { |
1753 | 102k | int i; |
1754 | | |
1755 | 1.22M | for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++) |
1756 | 1.12M | if (strcmp (bfd_section_name (section), |
1757 | 1.12M | xcoff_dwsect_names[i].xcoff_name) == 0) |
1758 | 80 | { |
1759 | 80 | section->alignment_power = 0; |
1760 | 80 | sclass = C_DWARF; |
1761 | 80 | break; |
1762 | 80 | } |
1763 | 102k | } |
1764 | | #endif |
1765 | | |
1766 | | /* Set up the section symbol. */ |
1767 | 1.98M | 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.98M | amt = sizeof (combined_entry_type) * 10; |
1776 | 1.98M | native = (combined_entry_type *) bfd_zalloc (abfd, amt); |
1777 | 1.98M | 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.98M | native->is_sym = true; |
1787 | 1.98M | native->u.syment.n_type = T_NULL; |
1788 | 1.98M | native->u.syment.n_sclass = sclass; |
1789 | | |
1790 | 1.98M | coffsymbol (section->symbol)->native = native; |
1791 | | |
1792 | 1.98M | coff_set_custom_section_alignment (abfd, section, |
1793 | 1.98M | coff_section_alignment_table, |
1794 | 1.98M | coff_section_alignment_table_size); |
1795 | | |
1796 | 1.98M | return true; |
1797 | 1.98M | } pei-i386.c:coff_new_section_hook Line | Count | Source | 1737 | 12.0k | { | 1738 | 12.0k | combined_entry_type *native; | 1739 | 12.0k | size_t amt; | 1740 | 12.0k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 12.0k | 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 | 12.0k | 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 | 12.0k | amt = sizeof (combined_entry_type) * 10; | 1776 | 12.0k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 12.0k | 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 | 12.0k | native->is_sym = true; | 1787 | 12.0k | native->u.syment.n_type = T_NULL; | 1788 | 12.0k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 12.0k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 12.0k | coff_set_custom_section_alignment (abfd, section, | 1793 | 12.0k | coff_section_alignment_table, | 1794 | 12.0k | coff_section_alignment_table_size); | 1795 | | | 1796 | 12.0k | return true; | 1797 | 12.0k | } |
pe-x86_64.c:coff_new_section_hook Line | Count | Source | 1737 | 86.6k | { | 1738 | 86.6k | combined_entry_type *native; | 1739 | 86.6k | size_t amt; | 1740 | 86.6k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 86.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 | 86.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 | 86.6k | amt = sizeof (combined_entry_type) * 10; | 1776 | 86.6k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 86.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 | 86.6k | native->is_sym = true; | 1787 | 86.6k | native->u.syment.n_type = T_NULL; | 1788 | 86.6k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 86.6k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 86.6k | coff_set_custom_section_alignment (abfd, section, | 1793 | 86.6k | coff_section_alignment_table, | 1794 | 86.6k | coff_section_alignment_table_size); | 1795 | | | 1796 | 86.6k | return true; | 1797 | 86.6k | } |
pei-x86_64.c:coff_new_section_hook Line | Count | Source | 1737 | 3.28k | { | 1738 | 3.28k | combined_entry_type *native; | 1739 | 3.28k | size_t amt; | 1740 | 3.28k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 3.28k | 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.28k | 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.28k | amt = sizeof (combined_entry_type) * 10; | 1776 | 3.28k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 3.28k | 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.28k | native->is_sym = true; | 1787 | 3.28k | native->u.syment.n_type = T_NULL; | 1788 | 3.28k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 3.28k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 3.28k | coff_set_custom_section_alignment (abfd, section, | 1793 | 3.28k | coff_section_alignment_table, | 1794 | 3.28k | coff_section_alignment_table_size); | 1795 | | | 1796 | 3.28k | return true; | 1797 | 3.28k | } |
coff-x86_64.c:coff_new_section_hook Line | Count | Source | 1737 | 304k | { | 1738 | 304k | combined_entry_type *native; | 1739 | 304k | size_t amt; | 1740 | 304k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 304k | 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 | 304k | 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 | 304k | amt = sizeof (combined_entry_type) * 10; | 1776 | 304k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 304k | 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 | 304k | native->is_sym = true; | 1787 | 304k | native->u.syment.n_type = T_NULL; | 1788 | 304k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 304k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 304k | coff_set_custom_section_alignment (abfd, section, | 1793 | 304k | coff_section_alignment_table, | 1794 | 304k | coff_section_alignment_table_size); | 1795 | | | 1796 | 304k | return true; | 1797 | 304k | } |
coff64-rs6000.c:coff_new_section_hook Line | Count | Source | 1737 | 71.0k | { | 1738 | 71.0k | combined_entry_type *native; | 1739 | 71.0k | size_t amt; | 1740 | 71.0k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 71.0k | section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1743 | | | 1744 | 71.0k | #ifdef RS6000COFF_C | 1745 | 71.0k | if (bfd_xcoff_text_align_power (abfd) != 0 | 1746 | 71.0k | && strcmp (bfd_section_name (section), ".text") == 0) | 1747 | 2 | section->alignment_power = bfd_xcoff_text_align_power (abfd); | 1748 | 71.0k | else if (bfd_xcoff_data_align_power (abfd) != 0 | 1749 | 71.0k | && strcmp (bfd_section_name (section), ".data") == 0) | 1750 | 0 | section->alignment_power = bfd_xcoff_data_align_power (abfd); | 1751 | 71.0k | else | 1752 | 71.0k | { | 1753 | 71.0k | int i; | 1754 | | | 1755 | 851k | for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++) | 1756 | 780k | if (strcmp (bfd_section_name (section), | 1757 | 780k | xcoff_dwsect_names[i].xcoff_name) == 0) | 1758 | 50 | { | 1759 | 50 | section->alignment_power = 0; | 1760 | 50 | sclass = C_DWARF; | 1761 | 50 | break; | 1762 | 50 | } | 1763 | 71.0k | } | 1764 | 71.0k | #endif | 1765 | | | 1766 | | /* Set up the section symbol. */ | 1767 | 71.0k | 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 | 71.0k | amt = sizeof (combined_entry_type) * 10; | 1776 | 71.0k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 71.0k | 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 | 71.0k | native->is_sym = true; | 1787 | 71.0k | native->u.syment.n_type = T_NULL; | 1788 | 71.0k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 71.0k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 71.0k | coff_set_custom_section_alignment (abfd, section, | 1793 | 71.0k | coff_section_alignment_table, | 1794 | 71.0k | coff_section_alignment_table_size); | 1795 | | | 1796 | 71.0k | return true; | 1797 | 71.0k | } |
pei-aarch64.c:coff_new_section_hook Line | Count | Source | 1737 | 10.0k | { | 1738 | 10.0k | combined_entry_type *native; | 1739 | 10.0k | size_t amt; | 1740 | 10.0k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 10.0k | 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 | 10.0k | 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 | 10.0k | amt = sizeof (combined_entry_type) * 10; | 1776 | 10.0k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 10.0k | 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 | 10.0k | native->is_sym = true; | 1787 | 10.0k | native->u.syment.n_type = T_NULL; | 1788 | 10.0k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 10.0k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 10.0k | coff_set_custom_section_alignment (abfd, section, | 1793 | 10.0k | coff_section_alignment_table, | 1794 | 10.0k | coff_section_alignment_table_size); | 1795 | | | 1796 | 10.0k | return true; | 1797 | 10.0k | } |
pe-aarch64.c:coff_new_section_hook Line | Count | Source | 1737 | 4.04k | { | 1738 | 4.04k | combined_entry_type *native; | 1739 | 4.04k | size_t amt; | 1740 | 4.04k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 4.04k | 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 | 4.04k | 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 | 4.04k | amt = sizeof (combined_entry_type) * 10; | 1776 | 4.04k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 4.04k | 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 | 4.04k | native->is_sym = true; | 1787 | 4.04k | native->u.syment.n_type = T_NULL; | 1788 | 4.04k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 4.04k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 4.04k | coff_set_custom_section_alignment (abfd, section, | 1793 | 4.04k | coff_section_alignment_table, | 1794 | 4.04k | coff_section_alignment_table_size); | 1795 | | | 1796 | 4.04k | return true; | 1797 | 4.04k | } |
pei-ia64.c:coff_new_section_hook Line | Count | Source | 1737 | 97.1k | { | 1738 | 97.1k | combined_entry_type *native; | 1739 | 97.1k | size_t amt; | 1740 | 97.1k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 97.1k | 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 | 97.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 | 97.1k | amt = sizeof (combined_entry_type) * 10; | 1776 | 97.1k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 97.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 | 97.1k | native->is_sym = true; | 1787 | 97.1k | native->u.syment.n_type = T_NULL; | 1788 | 97.1k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 97.1k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 97.1k | coff_set_custom_section_alignment (abfd, section, | 1793 | 97.1k | coff_section_alignment_table, | 1794 | 97.1k | coff_section_alignment_table_size); | 1795 | | | 1796 | 97.1k | return true; | 1797 | 97.1k | } |
pei-loongarch64.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 | } |
cf-i386lynx.c:coff_new_section_hook Line | Count | Source | 1737 | 193k | { | 1738 | 193k | combined_entry_type *native; | 1739 | 193k | size_t amt; | 1740 | 193k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 193k | 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 | 193k | 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 | 193k | amt = sizeof (combined_entry_type) * 10; | 1776 | 193k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 193k | 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 | 193k | native->is_sym = true; | 1787 | 193k | native->u.syment.n_type = T_NULL; | 1788 | 193k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 193k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 193k | coff_set_custom_section_alignment (abfd, section, | 1793 | 193k | coff_section_alignment_table, | 1794 | 193k | coff_section_alignment_table_size); | 1795 | | | 1796 | 193k | return true; | 1797 | 193k | } |
coff-go32.c:coff_new_section_hook Line | Count | Source | 1737 | 189k | { | 1738 | 189k | combined_entry_type *native; | 1739 | 189k | size_t amt; | 1740 | 189k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 189k | 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 | 189k | 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 | 189k | amt = sizeof (combined_entry_type) * 10; | 1776 | 189k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 189k | 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 | 189k | native->is_sym = true; | 1787 | 189k | native->u.syment.n_type = T_NULL; | 1788 | 189k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 189k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 189k | coff_set_custom_section_alignment (abfd, section, | 1793 | 189k | coff_section_alignment_table, | 1794 | 189k | coff_section_alignment_table_size); | 1795 | | | 1796 | 189k | return true; | 1797 | 189k | } |
coff-i386.c:coff_new_section_hook Line | Count | Source | 1737 | 193k | { | 1738 | 193k | combined_entry_type *native; | 1739 | 193k | size_t amt; | 1740 | 193k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 193k | 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 | 193k | 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 | 193k | amt = sizeof (combined_entry_type) * 10; | 1776 | 193k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 193k | 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 | 193k | native->is_sym = true; | 1787 | 193k | native->u.syment.n_type = T_NULL; | 1788 | 193k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 193k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 193k | coff_set_custom_section_alignment (abfd, section, | 1793 | 193k | coff_section_alignment_table, | 1794 | 193k | coff_section_alignment_table_size); | 1795 | | | 1796 | 193k | return true; | 1797 | 193k | } |
coff-rs6000.c:coff_new_section_hook Line | Count | Source | 1737 | 31.3k | { | 1738 | 31.3k | combined_entry_type *native; | 1739 | 31.3k | size_t amt; | 1740 | 31.3k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 31.3k | section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; | 1743 | | | 1744 | 31.3k | #ifdef RS6000COFF_C | 1745 | 31.3k | if (bfd_xcoff_text_align_power (abfd) != 0 | 1746 | 31.3k | && strcmp (bfd_section_name (section), ".text") == 0) | 1747 | 14 | section->alignment_power = bfd_xcoff_text_align_power (abfd); | 1748 | 31.3k | else if (bfd_xcoff_data_align_power (abfd) != 0 | 1749 | 31.3k | && strcmp (bfd_section_name (section), ".data") == 0) | 1750 | 10 | section->alignment_power = bfd_xcoff_data_align_power (abfd); | 1751 | 31.3k | else | 1752 | 31.3k | { | 1753 | 31.3k | int i; | 1754 | | | 1755 | 375k | for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++) | 1756 | 344k | if (strcmp (bfd_section_name (section), | 1757 | 344k | xcoff_dwsect_names[i].xcoff_name) == 0) | 1758 | 30 | { | 1759 | 30 | section->alignment_power = 0; | 1760 | 30 | sclass = C_DWARF; | 1761 | 30 | break; | 1762 | 30 | } | 1763 | 31.3k | } | 1764 | 31.3k | #endif | 1765 | | | 1766 | | /* Set up the section symbol. */ | 1767 | 31.3k | 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 | 31.3k | amt = sizeof (combined_entry_type) * 10; | 1776 | 31.3k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 31.3k | 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 | 31.3k | native->is_sym = true; | 1787 | 31.3k | native->u.syment.n_type = T_NULL; | 1788 | 31.3k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 31.3k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 31.3k | coff_set_custom_section_alignment (abfd, section, | 1793 | 31.3k | coff_section_alignment_table, | 1794 | 31.3k | coff_section_alignment_table_size); | 1795 | | | 1796 | 31.3k | return true; | 1797 | 31.3k | } |
coff-sh.c:coff_new_section_hook Line | Count | Source | 1737 | 11.3k | { | 1738 | 11.3k | combined_entry_type *native; | 1739 | 11.3k | size_t amt; | 1740 | 11.3k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 11.3k | 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 | 11.3k | 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 | 11.3k | amt = sizeof (combined_entry_type) * 10; | 1776 | 11.3k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 11.3k | 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 | 11.3k | native->is_sym = true; | 1787 | 11.3k | native->u.syment.n_type = T_NULL; | 1788 | 11.3k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 11.3k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 11.3k | coff_set_custom_section_alignment (abfd, section, | 1793 | 11.3k | coff_section_alignment_table, | 1794 | 11.3k | coff_section_alignment_table_size); | 1795 | | | 1796 | 11.3k | return true; | 1797 | 11.3k | } |
Unexecuted instantiation: coff-stgo32.c:coff_new_section_hook coff-tic30.c:coff_new_section_hook Line | Count | Source | 1737 | 7.44k | { | 1738 | 7.44k | combined_entry_type *native; | 1739 | 7.44k | size_t amt; | 1740 | 7.44k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 7.44k | 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.44k | 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.44k | amt = sizeof (combined_entry_type) * 10; | 1776 | 7.44k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 7.44k | 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.44k | native->is_sym = true; | 1787 | 7.44k | native->u.syment.n_type = T_NULL; | 1788 | 7.44k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 7.44k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 7.44k | coff_set_custom_section_alignment (abfd, section, | 1793 | 7.44k | coff_section_alignment_table, | 1794 | 7.44k | coff_section_alignment_table_size); | 1795 | | | 1796 | 7.44k | return true; | 1797 | 7.44k | } |
Unexecuted instantiation: coff-tic4x.c:coff_new_section_hook coff-tic54x.c:coff_new_section_hook Line | Count | Source | 1737 | 7.88k | { | 1738 | 7.88k | combined_entry_type *native; | 1739 | 7.88k | size_t amt; | 1740 | 7.88k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 7.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 | 7.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 | 7.88k | amt = sizeof (combined_entry_type) * 10; | 1776 | 7.88k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 7.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 | 7.88k | native->is_sym = true; | 1787 | 7.88k | native->u.syment.n_type = T_NULL; | 1788 | 7.88k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 7.88k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 7.88k | coff_set_custom_section_alignment (abfd, section, | 1793 | 7.88k | coff_section_alignment_table, | 1794 | 7.88k | coff_section_alignment_table_size); | 1795 | | | 1796 | 7.88k | return true; | 1797 | 7.88k | } |
coff-z80.c:coff_new_section_hook Line | Count | Source | 1737 | 80.3k | { | 1738 | 80.3k | combined_entry_type *native; | 1739 | 80.3k | size_t amt; | 1740 | 80.3k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 80.3k | 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 | 80.3k | 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 | 80.3k | amt = sizeof (combined_entry_type) * 10; | 1776 | 80.3k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 80.3k | 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 | 80.3k | native->is_sym = true; | 1787 | 80.3k | native->u.syment.n_type = T_NULL; | 1788 | 80.3k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 80.3k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 80.3k | coff_set_custom_section_alignment (abfd, section, | 1793 | 80.3k | coff_section_alignment_table, | 1794 | 80.3k | coff_section_alignment_table_size); | 1795 | | | 1796 | 80.3k | return true; | 1797 | 80.3k | } |
coff-z8k.c:coff_new_section_hook Line | Count | Source | 1737 | 3.97k | { | 1738 | 3.97k | combined_entry_type *native; | 1739 | 3.97k | size_t amt; | 1740 | 3.97k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 3.97k | 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.97k | 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.97k | amt = sizeof (combined_entry_type) * 10; | 1776 | 3.97k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 3.97k | 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.97k | native->is_sym = true; | 1787 | 3.97k | native->u.syment.n_type = T_NULL; | 1788 | 3.97k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 3.97k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 3.97k | coff_set_custom_section_alignment (abfd, section, | 1793 | 3.97k | coff_section_alignment_table, | 1794 | 3.97k | coff_section_alignment_table_size); | 1795 | | | 1796 | 3.97k | return true; | 1797 | 3.97k | } |
pe-arm-wince.c:coff_new_section_hook Line | Count | Source | 1737 | 2.72k | { | 1738 | 2.72k | combined_entry_type *native; | 1739 | 2.72k | size_t amt; | 1740 | 2.72k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 2.72k | 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.72k | 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.72k | amt = sizeof (combined_entry_type) * 10; | 1776 | 2.72k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 2.72k | 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.72k | native->is_sym = true; | 1787 | 2.72k | native->u.syment.n_type = T_NULL; | 1788 | 2.72k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 2.72k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 2.72k | coff_set_custom_section_alignment (abfd, section, | 1793 | 2.72k | coff_section_alignment_table, | 1794 | 2.72k | coff_section_alignment_table_size); | 1795 | | | 1796 | 2.72k | return true; | 1797 | 2.72k | } |
pe-arm.c:coff_new_section_hook Line | Count | Source | 1737 | 2.72k | { | 1738 | 2.72k | combined_entry_type *native; | 1739 | 2.72k | size_t amt; | 1740 | 2.72k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 2.72k | 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.72k | 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.72k | amt = sizeof (combined_entry_type) * 10; | 1776 | 2.72k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 2.72k | 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.72k | native->is_sym = true; | 1787 | 2.72k | native->u.syment.n_type = T_NULL; | 1788 | 2.72k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 2.72k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 2.72k | coff_set_custom_section_alignment (abfd, section, | 1793 | 2.72k | coff_section_alignment_table, | 1794 | 2.72k | coff_section_alignment_table_size); | 1795 | | | 1796 | 2.72k | return true; | 1797 | 2.72k | } |
pe-i386.c:coff_new_section_hook Line | Count | Source | 1737 | 3.96k | { | 1738 | 3.96k | combined_entry_type *native; | 1739 | 3.96k | size_t amt; | 1740 | 3.96k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 3.96k | 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.96k | 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.96k | amt = sizeof (combined_entry_type) * 10; | 1776 | 3.96k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 3.96k | 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.96k | native->is_sym = true; | 1787 | 3.96k | native->u.syment.n_type = T_NULL; | 1788 | 3.96k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 3.96k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 3.96k | coff_set_custom_section_alignment (abfd, section, | 1793 | 3.96k | coff_section_alignment_table, | 1794 | 3.96k | coff_section_alignment_table_size); | 1795 | | | 1796 | 3.96k | return true; | 1797 | 3.96k | } |
pe-mcore.c:coff_new_section_hook Line | Count | Source | 1737 | 23.1k | { | 1738 | 23.1k | combined_entry_type *native; | 1739 | 23.1k | size_t amt; | 1740 | 23.1k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 23.1k | 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 | 23.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 | 23.1k | amt = sizeof (combined_entry_type) * 10; | 1776 | 23.1k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 23.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 | 23.1k | native->is_sym = true; | 1787 | 23.1k | native->u.syment.n_type = T_NULL; | 1788 | 23.1k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 23.1k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 23.1k | coff_set_custom_section_alignment (abfd, section, | 1793 | 23.1k | coff_section_alignment_table, | 1794 | 23.1k | coff_section_alignment_table_size); | 1795 | | | 1796 | 23.1k | return true; | 1797 | 23.1k | } |
pe-sh.c:coff_new_section_hook Line | Count | Source | 1737 | 11.7k | { | 1738 | 11.7k | combined_entry_type *native; | 1739 | 11.7k | size_t amt; | 1740 | 11.7k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 11.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 | 11.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 | 11.7k | amt = sizeof (combined_entry_type) * 10; | 1776 | 11.7k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 11.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 | 11.7k | native->is_sym = true; | 1787 | 11.7k | native->u.syment.n_type = T_NULL; | 1788 | 11.7k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 11.7k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 11.7k | coff_set_custom_section_alignment (abfd, section, | 1793 | 11.7k | coff_section_alignment_table, | 1794 | 11.7k | coff_section_alignment_table_size); | 1795 | | | 1796 | 11.7k | return true; | 1797 | 11.7k | } |
pei-arm-wince.c:coff_new_section_hook Line | Count | Source | 1737 | 39.0k | { | 1738 | 39.0k | combined_entry_type *native; | 1739 | 39.0k | size_t amt; | 1740 | 39.0k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 39.0k | 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 | 39.0k | 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 | 39.0k | amt = sizeof (combined_entry_type) * 10; | 1776 | 39.0k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 39.0k | 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 | 39.0k | native->is_sym = true; | 1787 | 39.0k | native->u.syment.n_type = T_NULL; | 1788 | 39.0k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 39.0k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 39.0k | coff_set_custom_section_alignment (abfd, section, | 1793 | 39.0k | coff_section_alignment_table, | 1794 | 39.0k | coff_section_alignment_table_size); | 1795 | | | 1796 | 39.0k | return true; | 1797 | 39.0k | } |
pei-arm.c:coff_new_section_hook Line | Count | Source | 1737 | 481k | { | 1738 | 481k | combined_entry_type *native; | 1739 | 481k | size_t amt; | 1740 | 481k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 481k | 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 | 481k | 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 | 481k | amt = sizeof (combined_entry_type) * 10; | 1776 | 481k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 481k | 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 | 481k | native->is_sym = true; | 1787 | 481k | native->u.syment.n_type = T_NULL; | 1788 | 481k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 481k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 481k | coff_set_custom_section_alignment (abfd, section, | 1793 | 481k | coff_section_alignment_table, | 1794 | 481k | coff_section_alignment_table_size); | 1795 | | | 1796 | 481k | return true; | 1797 | 481k | } |
pei-mcore.c:coff_new_section_hook Line | Count | Source | 1737 | 60.9k | { | 1738 | 60.9k | combined_entry_type *native; | 1739 | 60.9k | size_t amt; | 1740 | 60.9k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 60.9k | 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 | 60.9k | 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 | 60.9k | amt = sizeof (combined_entry_type) * 10; | 1776 | 60.9k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 60.9k | 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 | 60.9k | native->is_sym = true; | 1787 | 60.9k | native->u.syment.n_type = T_NULL; | 1788 | 60.9k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 60.9k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 60.9k | coff_set_custom_section_alignment (abfd, section, | 1793 | 60.9k | coff_section_alignment_table, | 1794 | 60.9k | coff_section_alignment_table_size); | 1795 | | | 1796 | 60.9k | return true; | 1797 | 60.9k | } |
pei-sh.c:coff_new_section_hook Line | Count | Source | 1737 | 50.7k | { | 1738 | 50.7k | combined_entry_type *native; | 1739 | 50.7k | size_t amt; | 1740 | 50.7k | unsigned char sclass = C_STAT; | 1741 | | | 1742 | 50.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 | 50.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 | 50.7k | amt = sizeof (combined_entry_type) * 10; | 1776 | 50.7k | native = (combined_entry_type *) bfd_zalloc (abfd, amt); | 1777 | 50.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 | 50.7k | native->is_sym = true; | 1787 | 50.7k | native->u.syment.n_type = T_NULL; | 1788 | 50.7k | native->u.syment.n_sclass = sclass; | 1789 | | | 1790 | 50.7k | coffsymbol (section->symbol)->native = native; | 1791 | | | 1792 | 50.7k | coff_set_custom_section_alignment (abfd, section, | 1793 | 50.7k | coff_section_alignment_table, | 1794 | 50.7k | coff_section_alignment_table_size); | 1795 | | | 1796 | 50.7k | return true; | 1797 | 50.7k | } |
|
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 | 88.2k | { |
1808 | 88.2k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; |
1809 | 88.2k | unsigned int i; |
1810 | | |
1811 | 88.2k | #ifdef COFF_DECODE_ALIGNMENT |
1812 | 88.2k | i = COFF_DECODE_ALIGNMENT(hdr->s_flags); |
1813 | 88.2k | #endif |
1814 | 88.2k | section->alignment_power = i; |
1815 | | |
1816 | | #ifdef coff_set_section_load_page |
1817 | 7.88k | coff_set_section_load_page (section, hdr->s_page); |
1818 | | #endif |
1819 | 88.2k | } Unexecuted instantiation: coff-tic4x.c:coff_set_alignment_hook coff-tic54x.c:coff_set_alignment_hook Line | Count | Source | 1807 | 7.88k | { | 1808 | 7.88k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; | 1809 | 7.88k | unsigned int i; | 1810 | | | 1811 | 7.88k | #ifdef COFF_DECODE_ALIGNMENT | 1812 | 7.88k | i = COFF_DECODE_ALIGNMENT(hdr->s_flags); | 1813 | 7.88k | #endif | 1814 | 7.88k | section->alignment_power = i; | 1815 | | | 1816 | 7.88k | #ifdef coff_set_section_load_page | 1817 | 7.88k | coff_set_section_load_page (section, hdr->s_page); | 1818 | 7.88k | #endif | 1819 | 7.88k | } |
coff-z80.c:coff_set_alignment_hook Line | Count | Source | 1807 | 80.3k | { | 1808 | 80.3k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; | 1809 | 80.3k | unsigned int i; | 1810 | | | 1811 | 80.3k | #ifdef COFF_DECODE_ALIGNMENT | 1812 | 80.3k | i = COFF_DECODE_ALIGNMENT(hdr->s_flags); | 1813 | 80.3k | #endif | 1814 | 80.3k | 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 | 80.3k | } |
|
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 | 890k | { |
1829 | 890k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; |
1830 | 890k | size_t amt; |
1831 | 890k | unsigned int alignment_power_const |
1832 | 890k | = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK; |
1833 | | |
1834 | 890k | switch (alignment_power_const) |
1835 | 890k | { |
1836 | 5.91k | case IMAGE_SCN_ALIGN_8192BYTES: |
1837 | 6.99k | case IMAGE_SCN_ALIGN_4096BYTES: |
1838 | 9.12k | case IMAGE_SCN_ALIGN_2048BYTES: |
1839 | 11.6k | case IMAGE_SCN_ALIGN_1024BYTES: |
1840 | 14.4k | case IMAGE_SCN_ALIGN_512BYTES: |
1841 | 18.8k | case IMAGE_SCN_ALIGN_256BYTES: |
1842 | 24.6k | case IMAGE_SCN_ALIGN_128BYTES: |
1843 | 26.7k | case IMAGE_SCN_ALIGN_64BYTES: |
1844 | 38.5k | case IMAGE_SCN_ALIGN_32BYTES: |
1845 | 39.1k | case IMAGE_SCN_ALIGN_16BYTES: |
1846 | 56.6k | case IMAGE_SCN_ALIGN_8BYTES: |
1847 | 63.2k | case IMAGE_SCN_ALIGN_4BYTES: |
1848 | 68.4k | case IMAGE_SCN_ALIGN_2BYTES: |
1849 | 69.2k | case IMAGE_SCN_ALIGN_1BYTES: |
1850 | 69.2k | section->alignment_power |
1851 | 69.2k | = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const); |
1852 | 69.2k | break; |
1853 | 821k | default: |
1854 | 821k | break; |
1855 | 890k | } |
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 | 890k | if (coff_section_data (abfd, section) == NULL) |
1862 | 890k | { |
1863 | 890k | amt = sizeof (struct coff_section_tdata); |
1864 | 890k | section->used_by_bfd = bfd_zalloc (abfd, amt); |
1865 | 890k | if (section->used_by_bfd == NULL) |
1866 | | /* FIXME: Return error. */ |
1867 | 0 | abort (); |
1868 | 890k | } |
1869 | | |
1870 | 890k | if (pei_section_data (abfd, section) == NULL) |
1871 | 890k | { |
1872 | 890k | amt = sizeof (struct pei_section_tdata); |
1873 | 890k | coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt); |
1874 | 890k | if (coff_section_data (abfd, section)->tdata == NULL) |
1875 | | /* FIXME: Return error. */ |
1876 | 0 | abort (); |
1877 | 890k | } |
1878 | 890k | pei_section_data (abfd, section)->virt_size = hdr->s_paddr; |
1879 | 890k | pei_section_data (abfd, section)->pe_flags = hdr->s_flags; |
1880 | | |
1881 | 890k | section->lma = hdr->s_vaddr; |
1882 | | |
1883 | | /* Check for extended relocs. */ |
1884 | 890k | if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL) |
1885 | 47.4k | { |
1886 | 47.4k | struct external_reloc dst; |
1887 | 47.4k | struct internal_reloc n; |
1888 | 47.4k | file_ptr oldpos = bfd_tell (abfd); |
1889 | 47.4k | bfd_size_type relsz = bfd_coff_relsz (abfd); |
1890 | | |
1891 | 47.4k | if (bfd_seek (abfd, (file_ptr) hdr->s_relptr, 0) != 0) |
1892 | 0 | return; |
1893 | 47.4k | if (bfd_bread (& dst, relsz, abfd) != relsz) |
1894 | 16.4k | return; |
1895 | | |
1896 | 30.9k | bfd_coff_swap_reloc_in (abfd, &dst, &n); |
1897 | 30.9k | if (bfd_seek (abfd, oldpos, 0) != 0) |
1898 | 0 | return; |
1899 | 30.9k | if (n.r_vaddr < 0x10000) |
1900 | 14.0k | { |
1901 | 14.0k | _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd); |
1902 | 14.0k | bfd_set_error (bfd_error_bad_value); |
1903 | 14.0k | return; |
1904 | 14.0k | } |
1905 | 16.9k | section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1; |
1906 | 16.9k | section->rel_filepos += relsz; |
1907 | 16.9k | } |
1908 | 843k | else if (hdr->s_nreloc == 0xffff) |
1909 | 2.64k | _bfd_error_handler |
1910 | 2.64k | (_("%pB: warning: claims to have 0xffff relocs, without overflow"), |
1911 | 2.64k | abfd); |
1912 | 890k | } pei-i386.c:coff_set_alignment_hook Line | Count | Source | 1828 | 12.0k | { | 1829 | 12.0k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; | 1830 | 12.0k | size_t amt; | 1831 | 12.0k | unsigned int alignment_power_const | 1832 | 12.0k | = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK; | 1833 | | | 1834 | 12.0k | switch (alignment_power_const) | 1835 | 12.0k | { | 1836 | 214 | case IMAGE_SCN_ALIGN_8192BYTES: | 1837 | 218 | case IMAGE_SCN_ALIGN_4096BYTES: | 1838 | 220 | case IMAGE_SCN_ALIGN_2048BYTES: | 1839 | 716 | case IMAGE_SCN_ALIGN_1024BYTES: | 1840 | 724 | case IMAGE_SCN_ALIGN_512BYTES: | 1841 | 1.20k | case IMAGE_SCN_ALIGN_256BYTES: | 1842 | 1.20k | case IMAGE_SCN_ALIGN_128BYTES: | 1843 | 1.21k | case IMAGE_SCN_ALIGN_64BYTES: | 1844 | 1.23k | case IMAGE_SCN_ALIGN_32BYTES: | 1845 | 1.24k | case IMAGE_SCN_ALIGN_16BYTES: | 1846 | 1.28k | case IMAGE_SCN_ALIGN_8BYTES: | 1847 | 1.77k | case IMAGE_SCN_ALIGN_4BYTES: | 1848 | 1.80k | case IMAGE_SCN_ALIGN_2BYTES: | 1849 | 1.81k | case IMAGE_SCN_ALIGN_1BYTES: | 1850 | 1.81k | section->alignment_power | 1851 | 1.81k | = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const); | 1852 | 1.81k | break; | 1853 | 10.1k | default: | 1854 | 10.1k | break; | 1855 | 12.0k | } | 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 | 12.0k | if (coff_section_data (abfd, section) == NULL) | 1862 | 12.0k | { | 1863 | 12.0k | amt = sizeof (struct coff_section_tdata); | 1864 | 12.0k | section->used_by_bfd = bfd_zalloc (abfd, amt); | 1865 | 12.0k | if (section->used_by_bfd == NULL) | 1866 | | /* FIXME: Return error. */ | 1867 | 0 | abort (); | 1868 | 12.0k | } | 1869 | | | 1870 | 12.0k | if (pei_section_data (abfd, section) == NULL) | 1871 | 12.0k | { | 1872 | 12.0k | amt = sizeof (struct pei_section_tdata); | 1873 | 12.0k | coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt); | 1874 | 12.0k | if (coff_section_data (abfd, section)->tdata == NULL) | 1875 | | /* FIXME: Return error. */ | 1876 | 0 | abort (); | 1877 | 12.0k | } | 1878 | 12.0k | pei_section_data (abfd, section)->virt_size = hdr->s_paddr; | 1879 | 12.0k | pei_section_data (abfd, section)->pe_flags = hdr->s_flags; | 1880 | | | 1881 | 12.0k | section->lma = hdr->s_vaddr; | 1882 | | | 1883 | | /* Check for extended relocs. */ | 1884 | 12.0k | if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL) | 1885 | 1.54k | { | 1886 | 1.54k | struct external_reloc dst; | 1887 | 1.54k | struct internal_reloc n; | 1888 | 1.54k | file_ptr oldpos = bfd_tell (abfd); | 1889 | 1.54k | bfd_size_type relsz = bfd_coff_relsz (abfd); | 1890 | | | 1891 | 1.54k | if (bfd_seek (abfd, (file_ptr) hdr->s_relptr, 0) != 0) | 1892 | 0 | return; | 1893 | 1.54k | if (bfd_bread (& dst, relsz, abfd) != relsz) | 1894 | 552 | return; | 1895 | | | 1896 | 990 | bfd_coff_swap_reloc_in (abfd, &dst, &n); | 1897 | 990 | if (bfd_seek (abfd, oldpos, 0) != 0) | 1898 | 0 | return; | 1899 | 990 | if (n.r_vaddr < 0x10000) | 1900 | 504 | { | 1901 | 504 | _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd); | 1902 | 504 | bfd_set_error (bfd_error_bad_value); | 1903 | 504 | return; | 1904 | 504 | } | 1905 | 486 | section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1; | 1906 | 486 | section->rel_filepos += relsz; | 1907 | 486 | } | 1908 | 10.4k | 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 | 12.0k | } |
pe-x86_64.c:coff_set_alignment_hook Line | Count | Source | 1828 | 86.6k | { | 1829 | 86.6k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; | 1830 | 86.6k | size_t amt; | 1831 | 86.6k | unsigned int alignment_power_const | 1832 | 86.6k | = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK; | 1833 | | | 1834 | 86.6k | switch (alignment_power_const) | 1835 | 86.6k | { | 1836 | 66 | case IMAGE_SCN_ALIGN_8192BYTES: | 1837 | 66 | case IMAGE_SCN_ALIGN_4096BYTES: | 1838 | 72 | case IMAGE_SCN_ALIGN_2048BYTES: | 1839 | 80 | case IMAGE_SCN_ALIGN_1024BYTES: | 1840 | 88 | case IMAGE_SCN_ALIGN_512BYTES: | 1841 | 166 | case IMAGE_SCN_ALIGN_256BYTES: | 1842 | 528 | case IMAGE_SCN_ALIGN_128BYTES: | 1843 | 530 | case IMAGE_SCN_ALIGN_64BYTES: | 1844 | 562 | case IMAGE_SCN_ALIGN_32BYTES: | 1845 | 580 | case IMAGE_SCN_ALIGN_16BYTES: | 1846 | 13.8k | case IMAGE_SCN_ALIGN_8BYTES: | 1847 | 13.8k | case IMAGE_SCN_ALIGN_4BYTES: | 1848 | 13.9k | case IMAGE_SCN_ALIGN_2BYTES: | 1849 | 13.9k | case IMAGE_SCN_ALIGN_1BYTES: | 1850 | 13.9k | section->alignment_power | 1851 | 13.9k | = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const); | 1852 | 13.9k | break; | 1853 | 72.6k | default: | 1854 | 72.6k | break; | 1855 | 86.6k | } | 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 | 86.6k | if (coff_section_data (abfd, section) == NULL) | 1862 | 86.6k | { | 1863 | 86.6k | amt = sizeof (struct coff_section_tdata); | 1864 | 86.6k | section->used_by_bfd = bfd_zalloc (abfd, amt); | 1865 | 86.6k | if (section->used_by_bfd == NULL) | 1866 | | /* FIXME: Return error. */ | 1867 | 0 | abort (); | 1868 | 86.6k | } | 1869 | | | 1870 | 86.6k | if (pei_section_data (abfd, section) == NULL) | 1871 | 86.6k | { | 1872 | 86.6k | amt = sizeof (struct pei_section_tdata); | 1873 | 86.6k | coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt); | 1874 | 86.6k | if (coff_section_data (abfd, section)->tdata == NULL) | 1875 | | /* FIXME: Return error. */ | 1876 | 0 | abort (); | 1877 | 86.6k | } | 1878 | 86.6k | pei_section_data (abfd, section)->virt_size = hdr->s_paddr; | 1879 | 86.6k | pei_section_data (abfd, section)->pe_flags = hdr->s_flags; | 1880 | | | 1881 | 86.6k | section->lma = hdr->s_vaddr; | 1882 | | | 1883 | | /* Check for extended relocs. */ | 1884 | 86.6k | if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL) | 1885 | 160 | { | 1886 | 160 | struct external_reloc dst; | 1887 | 160 | struct internal_reloc n; | 1888 | 160 | file_ptr oldpos = bfd_tell (abfd); | 1889 | 160 | bfd_size_type relsz = bfd_coff_relsz (abfd); | 1890 | | | 1891 | 160 | if (bfd_seek (abfd, (file_ptr) hdr->s_relptr, 0) != 0) | 1892 | 0 | return; | 1893 | 160 | if (bfd_bread (& dst, relsz, abfd) != relsz) | 1894 | 98 | return; | 1895 | | | 1896 | 62 | bfd_coff_swap_reloc_in (abfd, &dst, &n); | 1897 | 62 | if (bfd_seek (abfd, oldpos, 0) != 0) | 1898 | 0 | return; | 1899 | 62 | 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 | 56 | section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1; | 1906 | 56 | section->rel_filepos += relsz; | 1907 | 56 | } | 1908 | 86.4k | else if (hdr->s_nreloc == 0xffff) | 1909 | 34 | _bfd_error_handler | 1910 | 34 | (_("%pB: warning: claims to have 0xffff relocs, without overflow"), | 1911 | 34 | abfd); | 1912 | 86.6k | } |
pei-x86_64.c:coff_set_alignment_hook Line | Count | Source | 1828 | 3.22k | { | 1829 | 3.22k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; | 1830 | 3.22k | size_t amt; | 1831 | 3.22k | unsigned int alignment_power_const | 1832 | 3.22k | = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK; | 1833 | | | 1834 | 3.22k | switch (alignment_power_const) | 1835 | 3.22k | { | 1836 | 536 | case IMAGE_SCN_ALIGN_8192BYTES: | 1837 | 536 | case IMAGE_SCN_ALIGN_4096BYTES: | 1838 | 546 | case IMAGE_SCN_ALIGN_2048BYTES: | 1839 | 556 | case IMAGE_SCN_ALIGN_1024BYTES: | 1840 | 566 | case IMAGE_SCN_ALIGN_512BYTES: | 1841 | 566 | case IMAGE_SCN_ALIGN_256BYTES: | 1842 | 570 | case IMAGE_SCN_ALIGN_128BYTES: | 1843 | 580 | case IMAGE_SCN_ALIGN_64BYTES: | 1844 | 590 | case IMAGE_SCN_ALIGN_32BYTES: | 1845 | 598 | case IMAGE_SCN_ALIGN_16BYTES: | 1846 | 640 | case IMAGE_SCN_ALIGN_8BYTES: | 1847 | 646 | case IMAGE_SCN_ALIGN_4BYTES: | 1848 | 854 | case IMAGE_SCN_ALIGN_2BYTES: | 1849 | 862 | case IMAGE_SCN_ALIGN_1BYTES: | 1850 | 862 | section->alignment_power | 1851 | 862 | = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const); | 1852 | 862 | break; | 1853 | 2.36k | default: | 1854 | 2.36k | break; | 1855 | 3.22k | } | 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.22k | if (coff_section_data (abfd, section) == NULL) | 1862 | 3.22k | { | 1863 | 3.22k | amt = sizeof (struct coff_section_tdata); | 1864 | 3.22k | section->used_by_bfd = bfd_zalloc (abfd, amt); | 1865 | 3.22k | if (section->used_by_bfd == NULL) | 1866 | | /* FIXME: Return error. */ | 1867 | 0 | abort (); | 1868 | 3.22k | } | 1869 | | | 1870 | 3.22k | if (pei_section_data (abfd, section) == NULL) | 1871 | 3.22k | { | 1872 | 3.22k | amt = sizeof (struct pei_section_tdata); | 1873 | 3.22k | coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt); | 1874 | 3.22k | if (coff_section_data (abfd, section)->tdata == NULL) | 1875 | | /* FIXME: Return error. */ | 1876 | 0 | abort (); | 1877 | 3.22k | } | 1878 | 3.22k | pei_section_data (abfd, section)->virt_size = hdr->s_paddr; | 1879 | 3.22k | pei_section_data (abfd, section)->pe_flags = hdr->s_flags; | 1880 | | | 1881 | 3.22k | section->lma = hdr->s_vaddr; | 1882 | | | 1883 | | /* Check for extended relocs. */ | 1884 | 3.22k | if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL) | 1885 | 294 | { | 1886 | 294 | struct external_reloc dst; | 1887 | 294 | struct internal_reloc n; | 1888 | 294 | file_ptr oldpos = bfd_tell (abfd); | 1889 | 294 | bfd_size_type relsz = bfd_coff_relsz (abfd); | 1890 | | | 1891 | 294 | if (bfd_seek (abfd, (file_ptr) hdr->s_relptr, 0) != 0) | 1892 | 0 | return; | 1893 | 294 | if (bfd_bread (& dst, relsz, abfd) != relsz) | 1894 | 110 | return; | 1895 | | | 1896 | 184 | bfd_coff_swap_reloc_in (abfd, &dst, &n); | 1897 | 184 | if (bfd_seek (abfd, oldpos, 0) != 0) | 1898 | 0 | return; | 1899 | 184 | if (n.r_vaddr < 0x10000) | 1900 | 10 | { | 1901 | 10 | _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd); | 1902 | 10 | bfd_set_error (bfd_error_bad_value); | 1903 | 10 | return; | 1904 | 10 | } | 1905 | 174 | section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1; | 1906 | 174 | section->rel_filepos += relsz; | 1907 | 174 | } | 1908 | 2.93k | 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.22k | } |
pei-aarch64.c:coff_set_alignment_hook Line | Count | Source | 1828 | 9.93k | { | 1829 | 9.93k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; | 1830 | 9.93k | size_t amt; | 1831 | 9.93k | unsigned int alignment_power_const | 1832 | 9.93k | = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK; | 1833 | | | 1834 | 9.93k | switch (alignment_power_const) | 1835 | 9.93k | { | 1836 | 10 | case IMAGE_SCN_ALIGN_8192BYTES: | 1837 | 14 | case IMAGE_SCN_ALIGN_4096BYTES: | 1838 | 20 | case IMAGE_SCN_ALIGN_2048BYTES: | 1839 | 24 | case IMAGE_SCN_ALIGN_1024BYTES: | 1840 | 86 | case IMAGE_SCN_ALIGN_512BYTES: | 1841 | 88 | case IMAGE_SCN_ALIGN_256BYTES: | 1842 | 576 | case IMAGE_SCN_ALIGN_128BYTES: | 1843 | 588 | case IMAGE_SCN_ALIGN_64BYTES: | 1844 | 1.07k | case IMAGE_SCN_ALIGN_32BYTES: | 1845 | 1.07k | case IMAGE_SCN_ALIGN_16BYTES: | 1846 | 1.69k | case IMAGE_SCN_ALIGN_8BYTES: | 1847 | 2.17k | case IMAGE_SCN_ALIGN_4BYTES: | 1848 | 3.32k | case IMAGE_SCN_ALIGN_2BYTES: | 1849 | 3.34k | case IMAGE_SCN_ALIGN_1BYTES: | 1850 | 3.34k | section->alignment_power | 1851 | 3.34k | = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const); | 1852 | 3.34k | break; | 1853 | 6.59k | default: | 1854 | 6.59k | break; | 1855 | 9.93k | } | 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 | 9.93k | if (coff_section_data (abfd, section) == NULL) | 1862 | 9.93k | { | 1863 | 9.93k | amt = sizeof (struct coff_section_tdata); | 1864 | 9.93k | section->used_by_bfd = bfd_zalloc (abfd, amt); | 1865 | 9.93k | if (section->used_by_bfd == NULL) | 1866 | | /* FIXME: Return error. */ | 1867 | 0 | abort (); | 1868 | 9.93k | } | 1869 | | | 1870 | 9.93k | if (pei_section_data (abfd, section) == NULL) | 1871 | 9.93k | { | 1872 | 9.93k | amt = sizeof (struct pei_section_tdata); | 1873 | 9.93k | coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt); | 1874 | 9.93k | if (coff_section_data (abfd, section)->tdata == NULL) | 1875 | | /* FIXME: Return error. */ | 1876 | 0 | abort (); | 1877 | 9.93k | } | 1878 | 9.93k | pei_section_data (abfd, section)->virt_size = hdr->s_paddr; | 1879 | 9.93k | pei_section_data (abfd, section)->pe_flags = hdr->s_flags; | 1880 | | | 1881 | 9.93k | section->lma = hdr->s_vaddr; | 1882 | | | 1883 | | /* Check for extended relocs. */ | 1884 | 9.93k | if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL) | 1885 | 1.68k | { | 1886 | 1.68k | struct external_reloc dst; | 1887 | 1.68k | struct internal_reloc n; | 1888 | 1.68k | file_ptr oldpos = bfd_tell (abfd); | 1889 | 1.68k | bfd_size_type relsz = bfd_coff_relsz (abfd); | 1890 | | | 1891 | 1.68k | if (bfd_seek (abfd, (file_ptr) hdr->s_relptr, 0) != 0) | 1892 | 0 | return; | 1893 | 1.68k | if (bfd_bread (& dst, relsz, abfd) != relsz) | 1894 | 1.11k | return; | 1895 | | | 1896 | 576 | bfd_coff_swap_reloc_in (abfd, &dst, &n); | 1897 | 576 | if (bfd_seek (abfd, oldpos, 0) != 0) | 1898 | 0 | return; | 1899 | 576 | if (n.r_vaddr < 0x10000) | 1900 | 46 | { | 1901 | 46 | _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd); | 1902 | 46 | bfd_set_error (bfd_error_bad_value); | 1903 | 46 | return; | 1904 | 46 | } | 1905 | 530 | section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1; | 1906 | 530 | section->rel_filepos += relsz; | 1907 | 530 | } | 1908 | 8.25k | 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 | 9.93k | } |
pe-aarch64.c:coff_set_alignment_hook Line | Count | Source | 1828 | 4.02k | { | 1829 | 4.02k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; | 1830 | 4.02k | size_t amt; | 1831 | 4.02k | unsigned int alignment_power_const | 1832 | 4.02k | = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK; | 1833 | | | 1834 | 4.02k | switch (alignment_power_const) | 1835 | 4.02k | { | 1836 | 24 | case IMAGE_SCN_ALIGN_8192BYTES: | 1837 | 34 | case IMAGE_SCN_ALIGN_4096BYTES: | 1838 | 74 | case IMAGE_SCN_ALIGN_2048BYTES: | 1839 | 78 | case IMAGE_SCN_ALIGN_1024BYTES: | 1840 | 206 | case IMAGE_SCN_ALIGN_512BYTES: | 1841 | 210 | case IMAGE_SCN_ALIGN_256BYTES: | 1842 | 210 | case IMAGE_SCN_ALIGN_128BYTES: | 1843 | 216 | case IMAGE_SCN_ALIGN_64BYTES: | 1844 | 380 | case IMAGE_SCN_ALIGN_32BYTES: | 1845 | 384 | case IMAGE_SCN_ALIGN_16BYTES: | 1846 | 462 | case IMAGE_SCN_ALIGN_8BYTES: | 1847 | 478 | case IMAGE_SCN_ALIGN_4BYTES: | 1848 | 584 | case IMAGE_SCN_ALIGN_2BYTES: | 1849 | 636 | case IMAGE_SCN_ALIGN_1BYTES: | 1850 | 636 | section->alignment_power | 1851 | 636 | = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const); | 1852 | 636 | break; | 1853 | 3.38k | default: | 1854 | 3.38k | break; | 1855 | 4.02k | } | 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 | 4.02k | if (coff_section_data (abfd, section) == NULL) | 1862 | 4.02k | { | 1863 | 4.02k | amt = sizeof (struct coff_section_tdata); | 1864 | 4.02k | section->used_by_bfd = bfd_zalloc (abfd, amt); | 1865 | 4.02k | if (section->used_by_bfd == NULL) | 1866 | | /* FIXME: Return error. */ | 1867 | 0 | abort (); | 1868 | 4.02k | } | 1869 | | | 1870 | 4.02k | if (pei_section_data (abfd, section) == NULL) | 1871 | 4.02k | { | 1872 | 4.02k | amt = sizeof (struct pei_section_tdata); | 1873 | 4.02k | coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt); | 1874 | 4.02k | if (coff_section_data (abfd, section)->tdata == NULL) | 1875 | | /* FIXME: Return error. */ | 1876 | 0 | abort (); | 1877 | 4.02k | } | 1878 | 4.02k | pei_section_data (abfd, section)->virt_size = hdr->s_paddr; | 1879 | 4.02k | pei_section_data (abfd, section)->pe_flags = hdr->s_flags; | 1880 | | | 1881 | 4.02k | section->lma = hdr->s_vaddr; | 1882 | | | 1883 | | /* Check for extended relocs. */ | 1884 | 4.02k | if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL) | 1885 | 280 | { | 1886 | 280 | struct external_reloc dst; | 1887 | 280 | struct internal_reloc n; | 1888 | 280 | file_ptr oldpos = bfd_tell (abfd); | 1889 | 280 | bfd_size_type relsz = bfd_coff_relsz (abfd); | 1890 | | | 1891 | 280 | if (bfd_seek (abfd, (file_ptr) hdr->s_relptr, 0) != 0) | 1892 | 0 | return; | 1893 | 280 | if (bfd_bread (& dst, relsz, abfd) != relsz) | 1894 | 168 | return; | 1895 | | | 1896 | 112 | bfd_coff_swap_reloc_in (abfd, &dst, &n); | 1897 | 112 | if (bfd_seek (abfd, oldpos, 0) != 0) | 1898 | 0 | return; | 1899 | 112 | 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 | 50 | section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1; | 1906 | 50 | section->rel_filepos += relsz; | 1907 | 50 | } | 1908 | 3.74k | else if (hdr->s_nreloc == 0xffff) | 1909 | 22 | _bfd_error_handler | 1910 | 22 | (_("%pB: warning: claims to have 0xffff relocs, without overflow"), | 1911 | 22 | abfd); | 1912 | 4.02k | } |
pei-ia64.c:coff_set_alignment_hook Line | Count | Source | 1828 | 97.0k | { | 1829 | 97.0k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; | 1830 | 97.0k | size_t amt; | 1831 | 97.0k | unsigned int alignment_power_const | 1832 | 97.0k | = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK; | 1833 | | | 1834 | 97.0k | switch (alignment_power_const) | 1835 | 97.0k | { | 1836 | 490 | case IMAGE_SCN_ALIGN_8192BYTES: | 1837 | 490 | case IMAGE_SCN_ALIGN_4096BYTES: | 1838 | 512 | case IMAGE_SCN_ALIGN_2048BYTES: | 1839 | 1.00k | case IMAGE_SCN_ALIGN_1024BYTES: | 1840 | 1.96k | case IMAGE_SCN_ALIGN_512BYTES: | 1841 | 1.97k | case IMAGE_SCN_ALIGN_256BYTES: | 1842 | 6.38k | case IMAGE_SCN_ALIGN_128BYTES: | 1843 | 6.38k | case IMAGE_SCN_ALIGN_64BYTES: | 1844 | 7.36k | case IMAGE_SCN_ALIGN_32BYTES: | 1845 | 7.36k | case IMAGE_SCN_ALIGN_16BYTES: | 1846 | 7.84k | case IMAGE_SCN_ALIGN_8BYTES: | 1847 | 9.32k | case IMAGE_SCN_ALIGN_4BYTES: | 1848 | 10.3k | case IMAGE_SCN_ALIGN_2BYTES: | 1849 | 10.3k | case IMAGE_SCN_ALIGN_1BYTES: | 1850 | 10.3k | section->alignment_power | 1851 | 10.3k | = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const); | 1852 | 10.3k | break; | 1853 | 86.6k | default: | 1854 | 86.6k | break; | 1855 | 97.0k | } | 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 | 97.0k | if (coff_section_data (abfd, section) == NULL) | 1862 | 97.0k | { | 1863 | 97.0k | amt = sizeof (struct coff_section_tdata); | 1864 | 97.0k | section->used_by_bfd = bfd_zalloc (abfd, amt); | 1865 | 97.0k | if (section->used_by_bfd == NULL) | 1866 | | /* FIXME: Return error. */ | 1867 | 0 | abort (); | 1868 | 97.0k | } | 1869 | | | 1870 | 97.0k | if (pei_section_data (abfd, section) == NULL) | 1871 | 97.0k | { | 1872 | 97.0k | amt = sizeof (struct pei_section_tdata); | 1873 | 97.0k | coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt); | 1874 | 97.0k | if (coff_section_data (abfd, section)->tdata == NULL) | 1875 | | /* FIXME: Return error. */ | 1876 | 0 | abort (); | 1877 | 97.0k | } | 1878 | 97.0k | pei_section_data (abfd, section)->virt_size = hdr->s_paddr; | 1879 | 97.0k | pei_section_data (abfd, section)->pe_flags = hdr->s_flags; | 1880 | | | 1881 | 97.0k | section->lma = hdr->s_vaddr; | 1882 | | | 1883 | | /* Check for extended relocs. */ | 1884 | 97.0k | if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL) | 1885 | 10.7k | { | 1886 | 10.7k | struct external_reloc dst; | 1887 | 10.7k | struct internal_reloc n; | 1888 | 10.7k | file_ptr oldpos = bfd_tell (abfd); | 1889 | 10.7k | bfd_size_type relsz = bfd_coff_relsz (abfd); | 1890 | | | 1891 | 10.7k | if (bfd_seek (abfd, (file_ptr) hdr->s_relptr, 0) != 0) | 1892 | 0 | return; | 1893 | 10.7k | if (bfd_bread (& dst, relsz, abfd) != relsz) | 1894 | 3.94k | return; | 1895 | | | 1896 | 6.85k | bfd_coff_swap_reloc_in (abfd, &dst, &n); | 1897 | 6.85k | if (bfd_seek (abfd, oldpos, 0) != 0) | 1898 | 0 | return; | 1899 | 6.85k | if (n.r_vaddr < 0x10000) | 1900 | 5.36k | { | 1901 | 5.36k | _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd); | 1902 | 5.36k | bfd_set_error (bfd_error_bad_value); | 1903 | 5.36k | return; | 1904 | 5.36k | } | 1905 | 1.48k | section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1; | 1906 | 1.48k | section->rel_filepos += relsz; | 1907 | 1.48k | } | 1908 | 86.2k | 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 | 97.0k | } |
pei-loongarch64.c:coff_set_alignment_hook Line | Count | Source | 1828 | 2.07k | { | 1829 | 2.07k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; | 1830 | 2.07k | size_t amt; | 1831 | 2.07k | unsigned int alignment_power_const | 1832 | 2.07k | = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK; | 1833 | | | 1834 | 2.07k | switch (alignment_power_const) | 1835 | 2.07k | { | 1836 | 20 | case IMAGE_SCN_ALIGN_8192BYTES: | 1837 | 24 | case IMAGE_SCN_ALIGN_4096BYTES: | 1838 | 98 | case IMAGE_SCN_ALIGN_2048BYTES: | 1839 | 102 | case IMAGE_SCN_ALIGN_1024BYTES: | 1840 | 104 | case IMAGE_SCN_ALIGN_512BYTES: | 1841 | 104 | case IMAGE_SCN_ALIGN_256BYTES: | 1842 | 182 | case IMAGE_SCN_ALIGN_128BYTES: | 1843 | 184 | case IMAGE_SCN_ALIGN_64BYTES: | 1844 | 216 | case IMAGE_SCN_ALIGN_32BYTES: | 1845 | 218 | case IMAGE_SCN_ALIGN_16BYTES: | 1846 | 422 | case IMAGE_SCN_ALIGN_8BYTES: | 1847 | 428 | case IMAGE_SCN_ALIGN_4BYTES: | 1848 | 554 | case IMAGE_SCN_ALIGN_2BYTES: | 1849 | 562 | case IMAGE_SCN_ALIGN_1BYTES: | 1850 | 562 | section->alignment_power | 1851 | 562 | = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const); | 1852 | 562 | break; | 1853 | 1.51k | default: | 1854 | 1.51k | break; | 1855 | 2.07k | } | 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.07k | if (coff_section_data (abfd, section) == NULL) | 1862 | 2.07k | { | 1863 | 2.07k | amt = sizeof (struct coff_section_tdata); | 1864 | 2.07k | section->used_by_bfd = bfd_zalloc (abfd, amt); | 1865 | 2.07k | if (section->used_by_bfd == NULL) | 1866 | | /* FIXME: Return error. */ | 1867 | 0 | abort (); | 1868 | 2.07k | } | 1869 | | | 1870 | 2.07k | if (pei_section_data (abfd, section) == NULL) | 1871 | 2.07k | { | 1872 | 2.07k | amt = sizeof (struct pei_section_tdata); | 1873 | 2.07k | coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt); | 1874 | 2.07k | if (coff_section_data (abfd, section)->tdata == NULL) | 1875 | | /* FIXME: Return error. */ | 1876 | 0 | abort (); | 1877 | 2.07k | } | 1878 | 2.07k | pei_section_data (abfd, section)->virt_size = hdr->s_paddr; | 1879 | 2.07k | pei_section_data (abfd, section)->pe_flags = hdr->s_flags; | 1880 | | | 1881 | 2.07k | section->lma = hdr->s_vaddr; | 1882 | | | 1883 | | /* Check for extended relocs. */ | 1884 | 2.07k | if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL) | 1885 | 156 | { | 1886 | 156 | struct external_reloc dst; | 1887 | 156 | struct internal_reloc n; | 1888 | 156 | file_ptr oldpos = bfd_tell (abfd); | 1889 | 156 | bfd_size_type relsz = bfd_coff_relsz (abfd); | 1890 | | | 1891 | 156 | if (bfd_seek (abfd, (file_ptr) hdr->s_relptr, 0) != 0) | 1892 | 0 | return; | 1893 | 156 | if (bfd_bread (& dst, relsz, abfd) != relsz) | 1894 | 48 | return; | 1895 | | | 1896 | 108 | bfd_coff_swap_reloc_in (abfd, &dst, &n); | 1897 | 108 | if (bfd_seek (abfd, oldpos, 0) != 0) | 1898 | 0 | return; | 1899 | 108 | 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 | 88 | section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1; | 1906 | 88 | section->rel_filepos += relsz; | 1907 | 88 | } | 1908 | 1.91k | 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.07k | } |
pe-arm-wince.c:coff_set_alignment_hook Line | Count | Source | 1828 | 2.71k | { | 1829 | 2.71k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; | 1830 | 2.71k | size_t amt; | 1831 | 2.71k | unsigned int alignment_power_const | 1832 | 2.71k | = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK; | 1833 | | | 1834 | 2.71k | switch (alignment_power_const) | 1835 | 2.71k | { | 1836 | 534 | case IMAGE_SCN_ALIGN_8192BYTES: | 1837 | 558 | case IMAGE_SCN_ALIGN_4096BYTES: | 1838 | 600 | case IMAGE_SCN_ALIGN_2048BYTES: | 1839 | 602 | case IMAGE_SCN_ALIGN_1024BYTES: | 1840 | 622 | case IMAGE_SCN_ALIGN_512BYTES: | 1841 | 630 | case IMAGE_SCN_ALIGN_256BYTES: | 1842 | 700 | case IMAGE_SCN_ALIGN_128BYTES: | 1843 | 708 | case IMAGE_SCN_ALIGN_64BYTES: | 1844 | 760 | case IMAGE_SCN_ALIGN_32BYTES: | 1845 | 768 | case IMAGE_SCN_ALIGN_16BYTES: | 1846 | 772 | case IMAGE_SCN_ALIGN_8BYTES: | 1847 | 794 | case IMAGE_SCN_ALIGN_4BYTES: | 1848 | 1.03k | case IMAGE_SCN_ALIGN_2BYTES: | 1849 | 1.05k | case IMAGE_SCN_ALIGN_1BYTES: | 1850 | 1.05k | section->alignment_power | 1851 | 1.05k | = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const); | 1852 | 1.05k | break; | 1853 | 1.66k | default: | 1854 | 1.66k | break; | 1855 | 2.71k | } | 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.71k | if (coff_section_data (abfd, section) == NULL) | 1862 | 2.71k | { | 1863 | 2.71k | amt = sizeof (struct coff_section_tdata); | 1864 | 2.71k | section->used_by_bfd = bfd_zalloc (abfd, amt); | 1865 | 2.71k | if (section->used_by_bfd == NULL) | 1866 | | /* FIXME: Return error. */ | 1867 | 0 | abort (); | 1868 | 2.71k | } | 1869 | | | 1870 | 2.71k | if (pei_section_data (abfd, section) == NULL) | 1871 | 2.71k | { | 1872 | 2.71k | amt = sizeof (struct pei_section_tdata); | 1873 | 2.71k | coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt); | 1874 | 2.71k | if (coff_section_data (abfd, section)->tdata == NULL) | 1875 | | /* FIXME: Return error. */ | 1876 | 0 | abort (); | 1877 | 2.71k | } | 1878 | 2.71k | pei_section_data (abfd, section)->virt_size = hdr->s_paddr; | 1879 | 2.71k | pei_section_data (abfd, section)->pe_flags = hdr->s_flags; | 1880 | | | 1881 | 2.71k | section->lma = hdr->s_vaddr; | 1882 | | | 1883 | | /* Check for extended relocs. */ | 1884 | 2.71k | if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL) | 1885 | 286 | { | 1886 | 286 | struct external_reloc dst; | 1887 | 286 | struct internal_reloc n; | 1888 | 286 | file_ptr oldpos = bfd_tell (abfd); | 1889 | 286 | bfd_size_type relsz = bfd_coff_relsz (abfd); | 1890 | | | 1891 | 286 | if (bfd_seek (abfd, (file_ptr) hdr->s_relptr, 0) != 0) | 1892 | 0 | return; | 1893 | 286 | if (bfd_bread (& dst, relsz, abfd) != relsz) | 1894 | 160 | return; | 1895 | | | 1896 | 126 | bfd_coff_swap_reloc_in (abfd, &dst, &n); | 1897 | 126 | if (bfd_seek (abfd, oldpos, 0) != 0) | 1898 | 0 | return; | 1899 | 126 | 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 | 90 | section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1; | 1906 | 90 | section->rel_filepos += relsz; | 1907 | 90 | } | 1908 | 2.43k | else if (hdr->s_nreloc == 0xffff) | 1909 | 26 | _bfd_error_handler | 1910 | 26 | (_("%pB: warning: claims to have 0xffff relocs, without overflow"), | 1911 | 26 | abfd); | 1912 | 2.71k | } |
pe-arm.c:coff_set_alignment_hook Line | Count | Source | 1828 | 2.71k | { | 1829 | 2.71k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; | 1830 | 2.71k | size_t amt; | 1831 | 2.71k | unsigned int alignment_power_const | 1832 | 2.71k | = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK; | 1833 | | | 1834 | 2.71k | switch (alignment_power_const) | 1835 | 2.71k | { | 1836 | 534 | case IMAGE_SCN_ALIGN_8192BYTES: | 1837 | 558 | case IMAGE_SCN_ALIGN_4096BYTES: | 1838 | 600 | case IMAGE_SCN_ALIGN_2048BYTES: | 1839 | 602 | case IMAGE_SCN_ALIGN_1024BYTES: | 1840 | 622 | case IMAGE_SCN_ALIGN_512BYTES: | 1841 | 630 | case IMAGE_SCN_ALIGN_256BYTES: | 1842 | 700 | case IMAGE_SCN_ALIGN_128BYTES: | 1843 | 708 | case IMAGE_SCN_ALIGN_64BYTES: | 1844 | 760 | case IMAGE_SCN_ALIGN_32BYTES: | 1845 | 768 | case IMAGE_SCN_ALIGN_16BYTES: | 1846 | 772 | case IMAGE_SCN_ALIGN_8BYTES: | 1847 | 794 | case IMAGE_SCN_ALIGN_4BYTES: | 1848 | 1.03k | case IMAGE_SCN_ALIGN_2BYTES: | 1849 | 1.05k | case IMAGE_SCN_ALIGN_1BYTES: | 1850 | 1.05k | section->alignment_power | 1851 | 1.05k | = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const); | 1852 | 1.05k | break; | 1853 | 1.66k | default: | 1854 | 1.66k | break; | 1855 | 2.71k | } | 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.71k | if (coff_section_data (abfd, section) == NULL) | 1862 | 2.71k | { | 1863 | 2.71k | amt = sizeof (struct coff_section_tdata); | 1864 | 2.71k | section->used_by_bfd = bfd_zalloc (abfd, amt); | 1865 | 2.71k | if (section->used_by_bfd == NULL) | 1866 | | /* FIXME: Return error. */ | 1867 | 0 | abort (); | 1868 | 2.71k | } | 1869 | | | 1870 | 2.71k | if (pei_section_data (abfd, section) == NULL) | 1871 | 2.71k | { | 1872 | 2.71k | amt = sizeof (struct pei_section_tdata); | 1873 | 2.71k | coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt); | 1874 | 2.71k | if (coff_section_data (abfd, section)->tdata == NULL) | 1875 | | /* FIXME: Return error. */ | 1876 | 0 | abort (); | 1877 | 2.71k | } | 1878 | 2.71k | pei_section_data (abfd, section)->virt_size = hdr->s_paddr; | 1879 | 2.71k | pei_section_data (abfd, section)->pe_flags = hdr->s_flags; | 1880 | | | 1881 | 2.71k | section->lma = hdr->s_vaddr; | 1882 | | | 1883 | | /* Check for extended relocs. */ | 1884 | 2.71k | if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL) | 1885 | 286 | { | 1886 | 286 | struct external_reloc dst; | 1887 | 286 | struct internal_reloc n; | 1888 | 286 | file_ptr oldpos = bfd_tell (abfd); | 1889 | 286 | bfd_size_type relsz = bfd_coff_relsz (abfd); | 1890 | | | 1891 | 286 | if (bfd_seek (abfd, (file_ptr) hdr->s_relptr, 0) != 0) | 1892 | 0 | return; | 1893 | 286 | if (bfd_bread (& dst, relsz, abfd) != relsz) | 1894 | 160 | return; | 1895 | | | 1896 | 126 | bfd_coff_swap_reloc_in (abfd, &dst, &n); | 1897 | 126 | if (bfd_seek (abfd, oldpos, 0) != 0) | 1898 | 0 | return; | 1899 | 126 | 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 | 90 | section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1; | 1906 | 90 | section->rel_filepos += relsz; | 1907 | 90 | } | 1908 | 2.43k | else if (hdr->s_nreloc == 0xffff) | 1909 | 26 | _bfd_error_handler | 1910 | 26 | (_("%pB: warning: claims to have 0xffff relocs, without overflow"), | 1911 | 26 | abfd); | 1912 | 2.71k | } |
pe-i386.c:coff_set_alignment_hook Line | Count | Source | 1828 | 3.95k | { | 1829 | 3.95k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; | 1830 | 3.95k | size_t amt; | 1831 | 3.95k | unsigned int alignment_power_const | 1832 | 3.95k | = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK; | 1833 | | | 1834 | 3.95k | switch (alignment_power_const) | 1835 | 3.95k | { | 1836 | 396 | case IMAGE_SCN_ALIGN_8192BYTES: | 1837 | 400 | case IMAGE_SCN_ALIGN_4096BYTES: | 1838 | 412 | case IMAGE_SCN_ALIGN_2048BYTES: | 1839 | 418 | case IMAGE_SCN_ALIGN_1024BYTES: | 1840 | 452 | case IMAGE_SCN_ALIGN_512BYTES: | 1841 | 456 | case IMAGE_SCN_ALIGN_256BYTES: | 1842 | 492 | case IMAGE_SCN_ALIGN_128BYTES: | 1843 | 508 | case IMAGE_SCN_ALIGN_64BYTES: | 1844 | 534 | case IMAGE_SCN_ALIGN_32BYTES: | 1845 | 572 | case IMAGE_SCN_ALIGN_16BYTES: | 1846 | 620 | case IMAGE_SCN_ALIGN_8BYTES: | 1847 | 646 | case IMAGE_SCN_ALIGN_4BYTES: | 1848 | 726 | case IMAGE_SCN_ALIGN_2BYTES: | 1849 | 768 | case IMAGE_SCN_ALIGN_1BYTES: | 1850 | 768 | section->alignment_power | 1851 | 768 | = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const); | 1852 | 768 | break; | 1853 | 3.18k | default: | 1854 | 3.18k | break; | 1855 | 3.95k | } | 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.95k | if (coff_section_data (abfd, section) == NULL) | 1862 | 3.95k | { | 1863 | 3.95k | amt = sizeof (struct coff_section_tdata); | 1864 | 3.95k | section->used_by_bfd = bfd_zalloc (abfd, amt); | 1865 | 3.95k | if (section->used_by_bfd == NULL) | 1866 | | /* FIXME: Return error. */ | 1867 | 0 | abort (); | 1868 | 3.95k | } | 1869 | | | 1870 | 3.95k | if (pei_section_data (abfd, section) == NULL) | 1871 | 3.95k | { | 1872 | 3.95k | amt = sizeof (struct pei_section_tdata); | 1873 | 3.95k | coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt); | 1874 | 3.95k | if (coff_section_data (abfd, section)->tdata == NULL) | 1875 | | /* FIXME: Return error. */ | 1876 | 0 | abort (); | 1877 | 3.95k | } | 1878 | 3.95k | pei_section_data (abfd, section)->virt_size = hdr->s_paddr; | 1879 | 3.95k | pei_section_data (abfd, section)->pe_flags = hdr->s_flags; | 1880 | | | 1881 | 3.95k | section->lma = hdr->s_vaddr; | 1882 | | | 1883 | | /* Check for extended relocs. */ | 1884 | 3.95k | if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL) | 1885 | 276 | { | 1886 | 276 | struct external_reloc dst; | 1887 | 276 | struct internal_reloc n; | 1888 | 276 | file_ptr oldpos = bfd_tell (abfd); | 1889 | 276 | bfd_size_type relsz = bfd_coff_relsz (abfd); | 1890 | | | 1891 | 276 | if (bfd_seek (abfd, (file_ptr) hdr->s_relptr, 0) != 0) | 1892 | 0 | return; | 1893 | 276 | if (bfd_bread (& dst, relsz, abfd) != relsz) | 1894 | 208 | 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 | 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 | 54 | section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1; | 1906 | 54 | section->rel_filepos += relsz; | 1907 | 54 | } | 1908 | 3.67k | else if (hdr->s_nreloc == 0xffff) | 1909 | 44 | _bfd_error_handler | 1910 | 44 | (_("%pB: warning: claims to have 0xffff relocs, without overflow"), | 1911 | 44 | abfd); | 1912 | 3.95k | } |
pe-mcore.c:coff_set_alignment_hook Line | Count | Source | 1828 | 23.1k | { | 1829 | 23.1k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; | 1830 | 23.1k | size_t amt; | 1831 | 23.1k | unsigned int alignment_power_const | 1832 | 23.1k | = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK; | 1833 | | | 1834 | 23.1k | switch (alignment_power_const) | 1835 | 23.1k | { | 1836 | 1.78k | case IMAGE_SCN_ALIGN_8192BYTES: | 1837 | 1.79k | case IMAGE_SCN_ALIGN_4096BYTES: | 1838 | 1.81k | case IMAGE_SCN_ALIGN_2048BYTES: | 1839 | 1.83k | case IMAGE_SCN_ALIGN_1024BYTES: | 1840 | 1.84k | case IMAGE_SCN_ALIGN_512BYTES: | 1841 | 1.85k | case IMAGE_SCN_ALIGN_256BYTES: | 1842 | 1.90k | case IMAGE_SCN_ALIGN_128BYTES: | 1843 | 1.92k | case IMAGE_SCN_ALIGN_64BYTES: | 1844 | 1.95k | case IMAGE_SCN_ALIGN_32BYTES: | 1845 | 1.95k | case IMAGE_SCN_ALIGN_16BYTES: | 1846 | 3.47k | case IMAGE_SCN_ALIGN_8BYTES: | 1847 | 3.48k | case IMAGE_SCN_ALIGN_4BYTES: | 1848 | 4.18k | case IMAGE_SCN_ALIGN_2BYTES: | 1849 | 4.20k | case IMAGE_SCN_ALIGN_1BYTES: | 1850 | 4.20k | section->alignment_power | 1851 | 4.20k | = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const); | 1852 | 4.20k | break; | 1853 | 18.9k | default: | 1854 | 18.9k | break; | 1855 | 23.1k | } | 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 | 23.1k | if (coff_section_data (abfd, section) == NULL) | 1862 | 23.1k | { | 1863 | 23.1k | amt = sizeof (struct coff_section_tdata); | 1864 | 23.1k | section->used_by_bfd = bfd_zalloc (abfd, amt); | 1865 | 23.1k | if (section->used_by_bfd == NULL) | 1866 | | /* FIXME: Return error. */ | 1867 | 0 | abort (); | 1868 | 23.1k | } | 1869 | | | 1870 | 23.1k | if (pei_section_data (abfd, section) == NULL) | 1871 | 23.1k | { | 1872 | 23.1k | amt = sizeof (struct pei_section_tdata); | 1873 | 23.1k | coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt); | 1874 | 23.1k | if (coff_section_data (abfd, section)->tdata == NULL) | 1875 | | /* FIXME: Return error. */ | 1876 | 0 | abort (); | 1877 | 23.1k | } | 1878 | 23.1k | pei_section_data (abfd, section)->virt_size = hdr->s_paddr; | 1879 | 23.1k | pei_section_data (abfd, section)->pe_flags = hdr->s_flags; | 1880 | | | 1881 | 23.1k | section->lma = hdr->s_vaddr; | 1882 | | | 1883 | | /* Check for extended relocs. */ | 1884 | 23.1k | if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL) | 1885 | 2.12k | { | 1886 | 2.12k | struct external_reloc dst; | 1887 | 2.12k | struct internal_reloc n; | 1888 | 2.12k | file_ptr oldpos = bfd_tell (abfd); | 1889 | 2.12k | bfd_size_type relsz = bfd_coff_relsz (abfd); | 1890 | | | 1891 | 2.12k | if (bfd_seek (abfd, (file_ptr) hdr->s_relptr, 0) != 0) | 1892 | 0 | return; | 1893 | 2.12k | if (bfd_bread (& dst, relsz, abfd) != relsz) | 1894 | 584 | return; | 1895 | | | 1896 | 1.54k | bfd_coff_swap_reloc_in (abfd, &dst, &n); | 1897 | 1.54k | if (bfd_seek (abfd, oldpos, 0) != 0) | 1898 | 0 | return; | 1899 | 1.54k | if (n.r_vaddr < 0x10000) | 1900 | 494 | { | 1901 | 494 | _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd); | 1902 | 494 | bfd_set_error (bfd_error_bad_value); | 1903 | 494 | return; | 1904 | 494 | } | 1905 | 1.04k | section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1; | 1906 | 1.04k | section->rel_filepos += relsz; | 1907 | 1.04k | } | 1908 | 21.0k | else if (hdr->s_nreloc == 0xffff) | 1909 | 1.99k | _bfd_error_handler | 1910 | 1.99k | (_("%pB: warning: claims to have 0xffff relocs, without overflow"), | 1911 | 1.99k | abfd); | 1912 | 23.1k | } |
pe-sh.c:coff_set_alignment_hook Line | Count | Source | 1828 | 11.7k | { | 1829 | 11.7k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; | 1830 | 11.7k | size_t amt; | 1831 | 11.7k | unsigned int alignment_power_const | 1832 | 11.7k | = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK; | 1833 | | | 1834 | 11.7k | switch (alignment_power_const) | 1835 | 11.7k | { | 1836 | 60 | case IMAGE_SCN_ALIGN_8192BYTES: | 1837 | 546 | case IMAGE_SCN_ALIGN_4096BYTES: | 1838 | 1.07k | case IMAGE_SCN_ALIGN_2048BYTES: | 1839 | 1.08k | case IMAGE_SCN_ALIGN_1024BYTES: | 1840 | 1.08k | case IMAGE_SCN_ALIGN_512BYTES: | 1841 | 1.09k | case IMAGE_SCN_ALIGN_256BYTES: | 1842 | 1.19k | case IMAGE_SCN_ALIGN_128BYTES: | 1843 | 1.21k | case IMAGE_SCN_ALIGN_64BYTES: | 1844 | 1.72k | case IMAGE_SCN_ALIGN_32BYTES: | 1845 | 1.72k | case IMAGE_SCN_ALIGN_16BYTES: | 1846 | 1.93k | case IMAGE_SCN_ALIGN_8BYTES: | 1847 | 1.96k | case IMAGE_SCN_ALIGN_4BYTES: | 1848 | 2.13k | case IMAGE_SCN_ALIGN_2BYTES: | 1849 | 2.14k | case IMAGE_SCN_ALIGN_1BYTES: | 1850 | 2.14k | section->alignment_power | 1851 | 2.14k | = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const); | 1852 | 2.14k | break; | 1853 | 9.56k | default: | 1854 | 9.56k | break; | 1855 | 11.7k | } | 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 | 11.7k | if (coff_section_data (abfd, section) == NULL) | 1862 | 11.7k | { | 1863 | 11.7k | amt = sizeof (struct coff_section_tdata); | 1864 | 11.7k | section->used_by_bfd = bfd_zalloc (abfd, amt); | 1865 | 11.7k | if (section->used_by_bfd == NULL) | 1866 | | /* FIXME: Return error. */ | 1867 | 0 | abort (); | 1868 | 11.7k | } | 1869 | | | 1870 | 11.7k | if (pei_section_data (abfd, section) == NULL) | 1871 | 11.7k | { | 1872 | 11.7k | amt = sizeof (struct pei_section_tdata); | 1873 | 11.7k | coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt); | 1874 | 11.7k | if (coff_section_data (abfd, section)->tdata == NULL) | 1875 | | /* FIXME: Return error. */ | 1876 | 0 | abort (); | 1877 | 11.7k | } | 1878 | 11.7k | pei_section_data (abfd, section)->virt_size = hdr->s_paddr; | 1879 | 11.7k | pei_section_data (abfd, section)->pe_flags = hdr->s_flags; | 1880 | | | 1881 | 11.7k | section->lma = hdr->s_vaddr; | 1882 | | | 1883 | | /* Check for extended relocs. */ | 1884 | 11.7k | if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL) | 1885 | 1.24k | { | 1886 | 1.24k | struct external_reloc dst; | 1887 | 1.24k | struct internal_reloc n; | 1888 | 1.24k | file_ptr oldpos = bfd_tell (abfd); | 1889 | 1.24k | bfd_size_type relsz = bfd_coff_relsz (abfd); | 1890 | | | 1891 | 1.24k | if (bfd_seek (abfd, (file_ptr) hdr->s_relptr, 0) != 0) | 1892 | 0 | return; | 1893 | 1.24k | if (bfd_bread (& dst, relsz, abfd) != relsz) | 1894 | 182 | return; | 1895 | | | 1896 | 1.06k | bfd_coff_swap_reloc_in (abfd, &dst, &n); | 1897 | 1.06k | if (bfd_seek (abfd, oldpos, 0) != 0) | 1898 | 0 | return; | 1899 | 1.06k | if (n.r_vaddr < 0x10000) | 1900 | 514 | { | 1901 | 514 | _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd); | 1902 | 514 | bfd_set_error (bfd_error_bad_value); | 1903 | 514 | return; | 1904 | 514 | } | 1905 | 552 | section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1; | 1906 | 552 | section->rel_filepos += relsz; | 1907 | 552 | } | 1908 | 10.4k | else if (hdr->s_nreloc == 0xffff) | 1909 | 498 | _bfd_error_handler | 1910 | 498 | (_("%pB: warning: claims to have 0xffff relocs, without overflow"), | 1911 | 498 | abfd); | 1912 | 11.7k | } |
pei-arm-wince.c:coff_set_alignment_hook Line | Count | Source | 1828 | 38.9k | { | 1829 | 38.9k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; | 1830 | 38.9k | size_t amt; | 1831 | 38.9k | unsigned int alignment_power_const | 1832 | 38.9k | = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK; | 1833 | | | 1834 | 38.9k | switch (alignment_power_const) | 1835 | 38.9k | { | 1836 | 110 | case IMAGE_SCN_ALIGN_8192BYTES: | 1837 | 118 | case IMAGE_SCN_ALIGN_4096BYTES: | 1838 | 132 | case IMAGE_SCN_ALIGN_2048BYTES: | 1839 | 1.11k | case IMAGE_SCN_ALIGN_1024BYTES: | 1840 | 1.12k | case IMAGE_SCN_ALIGN_512BYTES: | 1841 | 3.99k | case IMAGE_SCN_ALIGN_256BYTES: | 1842 | 4.03k | case IMAGE_SCN_ALIGN_128BYTES: | 1843 | 4.04k | case IMAGE_SCN_ALIGN_64BYTES: | 1844 | 5.07k | case IMAGE_SCN_ALIGN_32BYTES: | 1845 | 5.07k | case IMAGE_SCN_ALIGN_16BYTES: | 1846 | 5.55k | case IMAGE_SCN_ALIGN_8BYTES: | 1847 | 6.07k | case IMAGE_SCN_ALIGN_4BYTES: | 1848 | 6.09k | case IMAGE_SCN_ALIGN_2BYTES: | 1849 | 6.10k | case IMAGE_SCN_ALIGN_1BYTES: | 1850 | 6.10k | section->alignment_power | 1851 | 6.10k | = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const); | 1852 | 6.10k | break; | 1853 | 32.8k | default: | 1854 | 32.8k | break; | 1855 | 38.9k | } | 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 | 38.9k | if (coff_section_data (abfd, section) == NULL) | 1862 | 38.9k | { | 1863 | 38.9k | amt = sizeof (struct coff_section_tdata); | 1864 | 38.9k | section->used_by_bfd = bfd_zalloc (abfd, amt); | 1865 | 38.9k | if (section->used_by_bfd == NULL) | 1866 | | /* FIXME: Return error. */ | 1867 | 0 | abort (); | 1868 | 38.9k | } | 1869 | | | 1870 | 38.9k | if (pei_section_data (abfd, section) == NULL) | 1871 | 38.9k | { | 1872 | 38.9k | amt = sizeof (struct pei_section_tdata); | 1873 | 38.9k | coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt); | 1874 | 38.9k | if (coff_section_data (abfd, section)->tdata == NULL) | 1875 | | /* FIXME: Return error. */ | 1876 | 0 | abort (); | 1877 | 38.9k | } | 1878 | 38.9k | pei_section_data (abfd, section)->virt_size = hdr->s_paddr; | 1879 | 38.9k | pei_section_data (abfd, section)->pe_flags = hdr->s_flags; | 1880 | | | 1881 | 38.9k | section->lma = hdr->s_vaddr; | 1882 | | | 1883 | | /* Check for extended relocs. */ | 1884 | 38.9k | if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL) | 1885 | 11.2k | { | 1886 | 11.2k | struct external_reloc dst; | 1887 | 11.2k | struct internal_reloc n; | 1888 | 11.2k | file_ptr oldpos = bfd_tell (abfd); | 1889 | 11.2k | bfd_size_type relsz = bfd_coff_relsz (abfd); | 1890 | | | 1891 | 11.2k | if (bfd_seek (abfd, (file_ptr) hdr->s_relptr, 0) != 0) | 1892 | 0 | return; | 1893 | 11.2k | if (bfd_bread (& dst, relsz, abfd) != relsz) | 1894 | 4.43k | return; | 1895 | | | 1896 | 6.83k | bfd_coff_swap_reloc_in (abfd, &dst, &n); | 1897 | 6.83k | if (bfd_seek (abfd, oldpos, 0) != 0) | 1898 | 0 | return; | 1899 | 6.83k | if (n.r_vaddr < 0x10000) | 1900 | 538 | { | 1901 | 538 | _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd); | 1902 | 538 | bfd_set_error (bfd_error_bad_value); | 1903 | 538 | return; | 1904 | 538 | } | 1905 | 6.29k | section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1; | 1906 | 6.29k | section->rel_filepos += relsz; | 1907 | 6.29k | } | 1908 | 27.6k | 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 | 38.9k | } |
pei-arm.c:coff_set_alignment_hook Line | Count | Source | 1828 | 480k | { | 1829 | 480k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; | 1830 | 480k | size_t amt; | 1831 | 480k | unsigned int alignment_power_const | 1832 | 480k | = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK; | 1833 | | | 1834 | 480k | switch (alignment_power_const) | 1835 | 480k | { | 1836 | 1.07k | case IMAGE_SCN_ALIGN_8192BYTES: | 1837 | 1.08k | case IMAGE_SCN_ALIGN_4096BYTES: | 1838 | 1.09k | case IMAGE_SCN_ALIGN_2048BYTES: | 1839 | 1.60k | case IMAGE_SCN_ALIGN_1024BYTES: | 1840 | 1.61k | case IMAGE_SCN_ALIGN_512BYTES: | 1841 | 2.56k | case IMAGE_SCN_ALIGN_256BYTES: | 1842 | 2.61k | case IMAGE_SCN_ALIGN_128BYTES: | 1843 | 2.62k | case IMAGE_SCN_ALIGN_64BYTES: | 1844 | 10.3k | case IMAGE_SCN_ALIGN_32BYTES: | 1845 | 10.3k | case IMAGE_SCN_ALIGN_16BYTES: | 1846 | 10.8k | case IMAGE_SCN_ALIGN_8BYTES: | 1847 | 13.7k | case IMAGE_SCN_ALIGN_4BYTES: | 1848 | 13.7k | case IMAGE_SCN_ALIGN_2BYTES: | 1849 | 14.2k | case IMAGE_SCN_ALIGN_1BYTES: | 1850 | 14.2k | section->alignment_power | 1851 | 14.2k | = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const); | 1852 | 14.2k | break; | 1853 | 466k | default: | 1854 | 466k | break; | 1855 | 480k | } | 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 | 480k | if (coff_section_data (abfd, section) == NULL) | 1862 | 480k | { | 1863 | 480k | amt = sizeof (struct coff_section_tdata); | 1864 | 480k | section->used_by_bfd = bfd_zalloc (abfd, amt); | 1865 | 480k | if (section->used_by_bfd == NULL) | 1866 | | /* FIXME: Return error. */ | 1867 | 0 | abort (); | 1868 | 480k | } | 1869 | | | 1870 | 480k | if (pei_section_data (abfd, section) == NULL) | 1871 | 480k | { | 1872 | 480k | amt = sizeof (struct pei_section_tdata); | 1873 | 480k | coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt); | 1874 | 480k | if (coff_section_data (abfd, section)->tdata == NULL) | 1875 | | /* FIXME: Return error. */ | 1876 | 0 | abort (); | 1877 | 480k | } | 1878 | 480k | pei_section_data (abfd, section)->virt_size = hdr->s_paddr; | 1879 | 480k | pei_section_data (abfd, section)->pe_flags = hdr->s_flags; | 1880 | | | 1881 | 480k | section->lma = hdr->s_vaddr; | 1882 | | | 1883 | | /* Check for extended relocs. */ | 1884 | 480k | if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL) | 1885 | 6.52k | { | 1886 | 6.52k | struct external_reloc dst; | 1887 | 6.52k | struct internal_reloc n; | 1888 | 6.52k | file_ptr oldpos = bfd_tell (abfd); | 1889 | 6.52k | bfd_size_type relsz = bfd_coff_relsz (abfd); | 1890 | | | 1891 | 6.52k | if (bfd_seek (abfd, (file_ptr) hdr->s_relptr, 0) != 0) | 1892 | 0 | return; | 1893 | 6.52k | if (bfd_bread (& dst, relsz, abfd) != relsz) | 1894 | 2.56k | return; | 1895 | | | 1896 | 3.95k | bfd_coff_swap_reloc_in (abfd, &dst, &n); | 1897 | 3.95k | if (bfd_seek (abfd, oldpos, 0) != 0) | 1898 | 0 | return; | 1899 | 3.95k | if (n.r_vaddr < 0x10000) | 1900 | 998 | { | 1901 | 998 | _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd); | 1902 | 998 | bfd_set_error (bfd_error_bad_value); | 1903 | 998 | return; | 1904 | 998 | } | 1905 | 2.95k | section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1; | 1906 | 2.95k | section->rel_filepos += relsz; | 1907 | 2.95k | } | 1908 | 474k | 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 | 480k | } |
pei-mcore.c:coff_set_alignment_hook Line | Count | Source | 1828 | 60.9k | { | 1829 | 60.9k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; | 1830 | 60.9k | size_t amt; | 1831 | 60.9k | unsigned int alignment_power_const | 1832 | 60.9k | = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK; | 1833 | | | 1834 | 60.9k | switch (alignment_power_const) | 1835 | 60.9k | { | 1836 | 48 | case IMAGE_SCN_ALIGN_8192BYTES: | 1837 | 530 | case IMAGE_SCN_ALIGN_4096BYTES: | 1838 | 1.34k | case IMAGE_SCN_ALIGN_2048BYTES: | 1839 | 1.35k | case IMAGE_SCN_ALIGN_1024BYTES: | 1840 | 1.83k | case IMAGE_SCN_ALIGN_512BYTES: | 1841 | 1.83k | case IMAGE_SCN_ALIGN_256BYTES: | 1842 | 1.86k | case IMAGE_SCN_ALIGN_128BYTES: | 1843 | 2.83k | case IMAGE_SCN_ALIGN_64BYTES: | 1844 | 2.94k | case IMAGE_SCN_ALIGN_32BYTES: | 1845 | 3.42k | case IMAGE_SCN_ALIGN_16BYTES: | 1846 | 3.44k | case IMAGE_SCN_ALIGN_8BYTES: | 1847 | 3.48k | case IMAGE_SCN_ALIGN_4BYTES: | 1848 | 4.45k | case IMAGE_SCN_ALIGN_2BYTES: | 1849 | 4.47k | case IMAGE_SCN_ALIGN_1BYTES: | 1850 | 4.47k | section->alignment_power | 1851 | 4.47k | = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const); | 1852 | 4.47k | break; | 1853 | 56.4k | default: | 1854 | 56.4k | break; | 1855 | 60.9k | } | 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 | 60.9k | if (coff_section_data (abfd, section) == NULL) | 1862 | 60.9k | { | 1863 | 60.9k | amt = sizeof (struct coff_section_tdata); | 1864 | 60.9k | section->used_by_bfd = bfd_zalloc (abfd, amt); | 1865 | 60.9k | if (section->used_by_bfd == NULL) | 1866 | | /* FIXME: Return error. */ | 1867 | 0 | abort (); | 1868 | 60.9k | } | 1869 | | | 1870 | 60.9k | if (pei_section_data (abfd, section) == NULL) | 1871 | 60.9k | { | 1872 | 60.9k | amt = sizeof (struct pei_section_tdata); | 1873 | 60.9k | coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt); | 1874 | 60.9k | if (coff_section_data (abfd, section)->tdata == NULL) | 1875 | | /* FIXME: Return error. */ | 1876 | 0 | abort (); | 1877 | 60.9k | } | 1878 | 60.9k | pei_section_data (abfd, section)->virt_size = hdr->s_paddr; | 1879 | 60.9k | pei_section_data (abfd, section)->pe_flags = hdr->s_flags; | 1880 | | | 1881 | 60.9k | section->lma = hdr->s_vaddr; | 1882 | | | 1883 | | /* Check for extended relocs. */ | 1884 | 60.9k | if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL) | 1885 | 6.93k | { | 1886 | 6.93k | struct external_reloc dst; | 1887 | 6.93k | struct internal_reloc n; | 1888 | 6.93k | file_ptr oldpos = bfd_tell (abfd); | 1889 | 6.93k | bfd_size_type relsz = bfd_coff_relsz (abfd); | 1890 | | | 1891 | 6.93k | if (bfd_seek (abfd, (file_ptr) hdr->s_relptr, 0) != 0) | 1892 | 0 | return; | 1893 | 6.93k | if (bfd_bread (& dst, relsz, abfd) != relsz) | 1894 | 1.06k | return; | 1895 | | | 1896 | 5.87k | bfd_coff_swap_reloc_in (abfd, &dst, &n); | 1897 | 5.87k | if (bfd_seek (abfd, oldpos, 0) != 0) | 1898 | 0 | return; | 1899 | 5.87k | if (n.r_vaddr < 0x10000) | 1900 | 3.40k | { | 1901 | 3.40k | _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd); | 1902 | 3.40k | bfd_set_error (bfd_error_bad_value); | 1903 | 3.40k | return; | 1904 | 3.40k | } | 1905 | 2.47k | section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1; | 1906 | 2.47k | section->rel_filepos += relsz; | 1907 | 2.47k | } | 1908 | 53.9k | 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 | 60.9k | } |
pei-sh.c:coff_set_alignment_hook Line | Count | Source | 1828 | 50.6k | { | 1829 | 50.6k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; | 1830 | 50.6k | size_t amt; | 1831 | 50.6k | unsigned int alignment_power_const | 1832 | 50.6k | = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK; | 1833 | | | 1834 | 50.6k | switch (alignment_power_const) | 1835 | 50.6k | { | 1836 | 20 | case IMAGE_SCN_ALIGN_8192BYTES: | 1837 | 24 | case IMAGE_SCN_ALIGN_4096BYTES: | 1838 | 512 | case IMAGE_SCN_ALIGN_2048BYTES: | 1839 | 524 | case IMAGE_SCN_ALIGN_1024BYTES: | 1840 | 1.49k | case IMAGE_SCN_ALIGN_512BYTES: | 1841 | 1.49k | case IMAGE_SCN_ALIGN_256BYTES: | 1842 | 1.53k | case IMAGE_SCN_ALIGN_128BYTES: | 1843 | 2.51k | case IMAGE_SCN_ALIGN_64BYTES: | 1844 | 3.01k | case IMAGE_SCN_ALIGN_32BYTES: | 1845 | 3.01k | case IMAGE_SCN_ALIGN_16BYTES: | 1846 | 3.04k | case IMAGE_SCN_ALIGN_8BYTES: | 1847 | 3.54k | case IMAGE_SCN_ALIGN_4BYTES: | 1848 | 3.60k | case IMAGE_SCN_ALIGN_2BYTES: | 1849 | 3.63k | case IMAGE_SCN_ALIGN_1BYTES: | 1850 | 3.63k | section->alignment_power | 1851 | 3.63k | = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const); | 1852 | 3.63k | break; | 1853 | 47.0k | default: | 1854 | 47.0k | break; | 1855 | 50.6k | } | 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 | 50.6k | if (coff_section_data (abfd, section) == NULL) | 1862 | 50.6k | { | 1863 | 50.6k | amt = sizeof (struct coff_section_tdata); | 1864 | 50.6k | section->used_by_bfd = bfd_zalloc (abfd, amt); | 1865 | 50.6k | if (section->used_by_bfd == NULL) | 1866 | | /* FIXME: Return error. */ | 1867 | 0 | abort (); | 1868 | 50.6k | } | 1869 | | | 1870 | 50.6k | if (pei_section_data (abfd, section) == NULL) | 1871 | 50.6k | { | 1872 | 50.6k | amt = sizeof (struct pei_section_tdata); | 1873 | 50.6k | coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt); | 1874 | 50.6k | if (coff_section_data (abfd, section)->tdata == NULL) | 1875 | | /* FIXME: Return error. */ | 1876 | 0 | abort (); | 1877 | 50.6k | } | 1878 | 50.6k | pei_section_data (abfd, section)->virt_size = hdr->s_paddr; | 1879 | 50.6k | pei_section_data (abfd, section)->pe_flags = hdr->s_flags; | 1880 | | | 1881 | 50.6k | section->lma = hdr->s_vaddr; | 1882 | | | 1883 | | /* Check for extended relocs. */ | 1884 | 50.6k | if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL) | 1885 | 3.56k | { | 1886 | 3.56k | struct external_reloc dst; | 1887 | 3.56k | struct internal_reloc n; | 1888 | 3.56k | file_ptr oldpos = bfd_tell (abfd); | 1889 | 3.56k | bfd_size_type relsz = bfd_coff_relsz (abfd); | 1890 | | | 1891 | 3.56k | if (bfd_seek (abfd, (file_ptr) hdr->s_relptr, 0) != 0) | 1892 | 0 | return; | 1893 | 3.56k | if (bfd_bread (& dst, relsz, abfd) != relsz) | 1894 | 1.06k | return; | 1895 | | | 1896 | 2.50k | bfd_coff_swap_reloc_in (abfd, &dst, &n); | 1897 | 2.50k | if (bfd_seek (abfd, oldpos, 0) != 0) | 1898 | 0 | return; | 1899 | 2.50k | if (n.r_vaddr < 0x10000) | 1900 | 1.97k | { | 1901 | 1.97k | _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd); | 1902 | 1.97k | bfd_set_error (bfd_error_bad_value); | 1903 | 1.97k | return; | 1904 | 1.97k | } | 1905 | 532 | section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1; | 1906 | 532 | section->rel_filepos += relsz; | 1907 | 532 | } | 1908 | 47.1k | 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 | 50.6k | } |
|
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 | 102k | { |
1926 | 102k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; |
1927 | 102k | asection *real_sec; |
1928 | | |
1929 | 102k | if ((hdr->s_flags & STYP_OVRFLO) == 0) |
1930 | 77.3k | return; |
1931 | | |
1932 | 25.0k | real_sec = coff_section_from_bfd_index (abfd, (int) hdr->s_nreloc); |
1933 | 25.0k | if (real_sec == NULL) |
1934 | 0 | return; |
1935 | | |
1936 | 25.0k | real_sec->reloc_count = hdr->s_paddr; |
1937 | 25.0k | real_sec->lineno_count = hdr->s_vaddr; |
1938 | | |
1939 | 25.0k | if (!bfd_section_removed_from_list (abfd, section)) |
1940 | 25.0k | { |
1941 | 25.0k | bfd_section_list_remove (abfd, section); |
1942 | 25.0k | --abfd->section_count; |
1943 | 25.0k | } |
1944 | 25.0k | } coff64-rs6000.c:coff_set_alignment_hook Line | Count | Source | 1925 | 71.0k | { | 1926 | 71.0k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; | 1927 | 71.0k | asection *real_sec; | 1928 | | | 1929 | 71.0k | if ((hdr->s_flags & STYP_OVRFLO) == 0) | 1930 | 49.8k | return; | 1931 | | | 1932 | 21.1k | real_sec = coff_section_from_bfd_index (abfd, (int) hdr->s_nreloc); | 1933 | 21.1k | if (real_sec == NULL) | 1934 | 0 | return; | 1935 | | | 1936 | 21.1k | real_sec->reloc_count = hdr->s_paddr; | 1937 | 21.1k | real_sec->lineno_count = hdr->s_vaddr; | 1938 | | | 1939 | 21.1k | if (!bfd_section_removed_from_list (abfd, section)) | 1940 | 21.1k | { | 1941 | 21.1k | bfd_section_list_remove (abfd, section); | 1942 | 21.1k | --abfd->section_count; | 1943 | 21.1k | } | 1944 | 21.1k | } |
coff-rs6000.c:coff_set_alignment_hook Line | Count | Source | 1925 | 31.3k | { | 1926 | 31.3k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; | 1927 | 31.3k | asection *real_sec; | 1928 | | | 1929 | 31.3k | if ((hdr->s_flags & STYP_OVRFLO) == 0) | 1930 | 27.4k | return; | 1931 | | | 1932 | 3.86k | real_sec = coff_section_from_bfd_index (abfd, (int) hdr->s_nreloc); | 1933 | 3.86k | if (real_sec == NULL) | 1934 | 0 | return; | 1935 | | | 1936 | 3.86k | real_sec->reloc_count = hdr->s_paddr; | 1937 | 3.86k | real_sec->lineno_count = hdr->s_vaddr; | 1938 | | | 1939 | 3.86k | if (!bfd_section_removed_from_list (abfd, section)) | 1940 | 3.86k | { | 1941 | 3.86k | bfd_section_list_remove (abfd, section); | 1942 | 3.86k | --abfd->section_count; | 1943 | 3.86k | } | 1944 | 3.86k | } |
|
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 | 189k | { |
1952 | 189k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; |
1953 | | |
1954 | | /* Check for extended relocs. */ |
1955 | 189k | if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL) |
1956 | 82.0k | { |
1957 | 82.0k | struct external_reloc dst; |
1958 | 82.0k | struct internal_reloc n; |
1959 | 82.0k | const file_ptr oldpos = bfd_tell (abfd); |
1960 | 82.0k | const bfd_size_type relsz = bfd_coff_relsz (abfd); |
1961 | | |
1962 | 82.0k | if (bfd_seek (abfd, (file_ptr) hdr->s_relptr, 0) != 0) |
1963 | 0 | return; |
1964 | 82.0k | if (bfd_bread (& dst, relsz, abfd) != relsz) |
1965 | 81.6k | return; |
1966 | | |
1967 | 408 | bfd_coff_swap_reloc_in (abfd, &dst, &n); |
1968 | 408 | if (bfd_seek (abfd, oldpos, 0) != 0) |
1969 | 0 | return; |
1970 | 408 | section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1; |
1971 | 408 | section->rel_filepos += relsz; |
1972 | 408 | } |
1973 | 107k | else if (hdr->s_nreloc == 0xffff) |
1974 | 102 | _bfd_error_handler |
1975 | 102 | (_("%pB: warning: claims to have 0xffff relocs, without overflow"), |
1976 | 102 | abfd); |
1977 | 189k | } coff-go32.c:coff_set_alignment_hook Line | Count | Source | 1951 | 189k | { | 1952 | 189k | struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; | 1953 | | | 1954 | | /* Check for extended relocs. */ | 1955 | 189k | if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL) | 1956 | 82.0k | { | 1957 | 82.0k | struct external_reloc dst; | 1958 | 82.0k | struct internal_reloc n; | 1959 | 82.0k | const file_ptr oldpos = bfd_tell (abfd); | 1960 | 82.0k | const bfd_size_type relsz = bfd_coff_relsz (abfd); | 1961 | | | 1962 | 82.0k | if (bfd_seek (abfd, (file_ptr) hdr->s_relptr, 0) != 0) | 1963 | 0 | return; | 1964 | 82.0k | if (bfd_bread (& dst, relsz, abfd) != relsz) | 1965 | 81.6k | return; | 1966 | | | 1967 | 408 | bfd_coff_swap_reloc_in (abfd, &dst, &n); | 1968 | 408 | if (bfd_seek (abfd, oldpos, 0) != 0) | 1969 | 0 | return; | 1970 | 408 | section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1; | 1971 | 408 | section->rel_filepos += relsz; | 1972 | 408 | } | 1973 | 107k | else if (hdr->s_nreloc == 0xffff) | 1974 | 102 | _bfd_error_handler | 1975 | 102 | (_("%pB: warning: claims to have 0xffff relocs, without overflow"), | 1976 | 102 | abfd); | 1977 | 189k | } |
Unexecuted instantiation: coff-stgo32.c:coff_set_alignment_hook |
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 | 714k | { |
1986 | 714k | } coff-x86_64.c:coff_set_alignment_hook Line | Count | Source | 1985 | 304k | { | 1986 | 304k | } |
cf-i386lynx.c:coff_set_alignment_hook Line | Count | Source | 1985 | 193k | { | 1986 | 193k | } |
coff-i386.c:coff_set_alignment_hook Line | Count | Source | 1985 | 193k | { | 1986 | 193k | } |
coff-sh.c:coff_set_alignment_hook Line | Count | Source | 1985 | 11.3k | { | 1986 | 11.3k | } |
coff-tic30.c:coff_set_alignment_hook Line | Count | Source | 1985 | 7.44k | { | 1986 | 7.44k | } |
coff-z8k.c:coff_set_alignment_hook Line | Count | Source | 1985 | 3.97k | { | 1986 | 3.97k | } |
|
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.35k | { |
1998 | 3.35k | coff_data_type *coff; |
1999 | 3.35k | size_t amt = sizeof (coff_data_type); |
2000 | | |
2001 | 3.35k | abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt); |
2002 | 3.35k | if (abfd->tdata.coff_obj_data == NULL) |
2003 | 0 | return false; |
2004 | | |
2005 | 3.35k | coff = coff_data (abfd); |
2006 | 3.35k | coff->symbols = NULL; |
2007 | 3.35k | coff->conversion_table = NULL; |
2008 | 3.35k | coff->raw_syments = NULL; |
2009 | 3.35k | coff->relocbase = 0; |
2010 | 3.35k | coff->local_toc_sym_map = 0; |
2011 | | |
2012 | 3.35k | bfd_coff_long_section_names (abfd) |
2013 | 3.35k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; |
2014 | | |
2015 | | /* make_abs_section(abfd);*/ |
2016 | | |
2017 | 3.35k | return true; |
2018 | 3.35k | } coff-x86_64.c:coff_mkobject Line | Count | Source | 1997 | 560 | { | 1998 | 560 | coff_data_type *coff; | 1999 | 560 | size_t amt = sizeof (coff_data_type); | 2000 | | | 2001 | 560 | abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt); | 2002 | 560 | if (abfd->tdata.coff_obj_data == NULL) | 2003 | 0 | return false; | 2004 | | | 2005 | 560 | coff = coff_data (abfd); | 2006 | 560 | coff->symbols = NULL; | 2007 | 560 | coff->conversion_table = NULL; | 2008 | 560 | coff->raw_syments = NULL; | 2009 | 560 | coff->relocbase = 0; | 2010 | 560 | coff->local_toc_sym_map = 0; | 2011 | | | 2012 | 560 | bfd_coff_long_section_names (abfd) | 2013 | 560 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 2014 | | | 2015 | | /* make_abs_section(abfd);*/ | 2016 | | | 2017 | 560 | return true; | 2018 | 560 | } |
cf-i386lynx.c:coff_mkobject Line | Count | Source | 1997 | 448 | { | 1998 | 448 | coff_data_type *coff; | 1999 | 448 | size_t amt = sizeof (coff_data_type); | 2000 | | | 2001 | 448 | abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt); | 2002 | 448 | if (abfd->tdata.coff_obj_data == NULL) | 2003 | 0 | return false; | 2004 | | | 2005 | 448 | coff = coff_data (abfd); | 2006 | 448 | coff->symbols = NULL; | 2007 | 448 | coff->conversion_table = NULL; | 2008 | 448 | coff->raw_syments = NULL; | 2009 | 448 | coff->relocbase = 0; | 2010 | 448 | coff->local_toc_sym_map = 0; | 2011 | | | 2012 | 448 | bfd_coff_long_section_names (abfd) | 2013 | 448 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 2014 | | | 2015 | | /* make_abs_section(abfd);*/ | 2016 | | | 2017 | 448 | return true; | 2018 | 448 | } |
coff-i386.c:coff_mkobject Line | Count | Source | 1997 | 448 | { | 1998 | 448 | coff_data_type *coff; | 1999 | 448 | size_t amt = sizeof (coff_data_type); | 2000 | | | 2001 | 448 | abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt); | 2002 | 448 | if (abfd->tdata.coff_obj_data == NULL) | 2003 | 0 | return false; | 2004 | | | 2005 | 448 | coff = coff_data (abfd); | 2006 | 448 | coff->symbols = NULL; | 2007 | 448 | coff->conversion_table = NULL; | 2008 | 448 | coff->raw_syments = NULL; | 2009 | 448 | coff->relocbase = 0; | 2010 | 448 | coff->local_toc_sym_map = 0; | 2011 | | | 2012 | 448 | bfd_coff_long_section_names (abfd) | 2013 | 448 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 2014 | | | 2015 | | /* make_abs_section(abfd);*/ | 2016 | | | 2017 | 448 | return true; | 2018 | 448 | } |
Line | Count | Source | 1997 | 522 | { | 1998 | 522 | coff_data_type *coff; | 1999 | 522 | size_t amt = sizeof (coff_data_type); | 2000 | | | 2001 | 522 | abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt); | 2002 | 522 | if (abfd->tdata.coff_obj_data == NULL) | 2003 | 0 | return false; | 2004 | | | 2005 | 522 | coff = coff_data (abfd); | 2006 | 522 | coff->symbols = NULL; | 2007 | 522 | coff->conversion_table = NULL; | 2008 | 522 | coff->raw_syments = NULL; | 2009 | 522 | coff->relocbase = 0; | 2010 | 522 | coff->local_toc_sym_map = 0; | 2011 | | | 2012 | 522 | bfd_coff_long_section_names (abfd) | 2013 | 522 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 2014 | | | 2015 | | /* make_abs_section(abfd);*/ | 2016 | | | 2017 | 522 | return true; | 2018 | 522 | } |
coff-tic30.c:coff_mkobject Line | Count | Source | 1997 | 270 | { | 1998 | 270 | coff_data_type *coff; | 1999 | 270 | size_t amt = sizeof (coff_data_type); | 2000 | | | 2001 | 270 | abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt); | 2002 | 270 | if (abfd->tdata.coff_obj_data == NULL) | 2003 | 0 | return false; | 2004 | | | 2005 | 270 | coff = coff_data (abfd); | 2006 | 270 | coff->symbols = NULL; | 2007 | 270 | coff->conversion_table = NULL; | 2008 | 270 | coff->raw_syments = NULL; | 2009 | 270 | coff->relocbase = 0; | 2010 | 270 | coff->local_toc_sym_map = 0; | 2011 | | | 2012 | 270 | bfd_coff_long_section_names (abfd) | 2013 | 270 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 2014 | | | 2015 | | /* make_abs_section(abfd);*/ | 2016 | | | 2017 | 270 | return true; | 2018 | 270 | } |
Unexecuted instantiation: coff-tic4x.c:coff_mkobject coff-tic54x.c:coff_mkobject Line | Count | Source | 1997 | 530 | { | 1998 | 530 | coff_data_type *coff; | 1999 | 530 | size_t amt = sizeof (coff_data_type); | 2000 | | | 2001 | 530 | abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt); | 2002 | 530 | if (abfd->tdata.coff_obj_data == NULL) | 2003 | 0 | return false; | 2004 | | | 2005 | 530 | coff = coff_data (abfd); | 2006 | 530 | coff->symbols = NULL; | 2007 | 530 | coff->conversion_table = NULL; | 2008 | 530 | coff->raw_syments = NULL; | 2009 | 530 | coff->relocbase = 0; | 2010 | 530 | coff->local_toc_sym_map = 0; | 2011 | | | 2012 | 530 | bfd_coff_long_section_names (abfd) | 2013 | 530 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 2014 | | | 2015 | | /* make_abs_section(abfd);*/ | 2016 | | | 2017 | 530 | return true; | 2018 | 530 | } |
Line | Count | Source | 1997 | 296 | { | 1998 | 296 | coff_data_type *coff; | 1999 | 296 | size_t amt = sizeof (coff_data_type); | 2000 | | | 2001 | 296 | abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt); | 2002 | 296 | if (abfd->tdata.coff_obj_data == NULL) | 2003 | 0 | return false; | 2004 | | | 2005 | 296 | coff = coff_data (abfd); | 2006 | 296 | coff->symbols = NULL; | 2007 | 296 | coff->conversion_table = NULL; | 2008 | 296 | coff->raw_syments = NULL; | 2009 | 296 | coff->relocbase = 0; | 2010 | 296 | coff->local_toc_sym_map = 0; | 2011 | | | 2012 | 296 | bfd_coff_long_section_names (abfd) | 2013 | 296 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 2014 | | | 2015 | | /* make_abs_section(abfd);*/ | 2016 | | | 2017 | 296 | return true; | 2018 | 296 | } |
Line | Count | Source | 1997 | 284 | { | 1998 | 284 | coff_data_type *coff; | 1999 | 284 | size_t amt = sizeof (coff_data_type); | 2000 | | | 2001 | 284 | abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt); | 2002 | 284 | if (abfd->tdata.coff_obj_data == NULL) | 2003 | 0 | return false; | 2004 | | | 2005 | 284 | coff = coff_data (abfd); | 2006 | 284 | coff->symbols = NULL; | 2007 | 284 | coff->conversion_table = NULL; | 2008 | 284 | coff->raw_syments = NULL; | 2009 | 284 | coff->relocbase = 0; | 2010 | 284 | coff->local_toc_sym_map = 0; | 2011 | | | 2012 | 284 | bfd_coff_long_section_names (abfd) | 2013 | 284 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 2014 | | | 2015 | | /* make_abs_section(abfd);*/ | 2016 | | | 2017 | 284 | return true; | 2018 | 284 | } |
|
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 | 4.65k | { |
2029 | 4.65k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; |
2030 | 4.65k | coff_data_type *coff; |
2031 | | |
2032 | 4.65k | if (! coff_mkobject (abfd)) |
2033 | 0 | return NULL; |
2034 | | |
2035 | 4.65k | coff = coff_data (abfd); |
2036 | | |
2037 | 4.65k | 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 | 4.65k | coff->local_n_btmask = N_BTMASK; |
2043 | 4.65k | coff->local_n_btshft = N_BTSHFT; |
2044 | 4.65k | coff->local_n_tmask = N_TMASK; |
2045 | 4.65k | coff->local_n_tshift = N_TSHIFT; |
2046 | 4.65k | coff->local_symesz = bfd_coff_symesz (abfd); |
2047 | 4.65k | coff->local_auxesz = bfd_coff_auxesz (abfd); |
2048 | 4.65k | coff->local_linesz = bfd_coff_linesz (abfd); |
2049 | | |
2050 | 4.65k | coff->timestamp = internal_f->f_timdat; |
2051 | | |
2052 | 4.65k | obj_raw_syment_count (abfd) = |
2053 | 4.65k | obj_conv_table_size (abfd) = |
2054 | 4.65k | internal_f->f_nsyms; |
2055 | | |
2056 | | #ifdef RS6000COFF_C |
2057 | 850 | if ((internal_f->f_flags & F_SHROBJ) != 0) |
2058 | 122 | abfd->flags |= DYNAMIC; |
2059 | 850 | if (aouthdr != NULL && internal_f->f_opthdr >= bfd_coff_aoutsz (abfd)) |
2060 | 132 | { |
2061 | 132 | struct internal_aouthdr *internal_a = |
2062 | 132 | (struct internal_aouthdr *) aouthdr; |
2063 | 132 | struct xcoff_tdata *xcoff; |
2064 | | |
2065 | 132 | xcoff = xcoff_data (abfd); |
2066 | | # ifdef U803XTOCMAGIC |
2067 | 56 | xcoff->xcoff64 = internal_f->f_magic == U803XTOCMAGIC; |
2068 | | # else |
2069 | | xcoff->xcoff64 = 0; |
2070 | | # endif |
2071 | 132 | xcoff->full_aouthdr = true; |
2072 | 132 | xcoff->toc = internal_a->o_toc; |
2073 | 132 | xcoff->sntoc = internal_a->o_sntoc; |
2074 | 132 | xcoff->snentry = internal_a->o_snentry; |
2075 | 132 | bfd_xcoff_text_align_power (abfd) = internal_a->o_algntext; |
2076 | 132 | bfd_xcoff_data_align_power (abfd) = internal_a->o_algndata; |
2077 | 132 | xcoff->modtype = internal_a->o_modtype; |
2078 | 132 | xcoff->cputype = internal_a->o_cputype; |
2079 | 132 | xcoff->maxdata = internal_a->o_maxdata; |
2080 | 132 | xcoff->maxstack = internal_a->o_maxstack; |
2081 | 132 | } |
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 | 4.65k | return coff; |
2098 | 4.65k | } coff-x86_64.c:coff_mkobject_hook Line | Count | Source | 2028 | 560 | { | 2029 | 560 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2030 | 560 | coff_data_type *coff; | 2031 | | | 2032 | 560 | if (! coff_mkobject (abfd)) | 2033 | 0 | return NULL; | 2034 | | | 2035 | 560 | coff = coff_data (abfd); | 2036 | | | 2037 | 560 | 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 | 560 | coff->local_n_btmask = N_BTMASK; | 2043 | 560 | coff->local_n_btshft = N_BTSHFT; | 2044 | 560 | coff->local_n_tmask = N_TMASK; | 2045 | 560 | coff->local_n_tshift = N_TSHIFT; | 2046 | 560 | coff->local_symesz = bfd_coff_symesz (abfd); | 2047 | 560 | coff->local_auxesz = bfd_coff_auxesz (abfd); | 2048 | 560 | coff->local_linesz = bfd_coff_linesz (abfd); | 2049 | | | 2050 | 560 | coff->timestamp = internal_f->f_timdat; | 2051 | | | 2052 | 560 | obj_raw_syment_count (abfd) = | 2053 | 560 | obj_conv_table_size (abfd) = | 2054 | 560 | 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 | 560 | return coff; | 2098 | 560 | } |
coff64-rs6000.c:coff_mkobject_hook Line | Count | Source | 2028 | 436 | { | 2029 | 436 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2030 | 436 | coff_data_type *coff; | 2031 | | | 2032 | 436 | if (! coff_mkobject (abfd)) | 2033 | 0 | return NULL; | 2034 | | | 2035 | 436 | coff = coff_data (abfd); | 2036 | | | 2037 | 436 | 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 | 436 | coff->local_n_btmask = N_BTMASK; | 2043 | 436 | coff->local_n_btshft = N_BTSHFT; | 2044 | 436 | coff->local_n_tmask = N_TMASK; | 2045 | 436 | coff->local_n_tshift = N_TSHIFT; | 2046 | 436 | coff->local_symesz = bfd_coff_symesz (abfd); | 2047 | 436 | coff->local_auxesz = bfd_coff_auxesz (abfd); | 2048 | 436 | coff->local_linesz = bfd_coff_linesz (abfd); | 2049 | | | 2050 | 436 | coff->timestamp = internal_f->f_timdat; | 2051 | | | 2052 | 436 | obj_raw_syment_count (abfd) = | 2053 | 436 | obj_conv_table_size (abfd) = | 2054 | 436 | internal_f->f_nsyms; | 2055 | | | 2056 | 436 | #ifdef RS6000COFF_C | 2057 | 436 | if ((internal_f->f_flags & F_SHROBJ) != 0) | 2058 | 22 | abfd->flags |= DYNAMIC; | 2059 | 436 | if (aouthdr != NULL && internal_f->f_opthdr >= bfd_coff_aoutsz (abfd)) | 2060 | 56 | { | 2061 | 56 | struct internal_aouthdr *internal_a = | 2062 | 56 | (struct internal_aouthdr *) aouthdr; | 2063 | 56 | struct xcoff_tdata *xcoff; | 2064 | | | 2065 | 56 | xcoff = xcoff_data (abfd); | 2066 | 56 | # ifdef U803XTOCMAGIC | 2067 | 56 | xcoff->xcoff64 = internal_f->f_magic == U803XTOCMAGIC; | 2068 | | # else | 2069 | | xcoff->xcoff64 = 0; | 2070 | | # endif | 2071 | 56 | xcoff->full_aouthdr = true; | 2072 | 56 | xcoff->toc = internal_a->o_toc; | 2073 | 56 | xcoff->sntoc = internal_a->o_sntoc; | 2074 | 56 | xcoff->snentry = internal_a->o_snentry; | 2075 | 56 | bfd_xcoff_text_align_power (abfd) = internal_a->o_algntext; | 2076 | 56 | bfd_xcoff_data_align_power (abfd) = internal_a->o_algndata; | 2077 | 56 | xcoff->modtype = internal_a->o_modtype; | 2078 | 56 | xcoff->cputype = internal_a->o_cputype; | 2079 | 56 | xcoff->maxdata = internal_a->o_maxdata; | 2080 | 56 | xcoff->maxstack = internal_a->o_maxstack; | 2081 | 56 | } | 2082 | 436 | #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 | 436 | return coff; | 2098 | 436 | } |
cf-i386lynx.c:coff_mkobject_hook Line | Count | Source | 2028 | 448 | { | 2029 | 448 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2030 | 448 | coff_data_type *coff; | 2031 | | | 2032 | 448 | if (! coff_mkobject (abfd)) | 2033 | 0 | return NULL; | 2034 | | | 2035 | 448 | coff = coff_data (abfd); | 2036 | | | 2037 | 448 | 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 | 448 | coff->local_n_btmask = N_BTMASK; | 2043 | 448 | coff->local_n_btshft = N_BTSHFT; | 2044 | 448 | coff->local_n_tmask = N_TMASK; | 2045 | 448 | coff->local_n_tshift = N_TSHIFT; | 2046 | 448 | coff->local_symesz = bfd_coff_symesz (abfd); | 2047 | 448 | coff->local_auxesz = bfd_coff_auxesz (abfd); | 2048 | 448 | coff->local_linesz = bfd_coff_linesz (abfd); | 2049 | | | 2050 | 448 | coff->timestamp = internal_f->f_timdat; | 2051 | | | 2052 | 448 | obj_raw_syment_count (abfd) = | 2053 | 448 | obj_conv_table_size (abfd) = | 2054 | 448 | 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 | 448 | return coff; | 2098 | 448 | } |
coff-go32.c:coff_mkobject_hook Line | Count | Source | 2028 | 448 | { | 2029 | 448 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2030 | 448 | coff_data_type *coff; | 2031 | | | 2032 | 448 | if (! coff_mkobject (abfd)) | 2033 | 0 | return NULL; | 2034 | | | 2035 | 448 | coff = coff_data (abfd); | 2036 | | | 2037 | 448 | 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 | 448 | coff->local_n_btmask = N_BTMASK; | 2043 | 448 | coff->local_n_btshft = N_BTSHFT; | 2044 | 448 | coff->local_n_tmask = N_TMASK; | 2045 | 448 | coff->local_n_tshift = N_TSHIFT; | 2046 | 448 | coff->local_symesz = bfd_coff_symesz (abfd); | 2047 | 448 | coff->local_auxesz = bfd_coff_auxesz (abfd); | 2048 | 448 | coff->local_linesz = bfd_coff_linesz (abfd); | 2049 | | | 2050 | 448 | coff->timestamp = internal_f->f_timdat; | 2051 | | | 2052 | 448 | obj_raw_syment_count (abfd) = | 2053 | 448 | obj_conv_table_size (abfd) = | 2054 | 448 | 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 | 448 | return coff; | 2098 | 448 | } |
coff-i386.c:coff_mkobject_hook Line | Count | Source | 2028 | 448 | { | 2029 | 448 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2030 | 448 | coff_data_type *coff; | 2031 | | | 2032 | 448 | if (! coff_mkobject (abfd)) | 2033 | 0 | return NULL; | 2034 | | | 2035 | 448 | coff = coff_data (abfd); | 2036 | | | 2037 | 448 | 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 | 448 | coff->local_n_btmask = N_BTMASK; | 2043 | 448 | coff->local_n_btshft = N_BTSHFT; | 2044 | 448 | coff->local_n_tmask = N_TMASK; | 2045 | 448 | coff->local_n_tshift = N_TSHIFT; | 2046 | 448 | coff->local_symesz = bfd_coff_symesz (abfd); | 2047 | 448 | coff->local_auxesz = bfd_coff_auxesz (abfd); | 2048 | 448 | coff->local_linesz = bfd_coff_linesz (abfd); | 2049 | | | 2050 | 448 | coff->timestamp = internal_f->f_timdat; | 2051 | | | 2052 | 448 | obj_raw_syment_count (abfd) = | 2053 | 448 | obj_conv_table_size (abfd) = | 2054 | 448 | 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 | 448 | return coff; | 2098 | 448 | } |
coff-rs6000.c:coff_mkobject_hook Line | Count | Source | 2028 | 414 | { | 2029 | 414 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2030 | 414 | coff_data_type *coff; | 2031 | | | 2032 | 414 | if (! coff_mkobject (abfd)) | 2033 | 0 | return NULL; | 2034 | | | 2035 | 414 | coff = coff_data (abfd); | 2036 | | | 2037 | 414 | 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 | 414 | coff->local_n_btmask = N_BTMASK; | 2043 | 414 | coff->local_n_btshft = N_BTSHFT; | 2044 | 414 | coff->local_n_tmask = N_TMASK; | 2045 | 414 | coff->local_n_tshift = N_TSHIFT; | 2046 | 414 | coff->local_symesz = bfd_coff_symesz (abfd); | 2047 | 414 | coff->local_auxesz = bfd_coff_auxesz (abfd); | 2048 | 414 | coff->local_linesz = bfd_coff_linesz (abfd); | 2049 | | | 2050 | 414 | coff->timestamp = internal_f->f_timdat; | 2051 | | | 2052 | 414 | obj_raw_syment_count (abfd) = | 2053 | 414 | obj_conv_table_size (abfd) = | 2054 | 414 | internal_f->f_nsyms; | 2055 | | | 2056 | 414 | #ifdef RS6000COFF_C | 2057 | 414 | if ((internal_f->f_flags & F_SHROBJ) != 0) | 2058 | 100 | abfd->flags |= DYNAMIC; | 2059 | 414 | if (aouthdr != NULL && internal_f->f_opthdr >= bfd_coff_aoutsz (abfd)) | 2060 | 76 | { | 2061 | 76 | struct internal_aouthdr *internal_a = | 2062 | 76 | (struct internal_aouthdr *) aouthdr; | 2063 | 76 | struct xcoff_tdata *xcoff; | 2064 | | | 2065 | 76 | xcoff = xcoff_data (abfd); | 2066 | | # ifdef U803XTOCMAGIC | 2067 | | xcoff->xcoff64 = internal_f->f_magic == U803XTOCMAGIC; | 2068 | | # else | 2069 | 76 | xcoff->xcoff64 = 0; | 2070 | 76 | # endif | 2071 | 76 | xcoff->full_aouthdr = true; | 2072 | 76 | xcoff->toc = internal_a->o_toc; | 2073 | 76 | xcoff->sntoc = internal_a->o_sntoc; | 2074 | 76 | xcoff->snentry = internal_a->o_snentry; | 2075 | 76 | bfd_xcoff_text_align_power (abfd) = internal_a->o_algntext; | 2076 | 76 | bfd_xcoff_data_align_power (abfd) = internal_a->o_algndata; | 2077 | 76 | xcoff->modtype = internal_a->o_modtype; | 2078 | 76 | xcoff->cputype = internal_a->o_cputype; | 2079 | 76 | xcoff->maxdata = internal_a->o_maxdata; | 2080 | 76 | xcoff->maxstack = internal_a->o_maxstack; | 2081 | 76 | } | 2082 | 414 | #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 | 414 | return coff; | 2098 | 414 | } |
coff-sh.c:coff_mkobject_hook Line | Count | Source | 2028 | 522 | { | 2029 | 522 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2030 | 522 | coff_data_type *coff; | 2031 | | | 2032 | 522 | if (! coff_mkobject (abfd)) | 2033 | 0 | return NULL; | 2034 | | | 2035 | 522 | coff = coff_data (abfd); | 2036 | | | 2037 | 522 | 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 | 522 | coff->local_n_btmask = N_BTMASK; | 2043 | 522 | coff->local_n_btshft = N_BTSHFT; | 2044 | 522 | coff->local_n_tmask = N_TMASK; | 2045 | 522 | coff->local_n_tshift = N_TSHIFT; | 2046 | 522 | coff->local_symesz = bfd_coff_symesz (abfd); | 2047 | 522 | coff->local_auxesz = bfd_coff_auxesz (abfd); | 2048 | 522 | coff->local_linesz = bfd_coff_linesz (abfd); | 2049 | | | 2050 | 522 | coff->timestamp = internal_f->f_timdat; | 2051 | | | 2052 | 522 | obj_raw_syment_count (abfd) = | 2053 | 522 | obj_conv_table_size (abfd) = | 2054 | 522 | 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 | 522 | return coff; | 2098 | 522 | } |
Unexecuted instantiation: coff-stgo32.c:coff_mkobject_hook coff-tic30.c:coff_mkobject_hook Line | Count | Source | 2028 | 270 | { | 2029 | 270 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2030 | 270 | coff_data_type *coff; | 2031 | | | 2032 | 270 | if (! coff_mkobject (abfd)) | 2033 | 0 | return NULL; | 2034 | | | 2035 | 270 | coff = coff_data (abfd); | 2036 | | | 2037 | 270 | 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 | 270 | coff->local_n_btmask = N_BTMASK; | 2043 | 270 | coff->local_n_btshft = N_BTSHFT; | 2044 | 270 | coff->local_n_tmask = N_TMASK; | 2045 | 270 | coff->local_n_tshift = N_TSHIFT; | 2046 | 270 | coff->local_symesz = bfd_coff_symesz (abfd); | 2047 | 270 | coff->local_auxesz = bfd_coff_auxesz (abfd); | 2048 | 270 | coff->local_linesz = bfd_coff_linesz (abfd); | 2049 | | | 2050 | 270 | coff->timestamp = internal_f->f_timdat; | 2051 | | | 2052 | 270 | obj_raw_syment_count (abfd) = | 2053 | 270 | obj_conv_table_size (abfd) = | 2054 | 270 | 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 | 270 | return coff; | 2098 | 270 | } |
Unexecuted instantiation: coff-tic4x.c:coff_mkobject_hook coff-tic54x.c:coff_mkobject_hook Line | Count | Source | 2028 | 530 | { | 2029 | 530 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2030 | 530 | coff_data_type *coff; | 2031 | | | 2032 | 530 | if (! coff_mkobject (abfd)) | 2033 | 0 | return NULL; | 2034 | | | 2035 | 530 | coff = coff_data (abfd); | 2036 | | | 2037 | 530 | 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 | 530 | coff->local_n_btmask = N_BTMASK; | 2043 | 530 | coff->local_n_btshft = N_BTSHFT; | 2044 | 530 | coff->local_n_tmask = N_TMASK; | 2045 | 530 | coff->local_n_tshift = N_TSHIFT; | 2046 | 530 | coff->local_symesz = bfd_coff_symesz (abfd); | 2047 | 530 | coff->local_auxesz = bfd_coff_auxesz (abfd); | 2048 | 530 | coff->local_linesz = bfd_coff_linesz (abfd); | 2049 | | | 2050 | 530 | coff->timestamp = internal_f->f_timdat; | 2051 | | | 2052 | 530 | obj_raw_syment_count (abfd) = | 2053 | 530 | obj_conv_table_size (abfd) = | 2054 | 530 | 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 | 530 | return coff; | 2098 | 530 | } |
coff-z80.c:coff_mkobject_hook Line | Count | Source | 2028 | 296 | { | 2029 | 296 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2030 | 296 | coff_data_type *coff; | 2031 | | | 2032 | 296 | if (! coff_mkobject (abfd)) | 2033 | 0 | return NULL; | 2034 | | | 2035 | 296 | coff = coff_data (abfd); | 2036 | | | 2037 | 296 | 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 | 296 | coff->local_n_btmask = N_BTMASK; | 2043 | 296 | coff->local_n_btshft = N_BTSHFT; | 2044 | 296 | coff->local_n_tmask = N_TMASK; | 2045 | 296 | coff->local_n_tshift = N_TSHIFT; | 2046 | 296 | coff->local_symesz = bfd_coff_symesz (abfd); | 2047 | 296 | coff->local_auxesz = bfd_coff_auxesz (abfd); | 2048 | 296 | coff->local_linesz = bfd_coff_linesz (abfd); | 2049 | | | 2050 | 296 | coff->timestamp = internal_f->f_timdat; | 2051 | | | 2052 | 296 | obj_raw_syment_count (abfd) = | 2053 | 296 | obj_conv_table_size (abfd) = | 2054 | 296 | 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 | 296 | return coff; | 2098 | 296 | } |
coff-z8k.c:coff_mkobject_hook Line | Count | Source | 2028 | 284 | { | 2029 | 284 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2030 | 284 | coff_data_type *coff; | 2031 | | | 2032 | 284 | if (! coff_mkobject (abfd)) | 2033 | 0 | return NULL; | 2034 | | | 2035 | 284 | coff = coff_data (abfd); | 2036 | | | 2037 | 284 | 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 | 284 | coff->local_n_btmask = N_BTMASK; | 2043 | 284 | coff->local_n_btshft = N_BTSHFT; | 2044 | 284 | coff->local_n_tmask = N_TMASK; | 2045 | 284 | coff->local_n_tshift = N_TSHIFT; | 2046 | 284 | coff->local_symesz = bfd_coff_symesz (abfd); | 2047 | 284 | coff->local_auxesz = bfd_coff_auxesz (abfd); | 2048 | 284 | coff->local_linesz = bfd_coff_linesz (abfd); | 2049 | | | 2050 | 284 | coff->timestamp = internal_f->f_timdat; | 2051 | | | 2052 | 284 | obj_raw_syment_count (abfd) = | 2053 | 284 | obj_conv_table_size (abfd) = | 2054 | 284 | 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 | 284 | return coff; | 2098 | 284 | } |
|
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 | 75.5k | { |
2111 | 75.5k | unsigned long machine; |
2112 | 75.5k | enum bfd_architecture arch; |
2113 | 75.5k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; |
2114 | | |
2115 | | /* Zero selects the default machine for an arch. */ |
2116 | 75.5k | machine = 0; |
2117 | 75.5k | switch (internal_f->f_magic) |
2118 | 75.5k | { |
2119 | | #ifdef I386MAGIC |
2120 | 42 | case I386MAGIC: |
2121 | 244 | case I386PTXMAGIC: |
2122 | 340 | case I386AIXMAGIC: /* Danbury PS/2 AIX C Compiler. */ |
2123 | 5.50k | case LYNXCOFFMAGIC: |
2124 | 5.54k | case I386_APPLE_MAGIC: |
2125 | 5.56k | case I386_FREEBSD_MAGIC: |
2126 | 5.56k | case I386_LINUX_MAGIC: |
2127 | 5.56k | case I386_NETBSD_MAGIC: |
2128 | 5.56k | arch = bfd_arch_i386; |
2129 | 5.56k | break; |
2130 | 0 | #endif |
2131 | | #ifdef AMD64MAGIC |
2132 | 660 | case AMD64MAGIC: |
2133 | 1.85k | case AMD64_APPLE_MAGIC: |
2134 | 1.85k | case AMD64_FREEBSD_MAGIC: |
2135 | 1.85k | case AMD64_LINUX_MAGIC: |
2136 | 1.88k | case AMD64_NETBSD_MAGIC: |
2137 | 1.88k | arch = bfd_arch_i386; |
2138 | 1.88k | machine = bfd_mach_x86_64; |
2139 | 1.88k | break; |
2140 | 0 | #endif |
2141 | | #ifdef IA64MAGIC |
2142 | 13.8k | case IA64MAGIC: |
2143 | 13.8k | arch = bfd_arch_ia64; |
2144 | 13.8k | break; |
2145 | 0 | #endif |
2146 | | #ifdef ARMMAGIC |
2147 | 19.4k | case ARMMAGIC: |
2148 | 19.5k | case ARMPEMAGIC: |
2149 | 19.5k | case THUMBPEMAGIC: |
2150 | 19.5k | arch = bfd_arch_arm; |
2151 | 19.5k | machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION); |
2152 | 19.5k | if (machine == bfd_mach_arm_unknown) |
2153 | 19.5k | { |
2154 | 19.5k | switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK) |
2155 | 19.5k | { |
2156 | 504 | case F_ARM_2: machine = bfd_mach_arm_2; break; |
2157 | 1.06k | case F_ARM_2a: machine = bfd_mach_arm_2a; break; |
2158 | 996 | case F_ARM_3: machine = bfd_mach_arm_3; break; |
2159 | 12.4k | default: |
2160 | 12.4k | case F_ARM_3M: machine = bfd_mach_arm_3M; break; |
2161 | 1.48k | case F_ARM_4: machine = bfd_mach_arm_4; break; |
2162 | 1.50k | 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 | 1.48k | case F_ARM_5: machine = bfd_mach_arm_XScale; break; |
2169 | 19.5k | } |
2170 | 19.5k | } |
2171 | 19.5k | break; |
2172 | 19.5k | #endif |
2173 | | #ifdef AARCH64MAGIC |
2174 | 7.37k | case AARCH64MAGIC: |
2175 | 7.37k | arch = bfd_arch_aarch64; |
2176 | 7.37k | machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK; |
2177 | 7.37k | break; |
2178 | 0 | #endif |
2179 | | #ifdef LOONGARCH64MAGIC |
2180 | 364 | case LOONGARCH64MAGIC: |
2181 | 364 | arch = bfd_arch_loongarch; |
2182 | 364 | machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK; |
2183 | 364 | break; |
2184 | 0 | #endif |
2185 | | #ifdef Z80MAGIC |
2186 | 294 | case Z80MAGIC: |
2187 | 294 | arch = bfd_arch_z80; |
2188 | 294 | switch (internal_f->f_flags & F_MACHMASK) |
2189 | 294 | { |
2190 | 2 | case bfd_mach_z80strict << 12: |
2191 | 232 | case bfd_mach_z80 << 12: |
2192 | 234 | case bfd_mach_z80n << 12: |
2193 | 236 | case bfd_mach_z80full << 12: |
2194 | 238 | case bfd_mach_r800 << 12: |
2195 | 240 | case bfd_mach_gbz80 << 12: |
2196 | 278 | case bfd_mach_z180 << 12: |
2197 | 280 | case bfd_mach_ez80_z80 << 12: |
2198 | 292 | case bfd_mach_ez80_adl << 12: |
2199 | 292 | machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12; |
2200 | 292 | break; |
2201 | 2 | default: |
2202 | 2 | return false; |
2203 | 294 | } |
2204 | 292 | break; |
2205 | 292 | #endif |
2206 | | #ifdef Z8KMAGIC |
2207 | 282 | case Z8KMAGIC: |
2208 | 282 | arch = bfd_arch_z8k; |
2209 | 282 | switch (internal_f->f_flags & F_MACHMASK) |
2210 | 282 | { |
2211 | 182 | case F_Z8001: |
2212 | 182 | machine = bfd_mach_z8001; |
2213 | 182 | break; |
2214 | 92 | case F_Z8002: |
2215 | 92 | machine = bfd_mach_z8002; |
2216 | 92 | break; |
2217 | 8 | default: |
2218 | 8 | return false; |
2219 | 282 | } |
2220 | 274 | break; |
2221 | 274 | #endif |
2222 | | |
2223 | | #ifdef RS6000COFF_C |
2224 | | #ifdef XCOFF64 |
2225 | 396 | case U64_TOCMAGIC: |
2226 | 432 | case U803XTOCMAGIC: |
2227 | | #else |
2228 | 400 | case U802ROMAGIC: |
2229 | 402 | case U802WRMAGIC: |
2230 | 408 | case U802TOCMAGIC: |
2231 | | #endif |
2232 | 408 | { |
2233 | 408 | int cputype; |
2234 | | |
2235 | 840 | if (xcoff_data (abfd)->cputype != -1) |
2236 | 130 | cputype = xcoff_data (abfd)->cputype & 0xff; |
2237 | 710 | else |
2238 | 710 | { |
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 | 710 | if (obj_raw_syment_count (abfd) == 0) |
2244 | 292 | cputype = 0; |
2245 | 418 | else |
2246 | 418 | { |
2247 | 418 | bfd_byte *buf; |
2248 | 418 | struct internal_syment sym; |
2249 | 418 | bfd_size_type amt = bfd_coff_symesz (abfd); |
2250 | | |
2251 | 418 | if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0) |
2252 | 4 | return false; |
2253 | 414 | buf = _bfd_malloc_and_read (abfd, amt, amt); |
2254 | 414 | if (buf == NULL) |
2255 | 10 | return false; |
2256 | 404 | bfd_coff_swap_sym_in (abfd, buf, & sym); |
2257 | 404 | if (sym.n_sclass == C_FILE) |
2258 | 36 | cputype = sym.n_type & 0xff; |
2259 | 368 | else |
2260 | 368 | cputype = 0; |
2261 | 404 | free (buf); |
2262 | 404 | } |
2263 | 710 | } |
2264 | | |
2265 | | /* FIXME: We don't handle all cases here. */ |
2266 | 826 | switch (cputype) |
2267 | 826 | { |
2268 | 82 | default: |
2269 | 786 | case 0: |
2270 | 786 | arch = bfd_xcoff_architecture (abfd); |
2271 | 786 | machine = bfd_xcoff_machine (abfd); |
2272 | 786 | break; |
2273 | | |
2274 | 14 | case 1: |
2275 | 14 | arch = bfd_arch_powerpc; |
2276 | 14 | machine = bfd_mach_ppc_601; |
2277 | 14 | break; |
2278 | 4 | case 2: /* 64 bit PowerPC */ |
2279 | 4 | arch = bfd_arch_powerpc; |
2280 | 4 | machine = bfd_mach_ppc_620; |
2281 | 4 | break; |
2282 | 10 | case 3: |
2283 | 10 | arch = bfd_arch_powerpc; |
2284 | 10 | machine = bfd_mach_ppc; |
2285 | 10 | break; |
2286 | 12 | case 4: |
2287 | 12 | arch = bfd_arch_rs6000; |
2288 | 12 | machine = bfd_mach_rs6k; |
2289 | 12 | break; |
2290 | 826 | } |
2291 | 826 | } |
2292 | 826 | break; |
2293 | 826 | #endif |
2294 | | |
2295 | | #ifdef SH_ARCH_MAGIC_BIG |
2296 | 11.7k | case SH_ARCH_MAGIC_BIG: |
2297 | 11.8k | case SH_ARCH_MAGIC_LITTLE: |
2298 | | #ifdef COFF_WITH_PE |
2299 | 11.8k | case SH_ARCH_MAGIC_WINCE: |
2300 | | #endif |
2301 | 11.8k | arch = bfd_arch_sh; |
2302 | 11.8k | 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 | 268 | case TIC30MAGIC: |
2322 | 268 | arch = bfd_arch_tic30; |
2323 | 268 | 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 | 506 | case TICOFF0MAGIC: |
2330 | 506 | arch = TICOFF_TARGET_ARCH; |
2331 | 506 | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); |
2332 | 506 | 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 | 8 | case TICOFF1MAGIC: |
2340 | 12 | case TICOFF2MAGIC: |
2341 | 12 | switch (internal_f->f_target_id) |
2342 | 12 | { |
2343 | 0 | #ifdef TI_TARGET_ID |
2344 | 12 | case TI_TARGET_ID: |
2345 | 12 | arch = TICOFF_TARGET_ARCH; |
2346 | 12 | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); |
2347 | 12 | 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 | 12 | } |
2356 | 12 | break; |
2357 | 12 | #endif |
2358 | | |
2359 | | #ifdef MCOREMAGIC |
2360 | 12.3k | case MCOREMAGIC: |
2361 | 12.3k | arch = bfd_arch_mcore; |
2362 | 12.3k | break; |
2363 | 0 | #endif |
2364 | | |
2365 | 230 | default: /* Unreadable input file type. */ |
2366 | 230 | arch = bfd_arch_obscure; |
2367 | 230 | break; |
2368 | 75.5k | } |
2369 | | |
2370 | 75.5k | bfd_default_set_arch_mach (abfd, arch, machine); |
2371 | 75.5k | return true; |
2372 | 75.5k | } pei-i386.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 3.77k | { | 2111 | 3.77k | unsigned long machine; | 2112 | 3.77k | enum bfd_architecture arch; | 2113 | 3.77k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 3.77k | machine = 0; | 2117 | 3.77k | switch (internal_f->f_magic) | 2118 | 3.77k | { | 2119 | 0 | #ifdef I386MAGIC | 2120 | 10 | case I386MAGIC: | 2121 | 12 | case I386PTXMAGIC: | 2122 | 92 | case I386AIXMAGIC: /* Danbury PS/2 AIX C Compiler. */ | 2123 | 3.76k | case LYNXCOFFMAGIC: | 2124 | 3.76k | case I386_APPLE_MAGIC: | 2125 | 3.77k | case I386_FREEBSD_MAGIC: | 2126 | 3.77k | case I386_LINUX_MAGIC: | 2127 | 3.77k | case I386_NETBSD_MAGIC: | 2128 | 3.77k | arch = bfd_arch_i386; | 2129 | 3.77k | 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 | 3.77k | } | 2369 | | | 2370 | 3.77k | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 3.77k | return true; | 2372 | 3.77k | } |
pe-x86_64.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 810 | { | 2111 | 810 | unsigned long machine; | 2112 | 810 | enum bfd_architecture arch; | 2113 | 810 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 810 | machine = 0; | 2117 | 810 | switch (internal_f->f_magic) | 2118 | 810 | { | 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 | 84 | case AMD64MAGIC: | 2133 | 790 | case AMD64_APPLE_MAGIC: | 2134 | 794 | case AMD64_FREEBSD_MAGIC: | 2135 | 794 | case AMD64_LINUX_MAGIC: | 2136 | 810 | case AMD64_NETBSD_MAGIC: | 2137 | 810 | arch = bfd_arch_i386; | 2138 | 810 | machine = bfd_mach_x86_64; | 2139 | 810 | 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 | 810 | } | 2369 | | | 2370 | 810 | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 810 | return true; | 2372 | 810 | } |
pei-x86_64.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 522 | { | 2111 | 522 | unsigned long machine; | 2112 | 522 | enum bfd_architecture arch; | 2113 | 522 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 522 | machine = 0; | 2117 | 522 | switch (internal_f->f_magic) | 2118 | 522 | { | 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 | 522 | case AMD64MAGIC: | 2133 | 522 | case AMD64_APPLE_MAGIC: | 2134 | 522 | case AMD64_FREEBSD_MAGIC: | 2135 | 522 | case AMD64_LINUX_MAGIC: | 2136 | 522 | case AMD64_NETBSD_MAGIC: | 2137 | 522 | arch = bfd_arch_i386; | 2138 | 522 | machine = bfd_mach_x86_64; | 2139 | 522 | 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 | 522 | } | 2369 | | | 2370 | 522 | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 522 | return true; | 2372 | 522 | } |
coff-x86_64.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 552 | { | 2111 | 552 | unsigned long machine; | 2112 | 552 | enum bfd_architecture arch; | 2113 | 552 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 552 | machine = 0; | 2117 | 552 | switch (internal_f->f_magic) | 2118 | 552 | { | 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 | 54 | case AMD64MAGIC: | 2133 | 540 | case AMD64_APPLE_MAGIC: | 2134 | 542 | case AMD64_FREEBSD_MAGIC: | 2135 | 542 | case AMD64_LINUX_MAGIC: | 2136 | 552 | case AMD64_NETBSD_MAGIC: | 2137 | 552 | arch = bfd_arch_i386; | 2138 | 552 | machine = bfd_mach_x86_64; | 2139 | 552 | 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 | 552 | } | 2369 | | | 2370 | 552 | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 552 | return true; | 2372 | 552 | } |
coff64-rs6000.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 432 | { | 2111 | 432 | unsigned long machine; | 2112 | 432 | enum bfd_architecture arch; | 2113 | 432 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 432 | machine = 0; | 2117 | 432 | switch (internal_f->f_magic) | 2118 | 432 | { | 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 | 396 | case U64_TOCMAGIC: | 2226 | 432 | case U803XTOCMAGIC: | 2227 | | #else | 2228 | | case U802ROMAGIC: | 2229 | | case U802WRMAGIC: | 2230 | | case U802TOCMAGIC: | 2231 | | #endif | 2232 | 432 | { | 2233 | 432 | int cputype; | 2234 | | | 2235 | 432 | if (xcoff_data (abfd)->cputype != -1) | 2236 | 56 | cputype = xcoff_data (abfd)->cputype & 0xff; | 2237 | 376 | else | 2238 | 376 | { | 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 | 376 | if (obj_raw_syment_count (abfd) == 0) | 2244 | 198 | cputype = 0; | 2245 | 178 | else | 2246 | 178 | { | 2247 | 178 | bfd_byte *buf; | 2248 | 178 | struct internal_syment sym; | 2249 | 178 | bfd_size_type amt = bfd_coff_symesz (abfd); | 2250 | | | 2251 | 178 | if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0) | 2252 | 4 | return false; | 2253 | 174 | buf = _bfd_malloc_and_read (abfd, amt, amt); | 2254 | 174 | if (buf == NULL) | 2255 | 4 | return false; | 2256 | 170 | bfd_coff_swap_sym_in (abfd, buf, & sym); | 2257 | 170 | if (sym.n_sclass == C_FILE) | 2258 | 16 | cputype = sym.n_type & 0xff; | 2259 | 154 | else | 2260 | 154 | cputype = 0; | 2261 | 170 | free (buf); | 2262 | 170 | } | 2263 | 376 | } | 2264 | | | 2265 | | /* FIXME: We don't handle all cases here. */ | 2266 | 424 | switch (cputype) | 2267 | 424 | { | 2268 | 42 | default: | 2269 | 414 | case 0: | 2270 | 414 | arch = bfd_xcoff_architecture (abfd); | 2271 | 414 | machine = bfd_xcoff_machine (abfd); | 2272 | 414 | break; | 2273 | | | 2274 | 2 | case 1: | 2275 | 2 | arch = bfd_arch_powerpc; | 2276 | 2 | machine = bfd_mach_ppc_601; | 2277 | 2 | 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 | 424 | } | 2291 | 424 | } | 2292 | 424 | break; | 2293 | 424 | #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 | 424 | default: /* Unreadable input file type. */ | 2366 | 0 | arch = bfd_arch_obscure; | 2367 | 0 | break; | 2368 | 432 | } | 2369 | | | 2370 | 424 | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 424 | return true; | 2372 | 432 | } |
pei-aarch64.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 6.10k | { | 2111 | 6.10k | unsigned long machine; | 2112 | 6.10k | enum bfd_architecture arch; | 2113 | 6.10k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 6.10k | machine = 0; | 2117 | 6.10k | switch (internal_f->f_magic) | 2118 | 6.10k | { | 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 | 6.10k | case AARCH64MAGIC: | 2175 | 6.10k | arch = bfd_arch_aarch64; | 2176 | 6.10k | machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK; | 2177 | 6.10k | 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 | 6.10k | } | 2369 | | | 2370 | 6.10k | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 6.10k | return true; | 2372 | 6.10k | } |
pe-aarch64.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 1.27k | { | 2111 | 1.27k | unsigned long machine; | 2112 | 1.27k | enum bfd_architecture arch; | 2113 | 1.27k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 1.27k | machine = 0; | 2117 | 1.27k | switch (internal_f->f_magic) | 2118 | 1.27k | { | 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 | 1.27k | case AARCH64MAGIC: | 2175 | 1.27k | arch = bfd_arch_aarch64; | 2176 | 1.27k | machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK; | 2177 | 1.27k | 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 | 1.27k | } | 2369 | | | 2370 | 1.27k | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 1.27k | return true; | 2372 | 1.27k | } |
pei-ia64.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 13.8k | { | 2111 | 13.8k | unsigned long machine; | 2112 | 13.8k | enum bfd_architecture arch; | 2113 | 13.8k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 13.8k | machine = 0; | 2117 | 13.8k | switch (internal_f->f_magic) | 2118 | 13.8k | { | 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 | 13.8k | case IA64MAGIC: | 2143 | 13.8k | arch = bfd_arch_ia64; | 2144 | 13.8k | 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 | 13.8k | } | 2369 | | | 2370 | 13.8k | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 13.8k | return true; | 2372 | 13.8k | } |
pei-loongarch64.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 364 | { | 2111 | 364 | unsigned long machine; | 2112 | 364 | enum bfd_architecture arch; | 2113 | 364 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 364 | machine = 0; | 2117 | 364 | switch (internal_f->f_magic) | 2118 | 364 | { | 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 | 364 | case LOONGARCH64MAGIC: | 2181 | 364 | arch = bfd_arch_loongarch; | 2182 | 364 | machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK; | 2183 | 364 | 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 | 364 | } | 2369 | | | 2370 | 364 | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 364 | return true; | 2372 | 364 | } |
cf-i386lynx.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 416 | { | 2111 | 416 | unsigned long machine; | 2112 | 416 | enum bfd_architecture arch; | 2113 | 416 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 416 | machine = 0; | 2117 | 416 | switch (internal_f->f_magic) | 2118 | 416 | { | 2119 | 0 | #ifdef I386MAGIC | 2120 | 8 | case I386MAGIC: | 2121 | 58 | case I386PTXMAGIC: | 2122 | 62 | case I386AIXMAGIC: /* Danbury PS/2 AIX C Compiler. */ | 2123 | 402 | case LYNXCOFFMAGIC: | 2124 | 412 | case I386_APPLE_MAGIC: | 2125 | 414 | case I386_FREEBSD_MAGIC: | 2126 | 414 | case I386_LINUX_MAGIC: | 2127 | 416 | case I386_NETBSD_MAGIC: | 2128 | 416 | arch = bfd_arch_i386; | 2129 | 416 | 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 | 416 | } | 2369 | | | 2370 | 416 | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 416 | return true; | 2372 | 416 | } |
coff-go32.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 416 | { | 2111 | 416 | unsigned long machine; | 2112 | 416 | enum bfd_architecture arch; | 2113 | 416 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 416 | machine = 0; | 2117 | 416 | switch (internal_f->f_magic) | 2118 | 416 | { | 2119 | 0 | #ifdef I386MAGIC | 2120 | 8 | case I386MAGIC: | 2121 | 58 | case I386PTXMAGIC: | 2122 | 62 | case I386AIXMAGIC: /* Danbury PS/2 AIX C Compiler. */ | 2123 | 402 | case LYNXCOFFMAGIC: | 2124 | 412 | case I386_APPLE_MAGIC: | 2125 | 414 | case I386_FREEBSD_MAGIC: | 2126 | 414 | case I386_LINUX_MAGIC: | 2127 | 416 | case I386_NETBSD_MAGIC: | 2128 | 416 | arch = bfd_arch_i386; | 2129 | 416 | 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 | 416 | } | 2369 | | | 2370 | 416 | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 416 | return true; | 2372 | 416 | } |
coff-i386.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 416 | { | 2111 | 416 | unsigned long machine; | 2112 | 416 | enum bfd_architecture arch; | 2113 | 416 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 416 | machine = 0; | 2117 | 416 | switch (internal_f->f_magic) | 2118 | 416 | { | 2119 | 0 | #ifdef I386MAGIC | 2120 | 8 | case I386MAGIC: | 2121 | 58 | case I386PTXMAGIC: | 2122 | 62 | case I386AIXMAGIC: /* Danbury PS/2 AIX C Compiler. */ | 2123 | 402 | case LYNXCOFFMAGIC: | 2124 | 412 | case I386_APPLE_MAGIC: | 2125 | 414 | case I386_FREEBSD_MAGIC: | 2126 | 414 | case I386_LINUX_MAGIC: | 2127 | 416 | case I386_NETBSD_MAGIC: | 2128 | 416 | arch = bfd_arch_i386; | 2129 | 416 | 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 | 416 | } | 2369 | | | 2370 | 416 | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 416 | return true; | 2372 | 416 | } |
coff-rs6000.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 408 | { | 2111 | 408 | unsigned long machine; | 2112 | 408 | enum bfd_architecture arch; | 2113 | 408 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 408 | machine = 0; | 2117 | 408 | switch (internal_f->f_magic) | 2118 | 408 | { | 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 | 400 | case U802ROMAGIC: | 2229 | 402 | case U802WRMAGIC: | 2230 | 408 | case U802TOCMAGIC: | 2231 | 408 | #endif | 2232 | 408 | { | 2233 | 408 | int cputype; | 2234 | | | 2235 | 408 | if (xcoff_data (abfd)->cputype != -1) | 2236 | 74 | cputype = xcoff_data (abfd)->cputype & 0xff; | 2237 | 334 | else | 2238 | 334 | { | 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 | 334 | if (obj_raw_syment_count (abfd) == 0) | 2244 | 94 | cputype = 0; | 2245 | 240 | else | 2246 | 240 | { | 2247 | 240 | bfd_byte *buf; | 2248 | 240 | struct internal_syment sym; | 2249 | 240 | bfd_size_type amt = bfd_coff_symesz (abfd); | 2250 | | | 2251 | 240 | if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0) | 2252 | 0 | return false; | 2253 | 240 | buf = _bfd_malloc_and_read (abfd, amt, amt); | 2254 | 240 | if (buf == NULL) | 2255 | 6 | return false; | 2256 | 234 | bfd_coff_swap_sym_in (abfd, buf, & sym); | 2257 | 234 | if (sym.n_sclass == C_FILE) | 2258 | 20 | cputype = sym.n_type & 0xff; | 2259 | 214 | else | 2260 | 214 | cputype = 0; | 2261 | 234 | free (buf); | 2262 | 234 | } | 2263 | 334 | } | 2264 | | | 2265 | | /* FIXME: We don't handle all cases here. */ | 2266 | 402 | switch (cputype) | 2267 | 402 | { | 2268 | 40 | default: | 2269 | 372 | case 0: | 2270 | 372 | arch = bfd_xcoff_architecture (abfd); | 2271 | 372 | machine = bfd_xcoff_machine (abfd); | 2272 | 372 | break; | 2273 | | | 2274 | 12 | case 1: | 2275 | 12 | arch = bfd_arch_powerpc; | 2276 | 12 | machine = bfd_mach_ppc_601; | 2277 | 12 | 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 | 6 | case 3: | 2283 | 6 | arch = bfd_arch_powerpc; | 2284 | 6 | machine = bfd_mach_ppc; | 2285 | 6 | break; | 2286 | 10 | case 4: | 2287 | 10 | arch = bfd_arch_rs6000; | 2288 | 10 | machine = bfd_mach_rs6k; | 2289 | 10 | break; | 2290 | 402 | } | 2291 | 402 | } | 2292 | 402 | break; | 2293 | 402 | #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 | 402 | default: /* Unreadable input file type. */ | 2366 | 0 | arch = bfd_arch_obscure; | 2367 | 0 | break; | 2368 | 408 | } | 2369 | | | 2370 | 402 | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 402 | return true; | 2372 | 408 | } |
coff-sh.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 504 | { | 2111 | 504 | unsigned long machine; | 2112 | 504 | enum bfd_architecture arch; | 2113 | 504 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 504 | machine = 0; | 2117 | 504 | switch (internal_f->f_magic) | 2118 | 504 | { | 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 | 310 | case SH_ARCH_MAGIC_BIG: | 2297 | 312 | case SH_ARCH_MAGIC_LITTLE: | 2298 | | #ifdef COFF_WITH_PE | 2299 | | case SH_ARCH_MAGIC_WINCE: | 2300 | | #endif | 2301 | 312 | arch = bfd_arch_sh; | 2302 | 312 | 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 | 192 | default: /* Unreadable input file type. */ | 2366 | 192 | arch = bfd_arch_obscure; | 2367 | 192 | break; | 2368 | 504 | } | 2369 | | | 2370 | 504 | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 504 | return true; | 2372 | 504 | } |
Unexecuted instantiation: coff-stgo32.c:coff_set_arch_mach_hook coff-tic30.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 268 | { | 2111 | 268 | unsigned long machine; | 2112 | 268 | enum bfd_architecture arch; | 2113 | 268 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 268 | machine = 0; | 2117 | 268 | switch (internal_f->f_magic) | 2118 | 268 | { | 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 | 268 | case TIC30MAGIC: | 2322 | 268 | arch = bfd_arch_tic30; | 2323 | 268 | 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 | 268 | } | 2369 | | | 2370 | 268 | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 268 | return true; | 2372 | 268 | } |
Unexecuted instantiation: coff-tic4x.c:coff_set_arch_mach_hook coff-tic54x.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 518 | { | 2111 | 518 | unsigned long machine; | 2112 | 518 | enum bfd_architecture arch; | 2113 | 518 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 518 | machine = 0; | 2117 | 518 | switch (internal_f->f_magic) | 2118 | 518 | { | 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 | 506 | case TICOFF0MAGIC: | 2330 | 506 | arch = TICOFF_TARGET_ARCH; | 2331 | 506 | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2332 | 506 | 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 | 8 | case TICOFF1MAGIC: | 2340 | 12 | case TICOFF2MAGIC: | 2341 | 12 | switch (internal_f->f_target_id) | 2342 | 12 | { | 2343 | 0 | #ifdef TI_TARGET_ID | 2344 | 12 | case TI_TARGET_ID: | 2345 | 12 | arch = TICOFF_TARGET_ARCH; | 2346 | 12 | machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags); | 2347 | 12 | 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 | 12 | } | 2356 | 12 | break; | 2357 | 12 | #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 | 0 | arch = bfd_arch_obscure; | 2367 | 0 | break; | 2368 | 518 | } | 2369 | | | 2370 | 518 | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 518 | return true; | 2372 | 518 | } |
coff-z80.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 294 | { | 2111 | 294 | unsigned long machine; | 2112 | 294 | enum bfd_architecture arch; | 2113 | 294 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 294 | machine = 0; | 2117 | 294 | switch (internal_f->f_magic) | 2118 | 294 | { | 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 | 294 | case Z80MAGIC: | 2187 | 294 | arch = bfd_arch_z80; | 2188 | 294 | switch (internal_f->f_flags & F_MACHMASK) | 2189 | 294 | { | 2190 | 2 | case bfd_mach_z80strict << 12: | 2191 | 232 | case bfd_mach_z80 << 12: | 2192 | 234 | case bfd_mach_z80n << 12: | 2193 | 236 | case bfd_mach_z80full << 12: | 2194 | 238 | case bfd_mach_r800 << 12: | 2195 | 240 | case bfd_mach_gbz80 << 12: | 2196 | 278 | case bfd_mach_z180 << 12: | 2197 | 280 | case bfd_mach_ez80_z80 << 12: | 2198 | 292 | case bfd_mach_ez80_adl << 12: | 2199 | 292 | machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12; | 2200 | 292 | break; | 2201 | 2 | default: | 2202 | 2 | return false; | 2203 | 294 | } | 2204 | 292 | break; | 2205 | 292 | #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 | 292 | default: /* Unreadable input file type. */ | 2366 | 0 | arch = bfd_arch_obscure; | 2367 | 0 | break; | 2368 | 294 | } | 2369 | | | 2370 | 292 | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 292 | return true; | 2372 | 294 | } |
coff-z8k.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 | | #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 | 282 | case Z8KMAGIC: | 2208 | 282 | arch = bfd_arch_z8k; | 2209 | 282 | switch (internal_f->f_flags & F_MACHMASK) | 2210 | 282 | { | 2211 | 182 | case F_Z8001: | 2212 | 182 | machine = bfd_mach_z8001; | 2213 | 182 | break; | 2214 | 92 | case F_Z8002: | 2215 | 92 | machine = bfd_mach_z8002; | 2216 | 92 | break; | 2217 | 8 | default: | 2218 | 8 | return false; | 2219 | 282 | } | 2220 | 274 | break; | 2221 | 274 | #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 | 274 | default: /* Unreadable input file type. */ | 2366 | 0 | arch = bfd_arch_obscure; | 2367 | 0 | break; | 2368 | 282 | } | 2369 | | | 2370 | 274 | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 274 | return true; | 2372 | 282 | } |
pe-arm-wince.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 324 | { | 2111 | 324 | unsigned long machine; | 2112 | 324 | enum bfd_architecture arch; | 2113 | 324 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 324 | machine = 0; | 2117 | 324 | switch (internal_f->f_magic) | 2118 | 324 | { | 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 | 276 | case ARMMAGIC: | 2148 | 302 | case ARMPEMAGIC: | 2149 | 310 | case THUMBPEMAGIC: | 2150 | 310 | arch = bfd_arch_arm; | 2151 | 310 | machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION); | 2152 | 310 | if (machine == bfd_mach_arm_unknown) | 2153 | 310 | { | 2154 | 310 | switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK) | 2155 | 310 | { | 2156 | 6 | case F_ARM_2: machine = bfd_mach_arm_2; break; | 2157 | 22 | case F_ARM_2a: machine = bfd_mach_arm_2a; break; | 2158 | 16 | case F_ARM_3: machine = bfd_mach_arm_3; break; | 2159 | 206 | default: | 2160 | 208 | case F_ARM_3M: machine = bfd_mach_arm_3M; break; | 2161 | 14 | case F_ARM_4: machine = bfd_mach_arm_4; break; | 2162 | 24 | 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 | 20 | case F_ARM_5: machine = bfd_mach_arm_XScale; break; | 2169 | 310 | } | 2170 | 310 | } | 2171 | 310 | break; | 2172 | 310 | #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 | 310 | default: /* Unreadable input file type. */ | 2366 | 14 | arch = bfd_arch_obscure; | 2367 | 14 | break; | 2368 | 324 | } | 2369 | | | 2370 | 324 | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 324 | return true; | 2372 | 324 | } |
pe-arm.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 324 | { | 2111 | 324 | unsigned long machine; | 2112 | 324 | enum bfd_architecture arch; | 2113 | 324 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 324 | machine = 0; | 2117 | 324 | switch (internal_f->f_magic) | 2118 | 324 | { | 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 | 276 | case ARMMAGIC: | 2148 | 302 | case ARMPEMAGIC: | 2149 | 310 | case THUMBPEMAGIC: | 2150 | 310 | arch = bfd_arch_arm; | 2151 | 310 | machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION); | 2152 | 310 | if (machine == bfd_mach_arm_unknown) | 2153 | 310 | { | 2154 | 310 | switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK) | 2155 | 310 | { | 2156 | 6 | case F_ARM_2: machine = bfd_mach_arm_2; break; | 2157 | 22 | case F_ARM_2a: machine = bfd_mach_arm_2a; break; | 2158 | 16 | case F_ARM_3: machine = bfd_mach_arm_3; break; | 2159 | 206 | default: | 2160 | 208 | case F_ARM_3M: machine = bfd_mach_arm_3M; break; | 2161 | 14 | case F_ARM_4: machine = bfd_mach_arm_4; break; | 2162 | 24 | 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 | 20 | case F_ARM_5: machine = bfd_mach_arm_XScale; break; | 2169 | 310 | } | 2170 | 310 | } | 2171 | 310 | break; | 2172 | 310 | #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 | 310 | default: /* Unreadable input file type. */ | 2366 | 14 | arch = bfd_arch_obscure; | 2367 | 14 | break; | 2368 | 324 | } | 2369 | | | 2370 | 324 | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 324 | return true; | 2372 | 324 | } |
pe-i386.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 550 | { | 2111 | 550 | unsigned long machine; | 2112 | 550 | enum bfd_architecture arch; | 2113 | 550 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 550 | machine = 0; | 2117 | 550 | switch (internal_f->f_magic) | 2118 | 550 | { | 2119 | 0 | #ifdef I386MAGIC | 2120 | 8 | case I386MAGIC: | 2121 | 58 | case I386PTXMAGIC: | 2122 | 62 | case I386AIXMAGIC: /* Danbury PS/2 AIX C Compiler. */ | 2123 | 536 | case LYNXCOFFMAGIC: | 2124 | 546 | case I386_APPLE_MAGIC: | 2125 | 548 | case I386_FREEBSD_MAGIC: | 2126 | 548 | case I386_LINUX_MAGIC: | 2127 | 550 | case I386_NETBSD_MAGIC: | 2128 | 550 | arch = bfd_arch_i386; | 2129 | 550 | 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 | 550 | } | 2369 | | | 2370 | 550 | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 550 | return true; | 2372 | 550 | } |
pe-mcore.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 3.94k | { | 2111 | 3.94k | unsigned long machine; | 2112 | 3.94k | enum bfd_architecture arch; | 2113 | 3.94k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 3.94k | machine = 0; | 2117 | 3.94k | switch (internal_f->f_magic) | 2118 | 3.94k | { | 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 | 3.94k | case MCOREMAGIC: | 2361 | 3.94k | arch = bfd_arch_mcore; | 2362 | 3.94k | break; | 2363 | 0 | #endif | 2364 | | | 2365 | 0 | default: /* Unreadable input file type. */ | 2366 | 0 | arch = bfd_arch_obscure; | 2367 | 0 | break; | 2368 | 3.94k | } | 2369 | | | 2370 | 3.94k | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 3.94k | return true; | 2372 | 3.94k | } |
pe-sh.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 3.87k | { | 2111 | 3.87k | unsigned long machine; | 2112 | 3.87k | enum bfd_architecture arch; | 2113 | 3.87k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 3.87k | machine = 0; | 2117 | 3.87k | switch (internal_f->f_magic) | 2118 | 3.87k | { | 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 | 3.53k | case SH_ARCH_MAGIC_BIG: | 2297 | 3.53k | case SH_ARCH_MAGIC_LITTLE: | 2298 | 3.53k | #ifdef COFF_WITH_PE | 2299 | 3.87k | case SH_ARCH_MAGIC_WINCE: | 2300 | 3.87k | #endif | 2301 | 3.87k | arch = bfd_arch_sh; | 2302 | 3.87k | 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 | 3.87k | } | 2369 | | | 2370 | 3.87k | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 3.87k | return true; | 2372 | 3.87k | } |
pei-arm-wince.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 9.41k | { | 2111 | 9.41k | unsigned long machine; | 2112 | 9.41k | enum bfd_architecture arch; | 2113 | 9.41k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 9.41k | machine = 0; | 2117 | 9.41k | switch (internal_f->f_magic) | 2118 | 9.41k | { | 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 | 9.38k | case ARMMAGIC: | 2148 | 9.40k | case ARMPEMAGIC: | 2149 | 9.40k | case THUMBPEMAGIC: | 2150 | 9.40k | arch = bfd_arch_arm; | 2151 | 9.40k | machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION); | 2152 | 9.40k | if (machine == bfd_mach_arm_unknown) | 2153 | 9.40k | { | 2154 | 9.40k | switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK) | 2155 | 9.40k | { | 2156 | 6 | case F_ARM_2: machine = bfd_mach_arm_2; break; | 2157 | 30 | case F_ARM_2a: machine = bfd_mach_arm_2a; break; | 2158 | 482 | case F_ARM_3: machine = bfd_mach_arm_3; break; | 2159 | 7.42k | default: | 2160 | 7.42k | case F_ARM_3M: machine = bfd_mach_arm_3M; break; | 2161 | 486 | case F_ARM_4: machine = bfd_mach_arm_4; break; | 2162 | 492 | 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 | 484 | case F_ARM_5: machine = bfd_mach_arm_XScale; break; | 2169 | 9.40k | } | 2170 | 9.40k | } | 2171 | 9.40k | break; | 2172 | 9.40k | #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 | 9.40k | default: /* Unreadable input file type. */ | 2366 | 2 | arch = bfd_arch_obscure; | 2367 | 2 | break; | 2368 | 9.41k | } | 2369 | | | 2370 | 9.41k | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 9.41k | return true; | 2372 | 9.41k | } |
pei-arm.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 9.51k | { | 2111 | 9.51k | unsigned long machine; | 2112 | 9.51k | enum bfd_architecture arch; | 2113 | 9.51k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 9.51k | machine = 0; | 2117 | 9.51k | switch (internal_f->f_magic) | 2118 | 9.51k | { | 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 | 9.48k | case ARMMAGIC: | 2148 | 9.50k | case ARMPEMAGIC: | 2149 | 9.51k | case THUMBPEMAGIC: | 2150 | 9.51k | arch = bfd_arch_arm; | 2151 | 9.51k | machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION); | 2152 | 9.51k | if (machine == bfd_mach_arm_unknown) | 2153 | 9.51k | { | 2154 | 9.51k | switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK) | 2155 | 9.51k | { | 2156 | 486 | case F_ARM_2: machine = bfd_mach_arm_2; break; | 2157 | 992 | case F_ARM_2a: machine = bfd_mach_arm_2a; break; | 2158 | 482 | case F_ARM_3: machine = bfd_mach_arm_3; break; | 2159 | 4.64k | default: | 2160 | 4.65k | case F_ARM_3M: machine = bfd_mach_arm_3M; break; | 2161 | 970 | case F_ARM_4: machine = bfd_mach_arm_4; break; | 2162 | 966 | 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 | 964 | case F_ARM_5: machine = bfd_mach_arm_XScale; break; | 2169 | 9.51k | } | 2170 | 9.51k | } | 2171 | 9.51k | break; | 2172 | 9.51k | #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 | 9.51k | default: /* Unreadable input file type. */ | 2366 | 8 | arch = bfd_arch_obscure; | 2367 | 8 | break; | 2368 | 9.51k | } | 2369 | | | 2370 | 9.51k | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 9.51k | return true; | 2372 | 9.51k | } |
pei-mcore.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 8.42k | { | 2111 | 8.42k | unsigned long machine; | 2112 | 8.42k | enum bfd_architecture arch; | 2113 | 8.42k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 8.42k | machine = 0; | 2117 | 8.42k | switch (internal_f->f_magic) | 2118 | 8.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 | | #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 | 8.42k | case MCOREMAGIC: | 2361 | 8.42k | arch = bfd_arch_mcore; | 2362 | 8.42k | break; | 2363 | 0 | #endif | 2364 | | | 2365 | 0 | default: /* Unreadable input file type. */ | 2366 | 0 | arch = bfd_arch_obscure; | 2367 | 0 | break; | 2368 | 8.42k | } | 2369 | | | 2370 | 8.42k | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 8.42k | return true; | 2372 | 8.42k | } |
pei-sh.c:coff_set_arch_mach_hook Line | Count | Source | 2110 | 7.99k | { | 2111 | 7.99k | unsigned long machine; | 2112 | 7.99k | enum bfd_architecture arch; | 2113 | 7.99k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 2114 | | | 2115 | | /* Zero selects the default machine for an arch. */ | 2116 | 7.99k | machine = 0; | 2117 | 7.99k | switch (internal_f->f_magic) | 2118 | 7.99k | { | 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 | 7.92k | case SH_ARCH_MAGIC_BIG: | 2297 | 7.96k | case SH_ARCH_MAGIC_LITTLE: | 2298 | 7.96k | #ifdef COFF_WITH_PE | 2299 | 7.99k | case SH_ARCH_MAGIC_WINCE: | 2300 | 7.99k | #endif | 2301 | 7.99k | arch = bfd_arch_sh; | 2302 | 7.99k | 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 | 7.99k | } | 2369 | | | 2370 | 7.99k | bfd_default_set_arch_mach (abfd, arch, machine); | 2371 | 7.99k | return true; | 2372 | 7.99k | } |
|
2373 | | |
2374 | | static bool |
2375 | | symname_in_debug_hook (bfd *abfd ATTRIBUTE_UNUSED, |
2376 | | struct internal_syment *sym ATTRIBUTE_UNUSED) |
2377 | 922 | { |
2378 | | #ifdef SYMNAME_IN_DEBUG |
2379 | 327 | return SYMNAME_IN_DEBUG (sym) != 0; |
2380 | | #else |
2381 | | return false; |
2382 | | #endif |
2383 | 922 | } pei-i386.c:symname_in_debug_hook Line | Count | Source | 2377 | 17 | { | 2378 | | #ifdef SYMNAME_IN_DEBUG | 2379 | | return SYMNAME_IN_DEBUG (sym) != 0; | 2380 | | #else | 2381 | 17 | return false; | 2382 | 17 | #endif | 2383 | 17 | } |
pe-x86_64.c:symname_in_debug_hook Line | Count | Source | 2377 | 46 | { | 2378 | | #ifdef SYMNAME_IN_DEBUG | 2379 | | return SYMNAME_IN_DEBUG (sym) != 0; | 2380 | | #else | 2381 | 46 | return false; | 2382 | 46 | #endif | 2383 | 46 | } |
pei-x86_64.c:symname_in_debug_hook Line | Count | Source | 2377 | 31 | { | 2378 | | #ifdef SYMNAME_IN_DEBUG | 2379 | | return SYMNAME_IN_DEBUG (sym) != 0; | 2380 | | #else | 2381 | 31 | return false; | 2382 | 31 | #endif | 2383 | 31 | } |
coff-x86_64.c:symname_in_debug_hook Line | Count | Source | 2377 | 19 | { | 2378 | | #ifdef SYMNAME_IN_DEBUG | 2379 | | return SYMNAME_IN_DEBUG (sym) != 0; | 2380 | | #else | 2381 | 19 | return false; | 2382 | 19 | #endif | 2383 | 19 | } |
coff64-rs6000.c:symname_in_debug_hook Line | Count | Source | 2377 | 320 | { | 2378 | 320 | #ifdef SYMNAME_IN_DEBUG | 2379 | 320 | return SYMNAME_IN_DEBUG (sym) != 0; | 2380 | | #else | 2381 | | return false; | 2382 | | #endif | 2383 | 320 | } |
pei-aarch64.c:symname_in_debug_hook Line | Count | Source | 2377 | 27 | { | 2378 | | #ifdef SYMNAME_IN_DEBUG | 2379 | | return SYMNAME_IN_DEBUG (sym) != 0; | 2380 | | #else | 2381 | 27 | return false; | 2382 | 27 | #endif | 2383 | 27 | } |
pe-aarch64.c:symname_in_debug_hook Line | Count | Source | 2377 | 10 | { | 2378 | | #ifdef SYMNAME_IN_DEBUG | 2379 | | return SYMNAME_IN_DEBUG (sym) != 0; | 2380 | | #else | 2381 | 10 | return false; | 2382 | 10 | #endif | 2383 | 10 | } |
pei-ia64.c:symname_in_debug_hook Line | Count | Source | 2377 | 12 | { | 2378 | | #ifdef SYMNAME_IN_DEBUG | 2379 | | return SYMNAME_IN_DEBUG (sym) != 0; | 2380 | | #else | 2381 | 12 | return false; | 2382 | 12 | #endif | 2383 | 12 | } |
pei-loongarch64.c:symname_in_debug_hook Line | Count | Source | 2377 | 65 | { | 2378 | | #ifdef SYMNAME_IN_DEBUG | 2379 | | return SYMNAME_IN_DEBUG (sym) != 0; | 2380 | | #else | 2381 | 65 | return false; | 2382 | 65 | #endif | 2383 | 65 | } |
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 | 7 | { | 2378 | 7 | #ifdef SYMNAME_IN_DEBUG | 2379 | 7 | return SYMNAME_IN_DEBUG (sym) != 0; | 2380 | | #else | 2381 | | return false; | 2382 | | #endif | 2383 | 7 | } |
coff-sh.c:symname_in_debug_hook Line | Count | Source | 2377 | 57 | { | 2378 | | #ifdef SYMNAME_IN_DEBUG | 2379 | | return SYMNAME_IN_DEBUG (sym) != 0; | 2380 | | #else | 2381 | 57 | return false; | 2382 | 57 | #endif | 2383 | 57 | } |
Unexecuted instantiation: coff-stgo32.c:symname_in_debug_hook coff-tic30.c:symname_in_debug_hook Line | Count | Source | 2377 | 13 | { | 2378 | | #ifdef SYMNAME_IN_DEBUG | 2379 | | return SYMNAME_IN_DEBUG (sym) != 0; | 2380 | | #else | 2381 | 13 | return false; | 2382 | 13 | #endif | 2383 | 13 | } |
Unexecuted instantiation: coff-tic4x.c:symname_in_debug_hook coff-tic54x.c:symname_in_debug_hook Line | Count | Source | 2377 | 57 | { | 2378 | | #ifdef SYMNAME_IN_DEBUG | 2379 | | return SYMNAME_IN_DEBUG (sym) != 0; | 2380 | | #else | 2381 | 57 | return false; | 2382 | 57 | #endif | 2383 | 57 | } |
coff-z80.c:symname_in_debug_hook Line | Count | Source | 2377 | 17 | { | 2378 | | #ifdef SYMNAME_IN_DEBUG | 2379 | | return SYMNAME_IN_DEBUG (sym) != 0; | 2380 | | #else | 2381 | 17 | return false; | 2382 | 17 | #endif | 2383 | 17 | } |
coff-z8k.c:symname_in_debug_hook Line | Count | Source | 2377 | 37 | { | 2378 | | #ifdef SYMNAME_IN_DEBUG | 2379 | | return SYMNAME_IN_DEBUG (sym) != 0; | 2380 | | #else | 2381 | 37 | return false; | 2382 | 37 | #endif | 2383 | 37 | } |
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 | 37 | { | 2378 | | #ifdef SYMNAME_IN_DEBUG | 2379 | | return SYMNAME_IN_DEBUG (sym) != 0; | 2380 | | #else | 2381 | 37 | return false; | 2382 | 37 | #endif | 2383 | 37 | } |
pe-mcore.c:symname_in_debug_hook Line | Count | Source | 2377 | 79 | { | 2378 | | #ifdef SYMNAME_IN_DEBUG | 2379 | | return SYMNAME_IN_DEBUG (sym) != 0; | 2380 | | #else | 2381 | 79 | return false; | 2382 | 79 | #endif | 2383 | 79 | } |
pe-sh.c:symname_in_debug_hook Line | Count | Source | 2377 | 40 | { | 2378 | | #ifdef SYMNAME_IN_DEBUG | 2379 | | return SYMNAME_IN_DEBUG (sym) != 0; | 2380 | | #else | 2381 | 40 | return false; | 2382 | 40 | #endif | 2383 | 40 | } |
pei-arm-wince.c:symname_in_debug_hook Line | Count | Source | 2377 | 6 | { | 2378 | | #ifdef SYMNAME_IN_DEBUG | 2379 | | return SYMNAME_IN_DEBUG (sym) != 0; | 2380 | | #else | 2381 | 6 | return false; | 2382 | 6 | #endif | 2383 | 6 | } |
pei-arm.c:symname_in_debug_hook Line | Count | Source | 2377 | 3 | { | 2378 | | #ifdef SYMNAME_IN_DEBUG | 2379 | | return SYMNAME_IN_DEBUG (sym) != 0; | 2380 | | #else | 2381 | 3 | return false; | 2382 | 3 | #endif | 2383 | 3 | } |
pei-mcore.c:symname_in_debug_hook Line | Count | Source | 2377 | 10 | { | 2378 | | #ifdef SYMNAME_IN_DEBUG | 2379 | | return SYMNAME_IN_DEBUG (sym) != 0; | 2380 | | #else | 2381 | 10 | return false; | 2382 | 10 | #endif | 2383 | 10 | } |
pei-sh.c:symname_in_debug_hook Line | Count | Source | 2377 | 12 | { | 2378 | | #ifdef SYMNAME_IN_DEBUG | 2379 | | return SYMNAME_IN_DEBUG (sym) != 0; | 2380 | | #else | 2381 | 12 | return false; | 2382 | 12 | #endif | 2383 | 12 | } |
|
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 | 27.7k | { |
2400 | 27.7k | BFD_ASSERT (symbol->is_sym); |
2401 | 27.7k | int n_sclass = symbol->u.syment.n_sclass; |
2402 | | |
2403 | 27.7k | if (CSECT_SYM_P (n_sclass) |
2404 | 27.7k | && indaux + 1 == symbol->u.syment.n_numaux) |
2405 | 1.12k | { |
2406 | 1.12k | BFD_ASSERT (! aux->is_sym); |
2407 | 1.12k | if (SMTYP_SMTYP (aux->u.auxent.x_csect.x_smtyp) == XTY_LD |
2408 | 1.12k | && aux->u.auxent.x_csect.x_scnlen.u64 < obj_raw_syment_count (abfd)) |
2409 | 14 | { |
2410 | 14 | aux->u.auxent.x_csect.x_scnlen.p = |
2411 | 14 | table_base + aux->u.auxent.x_csect.x_scnlen.u64; |
2412 | 14 | aux->fix_scnlen = 1; |
2413 | 14 | } |
2414 | | |
2415 | | /* Return TRUE to indicate that the caller should not do any |
2416 | | further work on this auxent. */ |
2417 | 1.12k | return true; |
2418 | 1.12k | } |
2419 | | |
2420 | | /* Return FALSE to indicate that this auxent should be handled by |
2421 | | the caller. */ |
2422 | 26.6k | return false; |
2423 | 27.7k | } coff64-rs6000.c:coff_pointerize_aux_hook Line | Count | Source | 2399 | 10.4k | { | 2400 | 10.4k | BFD_ASSERT (symbol->is_sym); | 2401 | 10.4k | int n_sclass = symbol->u.syment.n_sclass; | 2402 | | | 2403 | 10.4k | if (CSECT_SYM_P (n_sclass) | 2404 | 10.4k | && indaux + 1 == symbol->u.syment.n_numaux) | 2405 | 70 | { | 2406 | 70 | BFD_ASSERT (! aux->is_sym); | 2407 | 70 | if (SMTYP_SMTYP (aux->u.auxent.x_csect.x_smtyp) == XTY_LD | 2408 | 70 | && aux->u.auxent.x_csect.x_scnlen.u64 < obj_raw_syment_count (abfd)) | 2409 | 1 | { | 2410 | 1 | aux->u.auxent.x_csect.x_scnlen.p = | 2411 | 1 | table_base + aux->u.auxent.x_csect.x_scnlen.u64; | 2412 | 1 | aux->fix_scnlen = 1; | 2413 | 1 | } | 2414 | | | 2415 | | /* Return TRUE to indicate that the caller should not do any | 2416 | | further work on this auxent. */ | 2417 | 70 | return true; | 2418 | 70 | } | 2419 | | | 2420 | | /* Return FALSE to indicate that this auxent should be handled by | 2421 | | the caller. */ | 2422 | 10.4k | return false; | 2423 | 10.4k | } |
coff-rs6000.c:coff_pointerize_aux_hook Line | Count | Source | 2399 | 17.2k | { | 2400 | 17.2k | BFD_ASSERT (symbol->is_sym); | 2401 | 17.2k | int n_sclass = symbol->u.syment.n_sclass; | 2402 | | | 2403 | 17.2k | if (CSECT_SYM_P (n_sclass) | 2404 | 17.2k | && indaux + 1 == symbol->u.syment.n_numaux) | 2405 | 1.05k | { | 2406 | 1.05k | BFD_ASSERT (! aux->is_sym); | 2407 | 1.05k | if (SMTYP_SMTYP (aux->u.auxent.x_csect.x_smtyp) == XTY_LD | 2408 | 1.05k | && aux->u.auxent.x_csect.x_scnlen.u64 < obj_raw_syment_count (abfd)) | 2409 | 13 | { | 2410 | 13 | aux->u.auxent.x_csect.x_scnlen.p = | 2411 | 13 | table_base + aux->u.auxent.x_csect.x_scnlen.u64; | 2412 | 13 | aux->fix_scnlen = 1; | 2413 | 13 | } | 2414 | | | 2415 | | /* Return TRUE to indicate that the caller should not do any | 2416 | | further work on this auxent. */ | 2417 | 1.05k | return true; | 2418 | 1.05k | } | 2419 | | | 2420 | | /* Return FALSE to indicate that this auxent should be handled by | 2421 | | the caller. */ | 2422 | 16.1k | return false; | 2423 | 17.2k | } |
|
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 | 1.17k | { |
4370 | 1.17k | size_t amt; |
4371 | | |
4372 | 1.17k | 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.17k | if (bfd_seek (abfd, where, SEEK_SET) != 0) |
4378 | 0 | return NULL; |
4379 | 1.17k | return _bfd_malloc_and_read (abfd, amt, amt); |
4380 | 1.17k | } Line | Count | Source | 4369 | 27 | { | 4370 | 27 | size_t amt; | 4371 | | | 4372 | 27 | 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 | 27 | if (bfd_seek (abfd, where, SEEK_SET) != 0) | 4378 | 0 | return NULL; | 4379 | 27 | return _bfd_malloc_and_read (abfd, amt, amt); | 4380 | 27 | } |
Line | Count | Source | 4369 | 35 | { | 4370 | 35 | size_t amt; | 4371 | | | 4372 | 35 | 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 | 35 | if (bfd_seek (abfd, where, SEEK_SET) != 0) | 4378 | 0 | return NULL; | 4379 | 35 | return _bfd_malloc_and_read (abfd, amt, amt); | 4380 | 35 | } |
pei-x86_64.c:buy_and_read Line | Count | Source | 4369 | 43 | { | 4370 | 43 | size_t amt; | 4371 | | | 4372 | 43 | 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 | 43 | if (bfd_seek (abfd, where, SEEK_SET) != 0) | 4378 | 0 | return NULL; | 4379 | 43 | return _bfd_malloc_and_read (abfd, amt, amt); | 4380 | 43 | } |
coff-x86_64.c:buy_and_read Line | Count | Source | 4369 | 64 | { | 4370 | 64 | size_t amt; | 4371 | | | 4372 | 64 | 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 | 64 | if (bfd_seek (abfd, where, SEEK_SET) != 0) | 4378 | 0 | return NULL; | 4379 | 64 | return _bfd_malloc_and_read (abfd, amt, amt); | 4380 | 64 | } |
coff64-rs6000.c:buy_and_read Line | Count | Source | 4369 | 65 | { | 4370 | 65 | size_t amt; | 4371 | | | 4372 | 65 | 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 | 65 | if (bfd_seek (abfd, where, SEEK_SET) != 0) | 4378 | 0 | return NULL; | 4379 | 65 | return _bfd_malloc_and_read (abfd, amt, amt); | 4380 | 65 | } |
pei-aarch64.c:buy_and_read Line | Count | Source | 4369 | 31 | { | 4370 | 31 | size_t amt; | 4371 | | | 4372 | 31 | 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 | 31 | if (bfd_seek (abfd, where, SEEK_SET) != 0) | 4378 | 0 | return NULL; | 4379 | 31 | return _bfd_malloc_and_read (abfd, amt, amt); | 4380 | 31 | } |
pe-aarch64.c:buy_and_read Line | Count | Source | 4369 | 36 | { | 4370 | 36 | size_t amt; | 4371 | | | 4372 | 36 | 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 | 36 | if (bfd_seek (abfd, where, SEEK_SET) != 0) | 4378 | 0 | return NULL; | 4379 | 36 | return _bfd_malloc_and_read (abfd, amt, amt); | 4380 | 36 | } |
Line | Count | Source | 4369 | 27 | { | 4370 | 27 | size_t amt; | 4371 | | | 4372 | 27 | 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 | 27 | if (bfd_seek (abfd, where, SEEK_SET) != 0) | 4378 | 0 | return NULL; | 4379 | 27 | return _bfd_malloc_and_read (abfd, amt, amt); | 4380 | 27 | } |
pei-loongarch64.c:buy_and_read Line | Count | Source | 4369 | 42 | { | 4370 | 42 | size_t amt; | 4371 | | | 4372 | 42 | 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 | 42 | if (bfd_seek (abfd, where, SEEK_SET) != 0) | 4378 | 0 | return NULL; | 4379 | 42 | return _bfd_malloc_and_read (abfd, amt, amt); | 4380 | 42 | } |
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 | 151 | { | 4370 | 151 | size_t amt; | 4371 | | | 4372 | 151 | 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 | 151 | if (bfd_seek (abfd, where, SEEK_SET) != 0) | 4378 | 0 | return NULL; | 4379 | 151 | return _bfd_malloc_and_read (abfd, amt, amt); | 4380 | 151 | } |
Line | Count | Source | 4369 | 82 | { | 4370 | 82 | size_t amt; | 4371 | | | 4372 | 82 | 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 | 82 | if (bfd_seek (abfd, where, SEEK_SET) != 0) | 4378 | 0 | return NULL; | 4379 | 82 | return _bfd_malloc_and_read (abfd, amt, amt); | 4380 | 82 | } |
Unexecuted instantiation: coff-stgo32.c:buy_and_read coff-tic30.c:buy_and_read Line | Count | Source | 4369 | 74 | { | 4370 | 74 | size_t amt; | 4371 | | | 4372 | 74 | 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 | 74 | if (bfd_seek (abfd, where, SEEK_SET) != 0) | 4378 | 0 | return NULL; | 4379 | 74 | return _bfd_malloc_and_read (abfd, amt, amt); | 4380 | 74 | } |
Unexecuted instantiation: coff-tic4x.c:buy_and_read coff-tic54x.c:buy_and_read Line | Count | Source | 4369 | 28 | { | 4370 | 28 | size_t amt; | 4371 | | | 4372 | 28 | 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 | 28 | if (bfd_seek (abfd, where, SEEK_SET) != 0) | 4378 | 0 | return NULL; | 4379 | 28 | return _bfd_malloc_and_read (abfd, amt, amt); | 4380 | 28 | } |
Line | Count | Source | 4369 | 67 | { | 4370 | 67 | size_t amt; | 4371 | | | 4372 | 67 | 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 | 67 | if (bfd_seek (abfd, where, SEEK_SET) != 0) | 4378 | 0 | return NULL; | 4379 | 67 | return _bfd_malloc_and_read (abfd, amt, amt); | 4380 | 67 | } |
Line | Count | Source | 4369 | 30 | { | 4370 | 30 | size_t amt; | 4371 | | | 4372 | 30 | 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 | 30 | if (bfd_seek (abfd, where, SEEK_SET) != 0) | 4378 | 0 | return NULL; | 4379 | 30 | return _bfd_malloc_and_read (abfd, amt, amt); | 4380 | 30 | } |
Unexecuted instantiation: pe-arm-wince.c:buy_and_read Unexecuted instantiation: pe-arm.c:buy_and_read Line | Count | Source | 4369 | 94 | { | 4370 | 94 | size_t amt; | 4371 | | | 4372 | 94 | 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 | 94 | if (bfd_seek (abfd, where, SEEK_SET) != 0) | 4378 | 0 | return NULL; | 4379 | 94 | return _bfd_malloc_and_read (abfd, amt, amt); | 4380 | 94 | } |
Line | Count | Source | 4369 | 49 | { | 4370 | 49 | size_t amt; | 4371 | | | 4372 | 49 | 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 | 49 | if (bfd_seek (abfd, where, SEEK_SET) != 0) | 4378 | 0 | return NULL; | 4379 | 49 | return _bfd_malloc_and_read (abfd, amt, amt); | 4380 | 49 | } |
Line | Count | Source | 4369 | 73 | { | 4370 | 73 | size_t amt; | 4371 | | | 4372 | 73 | 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 | 73 | if (bfd_seek (abfd, where, SEEK_SET) != 0) | 4378 | 0 | return NULL; | 4379 | 73 | return _bfd_malloc_and_read (abfd, amt, amt); | 4380 | 73 | } |
pei-arm-wince.c:buy_and_read Line | Count | Source | 4369 | 14 | { | 4370 | 14 | size_t amt; | 4371 | | | 4372 | 14 | 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 | 14 | if (bfd_seek (abfd, where, SEEK_SET) != 0) | 4378 | 0 | return NULL; | 4379 | 14 | return _bfd_malloc_and_read (abfd, amt, amt); | 4380 | 14 | } |
Line | Count | Source | 4369 | 51 | { | 4370 | 51 | size_t amt; | 4371 | | | 4372 | 51 | 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 | 51 | if (bfd_seek (abfd, where, SEEK_SET) != 0) | 4378 | 0 | return NULL; | 4379 | 51 | return _bfd_malloc_and_read (abfd, amt, amt); | 4380 | 51 | } |
Line | Count | Source | 4369 | 53 | { | 4370 | 53 | size_t amt; | 4371 | | | 4372 | 53 | 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 | 53 | if (bfd_seek (abfd, where, SEEK_SET) != 0) | 4378 | 0 | return NULL; | 4379 | 53 | return _bfd_malloc_and_read (abfd, amt, amt); | 4380 | 53 | } |
Line | Count | Source | 4369 | 41 | { | 4370 | 41 | size_t amt; | 4371 | | | 4372 | 41 | 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 | 41 | if (bfd_seek (abfd, where, SEEK_SET) != 0) | 4378 | 0 | return NULL; | 4379 | 41 | return _bfd_malloc_and_read (abfd, amt, amt); | 4380 | 41 | } |
|
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 | 115k | { |
4408 | 115k | const alent *al1 = *(const alent **) arg1; |
4409 | 115k | const alent *al2 = *(const alent **) arg2; |
4410 | 115k | const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym); |
4411 | 115k | const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym); |
4412 | | |
4413 | 115k | if (s1 == NULL || s2 == NULL) |
4414 | 0 | return 0; |
4415 | 115k | if (s1->symbol.value < s2->symbol.value) |
4416 | 362 | return -1; |
4417 | 114k | else if (s1->symbol.value > s2->symbol.value) |
4418 | 13.8k | return 1; |
4419 | | |
4420 | 100k | return 0; |
4421 | 115k | } pei-i386.c:coff_sort_func_alent Line | Count | Source | 4407 | 231 | { | 4408 | 231 | const alent *al1 = *(const alent **) arg1; | 4409 | 231 | const alent *al2 = *(const alent **) arg2; | 4410 | 231 | const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym); | 4411 | 231 | const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym); | 4412 | | | 4413 | 231 | if (s1 == NULL || s2 == NULL) | 4414 | 0 | return 0; | 4415 | 231 | if (s1->symbol.value < s2->symbol.value) | 4416 | 21 | return -1; | 4417 | 210 | else if (s1->symbol.value > s2->symbol.value) | 4418 | 18 | return 1; | 4419 | | | 4420 | 192 | return 0; | 4421 | 231 | } |
pe-x86_64.c:coff_sort_func_alent Line | Count | Source | 4407 | 1.25k | { | 4408 | 1.25k | const alent *al1 = *(const alent **) arg1; | 4409 | 1.25k | const alent *al2 = *(const alent **) arg2; | 4410 | 1.25k | const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym); | 4411 | 1.25k | const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym); | 4412 | | | 4413 | 1.25k | if (s1 == NULL || s2 == NULL) | 4414 | 0 | return 0; | 4415 | 1.25k | if (s1->symbol.value < s2->symbol.value) | 4416 | 18 | return -1; | 4417 | 1.23k | else if (s1->symbol.value > s2->symbol.value) | 4418 | 278 | return 1; | 4419 | | | 4420 | 961 | return 0; | 4421 | 1.25k | } |
pei-x86_64.c:coff_sort_func_alent Line | Count | Source | 4407 | 332 | { | 4408 | 332 | const alent *al1 = *(const alent **) arg1; | 4409 | 332 | const alent *al2 = *(const alent **) arg2; | 4410 | 332 | const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym); | 4411 | 332 | const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym); | 4412 | | | 4413 | 332 | if (s1 == NULL || s2 == NULL) | 4414 | 0 | return 0; | 4415 | 332 | if (s1->symbol.value < s2->symbol.value) | 4416 | 15 | return -1; | 4417 | 317 | else if (s1->symbol.value > s2->symbol.value) | 4418 | 127 | return 1; | 4419 | | | 4420 | 190 | return 0; | 4421 | 332 | } |
coff-x86_64.c:coff_sort_func_alent Line | Count | Source | 4407 | 667 | { | 4408 | 667 | const alent *al1 = *(const alent **) arg1; | 4409 | 667 | const alent *al2 = *(const alent **) arg2; | 4410 | 667 | const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym); | 4411 | 667 | const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym); | 4412 | | | 4413 | 667 | if (s1 == NULL || s2 == NULL) | 4414 | 0 | return 0; | 4415 | 667 | if (s1->symbol.value < s2->symbol.value) | 4416 | 18 | return -1; | 4417 | 649 | else if (s1->symbol.value > s2->symbol.value) | 4418 | 116 | return 1; | 4419 | | | 4420 | 533 | return 0; | 4421 | 667 | } |
coff64-rs6000.c:coff_sort_func_alent Line | Count | Source | 4407 | 221 | { | 4408 | 221 | const alent *al1 = *(const alent **) arg1; | 4409 | 221 | const alent *al2 = *(const alent **) arg2; | 4410 | 221 | const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym); | 4411 | 221 | const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym); | 4412 | | | 4413 | 221 | if (s1 == NULL || s2 == NULL) | 4414 | 0 | return 0; | 4415 | 221 | if (s1->symbol.value < s2->symbol.value) | 4416 | 35 | return -1; | 4417 | 186 | else if (s1->symbol.value > s2->symbol.value) | 4418 | 67 | return 1; | 4419 | | | 4420 | 119 | return 0; | 4421 | 221 | } |
pei-aarch64.c:coff_sort_func_alent Line | Count | Source | 4407 | 410 | { | 4408 | 410 | const alent *al1 = *(const alent **) arg1; | 4409 | 410 | const alent *al2 = *(const alent **) arg2; | 4410 | 410 | const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym); | 4411 | 410 | const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym); | 4412 | | | 4413 | 410 | if (s1 == NULL || s2 == NULL) | 4414 | 0 | return 0; | 4415 | 410 | if (s1->symbol.value < s2->symbol.value) | 4416 | 18 | return -1; | 4417 | 392 | else if (s1->symbol.value > s2->symbol.value) | 4418 | 157 | return 1; | 4419 | | | 4420 | 235 | return 0; | 4421 | 410 | } |
pe-aarch64.c:coff_sort_func_alent Line | Count | Source | 4407 | 36 | { | 4408 | 36 | const alent *al1 = *(const alent **) arg1; | 4409 | 36 | const alent *al2 = *(const alent **) arg2; | 4410 | 36 | const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym); | 4411 | 36 | const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym); | 4412 | | | 4413 | 36 | if (s1 == NULL || s2 == NULL) | 4414 | 0 | return 0; | 4415 | 36 | if (s1->symbol.value < s2->symbol.value) | 4416 | 6 | return -1; | 4417 | 30 | else if (s1->symbol.value > s2->symbol.value) | 4418 | 9 | return 1; | 4419 | | | 4420 | 21 | return 0; | 4421 | 36 | } |
pei-ia64.c:coff_sort_func_alent Line | Count | Source | 4407 | 51 | { | 4408 | 51 | const alent *al1 = *(const alent **) arg1; | 4409 | 51 | const alent *al2 = *(const alent **) arg2; | 4410 | 51 | const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym); | 4411 | 51 | const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym); | 4412 | | | 4413 | 51 | if (s1 == NULL || s2 == NULL) | 4414 | 0 | return 0; | 4415 | 51 | if (s1->symbol.value < s2->symbol.value) | 4416 | 11 | return -1; | 4417 | 40 | else if (s1->symbol.value > s2->symbol.value) | 4418 | 13 | return 1; | 4419 | | | 4420 | 27 | return 0; | 4421 | 51 | } |
pei-loongarch64.c:coff_sort_func_alent Line | Count | Source | 4407 | 268 | { | 4408 | 268 | const alent *al1 = *(const alent **) arg1; | 4409 | 268 | const alent *al2 = *(const alent **) arg2; | 4410 | 268 | const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym); | 4411 | 268 | const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym); | 4412 | | | 4413 | 268 | if (s1 == NULL || s2 == NULL) | 4414 | 0 | return 0; | 4415 | 268 | if (s1->symbol.value < s2->symbol.value) | 4416 | 22 | return -1; | 4417 | 246 | else if (s1->symbol.value > s2->symbol.value) | 4418 | 93 | return 1; | 4419 | | | 4420 | 153 | return 0; | 4421 | 268 | } |
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 | 78.6k | { | 4408 | 78.6k | const alent *al1 = *(const alent **) arg1; | 4409 | 78.6k | const alent *al2 = *(const alent **) arg2; | 4410 | 78.6k | const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym); | 4411 | 78.6k | const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym); | 4412 | | | 4413 | 78.6k | if (s1 == NULL || s2 == NULL) | 4414 | 0 | return 0; | 4415 | 78.6k | if (s1->symbol.value < s2->symbol.value) | 4416 | 75 | return -1; | 4417 | 78.5k | else if (s1->symbol.value > s2->symbol.value) | 4418 | 9.15k | return 1; | 4419 | | | 4420 | 69.4k | return 0; | 4421 | 78.6k | } |
coff-sh.c:coff_sort_func_alent Line | Count | Source | 4407 | 12.6k | { | 4408 | 12.6k | const alent *al1 = *(const alent **) arg1; | 4409 | 12.6k | const alent *al2 = *(const alent **) arg2; | 4410 | 12.6k | const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym); | 4411 | 12.6k | const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym); | 4412 | | | 4413 | 12.6k | if (s1 == NULL || s2 == NULL) | 4414 | 0 | return 0; | 4415 | 12.6k | if (s1->symbol.value < s2->symbol.value) | 4416 | 34 | return -1; | 4417 | 12.6k | else if (s1->symbol.value > s2->symbol.value) | 4418 | 352 | return 1; | 4419 | | | 4420 | 12.2k | return 0; | 4421 | 12.6k | } |
Unexecuted instantiation: coff-stgo32.c:coff_sort_func_alent coff-tic30.c:coff_sort_func_alent Line | Count | Source | 4407 | 986 | { | 4408 | 986 | const alent *al1 = *(const alent **) arg1; | 4409 | 986 | const alent *al2 = *(const alent **) arg2; | 4410 | 986 | const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym); | 4411 | 986 | const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym); | 4412 | | | 4413 | 986 | if (s1 == NULL || s2 == NULL) | 4414 | 0 | return 0; | 4415 | 986 | if (s1->symbol.value < s2->symbol.value) | 4416 | 12 | return -1; | 4417 | 974 | else if (s1->symbol.value > s2->symbol.value) | 4418 | 268 | return 1; | 4419 | | | 4420 | 706 | return 0; | 4421 | 986 | } |
Unexecuted instantiation: coff-tic4x.c:coff_sort_func_alent coff-tic54x.c:coff_sort_func_alent Line | Count | Source | 4407 | 1.66k | { | 4408 | 1.66k | const alent *al1 = *(const alent **) arg1; | 4409 | 1.66k | const alent *al2 = *(const alent **) arg2; | 4410 | 1.66k | const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym); | 4411 | 1.66k | const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym); | 4412 | | | 4413 | 1.66k | if (s1 == NULL || s2 == NULL) | 4414 | 0 | return 0; | 4415 | 1.66k | if (s1->symbol.value < s2->symbol.value) | 4416 | 6 | return -1; | 4417 | 1.66k | else if (s1->symbol.value > s2->symbol.value) | 4418 | 303 | return 1; | 4419 | | | 4420 | 1.35k | return 0; | 4421 | 1.66k | } |
coff-z80.c:coff_sort_func_alent Line | Count | Source | 4407 | 204 | { | 4408 | 204 | const alent *al1 = *(const alent **) arg1; | 4409 | 204 | const alent *al2 = *(const alent **) arg2; | 4410 | 204 | const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym); | 4411 | 204 | const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym); | 4412 | | | 4413 | 204 | if (s1 == NULL || s2 == NULL) | 4414 | 0 | return 0; | 4415 | 204 | if (s1->symbol.value < s2->symbol.value) | 4416 | 8 | return -1; | 4417 | 196 | else if (s1->symbol.value > s2->symbol.value) | 4418 | 75 | return 1; | 4419 | | | 4420 | 121 | return 0; | 4421 | 204 | } |
Unexecuted instantiation: coff-z8k.c:coff_sort_func_alent 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 | 16.6k | { | 4408 | 16.6k | const alent *al1 = *(const alent **) arg1; | 4409 | 16.6k | const alent *al2 = *(const alent **) arg2; | 4410 | 16.6k | const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym); | 4411 | 16.6k | const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym); | 4412 | | | 4413 | 16.6k | if (s1 == NULL || s2 == NULL) | 4414 | 0 | return 0; | 4415 | 16.6k | if (s1->symbol.value < s2->symbol.value) | 4416 | 16 | return -1; | 4417 | 16.6k | else if (s1->symbol.value > s2->symbol.value) | 4418 | 2.59k | return 1; | 4419 | | | 4420 | 14.0k | return 0; | 4421 | 16.6k | } |
pe-mcore.c:coff_sort_func_alent Line | Count | Source | 4407 | 151 | { | 4408 | 151 | const alent *al1 = *(const alent **) arg1; | 4409 | 151 | const alent *al2 = *(const alent **) arg2; | 4410 | 151 | const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym); | 4411 | 151 | const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym); | 4412 | | | 4413 | 151 | if (s1 == NULL || s2 == NULL) | 4414 | 0 | return 0; | 4415 | 151 | if (s1->symbol.value < s2->symbol.value) | 4416 | 4 | return -1; | 4417 | 147 | else if (s1->symbol.value > s2->symbol.value) | 4418 | 39 | return 1; | 4419 | | | 4420 | 108 | return 0; | 4421 | 151 | } |
pe-sh.c:coff_sort_func_alent Line | Count | Source | 4407 | 305 | { | 4408 | 305 | const alent *al1 = *(const alent **) arg1; | 4409 | 305 | const alent *al2 = *(const alent **) arg2; | 4410 | 305 | const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym); | 4411 | 305 | const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym); | 4412 | | | 4413 | 305 | if (s1 == NULL || s2 == NULL) | 4414 | 0 | return 0; | 4415 | 305 | if (s1->symbol.value < s2->symbol.value) | 4416 | 10 | return -1; | 4417 | 295 | else if (s1->symbol.value > s2->symbol.value) | 4418 | 118 | return 1; | 4419 | | | 4420 | 177 | return 0; | 4421 | 305 | } |
Unexecuted instantiation: pei-arm-wince.c:coff_sort_func_alent pei-arm.c:coff_sort_func_alent Line | Count | Source | 4407 | 114 | { | 4408 | 114 | const alent *al1 = *(const alent **) arg1; | 4409 | 114 | const alent *al2 = *(const alent **) arg2; | 4410 | 114 | const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym); | 4411 | 114 | const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym); | 4412 | | | 4413 | 114 | if (s1 == NULL || s2 == NULL) | 4414 | 0 | return 0; | 4415 | 114 | if (s1->symbol.value < s2->symbol.value) | 4416 | 3 | return -1; | 4417 | 111 | else if (s1->symbol.value > s2->symbol.value) | 4418 | 47 | return 1; | 4419 | | | 4420 | 64 | return 0; | 4421 | 114 | } |
pei-mcore.c:coff_sort_func_alent Line | Count | Source | 4407 | 46 | { | 4408 | 46 | const alent *al1 = *(const alent **) arg1; | 4409 | 46 | const alent *al2 = *(const alent **) arg2; | 4410 | 46 | const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym); | 4411 | 46 | const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym); | 4412 | | | 4413 | 46 | if (s1 == NULL || s2 == NULL) | 4414 | 0 | return 0; | 4415 | 46 | if (s1->symbol.value < s2->symbol.value) | 4416 | 6 | return -1; | 4417 | 40 | else if (s1->symbol.value > s2->symbol.value) | 4418 | 14 | return 1; | 4419 | | | 4420 | 26 | return 0; | 4421 | 46 | } |
pei-sh.c:coff_sort_func_alent Line | Count | Source | 4407 | 177 | { | 4408 | 177 | const alent *al1 = *(const alent **) arg1; | 4409 | 177 | const alent *al2 = *(const alent **) arg2; | 4410 | 177 | const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym); | 4411 | 177 | const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym); | 4412 | | | 4413 | 177 | if (s1 == NULL || s2 == NULL) | 4414 | 0 | return 0; | 4415 | 177 | if (s1->symbol.value < s2->symbol.value) | 4416 | 24 | return -1; | 4417 | 153 | else if (s1->symbol.value > s2->symbol.value) | 4418 | 22 | return 1; | 4419 | | | 4420 | 131 | return 0; | 4421 | 177 | } |
|
4422 | | |
4423 | | static bool |
4424 | | coff_slurp_line_table (bfd *abfd, asection *asect) |
4425 | 52.7k | { |
4426 | 52.7k | LINENO *native_lineno; |
4427 | 52.7k | alent *lineno_cache; |
4428 | 52.7k | unsigned int counter; |
4429 | 52.7k | alent *cache_ptr; |
4430 | 52.7k | bfd_vma prev_offset = 0; |
4431 | 52.7k | bool ordered = true; |
4432 | 52.7k | unsigned int nbr_func; |
4433 | 52.7k | LINENO *src; |
4434 | 52.7k | bool have_func; |
4435 | 52.7k | bool ret = true; |
4436 | 52.7k | size_t amt; |
4437 | | |
4438 | 52.7k | if (asect->lineno_count == 0) |
4439 | 51.6k | return true; |
4440 | | |
4441 | 1.17k | BFD_ASSERT (asect->lineno == NULL); |
4442 | | |
4443 | 1.17k | native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, |
4444 | 1.17k | asect->lineno_count, |
4445 | 1.17k | bfd_coff_linesz (abfd)); |
4446 | 1.17k | if (native_lineno == NULL) |
4447 | 0 | { |
4448 | 0 | _bfd_error_handler |
4449 | 0 | (_("%pB: warning: line number table read failed"), abfd); |
4450 | 0 | return false; |
4451 | 0 | } |
4452 | | |
4453 | 1.17k | 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 | 1.17k | lineno_cache = (alent *) bfd_alloc (abfd, amt); |
4460 | 1.17k | if (lineno_cache == NULL) |
4461 | 0 | { |
4462 | 0 | free (native_lineno); |
4463 | 0 | return false; |
4464 | 0 | } |
4465 | | |
4466 | 1.17k | cache_ptr = lineno_cache; |
4467 | 1.17k | asect->lineno = lineno_cache; |
4468 | 1.17k | src = native_lineno; |
4469 | 1.17k | nbr_func = 0; |
4470 | 1.17k | have_func = false; |
4471 | | |
4472 | 104k | for (counter = 0; counter < asect->lineno_count; counter++, src++) |
4473 | 103k | { |
4474 | 103k | struct internal_lineno dst; |
4475 | | |
4476 | 103k | bfd_coff_swap_lineno_in (abfd, src, &dst); |
4477 | 103k | 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 | 103k | memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); |
4482 | | |
4483 | 103k | if (cache_ptr->line_number == 0) |
4484 | 43.8k | { |
4485 | 43.8k | combined_entry_type * ent; |
4486 | 43.8k | unsigned long symndx; |
4487 | 43.8k | coff_symbol_type *sym; |
4488 | | |
4489 | 43.8k | have_func = false; |
4490 | 43.8k | symndx = dst.l_addr.l_symndx; |
4491 | 43.8k | if (symndx >= obj_raw_syment_count (abfd)) |
4492 | 0 | { |
4493 | 0 | _bfd_error_handler |
4494 | | /* xgettext:c-format */ |
4495 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), |
4496 | 0 | abfd, symndx, counter); |
4497 | 0 | cache_ptr->line_number = -1; |
4498 | 0 | ret = false; |
4499 | 0 | continue; |
4500 | 0 | } |
4501 | | |
4502 | 43.8k | ent = obj_raw_syments (abfd) + symndx; |
4503 | | /* FIXME: We should not be casting between ints and |
4504 | | pointers like this. */ |
4505 | 43.8k | if (! ent->is_sym) |
4506 | 0 | { |
4507 | 0 | _bfd_error_handler |
4508 | | /* xgettext:c-format */ |
4509 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), |
4510 | 0 | abfd, symndx, counter); |
4511 | 0 | cache_ptr->line_number = -1; |
4512 | 0 | ret = false; |
4513 | 0 | continue; |
4514 | 0 | } |
4515 | 43.8k | sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); |
4516 | | |
4517 | | /* PR 17512 file: 078-10659-0.004 */ |
4518 | 43.8k | if (sym < obj_symbols (abfd) |
4519 | 43.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 | 43.8k | have_func = true; |
4531 | 43.8k | nbr_func++; |
4532 | 43.8k | cache_ptr->u.sym = (asymbol *) sym; |
4533 | 43.8k | if (sym->lineno != NULL) |
4534 | 42.8k | _bfd_error_handler |
4535 | | /* xgettext:c-format */ |
4536 | 42.8k | (_("%pB: warning: duplicate line number information for `%s'"), |
4537 | 42.8k | abfd, bfd_asymbol_name (&sym->symbol)); |
4538 | | |
4539 | 43.8k | sym->lineno = cache_ptr; |
4540 | 43.8k | if (sym->symbol.value < prev_offset) |
4541 | 579 | ordered = false; |
4542 | 43.8k | prev_offset = sym->symbol.value; |
4543 | 43.8k | } |
4544 | 59.1k | else if (!have_func) |
4545 | | /* Drop line information that has no associated function. |
4546 | | PR 17521: file: 078-10659-0.004. */ |
4547 | 24.2k | continue; |
4548 | 34.8k | else |
4549 | 34.8k | cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect); |
4550 | 78.7k | cache_ptr++; |
4551 | 78.7k | } |
4552 | | |
4553 | 1.17k | asect->lineno_count = cache_ptr - lineno_cache; |
4554 | 1.17k | memset (cache_ptr, 0, sizeof (*cache_ptr)); |
4555 | 1.17k | free (native_lineno); |
4556 | | |
4557 | | /* On some systems (eg AIX5.3) the lineno table may not be sorted. */ |
4558 | 1.17k | if (!ordered) |
4559 | 465 | { |
4560 | | /* Sort the table. */ |
4561 | 465 | alent **func_table; |
4562 | 465 | alent *n_lineno_cache; |
4563 | | |
4564 | | /* Create a table of functions. */ |
4565 | 465 | 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 | 465 | else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL) |
4571 | 465 | { |
4572 | 465 | alent **p = func_table; |
4573 | 465 | unsigned int i; |
4574 | | |
4575 | 37.1k | for (i = 0; i < asect->lineno_count; i++) |
4576 | 36.6k | if (lineno_cache[i].line_number == 0) |
4577 | 27.6k | *p++ = &lineno_cache[i]; |
4578 | | |
4579 | 465 | BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func); |
4580 | | |
4581 | | /* Sort by functions. */ |
4582 | 465 | qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent); |
4583 | | |
4584 | | /* Create the new sorted table. */ |
4585 | 465 | 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 | 465 | else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL) |
4591 | 465 | { |
4592 | 465 | alent *n_cache_ptr = n_lineno_cache; |
4593 | | |
4594 | 28.1k | for (i = 0; i < nbr_func; i++) |
4595 | 27.6k | { |
4596 | 27.6k | coff_symbol_type *sym; |
4597 | 27.6k | alent *old_ptr = func_table[i]; |
4598 | | |
4599 | | /* Update the function entry. */ |
4600 | 27.6k | 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 | 27.6k | sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); |
4604 | | /* Copy the function and line number entries. */ |
4605 | 27.6k | do |
4606 | 36.6k | *n_cache_ptr++ = *old_ptr++; |
4607 | 36.6k | while (old_ptr->line_number != 0); |
4608 | 27.6k | } |
4609 | | |
4610 | 465 | memcpy (lineno_cache, n_lineno_cache, |
4611 | 465 | asect->lineno_count * sizeof (alent)); |
4612 | 465 | } |
4613 | 0 | else |
4614 | 0 | ret = false; |
4615 | 465 | bfd_release (abfd, func_table); |
4616 | 465 | } |
4617 | 0 | else |
4618 | 0 | ret = false; |
4619 | 465 | } |
4620 | | |
4621 | 1.17k | return ret; |
4622 | 1.17k | } pei-i386.c:coff_slurp_line_table Line | Count | Source | 4425 | 172 | { | 4426 | 172 | LINENO *native_lineno; | 4427 | 172 | alent *lineno_cache; | 4428 | 172 | unsigned int counter; | 4429 | 172 | alent *cache_ptr; | 4430 | 172 | bfd_vma prev_offset = 0; | 4431 | 172 | bool ordered = true; | 4432 | 172 | unsigned int nbr_func; | 4433 | 172 | LINENO *src; | 4434 | 172 | bool have_func; | 4435 | 172 | bool ret = true; | 4436 | 172 | size_t amt; | 4437 | | | 4438 | 172 | if (asect->lineno_count == 0) | 4439 | 145 | return true; | 4440 | | | 4441 | 27 | BFD_ASSERT (asect->lineno == NULL); | 4442 | | | 4443 | 27 | native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, | 4444 | 27 | asect->lineno_count, | 4445 | 27 | bfd_coff_linesz (abfd)); | 4446 | 27 | if (native_lineno == NULL) | 4447 | 0 | { | 4448 | 0 | _bfd_error_handler | 4449 | 0 | (_("%pB: warning: line number table read failed"), abfd); | 4450 | 0 | return false; | 4451 | 0 | } | 4452 | | | 4453 | 27 | 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 | 27 | lineno_cache = (alent *) bfd_alloc (abfd, amt); | 4460 | 27 | if (lineno_cache == NULL) | 4461 | 0 | { | 4462 | 0 | free (native_lineno); | 4463 | 0 | return false; | 4464 | 0 | } | 4465 | | | 4466 | 27 | cache_ptr = lineno_cache; | 4467 | 27 | asect->lineno = lineno_cache; | 4468 | 27 | src = native_lineno; | 4469 | 27 | nbr_func = 0; | 4470 | 27 | have_func = false; | 4471 | | | 4472 | 356 | for (counter = 0; counter < asect->lineno_count; counter++, src++) | 4473 | 329 | { | 4474 | 329 | struct internal_lineno dst; | 4475 | | | 4476 | 329 | bfd_coff_swap_lineno_in (abfd, src, &dst); | 4477 | 329 | 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 | 329 | memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); | 4482 | | | 4483 | 329 | if (cache_ptr->line_number == 0) | 4484 | 142 | { | 4485 | 142 | combined_entry_type * ent; | 4486 | 142 | unsigned long symndx; | 4487 | 142 | coff_symbol_type *sym; | 4488 | | | 4489 | 142 | have_func = false; | 4490 | 142 | symndx = dst.l_addr.l_symndx; | 4491 | 142 | if (symndx >= obj_raw_syment_count (abfd)) | 4492 | 0 | { | 4493 | 0 | _bfd_error_handler | 4494 | | /* xgettext:c-format */ | 4495 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4496 | 0 | abfd, symndx, counter); | 4497 | 0 | cache_ptr->line_number = -1; | 4498 | 0 | ret = false; | 4499 | 0 | continue; | 4500 | 0 | } | 4501 | | | 4502 | 142 | ent = obj_raw_syments (abfd) + symndx; | 4503 | | /* FIXME: We should not be casting between ints and | 4504 | | pointers like this. */ | 4505 | 142 | if (! ent->is_sym) | 4506 | 0 | { | 4507 | 0 | _bfd_error_handler | 4508 | | /* xgettext:c-format */ | 4509 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4510 | 0 | abfd, symndx, counter); | 4511 | 0 | cache_ptr->line_number = -1; | 4512 | 0 | ret = false; | 4513 | 0 | continue; | 4514 | 0 | } | 4515 | 142 | sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); | 4516 | | | 4517 | | /* PR 17512 file: 078-10659-0.004 */ | 4518 | 142 | if (sym < obj_symbols (abfd) | 4519 | 142 | || 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 | 142 | have_func = true; | 4531 | 142 | nbr_func++; | 4532 | 142 | cache_ptr->u.sym = (asymbol *) sym; | 4533 | 142 | if (sym->lineno != NULL) | 4534 | 115 | _bfd_error_handler | 4535 | | /* xgettext:c-format */ | 4536 | 115 | (_("%pB: warning: duplicate line number information for `%s'"), | 4537 | 115 | abfd, bfd_asymbol_name (&sym->symbol)); | 4538 | | | 4539 | 142 | sym->lineno = cache_ptr; | 4540 | 142 | if (sym->symbol.value < prev_offset) | 4541 | 11 | ordered = false; | 4542 | 142 | prev_offset = sym->symbol.value; | 4543 | 142 | } | 4544 | 187 | else if (!have_func) | 4545 | | /* Drop line information that has no associated function. | 4546 | | PR 17521: file: 078-10659-0.004. */ | 4547 | 88 | continue; | 4548 | 99 | else | 4549 | 99 | cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect); | 4550 | 241 | cache_ptr++; | 4551 | 241 | } | 4552 | | | 4553 | 27 | asect->lineno_count = cache_ptr - lineno_cache; | 4554 | 27 | memset (cache_ptr, 0, sizeof (*cache_ptr)); | 4555 | 27 | free (native_lineno); | 4556 | | | 4557 | | /* On some systems (eg AIX5.3) the lineno table may not be sorted. */ | 4558 | 27 | if (!ordered) | 4559 | 10 | { | 4560 | | /* Sort the table. */ | 4561 | 10 | alent **func_table; | 4562 | 10 | alent *n_lineno_cache; | 4563 | | | 4564 | | /* Create a table of functions. */ | 4565 | 10 | 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 | 10 | else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL) | 4571 | 10 | { | 4572 | 10 | alent **p = func_table; | 4573 | 10 | unsigned int i; | 4574 | | | 4575 | 219 | for (i = 0; i < asect->lineno_count; i++) | 4576 | 209 | if (lineno_cache[i].line_number == 0) | 4577 | 118 | *p++ = &lineno_cache[i]; | 4578 | | | 4579 | 10 | BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func); | 4580 | | | 4581 | | /* Sort by functions. */ | 4582 | 10 | qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent); | 4583 | | | 4584 | | /* Create the new sorted table. */ | 4585 | 10 | 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 | 10 | else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL) | 4591 | 10 | { | 4592 | 10 | alent *n_cache_ptr = n_lineno_cache; | 4593 | | | 4594 | 128 | for (i = 0; i < nbr_func; i++) | 4595 | 118 | { | 4596 | 118 | coff_symbol_type *sym; | 4597 | 118 | alent *old_ptr = func_table[i]; | 4598 | | | 4599 | | /* Update the function entry. */ | 4600 | 118 | 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 | 118 | sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); | 4604 | | /* Copy the function and line number entries. */ | 4605 | 118 | do | 4606 | 209 | *n_cache_ptr++ = *old_ptr++; | 4607 | 209 | while (old_ptr->line_number != 0); | 4608 | 118 | } | 4609 | | | 4610 | 10 | memcpy (lineno_cache, n_lineno_cache, | 4611 | 10 | asect->lineno_count * sizeof (alent)); | 4612 | 10 | } | 4613 | 0 | else | 4614 | 0 | ret = false; | 4615 | 10 | bfd_release (abfd, func_table); | 4616 | 10 | } | 4617 | 0 | else | 4618 | 0 | ret = false; | 4619 | 10 | } | 4620 | | | 4621 | 27 | return ret; | 4622 | 27 | } |
pe-x86_64.c:coff_slurp_line_table Line | Count | Source | 4425 | 8.53k | { | 4426 | 8.53k | LINENO *native_lineno; | 4427 | 8.53k | alent *lineno_cache; | 4428 | 8.53k | unsigned int counter; | 4429 | 8.53k | alent *cache_ptr; | 4430 | 8.53k | bfd_vma prev_offset = 0; | 4431 | 8.53k | bool ordered = true; | 4432 | 8.53k | unsigned int nbr_func; | 4433 | 8.53k | LINENO *src; | 4434 | 8.53k | bool have_func; | 4435 | 8.53k | bool ret = true; | 4436 | 8.53k | size_t amt; | 4437 | | | 4438 | 8.53k | if (asect->lineno_count == 0) | 4439 | 8.50k | return true; | 4440 | | | 4441 | 35 | BFD_ASSERT (asect->lineno == NULL); | 4442 | | | 4443 | 35 | native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, | 4444 | 35 | asect->lineno_count, | 4445 | 35 | bfd_coff_linesz (abfd)); | 4446 | 35 | if (native_lineno == NULL) | 4447 | 0 | { | 4448 | 0 | _bfd_error_handler | 4449 | 0 | (_("%pB: warning: line number table read failed"), abfd); | 4450 | 0 | return false; | 4451 | 0 | } | 4452 | | | 4453 | 35 | 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 | 35 | lineno_cache = (alent *) bfd_alloc (abfd, amt); | 4460 | 35 | if (lineno_cache == NULL) | 4461 | 0 | { | 4462 | 0 | free (native_lineno); | 4463 | 0 | return false; | 4464 | 0 | } | 4465 | | | 4466 | 35 | cache_ptr = lineno_cache; | 4467 | 35 | asect->lineno = lineno_cache; | 4468 | 35 | src = native_lineno; | 4469 | 35 | nbr_func = 0; | 4470 | 35 | have_func = false; | 4471 | | | 4472 | 1.01k | for (counter = 0; counter < asect->lineno_count; counter++, src++) | 4473 | 982 | { | 4474 | 982 | struct internal_lineno dst; | 4475 | | | 4476 | 982 | bfd_coff_swap_lineno_in (abfd, src, &dst); | 4477 | 982 | 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 | 982 | memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); | 4482 | | | 4483 | 982 | if (cache_ptr->line_number == 0) | 4484 | 417 | { | 4485 | 417 | combined_entry_type * ent; | 4486 | 417 | unsigned long symndx; | 4487 | 417 | coff_symbol_type *sym; | 4488 | | | 4489 | 417 | have_func = false; | 4490 | 417 | symndx = dst.l_addr.l_symndx; | 4491 | 417 | if (symndx >= obj_raw_syment_count (abfd)) | 4492 | 0 | { | 4493 | 0 | _bfd_error_handler | 4494 | | /* xgettext:c-format */ | 4495 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4496 | 0 | abfd, symndx, counter); | 4497 | 0 | cache_ptr->line_number = -1; | 4498 | 0 | ret = false; | 4499 | 0 | continue; | 4500 | 0 | } | 4501 | | | 4502 | 417 | ent = obj_raw_syments (abfd) + symndx; | 4503 | | /* FIXME: We should not be casting between ints and | 4504 | | pointers like this. */ | 4505 | 417 | if (! ent->is_sym) | 4506 | 0 | { | 4507 | 0 | _bfd_error_handler | 4508 | | /* xgettext:c-format */ | 4509 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4510 | 0 | abfd, symndx, counter); | 4511 | 0 | cache_ptr->line_number = -1; | 4512 | 0 | ret = false; | 4513 | 0 | continue; | 4514 | 0 | } | 4515 | 417 | sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); | 4516 | | | 4517 | | /* PR 17512 file: 078-10659-0.004 */ | 4518 | 417 | if (sym < obj_symbols (abfd) | 4519 | 417 | || 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 | 417 | have_func = true; | 4531 | 417 | nbr_func++; | 4532 | 417 | cache_ptr->u.sym = (asymbol *) sym; | 4533 | 417 | if (sym->lineno != NULL) | 4534 | 380 | _bfd_error_handler | 4535 | | /* xgettext:c-format */ | 4536 | 380 | (_("%pB: warning: duplicate line number information for `%s'"), | 4537 | 380 | abfd, bfd_asymbol_name (&sym->symbol)); | 4538 | | | 4539 | 417 | sym->lineno = cache_ptr; | 4540 | 417 | if (sym->symbol.value < prev_offset) | 4541 | 23 | ordered = false; | 4542 | 417 | prev_offset = sym->symbol.value; | 4543 | 417 | } | 4544 | 565 | else if (!have_func) | 4545 | | /* Drop line information that has no associated function. | 4546 | | PR 17521: file: 078-10659-0.004. */ | 4547 | 474 | continue; | 4548 | 91 | else | 4549 | 91 | cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect); | 4550 | 508 | cache_ptr++; | 4551 | 508 | } | 4552 | | | 4553 | 35 | asect->lineno_count = cache_ptr - lineno_cache; | 4554 | 35 | memset (cache_ptr, 0, sizeof (*cache_ptr)); | 4555 | 35 | free (native_lineno); | 4556 | | | 4557 | | /* On some systems (eg AIX5.3) the lineno table may not be sorted. */ | 4558 | 35 | if (!ordered) | 4559 | 20 | { | 4560 | | /* Sort the table. */ | 4561 | 20 | alent **func_table; | 4562 | 20 | alent *n_lineno_cache; | 4563 | | | 4564 | | /* Create a table of functions. */ | 4565 | 20 | 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 | 20 | else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL) | 4571 | 20 | { | 4572 | 20 | alent **p = func_table; | 4573 | 20 | unsigned int i; | 4574 | | | 4575 | 457 | for (i = 0; i < asect->lineno_count; i++) | 4576 | 437 | if (lineno_cache[i].line_number == 0) | 4577 | 349 | *p++ = &lineno_cache[i]; | 4578 | | | 4579 | 20 | BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func); | 4580 | | | 4581 | | /* Sort by functions. */ | 4582 | 20 | qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent); | 4583 | | | 4584 | | /* Create the new sorted table. */ | 4585 | 20 | 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 | 20 | else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL) | 4591 | 20 | { | 4592 | 20 | alent *n_cache_ptr = n_lineno_cache; | 4593 | | | 4594 | 369 | for (i = 0; i < nbr_func; i++) | 4595 | 349 | { | 4596 | 349 | coff_symbol_type *sym; | 4597 | 349 | alent *old_ptr = func_table[i]; | 4598 | | | 4599 | | /* Update the function entry. */ | 4600 | 349 | 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 | 349 | sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); | 4604 | | /* Copy the function and line number entries. */ | 4605 | 349 | do | 4606 | 437 | *n_cache_ptr++ = *old_ptr++; | 4607 | 437 | while (old_ptr->line_number != 0); | 4608 | 349 | } | 4609 | | | 4610 | 20 | memcpy (lineno_cache, n_lineno_cache, | 4611 | 20 | asect->lineno_count * sizeof (alent)); | 4612 | 20 | } | 4613 | 0 | else | 4614 | 0 | ret = false; | 4615 | 20 | bfd_release (abfd, func_table); | 4616 | 20 | } | 4617 | 0 | else | 4618 | 0 | ret = false; | 4619 | 20 | } | 4620 | | | 4621 | 35 | return ret; | 4622 | 35 | } |
pei-x86_64.c:coff_slurp_line_table Line | Count | Source | 4425 | 355 | { | 4426 | 355 | LINENO *native_lineno; | 4427 | 355 | alent *lineno_cache; | 4428 | 355 | unsigned int counter; | 4429 | 355 | alent *cache_ptr; | 4430 | 355 | bfd_vma prev_offset = 0; | 4431 | 355 | bool ordered = true; | 4432 | 355 | unsigned int nbr_func; | 4433 | 355 | LINENO *src; | 4434 | 355 | bool have_func; | 4435 | 355 | bool ret = true; | 4436 | 355 | size_t amt; | 4437 | | | 4438 | 355 | if (asect->lineno_count == 0) | 4439 | 312 | return true; | 4440 | | | 4441 | 43 | BFD_ASSERT (asect->lineno == NULL); | 4442 | | | 4443 | 43 | native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, | 4444 | 43 | asect->lineno_count, | 4445 | 43 | bfd_coff_linesz (abfd)); | 4446 | 43 | if (native_lineno == NULL) | 4447 | 0 | { | 4448 | 0 | _bfd_error_handler | 4449 | 0 | (_("%pB: warning: line number table read failed"), abfd); | 4450 | 0 | return false; | 4451 | 0 | } | 4452 | | | 4453 | 43 | 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 | 43 | lineno_cache = (alent *) bfd_alloc (abfd, amt); | 4460 | 43 | if (lineno_cache == NULL) | 4461 | 0 | { | 4462 | 0 | free (native_lineno); | 4463 | 0 | return false; | 4464 | 0 | } | 4465 | | | 4466 | 43 | cache_ptr = lineno_cache; | 4467 | 43 | asect->lineno = lineno_cache; | 4468 | 43 | src = native_lineno; | 4469 | 43 | nbr_func = 0; | 4470 | 43 | have_func = false; | 4471 | | | 4472 | 417 | for (counter = 0; counter < asect->lineno_count; counter++, src++) | 4473 | 374 | { | 4474 | 374 | struct internal_lineno dst; | 4475 | | | 4476 | 374 | bfd_coff_swap_lineno_in (abfd, src, &dst); | 4477 | 374 | 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 | 374 | memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); | 4482 | | | 4483 | 374 | if (cache_ptr->line_number == 0) | 4484 | 194 | { | 4485 | 194 | combined_entry_type * ent; | 4486 | 194 | unsigned long symndx; | 4487 | 194 | coff_symbol_type *sym; | 4488 | | | 4489 | 194 | have_func = false; | 4490 | 194 | symndx = dst.l_addr.l_symndx; | 4491 | 194 | if (symndx >= obj_raw_syment_count (abfd)) | 4492 | 0 | { | 4493 | 0 | _bfd_error_handler | 4494 | | /* xgettext:c-format */ | 4495 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4496 | 0 | abfd, symndx, counter); | 4497 | 0 | cache_ptr->line_number = -1; | 4498 | 0 | ret = false; | 4499 | 0 | continue; | 4500 | 0 | } | 4501 | | | 4502 | 194 | ent = obj_raw_syments (abfd) + symndx; | 4503 | | /* FIXME: We should not be casting between ints and | 4504 | | pointers like this. */ | 4505 | 194 | if (! ent->is_sym) | 4506 | 0 | { | 4507 | 0 | _bfd_error_handler | 4508 | | /* xgettext:c-format */ | 4509 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4510 | 0 | abfd, symndx, counter); | 4511 | 0 | cache_ptr->line_number = -1; | 4512 | 0 | ret = false; | 4513 | 0 | continue; | 4514 | 0 | } | 4515 | 194 | sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); | 4516 | | | 4517 | | /* PR 17512 file: 078-10659-0.004 */ | 4518 | 194 | if (sym < obj_symbols (abfd) | 4519 | 194 | || 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 | 194 | have_func = true; | 4531 | 194 | nbr_func++; | 4532 | 194 | cache_ptr->u.sym = (asymbol *) sym; | 4533 | 194 | if (sym->lineno != NULL) | 4534 | 140 | _bfd_error_handler | 4535 | | /* xgettext:c-format */ | 4536 | 140 | (_("%pB: warning: duplicate line number information for `%s'"), | 4537 | 140 | abfd, bfd_asymbol_name (&sym->symbol)); | 4538 | | | 4539 | 194 | sym->lineno = cache_ptr; | 4540 | 194 | if (sym->symbol.value < prev_offset) | 4541 | 20 | ordered = false; | 4542 | 194 | prev_offset = sym->symbol.value; | 4543 | 194 | } | 4544 | 180 | else if (!have_func) | 4545 | | /* Drop line information that has no associated function. | 4546 | | PR 17521: file: 078-10659-0.004. */ | 4547 | 105 | continue; | 4548 | 75 | else | 4549 | 75 | cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect); | 4550 | 269 | cache_ptr++; | 4551 | 269 | } | 4552 | | | 4553 | 43 | asect->lineno_count = cache_ptr - lineno_cache; | 4554 | 43 | memset (cache_ptr, 0, sizeof (*cache_ptr)); | 4555 | 43 | free (native_lineno); | 4556 | | | 4557 | | /* On some systems (eg AIX5.3) the lineno table may not be sorted. */ | 4558 | 43 | if (!ordered) | 4559 | 18 | { | 4560 | | /* Sort the table. */ | 4561 | 18 | alent **func_table; | 4562 | 18 | alent *n_lineno_cache; | 4563 | | | 4564 | | /* Create a table of functions. */ | 4565 | 18 | 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 | 18 | else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL) | 4571 | 18 | { | 4572 | 18 | alent **p = func_table; | 4573 | 18 | unsigned int i; | 4574 | | | 4575 | 251 | for (i = 0; i < asect->lineno_count; i++) | 4576 | 233 | if (lineno_cache[i].line_number == 0) | 4577 | 159 | *p++ = &lineno_cache[i]; | 4578 | | | 4579 | 18 | BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func); | 4580 | | | 4581 | | /* Sort by functions. */ | 4582 | 18 | qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent); | 4583 | | | 4584 | | /* Create the new sorted table. */ | 4585 | 18 | 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 | 18 | else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL) | 4591 | 18 | { | 4592 | 18 | alent *n_cache_ptr = n_lineno_cache; | 4593 | | | 4594 | 177 | for (i = 0; i < nbr_func; i++) | 4595 | 159 | { | 4596 | 159 | coff_symbol_type *sym; | 4597 | 159 | alent *old_ptr = func_table[i]; | 4598 | | | 4599 | | /* Update the function entry. */ | 4600 | 159 | 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 | 159 | sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); | 4604 | | /* Copy the function and line number entries. */ | 4605 | 159 | do | 4606 | 233 | *n_cache_ptr++ = *old_ptr++; | 4607 | 233 | while (old_ptr->line_number != 0); | 4608 | 159 | } | 4609 | | | 4610 | 18 | memcpy (lineno_cache, n_lineno_cache, | 4611 | 18 | asect->lineno_count * sizeof (alent)); | 4612 | 18 | } | 4613 | 0 | else | 4614 | 0 | ret = false; | 4615 | 18 | bfd_release (abfd, func_table); | 4616 | 18 | } | 4617 | 0 | else | 4618 | 0 | ret = false; | 4619 | 18 | } | 4620 | | | 4621 | 43 | return ret; | 4622 | 43 | } |
coff-x86_64.c:coff_slurp_line_table Line | Count | Source | 4425 | 25.2k | { | 4426 | 25.2k | LINENO *native_lineno; | 4427 | 25.2k | alent *lineno_cache; | 4428 | 25.2k | unsigned int counter; | 4429 | 25.2k | alent *cache_ptr; | 4430 | 25.2k | bfd_vma prev_offset = 0; | 4431 | 25.2k | bool ordered = true; | 4432 | 25.2k | unsigned int nbr_func; | 4433 | 25.2k | LINENO *src; | 4434 | 25.2k | bool have_func; | 4435 | 25.2k | bool ret = true; | 4436 | 25.2k | size_t amt; | 4437 | | | 4438 | 25.2k | if (asect->lineno_count == 0) | 4439 | 25.2k | return true; | 4440 | | | 4441 | 64 | BFD_ASSERT (asect->lineno == NULL); | 4442 | | | 4443 | 64 | native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, | 4444 | 64 | asect->lineno_count, | 4445 | 64 | bfd_coff_linesz (abfd)); | 4446 | 64 | if (native_lineno == NULL) | 4447 | 0 | { | 4448 | 0 | _bfd_error_handler | 4449 | 0 | (_("%pB: warning: line number table read failed"), abfd); | 4450 | 0 | return false; | 4451 | 0 | } | 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 | 5.02k | for (counter = 0; counter < asect->lineno_count; counter++, src++) | 4473 | 4.95k | { | 4474 | 4.95k | struct internal_lineno dst; | 4475 | | | 4476 | 4.95k | bfd_coff_swap_lineno_in (abfd, src, &dst); | 4477 | 4.95k | 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 | 4.95k | memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); | 4482 | | | 4483 | 4.95k | if (cache_ptr->line_number == 0) | 4484 | 1.03k | { | 4485 | 1.03k | combined_entry_type * ent; | 4486 | 1.03k | unsigned long symndx; | 4487 | 1.03k | coff_symbol_type *sym; | 4488 | | | 4489 | 1.03k | have_func = false; | 4490 | 1.03k | symndx = dst.l_addr.l_symndx; | 4491 | 1.03k | if (symndx >= obj_raw_syment_count (abfd)) | 4492 | 0 | { | 4493 | 0 | _bfd_error_handler | 4494 | | /* xgettext:c-format */ | 4495 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4496 | 0 | abfd, symndx, counter); | 4497 | 0 | cache_ptr->line_number = -1; | 4498 | 0 | ret = false; | 4499 | 0 | continue; | 4500 | 0 | } | 4501 | | | 4502 | 1.03k | ent = obj_raw_syments (abfd) + symndx; | 4503 | | /* FIXME: We should not be casting between ints and | 4504 | | pointers like this. */ | 4505 | 1.03k | if (! ent->is_sym) | 4506 | 0 | { | 4507 | 0 | _bfd_error_handler | 4508 | | /* xgettext:c-format */ | 4509 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4510 | 0 | abfd, symndx, counter); | 4511 | 0 | cache_ptr->line_number = -1; | 4512 | 0 | ret = false; | 4513 | 0 | continue; | 4514 | 0 | } | 4515 | 1.03k | sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); | 4516 | | | 4517 | | /* PR 17512 file: 078-10659-0.004 */ | 4518 | 1.03k | if (sym < obj_symbols (abfd) | 4519 | 1.03k | || 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 | 1.03k | have_func = true; | 4531 | 1.03k | nbr_func++; | 4532 | 1.03k | cache_ptr->u.sym = (asymbol *) sym; | 4533 | 1.03k | if (sym->lineno != NULL) | 4534 | 971 | _bfd_error_handler | 4535 | | /* xgettext:c-format */ | 4536 | 971 | (_("%pB: warning: duplicate line number information for `%s'"), | 4537 | 971 | abfd, bfd_asymbol_name (&sym->symbol)); | 4538 | | | 4539 | 1.03k | sym->lineno = cache_ptr; | 4540 | 1.03k | if (sym->symbol.value < prev_offset) | 4541 | 29 | ordered = false; | 4542 | 1.03k | prev_offset = sym->symbol.value; | 4543 | 1.03k | } | 4544 | 3.92k | else if (!have_func) | 4545 | | /* Drop line information that has no associated function. | 4546 | | PR 17521: file: 078-10659-0.004. */ | 4547 | 2.86k | continue; | 4548 | 1.05k | else | 4549 | 1.05k | cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect); | 4550 | 2.09k | cache_ptr++; | 4551 | 2.09k | } | 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 | 24 | { | 4560 | | /* Sort the table. */ | 4561 | 24 | alent **func_table; | 4562 | 24 | alent *n_lineno_cache; | 4563 | | | 4564 | | /* Create a table of functions. */ | 4565 | 24 | 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 | 24 | else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL) | 4571 | 24 | { | 4572 | 24 | alent **p = func_table; | 4573 | 24 | unsigned int i; | 4574 | | | 4575 | 866 | for (i = 0; i < asect->lineno_count; i++) | 4576 | 842 | if (lineno_cache[i].line_number == 0) | 4577 | 268 | *p++ = &lineno_cache[i]; | 4578 | | | 4579 | 24 | BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func); | 4580 | | | 4581 | | /* Sort by functions. */ | 4582 | 24 | qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent); | 4583 | | | 4584 | | /* Create the new sorted table. */ | 4585 | 24 | 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 | 24 | else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL) | 4591 | 24 | { | 4592 | 24 | alent *n_cache_ptr = n_lineno_cache; | 4593 | | | 4594 | 292 | for (i = 0; i < nbr_func; i++) | 4595 | 268 | { | 4596 | 268 | coff_symbol_type *sym; | 4597 | 268 | alent *old_ptr = func_table[i]; | 4598 | | | 4599 | | /* Update the function entry. */ | 4600 | 268 | 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 | 268 | sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); | 4604 | | /* Copy the function and line number entries. */ | 4605 | 268 | do | 4606 | 842 | *n_cache_ptr++ = *old_ptr++; | 4607 | 842 | while (old_ptr->line_number != 0); | 4608 | 268 | } | 4609 | | | 4610 | 24 | memcpy (lineno_cache, n_lineno_cache, | 4611 | 24 | asect->lineno_count * sizeof (alent)); | 4612 | 24 | } | 4613 | 0 | else | 4614 | 0 | ret = false; | 4615 | 24 | bfd_release (abfd, func_table); | 4616 | 24 | } | 4617 | 0 | else | 4618 | 0 | ret = false; | 4619 | 24 | } | 4620 | | | 4621 | 64 | return ret; | 4622 | 64 | } |
coff64-rs6000.c:coff_slurp_line_table Line | Count | Source | 4425 | 1.10k | { | 4426 | 1.10k | LINENO *native_lineno; | 4427 | 1.10k | alent *lineno_cache; | 4428 | 1.10k | unsigned int counter; | 4429 | 1.10k | alent *cache_ptr; | 4430 | 1.10k | bfd_vma prev_offset = 0; | 4431 | 1.10k | bool ordered = true; | 4432 | 1.10k | unsigned int nbr_func; | 4433 | 1.10k | LINENO *src; | 4434 | 1.10k | bool have_func; | 4435 | 1.10k | bool ret = true; | 4436 | 1.10k | size_t amt; | 4437 | | | 4438 | 1.10k | if (asect->lineno_count == 0) | 4439 | 1.04k | return true; | 4440 | | | 4441 | 65 | BFD_ASSERT (asect->lineno == NULL); | 4442 | | | 4443 | 65 | native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, | 4444 | 65 | asect->lineno_count, | 4445 | 65 | bfd_coff_linesz (abfd)); | 4446 | 65 | if (native_lineno == NULL) | 4447 | 0 | { | 4448 | 0 | _bfd_error_handler | 4449 | 0 | (_("%pB: warning: line number table read failed"), abfd); | 4450 | 0 | return false; | 4451 | 0 | } | 4452 | | | 4453 | 65 | 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 | 65 | lineno_cache = (alent *) bfd_alloc (abfd, amt); | 4460 | 65 | if (lineno_cache == NULL) | 4461 | 0 | { | 4462 | 0 | free (native_lineno); | 4463 | 0 | return false; | 4464 | 0 | } | 4465 | | | 4466 | 65 | cache_ptr = lineno_cache; | 4467 | 65 | asect->lineno = lineno_cache; | 4468 | 65 | src = native_lineno; | 4469 | 65 | nbr_func = 0; | 4470 | 65 | have_func = false; | 4471 | | | 4472 | 1.42k | for (counter = 0; counter < asect->lineno_count; counter++, src++) | 4473 | 1.36k | { | 4474 | 1.36k | struct internal_lineno dst; | 4475 | | | 4476 | 1.36k | bfd_coff_swap_lineno_in (abfd, src, &dst); | 4477 | 1.36k | 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 | 1.36k | memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); | 4482 | | | 4483 | 1.36k | if (cache_ptr->line_number == 0) | 4484 | 499 | { | 4485 | 499 | combined_entry_type * ent; | 4486 | 499 | unsigned long symndx; | 4487 | 499 | coff_symbol_type *sym; | 4488 | | | 4489 | 499 | have_func = false; | 4490 | 499 | symndx = dst.l_addr.l_symndx; | 4491 | 499 | if (symndx >= obj_raw_syment_count (abfd)) | 4492 | 0 | { | 4493 | 0 | _bfd_error_handler | 4494 | | /* xgettext:c-format */ | 4495 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4496 | 0 | abfd, symndx, counter); | 4497 | 0 | cache_ptr->line_number = -1; | 4498 | 0 | ret = false; | 4499 | 0 | continue; | 4500 | 0 | } | 4501 | | | 4502 | 499 | ent = obj_raw_syments (abfd) + symndx; | 4503 | | /* FIXME: We should not be casting between ints and | 4504 | | pointers like this. */ | 4505 | 499 | if (! ent->is_sym) | 4506 | 0 | { | 4507 | 0 | _bfd_error_handler | 4508 | | /* xgettext:c-format */ | 4509 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4510 | 0 | abfd, symndx, counter); | 4511 | 0 | cache_ptr->line_number = -1; | 4512 | 0 | ret = false; | 4513 | 0 | continue; | 4514 | 0 | } | 4515 | 499 | sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); | 4516 | | | 4517 | | /* PR 17512 file: 078-10659-0.004 */ | 4518 | 499 | if (sym < obj_symbols (abfd) | 4519 | 499 | || 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 | 499 | have_func = true; | 4531 | 499 | nbr_func++; | 4532 | 499 | cache_ptr->u.sym = (asymbol *) sym; | 4533 | 499 | if (sym->lineno != NULL) | 4534 | 437 | _bfd_error_handler | 4535 | | /* xgettext:c-format */ | 4536 | 437 | (_("%pB: warning: duplicate line number information for `%s'"), | 4537 | 437 | abfd, bfd_asymbol_name (&sym->symbol)); | 4538 | | | 4539 | 499 | sym->lineno = cache_ptr; | 4540 | 499 | if (sym->symbol.value < prev_offset) | 4541 | 41 | ordered = false; | 4542 | 499 | prev_offset = sym->symbol.value; | 4543 | 499 | } | 4544 | 865 | else if (!have_func) | 4545 | | /* Drop line information that has no associated function. | 4546 | | PR 17521: file: 078-10659-0.004. */ | 4547 | 290 | continue; | 4548 | 575 | else | 4549 | 575 | cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect); | 4550 | 1.07k | cache_ptr++; | 4551 | 1.07k | } | 4552 | | | 4553 | 65 | asect->lineno_count = cache_ptr - lineno_cache; | 4554 | 65 | memset (cache_ptr, 0, sizeof (*cache_ptr)); | 4555 | 65 | free (native_lineno); | 4556 | | | 4557 | | /* On some systems (eg AIX5.3) the lineno table may not be sorted. */ | 4558 | 65 | if (!ordered) | 4559 | 30 | { | 4560 | | /* Sort the table. */ | 4561 | 30 | alent **func_table; | 4562 | 30 | alent *n_lineno_cache; | 4563 | | | 4564 | | /* Create a table of functions. */ | 4565 | 30 | 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 | 30 | else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL) | 4571 | 30 | { | 4572 | 30 | alent **p = func_table; | 4573 | 30 | unsigned int i; | 4574 | | | 4575 | 252 | for (i = 0; i < asect->lineno_count; i++) | 4576 | 222 | if (lineno_cache[i].line_number == 0) | 4577 | 157 | *p++ = &lineno_cache[i]; | 4578 | | | 4579 | 30 | BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func); | 4580 | | | 4581 | | /* Sort by functions. */ | 4582 | 30 | qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent); | 4583 | | | 4584 | | /* Create the new sorted table. */ | 4585 | 30 | 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 | 30 | else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL) | 4591 | 30 | { | 4592 | 30 | alent *n_cache_ptr = n_lineno_cache; | 4593 | | | 4594 | 187 | for (i = 0; i < nbr_func; i++) | 4595 | 157 | { | 4596 | 157 | coff_symbol_type *sym; | 4597 | 157 | alent *old_ptr = func_table[i]; | 4598 | | | 4599 | | /* Update the function entry. */ | 4600 | 157 | 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 | 157 | sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); | 4604 | | /* Copy the function and line number entries. */ | 4605 | 157 | do | 4606 | 222 | *n_cache_ptr++ = *old_ptr++; | 4607 | 222 | while (old_ptr->line_number != 0); | 4608 | 157 | } | 4609 | | | 4610 | 30 | memcpy (lineno_cache, n_lineno_cache, | 4611 | 30 | asect->lineno_count * sizeof (alent)); | 4612 | 30 | } | 4613 | 0 | else | 4614 | 0 | ret = false; | 4615 | 30 | bfd_release (abfd, func_table); | 4616 | 30 | } | 4617 | 0 | else | 4618 | 0 | ret = false; | 4619 | 30 | } | 4620 | | | 4621 | 65 | return ret; | 4622 | 65 | } |
pei-aarch64.c:coff_slurp_line_table Line | Count | Source | 4425 | 272 | { | 4426 | 272 | LINENO *native_lineno; | 4427 | 272 | alent *lineno_cache; | 4428 | 272 | unsigned int counter; | 4429 | 272 | alent *cache_ptr; | 4430 | 272 | bfd_vma prev_offset = 0; | 4431 | 272 | bool ordered = true; | 4432 | 272 | unsigned int nbr_func; | 4433 | 272 | LINENO *src; | 4434 | 272 | bool have_func; | 4435 | 272 | bool ret = true; | 4436 | 272 | size_t amt; | 4437 | | | 4438 | 272 | if (asect->lineno_count == 0) | 4439 | 241 | return true; | 4440 | | | 4441 | 31 | BFD_ASSERT (asect->lineno == NULL); | 4442 | | | 4443 | 31 | native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, | 4444 | 31 | asect->lineno_count, | 4445 | 31 | bfd_coff_linesz (abfd)); | 4446 | 31 | if (native_lineno == NULL) | 4447 | 0 | { | 4448 | 0 | _bfd_error_handler | 4449 | 0 | (_("%pB: warning: line number table read failed"), abfd); | 4450 | 0 | return false; | 4451 | 0 | } | 4452 | | | 4453 | 31 | 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 | 31 | lineno_cache = (alent *) bfd_alloc (abfd, amt); | 4460 | 31 | if (lineno_cache == NULL) | 4461 | 0 | { | 4462 | 0 | free (native_lineno); | 4463 | 0 | return false; | 4464 | 0 | } | 4465 | | | 4466 | 31 | cache_ptr = lineno_cache; | 4467 | 31 | asect->lineno = lineno_cache; | 4468 | 31 | src = native_lineno; | 4469 | 31 | nbr_func = 0; | 4470 | 31 | have_func = false; | 4471 | | | 4472 | 309 | for (counter = 0; counter < asect->lineno_count; counter++, src++) | 4473 | 278 | { | 4474 | 278 | struct internal_lineno dst; | 4475 | | | 4476 | 278 | bfd_coff_swap_lineno_in (abfd, src, &dst); | 4477 | 278 | 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 | 278 | memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); | 4482 | | | 4483 | 278 | if (cache_ptr->line_number == 0) | 4484 | 206 | { | 4485 | 206 | combined_entry_type * ent; | 4486 | 206 | unsigned long symndx; | 4487 | 206 | coff_symbol_type *sym; | 4488 | | | 4489 | 206 | have_func = false; | 4490 | 206 | symndx = dst.l_addr.l_symndx; | 4491 | 206 | if (symndx >= obj_raw_syment_count (abfd)) | 4492 | 0 | { | 4493 | 0 | _bfd_error_handler | 4494 | | /* xgettext:c-format */ | 4495 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4496 | 0 | abfd, symndx, counter); | 4497 | 0 | cache_ptr->line_number = -1; | 4498 | 0 | ret = false; | 4499 | 0 | continue; | 4500 | 0 | } | 4501 | | | 4502 | 206 | ent = obj_raw_syments (abfd) + symndx; | 4503 | | /* FIXME: We should not be casting between ints and | 4504 | | pointers like this. */ | 4505 | 206 | if (! ent->is_sym) | 4506 | 0 | { | 4507 | 0 | _bfd_error_handler | 4508 | | /* xgettext:c-format */ | 4509 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4510 | 0 | abfd, symndx, counter); | 4511 | 0 | cache_ptr->line_number = -1; | 4512 | 0 | ret = false; | 4513 | 0 | continue; | 4514 | 0 | } | 4515 | 206 | sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); | 4516 | | | 4517 | | /* PR 17512 file: 078-10659-0.004 */ | 4518 | 206 | if (sym < obj_symbols (abfd) | 4519 | 206 | || 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 | 206 | have_func = true; | 4531 | 206 | nbr_func++; | 4532 | 206 | cache_ptr->u.sym = (asymbol *) sym; | 4533 | 206 | if (sym->lineno != NULL) | 4534 | 147 | _bfd_error_handler | 4535 | | /* xgettext:c-format */ | 4536 | 147 | (_("%pB: warning: duplicate line number information for `%s'"), | 4537 | 147 | abfd, bfd_asymbol_name (&sym->symbol)); | 4538 | | | 4539 | 206 | sym->lineno = cache_ptr; | 4540 | 206 | if (sym->symbol.value < prev_offset) | 4541 | 28 | ordered = false; | 4542 | 206 | prev_offset = sym->symbol.value; | 4543 | 206 | } | 4544 | 72 | else if (!have_func) | 4545 | | /* Drop line information that has no associated function. | 4546 | | PR 17521: file: 078-10659-0.004. */ | 4547 | 21 | continue; | 4548 | 51 | else | 4549 | 51 | cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect); | 4550 | 257 | cache_ptr++; | 4551 | 257 | } | 4552 | | | 4553 | 31 | asect->lineno_count = cache_ptr - lineno_cache; | 4554 | 31 | memset (cache_ptr, 0, sizeof (*cache_ptr)); | 4555 | 31 | free (native_lineno); | 4556 | | | 4557 | | /* On some systems (eg AIX5.3) the lineno table may not be sorted. */ | 4558 | 31 | 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 | 264 | for (i = 0; i < asect->lineno_count; i++) | 4576 | 243 | if (lineno_cache[i].line_number == 0) | 4577 | 194 | *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 | 215 | for (i = 0; i < nbr_func; i++) | 4595 | 194 | { | 4596 | 194 | coff_symbol_type *sym; | 4597 | 194 | alent *old_ptr = func_table[i]; | 4598 | | | 4599 | | /* Update the function entry. */ | 4600 | 194 | 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 | 194 | sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); | 4604 | | /* Copy the function and line number entries. */ | 4605 | 194 | do | 4606 | 243 | *n_cache_ptr++ = *old_ptr++; | 4607 | 243 | while (old_ptr->line_number != 0); | 4608 | 194 | } | 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 | 31 | return ret; | 4622 | 31 | } |
pe-aarch64.c:coff_slurp_line_table Line | Count | Source | 4425 | 605 | { | 4426 | 605 | LINENO *native_lineno; | 4427 | 605 | alent *lineno_cache; | 4428 | 605 | unsigned int counter; | 4429 | 605 | alent *cache_ptr; | 4430 | 605 | bfd_vma prev_offset = 0; | 4431 | 605 | bool ordered = true; | 4432 | 605 | unsigned int nbr_func; | 4433 | 605 | LINENO *src; | 4434 | 605 | bool have_func; | 4435 | 605 | bool ret = true; | 4436 | 605 | size_t amt; | 4437 | | | 4438 | 605 | if (asect->lineno_count == 0) | 4439 | 569 | return true; | 4440 | | | 4441 | 36 | BFD_ASSERT (asect->lineno == NULL); | 4442 | | | 4443 | 36 | native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, | 4444 | 36 | asect->lineno_count, | 4445 | 36 | bfd_coff_linesz (abfd)); | 4446 | 36 | if (native_lineno == NULL) | 4447 | 0 | { | 4448 | 0 | _bfd_error_handler | 4449 | 0 | (_("%pB: warning: line number table read failed"), abfd); | 4450 | 0 | return false; | 4451 | 0 | } | 4452 | | | 4453 | 36 | 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 | 36 | lineno_cache = (alent *) bfd_alloc (abfd, amt); | 4460 | 36 | if (lineno_cache == NULL) | 4461 | 0 | { | 4462 | 0 | free (native_lineno); | 4463 | 0 | return false; | 4464 | 0 | } | 4465 | | | 4466 | 36 | cache_ptr = lineno_cache; | 4467 | 36 | asect->lineno = lineno_cache; | 4468 | 36 | src = native_lineno; | 4469 | 36 | nbr_func = 0; | 4470 | 36 | have_func = false; | 4471 | | | 4472 | 511 | for (counter = 0; counter < asect->lineno_count; counter++, src++) | 4473 | 475 | { | 4474 | 475 | struct internal_lineno dst; | 4475 | | | 4476 | 475 | bfd_coff_swap_lineno_in (abfd, src, &dst); | 4477 | 475 | 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 | 475 | memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); | 4482 | | | 4483 | 475 | if (cache_ptr->line_number == 0) | 4484 | 192 | { | 4485 | 192 | combined_entry_type * ent; | 4486 | 192 | unsigned long symndx; | 4487 | 192 | coff_symbol_type *sym; | 4488 | | | 4489 | 192 | have_func = false; | 4490 | 192 | symndx = dst.l_addr.l_symndx; | 4491 | 192 | if (symndx >= obj_raw_syment_count (abfd)) | 4492 | 0 | { | 4493 | 0 | _bfd_error_handler | 4494 | | /* xgettext:c-format */ | 4495 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4496 | 0 | abfd, symndx, counter); | 4497 | 0 | cache_ptr->line_number = -1; | 4498 | 0 | ret = false; | 4499 | 0 | continue; | 4500 | 0 | } | 4501 | | | 4502 | 192 | ent = obj_raw_syments (abfd) + symndx; | 4503 | | /* FIXME: We should not be casting between ints and | 4504 | | pointers like this. */ | 4505 | 192 | if (! ent->is_sym) | 4506 | 0 | { | 4507 | 0 | _bfd_error_handler | 4508 | | /* xgettext:c-format */ | 4509 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4510 | 0 | abfd, symndx, counter); | 4511 | 0 | cache_ptr->line_number = -1; | 4512 | 0 | ret = false; | 4513 | 0 | continue; | 4514 | 0 | } | 4515 | 192 | sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); | 4516 | | | 4517 | | /* PR 17512 file: 078-10659-0.004 */ | 4518 | 192 | if (sym < obj_symbols (abfd) | 4519 | 192 | || 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 | 192 | have_func = true; | 4531 | 192 | nbr_func++; | 4532 | 192 | cache_ptr->u.sym = (asymbol *) sym; | 4533 | 192 | if (sym->lineno != NULL) | 4534 | 161 | _bfd_error_handler | 4535 | | /* xgettext:c-format */ | 4536 | 161 | (_("%pB: warning: duplicate line number information for `%s'"), | 4537 | 161 | abfd, bfd_asymbol_name (&sym->symbol)); | 4538 | | | 4539 | 192 | sym->lineno = cache_ptr; | 4540 | 192 | if (sym->symbol.value < prev_offset) | 4541 | 8 | ordered = false; | 4542 | 192 | prev_offset = sym->symbol.value; | 4543 | 192 | } | 4544 | 283 | else if (!have_func) | 4545 | | /* Drop line information that has no associated function. | 4546 | | PR 17521: file: 078-10659-0.004. */ | 4547 | 236 | continue; | 4548 | 47 | else | 4549 | 47 | cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect); | 4550 | 239 | cache_ptr++; | 4551 | 239 | } | 4552 | | | 4553 | 36 | asect->lineno_count = cache_ptr - lineno_cache; | 4554 | 36 | memset (cache_ptr, 0, sizeof (*cache_ptr)); | 4555 | 36 | free (native_lineno); | 4556 | | | 4557 | | /* On some systems (eg AIX5.3) the lineno table may not be sorted. */ | 4558 | 36 | if (!ordered) | 4559 | 8 | { | 4560 | | /* Sort the table. */ | 4561 | 8 | alent **func_table; | 4562 | 8 | alent *n_lineno_cache; | 4563 | | | 4564 | | /* Create a table of functions. */ | 4565 | 8 | 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 | 8 | else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL) | 4571 | 8 | { | 4572 | 8 | alent **p = func_table; | 4573 | 8 | unsigned int i; | 4574 | | | 4575 | 65 | for (i = 0; i < asect->lineno_count; i++) | 4576 | 57 | if (lineno_cache[i].line_number == 0) | 4577 | 33 | *p++ = &lineno_cache[i]; | 4578 | | | 4579 | 8 | BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func); | 4580 | | | 4581 | | /* Sort by functions. */ | 4582 | 8 | qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent); | 4583 | | | 4584 | | /* Create the new sorted table. */ | 4585 | 8 | 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 | 8 | else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL) | 4591 | 8 | { | 4592 | 8 | alent *n_cache_ptr = n_lineno_cache; | 4593 | | | 4594 | 41 | for (i = 0; i < nbr_func; i++) | 4595 | 33 | { | 4596 | 33 | coff_symbol_type *sym; | 4597 | 33 | alent *old_ptr = func_table[i]; | 4598 | | | 4599 | | /* Update the function entry. */ | 4600 | 33 | 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 | 33 | sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); | 4604 | | /* Copy the function and line number entries. */ | 4605 | 33 | do | 4606 | 57 | *n_cache_ptr++ = *old_ptr++; | 4607 | 57 | while (old_ptr->line_number != 0); | 4608 | 33 | } | 4609 | | | 4610 | 8 | memcpy (lineno_cache, n_lineno_cache, | 4611 | 8 | asect->lineno_count * sizeof (alent)); | 4612 | 8 | } | 4613 | 0 | else | 4614 | 0 | ret = false; | 4615 | 8 | bfd_release (abfd, func_table); | 4616 | 8 | } | 4617 | 0 | else | 4618 | 0 | ret = false; | 4619 | 8 | } | 4620 | | | 4621 | 36 | return ret; | 4622 | 36 | } |
pei-ia64.c:coff_slurp_line_table Line | Count | Source | 4425 | 104 | { | 4426 | 104 | LINENO *native_lineno; | 4427 | 104 | alent *lineno_cache; | 4428 | 104 | unsigned int counter; | 4429 | 104 | alent *cache_ptr; | 4430 | 104 | bfd_vma prev_offset = 0; | 4431 | 104 | bool ordered = true; | 4432 | 104 | unsigned int nbr_func; | 4433 | 104 | LINENO *src; | 4434 | 104 | bool have_func; | 4435 | 104 | bool ret = true; | 4436 | 104 | size_t amt; | 4437 | | | 4438 | 104 | if (asect->lineno_count == 0) | 4439 | 77 | return true; | 4440 | | | 4441 | 27 | BFD_ASSERT (asect->lineno == NULL); | 4442 | | | 4443 | 27 | native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, | 4444 | 27 | asect->lineno_count, | 4445 | 27 | bfd_coff_linesz (abfd)); | 4446 | 27 | if (native_lineno == NULL) | 4447 | 0 | { | 4448 | 0 | _bfd_error_handler | 4449 | 0 | (_("%pB: warning: line number table read failed"), abfd); | 4450 | 0 | return false; | 4451 | 0 | } | 4452 | | | 4453 | 27 | 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 | 27 | lineno_cache = (alent *) bfd_alloc (abfd, amt); | 4460 | 27 | if (lineno_cache == NULL) | 4461 | 0 | { | 4462 | 0 | free (native_lineno); | 4463 | 0 | return false; | 4464 | 0 | } | 4465 | | | 4466 | 27 | cache_ptr = lineno_cache; | 4467 | 27 | asect->lineno = lineno_cache; | 4468 | 27 | src = native_lineno; | 4469 | 27 | nbr_func = 0; | 4470 | 27 | have_func = false; | 4471 | | | 4472 | 320 | for (counter = 0; counter < asect->lineno_count; counter++, src++) | 4473 | 293 | { | 4474 | 293 | struct internal_lineno dst; | 4475 | | | 4476 | 293 | bfd_coff_swap_lineno_in (abfd, src, &dst); | 4477 | 293 | 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 | 293 | memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); | 4482 | | | 4483 | 293 | if (cache_ptr->line_number == 0) | 4484 | 141 | { | 4485 | 141 | combined_entry_type * ent; | 4486 | 141 | unsigned long symndx; | 4487 | 141 | coff_symbol_type *sym; | 4488 | | | 4489 | 141 | have_func = false; | 4490 | 141 | symndx = dst.l_addr.l_symndx; | 4491 | 141 | if (symndx >= obj_raw_syment_count (abfd)) | 4492 | 0 | { | 4493 | 0 | _bfd_error_handler | 4494 | | /* xgettext:c-format */ | 4495 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4496 | 0 | abfd, symndx, counter); | 4497 | 0 | cache_ptr->line_number = -1; | 4498 | 0 | ret = false; | 4499 | 0 | continue; | 4500 | 0 | } | 4501 | | | 4502 | 141 | ent = obj_raw_syments (abfd) + symndx; | 4503 | | /* FIXME: We should not be casting between ints and | 4504 | | pointers like this. */ | 4505 | 141 | if (! ent->is_sym) | 4506 | 0 | { | 4507 | 0 | _bfd_error_handler | 4508 | | /* xgettext:c-format */ | 4509 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4510 | 0 | abfd, symndx, counter); | 4511 | 0 | cache_ptr->line_number = -1; | 4512 | 0 | ret = false; | 4513 | 0 | continue; | 4514 | 0 | } | 4515 | 141 | sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); | 4516 | | | 4517 | | /* PR 17512 file: 078-10659-0.004 */ | 4518 | 141 | if (sym < obj_symbols (abfd) | 4519 | 141 | || 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 | 141 | have_func = true; | 4531 | 141 | nbr_func++; | 4532 | 141 | cache_ptr->u.sym = (asymbol *) sym; | 4533 | 141 | if (sym->lineno != NULL) | 4534 | 111 | _bfd_error_handler | 4535 | | /* xgettext:c-format */ | 4536 | 111 | (_("%pB: warning: duplicate line number information for `%s'"), | 4537 | 111 | abfd, bfd_asymbol_name (&sym->symbol)); | 4538 | | | 4539 | 141 | sym->lineno = cache_ptr; | 4540 | 141 | if (sym->symbol.value < prev_offset) | 4541 | 11 | ordered = false; | 4542 | 141 | prev_offset = sym->symbol.value; | 4543 | 141 | } | 4544 | 152 | else if (!have_func) | 4545 | | /* Drop line information that has no associated function. | 4546 | | PR 17521: file: 078-10659-0.004. */ | 4547 | 63 | continue; | 4548 | 89 | else | 4549 | 89 | cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect); | 4550 | 230 | cache_ptr++; | 4551 | 230 | } | 4552 | | | 4553 | 27 | asect->lineno_count = cache_ptr - lineno_cache; | 4554 | 27 | memset (cache_ptr, 0, sizeof (*cache_ptr)); | 4555 | 27 | free (native_lineno); | 4556 | | | 4557 | | /* On some systems (eg AIX5.3) the lineno table may not be sorted. */ | 4558 | 27 | if (!ordered) | 4559 | 11 | { | 4560 | | /* Sort the table. */ | 4561 | 11 | alent **func_table; | 4562 | 11 | alent *n_lineno_cache; | 4563 | | | 4564 | | /* Create a table of functions. */ | 4565 | 11 | 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 | 11 | else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL) | 4571 | 11 | { | 4572 | 11 | alent **p = func_table; | 4573 | 11 | unsigned int i; | 4574 | | | 4575 | 99 | for (i = 0; i < asect->lineno_count; i++) | 4576 | 88 | if (lineno_cache[i].line_number == 0) | 4577 | 44 | *p++ = &lineno_cache[i]; | 4578 | | | 4579 | 11 | BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func); | 4580 | | | 4581 | | /* Sort by functions. */ | 4582 | 11 | qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent); | 4583 | | | 4584 | | /* Create the new sorted table. */ | 4585 | 11 | 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 | 11 | else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL) | 4591 | 11 | { | 4592 | 11 | alent *n_cache_ptr = n_lineno_cache; | 4593 | | | 4594 | 55 | for (i = 0; i < nbr_func; i++) | 4595 | 44 | { | 4596 | 44 | coff_symbol_type *sym; | 4597 | 44 | alent *old_ptr = func_table[i]; | 4598 | | | 4599 | | /* Update the function entry. */ | 4600 | 44 | 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 | 44 | sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); | 4604 | | /* Copy the function and line number entries. */ | 4605 | 44 | do | 4606 | 88 | *n_cache_ptr++ = *old_ptr++; | 4607 | 88 | while (old_ptr->line_number != 0); | 4608 | 44 | } | 4609 | | | 4610 | 11 | memcpy (lineno_cache, n_lineno_cache, | 4611 | 11 | asect->lineno_count * sizeof (alent)); | 4612 | 11 | } | 4613 | 0 | else | 4614 | 0 | ret = false; | 4615 | 11 | bfd_release (abfd, func_table); | 4616 | 11 | } | 4617 | 0 | else | 4618 | 0 | ret = false; | 4619 | 11 | } | 4620 | | | 4621 | 27 | return ret; | 4622 | 27 | } |
pei-loongarch64.c:coff_slurp_line_table Line | Count | Source | 4425 | 285 | { | 4426 | 285 | LINENO *native_lineno; | 4427 | 285 | alent *lineno_cache; | 4428 | 285 | unsigned int counter; | 4429 | 285 | alent *cache_ptr; | 4430 | 285 | bfd_vma prev_offset = 0; | 4431 | 285 | bool ordered = true; | 4432 | 285 | unsigned int nbr_func; | 4433 | 285 | LINENO *src; | 4434 | 285 | bool have_func; | 4435 | 285 | bool ret = true; | 4436 | 285 | size_t amt; | 4437 | | | 4438 | 285 | if (asect->lineno_count == 0) | 4439 | 243 | return true; | 4440 | | | 4441 | 42 | BFD_ASSERT (asect->lineno == NULL); | 4442 | | | 4443 | 42 | native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, | 4444 | 42 | asect->lineno_count, | 4445 | 42 | bfd_coff_linesz (abfd)); | 4446 | 42 | if (native_lineno == NULL) | 4447 | 0 | { | 4448 | 0 | _bfd_error_handler | 4449 | 0 | (_("%pB: warning: line number table read failed"), abfd); | 4450 | 0 | return false; | 4451 | 0 | } | 4452 | | | 4453 | 42 | 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 | 42 | lineno_cache = (alent *) bfd_alloc (abfd, amt); | 4460 | 42 | if (lineno_cache == NULL) | 4461 | 0 | { | 4462 | 0 | free (native_lineno); | 4463 | 0 | return false; | 4464 | 0 | } | 4465 | | | 4466 | 42 | cache_ptr = lineno_cache; | 4467 | 42 | asect->lineno = lineno_cache; | 4468 | 42 | src = native_lineno; | 4469 | 42 | nbr_func = 0; | 4470 | 42 | have_func = false; | 4471 | | | 4472 | 1.41k | for (counter = 0; counter < asect->lineno_count; counter++, src++) | 4473 | 1.37k | { | 4474 | 1.37k | struct internal_lineno dst; | 4475 | | | 4476 | 1.37k | bfd_coff_swap_lineno_in (abfd, src, &dst); | 4477 | 1.37k | 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 | 1.37k | memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); | 4482 | | | 4483 | 1.37k | if (cache_ptr->line_number == 0) | 4484 | 314 | { | 4485 | 314 | combined_entry_type * ent; | 4486 | 314 | unsigned long symndx; | 4487 | 314 | coff_symbol_type *sym; | 4488 | | | 4489 | 314 | have_func = false; | 4490 | 314 | symndx = dst.l_addr.l_symndx; | 4491 | 314 | if (symndx >= obj_raw_syment_count (abfd)) | 4492 | 0 | { | 4493 | 0 | _bfd_error_handler | 4494 | | /* xgettext:c-format */ | 4495 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4496 | 0 | abfd, symndx, counter); | 4497 | 0 | cache_ptr->line_number = -1; | 4498 | 0 | ret = false; | 4499 | 0 | continue; | 4500 | 0 | } | 4501 | | | 4502 | 314 | ent = obj_raw_syments (abfd) + symndx; | 4503 | | /* FIXME: We should not be casting between ints and | 4504 | | pointers like this. */ | 4505 | 314 | if (! ent->is_sym) | 4506 | 0 | { | 4507 | 0 | _bfd_error_handler | 4508 | | /* xgettext:c-format */ | 4509 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4510 | 0 | abfd, symndx, counter); | 4511 | 0 | cache_ptr->line_number = -1; | 4512 | 0 | ret = false; | 4513 | 0 | continue; | 4514 | 0 | } | 4515 | 314 | sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); | 4516 | | | 4517 | | /* PR 17512 file: 078-10659-0.004 */ | 4518 | 314 | if (sym < obj_symbols (abfd) | 4519 | 314 | || 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 | 314 | have_func = true; | 4531 | 314 | nbr_func++; | 4532 | 314 | cache_ptr->u.sym = (asymbol *) sym; | 4533 | 314 | if (sym->lineno != NULL) | 4534 | 250 | _bfd_error_handler | 4535 | | /* xgettext:c-format */ | 4536 | 250 | (_("%pB: warning: duplicate line number information for `%s'"), | 4537 | 250 | abfd, bfd_asymbol_name (&sym->symbol)); | 4538 | | | 4539 | 314 | sym->lineno = cache_ptr; | 4540 | 314 | if (sym->symbol.value < prev_offset) | 4541 | 30 | ordered = false; | 4542 | 314 | prev_offset = sym->symbol.value; | 4543 | 314 | } | 4544 | 1.06k | else if (!have_func) | 4545 | | /* Drop line information that has no associated function. | 4546 | | PR 17521: file: 078-10659-0.004. */ | 4547 | 508 | continue; | 4548 | 552 | else | 4549 | 552 | cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect); | 4550 | 866 | cache_ptr++; | 4551 | 866 | } | 4552 | | | 4553 | 42 | asect->lineno_count = cache_ptr - lineno_cache; | 4554 | 42 | memset (cache_ptr, 0, sizeof (*cache_ptr)); | 4555 | 42 | free (native_lineno); | 4556 | | | 4557 | | /* On some systems (eg AIX5.3) the lineno table may not be sorted. */ | 4558 | 42 | if (!ordered) | 4559 | 25 | { | 4560 | | /* Sort the table. */ | 4561 | 25 | alent **func_table; | 4562 | 25 | alent *n_lineno_cache; | 4563 | | | 4564 | | /* Create a table of functions. */ | 4565 | 25 | 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 | 25 | else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL) | 4571 | 25 | { | 4572 | 25 | alent **p = func_table; | 4573 | 25 | unsigned int i; | 4574 | | | 4575 | 630 | for (i = 0; i < asect->lineno_count; i++) | 4576 | 605 | if (lineno_cache[i].line_number == 0) | 4577 | 159 | *p++ = &lineno_cache[i]; | 4578 | | | 4579 | 25 | BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func); | 4580 | | | 4581 | | /* Sort by functions. */ | 4582 | 25 | qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent); | 4583 | | | 4584 | | /* Create the new sorted table. */ | 4585 | 25 | 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 | 25 | else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL) | 4591 | 25 | { | 4592 | 25 | alent *n_cache_ptr = n_lineno_cache; | 4593 | | | 4594 | 184 | for (i = 0; i < nbr_func; i++) | 4595 | 159 | { | 4596 | 159 | coff_symbol_type *sym; | 4597 | 159 | alent *old_ptr = func_table[i]; | 4598 | | | 4599 | | /* Update the function entry. */ | 4600 | 159 | 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 | 159 | sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); | 4604 | | /* Copy the function and line number entries. */ | 4605 | 159 | do | 4606 | 605 | *n_cache_ptr++ = *old_ptr++; | 4607 | 605 | while (old_ptr->line_number != 0); | 4608 | 159 | } | 4609 | | | 4610 | 25 | memcpy (lineno_cache, n_lineno_cache, | 4611 | 25 | asect->lineno_count * sizeof (alent)); | 4612 | 25 | } | 4613 | 0 | else | 4614 | 0 | ret = false; | 4615 | 25 | bfd_release (abfd, func_table); | 4616 | 25 | } | 4617 | 0 | else | 4618 | 0 | ret = false; | 4619 | 25 | } | 4620 | | | 4621 | 42 | return ret; | 4622 | 42 | } |
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 | 9.28k | { | 4426 | 9.28k | LINENO *native_lineno; | 4427 | 9.28k | alent *lineno_cache; | 4428 | 9.28k | unsigned int counter; | 4429 | 9.28k | alent *cache_ptr; | 4430 | 9.28k | bfd_vma prev_offset = 0; | 4431 | 9.28k | bool ordered = true; | 4432 | 9.28k | unsigned int nbr_func; | 4433 | 9.28k | LINENO *src; | 4434 | 9.28k | bool have_func; | 4435 | 9.28k | bool ret = true; | 4436 | 9.28k | size_t amt; | 4437 | | | 4438 | 9.28k | if (asect->lineno_count == 0) | 4439 | 9.13k | return true; | 4440 | | | 4441 | 151 | BFD_ASSERT (asect->lineno == NULL); | 4442 | | | 4443 | 151 | native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, | 4444 | 151 | asect->lineno_count, | 4445 | 151 | bfd_coff_linesz (abfd)); | 4446 | 151 | if (native_lineno == NULL) | 4447 | 0 | { | 4448 | 0 | _bfd_error_handler | 4449 | 0 | (_("%pB: warning: line number table read failed"), abfd); | 4450 | 0 | return false; | 4451 | 0 | } | 4452 | | | 4453 | 151 | 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 | 151 | lineno_cache = (alent *) bfd_alloc (abfd, amt); | 4460 | 151 | if (lineno_cache == NULL) | 4461 | 0 | { | 4462 | 0 | free (native_lineno); | 4463 | 0 | return false; | 4464 | 0 | } | 4465 | | | 4466 | 151 | cache_ptr = lineno_cache; | 4467 | 151 | asect->lineno = lineno_cache; | 4468 | 151 | src = native_lineno; | 4469 | 151 | nbr_func = 0; | 4470 | 151 | have_func = false; | 4471 | | | 4472 | 25.2k | for (counter = 0; counter < asect->lineno_count; counter++, src++) | 4473 | 25.1k | { | 4474 | 25.1k | struct internal_lineno dst; | 4475 | | | 4476 | 25.1k | bfd_coff_swap_lineno_in (abfd, src, &dst); | 4477 | 25.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 | 25.1k | memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); | 4482 | | | 4483 | 25.1k | if (cache_ptr->line_number == 0) | 4484 | 24.0k | { | 4485 | 24.0k | combined_entry_type * ent; | 4486 | 24.0k | unsigned long symndx; | 4487 | 24.0k | coff_symbol_type *sym; | 4488 | | | 4489 | 24.0k | have_func = false; | 4490 | 24.0k | symndx = dst.l_addr.l_symndx; | 4491 | 24.0k | if (symndx >= obj_raw_syment_count (abfd)) | 4492 | 0 | { | 4493 | 0 | _bfd_error_handler | 4494 | | /* xgettext:c-format */ | 4495 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4496 | 0 | abfd, symndx, counter); | 4497 | 0 | cache_ptr->line_number = -1; | 4498 | 0 | ret = false; | 4499 | 0 | continue; | 4500 | 0 | } | 4501 | | | 4502 | 24.0k | ent = obj_raw_syments (abfd) + symndx; | 4503 | | /* FIXME: We should not be casting between ints and | 4504 | | pointers like this. */ | 4505 | 24.0k | if (! ent->is_sym) | 4506 | 0 | { | 4507 | 0 | _bfd_error_handler | 4508 | | /* xgettext:c-format */ | 4509 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4510 | 0 | abfd, symndx, counter); | 4511 | 0 | cache_ptr->line_number = -1; | 4512 | 0 | ret = false; | 4513 | 0 | continue; | 4514 | 0 | } | 4515 | 24.0k | sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); | 4516 | | | 4517 | | /* PR 17512 file: 078-10659-0.004 */ | 4518 | 24.0k | if (sym < obj_symbols (abfd) | 4519 | 24.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 | 24.0k | have_func = true; | 4531 | 24.0k | nbr_func++; | 4532 | 24.0k | cache_ptr->u.sym = (asymbol *) sym; | 4533 | 24.0k | 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.0k | sym->lineno = cache_ptr; | 4540 | 24.0k | if (sym->symbol.value < prev_offset) | 4541 | 138 | ordered = false; | 4542 | 24.0k | prev_offset = sym->symbol.value; | 4543 | 24.0k | } | 4544 | 1.06k | else if (!have_func) | 4545 | | /* Drop line information that has no associated function. | 4546 | | PR 17521: file: 078-10659-0.004. */ | 4547 | 497 | continue; | 4548 | 565 | else | 4549 | 565 | cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect); | 4550 | 24.6k | cache_ptr++; | 4551 | 24.6k | } | 4552 | | | 4553 | 151 | asect->lineno_count = cache_ptr - lineno_cache; | 4554 | 151 | memset (cache_ptr, 0, sizeof (*cache_ptr)); | 4555 | 151 | free (native_lineno); | 4556 | | | 4557 | | /* On some systems (eg AIX5.3) the lineno table may not be sorted. */ | 4558 | 151 | if (!ordered) | 4559 | 91 | { | 4560 | | /* Sort the table. */ | 4561 | 91 | alent **func_table; | 4562 | 91 | alent *n_lineno_cache; | 4563 | | | 4564 | | /* Create a table of functions. */ | 4565 | 91 | 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 | 91 | else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL) | 4571 | 91 | { | 4572 | 91 | alent **p = func_table; | 4573 | 91 | unsigned int i; | 4574 | | | 4575 | 18.9k | for (i = 0; i < asect->lineno_count; i++) | 4576 | 18.8k | if (lineno_cache[i].line_number == 0) | 4577 | 18.4k | *p++ = &lineno_cache[i]; | 4578 | | | 4579 | 91 | BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func); | 4580 | | | 4581 | | /* Sort by functions. */ | 4582 | 91 | qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent); | 4583 | | | 4584 | | /* Create the new sorted table. */ | 4585 | 91 | 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 | 91 | else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL) | 4591 | 91 | { | 4592 | 91 | alent *n_cache_ptr = n_lineno_cache; | 4593 | | | 4594 | 18.5k | for (i = 0; i < nbr_func; i++) | 4595 | 18.4k | { | 4596 | 18.4k | coff_symbol_type *sym; | 4597 | 18.4k | alent *old_ptr = func_table[i]; | 4598 | | | 4599 | | /* Update the function entry. */ | 4600 | 18.4k | 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 | 18.4k | sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); | 4604 | | /* Copy the function and line number entries. */ | 4605 | 18.4k | do | 4606 | 18.8k | *n_cache_ptr++ = *old_ptr++; | 4607 | 18.8k | while (old_ptr->line_number != 0); | 4608 | 18.4k | } | 4609 | | | 4610 | 91 | memcpy (lineno_cache, n_lineno_cache, | 4611 | 91 | asect->lineno_count * sizeof (alent)); | 4612 | 91 | } | 4613 | 0 | else | 4614 | 0 | ret = false; | 4615 | 91 | bfd_release (abfd, func_table); | 4616 | 91 | } | 4617 | 0 | else | 4618 | 0 | ret = false; | 4619 | 91 | } | 4620 | | | 4621 | 151 | return ret; | 4622 | 151 | } |
coff-sh.c:coff_slurp_line_table Line | Count | Source | 4425 | 1.96k | { | 4426 | 1.96k | LINENO *native_lineno; | 4427 | 1.96k | alent *lineno_cache; | 4428 | 1.96k | unsigned int counter; | 4429 | 1.96k | alent *cache_ptr; | 4430 | 1.96k | bfd_vma prev_offset = 0; | 4431 | 1.96k | bool ordered = true; | 4432 | 1.96k | unsigned int nbr_func; | 4433 | 1.96k | LINENO *src; | 4434 | 1.96k | bool have_func; | 4435 | 1.96k | bool ret = true; | 4436 | 1.96k | size_t amt; | 4437 | | | 4438 | 1.96k | if (asect->lineno_count == 0) | 4439 | 1.88k | return true; | 4440 | | | 4441 | 82 | BFD_ASSERT (asect->lineno == NULL); | 4442 | | | 4443 | 82 | native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, | 4444 | 82 | asect->lineno_count, | 4445 | 82 | bfd_coff_linesz (abfd)); | 4446 | 82 | if (native_lineno == NULL) | 4447 | 0 | { | 4448 | 0 | _bfd_error_handler | 4449 | 0 | (_("%pB: warning: line number table read failed"), abfd); | 4450 | 0 | return false; | 4451 | 0 | } | 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 | 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 | 5.40k | { | 4485 | 5.40k | combined_entry_type * ent; | 4486 | 5.40k | unsigned long symndx; | 4487 | 5.40k | coff_symbol_type *sym; | 4488 | | | 4489 | 5.40k | have_func = false; | 4490 | 5.40k | symndx = dst.l_addr.l_symndx; | 4491 | 5.40k | if (symndx >= obj_raw_syment_count (abfd)) | 4492 | 0 | { | 4493 | 0 | _bfd_error_handler | 4494 | | /* xgettext:c-format */ | 4495 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4496 | 0 | abfd, symndx, counter); | 4497 | 0 | cache_ptr->line_number = -1; | 4498 | 0 | ret = false; | 4499 | 0 | continue; | 4500 | 0 | } | 4501 | | | 4502 | 5.40k | ent = obj_raw_syments (abfd) + symndx; | 4503 | | /* FIXME: We should not be casting between ints and | 4504 | | pointers like this. */ | 4505 | 5.40k | if (! ent->is_sym) | 4506 | 0 | { | 4507 | 0 | _bfd_error_handler | 4508 | | /* xgettext:c-format */ | 4509 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4510 | 0 | abfd, symndx, counter); | 4511 | 0 | cache_ptr->line_number = -1; | 4512 | 0 | ret = false; | 4513 | 0 | continue; | 4514 | 0 | } | 4515 | 5.40k | sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); | 4516 | | | 4517 | | /* PR 17512 file: 078-10659-0.004 */ | 4518 | 5.40k | if (sym < obj_symbols (abfd) | 4519 | 5.40k | || 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 | 5.40k | have_func = true; | 4531 | 5.40k | nbr_func++; | 4532 | 5.40k | cache_ptr->u.sym = (asymbol *) sym; | 4533 | 5.40k | if (sym->lineno != NULL) | 4534 | 5.34k | _bfd_error_handler | 4535 | | /* xgettext:c-format */ | 4536 | 5.34k | (_("%pB: warning: duplicate line number information for `%s'"), | 4537 | 5.34k | abfd, bfd_asymbol_name (&sym->symbol)); | 4538 | | | 4539 | 5.40k | sym->lineno = cache_ptr; | 4540 | 5.40k | if (sym->symbol.value < prev_offset) | 4541 | 26 | ordered = false; | 4542 | 5.40k | prev_offset = sym->symbol.value; | 4543 | 5.40k | } | 4544 | 11.3k | else if (!have_func) | 4545 | | /* Drop line information that has no associated function. | 4546 | | PR 17521: file: 078-10659-0.004. */ | 4547 | 3.78k | continue; | 4548 | 7.60k | else | 4549 | 7.60k | cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect); | 4550 | 13.0k | cache_ptr++; | 4551 | 13.0k | } | 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 | 23 | { | 4560 | | /* Sort the table. */ | 4561 | 23 | alent **func_table; | 4562 | 23 | alent *n_lineno_cache; | 4563 | | | 4564 | | /* Create a table of functions. */ | 4565 | 23 | 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 | 23 | else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL) | 4571 | 23 | { | 4572 | 23 | alent **p = func_table; | 4573 | 23 | unsigned int i; | 4574 | | | 4575 | 7.03k | for (i = 0; i < asect->lineno_count; i++) | 4576 | 7.01k | if (lineno_cache[i].line_number == 0) | 4577 | 3.01k | *p++ = &lineno_cache[i]; | 4578 | | | 4579 | 23 | BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func); | 4580 | | | 4581 | | /* Sort by functions. */ | 4582 | 23 | qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent); | 4583 | | | 4584 | | /* Create the new sorted table. */ | 4585 | 23 | 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 | 23 | else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL) | 4591 | 23 | { | 4592 | 23 | alent *n_cache_ptr = n_lineno_cache; | 4593 | | | 4594 | 3.04k | for (i = 0; i < nbr_func; i++) | 4595 | 3.01k | { | 4596 | 3.01k | coff_symbol_type *sym; | 4597 | 3.01k | alent *old_ptr = func_table[i]; | 4598 | | | 4599 | | /* Update the function entry. */ | 4600 | 3.01k | 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 | 3.01k | sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); | 4604 | | /* Copy the function and line number entries. */ | 4605 | 3.01k | do | 4606 | 7.01k | *n_cache_ptr++ = *old_ptr++; | 4607 | 7.01k | while (old_ptr->line_number != 0); | 4608 | 3.01k | } | 4609 | | | 4610 | 23 | memcpy (lineno_cache, n_lineno_cache, | 4611 | 23 | asect->lineno_count * sizeof (alent)); | 4612 | 23 | } | 4613 | 0 | else | 4614 | 0 | ret = false; | 4615 | 23 | bfd_release (abfd, func_table); | 4616 | 23 | } | 4617 | 0 | else | 4618 | 0 | ret = false; | 4619 | 23 | } | 4620 | | | 4621 | 82 | return ret; | 4622 | 82 | } |
Unexecuted instantiation: coff-stgo32.c:coff_slurp_line_table coff-tic30.c:coff_slurp_line_table Line | Count | Source | 4425 | 182 | { | 4426 | 182 | LINENO *native_lineno; | 4427 | 182 | alent *lineno_cache; | 4428 | 182 | unsigned int counter; | 4429 | 182 | alent *cache_ptr; | 4430 | 182 | bfd_vma prev_offset = 0; | 4431 | 182 | bool ordered = true; | 4432 | 182 | unsigned int nbr_func; | 4433 | 182 | LINENO *src; | 4434 | 182 | bool have_func; | 4435 | 182 | bool ret = true; | 4436 | 182 | size_t amt; | 4437 | | | 4438 | 182 | if (asect->lineno_count == 0) | 4439 | 108 | return true; | 4440 | | | 4441 | 74 | BFD_ASSERT (asect->lineno == NULL); | 4442 | | | 4443 | 74 | native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, | 4444 | 74 | asect->lineno_count, | 4445 | 74 | bfd_coff_linesz (abfd)); | 4446 | 74 | if (native_lineno == NULL) | 4447 | 0 | { | 4448 | 0 | _bfd_error_handler | 4449 | 0 | (_("%pB: warning: line number table read failed"), abfd); | 4450 | 0 | return false; | 4451 | 0 | } | 4452 | | | 4453 | 74 | 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 | 74 | lineno_cache = (alent *) bfd_alloc (abfd, amt); | 4460 | 74 | if (lineno_cache == NULL) | 4461 | 0 | { | 4462 | 0 | free (native_lineno); | 4463 | 0 | return false; | 4464 | 0 | } | 4465 | | | 4466 | 74 | cache_ptr = lineno_cache; | 4467 | 74 | asect->lineno = lineno_cache; | 4468 | 74 | src = native_lineno; | 4469 | 74 | nbr_func = 0; | 4470 | 74 | have_func = false; | 4471 | | | 4472 | 3.81k | for (counter = 0; counter < asect->lineno_count; counter++, src++) | 4473 | 3.74k | { | 4474 | 3.74k | struct internal_lineno dst; | 4475 | | | 4476 | 3.74k | bfd_coff_swap_lineno_in (abfd, src, &dst); | 4477 | 3.74k | 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 | 3.74k | memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); | 4482 | | | 4483 | 3.74k | if (cache_ptr->line_number == 0) | 4484 | 448 | { | 4485 | 448 | combined_entry_type * ent; | 4486 | 448 | unsigned long symndx; | 4487 | 448 | coff_symbol_type *sym; | 4488 | | | 4489 | 448 | have_func = false; | 4490 | 448 | symndx = dst.l_addr.l_symndx; | 4491 | 448 | if (symndx >= obj_raw_syment_count (abfd)) | 4492 | 0 | { | 4493 | 0 | _bfd_error_handler | 4494 | | /* xgettext:c-format */ | 4495 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4496 | 0 | abfd, symndx, counter); | 4497 | 0 | cache_ptr->line_number = -1; | 4498 | 0 | ret = false; | 4499 | 0 | continue; | 4500 | 0 | } | 4501 | | | 4502 | 448 | ent = obj_raw_syments (abfd) + symndx; | 4503 | | /* FIXME: We should not be casting between ints and | 4504 | | pointers like this. */ | 4505 | 448 | if (! ent->is_sym) | 4506 | 0 | { | 4507 | 0 | _bfd_error_handler | 4508 | | /* xgettext:c-format */ | 4509 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4510 | 0 | abfd, symndx, counter); | 4511 | 0 | cache_ptr->line_number = -1; | 4512 | 0 | ret = false; | 4513 | 0 | continue; | 4514 | 0 | } | 4515 | 448 | sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); | 4516 | | | 4517 | | /* PR 17512 file: 078-10659-0.004 */ | 4518 | 448 | if (sym < obj_symbols (abfd) | 4519 | 448 | || 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 | 448 | have_func = true; | 4531 | 448 | nbr_func++; | 4532 | 448 | cache_ptr->u.sym = (asymbol *) sym; | 4533 | 448 | if (sym->lineno != NULL) | 4534 | 376 | _bfd_error_handler | 4535 | | /* xgettext:c-format */ | 4536 | 376 | (_("%pB: warning: duplicate line number information for `%s'"), | 4537 | 376 | abfd, bfd_asymbol_name (&sym->symbol)); | 4538 | | | 4539 | 448 | sym->lineno = cache_ptr; | 4540 | 448 | if (sym->symbol.value < prev_offset) | 4541 | 38 | ordered = false; | 4542 | 448 | prev_offset = sym->symbol.value; | 4543 | 448 | } | 4544 | 3.29k | else if (!have_func) | 4545 | | /* Drop line information that has no associated function. | 4546 | | PR 17521: file: 078-10659-0.004. */ | 4547 | 1.71k | continue; | 4548 | 1.58k | else | 4549 | 1.58k | cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect); | 4550 | 2.02k | cache_ptr++; | 4551 | 2.02k | } | 4552 | | | 4553 | 74 | asect->lineno_count = cache_ptr - lineno_cache; | 4554 | 74 | memset (cache_ptr, 0, sizeof (*cache_ptr)); | 4555 | 74 | free (native_lineno); | 4556 | | | 4557 | | /* On some systems (eg AIX5.3) the lineno table may not be sorted. */ | 4558 | 74 | if (!ordered) | 4559 | 33 | { | 4560 | | /* Sort the table. */ | 4561 | 33 | alent **func_table; | 4562 | 33 | alent *n_lineno_cache; | 4563 | | | 4564 | | /* Create a table of functions. */ | 4565 | 33 | 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 | 33 | else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL) | 4571 | 33 | { | 4572 | 33 | alent **p = func_table; | 4573 | 33 | unsigned int i; | 4574 | | | 4575 | 1.42k | for (i = 0; i < asect->lineno_count; i++) | 4576 | 1.39k | if (lineno_cache[i].line_number == 0) | 4577 | 356 | *p++ = &lineno_cache[i]; | 4578 | | | 4579 | 33 | BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func); | 4580 | | | 4581 | | /* Sort by functions. */ | 4582 | 33 | qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent); | 4583 | | | 4584 | | /* Create the new sorted table. */ | 4585 | 33 | 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 | 33 | else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL) | 4591 | 33 | { | 4592 | 33 | alent *n_cache_ptr = n_lineno_cache; | 4593 | | | 4594 | 389 | for (i = 0; i < nbr_func; i++) | 4595 | 356 | { | 4596 | 356 | coff_symbol_type *sym; | 4597 | 356 | alent *old_ptr = func_table[i]; | 4598 | | | 4599 | | /* Update the function entry. */ | 4600 | 356 | 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 | 356 | sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); | 4604 | | /* Copy the function and line number entries. */ | 4605 | 356 | do | 4606 | 1.39k | *n_cache_ptr++ = *old_ptr++; | 4607 | 1.39k | while (old_ptr->line_number != 0); | 4608 | 356 | } | 4609 | | | 4610 | 33 | memcpy (lineno_cache, n_lineno_cache, | 4611 | 33 | asect->lineno_count * sizeof (alent)); | 4612 | 33 | } | 4613 | 0 | else | 4614 | 0 | ret = false; | 4615 | 33 | bfd_release (abfd, func_table); | 4616 | 33 | } | 4617 | 0 | else | 4618 | 0 | ret = false; | 4619 | 33 | } | 4620 | | | 4621 | 74 | return ret; | 4622 | 74 | } |
Unexecuted instantiation: coff-tic4x.c:coff_slurp_line_table coff-tic54x.c:coff_slurp_line_table Line | Count | Source | 4425 | 668 | { | 4426 | 668 | LINENO *native_lineno; | 4427 | 668 | alent *lineno_cache; | 4428 | 668 | unsigned int counter; | 4429 | 668 | alent *cache_ptr; | 4430 | 668 | bfd_vma prev_offset = 0; | 4431 | 668 | bool ordered = true; | 4432 | 668 | unsigned int nbr_func; | 4433 | 668 | LINENO *src; | 4434 | 668 | bool have_func; | 4435 | 668 | bool ret = true; | 4436 | 668 | size_t amt; | 4437 | | | 4438 | 668 | if (asect->lineno_count == 0) | 4439 | 640 | return true; | 4440 | | | 4441 | 28 | BFD_ASSERT (asect->lineno == NULL); | 4442 | | | 4443 | 28 | native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, | 4444 | 28 | asect->lineno_count, | 4445 | 28 | bfd_coff_linesz (abfd)); | 4446 | 28 | if (native_lineno == NULL) | 4447 | 0 | { | 4448 | 0 | _bfd_error_handler | 4449 | 0 | (_("%pB: warning: line number table read failed"), abfd); | 4450 | 0 | return false; | 4451 | 0 | } | 4452 | | | 4453 | 28 | 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 | 28 | lineno_cache = (alent *) bfd_alloc (abfd, amt); | 4460 | 28 | if (lineno_cache == NULL) | 4461 | 0 | { | 4462 | 0 | free (native_lineno); | 4463 | 0 | return false; | 4464 | 0 | } | 4465 | | | 4466 | 28 | cache_ptr = lineno_cache; | 4467 | 28 | asect->lineno = lineno_cache; | 4468 | 28 | src = native_lineno; | 4469 | 28 | nbr_func = 0; | 4470 | 28 | have_func = false; | 4471 | | | 4472 | 742 | for (counter = 0; counter < asect->lineno_count; counter++, src++) | 4473 | 714 | { | 4474 | 714 | struct internal_lineno dst; | 4475 | | | 4476 | 714 | bfd_coff_swap_lineno_in (abfd, src, &dst); | 4477 | 714 | 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 | 714 | memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); | 4482 | | | 4483 | 714 | if (cache_ptr->line_number == 0) | 4484 | 552 | { | 4485 | 552 | combined_entry_type * ent; | 4486 | 552 | unsigned long symndx; | 4487 | 552 | coff_symbol_type *sym; | 4488 | | | 4489 | 552 | have_func = false; | 4490 | 552 | symndx = dst.l_addr.l_symndx; | 4491 | 552 | if (symndx >= obj_raw_syment_count (abfd)) | 4492 | 0 | { | 4493 | 0 | _bfd_error_handler | 4494 | | /* xgettext:c-format */ | 4495 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4496 | 0 | abfd, symndx, counter); | 4497 | 0 | cache_ptr->line_number = -1; | 4498 | 0 | ret = false; | 4499 | 0 | continue; | 4500 | 0 | } | 4501 | | | 4502 | 552 | ent = obj_raw_syments (abfd) + symndx; | 4503 | | /* FIXME: We should not be casting between ints and | 4504 | | pointers like this. */ | 4505 | 552 | if (! ent->is_sym) | 4506 | 0 | { | 4507 | 0 | _bfd_error_handler | 4508 | | /* xgettext:c-format */ | 4509 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4510 | 0 | abfd, symndx, counter); | 4511 | 0 | cache_ptr->line_number = -1; | 4512 | 0 | ret = false; | 4513 | 0 | continue; | 4514 | 0 | } | 4515 | 552 | sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); | 4516 | | | 4517 | | /* PR 17512 file: 078-10659-0.004 */ | 4518 | 552 | if (sym < obj_symbols (abfd) | 4519 | 552 | || 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 | 552 | have_func = true; | 4531 | 552 | nbr_func++; | 4532 | 552 | cache_ptr->u.sym = (asymbol *) sym; | 4533 | 552 | if (sym->lineno != NULL) | 4534 | 517 | _bfd_error_handler | 4535 | | /* xgettext:c-format */ | 4536 | 517 | (_("%pB: warning: duplicate line number information for `%s'"), | 4537 | 517 | abfd, bfd_asymbol_name (&sym->symbol)); | 4538 | | | 4539 | 552 | sym->lineno = cache_ptr; | 4540 | 552 | if (sym->symbol.value < prev_offset) | 4541 | 18 | ordered = false; | 4542 | 552 | prev_offset = sym->symbol.value; | 4543 | 552 | } | 4544 | 162 | else if (!have_func) | 4545 | | /* Drop line information that has no associated function. | 4546 | | PR 17521: file: 078-10659-0.004. */ | 4547 | 46 | continue; | 4548 | 116 | else | 4549 | 116 | cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect); | 4550 | 668 | cache_ptr++; | 4551 | 668 | } | 4552 | | | 4553 | 28 | asect->lineno_count = cache_ptr - lineno_cache; | 4554 | 28 | memset (cache_ptr, 0, sizeof (*cache_ptr)); | 4555 | 28 | free (native_lineno); | 4556 | | | 4557 | | /* On some systems (eg AIX5.3) the lineno table may not be sorted. */ | 4558 | 28 | if (!ordered) | 4559 | 11 | { | 4560 | | /* Sort the table. */ | 4561 | 11 | alent **func_table; | 4562 | 11 | alent *n_lineno_cache; | 4563 | | | 4564 | | /* Create a table of functions. */ | 4565 | 11 | 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 | 11 | else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL) | 4571 | 11 | { | 4572 | 11 | alent **p = func_table; | 4573 | 11 | unsigned int i; | 4574 | | | 4575 | 620 | for (i = 0; i < asect->lineno_count; i++) | 4576 | 609 | if (lineno_cache[i].line_number == 0) | 4577 | 522 | *p++ = &lineno_cache[i]; | 4578 | | | 4579 | 11 | BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func); | 4580 | | | 4581 | | /* Sort by functions. */ | 4582 | 11 | qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent); | 4583 | | | 4584 | | /* Create the new sorted table. */ | 4585 | 11 | 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 | 11 | else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL) | 4591 | 11 | { | 4592 | 11 | alent *n_cache_ptr = n_lineno_cache; | 4593 | | | 4594 | 533 | for (i = 0; i < nbr_func; i++) | 4595 | 522 | { | 4596 | 522 | coff_symbol_type *sym; | 4597 | 522 | alent *old_ptr = func_table[i]; | 4598 | | | 4599 | | /* Update the function entry. */ | 4600 | 522 | 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 | 522 | sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); | 4604 | | /* Copy the function and line number entries. */ | 4605 | 522 | do | 4606 | 609 | *n_cache_ptr++ = *old_ptr++; | 4607 | 609 | while (old_ptr->line_number != 0); | 4608 | 522 | } | 4609 | | | 4610 | 11 | memcpy (lineno_cache, n_lineno_cache, | 4611 | 11 | asect->lineno_count * sizeof (alent)); | 4612 | 11 | } | 4613 | 0 | else | 4614 | 0 | ret = false; | 4615 | 11 | bfd_release (abfd, func_table); | 4616 | 11 | } | 4617 | 0 | else | 4618 | 0 | ret = false; | 4619 | 11 | } | 4620 | | | 4621 | 28 | return ret; | 4622 | 28 | } |
coff-z80.c:coff_slurp_line_table Line | Count | Source | 4425 | 571 | { | 4426 | 571 | LINENO *native_lineno; | 4427 | 571 | alent *lineno_cache; | 4428 | 571 | unsigned int counter; | 4429 | 571 | alent *cache_ptr; | 4430 | 571 | bfd_vma prev_offset = 0; | 4431 | 571 | bool ordered = true; | 4432 | 571 | unsigned int nbr_func; | 4433 | 571 | LINENO *src; | 4434 | 571 | bool have_func; | 4435 | 571 | bool ret = true; | 4436 | 571 | size_t amt; | 4437 | | | 4438 | 571 | if (asect->lineno_count == 0) | 4439 | 504 | return true; | 4440 | | | 4441 | 67 | BFD_ASSERT (asect->lineno == NULL); | 4442 | | | 4443 | 67 | native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, | 4444 | 67 | asect->lineno_count, | 4445 | 67 | bfd_coff_linesz (abfd)); | 4446 | 67 | if (native_lineno == NULL) | 4447 | 0 | { | 4448 | 0 | _bfd_error_handler | 4449 | 0 | (_("%pB: warning: line number table read failed"), abfd); | 4450 | 0 | return false; | 4451 | 0 | } | 4452 | | | 4453 | 67 | 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 | 67 | lineno_cache = (alent *) bfd_alloc (abfd, amt); | 4460 | 67 | if (lineno_cache == NULL) | 4461 | 0 | { | 4462 | 0 | free (native_lineno); | 4463 | 0 | return false; | 4464 | 0 | } | 4465 | | | 4466 | 67 | cache_ptr = lineno_cache; | 4467 | 67 | asect->lineno = lineno_cache; | 4468 | 67 | src = native_lineno; | 4469 | 67 | nbr_func = 0; | 4470 | 67 | have_func = false; | 4471 | | | 4472 | 613 | for (counter = 0; counter < asect->lineno_count; counter++, src++) | 4473 | 546 | { | 4474 | 546 | struct internal_lineno dst; | 4475 | | | 4476 | 546 | bfd_coff_swap_lineno_in (abfd, src, &dst); | 4477 | 546 | 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 | 546 | memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); | 4482 | | | 4483 | 546 | if (cache_ptr->line_number == 0) | 4484 | 282 | { | 4485 | 282 | combined_entry_type * ent; | 4486 | 282 | unsigned long symndx; | 4487 | 282 | coff_symbol_type *sym; | 4488 | | | 4489 | 282 | have_func = false; | 4490 | 282 | symndx = dst.l_addr.l_symndx; | 4491 | 282 | if (symndx >= obj_raw_syment_count (abfd)) | 4492 | 0 | { | 4493 | 0 | _bfd_error_handler | 4494 | | /* xgettext:c-format */ | 4495 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4496 | 0 | abfd, symndx, counter); | 4497 | 0 | cache_ptr->line_number = -1; | 4498 | 0 | ret = false; | 4499 | 0 | continue; | 4500 | 0 | } | 4501 | | | 4502 | 282 | ent = obj_raw_syments (abfd) + symndx; | 4503 | | /* FIXME: We should not be casting between ints and | 4504 | | pointers like this. */ | 4505 | 282 | if (! ent->is_sym) | 4506 | 0 | { | 4507 | 0 | _bfd_error_handler | 4508 | | /* xgettext:c-format */ | 4509 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4510 | 0 | abfd, symndx, counter); | 4511 | 0 | cache_ptr->line_number = -1; | 4512 | 0 | ret = false; | 4513 | 0 | continue; | 4514 | 0 | } | 4515 | 282 | sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); | 4516 | | | 4517 | | /* PR 17512 file: 078-10659-0.004 */ | 4518 | 282 | if (sym < obj_symbols (abfd) | 4519 | 282 | || 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 | 282 | have_func = true; | 4531 | 282 | nbr_func++; | 4532 | 282 | cache_ptr->u.sym = (asymbol *) sym; | 4533 | 282 | if (sym->lineno != NULL) | 4534 | 240 | _bfd_error_handler | 4535 | | /* xgettext:c-format */ | 4536 | 240 | (_("%pB: warning: duplicate line number information for `%s'"), | 4537 | 240 | abfd, bfd_asymbol_name (&sym->symbol)); | 4538 | | | 4539 | 282 | sym->lineno = cache_ptr; | 4540 | 282 | if (sym->symbol.value < prev_offset) | 4541 | 28 | ordered = false; | 4542 | 282 | prev_offset = sym->symbol.value; | 4543 | 282 | } | 4544 | 264 | else if (!have_func) | 4545 | | /* Drop line information that has no associated function. | 4546 | | PR 17521: file: 078-10659-0.004. */ | 4547 | 175 | continue; | 4548 | 89 | else | 4549 | 89 | cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect); | 4550 | 371 | cache_ptr++; | 4551 | 371 | } | 4552 | | | 4553 | 67 | asect->lineno_count = cache_ptr - lineno_cache; | 4554 | 67 | memset (cache_ptr, 0, sizeof (*cache_ptr)); | 4555 | 67 | free (native_lineno); | 4556 | | | 4557 | | /* On some systems (eg AIX5.3) the lineno table may not be sorted. */ | 4558 | 67 | if (!ordered) | 4559 | 28 | { | 4560 | | /* Sort the table. */ | 4561 | 28 | alent **func_table; | 4562 | 28 | alent *n_lineno_cache; | 4563 | | | 4564 | | /* Create a table of functions. */ | 4565 | 28 | 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 | 28 | else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL) | 4571 | 28 | { | 4572 | 28 | alent **p = func_table; | 4573 | 28 | unsigned int i; | 4574 | | | 4575 | 232 | for (i = 0; i < asect->lineno_count; i++) | 4576 | 204 | if (lineno_cache[i].line_number == 0) | 4577 | 144 | *p++ = &lineno_cache[i]; | 4578 | | | 4579 | 28 | BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func); | 4580 | | | 4581 | | /* Sort by functions. */ | 4582 | 28 | qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent); | 4583 | | | 4584 | | /* Create the new sorted table. */ | 4585 | 28 | 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 | 28 | else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL) | 4591 | 28 | { | 4592 | 28 | alent *n_cache_ptr = n_lineno_cache; | 4593 | | | 4594 | 172 | for (i = 0; i < nbr_func; i++) | 4595 | 144 | { | 4596 | 144 | coff_symbol_type *sym; | 4597 | 144 | alent *old_ptr = func_table[i]; | 4598 | | | 4599 | | /* Update the function entry. */ | 4600 | 144 | 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 | 144 | sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); | 4604 | | /* Copy the function and line number entries. */ | 4605 | 144 | do | 4606 | 204 | *n_cache_ptr++ = *old_ptr++; | 4607 | 204 | while (old_ptr->line_number != 0); | 4608 | 144 | } | 4609 | | | 4610 | 28 | memcpy (lineno_cache, n_lineno_cache, | 4611 | 28 | asect->lineno_count * sizeof (alent)); | 4612 | 28 | } | 4613 | 0 | else | 4614 | 0 | ret = false; | 4615 | 28 | bfd_release (abfd, func_table); | 4616 | 28 | } | 4617 | 0 | else | 4618 | 0 | ret = false; | 4619 | 28 | } | 4620 | | | 4621 | 67 | return ret; | 4622 | 67 | } |
coff-z8k.c:coff_slurp_line_table Line | Count | Source | 4425 | 459 | { | 4426 | 459 | LINENO *native_lineno; | 4427 | 459 | alent *lineno_cache; | 4428 | 459 | unsigned int counter; | 4429 | 459 | alent *cache_ptr; | 4430 | 459 | bfd_vma prev_offset = 0; | 4431 | 459 | bool ordered = true; | 4432 | 459 | unsigned int nbr_func; | 4433 | 459 | LINENO *src; | 4434 | 459 | bool have_func; | 4435 | 459 | bool ret = true; | 4436 | 459 | size_t amt; | 4437 | | | 4438 | 459 | if (asect->lineno_count == 0) | 4439 | 429 | return true; | 4440 | | | 4441 | 30 | BFD_ASSERT (asect->lineno == NULL); | 4442 | | | 4443 | 30 | native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, | 4444 | 30 | asect->lineno_count, | 4445 | 30 | bfd_coff_linesz (abfd)); | 4446 | 30 | if (native_lineno == NULL) | 4447 | 0 | { | 4448 | 0 | _bfd_error_handler | 4449 | 0 | (_("%pB: warning: line number table read failed"), abfd); | 4450 | 0 | return false; | 4451 | 0 | } | 4452 | | | 4453 | 30 | 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 | 30 | lineno_cache = (alent *) bfd_alloc (abfd, amt); | 4460 | 30 | if (lineno_cache == NULL) | 4461 | 0 | { | 4462 | 0 | free (native_lineno); | 4463 | 0 | return false; | 4464 | 0 | } | 4465 | | | 4466 | 30 | cache_ptr = lineno_cache; | 4467 | 30 | asect->lineno = lineno_cache; | 4468 | 30 | src = native_lineno; | 4469 | 30 | nbr_func = 0; | 4470 | 30 | have_func = false; | 4471 | | | 4472 | 843 | for (counter = 0; counter < asect->lineno_count; counter++, src++) | 4473 | 813 | { | 4474 | 813 | struct internal_lineno dst; | 4475 | | | 4476 | 813 | bfd_coff_swap_lineno_in (abfd, src, &dst); | 4477 | 813 | 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 | 813 | memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); | 4482 | | | 4483 | 813 | if (cache_ptr->line_number == 0) | 4484 | 409 | { | 4485 | 409 | combined_entry_type * ent; | 4486 | 409 | unsigned long symndx; | 4487 | 409 | coff_symbol_type *sym; | 4488 | | | 4489 | 409 | have_func = false; | 4490 | 409 | symndx = dst.l_addr.l_symndx; | 4491 | 409 | if (symndx >= obj_raw_syment_count (abfd)) | 4492 | 0 | { | 4493 | 0 | _bfd_error_handler | 4494 | | /* xgettext:c-format */ | 4495 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4496 | 0 | abfd, symndx, counter); | 4497 | 0 | cache_ptr->line_number = -1; | 4498 | 0 | ret = false; | 4499 | 0 | continue; | 4500 | 0 | } | 4501 | | | 4502 | 409 | ent = obj_raw_syments (abfd) + symndx; | 4503 | | /* FIXME: We should not be casting between ints and | 4504 | | pointers like this. */ | 4505 | 409 | if (! ent->is_sym) | 4506 | 0 | { | 4507 | 0 | _bfd_error_handler | 4508 | | /* xgettext:c-format */ | 4509 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4510 | 0 | abfd, symndx, counter); | 4511 | 0 | cache_ptr->line_number = -1; | 4512 | 0 | ret = false; | 4513 | 0 | continue; | 4514 | 0 | } | 4515 | 409 | sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); | 4516 | | | 4517 | | /* PR 17512 file: 078-10659-0.004 */ | 4518 | 409 | if (sym < obj_symbols (abfd) | 4519 | 409 | || 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 | 409 | have_func = true; | 4531 | 409 | nbr_func++; | 4532 | 409 | cache_ptr->u.sym = (asymbol *) sym; | 4533 | 409 | if (sym->lineno != NULL) | 4534 | 393 | _bfd_error_handler | 4535 | | /* xgettext:c-format */ | 4536 | 393 | (_("%pB: warning: duplicate line number information for `%s'"), | 4537 | 393 | abfd, bfd_asymbol_name (&sym->symbol)); | 4538 | | | 4539 | 409 | sym->lineno = cache_ptr; | 4540 | 409 | if (sym->symbol.value < prev_offset) | 4541 | 0 | ordered = false; | 4542 | 409 | prev_offset = sym->symbol.value; | 4543 | 409 | } | 4544 | 404 | else if (!have_func) | 4545 | | /* Drop line information that has no associated function. | 4546 | | PR 17521: file: 078-10659-0.004. */ | 4547 | 270 | continue; | 4548 | 134 | else | 4549 | 134 | cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect); | 4550 | 543 | cache_ptr++; | 4551 | 543 | } | 4552 | | | 4553 | 30 | asect->lineno_count = cache_ptr - lineno_cache; | 4554 | 30 | memset (cache_ptr, 0, sizeof (*cache_ptr)); | 4555 | 30 | free (native_lineno); | 4556 | | | 4557 | | /* On some systems (eg AIX5.3) the lineno table may not be sorted. */ | 4558 | 30 | if (!ordered) | 4559 | 0 | { | 4560 | | /* Sort the table. */ | 4561 | 0 | alent **func_table; | 4562 | 0 | alent *n_lineno_cache; | 4563 | | | 4564 | | /* Create a table of functions. */ | 4565 | 0 | 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 | 0 | else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL) | 4571 | 0 | { | 4572 | 0 | alent **p = func_table; | 4573 | 0 | unsigned int i; | 4574 | |
| 4575 | 0 | for (i = 0; i < asect->lineno_count; i++) | 4576 | 0 | if (lineno_cache[i].line_number == 0) | 4577 | 0 | *p++ = &lineno_cache[i]; | 4578 | |
| 4579 | 0 | BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func); | 4580 | | | 4581 | | /* Sort by functions. */ | 4582 | 0 | qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent); | 4583 | | | 4584 | | /* Create the new sorted table. */ | 4585 | 0 | 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 | 0 | else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL) | 4591 | 0 | { | 4592 | 0 | alent *n_cache_ptr = n_lineno_cache; | 4593 | |
| 4594 | 0 | for (i = 0; i < nbr_func; i++) | 4595 | 0 | { | 4596 | 0 | coff_symbol_type *sym; | 4597 | 0 | alent *old_ptr = func_table[i]; | 4598 | | | 4599 | | /* Update the function entry. */ | 4600 | 0 | 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 | 0 | sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); | 4604 | | /* Copy the function and line number entries. */ | 4605 | 0 | do | 4606 | 0 | *n_cache_ptr++ = *old_ptr++; | 4607 | 0 | while (old_ptr->line_number != 0); | 4608 | 0 | } | 4609 | |
| 4610 | 0 | memcpy (lineno_cache, n_lineno_cache, | 4611 | 0 | asect->lineno_count * sizeof (alent)); | 4612 | 0 | } | 4613 | 0 | else | 4614 | 0 | ret = false; | 4615 | 0 | bfd_release (abfd, func_table); | 4616 | 0 | } | 4617 | 0 | else | 4618 | 0 | ret = false; | 4619 | 0 | } | 4620 | | | 4621 | 30 | return ret; | 4622 | 30 | } |
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 | 821 | { | 4426 | 821 | LINENO *native_lineno; | 4427 | 821 | alent *lineno_cache; | 4428 | 821 | unsigned int counter; | 4429 | 821 | alent *cache_ptr; | 4430 | 821 | bfd_vma prev_offset = 0; | 4431 | 821 | bool ordered = true; | 4432 | 821 | unsigned int nbr_func; | 4433 | 821 | LINENO *src; | 4434 | 821 | bool have_func; | 4435 | 821 | bool ret = true; | 4436 | 821 | size_t amt; | 4437 | | | 4438 | 821 | if (asect->lineno_count == 0) | 4439 | 727 | return true; | 4440 | | | 4441 | 94 | BFD_ASSERT (asect->lineno == NULL); | 4442 | | | 4443 | 94 | native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, | 4444 | 94 | asect->lineno_count, | 4445 | 94 | bfd_coff_linesz (abfd)); | 4446 | 94 | if (native_lineno == NULL) | 4447 | 0 | { | 4448 | 0 | _bfd_error_handler | 4449 | 0 | (_("%pB: warning: line number table read failed"), abfd); | 4450 | 0 | return false; | 4451 | 0 | } | 4452 | | | 4453 | 94 | 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 | 94 | lineno_cache = (alent *) bfd_alloc (abfd, amt); | 4460 | 94 | if (lineno_cache == NULL) | 4461 | 0 | { | 4462 | 0 | free (native_lineno); | 4463 | 0 | return false; | 4464 | 0 | } | 4465 | | | 4466 | 94 | cache_ptr = lineno_cache; | 4467 | 94 | asect->lineno = lineno_cache; | 4468 | 94 | src = native_lineno; | 4469 | 94 | nbr_func = 0; | 4470 | 94 | have_func = false; | 4471 | | | 4472 | 6.89k | for (counter = 0; counter < asect->lineno_count; counter++, src++) | 4473 | 6.80k | { | 4474 | 6.80k | struct internal_lineno dst; | 4475 | | | 4476 | 6.80k | bfd_coff_swap_lineno_in (abfd, src, &dst); | 4477 | 6.80k | 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 | 6.80k | memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); | 4482 | | | 4483 | 6.80k | if (cache_ptr->line_number == 0) | 4484 | 3.52k | { | 4485 | 3.52k | combined_entry_type * ent; | 4486 | 3.52k | unsigned long symndx; | 4487 | 3.52k | coff_symbol_type *sym; | 4488 | | | 4489 | 3.52k | have_func = false; | 4490 | 3.52k | symndx = dst.l_addr.l_symndx; | 4491 | 3.52k | if (symndx >= obj_raw_syment_count (abfd)) | 4492 | 0 | { | 4493 | 0 | _bfd_error_handler | 4494 | | /* xgettext:c-format */ | 4495 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4496 | 0 | abfd, symndx, counter); | 4497 | 0 | cache_ptr->line_number = -1; | 4498 | 0 | ret = false; | 4499 | 0 | continue; | 4500 | 0 | } | 4501 | | | 4502 | 3.52k | ent = obj_raw_syments (abfd) + symndx; | 4503 | | /* FIXME: We should not be casting between ints and | 4504 | | pointers like this. */ | 4505 | 3.52k | if (! ent->is_sym) | 4506 | 0 | { | 4507 | 0 | _bfd_error_handler | 4508 | | /* xgettext:c-format */ | 4509 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4510 | 0 | abfd, symndx, counter); | 4511 | 0 | cache_ptr->line_number = -1; | 4512 | 0 | ret = false; | 4513 | 0 | continue; | 4514 | 0 | } | 4515 | 3.52k | sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); | 4516 | | | 4517 | | /* PR 17512 file: 078-10659-0.004 */ | 4518 | 3.52k | if (sym < obj_symbols (abfd) | 4519 | 3.52k | || 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.52k | have_func = true; | 4531 | 3.52k | nbr_func++; | 4532 | 3.52k | cache_ptr->u.sym = (asymbol *) sym; | 4533 | 3.52k | if (sym->lineno != NULL) | 4534 | 3.45k | _bfd_error_handler | 4535 | | /* xgettext:c-format */ | 4536 | 3.45k | (_("%pB: warning: duplicate line number information for `%s'"), | 4537 | 3.45k | abfd, bfd_asymbol_name (&sym->symbol)); | 4538 | | | 4539 | 3.52k | sym->lineno = cache_ptr; | 4540 | 3.52k | if (sym->symbol.value < prev_offset) | 4541 | 39 | ordered = false; | 4542 | 3.52k | prev_offset = sym->symbol.value; | 4543 | 3.52k | } | 4544 | 3.27k | else if (!have_func) | 4545 | | /* Drop line information that has no associated function. | 4546 | | PR 17521: file: 078-10659-0.004. */ | 4547 | 1.04k | continue; | 4548 | 2.23k | else | 4549 | 2.23k | cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect); | 4550 | 5.75k | cache_ptr++; | 4551 | 5.75k | } | 4552 | | | 4553 | 94 | asect->lineno_count = cache_ptr - lineno_cache; | 4554 | 94 | memset (cache_ptr, 0, sizeof (*cache_ptr)); | 4555 | 94 | free (native_lineno); | 4556 | | | 4557 | | /* On some systems (eg AIX5.3) the lineno table may not be sorted. */ | 4558 | 94 | 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 | 4.29k | for (i = 0; i < asect->lineno_count; i++) | 4576 | 4.26k | if (lineno_cache[i].line_number == 0) | 4577 | 3.17k | *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 | 3.20k | for (i = 0; i < nbr_func; i++) | 4595 | 3.17k | { | 4596 | 3.17k | coff_symbol_type *sym; | 4597 | 3.17k | alent *old_ptr = func_table[i]; | 4598 | | | 4599 | | /* Update the function entry. */ | 4600 | 3.17k | 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 | 3.17k | sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); | 4604 | | /* Copy the function and line number entries. */ | 4605 | 3.17k | do | 4606 | 4.26k | *n_cache_ptr++ = *old_ptr++; | 4607 | 4.26k | while (old_ptr->line_number != 0); | 4608 | 3.17k | } | 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 | 94 | return ret; | 4622 | 94 | } |
pe-mcore.c:coff_slurp_line_table Line | Count | Source | 4425 | 510 | { | 4426 | 510 | LINENO *native_lineno; | 4427 | 510 | alent *lineno_cache; | 4428 | 510 | unsigned int counter; | 4429 | 510 | alent *cache_ptr; | 4430 | 510 | bfd_vma prev_offset = 0; | 4431 | 510 | bool ordered = true; | 4432 | 510 | unsigned int nbr_func; | 4433 | 510 | LINENO *src; | 4434 | 510 | bool have_func; | 4435 | 510 | bool ret = true; | 4436 | 510 | size_t amt; | 4437 | | | 4438 | 510 | if (asect->lineno_count == 0) | 4439 | 461 | return true; | 4440 | | | 4441 | 49 | BFD_ASSERT (asect->lineno == NULL); | 4442 | | | 4443 | 49 | native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, | 4444 | 49 | asect->lineno_count, | 4445 | 49 | bfd_coff_linesz (abfd)); | 4446 | 49 | if (native_lineno == NULL) | 4447 | 0 | { | 4448 | 0 | _bfd_error_handler | 4449 | 0 | (_("%pB: warning: line number table read failed"), abfd); | 4450 | 0 | return false; | 4451 | 0 | } | 4452 | | | 4453 | 49 | 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 | 49 | lineno_cache = (alent *) bfd_alloc (abfd, amt); | 4460 | 49 | if (lineno_cache == NULL) | 4461 | 0 | { | 4462 | 0 | free (native_lineno); | 4463 | 0 | return false; | 4464 | 0 | } | 4465 | | | 4466 | 49 | cache_ptr = lineno_cache; | 4467 | 49 | asect->lineno = lineno_cache; | 4468 | 49 | src = native_lineno; | 4469 | 49 | nbr_func = 0; | 4470 | 49 | have_func = false; | 4471 | | | 4472 | 15.7k | for (counter = 0; counter < asect->lineno_count; counter++, src++) | 4473 | 15.7k | { | 4474 | 15.7k | struct internal_lineno dst; | 4475 | | | 4476 | 15.7k | bfd_coff_swap_lineno_in (abfd, src, &dst); | 4477 | 15.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 | 15.7k | memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); | 4482 | | | 4483 | 15.7k | if (cache_ptr->line_number == 0) | 4484 | 482 | { | 4485 | 482 | combined_entry_type * ent; | 4486 | 482 | unsigned long symndx; | 4487 | 482 | coff_symbol_type *sym; | 4488 | | | 4489 | 482 | have_func = false; | 4490 | 482 | symndx = dst.l_addr.l_symndx; | 4491 | 482 | if (symndx >= obj_raw_syment_count (abfd)) | 4492 | 0 | { | 4493 | 0 | _bfd_error_handler | 4494 | | /* xgettext:c-format */ | 4495 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4496 | 0 | abfd, symndx, counter); | 4497 | 0 | cache_ptr->line_number = -1; | 4498 | 0 | ret = false; | 4499 | 0 | continue; | 4500 | 0 | } | 4501 | | | 4502 | 482 | ent = obj_raw_syments (abfd) + symndx; | 4503 | | /* FIXME: We should not be casting between ints and | 4504 | | pointers like this. */ | 4505 | 482 | if (! ent->is_sym) | 4506 | 0 | { | 4507 | 0 | _bfd_error_handler | 4508 | | /* xgettext:c-format */ | 4509 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4510 | 0 | abfd, symndx, counter); | 4511 | 0 | cache_ptr->line_number = -1; | 4512 | 0 | ret = false; | 4513 | 0 | continue; | 4514 | 0 | } | 4515 | 482 | sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); | 4516 | | | 4517 | | /* PR 17512 file: 078-10659-0.004 */ | 4518 | 482 | if (sym < obj_symbols (abfd) | 4519 | 482 | || 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 | 482 | have_func = true; | 4531 | 482 | nbr_func++; | 4532 | 482 | cache_ptr->u.sym = (asymbol *) sym; | 4533 | 482 | if (sym->lineno != NULL) | 4534 | 433 | _bfd_error_handler | 4535 | | /* xgettext:c-format */ | 4536 | 433 | (_("%pB: warning: duplicate line number information for `%s'"), | 4537 | 433 | abfd, bfd_asymbol_name (&sym->symbol)); | 4538 | | | 4539 | 482 | sym->lineno = cache_ptr; | 4540 | 482 | if (sym->symbol.value < prev_offset) | 4541 | 19 | ordered = false; | 4542 | 482 | prev_offset = sym->symbol.value; | 4543 | 482 | } | 4544 | 15.2k | else if (!have_func) | 4545 | | /* Drop line information that has no associated function. | 4546 | | PR 17521: file: 078-10659-0.004. */ | 4547 | 5.22k | continue; | 4548 | 10.0k | else | 4549 | 10.0k | cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect); | 4550 | 10.5k | cache_ptr++; | 4551 | 10.5k | } | 4552 | | | 4553 | 49 | asect->lineno_count = cache_ptr - lineno_cache; | 4554 | 49 | memset (cache_ptr, 0, sizeof (*cache_ptr)); | 4555 | 49 | free (native_lineno); | 4556 | | | 4557 | | /* On some systems (eg AIX5.3) the lineno table may not be sorted. */ | 4558 | 49 | if (!ordered) | 4559 | 19 | { | 4560 | | /* Sort the table. */ | 4561 | 19 | alent **func_table; | 4562 | 19 | alent *n_lineno_cache; | 4563 | | | 4564 | | /* Create a table of functions. */ | 4565 | 19 | 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 | 19 | else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL) | 4571 | 19 | { | 4572 | 19 | alent **p = func_table; | 4573 | 19 | unsigned int i; | 4574 | | | 4575 | 195 | for (i = 0; i < asect->lineno_count; i++) | 4576 | 176 | if (lineno_cache[i].line_number == 0) | 4577 | 109 | *p++ = &lineno_cache[i]; | 4578 | | | 4579 | 19 | BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func); | 4580 | | | 4581 | | /* Sort by functions. */ | 4582 | 19 | qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent); | 4583 | | | 4584 | | /* Create the new sorted table. */ | 4585 | 19 | 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 | 19 | else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL) | 4591 | 19 | { | 4592 | 19 | alent *n_cache_ptr = n_lineno_cache; | 4593 | | | 4594 | 128 | for (i = 0; i < nbr_func; i++) | 4595 | 109 | { | 4596 | 109 | coff_symbol_type *sym; | 4597 | 109 | alent *old_ptr = func_table[i]; | 4598 | | | 4599 | | /* Update the function entry. */ | 4600 | 109 | 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 | 109 | sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); | 4604 | | /* Copy the function and line number entries. */ | 4605 | 109 | do | 4606 | 176 | *n_cache_ptr++ = *old_ptr++; | 4607 | 176 | while (old_ptr->line_number != 0); | 4608 | 109 | } | 4609 | | | 4610 | 19 | memcpy (lineno_cache, n_lineno_cache, | 4611 | 19 | asect->lineno_count * sizeof (alent)); | 4612 | 19 | } | 4613 | 0 | else | 4614 | 0 | ret = false; | 4615 | 19 | bfd_release (abfd, func_table); | 4616 | 19 | } | 4617 | 0 | else | 4618 | 0 | ret = false; | 4619 | 19 | } | 4620 | | | 4621 | 49 | return ret; | 4622 | 49 | } |
pe-sh.c:coff_slurp_line_table Line | Count | Source | 4425 | 891 | { | 4426 | 891 | LINENO *native_lineno; | 4427 | 891 | alent *lineno_cache; | 4428 | 891 | unsigned int counter; | 4429 | 891 | alent *cache_ptr; | 4430 | 891 | bfd_vma prev_offset = 0; | 4431 | 891 | bool ordered = true; | 4432 | 891 | unsigned int nbr_func; | 4433 | 891 | LINENO *src; | 4434 | 891 | bool have_func; | 4435 | 891 | bool ret = true; | 4436 | 891 | size_t amt; | 4437 | | | 4438 | 891 | if (asect->lineno_count == 0) | 4439 | 818 | return true; | 4440 | | | 4441 | 73 | BFD_ASSERT (asect->lineno == NULL); | 4442 | | | 4443 | 73 | native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, | 4444 | 73 | asect->lineno_count, | 4445 | 73 | bfd_coff_linesz (abfd)); | 4446 | 73 | if (native_lineno == NULL) | 4447 | 0 | { | 4448 | 0 | _bfd_error_handler | 4449 | 0 | (_("%pB: warning: line number table read failed"), abfd); | 4450 | 0 | return false; | 4451 | 0 | } | 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 | 2.00k | for (counter = 0; counter < asect->lineno_count; counter++, src++) | 4473 | 1.93k | { | 4474 | 1.93k | struct internal_lineno dst; | 4475 | | | 4476 | 1.93k | bfd_coff_swap_lineno_in (abfd, src, &dst); | 4477 | 1.93k | 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 | 1.93k | memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); | 4482 | | | 4483 | 1.93k | if (cache_ptr->line_number == 0) | 4484 | 375 | { | 4485 | 375 | combined_entry_type * ent; | 4486 | 375 | unsigned long symndx; | 4487 | 375 | coff_symbol_type *sym; | 4488 | | | 4489 | 375 | have_func = false; | 4490 | 375 | symndx = dst.l_addr.l_symndx; | 4491 | 375 | if (symndx >= obj_raw_syment_count (abfd)) | 4492 | 0 | { | 4493 | 0 | _bfd_error_handler | 4494 | | /* xgettext:c-format */ | 4495 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4496 | 0 | abfd, symndx, counter); | 4497 | 0 | cache_ptr->line_number = -1; | 4498 | 0 | ret = false; | 4499 | 0 | continue; | 4500 | 0 | } | 4501 | | | 4502 | 375 | ent = obj_raw_syments (abfd) + symndx; | 4503 | | /* FIXME: We should not be casting between ints and | 4504 | | pointers like this. */ | 4505 | 375 | if (! ent->is_sym) | 4506 | 0 | { | 4507 | 0 | _bfd_error_handler | 4508 | | /* xgettext:c-format */ | 4509 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4510 | 0 | abfd, symndx, counter); | 4511 | 0 | cache_ptr->line_number = -1; | 4512 | 0 | ret = false; | 4513 | 0 | continue; | 4514 | 0 | } | 4515 | 375 | sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); | 4516 | | | 4517 | | /* PR 17512 file: 078-10659-0.004 */ | 4518 | 375 | if (sym < obj_symbols (abfd) | 4519 | 375 | || 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 | 375 | have_func = true; | 4531 | 375 | nbr_func++; | 4532 | 375 | cache_ptr->u.sym = (asymbol *) sym; | 4533 | 375 | if (sym->lineno != NULL) | 4534 | 314 | _bfd_error_handler | 4535 | | /* xgettext:c-format */ | 4536 | 314 | (_("%pB: warning: duplicate line number information for `%s'"), | 4537 | 314 | abfd, bfd_asymbol_name (&sym->symbol)); | 4538 | | | 4539 | 375 | sym->lineno = cache_ptr; | 4540 | 375 | if (sym->symbol.value < prev_offset) | 4541 | 28 | ordered = false; | 4542 | 375 | prev_offset = sym->symbol.value; | 4543 | 375 | } | 4544 | 1.55k | else if (!have_func) | 4545 | | /* Drop line information that has no associated function. | 4546 | | PR 17521: file: 078-10659-0.004. */ | 4547 | 848 | continue; | 4548 | 709 | else | 4549 | 709 | cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect); | 4550 | 1.08k | cache_ptr++; | 4551 | 1.08k | } | 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 | 24 | { | 4560 | | /* Sort the table. */ | 4561 | 24 | alent **func_table; | 4562 | 24 | alent *n_lineno_cache; | 4563 | | | 4564 | | /* Create a table of functions. */ | 4565 | 24 | 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 | 24 | else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL) | 4571 | 24 | { | 4572 | 24 | alent **p = func_table; | 4573 | 24 | unsigned int i; | 4574 | | | 4575 | 786 | for (i = 0; i < asect->lineno_count; i++) | 4576 | 762 | if (lineno_cache[i].line_number == 0) | 4577 | 155 | *p++ = &lineno_cache[i]; | 4578 | | | 4579 | 24 | BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func); | 4580 | | | 4581 | | /* Sort by functions. */ | 4582 | 24 | qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent); | 4583 | | | 4584 | | /* Create the new sorted table. */ | 4585 | 24 | 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 | 24 | else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL) | 4591 | 24 | { | 4592 | 24 | alent *n_cache_ptr = n_lineno_cache; | 4593 | | | 4594 | 179 | for (i = 0; i < nbr_func; i++) | 4595 | 155 | { | 4596 | 155 | coff_symbol_type *sym; | 4597 | 155 | alent *old_ptr = func_table[i]; | 4598 | | | 4599 | | /* Update the function entry. */ | 4600 | 155 | 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 | 155 | sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); | 4604 | | /* Copy the function and line number entries. */ | 4605 | 155 | do | 4606 | 762 | *n_cache_ptr++ = *old_ptr++; | 4607 | 762 | while (old_ptr->line_number != 0); | 4608 | 155 | } | 4609 | | | 4610 | 24 | memcpy (lineno_cache, n_lineno_cache, | 4611 | 24 | asect->lineno_count * sizeof (alent)); | 4612 | 24 | } | 4613 | 0 | else | 4614 | 0 | ret = false; | 4615 | 24 | bfd_release (abfd, func_table); | 4616 | 24 | } | 4617 | 0 | else | 4618 | 0 | ret = false; | 4619 | 24 | } | 4620 | | | 4621 | 73 | return ret; | 4622 | 73 | } |
pei-arm-wince.c:coff_slurp_line_table Line | Count | Source | 4425 | 19 | { | 4426 | 19 | LINENO *native_lineno; | 4427 | 19 | alent *lineno_cache; | 4428 | 19 | unsigned int counter; | 4429 | 19 | alent *cache_ptr; | 4430 | 19 | bfd_vma prev_offset = 0; | 4431 | 19 | bool ordered = true; | 4432 | 19 | unsigned int nbr_func; | 4433 | 19 | LINENO *src; | 4434 | 19 | bool have_func; | 4435 | 19 | bool ret = true; | 4436 | 19 | size_t amt; | 4437 | | | 4438 | 19 | if (asect->lineno_count == 0) | 4439 | 5 | return true; | 4440 | | | 4441 | 14 | BFD_ASSERT (asect->lineno == NULL); | 4442 | | | 4443 | 14 | native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, | 4444 | 14 | asect->lineno_count, | 4445 | 14 | bfd_coff_linesz (abfd)); | 4446 | 14 | if (native_lineno == NULL) | 4447 | 0 | { | 4448 | 0 | _bfd_error_handler | 4449 | 0 | (_("%pB: warning: line number table read failed"), abfd); | 4450 | 0 | return false; | 4451 | 0 | } | 4452 | | | 4453 | 14 | 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 | 14 | lineno_cache = (alent *) bfd_alloc (abfd, amt); | 4460 | 14 | if (lineno_cache == NULL) | 4461 | 0 | { | 4462 | 0 | free (native_lineno); | 4463 | 0 | return false; | 4464 | 0 | } | 4465 | | | 4466 | 14 | cache_ptr = lineno_cache; | 4467 | 14 | asect->lineno = lineno_cache; | 4468 | 14 | src = native_lineno; | 4469 | 14 | nbr_func = 0; | 4470 | 14 | have_func = false; | 4471 | | | 4472 | 105 | for (counter = 0; counter < asect->lineno_count; counter++, src++) | 4473 | 91 | { | 4474 | 91 | struct internal_lineno dst; | 4475 | | | 4476 | 91 | bfd_coff_swap_lineno_in (abfd, src, &dst); | 4477 | 91 | 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 | 91 | memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); | 4482 | | | 4483 | 91 | if (cache_ptr->line_number == 0) | 4484 | 29 | { | 4485 | 29 | combined_entry_type * ent; | 4486 | 29 | unsigned long symndx; | 4487 | 29 | coff_symbol_type *sym; | 4488 | | | 4489 | 29 | have_func = false; | 4490 | 29 | symndx = dst.l_addr.l_symndx; | 4491 | 29 | if (symndx >= obj_raw_syment_count (abfd)) | 4492 | 0 | { | 4493 | 0 | _bfd_error_handler | 4494 | | /* xgettext:c-format */ | 4495 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4496 | 0 | abfd, symndx, counter); | 4497 | 0 | cache_ptr->line_number = -1; | 4498 | 0 | ret = false; | 4499 | 0 | continue; | 4500 | 0 | } | 4501 | | | 4502 | 29 | ent = obj_raw_syments (abfd) + symndx; | 4503 | | /* FIXME: We should not be casting between ints and | 4504 | | pointers like this. */ | 4505 | 29 | if (! ent->is_sym) | 4506 | 0 | { | 4507 | 0 | _bfd_error_handler | 4508 | | /* xgettext:c-format */ | 4509 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4510 | 0 | abfd, symndx, counter); | 4511 | 0 | cache_ptr->line_number = -1; | 4512 | 0 | ret = false; | 4513 | 0 | continue; | 4514 | 0 | } | 4515 | 29 | sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); | 4516 | | | 4517 | | /* PR 17512 file: 078-10659-0.004 */ | 4518 | 29 | if (sym < obj_symbols (abfd) | 4519 | 29 | || 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 | 29 | have_func = true; | 4531 | 29 | nbr_func++; | 4532 | 29 | cache_ptr->u.sym = (asymbol *) sym; | 4533 | 29 | if (sym->lineno != NULL) | 4534 | 20 | _bfd_error_handler | 4535 | | /* xgettext:c-format */ | 4536 | 20 | (_("%pB: warning: duplicate line number information for `%s'"), | 4537 | 20 | abfd, bfd_asymbol_name (&sym->symbol)); | 4538 | | | 4539 | 29 | sym->lineno = cache_ptr; | 4540 | 29 | if (sym->symbol.value < prev_offset) | 4541 | 0 | ordered = false; | 4542 | 29 | prev_offset = sym->symbol.value; | 4543 | 29 | } | 4544 | 62 | else if (!have_func) | 4545 | | /* Drop line information that has no associated function. | 4546 | | PR 17521: file: 078-10659-0.004. */ | 4547 | 37 | continue; | 4548 | 25 | else | 4549 | 25 | cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect); | 4550 | 54 | cache_ptr++; | 4551 | 54 | } | 4552 | | | 4553 | 14 | asect->lineno_count = cache_ptr - lineno_cache; | 4554 | 14 | memset (cache_ptr, 0, sizeof (*cache_ptr)); | 4555 | 14 | free (native_lineno); | 4556 | | | 4557 | | /* On some systems (eg AIX5.3) the lineno table may not be sorted. */ | 4558 | 14 | if (!ordered) | 4559 | 0 | { | 4560 | | /* Sort the table. */ | 4561 | 0 | alent **func_table; | 4562 | 0 | alent *n_lineno_cache; | 4563 | | | 4564 | | /* Create a table of functions. */ | 4565 | 0 | 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 | 0 | else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL) | 4571 | 0 | { | 4572 | 0 | alent **p = func_table; | 4573 | 0 | unsigned int i; | 4574 | |
| 4575 | 0 | for (i = 0; i < asect->lineno_count; i++) | 4576 | 0 | if (lineno_cache[i].line_number == 0) | 4577 | 0 | *p++ = &lineno_cache[i]; | 4578 | |
| 4579 | 0 | BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func); | 4580 | | | 4581 | | /* Sort by functions. */ | 4582 | 0 | qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent); | 4583 | | | 4584 | | /* Create the new sorted table. */ | 4585 | 0 | 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 | 0 | else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL) | 4591 | 0 | { | 4592 | 0 | alent *n_cache_ptr = n_lineno_cache; | 4593 | |
| 4594 | 0 | for (i = 0; i < nbr_func; i++) | 4595 | 0 | { | 4596 | 0 | coff_symbol_type *sym; | 4597 | 0 | alent *old_ptr = func_table[i]; | 4598 | | | 4599 | | /* Update the function entry. */ | 4600 | 0 | 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 | 0 | sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); | 4604 | | /* Copy the function and line number entries. */ | 4605 | 0 | do | 4606 | 0 | *n_cache_ptr++ = *old_ptr++; | 4607 | 0 | while (old_ptr->line_number != 0); | 4608 | 0 | } | 4609 | |
| 4610 | 0 | memcpy (lineno_cache, n_lineno_cache, | 4611 | 0 | asect->lineno_count * sizeof (alent)); | 4612 | 0 | } | 4613 | 0 | else | 4614 | 0 | ret = false; | 4615 | 0 | bfd_release (abfd, func_table); | 4616 | 0 | } | 4617 | 0 | else | 4618 | 0 | ret = false; | 4619 | 0 | } | 4620 | | | 4621 | 14 | return ret; | 4622 | 14 | } |
pei-arm.c:coff_slurp_line_table Line | Count | Source | 4425 | 261 | { | 4426 | 261 | LINENO *native_lineno; | 4427 | 261 | alent *lineno_cache; | 4428 | 261 | unsigned int counter; | 4429 | 261 | alent *cache_ptr; | 4430 | 261 | bfd_vma prev_offset = 0; | 4431 | 261 | bool ordered = true; | 4432 | 261 | unsigned int nbr_func; | 4433 | 261 | LINENO *src; | 4434 | 261 | bool have_func; | 4435 | 261 | bool ret = true; | 4436 | 261 | size_t amt; | 4437 | | | 4438 | 261 | if (asect->lineno_count == 0) | 4439 | 210 | return true; | 4440 | | | 4441 | 51 | BFD_ASSERT (asect->lineno == NULL); | 4442 | | | 4443 | 51 | native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, | 4444 | 51 | asect->lineno_count, | 4445 | 51 | bfd_coff_linesz (abfd)); | 4446 | 51 | if (native_lineno == NULL) | 4447 | 0 | { | 4448 | 0 | _bfd_error_handler | 4449 | 0 | (_("%pB: warning: line number table read failed"), abfd); | 4450 | 0 | return false; | 4451 | 0 | } | 4452 | | | 4453 | 51 | 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 | 51 | lineno_cache = (alent *) bfd_alloc (abfd, amt); | 4460 | 51 | if (lineno_cache == NULL) | 4461 | 0 | { | 4462 | 0 | free (native_lineno); | 4463 | 0 | return false; | 4464 | 0 | } | 4465 | | | 4466 | 51 | cache_ptr = lineno_cache; | 4467 | 51 | asect->lineno = lineno_cache; | 4468 | 51 | src = native_lineno; | 4469 | 51 | nbr_func = 0; | 4470 | 51 | have_func = false; | 4471 | | | 4472 | 19.7k | for (counter = 0; counter < asect->lineno_count; counter++, src++) | 4473 | 19.7k | { | 4474 | 19.7k | struct internal_lineno dst; | 4475 | | | 4476 | 19.7k | bfd_coff_swap_lineno_in (abfd, src, &dst); | 4477 | 19.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 | 19.7k | memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); | 4482 | | | 4483 | 19.7k | if (cache_ptr->line_number == 0) | 4484 | 4.95k | { | 4485 | 4.95k | combined_entry_type * ent; | 4486 | 4.95k | unsigned long symndx; | 4487 | 4.95k | coff_symbol_type *sym; | 4488 | | | 4489 | 4.95k | have_func = false; | 4490 | 4.95k | symndx = dst.l_addr.l_symndx; | 4491 | 4.95k | if (symndx >= obj_raw_syment_count (abfd)) | 4492 | 0 | { | 4493 | 0 | _bfd_error_handler | 4494 | | /* xgettext:c-format */ | 4495 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4496 | 0 | abfd, symndx, counter); | 4497 | 0 | cache_ptr->line_number = -1; | 4498 | 0 | ret = false; | 4499 | 0 | continue; | 4500 | 0 | } | 4501 | | | 4502 | 4.95k | ent = obj_raw_syments (abfd) + symndx; | 4503 | | /* FIXME: We should not be casting between ints and | 4504 | | pointers like this. */ | 4505 | 4.95k | if (! ent->is_sym) | 4506 | 0 | { | 4507 | 0 | _bfd_error_handler | 4508 | | /* xgettext:c-format */ | 4509 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4510 | 0 | abfd, symndx, counter); | 4511 | 0 | cache_ptr->line_number = -1; | 4512 | 0 | ret = false; | 4513 | 0 | continue; | 4514 | 0 | } | 4515 | 4.95k | sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); | 4516 | | | 4517 | | /* PR 17512 file: 078-10659-0.004 */ | 4518 | 4.95k | if (sym < obj_symbols (abfd) | 4519 | 4.95k | || 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 | 4.95k | have_func = true; | 4531 | 4.95k | nbr_func++; | 4532 | 4.95k | cache_ptr->u.sym = (asymbol *) sym; | 4533 | 4.95k | if (sym->lineno != NULL) | 4534 | 4.92k | _bfd_error_handler | 4535 | | /* xgettext:c-format */ | 4536 | 4.92k | (_("%pB: warning: duplicate line number information for `%s'"), | 4537 | 4.92k | abfd, bfd_asymbol_name (&sym->symbol)); | 4538 | | | 4539 | 4.95k | sym->lineno = cache_ptr; | 4540 | 4.95k | if (sym->symbol.value < prev_offset) | 4541 | 14 | ordered = false; | 4542 | 4.95k | prev_offset = sym->symbol.value; | 4543 | 4.95k | } | 4544 | 14.7k | else if (!have_func) | 4545 | | /* Drop line information that has no associated function. | 4546 | | PR 17521: file: 078-10659-0.004. */ | 4547 | 5.86k | continue; | 4548 | 8.88k | else | 4549 | 8.88k | cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect); | 4550 | 13.8k | cache_ptr++; | 4551 | 13.8k | } | 4552 | | | 4553 | 51 | asect->lineno_count = cache_ptr - lineno_cache; | 4554 | 51 | memset (cache_ptr, 0, sizeof (*cache_ptr)); | 4555 | 51 | free (native_lineno); | 4556 | | | 4557 | | /* On some systems (eg AIX5.3) the lineno table may not be sorted. */ | 4558 | 51 | if (!ordered) | 4559 | 14 | { | 4560 | | /* Sort the table. */ | 4561 | 14 | alent **func_table; | 4562 | 14 | alent *n_lineno_cache; | 4563 | | | 4564 | | /* Create a table of functions. */ | 4565 | 14 | 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 | 14 | else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL) | 4571 | 14 | { | 4572 | 14 | alent **p = func_table; | 4573 | 14 | unsigned int i; | 4574 | | | 4575 | 133 | for (i = 0; i < asect->lineno_count; i++) | 4576 | 119 | if (lineno_cache[i].line_number == 0) | 4577 | 70 | *p++ = &lineno_cache[i]; | 4578 | | | 4579 | 14 | BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func); | 4580 | | | 4581 | | /* Sort by functions. */ | 4582 | 14 | qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent); | 4583 | | | 4584 | | /* Create the new sorted table. */ | 4585 | 14 | 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 | 14 | else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL) | 4591 | 14 | { | 4592 | 14 | alent *n_cache_ptr = n_lineno_cache; | 4593 | | | 4594 | 84 | for (i = 0; i < nbr_func; i++) | 4595 | 70 | { | 4596 | 70 | coff_symbol_type *sym; | 4597 | 70 | alent *old_ptr = func_table[i]; | 4598 | | | 4599 | | /* Update the function entry. */ | 4600 | 70 | 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 | 70 | sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); | 4604 | | /* Copy the function and line number entries. */ | 4605 | 70 | do | 4606 | 119 | *n_cache_ptr++ = *old_ptr++; | 4607 | 119 | while (old_ptr->line_number != 0); | 4608 | 70 | } | 4609 | | | 4610 | 14 | memcpy (lineno_cache, n_lineno_cache, | 4611 | 14 | asect->lineno_count * sizeof (alent)); | 4612 | 14 | } | 4613 | 0 | else | 4614 | 0 | ret = false; | 4615 | 14 | bfd_release (abfd, func_table); | 4616 | 14 | } | 4617 | 0 | else | 4618 | 0 | ret = false; | 4619 | 14 | } | 4620 | | | 4621 | 51 | return ret; | 4622 | 51 | } |
pei-mcore.c:coff_slurp_line_table Line | Count | Source | 4425 | 265 | { | 4426 | 265 | LINENO *native_lineno; | 4427 | 265 | alent *lineno_cache; | 4428 | 265 | unsigned int counter; | 4429 | 265 | alent *cache_ptr; | 4430 | 265 | bfd_vma prev_offset = 0; | 4431 | 265 | bool ordered = true; | 4432 | 265 | unsigned int nbr_func; | 4433 | 265 | LINENO *src; | 4434 | 265 | bool have_func; | 4435 | 265 | bool ret = true; | 4436 | 265 | size_t amt; | 4437 | | | 4438 | 265 | if (asect->lineno_count == 0) | 4439 | 212 | return true; | 4440 | | | 4441 | 53 | BFD_ASSERT (asect->lineno == NULL); | 4442 | | | 4443 | 53 | native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, | 4444 | 53 | asect->lineno_count, | 4445 | 53 | bfd_coff_linesz (abfd)); | 4446 | 53 | if (native_lineno == NULL) | 4447 | 0 | { | 4448 | 0 | _bfd_error_handler | 4449 | 0 | (_("%pB: warning: line number table read failed"), abfd); | 4450 | 0 | return false; | 4451 | 0 | } | 4452 | | | 4453 | 53 | 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 | 53 | lineno_cache = (alent *) bfd_alloc (abfd, amt); | 4460 | 53 | if (lineno_cache == NULL) | 4461 | 0 | { | 4462 | 0 | free (native_lineno); | 4463 | 0 | return false; | 4464 | 0 | } | 4465 | | | 4466 | 53 | cache_ptr = lineno_cache; | 4467 | 53 | asect->lineno = lineno_cache; | 4468 | 53 | src = native_lineno; | 4469 | 53 | nbr_func = 0; | 4470 | 53 | have_func = false; | 4471 | | | 4472 | 353 | for (counter = 0; counter < asect->lineno_count; counter++, src++) | 4473 | 300 | { | 4474 | 300 | struct internal_lineno dst; | 4475 | | | 4476 | 300 | bfd_coff_swap_lineno_in (abfd, src, &dst); | 4477 | 300 | 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 | 300 | memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); | 4482 | | | 4483 | 300 | if (cache_ptr->line_number == 0) | 4484 | 96 | { | 4485 | 96 | combined_entry_type * ent; | 4486 | 96 | unsigned long symndx; | 4487 | 96 | coff_symbol_type *sym; | 4488 | | | 4489 | 96 | have_func = false; | 4490 | 96 | symndx = dst.l_addr.l_symndx; | 4491 | 96 | if (symndx >= obj_raw_syment_count (abfd)) | 4492 | 0 | { | 4493 | 0 | _bfd_error_handler | 4494 | | /* xgettext:c-format */ | 4495 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4496 | 0 | abfd, symndx, counter); | 4497 | 0 | cache_ptr->line_number = -1; | 4498 | 0 | ret = false; | 4499 | 0 | continue; | 4500 | 0 | } | 4501 | | | 4502 | 96 | ent = obj_raw_syments (abfd) + symndx; | 4503 | | /* FIXME: We should not be casting between ints and | 4504 | | pointers like this. */ | 4505 | 96 | if (! ent->is_sym) | 4506 | 0 | { | 4507 | 0 | _bfd_error_handler | 4508 | | /* xgettext:c-format */ | 4509 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4510 | 0 | abfd, symndx, counter); | 4511 | 0 | cache_ptr->line_number = -1; | 4512 | 0 | ret = false; | 4513 | 0 | continue; | 4514 | 0 | } | 4515 | 96 | sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); | 4516 | | | 4517 | | /* PR 17512 file: 078-10659-0.004 */ | 4518 | 96 | if (sym < obj_symbols (abfd) | 4519 | 96 | || 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 | 96 | have_func = true; | 4531 | 96 | nbr_func++; | 4532 | 96 | cache_ptr->u.sym = (asymbol *) sym; | 4533 | 96 | if (sym->lineno != NULL) | 4534 | 61 | _bfd_error_handler | 4535 | | /* xgettext:c-format */ | 4536 | 61 | (_("%pB: warning: duplicate line number information for `%s'"), | 4537 | 61 | abfd, bfd_asymbol_name (&sym->symbol)); | 4538 | | | 4539 | 96 | sym->lineno = cache_ptr; | 4540 | 96 | if (sym->symbol.value < prev_offset) | 4541 | 12 | ordered = false; | 4542 | 96 | prev_offset = sym->symbol.value; | 4543 | 96 | } | 4544 | 204 | else if (!have_func) | 4545 | | /* Drop line information that has no associated function. | 4546 | | PR 17521: file: 078-10659-0.004. */ | 4547 | 84 | continue; | 4548 | 120 | else | 4549 | 120 | cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect); | 4550 | 216 | cache_ptr++; | 4551 | 216 | } | 4552 | | | 4553 | 53 | asect->lineno_count = cache_ptr - lineno_cache; | 4554 | 53 | memset (cache_ptr, 0, sizeof (*cache_ptr)); | 4555 | 53 | free (native_lineno); | 4556 | | | 4557 | | /* On some systems (eg AIX5.3) the lineno table may not be sorted. */ | 4558 | 53 | if (!ordered) | 4559 | 12 | { | 4560 | | /* Sort the table. */ | 4561 | 12 | alent **func_table; | 4562 | 12 | alent *n_lineno_cache; | 4563 | | | 4564 | | /* Create a table of functions. */ | 4565 | 12 | 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 | 12 | else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL) | 4571 | 12 | { | 4572 | 12 | alent **p = func_table; | 4573 | 12 | unsigned int i; | 4574 | | | 4575 | 98 | for (i = 0; i < asect->lineno_count; i++) | 4576 | 86 | if (lineno_cache[i].line_number == 0) | 4577 | 43 | *p++ = &lineno_cache[i]; | 4578 | | | 4579 | 12 | BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func); | 4580 | | | 4581 | | /* Sort by functions. */ | 4582 | 12 | qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent); | 4583 | | | 4584 | | /* Create the new sorted table. */ | 4585 | 12 | 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 | 12 | else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL) | 4591 | 12 | { | 4592 | 12 | alent *n_cache_ptr = n_lineno_cache; | 4593 | | | 4594 | 55 | for (i = 0; i < nbr_func; i++) | 4595 | 43 | { | 4596 | 43 | coff_symbol_type *sym; | 4597 | 43 | alent *old_ptr = func_table[i]; | 4598 | | | 4599 | | /* Update the function entry. */ | 4600 | 43 | 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 | 43 | sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); | 4604 | | /* Copy the function and line number entries. */ | 4605 | 43 | do | 4606 | 86 | *n_cache_ptr++ = *old_ptr++; | 4607 | 86 | while (old_ptr->line_number != 0); | 4608 | 43 | } | 4609 | | | 4610 | 12 | memcpy (lineno_cache, n_lineno_cache, | 4611 | 12 | asect->lineno_count * sizeof (alent)); | 4612 | 12 | } | 4613 | 0 | else | 4614 | 0 | ret = false; | 4615 | 12 | bfd_release (abfd, func_table); | 4616 | 12 | } | 4617 | 0 | else | 4618 | 0 | ret = false; | 4619 | 12 | } | 4620 | | | 4621 | 53 | return ret; | 4622 | 53 | } |
pei-sh.c:coff_slurp_line_table Line | Count | Source | 4425 | 197 | { | 4426 | 197 | LINENO *native_lineno; | 4427 | 197 | alent *lineno_cache; | 4428 | 197 | unsigned int counter; | 4429 | 197 | alent *cache_ptr; | 4430 | 197 | bfd_vma prev_offset = 0; | 4431 | 197 | bool ordered = true; | 4432 | 197 | unsigned int nbr_func; | 4433 | 197 | LINENO *src; | 4434 | 197 | bool have_func; | 4435 | 197 | bool ret = true; | 4436 | 197 | size_t amt; | 4437 | | | 4438 | 197 | if (asect->lineno_count == 0) | 4439 | 156 | return true; | 4440 | | | 4441 | 41 | BFD_ASSERT (asect->lineno == NULL); | 4442 | | | 4443 | 41 | native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, | 4444 | 41 | asect->lineno_count, | 4445 | 41 | bfd_coff_linesz (abfd)); | 4446 | 41 | if (native_lineno == NULL) | 4447 | 0 | { | 4448 | 0 | _bfd_error_handler | 4449 | 0 | (_("%pB: warning: line number table read failed"), abfd); | 4450 | 0 | return false; | 4451 | 0 | } | 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 | 328 | for (counter = 0; counter < asect->lineno_count; counter++, src++) | 4473 | 287 | { | 4474 | 287 | struct internal_lineno dst; | 4475 | | | 4476 | 287 | bfd_coff_swap_lineno_in (abfd, src, &dst); | 4477 | 287 | 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 | 287 | memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); | 4482 | | | 4483 | 287 | if (cache_ptr->line_number == 0) | 4484 | 127 | { | 4485 | 127 | combined_entry_type * ent; | 4486 | 127 | unsigned long symndx; | 4487 | 127 | coff_symbol_type *sym; | 4488 | | | 4489 | 127 | have_func = false; | 4490 | 127 | symndx = dst.l_addr.l_symndx; | 4491 | 127 | if (symndx >= obj_raw_syment_count (abfd)) | 4492 | 0 | { | 4493 | 0 | _bfd_error_handler | 4494 | | /* xgettext:c-format */ | 4495 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4496 | 0 | abfd, symndx, counter); | 4497 | 0 | cache_ptr->line_number = -1; | 4498 | 0 | ret = false; | 4499 | 0 | continue; | 4500 | 0 | } | 4501 | | | 4502 | 127 | ent = obj_raw_syments (abfd) + symndx; | 4503 | | /* FIXME: We should not be casting between ints and | 4504 | | pointers like this. */ | 4505 | 127 | if (! ent->is_sym) | 4506 | 0 | { | 4507 | 0 | _bfd_error_handler | 4508 | | /* xgettext:c-format */ | 4509 | 0 | (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), | 4510 | 0 | abfd, symndx, counter); | 4511 | 0 | cache_ptr->line_number = -1; | 4512 | 0 | ret = false; | 4513 | 0 | continue; | 4514 | 0 | } | 4515 | 127 | sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); | 4516 | | | 4517 | | /* PR 17512 file: 078-10659-0.004 */ | 4518 | 127 | if (sym < obj_symbols (abfd) | 4519 | 127 | || 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 | 127 | have_func = true; | 4531 | 127 | nbr_func++; | 4532 | 127 | cache_ptr->u.sym = (asymbol *) sym; | 4533 | 127 | if (sym->lineno != NULL) | 4534 | 84 | _bfd_error_handler | 4535 | | /* xgettext:c-format */ | 4536 | 84 | (_("%pB: warning: duplicate line number information for `%s'"), | 4537 | 84 | abfd, bfd_asymbol_name (&sym->symbol)); | 4538 | | | 4539 | 127 | sym->lineno = cache_ptr; | 4540 | 127 | if (sym->symbol.value < prev_offset) | 4541 | 18 | ordered = false; | 4542 | 127 | prev_offset = sym->symbol.value; | 4543 | 127 | } | 4544 | 160 | else if (!have_func) | 4545 | | /* Drop line information that has no associated function. | 4546 | | PR 17521: file: 078-10659-0.004. */ | 4547 | 52 | continue; | 4548 | 108 | else | 4549 | 108 | cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect); | 4550 | 235 | cache_ptr++; | 4551 | 235 | } | 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 | 16 | { | 4560 | | /* Sort the table. */ | 4561 | 16 | alent **func_table; | 4562 | 16 | alent *n_lineno_cache; | 4563 | | | 4564 | | /* Create a table of functions. */ | 4565 | 16 | 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 | 16 | else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL) | 4571 | 16 | { | 4572 | 16 | alent **p = func_table; | 4573 | 16 | unsigned int i; | 4574 | | | 4575 | 227 | for (i = 0; i < asect->lineno_count; i++) | 4576 | 211 | if (lineno_cache[i].line_number == 0) | 4577 | 113 | *p++ = &lineno_cache[i]; | 4578 | | | 4579 | 16 | BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func); | 4580 | | | 4581 | | /* Sort by functions. */ | 4582 | 16 | qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent); | 4583 | | | 4584 | | /* Create the new sorted table. */ | 4585 | 16 | 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 | 16 | else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL) | 4591 | 16 | { | 4592 | 16 | alent *n_cache_ptr = n_lineno_cache; | 4593 | | | 4594 | 129 | for (i = 0; i < nbr_func; i++) | 4595 | 113 | { | 4596 | 113 | coff_symbol_type *sym; | 4597 | 113 | alent *old_ptr = func_table[i]; | 4598 | | | 4599 | | /* Update the function entry. */ | 4600 | 113 | 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 | 113 | sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); | 4604 | | /* Copy the function and line number entries. */ | 4605 | 113 | do | 4606 | 211 | *n_cache_ptr++ = *old_ptr++; | 4607 | 211 | while (old_ptr->line_number != 0); | 4608 | 113 | } | 4609 | | | 4610 | 16 | memcpy (lineno_cache, n_lineno_cache, | 4611 | 16 | asect->lineno_count * sizeof (alent)); | 4612 | 16 | } | 4613 | 0 | else | 4614 | 0 | ret = false; | 4615 | 16 | bfd_release (abfd, func_table); | 4616 | 16 | } | 4617 | 0 | else | 4618 | 0 | ret = false; | 4619 | 16 | } | 4620 | | | 4621 | 41 | return ret; | 4622 | 41 | } |
|
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 | 3.31k | { |
4631 | 3.31k | combined_entry_type *native_symbols; |
4632 | 3.31k | coff_symbol_type *cached_area; |
4633 | 3.31k | unsigned int *table_ptr; |
4634 | 3.31k | unsigned int number_of_symbols = 0; |
4635 | 3.31k | bool ret = true; |
4636 | 3.31k | size_t amt; |
4637 | | |
4638 | 3.31k | if (obj_symbols (abfd)) |
4639 | 1.65k | return true; |
4640 | | |
4641 | | /* Read in the symbol table. */ |
4642 | 1.65k | if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) |
4643 | 0 | return false; |
4644 | | |
4645 | | /* Allocate enough room for all the symbols in cached form. */ |
4646 | 1.65k | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), |
4647 | 1.65k | sizeof (*cached_area), &amt)) |
4648 | 0 | { |
4649 | 0 | bfd_set_error (bfd_error_file_too_big); |
4650 | 0 | return false; |
4651 | 0 | } |
4652 | 1.65k | cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt); |
4653 | 1.65k | if (cached_area == NULL) |
4654 | 0 | return false; |
4655 | | |
4656 | 1.65k | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), |
4657 | 1.65k | sizeof (*table_ptr), &amt)) |
4658 | 0 | { |
4659 | 0 | bfd_set_error (bfd_error_file_too_big); |
4660 | 0 | return false; |
4661 | 0 | } |
4662 | 1.65k | table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); |
4663 | 1.65k | if (table_ptr == NULL) |
4664 | 0 | return false; |
4665 | 1.65k | else |
4666 | 1.65k | { |
4667 | 1.65k | coff_symbol_type *dst = cached_area; |
4668 | 1.65k | unsigned int last_native_index = obj_raw_syment_count (abfd); |
4669 | 1.65k | unsigned int this_index = 0; |
4670 | | |
4671 | 54.8k | while (this_index < last_native_index) |
4672 | 53.1k | { |
4673 | 53.1k | combined_entry_type *src = native_symbols + this_index; |
4674 | 53.1k | table_ptr[this_index] = number_of_symbols; |
4675 | | |
4676 | 53.1k | dst->symbol.the_bfd = abfd; |
4677 | 53.1k | BFD_ASSERT (src->is_sym); |
4678 | 53.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 | 53.1k | src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; |
4681 | 53.1k | dst->symbol.section = coff_section_from_bfd_index (abfd, |
4682 | 53.1k | src->u.syment.n_scnum); |
4683 | 53.1k | dst->symbol.flags = 0; |
4684 | | /* PR 17512: file: 079-7098-0.001:0.1. */ |
4685 | 53.1k | dst->symbol.value = 0; |
4686 | 53.1k | dst->done_lineno = false; |
4687 | | |
4688 | 53.1k | switch (src->u.syment.n_sclass) |
4689 | 53.1k | { |
4690 | 3.46k | case C_EXT: |
4691 | 3.77k | case C_WEAKEXT: |
4692 | | #if defined ARM |
4693 | 17 | case C_THUMBEXT: |
4694 | 19 | case C_THUMBEXTFUNC: |
4695 | | #endif |
4696 | | #ifdef RS6000COFF_C |
4697 | 1.12k | case C_HIDEXT: |
4698 | 1.12k | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT |
4699 | 1.13k | case C_AIX_WEAKEXT: |
4700 | | #endif |
4701 | | #endif |
4702 | 1.13k | #ifdef C_SYSTEM |
4703 | 4.31k | case C_SYSTEM: /* System Wide variable. */ |
4704 | 4.31k | #endif |
4705 | | #ifdef COFF_WITH_PE |
4706 | | /* In PE, 0x68 (104) denotes a section symbol. */ |
4707 | 1.82k | case C_SECTION: |
4708 | | /* In PE, 0x69 (105) denotes a weak external symbol. */ |
4709 | 1.97k | case C_NT_WEAK: |
4710 | | #endif |
4711 | 1.97k | switch (coff_classify_symbol (abfd, &src->u.syment)) |
4712 | 1.97k | { |
4713 | 3.83k | case COFF_SYMBOL_GLOBAL: |
4714 | 3.83k | 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 | 3.83k | if (ISFCN ((src->u.syment.n_type))) |
4724 | | /* A function ext does not go at the end of a |
4725 | | file. */ |
4726 | 255 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; |
4727 | 3.83k | break; |
4728 | | |
4729 | 222 | case COFF_SYMBOL_COMMON: |
4730 | 222 | dst->symbol.section = bfd_com_section_ptr; |
4731 | 222 | dst->symbol.value = src->u.syment.n_value; |
4732 | 222 | break; |
4733 | | |
4734 | 421 | case COFF_SYMBOL_UNDEFINED: |
4735 | 421 | dst->symbol.section = bfd_und_section_ptr; |
4736 | 421 | dst->symbol.value = 0; |
4737 | 421 | 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 | 21 | case COFF_SYMBOL_LOCAL: |
4745 | 21 | 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 | 21 | if (ISFCN ((src->u.syment.n_type))) |
4755 | 18 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; |
4756 | 21 | break; |
4757 | 1.97k | } |
4758 | | |
4759 | | #ifdef RS6000COFF_C |
4760 | | /* A symbol with a csect entry should not go at the end. */ |
4761 | 1.17k | if (src->u.syment.n_numaux > 0) |
4762 | 1.16k | dst->symbol.flags |= BSF_NOT_AT_END; |
4763 | | #endif |
4764 | | |
4765 | | #ifdef COFF_WITH_PE |
4766 | 1.97k | if (src->u.syment.n_sclass == C_NT_WEAK) |
4767 | 144 | dst->symbol.flags |= BSF_WEAK; |
4768 | | |
4769 | 1.97k | if (src->u.syment.n_sclass == C_SECTION |
4770 | 1.97k | && src->u.syment.n_scnum > 0) |
4771 | 0 | dst->symbol.flags = BSF_LOCAL; |
4772 | | #endif |
4773 | 4.49k | if (src->u.syment.n_sclass == C_WEAKEXT |
4774 | | #ifdef RS6000COFF_C |
4775 | 1.17k | || src->u.syment.n_sclass == C_AIX_WEAKEXT |
4776 | | #endif |
4777 | 1.34k | ) |
4778 | 325 | dst->symbol.flags |= BSF_WEAK; |
4779 | | |
4780 | 1.34k | break; |
4781 | | |
4782 | 1.43k | case C_STAT: /* Static. */ |
4783 | | #if defined ARM |
4784 | 30 | case C_THUMBSTAT: /* Thumb static. */ |
4785 | 30 | case C_THUMBLABEL: /* Thumb label. */ |
4786 | 30 | case C_THUMBSTATFUNC:/* Thumb static function. */ |
4787 | | #endif |
4788 | | #ifdef RS6000COFF_C |
4789 | 186 | case C_DWARF: /* A label in a dwarf section. */ |
4790 | 190 | case C_INFO: /* A label in a comment section. */ |
4791 | | #endif |
4792 | 2.86k | case C_LABEL: /* Label. */ |
4793 | 2.86k | if (src->u.syment.n_scnum == N_DEBUG) |
4794 | 2 | dst->symbol.flags = BSF_DEBUGGING; |
4795 | 2.86k | else |
4796 | 2.86k | 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.86k | if (dst->symbol.section) |
4801 | 2.86k | { |
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 | 2.86k | } |
4811 | 0 | else |
4812 | 0 | dst->symbol.value = src->u.syment.n_value; |
4813 | 2.86k | break; |
4814 | | |
4815 | 420 | case C_FILE: /* File name. */ |
4816 | 420 | dst->symbol.flags = BSF_FILE; |
4817 | | /* Fall through. */ |
4818 | 711 | case C_MOS: /* Member of structure. */ |
4819 | 823 | case C_EOS: /* End of structure. */ |
4820 | 1.17k | case C_REGPARM: /* Register parameter. */ |
4821 | 2.73k | case C_REG: /* register variable. */ |
4822 | | /* C_AUTOARG conflicts with TI COFF C_UEXT. */ |
4823 | 3.10k | case C_TPDEF: /* Type definition. */ |
4824 | 3.62k | case C_ARG: |
4825 | 10.5k | case C_AUTO: /* Automatic variable. */ |
4826 | 10.8k | case C_FIELD: /* Bit field. */ |
4827 | 11.1k | case C_ENTAG: /* Enumeration tag. */ |
4828 | 11.3k | case C_MOE: /* Member of enumeration. */ |
4829 | 12.3k | case C_MOU: /* Member of union. */ |
4830 | 13.3k | case C_UNTAG: /* Union tag. */ |
4831 | 14.0k | case C_STRTAG: /* Structure tag. */ |
4832 | | #ifdef RS6000COFF_C |
4833 | 554 | case C_GSYM: |
4834 | 556 | case C_LSYM: |
4835 | 557 | case C_PSYM: |
4836 | 558 | case C_RSYM: |
4837 | 559 | case C_RPSYM: |
4838 | 561 | case C_STSYM: |
4839 | 563 | case C_TCSYM: |
4840 | 564 | case C_BCOMM: |
4841 | 565 | case C_ECOML: |
4842 | 566 | case C_ECOMM: |
4843 | 567 | case C_DECL: |
4844 | 568 | case C_ENTRY: |
4845 | 570 | case C_FUN: |
4846 | 608 | case C_ESTAT: |
4847 | | #endif |
4848 | 14.1k | dst->symbol.flags |= BSF_DEBUGGING; |
4849 | 608 | dst->symbol.value = (src->u.syment.n_value); |
4850 | 608 | break; |
4851 | | |
4852 | | #ifdef RS6000COFF_C |
4853 | 10 | case C_BINCL: /* Beginning of include file. */ |
4854 | 73 | 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 | 73 | { |
4860 | 73 | asection *sec; |
4861 | | |
4862 | 73 | dst->symbol.flags = BSF_DEBUGGING; |
4863 | 2.29k | for (sec = abfd->sections; sec != NULL; sec = sec->next) |
4864 | 2.23k | if (sec->line_filepos <= (file_ptr) src->u.syment.n_value |
4865 | 2.23k | && ((file_ptr) (sec->line_filepos |
4866 | 1.56k | + sec->lineno_count * bfd_coff_linesz (abfd)) |
4867 | 1.56k | > (file_ptr) src->u.syment.n_value)) |
4868 | 6 | break; |
4869 | 73 | if (sec == NULL) |
4870 | 67 | dst->symbol.value = 0; |
4871 | 6 | else |
4872 | 6 | { |
4873 | 6 | dst->symbol.section = sec; |
4874 | 6 | dst->symbol.value = ((src->u.syment.n_value |
4875 | 6 | - sec->line_filepos) |
4876 | 6 | / bfd_coff_linesz (abfd)); |
4877 | 6 | src->fix_line = 1; |
4878 | 6 | } |
4879 | 73 | } |
4880 | 73 | break; |
4881 | | |
4882 | 6 | case C_BSTAT: |
4883 | 6 | dst->symbol.flags = BSF_DEBUGGING; |
4884 | | |
4885 | 6 | if (src->u.syment.n_value >= obj_raw_syment_count (abfd)) |
4886 | 2 | dst->symbol.value = 0; |
4887 | 4 | else |
4888 | 4 | { |
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 | 4 | src->u.syment.n_value |
4893 | 4 | = (uintptr_t) (native_symbols + src->u.syment.n_value); |
4894 | 4 | dst->symbol.value = src->u.syment.n_value; |
4895 | 4 | src->fix_value = 1; |
4896 | 4 | } |
4897 | 6 | break; |
4898 | 0 | #endif |
4899 | | |
4900 | 140 | case C_BLOCK: /* ".bb" or ".eb". */ |
4901 | 250 | case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */ |
4902 | 758 | 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 | 485 | if (strcmp (dst->symbol.name, ".bf") != 0) |
4908 | 485 | { |
4909 | | /* PE uses funny values for .ef and .lf; don't |
4910 | | relocate them. */ |
4911 | 485 | dst->symbol.flags = BSF_DEBUGGING; |
4912 | 485 | } |
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 | 273 | dst->symbol.flags = BSF_LOCAL; |
4919 | | dst->symbol.value = (src->u.syment.n_value |
4920 | | - dst->symbol.section->vma); |
4921 | | #endif |
4922 | 758 | break; |
4923 | | |
4924 | 396 | case C_STATLAB: /* Static load time label. */ |
4925 | 396 | dst->symbol.value = src->u.syment.n_value; |
4926 | 396 | dst->symbol.flags = BSF_GLOBAL; |
4927 | 396 | break; |
4928 | | |
4929 | 30.3k | case C_NULL: |
4930 | | /* PE DLLs sometimes have zeroed out symbols for some |
4931 | | reason. Just ignore them without a warning. */ |
4932 | 30.3k | if (src->u.syment.n_type == 0 |
4933 | 30.3k | && src->u.syment.n_value == 0 |
4934 | 30.3k | && src->u.syment.n_scnum == 0) |
4935 | 30.3k | break; |
4936 | | #ifdef RS6000COFF_C |
4937 | | /* XCOFF specific: deleted entry. */ |
4938 | 1 | if (src->u.syment.n_value == C_NULL_VALUE) |
4939 | 1 | break; |
4940 | 0 | #endif |
4941 | | /* Fall through. */ |
4942 | 0 | case C_EXTDEF: /* External definition. */ |
4943 | 0 | case C_ULABEL: /* Undefined label. */ |
4944 | 0 | 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 | 0 | case C_LINE: /* line # reformatted as symbol table entry. */ |
4949 | | /* NT uses 0x67 for a weak symbol, not C_ALIAS. */ |
4950 | 0 | case C_ALIAS: /* Duplicate tag. */ |
4951 | 0 | #endif |
4952 | | /* New storage classes for TI COFF. */ |
4953 | | #ifdef TICOFF |
4954 | 0 | case C_UEXT: /* Tentative external definition. */ |
4955 | | #endif |
4956 | 0 | case C_EXTLAB: /* External load time label. */ |
4957 | 0 | default: |
4958 | 0 | _bfd_error_handler |
4959 | | /* xgettext:c-format */ |
4960 | 0 | (_("%pB: unrecognized storage class %d for %s symbol `%s'"), |
4961 | 0 | abfd, src->u.syment.n_sclass, |
4962 | 0 | dst->symbol.section->name, dst->symbol.name); |
4963 | 0 | ret = false; |
4964 | | /* Fall through. */ |
4965 | 141 | 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 | 141 | dst->symbol.flags = BSF_DEBUGGING; |
4969 | 141 | dst->symbol.value = (src->u.syment.n_value); |
4970 | 141 | break; |
4971 | 53.1k | } |
4972 | | |
4973 | 53.1k | dst->native = src; |
4974 | 53.1k | dst->symbol.udata.i = 0; |
4975 | 53.1k | dst->lineno = NULL; |
4976 | | |
4977 | 53.1k | this_index += (src->u.syment.n_numaux) + 1; |
4978 | 53.1k | dst++; |
4979 | 53.1k | number_of_symbols++; |
4980 | 53.1k | } |
4981 | 1.65k | } |
4982 | | |
4983 | 1.65k | obj_symbols (abfd) = cached_area; |
4984 | 1.65k | obj_raw_syments (abfd) = native_symbols; |
4985 | | |
4986 | 1.65k | abfd->symcount = number_of_symbols; |
4987 | 1.65k | obj_convert (abfd) = table_ptr; |
4988 | | /* Slurp the line tables for each section too. */ |
4989 | 1.65k | { |
4990 | 1.65k | asection *p; |
4991 | | |
4992 | 1.65k | p = abfd->sections; |
4993 | 54.4k | while (p) |
4994 | 52.7k | { |
4995 | 52.7k | if (! coff_slurp_line_table (abfd, p)) |
4996 | 0 | return false; |
4997 | 52.7k | p = p->next; |
4998 | 52.7k | } |
4999 | 1.65k | } |
5000 | | |
5001 | 1.65k | return ret; |
5002 | 1.65k | } pei-i386.c:coff_slurp_symbol_table Line | Count | Source | 4630 | 114 | { | 4631 | 114 | combined_entry_type *native_symbols; | 4632 | 114 | coff_symbol_type *cached_area; | 4633 | 114 | unsigned int *table_ptr; | 4634 | 114 | unsigned int number_of_symbols = 0; | 4635 | 114 | bool ret = true; | 4636 | 114 | size_t amt; | 4637 | | | 4638 | 114 | if (obj_symbols (abfd)) | 4639 | 57 | return true; | 4640 | | | 4641 | | /* Read in the symbol table. */ | 4642 | 57 | if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) | 4643 | 0 | return false; | 4644 | | | 4645 | | /* Allocate enough room for all the symbols in cached form. */ | 4646 | 57 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4647 | 57 | sizeof (*cached_area), &amt)) | 4648 | 0 | { | 4649 | 0 | bfd_set_error (bfd_error_file_too_big); | 4650 | 0 | return false; | 4651 | 0 | } | 4652 | 57 | cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt); | 4653 | 57 | if (cached_area == NULL) | 4654 | 0 | return false; | 4655 | | | 4656 | 57 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4657 | 57 | sizeof (*table_ptr), &amt)) | 4658 | 0 | { | 4659 | 0 | bfd_set_error (bfd_error_file_too_big); | 4660 | 0 | return false; | 4661 | 0 | } | 4662 | 57 | table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); | 4663 | 57 | if (table_ptr == NULL) | 4664 | 0 | return false; | 4665 | 57 | else | 4666 | 57 | { | 4667 | 57 | coff_symbol_type *dst = cached_area; | 4668 | 57 | unsigned int last_native_index = obj_raw_syment_count (abfd); | 4669 | 57 | unsigned int this_index = 0; | 4670 | | | 4671 | 422 | while (this_index < last_native_index) | 4672 | 365 | { | 4673 | 365 | combined_entry_type *src = native_symbols + this_index; | 4674 | 365 | table_ptr[this_index] = number_of_symbols; | 4675 | | | 4676 | 365 | dst->symbol.the_bfd = abfd; | 4677 | 365 | BFD_ASSERT (src->is_sym); | 4678 | 365 | 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 | 365 | src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; | 4681 | 365 | dst->symbol.section = coff_section_from_bfd_index (abfd, | 4682 | 365 | src->u.syment.n_scnum); | 4683 | 365 | dst->symbol.flags = 0; | 4684 | | /* PR 17512: file: 079-7098-0.001:0.1. */ | 4685 | 365 | dst->symbol.value = 0; | 4686 | 365 | dst->done_lineno = false; | 4687 | | | 4688 | 365 | switch (src->u.syment.n_sclass) | 4689 | 365 | { | 4690 | 30 | case C_EXT: | 4691 | 44 | 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 | 44 | #ifdef C_SYSTEM | 4703 | 45 | case C_SYSTEM: /* System Wide variable. */ | 4704 | 45 | #endif | 4705 | 45 | #ifdef COFF_WITH_PE | 4706 | | /* In PE, 0x68 (104) denotes a section symbol. */ | 4707 | 47 | case C_SECTION: | 4708 | | /* In PE, 0x69 (105) denotes a weak external symbol. */ | 4709 | 54 | case C_NT_WEAK: | 4710 | 54 | #endif | 4711 | 54 | switch (coff_classify_symbol (abfd, &src->u.syment)) | 4712 | 54 | { | 4713 | 18 | case COFF_SYMBOL_GLOBAL: | 4714 | 18 | dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL; | 4715 | 18 | #if defined COFF_WITH_PE | 4716 | | /* PE sets the symbol to a value relative to the | 4717 | | start of the section. */ | 4718 | 18 | 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 | 18 | if (ISFCN ((src->u.syment.n_type))) | 4724 | | /* A function ext does not go at the end of a | 4725 | | file. */ | 4726 | 5 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4727 | 18 | break; | 4728 | | | 4729 | 18 | case COFF_SYMBOL_COMMON: | 4730 | 18 | dst->symbol.section = bfd_com_section_ptr; | 4731 | 18 | dst->symbol.value = src->u.syment.n_value; | 4732 | 18 | break; | 4733 | | | 4734 | 18 | case COFF_SYMBOL_UNDEFINED: | 4735 | 18 | dst->symbol.section = bfd_und_section_ptr; | 4736 | 18 | dst->symbol.value = 0; | 4737 | 18 | 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 | 54 | } | 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 | 54 | #ifdef COFF_WITH_PE | 4766 | 54 | if (src->u.syment.n_sclass == C_NT_WEAK) | 4767 | 7 | dst->symbol.flags |= BSF_WEAK; | 4768 | | | 4769 | 54 | if (src->u.syment.n_sclass == C_SECTION | 4770 | 54 | && src->u.syment.n_scnum > 0) | 4771 | 0 | dst->symbol.flags = BSF_LOCAL; | 4772 | 54 | #endif | 4773 | 54 | if (src->u.syment.n_sclass == C_WEAKEXT | 4774 | | #ifdef RS6000COFF_C | 4775 | | || src->u.syment.n_sclass == C_AIX_WEAKEXT | 4776 | | #endif | 4777 | 54 | ) | 4778 | 14 | dst->symbol.flags |= BSF_WEAK; | 4779 | | | 4780 | 54 | break; | 4781 | | | 4782 | 12 | 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 | 13 | case C_LABEL: /* Label. */ | 4793 | 13 | if (src->u.syment.n_scnum == N_DEBUG) | 4794 | 0 | dst->symbol.flags = BSF_DEBUGGING; | 4795 | 13 | else | 4796 | 13 | 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 | 13 | if (dst->symbol.section) | 4801 | 13 | { | 4802 | 13 | #if defined COFF_WITH_PE | 4803 | | /* PE sets the symbol to a value relative to the | 4804 | | start of the section. */ | 4805 | 13 | 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 | 13 | } | 4811 | 0 | else | 4812 | 0 | dst->symbol.value = src->u.syment.n_value; | 4813 | 13 | break; | 4814 | | | 4815 | 28 | case C_FILE: /* File name. */ | 4816 | 28 | dst->symbol.flags = BSF_FILE; | 4817 | | /* Fall through. */ | 4818 | 28 | case C_MOS: /* Member of structure. */ | 4819 | 29 | case C_EOS: /* End of structure. */ | 4820 | 30 | case C_REGPARM: /* Register parameter. */ | 4821 | 32 | case C_REG: /* register variable. */ | 4822 | | /* C_AUTOARG conflicts with TI COFF C_UEXT. */ | 4823 | 33 | case C_TPDEF: /* Type definition. */ | 4824 | 49 | case C_ARG: | 4825 | 54 | case C_AUTO: /* Automatic variable. */ | 4826 | 55 | case C_FIELD: /* Bit field. */ | 4827 | 56 | case C_ENTAG: /* Enumeration tag. */ | 4828 | 57 | case C_MOE: /* Member of enumeration. */ | 4829 | 69 | case C_MOU: /* Member of union. */ | 4830 | 71 | case C_UNTAG: /* Union tag. */ | 4831 | 73 | 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 | 73 | dst->symbol.flags |= BSF_DEBUGGING; | 4849 | 73 | dst->symbol.value = (src->u.syment.n_value); | 4850 | 73 | 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 | 3 | case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */ | 4902 | 34 | case C_EFCN: /* Physical end of function. */ | 4903 | 34 | #if defined COFF_WITH_PE | 4904 | | /* PE sets the symbol to a value relative to the start | 4905 | | of the section. */ | 4906 | 34 | dst->symbol.value = src->u.syment.n_value; | 4907 | 34 | if (strcmp (dst->symbol.name, ".bf") != 0) | 4908 | 34 | { | 4909 | | /* PE uses funny values for .ef and .lf; don't | 4910 | | relocate them. */ | 4911 | 34 | dst->symbol.flags = BSF_DEBUGGING; | 4912 | 34 | } | 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 | 34 | break; | 4923 | | | 4924 | 15 | case C_STATLAB: /* Static load time label. */ | 4925 | 15 | dst->symbol.value = src->u.syment.n_value; | 4926 | 15 | dst->symbol.flags = BSF_GLOBAL; | 4927 | 15 | break; | 4928 | | | 4929 | 173 | case C_NULL: | 4930 | | /* PE DLLs sometimes have zeroed out symbols for some | 4931 | | reason. Just ignore them without a warning. */ | 4932 | 173 | if (src->u.syment.n_type == 0 | 4933 | 173 | && src->u.syment.n_value == 0 | 4934 | 173 | && src->u.syment.n_scnum == 0) | 4935 | 173 | 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 | 0 | case C_EXTDEF: /* External definition. */ | 4943 | 0 | case C_ULABEL: /* Undefined label. */ | 4944 | 0 | 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 | 0 | case C_EXTLAB: /* External load time label. */ | 4957 | 0 | default: | 4958 | 0 | _bfd_error_handler | 4959 | | /* xgettext:c-format */ | 4960 | 0 | (_("%pB: unrecognized storage class %d for %s symbol `%s'"), | 4961 | 0 | abfd, src->u.syment.n_sclass, | 4962 | 0 | dst->symbol.section->name, dst->symbol.name); | 4963 | 0 | ret = false; | 4964 | | /* Fall through. */ | 4965 | 3 | 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 | 3 | dst->symbol.flags = BSF_DEBUGGING; | 4969 | 3 | dst->symbol.value = (src->u.syment.n_value); | 4970 | 3 | break; | 4971 | 365 | } | 4972 | | | 4973 | 365 | dst->native = src; | 4974 | 365 | dst->symbol.udata.i = 0; | 4975 | 365 | dst->lineno = NULL; | 4976 | | | 4977 | 365 | this_index += (src->u.syment.n_numaux) + 1; | 4978 | 365 | dst++; | 4979 | 365 | number_of_symbols++; | 4980 | 365 | } | 4981 | 57 | } | 4982 | | | 4983 | 57 | obj_symbols (abfd) = cached_area; | 4984 | 57 | obj_raw_syments (abfd) = native_symbols; | 4985 | | | 4986 | 57 | abfd->symcount = number_of_symbols; | 4987 | 57 | obj_convert (abfd) = table_ptr; | 4988 | | /* Slurp the line tables for each section too. */ | 4989 | 57 | { | 4990 | 57 | asection *p; | 4991 | | | 4992 | 57 | p = abfd->sections; | 4993 | 229 | while (p) | 4994 | 172 | { | 4995 | 172 | if (! coff_slurp_line_table (abfd, p)) | 4996 | 0 | return false; | 4997 | 172 | p = p->next; | 4998 | 172 | } | 4999 | 57 | } | 5000 | | | 5001 | 57 | return ret; | 5002 | 57 | } |
pe-x86_64.c:coff_slurp_symbol_table Line | Count | Source | 4630 | 196 | { | 4631 | 196 | combined_entry_type *native_symbols; | 4632 | 196 | coff_symbol_type *cached_area; | 4633 | 196 | unsigned int *table_ptr; | 4634 | 196 | unsigned int number_of_symbols = 0; | 4635 | 196 | bool ret = true; | 4636 | 196 | size_t amt; | 4637 | | | 4638 | 196 | if (obj_symbols (abfd)) | 4639 | 98 | return true; | 4640 | | | 4641 | | /* Read in the symbol table. */ | 4642 | 98 | if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) | 4643 | 0 | return false; | 4644 | | | 4645 | | /* Allocate enough room for all the symbols in cached form. */ | 4646 | 98 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4647 | 98 | sizeof (*cached_area), &amt)) | 4648 | 0 | { | 4649 | 0 | bfd_set_error (bfd_error_file_too_big); | 4650 | 0 | return false; | 4651 | 0 | } | 4652 | 98 | cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt); | 4653 | 98 | if (cached_area == NULL) | 4654 | 0 | return false; | 4655 | | | 4656 | 98 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4657 | 98 | sizeof (*table_ptr), &amt)) | 4658 | 0 | { | 4659 | 0 | bfd_set_error (bfd_error_file_too_big); | 4660 | 0 | return false; | 4661 | 0 | } | 4662 | 98 | table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); | 4663 | 98 | if (table_ptr == NULL) | 4664 | 0 | return false; | 4665 | 98 | else | 4666 | 98 | { | 4667 | 98 | coff_symbol_type *dst = cached_area; | 4668 | 98 | unsigned int last_native_index = obj_raw_syment_count (abfd); | 4669 | 98 | unsigned int this_index = 0; | 4670 | | | 4671 | 1.73k | while (this_index < last_native_index) | 4672 | 1.63k | { | 4673 | 1.63k | combined_entry_type *src = native_symbols + this_index; | 4674 | 1.63k | table_ptr[this_index] = number_of_symbols; | 4675 | | | 4676 | 1.63k | dst->symbol.the_bfd = abfd; | 4677 | 1.63k | BFD_ASSERT (src->is_sym); | 4678 | 1.63k | 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 | 1.63k | src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; | 4681 | 1.63k | dst->symbol.section = coff_section_from_bfd_index (abfd, | 4682 | 1.63k | src->u.syment.n_scnum); | 4683 | 1.63k | dst->symbol.flags = 0; | 4684 | | /* PR 17512: file: 079-7098-0.001:0.1. */ | 4685 | 1.63k | dst->symbol.value = 0; | 4686 | 1.63k | dst->done_lineno = false; | 4687 | | | 4688 | 1.63k | switch (src->u.syment.n_sclass) | 4689 | 1.63k | { | 4690 | 95 | case C_EXT: | 4691 | 106 | 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 | 106 | #ifdef C_SYSTEM | 4703 | 107 | case C_SYSTEM: /* System Wide variable. */ | 4704 | 107 | #endif | 4705 | 107 | #ifdef COFF_WITH_PE | 4706 | | /* In PE, 0x68 (104) denotes a section symbol. */ | 4707 | 111 | case C_SECTION: | 4708 | | /* In PE, 0x69 (105) denotes a weak external symbol. */ | 4709 | 114 | case C_NT_WEAK: | 4710 | 114 | #endif | 4711 | 114 | switch (coff_classify_symbol (abfd, &src->u.syment)) | 4712 | 114 | { | 4713 | 91 | case COFF_SYMBOL_GLOBAL: | 4714 | 91 | dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL; | 4715 | 91 | #if defined COFF_WITH_PE | 4716 | | /* PE sets the symbol to a value relative to the | 4717 | | start of the section. */ | 4718 | 91 | 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 | 91 | if (ISFCN ((src->u.syment.n_type))) | 4724 | | /* A function ext does not go at the end of a | 4725 | | file. */ | 4726 | 11 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4727 | 91 | break; | 4728 | | | 4729 | 8 | case COFF_SYMBOL_COMMON: | 4730 | 8 | dst->symbol.section = bfd_com_section_ptr; | 4731 | 8 | dst->symbol.value = src->u.syment.n_value; | 4732 | 8 | break; | 4733 | | | 4734 | 15 | case COFF_SYMBOL_UNDEFINED: | 4735 | 15 | dst->symbol.section = bfd_und_section_ptr; | 4736 | 15 | dst->symbol.value = 0; | 4737 | 15 | 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 | 114 | } | 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 | 114 | #ifdef COFF_WITH_PE | 4766 | 114 | if (src->u.syment.n_sclass == C_NT_WEAK) | 4767 | 3 | dst->symbol.flags |= BSF_WEAK; | 4768 | | | 4769 | 114 | if (src->u.syment.n_sclass == C_SECTION | 4770 | 114 | && src->u.syment.n_scnum > 0) | 4771 | 0 | dst->symbol.flags = BSF_LOCAL; | 4772 | 114 | #endif | 4773 | 114 | if (src->u.syment.n_sclass == C_WEAKEXT | 4774 | | #ifdef RS6000COFF_C | 4775 | | || src->u.syment.n_sclass == C_AIX_WEAKEXT | 4776 | | #endif | 4777 | 114 | ) | 4778 | 11 | dst->symbol.flags |= BSF_WEAK; | 4779 | | | 4780 | 114 | break; | 4781 | | | 4782 | 53 | 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 | 73 | case C_LABEL: /* Label. */ | 4793 | 73 | if (src->u.syment.n_scnum == N_DEBUG) | 4794 | 0 | dst->symbol.flags = BSF_DEBUGGING; | 4795 | 73 | else | 4796 | 73 | 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 | 73 | if (dst->symbol.section) | 4801 | 73 | { | 4802 | 73 | #if defined COFF_WITH_PE | 4803 | | /* PE sets the symbol to a value relative to the | 4804 | | start of the section. */ | 4805 | 73 | 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 | 73 | } | 4811 | 0 | else | 4812 | 0 | dst->symbol.value = src->u.syment.n_value; | 4813 | 73 | break; | 4814 | | | 4815 | 9 | case C_FILE: /* File name. */ | 4816 | 9 | dst->symbol.flags = BSF_FILE; | 4817 | | /* Fall through. */ | 4818 | 29 | case C_MOS: /* Member of structure. */ | 4819 | 30 | case C_EOS: /* End of structure. */ | 4820 | 67 | case C_REGPARM: /* Register parameter. */ | 4821 | 84 | case C_REG: /* register variable. */ | 4822 | | /* C_AUTOARG conflicts with TI COFF C_UEXT. */ | 4823 | 104 | case C_TPDEF: /* Type definition. */ | 4824 | 247 | case C_ARG: | 4825 | 413 | case C_AUTO: /* Automatic variable. */ | 4826 | 437 | case C_FIELD: /* Bit field. */ | 4827 | 454 | case C_ENTAG: /* Enumeration tag. */ | 4828 | 460 | case C_MOE: /* Member of enumeration. */ | 4829 | 477 | case C_MOU: /* Member of union. */ | 4830 | 504 | case C_UNTAG: /* Union tag. */ | 4831 | 548 | 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 | 548 | dst->symbol.flags |= BSF_DEBUGGING; | 4849 | 548 | dst->symbol.value = (src->u.syment.n_value); | 4850 | 548 | 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 | 16 | case C_BLOCK: /* ".bb" or ".eb". */ | 4901 | 19 | case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */ | 4902 | 50 | case C_EFCN: /* Physical end of function. */ | 4903 | 50 | #if defined COFF_WITH_PE | 4904 | | /* PE sets the symbol to a value relative to the start | 4905 | | of the section. */ | 4906 | 50 | dst->symbol.value = src->u.syment.n_value; | 4907 | 50 | if (strcmp (dst->symbol.name, ".bf") != 0) | 4908 | 50 | { | 4909 | | /* PE uses funny values for .ef and .lf; don't | 4910 | | relocate them. */ | 4911 | 50 | dst->symbol.flags = BSF_DEBUGGING; | 4912 | 50 | } | 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 | 50 | 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 | 824 | case C_NULL: | 4930 | | /* PE DLLs sometimes have zeroed out symbols for some | 4931 | | reason. Just ignore them without a warning. */ | 4932 | 824 | if (src->u.syment.n_type == 0 | 4933 | 824 | && src->u.syment.n_value == 0 | 4934 | 824 | && src->u.syment.n_scnum == 0) | 4935 | 824 | 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 | 0 | case C_EXTDEF: /* External definition. */ | 4943 | 0 | case C_ULABEL: /* Undefined label. */ | 4944 | 0 | 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 | 0 | case C_EXTLAB: /* External load time label. */ | 4957 | 0 | default: | 4958 | 0 | _bfd_error_handler | 4959 | | /* xgettext:c-format */ | 4960 | 0 | (_("%pB: unrecognized storage class %d for %s symbol `%s'"), | 4961 | 0 | abfd, src->u.syment.n_sclass, | 4962 | 0 | dst->symbol.section->name, dst->symbol.name); | 4963 | 0 | ret = false; | 4964 | | /* Fall through. */ | 4965 | 15 | 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 | dst->symbol.flags = BSF_DEBUGGING; | 4969 | 15 | dst->symbol.value = (src->u.syment.n_value); | 4970 | 15 | break; | 4971 | 1.63k | } | 4972 | | | 4973 | 1.63k | dst->native = src; | 4974 | 1.63k | dst->symbol.udata.i = 0; | 4975 | 1.63k | dst->lineno = NULL; | 4976 | | | 4977 | 1.63k | this_index += (src->u.syment.n_numaux) + 1; | 4978 | 1.63k | dst++; | 4979 | 1.63k | number_of_symbols++; | 4980 | 1.63k | } | 4981 | 98 | } | 4982 | | | 4983 | 98 | obj_symbols (abfd) = cached_area; | 4984 | 98 | obj_raw_syments (abfd) = native_symbols; | 4985 | | | 4986 | 98 | abfd->symcount = number_of_symbols; | 4987 | 98 | obj_convert (abfd) = table_ptr; | 4988 | | /* Slurp the line tables for each section too. */ | 4989 | 98 | { | 4990 | 98 | asection *p; | 4991 | | | 4992 | 98 | p = abfd->sections; | 4993 | 8.63k | while (p) | 4994 | 8.53k | { | 4995 | 8.53k | if (! coff_slurp_line_table (abfd, p)) | 4996 | 0 | return false; | 4997 | 8.53k | p = p->next; | 4998 | 8.53k | } | 4999 | 98 | } | 5000 | | | 5001 | 98 | return ret; | 5002 | 98 | } |
pei-x86_64.c:coff_slurp_symbol_table Line | Count | Source | 4630 | 126 | { | 4631 | 126 | combined_entry_type *native_symbols; | 4632 | 126 | coff_symbol_type *cached_area; | 4633 | 126 | unsigned int *table_ptr; | 4634 | 126 | unsigned int number_of_symbols = 0; | 4635 | 126 | bool ret = true; | 4636 | 126 | size_t amt; | 4637 | | | 4638 | 126 | if (obj_symbols (abfd)) | 4639 | 63 | return true; | 4640 | | | 4641 | | /* Read in the symbol table. */ | 4642 | 63 | if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) | 4643 | 0 | return false; | 4644 | | | 4645 | | /* Allocate enough room for all the symbols in cached form. */ | 4646 | 63 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4647 | 63 | sizeof (*cached_area), &amt)) | 4648 | 0 | { | 4649 | 0 | bfd_set_error (bfd_error_file_too_big); | 4650 | 0 | return false; | 4651 | 0 | } | 4652 | 63 | cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt); | 4653 | 63 | if (cached_area == NULL) | 4654 | 0 | return false; | 4655 | | | 4656 | 63 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4657 | 63 | sizeof (*table_ptr), &amt)) | 4658 | 0 | { | 4659 | 0 | bfd_set_error (bfd_error_file_too_big); | 4660 | 0 | return false; | 4661 | 0 | } | 4662 | 63 | table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); | 4663 | 63 | if (table_ptr == NULL) | 4664 | 0 | return false; | 4665 | 63 | else | 4666 | 63 | { | 4667 | 63 | coff_symbol_type *dst = cached_area; | 4668 | 63 | unsigned int last_native_index = obj_raw_syment_count (abfd); | 4669 | 63 | unsigned int this_index = 0; | 4670 | | | 4671 | 1.31k | while (this_index < last_native_index) | 4672 | 1.25k | { | 4673 | 1.25k | combined_entry_type *src = native_symbols + this_index; | 4674 | 1.25k | table_ptr[this_index] = number_of_symbols; | 4675 | | | 4676 | 1.25k | dst->symbol.the_bfd = abfd; | 4677 | 1.25k | BFD_ASSERT (src->is_sym); | 4678 | 1.25k | 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 | 1.25k | src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; | 4681 | 1.25k | dst->symbol.section = coff_section_from_bfd_index (abfd, | 4682 | 1.25k | src->u.syment.n_scnum); | 4683 | 1.25k | dst->symbol.flags = 0; | 4684 | | /* PR 17512: file: 079-7098-0.001:0.1. */ | 4685 | 1.25k | dst->symbol.value = 0; | 4686 | 1.25k | dst->done_lineno = false; | 4687 | | | 4688 | 1.25k | switch (src->u.syment.n_sclass) | 4689 | 1.25k | { | 4690 | 110 | case C_EXT: | 4691 | 115 | 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 | 115 | #ifdef C_SYSTEM | 4703 | 124 | case C_SYSTEM: /* System Wide variable. */ | 4704 | 124 | #endif | 4705 | 124 | #ifdef COFF_WITH_PE | 4706 | | /* In PE, 0x68 (104) denotes a section symbol. */ | 4707 | 127 | case C_SECTION: | 4708 | | /* In PE, 0x69 (105) denotes a weak external symbol. */ | 4709 | 139 | case C_NT_WEAK: | 4710 | 139 | #endif | 4711 | 139 | switch (coff_classify_symbol (abfd, &src->u.syment)) | 4712 | 139 | { | 4713 | 108 | case COFF_SYMBOL_GLOBAL: | 4714 | 108 | dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL; | 4715 | 108 | #if defined COFF_WITH_PE | 4716 | | /* PE sets the symbol to a value relative to the | 4717 | | start of the section. */ | 4718 | 108 | 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 | 108 | 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 | 108 | break; | 4728 | | | 4729 | 11 | case COFF_SYMBOL_COMMON: | 4730 | 11 | dst->symbol.section = bfd_com_section_ptr; | 4731 | 11 | dst->symbol.value = src->u.syment.n_value; | 4732 | 11 | 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 | 139 | } | 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 | 139 | #ifdef COFF_WITH_PE | 4766 | 139 | if (src->u.syment.n_sclass == C_NT_WEAK) | 4767 | 12 | dst->symbol.flags |= BSF_WEAK; | 4768 | | | 4769 | 139 | if (src->u.syment.n_sclass == C_SECTION | 4770 | 139 | && src->u.syment.n_scnum > 0) | 4771 | 0 | dst->symbol.flags = BSF_LOCAL; | 4772 | 139 | #endif | 4773 | 139 | if (src->u.syment.n_sclass == C_WEAKEXT | 4774 | | #ifdef RS6000COFF_C | 4775 | | || src->u.syment.n_sclass == C_AIX_WEAKEXT | 4776 | | #endif | 4777 | 139 | ) | 4778 | 5 | dst->symbol.flags |= BSF_WEAK; | 4779 | | | 4780 | 139 | break; | 4781 | | | 4782 | 57 | 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 | 68 | case C_LABEL: /* Label. */ | 4793 | 68 | if (src->u.syment.n_scnum == N_DEBUG) | 4794 | 0 | dst->symbol.flags = BSF_DEBUGGING; | 4795 | 68 | else | 4796 | 68 | 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 | 68 | if (dst->symbol.section) | 4801 | 68 | { | 4802 | 68 | #if defined COFF_WITH_PE | 4803 | | /* PE sets the symbol to a value relative to the | 4804 | | start of the section. */ | 4805 | 68 | 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 | 68 | } | 4811 | 0 | else | 4812 | 0 | dst->symbol.value = src->u.syment.n_value; | 4813 | 68 | break; | 4814 | | | 4815 | 32 | case C_FILE: /* File name. */ | 4816 | 32 | dst->symbol.flags = BSF_FILE; | 4817 | | /* Fall through. */ | 4818 | 60 | case C_MOS: /* Member of structure. */ | 4819 | 61 | case C_EOS: /* End of structure. */ | 4820 | 61 | case C_REGPARM: /* Register parameter. */ | 4821 | 112 | case C_REG: /* register variable. */ | 4822 | | /* C_AUTOARG conflicts with TI COFF C_UEXT. */ | 4823 | 116 | case C_TPDEF: /* Type definition. */ | 4824 | 127 | case C_ARG: | 4825 | 190 | case C_AUTO: /* Automatic variable. */ | 4826 | 194 | case C_FIELD: /* Bit field. */ | 4827 | 212 | case C_ENTAG: /* Enumeration tag. */ | 4828 | 215 | case C_MOE: /* Member of enumeration. */ | 4829 | 215 | case C_MOU: /* Member of union. */ | 4830 | 222 | case C_UNTAG: /* Union tag. */ | 4831 | 226 | 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 | 226 | dst->symbol.flags |= BSF_DEBUGGING; | 4849 | 226 | dst->symbol.value = (src->u.syment.n_value); | 4850 | 226 | 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 | 1 | case C_BLOCK: /* ".bb" or ".eb". */ | 4901 | 2 | case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */ | 4902 | 52 | case C_EFCN: /* Physical end of function. */ | 4903 | 52 | #if defined COFF_WITH_PE | 4904 | | /* PE sets the symbol to a value relative to the start | 4905 | | of the section. */ | 4906 | 52 | dst->symbol.value = src->u.syment.n_value; | 4907 | 52 | if (strcmp (dst->symbol.name, ".bf") != 0) | 4908 | 52 | { | 4909 | | /* PE uses funny values for .ef and .lf; don't | 4910 | | relocate them. */ | 4911 | 52 | dst->symbol.flags = BSF_DEBUGGING; | 4912 | 52 | } | 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 | 52 | break; | 4923 | | | 4924 | 7 | case C_STATLAB: /* Static load time label. */ | 4925 | 7 | dst->symbol.value = src->u.syment.n_value; | 4926 | 7 | dst->symbol.flags = BSF_GLOBAL; | 4927 | 7 | break; | 4928 | | | 4929 | 752 | case C_NULL: | 4930 | | /* PE DLLs sometimes have zeroed out symbols for some | 4931 | | reason. Just ignore them without a warning. */ | 4932 | 752 | if (src->u.syment.n_type == 0 | 4933 | 752 | && src->u.syment.n_value == 0 | 4934 | 752 | && src->u.syment.n_scnum == 0) | 4935 | 752 | 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 | 0 | case C_EXTDEF: /* External definition. */ | 4943 | 0 | case C_ULABEL: /* Undefined label. */ | 4944 | 0 | 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 | 0 | case C_EXTLAB: /* External load time label. */ | 4957 | 0 | default: | 4958 | 0 | _bfd_error_handler | 4959 | | /* xgettext:c-format */ | 4960 | 0 | (_("%pB: unrecognized storage class %d for %s symbol `%s'"), | 4961 | 0 | abfd, src->u.syment.n_sclass, | 4962 | 0 | dst->symbol.section->name, dst->symbol.name); | 4963 | 0 | ret = false; | 4964 | | /* Fall through. */ | 4965 | 7 | 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 | dst->symbol.flags = BSF_DEBUGGING; | 4969 | 7 | dst->symbol.value = (src->u.syment.n_value); | 4970 | 7 | break; | 4971 | 1.25k | } | 4972 | | | 4973 | 1.25k | dst->native = src; | 4974 | 1.25k | dst->symbol.udata.i = 0; | 4975 | 1.25k | dst->lineno = NULL; | 4976 | | | 4977 | 1.25k | this_index += (src->u.syment.n_numaux) + 1; | 4978 | 1.25k | dst++; | 4979 | 1.25k | number_of_symbols++; | 4980 | 1.25k | } | 4981 | 63 | } | 4982 | | | 4983 | 63 | obj_symbols (abfd) = cached_area; | 4984 | 63 | obj_raw_syments (abfd) = native_symbols; | 4985 | | | 4986 | 63 | abfd->symcount = number_of_symbols; | 4987 | 63 | obj_convert (abfd) = table_ptr; | 4988 | | /* Slurp the line tables for each section too. */ | 4989 | 63 | { | 4990 | 63 | asection *p; | 4991 | | | 4992 | 63 | p = abfd->sections; | 4993 | 418 | while (p) | 4994 | 355 | { | 4995 | 355 | if (! coff_slurp_line_table (abfd, p)) | 4996 | 0 | return false; | 4997 | 355 | p = p->next; | 4998 | 355 | } | 4999 | 63 | } | 5000 | | | 5001 | 63 | return ret; | 5002 | 63 | } |
coff-x86_64.c:coff_slurp_symbol_table Line | Count | Source | 4630 | 212 | { | 4631 | 212 | combined_entry_type *native_symbols; | 4632 | 212 | coff_symbol_type *cached_area; | 4633 | 212 | unsigned int *table_ptr; | 4634 | 212 | unsigned int number_of_symbols = 0; | 4635 | 212 | bool ret = true; | 4636 | 212 | size_t amt; | 4637 | | | 4638 | 212 | if (obj_symbols (abfd)) | 4639 | 106 | return true; | 4640 | | | 4641 | | /* Read in the symbol table. */ | 4642 | 106 | if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) | 4643 | 0 | return false; | 4644 | | | 4645 | | /* Allocate enough room for all the symbols in cached form. */ | 4646 | 106 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4647 | 106 | sizeof (*cached_area), &amt)) | 4648 | 0 | { | 4649 | 0 | bfd_set_error (bfd_error_file_too_big); | 4650 | 0 | return false; | 4651 | 0 | } | 4652 | 106 | cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt); | 4653 | 106 | if (cached_area == NULL) | 4654 | 0 | return false; | 4655 | | | 4656 | 106 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4657 | 106 | sizeof (*table_ptr), &amt)) | 4658 | 0 | { | 4659 | 0 | bfd_set_error (bfd_error_file_too_big); | 4660 | 0 | return false; | 4661 | 0 | } | 4662 | 106 | table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); | 4663 | 106 | if (table_ptr == NULL) | 4664 | 0 | return false; | 4665 | 106 | else | 4666 | 106 | { | 4667 | 106 | coff_symbol_type *dst = cached_area; | 4668 | 106 | unsigned int last_native_index = obj_raw_syment_count (abfd); | 4669 | 106 | unsigned int this_index = 0; | 4670 | | | 4671 | 2.13k | while (this_index < last_native_index) | 4672 | 2.02k | { | 4673 | 2.02k | combined_entry_type *src = native_symbols + this_index; | 4674 | 2.02k | table_ptr[this_index] = number_of_symbols; | 4675 | | | 4676 | 2.02k | dst->symbol.the_bfd = abfd; | 4677 | 2.02k | BFD_ASSERT (src->is_sym); | 4678 | 2.02k | 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 | 2.02k | src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; | 4681 | 2.02k | dst->symbol.section = coff_section_from_bfd_index (abfd, | 4682 | 2.02k | src->u.syment.n_scnum); | 4683 | 2.02k | dst->symbol.flags = 0; | 4684 | | /* PR 17512: file: 079-7098-0.001:0.1. */ | 4685 | 2.02k | dst->symbol.value = 0; | 4686 | 2.02k | dst->done_lineno = false; | 4687 | | | 4688 | 2.02k | switch (src->u.syment.n_sclass) | 4689 | 2.02k | { | 4690 | 114 | case C_EXT: | 4691 | 133 | 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 | 133 | #ifdef C_SYSTEM | 4703 | 158 | case C_SYSTEM: /* System Wide variable. */ | 4704 | 158 | #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 | 158 | switch (coff_classify_symbol (abfd, &src->u.syment)) | 4712 | 158 | { | 4713 | 133 | case COFF_SYMBOL_GLOBAL: | 4714 | 133 | 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 | 133 | dst->symbol.value = (src->u.syment.n_value | 4721 | 133 | - dst->symbol.section->vma); | 4722 | 133 | #endif | 4723 | 133 | 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 | 133 | break; | 4728 | | | 4729 | 11 | case COFF_SYMBOL_COMMON: | 4730 | 11 | dst->symbol.section = bfd_com_section_ptr; | 4731 | 11 | dst->symbol.value = src->u.syment.n_value; | 4732 | 11 | break; | 4733 | | | 4734 | 14 | case COFF_SYMBOL_UNDEFINED: | 4735 | 14 | dst->symbol.section = bfd_und_section_ptr; | 4736 | 14 | dst->symbol.value = 0; | 4737 | 14 | 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 | 158 | } | 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 | 158 | if (src->u.syment.n_sclass == C_WEAKEXT | 4774 | | #ifdef RS6000COFF_C | 4775 | | || src->u.syment.n_sclass == C_AIX_WEAKEXT | 4776 | | #endif | 4777 | 158 | ) | 4778 | 19 | dst->symbol.flags |= BSF_WEAK; | 4779 | | | 4780 | 158 | break; | 4781 | | | 4782 | 114 | 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 | 141 | case C_LABEL: /* Label. */ | 4793 | 141 | if (src->u.syment.n_scnum == N_DEBUG) | 4794 | 0 | dst->symbol.flags = BSF_DEBUGGING; | 4795 | 141 | else | 4796 | 141 | 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 | 141 | if (dst->symbol.section) | 4801 | 141 | { | 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 | 141 | dst->symbol.value = (src->u.syment.n_value | 4808 | 141 | - dst->symbol.section->vma); | 4809 | 141 | #endif | 4810 | 141 | } | 4811 | 0 | else | 4812 | 0 | dst->symbol.value = src->u.syment.n_value; | 4813 | 141 | break; | 4814 | | | 4815 | 11 | case C_FILE: /* File name. */ | 4816 | 11 | dst->symbol.flags = BSF_FILE; | 4817 | | /* Fall through. */ | 4818 | 25 | case C_MOS: /* Member of structure. */ | 4819 | 26 | case C_EOS: /* End of structure. */ | 4820 | 40 | case C_REGPARM: /* Register parameter. */ | 4821 | 65 | case C_REG: /* register variable. */ | 4822 | | /* C_AUTOARG conflicts with TI COFF C_UEXT. */ | 4823 | 76 | case C_TPDEF: /* Type definition. */ | 4824 | 151 | case C_ARG: | 4825 | 475 | case C_AUTO: /* Automatic variable. */ | 4826 | 523 | case C_FIELD: /* Bit field. */ | 4827 | 533 | case C_ENTAG: /* Enumeration tag. */ | 4828 | 546 | case C_MOE: /* Member of enumeration. */ | 4829 | 564 | case C_MOU: /* Member of union. */ | 4830 | 595 | case C_UNTAG: /* Union tag. */ | 4831 | 637 | 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 | 637 | dst->symbol.flags |= BSF_DEBUGGING; | 4849 | 637 | dst->symbol.value = (src->u.syment.n_value); | 4850 | 637 | 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 | 12 | case C_BLOCK: /* ".bb" or ".eb". */ | 4901 | 50 | case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */ | 4902 | 73 | 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 | 73 | dst->symbol.flags = BSF_LOCAL; | 4919 | 73 | dst->symbol.value = (src->u.syment.n_value | 4920 | 73 | - dst->symbol.section->vma); | 4921 | 73 | #endif | 4922 | 73 | break; | 4923 | | | 4924 | 70 | case C_STATLAB: /* Static load time label. */ | 4925 | 70 | dst->symbol.value = src->u.syment.n_value; | 4926 | 70 | dst->symbol.flags = BSF_GLOBAL; | 4927 | 70 | break; | 4928 | | | 4929 | 936 | case C_NULL: | 4930 | | /* PE DLLs sometimes have zeroed out symbols for some | 4931 | | reason. Just ignore them without a warning. */ | 4932 | 936 | if (src->u.syment.n_type == 0 | 4933 | 936 | && src->u.syment.n_value == 0 | 4934 | 936 | && src->u.syment.n_scnum == 0) | 4935 | 936 | 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 | 0 | case C_EXTDEF: /* External definition. */ | 4943 | 0 | case C_ULABEL: /* Undefined label. */ | 4944 | 0 | case C_USTATIC: /* Undefined static. */ | 4945 | 0 | #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 | 0 | case C_LINE: /* line # reformatted as symbol table entry. */ | 4949 | | /* NT uses 0x67 for a weak symbol, not C_ALIAS. */ | 4950 | 0 | case C_ALIAS: /* Duplicate tag. */ | 4951 | 0 | #endif | 4952 | | /* New storage classes for TI COFF. */ | 4953 | | #ifdef TICOFF | 4954 | | case C_UEXT: /* Tentative external definition. */ | 4955 | | #endif | 4956 | 0 | case C_EXTLAB: /* External load time label. */ | 4957 | 0 | default: | 4958 | 0 | _bfd_error_handler | 4959 | | /* xgettext:c-format */ | 4960 | 0 | (_("%pB: unrecognized storage class %d for %s symbol `%s'"), | 4961 | 0 | abfd, src->u.syment.n_sclass, | 4962 | 0 | dst->symbol.section->name, dst->symbol.name); | 4963 | 0 | ret = false; | 4964 | | /* Fall through. */ | 4965 | 9 | 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 | dst->symbol.flags = BSF_DEBUGGING; | 4969 | 9 | dst->symbol.value = (src->u.syment.n_value); | 4970 | 9 | break; | 4971 | 2.02k | } | 4972 | | | 4973 | 2.02k | dst->native = src; | 4974 | 2.02k | dst->symbol.udata.i = 0; | 4975 | 2.02k | dst->lineno = NULL; | 4976 | | | 4977 | 2.02k | this_index += (src->u.syment.n_numaux) + 1; | 4978 | 2.02k | dst++; | 4979 | 2.02k | number_of_symbols++; | 4980 | 2.02k | } | 4981 | 106 | } | 4982 | | | 4983 | 106 | obj_symbols (abfd) = cached_area; | 4984 | 106 | obj_raw_syments (abfd) = native_symbols; | 4985 | | | 4986 | 106 | abfd->symcount = number_of_symbols; | 4987 | 106 | obj_convert (abfd) = table_ptr; | 4988 | | /* Slurp the line tables for each section too. */ | 4989 | 106 | { | 4990 | 106 | asection *p; | 4991 | | | 4992 | 106 | p = abfd->sections; | 4993 | 25.3k | while (p) | 4994 | 25.2k | { | 4995 | 25.2k | if (! coff_slurp_line_table (abfd, p)) | 4996 | 0 | return false; | 4997 | 25.2k | p = p->next; | 4998 | 25.2k | } | 4999 | 106 | } | 5000 | | | 5001 | 106 | return ret; | 5002 | 106 | } |
coff64-rs6000.c:coff_slurp_symbol_table Line | Count | Source | 4630 | 170 | { | 4631 | 170 | combined_entry_type *native_symbols; | 4632 | 170 | coff_symbol_type *cached_area; | 4633 | 170 | unsigned int *table_ptr; | 4634 | 170 | unsigned int number_of_symbols = 0; | 4635 | 170 | bool ret = true; | 4636 | 170 | size_t amt; | 4637 | | | 4638 | 170 | if (obj_symbols (abfd)) | 4639 | 85 | return true; | 4640 | | | 4641 | | /* Read in the symbol table. */ | 4642 | 85 | if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) | 4643 | 0 | return false; | 4644 | | | 4645 | | /* Allocate enough room for all the symbols in cached form. */ | 4646 | 85 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4647 | 85 | sizeof (*cached_area), &amt)) | 4648 | 0 | { | 4649 | 0 | bfd_set_error (bfd_error_file_too_big); | 4650 | 0 | return false; | 4651 | 0 | } | 4652 | 85 | cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt); | 4653 | 85 | if (cached_area == NULL) | 4654 | 0 | return false; | 4655 | | | 4656 | 85 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4657 | 85 | sizeof (*table_ptr), &amt)) | 4658 | 0 | { | 4659 | 0 | bfd_set_error (bfd_error_file_too_big); | 4660 | 0 | return false; | 4661 | 0 | } | 4662 | 85 | table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); | 4663 | 85 | if (table_ptr == NULL) | 4664 | 0 | return false; | 4665 | 85 | else | 4666 | 85 | { | 4667 | 85 | coff_symbol_type *dst = cached_area; | 4668 | 85 | unsigned int last_native_index = obj_raw_syment_count (abfd); | 4669 | 85 | unsigned int this_index = 0; | 4670 | | | 4671 | 1.83k | while (this_index < last_native_index) | 4672 | 1.75k | { | 4673 | 1.75k | combined_entry_type *src = native_symbols + this_index; | 4674 | 1.75k | table_ptr[this_index] = number_of_symbols; | 4675 | | | 4676 | 1.75k | dst->symbol.the_bfd = abfd; | 4677 | 1.75k | BFD_ASSERT (src->is_sym); | 4678 | 1.75k | 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 | 1.75k | src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; | 4681 | 1.75k | dst->symbol.section = coff_section_from_bfd_index (abfd, | 4682 | 1.75k | src->u.syment.n_scnum); | 4683 | 1.75k | dst->symbol.flags = 0; | 4684 | | /* PR 17512: file: 079-7098-0.001:0.1. */ | 4685 | 1.75k | dst->symbol.value = 0; | 4686 | 1.75k | dst->done_lineno = false; | 4687 | | | 4688 | 1.75k | switch (src->u.syment.n_sclass) | 4689 | 1.75k | { | 4690 | 54 | case C_EXT: | 4691 | 57 | case C_WEAKEXT: | 4692 | | #if defined ARM | 4693 | | case C_THUMBEXT: | 4694 | | case C_THUMBEXTFUNC: | 4695 | | #endif | 4696 | 57 | #ifdef RS6000COFF_C | 4697 | 73 | case C_HIDEXT: | 4698 | 73 | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 4699 | 78 | case C_AIX_WEAKEXT: | 4700 | 78 | #endif | 4701 | 78 | #endif | 4702 | 78 | #ifdef C_SYSTEM | 4703 | 86 | case C_SYSTEM: /* System Wide variable. */ | 4704 | 86 | #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 | 86 | switch (coff_classify_symbol (abfd, &src->u.syment)) | 4712 | 86 | { | 4713 | 58 | case COFF_SYMBOL_GLOBAL: | 4714 | 58 | 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 | 58 | dst->symbol.value = (src->u.syment.n_value | 4721 | 58 | - dst->symbol.section->vma); | 4722 | 58 | #endif | 4723 | 58 | 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 | 58 | break; | 4728 | | | 4729 | 2 | case COFF_SYMBOL_COMMON: | 4730 | 2 | dst->symbol.section = bfd_com_section_ptr; | 4731 | 2 | dst->symbol.value = src->u.syment.n_value; | 4732 | 2 | break; | 4733 | | | 4734 | 10 | case COFF_SYMBOL_UNDEFINED: | 4735 | 10 | dst->symbol.section = bfd_und_section_ptr; | 4736 | 10 | dst->symbol.value = 0; | 4737 | 10 | 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 | 16 | case COFF_SYMBOL_LOCAL: | 4745 | 16 | 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 | 16 | dst->symbol.value = (src->u.syment.n_value | 4752 | 16 | - dst->symbol.section->vma); | 4753 | 16 | #endif | 4754 | 16 | if (ISFCN ((src->u.syment.n_type))) | 4755 | 14 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4756 | 16 | break; | 4757 | 86 | } | 4758 | | | 4759 | 86 | #ifdef RS6000COFF_C | 4760 | | /* A symbol with a csect entry should not go at the end. */ | 4761 | 86 | if (src->u.syment.n_numaux > 0) | 4762 | 77 | dst->symbol.flags |= BSF_NOT_AT_END; | 4763 | 86 | #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 | 86 | if (src->u.syment.n_sclass == C_WEAKEXT | 4774 | 86 | #ifdef RS6000COFF_C | 4775 | 86 | || src->u.syment.n_sclass == C_AIX_WEAKEXT | 4776 | 86 | #endif | 4777 | 86 | ) | 4778 | 8 | dst->symbol.flags |= BSF_WEAK; | 4779 | | | 4780 | 86 | break; | 4781 | | | 4782 | 12 | 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 | 12 | #ifdef RS6000COFF_C | 4789 | 16 | case C_DWARF: /* A label in a dwarf section. */ | 4790 | 16 | case C_INFO: /* A label in a comment section. */ | 4791 | 16 | #endif | 4792 | 25 | case C_LABEL: /* Label. */ | 4793 | 25 | if (src->u.syment.n_scnum == N_DEBUG) | 4794 | 0 | dst->symbol.flags = BSF_DEBUGGING; | 4795 | 25 | else | 4796 | 25 | 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 | 25 | if (dst->symbol.section) | 4801 | 25 | { | 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 | 25 | dst->symbol.value = (src->u.syment.n_value | 4808 | 25 | - dst->symbol.section->vma); | 4809 | 25 | #endif | 4810 | 25 | } | 4811 | 0 | else | 4812 | 0 | dst->symbol.value = src->u.syment.n_value; | 4813 | 25 | break; | 4814 | | | 4815 | 8 | case C_FILE: /* File name. */ | 4816 | 8 | dst->symbol.flags = BSF_FILE; | 4817 | | /* Fall through. */ | 4818 | 8 | case C_MOS: /* Member of structure. */ | 4819 | 9 | case C_EOS: /* End of structure. */ | 4820 | 13 | case C_REGPARM: /* Register parameter. */ | 4821 | 36 | case C_REG: /* register variable. */ | 4822 | | /* C_AUTOARG conflicts with TI COFF C_UEXT. */ | 4823 | 43 | case C_TPDEF: /* Type definition. */ | 4824 | 43 | case C_ARG: | 4825 | 116 | case C_AUTO: /* Automatic variable. */ | 4826 | 119 | case C_FIELD: /* Bit field. */ | 4827 | 130 | case C_ENTAG: /* Enumeration tag. */ | 4828 | 132 | case C_MOE: /* Member of enumeration. */ | 4829 | 158 | case C_MOU: /* Member of union. */ | 4830 | 166 | case C_UNTAG: /* Union tag. */ | 4831 | 192 | case C_STRTAG: /* Structure tag. */ | 4832 | 192 | #ifdef RS6000COFF_C | 4833 | 199 | case C_GSYM: | 4834 | 200 | case C_LSYM: | 4835 | 200 | case C_PSYM: | 4836 | 200 | case C_RSYM: | 4837 | 200 | case C_RPSYM: | 4838 | 201 | case C_STSYM: | 4839 | 202 | case C_TCSYM: | 4840 | 202 | case C_BCOMM: | 4841 | 202 | case C_ECOML: | 4842 | 202 | case C_ECOMM: | 4843 | 202 | case C_DECL: | 4844 | 203 | case C_ENTRY: | 4845 | 204 | case C_FUN: | 4846 | 241 | case C_ESTAT: | 4847 | 241 | #endif | 4848 | 241 | dst->symbol.flags |= BSF_DEBUGGING; | 4849 | 241 | dst->symbol.value = (src->u.syment.n_value); | 4850 | 241 | break; | 4851 | | | 4852 | 0 | #ifdef RS6000COFF_C | 4853 | 6 | case C_BINCL: /* Beginning of include file. */ | 4854 | 42 | 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 | 42 | { | 4860 | 42 | asection *sec; | 4861 | | | 4862 | 42 | dst->symbol.flags = BSF_DEBUGGING; | 4863 | 997 | for (sec = abfd->sections; sec != NULL; sec = sec->next) | 4864 | 960 | if (sec->line_filepos <= (file_ptr) src->u.syment.n_value | 4865 | 960 | && ((file_ptr) (sec->line_filepos | 4866 | 677 | + sec->lineno_count * bfd_coff_linesz (abfd)) | 4867 | 677 | > (file_ptr) src->u.syment.n_value)) | 4868 | 5 | break; | 4869 | 42 | if (sec == NULL) | 4870 | 37 | dst->symbol.value = 0; | 4871 | 5 | else | 4872 | 5 | { | 4873 | 5 | dst->symbol.section = sec; | 4874 | 5 | dst->symbol.value = ((src->u.syment.n_value | 4875 | 5 | - sec->line_filepos) | 4876 | 5 | / bfd_coff_linesz (abfd)); | 4877 | 5 | src->fix_line = 1; | 4878 | 5 | } | 4879 | 42 | } | 4880 | 42 | break; | 4881 | | | 4882 | 4 | case C_BSTAT: | 4883 | 4 | dst->symbol.flags = BSF_DEBUGGING; | 4884 | | | 4885 | 4 | if (src->u.syment.n_value >= obj_raw_syment_count (abfd)) | 4886 | 1 | dst->symbol.value = 0; | 4887 | 3 | else | 4888 | 3 | { | 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 | 3 | src->u.syment.n_value | 4893 | 3 | = (uintptr_t) (native_symbols + src->u.syment.n_value); | 4894 | 3 | dst->symbol.value = src->u.syment.n_value; | 4895 | 3 | src->fix_value = 1; | 4896 | 3 | } | 4897 | 4 | break; | 4898 | 0 | #endif | 4899 | | | 4900 | 11 | case C_BLOCK: /* ".bb" or ".eb". */ | 4901 | 12 | case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */ | 4902 | 28 | 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 | 28 | dst->symbol.flags = BSF_LOCAL; | 4919 | 28 | dst->symbol.value = (src->u.syment.n_value | 4920 | 28 | - dst->symbol.section->vma); | 4921 | 28 | #endif | 4922 | 28 | break; | 4923 | | | 4924 | 11 | case C_STATLAB: /* Static load time label. */ | 4925 | 11 | dst->symbol.value = src->u.syment.n_value; | 4926 | 11 | dst->symbol.flags = BSF_GLOBAL; | 4927 | 11 | break; | 4928 | | | 4929 | 1.31k | case C_NULL: | 4930 | | /* PE DLLs sometimes have zeroed out symbols for some | 4931 | | reason. Just ignore them without a warning. */ | 4932 | 1.31k | if (src->u.syment.n_type == 0 | 4933 | 1.31k | && src->u.syment.n_value == 0 | 4934 | 1.31k | && src->u.syment.n_scnum == 0) | 4935 | 1.31k | break; | 4936 | 0 | #ifdef RS6000COFF_C | 4937 | | /* XCOFF specific: deleted entry. */ | 4938 | 0 | if (src->u.syment.n_value == C_NULL_VALUE) | 4939 | 0 | break; | 4940 | 0 | #endif | 4941 | | /* Fall through. */ | 4942 | 0 | case C_EXTDEF: /* External definition. */ | 4943 | 0 | case C_ULABEL: /* Undefined label. */ | 4944 | 0 | case C_USTATIC: /* Undefined static. */ | 4945 | 0 | #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 | 0 | case C_LINE: /* line # reformatted as symbol table entry. */ | 4949 | | /* NT uses 0x67 for a weak symbol, not C_ALIAS. */ | 4950 | 0 | case C_ALIAS: /* Duplicate tag. */ | 4951 | 0 | #endif | 4952 | | /* New storage classes for TI COFF. */ | 4953 | | #ifdef TICOFF | 4954 | | case C_UEXT: /* Tentative external definition. */ | 4955 | | #endif | 4956 | 0 | case C_EXTLAB: /* External load time label. */ | 4957 | 0 | default: | 4958 | 0 | _bfd_error_handler | 4959 | | /* xgettext:c-format */ | 4960 | 0 | (_("%pB: unrecognized storage class %d for %s symbol `%s'"), | 4961 | 0 | abfd, src->u.syment.n_sclass, | 4962 | 0 | dst->symbol.section->name, dst->symbol.name); | 4963 | 0 | ret = false; | 4964 | | /* Fall through. */ | 4965 | 4 | 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 | 4 | dst->symbol.flags = BSF_DEBUGGING; | 4969 | 4 | dst->symbol.value = (src->u.syment.n_value); | 4970 | 4 | break; | 4971 | 1.75k | } | 4972 | | | 4973 | 1.75k | dst->native = src; | 4974 | 1.75k | dst->symbol.udata.i = 0; | 4975 | 1.75k | dst->lineno = NULL; | 4976 | | | 4977 | 1.75k | this_index += (src->u.syment.n_numaux) + 1; | 4978 | 1.75k | dst++; | 4979 | 1.75k | number_of_symbols++; | 4980 | 1.75k | } | 4981 | 85 | } | 4982 | | | 4983 | 85 | obj_symbols (abfd) = cached_area; | 4984 | 85 | obj_raw_syments (abfd) = native_symbols; | 4985 | | | 4986 | 85 | abfd->symcount = number_of_symbols; | 4987 | 85 | obj_convert (abfd) = table_ptr; | 4988 | | /* Slurp the line tables for each section too. */ | 4989 | 85 | { | 4990 | 85 | asection *p; | 4991 | | | 4992 | 85 | p = abfd->sections; | 4993 | 1.19k | while (p) | 4994 | 1.10k | { | 4995 | 1.10k | if (! coff_slurp_line_table (abfd, p)) | 4996 | 0 | return false; | 4997 | 1.10k | p = p->next; | 4998 | 1.10k | } | 4999 | 85 | } | 5000 | | | 5001 | 85 | return ret; | 5002 | 85 | } |
pei-aarch64.c:coff_slurp_symbol_table Line | Count | Source | 4630 | 122 | { | 4631 | 122 | combined_entry_type *native_symbols; | 4632 | 122 | coff_symbol_type *cached_area; | 4633 | 122 | unsigned int *table_ptr; | 4634 | 122 | unsigned int number_of_symbols = 0; | 4635 | 122 | bool ret = true; | 4636 | 122 | size_t amt; | 4637 | | | 4638 | 122 | if (obj_symbols (abfd)) | 4639 | 61 | return true; | 4640 | | | 4641 | | /* Read in the symbol table. */ | 4642 | 61 | if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) | 4643 | 0 | return false; | 4644 | | | 4645 | | /* Allocate enough room for all the symbols in cached form. */ | 4646 | 61 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4647 | 61 | sizeof (*cached_area), &amt)) | 4648 | 0 | { | 4649 | 0 | bfd_set_error (bfd_error_file_too_big); | 4650 | 0 | return false; | 4651 | 0 | } | 4652 | 61 | cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt); | 4653 | 61 | if (cached_area == NULL) | 4654 | 0 | return false; | 4655 | | | 4656 | 61 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4657 | 61 | sizeof (*table_ptr), &amt)) | 4658 | 0 | { | 4659 | 0 | bfd_set_error (bfd_error_file_too_big); | 4660 | 0 | return false; | 4661 | 0 | } | 4662 | 61 | table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); | 4663 | 61 | if (table_ptr == NULL) | 4664 | 0 | return false; | 4665 | 61 | else | 4666 | 61 | { | 4667 | 61 | coff_symbol_type *dst = cached_area; | 4668 | 61 | unsigned int last_native_index = obj_raw_syment_count (abfd); | 4669 | 61 | unsigned int this_index = 0; | 4670 | | | 4671 | 1.26k | while (this_index < last_native_index) | 4672 | 1.20k | { | 4673 | 1.20k | combined_entry_type *src = native_symbols + this_index; | 4674 | 1.20k | table_ptr[this_index] = number_of_symbols; | 4675 | | | 4676 | 1.20k | dst->symbol.the_bfd = abfd; | 4677 | 1.20k | BFD_ASSERT (src->is_sym); | 4678 | 1.20k | 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 | 1.20k | src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; | 4681 | 1.20k | dst->symbol.section = coff_section_from_bfd_index (abfd, | 4682 | 1.20k | src->u.syment.n_scnum); | 4683 | 1.20k | dst->symbol.flags = 0; | 4684 | | /* PR 17512: file: 079-7098-0.001:0.1. */ | 4685 | 1.20k | dst->symbol.value = 0; | 4686 | 1.20k | dst->done_lineno = false; | 4687 | | | 4688 | 1.20k | switch (src->u.syment.n_sclass) | 4689 | 1.20k | { | 4690 | 99 | case C_EXT: | 4691 | 104 | 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 | 104 | #ifdef C_SYSTEM | 4703 | 105 | case C_SYSTEM: /* System Wide variable. */ | 4704 | 105 | #endif | 4705 | 105 | #ifdef COFF_WITH_PE | 4706 | | /* In PE, 0x68 (104) denotes a section symbol. */ | 4707 | 109 | case C_SECTION: | 4708 | | /* In PE, 0x69 (105) denotes a weak external symbol. */ | 4709 | 111 | case C_NT_WEAK: | 4710 | 111 | #endif | 4711 | 111 | switch (coff_classify_symbol (abfd, &src->u.syment)) | 4712 | 111 | { | 4713 | 83 | case COFF_SYMBOL_GLOBAL: | 4714 | 83 | dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL; | 4715 | 83 | #if defined COFF_WITH_PE | 4716 | | /* PE sets the symbol to a value relative to the | 4717 | | start of the section. */ | 4718 | 83 | 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 | 83 | if (ISFCN ((src->u.syment.n_type))) | 4724 | | /* A function ext does not go at the end of a | 4725 | | file. */ | 4726 | 9 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4727 | 83 | break; | 4728 | | | 4729 | 7 | case COFF_SYMBOL_COMMON: | 4730 | 7 | dst->symbol.section = bfd_com_section_ptr; | 4731 | 7 | dst->symbol.value = src->u.syment.n_value; | 4732 | 7 | 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 | 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 | 111 | } | 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 | 111 | #ifdef COFF_WITH_PE | 4766 | 111 | if (src->u.syment.n_sclass == C_NT_WEAK) | 4767 | 2 | dst->symbol.flags |= BSF_WEAK; | 4768 | | | 4769 | 111 | if (src->u.syment.n_sclass == C_SECTION | 4770 | 111 | && src->u.syment.n_scnum > 0) | 4771 | 0 | dst->symbol.flags = BSF_LOCAL; | 4772 | 111 | #endif | 4773 | 111 | if (src->u.syment.n_sclass == C_WEAKEXT | 4774 | | #ifdef RS6000COFF_C | 4775 | | || src->u.syment.n_sclass == C_AIX_WEAKEXT | 4776 | | #endif | 4777 | 111 | ) | 4778 | 5 | dst->symbol.flags |= BSF_WEAK; | 4779 | | | 4780 | 111 | break; | 4781 | | | 4782 | 65 | 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 | 91 | case C_LABEL: /* Label. */ | 4793 | 91 | if (src->u.syment.n_scnum == N_DEBUG) | 4794 | 0 | dst->symbol.flags = BSF_DEBUGGING; | 4795 | 91 | else | 4796 | 91 | 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 | 91 | if (dst->symbol.section) | 4801 | 91 | { | 4802 | 91 | #if defined COFF_WITH_PE | 4803 | | /* PE sets the symbol to a value relative to the | 4804 | | start of the section. */ | 4805 | 91 | 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 | 91 | } | 4811 | 0 | else | 4812 | 0 | dst->symbol.value = src->u.syment.n_value; | 4813 | 91 | break; | 4814 | | | 4815 | 27 | case C_FILE: /* File name. */ | 4816 | 27 | dst->symbol.flags = BSF_FILE; | 4817 | | /* Fall through. */ | 4818 | 30 | case C_MOS: /* Member of structure. */ | 4819 | 30 | case C_EOS: /* End of structure. */ | 4820 | 36 | case C_REGPARM: /* Register parameter. */ | 4821 | 70 | case C_REG: /* register variable. */ | 4822 | | /* C_AUTOARG conflicts with TI COFF C_UEXT. */ | 4823 | 83 | case C_TPDEF: /* Type definition. */ | 4824 | 104 | case C_ARG: | 4825 | 188 | case C_AUTO: /* Automatic variable. */ | 4826 | 202 | case C_FIELD: /* Bit field. */ | 4827 | 207 | case C_ENTAG: /* Enumeration tag. */ | 4828 | 216 | case C_MOE: /* Member of enumeration. */ | 4829 | 230 | case C_MOU: /* Member of union. */ | 4830 | 238 | case C_UNTAG: /* Union tag. */ | 4831 | 260 | 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 | 260 | dst->symbol.flags |= BSF_DEBUGGING; | 4849 | 260 | dst->symbol.value = (src->u.syment.n_value); | 4850 | 260 | 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 | 7 | case C_BLOCK: /* ".bb" or ".eb". */ | 4901 | 8 | case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */ | 4902 | 53 | case C_EFCN: /* Physical end of function. */ | 4903 | 53 | #if defined COFF_WITH_PE | 4904 | | /* PE sets the symbol to a value relative to the start | 4905 | | of the section. */ | 4906 | 53 | dst->symbol.value = src->u.syment.n_value; | 4907 | 53 | if (strcmp (dst->symbol.name, ".bf") != 0) | 4908 | 53 | { | 4909 | | /* PE uses funny values for .ef and .lf; don't | 4910 | | relocate them. */ | 4911 | 53 | dst->symbol.flags = BSF_DEBUGGING; | 4912 | 53 | } | 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 | 53 | break; | 4923 | | | 4924 | 16 | case C_STATLAB: /* Static load time label. */ | 4925 | 16 | dst->symbol.value = src->u.syment.n_value; | 4926 | 16 | dst->symbol.flags = BSF_GLOBAL; | 4927 | 16 | break; | 4928 | | | 4929 | 675 | case C_NULL: | 4930 | | /* PE DLLs sometimes have zeroed out symbols for some | 4931 | | reason. Just ignore them without a warning. */ | 4932 | 675 | if (src->u.syment.n_type == 0 | 4933 | 675 | && src->u.syment.n_value == 0 | 4934 | 675 | && src->u.syment.n_scnum == 0) | 4935 | 675 | 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 | 0 | case C_EXTDEF: /* External definition. */ | 4943 | 0 | case C_ULABEL: /* Undefined label. */ | 4944 | 0 | 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 | 0 | case C_EXTLAB: /* External load time label. */ | 4957 | 0 | default: | 4958 | 0 | _bfd_error_handler | 4959 | | /* xgettext:c-format */ | 4960 | 0 | (_("%pB: unrecognized storage class %d for %s symbol `%s'"), | 4961 | 0 | abfd, src->u.syment.n_sclass, | 4962 | 0 | dst->symbol.section->name, dst->symbol.name); | 4963 | 0 | ret = false; | 4964 | | /* Fall through. */ | 4965 | 1 | 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 | 1 | dst->symbol.flags = BSF_DEBUGGING; | 4969 | 1 | dst->symbol.value = (src->u.syment.n_value); | 4970 | 1 | break; | 4971 | 1.20k | } | 4972 | | | 4973 | 1.20k | dst->native = src; | 4974 | 1.20k | dst->symbol.udata.i = 0; | 4975 | 1.20k | dst->lineno = NULL; | 4976 | | | 4977 | 1.20k | this_index += (src->u.syment.n_numaux) + 1; | 4978 | 1.20k | dst++; | 4979 | 1.20k | number_of_symbols++; | 4980 | 1.20k | } | 4981 | 61 | } | 4982 | | | 4983 | 61 | obj_symbols (abfd) = cached_area; | 4984 | 61 | obj_raw_syments (abfd) = native_symbols; | 4985 | | | 4986 | 61 | abfd->symcount = number_of_symbols; | 4987 | 61 | obj_convert (abfd) = table_ptr; | 4988 | | /* Slurp the line tables for each section too. */ | 4989 | 61 | { | 4990 | 61 | asection *p; | 4991 | | | 4992 | 61 | p = abfd->sections; | 4993 | 333 | while (p) | 4994 | 272 | { | 4995 | 272 | if (! coff_slurp_line_table (abfd, p)) | 4996 | 0 | return false; | 4997 | 272 | p = p->next; | 4998 | 272 | } | 4999 | 61 | } | 5000 | | | 5001 | 61 | return ret; | 5002 | 61 | } |
pe-aarch64.c:coff_slurp_symbol_table Line | Count | Source | 4630 | 156 | { | 4631 | 156 | combined_entry_type *native_symbols; | 4632 | 156 | coff_symbol_type *cached_area; | 4633 | 156 | unsigned int *table_ptr; | 4634 | 156 | unsigned int number_of_symbols = 0; | 4635 | 156 | bool ret = true; | 4636 | 156 | size_t amt; | 4637 | | | 4638 | 156 | if (obj_symbols (abfd)) | 4639 | 78 | return true; | 4640 | | | 4641 | | /* Read in the symbol table. */ | 4642 | 78 | if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) | 4643 | 0 | return false; | 4644 | | | 4645 | | /* Allocate enough room for all the symbols in cached form. */ | 4646 | 78 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4647 | 78 | sizeof (*cached_area), &amt)) | 4648 | 0 | { | 4649 | 0 | bfd_set_error (bfd_error_file_too_big); | 4650 | 0 | return false; | 4651 | 0 | } | 4652 | 78 | cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt); | 4653 | 78 | if (cached_area == NULL) | 4654 | 0 | return false; | 4655 | | | 4656 | 78 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4657 | 78 | sizeof (*table_ptr), &amt)) | 4658 | 0 | { | 4659 | 0 | bfd_set_error (bfd_error_file_too_big); | 4660 | 0 | return false; | 4661 | 0 | } | 4662 | 78 | table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); | 4663 | 78 | if (table_ptr == NULL) | 4664 | 0 | return false; | 4665 | 78 | else | 4666 | 78 | { | 4667 | 78 | coff_symbol_type *dst = cached_area; | 4668 | 78 | unsigned int last_native_index = obj_raw_syment_count (abfd); | 4669 | 78 | unsigned int this_index = 0; | 4670 | | | 4671 | 3.21k | while (this_index < last_native_index) | 4672 | 3.13k | { | 4673 | 3.13k | combined_entry_type *src = native_symbols + this_index; | 4674 | 3.13k | table_ptr[this_index] = number_of_symbols; | 4675 | | | 4676 | 3.13k | dst->symbol.the_bfd = abfd; | 4677 | 3.13k | BFD_ASSERT (src->is_sym); | 4678 | 3.13k | 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 | 3.13k | src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; | 4681 | 3.13k | dst->symbol.section = coff_section_from_bfd_index (abfd, | 4682 | 3.13k | src->u.syment.n_scnum); | 4683 | 3.13k | dst->symbol.flags = 0; | 4684 | | /* PR 17512: file: 079-7098-0.001:0.1. */ | 4685 | 3.13k | dst->symbol.value = 0; | 4686 | 3.13k | dst->done_lineno = false; | 4687 | | | 4688 | 3.13k | switch (src->u.syment.n_sclass) | 4689 | 3.13k | { | 4690 | 105 | case C_EXT: | 4691 | 124 | 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 | 124 | #ifdef C_SYSTEM | 4703 | 160 | case C_SYSTEM: /* System Wide variable. */ | 4704 | 160 | #endif | 4705 | 160 | #ifdef COFF_WITH_PE | 4706 | | /* In PE, 0x68 (104) denotes a section symbol. */ | 4707 | 160 | case C_SECTION: | 4708 | | /* In PE, 0x69 (105) denotes a weak external symbol. */ | 4709 | 167 | case C_NT_WEAK: | 4710 | 167 | #endif | 4711 | 167 | switch (coff_classify_symbol (abfd, &src->u.syment)) | 4712 | 167 | { | 4713 | 146 | case COFF_SYMBOL_GLOBAL: | 4714 | 146 | dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL; | 4715 | 146 | #if defined COFF_WITH_PE | 4716 | | /* PE sets the symbol to a value relative to the | 4717 | | start of the section. */ | 4718 | 146 | 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 | 146 | 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 | 146 | break; | 4728 | | | 4729 | 6 | case COFF_SYMBOL_COMMON: | 4730 | 6 | dst->symbol.section = bfd_com_section_ptr; | 4731 | 6 | dst->symbol.value = src->u.syment.n_value; | 4732 | 6 | break; | 4733 | | | 4734 | 15 | case COFF_SYMBOL_UNDEFINED: | 4735 | 15 | dst->symbol.section = bfd_und_section_ptr; | 4736 | 15 | dst->symbol.value = 0; | 4737 | 15 | 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 | 167 | } | 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 | 167 | #ifdef COFF_WITH_PE | 4766 | 167 | if (src->u.syment.n_sclass == C_NT_WEAK) | 4767 | 7 | dst->symbol.flags |= BSF_WEAK; | 4768 | | | 4769 | 167 | if (src->u.syment.n_sclass == C_SECTION | 4770 | 167 | && src->u.syment.n_scnum > 0) | 4771 | 0 | dst->symbol.flags = BSF_LOCAL; | 4772 | 167 | #endif | 4773 | 167 | if (src->u.syment.n_sclass == C_WEAKEXT | 4774 | | #ifdef RS6000COFF_C | 4775 | | || src->u.syment.n_sclass == C_AIX_WEAKEXT | 4776 | | #endif | 4777 | 167 | ) | 4778 | 19 | dst->symbol.flags |= BSF_WEAK; | 4779 | | | 4780 | 167 | break; | 4781 | | | 4782 | 46 | 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 | 104 | case C_LABEL: /* Label. */ | 4793 | 104 | if (src->u.syment.n_scnum == N_DEBUG) | 4794 | 0 | dst->symbol.flags = BSF_DEBUGGING; | 4795 | 104 | else | 4796 | 104 | 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 | 104 | if (dst->symbol.section) | 4801 | 104 | { | 4802 | 104 | #if defined COFF_WITH_PE | 4803 | | /* PE sets the symbol to a value relative to the | 4804 | | start of the section. */ | 4805 | 104 | 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 | 104 | } | 4811 | 0 | else | 4812 | 0 | dst->symbol.value = src->u.syment.n_value; | 4813 | 104 | break; | 4814 | | | 4815 | 3 | case C_FILE: /* File name. */ | 4816 | 3 | dst->symbol.flags = BSF_FILE; | 4817 | | /* Fall through. */ | 4818 | 4 | case C_MOS: /* Member of structure. */ | 4819 | 5 | case C_EOS: /* End of structure. */ | 4820 | 44 | case C_REGPARM: /* Register parameter. */ | 4821 | 170 | case C_REG: /* register variable. */ | 4822 | | /* C_AUTOARG conflicts with TI COFF C_UEXT. */ | 4823 | 176 | case C_TPDEF: /* Type definition. */ | 4824 | 216 | case C_ARG: | 4825 | 450 | case C_AUTO: /* Automatic variable. */ | 4826 | 451 | case C_FIELD: /* Bit field. */ | 4827 | 463 | case C_ENTAG: /* Enumeration tag. */ | 4828 | 479 | case C_MOE: /* Member of enumeration. */ | 4829 | 480 | case C_MOU: /* Member of union. */ | 4830 | 528 | case C_UNTAG: /* Union tag. */ | 4831 | 585 | 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 | 585 | dst->symbol.flags |= BSF_DEBUGGING; | 4849 | 585 | dst->symbol.value = (src->u.syment.n_value); | 4850 | 585 | 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 | 1 | case C_BLOCK: /* ".bb" or ".eb". */ | 4901 | 1 | case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */ | 4902 | 8 | case C_EFCN: /* Physical end of function. */ | 4903 | 8 | #if defined COFF_WITH_PE | 4904 | | /* PE sets the symbol to a value relative to the start | 4905 | | of the section. */ | 4906 | 8 | dst->symbol.value = src->u.syment.n_value; | 4907 | 8 | if (strcmp (dst->symbol.name, ".bf") != 0) | 4908 | 8 | { | 4909 | | /* PE uses funny values for .ef and .lf; don't | 4910 | | relocate them. */ | 4911 | 8 | dst->symbol.flags = BSF_DEBUGGING; | 4912 | 8 | } | 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 | 8 | break; | 4923 | | | 4924 | 5 | case C_STATLAB: /* Static load time label. */ | 4925 | 5 | dst->symbol.value = src->u.syment.n_value; | 4926 | 5 | dst->symbol.flags = BSF_GLOBAL; | 4927 | 5 | break; | 4928 | | | 4929 | 2.26k | case C_NULL: | 4930 | | /* PE DLLs sometimes have zeroed out symbols for some | 4931 | | reason. Just ignore them without a warning. */ | 4932 | 2.26k | if (src->u.syment.n_type == 0 | 4933 | 2.26k | && src->u.syment.n_value == 0 | 4934 | 2.26k | && src->u.syment.n_scnum == 0) | 4935 | 2.26k | 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 | 0 | case C_EXTDEF: /* External definition. */ | 4943 | 0 | case C_ULABEL: /* Undefined label. */ | 4944 | 0 | 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 | 0 | case C_EXTLAB: /* External load time label. */ | 4957 | 0 | default: | 4958 | 0 | _bfd_error_handler | 4959 | | /* xgettext:c-format */ | 4960 | 0 | (_("%pB: unrecognized storage class %d for %s symbol `%s'"), | 4961 | 0 | abfd, src->u.syment.n_sclass, | 4962 | 0 | dst->symbol.section->name, dst->symbol.name); | 4963 | 0 | ret = false; | 4964 | | /* Fall through. */ | 4965 | 2 | 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 | dst->symbol.flags = BSF_DEBUGGING; | 4969 | 2 | dst->symbol.value = (src->u.syment.n_value); | 4970 | 2 | break; | 4971 | 3.13k | } | 4972 | | | 4973 | 3.13k | dst->native = src; | 4974 | 3.13k | dst->symbol.udata.i = 0; | 4975 | 3.13k | dst->lineno = NULL; | 4976 | | | 4977 | 3.13k | this_index += (src->u.syment.n_numaux) + 1; | 4978 | 3.13k | dst++; | 4979 | 3.13k | number_of_symbols++; | 4980 | 3.13k | } | 4981 | 78 | } | 4982 | | | 4983 | 78 | obj_symbols (abfd) = cached_area; | 4984 | 78 | obj_raw_syments (abfd) = native_symbols; | 4985 | | | 4986 | 78 | abfd->symcount = number_of_symbols; | 4987 | 78 | obj_convert (abfd) = table_ptr; | 4988 | | /* Slurp the line tables for each section too. */ | 4989 | 78 | { | 4990 | 78 | asection *p; | 4991 | | | 4992 | 78 | p = abfd->sections; | 4993 | 683 | while (p) | 4994 | 605 | { | 4995 | 605 | if (! coff_slurp_line_table (abfd, p)) | 4996 | 0 | return false; | 4997 | 605 | p = p->next; | 4998 | 605 | } | 4999 | 78 | } | 5000 | | | 5001 | 78 | return ret; | 5002 | 78 | } |
pei-ia64.c:coff_slurp_symbol_table Line | Count | Source | 4630 | 190 | { | 4631 | 190 | combined_entry_type *native_symbols; | 4632 | 190 | coff_symbol_type *cached_area; | 4633 | 190 | unsigned int *table_ptr; | 4634 | 190 | unsigned int number_of_symbols = 0; | 4635 | 190 | bool ret = true; | 4636 | 190 | size_t amt; | 4637 | | | 4638 | 190 | if (obj_symbols (abfd)) | 4639 | 95 | return true; | 4640 | | | 4641 | | /* Read in the symbol table. */ | 4642 | 95 | if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) | 4643 | 0 | return false; | 4644 | | | 4645 | | /* Allocate enough room for all the symbols in cached form. */ | 4646 | 95 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4647 | 95 | sizeof (*cached_area), &amt)) | 4648 | 0 | { | 4649 | 0 | bfd_set_error (bfd_error_file_too_big); | 4650 | 0 | return false; | 4651 | 0 | } | 4652 | 95 | cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt); | 4653 | 95 | if (cached_area == NULL) | 4654 | 0 | return false; | 4655 | | | 4656 | 95 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4657 | 95 | sizeof (*table_ptr), &amt)) | 4658 | 0 | { | 4659 | 0 | bfd_set_error (bfd_error_file_too_big); | 4660 | 0 | return false; | 4661 | 0 | } | 4662 | 95 | table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); | 4663 | 95 | if (table_ptr == NULL) | 4664 | 0 | return false; | 4665 | 95 | else | 4666 | 95 | { | 4667 | 95 | coff_symbol_type *dst = cached_area; | 4668 | 95 | unsigned int last_native_index = obj_raw_syment_count (abfd); | 4669 | 95 | unsigned int this_index = 0; | 4670 | | | 4671 | 4.65k | while (this_index < last_native_index) | 4672 | 4.55k | { | 4673 | 4.55k | combined_entry_type *src = native_symbols + this_index; | 4674 | 4.55k | table_ptr[this_index] = number_of_symbols; | 4675 | | | 4676 | 4.55k | dst->symbol.the_bfd = abfd; | 4677 | 4.55k | BFD_ASSERT (src->is_sym); | 4678 | 4.55k | 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.55k | src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; | 4681 | 4.55k | dst->symbol.section = coff_section_from_bfd_index (abfd, | 4682 | 4.55k | src->u.syment.n_scnum); | 4683 | 4.55k | dst->symbol.flags = 0; | 4684 | | /* PR 17512: file: 079-7098-0.001:0.1. */ | 4685 | 4.55k | dst->symbol.value = 0; | 4686 | 4.55k | dst->done_lineno = false; | 4687 | | | 4688 | 4.55k | switch (src->u.syment.n_sclass) | 4689 | 4.55k | { | 4690 | 139 | case C_EXT: | 4691 | 157 | 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 | 157 | #ifdef C_SYSTEM | 4703 | 171 | case C_SYSTEM: /* System Wide variable. */ | 4704 | 171 | #endif | 4705 | 171 | #ifdef COFF_WITH_PE | 4706 | | /* In PE, 0x68 (104) denotes a section symbol. */ | 4707 | 173 | case C_SECTION: | 4708 | | /* In PE, 0x69 (105) denotes a weak external symbol. */ | 4709 | 208 | case C_NT_WEAK: | 4710 | 208 | #endif | 4711 | 208 | switch (coff_classify_symbol (abfd, &src->u.syment)) | 4712 | 208 | { | 4713 | 179 | case COFF_SYMBOL_GLOBAL: | 4714 | 179 | dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL; | 4715 | 179 | #if defined COFF_WITH_PE | 4716 | | /* PE sets the symbol to a value relative to the | 4717 | | start of the section. */ | 4718 | 179 | 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 | 179 | if (ISFCN ((src->u.syment.n_type))) | 4724 | | /* A function ext does not go at the end of a | 4725 | | file. */ | 4726 | 16 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4727 | 179 | break; | 4728 | | | 4729 | 16 | case COFF_SYMBOL_COMMON: | 4730 | 16 | dst->symbol.section = bfd_com_section_ptr; | 4731 | 16 | dst->symbol.value = src->u.syment.n_value; | 4732 | 16 | 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 | 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 | 208 | } | 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 | 208 | #ifdef COFF_WITH_PE | 4766 | 208 | if (src->u.syment.n_sclass == C_NT_WEAK) | 4767 | 35 | dst->symbol.flags |= BSF_WEAK; | 4768 | | | 4769 | 208 | if (src->u.syment.n_sclass == C_SECTION | 4770 | 208 | && src->u.syment.n_scnum > 0) | 4771 | 0 | dst->symbol.flags = BSF_LOCAL; | 4772 | 208 | #endif | 4773 | 208 | if (src->u.syment.n_sclass == C_WEAKEXT | 4774 | | #ifdef RS6000COFF_C | 4775 | | || src->u.syment.n_sclass == C_AIX_WEAKEXT | 4776 | | #endif | 4777 | 208 | ) | 4778 | 18 | dst->symbol.flags |= BSF_WEAK; | 4779 | | | 4780 | 208 | break; | 4781 | | | 4782 | 235 | 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 | 307 | case C_LABEL: /* Label. */ | 4793 | 307 | if (src->u.syment.n_scnum == N_DEBUG) | 4794 | 0 | dst->symbol.flags = BSF_DEBUGGING; | 4795 | 307 | else | 4796 | 307 | 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 | 307 | if (dst->symbol.section) | 4801 | 307 | { | 4802 | 307 | #if defined COFF_WITH_PE | 4803 | | /* PE sets the symbol to a value relative to the | 4804 | | start of the section. */ | 4805 | 307 | 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 | 307 | } | 4811 | 0 | else | 4812 | 0 | dst->symbol.value = src->u.syment.n_value; | 4813 | 307 | break; | 4814 | | | 4815 | 36 | case C_FILE: /* File name. */ | 4816 | 36 | dst->symbol.flags = BSF_FILE; | 4817 | | /* Fall through. */ | 4818 | 46 | case C_MOS: /* Member of structure. */ | 4819 | 50 | case C_EOS: /* End of structure. */ | 4820 | 136 | case C_REGPARM: /* Register parameter. */ | 4821 | 211 | case C_REG: /* register variable. */ | 4822 | | /* C_AUTOARG conflicts with TI COFF C_UEXT. */ | 4823 | 212 | case C_TPDEF: /* Type definition. */ | 4824 | 212 | case C_ARG: | 4825 | 569 | case C_AUTO: /* Automatic variable. */ | 4826 | 631 | case C_FIELD: /* Bit field. */ | 4827 | 647 | case C_ENTAG: /* Enumeration tag. */ | 4828 | 656 | case C_MOE: /* Member of enumeration. */ | 4829 | 698 | case C_MOU: /* Member of union. */ | 4830 | 889 | case C_UNTAG: /* Union tag. */ | 4831 | 943 | 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 | 943 | dst->symbol.flags |= BSF_DEBUGGING; | 4849 | 943 | dst->symbol.value = (src->u.syment.n_value); | 4850 | 943 | 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 | 1 | case C_BLOCK: /* ".bb" or ".eb". */ | 4901 | 10 | case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */ | 4902 | 14 | case C_EFCN: /* Physical end of function. */ | 4903 | 14 | #if defined COFF_WITH_PE | 4904 | | /* PE sets the symbol to a value relative to the start | 4905 | | of the section. */ | 4906 | 14 | dst->symbol.value = src->u.syment.n_value; | 4907 | 14 | if (strcmp (dst->symbol.name, ".bf") != 0) | 4908 | 14 | { | 4909 | | /* PE uses funny values for .ef and .lf; don't | 4910 | | relocate them. */ | 4911 | 14 | dst->symbol.flags = BSF_DEBUGGING; | 4912 | 14 | } | 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 | 14 | 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 | 3.01k | case C_NULL: | 4930 | | /* PE DLLs sometimes have zeroed out symbols for some | 4931 | | reason. Just ignore them without a warning. */ | 4932 | 3.01k | if (src->u.syment.n_type == 0 | 4933 | 3.01k | && src->u.syment.n_value == 0 | 4934 | 3.01k | && src->u.syment.n_scnum == 0) | 4935 | 3.01k | 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 | 0 | case C_EXTDEF: /* External definition. */ | 4943 | 0 | case C_ULABEL: /* Undefined label. */ | 4944 | 0 | 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 | 0 | case C_EXTLAB: /* External load time label. */ | 4957 | 0 | default: | 4958 | 0 | _bfd_error_handler | 4959 | | /* xgettext:c-format */ | 4960 | 0 | (_("%pB: unrecognized storage class %d for %s symbol `%s'"), | 4961 | 0 | abfd, src->u.syment.n_sclass, | 4962 | 0 | dst->symbol.section->name, dst->symbol.name); | 4963 | 0 | ret = false; | 4964 | | /* Fall through. */ | 4965 | 11 | 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 | 11 | dst->symbol.flags = BSF_DEBUGGING; | 4969 | 11 | dst->symbol.value = (src->u.syment.n_value); | 4970 | 11 | break; | 4971 | 4.55k | } | 4972 | | | 4973 | 4.55k | dst->native = src; | 4974 | 4.55k | dst->symbol.udata.i = 0; | 4975 | 4.55k | dst->lineno = NULL; | 4976 | | | 4977 | 4.55k | this_index += (src->u.syment.n_numaux) + 1; | 4978 | 4.55k | dst++; | 4979 | 4.55k | number_of_symbols++; | 4980 | 4.55k | } | 4981 | 95 | } | 4982 | | | 4983 | 95 | obj_symbols (abfd) = cached_area; | 4984 | 95 | obj_raw_syments (abfd) = native_symbols; | 4985 | | | 4986 | 95 | abfd->symcount = number_of_symbols; | 4987 | 95 | obj_convert (abfd) = table_ptr; | 4988 | | /* Slurp the line tables for each section too. */ | 4989 | 95 | { | 4990 | 95 | asection *p; | 4991 | | | 4992 | 95 | p = abfd->sections; | 4993 | 199 | while (p) | 4994 | 104 | { | 4995 | 104 | if (! coff_slurp_line_table (abfd, p)) | 4996 | 0 | return false; | 4997 | 104 | p = p->next; | 4998 | 104 | } | 4999 | 95 | } | 5000 | | | 5001 | 95 | return ret; | 5002 | 95 | } |
pei-loongarch64.c:coff_slurp_symbol_table Line | Count | Source | 4630 | 102 | { | 4631 | 102 | combined_entry_type *native_symbols; | 4632 | 102 | coff_symbol_type *cached_area; | 4633 | 102 | unsigned int *table_ptr; | 4634 | 102 | unsigned int number_of_symbols = 0; | 4635 | 102 | bool ret = true; | 4636 | 102 | size_t amt; | 4637 | | | 4638 | 102 | if (obj_symbols (abfd)) | 4639 | 51 | return true; | 4640 | | | 4641 | | /* Read in the symbol table. */ | 4642 | 51 | if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) | 4643 | 0 | return false; | 4644 | | | 4645 | | /* Allocate enough room for all the symbols in cached form. */ | 4646 | 51 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4647 | 51 | sizeof (*cached_area), &amt)) | 4648 | 0 | { | 4649 | 0 | bfd_set_error (bfd_error_file_too_big); | 4650 | 0 | return false; | 4651 | 0 | } | 4652 | 51 | cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt); | 4653 | 51 | if (cached_area == NULL) | 4654 | 0 | return false; | 4655 | | | 4656 | 51 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4657 | 51 | sizeof (*table_ptr), &amt)) | 4658 | 0 | { | 4659 | 0 | bfd_set_error (bfd_error_file_too_big); | 4660 | 0 | return false; | 4661 | 0 | } | 4662 | 51 | table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); | 4663 | 51 | if (table_ptr == NULL) | 4664 | 0 | return false; | 4665 | 51 | else | 4666 | 51 | { | 4667 | 51 | coff_symbol_type *dst = cached_area; | 4668 | 51 | unsigned int last_native_index = obj_raw_syment_count (abfd); | 4669 | 51 | unsigned int this_index = 0; | 4670 | | | 4671 | 1.04k | while (this_index < last_native_index) | 4672 | 997 | { | 4673 | 997 | combined_entry_type *src = native_symbols + this_index; | 4674 | 997 | table_ptr[this_index] = number_of_symbols; | 4675 | | | 4676 | 997 | dst->symbol.the_bfd = abfd; | 4677 | 997 | BFD_ASSERT (src->is_sym); | 4678 | 997 | 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 | 997 | src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; | 4681 | 997 | dst->symbol.section = coff_section_from_bfd_index (abfd, | 4682 | 997 | src->u.syment.n_scnum); | 4683 | 997 | dst->symbol.flags = 0; | 4684 | | /* PR 17512: file: 079-7098-0.001:0.1. */ | 4685 | 997 | dst->symbol.value = 0; | 4686 | 997 | dst->done_lineno = false; | 4687 | | | 4688 | 997 | switch (src->u.syment.n_sclass) | 4689 | 997 | { | 4690 | 82 | case C_EXT: | 4691 | 100 | 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 | 100 | #ifdef C_SYSTEM | 4703 | 100 | case C_SYSTEM: /* System Wide variable. */ | 4704 | 100 | #endif | 4705 | 100 | #ifdef COFF_WITH_PE | 4706 | | /* In PE, 0x68 (104) denotes a section symbol. */ | 4707 | 105 | case C_SECTION: | 4708 | | /* In PE, 0x69 (105) denotes a weak external symbol. */ | 4709 | 105 | case C_NT_WEAK: | 4710 | 105 | #endif | 4711 | 105 | switch (coff_classify_symbol (abfd, &src->u.syment)) | 4712 | 105 | { | 4713 | 73 | case COFF_SYMBOL_GLOBAL: | 4714 | 73 | dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL; | 4715 | 73 | #if defined COFF_WITH_PE | 4716 | | /* PE sets the symbol to a value relative to the | 4717 | | start of the section. */ | 4718 | 73 | 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 | 73 | if (ISFCN ((src->u.syment.n_type))) | 4724 | | /* A function ext does not go at the end of a | 4725 | | file. */ | 4726 | 5 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4727 | 73 | break; | 4728 | | | 4729 | 13 | case COFF_SYMBOL_COMMON: | 4730 | 13 | dst->symbol.section = bfd_com_section_ptr; | 4731 | 13 | dst->symbol.value = src->u.syment.n_value; | 4732 | 13 | break; | 4733 | | | 4734 | 19 | case COFF_SYMBOL_UNDEFINED: | 4735 | 19 | dst->symbol.section = bfd_und_section_ptr; | 4736 | 19 | dst->symbol.value = 0; | 4737 | 19 | 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 | 105 | } | 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 | 105 | #ifdef COFF_WITH_PE | 4766 | 105 | if (src->u.syment.n_sclass == C_NT_WEAK) | 4767 | 0 | dst->symbol.flags |= BSF_WEAK; | 4768 | | | 4769 | 105 | if (src->u.syment.n_sclass == C_SECTION | 4770 | 105 | && src->u.syment.n_scnum > 0) | 4771 | 0 | dst->symbol.flags = BSF_LOCAL; | 4772 | 105 | #endif | 4773 | 105 | if (src->u.syment.n_sclass == C_WEAKEXT | 4774 | | #ifdef RS6000COFF_C | 4775 | | || src->u.syment.n_sclass == C_AIX_WEAKEXT | 4776 | | #endif | 4777 | 105 | ) | 4778 | 18 | dst->symbol.flags |= BSF_WEAK; | 4779 | | | 4780 | 105 | break; | 4781 | | | 4782 | 111 | 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 | 129 | case C_LABEL: /* Label. */ | 4793 | 129 | if (src->u.syment.n_scnum == N_DEBUG) | 4794 | 0 | dst->symbol.flags = BSF_DEBUGGING; | 4795 | 129 | else | 4796 | 129 | 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 | 129 | if (dst->symbol.section) | 4801 | 129 | { | 4802 | 129 | #if defined COFF_WITH_PE | 4803 | | /* PE sets the symbol to a value relative to the | 4804 | | start of the section. */ | 4805 | 129 | 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 | 129 | } | 4811 | 0 | else | 4812 | 0 | dst->symbol.value = src->u.syment.n_value; | 4813 | 129 | break; | 4814 | | | 4815 | 23 | case C_FILE: /* File name. */ | 4816 | 23 | dst->symbol.flags = BSF_FILE; | 4817 | | /* Fall through. */ | 4818 | 24 | case C_MOS: /* Member of structure. */ | 4819 | 24 | case C_EOS: /* End of structure. */ | 4820 | 25 | case C_REGPARM: /* Register parameter. */ | 4821 | 30 | case C_REG: /* register variable. */ | 4822 | | /* C_AUTOARG conflicts with TI COFF C_UEXT. */ | 4823 | 49 | case C_TPDEF: /* Type definition. */ | 4824 | 52 | case C_ARG: | 4825 | 202 | case C_AUTO: /* Automatic variable. */ | 4826 | 209 | case C_FIELD: /* Bit field. */ | 4827 | 219 | case C_ENTAG: /* Enumeration tag. */ | 4828 | 234 | case C_MOE: /* Member of enumeration. */ | 4829 | 237 | case C_MOU: /* Member of union. */ | 4830 | 241 | case C_UNTAG: /* Union tag. */ | 4831 | 253 | 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 | 253 | dst->symbol.flags |= BSF_DEBUGGING; | 4849 | 253 | dst->symbol.value = (src->u.syment.n_value); | 4850 | 253 | 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 | 15 | case C_BLOCK: /* ".bb" or ".eb". */ | 4901 | 17 | case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */ | 4902 | 79 | case C_EFCN: /* Physical end of function. */ | 4903 | 79 | #if defined COFF_WITH_PE | 4904 | | /* PE sets the symbol to a value relative to the start | 4905 | | of the section. */ | 4906 | 79 | dst->symbol.value = src->u.syment.n_value; | 4907 | 79 | if (strcmp (dst->symbol.name, ".bf") != 0) | 4908 | 79 | { | 4909 | | /* PE uses funny values for .ef and .lf; don't | 4910 | | relocate them. */ | 4911 | 79 | dst->symbol.flags = BSF_DEBUGGING; | 4912 | 79 | } | 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 | 79 | 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 | 408 | case C_NULL: | 4930 | | /* PE DLLs sometimes have zeroed out symbols for some | 4931 | | reason. Just ignore them without a warning. */ | 4932 | 408 | if (src->u.syment.n_type == 0 | 4933 | 408 | && src->u.syment.n_value == 0 | 4934 | 408 | && src->u.syment.n_scnum == 0) | 4935 | 408 | 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 | 0 | case C_EXTDEF: /* External definition. */ | 4943 | 0 | case C_ULABEL: /* Undefined label. */ | 4944 | 0 | 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 | 0 | case C_EXTLAB: /* External load time label. */ | 4957 | 0 | default: | 4958 | 0 | _bfd_error_handler | 4959 | | /* xgettext:c-format */ | 4960 | 0 | (_("%pB: unrecognized storage class %d for %s symbol `%s'"), | 4961 | 0 | abfd, src->u.syment.n_sclass, | 4962 | 0 | dst->symbol.section->name, dst->symbol.name); | 4963 | 0 | ret = false; | 4964 | | /* Fall through. */ | 4965 | 6 | 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 | 6 | dst->symbol.flags = BSF_DEBUGGING; | 4969 | 6 | dst->symbol.value = (src->u.syment.n_value); | 4970 | 6 | break; | 4971 | 997 | } | 4972 | | | 4973 | 997 | dst->native = src; | 4974 | 997 | dst->symbol.udata.i = 0; | 4975 | 997 | dst->lineno = NULL; | 4976 | | | 4977 | 997 | this_index += (src->u.syment.n_numaux) + 1; | 4978 | 997 | dst++; | 4979 | 997 | number_of_symbols++; | 4980 | 997 | } | 4981 | 51 | } | 4982 | | | 4983 | 51 | obj_symbols (abfd) = cached_area; | 4984 | 51 | obj_raw_syments (abfd) = native_symbols; | 4985 | | | 4986 | 51 | abfd->symcount = number_of_symbols; | 4987 | 51 | obj_convert (abfd) = table_ptr; | 4988 | | /* Slurp the line tables for each section too. */ | 4989 | 51 | { | 4990 | 51 | asection *p; | 4991 | | | 4992 | 51 | p = abfd->sections; | 4993 | 336 | while (p) | 4994 | 285 | { | 4995 | 285 | if (! coff_slurp_line_table (abfd, p)) | 4996 | 0 | return false; | 4997 | 285 | p = p->next; | 4998 | 285 | } | 4999 | 51 | } | 5000 | | | 5001 | 51 | return ret; | 5002 | 51 | } |
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 | 244 | { | 4631 | 244 | combined_entry_type *native_symbols; | 4632 | 244 | coff_symbol_type *cached_area; | 4633 | 244 | unsigned int *table_ptr; | 4634 | 244 | unsigned int number_of_symbols = 0; | 4635 | 244 | bool ret = true; | 4636 | 244 | size_t amt; | 4637 | | | 4638 | 244 | if (obj_symbols (abfd)) | 4639 | 122 | return true; | 4640 | | | 4641 | | /* Read in the symbol table. */ | 4642 | 122 | if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) | 4643 | 0 | return false; | 4644 | | | 4645 | | /* Allocate enough room for all the symbols in cached form. */ | 4646 | 122 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4647 | 122 | sizeof (*cached_area), &amt)) | 4648 | 0 | { | 4649 | 0 | bfd_set_error (bfd_error_file_too_big); | 4650 | 0 | return false; | 4651 | 0 | } | 4652 | 122 | cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt); | 4653 | 122 | if (cached_area == NULL) | 4654 | 0 | return false; | 4655 | | | 4656 | 122 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4657 | 122 | sizeof (*table_ptr), &amt)) | 4658 | 0 | { | 4659 | 0 | bfd_set_error (bfd_error_file_too_big); | 4660 | 0 | return false; | 4661 | 0 | } | 4662 | 122 | table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); | 4663 | 122 | if (table_ptr == NULL) | 4664 | 0 | return false; | 4665 | 122 | else | 4666 | 122 | { | 4667 | 122 | coff_symbol_type *dst = cached_area; | 4668 | 122 | unsigned int last_native_index = obj_raw_syment_count (abfd); | 4669 | 122 | unsigned int this_index = 0; | 4670 | | | 4671 | 4.63k | while (this_index < last_native_index) | 4672 | 4.51k | { | 4673 | 4.51k | combined_entry_type *src = native_symbols + this_index; | 4674 | 4.51k | table_ptr[this_index] = number_of_symbols; | 4675 | | | 4676 | 4.51k | dst->symbol.the_bfd = abfd; | 4677 | 4.51k | BFD_ASSERT (src->is_sym); | 4678 | 4.51k | 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.51k | src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; | 4681 | 4.51k | dst->symbol.section = coff_section_from_bfd_index (abfd, | 4682 | 4.51k | src->u.syment.n_scnum); | 4683 | 4.51k | dst->symbol.flags = 0; | 4684 | | /* PR 17512: file: 079-7098-0.001:0.1. */ | 4685 | 4.51k | dst->symbol.value = 0; | 4686 | 4.51k | dst->done_lineno = false; | 4687 | | | 4688 | 4.51k | switch (src->u.syment.n_sclass) | 4689 | 4.51k | { | 4690 | 1.04k | case C_EXT: | 4691 | 1.04k | case C_WEAKEXT: | 4692 | | #if defined ARM | 4693 | | case C_THUMBEXT: | 4694 | | case C_THUMBEXTFUNC: | 4695 | | #endif | 4696 | 1.04k | #ifdef RS6000COFF_C | 4697 | 1.05k | case C_HIDEXT: | 4698 | 1.05k | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 4699 | 1.06k | case C_AIX_WEAKEXT: | 4700 | 1.06k | #endif | 4701 | 1.06k | #endif | 4702 | 1.06k | #ifdef C_SYSTEM | 4703 | 1.09k | case C_SYSTEM: /* System Wide variable. */ | 4704 | 1.09k | #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 | 1.09k | switch (coff_classify_symbol (abfd, &src->u.syment)) | 4712 | 1.09k | { | 4713 | 1.05k | case COFF_SYMBOL_GLOBAL: | 4714 | 1.05k | 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 | 1.05k | dst->symbol.value = (src->u.syment.n_value | 4721 | 1.05k | - dst->symbol.section->vma); | 4722 | 1.05k | #endif | 4723 | 1.05k | 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 | 1.05k | 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 | 7 | case COFF_SYMBOL_UNDEFINED: | 4735 | 7 | dst->symbol.section = bfd_und_section_ptr; | 4736 | 7 | dst->symbol.value = 0; | 4737 | 7 | 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 | 5 | case COFF_SYMBOL_LOCAL: | 4745 | 5 | 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 | 5 | dst->symbol.value = (src->u.syment.n_value | 4752 | 5 | - dst->symbol.section->vma); | 4753 | 5 | #endif | 4754 | 5 | if (ISFCN ((src->u.syment.n_type))) | 4755 | 4 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4756 | 5 | break; | 4757 | 1.09k | } | 4758 | | | 4759 | 1.09k | #ifdef RS6000COFF_C | 4760 | | /* A symbol with a csect entry should not go at the end. */ | 4761 | 1.09k | if (src->u.syment.n_numaux > 0) | 4762 | 1.08k | dst->symbol.flags |= BSF_NOT_AT_END; | 4763 | 1.09k | #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 | 1.09k | if (src->u.syment.n_sclass == C_WEAKEXT | 4774 | 1.09k | #ifdef RS6000COFF_C | 4775 | 1.09k | || src->u.syment.n_sclass == C_AIX_WEAKEXT | 4776 | 1.09k | #endif | 4777 | 1.09k | ) | 4778 | 12 | dst->symbol.flags |= BSF_WEAK; | 4779 | | | 4780 | 1.09k | break; | 4781 | | | 4782 | 162 | 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 | 162 | #ifdef RS6000COFF_C | 4789 | 170 | case C_DWARF: /* A label in a dwarf section. */ | 4790 | 174 | case C_INFO: /* A label in a comment section. */ | 4791 | 174 | #endif | 4792 | 243 | case C_LABEL: /* Label. */ | 4793 | 243 | if (src->u.syment.n_scnum == N_DEBUG) | 4794 | 0 | dst->symbol.flags = BSF_DEBUGGING; | 4795 | 243 | else | 4796 | 243 | 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 | 243 | if (dst->symbol.section) | 4801 | 243 | { | 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 | 243 | dst->symbol.value = (src->u.syment.n_value | 4808 | 243 | - dst->symbol.section->vma); | 4809 | 243 | #endif | 4810 | 243 | } | 4811 | 0 | else | 4812 | 0 | dst->symbol.value = src->u.syment.n_value; | 4813 | 243 | break; | 4814 | | | 4815 | 21 | case C_FILE: /* File name. */ | 4816 | 21 | dst->symbol.flags = BSF_FILE; | 4817 | | /* Fall through. */ | 4818 | 102 | case C_MOS: /* Member of structure. */ | 4819 | 103 | case C_EOS: /* End of structure. */ | 4820 | 104 | case C_REGPARM: /* Register parameter. */ | 4821 | 207 | case C_REG: /* register variable. */ | 4822 | | /* C_AUTOARG conflicts with TI COFF C_UEXT. */ | 4823 | 243 | case C_TPDEF: /* Type definition. */ | 4824 | 245 | case C_ARG: | 4825 | 283 | case C_AUTO: /* Automatic variable. */ | 4826 | 297 | case C_FIELD: /* Bit field. */ | 4827 | 303 | case C_ENTAG: /* Enumeration tag. */ | 4828 | 316 | case C_MOE: /* Member of enumeration. */ | 4829 | 319 | case C_MOU: /* Member of union. */ | 4830 | 340 | case C_UNTAG: /* Union tag. */ | 4831 | 354 | case C_STRTAG: /* Structure tag. */ | 4832 | 354 | #ifdef RS6000COFF_C | 4833 | 355 | case C_GSYM: | 4834 | 356 | case C_LSYM: | 4835 | 357 | case C_PSYM: | 4836 | 358 | case C_RSYM: | 4837 | 359 | case C_RPSYM: | 4838 | 360 | case C_STSYM: | 4839 | 361 | case C_TCSYM: | 4840 | 362 | case C_BCOMM: | 4841 | 363 | case C_ECOML: | 4842 | 364 | case C_ECOMM: | 4843 | 365 | case C_DECL: | 4844 | 365 | case C_ENTRY: | 4845 | 366 | case C_FUN: | 4846 | 367 | case C_ESTAT: | 4847 | 367 | #endif | 4848 | 367 | dst->symbol.flags |= BSF_DEBUGGING; | 4849 | 367 | dst->symbol.value = (src->u.syment.n_value); | 4850 | 367 | break; | 4851 | | | 4852 | 0 | #ifdef RS6000COFF_C | 4853 | 4 | case C_BINCL: /* Beginning of include file. */ | 4854 | 31 | 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 | 31 | { | 4860 | 31 | asection *sec; | 4861 | | | 4862 | 31 | dst->symbol.flags = BSF_DEBUGGING; | 4863 | 1.30k | for (sec = abfd->sections; sec != NULL; sec = sec->next) | 4864 | 1.27k | if (sec->line_filepos <= (file_ptr) src->u.syment.n_value | 4865 | 1.27k | && ((file_ptr) (sec->line_filepos | 4866 | 890 | + sec->lineno_count * bfd_coff_linesz (abfd)) | 4867 | 890 | > (file_ptr) src->u.syment.n_value)) | 4868 | 1 | break; | 4869 | 31 | if (sec == NULL) | 4870 | 30 | dst->symbol.value = 0; | 4871 | 1 | else | 4872 | 1 | { | 4873 | 1 | dst->symbol.section = sec; | 4874 | 1 | dst->symbol.value = ((src->u.syment.n_value | 4875 | 1 | - sec->line_filepos) | 4876 | 1 | / bfd_coff_linesz (abfd)); | 4877 | 1 | src->fix_line = 1; | 4878 | 1 | } | 4879 | 31 | } | 4880 | 31 | break; | 4881 | | | 4882 | 2 | case C_BSTAT: | 4883 | 2 | dst->symbol.flags = BSF_DEBUGGING; | 4884 | | | 4885 | 2 | if (src->u.syment.n_value >= obj_raw_syment_count (abfd)) | 4886 | 1 | dst->symbol.value = 0; | 4887 | 1 | else | 4888 | 1 | { | 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 | 1 | src->u.syment.n_value | 4893 | 1 | = (uintptr_t) (native_symbols + src->u.syment.n_value); | 4894 | 1 | dst->symbol.value = src->u.syment.n_value; | 4895 | 1 | src->fix_value = 1; | 4896 | 1 | } | 4897 | 2 | break; | 4898 | 0 | #endif | 4899 | | | 4900 | 5 | case C_BLOCK: /* ".bb" or ".eb". */ | 4901 | 9 | case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */ | 4902 | 17 | 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 | 17 | dst->symbol.flags = BSF_LOCAL; | 4919 | 17 | dst->symbol.value = (src->u.syment.n_value | 4920 | 17 | - dst->symbol.section->vma); | 4921 | 17 | #endif | 4922 | 17 | break; | 4923 | | | 4924 | 16 | case C_STATLAB: /* Static load time label. */ | 4925 | 16 | dst->symbol.value = src->u.syment.n_value; | 4926 | 16 | dst->symbol.flags = BSF_GLOBAL; | 4927 | 16 | break; | 4928 | | | 4929 | 2.73k | case C_NULL: | 4930 | | /* PE DLLs sometimes have zeroed out symbols for some | 4931 | | reason. Just ignore them without a warning. */ | 4932 | 2.73k | if (src->u.syment.n_type == 0 | 4933 | 2.73k | && src->u.syment.n_value == 0 | 4934 | 2.73k | && src->u.syment.n_scnum == 0) | 4935 | 2.73k | break; | 4936 | 1 | #ifdef RS6000COFF_C | 4937 | | /* XCOFF specific: deleted entry. */ | 4938 | 1 | if (src->u.syment.n_value == C_NULL_VALUE) | 4939 | 1 | break; | 4940 | 0 | #endif | 4941 | | /* Fall through. */ | 4942 | 0 | case C_EXTDEF: /* External definition. */ | 4943 | 0 | case C_ULABEL: /* Undefined label. */ | 4944 | 0 | case C_USTATIC: /* Undefined static. */ | 4945 | 0 | #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 | 0 | case C_LINE: /* line # reformatted as symbol table entry. */ | 4949 | | /* NT uses 0x67 for a weak symbol, not C_ALIAS. */ | 4950 | 0 | case C_ALIAS: /* Duplicate tag. */ | 4951 | 0 | #endif | 4952 | | /* New storage classes for TI COFF. */ | 4953 | | #ifdef TICOFF | 4954 | | case C_UEXT: /* Tentative external definition. */ | 4955 | | #endif | 4956 | 0 | case C_EXTLAB: /* External load time label. */ | 4957 | 0 | default: | 4958 | 0 | _bfd_error_handler | 4959 | | /* xgettext:c-format */ | 4960 | 0 | (_("%pB: unrecognized storage class %d for %s symbol `%s'"), | 4961 | 0 | abfd, src->u.syment.n_sclass, | 4962 | 0 | dst->symbol.section->name, dst->symbol.name); | 4963 | 0 | ret = false; | 4964 | | /* Fall through. */ | 4965 | 8 | 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 | 8 | dst->symbol.flags = BSF_DEBUGGING; | 4969 | 8 | dst->symbol.value = (src->u.syment.n_value); | 4970 | 8 | break; | 4971 | 4.51k | } | 4972 | | | 4973 | 4.51k | dst->native = src; | 4974 | 4.51k | dst->symbol.udata.i = 0; | 4975 | 4.51k | dst->lineno = NULL; | 4976 | | | 4977 | 4.51k | this_index += (src->u.syment.n_numaux) + 1; | 4978 | 4.51k | dst++; | 4979 | 4.51k | number_of_symbols++; | 4980 | 4.51k | } | 4981 | 122 | } | 4982 | | | 4983 | 122 | obj_symbols (abfd) = cached_area; | 4984 | 122 | obj_raw_syments (abfd) = native_symbols; | 4985 | | | 4986 | 122 | abfd->symcount = number_of_symbols; | 4987 | 122 | obj_convert (abfd) = table_ptr; | 4988 | | /* Slurp the line tables for each section too. */ | 4989 | 122 | { | 4990 | 122 | asection *p; | 4991 | | | 4992 | 122 | p = abfd->sections; | 4993 | 9.41k | while (p) | 4994 | 9.28k | { | 4995 | 9.28k | if (! coff_slurp_line_table (abfd, p)) | 4996 | 0 | return false; | 4997 | 9.28k | p = p->next; | 4998 | 9.28k | } | 4999 | 122 | } | 5000 | | | 5001 | 122 | return ret; | 5002 | 122 | } |
coff-sh.c:coff_slurp_symbol_table Line | Count | Source | 4630 | 188 | { | 4631 | 188 | combined_entry_type *native_symbols; | 4632 | 188 | coff_symbol_type *cached_area; | 4633 | 188 | unsigned int *table_ptr; | 4634 | 188 | unsigned int number_of_symbols = 0; | 4635 | 188 | bool ret = true; | 4636 | 188 | size_t amt; | 4637 | | | 4638 | 188 | if (obj_symbols (abfd)) | 4639 | 94 | return true; | 4640 | | | 4641 | | /* Read in the symbol table. */ | 4642 | 94 | if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) | 4643 | 0 | return false; | 4644 | | | 4645 | | /* Allocate enough room for all the symbols in cached form. */ | 4646 | 94 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4647 | 94 | sizeof (*cached_area), &amt)) | 4648 | 0 | { | 4649 | 0 | bfd_set_error (bfd_error_file_too_big); | 4650 | 0 | return false; | 4651 | 0 | } | 4652 | 94 | cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt); | 4653 | 94 | if (cached_area == NULL) | 4654 | 0 | return false; | 4655 | | | 4656 | 94 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4657 | 94 | sizeof (*table_ptr), &amt)) | 4658 | 0 | { | 4659 | 0 | bfd_set_error (bfd_error_file_too_big); | 4660 | 0 | return false; | 4661 | 0 | } | 4662 | 94 | table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); | 4663 | 94 | if (table_ptr == NULL) | 4664 | 0 | return false; | 4665 | 94 | else | 4666 | 94 | { | 4667 | 94 | coff_symbol_type *dst = cached_area; | 4668 | 94 | unsigned int last_native_index = obj_raw_syment_count (abfd); | 4669 | 94 | unsigned int this_index = 0; | 4670 | | | 4671 | 3.78k | while (this_index < last_native_index) | 4672 | 3.69k | { | 4673 | 3.69k | combined_entry_type *src = native_symbols + this_index; | 4674 | 3.69k | table_ptr[this_index] = number_of_symbols; | 4675 | | | 4676 | 3.69k | dst->symbol.the_bfd = abfd; | 4677 | 3.69k | BFD_ASSERT (src->is_sym); | 4678 | 3.69k | 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 | 3.69k | src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; | 4681 | 3.69k | dst->symbol.section = coff_section_from_bfd_index (abfd, | 4682 | 3.69k | src->u.syment.n_scnum); | 4683 | 3.69k | dst->symbol.flags = 0; | 4684 | | /* PR 17512: file: 079-7098-0.001:0.1. */ | 4685 | 3.69k | dst->symbol.value = 0; | 4686 | 3.69k | dst->done_lineno = false; | 4687 | | | 4688 | 3.69k | switch (src->u.syment.n_sclass) | 4689 | 3.69k | { | 4690 | 74 | case C_EXT: | 4691 | 130 | 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 | 130 | #ifdef C_SYSTEM | 4703 | 158 | case C_SYSTEM: /* System Wide variable. */ | 4704 | 158 | #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 | 158 | switch (coff_classify_symbol (abfd, &src->u.syment)) | 4712 | 158 | { | 4713 | 84 | case COFF_SYMBOL_GLOBAL: | 4714 | 84 | 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 | 84 | dst->symbol.value = (src->u.syment.n_value | 4721 | 84 | - dst->symbol.section->vma); | 4722 | 84 | #endif | 4723 | 84 | if (ISFCN ((src->u.syment.n_type))) | 4724 | | /* A function ext does not go at the end of a | 4725 | | file. */ | 4726 | 5 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4727 | 84 | break; | 4728 | | | 4729 | 4 | case COFF_SYMBOL_COMMON: | 4730 | 4 | dst->symbol.section = bfd_com_section_ptr; | 4731 | 4 | dst->symbol.value = src->u.syment.n_value; | 4732 | 4 | break; | 4733 | | | 4734 | 70 | case COFF_SYMBOL_UNDEFINED: | 4735 | 70 | dst->symbol.section = bfd_und_section_ptr; | 4736 | 70 | dst->symbol.value = 0; | 4737 | 70 | 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 | 158 | } | 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 | 158 | if (src->u.syment.n_sclass == C_WEAKEXT | 4774 | | #ifdef RS6000COFF_C | 4775 | | || src->u.syment.n_sclass == C_AIX_WEAKEXT | 4776 | | #endif | 4777 | 158 | ) | 4778 | 56 | dst->symbol.flags |= BSF_WEAK; | 4779 | | | 4780 | 158 | break; | 4781 | | | 4782 | 79 | 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 | 95 | case C_LABEL: /* Label. */ | 4793 | 95 | if (src->u.syment.n_scnum == N_DEBUG) | 4794 | 0 | dst->symbol.flags = BSF_DEBUGGING; | 4795 | 95 | else | 4796 | 95 | 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 | 95 | if (dst->symbol.section) | 4801 | 95 | { | 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 | 95 | dst->symbol.value = (src->u.syment.n_value | 4808 | 95 | - dst->symbol.section->vma); | 4809 | 95 | #endif | 4810 | 95 | } | 4811 | 0 | else | 4812 | 0 | dst->symbol.value = src->u.syment.n_value; | 4813 | 95 | break; | 4814 | | | 4815 | 23 | case C_FILE: /* File name. */ | 4816 | 23 | dst->symbol.flags = BSF_FILE; | 4817 | | /* Fall through. */ | 4818 | 24 | case C_MOS: /* Member of structure. */ | 4819 | 27 | case C_EOS: /* End of structure. */ | 4820 | 31 | case C_REGPARM: /* Register parameter. */ | 4821 | 50 | case C_REG: /* register variable. */ | 4822 | | /* C_AUTOARG conflicts with TI COFF C_UEXT. */ | 4823 | 139 | case C_TPDEF: /* Type definition. */ | 4824 | 159 | case C_ARG: | 4825 | 248 | case C_AUTO: /* Automatic variable. */ | 4826 | 254 | case C_FIELD: /* Bit field. */ | 4827 | 262 | case C_ENTAG: /* Enumeration tag. */ | 4828 | 269 | case C_MOE: /* Member of enumeration. */ | 4829 | 271 | case C_MOU: /* Member of union. */ | 4830 | 287 | case C_UNTAG: /* Union tag. */ | 4831 | 307 | 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 | 307 | dst->symbol.flags |= BSF_DEBUGGING; | 4849 | 307 | dst->symbol.value = (src->u.syment.n_value); | 4850 | 307 | 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 | 5 | case C_BLOCK: /* ".bb" or ".eb". */ | 4901 | 6 | case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */ | 4902 | 34 | 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 | 34 | dst->symbol.flags = BSF_LOCAL; | 4919 | 34 | dst->symbol.value = (src->u.syment.n_value | 4920 | 34 | - dst->symbol.section->vma); | 4921 | 34 | #endif | 4922 | 34 | break; | 4923 | | | 4924 | 13 | case C_STATLAB: /* Static load time label. */ | 4925 | 13 | dst->symbol.value = src->u.syment.n_value; | 4926 | 13 | dst->symbol.flags = BSF_GLOBAL; | 4927 | 13 | break; | 4928 | | | 4929 | 3.07k | case C_NULL: | 4930 | | /* PE DLLs sometimes have zeroed out symbols for some | 4931 | | reason. Just ignore them without a warning. */ | 4932 | 3.07k | if (src->u.syment.n_type == 0 | 4933 | 3.07k | && src->u.syment.n_value == 0 | 4934 | 3.07k | && src->u.syment.n_scnum == 0) | 4935 | 3.07k | 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 | 0 | case C_EXTDEF: /* External definition. */ | 4943 | 0 | case C_ULABEL: /* Undefined label. */ | 4944 | 0 | case C_USTATIC: /* Undefined static. */ | 4945 | 0 | #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 | 0 | case C_LINE: /* line # reformatted as symbol table entry. */ | 4949 | | /* NT uses 0x67 for a weak symbol, not C_ALIAS. */ | 4950 | 0 | case C_ALIAS: /* Duplicate tag. */ | 4951 | 0 | #endif | 4952 | | /* New storage classes for TI COFF. */ | 4953 | | #ifdef TICOFF | 4954 | | case C_UEXT: /* Tentative external definition. */ | 4955 | | #endif | 4956 | 0 | case C_EXTLAB: /* External load time label. */ | 4957 | 0 | default: | 4958 | 0 | _bfd_error_handler | 4959 | | /* xgettext:c-format */ | 4960 | 0 | (_("%pB: unrecognized storage class %d for %s symbol `%s'"), | 4961 | 0 | abfd, src->u.syment.n_sclass, | 4962 | 0 | dst->symbol.section->name, dst->symbol.name); | 4963 | 0 | ret = false; | 4964 | | /* Fall through. */ | 4965 | 10 | 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 | dst->symbol.flags = BSF_DEBUGGING; | 4969 | 10 | dst->symbol.value = (src->u.syment.n_value); | 4970 | 10 | break; | 4971 | 3.69k | } | 4972 | | | 4973 | 3.69k | dst->native = src; | 4974 | 3.69k | dst->symbol.udata.i = 0; | 4975 | 3.69k | dst->lineno = NULL; | 4976 | | | 4977 | 3.69k | this_index += (src->u.syment.n_numaux) + 1; | 4978 | 3.69k | dst++; | 4979 | 3.69k | number_of_symbols++; | 4980 | 3.69k | } | 4981 | 94 | } | 4982 | | | 4983 | 94 | obj_symbols (abfd) = cached_area; | 4984 | 94 | obj_raw_syments (abfd) = native_symbols; | 4985 | | | 4986 | 94 | abfd->symcount = number_of_symbols; | 4987 | 94 | obj_convert (abfd) = table_ptr; | 4988 | | /* Slurp the line tables for each section too. */ | 4989 | 94 | { | 4990 | 94 | asection *p; | 4991 | | | 4992 | 94 | p = abfd->sections; | 4993 | 2.05k | while (p) | 4994 | 1.96k | { | 4995 | 1.96k | if (! coff_slurp_line_table (abfd, p)) | 4996 | 0 | return false; | 4997 | 1.96k | p = p->next; | 4998 | 1.96k | } | 4999 | 94 | } | 5000 | | | 5001 | 94 | return ret; | 5002 | 94 | } |
Unexecuted instantiation: coff-stgo32.c:coff_slurp_symbol_table coff-tic30.c:coff_slurp_symbol_table Line | Count | Source | 4630 | 188 | { | 4631 | 188 | combined_entry_type *native_symbols; | 4632 | 188 | coff_symbol_type *cached_area; | 4633 | 188 | unsigned int *table_ptr; | 4634 | 188 | unsigned int number_of_symbols = 0; | 4635 | 188 | bool ret = true; | 4636 | 188 | size_t amt; | 4637 | | | 4638 | 188 | if (obj_symbols (abfd)) | 4639 | 94 | return true; | 4640 | | | 4641 | | /* Read in the symbol table. */ | 4642 | 94 | if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) | 4643 | 0 | return false; | 4644 | | | 4645 | | /* Allocate enough room for all the symbols in cached form. */ | 4646 | 94 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4647 | 94 | sizeof (*cached_area), &amt)) | 4648 | 0 | { | 4649 | 0 | bfd_set_error (bfd_error_file_too_big); | 4650 | 0 | return false; | 4651 | 0 | } | 4652 | 94 | cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt); | 4653 | 94 | if (cached_area == NULL) | 4654 | 0 | return false; | 4655 | | | 4656 | 94 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4657 | 94 | sizeof (*table_ptr), &amt)) | 4658 | 0 | { | 4659 | 0 | bfd_set_error (bfd_error_file_too_big); | 4660 | 0 | return false; | 4661 | 0 | } | 4662 | 94 | table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); | 4663 | 94 | if (table_ptr == NULL) | 4664 | 0 | return false; | 4665 | 94 | else | 4666 | 94 | { | 4667 | 94 | coff_symbol_type *dst = cached_area; | 4668 | 94 | unsigned int last_native_index = obj_raw_syment_count (abfd); | 4669 | 94 | unsigned int this_index = 0; | 4670 | | | 4671 | 1.85k | while (this_index < last_native_index) | 4672 | 1.76k | { | 4673 | 1.76k | combined_entry_type *src = native_symbols + this_index; | 4674 | 1.76k | table_ptr[this_index] = number_of_symbols; | 4675 | | | 4676 | 1.76k | dst->symbol.the_bfd = abfd; | 4677 | 1.76k | BFD_ASSERT (src->is_sym); | 4678 | 1.76k | 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 | 1.76k | src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; | 4681 | 1.76k | dst->symbol.section = coff_section_from_bfd_index (abfd, | 4682 | 1.76k | src->u.syment.n_scnum); | 4683 | 1.76k | dst->symbol.flags = 0; | 4684 | | /* PR 17512: file: 079-7098-0.001:0.1. */ | 4685 | 1.76k | dst->symbol.value = 0; | 4686 | 1.76k | dst->done_lineno = false; | 4687 | | | 4688 | 1.76k | switch (src->u.syment.n_sclass) | 4689 | 1.76k | { | 4690 | 108 | case C_EXT: | 4691 | 131 | 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 | 131 | #ifdef C_SYSTEM | 4703 | 144 | case C_SYSTEM: /* System Wide variable. */ | 4704 | 144 | #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 | 144 | switch (coff_classify_symbol (abfd, &src->u.syment)) | 4712 | 144 | { | 4713 | 124 | case COFF_SYMBOL_GLOBAL: | 4714 | 124 | 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 | 124 | dst->symbol.value = (src->u.syment.n_value | 4721 | 124 | - dst->symbol.section->vma); | 4722 | 124 | #endif | 4723 | 124 | 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 | 124 | break; | 4728 | | | 4729 | 6 | case COFF_SYMBOL_COMMON: | 4730 | 6 | dst->symbol.section = bfd_com_section_ptr; | 4731 | 6 | dst->symbol.value = src->u.syment.n_value; | 4732 | 6 | break; | 4733 | | | 4734 | 14 | case COFF_SYMBOL_UNDEFINED: | 4735 | 14 | dst->symbol.section = bfd_und_section_ptr; | 4736 | 14 | dst->symbol.value = 0; | 4737 | 14 | 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 | 144 | } | 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 | 144 | if (src->u.syment.n_sclass == C_WEAKEXT | 4774 | | #ifdef RS6000COFF_C | 4775 | | || src->u.syment.n_sclass == C_AIX_WEAKEXT | 4776 | | #endif | 4777 | 144 | ) | 4778 | 23 | dst->symbol.flags |= BSF_WEAK; | 4779 | | | 4780 | 144 | break; | 4781 | | | 4782 | 34 | 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 | 53 | case C_LABEL: /* Label. */ | 4793 | 53 | if (src->u.syment.n_scnum == N_DEBUG) | 4794 | 0 | dst->symbol.flags = BSF_DEBUGGING; | 4795 | 53 | else | 4796 | 53 | 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 | 53 | if (dst->symbol.section) | 4801 | 53 | { | 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 | 53 | dst->symbol.value = (src->u.syment.n_value | 4808 | 53 | - dst->symbol.section->vma); | 4809 | 53 | #endif | 4810 | 53 | } | 4811 | 0 | else | 4812 | 0 | dst->symbol.value = src->u.syment.n_value; | 4813 | 53 | break; | 4814 | | | 4815 | 14 | case C_FILE: /* File name. */ | 4816 | 14 | dst->symbol.flags = BSF_FILE; | 4817 | | /* Fall through. */ | 4818 | 49 | case C_MOS: /* Member of structure. */ | 4819 | 50 | case C_EOS: /* End of structure. */ | 4820 | 59 | case C_REGPARM: /* Register parameter. */ | 4821 | 91 | case C_REG: /* register variable. */ | 4822 | | /* C_AUTOARG conflicts with TI COFF C_UEXT. */ | 4823 | 98 | case C_TPDEF: /* Type definition. */ | 4824 | 131 | case C_ARG: | 4825 | 502 | case C_AUTO: /* Automatic variable. */ | 4826 | 535 | case C_FIELD: /* Bit field. */ | 4827 | 540 | case C_ENTAG: /* Enumeration tag. */ | 4828 | 552 | case C_MOE: /* Member of enumeration. */ | 4829 | 572 | case C_MOU: /* Member of union. */ | 4830 | 601 | case C_UNTAG: /* Union tag. */ | 4831 | 631 | 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 | 631 | dst->symbol.flags |= BSF_DEBUGGING; | 4849 | 631 | dst->symbol.value = (src->u.syment.n_value); | 4850 | 631 | 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 | 12 | case C_BLOCK: /* ".bb" or ".eb". */ | 4901 | 48 | case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */ | 4902 | 59 | 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 | 59 | dst->symbol.flags = BSF_LOCAL; | 4919 | 59 | dst->symbol.value = (src->u.syment.n_value | 4920 | 59 | - dst->symbol.section->vma); | 4921 | 59 | #endif | 4922 | 59 | break; | 4923 | | | 4924 | 12 | case C_STATLAB: /* Static load time label. */ | 4925 | 12 | dst->symbol.value = src->u.syment.n_value; | 4926 | 12 | dst->symbol.flags = BSF_GLOBAL; | 4927 | 12 | break; | 4928 | | | 4929 | 857 | case C_NULL: | 4930 | | /* PE DLLs sometimes have zeroed out symbols for some | 4931 | | reason. Just ignore them without a warning. */ | 4932 | 857 | if (src->u.syment.n_type == 0 | 4933 | 857 | && src->u.syment.n_value == 0 | 4934 | 857 | && src->u.syment.n_scnum == 0) | 4935 | 857 | 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 | 0 | case C_EXTDEF: /* External definition. */ | 4943 | 0 | case C_ULABEL: /* Undefined label. */ | 4944 | 0 | case C_USTATIC: /* Undefined static. */ | 4945 | 0 | #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 | 0 | case C_LINE: /* line # reformatted as symbol table entry. */ | 4949 | | /* NT uses 0x67 for a weak symbol, not C_ALIAS. */ | 4950 | 0 | case C_ALIAS: /* Duplicate tag. */ | 4951 | 0 | #endif | 4952 | | /* New storage classes for TI COFF. */ | 4953 | | #ifdef TICOFF | 4954 | | case C_UEXT: /* Tentative external definition. */ | 4955 | | #endif | 4956 | 0 | case C_EXTLAB: /* External load time label. */ | 4957 | 0 | default: | 4958 | 0 | _bfd_error_handler | 4959 | | /* xgettext:c-format */ | 4960 | 0 | (_("%pB: unrecognized storage class %d for %s symbol `%s'"), | 4961 | 0 | abfd, src->u.syment.n_sclass, | 4962 | 0 | dst->symbol.section->name, dst->symbol.name); | 4963 | 0 | ret = false; | 4964 | | /* Fall through. */ | 4965 | 9 | 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 | dst->symbol.flags = BSF_DEBUGGING; | 4969 | 9 | dst->symbol.value = (src->u.syment.n_value); | 4970 | 9 | break; | 4971 | 1.76k | } | 4972 | | | 4973 | 1.76k | dst->native = src; | 4974 | 1.76k | dst->symbol.udata.i = 0; | 4975 | 1.76k | dst->lineno = NULL; | 4976 | | | 4977 | 1.76k | this_index += (src->u.syment.n_numaux) + 1; | 4978 | 1.76k | dst++; | 4979 | 1.76k | number_of_symbols++; | 4980 | 1.76k | } | 4981 | 94 | } | 4982 | | | 4983 | 94 | obj_symbols (abfd) = cached_area; | 4984 | 94 | obj_raw_syments (abfd) = native_symbols; | 4985 | | | 4986 | 94 | abfd->symcount = number_of_symbols; | 4987 | 94 | obj_convert (abfd) = table_ptr; | 4988 | | /* Slurp the line tables for each section too. */ | 4989 | 94 | { | 4990 | 94 | asection *p; | 4991 | | | 4992 | 94 | p = abfd->sections; | 4993 | 276 | while (p) | 4994 | 182 | { | 4995 | 182 | if (! coff_slurp_line_table (abfd, p)) | 4996 | 0 | return false; | 4997 | 182 | p = p->next; | 4998 | 182 | } | 4999 | 94 | } | 5000 | | | 5001 | 94 | return ret; | 5002 | 94 | } |
Unexecuted instantiation: coff-tic4x.c:coff_slurp_symbol_table coff-tic54x.c:coff_slurp_symbol_table Line | Count | Source | 4630 | 150 | { | 4631 | 150 | combined_entry_type *native_symbols; | 4632 | 150 | coff_symbol_type *cached_area; | 4633 | 150 | unsigned int *table_ptr; | 4634 | 150 | unsigned int number_of_symbols = 0; | 4635 | 150 | bool ret = true; | 4636 | 150 | size_t amt; | 4637 | | | 4638 | 150 | if (obj_symbols (abfd)) | 4639 | 75 | return true; | 4640 | | | 4641 | | /* Read in the symbol table. */ | 4642 | 75 | if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) | 4643 | 0 | return false; | 4644 | | | 4645 | | /* Allocate enough room for all the symbols in cached form. */ | 4646 | 75 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4647 | 75 | sizeof (*cached_area), &amt)) | 4648 | 0 | { | 4649 | 0 | bfd_set_error (bfd_error_file_too_big); | 4650 | 0 | return false; | 4651 | 0 | } | 4652 | 75 | cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt); | 4653 | 75 | if (cached_area == NULL) | 4654 | 0 | return false; | 4655 | | | 4656 | 75 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4657 | 75 | sizeof (*table_ptr), &amt)) | 4658 | 0 | { | 4659 | 0 | bfd_set_error (bfd_error_file_too_big); | 4660 | 0 | return false; | 4661 | 0 | } | 4662 | 75 | table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); | 4663 | 75 | if (table_ptr == NULL) | 4664 | 0 | return false; | 4665 | 75 | else | 4666 | 75 | { | 4667 | 75 | coff_symbol_type *dst = cached_area; | 4668 | 75 | unsigned int last_native_index = obj_raw_syment_count (abfd); | 4669 | 75 | unsigned int this_index = 0; | 4670 | | | 4671 | 2.11k | while (this_index < last_native_index) | 4672 | 2.03k | { | 4673 | 2.03k | combined_entry_type *src = native_symbols + this_index; | 4674 | 2.03k | table_ptr[this_index] = number_of_symbols; | 4675 | | | 4676 | 2.03k | dst->symbol.the_bfd = abfd; | 4677 | 2.03k | BFD_ASSERT (src->is_sym); | 4678 | 2.03k | 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 | 2.03k | src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; | 4681 | 2.03k | dst->symbol.section = coff_section_from_bfd_index (abfd, | 4682 | 2.03k | src->u.syment.n_scnum); | 4683 | 2.03k | dst->symbol.flags = 0; | 4684 | | /* PR 17512: file: 079-7098-0.001:0.1. */ | 4685 | 2.03k | dst->symbol.value = 0; | 4686 | 2.03k | dst->done_lineno = false; | 4687 | | | 4688 | 2.03k | switch (src->u.syment.n_sclass) | 4689 | 2.03k | { | 4690 | 412 | case C_EXT: | 4691 | 439 | 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 | 439 | #ifdef C_SYSTEM | 4703 | 444 | case C_SYSTEM: /* System Wide variable. */ | 4704 | 444 | #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 | 444 | switch (coff_classify_symbol (abfd, &src->u.syment)) | 4712 | 444 | { | 4713 | 376 | case COFF_SYMBOL_GLOBAL: | 4714 | 376 | 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 | 376 | dst->symbol.value = (src->u.syment.n_value | 4721 | 376 | - dst->symbol.section->vma); | 4722 | 376 | #endif | 4723 | 376 | if (ISFCN ((src->u.syment.n_type))) | 4724 | | /* A function ext does not go at the end of a | 4725 | | file. */ | 4726 | 9 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4727 | 376 | 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 | 43 | case COFF_SYMBOL_UNDEFINED: | 4735 | 43 | dst->symbol.section = bfd_und_section_ptr; | 4736 | 43 | dst->symbol.value = 0; | 4737 | 43 | 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 | 444 | } | 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 | 444 | if (src->u.syment.n_sclass == C_WEAKEXT | 4774 | | #ifdef RS6000COFF_C | 4775 | | || src->u.syment.n_sclass == C_AIX_WEAKEXT | 4776 | | #endif | 4777 | 444 | ) | 4778 | 27 | dst->symbol.flags |= BSF_WEAK; | 4779 | | | 4780 | 444 | break; | 4781 | | | 4782 | 28 | 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 | 58 | case C_LABEL: /* Label. */ | 4793 | 58 | if (src->u.syment.n_scnum == N_DEBUG) | 4794 | 0 | dst->symbol.flags = BSF_DEBUGGING; | 4795 | 58 | else | 4796 | 58 | 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 | 58 | if (dst->symbol.section) | 4801 | 58 | { | 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 | 58 | dst->symbol.value = (src->u.syment.n_value | 4808 | 58 | - dst->symbol.section->vma); | 4809 | 58 | #endif | 4810 | 58 | } | 4811 | 0 | else | 4812 | 0 | dst->symbol.value = src->u.syment.n_value; | 4813 | 58 | break; | 4814 | | | 4815 | 21 | case C_FILE: /* File name. */ | 4816 | 21 | dst->symbol.flags = BSF_FILE; | 4817 | | /* Fall through. */ | 4818 | 36 | case C_MOS: /* Member of structure. */ | 4819 | 38 | case C_EOS: /* End of structure. */ | 4820 | 39 | case C_REGPARM: /* Register parameter. */ | 4821 | 52 | case C_REG: /* register variable. */ | 4822 | | /* C_AUTOARG conflicts with TI COFF C_UEXT. */ | 4823 | 75 | case C_TPDEF: /* Type definition. */ | 4824 | 82 | case C_ARG: | 4825 | 134 | case C_AUTO: /* Automatic variable. */ | 4826 | 173 | case C_FIELD: /* Bit field. */ | 4827 | 205 | case C_ENTAG: /* Enumeration tag. */ | 4828 | 214 | case C_MOE: /* Member of enumeration. */ | 4829 | 294 | case C_MOU: /* Member of union. */ | 4830 | 312 | case C_UNTAG: /* Union tag. */ | 4831 | 354 | 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 | 354 | dst->symbol.flags |= BSF_DEBUGGING; | 4849 | 354 | dst->symbol.value = (src->u.syment.n_value); | 4850 | 354 | 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 | 15 | case C_BLOCK: /* ".bb" or ".eb". */ | 4901 | 15 | case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */ | 4902 | 28 | 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 | 28 | dst->symbol.flags = BSF_LOCAL; | 4919 | 28 | dst->symbol.value = (src->u.syment.n_value | 4920 | 28 | - dst->symbol.section->vma); | 4921 | 28 | #endif | 4922 | 28 | 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 | 1.13k | case C_NULL: | 4930 | | /* PE DLLs sometimes have zeroed out symbols for some | 4931 | | reason. Just ignore them without a warning. */ | 4932 | 1.13k | if (src->u.syment.n_type == 0 | 4933 | 1.13k | && src->u.syment.n_value == 0 | 4934 | 1.13k | && src->u.syment.n_scnum == 0) | 4935 | 1.13k | 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 | 0 | case C_EXTDEF: /* External definition. */ | 4943 | 0 | case C_ULABEL: /* Undefined label. */ | 4944 | 0 | case C_USTATIC: /* Undefined static. */ | 4945 | 0 | #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 | 0 | case C_LINE: /* line # reformatted as symbol table entry. */ | 4949 | | /* NT uses 0x67 for a weak symbol, not C_ALIAS. */ | 4950 | 0 | case C_ALIAS: /* Duplicate tag. */ | 4951 | 0 | #endif | 4952 | | /* New storage classes for TI COFF. */ | 4953 | 0 | #ifdef TICOFF | 4954 | 0 | case C_UEXT: /* Tentative external definition. */ | 4955 | 0 | #endif | 4956 | 0 | case C_EXTLAB: /* External load time label. */ | 4957 | 0 | default: | 4958 | 0 | _bfd_error_handler | 4959 | | /* xgettext:c-format */ | 4960 | 0 | (_("%pB: unrecognized storage class %d for %s symbol `%s'"), | 4961 | 0 | abfd, src->u.syment.n_sclass, | 4962 | 0 | dst->symbol.section->name, dst->symbol.name); | 4963 | 0 | ret = false; | 4964 | | /* Fall through. */ | 4965 | 3 | 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 | 3 | dst->symbol.flags = BSF_DEBUGGING; | 4969 | 3 | dst->symbol.value = (src->u.syment.n_value); | 4970 | 3 | break; | 4971 | 2.03k | } | 4972 | | | 4973 | 2.03k | dst->native = src; | 4974 | 2.03k | dst->symbol.udata.i = 0; | 4975 | 2.03k | dst->lineno = NULL; | 4976 | | | 4977 | 2.03k | this_index += (src->u.syment.n_numaux) + 1; | 4978 | 2.03k | dst++; | 4979 | 2.03k | number_of_symbols++; | 4980 | 2.03k | } | 4981 | 75 | } | 4982 | | | 4983 | 75 | obj_symbols (abfd) = cached_area; | 4984 | 75 | obj_raw_syments (abfd) = native_symbols; | 4985 | | | 4986 | 75 | abfd->symcount = number_of_symbols; | 4987 | 75 | obj_convert (abfd) = table_ptr; | 4988 | | /* Slurp the line tables for each section too. */ | 4989 | 75 | { | 4990 | 75 | asection *p; | 4991 | | | 4992 | 75 | p = abfd->sections; | 4993 | 743 | while (p) | 4994 | 668 | { | 4995 | 668 | if (! coff_slurp_line_table (abfd, p)) | 4996 | 0 | return false; | 4997 | 668 | p = p->next; | 4998 | 668 | } | 4999 | 75 | } | 5000 | | | 5001 | 75 | return ret; | 5002 | 75 | } |
coff-z80.c:coff_slurp_symbol_table Line | Count | Source | 4630 | 190 | { | 4631 | 190 | combined_entry_type *native_symbols; | 4632 | 190 | coff_symbol_type *cached_area; | 4633 | 190 | unsigned int *table_ptr; | 4634 | 190 | unsigned int number_of_symbols = 0; | 4635 | 190 | bool ret = true; | 4636 | 190 | size_t amt; | 4637 | | | 4638 | 190 | if (obj_symbols (abfd)) | 4639 | 95 | return true; | 4640 | | | 4641 | | /* Read in the symbol table. */ | 4642 | 95 | if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) | 4643 | 0 | return false; | 4644 | | | 4645 | | /* Allocate enough room for all the symbols in cached form. */ | 4646 | 95 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4647 | 95 | sizeof (*cached_area), &amt)) | 4648 | 0 | { | 4649 | 0 | bfd_set_error (bfd_error_file_too_big); | 4650 | 0 | return false; | 4651 | 0 | } | 4652 | 95 | cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt); | 4653 | 95 | if (cached_area == NULL) | 4654 | 0 | return false; | 4655 | | | 4656 | 95 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4657 | 95 | sizeof (*table_ptr), &amt)) | 4658 | 0 | { | 4659 | 0 | bfd_set_error (bfd_error_file_too_big); | 4660 | 0 | return false; | 4661 | 0 | } | 4662 | 95 | table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); | 4663 | 95 | if (table_ptr == NULL) | 4664 | 0 | return false; | 4665 | 95 | else | 4666 | 95 | { | 4667 | 95 | coff_symbol_type *dst = cached_area; | 4668 | 95 | unsigned int last_native_index = obj_raw_syment_count (abfd); | 4669 | 95 | unsigned int this_index = 0; | 4670 | | | 4671 | 3.48k | while (this_index < last_native_index) | 4672 | 3.39k | { | 4673 | 3.39k | combined_entry_type *src = native_symbols + this_index; | 4674 | 3.39k | table_ptr[this_index] = number_of_symbols; | 4675 | | | 4676 | 3.39k | dst->symbol.the_bfd = abfd; | 4677 | 3.39k | BFD_ASSERT (src->is_sym); | 4678 | 3.39k | 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 | 3.39k | src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; | 4681 | 3.39k | dst->symbol.section = coff_section_from_bfd_index (abfd, | 4682 | 3.39k | src->u.syment.n_scnum); | 4683 | 3.39k | dst->symbol.flags = 0; | 4684 | | /* PR 17512: file: 079-7098-0.001:0.1. */ | 4685 | 3.39k | dst->symbol.value = 0; | 4686 | 3.39k | dst->done_lineno = false; | 4687 | | | 4688 | 3.39k | switch (src->u.syment.n_sclass) | 4689 | 3.39k | { | 4690 | 356 | case C_EXT: | 4691 | 367 | 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 | 367 | #ifdef C_SYSTEM | 4703 | 377 | case C_SYSTEM: /* System Wide variable. */ | 4704 | 377 | #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 | 377 | switch (coff_classify_symbol (abfd, &src->u.syment)) | 4712 | 377 | { | 4713 | 349 | case COFF_SYMBOL_GLOBAL: | 4714 | 349 | 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 | 349 | dst->symbol.value = (src->u.syment.n_value | 4721 | 349 | - dst->symbol.section->vma); | 4722 | 349 | #endif | 4723 | 349 | if (ISFCN ((src->u.syment.n_type))) | 4724 | | /* A function ext does not go at the end of a | 4725 | | file. */ | 4726 | 16 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4727 | 349 | 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 | 18 | case COFF_SYMBOL_UNDEFINED: | 4735 | 18 | dst->symbol.section = bfd_und_section_ptr; | 4736 | 18 | dst->symbol.value = 0; | 4737 | 18 | 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 | 377 | } | 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 | 377 | if (src->u.syment.n_sclass == C_WEAKEXT | 4774 | | #ifdef RS6000COFF_C | 4775 | | || src->u.syment.n_sclass == C_AIX_WEAKEXT | 4776 | | #endif | 4777 | 377 | ) | 4778 | 11 | dst->symbol.flags |= BSF_WEAK; | 4779 | | | 4780 | 377 | break; | 4781 | | | 4782 | 152 | 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 | 221 | case C_LABEL: /* Label. */ | 4793 | 221 | if (src->u.syment.n_scnum == N_DEBUG) | 4794 | 0 | dst->symbol.flags = BSF_DEBUGGING; | 4795 | 221 | else | 4796 | 221 | 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 | 221 | if (dst->symbol.section) | 4801 | 221 | { | 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 | 221 | dst->symbol.value = (src->u.syment.n_value | 4808 | 221 | - dst->symbol.section->vma); | 4809 | 221 | #endif | 4810 | 221 | } | 4811 | 0 | else | 4812 | 0 | dst->symbol.value = src->u.syment.n_value; | 4813 | 221 | break; | 4814 | | | 4815 | 31 | case C_FILE: /* File name. */ | 4816 | 31 | dst->symbol.flags = BSF_FILE; | 4817 | | /* Fall through. */ | 4818 | 62 | case C_MOS: /* Member of structure. */ | 4819 | 67 | case C_EOS: /* End of structure. */ | 4820 | 118 | case C_REGPARM: /* Register parameter. */ | 4821 | 172 | case C_REG: /* register variable. */ | 4822 | | /* C_AUTOARG conflicts with TI COFF C_UEXT. */ | 4823 | 180 | case C_TPDEF: /* Type definition. */ | 4824 | 204 | case C_ARG: | 4825 | 1.05k | case C_AUTO: /* Automatic variable. */ | 4826 | 1.05k | case C_FIELD: /* Bit field. */ | 4827 | 1.06k | case C_ENTAG: /* Enumeration tag. */ | 4828 | 1.10k | case C_MOE: /* Member of enumeration. */ | 4829 | 1.13k | case C_MOU: /* Member of union. */ | 4830 | 1.14k | case C_UNTAG: /* Union tag. */ | 4831 | 1.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 | 1.18k | dst->symbol.flags |= BSF_DEBUGGING; | 4849 | 1.18k | dst->symbol.value = (src->u.syment.n_value); | 4850 | 1.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 | 8 | case C_BLOCK: /* ".bb" or ".eb". */ | 4901 | 9 | case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */ | 4902 | 18 | 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 | 18 | dst->symbol.flags = BSF_LOCAL; | 4919 | 18 | dst->symbol.value = (src->u.syment.n_value | 4920 | 18 | - dst->symbol.section->vma); | 4921 | 18 | #endif | 4922 | 18 | break; | 4923 | | | 4924 | 26 | case C_STATLAB: /* Static load time label. */ | 4925 | 26 | dst->symbol.value = src->u.syment.n_value; | 4926 | 26 | dst->symbol.flags = BSF_GLOBAL; | 4927 | 26 | break; | 4928 | | | 4929 | 1.55k | case C_NULL: | 4930 | | /* PE DLLs sometimes have zeroed out symbols for some | 4931 | | reason. Just ignore them without a warning. */ | 4932 | 1.55k | if (src->u.syment.n_type == 0 | 4933 | 1.55k | && src->u.syment.n_value == 0 | 4934 | 1.55k | && src->u.syment.n_scnum == 0) | 4935 | 1.55k | 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 | 0 | case C_EXTDEF: /* External definition. */ | 4943 | 0 | case C_ULABEL: /* Undefined label. */ | 4944 | 0 | case C_USTATIC: /* Undefined static. */ | 4945 | 0 | #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 | 0 | case C_LINE: /* line # reformatted as symbol table entry. */ | 4949 | | /* NT uses 0x67 for a weak symbol, not C_ALIAS. */ | 4950 | 0 | case C_ALIAS: /* Duplicate tag. */ | 4951 | 0 | #endif | 4952 | | /* New storage classes for TI COFF. */ | 4953 | | #ifdef TICOFF | 4954 | | case C_UEXT: /* Tentative external definition. */ | 4955 | | #endif | 4956 | 0 | case C_EXTLAB: /* External load time label. */ | 4957 | 0 | default: | 4958 | 0 | _bfd_error_handler | 4959 | | /* xgettext:c-format */ | 4960 | 0 | (_("%pB: unrecognized storage class %d for %s symbol `%s'"), | 4961 | 0 | abfd, src->u.syment.n_sclass, | 4962 | 0 | dst->symbol.section->name, dst->symbol.name); | 4963 | 0 | ret = false; | 4964 | | /* Fall through. */ | 4965 | 13 | 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 | dst->symbol.flags = BSF_DEBUGGING; | 4969 | 13 | dst->symbol.value = (src->u.syment.n_value); | 4970 | 13 | break; | 4971 | 3.39k | } | 4972 | | | 4973 | 3.39k | dst->native = src; | 4974 | 3.39k | dst->symbol.udata.i = 0; | 4975 | 3.39k | dst->lineno = NULL; | 4976 | | | 4977 | 3.39k | this_index += (src->u.syment.n_numaux) + 1; | 4978 | 3.39k | dst++; | 4979 | 3.39k | number_of_symbols++; | 4980 | 3.39k | } | 4981 | 95 | } | 4982 | | | 4983 | 95 | obj_symbols (abfd) = cached_area; | 4984 | 95 | obj_raw_syments (abfd) = native_symbols; | 4985 | | | 4986 | 95 | abfd->symcount = number_of_symbols; | 4987 | 95 | obj_convert (abfd) = table_ptr; | 4988 | | /* Slurp the line tables for each section too. */ | 4989 | 95 | { | 4990 | 95 | asection *p; | 4991 | | | 4992 | 95 | p = abfd->sections; | 4993 | 666 | while (p) | 4994 | 571 | { | 4995 | 571 | if (! coff_slurp_line_table (abfd, p)) | 4996 | 0 | return false; | 4997 | 571 | p = p->next; | 4998 | 571 | } | 4999 | 95 | } | 5000 | | | 5001 | 95 | return ret; | 5002 | 95 | } |
coff-z8k.c:coff_slurp_symbol_table Line | Count | Source | 4630 | 166 | { | 4631 | 166 | combined_entry_type *native_symbols; | 4632 | 166 | coff_symbol_type *cached_area; | 4633 | 166 | unsigned int *table_ptr; | 4634 | 166 | unsigned int number_of_symbols = 0; | 4635 | 166 | bool ret = true; | 4636 | 166 | size_t amt; | 4637 | | | 4638 | 166 | if (obj_symbols (abfd)) | 4639 | 83 | return true; | 4640 | | | 4641 | | /* Read in the symbol table. */ | 4642 | 83 | if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) | 4643 | 0 | return false; | 4644 | | | 4645 | | /* Allocate enough room for all the symbols in cached form. */ | 4646 | 83 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4647 | 83 | sizeof (*cached_area), &amt)) | 4648 | 0 | { | 4649 | 0 | bfd_set_error (bfd_error_file_too_big); | 4650 | 0 | return false; | 4651 | 0 | } | 4652 | 83 | cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt); | 4653 | 83 | if (cached_area == NULL) | 4654 | 0 | return false; | 4655 | | | 4656 | 83 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4657 | 83 | sizeof (*table_ptr), &amt)) | 4658 | 0 | { | 4659 | 0 | bfd_set_error (bfd_error_file_too_big); | 4660 | 0 | return false; | 4661 | 0 | } | 4662 | 83 | table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); | 4663 | 83 | if (table_ptr == NULL) | 4664 | 0 | return false; | 4665 | 83 | else | 4666 | 83 | { | 4667 | 83 | coff_symbol_type *dst = cached_area; | 4668 | 83 | unsigned int last_native_index = obj_raw_syment_count (abfd); | 4669 | 83 | unsigned int this_index = 0; | 4670 | | | 4671 | 1.26k | while (this_index < last_native_index) | 4672 | 1.18k | { | 4673 | 1.18k | combined_entry_type *src = native_symbols + this_index; | 4674 | 1.18k | table_ptr[this_index] = number_of_symbols; | 4675 | | | 4676 | 1.18k | dst->symbol.the_bfd = abfd; | 4677 | 1.18k | BFD_ASSERT (src->is_sym); | 4678 | 1.18k | 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 | 1.18k | src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; | 4681 | 1.18k | dst->symbol.section = coff_section_from_bfd_index (abfd, | 4682 | 1.18k | src->u.syment.n_scnum); | 4683 | 1.18k | dst->symbol.flags = 0; | 4684 | | /* PR 17512: file: 079-7098-0.001:0.1. */ | 4685 | 1.18k | dst->symbol.value = 0; | 4686 | 1.18k | dst->done_lineno = false; | 4687 | | | 4688 | 1.18k | switch (src->u.syment.n_sclass) | 4689 | 1.18k | { | 4690 | 18 | case C_EXT: | 4691 | 32 | 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 | 32 | #ifdef C_SYSTEM | 4703 | 65 | case C_SYSTEM: /* System Wide variable. */ | 4704 | 65 | #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 | 65 | switch (coff_classify_symbol (abfd, &src->u.syment)) | 4712 | 65 | { | 4713 | 45 | case COFF_SYMBOL_GLOBAL: | 4714 | 45 | 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 | 45 | dst->symbol.value = (src->u.syment.n_value | 4721 | 45 | - dst->symbol.section->vma); | 4722 | 45 | #endif | 4723 | 45 | if (ISFCN ((src->u.syment.n_type))) | 4724 | | /* A function ext does not go at the end of a | 4725 | | file. */ | 4726 | 6 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4727 | 45 | break; | 4728 | | | 4729 | 6 | case COFF_SYMBOL_COMMON: | 4730 | 6 | dst->symbol.section = bfd_com_section_ptr; | 4731 | 6 | dst->symbol.value = src->u.syment.n_value; | 4732 | 6 | break; | 4733 | | | 4734 | 14 | case COFF_SYMBOL_UNDEFINED: | 4735 | 14 | dst->symbol.section = bfd_und_section_ptr; | 4736 | 14 | dst->symbol.value = 0; | 4737 | 14 | 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 | 65 | } | 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 | 65 | if (src->u.syment.n_sclass == C_WEAKEXT | 4774 | | #ifdef RS6000COFF_C | 4775 | | || src->u.syment.n_sclass == C_AIX_WEAKEXT | 4776 | | #endif | 4777 | 65 | ) | 4778 | 14 | dst->symbol.flags |= BSF_WEAK; | 4779 | | | 4780 | 65 | break; | 4781 | | | 4782 | 49 | 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 | 90 | case C_LABEL: /* Label. */ | 4793 | 90 | if (src->u.syment.n_scnum == N_DEBUG) | 4794 | 0 | dst->symbol.flags = BSF_DEBUGGING; | 4795 | 90 | else | 4796 | 90 | 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 | 90 | if (dst->symbol.section) | 4801 | 90 | { | 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 | 90 | dst->symbol.value = (src->u.syment.n_value | 4808 | 90 | - dst->symbol.section->vma); | 4809 | 90 | #endif | 4810 | 90 | } | 4811 | 0 | else | 4812 | 0 | dst->symbol.value = src->u.syment.n_value; | 4813 | 90 | break; | 4814 | | | 4815 | 27 | case C_FILE: /* File name. */ | 4816 | 27 | dst->symbol.flags = BSF_FILE; | 4817 | | /* Fall through. */ | 4818 | 49 | case C_MOS: /* Member of structure. */ | 4819 | 51 | case C_EOS: /* End of structure. */ | 4820 | 55 | case C_REGPARM: /* Register parameter. */ | 4821 | 107 | case C_REG: /* register variable. */ | 4822 | | /* C_AUTOARG conflicts with TI COFF C_UEXT. */ | 4823 | 127 | case C_TPDEF: /* Type definition. */ | 4824 | 147 | case C_ARG: | 4825 | 320 | case C_AUTO: /* Automatic variable. */ | 4826 | 321 | case C_FIELD: /* Bit field. */ | 4827 | 333 | case C_ENTAG: /* Enumeration tag. */ | 4828 | 346 | case C_MOE: /* Member of enumeration. */ | 4829 | 349 | case C_MOU: /* Member of union. */ | 4830 | 362 | case C_UNTAG: /* Union tag. */ | 4831 | 394 | 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 | 394 | dst->symbol.flags |= BSF_DEBUGGING; | 4849 | 394 | dst->symbol.value = (src->u.syment.n_value); | 4850 | 394 | 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 | 6 | case C_BLOCK: /* ".bb" or ".eb". */ | 4901 | 7 | case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */ | 4902 | 16 | 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 | 16 | dst->symbol.flags = BSF_LOCAL; | 4919 | 16 | dst->symbol.value = (src->u.syment.n_value | 4920 | 16 | - dst->symbol.section->vma); | 4921 | 16 | #endif | 4922 | 16 | break; | 4923 | | | 4924 | 16 | case C_STATLAB: /* Static load time label. */ | 4925 | 16 | dst->symbol.value = src->u.syment.n_value; | 4926 | 16 | dst->symbol.flags = BSF_GLOBAL; | 4927 | 16 | break; | 4928 | | | 4929 | 591 | case C_NULL: | 4930 | | /* PE DLLs sometimes have zeroed out symbols for some | 4931 | | reason. Just ignore them without a warning. */ | 4932 | 591 | if (src->u.syment.n_type == 0 | 4933 | 591 | && src->u.syment.n_value == 0 | 4934 | 591 | && src->u.syment.n_scnum == 0) | 4935 | 591 | 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 | 0 | case C_EXTDEF: /* External definition. */ | 4943 | 0 | case C_ULABEL: /* Undefined label. */ | 4944 | 0 | case C_USTATIC: /* Undefined static. */ | 4945 | 0 | #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 | 0 | case C_LINE: /* line # reformatted as symbol table entry. */ | 4949 | | /* NT uses 0x67 for a weak symbol, not C_ALIAS. */ | 4950 | 0 | case C_ALIAS: /* Duplicate tag. */ | 4951 | 0 | #endif | 4952 | | /* New storage classes for TI COFF. */ | 4953 | | #ifdef TICOFF | 4954 | | case C_UEXT: /* Tentative external definition. */ | 4955 | | #endif | 4956 | 0 | case C_EXTLAB: /* External load time label. */ | 4957 | 0 | default: | 4958 | 0 | _bfd_error_handler | 4959 | | /* xgettext:c-format */ | 4960 | 0 | (_("%pB: unrecognized storage class %d for %s symbol `%s'"), | 4961 | 0 | abfd, src->u.syment.n_sclass, | 4962 | 0 | dst->symbol.section->name, dst->symbol.name); | 4963 | 0 | ret = false; | 4964 | | /* Fall through. */ | 4965 | 10 | 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 | dst->symbol.flags = BSF_DEBUGGING; | 4969 | 10 | dst->symbol.value = (src->u.syment.n_value); | 4970 | 10 | break; | 4971 | 1.18k | } | 4972 | | | 4973 | 1.18k | dst->native = src; | 4974 | 1.18k | dst->symbol.udata.i = 0; | 4975 | 1.18k | dst->lineno = NULL; | 4976 | | | 4977 | 1.18k | this_index += (src->u.syment.n_numaux) + 1; | 4978 | 1.18k | dst++; | 4979 | 1.18k | number_of_symbols++; | 4980 | 1.18k | } | 4981 | 83 | } | 4982 | | | 4983 | 83 | obj_symbols (abfd) = cached_area; | 4984 | 83 | obj_raw_syments (abfd) = native_symbols; | 4985 | | | 4986 | 83 | abfd->symcount = number_of_symbols; | 4987 | 83 | obj_convert (abfd) = table_ptr; | 4988 | | /* Slurp the line tables for each section too. */ | 4989 | 83 | { | 4990 | 83 | asection *p; | 4991 | | | 4992 | 83 | p = abfd->sections; | 4993 | 542 | while (p) | 4994 | 459 | { | 4995 | 459 | if (! coff_slurp_line_table (abfd, p)) | 4996 | 0 | return false; | 4997 | 459 | p = p->next; | 4998 | 459 | } | 4999 | 83 | } | 5000 | | | 5001 | 83 | return ret; | 5002 | 83 | } |
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 | 124 | { | 4631 | 124 | combined_entry_type *native_symbols; | 4632 | 124 | coff_symbol_type *cached_area; | 4633 | 124 | unsigned int *table_ptr; | 4634 | 124 | unsigned int number_of_symbols = 0; | 4635 | 124 | bool ret = true; | 4636 | 124 | size_t amt; | 4637 | | | 4638 | 124 | if (obj_symbols (abfd)) | 4639 | 62 | return true; | 4640 | | | 4641 | | /* Read in the symbol table. */ | 4642 | 62 | if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) | 4643 | 0 | return false; | 4644 | | | 4645 | | /* Allocate enough room for all the symbols in cached form. */ | 4646 | 62 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4647 | 62 | sizeof (*cached_area), &amt)) | 4648 | 0 | { | 4649 | 0 | bfd_set_error (bfd_error_file_too_big); | 4650 | 0 | return false; | 4651 | 0 | } | 4652 | 62 | cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt); | 4653 | 62 | if (cached_area == NULL) | 4654 | 0 | return false; | 4655 | | | 4656 | 62 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4657 | 62 | sizeof (*table_ptr), &amt)) | 4658 | 0 | { | 4659 | 0 | bfd_set_error (bfd_error_file_too_big); | 4660 | 0 | return false; | 4661 | 0 | } | 4662 | 62 | table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); | 4663 | 62 | if (table_ptr == NULL) | 4664 | 0 | return false; | 4665 | 62 | else | 4666 | 62 | { | 4667 | 62 | coff_symbol_type *dst = cached_area; | 4668 | 62 | unsigned int last_native_index = obj_raw_syment_count (abfd); | 4669 | 62 | unsigned int this_index = 0; | 4670 | | | 4671 | 1.72k | while (this_index < last_native_index) | 4672 | 1.65k | { | 4673 | 1.65k | combined_entry_type *src = native_symbols + this_index; | 4674 | 1.65k | table_ptr[this_index] = number_of_symbols; | 4675 | | | 4676 | 1.65k | dst->symbol.the_bfd = abfd; | 4677 | 1.65k | BFD_ASSERT (src->is_sym); | 4678 | 1.65k | 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 | 1.65k | src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; | 4681 | 1.65k | dst->symbol.section = coff_section_from_bfd_index (abfd, | 4682 | 1.65k | src->u.syment.n_scnum); | 4683 | 1.65k | dst->symbol.flags = 0; | 4684 | | /* PR 17512: file: 079-7098-0.001:0.1. */ | 4685 | 1.65k | dst->symbol.value = 0; | 4686 | 1.65k | dst->done_lineno = false; | 4687 | | | 4688 | 1.65k | switch (src->u.syment.n_sclass) | 4689 | 1.65k | { | 4690 | 154 | case C_EXT: | 4691 | 157 | 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 | 157 | #ifdef C_SYSTEM | 4703 | 162 | case C_SYSTEM: /* System Wide variable. */ | 4704 | 162 | #endif | 4705 | 162 | #ifdef COFF_WITH_PE | 4706 | | /* In PE, 0x68 (104) denotes a section symbol. */ | 4707 | 166 | case C_SECTION: | 4708 | | /* In PE, 0x69 (105) denotes a weak external symbol. */ | 4709 | 177 | case C_NT_WEAK: | 4710 | 177 | #endif | 4711 | 177 | switch (coff_classify_symbol (abfd, &src->u.syment)) | 4712 | 177 | { | 4713 | 136 | case COFF_SYMBOL_GLOBAL: | 4714 | 136 | dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL; | 4715 | 136 | #if defined COFF_WITH_PE | 4716 | | /* PE sets the symbol to a value relative to the | 4717 | | start of the section. */ | 4718 | 136 | 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 | 136 | if (ISFCN ((src->u.syment.n_type))) | 4724 | | /* A function ext does not go at the end of a | 4725 | | file. */ | 4726 | 13 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4727 | 136 | break; | 4728 | | | 4729 | 20 | case COFF_SYMBOL_COMMON: | 4730 | 20 | dst->symbol.section = bfd_com_section_ptr; | 4731 | 20 | dst->symbol.value = src->u.syment.n_value; | 4732 | 20 | 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 | 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 | 177 | } | 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 | 177 | #ifdef COFF_WITH_PE | 4766 | 177 | if (src->u.syment.n_sclass == C_NT_WEAK) | 4767 | 11 | dst->symbol.flags |= BSF_WEAK; | 4768 | | | 4769 | 177 | if (src->u.syment.n_sclass == C_SECTION | 4770 | 177 | && src->u.syment.n_scnum > 0) | 4771 | 0 | dst->symbol.flags = BSF_LOCAL; | 4772 | 177 | #endif | 4773 | 177 | if (src->u.syment.n_sclass == C_WEAKEXT | 4774 | | #ifdef RS6000COFF_C | 4775 | | || src->u.syment.n_sclass == C_AIX_WEAKEXT | 4776 | | #endif | 4777 | 177 | ) | 4778 | 3 | dst->symbol.flags |= BSF_WEAK; | 4779 | | | 4780 | 177 | break; | 4781 | | | 4782 | 16 | 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 | 63 | case C_LABEL: /* Label. */ | 4793 | 63 | if (src->u.syment.n_scnum == N_DEBUG) | 4794 | 0 | dst->symbol.flags = BSF_DEBUGGING; | 4795 | 63 | else | 4796 | 63 | 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 | 63 | if (dst->symbol.section) | 4801 | 63 | { | 4802 | 63 | #if defined COFF_WITH_PE | 4803 | | /* PE sets the symbol to a value relative to the | 4804 | | start of the section. */ | 4805 | 63 | 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 | 63 | } | 4811 | 0 | else | 4812 | 0 | dst->symbol.value = src->u.syment.n_value; | 4813 | 63 | break; | 4814 | | | 4815 | 15 | case C_FILE: /* File name. */ | 4816 | 15 | dst->symbol.flags = BSF_FILE; | 4817 | | /* Fall through. */ | 4818 | 27 | case C_MOS: /* Member of structure. */ | 4819 | 28 | case C_EOS: /* End of structure. */ | 4820 | 43 | case C_REGPARM: /* Register parameter. */ | 4821 | 54 | case C_REG: /* register variable. */ | 4822 | | /* C_AUTOARG conflicts with TI COFF C_UEXT. */ | 4823 | 61 | case C_TPDEF: /* Type definition. */ | 4824 | 75 | case C_ARG: | 4825 | 116 | case C_AUTO: /* Automatic variable. */ | 4826 | 117 | case C_FIELD: /* Bit field. */ | 4827 | 165 | case C_ENTAG: /* Enumeration tag. */ | 4828 | 168 | case C_MOE: /* Member of enumeration. */ | 4829 | 178 | case C_MOU: /* Member of union. */ | 4830 | 187 | case C_UNTAG: /* Union tag. */ | 4831 | 197 | 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 | 197 | dst->symbol.flags |= BSF_DEBUGGING; | 4849 | 197 | dst->symbol.value = (src->u.syment.n_value); | 4850 | 197 | 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 | 1 | case C_BLOCK: /* ".bb" or ".eb". */ | 4901 | 1 | case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */ | 4902 | 21 | case C_EFCN: /* Physical end of function. */ | 4903 | 21 | #if defined COFF_WITH_PE | 4904 | | /* PE sets the symbol to a value relative to the start | 4905 | | of the section. */ | 4906 | 21 | dst->symbol.value = src->u.syment.n_value; | 4907 | 21 | if (strcmp (dst->symbol.name, ".bf") != 0) | 4908 | 21 | { | 4909 | | /* PE uses funny values for .ef and .lf; don't | 4910 | | relocate them. */ | 4911 | 21 | dst->symbol.flags = BSF_DEBUGGING; | 4912 | 21 | } | 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 | 21 | break; | 4923 | | | 4924 | 1 | case C_STATLAB: /* Static load time label. */ | 4925 | 1 | dst->symbol.value = src->u.syment.n_value; | 4926 | 1 | dst->symbol.flags = BSF_GLOBAL; | 4927 | 1 | break; | 4928 | | | 4929 | 1.19k | case C_NULL: | 4930 | | /* PE DLLs sometimes have zeroed out symbols for some | 4931 | | reason. Just ignore them without a warning. */ | 4932 | 1.19k | if (src->u.syment.n_type == 0 | 4933 | 1.19k | && src->u.syment.n_value == 0 | 4934 | 1.19k | && src->u.syment.n_scnum == 0) | 4935 | 1.19k | 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 | 0 | case C_EXTDEF: /* External definition. */ | 4943 | 0 | case C_ULABEL: /* Undefined label. */ | 4944 | 0 | 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 | 0 | case C_EXTLAB: /* External load time label. */ | 4957 | 0 | default: | 4958 | 0 | _bfd_error_handler | 4959 | | /* xgettext:c-format */ | 4960 | 0 | (_("%pB: unrecognized storage class %d for %s symbol `%s'"), | 4961 | 0 | abfd, src->u.syment.n_sclass, | 4962 | 0 | dst->symbol.section->name, dst->symbol.name); | 4963 | 0 | ret = false; | 4964 | | /* Fall through. */ | 4965 | 1 | 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 | 1 | dst->symbol.flags = BSF_DEBUGGING; | 4969 | 1 | dst->symbol.value = (src->u.syment.n_value); | 4970 | 1 | break; | 4971 | 1.65k | } | 4972 | | | 4973 | 1.65k | dst->native = src; | 4974 | 1.65k | dst->symbol.udata.i = 0; | 4975 | 1.65k | dst->lineno = NULL; | 4976 | | | 4977 | 1.65k | this_index += (src->u.syment.n_numaux) + 1; | 4978 | 1.65k | dst++; | 4979 | 1.65k | number_of_symbols++; | 4980 | 1.65k | } | 4981 | 62 | } | 4982 | | | 4983 | 62 | obj_symbols (abfd) = cached_area; | 4984 | 62 | obj_raw_syments (abfd) = native_symbols; | 4985 | | | 4986 | 62 | abfd->symcount = number_of_symbols; | 4987 | 62 | obj_convert (abfd) = table_ptr; | 4988 | | /* Slurp the line tables for each section too. */ | 4989 | 62 | { | 4990 | 62 | asection *p; | 4991 | | | 4992 | 62 | p = abfd->sections; | 4993 | 883 | while (p) | 4994 | 821 | { | 4995 | 821 | if (! coff_slurp_line_table (abfd, p)) | 4996 | 0 | return false; | 4997 | 821 | p = p->next; | 4998 | 821 | } | 4999 | 62 | } | 5000 | | | 5001 | 62 | return ret; | 5002 | 62 | } |
pe-mcore.c:coff_slurp_symbol_table Line | Count | Source | 4630 | 158 | { | 4631 | 158 | combined_entry_type *native_symbols; | 4632 | 158 | coff_symbol_type *cached_area; | 4633 | 158 | unsigned int *table_ptr; | 4634 | 158 | unsigned int number_of_symbols = 0; | 4635 | 158 | bool ret = true; | 4636 | 158 | size_t amt; | 4637 | | | 4638 | 158 | if (obj_symbols (abfd)) | 4639 | 79 | return true; | 4640 | | | 4641 | | /* Read in the symbol table. */ | 4642 | 79 | if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) | 4643 | 0 | return false; | 4644 | | | 4645 | | /* Allocate enough room for all the symbols in cached form. */ | 4646 | 79 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4647 | 79 | sizeof (*cached_area), &amt)) | 4648 | 0 | { | 4649 | 0 | bfd_set_error (bfd_error_file_too_big); | 4650 | 0 | return false; | 4651 | 0 | } | 4652 | 79 | cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt); | 4653 | 79 | if (cached_area == NULL) | 4654 | 0 | return false; | 4655 | | | 4656 | 79 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4657 | 79 | sizeof (*table_ptr), &amt)) | 4658 | 0 | { | 4659 | 0 | bfd_set_error (bfd_error_file_too_big); | 4660 | 0 | return false; | 4661 | 0 | } | 4662 | 79 | table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); | 4663 | 79 | if (table_ptr == NULL) | 4664 | 0 | return false; | 4665 | 79 | else | 4666 | 79 | { | 4667 | 79 | coff_symbol_type *dst = cached_area; | 4668 | 79 | unsigned int last_native_index = obj_raw_syment_count (abfd); | 4669 | 79 | unsigned int this_index = 0; | 4670 | | | 4671 | 14.7k | while (this_index < last_native_index) | 4672 | 14.6k | { | 4673 | 14.6k | combined_entry_type *src = native_symbols + this_index; | 4674 | 14.6k | table_ptr[this_index] = number_of_symbols; | 4675 | | | 4676 | 14.6k | dst->symbol.the_bfd = abfd; | 4677 | 14.6k | BFD_ASSERT (src->is_sym); | 4678 | 14.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 | 14.6k | src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; | 4681 | 14.6k | dst->symbol.section = coff_section_from_bfd_index (abfd, | 4682 | 14.6k | src->u.syment.n_scnum); | 4683 | 14.6k | dst->symbol.flags = 0; | 4684 | | /* PR 17512: file: 079-7098-0.001:0.1. */ | 4685 | 14.6k | dst->symbol.value = 0; | 4686 | 14.6k | dst->done_lineno = false; | 4687 | | | 4688 | 14.6k | switch (src->u.syment.n_sclass) | 4689 | 14.6k | { | 4690 | 38 | case C_EXT: | 4691 | 52 | 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 | 52 | #ifdef C_SYSTEM | 4703 | 301 | case C_SYSTEM: /* System Wide variable. */ | 4704 | 301 | #endif | 4705 | 301 | #ifdef COFF_WITH_PE | 4706 | | /* In PE, 0x68 (104) denotes a section symbol. */ | 4707 | 308 | case C_SECTION: | 4708 | | /* In PE, 0x69 (105) denotes a weak external symbol. */ | 4709 | 357 | case C_NT_WEAK: | 4710 | 357 | #endif | 4711 | 357 | switch (coff_classify_symbol (abfd, &src->u.syment)) | 4712 | 357 | { | 4713 | 333 | case COFF_SYMBOL_GLOBAL: | 4714 | 333 | dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL; | 4715 | 333 | #if defined COFF_WITH_PE | 4716 | | /* PE sets the symbol to a value relative to the | 4717 | | start of the section. */ | 4718 | 333 | 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 | 333 | if (ISFCN ((src->u.syment.n_type))) | 4724 | | /* A function ext does not go at the end of a | 4725 | | file. */ | 4726 | 52 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4727 | 333 | break; | 4728 | | | 4729 | 6 | case COFF_SYMBOL_COMMON: | 4730 | 6 | dst->symbol.section = bfd_com_section_ptr; | 4731 | 6 | dst->symbol.value = src->u.syment.n_value; | 4732 | 6 | break; | 4733 | | | 4734 | 18 | case COFF_SYMBOL_UNDEFINED: | 4735 | 18 | dst->symbol.section = bfd_und_section_ptr; | 4736 | 18 | dst->symbol.value = 0; | 4737 | 18 | 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 | 357 | } | 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 | 357 | #ifdef COFF_WITH_PE | 4766 | 357 | if (src->u.syment.n_sclass == C_NT_WEAK) | 4767 | 49 | dst->symbol.flags |= BSF_WEAK; | 4768 | | | 4769 | 357 | if (src->u.syment.n_sclass == C_SECTION | 4770 | 357 | && src->u.syment.n_scnum > 0) | 4771 | 0 | dst->symbol.flags = BSF_LOCAL; | 4772 | 357 | #endif | 4773 | 357 | if (src->u.syment.n_sclass == C_WEAKEXT | 4774 | | #ifdef RS6000COFF_C | 4775 | | || src->u.syment.n_sclass == C_AIX_WEAKEXT | 4776 | | #endif | 4777 | 357 | ) | 4778 | 14 | dst->symbol.flags |= BSF_WEAK; | 4779 | | | 4780 | 357 | break; | 4781 | | | 4782 | 118 | 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 | 948 | case C_LABEL: /* Label. */ | 4793 | 948 | if (src->u.syment.n_scnum == N_DEBUG) | 4794 | 0 | dst->symbol.flags = BSF_DEBUGGING; | 4795 | 948 | else | 4796 | 948 | 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 | 948 | if (dst->symbol.section) | 4801 | 948 | { | 4802 | 948 | #if defined COFF_WITH_PE | 4803 | | /* PE sets the symbol to a value relative to the | 4804 | | start of the section. */ | 4805 | 948 | 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 | 948 | } | 4811 | 0 | else | 4812 | 0 | dst->symbol.value = src->u.syment.n_value; | 4813 | 948 | break; | 4814 | | | 4815 | 67 | case C_FILE: /* File name. */ | 4816 | 67 | dst->symbol.flags = BSF_FILE; | 4817 | | /* Fall through. */ | 4818 | 70 | case C_MOS: /* Member of structure. */ | 4819 | 153 | case C_EOS: /* End of structure. */ | 4820 | 213 | case C_REGPARM: /* Register parameter. */ | 4821 | 1.11k | case C_REG: /* register variable. */ | 4822 | | /* C_AUTOARG conflicts with TI COFF C_UEXT. */ | 4823 | 1.18k | case C_TPDEF: /* Type definition. */ | 4824 | 1.24k | case C_ARG: | 4825 | 4.92k | case C_AUTO: /* Automatic variable. */ | 4826 | 4.92k | case C_FIELD: /* Bit field. */ | 4827 | 4.93k | case C_ENTAG: /* Enumeration tag. */ | 4828 | 4.94k | case C_MOE: /* Member of enumeration. */ | 4829 | 5.69k | case C_MOU: /* Member of union. */ | 4830 | 6.23k | case C_UNTAG: /* Union tag. */ | 4831 | 6.44k | 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.44k | dst->symbol.flags |= BSF_DEBUGGING; | 4849 | 6.44k | dst->symbol.value = (src->u.syment.n_value); | 4850 | 6.44k | 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 | 4 | case C_BLOCK: /* ".bb" or ".eb". */ | 4901 | 10 | case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */ | 4902 | 57 | case C_EFCN: /* Physical end of function. */ | 4903 | 57 | #if defined COFF_WITH_PE | 4904 | | /* PE sets the symbol to a value relative to the start | 4905 | | of the section. */ | 4906 | 57 | dst->symbol.value = src->u.syment.n_value; | 4907 | 57 | if (strcmp (dst->symbol.name, ".bf") != 0) | 4908 | 57 | { | 4909 | | /* PE uses funny values for .ef and .lf; don't | 4910 | | relocate them. */ | 4911 | 57 | dst->symbol.flags = BSF_DEBUGGING; | 4912 | 57 | } | 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 | 57 | break; | 4923 | | | 4924 | 56 | case C_STATLAB: /* Static load time label. */ | 4925 | 56 | dst->symbol.value = src->u.syment.n_value; | 4926 | 56 | dst->symbol.flags = BSF_GLOBAL; | 4927 | 56 | break; | 4928 | | | 4929 | 6.82k | case C_NULL: | 4930 | | /* PE DLLs sometimes have zeroed out symbols for some | 4931 | | reason. Just ignore them without a warning. */ | 4932 | 6.82k | if (src->u.syment.n_type == 0 | 4933 | 6.82k | && src->u.syment.n_value == 0 | 4934 | 6.82k | && src->u.syment.n_scnum == 0) | 4935 | 6.82k | 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 | 0 | case C_EXTDEF: /* External definition. */ | 4943 | 0 | case C_ULABEL: /* Undefined label. */ | 4944 | 0 | 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 | 0 | case C_EXTLAB: /* External load time label. */ | 4957 | 0 | default: | 4958 | 0 | _bfd_error_handler | 4959 | | /* xgettext:c-format */ | 4960 | 0 | (_("%pB: unrecognized storage class %d for %s symbol `%s'"), | 4961 | 0 | abfd, src->u.syment.n_sclass, | 4962 | 0 | dst->symbol.section->name, dst->symbol.name); | 4963 | 0 | ret = false; | 4964 | | /* Fall through. */ | 4965 | 8 | 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 | 8 | dst->symbol.flags = BSF_DEBUGGING; | 4969 | 8 | dst->symbol.value = (src->u.syment.n_value); | 4970 | 8 | break; | 4971 | 14.6k | } | 4972 | | | 4973 | 14.6k | dst->native = src; | 4974 | 14.6k | dst->symbol.udata.i = 0; | 4975 | 14.6k | dst->lineno = NULL; | 4976 | | | 4977 | 14.6k | this_index += (src->u.syment.n_numaux) + 1; | 4978 | 14.6k | dst++; | 4979 | 14.6k | number_of_symbols++; | 4980 | 14.6k | } | 4981 | 79 | } | 4982 | | | 4983 | 79 | obj_symbols (abfd) = cached_area; | 4984 | 79 | obj_raw_syments (abfd) = native_symbols; | 4985 | | | 4986 | 79 | abfd->symcount = number_of_symbols; | 4987 | 79 | obj_convert (abfd) = table_ptr; | 4988 | | /* Slurp the line tables for each section too. */ | 4989 | 79 | { | 4990 | 79 | asection *p; | 4991 | | | 4992 | 79 | p = abfd->sections; | 4993 | 589 | while (p) | 4994 | 510 | { | 4995 | 510 | if (! coff_slurp_line_table (abfd, p)) | 4996 | 0 | return false; | 4997 | 510 | p = p->next; | 4998 | 510 | } | 4999 | 79 | } | 5000 | | | 5001 | 79 | return ret; | 5002 | 79 | } |
pe-sh.c:coff_slurp_symbol_table Line | Count | Source | 4630 | 134 | { | 4631 | 134 | combined_entry_type *native_symbols; | 4632 | 134 | coff_symbol_type *cached_area; | 4633 | 134 | unsigned int *table_ptr; | 4634 | 134 | unsigned int number_of_symbols = 0; | 4635 | 134 | bool ret = true; | 4636 | 134 | size_t amt; | 4637 | | | 4638 | 134 | if (obj_symbols (abfd)) | 4639 | 67 | return true; | 4640 | | | 4641 | | /* Read in the symbol table. */ | 4642 | 67 | if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) | 4643 | 0 | return false; | 4644 | | | 4645 | | /* Allocate enough room for all the symbols in cached form. */ | 4646 | 67 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4647 | 67 | sizeof (*cached_area), &amt)) | 4648 | 0 | { | 4649 | 0 | bfd_set_error (bfd_error_file_too_big); | 4650 | 0 | return false; | 4651 | 0 | } | 4652 | 67 | cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt); | 4653 | 67 | if (cached_area == NULL) | 4654 | 0 | return false; | 4655 | | | 4656 | 67 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4657 | 67 | sizeof (*table_ptr), &amt)) | 4658 | 0 | { | 4659 | 0 | bfd_set_error (bfd_error_file_too_big); | 4660 | 0 | return false; | 4661 | 0 | } | 4662 | 67 | table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); | 4663 | 67 | if (table_ptr == NULL) | 4664 | 0 | return false; | 4665 | 67 | else | 4666 | 67 | { | 4667 | 67 | coff_symbol_type *dst = cached_area; | 4668 | 67 | unsigned int last_native_index = obj_raw_syment_count (abfd); | 4669 | 67 | unsigned int this_index = 0; | 4670 | | | 4671 | 2.14k | while (this_index < last_native_index) | 4672 | 2.07k | { | 4673 | 2.07k | combined_entry_type *src = native_symbols + this_index; | 4674 | 2.07k | table_ptr[this_index] = number_of_symbols; | 4675 | | | 4676 | 2.07k | dst->symbol.the_bfd = abfd; | 4677 | 2.07k | BFD_ASSERT (src->is_sym); | 4678 | 2.07k | 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 | 2.07k | src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; | 4681 | 2.07k | dst->symbol.section = coff_section_from_bfd_index (abfd, | 4682 | 2.07k | src->u.syment.n_scnum); | 4683 | 2.07k | dst->symbol.flags = 0; | 4684 | | /* PR 17512: file: 079-7098-0.001:0.1. */ | 4685 | 2.07k | dst->symbol.value = 0; | 4686 | 2.07k | dst->done_lineno = false; | 4687 | | | 4688 | 2.07k | switch (src->u.syment.n_sclass) | 4689 | 2.07k | { | 4690 | 333 | case C_EXT: | 4691 | 345 | 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 | 345 | #ifdef C_SYSTEM | 4703 | 346 | case C_SYSTEM: /* System Wide variable. */ | 4704 | 346 | #endif | 4705 | 346 | #ifdef COFF_WITH_PE | 4706 | | /* In PE, 0x68 (104) denotes a section symbol. */ | 4707 | 346 | case C_SECTION: | 4708 | | /* In PE, 0x69 (105) denotes a weak external symbol. */ | 4709 | 351 | case C_NT_WEAK: | 4710 | 351 | #endif | 4711 | 351 | switch (coff_classify_symbol (abfd, &src->u.syment)) | 4712 | 351 | { | 4713 | 317 | case COFF_SYMBOL_GLOBAL: | 4714 | 317 | dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL; | 4715 | 317 | #if defined COFF_WITH_PE | 4716 | | /* PE sets the symbol to a value relative to the | 4717 | | start of the section. */ | 4718 | 317 | 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 | 317 | if (ISFCN ((src->u.syment.n_type))) | 4724 | | /* A function ext does not go at the end of a | 4725 | | file. */ | 4726 | 11 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4727 | 317 | break; | 4728 | | | 4729 | 8 | case COFF_SYMBOL_COMMON: | 4730 | 8 | dst->symbol.section = bfd_com_section_ptr; | 4731 | 8 | dst->symbol.value = src->u.syment.n_value; | 4732 | 8 | break; | 4733 | | | 4734 | 26 | case COFF_SYMBOL_UNDEFINED: | 4735 | 26 | dst->symbol.section = bfd_und_section_ptr; | 4736 | 26 | dst->symbol.value = 0; | 4737 | 26 | 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 | 351 | } | 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 | 351 | #ifdef COFF_WITH_PE | 4766 | 351 | if (src->u.syment.n_sclass == C_NT_WEAK) | 4767 | 5 | dst->symbol.flags |= BSF_WEAK; | 4768 | | | 4769 | 351 | if (src->u.syment.n_sclass == C_SECTION | 4770 | 351 | && src->u.syment.n_scnum > 0) | 4771 | 0 | dst->symbol.flags = BSF_LOCAL; | 4772 | 351 | #endif | 4773 | 351 | if (src->u.syment.n_sclass == C_WEAKEXT | 4774 | | #ifdef RS6000COFF_C | 4775 | | || src->u.syment.n_sclass == C_AIX_WEAKEXT | 4776 | | #endif | 4777 | 351 | ) | 4778 | 12 | dst->symbol.flags |= BSF_WEAK; | 4779 | | | 4780 | 351 | break; | 4781 | | | 4782 | 31 | 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 | 54 | case C_LABEL: /* Label. */ | 4793 | 54 | if (src->u.syment.n_scnum == N_DEBUG) | 4794 | 0 | dst->symbol.flags = BSF_DEBUGGING; | 4795 | 54 | else | 4796 | 54 | 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 | 54 | if (dst->symbol.section) | 4801 | 54 | { | 4802 | 54 | #if defined COFF_WITH_PE | 4803 | | /* PE sets the symbol to a value relative to the | 4804 | | start of the section. */ | 4805 | 54 | 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 | 54 | } | 4811 | 0 | else | 4812 | 0 | dst->symbol.value = src->u.syment.n_value; | 4813 | 54 | break; | 4814 | | | 4815 | 13 | case C_FILE: /* File name. */ | 4816 | 13 | dst->symbol.flags = BSF_FILE; | 4817 | | /* Fall through. */ | 4818 | 15 | case C_MOS: /* Member of structure. */ | 4819 | 16 | case C_EOS: /* End of structure. */ | 4820 | 24 | case C_REGPARM: /* Register parameter. */ | 4821 | 24 | case C_REG: /* register variable. */ | 4822 | | /* C_AUTOARG conflicts with TI COFF C_UEXT. */ | 4823 | 56 | case C_TPDEF: /* Type definition. */ | 4824 | 57 | case C_ARG: | 4825 | 114 | case C_AUTO: /* Automatic variable. */ | 4826 | 119 | case C_FIELD: /* Bit field. */ | 4827 | 138 | case C_ENTAG: /* Enumeration tag. */ | 4828 | 144 | case C_MOE: /* Member of enumeration. */ | 4829 | 151 | case C_MOU: /* Member of union. */ | 4830 | 155 | case C_UNTAG: /* Union tag. */ | 4831 | 161 | 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 | 161 | dst->symbol.flags |= BSF_DEBUGGING; | 4849 | 161 | dst->symbol.value = (src->u.syment.n_value); | 4850 | 161 | 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 | 1 | case C_BLOCK: /* ".bb" or ".eb". */ | 4901 | 4 | case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */ | 4902 | 31 | case C_EFCN: /* Physical end of function. */ | 4903 | 31 | #if defined COFF_WITH_PE | 4904 | | /* PE sets the symbol to a value relative to the start | 4905 | | of the section. */ | 4906 | 31 | dst->symbol.value = src->u.syment.n_value; | 4907 | 31 | if (strcmp (dst->symbol.name, ".bf") != 0) | 4908 | 31 | { | 4909 | | /* PE uses funny values for .ef and .lf; don't | 4910 | | relocate them. */ | 4911 | 31 | dst->symbol.flags = BSF_DEBUGGING; | 4912 | 31 | } | 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 | 31 | break; | 4923 | | | 4924 | 13 | case C_STATLAB: /* Static load time label. */ | 4925 | 13 | dst->symbol.value = src->u.syment.n_value; | 4926 | 13 | dst->symbol.flags = BSF_GLOBAL; | 4927 | 13 | break; | 4928 | | | 4929 | 1.45k | case C_NULL: | 4930 | | /* PE DLLs sometimes have zeroed out symbols for some | 4931 | | reason. Just ignore them without a warning. */ | 4932 | 1.45k | if (src->u.syment.n_type == 0 | 4933 | 1.45k | && src->u.syment.n_value == 0 | 4934 | 1.45k | && src->u.syment.n_scnum == 0) | 4935 | 1.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 | 0 | case C_EXTDEF: /* External definition. */ | 4943 | 0 | case C_ULABEL: /* Undefined label. */ | 4944 | 0 | 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 | 0 | case C_EXTLAB: /* External load time label. */ | 4957 | 0 | default: | 4958 | 0 | _bfd_error_handler | 4959 | | /* xgettext:c-format */ | 4960 | 0 | (_("%pB: unrecognized storage class %d for %s symbol `%s'"), | 4961 | 0 | abfd, src->u.syment.n_sclass, | 4962 | 0 | dst->symbol.section->name, dst->symbol.name); | 4963 | 0 | ret = false; | 4964 | | /* Fall through. */ | 4965 | 10 | 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 | dst->symbol.flags = BSF_DEBUGGING; | 4969 | 10 | dst->symbol.value = (src->u.syment.n_value); | 4970 | 10 | break; | 4971 | 2.07k | } | 4972 | | | 4973 | 2.07k | dst->native = src; | 4974 | 2.07k | dst->symbol.udata.i = 0; | 4975 | 2.07k | dst->lineno = NULL; | 4976 | | | 4977 | 2.07k | this_index += (src->u.syment.n_numaux) + 1; | 4978 | 2.07k | dst++; | 4979 | 2.07k | number_of_symbols++; | 4980 | 2.07k | } | 4981 | 67 | } | 4982 | | | 4983 | 67 | obj_symbols (abfd) = cached_area; | 4984 | 67 | obj_raw_syments (abfd) = native_symbols; | 4985 | | | 4986 | 67 | abfd->symcount = number_of_symbols; | 4987 | 67 | obj_convert (abfd) = table_ptr; | 4988 | | /* Slurp the line tables for each section too. */ | 4989 | 67 | { | 4990 | 67 | asection *p; | 4991 | | | 4992 | 67 | p = abfd->sections; | 4993 | 958 | while (p) | 4994 | 891 | { | 4995 | 891 | if (! coff_slurp_line_table (abfd, p)) | 4996 | 0 | return false; | 4997 | 891 | p = p->next; | 4998 | 891 | } | 4999 | 67 | } | 5000 | | | 5001 | 67 | return ret; | 5002 | 67 | } |
pei-arm-wince.c:coff_slurp_symbol_table Line | Count | Source | 4630 | 58 | { | 4631 | 58 | combined_entry_type *native_symbols; | 4632 | 58 | coff_symbol_type *cached_area; | 4633 | 58 | unsigned int *table_ptr; | 4634 | 58 | unsigned int number_of_symbols = 0; | 4635 | 58 | bool ret = true; | 4636 | 58 | size_t amt; | 4637 | | | 4638 | 58 | if (obj_symbols (abfd)) | 4639 | 29 | return true; | 4640 | | | 4641 | | /* Read in the symbol table. */ | 4642 | 29 | if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) | 4643 | 0 | return false; | 4644 | | | 4645 | | /* Allocate enough room for all the symbols in cached form. */ | 4646 | 29 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4647 | 29 | sizeof (*cached_area), &amt)) | 4648 | 0 | { | 4649 | 0 | bfd_set_error (bfd_error_file_too_big); | 4650 | 0 | return false; | 4651 | 0 | } | 4652 | 29 | cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt); | 4653 | 29 | if (cached_area == NULL) | 4654 | 0 | return false; | 4655 | | | 4656 | 29 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4657 | 29 | sizeof (*table_ptr), &amt)) | 4658 | 0 | { | 4659 | 0 | bfd_set_error (bfd_error_file_too_big); | 4660 | 0 | return false; | 4661 | 0 | } | 4662 | 29 | table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); | 4663 | 29 | if (table_ptr == NULL) | 4664 | 0 | return false; | 4665 | 29 | else | 4666 | 29 | { | 4667 | 29 | coff_symbol_type *dst = cached_area; | 4668 | 29 | unsigned int last_native_index = obj_raw_syment_count (abfd); | 4669 | 29 | unsigned int this_index = 0; | 4670 | | | 4671 | 67 | while (this_index < last_native_index) | 4672 | 38 | { | 4673 | 38 | combined_entry_type *src = native_symbols + this_index; | 4674 | 38 | table_ptr[this_index] = number_of_symbols; | 4675 | | | 4676 | 38 | dst->symbol.the_bfd = abfd; | 4677 | 38 | BFD_ASSERT (src->is_sym); | 4678 | 38 | 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 | 38 | src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; | 4681 | 38 | dst->symbol.section = coff_section_from_bfd_index (abfd, | 4682 | 38 | src->u.syment.n_scnum); | 4683 | 38 | dst->symbol.flags = 0; | 4684 | | /* PR 17512: file: 079-7098-0.001:0.1. */ | 4685 | 38 | dst->symbol.value = 0; | 4686 | 38 | dst->done_lineno = false; | 4687 | | | 4688 | 38 | switch (src->u.syment.n_sclass) | 4689 | 38 | { | 4690 | 4 | case C_EXT: | 4691 | 8 | case C_WEAKEXT: | 4692 | 8 | #if defined ARM | 4693 | 9 | case C_THUMBEXT: | 4694 | 10 | case C_THUMBEXTFUNC: | 4695 | 10 | #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 | 10 | #ifdef C_SYSTEM | 4703 | 10 | case C_SYSTEM: /* System Wide variable. */ | 4704 | 10 | #endif | 4705 | 10 | #ifdef COFF_WITH_PE | 4706 | | /* In PE, 0x68 (104) denotes a section symbol. */ | 4707 | 12 | case C_SECTION: | 4708 | | /* In PE, 0x69 (105) denotes a weak external symbol. */ | 4709 | 15 | case C_NT_WEAK: | 4710 | 15 | #endif | 4711 | 15 | switch (coff_classify_symbol (abfd, &src->u.syment)) | 4712 | 15 | { | 4713 | 11 | case COFF_SYMBOL_GLOBAL: | 4714 | 11 | dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL; | 4715 | 11 | #if defined COFF_WITH_PE | 4716 | | /* PE sets the symbol to a value relative to the | 4717 | | start of the section. */ | 4718 | 11 | 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 | 11 | if (ISFCN ((src->u.syment.n_type))) | 4724 | | /* A function ext does not go at the end of a | 4725 | | file. */ | 4726 | 6 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4727 | 11 | break; | 4728 | | | 4729 | 2 | case COFF_SYMBOL_COMMON: | 4730 | 2 | dst->symbol.section = bfd_com_section_ptr; | 4731 | 2 | dst->symbol.value = src->u.syment.n_value; | 4732 | 2 | break; | 4733 | | | 4734 | 2 | case COFF_SYMBOL_UNDEFINED: | 4735 | 2 | dst->symbol.section = bfd_und_section_ptr; | 4736 | 2 | dst->symbol.value = 0; | 4737 | 2 | 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 | 15 | } | 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 | 15 | #ifdef COFF_WITH_PE | 4766 | 15 | if (src->u.syment.n_sclass == C_NT_WEAK) | 4767 | 3 | dst->symbol.flags |= BSF_WEAK; | 4768 | | | 4769 | 15 | if (src->u.syment.n_sclass == C_SECTION | 4770 | 15 | && src->u.syment.n_scnum > 0) | 4771 | 0 | dst->symbol.flags = BSF_LOCAL; | 4772 | 15 | #endif | 4773 | 15 | if (src->u.syment.n_sclass == C_WEAKEXT | 4774 | | #ifdef RS6000COFF_C | 4775 | | || src->u.syment.n_sclass == C_AIX_WEAKEXT | 4776 | | #endif | 4777 | 15 | ) | 4778 | 4 | dst->symbol.flags |= BSF_WEAK; | 4779 | | | 4780 | 15 | break; | 4781 | | | 4782 | 6 | case C_STAT: /* Static. */ | 4783 | 6 | #if defined ARM | 4784 | 8 | case C_THUMBSTAT: /* Thumb static. */ | 4785 | 8 | case C_THUMBLABEL: /* Thumb label. */ | 4786 | 8 | case C_THUMBSTATFUNC:/* Thumb static function. */ | 4787 | 8 | #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 | 9 | case C_LABEL: /* Label. */ | 4793 | 9 | if (src->u.syment.n_scnum == N_DEBUG) | 4794 | 0 | dst->symbol.flags = BSF_DEBUGGING; | 4795 | 9 | else | 4796 | 9 | 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 | 9 | if (dst->symbol.section) | 4801 | 9 | { | 4802 | 9 | #if defined COFF_WITH_PE | 4803 | | /* PE sets the symbol to a value relative to the | 4804 | | start of the section. */ | 4805 | 9 | 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 | 9 | } | 4811 | 0 | else | 4812 | 0 | dst->symbol.value = src->u.syment.n_value; | 4813 | 9 | break; | 4814 | | | 4815 | 0 | case C_FILE: /* File name. */ | 4816 | 0 | dst->symbol.flags = BSF_FILE; | 4817 | | /* Fall through. */ | 4818 | 0 | case C_MOS: /* Member of structure. */ | 4819 | 1 | case C_EOS: /* End of structure. */ | 4820 | 2 | case C_REGPARM: /* Register parameter. */ | 4821 | 3 | case C_REG: /* register variable. */ | 4822 | | /* C_AUTOARG conflicts with TI COFF C_UEXT. */ | 4823 | 3 | case C_TPDEF: /* Type definition. */ | 4824 | 3 | case C_ARG: | 4825 | 4 | case C_AUTO: /* Automatic variable. */ | 4826 | 4 | case C_FIELD: /* Bit field. */ | 4827 | 4 | case C_ENTAG: /* Enumeration tag. */ | 4828 | 5 | case C_MOE: /* Member of enumeration. */ | 4829 | 6 | case C_MOU: /* Member of union. */ | 4830 | 6 | case C_UNTAG: /* Union tag. */ | 4831 | 6 | 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 | dst->symbol.flags |= BSF_DEBUGGING; | 4849 | 6 | dst->symbol.value = (src->u.syment.n_value); | 4850 | 6 | 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 | 1 | case C_BLOCK: /* ".bb" or ".eb". */ | 4901 | 1 | case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */ | 4902 | 2 | case C_EFCN: /* Physical end of function. */ | 4903 | 2 | #if defined COFF_WITH_PE | 4904 | | /* PE sets the symbol to a value relative to the start | 4905 | | of the section. */ | 4906 | 2 | dst->symbol.value = src->u.syment.n_value; | 4907 | 2 | if (strcmp (dst->symbol.name, ".bf") != 0) | 4908 | 2 | { | 4909 | | /* PE uses funny values for .ef and .lf; don't | 4910 | | relocate them. */ | 4911 | 2 | dst->symbol.flags = BSF_DEBUGGING; | 4912 | 2 | } | 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 | 2 | break; | 4923 | | | 4924 | 1 | case C_STATLAB: /* Static load time label. */ | 4925 | 1 | dst->symbol.value = src->u.syment.n_value; | 4926 | 1 | dst->symbol.flags = BSF_GLOBAL; | 4927 | 1 | break; | 4928 | | | 4929 | 3 | case C_NULL: | 4930 | | /* PE DLLs sometimes have zeroed out symbols for some | 4931 | | reason. Just ignore them without a warning. */ | 4932 | 3 | if (src->u.syment.n_type == 0 | 4933 | 3 | && src->u.syment.n_value == 0 | 4934 | 3 | && src->u.syment.n_scnum == 0) | 4935 | 3 | 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 | 0 | case C_EXTDEF: /* External definition. */ | 4943 | 0 | case C_ULABEL: /* Undefined label. */ | 4944 | 0 | 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 | 0 | case C_EXTLAB: /* External load time label. */ | 4957 | 0 | default: | 4958 | 0 | _bfd_error_handler | 4959 | | /* xgettext:c-format */ | 4960 | 0 | (_("%pB: unrecognized storage class %d for %s symbol `%s'"), | 4961 | 0 | abfd, src->u.syment.n_sclass, | 4962 | 0 | dst->symbol.section->name, dst->symbol.name); | 4963 | 0 | ret = false; | 4964 | | /* Fall through. */ | 4965 | 2 | 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 | dst->symbol.flags = BSF_DEBUGGING; | 4969 | 2 | dst->symbol.value = (src->u.syment.n_value); | 4970 | 2 | break; | 4971 | 38 | } | 4972 | | | 4973 | 38 | dst->native = src; | 4974 | 38 | dst->symbol.udata.i = 0; | 4975 | 38 | dst->lineno = NULL; | 4976 | | | 4977 | 38 | this_index += (src->u.syment.n_numaux) + 1; | 4978 | 38 | dst++; | 4979 | 38 | number_of_symbols++; | 4980 | 38 | } | 4981 | 29 | } | 4982 | | | 4983 | 29 | obj_symbols (abfd) = cached_area; | 4984 | 29 | obj_raw_syments (abfd) = native_symbols; | 4985 | | | 4986 | 29 | abfd->symcount = number_of_symbols; | 4987 | 29 | obj_convert (abfd) = table_ptr; | 4988 | | /* Slurp the line tables for each section too. */ | 4989 | 29 | { | 4990 | 29 | asection *p; | 4991 | | | 4992 | 29 | p = abfd->sections; | 4993 | 48 | while (p) | 4994 | 19 | { | 4995 | 19 | if (! coff_slurp_line_table (abfd, p)) | 4996 | 0 | return false; | 4997 | 19 | p = p->next; | 4998 | 19 | } | 4999 | 29 | } | 5000 | | | 5001 | 29 | return ret; | 5002 | 29 | } |
pei-arm.c:coff_slurp_symbol_table Line | Count | Source | 4630 | 116 | { | 4631 | 116 | combined_entry_type *native_symbols; | 4632 | 116 | coff_symbol_type *cached_area; | 4633 | 116 | unsigned int *table_ptr; | 4634 | 116 | unsigned int number_of_symbols = 0; | 4635 | 116 | bool ret = true; | 4636 | 116 | size_t amt; | 4637 | | | 4638 | 116 | if (obj_symbols (abfd)) | 4639 | 58 | return true; | 4640 | | | 4641 | | /* Read in the symbol table. */ | 4642 | 58 | if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) | 4643 | 0 | return false; | 4644 | | | 4645 | | /* Allocate enough room for all the symbols in cached form. */ | 4646 | 58 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4647 | 58 | sizeof (*cached_area), &amt)) | 4648 | 0 | { | 4649 | 0 | bfd_set_error (bfd_error_file_too_big); | 4650 | 0 | return false; | 4651 | 0 | } | 4652 | 58 | cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt); | 4653 | 58 | if (cached_area == NULL) | 4654 | 0 | return false; | 4655 | | | 4656 | 58 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4657 | 58 | sizeof (*table_ptr), &amt)) | 4658 | 0 | { | 4659 | 0 | bfd_set_error (bfd_error_file_too_big); | 4660 | 0 | return false; | 4661 | 0 | } | 4662 | 58 | table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); | 4663 | 58 | if (table_ptr == NULL) | 4664 | 0 | return false; | 4665 | 58 | else | 4666 | 58 | { | 4667 | 58 | coff_symbol_type *dst = cached_area; | 4668 | 58 | unsigned int last_native_index = obj_raw_syment_count (abfd); | 4669 | 58 | unsigned int this_index = 0; | 4670 | | | 4671 | 255 | while (this_index < last_native_index) | 4672 | 197 | { | 4673 | 197 | combined_entry_type *src = native_symbols + this_index; | 4674 | 197 | table_ptr[this_index] = number_of_symbols; | 4675 | | | 4676 | 197 | dst->symbol.the_bfd = abfd; | 4677 | 197 | BFD_ASSERT (src->is_sym); | 4678 | 197 | 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 | 197 | src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; | 4681 | 197 | dst->symbol.section = coff_section_from_bfd_index (abfd, | 4682 | 197 | src->u.syment.n_scnum); | 4683 | 197 | dst->symbol.flags = 0; | 4684 | | /* PR 17512: file: 079-7098-0.001:0.1. */ | 4685 | 197 | dst->symbol.value = 0; | 4686 | 197 | dst->done_lineno = false; | 4687 | | | 4688 | 197 | switch (src->u.syment.n_sclass) | 4689 | 197 | { | 4690 | 4 | case C_EXT: | 4691 | 7 | case C_WEAKEXT: | 4692 | 7 | #if defined ARM | 4693 | 8 | case C_THUMBEXT: | 4694 | 9 | case C_THUMBEXTFUNC: | 4695 | 9 | #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 | 9 | #ifdef C_SYSTEM | 4703 | 9 | case C_SYSTEM: /* System Wide variable. */ | 4704 | 9 | #endif | 4705 | 9 | #ifdef COFF_WITH_PE | 4706 | | /* In PE, 0x68 (104) denotes a section symbol. */ | 4707 | 10 | case C_SECTION: | 4708 | | /* In PE, 0x69 (105) denotes a weak external symbol. */ | 4709 | 11 | case C_NT_WEAK: | 4710 | 11 | #endif | 4711 | 11 | switch (coff_classify_symbol (abfd, &src->u.syment)) | 4712 | 11 | { | 4713 | 6 | case COFF_SYMBOL_GLOBAL: | 4714 | 6 | dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL; | 4715 | 6 | #if defined COFF_WITH_PE | 4716 | | /* PE sets the symbol to a value relative to the | 4717 | | start of the section. */ | 4718 | 6 | 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 | 6 | 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 | 6 | break; | 4728 | | | 4729 | 3 | case COFF_SYMBOL_COMMON: | 4730 | 3 | dst->symbol.section = bfd_com_section_ptr; | 4731 | 3 | dst->symbol.value = src->u.syment.n_value; | 4732 | 3 | break; | 4733 | | | 4734 | 2 | case COFF_SYMBOL_UNDEFINED: | 4735 | 2 | dst->symbol.section = bfd_und_section_ptr; | 4736 | 2 | dst->symbol.value = 0; | 4737 | 2 | 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 | 11 | } | 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 | 11 | #ifdef COFF_WITH_PE | 4766 | 11 | if (src->u.syment.n_sclass == C_NT_WEAK) | 4767 | 1 | dst->symbol.flags |= BSF_WEAK; | 4768 | | | 4769 | 11 | if (src->u.syment.n_sclass == C_SECTION | 4770 | 11 | && src->u.syment.n_scnum > 0) | 4771 | 0 | dst->symbol.flags = BSF_LOCAL; | 4772 | 11 | #endif | 4773 | 11 | if (src->u.syment.n_sclass == C_WEAKEXT | 4774 | | #ifdef RS6000COFF_C | 4775 | | || src->u.syment.n_sclass == C_AIX_WEAKEXT | 4776 | | #endif | 4777 | 11 | ) | 4778 | 3 | dst->symbol.flags |= BSF_WEAK; | 4779 | | | 4780 | 11 | break; | 4781 | | | 4782 | 20 | case C_STAT: /* Static. */ | 4783 | 20 | #if defined ARM | 4784 | 22 | case C_THUMBSTAT: /* Thumb static. */ | 4785 | 22 | case C_THUMBLABEL: /* Thumb label. */ | 4786 | 22 | case C_THUMBSTATFUNC:/* Thumb static function. */ | 4787 | 22 | #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 | 23 | case C_LABEL: /* Label. */ | 4793 | 23 | if (src->u.syment.n_scnum == N_DEBUG) | 4794 | 0 | dst->symbol.flags = BSF_DEBUGGING; | 4795 | 23 | else | 4796 | 23 | 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 | 23 | if (dst->symbol.section) | 4801 | 23 | { | 4802 | 23 | #if defined COFF_WITH_PE | 4803 | | /* PE sets the symbol to a value relative to the | 4804 | | start of the section. */ | 4805 | 23 | 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 | 23 | } | 4811 | 0 | else | 4812 | 0 | dst->symbol.value = src->u.syment.n_value; | 4813 | 23 | break; | 4814 | | | 4815 | 1 | case C_FILE: /* File name. */ | 4816 | 1 | dst->symbol.flags = BSF_FILE; | 4817 | | /* Fall through. */ | 4818 | 2 | case C_MOS: /* Member of structure. */ | 4819 | 3 | case C_EOS: /* End of structure. */ | 4820 | 3 | case C_REGPARM: /* Register parameter. */ | 4821 | 10 | case C_REG: /* register variable. */ | 4822 | | /* C_AUTOARG conflicts with TI COFF C_UEXT. */ | 4823 | 10 | case C_TPDEF: /* Type definition. */ | 4824 | 11 | case C_ARG: | 4825 | 13 | case C_AUTO: /* Automatic variable. */ | 4826 | 14 | case C_FIELD: /* Bit field. */ | 4827 | 14 | case C_ENTAG: /* Enumeration tag. */ | 4828 | 20 | case C_MOE: /* Member of enumeration. */ | 4829 | 21 | case C_MOU: /* Member of union. */ | 4830 | 21 | case C_UNTAG: /* Union tag. */ | 4831 | 44 | 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 | 44 | dst->symbol.flags |= BSF_DEBUGGING; | 4849 | 44 | dst->symbol.value = (src->u.syment.n_value); | 4850 | 44 | 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 | 13 | case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */ | 4902 | 40 | case C_EFCN: /* Physical end of function. */ | 4903 | 40 | #if defined COFF_WITH_PE | 4904 | | /* PE sets the symbol to a value relative to the start | 4905 | | of the section. */ | 4906 | 40 | dst->symbol.value = src->u.syment.n_value; | 4907 | 40 | if (strcmp (dst->symbol.name, ".bf") != 0) | 4908 | 40 | { | 4909 | | /* PE uses funny values for .ef and .lf; don't | 4910 | | relocate them. */ | 4911 | 40 | dst->symbol.flags = BSF_DEBUGGING; | 4912 | 40 | } | 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 | 40 | break; | 4923 | | | 4924 | 1 | case C_STATLAB: /* Static load time label. */ | 4925 | 1 | dst->symbol.value = src->u.syment.n_value; | 4926 | 1 | dst->symbol.flags = BSF_GLOBAL; | 4927 | 1 | break; | 4928 | | | 4929 | 77 | case C_NULL: | 4930 | | /* PE DLLs sometimes have zeroed out symbols for some | 4931 | | reason. Just ignore them without a warning. */ | 4932 | 77 | if (src->u.syment.n_type == 0 | 4933 | 77 | && src->u.syment.n_value == 0 | 4934 | 77 | && src->u.syment.n_scnum == 0) | 4935 | 77 | 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 | 0 | case C_EXTDEF: /* External definition. */ | 4943 | 0 | case C_ULABEL: /* Undefined label. */ | 4944 | 0 | 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 | 0 | case C_EXTLAB: /* External load time label. */ | 4957 | 0 | default: | 4958 | 0 | _bfd_error_handler | 4959 | | /* xgettext:c-format */ | 4960 | 0 | (_("%pB: unrecognized storage class %d for %s symbol `%s'"), | 4961 | 0 | abfd, src->u.syment.n_sclass, | 4962 | 0 | dst->symbol.section->name, dst->symbol.name); | 4963 | 0 | ret = false; | 4964 | | /* Fall through. */ | 4965 | 1 | 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 | 1 | dst->symbol.flags = BSF_DEBUGGING; | 4969 | 1 | dst->symbol.value = (src->u.syment.n_value); | 4970 | 1 | break; | 4971 | 197 | } | 4972 | | | 4973 | 197 | dst->native = src; | 4974 | 197 | dst->symbol.udata.i = 0; | 4975 | 197 | dst->lineno = NULL; | 4976 | | | 4977 | 197 | this_index += (src->u.syment.n_numaux) + 1; | 4978 | 197 | dst++; | 4979 | 197 | number_of_symbols++; | 4980 | 197 | } | 4981 | 58 | } | 4982 | | | 4983 | 58 | obj_symbols (abfd) = cached_area; | 4984 | 58 | obj_raw_syments (abfd) = native_symbols; | 4985 | | | 4986 | 58 | abfd->symcount = number_of_symbols; | 4987 | 58 | obj_convert (abfd) = table_ptr; | 4988 | | /* Slurp the line tables for each section too. */ | 4989 | 58 | { | 4990 | 58 | asection *p; | 4991 | | | 4992 | 58 | p = abfd->sections; | 4993 | 319 | while (p) | 4994 | 261 | { | 4995 | 261 | if (! coff_slurp_line_table (abfd, p)) | 4996 | 0 | return false; | 4997 | 261 | p = p->next; | 4998 | 261 | } | 4999 | 58 | } | 5000 | | | 5001 | 58 | return ret; | 5002 | 58 | } |
pei-mcore.c:coff_slurp_symbol_table Line | Count | Source | 4630 | 88 | { | 4631 | 88 | combined_entry_type *native_symbols; | 4632 | 88 | coff_symbol_type *cached_area; | 4633 | 88 | unsigned int *table_ptr; | 4634 | 88 | unsigned int number_of_symbols = 0; | 4635 | 88 | bool ret = true; | 4636 | 88 | size_t amt; | 4637 | | | 4638 | 88 | if (obj_symbols (abfd)) | 4639 | 44 | return true; | 4640 | | | 4641 | | /* Read in the symbol table. */ | 4642 | 44 | if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) | 4643 | 0 | return false; | 4644 | | | 4645 | | /* Allocate enough room for all the symbols in cached form. */ | 4646 | 44 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4647 | 44 | sizeof (*cached_area), &amt)) | 4648 | 0 | { | 4649 | 0 | bfd_set_error (bfd_error_file_too_big); | 4650 | 0 | return false; | 4651 | 0 | } | 4652 | 44 | cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt); | 4653 | 44 | if (cached_area == NULL) | 4654 | 0 | return false; | 4655 | | | 4656 | 44 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4657 | 44 | sizeof (*table_ptr), &amt)) | 4658 | 0 | { | 4659 | 0 | bfd_set_error (bfd_error_file_too_big); | 4660 | 0 | return false; | 4661 | 0 | } | 4662 | 44 | table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); | 4663 | 44 | if (table_ptr == NULL) | 4664 | 0 | return false; | 4665 | 44 | else | 4666 | 44 | { | 4667 | 44 | coff_symbol_type *dst = cached_area; | 4668 | 44 | unsigned int last_native_index = obj_raw_syment_count (abfd); | 4669 | 44 | unsigned int this_index = 0; | 4670 | | | 4671 | 307 | while (this_index < last_native_index) | 4672 | 263 | { | 4673 | 263 | combined_entry_type *src = native_symbols + this_index; | 4674 | 263 | table_ptr[this_index] = number_of_symbols; | 4675 | | | 4676 | 263 | dst->symbol.the_bfd = abfd; | 4677 | 263 | BFD_ASSERT (src->is_sym); | 4678 | 263 | 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 | 263 | src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; | 4681 | 263 | dst->symbol.section = coff_section_from_bfd_index (abfd, | 4682 | 263 | src->u.syment.n_scnum); | 4683 | 263 | dst->symbol.flags = 0; | 4684 | | /* PR 17512: file: 079-7098-0.001:0.1. */ | 4685 | 263 | dst->symbol.value = 0; | 4686 | 263 | dst->done_lineno = false; | 4687 | | | 4688 | 263 | switch (src->u.syment.n_sclass) | 4689 | 263 | { | 4690 | 17 | case C_EXT: | 4691 | 32 | 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 | 32 | #ifdef C_SYSTEM | 4703 | 41 | case C_SYSTEM: /* System Wide variable. */ | 4704 | 41 | #endif | 4705 | 41 | #ifdef COFF_WITH_PE | 4706 | | /* In PE, 0x68 (104) denotes a section symbol. */ | 4707 | 43 | case C_SECTION: | 4708 | | /* In PE, 0x69 (105) denotes a weak external symbol. */ | 4709 | 46 | case C_NT_WEAK: | 4710 | 46 | #endif | 4711 | 46 | switch (coff_classify_symbol (abfd, &src->u.syment)) | 4712 | 46 | { | 4713 | 22 | case COFF_SYMBOL_GLOBAL: | 4714 | 22 | dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL; | 4715 | 22 | #if defined COFF_WITH_PE | 4716 | | /* PE sets the symbol to a value relative to the | 4717 | | start of the section. */ | 4718 | 22 | 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 | 22 | 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 | 22 | break; | 4728 | | | 4729 | 2 | case COFF_SYMBOL_COMMON: | 4730 | 2 | dst->symbol.section = bfd_com_section_ptr; | 4731 | 2 | dst->symbol.value = src->u.syment.n_value; | 4732 | 2 | break; | 4733 | | | 4734 | 22 | case COFF_SYMBOL_UNDEFINED: | 4735 | 22 | dst->symbol.section = bfd_und_section_ptr; | 4736 | 22 | dst->symbol.value = 0; | 4737 | 22 | 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 | 46 | } | 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 | 46 | #ifdef COFF_WITH_PE | 4766 | 46 | if (src->u.syment.n_sclass == C_NT_WEAK) | 4767 | 3 | dst->symbol.flags |= BSF_WEAK; | 4768 | | | 4769 | 46 | if (src->u.syment.n_sclass == C_SECTION | 4770 | 46 | && src->u.syment.n_scnum > 0) | 4771 | 0 | dst->symbol.flags = BSF_LOCAL; | 4772 | 46 | #endif | 4773 | 46 | if (src->u.syment.n_sclass == C_WEAKEXT | 4774 | | #ifdef RS6000COFF_C | 4775 | | || src->u.syment.n_sclass == C_AIX_WEAKEXT | 4776 | | #endif | 4777 | 46 | ) | 4778 | 15 | dst->symbol.flags |= BSF_WEAK; | 4779 | | | 4780 | 46 | break; | 4781 | | | 4782 | 11 | 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 | 11 | case C_LABEL: /* Label. */ | 4793 | 11 | if (src->u.syment.n_scnum == N_DEBUG) | 4794 | 2 | dst->symbol.flags = BSF_DEBUGGING; | 4795 | 9 | else | 4796 | 9 | 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 | 11 | if (dst->symbol.section) | 4801 | 11 | { | 4802 | 11 | #if defined COFF_WITH_PE | 4803 | | /* PE sets the symbol to a value relative to the | 4804 | | start of the section. */ | 4805 | 11 | 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 | 11 | } | 4811 | 0 | else | 4812 | 0 | dst->symbol.value = src->u.syment.n_value; | 4813 | 11 | break; | 4814 | | | 4815 | 4 | case C_FILE: /* File name. */ | 4816 | 4 | dst->symbol.flags = BSF_FILE; | 4817 | | /* Fall through. */ | 4818 | 4 | case C_MOS: /* Member of structure. */ | 4819 | 4 | case C_EOS: /* End of structure. */ | 4820 | 5 | case C_REGPARM: /* Register parameter. */ | 4821 | 7 | case C_REG: /* register variable. */ | 4822 | | /* C_AUTOARG conflicts with TI COFF C_UEXT. */ | 4823 | 7 | case C_TPDEF: /* Type definition. */ | 4824 | 9 | case C_ARG: | 4825 | 10 | case C_AUTO: /* Automatic variable. */ | 4826 | 11 | case C_FIELD: /* Bit field. */ | 4827 | 12 | case C_ENTAG: /* Enumeration tag. */ | 4828 | 18 | case C_MOE: /* Member of enumeration. */ | 4829 | 19 | case C_MOU: /* Member of union. */ | 4830 | 20 | case C_UNTAG: /* Union tag. */ | 4831 | 27 | 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 | 27 | dst->symbol.flags |= BSF_DEBUGGING; | 4849 | 27 | dst->symbol.value = (src->u.syment.n_value); | 4850 | 27 | 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 | 4 | case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */ | 4902 | 25 | case C_EFCN: /* Physical end of function. */ | 4903 | 25 | #if defined COFF_WITH_PE | 4904 | | /* PE sets the symbol to a value relative to the start | 4905 | | of the section. */ | 4906 | 25 | dst->symbol.value = src->u.syment.n_value; | 4907 | 25 | if (strcmp (dst->symbol.name, ".bf") != 0) | 4908 | 25 | { | 4909 | | /* PE uses funny values for .ef and .lf; don't | 4910 | | relocate them. */ | 4911 | 25 | dst->symbol.flags = BSF_DEBUGGING; | 4912 | 25 | } | 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 | 25 | break; | 4923 | | | 4924 | 4 | case C_STATLAB: /* Static load time label. */ | 4925 | 4 | dst->symbol.value = src->u.syment.n_value; | 4926 | 4 | dst->symbol.flags = BSF_GLOBAL; | 4927 | 4 | break; | 4928 | | | 4929 | 146 | case C_NULL: | 4930 | | /* PE DLLs sometimes have zeroed out symbols for some | 4931 | | reason. Just ignore them without a warning. */ | 4932 | 146 | if (src->u.syment.n_type == 0 | 4933 | 146 | && src->u.syment.n_value == 0 | 4934 | 146 | && src->u.syment.n_scnum == 0) | 4935 | 146 | 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 | 0 | case C_EXTDEF: /* External definition. */ | 4943 | 0 | case C_ULABEL: /* Undefined label. */ | 4944 | 0 | 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 | 0 | case C_EXTLAB: /* External load time label. */ | 4957 | 0 | default: | 4958 | 0 | _bfd_error_handler | 4959 | | /* xgettext:c-format */ | 4960 | 0 | (_("%pB: unrecognized storage class %d for %s symbol `%s'"), | 4961 | 0 | abfd, src->u.syment.n_sclass, | 4962 | 0 | dst->symbol.section->name, dst->symbol.name); | 4963 | 0 | ret = false; | 4964 | | /* Fall through. */ | 4965 | 4 | 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 | 4 | dst->symbol.flags = BSF_DEBUGGING; | 4969 | 4 | dst->symbol.value = (src->u.syment.n_value); | 4970 | 4 | break; | 4971 | 263 | } | 4972 | | | 4973 | 263 | dst->native = src; | 4974 | 263 | dst->symbol.udata.i = 0; | 4975 | 263 | dst->lineno = NULL; | 4976 | | | 4977 | 263 | this_index += (src->u.syment.n_numaux) + 1; | 4978 | 263 | dst++; | 4979 | 263 | number_of_symbols++; | 4980 | 263 | } | 4981 | 44 | } | 4982 | | | 4983 | 44 | obj_symbols (abfd) = cached_area; | 4984 | 44 | obj_raw_syments (abfd) = native_symbols; | 4985 | | | 4986 | 44 | abfd->symcount = number_of_symbols; | 4987 | 44 | obj_convert (abfd) = table_ptr; | 4988 | | /* Slurp the line tables for each section too. */ | 4989 | 44 | { | 4990 | 44 | asection *p; | 4991 | | | 4992 | 44 | p = abfd->sections; | 4993 | 309 | while (p) | 4994 | 265 | { | 4995 | 265 | if (! coff_slurp_line_table (abfd, p)) | 4996 | 0 | return false; | 4997 | 265 | p = p->next; | 4998 | 265 | } | 4999 | 44 | } | 5000 | | | 5001 | 44 | return ret; | 5002 | 44 | } |
pei-sh.c:coff_slurp_symbol_table Line | Count | Source | 4630 | 122 | { | 4631 | 122 | combined_entry_type *native_symbols; | 4632 | 122 | coff_symbol_type *cached_area; | 4633 | 122 | unsigned int *table_ptr; | 4634 | 122 | unsigned int number_of_symbols = 0; | 4635 | 122 | bool ret = true; | 4636 | 122 | size_t amt; | 4637 | | | 4638 | 122 | if (obj_symbols (abfd)) | 4639 | 61 | return true; | 4640 | | | 4641 | | /* Read in the symbol table. */ | 4642 | 61 | if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) | 4643 | 0 | return false; | 4644 | | | 4645 | | /* Allocate enough room for all the symbols in cached form. */ | 4646 | 61 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4647 | 61 | sizeof (*cached_area), &amt)) | 4648 | 0 | { | 4649 | 0 | bfd_set_error (bfd_error_file_too_big); | 4650 | 0 | return false; | 4651 | 0 | } | 4652 | 61 | cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt); | 4653 | 61 | if (cached_area == NULL) | 4654 | 0 | return false; | 4655 | | | 4656 | 61 | if (_bfd_mul_overflow (obj_raw_syment_count (abfd), | 4657 | 61 | sizeof (*table_ptr), &amt)) | 4658 | 0 | { | 4659 | 0 | bfd_set_error (bfd_error_file_too_big); | 4660 | 0 | return false; | 4661 | 0 | } | 4662 | 61 | table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); | 4663 | 61 | if (table_ptr == NULL) | 4664 | 0 | return false; | 4665 | 61 | else | 4666 | 61 | { | 4667 | 61 | coff_symbol_type *dst = cached_area; | 4668 | 61 | unsigned int last_native_index = obj_raw_syment_count (abfd); | 4669 | 61 | unsigned int this_index = 0; | 4670 | | | 4671 | 788 | while (this_index < last_native_index) | 4672 | 727 | { | 4673 | 727 | combined_entry_type *src = native_symbols + this_index; | 4674 | 727 | table_ptr[this_index] = number_of_symbols; | 4675 | | | 4676 | 727 | dst->symbol.the_bfd = abfd; | 4677 | 727 | BFD_ASSERT (src->is_sym); | 4678 | 727 | 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 | 727 | src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; | 4681 | 727 | dst->symbol.section = coff_section_from_bfd_index (abfd, | 4682 | 727 | src->u.syment.n_scnum); | 4683 | 727 | dst->symbol.flags = 0; | 4684 | | /* PR 17512: file: 079-7098-0.001:0.1. */ | 4685 | 727 | dst->symbol.value = 0; | 4686 | 727 | dst->done_lineno = false; | 4687 | | | 4688 | 727 | switch (src->u.syment.n_sclass) | 4689 | 727 | { | 4690 | 75 | case C_EXT: | 4691 | 89 | 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 | 89 | #ifdef C_SYSTEM | 4703 | 107 | case C_SYSTEM: /* System Wide variable. */ | 4704 | 107 | #endif | 4705 | 107 | #ifdef COFF_WITH_PE | 4706 | | /* In PE, 0x68 (104) denotes a section symbol. */ | 4707 | 110 | case C_SECTION: | 4708 | | /* In PE, 0x69 (105) denotes a weak external symbol. */ | 4709 | 116 | case C_NT_WEAK: | 4710 | 116 | #endif | 4711 | 116 | switch (coff_classify_symbol (abfd, &src->u.syment)) | 4712 | 116 | { | 4713 | 84 | case COFF_SYMBOL_GLOBAL: | 4714 | 84 | dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL; | 4715 | 84 | #if defined COFF_WITH_PE | 4716 | | /* PE sets the symbol to a value relative to the | 4717 | | start of the section. */ | 4718 | 84 | 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 | 84 | if (ISFCN ((src->u.syment.n_type))) | 4724 | | /* A function ext does not go at the end of a | 4725 | | file. */ | 4726 | 16 | dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; | 4727 | 84 | break; | 4728 | | | 4729 | 13 | case COFF_SYMBOL_COMMON: | 4730 | 13 | dst->symbol.section = bfd_com_section_ptr; | 4731 | 13 | dst->symbol.value = src->u.syment.n_value; | 4732 | 13 | break; | 4733 | | | 4734 | 19 | case COFF_SYMBOL_UNDEFINED: | 4735 | 19 | dst->symbol.section = bfd_und_section_ptr; | 4736 | 19 | dst->symbol.value = 0; | 4737 | 19 | 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 | 116 | } | 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 | 116 | #ifdef COFF_WITH_PE | 4766 | 116 | if (src->u.syment.n_sclass == C_NT_WEAK) | 4767 | 6 | dst->symbol.flags |= BSF_WEAK; | 4768 | | | 4769 | 116 | if (src->u.syment.n_sclass == C_SECTION | 4770 | 116 | && src->u.syment.n_scnum > 0) | 4771 | 0 | dst->symbol.flags = BSF_LOCAL; | 4772 | 116 | #endif | 4773 | 116 | if (src->u.syment.n_sclass == C_WEAKEXT | 4774 | | #ifdef RS6000COFF_C | 4775 | | || src->u.syment.n_sclass == C_AIX_WEAKEXT | 4776 | | #endif | 4777 | 116 | ) | 4778 | 14 | dst->symbol.flags |= BSF_WEAK; | 4779 | | | 4780 | 116 | break; | 4781 | | | 4782 | 25 | 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 | 47 | case C_LABEL: /* Label. */ | 4793 | 47 | if (src->u.syment.n_scnum == N_DEBUG) | 4794 | 0 | dst->symbol.flags = BSF_DEBUGGING; | 4795 | 47 | else | 4796 | 47 | 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 | 47 | if (dst->symbol.section) | 4801 | 47 | { | 4802 | 47 | #if defined COFF_WITH_PE | 4803 | | /* PE sets the symbol to a value relative to the | 4804 | | start of the section. */ | 4805 | 47 | 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 | 47 | } | 4811 | 0 | else | 4812 | 0 | dst->symbol.value = src->u.syment.n_value; | 4813 | 47 | break; | 4814 | | | 4815 | 6 | case C_FILE: /* File name. */ | 4816 | 6 | dst->symbol.flags = BSF_FILE; | 4817 | | /* Fall through. */ | 4818 | 17 | case C_MOS: /* Member of structure. */ | 4819 | 18 | case C_EOS: /* End of structure. */ | 4820 | 29 | case C_REGPARM: /* Register parameter. */ | 4821 | 33 | case C_REG: /* register variable. */ | 4822 | | /* C_AUTOARG conflicts with TI COFF C_UEXT. */ | 4823 | 38 | case C_TPDEF: /* Type definition. */ | 4824 | 51 | case C_ARG: | 4825 | 184 | case C_AUTO: /* Automatic variable. */ | 4826 | 203 | case C_FIELD: /* Bit field. */ | 4827 | 208 | case C_ENTAG: /* Enumeration tag. */ | 4828 | 213 | case C_MOE: /* Member of enumeration. */ | 4829 | 219 | case C_MOU: /* Member of union. */ | 4830 | 226 | case C_UNTAG: /* Union tag. */ | 4831 | 230 | 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 | 230 | dst->symbol.flags |= BSF_DEBUGGING; | 4849 | 230 | dst->symbol.value = (src->u.syment.n_value); | 4850 | 230 | 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 | 1 | case C_BLOCK: /* ".bb" or ".eb". */ | 4901 | 1 | case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */ | 4902 | 19 | case C_EFCN: /* Physical end of function. */ | 4903 | 19 | #if defined COFF_WITH_PE | 4904 | | /* PE sets the symbol to a value relative to the start | 4905 | | of the section. */ | 4906 | 19 | dst->symbol.value = src->u.syment.n_value; | 4907 | 19 | if (strcmp (dst->symbol.name, ".bf") != 0) | 4908 | 19 | { | 4909 | | /* PE uses funny values for .ef and .lf; don't | 4910 | | relocate them. */ | 4911 | 19 | dst->symbol.flags = BSF_DEBUGGING; | 4912 | 19 | } | 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 | 19 | break; | 4923 | | | 4924 | 4 | case C_STATLAB: /* Static load time label. */ | 4925 | 4 | dst->symbol.value = src->u.syment.n_value; | 4926 | 4 | dst->symbol.flags = BSF_GLOBAL; | 4927 | 4 | break; | 4928 | | | 4929 | 307 | case C_NULL: | 4930 | | /* PE DLLs sometimes have zeroed out symbols for some | 4931 | | reason. Just ignore them without a warning. */ | 4932 | 307 | if (src->u.syment.n_type == 0 | 4933 | 307 | && src->u.syment.n_value == 0 | 4934 | 307 | && src->u.syment.n_scnum == 0) | 4935 | 307 | 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 | 0 | case C_EXTDEF: /* External definition. */ | 4943 | 0 | case C_ULABEL: /* Undefined label. */ | 4944 | 0 | 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 | 0 | case C_EXTLAB: /* External load time label. */ | 4957 | 0 | default: | 4958 | 0 | _bfd_error_handler | 4959 | | /* xgettext:c-format */ | 4960 | 0 | (_("%pB: unrecognized storage class %d for %s symbol `%s'"), | 4961 | 0 | abfd, src->u.syment.n_sclass, | 4962 | 0 | dst->symbol.section->name, dst->symbol.name); | 4963 | 0 | ret = false; | 4964 | | /* Fall through. */ | 4965 | 4 | 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 | 4 | dst->symbol.flags = BSF_DEBUGGING; | 4969 | 4 | dst->symbol.value = (src->u.syment.n_value); | 4970 | 4 | break; | 4971 | 727 | } | 4972 | | | 4973 | 727 | dst->native = src; | 4974 | 727 | dst->symbol.udata.i = 0; | 4975 | 727 | dst->lineno = NULL; | 4976 | | | 4977 | 727 | this_index += (src->u.syment.n_numaux) + 1; | 4978 | 727 | dst++; | 4979 | 727 | number_of_symbols++; | 4980 | 727 | } | 4981 | 61 | } | 4982 | | | 4983 | 61 | obj_symbols (abfd) = cached_area; | 4984 | 61 | obj_raw_syments (abfd) = native_symbols; | 4985 | | | 4986 | 61 | abfd->symcount = number_of_symbols; | 4987 | 61 | obj_convert (abfd) = table_ptr; | 4988 | | /* Slurp the line tables for each section too. */ | 4989 | 61 | { | 4990 | 61 | asection *p; | 4991 | | | 4992 | 61 | p = abfd->sections; | 4993 | 258 | while (p) | 4994 | 197 | { | 4995 | 197 | if (! coff_slurp_line_table (abfd, p)) | 4996 | 0 | return false; | 4997 | 197 | p = p->next; | 4998 | 197 | } | 4999 | 61 | } | 5000 | | | 5001 | 61 | return ret; | 5002 | 61 | } |
|
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 | 4.49k | { |
5012 | | /* FIXME: This partially duplicates the switch in |
5013 | | coff_slurp_symbol_table. */ |
5014 | 4.49k | switch (syment->n_sclass) |
5015 | 4.49k | { |
5016 | 3.46k | case C_EXT: |
5017 | 3.77k | case C_WEAKEXT: |
5018 | | #ifdef ARM |
5019 | 17 | case C_THUMBEXT: |
5020 | 19 | case C_THUMBEXTFUNC: |
5021 | | #endif |
5022 | | #ifdef RS6000COFF_C |
5023 | 1.12k | case C_HIDEXT: |
5024 | 1.12k | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT |
5025 | 1.13k | case C_AIX_WEAKEXT: |
5026 | | #endif |
5027 | | #endif |
5028 | 1.13k | #ifdef C_SYSTEM |
5029 | 4.31k | case C_SYSTEM: |
5030 | 4.31k | #endif |
5031 | | #ifdef COFF_WITH_PE |
5032 | 1.93k | case C_NT_WEAK: |
5033 | | #endif |
5034 | 4.45k | if (syment->n_scnum == 0) |
5035 | 604 | { |
5036 | 604 | if (syment->n_value == 0) |
5037 | 382 | return COFF_SYMBOL_UNDEFINED; |
5038 | 222 | else |
5039 | 222 | return COFF_SYMBOL_COMMON; |
5040 | 604 | } |
5041 | | #ifdef RS6000COFF_C |
5042 | 1.13k | if (syment->n_sclass == C_HIDEXT) |
5043 | 21 | return COFF_SYMBOL_LOCAL; |
5044 | 1.11k | #endif |
5045 | 3.83k | return COFF_SYMBOL_GLOBAL; |
5046 | | |
5047 | 39 | default: |
5048 | 39 | break; |
5049 | 4.49k | } |
5050 | | |
5051 | | #ifdef COFF_WITH_PE |
5052 | 39 | 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 | 39 | if (syment->n_sclass == C_SECTION) |
5082 | 39 | { |
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 | 39 | syment->n_value = 0; |
5087 | 39 | if (syment->n_scnum == 0) |
5088 | 39 | return COFF_SYMBOL_UNDEFINED; |
5089 | 0 | return COFF_SYMBOL_PE_SECTION; |
5090 | 39 | } |
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 | 39 | } pei-i386.c:coff_classify_symbol Line | Count | Source | 5011 | 54 | { | 5012 | | /* FIXME: This partially duplicates the switch in | 5013 | | coff_slurp_symbol_table. */ | 5014 | 54 | switch (syment->n_sclass) | 5015 | 54 | { | 5016 | 30 | case C_EXT: | 5017 | 44 | 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 | 44 | #ifdef C_SYSTEM | 5029 | 45 | case C_SYSTEM: | 5030 | 45 | #endif | 5031 | 45 | #ifdef COFF_WITH_PE | 5032 | 52 | case C_NT_WEAK: | 5033 | 52 | #endif | 5034 | 52 | if (syment->n_scnum == 0) | 5035 | 34 | { | 5036 | 34 | if (syment->n_value == 0) | 5037 | 16 | return COFF_SYMBOL_UNDEFINED; | 5038 | 18 | else | 5039 | 18 | return COFF_SYMBOL_COMMON; | 5040 | 34 | } | 5041 | | #ifdef RS6000COFF_C | 5042 | | if (syment->n_sclass == C_HIDEXT) | 5043 | | return COFF_SYMBOL_LOCAL; | 5044 | | #endif | 5045 | 18 | return COFF_SYMBOL_GLOBAL; | 5046 | | | 5047 | 2 | default: | 5048 | 2 | break; | 5049 | 54 | } | 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 | } |
pe-x86_64.c:coff_classify_symbol Line | Count | Source | 5011 | 114 | { | 5012 | | /* FIXME: This partially duplicates the switch in | 5013 | | coff_slurp_symbol_table. */ | 5014 | 114 | switch (syment->n_sclass) | 5015 | 114 | { | 5016 | 95 | case C_EXT: | 5017 | 106 | 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 | 106 | #ifdef C_SYSTEM | 5029 | 107 | case C_SYSTEM: | 5030 | 107 | #endif | 5031 | 107 | #ifdef COFF_WITH_PE | 5032 | 110 | case C_NT_WEAK: | 5033 | 110 | #endif | 5034 | 110 | if (syment->n_scnum == 0) | 5035 | 19 | { | 5036 | 19 | if (syment->n_value == 0) | 5037 | 11 | return COFF_SYMBOL_UNDEFINED; | 5038 | 8 | else | 5039 | 8 | return COFF_SYMBOL_COMMON; | 5040 | 19 | } | 5041 | | #ifdef RS6000COFF_C | 5042 | | if (syment->n_sclass == C_HIDEXT) | 5043 | | return COFF_SYMBOL_LOCAL; | 5044 | | #endif | 5045 | 91 | return COFF_SYMBOL_GLOBAL; | 5046 | | | 5047 | 4 | default: | 5048 | 4 | break; | 5049 | 114 | } | 5050 | | | 5051 | 4 | #ifdef COFF_WITH_PE | 5052 | 4 | 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 | 4 | if (syment->n_sclass == C_SECTION) | 5082 | 4 | { | 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 | 4 | syment->n_value = 0; | 5087 | 4 | if (syment->n_scnum == 0) | 5088 | 4 | return COFF_SYMBOL_UNDEFINED; | 5089 | 0 | return COFF_SYMBOL_PE_SECTION; | 5090 | 4 | } | 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 | 4 | } |
pei-x86_64.c:coff_classify_symbol Line | Count | Source | 5011 | 139 | { | 5012 | | /* FIXME: This partially duplicates the switch in | 5013 | | coff_slurp_symbol_table. */ | 5014 | 139 | switch (syment->n_sclass) | 5015 | 139 | { | 5016 | 110 | case C_EXT: | 5017 | 115 | 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 | 115 | #ifdef C_SYSTEM | 5029 | 124 | case C_SYSTEM: | 5030 | 124 | #endif | 5031 | 124 | #ifdef COFF_WITH_PE | 5032 | 136 | case C_NT_WEAK: | 5033 | 136 | #endif | 5034 | 136 | if (syment->n_scnum == 0) | 5035 | 28 | { | 5036 | 28 | if (syment->n_value == 0) | 5037 | 17 | return COFF_SYMBOL_UNDEFINED; | 5038 | 11 | else | 5039 | 11 | return COFF_SYMBOL_COMMON; | 5040 | 28 | } | 5041 | | #ifdef RS6000COFF_C | 5042 | | if (syment->n_sclass == C_HIDEXT) | 5043 | | return COFF_SYMBOL_LOCAL; | 5044 | | #endif | 5045 | 108 | return COFF_SYMBOL_GLOBAL; | 5046 | | | 5047 | 3 | default: | 5048 | 3 | break; | 5049 | 139 | } | 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 | } |
coff-x86_64.c:coff_classify_symbol Line | Count | Source | 5011 | 158 | { | 5012 | | /* FIXME: This partially duplicates the switch in | 5013 | | coff_slurp_symbol_table. */ | 5014 | 158 | switch (syment->n_sclass) | 5015 | 158 | { | 5016 | 114 | case C_EXT: | 5017 | 133 | 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 | 133 | #ifdef C_SYSTEM | 5029 | 158 | case C_SYSTEM: | 5030 | 158 | #endif | 5031 | | #ifdef COFF_WITH_PE | 5032 | | case C_NT_WEAK: | 5033 | | #endif | 5034 | 158 | if (syment->n_scnum == 0) | 5035 | 25 | { | 5036 | 25 | if (syment->n_value == 0) | 5037 | 14 | return COFF_SYMBOL_UNDEFINED; | 5038 | 11 | else | 5039 | 11 | return COFF_SYMBOL_COMMON; | 5040 | 25 | } | 5041 | | #ifdef RS6000COFF_C | 5042 | | if (syment->n_sclass == C_HIDEXT) | 5043 | | return COFF_SYMBOL_LOCAL; | 5044 | | #endif | 5045 | 133 | return COFF_SYMBOL_GLOBAL; | 5046 | | | 5047 | 0 | default: | 5048 | 0 | break; | 5049 | 158 | } | 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 | 158 | } |
coff64-rs6000.c:coff_classify_symbol Line | Count | Source | 5011 | 86 | { | 5012 | | /* FIXME: This partially duplicates the switch in | 5013 | | coff_slurp_symbol_table. */ | 5014 | 86 | switch (syment->n_sclass) | 5015 | 86 | { | 5016 | 54 | case C_EXT: | 5017 | 57 | case C_WEAKEXT: | 5018 | | #ifdef ARM | 5019 | | case C_THUMBEXT: | 5020 | | case C_THUMBEXTFUNC: | 5021 | | #endif | 5022 | 57 | #ifdef RS6000COFF_C | 5023 | 73 | case C_HIDEXT: | 5024 | 73 | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 5025 | 78 | case C_AIX_WEAKEXT: | 5026 | 78 | #endif | 5027 | 78 | #endif | 5028 | 78 | #ifdef C_SYSTEM | 5029 | 86 | case C_SYSTEM: | 5030 | 86 | #endif | 5031 | | #ifdef COFF_WITH_PE | 5032 | | case C_NT_WEAK: | 5033 | | #endif | 5034 | 86 | if (syment->n_scnum == 0) | 5035 | 12 | { | 5036 | 12 | if (syment->n_value == 0) | 5037 | 10 | return COFF_SYMBOL_UNDEFINED; | 5038 | 2 | else | 5039 | 2 | return COFF_SYMBOL_COMMON; | 5040 | 12 | } | 5041 | 74 | #ifdef RS6000COFF_C | 5042 | 74 | if (syment->n_sclass == C_HIDEXT) | 5043 | 16 | return COFF_SYMBOL_LOCAL; | 5044 | 58 | #endif | 5045 | 58 | return COFF_SYMBOL_GLOBAL; | 5046 | | | 5047 | 0 | default: | 5048 | 0 | break; | 5049 | 86 | } | 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 | 86 | } |
pei-aarch64.c:coff_classify_symbol Line | Count | Source | 5011 | 111 | { | 5012 | | /* FIXME: This partially duplicates the switch in | 5013 | | coff_slurp_symbol_table. */ | 5014 | 111 | switch (syment->n_sclass) | 5015 | 111 | { | 5016 | 99 | case C_EXT: | 5017 | 104 | 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 | 104 | #ifdef C_SYSTEM | 5029 | 105 | case C_SYSTEM: | 5030 | 105 | #endif | 5031 | 105 | #ifdef COFF_WITH_PE | 5032 | 107 | case C_NT_WEAK: | 5033 | 107 | #endif | 5034 | 107 | if (syment->n_scnum == 0) | 5035 | 24 | { | 5036 | 24 | if (syment->n_value == 0) | 5037 | 17 | return COFF_SYMBOL_UNDEFINED; | 5038 | 7 | else | 5039 | 7 | return COFF_SYMBOL_COMMON; | 5040 | 24 | } | 5041 | | #ifdef RS6000COFF_C | 5042 | | if (syment->n_sclass == C_HIDEXT) | 5043 | | return COFF_SYMBOL_LOCAL; | 5044 | | #endif | 5045 | 83 | return COFF_SYMBOL_GLOBAL; | 5046 | | | 5047 | 4 | default: | 5048 | 4 | break; | 5049 | 111 | } | 5050 | | | 5051 | 4 | #ifdef COFF_WITH_PE | 5052 | 4 | 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 | 4 | if (syment->n_sclass == C_SECTION) | 5082 | 4 | { | 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 | 4 | syment->n_value = 0; | 5087 | 4 | if (syment->n_scnum == 0) | 5088 | 4 | return COFF_SYMBOL_UNDEFINED; | 5089 | 0 | return COFF_SYMBOL_PE_SECTION; | 5090 | 4 | } | 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 | 4 | } |
pe-aarch64.c:coff_classify_symbol Line | Count | Source | 5011 | 167 | { | 5012 | | /* FIXME: This partially duplicates the switch in | 5013 | | coff_slurp_symbol_table. */ | 5014 | 167 | switch (syment->n_sclass) | 5015 | 167 | { | 5016 | 105 | case C_EXT: | 5017 | 124 | 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 | 124 | #ifdef C_SYSTEM | 5029 | 160 | case C_SYSTEM: | 5030 | 160 | #endif | 5031 | 160 | #ifdef COFF_WITH_PE | 5032 | 167 | case C_NT_WEAK: | 5033 | 167 | #endif | 5034 | 167 | if (syment->n_scnum == 0) | 5035 | 21 | { | 5036 | 21 | if (syment->n_value == 0) | 5037 | 15 | return COFF_SYMBOL_UNDEFINED; | 5038 | 6 | else | 5039 | 6 | return COFF_SYMBOL_COMMON; | 5040 | 21 | } | 5041 | | #ifdef RS6000COFF_C | 5042 | | if (syment->n_sclass == C_HIDEXT) | 5043 | | return COFF_SYMBOL_LOCAL; | 5044 | | #endif | 5045 | 146 | return COFF_SYMBOL_GLOBAL; | 5046 | | | 5047 | 0 | default: | 5048 | 0 | break; | 5049 | 167 | } | 5050 | | | 5051 | 0 | #ifdef COFF_WITH_PE | 5052 | 0 | 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 | 0 | if (syment->n_sclass == C_SECTION) | 5082 | 0 | { | 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 | 0 | syment->n_value = 0; | 5087 | 0 | if (syment->n_scnum == 0) | 5088 | 0 | return COFF_SYMBOL_UNDEFINED; | 5089 | 0 | return COFF_SYMBOL_PE_SECTION; | 5090 | 0 | } | 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 | 0 | } |
pei-ia64.c:coff_classify_symbol Line | Count | Source | 5011 | 208 | { | 5012 | | /* FIXME: This partially duplicates the switch in | 5013 | | coff_slurp_symbol_table. */ | 5014 | 208 | switch (syment->n_sclass) | 5015 | 208 | { | 5016 | 139 | case C_EXT: | 5017 | 157 | 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 | 157 | #ifdef C_SYSTEM | 5029 | 171 | case C_SYSTEM: | 5030 | 171 | #endif | 5031 | 171 | #ifdef COFF_WITH_PE | 5032 | 206 | case C_NT_WEAK: | 5033 | 206 | #endif | 5034 | 206 | if (syment->n_scnum == 0) | 5035 | 27 | { | 5036 | 27 | if (syment->n_value == 0) | 5037 | 11 | return COFF_SYMBOL_UNDEFINED; | 5038 | 16 | else | 5039 | 16 | return COFF_SYMBOL_COMMON; | 5040 | 27 | } | 5041 | | #ifdef RS6000COFF_C | 5042 | | if (syment->n_sclass == C_HIDEXT) | 5043 | | return COFF_SYMBOL_LOCAL; | 5044 | | #endif | 5045 | 179 | return COFF_SYMBOL_GLOBAL; | 5046 | | | 5047 | 2 | default: | 5048 | 2 | break; | 5049 | 208 | } | 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-loongarch64.c:coff_classify_symbol Line | Count | Source | 5011 | 105 | { | 5012 | | /* FIXME: This partially duplicates the switch in | 5013 | | coff_slurp_symbol_table. */ | 5014 | 105 | switch (syment->n_sclass) | 5015 | 105 | { | 5016 | 82 | case C_EXT: | 5017 | 100 | 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 | 100 | #ifdef C_SYSTEM | 5029 | 100 | case C_SYSTEM: | 5030 | 100 | #endif | 5031 | 100 | #ifdef COFF_WITH_PE | 5032 | 100 | case C_NT_WEAK: | 5033 | 100 | #endif | 5034 | 100 | if (syment->n_scnum == 0) | 5035 | 27 | { | 5036 | 27 | if (syment->n_value == 0) | 5037 | 14 | return COFF_SYMBOL_UNDEFINED; | 5038 | 13 | else | 5039 | 13 | return COFF_SYMBOL_COMMON; | 5040 | 27 | } | 5041 | | #ifdef RS6000COFF_C | 5042 | | if (syment->n_sclass == C_HIDEXT) | 5043 | | return COFF_SYMBOL_LOCAL; | 5044 | | #endif | 5045 | 73 | return COFF_SYMBOL_GLOBAL; | 5046 | | | 5047 | 5 | default: | 5048 | 5 | break; | 5049 | 105 | } | 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 | } |
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 | 1.09k | { | 5012 | | /* FIXME: This partially duplicates the switch in | 5013 | | coff_slurp_symbol_table. */ | 5014 | 1.09k | switch (syment->n_sclass) | 5015 | 1.09k | { | 5016 | 1.04k | case C_EXT: | 5017 | 1.04k | case C_WEAKEXT: | 5018 | | #ifdef ARM | 5019 | | case C_THUMBEXT: | 5020 | | case C_THUMBEXTFUNC: | 5021 | | #endif | 5022 | 1.04k | #ifdef RS6000COFF_C | 5023 | 1.05k | case C_HIDEXT: | 5024 | 1.05k | #if ! defined _AIX52 && ! defined AIX_WEAK_SUPPORT | 5025 | 1.06k | case C_AIX_WEAKEXT: | 5026 | 1.06k | #endif | 5027 | 1.06k | #endif | 5028 | 1.06k | #ifdef C_SYSTEM | 5029 | 1.09k | case C_SYSTEM: | 5030 | 1.09k | #endif | 5031 | | #ifdef COFF_WITH_PE | 5032 | | case C_NT_WEAK: | 5033 | | #endif | 5034 | 1.09k | 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 | 1.06k | #ifdef RS6000COFF_C | 5042 | 1.06k | if (syment->n_sclass == C_HIDEXT) | 5043 | 5 | return COFF_SYMBOL_LOCAL; | 5044 | 1.05k | #endif | 5045 | 1.05k | return COFF_SYMBOL_GLOBAL; | 5046 | | | 5047 | 0 | default: | 5048 | 0 | break; | 5049 | 1.09k | } | 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 | 1.09k | } |
coff-sh.c:coff_classify_symbol Line | Count | Source | 5011 | 158 | { | 5012 | | /* FIXME: This partially duplicates the switch in | 5013 | | coff_slurp_symbol_table. */ | 5014 | 158 | switch (syment->n_sclass) | 5015 | 158 | { | 5016 | 74 | case C_EXT: | 5017 | 130 | 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 | 130 | #ifdef C_SYSTEM | 5029 | 158 | case C_SYSTEM: | 5030 | 158 | #endif | 5031 | | #ifdef COFF_WITH_PE | 5032 | | case C_NT_WEAK: | 5033 | | #endif | 5034 | 158 | if (syment->n_scnum == 0) | 5035 | 74 | { | 5036 | 74 | if (syment->n_value == 0) | 5037 | 70 | return COFF_SYMBOL_UNDEFINED; | 5038 | 4 | else | 5039 | 4 | return COFF_SYMBOL_COMMON; | 5040 | 74 | } | 5041 | | #ifdef RS6000COFF_C | 5042 | | if (syment->n_sclass == C_HIDEXT) | 5043 | | return COFF_SYMBOL_LOCAL; | 5044 | | #endif | 5045 | 84 | return COFF_SYMBOL_GLOBAL; | 5046 | | | 5047 | 0 | default: | 5048 | 0 | break; | 5049 | 158 | } | 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 | 158 | } |
Unexecuted instantiation: coff-stgo32.c:coff_classify_symbol coff-tic30.c:coff_classify_symbol Line | Count | Source | 5011 | 144 | { | 5012 | | /* FIXME: This partially duplicates the switch in | 5013 | | coff_slurp_symbol_table. */ | 5014 | 144 | switch (syment->n_sclass) | 5015 | 144 | { | 5016 | 108 | case C_EXT: | 5017 | 131 | 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 | 131 | #ifdef C_SYSTEM | 5029 | 144 | case C_SYSTEM: | 5030 | 144 | #endif | 5031 | | #ifdef COFF_WITH_PE | 5032 | | case C_NT_WEAK: | 5033 | | #endif | 5034 | 144 | if (syment->n_scnum == 0) | 5035 | 20 | { | 5036 | 20 | if (syment->n_value == 0) | 5037 | 14 | return COFF_SYMBOL_UNDEFINED; | 5038 | 6 | else | 5039 | 6 | return COFF_SYMBOL_COMMON; | 5040 | 20 | } | 5041 | | #ifdef RS6000COFF_C | 5042 | | if (syment->n_sclass == C_HIDEXT) | 5043 | | return COFF_SYMBOL_LOCAL; | 5044 | | #endif | 5045 | 124 | return COFF_SYMBOL_GLOBAL; | 5046 | | | 5047 | 0 | default: | 5048 | 0 | break; | 5049 | 144 | } | 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 | 144 | } |
Unexecuted instantiation: coff-tic4x.c:coff_classify_symbol coff-tic54x.c:coff_classify_symbol Line | Count | Source | 5011 | 444 | { | 5012 | | /* FIXME: This partially duplicates the switch in | 5013 | | coff_slurp_symbol_table. */ | 5014 | 444 | switch (syment->n_sclass) | 5015 | 444 | { | 5016 | 412 | case C_EXT: | 5017 | 439 | 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 | 439 | #ifdef C_SYSTEM | 5029 | 444 | case C_SYSTEM: | 5030 | 444 | #endif | 5031 | | #ifdef COFF_WITH_PE | 5032 | | case C_NT_WEAK: | 5033 | | #endif | 5034 | 444 | if (syment->n_scnum == 0) | 5035 | 68 | { | 5036 | 68 | if (syment->n_value == 0) | 5037 | 43 | return COFF_SYMBOL_UNDEFINED; | 5038 | 25 | else | 5039 | 25 | return COFF_SYMBOL_COMMON; | 5040 | 68 | } | 5041 | | #ifdef RS6000COFF_C | 5042 | | if (syment->n_sclass == C_HIDEXT) | 5043 | | return COFF_SYMBOL_LOCAL; | 5044 | | #endif | 5045 | 376 | return COFF_SYMBOL_GLOBAL; | 5046 | | | 5047 | 0 | default: | 5048 | 0 | break; | 5049 | 444 | } | 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 | 444 | } |
coff-z80.c:coff_classify_symbol Line | Count | Source | 5011 | 377 | { | 5012 | | /* FIXME: This partially duplicates the switch in | 5013 | | coff_slurp_symbol_table. */ | 5014 | 377 | switch (syment->n_sclass) | 5015 | 377 | { | 5016 | 356 | case C_EXT: | 5017 | 367 | 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 | 367 | #ifdef C_SYSTEM | 5029 | 377 | case C_SYSTEM: | 5030 | 377 | #endif | 5031 | | #ifdef COFF_WITH_PE | 5032 | | case C_NT_WEAK: | 5033 | | #endif | 5034 | 377 | if (syment->n_scnum == 0) | 5035 | 28 | { | 5036 | 28 | if (syment->n_value == 0) | 5037 | 18 | return COFF_SYMBOL_UNDEFINED; | 5038 | 10 | else | 5039 | 10 | return COFF_SYMBOL_COMMON; | 5040 | 28 | } | 5041 | | #ifdef RS6000COFF_C | 5042 | | if (syment->n_sclass == C_HIDEXT) | 5043 | | return COFF_SYMBOL_LOCAL; | 5044 | | #endif | 5045 | 349 | return COFF_SYMBOL_GLOBAL; | 5046 | | | 5047 | 0 | default: | 5048 | 0 | break; | 5049 | 377 | } | 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 | 377 | } |
coff-z8k.c:coff_classify_symbol Line | Count | Source | 5011 | 65 | { | 5012 | | /* FIXME: This partially duplicates the switch in | 5013 | | coff_slurp_symbol_table. */ | 5014 | 65 | switch (syment->n_sclass) | 5015 | 65 | { | 5016 | 18 | case C_EXT: | 5017 | 32 | 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 | 32 | #ifdef C_SYSTEM | 5029 | 65 | case C_SYSTEM: | 5030 | 65 | #endif | 5031 | | #ifdef COFF_WITH_PE | 5032 | | case C_NT_WEAK: | 5033 | | #endif | 5034 | 65 | if (syment->n_scnum == 0) | 5035 | 20 | { | 5036 | 20 | if (syment->n_value == 0) | 5037 | 14 | return COFF_SYMBOL_UNDEFINED; | 5038 | 6 | else | 5039 | 6 | return COFF_SYMBOL_COMMON; | 5040 | 20 | } | 5041 | | #ifdef RS6000COFF_C | 5042 | | if (syment->n_sclass == C_HIDEXT) | 5043 | | return COFF_SYMBOL_LOCAL; | 5044 | | #endif | 5045 | 45 | return COFF_SYMBOL_GLOBAL; | 5046 | | | 5047 | 0 | default: | 5048 | 0 | break; | 5049 | 65 | } | 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 | 65 | } |
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 | 177 | { | 5012 | | /* FIXME: This partially duplicates the switch in | 5013 | | coff_slurp_symbol_table. */ | 5014 | 177 | switch (syment->n_sclass) | 5015 | 177 | { | 5016 | 154 | case C_EXT: | 5017 | 157 | 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 | 157 | #ifdef C_SYSTEM | 5029 | 162 | case C_SYSTEM: | 5030 | 162 | #endif | 5031 | 162 | #ifdef COFF_WITH_PE | 5032 | 173 | case C_NT_WEAK: | 5033 | 173 | #endif | 5034 | 173 | if (syment->n_scnum == 0) | 5035 | 37 | { | 5036 | 37 | if (syment->n_value == 0) | 5037 | 17 | return COFF_SYMBOL_UNDEFINED; | 5038 | 20 | else | 5039 | 20 | 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 | 136 | return COFF_SYMBOL_GLOBAL; | 5046 | | | 5047 | 4 | default: | 5048 | 4 | break; | 5049 | 177 | } | 5050 | | | 5051 | 4 | #ifdef COFF_WITH_PE | 5052 | 4 | 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 | 4 | if (syment->n_sclass == C_SECTION) | 5082 | 4 | { | 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 | 4 | syment->n_value = 0; | 5087 | 4 | if (syment->n_scnum == 0) | 5088 | 4 | return COFF_SYMBOL_UNDEFINED; | 5089 | 0 | return COFF_SYMBOL_PE_SECTION; | 5090 | 4 | } | 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 | 4 | } |
pe-mcore.c:coff_classify_symbol Line | Count | Source | 5011 | 357 | { | 5012 | | /* FIXME: This partially duplicates the switch in | 5013 | | coff_slurp_symbol_table. */ | 5014 | 357 | switch (syment->n_sclass) | 5015 | 357 | { | 5016 | 38 | case C_EXT: | 5017 | 52 | 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 | 52 | #ifdef C_SYSTEM | 5029 | 301 | case C_SYSTEM: | 5030 | 301 | #endif | 5031 | 301 | #ifdef COFF_WITH_PE | 5032 | 350 | case C_NT_WEAK: | 5033 | 350 | #endif | 5034 | 350 | if (syment->n_scnum == 0) | 5035 | 17 | { | 5036 | 17 | if (syment->n_value == 0) | 5037 | 11 | return COFF_SYMBOL_UNDEFINED; | 5038 | 6 | else | 5039 | 6 | return COFF_SYMBOL_COMMON; | 5040 | 17 | } | 5041 | | #ifdef RS6000COFF_C | 5042 | | if (syment->n_sclass == C_HIDEXT) | 5043 | | return COFF_SYMBOL_LOCAL; | 5044 | | #endif | 5045 | 333 | return COFF_SYMBOL_GLOBAL; | 5046 | | | 5047 | 7 | default: | 5048 | 7 | break; | 5049 | 357 | } | 5050 | | | 5051 | 7 | #ifdef COFF_WITH_PE | 5052 | 7 | 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 | 7 | if (syment->n_sclass == C_SECTION) | 5082 | 7 | { | 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 | 7 | syment->n_value = 0; | 5087 | 7 | if (syment->n_scnum == 0) | 5088 | 7 | return COFF_SYMBOL_UNDEFINED; | 5089 | 0 | return COFF_SYMBOL_PE_SECTION; | 5090 | 7 | } | 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 | 7 | } |
pe-sh.c:coff_classify_symbol Line | Count | Source | 5011 | 351 | { | 5012 | | /* FIXME: This partially duplicates the switch in | 5013 | | coff_slurp_symbol_table. */ | 5014 | 351 | switch (syment->n_sclass) | 5015 | 351 | { | 5016 | 333 | case C_EXT: | 5017 | 345 | 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 | 345 | #ifdef C_SYSTEM | 5029 | 346 | case C_SYSTEM: | 5030 | 346 | #endif | 5031 | 346 | #ifdef COFF_WITH_PE | 5032 | 351 | case C_NT_WEAK: | 5033 | 351 | #endif | 5034 | 351 | if (syment->n_scnum == 0) | 5035 | 34 | { | 5036 | 34 | if (syment->n_value == 0) | 5037 | 26 | return COFF_SYMBOL_UNDEFINED; | 5038 | 8 | else | 5039 | 8 | return COFF_SYMBOL_COMMON; | 5040 | 34 | } | 5041 | | #ifdef RS6000COFF_C | 5042 | | if (syment->n_sclass == C_HIDEXT) | 5043 | | return COFF_SYMBOL_LOCAL; | 5044 | | #endif | 5045 | 317 | return COFF_SYMBOL_GLOBAL; | 5046 | | | 5047 | 0 | default: | 5048 | 0 | break; | 5049 | 351 | } | 5050 | | | 5051 | 0 | #ifdef COFF_WITH_PE | 5052 | 0 | 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 | 0 | if (syment->n_sclass == C_SECTION) | 5082 | 0 | { | 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 | 0 | syment->n_value = 0; | 5087 | 0 | if (syment->n_scnum == 0) | 5088 | 0 | return COFF_SYMBOL_UNDEFINED; | 5089 | 0 | return COFF_SYMBOL_PE_SECTION; | 5090 | 0 | } | 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 | 0 | } |
pei-arm-wince.c:coff_classify_symbol Line | Count | Source | 5011 | 15 | { | 5012 | | /* FIXME: This partially duplicates the switch in | 5013 | | coff_slurp_symbol_table. */ | 5014 | 15 | switch (syment->n_sclass) | 5015 | 15 | { | 5016 | 4 | case C_EXT: | 5017 | 8 | case C_WEAKEXT: | 5018 | 8 | #ifdef ARM | 5019 | 9 | case C_THUMBEXT: | 5020 | 10 | case C_THUMBEXTFUNC: | 5021 | 10 | #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 | 10 | #ifdef C_SYSTEM | 5029 | 10 | case C_SYSTEM: | 5030 | 10 | #endif | 5031 | 10 | #ifdef COFF_WITH_PE | 5032 | 13 | case C_NT_WEAK: | 5033 | 13 | #endif | 5034 | 13 | if (syment->n_scnum == 0) | 5035 | 2 | { | 5036 | 2 | if (syment->n_value == 0) | 5037 | 0 | return COFF_SYMBOL_UNDEFINED; | 5038 | 2 | else | 5039 | 2 | return COFF_SYMBOL_COMMON; | 5040 | 2 | } | 5041 | | #ifdef RS6000COFF_C | 5042 | | if (syment->n_sclass == C_HIDEXT) | 5043 | | return COFF_SYMBOL_LOCAL; | 5044 | | #endif | 5045 | 11 | return COFF_SYMBOL_GLOBAL; | 5046 | | | 5047 | 2 | default: | 5048 | 2 | break; | 5049 | 15 | } | 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.c:coff_classify_symbol Line | Count | Source | 5011 | 11 | { | 5012 | | /* FIXME: This partially duplicates the switch in | 5013 | | coff_slurp_symbol_table. */ | 5014 | 11 | switch (syment->n_sclass) | 5015 | 11 | { | 5016 | 4 | case C_EXT: | 5017 | 7 | case C_WEAKEXT: | 5018 | 7 | #ifdef ARM | 5019 | 8 | case C_THUMBEXT: | 5020 | 9 | case C_THUMBEXTFUNC: | 5021 | 9 | #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 | 9 | #ifdef C_SYSTEM | 5029 | 9 | case C_SYSTEM: | 5030 | 9 | #endif | 5031 | 9 | #ifdef COFF_WITH_PE | 5032 | 10 | case C_NT_WEAK: | 5033 | 10 | #endif | 5034 | 10 | if (syment->n_scnum == 0) | 5035 | 4 | { | 5036 | 4 | if (syment->n_value == 0) | 5037 | 1 | return COFF_SYMBOL_UNDEFINED; | 5038 | 3 | else | 5039 | 3 | return COFF_SYMBOL_COMMON; | 5040 | 4 | } | 5041 | | #ifdef RS6000COFF_C | 5042 | | if (syment->n_sclass == C_HIDEXT) | 5043 | | return COFF_SYMBOL_LOCAL; | 5044 | | #endif | 5045 | 6 | return COFF_SYMBOL_GLOBAL; | 5046 | | | 5047 | 1 | default: | 5048 | 1 | break; | 5049 | 11 | } | 5050 | | | 5051 | 1 | #ifdef COFF_WITH_PE | 5052 | 1 | 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 | 1 | if (syment->n_sclass == C_SECTION) | 5082 | 1 | { | 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 | 1 | syment->n_value = 0; | 5087 | 1 | if (syment->n_scnum == 0) | 5088 | 1 | return COFF_SYMBOL_UNDEFINED; | 5089 | 0 | return COFF_SYMBOL_PE_SECTION; | 5090 | 1 | } | 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 | 1 | } |
pei-mcore.c:coff_classify_symbol Line | Count | Source | 5011 | 46 | { | 5012 | | /* FIXME: This partially duplicates the switch in | 5013 | | coff_slurp_symbol_table. */ | 5014 | 46 | switch (syment->n_sclass) | 5015 | 46 | { | 5016 | 17 | case C_EXT: | 5017 | 32 | 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 | 32 | #ifdef C_SYSTEM | 5029 | 41 | case C_SYSTEM: | 5030 | 41 | #endif | 5031 | 41 | #ifdef COFF_WITH_PE | 5032 | 44 | case C_NT_WEAK: | 5033 | 44 | #endif | 5034 | 44 | if (syment->n_scnum == 0) | 5035 | 22 | { | 5036 | 22 | if (syment->n_value == 0) | 5037 | 20 | return COFF_SYMBOL_UNDEFINED; | 5038 | 2 | else | 5039 | 2 | 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 | 22 | return COFF_SYMBOL_GLOBAL; | 5046 | | | 5047 | 2 | default: | 5048 | 2 | break; | 5049 | 46 | } | 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-sh.c:coff_classify_symbol Line | Count | Source | 5011 | 116 | { | 5012 | | /* FIXME: This partially duplicates the switch in | 5013 | | coff_slurp_symbol_table. */ | 5014 | 116 | switch (syment->n_sclass) | 5015 | 116 | { | 5016 | 75 | case C_EXT: | 5017 | 89 | 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 | 89 | #ifdef C_SYSTEM | 5029 | 107 | case C_SYSTEM: | 5030 | 107 | #endif | 5031 | 107 | #ifdef COFF_WITH_PE | 5032 | 113 | case C_NT_WEAK: | 5033 | 113 | #endif | 5034 | 113 | if (syment->n_scnum == 0) | 5035 | 29 | { | 5036 | 29 | if (syment->n_value == 0) | 5037 | 16 | return COFF_SYMBOL_UNDEFINED; | 5038 | 13 | else | 5039 | 13 | return COFF_SYMBOL_COMMON; | 5040 | 29 | } | 5041 | | #ifdef RS6000COFF_C | 5042 | | if (syment->n_sclass == C_HIDEXT) | 5043 | | return COFF_SYMBOL_LOCAL; | 5044 | | #endif | 5045 | 84 | return COFF_SYMBOL_GLOBAL; | 5046 | | | 5047 | 3 | default: | 5048 | 3 | break; | 5049 | 116 | } | 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 | } |
|
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 | 0 | { \ |
5144 | 0 | coff_symbol_type *coffsym = NULL; \ |
5145 | 0 | \ |
5146 | 0 | if (ptr && bfd_asymbol_bfd (ptr) != abfd) \ |
5147 | 0 | coffsym = (obj_symbols (abfd) \ |
5148 | 0 | + (cache_ptr->sym_ptr_ptr - symbols)); \ |
5149 | 0 | else if (ptr) \ |
5150 | 0 | coffsym = coff_symbol_from (ptr); \ |
5151 | 0 | if (coffsym != NULL \ |
5152 | 0 | && coffsym->native->is_sym \ |
5153 | 0 | && coffsym->native->u.syment.n_scnum == 0) \ |
5154 | 0 | cache_ptr->addend = 0; \ |
5155 | 0 | else if (ptr && bfd_asymbol_bfd (ptr) == abfd \ |
5156 | 0 | && ptr->section != NULL) \ |
5157 | 0 | cache_ptr->addend = - (ptr->section->vma + ptr->value); \ |
5158 | 0 | else \ |
5159 | 0 | cache_ptr->addend = 0; \ |
5160 | 0 | } |
5161 | | #endif |
5162 | | |
5163 | | static bool |
5164 | | coff_slurp_reloc_table (bfd * abfd, sec_ptr asect, asymbol ** symbols) |
5165 | 0 | { |
5166 | 0 | bfd_byte *native_relocs; |
5167 | 0 | arelent *reloc_cache; |
5168 | 0 | arelent *cache_ptr; |
5169 | 0 | unsigned int idx; |
5170 | 0 | size_t amt; |
5171 | |
|
5172 | 0 | if (asect->relocation) |
5173 | 0 | 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 | | #ifndef RELOC_PROCESSING |
5204 | | asymbol *ptr; |
5205 | | #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 | 0 | RELOC_PROCESSING (cache_ptr, &dst, symbols, abfd, asect); |
5215 | | #else |
5216 | | 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 | | (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 | 0 | RTYPE2HOWTO (cache_ptr, &dst); |
5258 | | #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-i386.c:coff_slurp_reloc_table Unexecuted instantiation: pe-x86_64.c:coff_slurp_reloc_table Unexecuted instantiation: pei-x86_64.c:coff_slurp_reloc_table Unexecuted instantiation: coff-x86_64.c:coff_slurp_reloc_table Unexecuted instantiation: coff64-rs6000.c:coff_slurp_reloc_table Unexecuted instantiation: pei-aarch64.c:coff_slurp_reloc_table Unexecuted instantiation: pe-aarch64.c:coff_slurp_reloc_table Unexecuted instantiation: pei-ia64.c:coff_slurp_reloc_table Unexecuted instantiation: pei-loongarch64.c:coff_slurp_reloc_table 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 Unexecuted instantiation: coff-rs6000.c:coff_slurp_reloc_table Unexecuted instantiation: coff-sh.c:coff_slurp_reloc_table Unexecuted instantiation: coff-stgo32.c:coff_slurp_reloc_table Unexecuted instantiation: coff-tic30.c:coff_slurp_reloc_table Unexecuted instantiation: coff-tic4x.c:coff_slurp_reloc_table Unexecuted instantiation: coff-tic54x.c:coff_slurp_reloc_table Unexecuted instantiation: coff-z80.c:coff_slurp_reloc_table Unexecuted instantiation: coff-z8k.c:coff_slurp_reloc_table Unexecuted instantiation: pe-arm-wince.c:coff_slurp_reloc_table Unexecuted instantiation: pe-arm.c:coff_slurp_reloc_table Unexecuted instantiation: pe-i386.c:coff_slurp_reloc_table Unexecuted instantiation: pe-mcore.c:coff_slurp_reloc_table Unexecuted instantiation: pe-sh.c:coff_slurp_reloc_table Unexecuted instantiation: pei-arm-wince.c:coff_slurp_reloc_table Unexecuted instantiation: pei-arm.c:coff_slurp_reloc_table Unexecuted instantiation: pei-mcore.c:coff_slurp_reloc_table Unexecuted instantiation: pei-sh.c:coff_slurp_reloc_table |
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 | 0 | { |
5316 | 0 | arelent *tblptr = section->relocation; |
5317 | 0 | unsigned int count = 0; |
5318 | |
|
5319 | 0 | 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 | 0 | else |
5333 | 0 | { |
5334 | 0 | if (! coff_slurp_reloc_table (abfd, section, symbols)) |
5335 | 0 | return -1; |
5336 | | |
5337 | 0 | tblptr = section->relocation; |
5338 | |
|
5339 | 0 | for (; count++ < section->reloc_count;) |
5340 | 0 | *relptr++ = tblptr++; |
5341 | 0 | } |
5342 | 0 | *relptr = 0; |
5343 | 0 | return section->reloc_count; |
5344 | 0 | } Unexecuted instantiation: pei-i386.c:coff_canonicalize_reloc Unexecuted instantiation: pe-x86_64.c:coff_canonicalize_reloc Unexecuted instantiation: pei-x86_64.c:coff_canonicalize_reloc Unexecuted instantiation: coff-x86_64.c:coff_canonicalize_reloc Unexecuted instantiation: coff64-rs6000.c:coff_canonicalize_reloc Unexecuted instantiation: pei-aarch64.c:coff_canonicalize_reloc Unexecuted instantiation: pe-aarch64.c:coff_canonicalize_reloc Unexecuted instantiation: pei-ia64.c:coff_canonicalize_reloc Unexecuted instantiation: pei-loongarch64.c:coff_canonicalize_reloc Unexecuted instantiation: cf-i386lynx.c:coff_canonicalize_reloc Unexecuted instantiation: coff-go32.c:coff_canonicalize_reloc Unexecuted instantiation: coff-i386.c:coff_canonicalize_reloc Unexecuted instantiation: coff-rs6000.c:coff_canonicalize_reloc Unexecuted instantiation: coff-sh.c:coff_canonicalize_reloc Unexecuted instantiation: coff-stgo32.c:coff_canonicalize_reloc Unexecuted instantiation: coff-tic30.c:coff_canonicalize_reloc Unexecuted instantiation: coff-tic4x.c:coff_canonicalize_reloc Unexecuted instantiation: coff-tic54x.c:coff_canonicalize_reloc Unexecuted instantiation: coff-z80.c:coff_canonicalize_reloc Unexecuted instantiation: coff-z8k.c:coff_canonicalize_reloc Unexecuted instantiation: pe-arm-wince.c:coff_canonicalize_reloc Unexecuted instantiation: pe-arm.c:coff_canonicalize_reloc Unexecuted instantiation: pe-i386.c:coff_canonicalize_reloc Unexecuted instantiation: pe-mcore.c:coff_canonicalize_reloc Unexecuted instantiation: pe-sh.c:coff_canonicalize_reloc Unexecuted instantiation: pei-arm-wince.c:coff_canonicalize_reloc Unexecuted instantiation: pei-arm.c:coff_canonicalize_reloc Unexecuted instantiation: pei-mcore.c:coff_canonicalize_reloc Unexecuted instantiation: pei-sh.c:coff_canonicalize_reloc |
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 | 225k | { |
5634 | 225k | struct external_ANON_OBJECT_HEADER_BIGOBJ *filehdr_src = |
5635 | 225k | (struct external_ANON_OBJECT_HEADER_BIGOBJ *) src; |
5636 | 225k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; |
5637 | | |
5638 | 225k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->Machine); |
5639 | 225k | filehdr_dst->f_nscns = H_GET_32 (abfd, filehdr_src->NumberOfSections); |
5640 | 225k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->TimeDateStamp); |
5641 | 225k | filehdr_dst->f_symptr = |
5642 | 225k | GET_FILEHDR_SYMPTR (abfd, filehdr_src->PointerToSymbolTable); |
5643 | 225k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->NumberOfSymbols); |
5644 | 225k | filehdr_dst->f_opthdr = 0; |
5645 | 225k | filehdr_dst->f_flags = 0; |
5646 | | |
5647 | | /* Check other magic numbers. */ |
5648 | 225k | if (H_GET_16 (abfd, filehdr_src->Sig1) != IMAGE_FILE_MACHINE_UNKNOWN |
5649 | 225k | || H_GET_16 (abfd, filehdr_src->Sig2) != 0xffff |
5650 | 225k | || H_GET_16 (abfd, filehdr_src->Version) != 2 |
5651 | 225k | || memcmp (filehdr_src->ClassID, header_bigobj_classid, 16) != 0) |
5652 | 225k | filehdr_dst->f_opthdr = 0xffff; |
5653 | | |
5654 | | /* Note that CLR metadata are ignored. */ |
5655 | 225k | } pe-x86_64.c:coff_bigobj_swap_filehdr_in Line | Count | Source | 5633 | 112k | { | 5634 | 112k | struct external_ANON_OBJECT_HEADER_BIGOBJ *filehdr_src = | 5635 | 112k | (struct external_ANON_OBJECT_HEADER_BIGOBJ *) src; | 5636 | 112k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 5637 | | | 5638 | 112k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->Machine); | 5639 | 112k | filehdr_dst->f_nscns = H_GET_32 (abfd, filehdr_src->NumberOfSections); | 5640 | 112k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->TimeDateStamp); | 5641 | 112k | filehdr_dst->f_symptr = | 5642 | 112k | GET_FILEHDR_SYMPTR (abfd, filehdr_src->PointerToSymbolTable); | 5643 | 112k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->NumberOfSymbols); | 5644 | 112k | filehdr_dst->f_opthdr = 0; | 5645 | 112k | filehdr_dst->f_flags = 0; | 5646 | | | 5647 | | /* Check other magic numbers. */ | 5648 | 112k | if (H_GET_16 (abfd, filehdr_src->Sig1) != IMAGE_FILE_MACHINE_UNKNOWN | 5649 | 112k | || H_GET_16 (abfd, filehdr_src->Sig2) != 0xffff | 5650 | 112k | || H_GET_16 (abfd, filehdr_src->Version) != 2 | 5651 | 112k | || memcmp (filehdr_src->ClassID, header_bigobj_classid, 16) != 0) | 5652 | 112k | filehdr_dst->f_opthdr = 0xffff; | 5653 | | | 5654 | | /* Note that CLR metadata are ignored. */ | 5655 | 112k | } |
pe-i386.c:coff_bigobj_swap_filehdr_in Line | Count | Source | 5633 | 112k | { | 5634 | 112k | struct external_ANON_OBJECT_HEADER_BIGOBJ *filehdr_src = | 5635 | 112k | (struct external_ANON_OBJECT_HEADER_BIGOBJ *) src; | 5636 | 112k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 5637 | | | 5638 | 112k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->Machine); | 5639 | 112k | filehdr_dst->f_nscns = H_GET_32 (abfd, filehdr_src->NumberOfSections); | 5640 | 112k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->TimeDateStamp); | 5641 | 112k | filehdr_dst->f_symptr = | 5642 | 112k | GET_FILEHDR_SYMPTR (abfd, filehdr_src->PointerToSymbolTable); | 5643 | 112k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->NumberOfSymbols); | 5644 | 112k | filehdr_dst->f_opthdr = 0; | 5645 | 112k | filehdr_dst->f_flags = 0; | 5646 | | | 5647 | | /* Check other magic numbers. */ | 5648 | 112k | if (H_GET_16 (abfd, filehdr_src->Sig1) != IMAGE_FILE_MACHINE_UNKNOWN | 5649 | 112k | || H_GET_16 (abfd, filehdr_src->Sig2) != 0xffff | 5650 | 112k | || H_GET_16 (abfd, filehdr_src->Version) != 2 | 5651 | 112k | || memcmp (filehdr_src->ClassID, header_bigobj_classid, 16) != 0) | 5652 | 112k | filehdr_dst->f_opthdr = 0xffff; | 5653 | | | 5654 | | /* Note that CLR metadata are ignored. */ | 5655 | 112k | } |
|
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 | 0 | { |
5683 | 0 | SYMENT_BIGOBJ *ext = (SYMENT_BIGOBJ *) ext1; |
5684 | 0 | struct internal_syment *in = (struct internal_syment *) in1; |
5685 | |
|
5686 | 0 | if (ext->e.e_name[0] == 0) |
5687 | 0 | { |
5688 | 0 | in->_n._n_n._n_zeroes = 0; |
5689 | 0 | in->_n._n_n._n_offset = H_GET_32 (abfd, ext->e.e.e_offset); |
5690 | 0 | } |
5691 | 0 | else |
5692 | 0 | { |
5693 | | #if SYMNMLEN != E_SYMNMLEN |
5694 | | #error we need to cope with truncating or extending SYMNMLEN |
5695 | | #else |
5696 | 0 | memcpy (in->_n._n_name, ext->e.e_name, SYMNMLEN); |
5697 | 0 | #endif |
5698 | 0 | } |
5699 | |
|
5700 | 0 | in->n_value = H_GET_32 (abfd, ext->e_value); |
5701 | 0 | BFD_ASSERT (sizeof (in->n_scnum) >= 4); |
5702 | 0 | in->n_scnum = H_GET_32 (abfd, ext->e_scnum); |
5703 | 0 | in->n_type = H_GET_16 (abfd, ext->e_type); |
5704 | 0 | in->n_sclass = H_GET_8 (abfd, ext->e_sclass); |
5705 | 0 | in->n_numaux = H_GET_8 (abfd, ext->e_numaux); |
5706 | 0 | } Unexecuted instantiation: pe-x86_64.c:coff_bigobj_swap_sym_in 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 | 0 | { |
5747 | 0 | AUXENT_BIGOBJ *ext = (AUXENT_BIGOBJ *) ext1; |
5748 | 0 | union internal_auxent *in = (union internal_auxent *) in1; |
5749 | | |
5750 | | /* Make sure that all fields in the aux structure are |
5751 | | initialised. */ |
5752 | 0 | memset (in, 0, sizeof * in); |
5753 | 0 | switch (in_class) |
5754 | 0 | { |
5755 | 0 | case C_FILE: |
5756 | 0 | if (numaux > 1) |
5757 | 0 | { |
5758 | 0 | if (indx == 0) |
5759 | 0 | memcpy (in->x_file.x_n.x_fname, ext->File.Name, |
5760 | 0 | numaux * sizeof (AUXENT_BIGOBJ)); |
5761 | 0 | } |
5762 | 0 | else |
5763 | 0 | memcpy (in->x_file.x_n.x_fname, ext->File.Name, sizeof (ext->File.Name)); |
5764 | 0 | break; |
5765 | | |
5766 | 0 | case C_STAT: |
5767 | 0 | case C_LEAFSTAT: |
5768 | 0 | case C_HIDDEN: |
5769 | 0 | if (type == T_NULL) |
5770 | 0 | { |
5771 | 0 | in->x_scn.x_scnlen = H_GET_32 (abfd, ext->Section.Length); |
5772 | 0 | in->x_scn.x_nreloc = |
5773 | 0 | H_GET_16 (abfd, ext->Section.NumberOfRelocations); |
5774 | 0 | in->x_scn.x_nlinno = |
5775 | 0 | H_GET_16 (abfd, ext->Section.NumberOfLinenumbers); |
5776 | 0 | in->x_scn.x_checksum = H_GET_32 (abfd, ext->Section.Checksum); |
5777 | 0 | in->x_scn.x_associated = H_GET_16 (abfd, ext->Section.Number) |
5778 | 0 | | (H_GET_16 (abfd, ext->Section.HighNumber) << 16); |
5779 | 0 | in->x_scn.x_comdat = H_GET_8 (abfd, ext->Section.Selection); |
5780 | 0 | return; |
5781 | 0 | } |
5782 | 0 | break; |
5783 | | |
5784 | 0 | default: |
5785 | 0 | in->x_sym.x_tagndx.u32 = H_GET_32 (abfd, ext->Sym.WeakDefaultSymIndex); |
5786 | | /* Characteristics is ignored. */ |
5787 | 0 | break; |
5788 | 0 | } |
5789 | 0 | } Unexecuted instantiation: pe-x86_64.c:coff_bigobj_swap_aux_in 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 | | }; |