Coverage Report

Created: 2023-08-28 06:28

/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
#include <string.h>
356
357
#ifdef COFF_WITH_PE
358
#include "peicode.h"
359
#else
360
#include "coffswap.h"
361
#endif
362
363
0
#define STRING_SIZE_SIZE 4
364
365
7.15M
#define DOT_DEBUG ".debug"
366
7.14M
#define DOT_ZDEBUG  ".zdebug"
367
598k
#define GNU_LINKONCE_WI ".gnu.linkonce.wi."
368
598k
#define GNU_LINKONCE_WT ".gnu.linkonce.wt."
369
0
#define DOT_RELOC ".reloc"
370
371
#if defined(COFF_WITH_PE) || defined(COFF_GO32_EXE) || defined(COFF_GO32)
372
# define COFF_WITH_EXTENDED_RELOC_COUNTER
373
#endif
374
375
#if defined (COFF_LONG_SECTION_NAMES)
376
/* Needed to expand the inputs to BLANKOR1TOODD.  */
377
#define COFFLONGSECTIONCATHELPER(x,y)    x ## y
378
/* If the input macro Y is blank or '1', return an odd number; if it is
379
   '0', return an even number.  Result undefined in all other cases.  */
380
#define BLANKOR1TOODD(y)     COFFLONGSECTIONCATHELPER(1,y)
381
/* Defined to numerical 0 or 1 according to whether generation of long
382
   section names is disabled or enabled by default.  */
383
#define COFF_ENABLE_LONG_SECTION_NAMES   (BLANKOR1TOODD(COFF_LONG_SECTION_NAMES) & 1)
384
/* Where long section names are supported, we allow them to be enabled
385
   and disabled at runtime, so select an appropriate hook function for
386
   _bfd_coff_set_long_section_names.  */
387
#define COFF_LONG_SECTION_NAMES_SETTER   bfd_coff_set_long_section_names_allowed
388
#else /* !defined (COFF_LONG_SECTION_NAMES) */
389
/* If long section names are not supported, this stub disallows any
390
   attempt to enable them at run-time.  */
391
#define COFF_LONG_SECTION_NAMES_SETTER   bfd_coff_set_long_section_names_disallowed
392
#endif /* defined (COFF_LONG_SECTION_NAMES) */
393
394
/* Define a macro that can be used to initialise both the fields relating
395
   to long section names in the backend data struct simultaneously.  */
396
#if COFF_ENABLE_LONG_SECTION_NAMES
397
#define COFF_DEFAULT_LONG_SECTION_NAMES  (true), COFF_LONG_SECTION_NAMES_SETTER
398
#else /* !COFF_ENABLE_LONG_SECTION_NAMES */
399
#define COFF_DEFAULT_LONG_SECTION_NAMES  (false), COFF_LONG_SECTION_NAMES_SETTER
400
#endif /* COFF_ENABLE_LONG_SECTION_NAMES */
401
402
static enum coff_symbol_classification coff_classify_symbol
403
  (bfd *, struct internal_syment *);
404

405
/* void warning(); */
406
407
#if defined (COFF_LONG_SECTION_NAMES)
408
static bool
409
bfd_coff_set_long_section_names_allowed (bfd *abfd, int enable)
410
806k
{
411
806k
  bfd_coff_long_section_names (abfd) = enable;
412
806k
  return true;
413
806k
}
pei-i386.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
121k
{
411
121k
  bfd_coff_long_section_names (abfd) = enable;
412
121k
  return true;
413
121k
}
pe-x86_64.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
42.9k
{
411
42.9k
  bfd_coff_long_section_names (abfd) = enable;
412
42.9k
  return true;
413
42.9k
}
pei-x86_64.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
24.0k
{
411
24.0k
  bfd_coff_long_section_names (abfd) = enable;
412
24.0k
  return true;
413
24.0k
}
pe-aarch64.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
35.8k
{
411
35.8k
  bfd_coff_long_section_names (abfd) = enable;
412
35.8k
  return true;
413
35.8k
}
pei-aarch64.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
10.4k
{
411
10.4k
  bfd_coff_long_section_names (abfd) = enable;
412
10.4k
  return true;
413
10.4k
}
pei-ia64.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
16.6k
{
411
16.6k
  bfd_coff_long_section_names (abfd) = enable;
412
16.6k
  return true;
413
16.6k
}
pei-loongarch64.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
14.5k
{
411
14.5k
  bfd_coff_long_section_names (abfd) = enable;
412
14.5k
  return true;
413
14.5k
}
coff-go32.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
347k
{
411
347k
  bfd_coff_long_section_names (abfd) = enable;
412
347k
  return true;
413
347k
}
coff-stgo32.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
14.6k
{
411
14.6k
  bfd_coff_long_section_names (abfd) = enable;
412
14.6k
  return true;
413
14.6k
}
pe-arm-wince.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
11.0k
{
411
11.0k
  bfd_coff_long_section_names (abfd) = enable;
412
11.0k
  return true;
413
11.0k
}
pe-arm.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
11.0k
{
411
11.0k
  bfd_coff_long_section_names (abfd) = enable;
412
11.0k
  return true;
413
11.0k
}
pe-i386.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
18.2k
{
411
18.2k
  bfd_coff_long_section_names (abfd) = enable;
412
18.2k
  return true;
413
18.2k
}
pe-mcore.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
10.9k
{
411
10.9k
  bfd_coff_long_section_names (abfd) = enable;
412
10.9k
  return true;
413
10.9k
}
pe-sh.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
20.8k
{
411
20.8k
  bfd_coff_long_section_names (abfd) = enable;
412
20.8k
  return true;
413
20.8k
}
pei-arm-wince.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
23.3k
{
411
23.3k
  bfd_coff_long_section_names (abfd) = enable;
412
23.3k
  return true;
413
23.3k
}
pei-arm.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
28.4k
{
411
28.4k
  bfd_coff_long_section_names (abfd) = enable;
412
28.4k
  return true;
413
28.4k
}
pei-mcore.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
25.3k
{
411
25.3k
  bfd_coff_long_section_names (abfd) = enable;
412
25.3k
  return true;
413
25.3k
}
pei-sh.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
28.2k
{
411
28.2k
  bfd_coff_long_section_names (abfd) = enable;
412
28.2k
  return true;
413
28.2k
}
414
#else /* !defined (COFF_LONG_SECTION_NAMES) */
415
static bool
416
bfd_coff_set_long_section_names_disallowed (bfd *abfd ATTRIBUTE_UNUSED,
417
              int enable ATTRIBUTE_UNUSED)
418
15.8M
{
419
15.8M
  return false;
420
15.8M
}
coff-x86_64.c:bfd_coff_set_long_section_names_disallowed
Line
Count
Source
418
3.19M
{
419
3.19M
  return false;
420
3.19M
}
coff64-rs6000.c:bfd_coff_set_long_section_names_disallowed
Line
Count
Source
418
871k
{
419
871k
  return false;
420
871k
}
cf-i386lynx.c:bfd_coff_set_long_section_names_disallowed
Line
Count
Source
418
400k
{
419
400k
  return false;
420
400k
}
coff-i386.c:bfd_coff_set_long_section_names_disallowed
Line
Count
Source
418
386k
{
419
386k
  return false;
420
386k
}
coff-rs6000.c:bfd_coff_set_long_section_names_disallowed
Line
Count
Source
418
3.72M
{
419
3.72M
  return false;
420
3.72M
}
coff-sh.c:bfd_coff_set_long_section_names_disallowed
Line
Count
Source
418
2.81M
{
419
2.81M
  return false;
420
2.81M
}
coff-tic30.c:bfd_coff_set_long_section_names_disallowed
Line
Count
Source
418
1.22M
{
419
1.22M
  return false;
420
1.22M
}
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
418
2.71M
{
419
2.71M
  return false;
420
2.71M
}
coff-z80.c:bfd_coff_set_long_section_names_disallowed
Line
Count
Source
418
142k
{
419
142k
  return false;
420
142k
}
coff-z8k.c:bfd_coff_set_long_section_names_disallowed
Line
Count
Source
418
365k
{
419
365k
  return false;
420
365k
}
421
#endif /* defined (COFF_LONG_SECTION_NAMES) */
422
423
/* Return a word with STYP_* (scnhdr.s_flags) flags set to represent
424
   the incoming SEC_* flags.  The inverse of this function is
425
   styp_to_sec_flags().  NOTE: If you add to/change this routine, you
426
   should probably mirror the changes in styp_to_sec_flags().  */
427
428
#ifndef COFF_WITH_PE
429
430
/* Macros for setting debugging flags.  */
431
432
#ifdef STYP_DEBUG
433
0
#define STYP_XCOFF_DEBUG STYP_DEBUG
434
#else
435
0
#define STYP_XCOFF_DEBUG STYP_INFO
436
#endif
437
438
#ifdef COFF_ALIGN_IN_S_FLAGS
439
0
#define STYP_DEBUG_INFO STYP_DSECT
440
#else
441
0
#define STYP_DEBUG_INFO STYP_INFO
442
#endif
443
444
static long
445
sec_to_styp_flags (const char *sec_name, flagword sec_flags)
446
0
{
447
0
  long styp_flags = 0;
448
449
0
  if (!strcmp (sec_name, _TEXT))
450
0
    {
451
0
      styp_flags = STYP_TEXT;
452
0
    }
453
0
  else if (!strcmp (sec_name, _DATA))
454
0
    {
455
0
      styp_flags = STYP_DATA;
456
0
    }
457
0
  else if (!strcmp (sec_name, _BSS))
458
0
    {
459
0
      styp_flags = STYP_BSS;
460
#ifdef _COMMENT
461
    }
462
0
  else if (!strcmp (sec_name, _COMMENT))
463
0
    {
464
0
      styp_flags = STYP_INFO;
465
#endif /* _COMMENT */
466
#ifdef _LIB
467
    }
468
0
  else if (!strcmp (sec_name, _LIB))
469
0
    {
470
0
      styp_flags = STYP_LIB;
471
#endif /* _LIB */
472
#ifdef _LIT
473
    }
474
  else if (!strcmp (sec_name, _LIT))
475
    {
476
      styp_flags = STYP_LIT;
477
#endif /* _LIT */
478
0
    }
479
0
  else if (startswith (sec_name, DOT_DEBUG)
480
0
     || startswith (sec_name, DOT_ZDEBUG))
481
0
    {
482
      /* Handle the XCOFF debug section and DWARF2 debug sections.  */
483
0
      if (!sec_name[6])
484
0
  styp_flags = STYP_XCOFF_DEBUG;
485
0
      else
486
0
  styp_flags = STYP_DEBUG_INFO;
487
0
    }
488
0
  else if (startswith (sec_name, ".stab"))
489
0
    {
490
0
      styp_flags = STYP_DEBUG_INFO;
491
0
    }
492
#ifdef COFF_LONG_SECTION_NAMES
493
0
  else if (startswith (sec_name, GNU_LINKONCE_WI)
494
0
     || startswith (sec_name, GNU_LINKONCE_WT))
495
0
    {
496
0
      styp_flags = STYP_DEBUG_INFO;
497
0
    }
498
0
#endif
499
#ifdef RS6000COFF_C
500
0
  else if (!strcmp (sec_name, _TDATA))
501
0
    {
502
0
      styp_flags = STYP_TDATA;
503
0
    }
504
0
  else if (!strcmp (sec_name, _TBSS))
505
0
    {
506
0
      styp_flags = STYP_TBSS;
507
0
    }
508
0
  else if (!strcmp (sec_name, _PAD))
509
0
    {
510
0
      styp_flags = STYP_PAD;
511
0
    }
512
0
  else if (!strcmp (sec_name, _LOADER))
513
0
    {
514
0
      styp_flags = STYP_LOADER;
515
0
    }
516
0
  else if (!strcmp (sec_name, _EXCEPT))
517
0
    {
518
0
      styp_flags = STYP_EXCEPT;
519
0
    }
520
0
  else if (!strcmp (sec_name, _TYPCHK))
521
0
    {
522
0
      styp_flags = STYP_TYPCHK;
523
0
    }
524
0
  else if (sec_flags & SEC_DEBUGGING)
525
0
    {
526
0
      int i;
527
528
0
      for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++)
529
0
  if (!strcmp (sec_name, xcoff_dwsect_names[i].xcoff_name))
530
0
    {
531
0
      styp_flags = STYP_DWARF | xcoff_dwsect_names[i].flag;
532
0
      break;
533
0
    }
534
0
    }
535
0
#endif
536
  /* Try and figure out what it should be */
537
0
  else if (sec_flags & SEC_CODE)
538
0
    {
539
0
      styp_flags = STYP_TEXT;
540
0
    }
541
0
  else if (sec_flags & SEC_DATA)
542
0
    {
543
0
      styp_flags = STYP_DATA;
544
0
    }
545
0
  else if (sec_flags & SEC_READONLY)
546
0
    {
547
0
#ifdef STYP_LIT     /* 29k readonly text/data section */
548
0
      styp_flags = STYP_LIT;
549
#else
550
      styp_flags = STYP_TEXT;
551
#endif /* STYP_LIT */
552
0
    }
553
0
  else if (sec_flags & SEC_LOAD)
554
0
    {
555
0
      styp_flags = STYP_TEXT;
556
0
    }
557
0
  else if (sec_flags & SEC_ALLOC)
558
0
    {
559
0
      styp_flags = STYP_BSS;
560
0
    }
561
562
#ifdef STYP_CLINK
563
0
  if (sec_flags & SEC_TIC54X_CLINK)
564
0
    styp_flags |= STYP_CLINK;
565
#endif
566
567
#ifdef STYP_BLOCK
568
0
  if (sec_flags & SEC_TIC54X_BLOCK)
569
0
    styp_flags |= STYP_BLOCK;
570
#endif
571
572
0
#ifdef STYP_NOLOAD
573
0
  if ((sec_flags & (SEC_NEVER_LOAD | SEC_COFF_SHARED_LIBRARY)) != 0)
574
0
    styp_flags |= STYP_NOLOAD;
575
0
#endif
576
577
0
  return styp_flags;
578
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
579
580
#else /* COFF_WITH_PE */
581
582
/* The PE version; see above for the general comments.  The non-PE
583
   case seems to be more guessing, and breaks PE format; specifically,
584
   .rdata is readonly, but it sure ain't text.  Really, all this
585
   should be set up properly in gas (or whatever assembler is in use),
586
   and honor whatever objcopy/strip, etc. sent us as input.  */
587
588
static long
589
sec_to_styp_flags (const char *sec_name, flagword sec_flags)
590
0
{
591
0
  long styp_flags = 0;
592
0
  bool is_dbg = false;
593
594
0
  if (startswith (sec_name, DOT_DEBUG)
595
0
      || startswith (sec_name, DOT_ZDEBUG)
596
0
#ifdef COFF_LONG_SECTION_NAMES
597
0
      || startswith (sec_name, GNU_LINKONCE_WI)
598
0
      || startswith (sec_name, GNU_LINKONCE_WT)
599
0
#endif
600
0
      || startswith (sec_name, ".stab"))
601
0
    is_dbg = true;
602
603
  /* caution: there are at least three groups of symbols that have
604
     very similar bits and meanings: IMAGE_SCN*, SEC_*, and STYP_*.
605
     SEC_* are the BFD internal flags, used for generic BFD
606
     information.  STYP_* are the COFF section flags which appear in
607
     COFF files.  IMAGE_SCN_* are the PE section flags which appear in
608
     PE files.  The STYP_* flags and the IMAGE_SCN_* flags overlap,
609
     but there are more IMAGE_SCN_* flags.  */
610
611
  /* FIXME: There is no gas syntax to specify the debug section flag.  */
612
0
  if (is_dbg)
613
0
    {
614
0
      sec_flags &= (SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD
615
0
        | SEC_LINK_DUPLICATES_SAME_CONTENTS
616
0
        | SEC_LINK_DUPLICATES_SAME_SIZE);
617
0
      sec_flags |= SEC_DEBUGGING | SEC_READONLY;
618
0
    }
619
620
  /* skip LOAD */
621
  /* READONLY later */
622
  /* skip RELOC */
623
0
  if ((sec_flags & SEC_CODE) != 0)
624
0
    styp_flags |= IMAGE_SCN_CNT_CODE;
625
0
  if ((sec_flags & (SEC_DATA | SEC_DEBUGGING)) != 0)
626
0
    styp_flags |= IMAGE_SCN_CNT_INITIALIZED_DATA;
627
0
  if ((sec_flags & SEC_ALLOC) != 0 && (sec_flags & SEC_LOAD) == 0)
628
0
    styp_flags |= IMAGE_SCN_CNT_UNINITIALIZED_DATA;  /* ==STYP_BSS */
629
  /* skip ROM */
630
  /* skip constRUCTOR */
631
  /* skip CONTENTS */
632
#ifndef COFF_IMAGE_WITH_PE
633
  /* I don't think any of the IMAGE_SCN_LNK_* flags set below should be set
634
     when the output is PE. Only object files should have them, for the linker
635
     to consume.  */
636
0
  if ((sec_flags & SEC_IS_COMMON) != 0)
637
0
    styp_flags |= IMAGE_SCN_LNK_COMDAT;
638
#endif
639
0
  if ((sec_flags & SEC_DEBUGGING) != 0)
640
0
    styp_flags |= IMAGE_SCN_MEM_DISCARDABLE;
641
0
  if ((sec_flags & (SEC_EXCLUDE | SEC_NEVER_LOAD)) != 0 && !is_dbg)
642
#ifdef COFF_IMAGE_WITH_PE
643
0
    styp_flags |= IMAGE_SCN_MEM_DISCARDABLE;
644
#else
645
0
    styp_flags |= IMAGE_SCN_LNK_REMOVE;
646
#endif
647
  /* skip IN_MEMORY */
648
  /* skip SORT */
649
#ifndef COFF_IMAGE_WITH_PE
650
0
  if (sec_flags & SEC_LINK_ONCE)
651
0
    styp_flags |= IMAGE_SCN_LNK_COMDAT;
652
0
  if ((sec_flags
653
0
       & (SEC_LINK_DUPLICATES_DISCARD | SEC_LINK_DUPLICATES_SAME_CONTENTS
654
0
    | SEC_LINK_DUPLICATES_SAME_SIZE)) != 0)
655
0
    styp_flags |= IMAGE_SCN_LNK_COMDAT;
656
#endif
657
658
  /* skip LINKER_CREATED */
659
660
0
  if ((sec_flags & SEC_COFF_NOREAD) == 0)
661
0
    styp_flags |= IMAGE_SCN_MEM_READ;     /* Invert NOREAD for read.  */
662
0
  if ((sec_flags & SEC_READONLY) == 0)
663
0
    styp_flags |= IMAGE_SCN_MEM_WRITE;    /* Invert READONLY for write.  */
664
0
  if (sec_flags & SEC_CODE)
665
0
    styp_flags |= IMAGE_SCN_MEM_EXECUTE;  /* CODE->EXECUTE.  */
666
0
  if (sec_flags & SEC_COFF_SHARED)
667
0
    styp_flags |= IMAGE_SCN_MEM_SHARED;   /* Shared remains meaningful.  */
668
669
0
  return styp_flags;
670
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: pe-aarch64.c:sec_to_styp_flags
Unexecuted instantiation: pei-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
671
672
#endif /* COFF_WITH_PE */
673
674
/* Return a word with SEC_* flags set to represent the incoming STYP_*
675
   flags (from scnhdr.s_flags).  The inverse of this function is
676
   sec_to_styp_flags().  NOTE: If you add to/change this routine, you
677
   should probably mirror the changes in sec_to_styp_flags().  */
678
679
#ifndef COFF_WITH_PE
680
681
static bool
682
styp_to_sec_flags (bfd *abfd,
683
       void * hdr,
684
       const char *name,
685
       asection *section ATTRIBUTE_UNUSED,
686
       flagword *flags_ptr)
687
16.2M
{
688
16.2M
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
689
16.2M
  unsigned long styp_flags = internal_s->s_flags;
690
16.2M
  flagword sec_flags = 0;
691
692
#ifdef STYP_BLOCK
693
2.71M
  if (styp_flags & STYP_BLOCK)
694
816k
    sec_flags |= SEC_TIC54X_BLOCK;
695
#endif
696
697
#ifdef STYP_CLINK
698
2.71M
  if (styp_flags & STYP_CLINK)
699
768k
    sec_flags |= SEC_TIC54X_CLINK;
700
#endif
701
702
16.2M
#ifdef STYP_NOLOAD
703
16.2M
  if (styp_flags & STYP_NOLOAD)
704
4.52M
    sec_flags |= SEC_NEVER_LOAD;
705
16.2M
#endif /* STYP_NOLOAD */
706
707
  /* For 386 COFF, at least, an unloadable text or data section is
708
     actually a shared library section.  */
709
16.2M
  if (styp_flags & STYP_TEXT)
710
6.08M
    {
711
6.08M
      if (sec_flags & SEC_NEVER_LOAD)
712
3.11M
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
713
2.96M
      else
714
2.96M
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
715
6.08M
    }
716
10.1M
  else if (styp_flags & STYP_DATA)
717
1.00M
    {
718
1.00M
      if (sec_flags & SEC_NEVER_LOAD)
719
506k
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
720
502k
      else
721
502k
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
722
1.00M
    }
723
9.11M
  else if (styp_flags & STYP_BSS)
724
558k
    {
725
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
726
150k
      if (sec_flags & SEC_NEVER_LOAD)
727
46.6k
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
728
104k
      else
729
104k
#endif
730
511k
  sec_flags |= SEC_ALLOC;
731
558k
    }
732
8.55M
  else if (styp_flags & STYP_INFO)
733
1.09M
    {
734
      /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is
735
   defined.  coff_compute_section_file_positions uses
736
   COFF_PAGE_SIZE to ensure that the low order bits of the
737
   section VMA and the file offset match.  If we don't know
738
   COFF_PAGE_SIZE, we can't ensure the correct correspondence,
739
   and demand page loading of the file will fail.  */
740
#if defined (COFF_PAGE_SIZE) && !defined (COFF_ALIGN_IN_S_FLAGS)
741
284k
      sec_flags |= SEC_DEBUGGING;
742
#endif
743
1.09M
    }
744
7.46M
  else if (styp_flags & STYP_PAD)
745
364k
    sec_flags = 0;
746
#ifdef RS6000COFF_C
747
2.09M
  else if (styp_flags & STYP_TDATA)
748
112k
    {
749
112k
      if (sec_flags & SEC_NEVER_LOAD)
750
8.81k
  sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY;
751
103k
      else
752
103k
  sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_LOAD | SEC_ALLOC;
753
112k
    }
754
1.98M
  else if (styp_flags & STYP_TBSS)
755
53.0k
    {
756
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
757
      if (sec_flags & SEC_NEVER_LOAD)
758
  sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY;
759
      else
760
#endif
761
53.0k
  sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL;
762
53.0k
    }
763
1.93M
  else if (styp_flags & STYP_EXCEPT)
764
91.3k
    sec_flags |= SEC_LOAD;
765
1.83M
  else if (styp_flags & STYP_LOADER)
766
35.8k
    sec_flags |= SEC_LOAD;
767
1.80M
  else if (styp_flags & STYP_TYPCHK)
768
14.8k
    sec_flags |= SEC_LOAD;
769
1.78M
  else if (styp_flags & STYP_DWARF)
770
20.8k
    sec_flags |= SEC_DEBUGGING;
771
1.76M
#endif
772
6.76M
  else if (strcmp (name, _TEXT) == 0)
773
14.8k
    {
774
14.8k
      if (sec_flags & SEC_NEVER_LOAD)
775
4.20k
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
776
10.6k
      else
777
10.6k
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
778
14.8k
    }
779
6.75M
  else if (strcmp (name, _DATA) == 0)
780
23.5k
    {
781
23.5k
      if (sec_flags & SEC_NEVER_LOAD)
782
3.51k
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
783
20.0k
      else
784
20.0k
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
785
23.5k
    }
786
6.72M
  else if (strcmp (name, _BSS) == 0)
787
10.2k
    {
788
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
789
2.84k
      if (sec_flags & SEC_NEVER_LOAD)
790
1.24k
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
791
1.59k
      else
792
1.59k
#endif
793
9.04k
  sec_flags |= SEC_ALLOC;
794
10.2k
    }
795
6.71M
  else if (startswith (name, DOT_DEBUG)
796
6.71M
     || startswith (name, DOT_ZDEBUG)
797
#ifdef _COMMENT
798
3.82M
     || strcmp (name, _COMMENT) == 0
799
#endif
800
#ifdef COFF_LONG_SECTION_NAMES
801
165k
     || startswith (name, GNU_LINKONCE_WI)
802
165k
     || startswith (name, GNU_LINKONCE_WT)
803
#endif
804
6.71M
     || startswith (name, ".stab"))
805
36.8k
    {
806
#ifdef COFF_PAGE_SIZE
807
15.9k
      sec_flags |= SEC_DEBUGGING;
808
#endif
809
36.8k
    }
810
#ifdef _LIB
811
3.80M
  else if (strcmp (name, _LIB) == 0)
812
1.87k
    ;
813
3.80M
#endif
814
#ifdef _LIT
815
  else if (strcmp (name, _LIT) == 0)
816
    sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY;
817
#endif
818
3.80M
  else
819
6.68M
    sec_flags |= SEC_ALLOC | SEC_LOAD;
820
821
16.2M
#ifdef STYP_LIT     /* A29k readonly text/data section type.  */
822
16.2M
  if ((styp_flags & STYP_LIT) == STYP_LIT)
823
1.61M
    sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY);
824
16.2M
#endif /* STYP_LIT */
825
826
#ifdef STYP_OTHER_LOAD    /* Other loaded sections.  */
827
  if (styp_flags & STYP_OTHER_LOAD)
828
    sec_flags = (SEC_LOAD | SEC_ALLOC);
829
#endif /* STYP_SDATA */
830
831
16.2M
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
832
16.2M
      && (startswith (name, ".sbss")
833
0
    || startswith (name, ".sdata")))
834
0
    sec_flags |= SEC_SMALL_DATA;
835
836
#if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE)
837
  /* As a GNU extension, if the name begins with .gnu.linkonce, we
838
     only link a single copy of the section.  This is used to support
839
     g++.  g++ will emit each template expansion in its own section.
840
     The symbols will be defined as weak, so that multiple definitions
841
     are permitted.  The GNU linker extension is to actually discard
842
     all but one of the sections.  */
843
357k
  if (startswith (name, ".gnu.linkonce"))
844
127
    sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
845
#endif
846
847
16.2M
  if (flags_ptr == NULL)
848
0
    return false;
849
850
16.2M
  * flags_ptr = sec_flags;
851
16.2M
  return true;
852
16.2M
}
coff-x86_64.c:styp_to_sec_flags
Line
Count
Source
687
3.19M
{
688
3.19M
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
689
3.19M
  unsigned long styp_flags = internal_s->s_flags;
690
3.19M
  flagword sec_flags = 0;
691
692
#ifdef STYP_BLOCK
693
  if (styp_flags & STYP_BLOCK)
694
    sec_flags |= SEC_TIC54X_BLOCK;
695
#endif
696
697
#ifdef STYP_CLINK
698
  if (styp_flags & STYP_CLINK)
699
    sec_flags |= SEC_TIC54X_CLINK;
700
#endif
701
702
3.19M
#ifdef STYP_NOLOAD
703
3.19M
  if (styp_flags & STYP_NOLOAD)
704
933k
    sec_flags |= SEC_NEVER_LOAD;
705
3.19M
#endif /* STYP_NOLOAD */
706
707
  /* For 386 COFF, at least, an unloadable text or data section is
708
     actually a shared library section.  */
709
3.19M
  if (styp_flags & STYP_TEXT)
710
1.25M
    {
711
1.25M
      if (sec_flags & SEC_NEVER_LOAD)
712
656k
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
713
597k
      else
714
597k
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
715
1.25M
    }
716
1.93M
  else if (styp_flags & STYP_DATA)
717
213k
    {
718
213k
      if (sec_flags & SEC_NEVER_LOAD)
719
110k
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
720
102k
      else
721
102k
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
722
213k
    }
723
1.72M
  else if (styp_flags & STYP_BSS)
724
104k
    {
725
104k
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
726
104k
      if (sec_flags & SEC_NEVER_LOAD)
727
28.9k
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
728
75.8k
      else
729
75.8k
#endif
730
75.8k
  sec_flags |= SEC_ALLOC;
731
104k
    }
732
1.62M
  else if (styp_flags & STYP_INFO)
733
194k
    {
734
      /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is
735
   defined.  coff_compute_section_file_positions uses
736
   COFF_PAGE_SIZE to ensure that the low order bits of the
737
   section VMA and the file offset match.  If we don't know
738
   COFF_PAGE_SIZE, we can't ensure the correct correspondence,
739
   and demand page loading of the file will fail.  */
740
194k
#if defined (COFF_PAGE_SIZE) && !defined (COFF_ALIGN_IN_S_FLAGS)
741
194k
      sec_flags |= SEC_DEBUGGING;
742
194k
#endif
743
194k
    }
744
1.42M
  else if (styp_flags & STYP_PAD)
745
68.3k
    sec_flags = 0;
746
#ifdef RS6000COFF_C
747
  else if (styp_flags & STYP_TDATA)
748
    {
749
      if (sec_flags & SEC_NEVER_LOAD)
750
  sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY;
751
      else
752
  sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_LOAD | SEC_ALLOC;
753
    }
754
  else if (styp_flags & STYP_TBSS)
755
    {
756
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
757
      if (sec_flags & SEC_NEVER_LOAD)
758
  sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY;
759
      else
760
#endif
761
  sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL;
762
    }
763
  else if (styp_flags & STYP_EXCEPT)
764
    sec_flags |= SEC_LOAD;
765
  else if (styp_flags & STYP_LOADER)
766
    sec_flags |= SEC_LOAD;
767
  else if (styp_flags & STYP_TYPCHK)
768
    sec_flags |= SEC_LOAD;
769
  else if (styp_flags & STYP_DWARF)
770
    sec_flags |= SEC_DEBUGGING;
771
#endif
772
1.35M
  else if (strcmp (name, _TEXT) == 0)
773
2.35k
    {
774
2.35k
      if (sec_flags & SEC_NEVER_LOAD)
775
241
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
776
2.11k
      else
777
2.11k
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
778
2.35k
    }
779
1.35M
  else if (strcmp (name, _DATA) == 0)
780
3.53k
    {
781
3.53k
      if (sec_flags & SEC_NEVER_LOAD)
782
1.07k
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
783
2.45k
      else
784
2.45k
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
785
3.53k
    }
786
1.35M
  else if (strcmp (name, _BSS) == 0)
787
2.12k
    {
788
2.12k
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
789
2.12k
      if (sec_flags & SEC_NEVER_LOAD)
790
1.07k
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
791
1.05k
      else
792
1.05k
#endif
793
1.05k
  sec_flags |= SEC_ALLOC;
794
2.12k
    }
795
1.34M
  else if (startswith (name, DOT_DEBUG)
796
1.34M
     || startswith (name, DOT_ZDEBUG)
797
1.34M
#ifdef _COMMENT
798
1.34M
     || strcmp (name, _COMMENT) == 0
799
1.34M
#endif
800
#ifdef COFF_LONG_SECTION_NAMES
801
     || startswith (name, GNU_LINKONCE_WI)
802
     || startswith (name, GNU_LINKONCE_WT)
803
#endif
804
1.34M
     || startswith (name, ".stab"))
805
11.8k
    {
806
11.8k
#ifdef COFF_PAGE_SIZE
807
11.8k
      sec_flags |= SEC_DEBUGGING;
808
11.8k
#endif
809
11.8k
    }
810
1.33M
#ifdef _LIB
811
1.33M
  else if (strcmp (name, _LIB) == 0)
812
539
    ;
813
1.33M
#endif
814
#ifdef _LIT
815
  else if (strcmp (name, _LIT) == 0)
816
    sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY;
817
#endif
818
1.33M
  else
819
1.33M
    sec_flags |= SEC_ALLOC | SEC_LOAD;
820
821
3.19M
#ifdef STYP_LIT     /* A29k readonly text/data section type.  */
822
3.19M
  if ((styp_flags & STYP_LIT) == STYP_LIT)
823
307k
    sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY);
824
3.19M
#endif /* STYP_LIT */
825
826
#ifdef STYP_OTHER_LOAD    /* Other loaded sections.  */
827
  if (styp_flags & STYP_OTHER_LOAD)
828
    sec_flags = (SEC_LOAD | SEC_ALLOC);
829
#endif /* STYP_SDATA */
830
831
3.19M
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
832
3.19M
      && (startswith (name, ".sbss")
833
0
    || startswith (name, ".sdata")))
834
0
    sec_flags |= SEC_SMALL_DATA;
835
836
#if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE)
837
  /* As a GNU extension, if the name begins with .gnu.linkonce, we
838
     only link a single copy of the section.  This is used to support
839
     g++.  g++ will emit each template expansion in its own section.
840
     The symbols will be defined as weak, so that multiple definitions
841
     are permitted.  The GNU linker extension is to actually discard
842
     all but one of the sections.  */
843
  if (startswith (name, ".gnu.linkonce"))
844
    sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
845
#endif
846
847
3.19M
  if (flags_ptr == NULL)
848
0
    return false;
849
850
3.19M
  * flags_ptr = sec_flags;
851
3.19M
  return true;
852
3.19M
}
coff64-rs6000.c:styp_to_sec_flags
Line
Count
Source
687
871k
{
688
871k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
689
871k
  unsigned long styp_flags = internal_s->s_flags;
690
871k
  flagword sec_flags = 0;
691
692
#ifdef STYP_BLOCK
693
  if (styp_flags & STYP_BLOCK)
694
    sec_flags |= SEC_TIC54X_BLOCK;
695
#endif
696
697
#ifdef STYP_CLINK
698
  if (styp_flags & STYP_CLINK)
699
    sec_flags |= SEC_TIC54X_CLINK;
700
#endif
701
702
871k
#ifdef STYP_NOLOAD
703
871k
  if (styp_flags & STYP_NOLOAD)
704
234k
    sec_flags |= SEC_NEVER_LOAD;
705
871k
#endif /* STYP_NOLOAD */
706
707
  /* For 386 COFF, at least, an unloadable text or data section is
708
     actually a shared library section.  */
709
871k
  if (styp_flags & STYP_TEXT)
710
287k
    {
711
287k
      if (sec_flags & SEC_NEVER_LOAD)
712
155k
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
713
132k
      else
714
132k
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
715
287k
    }
716
583k
  else if (styp_flags & STYP_DATA)
717
55.8k
    {
718
55.8k
      if (sec_flags & SEC_NEVER_LOAD)
719
25.7k
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
720
30.0k
      else
721
30.0k
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
722
55.8k
    }
723
528k
  else if (styp_flags & STYP_BSS)
724
35.2k
    {
725
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
726
      if (sec_flags & SEC_NEVER_LOAD)
727
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
728
      else
729
#endif
730
35.2k
  sec_flags |= SEC_ALLOC;
731
35.2k
    }
732
492k
  else if (styp_flags & STYP_INFO)
733
63.0k
    {
734
      /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is
735
   defined.  coff_compute_section_file_positions uses
736
   COFF_PAGE_SIZE to ensure that the low order bits of the
737
   section VMA and the file offset match.  If we don't know
738
   COFF_PAGE_SIZE, we can't ensure the correct correspondence,
739
   and demand page loading of the file will fail.  */
740
#if defined (COFF_PAGE_SIZE) && !defined (COFF_ALIGN_IN_S_FLAGS)
741
      sec_flags |= SEC_DEBUGGING;
742
#endif
743
63.0k
    }
744
429k
  else if (styp_flags & STYP_PAD)
745
25.7k
    sec_flags = 0;
746
404k
#ifdef RS6000COFF_C
747
404k
  else if (styp_flags & STYP_TDATA)
748
37.6k
    {
749
37.6k
      if (sec_flags & SEC_NEVER_LOAD)
750
2.29k
  sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY;
751
35.3k
      else
752
35.3k
  sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_LOAD | SEC_ALLOC;
753
37.6k
    }
754
366k
  else if (styp_flags & STYP_TBSS)
755
12.8k
    {
756
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
757
      if (sec_flags & SEC_NEVER_LOAD)
758
  sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY;
759
      else
760
#endif
761
12.8k
  sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL;
762
12.8k
    }
763
353k
  else if (styp_flags & STYP_EXCEPT)
764
22.5k
    sec_flags |= SEC_LOAD;
765
330k
  else if (styp_flags & STYP_LOADER)
766
16.3k
    sec_flags |= SEC_LOAD;
767
314k
  else if (styp_flags & STYP_TYPCHK)
768
3.45k
    sec_flags |= SEC_LOAD;
769
311k
  else if (styp_flags & STYP_DWARF)
770
5.94k
    sec_flags |= SEC_DEBUGGING;
771
305k
#endif
772
305k
  else if (strcmp (name, _TEXT) == 0)
773
638
    {
774
638
      if (sec_flags & SEC_NEVER_LOAD)
775
237
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
776
401
      else
777
401
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
778
638
    }
779
304k
  else if (strcmp (name, _DATA) == 0)
780
773
    {
781
773
      if (sec_flags & SEC_NEVER_LOAD)
782
134
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
783
639
      else
784
639
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
785
773
    }
786
303k
  else if (strcmp (name, _BSS) == 0)
787
464
    {
788
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
789
      if (sec_flags & SEC_NEVER_LOAD)
790
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
791
      else
792
#endif
793
464
  sec_flags |= SEC_ALLOC;
794
464
    }
795
303k
  else if (startswith (name, DOT_DEBUG)
796
303k
     || startswith (name, DOT_ZDEBUG)
797
#ifdef _COMMENT
798
     || strcmp (name, _COMMENT) == 0
799
#endif
800
#ifdef COFF_LONG_SECTION_NAMES
801
     || startswith (name, GNU_LINKONCE_WI)
802
     || startswith (name, GNU_LINKONCE_WT)
803
#endif
804
303k
     || startswith (name, ".stab"))
805
1.23k
    {
806
#ifdef COFF_PAGE_SIZE
807
      sec_flags |= SEC_DEBUGGING;
808
#endif
809
1.23k
    }
810
#ifdef _LIB
811
  else if (strcmp (name, _LIB) == 0)
812
    ;
813
#endif
814
#ifdef _LIT
815
  else if (strcmp (name, _LIT) == 0)
816
    sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY;
817
#endif
818
302k
  else
819
302k
    sec_flags |= SEC_ALLOC | SEC_LOAD;
820
821
871k
#ifdef STYP_LIT     /* A29k readonly text/data section type.  */
822
871k
  if ((styp_flags & STYP_LIT) == STYP_LIT)
823
65.1k
    sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY);
824
871k
#endif /* STYP_LIT */
825
826
#ifdef STYP_OTHER_LOAD    /* Other loaded sections.  */
827
  if (styp_flags & STYP_OTHER_LOAD)
828
    sec_flags = (SEC_LOAD | SEC_ALLOC);
829
#endif /* STYP_SDATA */
830
831
871k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
832
871k
      && (startswith (name, ".sbss")
833
0
    || startswith (name, ".sdata")))
834
0
    sec_flags |= SEC_SMALL_DATA;
835
836
#if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE)
837
  /* As a GNU extension, if the name begins with .gnu.linkonce, we
838
     only link a single copy of the section.  This is used to support
839
     g++.  g++ will emit each template expansion in its own section.
840
     The symbols will be defined as weak, so that multiple definitions
841
     are permitted.  The GNU linker extension is to actually discard
842
     all but one of the sections.  */
843
  if (startswith (name, ".gnu.linkonce"))
844
    sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
845
#endif
846
847
871k
  if (flags_ptr == NULL)
848
0
    return false;
849
850
871k
  * flags_ptr = sec_flags;
851
871k
  return true;
852
871k
}
cf-i386lynx.c:styp_to_sec_flags
Line
Count
Source
687
400k
{
688
400k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
689
400k
  unsigned long styp_flags = internal_s->s_flags;
690
400k
  flagword sec_flags = 0;
691
692
#ifdef STYP_BLOCK
693
  if (styp_flags & STYP_BLOCK)
694
    sec_flags |= SEC_TIC54X_BLOCK;
695
#endif
696
697
#ifdef STYP_CLINK
698
  if (styp_flags & STYP_CLINK)
699
    sec_flags |= SEC_TIC54X_CLINK;
700
#endif
701
702
400k
#ifdef STYP_NOLOAD
703
400k
  if (styp_flags & STYP_NOLOAD)
704
105k
    sec_flags |= SEC_NEVER_LOAD;
705
400k
#endif /* STYP_NOLOAD */
706
707
  /* For 386 COFF, at least, an unloadable text or data section is
708
     actually a shared library section.  */
709
400k
  if (styp_flags & STYP_TEXT)
710
124k
    {
711
124k
      if (sec_flags & SEC_NEVER_LOAD)
712
63.4k
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
713
61.1k
      else
714
61.1k
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
715
124k
    }
716
275k
  else if (styp_flags & STYP_DATA)
717
29.2k
    {
718
29.2k
      if (sec_flags & SEC_NEVER_LOAD)
719
13.0k
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
720
16.1k
      else
721
16.1k
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
722
29.2k
    }
723
246k
  else if (styp_flags & STYP_BSS)
724
15.9k
    {
725
15.9k
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
726
15.9k
      if (sec_flags & SEC_NEVER_LOAD)
727
6.15k
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
728
9.75k
      else
729
9.75k
#endif
730
9.75k
  sec_flags |= SEC_ALLOC;
731
15.9k
    }
732
230k
  else if (styp_flags & STYP_INFO)
733
31.6k
    {
734
      /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is
735
   defined.  coff_compute_section_file_positions uses
736
   COFF_PAGE_SIZE to ensure that the low order bits of the
737
   section VMA and the file offset match.  If we don't know
738
   COFF_PAGE_SIZE, we can't ensure the correct correspondence,
739
   and demand page loading of the file will fail.  */
740
31.6k
#if defined (COFF_PAGE_SIZE) && !defined (COFF_ALIGN_IN_S_FLAGS)
741
31.6k
      sec_flags |= SEC_DEBUGGING;
742
31.6k
#endif
743
31.6k
    }
744
198k
  else if (styp_flags & STYP_PAD)
745
11.7k
    sec_flags = 0;
746
#ifdef RS6000COFF_C
747
  else if (styp_flags & STYP_TDATA)
748
    {
749
      if (sec_flags & SEC_NEVER_LOAD)
750
  sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY;
751
      else
752
  sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_LOAD | SEC_ALLOC;
753
    }
754
  else if (styp_flags & STYP_TBSS)
755
    {
756
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
757
      if (sec_flags & SEC_NEVER_LOAD)
758
  sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY;
759
      else
760
#endif
761
  sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL;
762
    }
763
  else if (styp_flags & STYP_EXCEPT)
764
    sec_flags |= SEC_LOAD;
765
  else if (styp_flags & STYP_LOADER)
766
    sec_flags |= SEC_LOAD;
767
  else if (styp_flags & STYP_TYPCHK)
768
    sec_flags |= SEC_LOAD;
769
  else if (styp_flags & STYP_DWARF)
770
    sec_flags |= SEC_DEBUGGING;
771
#endif
772
186k
  else if (strcmp (name, _TEXT) == 0)
773
690
    {
774
690
      if (sec_flags & SEC_NEVER_LOAD)
775
543
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
776
147
      else
777
147
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
778
690
    }
779
186k
  else if (strcmp (name, _DATA) == 0)
780
283
    {
781
283
      if (sec_flags & SEC_NEVER_LOAD)
782
67
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
783
216
      else
784
216
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
785
283
    }
786
185k
  else if (strcmp (name, _BSS) == 0)
787
251
    {
788
251
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
789
251
      if (sec_flags & SEC_NEVER_LOAD)
790
61
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
791
190
      else
792
190
#endif
793
190
  sec_flags |= SEC_ALLOC;
794
251
    }
795
185k
  else if (startswith (name, DOT_DEBUG)
796
185k
     || startswith (name, DOT_ZDEBUG)
797
185k
#ifdef _COMMENT
798
185k
     || strcmp (name, _COMMENT) == 0
799
185k
#endif
800
#ifdef COFF_LONG_SECTION_NAMES
801
     || startswith (name, GNU_LINKONCE_WI)
802
     || startswith (name, GNU_LINKONCE_WT)
803
#endif
804
185k
     || startswith (name, ".stab"))
805
1.43k
    {
806
1.43k
#ifdef COFF_PAGE_SIZE
807
1.43k
      sec_flags |= SEC_DEBUGGING;
808
1.43k
#endif
809
1.43k
    }
810
184k
#ifdef _LIB
811
184k
  else if (strcmp (name, _LIB) == 0)
812
34
    ;
813
184k
#endif
814
#ifdef _LIT
815
  else if (strcmp (name, _LIT) == 0)
816
    sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY;
817
#endif
818
184k
  else
819
184k
    sec_flags |= SEC_ALLOC | SEC_LOAD;
820
821
400k
#ifdef STYP_LIT     /* A29k readonly text/data section type.  */
822
400k
  if ((styp_flags & STYP_LIT) == STYP_LIT)
823
41.3k
    sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY);
824
400k
#endif /* STYP_LIT */
825
826
#ifdef STYP_OTHER_LOAD    /* Other loaded sections.  */
827
  if (styp_flags & STYP_OTHER_LOAD)
828
    sec_flags = (SEC_LOAD | SEC_ALLOC);
829
#endif /* STYP_SDATA */
830
831
400k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
832
400k
      && (startswith (name, ".sbss")
833
0
    || startswith (name, ".sdata")))
834
0
    sec_flags |= SEC_SMALL_DATA;
835
836
#if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE)
837
  /* As a GNU extension, if the name begins with .gnu.linkonce, we
838
     only link a single copy of the section.  This is used to support
839
     g++.  g++ will emit each template expansion in its own section.
840
     The symbols will be defined as weak, so that multiple definitions
841
     are permitted.  The GNU linker extension is to actually discard
842
     all but one of the sections.  */
843
  if (startswith (name, ".gnu.linkonce"))
844
    sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
845
#endif
846
847
400k
  if (flags_ptr == NULL)
848
0
    return false;
849
850
400k
  * flags_ptr = sec_flags;
851
400k
  return true;
852
400k
}
coff-go32.c:styp_to_sec_flags
Line
Count
Source
687
342k
{
688
342k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
689
342k
  unsigned long styp_flags = internal_s->s_flags;
690
342k
  flagword sec_flags = 0;
691
692
#ifdef STYP_BLOCK
693
  if (styp_flags & STYP_BLOCK)
694
    sec_flags |= SEC_TIC54X_BLOCK;
695
#endif
696
697
#ifdef STYP_CLINK
698
  if (styp_flags & STYP_CLINK)
699
    sec_flags |= SEC_TIC54X_CLINK;
700
#endif
701
702
342k
#ifdef STYP_NOLOAD
703
342k
  if (styp_flags & STYP_NOLOAD)
704
89.8k
    sec_flags |= SEC_NEVER_LOAD;
705
342k
#endif /* STYP_NOLOAD */
706
707
  /* For 386 COFF, at least, an unloadable text or data section is
708
     actually a shared library section.  */
709
342k
  if (styp_flags & STYP_TEXT)
710
106k
    {
711
106k
      if (sec_flags & SEC_NEVER_LOAD)
712
53.4k
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
713
52.8k
      else
714
52.8k
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
715
106k
    }
716
236k
  else if (styp_flags & STYP_DATA)
717
25.4k
    {
718
25.4k
      if (sec_flags & SEC_NEVER_LOAD)
719
11.2k
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
720
14.1k
      else
721
14.1k
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
722
25.4k
    }
723
211k
  else if (styp_flags & STYP_BSS)
724
14.0k
    {
725
14.0k
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
726
14.0k
      if (sec_flags & SEC_NEVER_LOAD)
727
5.40k
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
728
8.62k
      else
729
8.62k
#endif
730
8.62k
  sec_flags |= SEC_ALLOC;
731
14.0k
    }
732
196k
  else if (styp_flags & STYP_INFO)
733
26.2k
    {
734
      /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is
735
   defined.  coff_compute_section_file_positions uses
736
   COFF_PAGE_SIZE to ensure that the low order bits of the
737
   section VMA and the file offset match.  If we don't know
738
   COFF_PAGE_SIZE, we can't ensure the correct correspondence,
739
   and demand page loading of the file will fail.  */
740
26.2k
#if defined (COFF_PAGE_SIZE) && !defined (COFF_ALIGN_IN_S_FLAGS)
741
26.2k
      sec_flags |= SEC_DEBUGGING;
742
26.2k
#endif
743
26.2k
    }
744
170k
  else if (styp_flags & STYP_PAD)
745
10.1k
    sec_flags = 0;
746
#ifdef RS6000COFF_C
747
  else if (styp_flags & STYP_TDATA)
748
    {
749
      if (sec_flags & SEC_NEVER_LOAD)
750
  sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY;
751
      else
752
  sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_LOAD | SEC_ALLOC;
753
    }
754
  else if (styp_flags & STYP_TBSS)
755
    {
756
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
757
      if (sec_flags & SEC_NEVER_LOAD)
758
  sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY;
759
      else
760
#endif
761
  sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL;
762
    }
763
  else if (styp_flags & STYP_EXCEPT)
764
    sec_flags |= SEC_LOAD;
765
  else if (styp_flags & STYP_LOADER)
766
    sec_flags |= SEC_LOAD;
767
  else if (styp_flags & STYP_TYPCHK)
768
    sec_flags |= SEC_LOAD;
769
  else if (styp_flags & STYP_DWARF)
770
    sec_flags |= SEC_DEBUGGING;
771
#endif
772
160k
  else if (strcmp (name, _TEXT) == 0)
773
658
    {
774
658
      if (sec_flags & SEC_NEVER_LOAD)
775
526
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
776
132
      else
777
132
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
778
658
    }
779
159k
  else if (strcmp (name, _DATA) == 0)
780
233
    {
781
233
      if (sec_flags & SEC_NEVER_LOAD)
782
54
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
783
179
      else
784
179
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
785
233
    }
786
159k
  else if (strcmp (name, _BSS) == 0)
787
209
    {
788
209
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
789
209
      if (sec_flags & SEC_NEVER_LOAD)
790
50
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
791
159
      else
792
159
#endif
793
159
  sec_flags |= SEC_ALLOC;
794
209
    }
795
159k
  else if (startswith (name, DOT_DEBUG)
796
159k
     || startswith (name, DOT_ZDEBUG)
797
159k
#ifdef _COMMENT
798
159k
     || strcmp (name, _COMMENT) == 0
799
159k
#endif
800
159k
#ifdef COFF_LONG_SECTION_NAMES
801
159k
     || startswith (name, GNU_LINKONCE_WI)
802
159k
     || startswith (name, GNU_LINKONCE_WT)
803
159k
#endif
804
159k
     || startswith (name, ".stab"))
805
1.18k
    {
806
1.18k
#ifdef COFF_PAGE_SIZE
807
1.18k
      sec_flags |= SEC_DEBUGGING;
808
1.18k
#endif
809
1.18k
    }
810
158k
#ifdef _LIB
811
158k
  else if (strcmp (name, _LIB) == 0)
812
24
    ;
813
158k
#endif
814
#ifdef _LIT
815
  else if (strcmp (name, _LIT) == 0)
816
    sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY;
817
#endif
818
158k
  else
819
158k
    sec_flags |= SEC_ALLOC | SEC_LOAD;
820
821
342k
#ifdef STYP_LIT     /* A29k readonly text/data section type.  */
822
342k
  if ((styp_flags & STYP_LIT) == STYP_LIT)
823
34.9k
    sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY);
824
342k
#endif /* STYP_LIT */
825
826
#ifdef STYP_OTHER_LOAD    /* Other loaded sections.  */
827
  if (styp_flags & STYP_OTHER_LOAD)
828
    sec_flags = (SEC_LOAD | SEC_ALLOC);
829
#endif /* STYP_SDATA */
830
831
342k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
832
342k
      && (startswith (name, ".sbss")
833
0
    || startswith (name, ".sdata")))
834
0
    sec_flags |= SEC_SMALL_DATA;
835
836
342k
#if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE)
837
  /* As a GNU extension, if the name begins with .gnu.linkonce, we
838
     only link a single copy of the section.  This is used to support
839
     g++.  g++ will emit each template expansion in its own section.
840
     The symbols will be defined as weak, so that multiple definitions
841
     are permitted.  The GNU linker extension is to actually discard
842
     all but one of the sections.  */
843
342k
  if (startswith (name, ".gnu.linkonce"))
844
106
    sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
845
342k
#endif
846
847
342k
  if (flags_ptr == NULL)
848
0
    return false;
849
850
342k
  * flags_ptr = sec_flags;
851
342k
  return true;
852
342k
}
coff-i386.c:styp_to_sec_flags
Line
Count
Source
687
386k
{
688
386k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
689
386k
  unsigned long styp_flags = internal_s->s_flags;
690
386k
  flagword sec_flags = 0;
691
692
#ifdef STYP_BLOCK
693
  if (styp_flags & STYP_BLOCK)
694
    sec_flags |= SEC_TIC54X_BLOCK;
695
#endif
696
697
#ifdef STYP_CLINK
698
  if (styp_flags & STYP_CLINK)
699
    sec_flags |= SEC_TIC54X_CLINK;
700
#endif
701
702
386k
#ifdef STYP_NOLOAD
703
386k
  if (styp_flags & STYP_NOLOAD)
704
101k
    sec_flags |= SEC_NEVER_LOAD;
705
386k
#endif /* STYP_NOLOAD */
706
707
  /* For 386 COFF, at least, an unloadable text or data section is
708
     actually a shared library section.  */
709
386k
  if (styp_flags & STYP_TEXT)
710
120k
    {
711
120k
      if (sec_flags & SEC_NEVER_LOAD)
712
61.1k
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
713
59.3k
      else
714
59.3k
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
715
120k
    }
716
266k
  else if (styp_flags & STYP_DATA)
717
28.2k
    {
718
28.2k
      if (sec_flags & SEC_NEVER_LOAD)
719
12.4k
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
720
15.7k
      else
721
15.7k
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
722
28.2k
    }
723
237k
  else if (styp_flags & STYP_BSS)
724
15.3k
    {
725
15.3k
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
726
15.3k
      if (sec_flags & SEC_NEVER_LOAD)
727
5.91k
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
728
9.46k
      else
729
9.46k
#endif
730
9.46k
  sec_flags |= SEC_ALLOC;
731
15.3k
    }
732
222k
  else if (styp_flags & STYP_INFO)
733
30.5k
    {
734
      /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is
735
   defined.  coff_compute_section_file_positions uses
736
   COFF_PAGE_SIZE to ensure that the low order bits of the
737
   section VMA and the file offset match.  If we don't know
738
   COFF_PAGE_SIZE, we can't ensure the correct correspondence,
739
   and demand page loading of the file will fail.  */
740
30.5k
#if defined (COFF_PAGE_SIZE) && !defined (COFF_ALIGN_IN_S_FLAGS)
741
30.5k
      sec_flags |= SEC_DEBUGGING;
742
30.5k
#endif
743
30.5k
    }
744
191k
  else if (styp_flags & STYP_PAD)
745
11.2k
    sec_flags = 0;
746
#ifdef RS6000COFF_C
747
  else if (styp_flags & STYP_TDATA)
748
    {
749
      if (sec_flags & SEC_NEVER_LOAD)
750
  sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY;
751
      else
752
  sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_LOAD | SEC_ALLOC;
753
    }
754
  else if (styp_flags & STYP_TBSS)
755
    {
756
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
757
      if (sec_flags & SEC_NEVER_LOAD)
758
  sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY;
759
      else
760
#endif
761
  sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL;
762
    }
763
  else if (styp_flags & STYP_EXCEPT)
764
    sec_flags |= SEC_LOAD;
765
  else if (styp_flags & STYP_LOADER)
766
    sec_flags |= SEC_LOAD;
767
  else if (styp_flags & STYP_TYPCHK)
768
    sec_flags |= SEC_LOAD;
769
  else if (styp_flags & STYP_DWARF)
770
    sec_flags |= SEC_DEBUGGING;
771
#endif
772
180k
  else if (strcmp (name, _TEXT) == 0)
773
676
    {
774
676
      if (sec_flags & SEC_NEVER_LOAD)
775
539
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
776
137
      else
777
137
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
778
676
    }
779
179k
  else if (strcmp (name, _DATA) == 0)
780
270
    {
781
270
      if (sec_flags & SEC_NEVER_LOAD)
782
64
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
783
206
      else
784
206
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
785
270
    }
786
179k
  else if (strcmp (name, _BSS) == 0)
787
219
    {
788
219
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
789
219
      if (sec_flags & SEC_NEVER_LOAD)
790
50
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
791
169
      else
792
169
#endif
793
169
  sec_flags |= SEC_ALLOC;
794
219
    }
795
179k
  else if (startswith (name, DOT_DEBUG)
796
179k
     || startswith (name, DOT_ZDEBUG)
797
179k
#ifdef _COMMENT
798
179k
     || strcmp (name, _COMMENT) == 0
799
179k
#endif
800
#ifdef COFF_LONG_SECTION_NAMES
801
     || startswith (name, GNU_LINKONCE_WI)
802
     || startswith (name, GNU_LINKONCE_WT)
803
#endif
804
179k
     || startswith (name, ".stab"))
805
1.24k
    {
806
1.24k
#ifdef COFF_PAGE_SIZE
807
1.24k
      sec_flags |= SEC_DEBUGGING;
808
1.24k
#endif
809
1.24k
    }
810
178k
#ifdef _LIB
811
178k
  else if (strcmp (name, _LIB) == 0)
812
28
    ;
813
178k
#endif
814
#ifdef _LIT
815
  else if (strcmp (name, _LIT) == 0)
816
    sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY;
817
#endif
818
178k
  else
819
178k
    sec_flags |= SEC_ALLOC | SEC_LOAD;
820
821
386k
#ifdef STYP_LIT     /* A29k readonly text/data section type.  */
822
386k
  if ((styp_flags & STYP_LIT) == STYP_LIT)
823
39.5k
    sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY);
824
386k
#endif /* STYP_LIT */
825
826
#ifdef STYP_OTHER_LOAD    /* Other loaded sections.  */
827
  if (styp_flags & STYP_OTHER_LOAD)
828
    sec_flags = (SEC_LOAD | SEC_ALLOC);
829
#endif /* STYP_SDATA */
830
831
386k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
832
386k
      && (startswith (name, ".sbss")
833
0
    || startswith (name, ".sdata")))
834
0
    sec_flags |= SEC_SMALL_DATA;
835
836
#if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE)
837
  /* As a GNU extension, if the name begins with .gnu.linkonce, we
838
     only link a single copy of the section.  This is used to support
839
     g++.  g++ will emit each template expansion in its own section.
840
     The symbols will be defined as weak, so that multiple definitions
841
     are permitted.  The GNU linker extension is to actually discard
842
     all but one of the sections.  */
843
  if (startswith (name, ".gnu.linkonce"))
844
    sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
845
#endif
846
847
386k
  if (flags_ptr == NULL)
848
0
    return false;
849
850
386k
  * flags_ptr = sec_flags;
851
386k
  return true;
852
386k
}
coff-rs6000.c:styp_to_sec_flags
Line
Count
Source
687
3.72M
{
688
3.72M
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
689
3.72M
  unsigned long styp_flags = internal_s->s_flags;
690
3.72M
  flagword sec_flags = 0;
691
692
#ifdef STYP_BLOCK
693
  if (styp_flags & STYP_BLOCK)
694
    sec_flags |= SEC_TIC54X_BLOCK;
695
#endif
696
697
#ifdef STYP_CLINK
698
  if (styp_flags & STYP_CLINK)
699
    sec_flags |= SEC_TIC54X_CLINK;
700
#endif
701
702
3.72M
#ifdef STYP_NOLOAD
703
3.72M
  if (styp_flags & STYP_NOLOAD)
704
998k
    sec_flags |= SEC_NEVER_LOAD;
705
3.72M
#endif /* STYP_NOLOAD */
706
707
  /* For 386 COFF, at least, an unloadable text or data section is
708
     actually a shared library section.  */
709
3.72M
  if (styp_flags & STYP_TEXT)
710
1.39M
    {
711
1.39M
      if (sec_flags & SEC_NEVER_LOAD)
712
723k
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
713
671k
      else
714
671k
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
715
1.39M
    }
716
2.33M
  else if (styp_flags & STYP_DATA)
717
225k
    {
718
225k
      if (sec_flags & SEC_NEVER_LOAD)
719
105k
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
720
120k
      else
721
120k
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
722
225k
    }
723
2.11M
  else if (styp_flags & STYP_BSS)
724
140k
    {
725
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
726
      if (sec_flags & SEC_NEVER_LOAD)
727
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
728
      else
729
#endif
730
140k
  sec_flags |= SEC_ALLOC;
731
140k
    }
732
1.96M
  else if (styp_flags & STYP_INFO)
733
209k
    {
734
      /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is
735
   defined.  coff_compute_section_file_positions uses
736
   COFF_PAGE_SIZE to ensure that the low order bits of the
737
   section VMA and the file offset match.  If we don't know
738
   COFF_PAGE_SIZE, we can't ensure the correct correspondence,
739
   and demand page loading of the file will fail.  */
740
#if defined (COFF_PAGE_SIZE) && !defined (COFF_ALIGN_IN_S_FLAGS)
741
      sec_flags |= SEC_DEBUGGING;
742
#endif
743
209k
    }
744
1.75M
  else if (styp_flags & STYP_PAD)
745
67.6k
    sec_flags = 0;
746
1.69M
#ifdef RS6000COFF_C
747
1.69M
  else if (styp_flags & STYP_TDATA)
748
74.5k
    {
749
74.5k
      if (sec_flags & SEC_NEVER_LOAD)
750
6.52k
  sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY;
751
68.0k
      else
752
68.0k
  sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_LOAD | SEC_ALLOC;
753
74.5k
    }
754
1.61M
  else if (styp_flags & STYP_TBSS)
755
40.1k
    {
756
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
757
      if (sec_flags & SEC_NEVER_LOAD)
758
  sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY;
759
      else
760
#endif
761
40.1k
  sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL;
762
40.1k
    }
763
1.57M
  else if (styp_flags & STYP_EXCEPT)
764
68.8k
    sec_flags |= SEC_LOAD;
765
1.50M
  else if (styp_flags & STYP_LOADER)
766
19.4k
    sec_flags |= SEC_LOAD;
767
1.48M
  else if (styp_flags & STYP_TYPCHK)
768
11.3k
    sec_flags |= SEC_LOAD;
769
1.47M
  else if (styp_flags & STYP_DWARF)
770
14.9k
    sec_flags |= SEC_DEBUGGING;
771
1.46M
#endif
772
1.46M
  else if (strcmp (name, _TEXT) == 0)
773
2.30k
    {
774
2.30k
      if (sec_flags & SEC_NEVER_LOAD)
775
8
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
776
2.29k
      else
777
2.29k
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
778
2.30k
    }
779
1.46M
  else if (strcmp (name, _DATA) == 0)
780
4.56k
    {
781
4.56k
      if (sec_flags & SEC_NEVER_LOAD)
782
3
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
783
4.56k
      else
784
4.56k
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
785
4.56k
    }
786
1.45M
  else if (strcmp (name, _BSS) == 0)
787
924
    {
788
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
789
      if (sec_flags & SEC_NEVER_LOAD)
790
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
791
      else
792
#endif
793
924
  sec_flags |= SEC_ALLOC;
794
924
    }
795
1.45M
  else if (startswith (name, DOT_DEBUG)
796
1.45M
     || startswith (name, DOT_ZDEBUG)
797
#ifdef _COMMENT
798
     || strcmp (name, _COMMENT) == 0
799
#endif
800
#ifdef COFF_LONG_SECTION_NAMES
801
     || startswith (name, GNU_LINKONCE_WI)
802
     || startswith (name, GNU_LINKONCE_WT)
803
#endif
804
1.45M
     || startswith (name, ".stab"))
805
4.33k
    {
806
#ifdef COFF_PAGE_SIZE
807
      sec_flags |= SEC_DEBUGGING;
808
#endif
809
4.33k
    }
810
#ifdef _LIB
811
  else if (strcmp (name, _LIB) == 0)
812
    ;
813
#endif
814
#ifdef _LIT
815
  else if (strcmp (name, _LIT) == 0)
816
    sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY;
817
#endif
818
1.45M
  else
819
1.45M
    sec_flags |= SEC_ALLOC | SEC_LOAD;
820
821
3.72M
#ifdef STYP_LIT     /* A29k readonly text/data section type.  */
822
3.72M
  if ((styp_flags & STYP_LIT) == STYP_LIT)
823
389k
    sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY);
824
3.72M
#endif /* STYP_LIT */
825
826
#ifdef STYP_OTHER_LOAD    /* Other loaded sections.  */
827
  if (styp_flags & STYP_OTHER_LOAD)
828
    sec_flags = (SEC_LOAD | SEC_ALLOC);
829
#endif /* STYP_SDATA */
830
831
3.72M
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
832
3.72M
      && (startswith (name, ".sbss")
833
0
    || startswith (name, ".sdata")))
834
0
    sec_flags |= SEC_SMALL_DATA;
835
836
#if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE)
837
  /* As a GNU extension, if the name begins with .gnu.linkonce, we
838
     only link a single copy of the section.  This is used to support
839
     g++.  g++ will emit each template expansion in its own section.
840
     The symbols will be defined as weak, so that multiple definitions
841
     are permitted.  The GNU linker extension is to actually discard
842
     all but one of the sections.  */
843
  if (startswith (name, ".gnu.linkonce"))
844
    sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
845
#endif
846
847
3.72M
  if (flags_ptr == NULL)
848
0
    return false;
849
850
3.72M
  * flags_ptr = sec_flags;
851
3.72M
  return true;
852
3.72M
}
coff-sh.c:styp_to_sec_flags
Line
Count
Source
687
2.81M
{
688
2.81M
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
689
2.81M
  unsigned long styp_flags = internal_s->s_flags;
690
2.81M
  flagword sec_flags = 0;
691
692
#ifdef STYP_BLOCK
693
  if (styp_flags & STYP_BLOCK)
694
    sec_flags |= SEC_TIC54X_BLOCK;
695
#endif
696
697
#ifdef STYP_CLINK
698
  if (styp_flags & STYP_CLINK)
699
    sec_flags |= SEC_TIC54X_CLINK;
700
#endif
701
702
2.81M
#ifdef STYP_NOLOAD
703
2.81M
  if (styp_flags & STYP_NOLOAD)
704
779k
    sec_flags |= SEC_NEVER_LOAD;
705
2.81M
#endif /* STYP_NOLOAD */
706
707
  /* For 386 COFF, at least, an unloadable text or data section is
708
     actually a shared library section.  */
709
2.81M
  if (styp_flags & STYP_TEXT)
710
1.05M
    {
711
1.05M
      if (sec_flags & SEC_NEVER_LOAD)
712
516k
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
713
538k
      else
714
538k
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
715
1.05M
    }
716
1.75M
  else if (styp_flags & STYP_DATA)
717
151k
    {
718
151k
      if (sec_flags & SEC_NEVER_LOAD)
719
73.1k
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
720
78.8k
      else
721
78.8k
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
722
151k
    }
723
1.60M
  else if (styp_flags & STYP_BSS)
724
89.3k
    {
725
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
726
      if (sec_flags & SEC_NEVER_LOAD)
727
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
728
      else
729
#endif
730
89.3k
  sec_flags |= SEC_ALLOC;
731
89.3k
    }
732
1.51M
  else if (styp_flags & STYP_INFO)
733
246k
    {
734
      /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is
735
   defined.  coff_compute_section_file_positions uses
736
   COFF_PAGE_SIZE to ensure that the low order bits of the
737
   section VMA and the file offset match.  If we don't know
738
   COFF_PAGE_SIZE, we can't ensure the correct correspondence,
739
   and demand page loading of the file will fail.  */
740
#if defined (COFF_PAGE_SIZE) && !defined (COFF_ALIGN_IN_S_FLAGS)
741
      sec_flags |= SEC_DEBUGGING;
742
#endif
743
246k
    }
744
1.26M
  else if (styp_flags & STYP_PAD)
745
65.4k
    sec_flags = 0;
746
#ifdef RS6000COFF_C
747
  else if (styp_flags & STYP_TDATA)
748
    {
749
      if (sec_flags & SEC_NEVER_LOAD)
750
  sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY;
751
      else
752
  sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_LOAD | SEC_ALLOC;
753
    }
754
  else if (styp_flags & STYP_TBSS)
755
    {
756
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
757
      if (sec_flags & SEC_NEVER_LOAD)
758
  sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY;
759
      else
760
#endif
761
  sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL;
762
    }
763
  else if (styp_flags & STYP_EXCEPT)
764
    sec_flags |= SEC_LOAD;
765
  else if (styp_flags & STYP_LOADER)
766
    sec_flags |= SEC_LOAD;
767
  else if (styp_flags & STYP_TYPCHK)
768
    sec_flags |= SEC_LOAD;
769
  else if (styp_flags & STYP_DWARF)
770
    sec_flags |= SEC_DEBUGGING;
771
#endif
772
1.20M
  else if (strcmp (name, _TEXT) == 0)
773
473
    {
774
473
      if (sec_flags & SEC_NEVER_LOAD)
775
223
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
776
250
      else
777
250
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
778
473
    }
779
1.20M
  else if (strcmp (name, _DATA) == 0)
780
2.45k
    {
781
2.45k
      if (sec_flags & SEC_NEVER_LOAD)
782
821
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
783
1.63k
      else
784
1.63k
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
785
2.45k
    }
786
1.20M
  else if (strcmp (name, _BSS) == 0)
787
1.66k
    {
788
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
789
      if (sec_flags & SEC_NEVER_LOAD)
790
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
791
      else
792
#endif
793
1.66k
  sec_flags |= SEC_ALLOC;
794
1.66k
    }
795
1.19M
  else if (startswith (name, DOT_DEBUG)
796
1.19M
     || startswith (name, DOT_ZDEBUG)
797
1.19M
#ifdef _COMMENT
798
1.19M
     || strcmp (name, _COMMENT) == 0
799
1.19M
#endif
800
#ifdef COFF_LONG_SECTION_NAMES
801
     || startswith (name, GNU_LINKONCE_WI)
802
     || startswith (name, GNU_LINKONCE_WT)
803
#endif
804
1.19M
     || startswith (name, ".stab"))
805
4.29k
    {
806
#ifdef COFF_PAGE_SIZE
807
      sec_flags |= SEC_DEBUGGING;
808
#endif
809
4.29k
    }
810
1.19M
#ifdef _LIB
811
1.19M
  else if (strcmp (name, _LIB) == 0)
812
411
    ;
813
1.19M
#endif
814
#ifdef _LIT
815
  else if (strcmp (name, _LIT) == 0)
816
    sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY;
817
#endif
818
1.19M
  else
819
1.19M
    sec_flags |= SEC_ALLOC | SEC_LOAD;
820
821
2.81M
#ifdef STYP_LIT     /* A29k readonly text/data section type.  */
822
2.81M
  if ((styp_flags & STYP_LIT) == STYP_LIT)
823
298k
    sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY);
824
2.81M
#endif /* STYP_LIT */
825
826
#ifdef STYP_OTHER_LOAD    /* Other loaded sections.  */
827
  if (styp_flags & STYP_OTHER_LOAD)
828
    sec_flags = (SEC_LOAD | SEC_ALLOC);
829
#endif /* STYP_SDATA */
830
831
2.81M
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
832
2.81M
      && (startswith (name, ".sbss")
833
0
    || startswith (name, ".sdata")))
834
0
    sec_flags |= SEC_SMALL_DATA;
835
836
#if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE)
837
  /* As a GNU extension, if the name begins with .gnu.linkonce, we
838
     only link a single copy of the section.  This is used to support
839
     g++.  g++ will emit each template expansion in its own section.
840
     The symbols will be defined as weak, so that multiple definitions
841
     are permitted.  The GNU linker extension is to actually discard
842
     all but one of the sections.  */
843
  if (startswith (name, ".gnu.linkonce"))
844
    sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
845
#endif
846
847
2.81M
  if (flags_ptr == NULL)
848
0
    return false;
849
850
2.81M
  * flags_ptr = sec_flags;
851
2.81M
  return true;
852
2.81M
}
coff-stgo32.c:styp_to_sec_flags
Line
Count
Source
687
14.4k
{
688
14.4k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
689
14.4k
  unsigned long styp_flags = internal_s->s_flags;
690
14.4k
  flagword sec_flags = 0;
691
692
#ifdef STYP_BLOCK
693
  if (styp_flags & STYP_BLOCK)
694
    sec_flags |= SEC_TIC54X_BLOCK;
695
#endif
696
697
#ifdef STYP_CLINK
698
  if (styp_flags & STYP_CLINK)
699
    sec_flags |= SEC_TIC54X_CLINK;
700
#endif
701
702
14.4k
#ifdef STYP_NOLOAD
703
14.4k
  if (styp_flags & STYP_NOLOAD)
704
4.29k
    sec_flags |= SEC_NEVER_LOAD;
705
14.4k
#endif /* STYP_NOLOAD */
706
707
  /* For 386 COFF, at least, an unloadable text or data section is
708
     actually a shared library section.  */
709
14.4k
  if (styp_flags & STYP_TEXT)
710
4.44k
    {
711
4.44k
      if (sec_flags & SEC_NEVER_LOAD)
712
2.52k
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
713
1.92k
      else
714
1.92k
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
715
4.44k
    }
716
10.0k
  else if (styp_flags & STYP_DATA)
717
1.11k
    {
718
1.11k
      if (sec_flags & SEC_NEVER_LOAD)
719
619
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
720
493
      else
721
493
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
722
1.11k
    }
723
8.91k
  else if (styp_flags & STYP_BSS)
724
674
    {
725
674
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
726
674
      if (sec_flags & SEC_NEVER_LOAD)
727
242
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
728
432
      else
729
432
#endif
730
432
  sec_flags |= SEC_ALLOC;
731
674
    }
732
8.24k
  else if (styp_flags & STYP_INFO)
733
1.11k
    {
734
      /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is
735
   defined.  coff_compute_section_file_positions uses
736
   COFF_PAGE_SIZE to ensure that the low order bits of the
737
   section VMA and the file offset match.  If we don't know
738
   COFF_PAGE_SIZE, we can't ensure the correct correspondence,
739
   and demand page loading of the file will fail.  */
740
1.11k
#if defined (COFF_PAGE_SIZE) && !defined (COFF_ALIGN_IN_S_FLAGS)
741
1.11k
      sec_flags |= SEC_DEBUGGING;
742
1.11k
#endif
743
1.11k
    }
744
7.12k
  else if (styp_flags & STYP_PAD)
745
572
    sec_flags = 0;
746
#ifdef RS6000COFF_C
747
  else if (styp_flags & STYP_TDATA)
748
    {
749
      if (sec_flags & SEC_NEVER_LOAD)
750
  sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY;
751
      else
752
  sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_LOAD | SEC_ALLOC;
753
    }
754
  else if (styp_flags & STYP_TBSS)
755
    {
756
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
757
      if (sec_flags & SEC_NEVER_LOAD)
758
  sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY;
759
      else
760
#endif
761
  sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL;
762
    }
763
  else if (styp_flags & STYP_EXCEPT)
764
    sec_flags |= SEC_LOAD;
765
  else if (styp_flags & STYP_LOADER)
766
    sec_flags |= SEC_LOAD;
767
  else if (styp_flags & STYP_TYPCHK)
768
    sec_flags |= SEC_LOAD;
769
  else if (styp_flags & STYP_DWARF)
770
    sec_flags |= SEC_DEBUGGING;
771
#endif
772
6.55k
  else if (strcmp (name, _TEXT) == 0)
773
14
    {
774
14
      if (sec_flags & SEC_NEVER_LOAD)
775
4
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
776
10
      else
777
10
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
778
14
    }
779
6.54k
  else if (strcmp (name, _DATA) == 0)
780
13
    {
781
13
      if (sec_flags & SEC_NEVER_LOAD)
782
3
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
783
10
      else
784
10
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
785
13
    }
786
6.53k
  else if (strcmp (name, _BSS) == 0)
787
32
    {
788
32
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
789
32
      if (sec_flags & SEC_NEVER_LOAD)
790
11
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
791
21
      else
792
21
#endif
793
21
  sec_flags |= SEC_ALLOC;
794
32
    }
795
6.49k
  else if (startswith (name, DOT_DEBUG)
796
6.49k
     || startswith (name, DOT_ZDEBUG)
797
6.49k
#ifdef _COMMENT
798
6.49k
     || strcmp (name, _COMMENT) == 0
799
6.49k
#endif
800
6.49k
#ifdef COFF_LONG_SECTION_NAMES
801
6.49k
     || startswith (name, GNU_LINKONCE_WI)
802
6.49k
     || startswith (name, GNU_LINKONCE_WT)
803
6.49k
#endif
804
6.49k
     || startswith (name, ".stab"))
805
203
    {
806
203
#ifdef COFF_PAGE_SIZE
807
203
      sec_flags |= SEC_DEBUGGING;
808
203
#endif
809
203
    }
810
6.29k
#ifdef _LIB
811
6.29k
  else if (strcmp (name, _LIB) == 0)
812
6
    ;
813
6.28k
#endif
814
#ifdef _LIT
815
  else if (strcmp (name, _LIT) == 0)
816
    sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY;
817
#endif
818
6.28k
  else
819
6.28k
    sec_flags |= SEC_ALLOC | SEC_LOAD;
820
821
14.4k
#ifdef STYP_LIT     /* A29k readonly text/data section type.  */
822
14.4k
  if ((styp_flags & STYP_LIT) == STYP_LIT)
823
1.94k
    sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY);
824
14.4k
#endif /* STYP_LIT */
825
826
#ifdef STYP_OTHER_LOAD    /* Other loaded sections.  */
827
  if (styp_flags & STYP_OTHER_LOAD)
828
    sec_flags = (SEC_LOAD | SEC_ALLOC);
829
#endif /* STYP_SDATA */
830
831
14.4k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
832
14.4k
      && (startswith (name, ".sbss")
833
0
    || startswith (name, ".sdata")))
834
0
    sec_flags |= SEC_SMALL_DATA;
835
836
14.4k
#if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE)
837
  /* As a GNU extension, if the name begins with .gnu.linkonce, we
838
     only link a single copy of the section.  This is used to support
839
     g++.  g++ will emit each template expansion in its own section.
840
     The symbols will be defined as weak, so that multiple definitions
841
     are permitted.  The GNU linker extension is to actually discard
842
     all but one of the sections.  */
843
14.4k
  if (startswith (name, ".gnu.linkonce"))
844
21
    sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
845
14.4k
#endif
846
847
14.4k
  if (flags_ptr == NULL)
848
0
    return false;
849
850
14.4k
  * flags_ptr = sec_flags;
851
14.4k
  return true;
852
14.4k
}
coff-tic30.c:styp_to_sec_flags
Line
Count
Source
687
1.22M
{
688
1.22M
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
689
1.22M
  unsigned long styp_flags = internal_s->s_flags;
690
1.22M
  flagword sec_flags = 0;
691
692
#ifdef STYP_BLOCK
693
  if (styp_flags & STYP_BLOCK)
694
    sec_flags |= SEC_TIC54X_BLOCK;
695
#endif
696
697
#ifdef STYP_CLINK
698
  if (styp_flags & STYP_CLINK)
699
    sec_flags |= SEC_TIC54X_CLINK;
700
#endif
701
702
1.22M
#ifdef STYP_NOLOAD
703
1.22M
  if (styp_flags & STYP_NOLOAD)
704
366k
    sec_flags |= SEC_NEVER_LOAD;
705
1.22M
#endif /* STYP_NOLOAD */
706
707
  /* For 386 COFF, at least, an unloadable text or data section is
708
     actually a shared library section.  */
709
1.22M
  if (styp_flags & STYP_TEXT)
710
455k
    {
711
455k
      if (sec_flags & SEC_NEVER_LOAD)
712
241k
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
713
214k
      else
714
214k
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
715
455k
    }
716
770k
  else if (styp_flags & STYP_DATA)
717
95.6k
    {
718
95.6k
      if (sec_flags & SEC_NEVER_LOAD)
719
54.5k
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
720
41.0k
      else
721
41.0k
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
722
95.6k
    }
723
675k
  else if (styp_flags & STYP_BSS)
724
53.0k
    {
725
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
726
      if (sec_flags & SEC_NEVER_LOAD)
727
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
728
      else
729
#endif
730
53.0k
  sec_flags |= SEC_ALLOC;
731
53.0k
    }
732
622k
  else if (styp_flags & STYP_INFO)
733
70.8k
    {
734
      /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is
735
   defined.  coff_compute_section_file_positions uses
736
   COFF_PAGE_SIZE to ensure that the low order bits of the
737
   section VMA and the file offset match.  If we don't know
738
   COFF_PAGE_SIZE, we can't ensure the correct correspondence,
739
   and demand page loading of the file will fail.  */
740
#if defined (COFF_PAGE_SIZE) && !defined (COFF_ALIGN_IN_S_FLAGS)
741
      sec_flags |= SEC_DEBUGGING;
742
#endif
743
70.8k
    }
744
551k
  else if (styp_flags & STYP_PAD)
745
24.3k
    sec_flags = 0;
746
#ifdef RS6000COFF_C
747
  else if (styp_flags & STYP_TDATA)
748
    {
749
      if (sec_flags & SEC_NEVER_LOAD)
750
  sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY;
751
      else
752
  sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_LOAD | SEC_ALLOC;
753
    }
754
  else if (styp_flags & STYP_TBSS)
755
    {
756
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
757
      if (sec_flags & SEC_NEVER_LOAD)
758
  sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY;
759
      else
760
#endif
761
  sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL;
762
    }
763
  else if (styp_flags & STYP_EXCEPT)
764
    sec_flags |= SEC_LOAD;
765
  else if (styp_flags & STYP_LOADER)
766
    sec_flags |= SEC_LOAD;
767
  else if (styp_flags & STYP_TYPCHK)
768
    sec_flags |= SEC_LOAD;
769
  else if (styp_flags & STYP_DWARF)
770
    sec_flags |= SEC_DEBUGGING;
771
#endif
772
526k
  else if (strcmp (name, _TEXT) == 0)
773
2.87k
    {
774
2.87k
      if (sec_flags & SEC_NEVER_LOAD)
775
418
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
776
2.46k
      else
777
2.46k
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
778
2.87k
    }
779
524k
  else if (strcmp (name, _DATA) == 0)
780
2.67k
    {
781
2.67k
      if (sec_flags & SEC_NEVER_LOAD)
782
414
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
783
2.25k
      else
784
2.25k
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
785
2.67k
    }
786
521k
  else if (strcmp (name, _BSS) == 0)
787
796
    {
788
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
789
      if (sec_flags & SEC_NEVER_LOAD)
790
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
791
      else
792
#endif
793
796
  sec_flags |= SEC_ALLOC;
794
796
    }
795
520k
  else if (startswith (name, DOT_DEBUG)
796
520k
     || startswith (name, DOT_ZDEBUG)
797
520k
#ifdef _COMMENT
798
520k
     || strcmp (name, _COMMENT) == 0
799
520k
#endif
800
#ifdef COFF_LONG_SECTION_NAMES
801
     || startswith (name, GNU_LINKONCE_WI)
802
     || startswith (name, GNU_LINKONCE_WT)
803
#endif
804
520k
     || startswith (name, ".stab"))
805
2.83k
    {
806
#ifdef COFF_PAGE_SIZE
807
      sec_flags |= SEC_DEBUGGING;
808
#endif
809
2.83k
    }
810
517k
#ifdef _LIB
811
517k
  else if (strcmp (name, _LIB) == 0)
812
556
    ;
813
517k
#endif
814
#ifdef _LIT
815
  else if (strcmp (name, _LIT) == 0)
816
    sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY;
817
#endif
818
517k
  else
819
517k
    sec_flags |= SEC_ALLOC | SEC_LOAD;
820
821
1.22M
#ifdef STYP_LIT     /* A29k readonly text/data section type.  */
822
1.22M
  if ((styp_flags & STYP_LIT) == STYP_LIT)
823
140k
    sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY);
824
1.22M
#endif /* STYP_LIT */
825
826
#ifdef STYP_OTHER_LOAD    /* Other loaded sections.  */
827
  if (styp_flags & STYP_OTHER_LOAD)
828
    sec_flags = (SEC_LOAD | SEC_ALLOC);
829
#endif /* STYP_SDATA */
830
831
1.22M
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
832
1.22M
      && (startswith (name, ".sbss")
833
0
    || startswith (name, ".sdata")))
834
0
    sec_flags |= SEC_SMALL_DATA;
835
836
#if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE)
837
  /* As a GNU extension, if the name begins with .gnu.linkonce, we
838
     only link a single copy of the section.  This is used to support
839
     g++.  g++ will emit each template expansion in its own section.
840
     The symbols will be defined as weak, so that multiple definitions
841
     are permitted.  The GNU linker extension is to actually discard
842
     all but one of the sections.  */
843
  if (startswith (name, ".gnu.linkonce"))
844
    sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
845
#endif
846
847
1.22M
  if (flags_ptr == NULL)
848
0
    return false;
849
850
1.22M
  * flags_ptr = sec_flags;
851
1.22M
  return true;
852
1.22M
}
Unexecuted instantiation: coff-tic4x.c:styp_to_sec_flags
coff-tic54x.c:styp_to_sec_flags
Line
Count
Source
687
2.71M
{
688
2.71M
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
689
2.71M
  unsigned long styp_flags = internal_s->s_flags;
690
2.71M
  flagword sec_flags = 0;
691
692
2.71M
#ifdef STYP_BLOCK
693
2.71M
  if (styp_flags & STYP_BLOCK)
694
816k
    sec_flags |= SEC_TIC54X_BLOCK;
695
2.71M
#endif
696
697
2.71M
#ifdef STYP_CLINK
698
2.71M
  if (styp_flags & STYP_CLINK)
699
768k
    sec_flags |= SEC_TIC54X_CLINK;
700
2.71M
#endif
701
702
2.71M
#ifdef STYP_NOLOAD
703
2.71M
  if (styp_flags & STYP_NOLOAD)
704
770k
    sec_flags |= SEC_NEVER_LOAD;
705
2.71M
#endif /* STYP_NOLOAD */
706
707
  /* For 386 COFF, at least, an unloadable text or data section is
708
     actually a shared library section.  */
709
2.71M
  if (styp_flags & STYP_TEXT)
710
1.12M
    {
711
1.12M
      if (sec_flags & SEC_NEVER_LOAD)
712
560k
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
713
560k
      else
714
560k
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
715
1.12M
    }
716
1.59M
  else if (styp_flags & STYP_DATA)
717
151k
    {
718
151k
      if (sec_flags & SEC_NEVER_LOAD)
719
80.8k
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
720
70.4k
      else
721
70.4k
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
722
151k
    }
723
1.44M
  else if (styp_flags & STYP_BSS)
724
72.9k
    {
725
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
726
      if (sec_flags & SEC_NEVER_LOAD)
727
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
728
      else
729
#endif
730
72.9k
  sec_flags |= SEC_ALLOC;
731
72.9k
    }
732
1.37M
  else if (styp_flags & STYP_INFO)
733
170k
    {
734
      /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is
735
   defined.  coff_compute_section_file_positions uses
736
   COFF_PAGE_SIZE to ensure that the low order bits of the
737
   section VMA and the file offset match.  If we don't know
738
   COFF_PAGE_SIZE, we can't ensure the correct correspondence,
739
   and demand page loading of the file will fail.  */
740
#if defined (COFF_PAGE_SIZE) && !defined (COFF_ALIGN_IN_S_FLAGS)
741
      sec_flags |= SEC_DEBUGGING;
742
#endif
743
170k
    }
744
1.20M
  else if (styp_flags & STYP_PAD)
745
61.4k
    sec_flags = 0;
746
#ifdef RS6000COFF_C
747
  else if (styp_flags & STYP_TDATA)
748
    {
749
      if (sec_flags & SEC_NEVER_LOAD)
750
  sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY;
751
      else
752
  sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_LOAD | SEC_ALLOC;
753
    }
754
  else if (styp_flags & STYP_TBSS)
755
    {
756
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
757
      if (sec_flags & SEC_NEVER_LOAD)
758
  sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY;
759
      else
760
#endif
761
  sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL;
762
    }
763
  else if (styp_flags & STYP_EXCEPT)
764
    sec_flags |= SEC_LOAD;
765
  else if (styp_flags & STYP_LOADER)
766
    sec_flags |= SEC_LOAD;
767
  else if (styp_flags & STYP_TYPCHK)
768
    sec_flags |= SEC_LOAD;
769
  else if (styp_flags & STYP_DWARF)
770
    sec_flags |= SEC_DEBUGGING;
771
#endif
772
1.14M
  else if (strcmp (name, _TEXT) == 0)
773
2.30k
    {
774
2.30k
      if (sec_flags & SEC_NEVER_LOAD)
775
511
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
776
1.79k
      else
777
1.79k
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
778
2.30k
    }
779
1.13M
  else if (strcmp (name, _DATA) == 0)
780
8.01k
    {
781
8.01k
      if (sec_flags & SEC_NEVER_LOAD)
782
877
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
783
7.13k
      else
784
7.13k
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
785
8.01k
    }
786
1.13M
  else if (strcmp (name, _BSS) == 0)
787
3.23k
    {
788
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
789
      if (sec_flags & SEC_NEVER_LOAD)
790
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
791
      else
792
#endif
793
3.23k
  sec_flags |= SEC_ALLOC;
794
3.23k
    }
795
1.12M
  else if (startswith (name, DOT_DEBUG)
796
1.12M
     || startswith (name, DOT_ZDEBUG)
797
#ifdef _COMMENT
798
     || strcmp (name, _COMMENT) == 0
799
#endif
800
#ifdef COFF_LONG_SECTION_NAMES
801
     || startswith (name, GNU_LINKONCE_WI)
802
     || startswith (name, GNU_LINKONCE_WT)
803
#endif
804
1.12M
     || startswith (name, ".stab"))
805
6.13k
    {
806
#ifdef COFF_PAGE_SIZE
807
      sec_flags |= SEC_DEBUGGING;
808
#endif
809
6.13k
    }
810
#ifdef _LIB
811
  else if (strcmp (name, _LIB) == 0)
812
    ;
813
#endif
814
#ifdef _LIT
815
  else if (strcmp (name, _LIT) == 0)
816
    sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY;
817
#endif
818
1.12M
  else
819
1.12M
    sec_flags |= SEC_ALLOC | SEC_LOAD;
820
821
2.71M
#ifdef STYP_LIT     /* A29k readonly text/data section type.  */
822
2.71M
  if ((styp_flags & STYP_LIT) == STYP_LIT)
823
257k
    sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY);
824
2.71M
#endif /* STYP_LIT */
825
826
#ifdef STYP_OTHER_LOAD    /* Other loaded sections.  */
827
  if (styp_flags & STYP_OTHER_LOAD)
828
    sec_flags = (SEC_LOAD | SEC_ALLOC);
829
#endif /* STYP_SDATA */
830
831
2.71M
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
832
2.71M
      && (startswith (name, ".sbss")
833
0
    || startswith (name, ".sdata")))
834
0
    sec_flags |= SEC_SMALL_DATA;
835
836
#if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE)
837
  /* As a GNU extension, if the name begins with .gnu.linkonce, we
838
     only link a single copy of the section.  This is used to support
839
     g++.  g++ will emit each template expansion in its own section.
840
     The symbols will be defined as weak, so that multiple definitions
841
     are permitted.  The GNU linker extension is to actually discard
842
     all but one of the sections.  */
843
  if (startswith (name, ".gnu.linkonce"))
844
    sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
845
#endif
846
847
2.71M
  if (flags_ptr == NULL)
848
0
    return false;
849
850
2.71M
  * flags_ptr = sec_flags;
851
2.71M
  return true;
852
2.71M
}
coff-z80.c:styp_to_sec_flags
Line
Count
Source
687
142k
{
688
142k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
689
142k
  unsigned long styp_flags = internal_s->s_flags;
690
142k
  flagword sec_flags = 0;
691
692
#ifdef STYP_BLOCK
693
  if (styp_flags & STYP_BLOCK)
694
    sec_flags |= SEC_TIC54X_BLOCK;
695
#endif
696
697
#ifdef STYP_CLINK
698
  if (styp_flags & STYP_CLINK)
699
    sec_flags |= SEC_TIC54X_CLINK;
700
#endif
701
702
142k
#ifdef STYP_NOLOAD
703
142k
  if (styp_flags & STYP_NOLOAD)
704
37.4k
    sec_flags |= SEC_NEVER_LOAD;
705
142k
#endif /* STYP_NOLOAD */
706
707
  /* For 386 COFF, at least, an unloadable text or data section is
708
     actually a shared library section.  */
709
142k
  if (styp_flags & STYP_TEXT)
710
39.8k
    {
711
39.8k
      if (sec_flags & SEC_NEVER_LOAD)
712
19.7k
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
713
20.1k
      else
714
20.1k
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
715
39.8k
    }
716
102k
  else if (styp_flags & STYP_DATA)
717
11.2k
    {
718
11.2k
      if (sec_flags & SEC_NEVER_LOAD)
719
5.78k
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
720
5.44k
      else
721
5.44k
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
722
11.2k
    }
723
91.5k
  else if (styp_flags & STYP_BSS)
724
3.54k
    {
725
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
726
      if (sec_flags & SEC_NEVER_LOAD)
727
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
728
      else
729
#endif
730
3.54k
  sec_flags |= SEC_ALLOC;
731
3.54k
    }
732
87.9k
  else if (styp_flags & STYP_INFO)
733
14.9k
    {
734
      /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is
735
   defined.  coff_compute_section_file_positions uses
736
   COFF_PAGE_SIZE to ensure that the low order bits of the
737
   section VMA and the file offset match.  If we don't know
738
   COFF_PAGE_SIZE, we can't ensure the correct correspondence,
739
   and demand page loading of the file will fail.  */
740
#if defined (COFF_PAGE_SIZE) && !defined (COFF_ALIGN_IN_S_FLAGS)
741
      sec_flags |= SEC_DEBUGGING;
742
#endif
743
14.9k
    }
744
72.9k
  else if (styp_flags & STYP_PAD)
745
8.36k
    sec_flags = 0;
746
#ifdef RS6000COFF_C
747
  else if (styp_flags & STYP_TDATA)
748
    {
749
      if (sec_flags & SEC_NEVER_LOAD)
750
  sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY;
751
      else
752
  sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_LOAD | SEC_ALLOC;
753
    }
754
  else if (styp_flags & STYP_TBSS)
755
    {
756
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
757
      if (sec_flags & SEC_NEVER_LOAD)
758
  sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY;
759
      else
760
#endif
761
  sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL;
762
    }
763
  else if (styp_flags & STYP_EXCEPT)
764
    sec_flags |= SEC_LOAD;
765
  else if (styp_flags & STYP_LOADER)
766
    sec_flags |= SEC_LOAD;
767
  else if (styp_flags & STYP_TYPCHK)
768
    sec_flags |= SEC_LOAD;
769
  else if (styp_flags & STYP_DWARF)
770
    sec_flags |= SEC_DEBUGGING;
771
#endif
772
64.6k
  else if (strcmp (name, _TEXT) == 0)
773
658
    {
774
658
      if (sec_flags & SEC_NEVER_LOAD)
775
3
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
776
655
      else
777
655
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
778
658
    }
779
63.9k
  else if (strcmp (name, _DATA) == 0)
780
451
    {
781
451
      if (sec_flags & SEC_NEVER_LOAD)
782
1
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
783
450
      else
784
450
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
785
451
    }
786
63.5k
  else if (strcmp (name, _BSS) == 0)
787
115
    {
788
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
789
      if (sec_flags & SEC_NEVER_LOAD)
790
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
791
      else
792
#endif
793
115
  sec_flags |= SEC_ALLOC;
794
115
    }
795
63.4k
  else if (startswith (name, DOT_DEBUG)
796
63.4k
     || startswith (name, DOT_ZDEBUG)
797
63.4k
#ifdef _COMMENT
798
63.4k
     || strcmp (name, _COMMENT) == 0
799
63.4k
#endif
800
#ifdef COFF_LONG_SECTION_NAMES
801
     || startswith (name, GNU_LINKONCE_WI)
802
     || startswith (name, GNU_LINKONCE_WT)
803
#endif
804
63.4k
     || startswith (name, ".stab"))
805
315
    {
806
#ifdef COFF_PAGE_SIZE
807
      sec_flags |= SEC_DEBUGGING;
808
#endif
809
315
    }
810
63.0k
#ifdef _LIB
811
63.0k
  else if (strcmp (name, _LIB) == 0)
812
137
    ;
813
62.9k
#endif
814
#ifdef _LIT
815
  else if (strcmp (name, _LIT) == 0)
816
    sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY;
817
#endif
818
62.9k
  else
819
62.9k
    sec_flags |= SEC_ALLOC | SEC_LOAD;
820
821
142k
#ifdef STYP_LIT     /* A29k readonly text/data section type.  */
822
142k
  if ((styp_flags & STYP_LIT) == STYP_LIT)
823
8.18k
    sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY);
824
142k
#endif /* STYP_LIT */
825
826
#ifdef STYP_OTHER_LOAD    /* Other loaded sections.  */
827
  if (styp_flags & STYP_OTHER_LOAD)
828
    sec_flags = (SEC_LOAD | SEC_ALLOC);
829
#endif /* STYP_SDATA */
830
831
142k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
832
142k
      && (startswith (name, ".sbss")
833
0
    || startswith (name, ".sdata")))
834
0
    sec_flags |= SEC_SMALL_DATA;
835
836
#if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE)
837
  /* As a GNU extension, if the name begins with .gnu.linkonce, we
838
     only link a single copy of the section.  This is used to support
839
     g++.  g++ will emit each template expansion in its own section.
840
     The symbols will be defined as weak, so that multiple definitions
841
     are permitted.  The GNU linker extension is to actually discard
842
     all but one of the sections.  */
843
  if (startswith (name, ".gnu.linkonce"))
844
    sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
845
#endif
846
847
142k
  if (flags_ptr == NULL)
848
0
    return false;
849
850
142k
  * flags_ptr = sec_flags;
851
142k
  return true;
852
142k
}
coff-z8k.c:styp_to_sec_flags
Line
Count
Source
687
365k
{
688
365k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
689
365k
  unsigned long styp_flags = internal_s->s_flags;
690
365k
  flagword sec_flags = 0;
691
692
#ifdef STYP_BLOCK
693
  if (styp_flags & STYP_BLOCK)
694
    sec_flags |= SEC_TIC54X_BLOCK;
695
#endif
696
697
#ifdef STYP_CLINK
698
  if (styp_flags & STYP_CLINK)
699
    sec_flags |= SEC_TIC54X_CLINK;
700
#endif
701
702
365k
#ifdef STYP_NOLOAD
703
365k
  if (styp_flags & STYP_NOLOAD)
704
102k
    sec_flags |= SEC_NEVER_LOAD;
705
365k
#endif /* STYP_NOLOAD */
706
707
  /* For 386 COFF, at least, an unloadable text or data section is
708
     actually a shared library section.  */
709
365k
  if (styp_flags & STYP_TEXT)
710
119k
    {
711
119k
      if (sec_flags & SEC_NEVER_LOAD)
712
63.6k
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
713
56.1k
      else
714
56.1k
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
715
119k
    }
716
246k
  else if (styp_flags & STYP_DATA)
717
21.0k
    {
718
21.0k
      if (sec_flags & SEC_NEVER_LOAD)
719
13.5k
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
720
7.45k
      else
721
7.45k
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
722
21.0k
    }
723
224k
  else if (styp_flags & STYP_BSS)
724
12.8k
    {
725
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
726
      if (sec_flags & SEC_NEVER_LOAD)
727
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
728
      else
729
#endif
730
12.8k
  sec_flags |= SEC_ALLOC;
731
12.8k
    }
732
212k
  else if (styp_flags & STYP_INFO)
733
31.5k
    {
734
      /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is
735
   defined.  coff_compute_section_file_positions uses
736
   COFF_PAGE_SIZE to ensure that the low order bits of the
737
   section VMA and the file offset match.  If we don't know
738
   COFF_PAGE_SIZE, we can't ensure the correct correspondence,
739
   and demand page loading of the file will fail.  */
740
#if defined (COFF_PAGE_SIZE) && !defined (COFF_ALIGN_IN_S_FLAGS)
741
      sec_flags |= SEC_DEBUGGING;
742
#endif
743
31.5k
    }
744
180k
  else if (styp_flags & STYP_PAD)
745
9.39k
    sec_flags = 0;
746
#ifdef RS6000COFF_C
747
  else if (styp_flags & STYP_TDATA)
748
    {
749
      if (sec_flags & SEC_NEVER_LOAD)
750
  sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY;
751
      else
752
  sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_LOAD | SEC_ALLOC;
753
    }
754
  else if (styp_flags & STYP_TBSS)
755
    {
756
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
757
      if (sec_flags & SEC_NEVER_LOAD)
758
  sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY;
759
      else
760
#endif
761
  sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL;
762
    }
763
  else if (styp_flags & STYP_EXCEPT)
764
    sec_flags |= SEC_LOAD;
765
  else if (styp_flags & STYP_LOADER)
766
    sec_flags |= SEC_LOAD;
767
  else if (styp_flags & STYP_TYPCHK)
768
    sec_flags |= SEC_LOAD;
769
  else if (styp_flags & STYP_DWARF)
770
    sec_flags |= SEC_DEBUGGING;
771
#endif
772
171k
  else if (strcmp (name, _TEXT) == 0)
773
1.21k
    {
774
1.21k
      if (sec_flags & SEC_NEVER_LOAD)
775
955
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
776
256
      else
777
256
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
778
1.21k
    }
779
170k
  else if (strcmp (name, _DATA) == 0)
780
251
    {
781
251
      if (sec_flags & SEC_NEVER_LOAD)
782
0
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
783
251
      else
784
251
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
785
251
    }
786
169k
  else if (strcmp (name, _BSS) == 0)
787
261
    {
788
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
789
      if (sec_flags & SEC_NEVER_LOAD)
790
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
791
      else
792
#endif
793
261
  sec_flags |= SEC_ALLOC;
794
261
    }
795
169k
  else if (startswith (name, DOT_DEBUG)
796
169k
     || startswith (name, DOT_ZDEBUG)
797
169k
#ifdef _COMMENT
798
169k
     || strcmp (name, _COMMENT) == 0
799
169k
#endif
800
#ifdef COFF_LONG_SECTION_NAMES
801
     || startswith (name, GNU_LINKONCE_WI)
802
     || startswith (name, GNU_LINKONCE_WT)
803
#endif
804
169k
     || startswith (name, ".stab"))
805
1.79k
    {
806
#ifdef COFF_PAGE_SIZE
807
      sec_flags |= SEC_DEBUGGING;
808
#endif
809
1.79k
    }
810
167k
#ifdef _LIB
811
167k
  else if (strcmp (name, _LIB) == 0)
812
144
    ;
813
167k
#endif
814
#ifdef _LIT
815
  else if (strcmp (name, _LIT) == 0)
816
    sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY;
817
#endif
818
167k
  else
819
167k
    sec_flags |= SEC_ALLOC | SEC_LOAD;
820
821
365k
#ifdef STYP_LIT     /* A29k readonly text/data section type.  */
822
365k
  if ((styp_flags & STYP_LIT) == STYP_LIT)
823
30.9k
    sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY);
824
365k
#endif /* STYP_LIT */
825
826
#ifdef STYP_OTHER_LOAD    /* Other loaded sections.  */
827
  if (styp_flags & STYP_OTHER_LOAD)
828
    sec_flags = (SEC_LOAD | SEC_ALLOC);
829
#endif /* STYP_SDATA */
830
831
365k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
832
365k
      && (startswith (name, ".sbss")
833
0
    || startswith (name, ".sdata")))
834
0
    sec_flags |= SEC_SMALL_DATA;
835
836
#if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE)
837
  /* As a GNU extension, if the name begins with .gnu.linkonce, we
838
     only link a single copy of the section.  This is used to support
839
     g++.  g++ will emit each template expansion in its own section.
840
     The symbols will be defined as weak, so that multiple definitions
841
     are permitted.  The GNU linker extension is to actually discard
842
     all but one of the sections.  */
843
  if (startswith (name, ".gnu.linkonce"))
844
    sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
845
#endif
846
847
365k
  if (flags_ptr == NULL)
848
0
    return false;
849
850
365k
  * flags_ptr = sec_flags;
851
365k
  return true;
852
365k
}
853
854
#else /* COFF_WITH_PE */
855
856
static hashval_t
857
comdat_hashf (const void *entry)
858
895k
{
859
895k
  const struct comdat_hash_entry *fe = entry;
860
895k
  return fe->target_index;
861
895k
}
pei-i386.c:comdat_hashf
Line
Count
Source
858
346k
{
859
346k
  const struct comdat_hash_entry *fe = entry;
860
346k
  return fe->target_index;
861
346k
}
pe-x86_64.c:comdat_hashf
Line
Count
Source
858
100k
{
859
100k
  const struct comdat_hash_entry *fe = entry;
860
100k
  return fe->target_index;
861
100k
}
pei-x86_64.c:comdat_hashf
Line
Count
Source
858
14.9k
{
859
14.9k
  const struct comdat_hash_entry *fe = entry;
860
14.9k
  return fe->target_index;
861
14.9k
}
pe-aarch64.c:comdat_hashf
Line
Count
Source
858
32.9k
{
859
32.9k
  const struct comdat_hash_entry *fe = entry;
860
32.9k
  return fe->target_index;
861
32.9k
}
pei-aarch64.c:comdat_hashf
Line
Count
Source
858
85.8k
{
859
85.8k
  const struct comdat_hash_entry *fe = entry;
860
85.8k
  return fe->target_index;
861
85.8k
}
pei-ia64.c:comdat_hashf
Line
Count
Source
858
18.5k
{
859
18.5k
  const struct comdat_hash_entry *fe = entry;
860
18.5k
  return fe->target_index;
861
18.5k
}
pei-loongarch64.c:comdat_hashf
Line
Count
Source
858
11.0k
{
859
11.0k
  const struct comdat_hash_entry *fe = entry;
860
11.0k
  return fe->target_index;
861
11.0k
}
pe-arm-wince.c:comdat_hashf
Line
Count
Source
858
7.74k
{
859
7.74k
  const struct comdat_hash_entry *fe = entry;
860
7.74k
  return fe->target_index;
861
7.74k
}
pe-arm.c:comdat_hashf
Line
Count
Source
858
7.74k
{
859
7.74k
  const struct comdat_hash_entry *fe = entry;
860
7.74k
  return fe->target_index;
861
7.74k
}
pe-i386.c:comdat_hashf
Line
Count
Source
858
13.7k
{
859
13.7k
  const struct comdat_hash_entry *fe = entry;
860
13.7k
  return fe->target_index;
861
13.7k
}
pe-mcore.c:comdat_hashf
Line
Count
Source
858
18.9k
{
859
18.9k
  const struct comdat_hash_entry *fe = entry;
860
18.9k
  return fe->target_index;
861
18.9k
}
pe-sh.c:comdat_hashf
Line
Count
Source
858
152k
{
859
152k
  const struct comdat_hash_entry *fe = entry;
860
152k
  return fe->target_index;
861
152k
}
pei-arm-wince.c:comdat_hashf
Line
Count
Source
858
16.2k
{
859
16.2k
  const struct comdat_hash_entry *fe = entry;
860
16.2k
  return fe->target_index;
861
16.2k
}
pei-arm.c:comdat_hashf
Line
Count
Source
858
36.3k
{
859
36.3k
  const struct comdat_hash_entry *fe = entry;
860
36.3k
  return fe->target_index;
861
36.3k
}
pei-mcore.c:comdat_hashf
Line
Count
Source
858
19.0k
{
859
19.0k
  const struct comdat_hash_entry *fe = entry;
860
19.0k
  return fe->target_index;
861
19.0k
}
pei-sh.c:comdat_hashf
Line
Count
Source
858
12.0k
{
859
12.0k
  const struct comdat_hash_entry *fe = entry;
860
12.0k
  return fe->target_index;
861
12.0k
}
862
863
static int
864
comdat_eqf (const void *e1, const void *e2)
865
710k
{
866
710k
  const struct comdat_hash_entry *fe1 = e1;
867
710k
  const struct comdat_hash_entry *fe2 = e2;
868
710k
  return fe1->target_index == fe2->target_index;
869
710k
}
pei-i386.c:comdat_eqf
Line
Count
Source
865
285k
{
866
285k
  const struct comdat_hash_entry *fe1 = e1;
867
285k
  const struct comdat_hash_entry *fe2 = e2;
868
285k
  return fe1->target_index == fe2->target_index;
869
285k
}
pe-x86_64.c:comdat_eqf
Line
Count
Source
865
74.8k
{
866
74.8k
  const struct comdat_hash_entry *fe1 = e1;
867
74.8k
  const struct comdat_hash_entry *fe2 = e2;
868
74.8k
  return fe1->target_index == fe2->target_index;
869
74.8k
}
pei-x86_64.c:comdat_eqf
Line
Count
Source
865
6.17k
{
866
6.17k
  const struct comdat_hash_entry *fe1 = e1;
867
6.17k
  const struct comdat_hash_entry *fe2 = e2;
868
6.17k
  return fe1->target_index == fe2->target_index;
869
6.17k
}
pe-aarch64.c:comdat_eqf
Line
Count
Source
865
24.0k
{
866
24.0k
  const struct comdat_hash_entry *fe1 = e1;
867
24.0k
  const struct comdat_hash_entry *fe2 = e2;
868
24.0k
  return fe1->target_index == fe2->target_index;
869
24.0k
}
pei-aarch64.c:comdat_eqf
Line
Count
Source
865
88.6k
{
866
88.6k
  const struct comdat_hash_entry *fe1 = e1;
867
88.6k
  const struct comdat_hash_entry *fe2 = e2;
868
88.6k
  return fe1->target_index == fe2->target_index;
869
88.6k
}
pei-ia64.c:comdat_eqf
Line
Count
Source
865
17.0k
{
866
17.0k
  const struct comdat_hash_entry *fe1 = e1;
867
17.0k
  const struct comdat_hash_entry *fe2 = e2;
868
17.0k
  return fe1->target_index == fe2->target_index;
869
17.0k
}
pei-loongarch64.c:comdat_eqf
Line
Count
Source
865
4.89k
{
866
4.89k
  const struct comdat_hash_entry *fe1 = e1;
867
4.89k
  const struct comdat_hash_entry *fe2 = e2;
868
4.89k
  return fe1->target_index == fe2->target_index;
869
4.89k
}
pe-arm-wince.c:comdat_eqf
Line
Count
Source
865
3.58k
{
866
3.58k
  const struct comdat_hash_entry *fe1 = e1;
867
3.58k
  const struct comdat_hash_entry *fe2 = e2;
868
3.58k
  return fe1->target_index == fe2->target_index;
869
3.58k
}
pe-arm.c:comdat_eqf
Line
Count
Source
865
3.58k
{
866
3.58k
  const struct comdat_hash_entry *fe1 = e1;
867
3.58k
  const struct comdat_hash_entry *fe2 = e2;
868
3.58k
  return fe1->target_index == fe2->target_index;
869
3.58k
}
pe-i386.c:comdat_eqf
Line
Count
Source
865
4.33k
{
866
4.33k
  const struct comdat_hash_entry *fe1 = e1;
867
4.33k
  const struct comdat_hash_entry *fe2 = e2;
868
4.33k
  return fe1->target_index == fe2->target_index;
869
4.33k
}
pe-mcore.c:comdat_eqf
Line
Count
Source
865
14.1k
{
866
14.1k
  const struct comdat_hash_entry *fe1 = e1;
867
14.1k
  const struct comdat_hash_entry *fe2 = e2;
868
14.1k
  return fe1->target_index == fe2->target_index;
869
14.1k
}
pe-sh.c:comdat_eqf
Line
Count
Source
865
136k
{
866
136k
  const struct comdat_hash_entry *fe1 = e1;
867
136k
  const struct comdat_hash_entry *fe2 = e2;
868
136k
  return fe1->target_index == fe2->target_index;
869
136k
}
pei-arm-wince.c:comdat_eqf
Line
Count
Source
865
7.52k
{
866
7.52k
  const struct comdat_hash_entry *fe1 = e1;
867
7.52k
  const struct comdat_hash_entry *fe2 = e2;
868
7.52k
  return fe1->target_index == fe2->target_index;
869
7.52k
}
pei-arm.c:comdat_eqf
Line
Count
Source
865
24.4k
{
866
24.4k
  const struct comdat_hash_entry *fe1 = e1;
867
24.4k
  const struct comdat_hash_entry *fe2 = e2;
868
24.4k
  return fe1->target_index == fe2->target_index;
869
24.4k
}
pei-mcore.c:comdat_eqf
Line
Count
Source
865
9.38k
{
866
9.38k
  const struct comdat_hash_entry *fe1 = e1;
867
9.38k
  const struct comdat_hash_entry *fe2 = e2;
868
9.38k
  return fe1->target_index == fe2->target_index;
869
9.38k
}
pei-sh.c:comdat_eqf
Line
Count
Source
865
6.06k
{
866
6.06k
  const struct comdat_hash_entry *fe1 = e1;
867
6.06k
  const struct comdat_hash_entry *fe2 = e2;
868
6.06k
  return fe1->target_index == fe2->target_index;
869
6.06k
}
870
871
static void
872
comdat_delf (void *ent)
873
201k
{
874
201k
  struct comdat_hash_entry *e = ent;
875
201k
  free (e->symname);
876
201k
  free (e);
877
201k
}
pei-i386.c:comdat_delf
Line
Count
Source
873
83.4k
{
874
83.4k
  struct comdat_hash_entry *e = ent;
875
83.4k
  free (e->symname);
876
83.4k
  free (e);
877
83.4k
}
pe-x86_64.c:comdat_delf
Line
Count
Source
873
19.4k
{
874
19.4k
  struct comdat_hash_entry *e = ent;
875
19.4k
  free (e->symname);
876
19.4k
  free (e);
877
19.4k
}
pei-x86_64.c:comdat_delf
Line
Count
Source
873
5.13k
{
874
5.13k
  struct comdat_hash_entry *e = ent;
875
5.13k
  free (e->symname);
876
5.13k
  free (e);
877
5.13k
}
pe-aarch64.c:comdat_delf
Line
Count
Source
873
3.99k
{
874
3.99k
  struct comdat_hash_entry *e = ent;
875
3.99k
  free (e->symname);
876
3.99k
  free (e);
877
3.99k
}
pei-aarch64.c:comdat_delf
Line
Count
Source
873
15.8k
{
874
15.8k
  struct comdat_hash_entry *e = ent;
875
15.8k
  free (e->symname);
876
15.8k
  free (e);
877
15.8k
}
pei-ia64.c:comdat_delf
Line
Count
Source
873
8.27k
{
874
8.27k
  struct comdat_hash_entry *e = ent;
875
8.27k
  free (e->symname);
876
8.27k
  free (e);
877
8.27k
}
pei-loongarch64.c:comdat_delf
Line
Count
Source
873
4.51k
{
874
4.51k
  struct comdat_hash_entry *e = ent;
875
4.51k
  free (e->symname);
876
4.51k
  free (e);
877
4.51k
}
pe-arm-wince.c:comdat_delf
Line
Count
Source
873
2.11k
{
874
2.11k
  struct comdat_hash_entry *e = ent;
875
2.11k
  free (e->symname);
876
2.11k
  free (e);
877
2.11k
}
pe-arm.c:comdat_delf
Line
Count
Source
873
2.11k
{
874
2.11k
  struct comdat_hash_entry *e = ent;
875
2.11k
  free (e->symname);
876
2.11k
  free (e);
877
2.11k
}
pe-i386.c:comdat_delf
Line
Count
Source
873
3.75k
{
874
3.75k
  struct comdat_hash_entry *e = ent;
875
3.75k
  free (e->symname);
876
3.75k
  free (e);
877
3.75k
}
pe-mcore.c:comdat_delf
Line
Count
Source
873
3.18k
{
874
3.18k
  struct comdat_hash_entry *e = ent;
875
3.18k
  free (e->symname);
876
3.18k
  free (e);
877
3.18k
}
pe-sh.c:comdat_delf
Line
Count
Source
873
25.8k
{
874
25.8k
  struct comdat_hash_entry *e = ent;
875
25.8k
  free (e->symname);
876
25.8k
  free (e);
877
25.8k
}
pei-arm-wince.c:comdat_delf
Line
Count
Source
873
4.68k
{
874
4.68k
  struct comdat_hash_entry *e = ent;
875
4.68k
  free (e->symname);
876
4.68k
  free (e);
877
4.68k
}
pei-arm.c:comdat_delf
Line
Count
Source
873
8.24k
{
874
8.24k
  struct comdat_hash_entry *e = ent;
875
8.24k
  free (e->symname);
876
8.24k
  free (e);
877
8.24k
}
pei-mcore.c:comdat_delf
Line
Count
Source
873
6.14k
{
874
6.14k
  struct comdat_hash_entry *e = ent;
875
6.14k
  free (e->symname);
876
6.14k
  free (e);
877
6.14k
}
pei-sh.c:comdat_delf
Line
Count
Source
873
5.09k
{
874
5.09k
  struct comdat_hash_entry *e = ent;
875
5.09k
  free (e->symname);
876
5.09k
  free (e);
877
5.09k
}
878
879
static struct comdat_hash_entry *
880
find_flags (htab_t comdat_hash, int target_index)
881
89.0k
{
882
89.0k
  struct comdat_hash_entry needle;
883
89.0k
  needle.target_index = target_index;
884
885
89.0k
  return htab_find (comdat_hash, &needle);
886
89.0k
}
pei-i386.c:find_flags
Line
Count
Source
881
17.1k
{
882
17.1k
  struct comdat_hash_entry needle;
883
17.1k
  needle.target_index = target_index;
884
885
17.1k
  return htab_find (comdat_hash, &needle);
886
17.1k
}
pe-x86_64.c:find_flags
Line
Count
Source
881
10.9k
{
882
10.9k
  struct comdat_hash_entry needle;
883
10.9k
  needle.target_index = target_index;
884
885
10.9k
  return htab_find (comdat_hash, &needle);
886
10.9k
}
pei-x86_64.c:find_flags
Line
Count
Source
881
5.02k
{
882
5.02k
  struct comdat_hash_entry needle;
883
5.02k
  needle.target_index = target_index;
884
885
5.02k
  return htab_find (comdat_hash, &needle);
886
5.02k
}
pe-aarch64.c:find_flags
Line
Count
Source
881
4.85k
{
882
4.85k
  struct comdat_hash_entry needle;
883
4.85k
  needle.target_index = target_index;
884
885
4.85k
  return htab_find (comdat_hash, &needle);
886
4.85k
}
pei-aarch64.c:find_flags
Line
Count
Source
881
2.59k
{
882
2.59k
  struct comdat_hash_entry needle;
883
2.59k
  needle.target_index = target_index;
884
885
2.59k
  return htab_find (comdat_hash, &needle);
886
2.59k
}
pei-ia64.c:find_flags
Line
Count
Source
881
3.39k
{
882
3.39k
  struct comdat_hash_entry needle;
883
3.39k
  needle.target_index = target_index;
884
885
3.39k
  return htab_find (comdat_hash, &needle);
886
3.39k
}
pei-loongarch64.c:find_flags
Line
Count
Source
881
3.38k
{
882
3.38k
  struct comdat_hash_entry needle;
883
3.38k
  needle.target_index = target_index;
884
885
3.38k
  return htab_find (comdat_hash, &needle);
886
3.38k
}
pe-arm-wince.c:find_flags
Line
Count
Source
881
1.71k
{
882
1.71k
  struct comdat_hash_entry needle;
883
1.71k
  needle.target_index = target_index;
884
885
1.71k
  return htab_find (comdat_hash, &needle);
886
1.71k
}
pe-arm.c:find_flags
Line
Count
Source
881
1.71k
{
882
1.71k
  struct comdat_hash_entry needle;
883
1.71k
  needle.target_index = target_index;
884
885
1.71k
  return htab_find (comdat_hash, &needle);
886
1.71k
}
pe-i386.c:find_flags
Line
Count
Source
881
6.64k
{
882
6.64k
  struct comdat_hash_entry needle;
883
6.64k
  needle.target_index = target_index;
884
885
6.64k
  return htab_find (comdat_hash, &needle);
886
6.64k
}
pe-mcore.c:find_flags
Line
Count
Source
881
2.88k
{
882
2.88k
  struct comdat_hash_entry needle;
883
2.88k
  needle.target_index = target_index;
884
885
2.88k
  return htab_find (comdat_hash, &needle);
886
2.88k
}
pe-sh.c:find_flags
Line
Count
Source
881
6.58k
{
882
6.58k
  struct comdat_hash_entry needle;
883
6.58k
  needle.target_index = target_index;
884
885
6.58k
  return htab_find (comdat_hash, &needle);
886
6.58k
}
pei-arm-wince.c:find_flags
Line
Count
Source
881
5.31k
{
882
5.31k
  struct comdat_hash_entry needle;
883
5.31k
  needle.target_index = target_index;
884
885
5.31k
  return htab_find (comdat_hash, &needle);
886
5.31k
}
pei-arm.c:find_flags
Line
Count
Source
881
6.33k
{
882
6.33k
  struct comdat_hash_entry needle;
883
6.33k
  needle.target_index = target_index;
884
885
6.33k
  return htab_find (comdat_hash, &needle);
886
6.33k
}
pei-mcore.c:find_flags
Line
Count
Source
881
6.88k
{
882
6.88k
  struct comdat_hash_entry needle;
883
6.88k
  needle.target_index = target_index;
884
885
6.88k
  return htab_find (comdat_hash, &needle);
886
6.88k
}
pei-sh.c:find_flags
Line
Count
Source
881
3.66k
{
882
3.66k
  struct comdat_hash_entry needle;
883
3.66k
  needle.target_index = target_index;
884
885
3.66k
  return htab_find (comdat_hash, &needle);
886
3.66k
}
887
888
static bool
889
fill_comdat_hash (bfd *abfd)
890
66.2k
{
891
66.2k
  bfd_byte *esymstart, *esym, *esymend;
892
893
  /* Unfortunately, the PE format stores essential information in the
894
     symbol table, of all places.  We need to extract that information
895
     now, so that objdump and the linker will know how to handle the
896
     section without worrying about the symbols.  We can't call
897
     slurp_symtab, because the linker doesn't want the swapped symbols.  */
898
899
  /* COMDAT sections are special.  The first symbol is the section
900
     symbol, which tells what kind of COMDAT section it is.  The
901
     second symbol is the "comdat symbol" - the one with the unique
902
     name.  GNU uses the section symbol for the unique name; MS uses
903
     ".text" for every comdat section.  Sigh.  - DJ.  */
904
905
  /* This is not mirrored in sec_to_styp_flags(), but there doesn't
906
     seem to be a need to, either, and it would at best be rather messy.  */
907
908
66.2k
  if (! _bfd_coff_get_external_symbols (abfd))
909
27.3k
    return true;
910
911
38.9k
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
38.9k
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
38.9k
  for (struct internal_syment isym;
915
1.20M
       esym < esymend;
916
1.17M
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
1.17M
    {
918
1.17M
      char buf[SYMNMLEN + 1];
919
1.17M
      const char *symname;
920
1.17M
      flagword sec_flags = SEC_LINK_ONCE;
921
922
1.17M
      bfd_coff_swap_sym_in (abfd, esym, &isym);
923
924
      /* According to the MSVC documentation, the first TWO entries
925
   with the section # are both of interest to us.  The first one
926
   is the "section symbol" (section name).  The second is the
927
   comdat symbol name.  Here, we've found the first qualifying
928
   entry; we distinguish it from the second with a state flag.
929
930
   In the case of gas-generated (at least until that is fixed)
931
   .o files, it isn't necessarily the second one.  It may be
932
   some other later symbol.
933
934
   Since gas also doesn't follow MS conventions and emits the
935
   section similar to .text$<name>, where <something> is the
936
   name we're looking for, we distinguish the two as follows:
937
938
   If the section name is simply a section name (no $) we
939
   presume it's MS-generated, and look at precisely the second
940
   symbol for the comdat name.  If the section name has a $, we
941
   assume it's gas-generated, and look for <something> (whatever
942
   follows the $) as the comdat symbol.  */
943
944
      /* All 3 branches use this.  */
945
1.17M
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
1.17M
      if (symname == NULL)
949
489k
  {
950
489k
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
489k
            abfd);
952
489k
    continue;
953
489k
  }
954
955
680k
      union internal_auxent aux;
956
957
680k
      struct comdat_hash_entry needle;
958
680k
      needle.target_index = isym.n_scnum;
959
960
680k
      void **slot
961
680k
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
680k
      if (slot == NULL)
963
0
  return false;
964
965
680k
      if (*slot == NULL)
966
215k
  {
967
215k
    if (isym.n_numaux == 0)
968
124k
      aux.x_scn.x_comdat = 0;
969
90.4k
    else
970
90.4k
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
90.4k
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
13.3k
    {
974
      /* xgettext:c-format */
975
13.3k
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
13.3k
          " section '%s' found"),
977
13.3k
              abfd, symname);
978
13.3k
      continue;
979
13.3k
    }
980
77.1k
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
77.1k
            isym.n_type, isym.n_sclass, 0,
982
77.1k
            isym.n_numaux, &aux);
983
77.1k
      }
984
985
    /* FIXME: Microsoft uses NODUPLICATES and ASSOCIATIVE, but
986
       gnu uses ANY and SAME_SIZE.  Unfortunately, gnu doesn't
987
       do the comdat symbols right.  So, until we can fix it to
988
       do the right thing, we are temporarily disabling comdats
989
       for the MS types (they're used in DLLs and C++, but we
990
       don't support *their* C++ libraries anyway - DJ.  */
991
992
    /* Cygwin does not follow the MS style, and uses ANY and
993
       SAME_SIZE where NODUPLICATES and ASSOCIATIVE should be
994
       used.  For Interix, we just do the right thing up
995
       front.  */
996
997
201k
    switch (aux.x_scn.x_comdat)
998
201k
      {
999
921
      case IMAGE_COMDAT_SELECT_NODUPLICATES:
1000
#ifdef STRICT_PE_FORMAT
1001
        sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY;
1002
#else
1003
921
        sec_flags &= ~SEC_LINK_ONCE;
1004
921
#endif
1005
921
        break;
1006
1007
4
      case IMAGE_COMDAT_SELECT_ANY:
1008
4
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1009
4
        break;
1010
1011
9
      case IMAGE_COMDAT_SELECT_SAME_SIZE:
1012
9
        sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE;
1013
9
        break;
1014
1015
38
      case IMAGE_COMDAT_SELECT_EXACT_MATCH:
1016
        /* Not yet fully implemented ??? */
1017
38
        sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS;
1018
38
        break;
1019
1020
        /* debug$S gets this case; other implications ???  */
1021
1022
        /* There may be no symbol.  We'll search the whole
1023
     table.  Is this the right place to play this game?
1024
     Or should we do it when reading it in?  */
1025
242
      case IMAGE_COMDAT_SELECT_ASSOCIATIVE:
1026
#ifdef STRICT_PE_FORMAT
1027
        /* FIXME: This is not currently implemented.  */
1028
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1029
#else
1030
242
        sec_flags &= ~SEC_LINK_ONCE;
1031
242
#endif
1032
242
        break;
1033
1034
200k
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
200k
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
200k
        break;
1038
201k
      }
1039
1040
201k
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
201k
    if (*slot == NULL)
1042
0
      return false;
1043
201k
    struct comdat_hash_entry *newentry = *slot;
1044
201k
    newentry->sec_flags = sec_flags;
1045
201k
    newentry->symname = bfd_strdup (symname);
1046
201k
    newentry->target_index = isym.n_scnum;
1047
201k
    newentry->isym = isym;
1048
201k
    newentry->comdat_symbol = -1;
1049
201k
  }
1050
465k
      else
1051
465k
  {
1052
465k
    struct comdat_hash_entry *entry = *slot;
1053
1054
465k
    if (entry->comdat_symbol != -1)
1055
411k
      continue;
1056
1057
53.9k
    char *target_name = strchr (entry->symname, '$');
1058
53.9k
    if (target_name != NULL)
1059
2.69k
      {
1060
        /* Gas mode: the first matching on partial name.  */
1061
1062
2.69k
        target_name += 1;
1063
#ifndef TARGET_UNDERSCORE
1064
67
#define TARGET_UNDERSCORE 0
1065
#endif
1066
        /* Is this the name we're looking for ?  */
1067
2.69k
        if (strcmp (target_name,
1068
2.69k
        symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0)
1069
1.74k
    {
1070
      /* Not the name we're looking for */
1071
1.74k
      continue;
1072
1.74k
    }
1073
2.69k
      }
1074
    /* MSVC mode: the lexically second symbol (or drop through
1075
       from the above).  */
1076
    /* This must the second symbol with the section #.  It is
1077
       the actual symbol name.  Intel puts the two adjacent, but
1078
       Alpha (at least) spreads them out.  */
1079
1080
52.2k
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
52.2k
    entry->comdat_name = bfd_strdup (symname);
1082
52.2k
  }
1083
680k
    }
1084
1085
38.9k
  return true;
1086
38.9k
}
pei-i386.c:fill_comdat_hash
Line
Count
Source
890
5.87k
{
891
5.87k
  bfd_byte *esymstart, *esym, *esymend;
892
893
  /* Unfortunately, the PE format stores essential information in the
894
     symbol table, of all places.  We need to extract that information
895
     now, so that objdump and the linker will know how to handle the
896
     section without worrying about the symbols.  We can't call
897
     slurp_symtab, because the linker doesn't want the swapped symbols.  */
898
899
  /* COMDAT sections are special.  The first symbol is the section
900
     symbol, which tells what kind of COMDAT section it is.  The
901
     second symbol is the "comdat symbol" - the one with the unique
902
     name.  GNU uses the section symbol for the unique name; MS uses
903
     ".text" for every comdat section.  Sigh.  - DJ.  */
904
905
  /* This is not mirrored in sec_to_styp_flags(), but there doesn't
906
     seem to be a need to, either, and it would at best be rather messy.  */
907
908
5.87k
  if (! _bfd_coff_get_external_symbols (abfd))
909
2.59k
    return true;
910
911
3.27k
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
3.27k
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
3.27k
  for (struct internal_syment isym;
915
465k
       esym < esymend;
916
462k
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
462k
    {
918
462k
      char buf[SYMNMLEN + 1];
919
462k
      const char *symname;
920
462k
      flagword sec_flags = SEC_LINK_ONCE;
921
922
462k
      bfd_coff_swap_sym_in (abfd, esym, &isym);
923
924
      /* According to the MSVC documentation, the first TWO entries
925
   with the section # are both of interest to us.  The first one
926
   is the "section symbol" (section name).  The second is the
927
   comdat symbol name.  Here, we've found the first qualifying
928
   entry; we distinguish it from the second with a state flag.
929
930
   In the case of gas-generated (at least until that is fixed)
931
   .o files, it isn't necessarily the second one.  It may be
932
   some other later symbol.
933
934
   Since gas also doesn't follow MS conventions and emits the
935
   section similar to .text$<name>, where <something> is the
936
   name we're looking for, we distinguish the two as follows:
937
938
   If the section name is simply a section name (no $) we
939
   presume it's MS-generated, and look at precisely the second
940
   symbol for the comdat name.  If the section name has a $, we
941
   assume it's gas-generated, and look for <something> (whatever
942
   follows the $) as the comdat symbol.  */
943
944
      /* All 3 branches use this.  */
945
462k
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
462k
      if (symname == NULL)
949
210k
  {
950
210k
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
210k
            abfd);
952
210k
    continue;
953
210k
  }
954
955
251k
      union internal_auxent aux;
956
957
251k
      struct comdat_hash_entry needle;
958
251k
      needle.target_index = isym.n_scnum;
959
960
251k
      void **slot
961
251k
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
251k
      if (slot == NULL)
963
0
  return false;
964
965
251k
      if (*slot == NULL)
966
85.0k
  {
967
85.0k
    if (isym.n_numaux == 0)
968
47.2k
      aux.x_scn.x_comdat = 0;
969
37.7k
    else
970
37.7k
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
37.7k
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
1.54k
    {
974
      /* xgettext:c-format */
975
1.54k
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
1.54k
          " section '%s' found"),
977
1.54k
              abfd, symname);
978
1.54k
      continue;
979
1.54k
    }
980
36.1k
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
36.1k
            isym.n_type, isym.n_sclass, 0,
982
36.1k
            isym.n_numaux, &aux);
983
36.1k
      }
984
985
    /* FIXME: Microsoft uses NODUPLICATES and ASSOCIATIVE, but
986
       gnu uses ANY and SAME_SIZE.  Unfortunately, gnu doesn't
987
       do the comdat symbols right.  So, until we can fix it to
988
       do the right thing, we are temporarily disabling comdats
989
       for the MS types (they're used in DLLs and C++, but we
990
       don't support *their* C++ libraries anyway - DJ.  */
991
992
    /* Cygwin does not follow the MS style, and uses ANY and
993
       SAME_SIZE where NODUPLICATES and ASSOCIATIVE should be
994
       used.  For Interix, we just do the right thing up
995
       front.  */
996
997
83.4k
    switch (aux.x_scn.x_comdat)
998
83.4k
      {
999
240
      case IMAGE_COMDAT_SELECT_NODUPLICATES:
1000
#ifdef STRICT_PE_FORMAT
1001
        sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY;
1002
#else
1003
240
        sec_flags &= ~SEC_LINK_ONCE;
1004
240
#endif
1005
240
        break;
1006
1007
0
      case IMAGE_COMDAT_SELECT_ANY:
1008
0
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1009
0
        break;
1010
1011
0
      case IMAGE_COMDAT_SELECT_SAME_SIZE:
1012
0
        sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE;
1013
0
        break;
1014
1015
1
      case IMAGE_COMDAT_SELECT_EXACT_MATCH:
1016
        /* Not yet fully implemented ??? */
1017
1
        sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS;
1018
1
        break;
1019
1020
        /* debug$S gets this case; other implications ???  */
1021
1022
        /* There may be no symbol.  We'll search the whole
1023
     table.  Is this the right place to play this game?
1024
     Or should we do it when reading it in?  */
1025
0
      case IMAGE_COMDAT_SELECT_ASSOCIATIVE:
1026
#ifdef STRICT_PE_FORMAT
1027
        /* FIXME: This is not currently implemented.  */
1028
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1029
#else
1030
0
        sec_flags &= ~SEC_LINK_ONCE;
1031
0
#endif
1032
0
        break;
1033
1034
83.2k
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
83.2k
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
83.2k
        break;
1038
83.4k
      }
1039
1040
83.4k
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
83.4k
    if (*slot == NULL)
1042
0
      return false;
1043
83.4k
    struct comdat_hash_entry *newentry = *slot;
1044
83.4k
    newentry->sec_flags = sec_flags;
1045
83.4k
    newentry->symname = bfd_strdup (symname);
1046
83.4k
    newentry->target_index = isym.n_scnum;
1047
83.4k
    newentry->isym = isym;
1048
83.4k
    newentry->comdat_symbol = -1;
1049
83.4k
  }
1050
166k
      else
1051
166k
  {
1052
166k
    struct comdat_hash_entry *entry = *slot;
1053
1054
166k
    if (entry->comdat_symbol != -1)
1055
147k
      continue;
1056
1057
19.1k
    char *target_name = strchr (entry->symname, '$');
1058
19.1k
    if (target_name != NULL)
1059
717
      {
1060
        /* Gas mode: the first matching on partial name.  */
1061
1062
717
        target_name += 1;
1063
#ifndef TARGET_UNDERSCORE
1064
#define TARGET_UNDERSCORE 0
1065
#endif
1066
        /* Is this the name we're looking for ?  */
1067
717
        if (strcmp (target_name,
1068
717
        symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0)
1069
478
    {
1070
      /* Not the name we're looking for */
1071
478
      continue;
1072
478
    }
1073
717
      }
1074
    /* MSVC mode: the lexically second symbol (or drop through
1075
       from the above).  */
1076
    /* This must the second symbol with the section #.  It is
1077
       the actual symbol name.  Intel puts the two adjacent, but
1078
       Alpha (at least) spreads them out.  */
1079
1080
18.7k
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
18.7k
    entry->comdat_name = bfd_strdup (symname);
1082
18.7k
  }
1083
251k
    }
1084
1085
3.27k
  return true;
1086
3.27k
}
pe-x86_64.c:fill_comdat_hash
Line
Count
Source
890
9.86k
{
891
9.86k
  bfd_byte *esymstart, *esym, *esymend;
892
893
  /* Unfortunately, the PE format stores essential information in the
894
     symbol table, of all places.  We need to extract that information
895
     now, so that objdump and the linker will know how to handle the
896
     section without worrying about the symbols.  We can't call
897
     slurp_symtab, because the linker doesn't want the swapped symbols.  */
898
899
  /* COMDAT sections are special.  The first symbol is the section
900
     symbol, which tells what kind of COMDAT section it is.  The
901
     second symbol is the "comdat symbol" - the one with the unique
902
     name.  GNU uses the section symbol for the unique name; MS uses
903
     ".text" for every comdat section.  Sigh.  - DJ.  */
904
905
  /* This is not mirrored in sec_to_styp_flags(), but there doesn't
906
     seem to be a need to, either, and it would at best be rather messy.  */
907
908
9.86k
  if (! _bfd_coff_get_external_symbols (abfd))
909
3.20k
    return true;
910
911
6.66k
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
6.66k
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
6.66k
  for (struct internal_syment isym;
915
159k
       esym < esymend;
916
152k
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
152k
    {
918
152k
      char buf[SYMNMLEN + 1];
919
152k
      const char *symname;
920
152k
      flagword sec_flags = SEC_LINK_ONCE;
921
922
152k
      bfd_coff_swap_sym_in (abfd, esym, &isym);
923
924
      /* According to the MSVC documentation, the first TWO entries
925
   with the section # are both of interest to us.  The first one
926
   is the "section symbol" (section name).  The second is the
927
   comdat symbol name.  Here, we've found the first qualifying
928
   entry; we distinguish it from the second with a state flag.
929
930
   In the case of gas-generated (at least until that is fixed)
931
   .o files, it isn't necessarily the second one.  It may be
932
   some other later symbol.
933
934
   Since gas also doesn't follow MS conventions and emits the
935
   section similar to .text$<name>, where <something> is the
936
   name we're looking for, we distinguish the two as follows:
937
938
   If the section name is simply a section name (no $) we
939
   presume it's MS-generated, and look at precisely the second
940
   symbol for the comdat name.  If the section name has a $, we
941
   assume it's gas-generated, and look for <something> (whatever
942
   follows the $) as the comdat symbol.  */
943
944
      /* All 3 branches use this.  */
945
152k
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
152k
      if (symname == NULL)
949
72.3k
  {
950
72.3k
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
72.3k
            abfd);
952
72.3k
    continue;
953
72.3k
  }
954
955
80.0k
      union internal_auxent aux;
956
957
80.0k
      struct comdat_hash_entry needle;
958
80.0k
      needle.target_index = isym.n_scnum;
959
960
80.0k
      void **slot
961
80.0k
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
80.0k
      if (slot == NULL)
963
0
  return false;
964
965
80.0k
      if (*slot == NULL)
966
21.6k
  {
967
21.6k
    if (isym.n_numaux == 0)
968
16.3k
      aux.x_scn.x_comdat = 0;
969
5.30k
    else
970
5.30k
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
5.30k
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
2.26k
    {
974
      /* xgettext:c-format */
975
2.26k
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
2.26k
          " section '%s' found"),
977
2.26k
              abfd, symname);
978
2.26k
      continue;
979
2.26k
    }
980
3.04k
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
3.04k
            isym.n_type, isym.n_sclass, 0,
982
3.04k
            isym.n_numaux, &aux);
983
3.04k
      }
984
985
    /* FIXME: Microsoft uses NODUPLICATES and ASSOCIATIVE, but
986
       gnu uses ANY and SAME_SIZE.  Unfortunately, gnu doesn't
987
       do the comdat symbols right.  So, until we can fix it to
988
       do the right thing, we are temporarily disabling comdats
989
       for the MS types (they're used in DLLs and C++, but we
990
       don't support *their* C++ libraries anyway - DJ.  */
991
992
    /* Cygwin does not follow the MS style, and uses ANY and
993
       SAME_SIZE where NODUPLICATES and ASSOCIATIVE should be
994
       used.  For Interix, we just do the right thing up
995
       front.  */
996
997
19.4k
    switch (aux.x_scn.x_comdat)
998
19.4k
      {
999
135
      case IMAGE_COMDAT_SELECT_NODUPLICATES:
1000
#ifdef STRICT_PE_FORMAT
1001
        sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY;
1002
#else
1003
135
        sec_flags &= ~SEC_LINK_ONCE;
1004
135
#endif
1005
135
        break;
1006
1007
3
      case IMAGE_COMDAT_SELECT_ANY:
1008
3
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1009
3
        break;
1010
1011
0
      case IMAGE_COMDAT_SELECT_SAME_SIZE:
1012
0
        sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE;
1013
0
        break;
1014
1015
0
      case IMAGE_COMDAT_SELECT_EXACT_MATCH:
1016
        /* Not yet fully implemented ??? */
1017
0
        sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS;
1018
0
        break;
1019
1020
        /* debug$S gets this case; other implications ???  */
1021
1022
        /* There may be no symbol.  We'll search the whole
1023
     table.  Is this the right place to play this game?
1024
     Or should we do it when reading it in?  */
1025
0
      case IMAGE_COMDAT_SELECT_ASSOCIATIVE:
1026
#ifdef STRICT_PE_FORMAT
1027
        /* FIXME: This is not currently implemented.  */
1028
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1029
#else
1030
0
        sec_flags &= ~SEC_LINK_ONCE;
1031
0
#endif
1032
0
        break;
1033
1034
19.2k
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
19.2k
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
19.2k
        break;
1038
19.4k
      }
1039
1040
19.4k
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
19.4k
    if (*slot == NULL)
1042
0
      return false;
1043
19.4k
    struct comdat_hash_entry *newentry = *slot;
1044
19.4k
    newentry->sec_flags = sec_flags;
1045
19.4k
    newentry->symname = bfd_strdup (symname);
1046
19.4k
    newentry->target_index = isym.n_scnum;
1047
19.4k
    newentry->isym = isym;
1048
19.4k
    newentry->comdat_symbol = -1;
1049
19.4k
  }
1050
58.3k
      else
1051
58.3k
  {
1052
58.3k
    struct comdat_hash_entry *entry = *slot;
1053
1054
58.3k
    if (entry->comdat_symbol != -1)
1055
52.6k
      continue;
1056
1057
5.70k
    char *target_name = strchr (entry->symname, '$');
1058
5.70k
    if (target_name != NULL)
1059
75
      {
1060
        /* Gas mode: the first matching on partial name.  */
1061
1062
75
        target_name += 1;
1063
#ifndef TARGET_UNDERSCORE
1064
#define TARGET_UNDERSCORE 0
1065
#endif
1066
        /* Is this the name we're looking for ?  */
1067
75
        if (strcmp (target_name,
1068
75
        symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0)
1069
74
    {
1070
      /* Not the name we're looking for */
1071
74
      continue;
1072
74
    }
1073
75
      }
1074
    /* MSVC mode: the lexically second symbol (or drop through
1075
       from the above).  */
1076
    /* This must the second symbol with the section #.  It is
1077
       the actual symbol name.  Intel puts the two adjacent, but
1078
       Alpha (at least) spreads them out.  */
1079
1080
5.62k
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
5.62k
    entry->comdat_name = bfd_strdup (symname);
1082
5.62k
  }
1083
80.0k
    }
1084
1085
6.66k
  return true;
1086
6.66k
}
pei-x86_64.c:fill_comdat_hash
Line
Count
Source
890
4.15k
{
891
4.15k
  bfd_byte *esymstart, *esym, *esymend;
892
893
  /* Unfortunately, the PE format stores essential information in the
894
     symbol table, of all places.  We need to extract that information
895
     now, so that objdump and the linker will know how to handle the
896
     section without worrying about the symbols.  We can't call
897
     slurp_symtab, because the linker doesn't want the swapped symbols.  */
898
899
  /* COMDAT sections are special.  The first symbol is the section
900
     symbol, which tells what kind of COMDAT section it is.  The
901
     second symbol is the "comdat symbol" - the one with the unique
902
     name.  GNU uses the section symbol for the unique name; MS uses
903
     ".text" for every comdat section.  Sigh.  - DJ.  */
904
905
  /* This is not mirrored in sec_to_styp_flags(), but there doesn't
906
     seem to be a need to, either, and it would at best be rather messy.  */
907
908
4.15k
  if (! _bfd_coff_get_external_symbols (abfd))
909
2.41k
    return true;
910
911
1.73k
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
1.73k
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
1.73k
  for (struct internal_syment isym;
915
15.4k
       esym < esymend;
916
13.7k
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
13.7k
    {
918
13.7k
      char buf[SYMNMLEN + 1];
919
13.7k
      const char *symname;
920
13.7k
      flagword sec_flags = SEC_LINK_ONCE;
921
922
13.7k
      bfd_coff_swap_sym_in (abfd, esym, &isym);
923
924
      /* According to the MSVC documentation, the first TWO entries
925
   with the section # are both of interest to us.  The first one
926
   is the "section symbol" (section name).  The second is the
927
   comdat symbol name.  Here, we've found the first qualifying
928
   entry; we distinguish it from the second with a state flag.
929
930
   In the case of gas-generated (at least until that is fixed)
931
   .o files, it isn't necessarily the second one.  It may be
932
   some other later symbol.
933
934
   Since gas also doesn't follow MS conventions and emits the
935
   section similar to .text$<name>, where <something> is the
936
   name we're looking for, we distinguish the two as follows:
937
938
   If the section name is simply a section name (no $) we
939
   presume it's MS-generated, and look at precisely the second
940
   symbol for the comdat name.  If the section name has a $, we
941
   assume it's gas-generated, and look for <something> (whatever
942
   follows the $) as the comdat symbol.  */
943
944
      /* All 3 branches use this.  */
945
13.7k
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
13.7k
      if (symname == NULL)
949
4.22k
  {
950
4.22k
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
4.22k
            abfd);
952
4.22k
    continue;
953
4.22k
  }
954
955
9.52k
      union internal_auxent aux;
956
957
9.52k
      struct comdat_hash_entry needle;
958
9.52k
      needle.target_index = isym.n_scnum;
959
960
9.52k
      void **slot
961
9.52k
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
9.52k
      if (slot == NULL)
963
0
  return false;
964
965
9.52k
      if (*slot == NULL)
966
5.48k
  {
967
5.48k
    if (isym.n_numaux == 0)
968
2.83k
      aux.x_scn.x_comdat = 0;
969
2.64k
    else
970
2.64k
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
2.64k
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
350
    {
974
      /* xgettext:c-format */
975
350
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
350
          " section '%s' found"),
977
350
              abfd, symname);
978
350
      continue;
979
350
    }
980
2.29k
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
2.29k
            isym.n_type, isym.n_sclass, 0,
982
2.29k
            isym.n_numaux, &aux);
983
2.29k
      }
984
985
    /* FIXME: Microsoft uses NODUPLICATES and ASSOCIATIVE, but
986
       gnu uses ANY and SAME_SIZE.  Unfortunately, gnu doesn't
987
       do the comdat symbols right.  So, until we can fix it to
988
       do the right thing, we are temporarily disabling comdats
989
       for the MS types (they're used in DLLs and C++, but we
990
       don't support *their* C++ libraries anyway - DJ.  */
991
992
    /* Cygwin does not follow the MS style, and uses ANY and
993
       SAME_SIZE where NODUPLICATES and ASSOCIATIVE should be
994
       used.  For Interix, we just do the right thing up
995
       front.  */
996
997
5.13k
    switch (aux.x_scn.x_comdat)
998
5.13k
      {
999
257
      case IMAGE_COMDAT_SELECT_NODUPLICATES:
1000
#ifdef STRICT_PE_FORMAT
1001
        sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY;
1002
#else
1003
257
        sec_flags &= ~SEC_LINK_ONCE;
1004
257
#endif
1005
257
        break;
1006
1007
0
      case IMAGE_COMDAT_SELECT_ANY:
1008
0
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1009
0
        break;
1010
1011
0
      case IMAGE_COMDAT_SELECT_SAME_SIZE:
1012
0
        sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE;
1013
0
        break;
1014
1015
6
      case IMAGE_COMDAT_SELECT_EXACT_MATCH:
1016
        /* Not yet fully implemented ??? */
1017
6
        sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS;
1018
6
        break;
1019
1020
        /* debug$S gets this case; other implications ???  */
1021
1022
        /* There may be no symbol.  We'll search the whole
1023
     table.  Is this the right place to play this game?
1024
     Or should we do it when reading it in?  */
1025
237
      case IMAGE_COMDAT_SELECT_ASSOCIATIVE:
1026
#ifdef STRICT_PE_FORMAT
1027
        /* FIXME: This is not currently implemented.  */
1028
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1029
#else
1030
237
        sec_flags &= ~SEC_LINK_ONCE;
1031
237
#endif
1032
237
        break;
1033
1034
4.63k
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
4.63k
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
4.63k
        break;
1038
5.13k
      }
1039
1040
5.13k
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
5.13k
    if (*slot == NULL)
1042
0
      return false;
1043
5.13k
    struct comdat_hash_entry *newentry = *slot;
1044
5.13k
    newentry->sec_flags = sec_flags;
1045
5.13k
    newentry->symname = bfd_strdup (symname);
1046
5.13k
    newentry->target_index = isym.n_scnum;
1047
5.13k
    newentry->isym = isym;
1048
5.13k
    newentry->comdat_symbol = -1;
1049
5.13k
  }
1050
4.04k
      else
1051
4.04k
  {
1052
4.04k
    struct comdat_hash_entry *entry = *slot;
1053
1054
4.04k
    if (entry->comdat_symbol != -1)
1055
3.07k
      continue;
1056
1057
969
    char *target_name = strchr (entry->symname, '$');
1058
969
    if (target_name != NULL)
1059
5
      {
1060
        /* Gas mode: the first matching on partial name.  */
1061
1062
5
        target_name += 1;
1063
#ifndef TARGET_UNDERSCORE
1064
#define TARGET_UNDERSCORE 0
1065
#endif
1066
        /* Is this the name we're looking for ?  */
1067
5
        if (strcmp (target_name,
1068
5
        symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0)
1069
5
    {
1070
      /* Not the name we're looking for */
1071
5
      continue;
1072
5
    }
1073
5
      }
1074
    /* MSVC mode: the lexically second symbol (or drop through
1075
       from the above).  */
1076
    /* This must the second symbol with the section #.  It is
1077
       the actual symbol name.  Intel puts the two adjacent, but
1078
       Alpha (at least) spreads them out.  */
1079
1080
964
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
964
    entry->comdat_name = bfd_strdup (symname);
1082
964
  }
1083
9.52k
    }
1084
1085
1.73k
  return true;
1086
1.73k
}
pe-aarch64.c:fill_comdat_hash
Line
Count
Source
890
3.60k
{
891
3.60k
  bfd_byte *esymstart, *esym, *esymend;
892
893
  /* Unfortunately, the PE format stores essential information in the
894
     symbol table, of all places.  We need to extract that information
895
     now, so that objdump and the linker will know how to handle the
896
     section without worrying about the symbols.  We can't call
897
     slurp_symtab, because the linker doesn't want the swapped symbols.  */
898
899
  /* COMDAT sections are special.  The first symbol is the section
900
     symbol, which tells what kind of COMDAT section it is.  The
901
     second symbol is the "comdat symbol" - the one with the unique
902
     name.  GNU uses the section symbol for the unique name; MS uses
903
     ".text" for every comdat section.  Sigh.  - DJ.  */
904
905
  /* This is not mirrored in sec_to_styp_flags(), but there doesn't
906
     seem to be a need to, either, and it would at best be rather messy.  */
907
908
3.60k
  if (! _bfd_coff_get_external_symbols (abfd))
909
1.31k
    return true;
910
911
2.28k
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
2.28k
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
2.28k
  for (struct internal_syment isym;
915
33.6k
       esym < esymend;
916
31.3k
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
31.3k
    {
918
31.3k
      char buf[SYMNMLEN + 1];
919
31.3k
      const char *symname;
920
31.3k
      flagword sec_flags = SEC_LINK_ONCE;
921
922
31.3k
      bfd_coff_swap_sym_in (abfd, esym, &isym);
923
924
      /* According to the MSVC documentation, the first TWO entries
925
   with the section # are both of interest to us.  The first one
926
   is the "section symbol" (section name).  The second is the
927
   comdat symbol name.  Here, we've found the first qualifying
928
   entry; we distinguish it from the second with a state flag.
929
930
   In the case of gas-generated (at least until that is fixed)
931
   .o files, it isn't necessarily the second one.  It may be
932
   some other later symbol.
933
934
   Since gas also doesn't follow MS conventions and emits the
935
   section similar to .text$<name>, where <something> is the
936
   name we're looking for, we distinguish the two as follows:
937
938
   If the section name is simply a section name (no $) we
939
   presume it's MS-generated, and look at precisely the second
940
   symbol for the comdat name.  If the section name has a $, we
941
   assume it's gas-generated, and look for <something> (whatever
942
   follows the $) as the comdat symbol.  */
943
944
      /* All 3 branches use this.  */
945
31.3k
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
31.3k
      if (symname == NULL)
949
3.66k
  {
950
3.66k
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
3.66k
            abfd);
952
3.66k
    continue;
953
3.66k
  }
954
955
27.7k
      union internal_auxent aux;
956
957
27.7k
      struct comdat_hash_entry needle;
958
27.7k
      needle.target_index = isym.n_scnum;
959
960
27.7k
      void **slot
961
27.7k
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
27.7k
      if (slot == NULL)
963
0
  return false;
964
965
27.7k
      if (*slot == NULL)
966
5.14k
  {
967
5.14k
    if (isym.n_numaux == 0)
968
2.28k
      aux.x_scn.x_comdat = 0;
969
2.86k
    else
970
2.86k
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
2.86k
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
1.15k
    {
974
      /* xgettext:c-format */
975
1.15k
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
1.15k
          " section '%s' found"),
977
1.15k
              abfd, symname);
978
1.15k
      continue;
979
1.15k
    }
980
1.70k
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
1.70k
            isym.n_type, isym.n_sclass, 0,
982
1.70k
            isym.n_numaux, &aux);
983
1.70k
      }
984
985
    /* FIXME: Microsoft uses NODUPLICATES and ASSOCIATIVE, but
986
       gnu uses ANY and SAME_SIZE.  Unfortunately, gnu doesn't
987
       do the comdat symbols right.  So, until we can fix it to
988
       do the right thing, we are temporarily disabling comdats
989
       for the MS types (they're used in DLLs and C++, but we
990
       don't support *their* C++ libraries anyway - DJ.  */
991
992
    /* Cygwin does not follow the MS style, and uses ANY and
993
       SAME_SIZE where NODUPLICATES and ASSOCIATIVE should be
994
       used.  For Interix, we just do the right thing up
995
       front.  */
996
997
3.99k
    switch (aux.x_scn.x_comdat)
998
3.99k
      {
999
0
      case IMAGE_COMDAT_SELECT_NODUPLICATES:
1000
#ifdef STRICT_PE_FORMAT
1001
        sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY;
1002
#else
1003
0
        sec_flags &= ~SEC_LINK_ONCE;
1004
0
#endif
1005
0
        break;
1006
1007
0
      case IMAGE_COMDAT_SELECT_ANY:
1008
0
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1009
0
        break;
1010
1011
0
      case IMAGE_COMDAT_SELECT_SAME_SIZE:
1012
0
        sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE;
1013
0
        break;
1014
1015
0
      case IMAGE_COMDAT_SELECT_EXACT_MATCH:
1016
        /* Not yet fully implemented ??? */
1017
0
        sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS;
1018
0
        break;
1019
1020
        /* debug$S gets this case; other implications ???  */
1021
1022
        /* There may be no symbol.  We'll search the whole
1023
     table.  Is this the right place to play this game?
1024
     Or should we do it when reading it in?  */
1025
0
      case IMAGE_COMDAT_SELECT_ASSOCIATIVE:
1026
#ifdef STRICT_PE_FORMAT
1027
        /* FIXME: This is not currently implemented.  */
1028
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1029
#else
1030
0
        sec_flags &= ~SEC_LINK_ONCE;
1031
0
#endif
1032
0
        break;
1033
1034
3.99k
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
3.99k
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
3.99k
        break;
1038
3.99k
      }
1039
1040
3.99k
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
3.99k
    if (*slot == NULL)
1042
0
      return false;
1043
3.99k
    struct comdat_hash_entry *newentry = *slot;
1044
3.99k
    newentry->sec_flags = sec_flags;
1045
3.99k
    newentry->symname = bfd_strdup (symname);
1046
3.99k
    newentry->target_index = isym.n_scnum;
1047
3.99k
    newentry->isym = isym;
1048
3.99k
    newentry->comdat_symbol = -1;
1049
3.99k
  }
1050
22.5k
      else
1051
22.5k
  {
1052
22.5k
    struct comdat_hash_entry *entry = *slot;
1053
1054
22.5k
    if (entry->comdat_symbol != -1)
1055
21.6k
      continue;
1056
1057
945
    char *target_name = strchr (entry->symname, '$');
1058
945
    if (target_name != NULL)
1059
8
      {
1060
        /* Gas mode: the first matching on partial name.  */
1061
1062
8
        target_name += 1;
1063
8
#ifndef TARGET_UNDERSCORE
1064
8
#define TARGET_UNDERSCORE 0
1065
8
#endif
1066
        /* Is this the name we're looking for ?  */
1067
8
        if (strcmp (target_name,
1068
8
        symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0)
1069
7
    {
1070
      /* Not the name we're looking for */
1071
7
      continue;
1072
7
    }
1073
8
      }
1074
    /* MSVC mode: the lexically second symbol (or drop through
1075
       from the above).  */
1076
    /* This must the second symbol with the section #.  It is
1077
       the actual symbol name.  Intel puts the two adjacent, but
1078
       Alpha (at least) spreads them out.  */
1079
1080
938
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
938
    entry->comdat_name = bfd_strdup (symname);
1082
938
  }
1083
27.7k
    }
1084
1085
2.28k
  return true;
1086
2.28k
}
pei-aarch64.c:fill_comdat_hash
Line
Count
Source
890
2.20k
{
891
2.20k
  bfd_byte *esymstart, *esym, *esymend;
892
893
  /* Unfortunately, the PE format stores essential information in the
894
     symbol table, of all places.  We need to extract that information
895
     now, so that objdump and the linker will know how to handle the
896
     section without worrying about the symbols.  We can't call
897
     slurp_symtab, because the linker doesn't want the swapped symbols.  */
898
899
  /* COMDAT sections are special.  The first symbol is the section
900
     symbol, which tells what kind of COMDAT section it is.  The
901
     second symbol is the "comdat symbol" - the one with the unique
902
     name.  GNU uses the section symbol for the unique name; MS uses
903
     ".text" for every comdat section.  Sigh.  - DJ.  */
904
905
  /* This is not mirrored in sec_to_styp_flags(), but there doesn't
906
     seem to be a need to, either, and it would at best be rather messy.  */
907
908
2.20k
  if (! _bfd_coff_get_external_symbols (abfd))
909
918
    return true;
910
911
1.28k
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
1.28k
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
1.28k
  for (struct internal_syment isym;
915
122k
       esym < esymend;
916
120k
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
120k
    {
918
120k
      char buf[SYMNMLEN + 1];
919
120k
      const char *symname;
920
120k
      flagword sec_flags = SEC_LINK_ONCE;
921
922
120k
      bfd_coff_swap_sym_in (abfd, esym, &isym);
923
924
      /* According to the MSVC documentation, the first TWO entries
925
   with the section # are both of interest to us.  The first one
926
   is the "section symbol" (section name).  The second is the
927
   comdat symbol name.  Here, we've found the first qualifying
928
   entry; we distinguish it from the second with a state flag.
929
930
   In the case of gas-generated (at least until that is fixed)
931
   .o files, it isn't necessarily the second one.  It may be
932
   some other later symbol.
933
934
   Since gas also doesn't follow MS conventions and emits the
935
   section similar to .text$<name>, where <something> is the
936
   name we're looking for, we distinguish the two as follows:
937
938
   If the section name is simply a section name (no $) we
939
   presume it's MS-generated, and look at precisely the second
940
   symbol for the comdat name.  If the section name has a $, we
941
   assume it's gas-generated, and look for <something> (whatever
942
   follows the $) as the comdat symbol.  */
943
944
      /* All 3 branches use this.  */
945
120k
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
120k
      if (symname == NULL)
949
50.2k
  {
950
50.2k
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
50.2k
            abfd);
952
50.2k
    continue;
953
50.2k
  }
954
955
70.4k
      union internal_auxent aux;
956
957
70.4k
      struct comdat_hash_entry needle;
958
70.4k
      needle.target_index = isym.n_scnum;
959
960
70.4k
      void **slot
961
70.4k
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
70.4k
      if (slot == NULL)
963
0
  return false;
964
965
70.4k
      if (*slot == NULL)
966
16.2k
  {
967
16.2k
    if (isym.n_numaux == 0)
968
10.4k
      aux.x_scn.x_comdat = 0;
969
5.75k
    else
970
5.75k
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
5.75k
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
365
    {
974
      /* xgettext:c-format */
975
365
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
365
          " section '%s' found"),
977
365
              abfd, symname);
978
365
      continue;
979
365
    }
980
5.38k
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
5.38k
            isym.n_type, isym.n_sclass, 0,
982
5.38k
            isym.n_numaux, &aux);
983
5.38k
      }
984
985
    /* FIXME: Microsoft uses NODUPLICATES and ASSOCIATIVE, but
986
       gnu uses ANY and SAME_SIZE.  Unfortunately, gnu doesn't
987
       do the comdat symbols right.  So, until we can fix it to
988
       do the right thing, we are temporarily disabling comdats
989
       for the MS types (they're used in DLLs and C++, but we
990
       don't support *their* C++ libraries anyway - DJ.  */
991
992
    /* Cygwin does not follow the MS style, and uses ANY and
993
       SAME_SIZE where NODUPLICATES and ASSOCIATIVE should be
994
       used.  For Interix, we just do the right thing up
995
       front.  */
996
997
15.8k
    switch (aux.x_scn.x_comdat)
998
15.8k
      {
999
6
      case IMAGE_COMDAT_SELECT_NODUPLICATES:
1000
#ifdef STRICT_PE_FORMAT
1001
        sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY;
1002
#else
1003
6
        sec_flags &= ~SEC_LINK_ONCE;
1004
6
#endif
1005
6
        break;
1006
1007
0
      case IMAGE_COMDAT_SELECT_ANY:
1008
0
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1009
0
        break;
1010
1011
1
      case IMAGE_COMDAT_SELECT_SAME_SIZE:
1012
1
        sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE;
1013
1
        break;
1014
1015
4
      case IMAGE_COMDAT_SELECT_EXACT_MATCH:
1016
        /* Not yet fully implemented ??? */
1017
4
        sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS;
1018
4
        break;
1019
1020
        /* debug$S gets this case; other implications ???  */
1021
1022
        /* There may be no symbol.  We'll search the whole
1023
     table.  Is this the right place to play this game?
1024
     Or should we do it when reading it in?  */
1025
4
      case IMAGE_COMDAT_SELECT_ASSOCIATIVE:
1026
#ifdef STRICT_PE_FORMAT
1027
        /* FIXME: This is not currently implemented.  */
1028
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1029
#else
1030
4
        sec_flags &= ~SEC_LINK_ONCE;
1031
4
#endif
1032
4
        break;
1033
1034
15.8k
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
15.8k
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
15.8k
        break;
1038
15.8k
      }
1039
1040
15.8k
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
15.8k
    if (*slot == NULL)
1042
0
      return false;
1043
15.8k
    struct comdat_hash_entry *newentry = *slot;
1044
15.8k
    newentry->sec_flags = sec_flags;
1045
15.8k
    newentry->symname = bfd_strdup (symname);
1046
15.8k
    newentry->target_index = isym.n_scnum;
1047
15.8k
    newentry->isym = isym;
1048
15.8k
    newentry->comdat_symbol = -1;
1049
15.8k
  }
1050
54.1k
      else
1051
54.1k
  {
1052
54.1k
    struct comdat_hash_entry *entry = *slot;
1053
1054
54.1k
    if (entry->comdat_symbol != -1)
1055
49.2k
      continue;
1056
1057
4.96k
    char *target_name = strchr (entry->symname, '$');
1058
4.96k
    if (target_name != NULL)
1059
39
      {
1060
        /* Gas mode: the first matching on partial name.  */
1061
1062
39
        target_name += 1;
1063
39
#ifndef TARGET_UNDERSCORE
1064
39
#define TARGET_UNDERSCORE 0
1065
39
#endif
1066
        /* Is this the name we're looking for ?  */
1067
39
        if (strcmp (target_name,
1068
39
        symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0)
1069
39
    {
1070
      /* Not the name we're looking for */
1071
39
      continue;
1072
39
    }
1073
39
      }
1074
    /* MSVC mode: the lexically second symbol (or drop through
1075
       from the above).  */
1076
    /* This must the second symbol with the section #.  It is
1077
       the actual symbol name.  Intel puts the two adjacent, but
1078
       Alpha (at least) spreads them out.  */
1079
1080
4.92k
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
4.92k
    entry->comdat_name = bfd_strdup (symname);
1082
4.92k
  }
1083
70.4k
    }
1084
1085
1.28k
  return true;
1086
1.28k
}
pei-ia64.c:fill_comdat_hash
Line
Count
Source
890
2.64k
{
891
2.64k
  bfd_byte *esymstart, *esym, *esymend;
892
893
  /* Unfortunately, the PE format stores essential information in the
894
     symbol table, of all places.  We need to extract that information
895
     now, so that objdump and the linker will know how to handle the
896
     section without worrying about the symbols.  We can't call
897
     slurp_symtab, because the linker doesn't want the swapped symbols.  */
898
899
  /* COMDAT sections are special.  The first symbol is the section
900
     symbol, which tells what kind of COMDAT section it is.  The
901
     second symbol is the "comdat symbol" - the one with the unique
902
     name.  GNU uses the section symbol for the unique name; MS uses
903
     ".text" for every comdat section.  Sigh.  - DJ.  */
904
905
  /* This is not mirrored in sec_to_styp_flags(), but there doesn't
906
     seem to be a need to, either, and it would at best be rather messy.  */
907
908
2.64k
  if (! _bfd_coff_get_external_symbols (abfd))
909
754
    return true;
910
911
1.88k
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
1.88k
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
1.88k
  for (struct internal_syment isym;
915
22.1k
       esym < esymend;
916
20.3k
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
20.3k
    {
918
20.3k
      char buf[SYMNMLEN + 1];
919
20.3k
      const char *symname;
920
20.3k
      flagword sec_flags = SEC_LINK_ONCE;
921
922
20.3k
      bfd_coff_swap_sym_in (abfd, esym, &isym);
923
924
      /* According to the MSVC documentation, the first TWO entries
925
   with the section # are both of interest to us.  The first one
926
   is the "section symbol" (section name).  The second is the
927
   comdat symbol name.  Here, we've found the first qualifying
928
   entry; we distinguish it from the second with a state flag.
929
930
   In the case of gas-generated (at least until that is fixed)
931
   .o files, it isn't necessarily the second one.  It may be
932
   some other later symbol.
933
934
   Since gas also doesn't follow MS conventions and emits the
935
   section similar to .text$<name>, where <something> is the
936
   name we're looking for, we distinguish the two as follows:
937
938
   If the section name is simply a section name (no $) we
939
   presume it's MS-generated, and look at precisely the second
940
   symbol for the comdat name.  If the section name has a $, we
941
   assume it's gas-generated, and look for <something> (whatever
942
   follows the $) as the comdat symbol.  */
943
944
      /* All 3 branches use this.  */
945
20.3k
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
20.3k
      if (symname == NULL)
949
5.82k
  {
950
5.82k
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
5.82k
            abfd);
952
5.82k
    continue;
953
5.82k
  }
954
955
14.4k
      union internal_auxent aux;
956
957
14.4k
      struct comdat_hash_entry needle;
958
14.4k
      needle.target_index = isym.n_scnum;
959
960
14.4k
      void **slot
961
14.4k
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
14.4k
      if (slot == NULL)
963
0
  return false;
964
965
14.4k
      if (*slot == NULL)
966
8.97k
  {
967
8.97k
    if (isym.n_numaux == 0)
968
5.65k
      aux.x_scn.x_comdat = 0;
969
3.32k
    else
970
3.32k
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
3.32k
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
699
    {
974
      /* xgettext:c-format */
975
699
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
699
          " section '%s' found"),
977
699
              abfd, symname);
978
699
      continue;
979
699
    }
980
2.62k
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
2.62k
            isym.n_type, isym.n_sclass, 0,
982
2.62k
            isym.n_numaux, &aux);
983
2.62k
      }
984
985
    /* FIXME: Microsoft uses NODUPLICATES and ASSOCIATIVE, but
986
       gnu uses ANY and SAME_SIZE.  Unfortunately, gnu doesn't
987
       do the comdat symbols right.  So, until we can fix it to
988
       do the right thing, we are temporarily disabling comdats
989
       for the MS types (they're used in DLLs and C++, but we
990
       don't support *their* C++ libraries anyway - DJ.  */
991
992
    /* Cygwin does not follow the MS style, and uses ANY and
993
       SAME_SIZE where NODUPLICATES and ASSOCIATIVE should be
994
       used.  For Interix, we just do the right thing up
995
       front.  */
996
997
8.27k
    switch (aux.x_scn.x_comdat)
998
8.27k
      {
999
7
      case IMAGE_COMDAT_SELECT_NODUPLICATES:
1000
#ifdef STRICT_PE_FORMAT
1001
        sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY;
1002
#else
1003
7
        sec_flags &= ~SEC_LINK_ONCE;
1004
7
#endif
1005
7
        break;
1006
1007
0
      case IMAGE_COMDAT_SELECT_ANY:
1008
0
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1009
0
        break;
1010
1011
8
      case IMAGE_COMDAT_SELECT_SAME_SIZE:
1012
8
        sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE;
1013
8
        break;
1014
1015
5
      case IMAGE_COMDAT_SELECT_EXACT_MATCH:
1016
        /* Not yet fully implemented ??? */
1017
5
        sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS;
1018
5
        break;
1019
1020
        /* debug$S gets this case; other implications ???  */
1021
1022
        /* There may be no symbol.  We'll search the whole
1023
     table.  Is this the right place to play this game?
1024
     Or should we do it when reading it in?  */
1025
0
      case IMAGE_COMDAT_SELECT_ASSOCIATIVE:
1026
#ifdef STRICT_PE_FORMAT
1027
        /* FIXME: This is not currently implemented.  */
1028
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1029
#else
1030
0
        sec_flags &= ~SEC_LINK_ONCE;
1031
0
#endif
1032
0
        break;
1033
1034
8.25k
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
8.25k
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
8.25k
        break;
1038
8.27k
      }
1039
1040
8.27k
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
8.27k
    if (*slot == NULL)
1042
0
      return false;
1043
8.27k
    struct comdat_hash_entry *newentry = *slot;
1044
8.27k
    newentry->sec_flags = sec_flags;
1045
8.27k
    newentry->symname = bfd_strdup (symname);
1046
8.27k
    newentry->target_index = isym.n_scnum;
1047
8.27k
    newentry->isym = isym;
1048
8.27k
    newentry->comdat_symbol = -1;
1049
8.27k
  }
1050
5.51k
      else
1051
5.51k
  {
1052
5.51k
    struct comdat_hash_entry *entry = *slot;
1053
1054
5.51k
    if (entry->comdat_symbol != -1)
1055
3.88k
      continue;
1056
1057
1.62k
    char *target_name = strchr (entry->symname, '$');
1058
1.62k
    if (target_name != NULL)
1059
87
      {
1060
        /* Gas mode: the first matching on partial name.  */
1061
1062
87
        target_name += 1;
1063
#ifndef TARGET_UNDERSCORE
1064
#define TARGET_UNDERSCORE 0
1065
#endif
1066
        /* Is this the name we're looking for ?  */
1067
87
        if (strcmp (target_name,
1068
87
        symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0)
1069
86
    {
1070
      /* Not the name we're looking for */
1071
86
      continue;
1072
86
    }
1073
87
      }
1074
    /* MSVC mode: the lexically second symbol (or drop through
1075
       from the above).  */
1076
    /* This must the second symbol with the section #.  It is
1077
       the actual symbol name.  Intel puts the two adjacent, but
1078
       Alpha (at least) spreads them out.  */
1079
1080
1.54k
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
1.54k
    entry->comdat_name = bfd_strdup (symname);
1082
1.54k
  }
1083
14.4k
    }
1084
1085
1.88k
  return true;
1086
1.88k
}
pei-loongarch64.c:fill_comdat_hash
Line
Count
Source
890
2.99k
{
891
2.99k
  bfd_byte *esymstart, *esym, *esymend;
892
893
  /* Unfortunately, the PE format stores essential information in the
894
     symbol table, of all places.  We need to extract that information
895
     now, so that objdump and the linker will know how to handle the
896
     section without worrying about the symbols.  We can't call
897
     slurp_symtab, because the linker doesn't want the swapped symbols.  */
898
899
  /* COMDAT sections are special.  The first symbol is the section
900
     symbol, which tells what kind of COMDAT section it is.  The
901
     second symbol is the "comdat symbol" - the one with the unique
902
     name.  GNU uses the section symbol for the unique name; MS uses
903
     ".text" for every comdat section.  Sigh.  - DJ.  */
904
905
  /* This is not mirrored in sec_to_styp_flags(), but there doesn't
906
     seem to be a need to, either, and it would at best be rather messy.  */
907
908
2.99k
  if (! _bfd_coff_get_external_symbols (abfd))
909
1.03k
    return true;
910
911
1.95k
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
1.95k
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
1.95k
  for (struct internal_syment isym;
915
12.1k
       esym < esymend;
916
10.1k
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
10.1k
    {
918
10.1k
      char buf[SYMNMLEN + 1];
919
10.1k
      const char *symname;
920
10.1k
      flagword sec_flags = SEC_LINK_ONCE;
921
922
10.1k
      bfd_coff_swap_sym_in (abfd, esym, &isym);
923
924
      /* According to the MSVC documentation, the first TWO entries
925
   with the section # are both of interest to us.  The first one
926
   is the "section symbol" (section name).  The second is the
927
   comdat symbol name.  Here, we've found the first qualifying
928
   entry; we distinguish it from the second with a state flag.
929
930
   In the case of gas-generated (at least until that is fixed)
931
   .o files, it isn't necessarily the second one.  It may be
932
   some other later symbol.
933
934
   Since gas also doesn't follow MS conventions and emits the
935
   section similar to .text$<name>, where <something> is the
936
   name we're looking for, we distinguish the two as follows:
937
938
   If the section name is simply a section name (no $) we
939
   presume it's MS-generated, and look at precisely the second
940
   symbol for the comdat name.  If the section name has a $, we
941
   assume it's gas-generated, and look for <something> (whatever
942
   follows the $) as the comdat symbol.  */
943
944
      /* All 3 branches use this.  */
945
10.1k
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
10.1k
      if (symname == NULL)
949
2.73k
  {
950
2.73k
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
2.73k
            abfd);
952
2.73k
    continue;
953
2.73k
  }
954
955
7.43k
      union internal_auxent aux;
956
957
7.43k
      struct comdat_hash_entry needle;
958
7.43k
      needle.target_index = isym.n_scnum;
959
960
7.43k
      void **slot
961
7.43k
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
7.43k
      if (slot == NULL)
963
0
  return false;
964
965
7.43k
      if (*slot == NULL)
966
5.32k
  {
967
5.32k
    if (isym.n_numaux == 0)
968
3.14k
      aux.x_scn.x_comdat = 0;
969
2.18k
    else
970
2.18k
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
2.18k
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
818
    {
974
      /* xgettext:c-format */
975
818
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
818
          " section '%s' found"),
977
818
              abfd, symname);
978
818
      continue;
979
818
    }
980
1.37k
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
1.37k
            isym.n_type, isym.n_sclass, 0,
982
1.37k
            isym.n_numaux, &aux);
983
1.37k
      }
984
985
    /* FIXME: Microsoft uses NODUPLICATES and ASSOCIATIVE, but
986
       gnu uses ANY and SAME_SIZE.  Unfortunately, gnu doesn't
987
       do the comdat symbols right.  So, until we can fix it to
988
       do the right thing, we are temporarily disabling comdats
989
       for the MS types (they're used in DLLs and C++, but we
990
       don't support *their* C++ libraries anyway - DJ.  */
991
992
    /* Cygwin does not follow the MS style, and uses ANY and
993
       SAME_SIZE where NODUPLICATES and ASSOCIATIVE should be
994
       used.  For Interix, we just do the right thing up
995
       front.  */
996
997
4.51k
    switch (aux.x_scn.x_comdat)
998
4.51k
      {
999
0
      case IMAGE_COMDAT_SELECT_NODUPLICATES:
1000
#ifdef STRICT_PE_FORMAT
1001
        sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY;
1002
#else
1003
0
        sec_flags &= ~SEC_LINK_ONCE;
1004
0
#endif
1005
0
        break;
1006
1007
0
      case IMAGE_COMDAT_SELECT_ANY:
1008
0
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1009
0
        break;
1010
1011
0
      case IMAGE_COMDAT_SELECT_SAME_SIZE:
1012
0
        sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE;
1013
0
        break;
1014
1015
3
      case IMAGE_COMDAT_SELECT_EXACT_MATCH:
1016
        /* Not yet fully implemented ??? */
1017
3
        sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS;
1018
3
        break;
1019
1020
        /* debug$S gets this case; other implications ???  */
1021
1022
        /* There may be no symbol.  We'll search the whole
1023
     table.  Is this the right place to play this game?
1024
     Or should we do it when reading it in?  */
1025
0
      case IMAGE_COMDAT_SELECT_ASSOCIATIVE:
1026
#ifdef STRICT_PE_FORMAT
1027
        /* FIXME: This is not currently implemented.  */
1028
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1029
#else
1030
0
        sec_flags &= ~SEC_LINK_ONCE;
1031
0
#endif
1032
0
        break;
1033
1034
4.50k
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
4.50k
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
4.50k
        break;
1038
4.51k
      }
1039
1040
4.51k
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
4.51k
    if (*slot == NULL)
1042
0
      return false;
1043
4.51k
    struct comdat_hash_entry *newentry = *slot;
1044
4.51k
    newentry->sec_flags = sec_flags;
1045
4.51k
    newentry->symname = bfd_strdup (symname);
1046
4.51k
    newentry->target_index = isym.n_scnum;
1047
4.51k
    newentry->isym = isym;
1048
4.51k
    newentry->comdat_symbol = -1;
1049
4.51k
  }
1050
2.10k
      else
1051
2.10k
  {
1052
2.10k
    struct comdat_hash_entry *entry = *slot;
1053
1054
2.10k
    if (entry->comdat_symbol != -1)
1055
1.51k
      continue;
1056
1057
587
    char *target_name = strchr (entry->symname, '$');
1058
587
    if (target_name != NULL)
1059
1
      {
1060
        /* Gas mode: the first matching on partial name.  */
1061
1062
1
        target_name += 1;
1063
1
#ifndef TARGET_UNDERSCORE
1064
1
#define TARGET_UNDERSCORE 0
1065
1
#endif
1066
        /* Is this the name we're looking for ?  */
1067
1
        if (strcmp (target_name,
1068
1
        symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0)
1069
1
    {
1070
      /* Not the name we're looking for */
1071
1
      continue;
1072
1
    }
1073
1
      }
1074
    /* MSVC mode: the lexically second symbol (or drop through
1075
       from the above).  */
1076
    /* This must the second symbol with the section #.  It is
1077
       the actual symbol name.  Intel puts the two adjacent, but
1078
       Alpha (at least) spreads them out.  */
1079
1080
586
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
586
    entry->comdat_name = bfd_strdup (symname);
1082
586
  }
1083
7.43k
    }
1084
1085
1.95k
  return true;
1086
1.95k
}
pe-arm-wince.c:fill_comdat_hash
Line
Count
Source
890
1.57k
{
891
1.57k
  bfd_byte *esymstart, *esym, *esymend;
892
893
  /* Unfortunately, the PE format stores essential information in the
894
     symbol table, of all places.  We need to extract that information
895
     now, so that objdump and the linker will know how to handle the
896
     section without worrying about the symbols.  We can't call
897
     slurp_symtab, because the linker doesn't want the swapped symbols.  */
898
899
  /* COMDAT sections are special.  The first symbol is the section
900
     symbol, which tells what kind of COMDAT section it is.  The
901
     second symbol is the "comdat symbol" - the one with the unique
902
     name.  GNU uses the section symbol for the unique name; MS uses
903
     ".text" for every comdat section.  Sigh.  - DJ.  */
904
905
  /* This is not mirrored in sec_to_styp_flags(), but there doesn't
906
     seem to be a need to, either, and it would at best be rather messy.  */
907
908
1.57k
  if (! _bfd_coff_get_external_symbols (abfd))
909
368
    return true;
910
911
1.20k
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
1.20k
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
1.20k
  for (struct internal_syment isym;
915
8.03k
       esym < esymend;
916
6.82k
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
6.82k
    {
918
6.82k
      char buf[SYMNMLEN + 1];
919
6.82k
      const char *symname;
920
6.82k
      flagword sec_flags = SEC_LINK_ONCE;
921
922
6.82k
      bfd_coff_swap_sym_in (abfd, esym, &isym);
923
924
      /* According to the MSVC documentation, the first TWO entries
925
   with the section # are both of interest to us.  The first one
926
   is the "section symbol" (section name).  The second is the
927
   comdat symbol name.  Here, we've found the first qualifying
928
   entry; we distinguish it from the second with a state flag.
929
930
   In the case of gas-generated (at least until that is fixed)
931
   .o files, it isn't necessarily the second one.  It may be
932
   some other later symbol.
933
934
   Since gas also doesn't follow MS conventions and emits the
935
   section similar to .text$<name>, where <something> is the
936
   name we're looking for, we distinguish the two as follows:
937
938
   If the section name is simply a section name (no $) we
939
   presume it's MS-generated, and look at precisely the second
940
   symbol for the comdat name.  If the section name has a $, we
941
   assume it's gas-generated, and look for <something> (whatever
942
   follows the $) as the comdat symbol.  */
943
944
      /* All 3 branches use this.  */
945
6.82k
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
6.82k
      if (symname == NULL)
949
827
  {
950
827
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
827
            abfd);
952
827
    continue;
953
827
  }
954
955
6.00k
      union internal_auxent aux;
956
957
6.00k
      struct comdat_hash_entry needle;
958
6.00k
      needle.target_index = isym.n_scnum;
959
960
6.00k
      void **slot
961
6.00k
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
6.00k
      if (slot == NULL)
963
0
  return false;
964
965
6.00k
      if (*slot == NULL)
966
2.74k
  {
967
2.74k
    if (isym.n_numaux == 0)
968
1.12k
      aux.x_scn.x_comdat = 0;
969
1.62k
    else
970
1.62k
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
1.62k
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
634
    {
974
      /* xgettext:c-format */
975
634
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
634
          " section '%s' found"),
977
634
              abfd, symname);
978
634
      continue;
979
634
    }
980
986
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
986
            isym.n_type, isym.n_sclass, 0,
982
986
            isym.n_numaux, &aux);
983
986
      }
984
985
    /* FIXME: Microsoft uses NODUPLICATES and ASSOCIATIVE, but
986
       gnu uses ANY and SAME_SIZE.  Unfortunately, gnu doesn't
987
       do the comdat symbols right.  So, until we can fix it to
988
       do the right thing, we are temporarily disabling comdats
989
       for the MS types (they're used in DLLs and C++, but we
990
       don't support *their* C++ libraries anyway - DJ.  */
991
992
    /* Cygwin does not follow the MS style, and uses ANY and
993
       SAME_SIZE where NODUPLICATES and ASSOCIATIVE should be
994
       used.  For Interix, we just do the right thing up
995
       front.  */
996
997
2.11k
    switch (aux.x_scn.x_comdat)
998
2.11k
      {
999
9
      case IMAGE_COMDAT_SELECT_NODUPLICATES:
1000
#ifdef STRICT_PE_FORMAT
1001
        sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY;
1002
#else
1003
9
        sec_flags &= ~SEC_LINK_ONCE;
1004
9
#endif
1005
9
        break;
1006
1007
0
      case IMAGE_COMDAT_SELECT_ANY:
1008
0
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1009
0
        break;
1010
1011
0
      case IMAGE_COMDAT_SELECT_SAME_SIZE:
1012
0
        sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE;
1013
0
        break;
1014
1015
0
      case IMAGE_COMDAT_SELECT_EXACT_MATCH:
1016
        /* Not yet fully implemented ??? */
1017
0
        sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS;
1018
0
        break;
1019
1020
        /* debug$S gets this case; other implications ???  */
1021
1022
        /* There may be no symbol.  We'll search the whole
1023
     table.  Is this the right place to play this game?
1024
     Or should we do it when reading it in?  */
1025
0
      case IMAGE_COMDAT_SELECT_ASSOCIATIVE:
1026
#ifdef STRICT_PE_FORMAT
1027
        /* FIXME: This is not currently implemented.  */
1028
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1029
#else
1030
0
        sec_flags &= ~SEC_LINK_ONCE;
1031
0
#endif
1032
0
        break;
1033
1034
2.10k
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
2.10k
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
2.10k
        break;
1038
2.11k
      }
1039
1040
2.11k
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
2.11k
    if (*slot == NULL)
1042
0
      return false;
1043
2.11k
    struct comdat_hash_entry *newentry = *slot;
1044
2.11k
    newentry->sec_flags = sec_flags;
1045
2.11k
    newentry->symname = bfd_strdup (symname);
1046
2.11k
    newentry->target_index = isym.n_scnum;
1047
2.11k
    newentry->isym = isym;
1048
2.11k
    newentry->comdat_symbol = -1;
1049
2.11k
  }
1050
3.25k
      else
1051
3.25k
  {
1052
3.25k
    struct comdat_hash_entry *entry = *slot;
1053
1054
3.25k
    if (entry->comdat_symbol != -1)
1055
2.39k
      continue;
1056
1057
857
    char *target_name = strchr (entry->symname, '$');
1058
857
    if (target_name != NULL)
1059
0
      {
1060
        /* Gas mode: the first matching on partial name.  */
1061
1062
0
        target_name += 1;
1063
#ifndef TARGET_UNDERSCORE
1064
#define TARGET_UNDERSCORE 0
1065
#endif
1066
        /* Is this the name we're looking for ?  */
1067
0
        if (strcmp (target_name,
1068
0
        symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0)
1069
0
    {
1070
      /* Not the name we're looking for */
1071
0
      continue;
1072
0
    }
1073
0
      }
1074
    /* MSVC mode: the lexically second symbol (or drop through
1075
       from the above).  */
1076
    /* This must the second symbol with the section #.  It is
1077
       the actual symbol name.  Intel puts the two adjacent, but
1078
       Alpha (at least) spreads them out.  */
1079
1080
857
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
857
    entry->comdat_name = bfd_strdup (symname);
1082
857
  }
1083
6.00k
    }
1084
1085
1.20k
  return true;
1086
1.20k
}
pe-arm.c:fill_comdat_hash
Line
Count
Source
890
1.57k
{
891
1.57k
  bfd_byte *esymstart, *esym, *esymend;
892
893
  /* Unfortunately, the PE format stores essential information in the
894
     symbol table, of all places.  We need to extract that information
895
     now, so that objdump and the linker will know how to handle the
896
     section without worrying about the symbols.  We can't call
897
     slurp_symtab, because the linker doesn't want the swapped symbols.  */
898
899
  /* COMDAT sections are special.  The first symbol is the section
900
     symbol, which tells what kind of COMDAT section it is.  The
901
     second symbol is the "comdat symbol" - the one with the unique
902
     name.  GNU uses the section symbol for the unique name; MS uses
903
     ".text" for every comdat section.  Sigh.  - DJ.  */
904
905
  /* This is not mirrored in sec_to_styp_flags(), but there doesn't
906
     seem to be a need to, either, and it would at best be rather messy.  */
907
908
1.57k
  if (! _bfd_coff_get_external_symbols (abfd))
909
368
    return true;
910
911
1.20k
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
1.20k
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
1.20k
  for (struct internal_syment isym;
915
8.03k
       esym < esymend;
916
6.82k
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
6.82k
    {
918
6.82k
      char buf[SYMNMLEN + 1];
919
6.82k
      const char *symname;
920
6.82k
      flagword sec_flags = SEC_LINK_ONCE;
921
922
6.82k
      bfd_coff_swap_sym_in (abfd, esym, &isym);
923
924
      /* According to the MSVC documentation, the first TWO entries
925
   with the section # are both of interest to us.  The first one
926
   is the "section symbol" (section name).  The second is the
927
   comdat symbol name.  Here, we've found the first qualifying
928
   entry; we distinguish it from the second with a state flag.
929
930
   In the case of gas-generated (at least until that is fixed)
931
   .o files, it isn't necessarily the second one.  It may be
932
   some other later symbol.
933
934
   Since gas also doesn't follow MS conventions and emits the
935
   section similar to .text$<name>, where <something> is the
936
   name we're looking for, we distinguish the two as follows:
937
938
   If the section name is simply a section name (no $) we
939
   presume it's MS-generated, and look at precisely the second
940
   symbol for the comdat name.  If the section name has a $, we
941
   assume it's gas-generated, and look for <something> (whatever
942
   follows the $) as the comdat symbol.  */
943
944
      /* All 3 branches use this.  */
945
6.82k
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
6.82k
      if (symname == NULL)
949
827
  {
950
827
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
827
            abfd);
952
827
    continue;
953
827
  }
954
955
6.00k
      union internal_auxent aux;
956
957
6.00k
      struct comdat_hash_entry needle;
958
6.00k
      needle.target_index = isym.n_scnum;
959
960
6.00k
      void **slot
961
6.00k
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
6.00k
      if (slot == NULL)
963
0
  return false;
964
965
6.00k
      if (*slot == NULL)
966
2.74k
  {
967
2.74k
    if (isym.n_numaux == 0)
968
1.12k
      aux.x_scn.x_comdat = 0;
969
1.62k
    else
970
1.62k
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
1.62k
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
634
    {
974
      /* xgettext:c-format */
975
634
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
634
          " section '%s' found"),
977
634
              abfd, symname);
978
634
      continue;
979
634
    }
980
986
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
986
            isym.n_type, isym.n_sclass, 0,
982
986
            isym.n_numaux, &aux);
983
986
      }
984
985
    /* FIXME: Microsoft uses NODUPLICATES and ASSOCIATIVE, but
986
       gnu uses ANY and SAME_SIZE.  Unfortunately, gnu doesn't
987
       do the comdat symbols right.  So, until we can fix it to
988
       do the right thing, we are temporarily disabling comdats
989
       for the MS types (they're used in DLLs and C++, but we
990
       don't support *their* C++ libraries anyway - DJ.  */
991
992
    /* Cygwin does not follow the MS style, and uses ANY and
993
       SAME_SIZE where NODUPLICATES and ASSOCIATIVE should be
994
       used.  For Interix, we just do the right thing up
995
       front.  */
996
997
2.11k
    switch (aux.x_scn.x_comdat)
998
2.11k
      {
999
9
      case IMAGE_COMDAT_SELECT_NODUPLICATES:
1000
#ifdef STRICT_PE_FORMAT
1001
        sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY;
1002
#else
1003
9
        sec_flags &= ~SEC_LINK_ONCE;
1004
9
#endif
1005
9
        break;
1006
1007
0
      case IMAGE_COMDAT_SELECT_ANY:
1008
0
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1009
0
        break;
1010
1011
0
      case IMAGE_COMDAT_SELECT_SAME_SIZE:
1012
0
        sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE;
1013
0
        break;
1014
1015
0
      case IMAGE_COMDAT_SELECT_EXACT_MATCH:
1016
        /* Not yet fully implemented ??? */
1017
0
        sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS;
1018
0
        break;
1019
1020
        /* debug$S gets this case; other implications ???  */
1021
1022
        /* There may be no symbol.  We'll search the whole
1023
     table.  Is this the right place to play this game?
1024
     Or should we do it when reading it in?  */
1025
0
      case IMAGE_COMDAT_SELECT_ASSOCIATIVE:
1026
#ifdef STRICT_PE_FORMAT
1027
        /* FIXME: This is not currently implemented.  */
1028
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1029
#else
1030
0
        sec_flags &= ~SEC_LINK_ONCE;
1031
0
#endif
1032
0
        break;
1033
1034
2.10k
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
2.10k
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
2.10k
        break;
1038
2.11k
      }
1039
1040
2.11k
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
2.11k
    if (*slot == NULL)
1042
0
      return false;
1043
2.11k
    struct comdat_hash_entry *newentry = *slot;
1044
2.11k
    newentry->sec_flags = sec_flags;
1045
2.11k
    newentry->symname = bfd_strdup (symname);
1046
2.11k
    newentry->target_index = isym.n_scnum;
1047
2.11k
    newentry->isym = isym;
1048
2.11k
    newentry->comdat_symbol = -1;
1049
2.11k
  }
1050
3.25k
      else
1051
3.25k
  {
1052
3.25k
    struct comdat_hash_entry *entry = *slot;
1053
1054
3.25k
    if (entry->comdat_symbol != -1)
1055
2.39k
      continue;
1056
1057
857
    char *target_name = strchr (entry->symname, '$');
1058
857
    if (target_name != NULL)
1059
0
      {
1060
        /* Gas mode: the first matching on partial name.  */
1061
1062
0
        target_name += 1;
1063
#ifndef TARGET_UNDERSCORE
1064
#define TARGET_UNDERSCORE 0
1065
#endif
1066
        /* Is this the name we're looking for ?  */
1067
0
        if (strcmp (target_name,
1068
0
        symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0)
1069
0
    {
1070
      /* Not the name we're looking for */
1071
0
      continue;
1072
0
    }
1073
0
      }
1074
    /* MSVC mode: the lexically second symbol (or drop through
1075
       from the above).  */
1076
    /* This must the second symbol with the section #.  It is
1077
       the actual symbol name.  Intel puts the two adjacent, but
1078
       Alpha (at least) spreads them out.  */
1079
1080
857
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
857
    entry->comdat_name = bfd_strdup (symname);
1082
857
  }
1083
6.00k
    }
1084
1085
1.20k
  return true;
1086
1.20k
}
pe-i386.c:fill_comdat_hash
Line
Count
Source
890
5.34k
{
891
5.34k
  bfd_byte *esymstart, *esym, *esymend;
892
893
  /* Unfortunately, the PE format stores essential information in the
894
     symbol table, of all places.  We need to extract that information
895
     now, so that objdump and the linker will know how to handle the
896
     section without worrying about the symbols.  We can't call
897
     slurp_symtab, because the linker doesn't want the swapped symbols.  */
898
899
  /* COMDAT sections are special.  The first symbol is the section
900
     symbol, which tells what kind of COMDAT section it is.  The
901
     second symbol is the "comdat symbol" - the one with the unique
902
     name.  GNU uses the section symbol for the unique name; MS uses
903
     ".text" for every comdat section.  Sigh.  - DJ.  */
904
905
  /* This is not mirrored in sec_to_styp_flags(), but there doesn't
906
     seem to be a need to, either, and it would at best be rather messy.  */
907
908
5.34k
  if (! _bfd_coff_get_external_symbols (abfd))
909
2.51k
    return true;
910
911
2.83k
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
2.83k
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
2.83k
  for (struct internal_syment isym;
915
14.4k
       esym < esymend;
916
11.6k
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
11.6k
    {
918
11.6k
      char buf[SYMNMLEN + 1];
919
11.6k
      const char *symname;
920
11.6k
      flagword sec_flags = SEC_LINK_ONCE;
921
922
11.6k
      bfd_coff_swap_sym_in (abfd, esym, &isym);
923
924
      /* According to the MSVC documentation, the first TWO entries
925
   with the section # are both of interest to us.  The first one
926
   is the "section symbol" (section name).  The second is the
927
   comdat symbol name.  Here, we've found the first qualifying
928
   entry; we distinguish it from the second with a state flag.
929
930
   In the case of gas-generated (at least until that is fixed)
931
   .o files, it isn't necessarily the second one.  It may be
932
   some other later symbol.
933
934
   Since gas also doesn't follow MS conventions and emits the
935
   section similar to .text$<name>, where <something> is the
936
   name we're looking for, we distinguish the two as follows:
937
938
   If the section name is simply a section name (no $) we
939
   presume it's MS-generated, and look at precisely the second
940
   symbol for the comdat name.  If the section name has a $, we
941
   assume it's gas-generated, and look for <something> (whatever
942
   follows the $) as the comdat symbol.  */
943
944
      /* All 3 branches use this.  */
945
11.6k
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
11.6k
      if (symname == NULL)
949
4.63k
  {
950
4.63k
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
4.63k
            abfd);
952
4.63k
    continue;
953
4.63k
  }
954
955
6.99k
      union internal_auxent aux;
956
957
6.99k
      struct comdat_hash_entry needle;
958
6.99k
      needle.target_index = isym.n_scnum;
959
960
6.99k
      void **slot
961
6.99k
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
6.99k
      if (slot == NULL)
963
0
  return false;
964
965
6.99k
      if (*slot == NULL)
966
4.48k
  {
967
4.48k
    if (isym.n_numaux == 0)
968
2.72k
      aux.x_scn.x_comdat = 0;
969
1.76k
    else
970
1.76k
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
1.76k
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
739
    {
974
      /* xgettext:c-format */
975
739
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
739
          " section '%s' found"),
977
739
              abfd, symname);
978
739
      continue;
979
739
    }
980
1.02k
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
1.02k
            isym.n_type, isym.n_sclass, 0,
982
1.02k
            isym.n_numaux, &aux);
983
1.02k
      }
984
985
    /* FIXME: Microsoft uses NODUPLICATES and ASSOCIATIVE, but
986
       gnu uses ANY and SAME_SIZE.  Unfortunately, gnu doesn't
987
       do the comdat symbols right.  So, until we can fix it to
988
       do the right thing, we are temporarily disabling comdats
989
       for the MS types (they're used in DLLs and C++, but we
990
       don't support *their* C++ libraries anyway - DJ.  */
991
992
    /* Cygwin does not follow the MS style, and uses ANY and
993
       SAME_SIZE where NODUPLICATES and ASSOCIATIVE should be
994
       used.  For Interix, we just do the right thing up
995
       front.  */
996
997
3.75k
    switch (aux.x_scn.x_comdat)
998
3.75k
      {
999
8
      case IMAGE_COMDAT_SELECT_NODUPLICATES:
1000
#ifdef STRICT_PE_FORMAT
1001
        sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY;
1002
#else
1003
8
        sec_flags &= ~SEC_LINK_ONCE;
1004
8
#endif
1005
8
        break;
1006
1007
0
      case IMAGE_COMDAT_SELECT_ANY:
1008
0
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1009
0
        break;
1010
1011
0
      case IMAGE_COMDAT_SELECT_SAME_SIZE:
1012
0
        sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE;
1013
0
        break;
1014
1015
6
      case IMAGE_COMDAT_SELECT_EXACT_MATCH:
1016
        /* Not yet fully implemented ??? */
1017
6
        sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS;
1018
6
        break;
1019
1020
        /* debug$S gets this case; other implications ???  */
1021
1022
        /* There may be no symbol.  We'll search the whole
1023
     table.  Is this the right place to play this game?
1024
     Or should we do it when reading it in?  */
1025
0
      case IMAGE_COMDAT_SELECT_ASSOCIATIVE:
1026
#ifdef STRICT_PE_FORMAT
1027
        /* FIXME: This is not currently implemented.  */
1028
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1029
#else
1030
0
        sec_flags &= ~SEC_LINK_ONCE;
1031
0
#endif
1032
0
        break;
1033
1034
3.73k
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
3.73k
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
3.73k
        break;
1038
3.75k
      }
1039
1040
3.75k
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
3.75k
    if (*slot == NULL)
1042
0
      return false;
1043
3.75k
    struct comdat_hash_entry *newentry = *slot;
1044
3.75k
    newentry->sec_flags = sec_flags;
1045
3.75k
    newentry->symname = bfd_strdup (symname);
1046
3.75k
    newentry->target_index = isym.n_scnum;
1047
3.75k
    newentry->isym = isym;
1048
3.75k
    newentry->comdat_symbol = -1;
1049
3.75k
  }
1050
2.50k
      else
1051
2.50k
  {
1052
2.50k
    struct comdat_hash_entry *entry = *slot;
1053
1054
2.50k
    if (entry->comdat_symbol != -1)
1055
1.71k
      continue;
1056
1057
785
    char *target_name = strchr (entry->symname, '$');
1058
785
    if (target_name != NULL)
1059
0
      {
1060
        /* Gas mode: the first matching on partial name.  */
1061
1062
0
        target_name += 1;
1063
#ifndef TARGET_UNDERSCORE
1064
#define TARGET_UNDERSCORE 0
1065
#endif
1066
        /* Is this the name we're looking for ?  */
1067
0
        if (strcmp (target_name,
1068
0
        symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0)
1069
0
    {
1070
      /* Not the name we're looking for */
1071
0
      continue;
1072
0
    }
1073
0
      }
1074
    /* MSVC mode: the lexically second symbol (or drop through
1075
       from the above).  */
1076
    /* This must the second symbol with the section #.  It is
1077
       the actual symbol name.  Intel puts the two adjacent, but
1078
       Alpha (at least) spreads them out.  */
1079
1080
785
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
785
    entry->comdat_name = bfd_strdup (symname);
1082
785
  }
1083
6.99k
    }
1084
1085
2.83k
  return true;
1086
2.83k
}
pe-mcore.c:fill_comdat_hash
Line
Count
Source
890
1.96k
{
891
1.96k
  bfd_byte *esymstart, *esym, *esymend;
892
893
  /* Unfortunately, the PE format stores essential information in the
894
     symbol table, of all places.  We need to extract that information
895
     now, so that objdump and the linker will know how to handle the
896
     section without worrying about the symbols.  We can't call
897
     slurp_symtab, because the linker doesn't want the swapped symbols.  */
898
899
  /* COMDAT sections are special.  The first symbol is the section
900
     symbol, which tells what kind of COMDAT section it is.  The
901
     second symbol is the "comdat symbol" - the one with the unique
902
     name.  GNU uses the section symbol for the unique name; MS uses
903
     ".text" for every comdat section.  Sigh.  - DJ.  */
904
905
  /* This is not mirrored in sec_to_styp_flags(), but there doesn't
906
     seem to be a need to, either, and it would at best be rather messy.  */
907
908
1.96k
  if (! _bfd_coff_get_external_symbols (abfd))
909
570
    return true;
910
911
1.39k
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
1.39k
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
1.39k
  for (struct internal_syment isym;
915
24.7k
       esym < esymend;
916
23.3k
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
23.3k
    {
918
23.3k
      char buf[SYMNMLEN + 1];
919
23.3k
      const char *symname;
920
23.3k
      flagword sec_flags = SEC_LINK_ONCE;
921
922
23.3k
      bfd_coff_swap_sym_in (abfd, esym, &isym);
923
924
      /* According to the MSVC documentation, the first TWO entries
925
   with the section # are both of interest to us.  The first one
926
   is the "section symbol" (section name).  The second is the
927
   comdat symbol name.  Here, we've found the first qualifying
928
   entry; we distinguish it from the second with a state flag.
929
930
   In the case of gas-generated (at least until that is fixed)
931
   .o files, it isn't necessarily the second one.  It may be
932
   some other later symbol.
933
934
   Since gas also doesn't follow MS conventions and emits the
935
   section similar to .text$<name>, where <something> is the
936
   name we're looking for, we distinguish the two as follows:
937
938
   If the section name is simply a section name (no $) we
939
   presume it's MS-generated, and look at precisely the second
940
   symbol for the comdat name.  If the section name has a $, we
941
   assume it's gas-generated, and look for <something> (whatever
942
   follows the $) as the comdat symbol.  */
943
944
      /* All 3 branches use this.  */
945
23.3k
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
23.3k
      if (symname == NULL)
949
9.28k
  {
950
9.28k
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
9.28k
            abfd);
952
9.28k
    continue;
953
9.28k
  }
954
955
14.0k
      union internal_auxent aux;
956
957
14.0k
      struct comdat_hash_entry needle;
958
14.0k
      needle.target_index = isym.n_scnum;
959
960
14.0k
      void **slot
961
14.0k
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
14.0k
      if (slot == NULL)
963
0
  return false;
964
965
14.0k
      if (*slot == NULL)
966
3.99k
  {
967
3.99k
    if (isym.n_numaux == 0)
968
1.26k
      aux.x_scn.x_comdat = 0;
969
2.72k
    else
970
2.72k
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
2.72k
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
813
    {
974
      /* xgettext:c-format */
975
813
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
813
          " section '%s' found"),
977
813
              abfd, symname);
978
813
      continue;
979
813
    }
980
1.91k
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
1.91k
            isym.n_type, isym.n_sclass, 0,
982
1.91k
            isym.n_numaux, &aux);
983
1.91k
      }
984
985
    /* FIXME: Microsoft uses NODUPLICATES and ASSOCIATIVE, but
986
       gnu uses ANY and SAME_SIZE.  Unfortunately, gnu doesn't
987
       do the comdat symbols right.  So, until we can fix it to
988
       do the right thing, we are temporarily disabling comdats
989
       for the MS types (they're used in DLLs and C++, but we
990
       don't support *their* C++ libraries anyway - DJ.  */
991
992
    /* Cygwin does not follow the MS style, and uses ANY and
993
       SAME_SIZE where NODUPLICATES and ASSOCIATIVE should be
994
       used.  For Interix, we just do the right thing up
995
       front.  */
996
997
3.18k
    switch (aux.x_scn.x_comdat)
998
3.18k
      {
999
3
      case IMAGE_COMDAT_SELECT_NODUPLICATES:
1000
#ifdef STRICT_PE_FORMAT
1001
        sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY;
1002
#else
1003
3
        sec_flags &= ~SEC_LINK_ONCE;
1004
3
#endif
1005
3
        break;
1006
1007
0
      case IMAGE_COMDAT_SELECT_ANY:
1008
0
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1009
0
        break;
1010
1011
0
      case IMAGE_COMDAT_SELECT_SAME_SIZE:
1012
0
        sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE;
1013
0
        break;
1014
1015
0
      case IMAGE_COMDAT_SELECT_EXACT_MATCH:
1016
        /* Not yet fully implemented ??? */
1017
0
        sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS;
1018
0
        break;
1019
1020
        /* debug$S gets this case; other implications ???  */
1021
1022
        /* There may be no symbol.  We'll search the whole
1023
     table.  Is this the right place to play this game?
1024
     Or should we do it when reading it in?  */
1025
0
      case IMAGE_COMDAT_SELECT_ASSOCIATIVE:
1026
#ifdef STRICT_PE_FORMAT
1027
        /* FIXME: This is not currently implemented.  */
1028
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1029
#else
1030
0
        sec_flags &= ~SEC_LINK_ONCE;
1031
0
#endif
1032
0
        break;
1033
1034
3.17k
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
3.17k
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
3.17k
        break;
1038
3.18k
      }
1039
1040
3.18k
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
3.18k
    if (*slot == NULL)
1042
0
      return false;
1043
3.18k
    struct comdat_hash_entry *newentry = *slot;
1044
3.18k
    newentry->sec_flags = sec_flags;
1045
3.18k
    newentry->symname = bfd_strdup (symname);
1046
3.18k
    newentry->target_index = isym.n_scnum;
1047
3.18k
    newentry->isym = isym;
1048
3.18k
    newentry->comdat_symbol = -1;
1049
3.18k
  }
1050
10.0k
      else
1051
10.0k
  {
1052
10.0k
    struct comdat_hash_entry *entry = *slot;
1053
1054
10.0k
    if (entry->comdat_symbol != -1)
1055
9.30k
      continue;
1056
1057
724
    char *target_name = strchr (entry->symname, '$');
1058
724
    if (target_name != NULL)
1059
19
      {
1060
        /* Gas mode: the first matching on partial name.  */
1061
1062
19
        target_name += 1;
1063
19
#ifndef TARGET_UNDERSCORE
1064
19
#define TARGET_UNDERSCORE 0
1065
19
#endif
1066
        /* Is this the name we're looking for ?  */
1067
19
        if (strcmp (target_name,
1068
19
        symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0)
1069
19
    {
1070
      /* Not the name we're looking for */
1071
19
      continue;
1072
19
    }
1073
19
      }
1074
    /* MSVC mode: the lexically second symbol (or drop through
1075
       from the above).  */
1076
    /* This must the second symbol with the section #.  It is
1077
       the actual symbol name.  Intel puts the two adjacent, but
1078
       Alpha (at least) spreads them out.  */
1079
1080
705
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
705
    entry->comdat_name = bfd_strdup (symname);
1082
705
  }
1083
14.0k
    }
1084
1085
1.39k
  return true;
1086
1.39k
}
pe-sh.c:fill_comdat_hash
Line
Count
Source
890
6.23k
{
891
6.23k
  bfd_byte *esymstart, *esym, *esymend;
892
893
  /* Unfortunately, the PE format stores essential information in the
894
     symbol table, of all places.  We need to extract that information
895
     now, so that objdump and the linker will know how to handle the
896
     section without worrying about the symbols.  We can't call
897
     slurp_symtab, because the linker doesn't want the swapped symbols.  */
898
899
  /* COMDAT sections are special.  The first symbol is the section
900
     symbol, which tells what kind of COMDAT section it is.  The
901
     second symbol is the "comdat symbol" - the one with the unique
902
     name.  GNU uses the section symbol for the unique name; MS uses
903
     ".text" for every comdat section.  Sigh.  - DJ.  */
904
905
  /* This is not mirrored in sec_to_styp_flags(), but there doesn't
906
     seem to be a need to, either, and it would at best be rather messy.  */
907
908
6.23k
  if (! _bfd_coff_get_external_symbols (abfd))
909
3.35k
    return true;
910
911
2.87k
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
2.87k
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
2.87k
  for (struct internal_syment isym;
915
224k
       esym < esymend;
916
221k
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
221k
    {
918
221k
      char buf[SYMNMLEN + 1];
919
221k
      const char *symname;
920
221k
      flagword sec_flags = SEC_LINK_ONCE;
921
922
221k
      bfd_coff_swap_sym_in (abfd, esym, &isym);
923
924
      /* According to the MSVC documentation, the first TWO entries
925
   with the section # are both of interest to us.  The first one
926
   is the "section symbol" (section name).  The second is the
927
   comdat symbol name.  Here, we've found the first qualifying
928
   entry; we distinguish it from the second with a state flag.
929
930
   In the case of gas-generated (at least until that is fixed)
931
   .o files, it isn't necessarily the second one.  It may be
932
   some other later symbol.
933
934
   Since gas also doesn't follow MS conventions and emits the
935
   section similar to .text$<name>, where <something> is the
936
   name we're looking for, we distinguish the two as follows:
937
938
   If the section name is simply a section name (no $) we
939
   presume it's MS-generated, and look at precisely the second
940
   symbol for the comdat name.  If the section name has a $, we
941
   assume it's gas-generated, and look for <something> (whatever
942
   follows the $) as the comdat symbol.  */
943
944
      /* All 3 branches use this.  */
945
221k
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
221k
      if (symname == NULL)
949
92.4k
  {
950
92.4k
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
92.4k
            abfd);
952
92.4k
    continue;
953
92.4k
  }
954
955
128k
      union internal_auxent aux;
956
957
128k
      struct comdat_hash_entry needle;
958
128k
      needle.target_index = isym.n_scnum;
959
960
128k
      void **slot
961
128k
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
128k
      if (slot == NULL)
963
0
  return false;
964
965
128k
      if (*slot == NULL)
966
26.5k
  {
967
26.5k
    if (isym.n_numaux == 0)
968
16.3k
      aux.x_scn.x_comdat = 0;
969
10.1k
    else
970
10.1k
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
10.1k
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
771
    {
974
      /* xgettext:c-format */
975
771
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
771
          " section '%s' found"),
977
771
              abfd, symname);
978
771
      continue;
979
771
    }
980
9.42k
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
9.42k
            isym.n_type, isym.n_sclass, 0,
982
9.42k
            isym.n_numaux, &aux);
983
9.42k
      }
984
985
    /* FIXME: Microsoft uses NODUPLICATES and ASSOCIATIVE, but
986
       gnu uses ANY and SAME_SIZE.  Unfortunately, gnu doesn't
987
       do the comdat symbols right.  So, until we can fix it to
988
       do the right thing, we are temporarily disabling comdats
989
       for the MS types (they're used in DLLs and C++, but we
990
       don't support *their* C++ libraries anyway - DJ.  */
991
992
    /* Cygwin does not follow the MS style, and uses ANY and
993
       SAME_SIZE where NODUPLICATES and ASSOCIATIVE should be
994
       used.  For Interix, we just do the right thing up
995
       front.  */
996
997
25.8k
    switch (aux.x_scn.x_comdat)
998
25.8k
      {
999
204
      case IMAGE_COMDAT_SELECT_NODUPLICATES:
1000
#ifdef STRICT_PE_FORMAT
1001
        sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY;
1002
#else
1003
204
        sec_flags &= ~SEC_LINK_ONCE;
1004
204
#endif
1005
204
        break;
1006
1007
1
      case IMAGE_COMDAT_SELECT_ANY:
1008
1
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1009
1
        break;
1010
1011
0
      case IMAGE_COMDAT_SELECT_SAME_SIZE:
1012
0
        sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE;
1013
0
        break;
1014
1015
1
      case IMAGE_COMDAT_SELECT_EXACT_MATCH:
1016
        /* Not yet fully implemented ??? */
1017
1
        sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS;
1018
1
        break;
1019
1020
        /* debug$S gets this case; other implications ???  */
1021
1022
        /* There may be no symbol.  We'll search the whole
1023
     table.  Is this the right place to play this game?
1024
     Or should we do it when reading it in?  */
1025
0
      case IMAGE_COMDAT_SELECT_ASSOCIATIVE:
1026
#ifdef STRICT_PE_FORMAT
1027
        /* FIXME: This is not currently implemented.  */
1028
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1029
#else
1030
0
        sec_flags &= ~SEC_LINK_ONCE;
1031
0
#endif
1032
0
        break;
1033
1034
25.6k
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
25.6k
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
25.6k
        break;
1038
25.8k
      }
1039
1040
25.8k
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
25.8k
    if (*slot == NULL)
1042
0
      return false;
1043
25.8k
    struct comdat_hash_entry *newentry = *slot;
1044
25.8k
    newentry->sec_flags = sec_flags;
1045
25.8k
    newentry->symname = bfd_strdup (symname);
1046
25.8k
    newentry->target_index = isym.n_scnum;
1047
25.8k
    newentry->isym = isym;
1048
25.8k
    newentry->comdat_symbol = -1;
1049
25.8k
  }
1050
102k
      else
1051
102k
  {
1052
102k
    struct comdat_hash_entry *entry = *slot;
1053
1054
102k
    if (entry->comdat_symbol != -1)
1055
92.7k
      continue;
1056
1057
9.33k
    char *target_name = strchr (entry->symname, '$');
1058
9.33k
    if (target_name != NULL)
1059
140
      {
1060
        /* Gas mode: the first matching on partial name.  */
1061
1062
140
        target_name += 1;
1063
#ifndef TARGET_UNDERSCORE
1064
#define TARGET_UNDERSCORE 0
1065
#endif
1066
        /* Is this the name we're looking for ?  */
1067
140
        if (strcmp (target_name,
1068
140
        symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0)
1069
138
    {
1070
      /* Not the name we're looking for */
1071
138
      continue;
1072
138
    }
1073
140
      }
1074
    /* MSVC mode: the lexically second symbol (or drop through
1075
       from the above).  */
1076
    /* This must the second symbol with the section #.  It is
1077
       the actual symbol name.  Intel puts the two adjacent, but
1078
       Alpha (at least) spreads them out.  */
1079
1080
9.19k
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
9.19k
    entry->comdat_name = bfd_strdup (symname);
1082
9.19k
  }
1083
128k
    }
1084
1085
2.87k
  return true;
1086
2.87k
}
pei-arm-wince.c:fill_comdat_hash
Line
Count
Source
890
4.69k
{
891
4.69k
  bfd_byte *esymstart, *esym, *esymend;
892
893
  /* Unfortunately, the PE format stores essential information in the
894
     symbol table, of all places.  We need to extract that information
895
     now, so that objdump and the linker will know how to handle the
896
     section without worrying about the symbols.  We can't call
897
     slurp_symtab, because the linker doesn't want the swapped symbols.  */
898
899
  /* COMDAT sections are special.  The first symbol is the section
900
     symbol, which tells what kind of COMDAT section it is.  The
901
     second symbol is the "comdat symbol" - the one with the unique
902
     name.  GNU uses the section symbol for the unique name; MS uses
903
     ".text" for every comdat section.  Sigh.  - DJ.  */
904
905
  /* This is not mirrored in sec_to_styp_flags(), but there doesn't
906
     seem to be a need to, either, and it would at best be rather messy.  */
907
908
4.69k
  if (! _bfd_coff_get_external_symbols (abfd))
909
2.39k
    return true;
910
911
2.29k
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
2.29k
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
2.29k
  for (struct internal_syment isym;
915
18.4k
       esym < esymend;
916
16.1k
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
16.1k
    {
918
16.1k
      char buf[SYMNMLEN + 1];
919
16.1k
      const char *symname;
920
16.1k
      flagword sec_flags = SEC_LINK_ONCE;
921
922
16.1k
      bfd_coff_swap_sym_in (abfd, esym, &isym);
923
924
      /* According to the MSVC documentation, the first TWO entries
925
   with the section # are both of interest to us.  The first one
926
   is the "section symbol" (section name).  The second is the
927
   comdat symbol name.  Here, we've found the first qualifying
928
   entry; we distinguish it from the second with a state flag.
929
930
   In the case of gas-generated (at least until that is fixed)
931
   .o files, it isn't necessarily the second one.  It may be
932
   some other later symbol.
933
934
   Since gas also doesn't follow MS conventions and emits the
935
   section similar to .text$<name>, where <something> is the
936
   name we're looking for, we distinguish the two as follows:
937
938
   If the section name is simply a section name (no $) we
939
   presume it's MS-generated, and look at precisely the second
940
   symbol for the comdat name.  If the section name has a $, we
941
   assume it's gas-generated, and look for <something> (whatever
942
   follows the $) as the comdat symbol.  */
943
944
      /* All 3 branches use this.  */
945
16.1k
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
16.1k
      if (symname == NULL)
949
5.79k
  {
950
5.79k
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
5.79k
            abfd);
952
5.79k
    continue;
953
5.79k
  }
954
955
10.3k
      union internal_auxent aux;
956
957
10.3k
      struct comdat_hash_entry needle;
958
10.3k
      needle.target_index = isym.n_scnum;
959
960
10.3k
      void **slot
961
10.3k
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
10.3k
      if (slot == NULL)
963
0
  return false;
964
965
10.3k
      if (*slot == NULL)
966
5.03k
  {
967
5.03k
    if (isym.n_numaux == 0)
968
2.61k
      aux.x_scn.x_comdat = 0;
969
2.42k
    else
970
2.42k
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
2.42k
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
352
    {
974
      /* xgettext:c-format */
975
352
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
352
          " section '%s' found"),
977
352
              abfd, symname);
978
352
      continue;
979
352
    }
980
2.06k
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
2.06k
            isym.n_type, isym.n_sclass, 0,
982
2.06k
            isym.n_numaux, &aux);
983
2.06k
      }
984
985
    /* FIXME: Microsoft uses NODUPLICATES and ASSOCIATIVE, but
986
       gnu uses ANY and SAME_SIZE.  Unfortunately, gnu doesn't
987
       do the comdat symbols right.  So, until we can fix it to
988
       do the right thing, we are temporarily disabling comdats
989
       for the MS types (they're used in DLLs and C++, but we
990
       don't support *their* C++ libraries anyway - DJ.  */
991
992
    /* Cygwin does not follow the MS style, and uses ANY and
993
       SAME_SIZE where NODUPLICATES and ASSOCIATIVE should be
994
       used.  For Interix, we just do the right thing up
995
       front.  */
996
997
4.68k
    switch (aux.x_scn.x_comdat)
998
4.68k
      {
999
18
      case IMAGE_COMDAT_SELECT_NODUPLICATES:
1000
#ifdef STRICT_PE_FORMAT
1001
        sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY;
1002
#else
1003
18
        sec_flags &= ~SEC_LINK_ONCE;
1004
18
#endif
1005
18
        break;
1006
1007
0
      case IMAGE_COMDAT_SELECT_ANY:
1008
0
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1009
0
        break;
1010
1011
0
      case IMAGE_COMDAT_SELECT_SAME_SIZE:
1012
0
        sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE;
1013
0
        break;
1014
1015
0
      case IMAGE_COMDAT_SELECT_EXACT_MATCH:
1016
        /* Not yet fully implemented ??? */
1017
0
        sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS;
1018
0
        break;
1019
1020
        /* debug$S gets this case; other implications ???  */
1021
1022
        /* There may be no symbol.  We'll search the whole
1023
     table.  Is this the right place to play this game?
1024
     Or should we do it when reading it in?  */
1025
0
      case IMAGE_COMDAT_SELECT_ASSOCIATIVE:
1026
#ifdef STRICT_PE_FORMAT
1027
        /* FIXME: This is not currently implemented.  */
1028
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1029
#else
1030
0
        sec_flags &= ~SEC_LINK_ONCE;
1031
0
#endif
1032
0
        break;
1033
1034
4.66k
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
4.66k
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
4.66k
        break;
1038
4.68k
      }
1039
1040
4.68k
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
4.68k
    if (*slot == NULL)
1042
0
      return false;
1043
4.68k
    struct comdat_hash_entry *newentry = *slot;
1044
4.68k
    newentry->sec_flags = sec_flags;
1045
4.68k
    newentry->symname = bfd_strdup (symname);
1046
4.68k
    newentry->target_index = isym.n_scnum;
1047
4.68k
    newentry->isym = isym;
1048
4.68k
    newentry->comdat_symbol = -1;
1049
4.68k
  }
1050
5.31k
      else
1051
5.31k
  {
1052
5.31k
    struct comdat_hash_entry *entry = *slot;
1053
1054
5.31k
    if (entry->comdat_symbol != -1)
1055
3.67k
      continue;
1056
1057
1.64k
    char *target_name = strchr (entry->symname, '$');
1058
1.64k
    if (target_name != NULL)
1059
796
      {
1060
        /* Gas mode: the first matching on partial name.  */
1061
1062
796
        target_name += 1;
1063
#ifndef TARGET_UNDERSCORE
1064
#define TARGET_UNDERSCORE 0
1065
#endif
1066
        /* Is this the name we're looking for ?  */
1067
796
        if (strcmp (target_name,
1068
796
        symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0)
1069
561
    {
1070
      /* Not the name we're looking for */
1071
561
      continue;
1072
561
    }
1073
796
      }
1074
    /* MSVC mode: the lexically second symbol (or drop through
1075
       from the above).  */
1076
    /* This must the second symbol with the section #.  It is
1077
       the actual symbol name.  Intel puts the two adjacent, but
1078
       Alpha (at least) spreads them out.  */
1079
1080
1.08k
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
1.08k
    entry->comdat_name = bfd_strdup (symname);
1082
1.08k
  }
1083
10.3k
    }
1084
1085
2.29k
  return true;
1086
2.29k
}
pei-arm.c:fill_comdat_hash
Line
Count
Source
890
5.57k
{
891
5.57k
  bfd_byte *esymstart, *esym, *esymend;
892
893
  /* Unfortunately, the PE format stores essential information in the
894
     symbol table, of all places.  We need to extract that information
895
     now, so that objdump and the linker will know how to handle the
896
     section without worrying about the symbols.  We can't call
897
     slurp_symtab, because the linker doesn't want the swapped symbols.  */
898
899
  /* COMDAT sections are special.  The first symbol is the section
900
     symbol, which tells what kind of COMDAT section it is.  The
901
     second symbol is the "comdat symbol" - the one with the unique
902
     name.  GNU uses the section symbol for the unique name; MS uses
903
     ".text" for every comdat section.  Sigh.  - DJ.  */
904
905
  /* This is not mirrored in sec_to_styp_flags(), but there doesn't
906
     seem to be a need to, either, and it would at best be rather messy.  */
907
908
5.57k
  if (! _bfd_coff_get_external_symbols (abfd))
909
2.97k
    return true;
910
911
2.60k
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
2.60k
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
2.60k
  for (struct internal_syment isym;
915
43.9k
       esym < esymend;
916
41.3k
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
41.3k
    {
918
41.3k
      char buf[SYMNMLEN + 1];
919
41.3k
      const char *symname;
920
41.3k
      flagword sec_flags = SEC_LINK_ONCE;
921
922
41.3k
      bfd_coff_swap_sym_in (abfd, esym, &isym);
923
924
      /* According to the MSVC documentation, the first TWO entries
925
   with the section # are both of interest to us.  The first one
926
   is the "section symbol" (section name).  The second is the
927
   comdat symbol name.  Here, we've found the first qualifying
928
   entry; we distinguish it from the second with a state flag.
929
930
   In the case of gas-generated (at least until that is fixed)
931
   .o files, it isn't necessarily the second one.  It may be
932
   some other later symbol.
933
934
   Since gas also doesn't follow MS conventions and emits the
935
   section similar to .text$<name>, where <something> is the
936
   name we're looking for, we distinguish the two as follows:
937
938
   If the section name is simply a section name (no $) we
939
   presume it's MS-generated, and look at precisely the second
940
   symbol for the comdat name.  If the section name has a $, we
941
   assume it's gas-generated, and look for <something> (whatever
942
   follows the $) as the comdat symbol.  */
943
944
      /* All 3 branches use this.  */
945
41.3k
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
41.3k
      if (symname == NULL)
949
14.1k
  {
950
14.1k
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
14.1k
            abfd);
952
14.1k
    continue;
953
14.1k
  }
954
955
27.1k
      union internal_auxent aux;
956
957
27.1k
      struct comdat_hash_entry needle;
958
27.1k
      needle.target_index = isym.n_scnum;
959
960
27.1k
      void **slot
961
27.1k
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
27.1k
      if (slot == NULL)
963
0
  return false;
964
965
27.1k
      if (*slot == NULL)
966
8.87k
  {
967
8.87k
    if (isym.n_numaux == 0)
968
5.28k
      aux.x_scn.x_comdat = 0;
969
3.59k
    else
970
3.59k
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
3.59k
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
629
    {
974
      /* xgettext:c-format */
975
629
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
629
          " section '%s' found"),
977
629
              abfd, symname);
978
629
      continue;
979
629
    }
980
2.96k
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
2.96k
            isym.n_type, isym.n_sclass, 0,
982
2.96k
            isym.n_numaux, &aux);
983
2.96k
      }
984
985
    /* FIXME: Microsoft uses NODUPLICATES and ASSOCIATIVE, but
986
       gnu uses ANY and SAME_SIZE.  Unfortunately, gnu doesn't
987
       do the comdat symbols right.  So, until we can fix it to
988
       do the right thing, we are temporarily disabling comdats
989
       for the MS types (they're used in DLLs and C++, but we
990
       don't support *their* C++ libraries anyway - DJ.  */
991
992
    /* Cygwin does not follow the MS style, and uses ANY and
993
       SAME_SIZE where NODUPLICATES and ASSOCIATIVE should be
994
       used.  For Interix, we just do the right thing up
995
       front.  */
996
997
8.24k
    switch (aux.x_scn.x_comdat)
998
8.24k
      {
999
22
      case IMAGE_COMDAT_SELECT_NODUPLICATES:
1000
#ifdef STRICT_PE_FORMAT
1001
        sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY;
1002
#else
1003
22
        sec_flags &= ~SEC_LINK_ONCE;
1004
22
#endif
1005
22
        break;
1006
1007
0
      case IMAGE_COMDAT_SELECT_ANY:
1008
0
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1009
0
        break;
1010
1011
0
      case IMAGE_COMDAT_SELECT_SAME_SIZE:
1012
0
        sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE;
1013
0
        break;
1014
1015
0
      case IMAGE_COMDAT_SELECT_EXACT_MATCH:
1016
        /* Not yet fully implemented ??? */
1017
0
        sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS;
1018
0
        break;
1019
1020
        /* debug$S gets this case; other implications ???  */
1021
1022
        /* There may be no symbol.  We'll search the whole
1023
     table.  Is this the right place to play this game?
1024
     Or should we do it when reading it in?  */
1025
0
      case IMAGE_COMDAT_SELECT_ASSOCIATIVE:
1026
#ifdef STRICT_PE_FORMAT
1027
        /* FIXME: This is not currently implemented.  */
1028
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1029
#else
1030
0
        sec_flags &= ~SEC_LINK_ONCE;
1031
0
#endif
1032
0
        break;
1033
1034
8.22k
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
8.22k
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
8.22k
        break;
1038
8.24k
      }
1039
1040
8.24k
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
8.24k
    if (*slot == NULL)
1042
0
      return false;
1043
8.24k
    struct comdat_hash_entry *newentry = *slot;
1044
8.24k
    newentry->sec_flags = sec_flags;
1045
8.24k
    newentry->symname = bfd_strdup (symname);
1046
8.24k
    newentry->target_index = isym.n_scnum;
1047
8.24k
    newentry->isym = isym;
1048
8.24k
    newentry->comdat_symbol = -1;
1049
8.24k
  }
1050
18.2k
      else
1051
18.2k
  {
1052
18.2k
    struct comdat_hash_entry *entry = *slot;
1053
1054
18.2k
    if (entry->comdat_symbol != -1)
1055
15.3k
      continue;
1056
1057
2.92k
    char *target_name = strchr (entry->symname, '$');
1058
2.92k
    if (target_name != NULL)
1059
803
      {
1060
        /* Gas mode: the first matching on partial name.  */
1061
1062
803
        target_name += 1;
1063
#ifndef TARGET_UNDERSCORE
1064
#define TARGET_UNDERSCORE 0
1065
#endif
1066
        /* Is this the name we're looking for ?  */
1067
803
        if (strcmp (target_name,
1068
803
        symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0)
1069
332
    {
1070
      /* Not the name we're looking for */
1071
332
      continue;
1072
332
    }
1073
803
      }
1074
    /* MSVC mode: the lexically second symbol (or drop through
1075
       from the above).  */
1076
    /* This must the second symbol with the section #.  It is
1077
       the actual symbol name.  Intel puts the two adjacent, but
1078
       Alpha (at least) spreads them out.  */
1079
1080
2.59k
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
2.59k
    entry->comdat_name = bfd_strdup (symname);
1082
2.59k
  }
1083
27.1k
    }
1084
1085
2.60k
  return true;
1086
2.60k
}
pei-mcore.c:fill_comdat_hash
Line
Count
Source
890
4.83k
{
891
4.83k
  bfd_byte *esymstart, *esym, *esymend;
892
893
  /* Unfortunately, the PE format stores essential information in the
894
     symbol table, of all places.  We need to extract that information
895
     now, so that objdump and the linker will know how to handle the
896
     section without worrying about the symbols.  We can't call
897
     slurp_symtab, because the linker doesn't want the swapped symbols.  */
898
899
  /* COMDAT sections are special.  The first symbol is the section
900
     symbol, which tells what kind of COMDAT section it is.  The
901
     second symbol is the "comdat symbol" - the one with the unique
902
     name.  GNU uses the section symbol for the unique name; MS uses
903
     ".text" for every comdat section.  Sigh.  - DJ.  */
904
905
  /* This is not mirrored in sec_to_styp_flags(), but there doesn't
906
     seem to be a need to, either, and it would at best be rather messy.  */
907
908
4.83k
  if (! _bfd_coff_get_external_symbols (abfd))
909
1.06k
    return true;
910
911
3.77k
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
3.77k
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
3.77k
  for (struct internal_syment isym;
915
23.5k
       esym < esymend;
916
19.7k
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
19.7k
    {
918
19.7k
      char buf[SYMNMLEN + 1];
919
19.7k
      const char *symname;
920
19.7k
      flagword sec_flags = SEC_LINK_ONCE;
921
922
19.7k
      bfd_coff_swap_sym_in (abfd, esym, &isym);
923
924
      /* According to the MSVC documentation, the first TWO entries
925
   with the section # are both of interest to us.  The first one
926
   is the "section symbol" (section name).  The second is the
927
   comdat symbol name.  Here, we've found the first qualifying
928
   entry; we distinguish it from the second with a state flag.
929
930
   In the case of gas-generated (at least until that is fixed)
931
   .o files, it isn't necessarily the second one.  It may be
932
   some other later symbol.
933
934
   Since gas also doesn't follow MS conventions and emits the
935
   section similar to .text$<name>, where <something> is the
936
   name we're looking for, we distinguish the two as follows:
937
938
   If the section name is simply a section name (no $) we
939
   presume it's MS-generated, and look at precisely the second
940
   symbol for the comdat name.  If the section name has a $, we
941
   assume it's gas-generated, and look for <something> (whatever
942
   follows the $) as the comdat symbol.  */
943
944
      /* All 3 branches use this.  */
945
19.7k
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
19.7k
      if (symname == NULL)
949
7.98k
  {
950
7.98k
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
7.98k
            abfd);
952
7.98k
    continue;
953
7.98k
  }
954
955
11.7k
      union internal_auxent aux;
956
957
11.7k
      struct comdat_hash_entry needle;
958
11.7k
      needle.target_index = isym.n_scnum;
959
960
11.7k
      void **slot
961
11.7k
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
11.7k
      if (slot == NULL)
963
0
  return false;
964
965
11.7k
      if (*slot == NULL)
966
6.62k
  {
967
6.62k
    if (isym.n_numaux == 0)
968
2.88k
      aux.x_scn.x_comdat = 0;
969
3.74k
    else
970
3.74k
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
3.74k
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
481
    {
974
      /* xgettext:c-format */
975
481
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
481
          " section '%s' found"),
977
481
              abfd, symname);
978
481
      continue;
979
481
    }
980
3.26k
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
3.26k
            isym.n_type, isym.n_sclass, 0,
982
3.26k
            isym.n_numaux, &aux);
983
3.26k
      }
984
985
    /* FIXME: Microsoft uses NODUPLICATES and ASSOCIATIVE, but
986
       gnu uses ANY and SAME_SIZE.  Unfortunately, gnu doesn't
987
       do the comdat symbols right.  So, until we can fix it to
988
       do the right thing, we are temporarily disabling comdats
989
       for the MS types (they're used in DLLs and C++, but we
990
       don't support *their* C++ libraries anyway - DJ.  */
991
992
    /* Cygwin does not follow the MS style, and uses ANY and
993
       SAME_SIZE where NODUPLICATES and ASSOCIATIVE should be
994
       used.  For Interix, we just do the right thing up
995
       front.  */
996
997
6.14k
    switch (aux.x_scn.x_comdat)
998
6.14k
      {
999
3
      case IMAGE_COMDAT_SELECT_NODUPLICATES:
1000
#ifdef STRICT_PE_FORMAT
1001
        sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY;
1002
#else
1003
3
        sec_flags &= ~SEC_LINK_ONCE;
1004
3
#endif
1005
3
        break;
1006
1007
0
      case IMAGE_COMDAT_SELECT_ANY:
1008
0
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1009
0
        break;
1010
1011
0
      case IMAGE_COMDAT_SELECT_SAME_SIZE:
1012
0
        sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE;
1013
0
        break;
1014
1015
12
      case IMAGE_COMDAT_SELECT_EXACT_MATCH:
1016
        /* Not yet fully implemented ??? */
1017
12
        sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS;
1018
12
        break;
1019
1020
        /* debug$S gets this case; other implications ???  */
1021
1022
        /* There may be no symbol.  We'll search the whole
1023
     table.  Is this the right place to play this game?
1024
     Or should we do it when reading it in?  */
1025
0
      case IMAGE_COMDAT_SELECT_ASSOCIATIVE:
1026
#ifdef STRICT_PE_FORMAT
1027
        /* FIXME: This is not currently implemented.  */
1028
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1029
#else
1030
0
        sec_flags &= ~SEC_LINK_ONCE;
1031
0
#endif
1032
0
        break;
1033
1034
6.12k
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
6.12k
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
6.12k
        break;
1038
6.14k
      }
1039
1040
6.14k
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
6.14k
    if (*slot == NULL)
1042
0
      return false;
1043
6.14k
    struct comdat_hash_entry *newentry = *slot;
1044
6.14k
    newentry->sec_flags = sec_flags;
1045
6.14k
    newentry->symname = bfd_strdup (symname);
1046
6.14k
    newentry->target_index = isym.n_scnum;
1047
6.14k
    newentry->isym = isym;
1048
6.14k
    newentry->comdat_symbol = -1;
1049
6.14k
  }
1050
5.13k
      else
1051
5.13k
  {
1052
5.13k
    struct comdat_hash_entry *entry = *slot;
1053
1054
5.13k
    if (entry->comdat_symbol != -1)
1055
3.10k
      continue;
1056
1057
2.03k
    char *target_name = strchr (entry->symname, '$');
1058
2.03k
    if (target_name != NULL)
1059
0
      {
1060
        /* Gas mode: the first matching on partial name.  */
1061
1062
0
        target_name += 1;
1063
0
#ifndef TARGET_UNDERSCORE
1064
0
#define TARGET_UNDERSCORE 0
1065
0
#endif
1066
        /* Is this the name we're looking for ?  */
1067
0
        if (strcmp (target_name,
1068
0
        symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0)
1069
0
    {
1070
      /* Not the name we're looking for */
1071
0
      continue;
1072
0
    }
1073
0
      }
1074
    /* MSVC mode: the lexically second symbol (or drop through
1075
       from the above).  */
1076
    /* This must the second symbol with the section #.  It is
1077
       the actual symbol name.  Intel puts the two adjacent, but
1078
       Alpha (at least) spreads them out.  */
1079
1080
2.03k
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
2.03k
    entry->comdat_name = bfd_strdup (symname);
1082
2.03k
  }
1083
11.7k
    }
1084
1085
3.77k
  return true;
1086
3.77k
}
pei-sh.c:fill_comdat_hash
Line
Count
Source
890
3.16k
{
891
3.16k
  bfd_byte *esymstart, *esym, *esymend;
892
893
  /* Unfortunately, the PE format stores essential information in the
894
     symbol table, of all places.  We need to extract that information
895
     now, so that objdump and the linker will know how to handle the
896
     section without worrying about the symbols.  We can't call
897
     slurp_symtab, because the linker doesn't want the swapped symbols.  */
898
899
  /* COMDAT sections are special.  The first symbol is the section
900
     symbol, which tells what kind of COMDAT section it is.  The
901
     second symbol is the "comdat symbol" - the one with the unique
902
     name.  GNU uses the section symbol for the unique name; MS uses
903
     ".text" for every comdat section.  Sigh.  - DJ.  */
904
905
  /* This is not mirrored in sec_to_styp_flags(), but there doesn't
906
     seem to be a need to, either, and it would at best be rather messy.  */
907
908
3.16k
  if (! _bfd_coff_get_external_symbols (abfd))
909
1.54k
    return true;
910
911
1.62k
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
1.62k
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
1.62k
  for (struct internal_syment isym;
915
13.6k
       esym < esymend;
916
12.0k
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
12.0k
    {
918
12.0k
      char buf[SYMNMLEN + 1];
919
12.0k
      const char *symname;
920
12.0k
      flagword sec_flags = SEC_LINK_ONCE;
921
922
12.0k
      bfd_coff_swap_sym_in (abfd, esym, &isym);
923
924
      /* According to the MSVC documentation, the first TWO entries
925
   with the section # are both of interest to us.  The first one
926
   is the "section symbol" (section name).  The second is the
927
   comdat symbol name.  Here, we've found the first qualifying
928
   entry; we distinguish it from the second with a state flag.
929
930
   In the case of gas-generated (at least until that is fixed)
931
   .o files, it isn't necessarily the second one.  It may be
932
   some other later symbol.
933
934
   Since gas also doesn't follow MS conventions and emits the
935
   section similar to .text$<name>, where <something> is the
936
   name we're looking for, we distinguish the two as follows:
937
938
   If the section name is simply a section name (no $) we
939
   presume it's MS-generated, and look at precisely the second
940
   symbol for the comdat name.  If the section name has a $, we
941
   assume it's gas-generated, and look for <something> (whatever
942
   follows the $) as the comdat symbol.  */
943
944
      /* All 3 branches use this.  */
945
12.0k
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
12.0k
      if (symname == NULL)
949
4.01k
  {
950
4.01k
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
4.01k
            abfd);
952
4.01k
    continue;
953
4.01k
  }
954
955
8.06k
      union internal_auxent aux;
956
957
8.06k
      struct comdat_hash_entry needle;
958
8.06k
      needle.target_index = isym.n_scnum;
959
960
8.06k
      void **slot
961
8.06k
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
8.06k
      if (slot == NULL)
963
0
  return false;
964
965
8.06k
      if (*slot == NULL)
966
6.18k
  {
967
6.18k
    if (isym.n_numaux == 0)
968
3.22k
      aux.x_scn.x_comdat = 0;
969
2.95k
    else
970
2.95k
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
2.95k
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
1.09k
    {
974
      /* xgettext:c-format */
975
1.09k
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
1.09k
          " section '%s' found"),
977
1.09k
              abfd, symname);
978
1.09k
      continue;
979
1.09k
    }
980
1.86k
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
1.86k
            isym.n_type, isym.n_sclass, 0,
982
1.86k
            isym.n_numaux, &aux);
983
1.86k
      }
984
985
    /* FIXME: Microsoft uses NODUPLICATES and ASSOCIATIVE, but
986
       gnu uses ANY and SAME_SIZE.  Unfortunately, gnu doesn't
987
       do the comdat symbols right.  So, until we can fix it to
988
       do the right thing, we are temporarily disabling comdats
989
       for the MS types (they're used in DLLs and C++, but we
990
       don't support *their* C++ libraries anyway - DJ.  */
991
992
    /* Cygwin does not follow the MS style, and uses ANY and
993
       SAME_SIZE where NODUPLICATES and ASSOCIATIVE should be
994
       used.  For Interix, we just do the right thing up
995
       front.  */
996
997
5.09k
    switch (aux.x_scn.x_comdat)
998
5.09k
      {
999
0
      case IMAGE_COMDAT_SELECT_NODUPLICATES:
1000
#ifdef STRICT_PE_FORMAT
1001
        sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY;
1002
#else
1003
0
        sec_flags &= ~SEC_LINK_ONCE;
1004
0
#endif
1005
0
        break;
1006
1007
0
      case IMAGE_COMDAT_SELECT_ANY:
1008
0
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1009
0
        break;
1010
1011
0
      case IMAGE_COMDAT_SELECT_SAME_SIZE:
1012
0
        sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE;
1013
0
        break;
1014
1015
0
      case IMAGE_COMDAT_SELECT_EXACT_MATCH:
1016
        /* Not yet fully implemented ??? */
1017
0
        sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS;
1018
0
        break;
1019
1020
        /* debug$S gets this case; other implications ???  */
1021
1022
        /* There may be no symbol.  We'll search the whole
1023
     table.  Is this the right place to play this game?
1024
     Or should we do it when reading it in?  */
1025
1
      case IMAGE_COMDAT_SELECT_ASSOCIATIVE:
1026
#ifdef STRICT_PE_FORMAT
1027
        /* FIXME: This is not currently implemented.  */
1028
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1029
#else
1030
1
        sec_flags &= ~SEC_LINK_ONCE;
1031
1
#endif
1032
1
        break;
1033
1034
5.08k
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
5.08k
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
5.08k
        break;
1038
5.09k
      }
1039
1040
5.09k
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
5.09k
    if (*slot == NULL)
1042
0
      return false;
1043
5.09k
    struct comdat_hash_entry *newentry = *slot;
1044
5.09k
    newentry->sec_flags = sec_flags;
1045
5.09k
    newentry->symname = bfd_strdup (symname);
1046
5.09k
    newentry->target_index = isym.n_scnum;
1047
5.09k
    newentry->isym = isym;
1048
5.09k
    newentry->comdat_symbol = -1;
1049
5.09k
  }
1050
1.87k
      else
1051
1.87k
  {
1052
1.87k
    struct comdat_hash_entry *entry = *slot;
1053
1054
1.87k
    if (entry->comdat_symbol != -1)
1055
1.06k
      continue;
1056
1057
813
    char *target_name = strchr (entry->symname, '$');
1058
813
    if (target_name != NULL)
1059
0
      {
1060
        /* Gas mode: the first matching on partial name.  */
1061
1062
0
        target_name += 1;
1063
#ifndef TARGET_UNDERSCORE
1064
#define TARGET_UNDERSCORE 0
1065
#endif
1066
        /* Is this the name we're looking for ?  */
1067
0
        if (strcmp (target_name,
1068
0
        symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0)
1069
0
    {
1070
      /* Not the name we're looking for */
1071
0
      continue;
1072
0
    }
1073
0
      }
1074
    /* MSVC mode: the lexically second symbol (or drop through
1075
       from the above).  */
1076
    /* This must the second symbol with the section #.  It is
1077
       the actual symbol name.  Intel puts the two adjacent, but
1078
       Alpha (at least) spreads them out.  */
1079
1080
813
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
813
    entry->comdat_name = bfd_strdup (symname);
1082
813
  }
1083
8.06k
    }
1084
1085
1.62k
  return true;
1086
1.62k
}
1087
1088
static bool
1089
insert_coff_comdat_info (bfd *abfd, asection *section, const char *symname,
1090
       long symbol)
1091
1.19k
{
1092
1.19k
  struct coff_comdat_info *comdat;
1093
1.19k
  size_t len = strlen (symname) + 1;
1094
1095
1.19k
  comdat = bfd_alloc (abfd, sizeof (*comdat) + len);
1096
1.19k
  if (comdat == NULL)
1097
0
    return false;
1098
1099
1.19k
  coff_section_data (abfd, section)->comdat = comdat;
1100
1.19k
  comdat->symbol = symbol;
1101
1.19k
  char *newname = (char *) (comdat + 1);
1102
1.19k
  comdat->name = newname;
1103
1.19k
  memcpy (newname, symname, len);
1104
1.19k
  return true;
1105
1.19k
}
pei-i386.c:insert_coff_comdat_info
Line
Count
Source
1091
242
{
1092
242
  struct coff_comdat_info *comdat;
1093
242
  size_t len = strlen (symname) + 1;
1094
1095
242
  comdat = bfd_alloc (abfd, sizeof (*comdat) + len);
1096
242
  if (comdat == NULL)
1097
0
    return false;
1098
1099
242
  coff_section_data (abfd, section)->comdat = comdat;
1100
242
  comdat->symbol = symbol;
1101
242
  char *newname = (char *) (comdat + 1);
1102
242
  comdat->name = newname;
1103
242
  memcpy (newname, symname, len);
1104
242
  return true;
1105
242
}
pe-x86_64.c:insert_coff_comdat_info
Line
Count
Source
1091
245
{
1092
245
  struct coff_comdat_info *comdat;
1093
245
  size_t len = strlen (symname) + 1;
1094
1095
245
  comdat = bfd_alloc (abfd, sizeof (*comdat) + len);
1096
245
  if (comdat == NULL)
1097
0
    return false;
1098
1099
245
  coff_section_data (abfd, section)->comdat = comdat;
1100
245
  comdat->symbol = symbol;
1101
245
  char *newname = (char *) (comdat + 1);
1102
245
  comdat->name = newname;
1103
245
  memcpy (newname, symname, len);
1104
245
  return true;
1105
245
}
pei-x86_64.c:insert_coff_comdat_info
Line
Count
Source
1091
28
{
1092
28
  struct coff_comdat_info *comdat;
1093
28
  size_t len = strlen (symname) + 1;
1094
1095
28
  comdat = bfd_alloc (abfd, sizeof (*comdat) + len);
1096
28
  if (comdat == NULL)
1097
0
    return false;
1098
1099
28
  coff_section_data (abfd, section)->comdat = comdat;
1100
28
  comdat->symbol = symbol;
1101
28
  char *newname = (char *) (comdat + 1);
1102
28
  comdat->name = newname;
1103
28
  memcpy (newname, symname, len);
1104
28
  return true;
1105
28
}
pe-aarch64.c:insert_coff_comdat_info
Line
Count
Source
1091
3
{
1092
3
  struct coff_comdat_info *comdat;
1093
3
  size_t len = strlen (symname) + 1;
1094
1095
3
  comdat = bfd_alloc (abfd, sizeof (*comdat) + len);
1096
3
  if (comdat == NULL)
1097
0
    return false;
1098
1099
3
  coff_section_data (abfd, section)->comdat = comdat;
1100
3
  comdat->symbol = symbol;
1101
3
  char *newname = (char *) (comdat + 1);
1102
3
  comdat->name = newname;
1103
3
  memcpy (newname, symname, len);
1104
3
  return true;
1105
3
}
pei-aarch64.c:insert_coff_comdat_info
Line
Count
Source
1091
18
{
1092
18
  struct coff_comdat_info *comdat;
1093
18
  size_t len = strlen (symname) + 1;
1094
1095
18
  comdat = bfd_alloc (abfd, sizeof (*comdat) + len);
1096
18
  if (comdat == NULL)
1097
0
    return false;
1098
1099
18
  coff_section_data (abfd, section)->comdat = comdat;
1100
18
  comdat->symbol = symbol;
1101
18
  char *newname = (char *) (comdat + 1);
1102
18
  comdat->name = newname;
1103
18
  memcpy (newname, symname, len);
1104
18
  return true;
1105
18
}
pei-ia64.c:insert_coff_comdat_info
Line
Count
Source
1091
242
{
1092
242
  struct coff_comdat_info *comdat;
1093
242
  size_t len = strlen (symname) + 1;
1094
1095
242
  comdat = bfd_alloc (abfd, sizeof (*comdat) + len);
1096
242
  if (comdat == NULL)
1097
0
    return false;
1098
1099
242
  coff_section_data (abfd, section)->comdat = comdat;
1100
242
  comdat->symbol = symbol;
1101
242
  char *newname = (char *) (comdat + 1);
1102
242
  comdat->name = newname;
1103
242
  memcpy (newname, symname, len);
1104
242
  return true;
1105
242
}
pei-loongarch64.c:insert_coff_comdat_info
Line
Count
Source
1091
2
{
1092
2
  struct coff_comdat_info *comdat;
1093
2
  size_t len = strlen (symname) + 1;
1094
1095
2
  comdat = bfd_alloc (abfd, sizeof (*comdat) + len);
1096
2
  if (comdat == NULL)
1097
0
    return false;
1098
1099
2
  coff_section_data (abfd, section)->comdat = comdat;
1100
2
  comdat->symbol = symbol;
1101
2
  char *newname = (char *) (comdat + 1);
1102
2
  comdat->name = newname;
1103
2
  memcpy (newname, symname, len);
1104
2
  return true;
1105
2
}
pe-arm-wince.c:insert_coff_comdat_info
Line
Count
Source
1091
5
{
1092
5
  struct coff_comdat_info *comdat;
1093
5
  size_t len = strlen (symname) + 1;
1094
1095
5
  comdat = bfd_alloc (abfd, sizeof (*comdat) + len);
1096
5
  if (comdat == NULL)
1097
0
    return false;
1098
1099
5
  coff_section_data (abfd, section)->comdat = comdat;
1100
5
  comdat->symbol = symbol;
1101
5
  char *newname = (char *) (comdat + 1);
1102
5
  comdat->name = newname;
1103
5
  memcpy (newname, symname, len);
1104
5
  return true;
1105
5
}
pe-arm.c:insert_coff_comdat_info
Line
Count
Source
1091
5
{
1092
5
  struct coff_comdat_info *comdat;
1093
5
  size_t len = strlen (symname) + 1;
1094
1095
5
  comdat = bfd_alloc (abfd, sizeof (*comdat) + len);
1096
5
  if (comdat == NULL)
1097
0
    return false;
1098
1099
5
  coff_section_data (abfd, section)->comdat = comdat;
1100
5
  comdat->symbol = symbol;
1101
5
  char *newname = (char *) (comdat + 1);
1102
5
  comdat->name = newname;
1103
5
  memcpy (newname, symname, len);
1104
5
  return true;
1105
5
}
pe-i386.c:insert_coff_comdat_info
Line
Count
Source
1091
111
{
1092
111
  struct coff_comdat_info *comdat;
1093
111
  size_t len = strlen (symname) + 1;
1094
1095
111
  comdat = bfd_alloc (abfd, sizeof (*comdat) + len);
1096
111
  if (comdat == NULL)
1097
0
    return false;
1098
1099
111
  coff_section_data (abfd, section)->comdat = comdat;
1100
111
  comdat->symbol = symbol;
1101
111
  char *newname = (char *) (comdat + 1);
1102
111
  comdat->name = newname;
1103
111
  memcpy (newname, symname, len);
1104
111
  return true;
1105
111
}
pe-mcore.c:insert_coff_comdat_info
Line
Count
Source
1091
4
{
1092
4
  struct coff_comdat_info *comdat;
1093
4
  size_t len = strlen (symname) + 1;
1094
1095
4
  comdat = bfd_alloc (abfd, sizeof (*comdat) + len);
1096
4
  if (comdat == NULL)
1097
0
    return false;
1098
1099
4
  coff_section_data (abfd, section)->comdat = comdat;
1100
4
  comdat->symbol = symbol;
1101
4
  char *newname = (char *) (comdat + 1);
1102
4
  comdat->name = newname;
1103
4
  memcpy (newname, symname, len);
1104
4
  return true;
1105
4
}
pe-sh.c:insert_coff_comdat_info
Line
Count
Source
1091
208
{
1092
208
  struct coff_comdat_info *comdat;
1093
208
  size_t len = strlen (symname) + 1;
1094
1095
208
  comdat = bfd_alloc (abfd, sizeof (*comdat) + len);
1096
208
  if (comdat == NULL)
1097
0
    return false;
1098
1099
208
  coff_section_data (abfd, section)->comdat = comdat;
1100
208
  comdat->symbol = symbol;
1101
208
  char *newname = (char *) (comdat + 1);
1102
208
  comdat->name = newname;
1103
208
  memcpy (newname, symname, len);
1104
208
  return true;
1105
208
}
pei-arm-wince.c:insert_coff_comdat_info
Line
Count
Source
1091
30
{
1092
30
  struct coff_comdat_info *comdat;
1093
30
  size_t len = strlen (symname) + 1;
1094
1095
30
  comdat = bfd_alloc (abfd, sizeof (*comdat) + len);
1096
30
  if (comdat == NULL)
1097
0
    return false;
1098
1099
30
  coff_section_data (abfd, section)->comdat = comdat;
1100
30
  comdat->symbol = symbol;
1101
30
  char *newname = (char *) (comdat + 1);
1102
30
  comdat->name = newname;
1103
30
  memcpy (newname, symname, len);
1104
30
  return true;
1105
30
}
pei-arm.c:insert_coff_comdat_info
Line
Count
Source
1091
31
{
1092
31
  struct coff_comdat_info *comdat;
1093
31
  size_t len = strlen (symname) + 1;
1094
1095
31
  comdat = bfd_alloc (abfd, sizeof (*comdat) + len);
1096
31
  if (comdat == NULL)
1097
0
    return false;
1098
1099
31
  coff_section_data (abfd, section)->comdat = comdat;
1100
31
  comdat->symbol = symbol;
1101
31
  char *newname = (char *) (comdat + 1);
1102
31
  comdat->name = newname;
1103
31
  memcpy (newname, symname, len);
1104
31
  return true;
1105
31
}
pei-mcore.c:insert_coff_comdat_info
Line
Count
Source
1091
18
{
1092
18
  struct coff_comdat_info *comdat;
1093
18
  size_t len = strlen (symname) + 1;
1094
1095
18
  comdat = bfd_alloc (abfd, sizeof (*comdat) + len);
1096
18
  if (comdat == NULL)
1097
0
    return false;
1098
1099
18
  coff_section_data (abfd, section)->comdat = comdat;
1100
18
  comdat->symbol = symbol;
1101
18
  char *newname = (char *) (comdat + 1);
1102
18
  comdat->name = newname;
1103
18
  memcpy (newname, symname, len);
1104
18
  return true;
1105
18
}
pei-sh.c:insert_coff_comdat_info
Line
Count
Source
1091
1
{
1092
1
  struct coff_comdat_info *comdat;
1093
1
  size_t len = strlen (symname) + 1;
1094
1095
1
  comdat = bfd_alloc (abfd, sizeof (*comdat) + len);
1096
1
  if (comdat == NULL)
1097
0
    return false;
1098
1099
1
  coff_section_data (abfd, section)->comdat = comdat;
1100
1
  comdat->symbol = symbol;
1101
1
  char *newname = (char *) (comdat + 1);
1102
1
  comdat->name = newname;
1103
1
  memcpy (newname, symname, len);
1104
1
  return true;
1105
1
}
1106
1107
static bool
1108
handle_COMDAT (bfd *abfd, flagword *sec_flags, const char *name,
1109
         asection *section)
1110
89.0k
{
1111
89.0k
  if (pe_data (abfd)->comdat_hash == NULL)
1112
58.1k
    {
1113
58.1k
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
58.1k
             comdat_delf);
1115
58.1k
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
58.1k
    }
1118
1119
89.0k
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
66.2k
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
89.0k
  struct comdat_hash_entry *found
1124
89.0k
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
89.0k
  if (found != NULL)
1126
10.1k
    {
1127
10.1k
      struct internal_syment isym = found->isym;
1128
1129
      /* If it isn't the stuff we're expecting, die;  The MS
1130
   documentation is vague, but it appears that the second entry
1131
   serves BOTH as the comdat symbol and the defining symbol
1132
   record (either C_STAT or C_EXT, possibly with an aux entry
1133
   with debug information if it's a function.)  It appears the
1134
   only way to find the second one is to count.  (On Intel, they
1135
   appear to be adjacent, but on Alpha, they have been found
1136
   separated.)
1137
1138
   Here, we think we've found the first one, but there's some
1139
   checking we can do to be sure.  */
1140
1141
10.1k
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
10.1k
       && BTYPE (isym.n_type) == T_NULL && isym.n_value == 0))
1143
6.07k
  {
1144
    /* Malformed input files can trigger this test.
1145
       cf PR 21781.  */
1146
6.07k
    _bfd_error_handler
1147
6.07k
      (_("%pB: error: unexpected symbol '%s' in COMDAT section"),
1148
6.07k
       abfd, found->symname);
1149
6.07k
    return false;
1150
6.07k
  }
1151
1152
      /* FIXME LATER: MSVC generates section names like .text for
1153
   comdats.  Gas generates names like .text$foo__Fv (in the case
1154
   of a function).  See comment above for more.  */
1155
1156
4.09k
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
2.08k
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
2.08k
            " does not match section name '%s'"),
1160
2.08k
          abfd, found->symname, name);
1161
1162
4.09k
      if (found->comdat_symbol != -1)
1163
1.19k
  {
1164
1.19k
    if (! insert_coff_comdat_info (abfd, section, found->comdat_name,
1165
1.19k
           found->comdat_symbol))
1166
0
      return false;
1167
1.19k
  }
1168
4.09k
      *sec_flags = *sec_flags | found->sec_flags;
1169
4.09k
      return true;
1170
4.09k
    }
1171
78.8k
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
78.8k
  return true;
1173
89.0k
}
pei-i386.c:handle_COMDAT
Line
Count
Source
1110
17.1k
{
1111
17.1k
  if (pe_data (abfd)->comdat_hash == NULL)
1112
5.11k
    {
1113
5.11k
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
5.11k
             comdat_delf);
1115
5.11k
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
5.11k
    }
1118
1119
17.1k
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
5.87k
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
17.1k
  struct comdat_hash_entry *found
1124
17.1k
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
17.1k
  if (found != NULL)
1126
1.21k
    {
1127
1.21k
      struct internal_syment isym = found->isym;
1128
1129
      /* If it isn't the stuff we're expecting, die;  The MS
1130
   documentation is vague, but it appears that the second entry
1131
   serves BOTH as the comdat symbol and the defining symbol
1132
   record (either C_STAT or C_EXT, possibly with an aux entry
1133
   with debug information if it's a function.)  It appears the
1134
   only way to find the second one is to count.  (On Intel, they
1135
   appear to be adjacent, but on Alpha, they have been found
1136
   separated.)
1137
1138
   Here, we think we've found the first one, but there's some
1139
   checking we can do to be sure.  */
1140
1141
1.21k
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
1.21k
       && BTYPE (isym.n_type) == T_NULL && isym.n_value == 0))
1143
727
  {
1144
    /* Malformed input files can trigger this test.
1145
       cf PR 21781.  */
1146
727
    _bfd_error_handler
1147
727
      (_("%pB: error: unexpected symbol '%s' in COMDAT section"),
1148
727
       abfd, found->symname);
1149
727
    return false;
1150
727
  }
1151
1152
      /* FIXME LATER: MSVC generates section names like .text for
1153
   comdats.  Gas generates names like .text$foo__Fv (in the case
1154
   of a function).  See comment above for more.  */
1155
1156
483
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
243
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
243
            " does not match section name '%s'"),
1160
243
          abfd, found->symname, name);
1161
1162
483
      if (found->comdat_symbol != -1)
1163
242
  {
1164
242
    if (! insert_coff_comdat_info (abfd, section, found->comdat_name,
1165
242
           found->comdat_symbol))
1166
0
      return false;
1167
242
  }
1168
483
      *sec_flags = *sec_flags | found->sec_flags;
1169
483
      return true;
1170
483
    }
1171
15.9k
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
15.9k
  return true;
1173
17.1k
}
pe-x86_64.c:handle_COMDAT
Line
Count
Source
1110
10.9k
{
1111
10.9k
  if (pe_data (abfd)->comdat_hash == NULL)
1112
8.74k
    {
1113
8.74k
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
8.74k
             comdat_delf);
1115
8.74k
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
8.74k
    }
1118
1119
10.9k
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
9.86k
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
10.9k
  struct comdat_hash_entry *found
1124
10.9k
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
10.9k
  if (found != NULL)
1126
679
    {
1127
679
      struct internal_syment isym = found->isym;
1128
1129
      /* If it isn't the stuff we're expecting, die;  The MS
1130
   documentation is vague, but it appears that the second entry
1131
   serves BOTH as the comdat symbol and the defining symbol
1132
   record (either C_STAT or C_EXT, possibly with an aux entry
1133
   with debug information if it's a function.)  It appears the
1134
   only way to find the second one is to count.  (On Intel, they
1135
   appear to be adjacent, but on Alpha, they have been found
1136
   separated.)
1137
1138
   Here, we think we've found the first one, but there's some
1139
   checking we can do to be sure.  */
1140
1141
679
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
679
       && BTYPE (isym.n_type) == T_NULL && isym.n_value == 0))
1143
423
  {
1144
    /* Malformed input files can trigger this test.
1145
       cf PR 21781.  */
1146
423
    _bfd_error_handler
1147
423
      (_("%pB: error: unexpected symbol '%s' in COMDAT section"),
1148
423
       abfd, found->symname);
1149
423
    return false;
1150
423
  }
1151
1152
      /* FIXME LATER: MSVC generates section names like .text for
1153
   comdats.  Gas generates names like .text$foo__Fv (in the case
1154
   of a function).  See comment above for more.  */
1155
1156
256
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
12
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
12
            " does not match section name '%s'"),
1160
12
          abfd, found->symname, name);
1161
1162
256
      if (found->comdat_symbol != -1)
1163
245
  {
1164
245
    if (! insert_coff_comdat_info (abfd, section, found->comdat_name,
1165
245
           found->comdat_symbol))
1166
0
      return false;
1167
245
  }
1168
256
      *sec_flags = *sec_flags | found->sec_flags;
1169
256
      return true;
1170
256
    }
1171
10.2k
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
10.2k
  return true;
1173
10.9k
}
pei-x86_64.c:handle_COMDAT
Line
Count
Source
1110
5.02k
{
1111
5.02k
  if (pe_data (abfd)->comdat_hash == NULL)
1112
3.67k
    {
1113
3.67k
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
3.67k
             comdat_delf);
1115
3.67k
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
3.67k
    }
1118
1119
5.02k
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
4.15k
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
5.02k
  struct comdat_hash_entry *found
1124
5.02k
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
5.02k
  if (found != NULL)
1126
900
    {
1127
900
      struct internal_syment isym = found->isym;
1128
1129
      /* If it isn't the stuff we're expecting, die;  The MS
1130
   documentation is vague, but it appears that the second entry
1131
   serves BOTH as the comdat symbol and the defining symbol
1132
   record (either C_STAT or C_EXT, possibly with an aux entry
1133
   with debug information if it's a function.)  It appears the
1134
   only way to find the second one is to count.  (On Intel, they
1135
   appear to be adjacent, but on Alpha, they have been found
1136
   separated.)
1137
1138
   Here, we think we've found the first one, but there's some
1139
   checking we can do to be sure.  */
1140
1141
900
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
900
       && BTYPE (isym.n_type) == T_NULL && isym.n_value == 0))
1143
349
  {
1144
    /* Malformed input files can trigger this test.
1145
       cf PR 21781.  */
1146
349
    _bfd_error_handler
1147
349
      (_("%pB: error: unexpected symbol '%s' in COMDAT section"),
1148
349
       abfd, found->symname);
1149
349
    return false;
1150
349
  }
1151
1152
      /* FIXME LATER: MSVC generates section names like .text for
1153
   comdats.  Gas generates names like .text$foo__Fv (in the case
1154
   of a function).  See comment above for more.  */
1155
1156
551
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
532
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
532
            " does not match section name '%s'"),
1160
532
          abfd, found->symname, name);
1161
1162
551
      if (found->comdat_symbol != -1)
1163
28
  {
1164
28
    if (! insert_coff_comdat_info (abfd, section, found->comdat_name,
1165
28
           found->comdat_symbol))
1166
0
      return false;
1167
28
  }
1168
551
      *sec_flags = *sec_flags | found->sec_flags;
1169
551
      return true;
1170
551
    }
1171
4.12k
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
4.12k
  return true;
1173
5.02k
}
pe-aarch64.c:handle_COMDAT
Line
Count
Source
1110
4.85k
{
1111
4.85k
  if (pe_data (abfd)->comdat_hash == NULL)
1112
3.14k
    {
1113
3.14k
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
3.14k
             comdat_delf);
1115
3.14k
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
3.14k
    }
1118
1119
4.85k
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
3.60k
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
4.85k
  struct comdat_hash_entry *found
1124
4.85k
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
4.85k
  if (found != NULL)
1126
222
    {
1127
222
      struct internal_syment isym = found->isym;
1128
1129
      /* If it isn't the stuff we're expecting, die;  The MS
1130
   documentation is vague, but it appears that the second entry
1131
   serves BOTH as the comdat symbol and the defining symbol
1132
   record (either C_STAT or C_EXT, possibly with an aux entry
1133
   with debug information if it's a function.)  It appears the
1134
   only way to find the second one is to count.  (On Intel, they
1135
   appear to be adjacent, but on Alpha, they have been found
1136
   separated.)
1137
1138
   Here, we think we've found the first one, but there's some
1139
   checking we can do to be sure.  */
1140
1141
222
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
222
       && BTYPE (isym.n_type) == T_NULL && isym.n_value == 0))
1143
114
  {
1144
    /* Malformed input files can trigger this test.
1145
       cf PR 21781.  */
1146
114
    _bfd_error_handler
1147
114
      (_("%pB: error: unexpected symbol '%s' in COMDAT section"),
1148
114
       abfd, found->symname);
1149
114
    return false;
1150
114
  }
1151
1152
      /* FIXME LATER: MSVC generates section names like .text for
1153
   comdats.  Gas generates names like .text$foo__Fv (in the case
1154
   of a function).  See comment above for more.  */
1155
1156
108
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
102
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
102
            " does not match section name '%s'"),
1160
102
          abfd, found->symname, name);
1161
1162
108
      if (found->comdat_symbol != -1)
1163
3
  {
1164
3
    if (! insert_coff_comdat_info (abfd, section, found->comdat_name,
1165
3
           found->comdat_symbol))
1166
0
      return false;
1167
3
  }
1168
108
      *sec_flags = *sec_flags | found->sec_flags;
1169
108
      return true;
1170
108
    }
1171
4.63k
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
4.63k
  return true;
1173
4.85k
}
pei-aarch64.c:handle_COMDAT
Line
Count
Source
1110
2.59k
{
1111
2.59k
  if (pe_data (abfd)->comdat_hash == NULL)
1112
2.12k
    {
1113
2.12k
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
2.12k
             comdat_delf);
1115
2.12k
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
2.12k
    }
1118
1119
2.59k
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
2.20k
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
2.59k
  struct comdat_hash_entry *found
1124
2.59k
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
2.59k
  if (found != NULL)
1126
503
    {
1127
503
      struct internal_syment isym = found->isym;
1128
1129
      /* If it isn't the stuff we're expecting, die;  The MS
1130
   documentation is vague, but it appears that the second entry
1131
   serves BOTH as the comdat symbol and the defining symbol
1132
   record (either C_STAT or C_EXT, possibly with an aux entry
1133
   with debug information if it's a function.)  It appears the
1134
   only way to find the second one is to count.  (On Intel, they
1135
   appear to be adjacent, but on Alpha, they have been found
1136
   separated.)
1137
1138
   Here, we think we've found the first one, but there's some
1139
   checking we can do to be sure.  */
1140
1141
503
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
503
       && BTYPE (isym.n_type) == T_NULL && isym.n_value == 0))
1143
212
  {
1144
    /* Malformed input files can trigger this test.
1145
       cf PR 21781.  */
1146
212
    _bfd_error_handler
1147
212
      (_("%pB: error: unexpected symbol '%s' in COMDAT section"),
1148
212
       abfd, found->symname);
1149
212
    return false;
1150
212
  }
1151
1152
      /* FIXME LATER: MSVC generates section names like .text for
1153
   comdats.  Gas generates names like .text$foo__Fv (in the case
1154
   of a function).  See comment above for more.  */
1155
1156
291
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
43
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
43
            " does not match section name '%s'"),
1160
43
          abfd, found->symname, name);
1161
1162
291
      if (found->comdat_symbol != -1)
1163
18
  {
1164
18
    if (! insert_coff_comdat_info (abfd, section, found->comdat_name,
1165
18
           found->comdat_symbol))
1166
0
      return false;
1167
18
  }
1168
291
      *sec_flags = *sec_flags | found->sec_flags;
1169
291
      return true;
1170
291
    }
1171
2.09k
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
2.09k
  return true;
1173
2.59k
}
pei-ia64.c:handle_COMDAT
Line
Count
Source
1110
3.39k
{
1111
3.39k
  if (pe_data (abfd)->comdat_hash == NULL)
1112
2.54k
    {
1113
2.54k
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
2.54k
             comdat_delf);
1115
2.54k
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
2.54k
    }
1118
1119
3.39k
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
2.64k
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
3.39k
  struct comdat_hash_entry *found
1124
3.39k
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
3.39k
  if (found != NULL)
1126
707
    {
1127
707
      struct internal_syment isym = found->isym;
1128
1129
      /* If it isn't the stuff we're expecting, die;  The MS
1130
   documentation is vague, but it appears that the second entry
1131
   serves BOTH as the comdat symbol and the defining symbol
1132
   record (either C_STAT or C_EXT, possibly with an aux entry
1133
   with debug information if it's a function.)  It appears the
1134
   only way to find the second one is to count.  (On Intel, they
1135
   appear to be adjacent, but on Alpha, they have been found
1136
   separated.)
1137
1138
   Here, we think we've found the first one, but there's some
1139
   checking we can do to be sure.  */
1140
1141
707
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
707
       && BTYPE (isym.n_type) == T_NULL && isym.n_value == 0))
1143
449
  {
1144
    /* Malformed input files can trigger this test.
1145
       cf PR 21781.  */
1146
449
    _bfd_error_handler
1147
449
      (_("%pB: error: unexpected symbol '%s' in COMDAT section"),
1148
449
       abfd, found->symname);
1149
449
    return false;
1150
449
  }
1151
1152
      /* FIXME LATER: MSVC generates section names like .text for
1153
   comdats.  Gas generates names like .text$foo__Fv (in the case
1154
   of a function).  See comment above for more.  */
1155
1156
258
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
251
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
251
            " does not match section name '%s'"),
1160
251
          abfd, found->symname, name);
1161
1162
258
      if (found->comdat_symbol != -1)
1163
242
  {
1164
242
    if (! insert_coff_comdat_info (abfd, section, found->comdat_name,
1165
242
           found->comdat_symbol))
1166
0
      return false;
1167
242
  }
1168
258
      *sec_flags = *sec_flags | found->sec_flags;
1169
258
      return true;
1170
258
    }
1171
2.68k
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
2.68k
  return true;
1173
3.39k
}
pei-loongarch64.c:handle_COMDAT
Line
Count
Source
1110
3.38k
{
1111
3.38k
  if (pe_data (abfd)->comdat_hash == NULL)
1112
2.79k
    {
1113
2.79k
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
2.79k
             comdat_delf);
1115
2.79k
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
2.79k
    }
1118
1119
3.38k
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
2.99k
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
3.38k
  struct comdat_hash_entry *found
1124
3.38k
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
3.38k
  if (found != NULL)
1126
520
    {
1127
520
      struct internal_syment isym = found->isym;
1128
1129
      /* If it isn't the stuff we're expecting, die;  The MS
1130
   documentation is vague, but it appears that the second entry
1131
   serves BOTH as the comdat symbol and the defining symbol
1132
   record (either C_STAT or C_EXT, possibly with an aux entry
1133
   with debug information if it's a function.)  It appears the
1134
   only way to find the second one is to count.  (On Intel, they
1135
   appear to be adjacent, but on Alpha, they have been found
1136
   separated.)
1137
1138
   Here, we think we've found the first one, but there's some
1139
   checking we can do to be sure.  */
1140
1141
520
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
520
       && BTYPE (isym.n_type) == T_NULL && isym.n_value == 0))
1143
491
  {
1144
    /* Malformed input files can trigger this test.
1145
       cf PR 21781.  */
1146
491
    _bfd_error_handler
1147
491
      (_("%pB: error: unexpected symbol '%s' in COMDAT section"),
1148
491
       abfd, found->symname);
1149
491
    return false;
1150
491
  }
1151
1152
      /* FIXME LATER: MSVC generates section names like .text for
1153
   comdats.  Gas generates names like .text$foo__Fv (in the case
1154
   of a function).  See comment above for more.  */
1155
1156
29
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
18
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
18
            " does not match section name '%s'"),
1160
18
          abfd, found->symname, name);
1161
1162
29
      if (found->comdat_symbol != -1)
1163
2
  {
1164
2
    if (! insert_coff_comdat_info (abfd, section, found->comdat_name,
1165
2
           found->comdat_symbol))
1166
0
      return false;
1167
2
  }
1168
29
      *sec_flags = *sec_flags | found->sec_flags;
1169
29
      return true;
1170
29
    }
1171
2.86k
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
2.86k
  return true;
1173
3.38k
}
pe-arm-wince.c:handle_COMDAT
Line
Count
Source
1110
1.71k
{
1111
1.71k
  if (pe_data (abfd)->comdat_hash == NULL)
1112
1.45k
    {
1113
1.45k
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
1.45k
             comdat_delf);
1115
1.45k
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
1.45k
    }
1118
1119
1.71k
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
1.57k
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
1.71k
  struct comdat_hash_entry *found
1124
1.71k
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
1.71k
  if (found != NULL)
1126
21
    {
1127
21
      struct internal_syment isym = found->isym;
1128
1129
      /* If it isn't the stuff we're expecting, die;  The MS
1130
   documentation is vague, but it appears that the second entry
1131
   serves BOTH as the comdat symbol and the defining symbol
1132
   record (either C_STAT or C_EXT, possibly with an aux entry
1133
   with debug information if it's a function.)  It appears the
1134
   only way to find the second one is to count.  (On Intel, they
1135
   appear to be adjacent, but on Alpha, they have been found
1136
   separated.)
1137
1138
   Here, we think we've found the first one, but there's some
1139
   checking we can do to be sure.  */
1140
1141
21
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
21
       && BTYPE (isym.n_type) == T_NULL && isym.n_value == 0))
1143
5
  {
1144
    /* Malformed input files can trigger this test.
1145
       cf PR 21781.  */
1146
5
    _bfd_error_handler
1147
5
      (_("%pB: error: unexpected symbol '%s' in COMDAT section"),
1148
5
       abfd, found->symname);
1149
5
    return false;
1150
5
  }
1151
1152
      /* FIXME LATER: MSVC generates section names like .text for
1153
   comdats.  Gas generates names like .text$foo__Fv (in the case
1154
   of a function).  See comment above for more.  */
1155
1156
16
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
5
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
5
            " does not match section name '%s'"),
1160
5
          abfd, found->symname, name);
1161
1162
16
      if (found->comdat_symbol != -1)
1163
5
  {
1164
5
    if (! insert_coff_comdat_info (abfd, section, found->comdat_name,
1165
5
           found->comdat_symbol))
1166
0
      return false;
1167
5
  }
1168
16
      *sec_flags = *sec_flags | found->sec_flags;
1169
16
      return true;
1170
16
    }
1171
1.69k
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
1.69k
  return true;
1173
1.71k
}
pe-arm.c:handle_COMDAT
Line
Count
Source
1110
1.71k
{
1111
1.71k
  if (pe_data (abfd)->comdat_hash == NULL)
1112
1.45k
    {
1113
1.45k
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
1.45k
             comdat_delf);
1115
1.45k
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
1.45k
    }
1118
1119
1.71k
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
1.57k
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
1.71k
  struct comdat_hash_entry *found
1124
1.71k
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
1.71k
  if (found != NULL)
1126
21
    {
1127
21
      struct internal_syment isym = found->isym;
1128
1129
      /* If it isn't the stuff we're expecting, die;  The MS
1130
   documentation is vague, but it appears that the second entry
1131
   serves BOTH as the comdat symbol and the defining symbol
1132
   record (either C_STAT or C_EXT, possibly with an aux entry
1133
   with debug information if it's a function.)  It appears the
1134
   only way to find the second one is to count.  (On Intel, they
1135
   appear to be adjacent, but on Alpha, they have been found
1136
   separated.)
1137
1138
   Here, we think we've found the first one, but there's some
1139
   checking we can do to be sure.  */
1140
1141
21
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
21
       && BTYPE (isym.n_type) == T_NULL && isym.n_value == 0))
1143
5
  {
1144
    /* Malformed input files can trigger this test.
1145
       cf PR 21781.  */
1146
5
    _bfd_error_handler
1147
5
      (_("%pB: error: unexpected symbol '%s' in COMDAT section"),
1148
5
       abfd, found->symname);
1149
5
    return false;
1150
5
  }
1151
1152
      /* FIXME LATER: MSVC generates section names like .text for
1153
   comdats.  Gas generates names like .text$foo__Fv (in the case
1154
   of a function).  See comment above for more.  */
1155
1156
16
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
5
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
5
            " does not match section name '%s'"),
1160
5
          abfd, found->symname, name);
1161
1162
16
      if (found->comdat_symbol != -1)
1163
5
  {
1164
5
    if (! insert_coff_comdat_info (abfd, section, found->comdat_name,
1165
5
           found->comdat_symbol))
1166
0
      return false;
1167
5
  }
1168
16
      *sec_flags = *sec_flags | found->sec_flags;
1169
16
      return true;
1170
16
    }
1171
1.69k
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
1.69k
  return true;
1173
1.71k
}
pe-i386.c:handle_COMDAT
Line
Count
Source
1110
6.64k
{
1111
6.64k
  if (pe_data (abfd)->comdat_hash == NULL)
1112
4.59k
    {
1113
4.59k
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
4.59k
             comdat_delf);
1115
4.59k
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
4.59k
    }
1118
1119
6.64k
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
5.34k
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
6.64k
  struct comdat_hash_entry *found
1124
6.64k
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
6.64k
  if (found != NULL)
1126
1.26k
    {
1127
1.26k
      struct internal_syment isym = found->isym;
1128
1129
      /* If it isn't the stuff we're expecting, die;  The MS
1130
   documentation is vague, but it appears that the second entry
1131
   serves BOTH as the comdat symbol and the defining symbol
1132
   record (either C_STAT or C_EXT, possibly with an aux entry
1133
   with debug information if it's a function.)  It appears the
1134
   only way to find the second one is to count.  (On Intel, they
1135
   appear to be adjacent, but on Alpha, they have been found
1136
   separated.)
1137
1138
   Here, we think we've found the first one, but there's some
1139
   checking we can do to be sure.  */
1140
1141
1.26k
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
1.26k
       && BTYPE (isym.n_type) == T_NULL && isym.n_value == 0))
1143
726
  {
1144
    /* Malformed input files can trigger this test.
1145
       cf PR 21781.  */
1146
726
    _bfd_error_handler
1147
726
      (_("%pB: error: unexpected symbol '%s' in COMDAT section"),
1148
726
       abfd, found->symname);
1149
726
    return false;
1150
726
  }
1151
1152
      /* FIXME LATER: MSVC generates section names like .text for
1153
   comdats.  Gas generates names like .text$foo__Fv (in the case
1154
   of a function).  See comment above for more.  */
1155
1156
536
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
25
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
25
            " does not match section name '%s'"),
1160
25
          abfd, found->symname, name);
1161
1162
536
      if (found->comdat_symbol != -1)
1163
111
  {
1164
111
    if (! insert_coff_comdat_info (abfd, section, found->comdat_name,
1165
111
           found->comdat_symbol))
1166
0
      return false;
1167
111
  }
1168
536
      *sec_flags = *sec_flags | found->sec_flags;
1169
536
      return true;
1170
536
    }
1171
5.37k
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
5.37k
  return true;
1173
6.64k
}
pe-mcore.c:handle_COMDAT
Line
Count
Source
1110
2.88k
{
1111
2.88k
  if (pe_data (abfd)->comdat_hash == NULL)
1112
1.95k
    {
1113
1.95k
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
1.95k
             comdat_delf);
1115
1.95k
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
1.95k
    }
1118
1119
2.88k
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
1.96k
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
2.88k
  struct comdat_hash_entry *found
1124
2.88k
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
2.88k
  if (found != NULL)
1126
468
    {
1127
468
      struct internal_syment isym = found->isym;
1128
1129
      /* If it isn't the stuff we're expecting, die;  The MS
1130
   documentation is vague, but it appears that the second entry
1131
   serves BOTH as the comdat symbol and the defining symbol
1132
   record (either C_STAT or C_EXT, possibly with an aux entry
1133
   with debug information if it's a function.)  It appears the
1134
   only way to find the second one is to count.  (On Intel, they
1135
   appear to be adjacent, but on Alpha, they have been found
1136
   separated.)
1137
1138
   Here, we think we've found the first one, but there's some
1139
   checking we can do to be sure.  */
1140
1141
468
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
468
       && BTYPE (isym.n_type) == T_NULL && isym.n_value == 0))
1143
118
  {
1144
    /* Malformed input files can trigger this test.
1145
       cf PR 21781.  */
1146
118
    _bfd_error_handler
1147
118
      (_("%pB: error: unexpected symbol '%s' in COMDAT section"),
1148
118
       abfd, found->symname);
1149
118
    return false;
1150
118
  }
1151
1152
      /* FIXME LATER: MSVC generates section names like .text for
1153
   comdats.  Gas generates names like .text$foo__Fv (in the case
1154
   of a function).  See comment above for more.  */
1155
1156
350
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
343
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
343
            " does not match section name '%s'"),
1160
343
          abfd, found->symname, name);
1161
1162
350
      if (found->comdat_symbol != -1)
1163
4
  {
1164
4
    if (! insert_coff_comdat_info (abfd, section, found->comdat_name,
1165
4
           found->comdat_symbol))
1166
0
      return false;
1167
4
  }
1168
350
      *sec_flags = *sec_flags | found->sec_flags;
1169
350
      return true;
1170
350
    }
1171
2.41k
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
2.41k
  return true;
1173
2.88k
}
pe-sh.c:handle_COMDAT
Line
Count
Source
1110
6.58k
{
1111
6.58k
  if (pe_data (abfd)->comdat_hash == NULL)
1112
4.47k
    {
1113
4.47k
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
4.47k
             comdat_delf);
1115
4.47k
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
4.47k
    }
1118
1119
6.58k
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
6.23k
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
6.58k
  struct comdat_hash_entry *found
1124
6.58k
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
6.58k
  if (found != NULL)
1126
863
    {
1127
863
      struct internal_syment isym = found->isym;
1128
1129
      /* If it isn't the stuff we're expecting, die;  The MS
1130
   documentation is vague, but it appears that the second entry
1131
   serves BOTH as the comdat symbol and the defining symbol
1132
   record (either C_STAT or C_EXT, possibly with an aux entry
1133
   with debug information if it's a function.)  It appears the
1134
   only way to find the second one is to count.  (On Intel, they
1135
   appear to be adjacent, but on Alpha, they have been found
1136
   separated.)
1137
1138
   Here, we think we've found the first one, but there's some
1139
   checking we can do to be sure.  */
1140
1141
863
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
863
       && BTYPE (isym.n_type) == T_NULL && isym.n_value == 0))
1143
541
  {
1144
    /* Malformed input files can trigger this test.
1145
       cf PR 21781.  */
1146
541
    _bfd_error_handler
1147
541
      (_("%pB: error: unexpected symbol '%s' in COMDAT section"),
1148
541
       abfd, found->symname);
1149
541
    return false;
1150
541
  }
1151
1152
      /* FIXME LATER: MSVC generates section names like .text for
1153
   comdats.  Gas generates names like .text$foo__Fv (in the case
1154
   of a function).  See comment above for more.  */
1155
1156
322
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
109
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
109
            " does not match section name '%s'"),
1160
109
          abfd, found->symname, name);
1161
1162
322
      if (found->comdat_symbol != -1)
1163
208
  {
1164
208
    if (! insert_coff_comdat_info (abfd, section, found->comdat_name,
1165
208
           found->comdat_symbol))
1166
0
      return false;
1167
208
  }
1168
322
      *sec_flags = *sec_flags | found->sec_flags;
1169
322
      return true;
1170
322
    }
1171
5.72k
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
5.72k
  return true;
1173
6.58k
}
pei-arm-wince.c:handle_COMDAT
Line
Count
Source
1110
5.31k
{
1111
5.31k
  if (pe_data (abfd)->comdat_hash == NULL)
1112
4.06k
    {
1113
4.06k
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
4.06k
             comdat_delf);
1115
4.06k
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
4.06k
    }
1118
1119
5.31k
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
4.69k
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
5.31k
  struct comdat_hash_entry *found
1124
5.31k
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
5.31k
  if (found != NULL)
1126
783
    {
1127
783
      struct internal_syment isym = found->isym;
1128
1129
      /* If it isn't the stuff we're expecting, die;  The MS
1130
   documentation is vague, but it appears that the second entry
1131
   serves BOTH as the comdat symbol and the defining symbol
1132
   record (either C_STAT or C_EXT, possibly with an aux entry
1133
   with debug information if it's a function.)  It appears the
1134
   only way to find the second one is to count.  (On Intel, they
1135
   appear to be adjacent, but on Alpha, they have been found
1136
   separated.)
1137
1138
   Here, we think we've found the first one, but there's some
1139
   checking we can do to be sure.  */
1140
1141
783
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
783
       && BTYPE (isym.n_type) == T_NULL && isym.n_value == 0))
1143
481
  {
1144
    /* Malformed input files can trigger this test.
1145
       cf PR 21781.  */
1146
481
    _bfd_error_handler
1147
481
      (_("%pB: error: unexpected symbol '%s' in COMDAT section"),
1148
481
       abfd, found->symname);
1149
481
    return false;
1150
481
  }
1151
1152
      /* FIXME LATER: MSVC generates section names like .text for
1153
   comdats.  Gas generates names like .text$foo__Fv (in the case
1154
   of a function).  See comment above for more.  */
1155
1156
302
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
60
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
60
            " does not match section name '%s'"),
1160
60
          abfd, found->symname, name);
1161
1162
302
      if (found->comdat_symbol != -1)
1163
30
  {
1164
30
    if (! insert_coff_comdat_info (abfd, section, found->comdat_name,
1165
30
           found->comdat_symbol))
1166
0
      return false;
1167
30
  }
1168
302
      *sec_flags = *sec_flags | found->sec_flags;
1169
302
      return true;
1170
302
    }
1171
4.53k
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
4.53k
  return true;
1173
5.31k
}
pei-arm.c:handle_COMDAT
Line
Count
Source
1110
6.33k
{
1111
6.33k
  if (pe_data (abfd)->comdat_hash == NULL)
1112
4.54k
    {
1113
4.54k
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
4.54k
             comdat_delf);
1115
4.54k
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
4.54k
    }
1118
1119
6.33k
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
5.57k
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
6.33k
  struct comdat_hash_entry *found
1124
6.33k
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
6.33k
  if (found != NULL)
1126
786
    {
1127
786
      struct internal_syment isym = found->isym;
1128
1129
      /* If it isn't the stuff we're expecting, die;  The MS
1130
   documentation is vague, but it appears that the second entry
1131
   serves BOTH as the comdat symbol and the defining symbol
1132
   record (either C_STAT or C_EXT, possibly with an aux entry
1133
   with debug information if it's a function.)  It appears the
1134
   only way to find the second one is to count.  (On Intel, they
1135
   appear to be adjacent, but on Alpha, they have been found
1136
   separated.)
1137
1138
   Here, we think we've found the first one, but there's some
1139
   checking we can do to be sure.  */
1140
1141
786
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
786
       && BTYPE (isym.n_type) == T_NULL && isym.n_value == 0))
1143
482
  {
1144
    /* Malformed input files can trigger this test.
1145
       cf PR 21781.  */
1146
482
    _bfd_error_handler
1147
482
      (_("%pB: error: unexpected symbol '%s' in COMDAT section"),
1148
482
       abfd, found->symname);
1149
482
    return false;
1150
482
  }
1151
1152
      /* FIXME LATER: MSVC generates section names like .text for
1153
   comdats.  Gas generates names like .text$foo__Fv (in the case
1154
   of a function).  See comment above for more.  */
1155
1156
304
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
62
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
62
            " does not match section name '%s'"),
1160
62
          abfd, found->symname, name);
1161
1162
304
      if (found->comdat_symbol != -1)
1163
31
  {
1164
31
    if (! insert_coff_comdat_info (abfd, section, found->comdat_name,
1165
31
           found->comdat_symbol))
1166
0
      return false;
1167
31
  }
1168
304
      *sec_flags = *sec_flags | found->sec_flags;
1169
304
      return true;
1170
304
    }
1171
5.55k
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
5.55k
  return true;
1173
6.33k
}
pei-mcore.c:handle_COMDAT
Line
Count
Source
1110
6.88k
{
1111
6.88k
  if (pe_data (abfd)->comdat_hash == NULL)
1112
4.41k
    {
1113
4.41k
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
4.41k
             comdat_delf);
1115
4.41k
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
4.41k
    }
1118
1119
6.88k
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
4.83k
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
6.88k
  struct comdat_hash_entry *found
1124
6.88k
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
6.88k
  if (found != NULL)
1126
751
    {
1127
751
      struct internal_syment isym = found->isym;
1128
1129
      /* If it isn't the stuff we're expecting, die;  The MS
1130
   documentation is vague, but it appears that the second entry
1131
   serves BOTH as the comdat symbol and the defining symbol
1132
   record (either C_STAT or C_EXT, possibly with an aux entry
1133
   with debug information if it's a function.)  It appears the
1134
   only way to find the second one is to count.  (On Intel, they
1135
   appear to be adjacent, but on Alpha, they have been found
1136
   separated.)
1137
1138
   Here, we think we've found the first one, but there's some
1139
   checking we can do to be sure.  */
1140
1141
751
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
751
       && BTYPE (isym.n_type) == T_NULL && isym.n_value == 0))
1143
480
  {
1144
    /* Malformed input files can trigger this test.
1145
       cf PR 21781.  */
1146
480
    _bfd_error_handler
1147
480
      (_("%pB: error: unexpected symbol '%s' in COMDAT section"),
1148
480
       abfd, found->symname);
1149
480
    return false;
1150
480
  }
1151
1152
      /* FIXME LATER: MSVC generates section names like .text for
1153
   comdats.  Gas generates names like .text$foo__Fv (in the case
1154
   of a function).  See comment above for more.  */
1155
1156
271
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
269
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
269
            " does not match section name '%s'"),
1160
269
          abfd, found->symname, name);
1161
1162
271
      if (found->comdat_symbol != -1)
1163
18
  {
1164
18
    if (! insert_coff_comdat_info (abfd, section, found->comdat_name,
1165
18
           found->comdat_symbol))
1166
0
      return false;
1167
18
  }
1168
271
      *sec_flags = *sec_flags | found->sec_flags;
1169
271
      return true;
1170
271
    }
1171
6.13k
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
6.13k
  return true;
1173
6.88k
}
pei-sh.c:handle_COMDAT
Line
Count
Source
1110
3.66k
{
1111
3.66k
  if (pe_data (abfd)->comdat_hash == NULL)
1112
3.01k
    {
1113
3.01k
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
3.01k
             comdat_delf);
1115
3.01k
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
3.01k
    }
1118
1119
3.66k
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
3.16k
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
3.66k
  struct comdat_hash_entry *found
1124
3.66k
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
3.66k
  if (found != NULL)
1126
481
    {
1127
481
      struct internal_syment isym = found->isym;
1128
1129
      /* If it isn't the stuff we're expecting, die;  The MS
1130
   documentation is vague, but it appears that the second entry
1131
   serves BOTH as the comdat symbol and the defining symbol
1132
   record (either C_STAT or C_EXT, possibly with an aux entry
1133
   with debug information if it's a function.)  It appears the
1134
   only way to find the second one is to count.  (On Intel, they
1135
   appear to be adjacent, but on Alpha, they have been found
1136
   separated.)
1137
1138
   Here, we think we've found the first one, but there's some
1139
   checking we can do to be sure.  */
1140
1141
481
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
481
       && BTYPE (isym.n_type) == T_NULL && isym.n_value == 0))
1143
476
  {
1144
    /* Malformed input files can trigger this test.
1145
       cf PR 21781.  */
1146
476
    _bfd_error_handler
1147
476
      (_("%pB: error: unexpected symbol '%s' in COMDAT section"),
1148
476
       abfd, found->symname);
1149
476
    return false;
1150
476
  }
1151
1152
      /* FIXME LATER: MSVC generates section names like .text for
1153
   comdats.  Gas generates names like .text$foo__Fv (in the case
1154
   of a function).  See comment above for more.  */
1155
1156
5
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
5
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
5
            " does not match section name '%s'"),
1160
5
          abfd, found->symname, name);
1161
1162
5
      if (found->comdat_symbol != -1)
1163
1
  {
1164
1
    if (! insert_coff_comdat_info (abfd, section, found->comdat_name,
1165
1
           found->comdat_symbol))
1166
0
      return false;
1167
1
  }
1168
5
      *sec_flags = *sec_flags | found->sec_flags;
1169
5
      return true;
1170
5
    }
1171
3.18k
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
3.18k
  return true;
1173
3.66k
}
1174
1175
1176
/* The PE version; see above for the general comments.
1177
1178
   Since to set the SEC_LINK_ONCE and associated flags, we have to
1179
   look at the symbol table anyway, we return the symbol table index
1180
   of the symbol being used as the COMDAT symbol.  This is admittedly
1181
   ugly, but there's really nowhere else that we have access to the
1182
   required information.  FIXME: Is the COMDAT symbol index used for
1183
   any purpose other than objdump?  */
1184
1185
static bool
1186
styp_to_sec_flags (bfd *abfd,
1187
       void * hdr,
1188
       const char *name,
1189
       asection *section,
1190
       flagword *flags_ptr)
1191
439k
{
1192
439k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
439k
  unsigned long styp_flags = internal_s->s_flags;
1194
439k
  flagword sec_flags;
1195
439k
  bool result = true;
1196
439k
  bool is_dbg = false;
1197
1198
439k
  if (startswith (name, DOT_DEBUG)
1199
439k
      || startswith (name, DOT_ZDEBUG)
1200
439k
#ifdef COFF_LONG_SECTION_NAMES
1201
439k
      || startswith (name, GNU_LINKONCE_WI)
1202
439k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
439k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
439k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
439k
      || startswith (name, GNU_DEBUGLINK)
1207
439k
      || startswith (name, GNU_DEBUGALTLINK)
1208
439k
#endif
1209
439k
      || startswith (name, ".stab"))
1210
22.2k
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
439k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
439k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
369k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
2.54M
  while (styp_flags)
1220
2.10M
    {
1221
2.10M
      unsigned long flag = styp_flags & - styp_flags;
1222
2.10M
      char * unhandled = NULL;
1223
1224
2.10M
      styp_flags &= ~ flag;
1225
1226
      /* We infer from the distinct read/write/execute bits the settings
1227
   of some of the bfd flags; the actual values, should we need them,
1228
   are also in pei_section_data (abfd, section)->pe_flags.  */
1229
1230
2.10M
      switch (flag)
1231
2.10M
  {
1232
30.8k
  case STYP_DSECT:
1233
30.8k
    unhandled = "STYP_DSECT";
1234
30.8k
    break;
1235
27.5k
  case STYP_GROUP:
1236
27.5k
    unhandled = "STYP_GROUP";
1237
27.5k
    break;
1238
31.0k
  case STYP_COPY:
1239
31.0k
    unhandled = "STYP_COPY";
1240
31.0k
    break;
1241
30.6k
  case STYP_OVER:
1242
30.6k
    unhandled = "STYP_OVER";
1243
30.6k
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
74.0k
  case STYP_NOLOAD:
1246
74.0k
    sec_flags |= SEC_NEVER_LOAD;
1247
74.0k
    break;
1248
0
#endif
1249
70.0k
  case IMAGE_SCN_MEM_READ:
1250
70.0k
    sec_flags &= ~SEC_COFF_NOREAD;
1251
70.0k
    break;
1252
59.0k
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
59.0k
    break;
1255
34.8k
  case IMAGE_SCN_LNK_OTHER:
1256
34.8k
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
34.8k
    break;
1258
32.7k
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
32.7k
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
32.7k
    break;
1261
69.8k
  case IMAGE_SCN_MEM_NOT_PAGED:
1262
    /* Generate a warning message rather using the 'unhandled'
1263
       variable as this will allow some .sys files generate by
1264
       other toolchains to be processed.  See bugzilla issue 196.  */
1265
    /* xgettext:c-format */
1266
69.8k
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
69.8k
        " %s in section %s"),
1268
69.8k
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
69.8k
    break;
1270
86.9k
  case IMAGE_SCN_MEM_EXECUTE:
1271
86.9k
    sec_flags |= SEC_CODE;
1272
86.9k
    break;
1273
67.1k
  case IMAGE_SCN_MEM_WRITE:
1274
67.1k
    sec_flags &= ~ SEC_READONLY;
1275
67.1k
    break;
1276
78.6k
  case IMAGE_SCN_MEM_DISCARDABLE:
1277
    /* The MS PE spec says that debug sections are DISCARDABLE,
1278
       but the presence of a DISCARDABLE flag does not necessarily
1279
       mean that a given section contains debug information.  Thus
1280
       we only set the SEC_DEBUGGING flag on sections that we
1281
       recognise as containing debug information.  */
1282
78.6k
       if (is_dbg
1283
78.6k
#ifdef _COMMENT
1284
78.6k
        || strcmp (name, _COMMENT) == 0
1285
78.6k
#endif
1286
78.6k
        )
1287
11.7k
      {
1288
11.7k
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
11.7k
      }
1290
78.6k
    break;
1291
56.9k
  case IMAGE_SCN_MEM_SHARED:
1292
56.9k
    sec_flags |= SEC_COFF_SHARED;
1293
56.9k
    break;
1294
91.8k
  case IMAGE_SCN_LNK_REMOVE:
1295
91.8k
    if (!is_dbg)
1296
85.0k
      sec_flags |= SEC_EXCLUDE;
1297
91.8k
    break;
1298
80.3k
  case IMAGE_SCN_CNT_CODE:
1299
80.3k
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
80.3k
    break;
1301
62.0k
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
62.0k
    if (is_dbg)
1303
6.02k
      sec_flags |= SEC_DEBUGGING;
1304
56.0k
    else
1305
56.0k
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
62.0k
    break;
1307
55.7k
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
55.7k
    sec_flags |= SEC_ALLOC;
1309
55.7k
    break;
1310
70.1k
  case IMAGE_SCN_LNK_INFO:
1311
    /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is
1312
       defined.  coff_compute_section_file_positions uses
1313
       COFF_PAGE_SIZE to ensure that the low order bits of the
1314
       section VMA and the file offset match.  If we don't know
1315
       COFF_PAGE_SIZE, we can't ensure the correct correspondence,
1316
       and demand page loading of the file will fail.  */
1317
#ifdef COFF_PAGE_SIZE
1318
66.7k
    sec_flags |= SEC_DEBUGGING;
1319
#endif
1320
70.1k
    break;
1321
89.0k
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
89.0k
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
6.07k
      result = false;
1325
89.0k
    break;
1326
903k
  default:
1327
    /* Silently ignore for now.  */
1328
903k
    break;
1329
2.10M
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
2.10M
      if (unhandled != NULL)
1333
187k
  {
1334
187k
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
187k
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
187k
       abfd, name, unhandled, flag);
1338
187k
    result = false;
1339
187k
  }
1340
2.10M
    }
1341
1342
439k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
439k
      && (startswith (name, ".sbss")
1344
0
    || startswith (name, ".sdata")))
1345
0
    sec_flags |= SEC_SMALL_DATA;
1346
1347
#if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE)
1348
  /* As a GNU extension, if the name begins with .gnu.linkonce, we
1349
     only link a single copy of the section.  This is used to support
1350
     g++.  g++ will emit each template expansion in its own section.
1351
     The symbols will be defined as weak, so that multiple definitions
1352
     are permitted.  The GNU linker extension is to actually discard
1353
     all but one of the sections.  */
1354
203k
  if (startswith (name, ".gnu.linkonce"))
1355
127
    sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
1356
#endif
1357
1358
439k
  if (flags_ptr)
1359
439k
    * flags_ptr = sec_flags;
1360
1361
439k
  return result;
1362
439k
}
pei-i386.c:styp_to_sec_flags
Line
Count
Source
1191
121k
{
1192
121k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
121k
  unsigned long styp_flags = internal_s->s_flags;
1194
121k
  flagword sec_flags;
1195
121k
  bool result = true;
1196
121k
  bool is_dbg = false;
1197
1198
121k
  if (startswith (name, DOT_DEBUG)
1199
121k
      || startswith (name, DOT_ZDEBUG)
1200
121k
#ifdef COFF_LONG_SECTION_NAMES
1201
121k
      || startswith (name, GNU_LINKONCE_WI)
1202
121k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
121k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
121k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
121k
      || startswith (name, GNU_DEBUGLINK)
1207
121k
      || startswith (name, GNU_DEBUGALTLINK)
1208
121k
#endif
1209
121k
      || startswith (name, ".stab"))
1210
2.11k
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
121k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
121k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
116k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
332k
  while (styp_flags)
1220
211k
    {
1221
211k
      unsigned long flag = styp_flags & - styp_flags;
1222
211k
      char * unhandled = NULL;
1223
1224
211k
      styp_flags &= ~ flag;
1225
1226
      /* We infer from the distinct read/write/execute bits the settings
1227
   of some of the bfd flags; the actual values, should we need them,
1228
   are also in pei_section_data (abfd, section)->pe_flags.  */
1229
1230
211k
      switch (flag)
1231
211k
  {
1232
2.11k
  case STYP_DSECT:
1233
2.11k
    unhandled = "STYP_DSECT";
1234
2.11k
    break;
1235
2.27k
  case STYP_GROUP:
1236
2.27k
    unhandled = "STYP_GROUP";
1237
2.27k
    break;
1238
1.66k
  case STYP_COPY:
1239
1.66k
    unhandled = "STYP_COPY";
1240
1.66k
    break;
1241
1.27k
  case STYP_OVER:
1242
1.27k
    unhandled = "STYP_OVER";
1243
1.27k
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
4.02k
  case STYP_NOLOAD:
1246
4.02k
    sec_flags |= SEC_NEVER_LOAD;
1247
4.02k
    break;
1248
0
#endif
1249
5.22k
  case IMAGE_SCN_MEM_READ:
1250
5.22k
    sec_flags &= ~SEC_COFF_NOREAD;
1251
5.22k
    break;
1252
3.70k
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
3.70k
    break;
1255
2.28k
  case IMAGE_SCN_LNK_OTHER:
1256
2.28k
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
2.28k
    break;
1258
2.04k
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
2.04k
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
2.04k
    break;
1261
5.52k
  case IMAGE_SCN_MEM_NOT_PAGED:
1262
    /* Generate a warning message rather using the 'unhandled'
1263
       variable as this will allow some .sys files generate by
1264
       other toolchains to be processed.  See bugzilla issue 196.  */
1265
    /* xgettext:c-format */
1266
5.52k
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
5.52k
        " %s in section %s"),
1268
5.52k
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
5.52k
    break;
1270
8.31k
  case IMAGE_SCN_MEM_EXECUTE:
1271
8.31k
    sec_flags |= SEC_CODE;
1272
8.31k
    break;
1273
2.71k
  case IMAGE_SCN_MEM_WRITE:
1274
2.71k
    sec_flags &= ~ SEC_READONLY;
1275
2.71k
    break;
1276
3.43k
  case IMAGE_SCN_MEM_DISCARDABLE:
1277
    /* The MS PE spec says that debug sections are DISCARDABLE,
1278
       but the presence of a DISCARDABLE flag does not necessarily
1279
       mean that a given section contains debug information.  Thus
1280
       we only set the SEC_DEBUGGING flag on sections that we
1281
       recognise as containing debug information.  */
1282
3.43k
       if (is_dbg
1283
3.43k
#ifdef _COMMENT
1284
3.43k
        || strcmp (name, _COMMENT) == 0
1285
3.43k
#endif
1286
3.43k
        )
1287
1.40k
      {
1288
1.40k
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
1.40k
      }
1290
3.43k
    break;
1291
4.40k
  case IMAGE_SCN_MEM_SHARED:
1292
4.40k
    sec_flags |= SEC_COFF_SHARED;
1293
4.40k
    break;
1294
22.7k
  case IMAGE_SCN_LNK_REMOVE:
1295
22.7k
    if (!is_dbg)
1296
21.8k
      sec_flags |= SEC_EXCLUDE;
1297
22.7k
    break;
1298
6.21k
  case IMAGE_SCN_CNT_CODE:
1299
6.21k
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
6.21k
    break;
1301
1.81k
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
1.81k
    if (is_dbg)
1303
286
      sec_flags |= SEC_DEBUGGING;
1304
1.52k
    else
1305
1.52k
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
1.81k
    break;
1307
2.44k
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
2.44k
    sec_flags |= SEC_ALLOC;
1309
2.44k
    break;
1310
2.66k
  case IMAGE_SCN_LNK_INFO:
1311
    /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is
1312
       defined.  coff_compute_section_file_positions uses
1313
       COFF_PAGE_SIZE to ensure that the low order bits of the
1314
       section VMA and the file offset match.  If we don't know
1315
       COFF_PAGE_SIZE, we can't ensure the correct correspondence,
1316
       and demand page loading of the file will fail.  */
1317
2.66k
#ifdef COFF_PAGE_SIZE
1318
2.66k
    sec_flags |= SEC_DEBUGGING;
1319
2.66k
#endif
1320
2.66k
    break;
1321
17.1k
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
17.1k
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
727
      result = false;
1325
17.1k
    break;
1326
109k
  default:
1327
    /* Silently ignore for now.  */
1328
109k
    break;
1329
211k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
211k
      if (unhandled != NULL)
1333
11.6k
  {
1334
11.6k
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
11.6k
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
11.6k
       abfd, name, unhandled, flag);
1338
11.6k
    result = false;
1339
11.6k
  }
1340
211k
    }
1341
1342
121k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
121k
      && (startswith (name, ".sbss")
1344
0
    || startswith (name, ".sdata")))
1345
0
    sec_flags |= SEC_SMALL_DATA;
1346
1347
121k
#if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE)
1348
  /* As a GNU extension, if the name begins with .gnu.linkonce, we
1349
     only link a single copy of the section.  This is used to support
1350
     g++.  g++ will emit each template expansion in its own section.
1351
     The symbols will be defined as weak, so that multiple definitions
1352
     are permitted.  The GNU linker extension is to actually discard
1353
     all but one of the sections.  */
1354
121k
  if (startswith (name, ".gnu.linkonce"))
1355
10
    sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
1356
121k
#endif
1357
1358
121k
  if (flags_ptr)
1359
121k
    * flags_ptr = sec_flags;
1360
1361
121k
  return result;
1362
121k
}
pe-x86_64.c:styp_to_sec_flags
Line
Count
Source
1191
42.2k
{
1192
42.2k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
42.2k
  unsigned long styp_flags = internal_s->s_flags;
1194
42.2k
  flagword sec_flags;
1195
42.2k
  bool result = true;
1196
42.2k
  bool is_dbg = false;
1197
1198
42.2k
  if (startswith (name, DOT_DEBUG)
1199
42.2k
      || startswith (name, DOT_ZDEBUG)
1200
42.2k
#ifdef COFF_LONG_SECTION_NAMES
1201
42.2k
      || startswith (name, GNU_LINKONCE_WI)
1202
42.2k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
42.2k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
42.2k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
42.2k
      || startswith (name, GNU_DEBUGLINK)
1207
42.2k
      || startswith (name, GNU_DEBUGALTLINK)
1208
42.2k
#endif
1209
42.2k
      || startswith (name, ".stab"))
1210
4.24k
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
42.2k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
42.2k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
36.2k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
301k
  while (styp_flags)
1220
259k
    {
1221
259k
      unsigned long flag = styp_flags & - styp_flags;
1222
259k
      char * unhandled = NULL;
1223
1224
259k
      styp_flags &= ~ flag;
1225
1226
      /* We infer from the distinct read/write/execute bits the settings
1227
   of some of the bfd flags; the actual values, should we need them,
1228
   are also in pei_section_data (abfd, section)->pe_flags.  */
1229
1230
259k
      switch (flag)
1231
259k
  {
1232
4.46k
  case STYP_DSECT:
1233
4.46k
    unhandled = "STYP_DSECT";
1234
4.46k
    break;
1235
3.70k
  case STYP_GROUP:
1236
3.70k
    unhandled = "STYP_GROUP";
1237
3.70k
    break;
1238
4.16k
  case STYP_COPY:
1239
4.16k
    unhandled = "STYP_COPY";
1240
4.16k
    break;
1241
3.17k
  case STYP_OVER:
1242
3.17k
    unhandled = "STYP_OVER";
1243
3.17k
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
11.1k
  case STYP_NOLOAD:
1246
11.1k
    sec_flags |= SEC_NEVER_LOAD;
1247
11.1k
    break;
1248
0
#endif
1249
6.04k
  case IMAGE_SCN_MEM_READ:
1250
6.04k
    sec_flags &= ~SEC_COFF_NOREAD;
1251
6.04k
    break;
1252
8.71k
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
8.71k
    break;
1255
6.03k
  case IMAGE_SCN_LNK_OTHER:
1256
6.03k
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
6.03k
    break;
1258
4.77k
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
4.77k
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
4.77k
    break;
1261
7.16k
  case IMAGE_SCN_MEM_NOT_PAGED:
1262
    /* Generate a warning message rather using the 'unhandled'
1263
       variable as this will allow some .sys files generate by
1264
       other toolchains to be processed.  See bugzilla issue 196.  */
1265
    /* xgettext:c-format */
1266
7.16k
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
7.16k
        " %s in section %s"),
1268
7.16k
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
7.16k
    break;
1270
12.1k
  case IMAGE_SCN_MEM_EXECUTE:
1271
12.1k
    sec_flags |= SEC_CODE;
1272
12.1k
    break;
1273
10.6k
  case IMAGE_SCN_MEM_WRITE:
1274
10.6k
    sec_flags &= ~ SEC_READONLY;
1275
10.6k
    break;
1276
8.56k
  case IMAGE_SCN_MEM_DISCARDABLE:
1277
    /* The MS PE spec says that debug sections are DISCARDABLE,
1278
       but the presence of a DISCARDABLE flag does not necessarily
1279
       mean that a given section contains debug information.  Thus
1280
       we only set the SEC_DEBUGGING flag on sections that we
1281
       recognise as containing debug information.  */
1282
8.56k
       if (is_dbg
1283
8.56k
#ifdef _COMMENT
1284
8.56k
        || strcmp (name, _COMMENT) == 0
1285
8.56k
#endif
1286
8.56k
        )
1287
1.08k
      {
1288
1.08k
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
1.08k
      }
1290
8.56k
    break;
1291
13.4k
  case IMAGE_SCN_MEM_SHARED:
1292
13.4k
    sec_flags |= SEC_COFF_SHARED;
1293
13.4k
    break;
1294
7.71k
  case IMAGE_SCN_LNK_REMOVE:
1295
7.71k
    if (!is_dbg)
1296
7.16k
      sec_flags |= SEC_EXCLUDE;
1297
7.71k
    break;
1298
12.4k
  case IMAGE_SCN_CNT_CODE:
1299
12.4k
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
12.4k
    break;
1301
5.93k
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
5.93k
    if (is_dbg)
1303
838
      sec_flags |= SEC_DEBUGGING;
1304
5.10k
    else
1305
5.10k
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
5.93k
    break;
1307
4.22k
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
4.22k
    sec_flags |= SEC_ALLOC;
1309
4.22k
    break;
1310
5.25k
  case IMAGE_SCN_LNK_INFO:
1311
    /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is
1312
       defined.  coff_compute_section_file_positions uses
1313
       COFF_PAGE_SIZE to ensure that the low order bits of the
1314
       section VMA and the file offset match.  If we don't know
1315
       COFF_PAGE_SIZE, we can't ensure the correct correspondence,
1316
       and demand page loading of the file will fail.  */
1317
5.25k
#ifdef COFF_PAGE_SIZE
1318
5.25k
    sec_flags |= SEC_DEBUGGING;
1319
5.25k
#endif
1320
5.25k
    break;
1321
10.9k
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
10.9k
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
423
      result = false;
1325
10.9k
    break;
1326
108k
  default:
1327
    /* Silently ignore for now.  */
1328
108k
    break;
1329
259k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
259k
      if (unhandled != NULL)
1333
26.3k
  {
1334
26.3k
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
26.3k
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
26.3k
       abfd, name, unhandled, flag);
1338
26.3k
    result = false;
1339
26.3k
  }
1340
259k
    }
1341
1342
42.2k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
42.2k
      && (startswith (name, ".sbss")
1344
0
    || startswith (name, ".sdata")))
1345
0
    sec_flags |= SEC_SMALL_DATA;
1346
1347
42.2k
#if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE)
1348
  /* As a GNU extension, if the name begins with .gnu.linkonce, we
1349
     only link a single copy of the section.  This is used to support
1350
     g++.  g++ will emit each template expansion in its own section.
1351
     The symbols will be defined as weak, so that multiple definitions
1352
     are permitted.  The GNU linker extension is to actually discard
1353
     all but one of the sections.  */
1354
42.2k
  if (startswith (name, ".gnu.linkonce"))
1355
0
    sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
1356
42.2k
#endif
1357
1358
42.2k
  if (flags_ptr)
1359
42.2k
    * flags_ptr = sec_flags;
1360
1361
42.2k
  return result;
1362
42.2k
}
pei-x86_64.c:styp_to_sec_flags
Line
Count
Source
1191
23.6k
{
1192
23.6k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
23.6k
  unsigned long styp_flags = internal_s->s_flags;
1194
23.6k
  flagword sec_flags;
1195
23.6k
  bool result = true;
1196
23.6k
  bool is_dbg = false;
1197
1198
23.6k
  if (startswith (name, DOT_DEBUG)
1199
23.6k
      || startswith (name, DOT_ZDEBUG)
1200
23.6k
#ifdef COFF_LONG_SECTION_NAMES
1201
23.6k
      || startswith (name, GNU_LINKONCE_WI)
1202
23.6k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
23.6k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
23.6k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
23.6k
      || startswith (name, GNU_DEBUGLINK)
1207
23.6k
      || startswith (name, GNU_DEBUGALTLINK)
1208
23.6k
#endif
1209
23.6k
      || startswith (name, ".stab"))
1210
1.74k
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
23.6k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
23.6k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
17.0k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
183k
  while (styp_flags)
1220
159k
    {
1221
159k
      unsigned long flag = styp_flags & - styp_flags;
1222
159k
      char * unhandled = NULL;
1223
1224
159k
      styp_flags &= ~ flag;
1225
1226
      /* We infer from the distinct read/write/execute bits the settings
1227
   of some of the bfd flags; the actual values, should we need them,
1228
   are also in pei_section_data (abfd, section)->pe_flags.  */
1229
1230
159k
      switch (flag)
1231
159k
  {
1232
2.52k
  case STYP_DSECT:
1233
2.52k
    unhandled = "STYP_DSECT";
1234
2.52k
    break;
1235
2.33k
  case STYP_GROUP:
1236
2.33k
    unhandled = "STYP_GROUP";
1237
2.33k
    break;
1238
2.43k
  case STYP_COPY:
1239
2.43k
    unhandled = "STYP_COPY";
1240
2.43k
    break;
1241
2.91k
  case STYP_OVER:
1242
2.91k
    unhandled = "STYP_OVER";
1243
2.91k
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
6.52k
  case STYP_NOLOAD:
1246
6.52k
    sec_flags |= SEC_NEVER_LOAD;
1247
6.52k
    break;
1248
0
#endif
1249
6.53k
  case IMAGE_SCN_MEM_READ:
1250
6.53k
    sec_flags &= ~SEC_COFF_NOREAD;
1251
6.53k
    break;
1252
3.98k
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
3.98k
    break;
1255
3.27k
  case IMAGE_SCN_LNK_OTHER:
1256
3.27k
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
3.27k
    break;
1258
1.60k
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
1.60k
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
1.60k
    break;
1261
4.85k
  case IMAGE_SCN_MEM_NOT_PAGED:
1262
    /* Generate a warning message rather using the 'unhandled'
1263
       variable as this will allow some .sys files generate by
1264
       other toolchains to be processed.  See bugzilla issue 196.  */
1265
    /* xgettext:c-format */
1266
4.85k
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
4.85k
        " %s in section %s"),
1268
4.85k
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
4.85k
    break;
1270
7.41k
  case IMAGE_SCN_MEM_EXECUTE:
1271
7.41k
    sec_flags |= SEC_CODE;
1272
7.41k
    break;
1273
5.49k
  case IMAGE_SCN_MEM_WRITE:
1274
5.49k
    sec_flags &= ~ SEC_READONLY;
1275
5.49k
    break;
1276
5.95k
  case IMAGE_SCN_MEM_DISCARDABLE:
1277
    /* The MS PE spec says that debug sections are DISCARDABLE,
1278
       but the presence of a DISCARDABLE flag does not necessarily
1279
       mean that a given section contains debug information.  Thus
1280
       we only set the SEC_DEBUGGING flag on sections that we
1281
       recognise as containing debug information.  */
1282
5.95k
       if (is_dbg
1283
5.95k
#ifdef _COMMENT
1284
5.95k
        || strcmp (name, _COMMENT) == 0
1285
5.95k
#endif
1286
5.95k
        )
1287
989
      {
1288
989
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
989
      }
1290
5.95k
    break;
1291
3.33k
  case IMAGE_SCN_MEM_SHARED:
1292
3.33k
    sec_flags |= SEC_COFF_SHARED;
1293
3.33k
    break;
1294
5.48k
  case IMAGE_SCN_LNK_REMOVE:
1295
5.48k
    if (!is_dbg)
1296
4.87k
      sec_flags |= SEC_EXCLUDE;
1297
5.48k
    break;
1298
7.38k
  case IMAGE_SCN_CNT_CODE:
1299
7.38k
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
7.38k
    break;
1301
6.64k
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
6.64k
    if (is_dbg)
1303
1.03k
      sec_flags |= SEC_DEBUGGING;
1304
5.61k
    else
1305
5.61k
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
6.64k
    break;
1307
5.78k
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
5.78k
    sec_flags |= SEC_ALLOC;
1309
5.78k
    break;
1310
6.29k
  case IMAGE_SCN_LNK_INFO:
1311
    /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is
1312
       defined.  coff_compute_section_file_positions uses
1313
       COFF_PAGE_SIZE to ensure that the low order bits of the
1314
       section VMA and the file offset match.  If we don't know
1315
       COFF_PAGE_SIZE, we can't ensure the correct correspondence,
1316
       and demand page loading of the file will fail.  */
1317
6.29k
#ifdef COFF_PAGE_SIZE
1318
6.29k
    sec_flags |= SEC_DEBUGGING;
1319
6.29k
#endif
1320
6.29k
    break;
1321
5.02k
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
5.02k
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
349
      result = false;
1325
5.02k
    break;
1326
63.8k
  default:
1327
    /* Silently ignore for now.  */
1328
63.8k
    break;
1329
159k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
159k
      if (unhandled != NULL)
1333
15.0k
  {
1334
15.0k
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
15.0k
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
15.0k
       abfd, name, unhandled, flag);
1338
15.0k
    result = false;
1339
15.0k
  }
1340
159k
    }
1341
1342
23.6k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
23.6k
      && (startswith (name, ".sbss")
1344
0
    || startswith (name, ".sdata")))
1345
0
    sec_flags |= SEC_SMALL_DATA;
1346
1347
23.6k
#if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE)
1348
  /* As a GNU extension, if the name begins with .gnu.linkonce, we
1349
     only link a single copy of the section.  This is used to support
1350
     g++.  g++ will emit each template expansion in its own section.
1351
     The symbols will be defined as weak, so that multiple definitions
1352
     are permitted.  The GNU linker extension is to actually discard
1353
     all but one of the sections.  */
1354
23.6k
  if (startswith (name, ".gnu.linkonce"))
1355
3
    sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
1356
23.6k
#endif
1357
1358
23.6k
  if (flags_ptr)
1359
23.6k
    * flags_ptr = sec_flags;
1360
1361
23.6k
  return result;
1362
23.6k
}
pe-aarch64.c:styp_to_sec_flags
Line
Count
Source
1191
35.8k
{
1192
35.8k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
35.8k
  unsigned long styp_flags = internal_s->s_flags;
1194
35.8k
  flagword sec_flags;
1195
35.8k
  bool result = true;
1196
35.8k
  bool is_dbg = false;
1197
1198
35.8k
  if (startswith (name, DOT_DEBUG)
1199
35.8k
      || startswith (name, DOT_ZDEBUG)
1200
35.8k
#ifdef COFF_LONG_SECTION_NAMES
1201
35.8k
      || startswith (name, GNU_LINKONCE_WI)
1202
35.8k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
35.8k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
35.8k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
35.8k
      || startswith (name, GNU_DEBUGLINK)
1207
35.8k
      || startswith (name, GNU_DEBUGALTLINK)
1208
35.8k
#endif
1209
35.8k
      || startswith (name, ".stab"))
1210
1.02k
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
35.8k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
35.8k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
25.8k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
242k
  while (styp_flags)
1220
207k
    {
1221
207k
      unsigned long flag = styp_flags & - styp_flags;
1222
207k
      char * unhandled = NULL;
1223
1224
207k
      styp_flags &= ~ flag;
1225
1226
      /* We infer from the distinct read/write/execute bits the settings
1227
   of some of the bfd flags; the actual values, should we need them,
1228
   are also in pei_section_data (abfd, section)->pe_flags.  */
1229
1230
207k
      switch (flag)
1231
207k
  {
1232
1.17k
  case STYP_DSECT:
1233
1.17k
    unhandled = "STYP_DSECT";
1234
1.17k
    break;
1235
857
  case STYP_GROUP:
1236
857
    unhandled = "STYP_GROUP";
1237
857
    break;
1238
1.38k
  case STYP_COPY:
1239
1.38k
    unhandled = "STYP_COPY";
1240
1.38k
    break;
1241
1.37k
  case STYP_OVER:
1242
1.37k
    unhandled = "STYP_OVER";
1243
1.37k
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
9.36k
  case STYP_NOLOAD:
1246
9.36k
    sec_flags |= SEC_NEVER_LOAD;
1247
9.36k
    break;
1248
0
#endif
1249
10.0k
  case IMAGE_SCN_MEM_READ:
1250
10.0k
    sec_flags &= ~SEC_COFF_NOREAD;
1251
10.0k
    break;
1252
7.30k
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
7.30k
    break;
1255
1.18k
  case IMAGE_SCN_LNK_OTHER:
1256
1.18k
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
1.18k
    break;
1258
1.37k
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
1.37k
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
1.37k
    break;
1261
8.76k
  case IMAGE_SCN_MEM_NOT_PAGED:
1262
    /* Generate a warning message rather using the 'unhandled'
1263
       variable as this will allow some .sys files generate by
1264
       other toolchains to be processed.  See bugzilla issue 196.  */
1265
    /* xgettext:c-format */
1266
8.76k
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
8.76k
        " %s in section %s"),
1268
8.76k
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
8.76k
    break;
1270
7.72k
  case IMAGE_SCN_MEM_EXECUTE:
1271
7.72k
    sec_flags |= SEC_CODE;
1272
7.72k
    break;
1273
11.6k
  case IMAGE_SCN_MEM_WRITE:
1274
11.6k
    sec_flags &= ~ SEC_READONLY;
1275
11.6k
    break;
1276
8.47k
  case IMAGE_SCN_MEM_DISCARDABLE:
1277
    /* The MS PE spec says that debug sections are DISCARDABLE,
1278
       but the presence of a DISCARDABLE flag does not necessarily
1279
       mean that a given section contains debug information.  Thus
1280
       we only set the SEC_DEBUGGING flag on sections that we
1281
       recognise as containing debug information.  */
1282
8.47k
       if (is_dbg
1283
8.47k
#ifdef _COMMENT
1284
8.47k
        || strcmp (name, _COMMENT) == 0
1285
8.47k
#endif
1286
8.47k
        )
1287
1.01k
      {
1288
1.01k
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
1.01k
      }
1290
8.47k
    break;
1291
3.81k
  case IMAGE_SCN_MEM_SHARED:
1292
3.81k
    sec_flags |= SEC_COFF_SHARED;
1293
3.81k
    break;
1294
8.13k
  case IMAGE_SCN_LNK_REMOVE:
1295
8.13k
    if (!is_dbg)
1296
7.93k
      sec_flags |= SEC_EXCLUDE;
1297
8.13k
    break;
1298
4.22k
  case IMAGE_SCN_CNT_CODE:
1299
4.22k
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
4.22k
    break;
1301
7.88k
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
7.88k
    if (is_dbg)
1303
206
      sec_flags |= SEC_DEBUGGING;
1304
7.67k
    else
1305
7.67k
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
7.88k
    break;
1307
12.0k
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
12.0k
    sec_flags |= SEC_ALLOC;
1309
12.0k
    break;
1310
7.34k
  case IMAGE_SCN_LNK_INFO:
1311
    /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is
1312
       defined.  coff_compute_section_file_positions uses
1313
       COFF_PAGE_SIZE to ensure that the low order bits of the
1314
       section VMA and the file offset match.  If we don't know
1315
       COFF_PAGE_SIZE, we can't ensure the correct correspondence,
1316
       and demand page loading of the file will fail.  */
1317
7.34k
#ifdef COFF_PAGE_SIZE
1318
7.34k
    sec_flags |= SEC_DEBUGGING;
1319
7.34k
#endif
1320
7.34k
    break;
1321
4.85k
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
4.85k
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
114
      result = false;
1325
4.85k
    break;
1326
88.1k
  default:
1327
    /* Silently ignore for now.  */
1328
88.1k
    break;
1329
207k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
207k
      if (unhandled != NULL)
1333
7.34k
  {
1334
7.34k
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
7.34k
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
7.34k
       abfd, name, unhandled, flag);
1338
7.34k
    result = false;
1339
7.34k
  }
1340
207k
    }
1341
1342
35.8k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
35.8k
      && (startswith (name, ".sbss")
1344
0
    || startswith (name, ".sdata")))
1345
0
    sec_flags |= SEC_SMALL_DATA;
1346
1347
#if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE)
1348
  /* As a GNU extension, if the name begins with .gnu.linkonce, we
1349
     only link a single copy of the section.  This is used to support
1350
     g++.  g++ will emit each template expansion in its own section.
1351
     The symbols will be defined as weak, so that multiple definitions
1352
     are permitted.  The GNU linker extension is to actually discard
1353
     all but one of the sections.  */
1354
  if (startswith (name, ".gnu.linkonce"))
1355
    sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
1356
#endif
1357
1358
35.8k
  if (flags_ptr)
1359
35.8k
    * flags_ptr = sec_flags;
1360
1361
35.8k
  return result;
1362
35.8k
}
pei-aarch64.c:styp_to_sec_flags
Line
Count
Source
1191
10.4k
{
1192
10.4k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
10.4k
  unsigned long styp_flags = internal_s->s_flags;
1194
10.4k
  flagword sec_flags;
1195
10.4k
  bool result = true;
1196
10.4k
  bool is_dbg = false;
1197
1198
10.4k
  if (startswith (name, DOT_DEBUG)
1199
10.4k
      || startswith (name, DOT_ZDEBUG)
1200
10.4k
#ifdef COFF_LONG_SECTION_NAMES
1201
10.4k
      || startswith (name, GNU_LINKONCE_WI)
1202
10.4k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
10.4k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
10.4k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
10.4k
      || startswith (name, GNU_DEBUGLINK)
1207
10.4k
      || startswith (name, GNU_DEBUGALTLINK)
1208
10.4k
#endif
1209
10.4k
      || startswith (name, ".stab"))
1210
790
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
10.4k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
10.4k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
7.33k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
89.0k
  while (styp_flags)
1220
78.5k
    {
1221
78.5k
      unsigned long flag = styp_flags & - styp_flags;
1222
78.5k
      char * unhandled = NULL;
1223
1224
78.5k
      styp_flags &= ~ flag;
1225
1226
      /* We infer from the distinct read/write/execute bits the settings
1227
   of some of the bfd flags; the actual values, should we need them,
1228
   are also in pei_section_data (abfd, section)->pe_flags.  */
1229
1230
78.5k
      switch (flag)
1231
78.5k
  {
1232
1.95k
  case STYP_DSECT:
1233
1.95k
    unhandled = "STYP_DSECT";
1234
1.95k
    break;
1235
1.50k
  case STYP_GROUP:
1236
1.50k
    unhandled = "STYP_GROUP";
1237
1.50k
    break;
1238
1.91k
  case STYP_COPY:
1239
1.91k
    unhandled = "STYP_COPY";
1240
1.91k
    break;
1241
1.36k
  case STYP_OVER:
1242
1.36k
    unhandled = "STYP_OVER";
1243
1.36k
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
2.55k
  case STYP_NOLOAD:
1246
2.55k
    sec_flags |= SEC_NEVER_LOAD;
1247
2.55k
    break;
1248
0
#endif
1249
3.12k
  case IMAGE_SCN_MEM_READ:
1250
3.12k
    sec_flags &= ~SEC_COFF_NOREAD;
1251
3.12k
    break;
1252
3.06k
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
3.06k
    break;
1255
1.71k
  case IMAGE_SCN_LNK_OTHER:
1256
1.71k
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
1.71k
    break;
1258
1.88k
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
1.88k
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
1.88k
    break;
1261
2.74k
  case IMAGE_SCN_MEM_NOT_PAGED:
1262
    /* Generate a warning message rather using the 'unhandled'
1263
       variable as this will allow some .sys files generate by
1264
       other toolchains to be processed.  See bugzilla issue 196.  */
1265
    /* xgettext:c-format */
1266
2.74k
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
2.74k
        " %s in section %s"),
1268
2.74k
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
2.74k
    break;
1270
2.94k
  case IMAGE_SCN_MEM_EXECUTE:
1271
2.94k
    sec_flags |= SEC_CODE;
1272
2.94k
    break;
1273
1.47k
  case IMAGE_SCN_MEM_WRITE:
1274
1.47k
    sec_flags &= ~ SEC_READONLY;
1275
1.47k
    break;
1276
2.33k
  case IMAGE_SCN_MEM_DISCARDABLE:
1277
    /* The MS PE spec says that debug sections are DISCARDABLE,
1278
       but the presence of a DISCARDABLE flag does not necessarily
1279
       mean that a given section contains debug information.  Thus
1280
       we only set the SEC_DEBUGGING flag on sections that we
1281
       recognise as containing debug information.  */
1282
2.33k
       if (is_dbg
1283
2.33k
#ifdef _COMMENT
1284
2.33k
        || strcmp (name, _COMMENT) == 0
1285
2.33k
#endif
1286
2.33k
        )
1287
239
      {
1288
239
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
239
      }
1290
2.33k
    break;
1291
2.01k
  case IMAGE_SCN_MEM_SHARED:
1292
2.01k
    sec_flags |= SEC_COFF_SHARED;
1293
2.01k
    break;
1294
3.15k
  case IMAGE_SCN_LNK_REMOVE:
1295
3.15k
    if (!is_dbg)
1296
3.00k
      sec_flags |= SEC_EXCLUDE;
1297
3.15k
    break;
1298
3.68k
  case IMAGE_SCN_CNT_CODE:
1299
3.68k
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
3.68k
    break;
1301
3.47k
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
3.47k
    if (is_dbg)
1303
277
      sec_flags |= SEC_DEBUGGING;
1304
3.19k
    else
1305
3.19k
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
3.47k
    break;
1307
1.96k
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
1.96k
    sec_flags |= SEC_ALLOC;
1309
1.96k
    break;
1310
2.10k
  case IMAGE_SCN_LNK_INFO:
1311
    /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is
1312
       defined.  coff_compute_section_file_positions uses
1313
       COFF_PAGE_SIZE to ensure that the low order bits of the
1314
       section VMA and the file offset match.  If we don't know
1315
       COFF_PAGE_SIZE, we can't ensure the correct correspondence,
1316
       and demand page loading of the file will fail.  */
1317
2.10k
#ifdef COFF_PAGE_SIZE
1318
2.10k
    sec_flags |= SEC_DEBUGGING;
1319
2.10k
#endif
1320
2.10k
    break;
1321
2.59k
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
2.59k
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
212
      result = false;
1325
2.59k
    break;
1326
30.9k
  default:
1327
    /* Silently ignore for now.  */
1328
30.9k
    break;
1329
78.5k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
78.5k
      if (unhandled != NULL)
1333
10.3k
  {
1334
10.3k
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
10.3k
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
10.3k
       abfd, name, unhandled, flag);
1338
10.3k
    result = false;
1339
10.3k
  }
1340
78.5k
    }
1341
1342
10.4k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
10.4k
      && (startswith (name, ".sbss")
1344
0
    || startswith (name, ".sdata")))
1345
0
    sec_flags |= SEC_SMALL_DATA;
1346
1347
#if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE)
1348
  /* As a GNU extension, if the name begins with .gnu.linkonce, we
1349
     only link a single copy of the section.  This is used to support
1350
     g++.  g++ will emit each template expansion in its own section.
1351
     The symbols will be defined as weak, so that multiple definitions
1352
     are permitted.  The GNU linker extension is to actually discard
1353
     all but one of the sections.  */
1354
  if (startswith (name, ".gnu.linkonce"))
1355
    sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
1356
#endif
1357
1358
10.4k
  if (flags_ptr)
1359
10.4k
    * flags_ptr = sec_flags;
1360
1361
10.4k
  return result;
1362
10.4k
}
pei-ia64.c:styp_to_sec_flags
Line
Count
Source
1191
16.6k
{
1192
16.6k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
16.6k
  unsigned long styp_flags = internal_s->s_flags;
1194
16.6k
  flagword sec_flags;
1195
16.6k
  bool result = true;
1196
16.6k
  bool is_dbg = false;
1197
1198
16.6k
  if (startswith (name, DOT_DEBUG)
1199
16.6k
      || startswith (name, DOT_ZDEBUG)
1200
16.6k
#ifdef COFF_LONG_SECTION_NAMES
1201
16.6k
      || startswith (name, GNU_LINKONCE_WI)
1202
16.6k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
16.6k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
16.6k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
16.6k
      || startswith (name, GNU_DEBUGLINK)
1207
16.6k
      || startswith (name, GNU_DEBUGALTLINK)
1208
16.6k
#endif
1209
16.6k
      || startswith (name, ".stab"))
1210
511
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
16.6k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
16.6k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
13.6k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
102k
  while (styp_flags)
1220
85.8k
    {
1221
85.8k
      unsigned long flag = styp_flags & - styp_flags;
1222
85.8k
      char * unhandled = NULL;
1223
1224
85.8k
      styp_flags &= ~ flag;
1225
1226
      /* We infer from the distinct read/write/execute bits the settings
1227
   of some of the bfd flags; the actual values, should we need them,
1228
   are also in pei_section_data (abfd, section)->pe_flags.  */
1229
1230
85.8k
      switch (flag)
1231
85.8k
  {
1232
1.69k
  case STYP_DSECT:
1233
1.69k
    unhandled = "STYP_DSECT";
1234
1.69k
    break;
1235
1.02k
  case STYP_GROUP:
1236
1.02k
    unhandled = "STYP_GROUP";
1237
1.02k
    break;
1238
1.16k
  case STYP_COPY:
1239
1.16k
    unhandled = "STYP_COPY";
1240
1.16k
    break;
1241
1.54k
  case STYP_OVER:
1242
1.54k
    unhandled = "STYP_OVER";
1243
1.54k
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
2.97k
  case STYP_NOLOAD:
1246
2.97k
    sec_flags |= SEC_NEVER_LOAD;
1247
2.97k
    break;
1248
0
#endif
1249
3.03k
  case IMAGE_SCN_MEM_READ:
1250
3.03k
    sec_flags &= ~SEC_COFF_NOREAD;
1251
3.03k
    break;
1252
2.03k
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
2.03k
    break;
1255
2.04k
  case IMAGE_SCN_LNK_OTHER:
1256
2.04k
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
2.04k
    break;
1258
1.66k
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
1.66k
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
1.66k
    break;
1261
2.28k
  case IMAGE_SCN_MEM_NOT_PAGED:
1262
    /* Generate a warning message rather using the 'unhandled'
1263
       variable as this will allow some .sys files generate by
1264
       other toolchains to be processed.  See bugzilla issue 196.  */
1265
    /* xgettext:c-format */
1266
2.28k
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
2.28k
        " %s in section %s"),
1268
2.28k
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
2.28k
    break;
1270
3.53k
  case IMAGE_SCN_MEM_EXECUTE:
1271
3.53k
    sec_flags |= SEC_CODE;
1272
3.53k
    break;
1273
1.93k
  case IMAGE_SCN_MEM_WRITE:
1274
1.93k
    sec_flags &= ~ SEC_READONLY;
1275
1.93k
    break;
1276
3.09k
  case IMAGE_SCN_MEM_DISCARDABLE:
1277
    /* The MS PE spec says that debug sections are DISCARDABLE,
1278
       but the presence of a DISCARDABLE flag does not necessarily
1279
       mean that a given section contains debug information.  Thus
1280
       we only set the SEC_DEBUGGING flag on sections that we
1281
       recognise as containing debug information.  */
1282
3.09k
       if (is_dbg
1283
3.09k
#ifdef _COMMENT
1284
3.09k
        || strcmp (name, _COMMENT) == 0
1285
3.09k
#endif
1286
3.09k
        )
1287
16
      {
1288
16
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
16
      }
1290
3.09k
    break;
1291
1.80k
  case IMAGE_SCN_MEM_SHARED:
1292
1.80k
    sec_flags |= SEC_COFF_SHARED;
1293
1.80k
    break;
1294
2.69k
  case IMAGE_SCN_LNK_REMOVE:
1295
2.69k
    if (!is_dbg)
1296
2.45k
      sec_flags |= SEC_EXCLUDE;
1297
2.69k
    break;
1298
3.20k
  case IMAGE_SCN_CNT_CODE:
1299
3.20k
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
3.20k
    break;
1301
2.09k
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
2.09k
    if (is_dbg)
1303
12
      sec_flags |= SEC_DEBUGGING;
1304
2.07k
    else
1305
2.07k
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
2.09k
    break;
1307
1.90k
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
1.90k
    sec_flags |= SEC_ALLOC;
1309
1.90k
    break;
1310
3.25k
  case IMAGE_SCN_LNK_INFO:
1311
    /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is
1312
       defined.  coff_compute_section_file_positions uses
1313
       COFF_PAGE_SIZE to ensure that the low order bits of the
1314
       section VMA and the file offset match.  If we don't know
1315
       COFF_PAGE_SIZE, we can't ensure the correct correspondence,
1316
       and demand page loading of the file will fail.  */
1317
3.25k
#ifdef COFF_PAGE_SIZE
1318
3.25k
    sec_flags |= SEC_DEBUGGING;
1319
3.25k
#endif
1320
3.25k
    break;
1321
3.39k
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
3.39k
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
449
      result = false;
1325
3.39k
    break;
1326
39.4k
  default:
1327
    /* Silently ignore for now.  */
1328
39.4k
    break;
1329
85.8k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
85.8k
      if (unhandled != NULL)
1333
9.13k
  {
1334
9.13k
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
9.13k
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
9.13k
       abfd, name, unhandled, flag);
1338
9.13k
    result = false;
1339
9.13k
  }
1340
85.8k
    }
1341
1342
16.6k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
16.6k
      && (startswith (name, ".sbss")
1344
0
    || startswith (name, ".sdata")))
1345
0
    sec_flags |= SEC_SMALL_DATA;
1346
1347
#if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE)
1348
  /* As a GNU extension, if the name begins with .gnu.linkonce, we
1349
     only link a single copy of the section.  This is used to support
1350
     g++.  g++ will emit each template expansion in its own section.
1351
     The symbols will be defined as weak, so that multiple definitions
1352
     are permitted.  The GNU linker extension is to actually discard
1353
     all but one of the sections.  */
1354
  if (startswith (name, ".gnu.linkonce"))
1355
    sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
1356
#endif
1357
1358
16.6k
  if (flags_ptr)
1359
16.6k
    * flags_ptr = sec_flags;
1360
1361
16.6k
  return result;
1362
16.6k
}
pei-loongarch64.c:styp_to_sec_flags
Line
Count
Source
1191
14.1k
{
1192
14.1k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
14.1k
  unsigned long styp_flags = internal_s->s_flags;
1194
14.1k
  flagword sec_flags;
1195
14.1k
  bool result = true;
1196
14.1k
  bool is_dbg = false;
1197
1198
14.1k
  if (startswith (name, DOT_DEBUG)
1199
14.1k
      || startswith (name, DOT_ZDEBUG)
1200
14.1k
#ifdef COFF_LONG_SECTION_NAMES
1201
14.1k
      || startswith (name, GNU_LINKONCE_WI)
1202
14.1k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
14.1k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
14.1k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
14.1k
      || startswith (name, GNU_DEBUGLINK)
1207
14.1k
      || startswith (name, GNU_DEBUGALTLINK)
1208
14.1k
#endif
1209
14.1k
      || startswith (name, ".stab"))
1210
900
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
14.1k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
14.1k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
8.90k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
154k
  while (styp_flags)
1220
140k
    {
1221
140k
      unsigned long flag = styp_flags & - styp_flags;
1222
140k
      char * unhandled = NULL;
1223
1224
140k
      styp_flags &= ~ flag;
1225
1226
      /* We infer from the distinct read/write/execute bits the settings
1227
   of some of the bfd flags; the actual values, should we need them,
1228
   are also in pei_section_data (abfd, section)->pe_flags.  */
1229
1230
140k
      switch (flag)
1231
140k
  {
1232
2.72k
  case STYP_DSECT:
1233
2.72k
    unhandled = "STYP_DSECT";
1234
2.72k
    break;
1235
2.04k
  case STYP_GROUP:
1236
2.04k
    unhandled = "STYP_GROUP";
1237
2.04k
    break;
1238
2.02k
  case STYP_COPY:
1239
2.02k
    unhandled = "STYP_COPY";
1240
2.02k
    break;
1241
2.21k
  case STYP_OVER:
1242
2.21k
    unhandled = "STYP_OVER";
1243
2.21k
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
3.93k
  case STYP_NOLOAD:
1246
3.93k
    sec_flags |= SEC_NEVER_LOAD;
1247
3.93k
    break;
1248
0
#endif
1249
5.21k
  case IMAGE_SCN_MEM_READ:
1250
5.21k
    sec_flags &= ~SEC_COFF_NOREAD;
1251
5.21k
    break;
1252
3.43k
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
3.43k
    break;
1255
2.68k
  case IMAGE_SCN_LNK_OTHER:
1256
2.68k
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
2.68k
    break;
1258
1.81k
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
1.81k
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
1.81k
    break;
1261
3.43k
  case IMAGE_SCN_MEM_NOT_PAGED:
1262
    /* Generate a warning message rather using the 'unhandled'
1263
       variable as this will allow some .sys files generate by
1264
       other toolchains to be processed.  See bugzilla issue 196.  */
1265
    /* xgettext:c-format */
1266
3.43k
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
3.43k
        " %s in section %s"),
1268
3.43k
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
3.43k
    break;
1270
6.22k
  case IMAGE_SCN_MEM_EXECUTE:
1271
6.22k
    sec_flags |= SEC_CODE;
1272
6.22k
    break;
1273
5.80k
  case IMAGE_SCN_MEM_WRITE:
1274
5.80k
    sec_flags &= ~ SEC_READONLY;
1275
5.80k
    break;
1276
5.15k
  case IMAGE_SCN_MEM_DISCARDABLE:
1277
    /* The MS PE spec says that debug sections are DISCARDABLE,
1278
       but the presence of a DISCARDABLE flag does not necessarily
1279
       mean that a given section contains debug information.  Thus
1280
       we only set the SEC_DEBUGGING flag on sections that we
1281
       recognise as containing debug information.  */
1282
5.15k
       if (is_dbg
1283
5.15k
#ifdef _COMMENT
1284
5.15k
        || strcmp (name, _COMMENT) == 0
1285
5.15k
#endif
1286
5.15k
        )
1287
522
      {
1288
522
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
522
      }
1290
5.15k
    break;
1291
2.51k
  case IMAGE_SCN_MEM_SHARED:
1292
2.51k
    sec_flags |= SEC_COFF_SHARED;
1293
2.51k
    break;
1294
4.39k
  case IMAGE_SCN_LNK_REMOVE:
1295
4.39k
    if (!is_dbg)
1296
4.12k
      sec_flags |= SEC_EXCLUDE;
1297
4.39k
    break;
1298
6.00k
  case IMAGE_SCN_CNT_CODE:
1299
6.00k
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
6.00k
    break;
1301
5.23k
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
5.23k
    if (is_dbg)
1303
676
      sec_flags |= SEC_DEBUGGING;
1304
4.56k
    else
1305
4.56k
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
5.23k
    break;
1307
4.88k
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
4.88k
    sec_flags |= SEC_ALLOC;
1309
4.88k
    break;
1310
5.46k
  case IMAGE_SCN_LNK_INFO:
1311
    /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is
1312
       defined.  coff_compute_section_file_positions uses
1313
       COFF_PAGE_SIZE to ensure that the low order bits of the
1314
       section VMA and the file offset match.  If we don't know
1315
       COFF_PAGE_SIZE, we can't ensure the correct correspondence,
1316
       and demand page loading of the file will fail.  */
1317
5.46k
#ifdef COFF_PAGE_SIZE
1318
5.46k
    sec_flags |= SEC_DEBUGGING;
1319
5.46k
#endif
1320
5.46k
    break;
1321
3.38k
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
3.38k
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
491
      result = false;
1325
3.38k
    break;
1326
61.5k
  default:
1327
    /* Silently ignore for now.  */
1328
61.5k
    break;
1329
140k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
140k
      if (unhandled != NULL)
1333
13.4k
  {
1334
13.4k
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
13.4k
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
13.4k
       abfd, name, unhandled, flag);
1338
13.4k
    result = false;
1339
13.4k
  }
1340
140k
    }
1341
1342
14.1k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
14.1k
      && (startswith (name, ".sbss")
1344
0
    || startswith (name, ".sdata")))
1345
0
    sec_flags |= SEC_SMALL_DATA;
1346
1347
#if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE)
1348
  /* As a GNU extension, if the name begins with .gnu.linkonce, we
1349
     only link a single copy of the section.  This is used to support
1350
     g++.  g++ will emit each template expansion in its own section.
1351
     The symbols will be defined as weak, so that multiple definitions
1352
     are permitted.  The GNU linker extension is to actually discard
1353
     all but one of the sections.  */
1354
  if (startswith (name, ".gnu.linkonce"))
1355
    sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
1356
#endif
1357
1358
14.1k
  if (flags_ptr)
1359
14.1k
    * flags_ptr = sec_flags;
1360
1361
14.1k
  return result;
1362
14.1k
}
pe-arm-wince.c:styp_to_sec_flags
Line
Count
Source
1191
10.9k
{
1192
10.9k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
10.9k
  unsigned long styp_flags = internal_s->s_flags;
1194
10.9k
  flagword sec_flags;
1195
10.9k
  bool result = true;
1196
10.9k
  bool is_dbg = false;
1197
1198
10.9k
  if (startswith (name, DOT_DEBUG)
1199
10.9k
      || startswith (name, DOT_ZDEBUG)
1200
10.9k
#ifdef COFF_LONG_SECTION_NAMES
1201
10.9k
      || startswith (name, GNU_LINKONCE_WI)
1202
10.9k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
10.9k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
10.9k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
10.9k
      || startswith (name, GNU_DEBUGLINK)
1207
10.9k
      || startswith (name, GNU_DEBUGALTLINK)
1208
10.9k
#endif
1209
10.9k
      || startswith (name, ".stab"))
1210
1.13k
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
10.9k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
10.9k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
9.42k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
76.6k
  while (styp_flags)
1220
65.6k
    {
1221
65.6k
      unsigned long flag = styp_flags & - styp_flags;
1222
65.6k
      char * unhandled = NULL;
1223
1224
65.6k
      styp_flags &= ~ flag;
1225
1226
      /* We infer from the distinct read/write/execute bits the settings
1227
   of some of the bfd flags; the actual values, should we need them,
1228
   are also in pei_section_data (abfd, section)->pe_flags.  */
1229
1230
65.6k
      switch (flag)
1231
65.6k
  {
1232
877
  case STYP_DSECT:
1233
877
    unhandled = "STYP_DSECT";
1234
877
    break;
1235
882
  case STYP_GROUP:
1236
882
    unhandled = "STYP_GROUP";
1237
882
    break;
1238
1.08k
  case STYP_COPY:
1239
1.08k
    unhandled = "STYP_COPY";
1240
1.08k
    break;
1241
1.32k
  case STYP_OVER:
1242
1.32k
    unhandled = "STYP_OVER";
1243
1.32k
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
2.78k
  case STYP_NOLOAD:
1246
2.78k
    sec_flags |= SEC_NEVER_LOAD;
1247
2.78k
    break;
1248
0
#endif
1249
1.57k
  case IMAGE_SCN_MEM_READ:
1250
1.57k
    sec_flags &= ~SEC_COFF_NOREAD;
1251
1.57k
    break;
1252
2.37k
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
2.37k
    break;
1255
1.10k
  case IMAGE_SCN_LNK_OTHER:
1256
1.10k
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
1.10k
    break;
1258
1.29k
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
1.29k
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
1.29k
    break;
1261
2.50k
  case IMAGE_SCN_MEM_NOT_PAGED:
1262
    /* Generate a warning message rather using the 'unhandled'
1263
       variable as this will allow some .sys files generate by
1264
       other toolchains to be processed.  See bugzilla issue 196.  */
1265
    /* xgettext:c-format */
1266
2.50k
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
2.50k
        " %s in section %s"),
1268
2.50k
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
2.50k
    break;
1270
2.73k
  case IMAGE_SCN_MEM_EXECUTE:
1271
2.73k
    sec_flags |= SEC_CODE;
1272
2.73k
    break;
1273
1.93k
  case IMAGE_SCN_MEM_WRITE:
1274
1.93k
    sec_flags &= ~ SEC_READONLY;
1275
1.93k
    break;
1276
3.03k
  case IMAGE_SCN_MEM_DISCARDABLE:
1277
    /* The MS PE spec says that debug sections are DISCARDABLE,
1278
       but the presence of a DISCARDABLE flag does not necessarily
1279
       mean that a given section contains debug information.  Thus
1280
       we only set the SEC_DEBUGGING flag on sections that we
1281
       recognise as containing debug information.  */
1282
3.03k
       if (is_dbg
1283
3.03k
#ifdef _COMMENT
1284
3.03k
        || strcmp (name, _COMMENT) == 0
1285
3.03k
#endif
1286
3.03k
        )
1287
821
      {
1288
821
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
821
      }
1290
3.03k
    break;
1291
1.69k
  case IMAGE_SCN_MEM_SHARED:
1292
1.69k
    sec_flags |= SEC_COFF_SHARED;
1293
1.69k
    break;
1294
3.07k
  case IMAGE_SCN_LNK_REMOVE:
1295
3.07k
    if (!is_dbg)
1296
2.46k
      sec_flags |= SEC_EXCLUDE;
1297
3.07k
    break;
1298
2.54k
  case IMAGE_SCN_CNT_CODE:
1299
2.54k
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
2.54k
    break;
1301
1.26k
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
1.26k
    if (is_dbg)
1303
110
      sec_flags |= SEC_DEBUGGING;
1304
1.15k
    else
1305
1.15k
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
1.26k
    break;
1307
2.13k
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
2.13k
    sec_flags |= SEC_ALLOC;
1309
2.13k
    break;
1310
2.85k
  case IMAGE_SCN_LNK_INFO:
1311
    /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is
1312
       defined.  coff_compute_section_file_positions uses
1313
       COFF_PAGE_SIZE to ensure that the low order bits of the
1314
       section VMA and the file offset match.  If we don't know
1315
       COFF_PAGE_SIZE, we can't ensure the correct correspondence,
1316
       and demand page loading of the file will fail.  */
1317
2.85k
#ifdef COFF_PAGE_SIZE
1318
2.85k
    sec_flags |= SEC_DEBUGGING;
1319
2.85k
#endif
1320
2.85k
    break;
1321
1.71k
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
1.71k
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
5
      result = false;
1325
1.71k
    break;
1326
26.9k
  default:
1327
    /* Silently ignore for now.  */
1328
26.9k
    break;
1329
65.6k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
65.6k
      if (unhandled != NULL)
1333
6.55k
  {
1334
6.55k
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
6.55k
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
6.55k
       abfd, name, unhandled, flag);
1338
6.55k
    result = false;
1339
6.55k
  }
1340
65.6k
    }
1341
1342
10.9k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
10.9k
      && (startswith (name, ".sbss")
1344
0
    || startswith (name, ".sdata")))
1345
0
    sec_flags |= SEC_SMALL_DATA;
1346
1347
#if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE)
1348
  /* As a GNU extension, if the name begins with .gnu.linkonce, we
1349
     only link a single copy of the section.  This is used to support
1350
     g++.  g++ will emit each template expansion in its own section.
1351
     The symbols will be defined as weak, so that multiple definitions
1352
     are permitted.  The GNU linker extension is to actually discard
1353
     all but one of the sections.  */
1354
  if (startswith (name, ".gnu.linkonce"))
1355
    sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
1356
#endif
1357
1358
10.9k
  if (flags_ptr)
1359
10.9k
    * flags_ptr = sec_flags;
1360
1361
10.9k
  return result;
1362
10.9k
}
pe-arm.c:styp_to_sec_flags
Line
Count
Source
1191
10.9k
{
1192
10.9k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
10.9k
  unsigned long styp_flags = internal_s->s_flags;
1194
10.9k
  flagword sec_flags;
1195
10.9k
  bool result = true;
1196
10.9k
  bool is_dbg = false;
1197
1198
10.9k
  if (startswith (name, DOT_DEBUG)
1199
10.9k
      || startswith (name, DOT_ZDEBUG)
1200
10.9k
#ifdef COFF_LONG_SECTION_NAMES
1201
10.9k
      || startswith (name, GNU_LINKONCE_WI)
1202
10.9k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
10.9k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
10.9k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
10.9k
      || startswith (name, GNU_DEBUGLINK)
1207
10.9k
      || startswith (name, GNU_DEBUGALTLINK)
1208
10.9k
#endif
1209
10.9k
      || startswith (name, ".stab"))
1210
1.13k
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
10.9k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
10.9k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
9.42k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
76.6k
  while (styp_flags)
1220
65.6k
    {
1221
65.6k
      unsigned long flag = styp_flags & - styp_flags;
1222
65.6k
      char * unhandled = NULL;
1223
1224
65.6k
      styp_flags &= ~ flag;
1225
1226
      /* We infer from the distinct read/write/execute bits the settings
1227
   of some of the bfd flags; the actual values, should we need them,
1228
   are also in pei_section_data (abfd, section)->pe_flags.  */
1229
1230
65.6k
      switch (flag)
1231
65.6k
  {
1232
877
  case STYP_DSECT:
1233
877
    unhandled = "STYP_DSECT";
1234
877
    break;
1235
882
  case STYP_GROUP:
1236
882
    unhandled = "STYP_GROUP";
1237
882
    break;
1238
1.08k
  case STYP_COPY:
1239
1.08k
    unhandled = "STYP_COPY";
1240
1.08k
    break;
1241
1.32k
  case STYP_OVER:
1242
1.32k
    unhandled = "STYP_OVER";
1243
1.32k
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
2.78k
  case STYP_NOLOAD:
1246
2.78k
    sec_flags |= SEC_NEVER_LOAD;
1247
2.78k
    break;
1248
0
#endif
1249
1.57k
  case IMAGE_SCN_MEM_READ:
1250
1.57k
    sec_flags &= ~SEC_COFF_NOREAD;
1251
1.57k
    break;
1252
2.37k
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
2.37k
    break;
1255
1.10k
  case IMAGE_SCN_LNK_OTHER:
1256
1.10k
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
1.10k
    break;
1258
1.29k
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
1.29k
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
1.29k
    break;
1261
2.50k
  case IMAGE_SCN_MEM_NOT_PAGED:
1262
    /* Generate a warning message rather using the 'unhandled'
1263
       variable as this will allow some .sys files generate by
1264
       other toolchains to be processed.  See bugzilla issue 196.  */
1265
    /* xgettext:c-format */
1266
2.50k
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
2.50k
        " %s in section %s"),
1268
2.50k
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
2.50k
    break;
1270
2.73k
  case IMAGE_SCN_MEM_EXECUTE:
1271
2.73k
    sec_flags |= SEC_CODE;
1272
2.73k
    break;
1273
1.93k
  case IMAGE_SCN_MEM_WRITE:
1274
1.93k
    sec_flags &= ~ SEC_READONLY;
1275
1.93k
    break;
1276
3.03k
  case IMAGE_SCN_MEM_DISCARDABLE:
1277
    /* The MS PE spec says that debug sections are DISCARDABLE,
1278
       but the presence of a DISCARDABLE flag does not necessarily
1279
       mean that a given section contains debug information.  Thus
1280
       we only set the SEC_DEBUGGING flag on sections that we
1281
       recognise as containing debug information.  */
1282
3.03k
       if (is_dbg
1283
3.03k
#ifdef _COMMENT
1284
3.03k
        || strcmp (name, _COMMENT) == 0
1285
3.03k
#endif
1286
3.03k
        )
1287
821
      {
1288
821
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
821
      }
1290
3.03k
    break;
1291
1.69k
  case IMAGE_SCN_MEM_SHARED:
1292
1.69k
    sec_flags |= SEC_COFF_SHARED;
1293
1.69k
    break;
1294
3.07k
  case IMAGE_SCN_LNK_REMOVE:
1295
3.07k
    if (!is_dbg)
1296
2.46k
      sec_flags |= SEC_EXCLUDE;
1297
3.07k
    break;
1298
2.54k
  case IMAGE_SCN_CNT_CODE:
1299
2.54k
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
2.54k
    break;
1301
1.26k
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
1.26k
    if (is_dbg)
1303
110
      sec_flags |= SEC_DEBUGGING;
1304
1.15k
    else
1305
1.15k
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
1.26k
    break;
1307
2.13k
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
2.13k
    sec_flags |= SEC_ALLOC;
1309
2.13k
    break;
1310
2.85k
  case IMAGE_SCN_LNK_INFO:
1311
    /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is
1312
       defined.  coff_compute_section_file_positions uses
1313
       COFF_PAGE_SIZE to ensure that the low order bits of the
1314
       section VMA and the file offset match.  If we don't know
1315
       COFF_PAGE_SIZE, we can't ensure the correct correspondence,
1316
       and demand page loading of the file will fail.  */
1317
2.85k
#ifdef COFF_PAGE_SIZE
1318
2.85k
    sec_flags |= SEC_DEBUGGING;
1319
2.85k
#endif
1320
2.85k
    break;
1321
1.71k
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
1.71k
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
5
      result = false;
1325
1.71k
    break;
1326
26.9k
  default:
1327
    /* Silently ignore for now.  */
1328
26.9k
    break;
1329
65.6k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
65.6k
      if (unhandled != NULL)
1333
6.55k
  {
1334
6.55k
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
6.55k
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
6.55k
       abfd, name, unhandled, flag);
1338
6.55k
    result = false;
1339
6.55k
  }
1340
65.6k
    }
1341
1342
10.9k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
10.9k
      && (startswith (name, ".sbss")
1344
0
    || startswith (name, ".sdata")))
1345
0
    sec_flags |= SEC_SMALL_DATA;
1346
1347
#if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE)
1348
  /* As a GNU extension, if the name begins with .gnu.linkonce, we
1349
     only link a single copy of the section.  This is used to support
1350
     g++.  g++ will emit each template expansion in its own section.
1351
     The symbols will be defined as weak, so that multiple definitions
1352
     are permitted.  The GNU linker extension is to actually discard
1353
     all but one of the sections.  */
1354
  if (startswith (name, ".gnu.linkonce"))
1355
    sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
1356
#endif
1357
1358
10.9k
  if (flags_ptr)
1359
10.9k
    * flags_ptr = sec_flags;
1360
1361
10.9k
  return result;
1362
10.9k
}
pe-i386.c:styp_to_sec_flags
Line
Count
Source
1191
16.5k
{
1192
16.5k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
16.5k
  unsigned long styp_flags = internal_s->s_flags;
1194
16.5k
  flagword sec_flags;
1195
16.5k
  bool result = true;
1196
16.5k
  bool is_dbg = false;
1197
1198
16.5k
  if (startswith (name, DOT_DEBUG)
1199
16.5k
      || startswith (name, DOT_ZDEBUG)
1200
16.5k
#ifdef COFF_LONG_SECTION_NAMES
1201
16.5k
      || startswith (name, GNU_LINKONCE_WI)
1202
16.5k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
16.5k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
16.5k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
16.5k
      || startswith (name, GNU_DEBUGLINK)
1207
16.5k
      || startswith (name, GNU_DEBUGALTLINK)
1208
16.5k
#endif
1209
16.5k
      || startswith (name, ".stab"))
1210
1.58k
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
16.5k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
16.5k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
11.9k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
144k
  while (styp_flags)
1220
127k
    {
1221
127k
      unsigned long flag = styp_flags & - styp_flags;
1222
127k
      char * unhandled = NULL;
1223
1224
127k
      styp_flags &= ~ flag;
1225
1226
      /* We infer from the distinct read/write/execute bits the settings
1227
   of some of the bfd flags; the actual values, should we need them,
1228
   are also in pei_section_data (abfd, section)->pe_flags.  */
1229
1230
127k
      switch (flag)
1231
127k
  {
1232
2.61k
  case STYP_DSECT:
1233
2.61k
    unhandled = "STYP_DSECT";
1234
2.61k
    break;
1235
2.98k
  case STYP_GROUP:
1236
2.98k
    unhandled = "STYP_GROUP";
1237
2.98k
    break;
1238
3.21k
  case STYP_COPY:
1239
3.21k
    unhandled = "STYP_COPY";
1240
3.21k
    break;
1241
3.32k
  case STYP_OVER:
1242
3.32k
    unhandled = "STYP_OVER";
1243
3.32k
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
3.21k
  case STYP_NOLOAD:
1246
3.21k
    sec_flags |= SEC_NEVER_LOAD;
1247
3.21k
    break;
1248
0
#endif
1249
4.64k
  case IMAGE_SCN_MEM_READ:
1250
4.64k
    sec_flags &= ~SEC_COFF_NOREAD;
1251
4.64k
    break;
1252
3.23k
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
3.23k
    break;
1255
2.59k
  case IMAGE_SCN_LNK_OTHER:
1256
2.59k
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
2.59k
    break;
1258
3.62k
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
3.62k
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
3.62k
    break;
1261
5.23k
  case IMAGE_SCN_MEM_NOT_PAGED:
1262
    /* Generate a warning message rather using the 'unhandled'
1263
       variable as this will allow some .sys files generate by
1264
       other toolchains to be processed.  See bugzilla issue 196.  */
1265
    /* xgettext:c-format */
1266
5.23k
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
5.23k
        " %s in section %s"),
1268
5.23k
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
5.23k
    break;
1270
5.10k
  case IMAGE_SCN_MEM_EXECUTE:
1271
5.10k
    sec_flags |= SEC_CODE;
1272
5.10k
    break;
1273
3.15k
  case IMAGE_SCN_MEM_WRITE:
1274
3.15k
    sec_flags &= ~ SEC_READONLY;
1275
3.15k
    break;
1276
4.91k
  case IMAGE_SCN_MEM_DISCARDABLE:
1277
    /* The MS PE spec says that debug sections are DISCARDABLE,
1278
       but the presence of a DISCARDABLE flag does not necessarily
1279
       mean that a given section contains debug information.  Thus
1280
       we only set the SEC_DEBUGGING flag on sections that we
1281
       recognise as containing debug information.  */
1282
4.91k
       if (is_dbg
1283
4.91k
#ifdef _COMMENT
1284
4.91k
        || strcmp (name, _COMMENT) == 0
1285
4.91k
#endif
1286
4.91k
        )
1287
1.00k
      {
1288
1.00k
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
1.00k
      }
1290
4.91k
    break;
1291
3.84k
  case IMAGE_SCN_MEM_SHARED:
1292
3.84k
    sec_flags |= SEC_COFF_SHARED;
1293
3.84k
    break;
1294
4.46k
  case IMAGE_SCN_LNK_REMOVE:
1295
4.46k
    if (!is_dbg)
1296
4.18k
      sec_flags |= SEC_EXCLUDE;
1297
4.46k
    break;
1298
3.80k
  case IMAGE_SCN_CNT_CODE:
1299
3.80k
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
3.80k
    break;
1301
4.73k
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
4.73k
    if (is_dbg)
1303
730
      sec_flags |= SEC_DEBUGGING;
1304
4.00k
    else
1305
4.00k
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
4.73k
    break;
1307
1.75k
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
1.75k
    sec_flags |= SEC_ALLOC;
1309
1.75k
    break;
1310
3.82k
  case IMAGE_SCN_LNK_INFO:
1311
    /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is
1312
       defined.  coff_compute_section_file_positions uses
1313
       COFF_PAGE_SIZE to ensure that the low order bits of the
1314
       section VMA and the file offset match.  If we don't know
1315
       COFF_PAGE_SIZE, we can't ensure the correct correspondence,
1316
       and demand page loading of the file will fail.  */
1317
3.82k
#ifdef COFF_PAGE_SIZE
1318
3.82k
    sec_flags |= SEC_DEBUGGING;
1319
3.82k
#endif
1320
3.82k
    break;
1321
6.64k
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
6.64k
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
726
      result = false;
1325
6.64k
    break;
1326
50.6k
  default:
1327
    /* Silently ignore for now.  */
1328
50.6k
    break;
1329
127k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
127k
      if (unhandled != NULL)
1333
18.3k
  {
1334
18.3k
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
18.3k
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
18.3k
       abfd, name, unhandled, flag);
1338
18.3k
    result = false;
1339
18.3k
  }
1340
127k
    }
1341
1342
16.5k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
16.5k
      && (startswith (name, ".sbss")
1344
0
    || startswith (name, ".sdata")))
1345
0
    sec_flags |= SEC_SMALL_DATA;
1346
1347
16.5k
#if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE)
1348
  /* As a GNU extension, if the name begins with .gnu.linkonce, we
1349
     only link a single copy of the section.  This is used to support
1350
     g++.  g++ will emit each template expansion in its own section.
1351
     The symbols will be defined as weak, so that multiple definitions
1352
     are permitted.  The GNU linker extension is to actually discard
1353
     all but one of the sections.  */
1354
16.5k
  if (startswith (name, ".gnu.linkonce"))
1355
114
    sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
1356
16.5k
#endif
1357
1358
16.5k
  if (flags_ptr)
1359
16.5k
    * flags_ptr = sec_flags;
1360
1361
16.5k
  return result;
1362
16.5k
}
pe-mcore.c:styp_to_sec_flags
Line
Count
Source
1191
10.9k
{
1192
10.9k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
10.9k
  unsigned long styp_flags = internal_s->s_flags;
1194
10.9k
  flagword sec_flags;
1195
10.9k
  bool result = true;
1196
10.9k
  bool is_dbg = false;
1197
1198
10.9k
  if (startswith (name, DOT_DEBUG)
1199
10.9k
      || startswith (name, DOT_ZDEBUG)
1200
10.9k
#ifdef COFF_LONG_SECTION_NAMES
1201
10.9k
      || startswith (name, GNU_LINKONCE_WI)
1202
10.9k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
10.9k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
10.9k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
10.9k
      || startswith (name, GNU_DEBUGLINK)
1207
10.9k
      || startswith (name, GNU_DEBUGALTLINK)
1208
10.9k
#endif
1209
10.9k
      || startswith (name, ".stab"))
1210
849
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
10.9k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
10.9k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
7.99k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
86.3k
  while (styp_flags)
1220
75.4k
    {
1221
75.4k
      unsigned long flag = styp_flags & - styp_flags;
1222
75.4k
      char * unhandled = NULL;
1223
1224
75.4k
      styp_flags &= ~ flag;
1225
1226
      /* We infer from the distinct read/write/execute bits the settings
1227
   of some of the bfd flags; the actual values, should we need them,
1228
   are also in pei_section_data (abfd, section)->pe_flags.  */
1229
1230
75.4k
      switch (flag)
1231
75.4k
  {
1232
361
  case STYP_DSECT:
1233
361
    unhandled = "STYP_DSECT";
1234
361
    break;
1235
561
  case STYP_GROUP:
1236
561
    unhandled = "STYP_GROUP";
1237
561
    break;
1238
454
  case STYP_COPY:
1239
454
    unhandled = "STYP_COPY";
1240
454
    break;
1241
759
  case STYP_OVER:
1242
759
    unhandled = "STYP_OVER";
1243
759
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
2.61k
  case STYP_NOLOAD:
1246
2.61k
    sec_flags |= SEC_NEVER_LOAD;
1247
2.61k
    break;
1248
0
#endif
1249
2.97k
  case IMAGE_SCN_MEM_READ:
1250
2.97k
    sec_flags &= ~SEC_COFF_NOREAD;
1251
2.97k
    break;
1252
1.68k
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
1.68k
    break;
1255
756
  case IMAGE_SCN_LNK_OTHER:
1256
756
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
756
    break;
1258
752
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
752
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
752
    break;
1261
2.52k
  case IMAGE_SCN_MEM_NOT_PAGED:
1262
    /* Generate a warning message rather using the 'unhandled'
1263
       variable as this will allow some .sys files generate by
1264
       other toolchains to be processed.  See bugzilla issue 196.  */
1265
    /* xgettext:c-format */
1266
2.52k
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
2.52k
        " %s in section %s"),
1268
2.52k
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
2.52k
    break;
1270
3.57k
  case IMAGE_SCN_MEM_EXECUTE:
1271
3.57k
    sec_flags |= SEC_CODE;
1272
3.57k
    break;
1273
3.28k
  case IMAGE_SCN_MEM_WRITE:
1274
3.28k
    sec_flags &= ~ SEC_READONLY;
1275
3.28k
    break;
1276
4.58k
  case IMAGE_SCN_MEM_DISCARDABLE:
1277
    /* The MS PE spec says that debug sections are DISCARDABLE,
1278
       but the presence of a DISCARDABLE flag does not necessarily
1279
       mean that a given section contains debug information.  Thus
1280
       we only set the SEC_DEBUGGING flag on sections that we
1281
       recognise as containing debug information.  */
1282
4.58k
       if (is_dbg
1283
4.58k
#ifdef _COMMENT
1284
4.58k
        || strcmp (name, _COMMENT) == 0
1285
4.58k
#endif
1286
4.58k
        )
1287
506
      {
1288
506
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
506
      }
1290
4.58k
    break;
1291
2.22k
  case IMAGE_SCN_MEM_SHARED:
1292
2.22k
    sec_flags |= SEC_COFF_SHARED;
1293
2.22k
    break;
1294
1.48k
  case IMAGE_SCN_LNK_REMOVE:
1295
1.48k
    if (!is_dbg)
1296
1.27k
      sec_flags |= SEC_EXCLUDE;
1297
1.48k
    break;
1298
3.76k
  case IMAGE_SCN_CNT_CODE:
1299
3.76k
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
3.76k
    break;
1301
3.61k
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
3.61k
    if (is_dbg)
1303
115
      sec_flags |= SEC_DEBUGGING;
1304
3.50k
    else
1305
3.50k
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
3.61k
    break;
1307
2.56k
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
2.56k
    sec_flags |= SEC_ALLOC;
1309
2.56k
    break;
1310
4.55k
  case IMAGE_SCN_LNK_INFO:
1311
    /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is
1312
       defined.  coff_compute_section_file_positions uses
1313
       COFF_PAGE_SIZE to ensure that the low order bits of the
1314
       section VMA and the file offset match.  If we don't know
1315
       COFF_PAGE_SIZE, we can't ensure the correct correspondence,
1316
       and demand page loading of the file will fail.  */
1317
4.55k
#ifdef COFF_PAGE_SIZE
1318
4.55k
    sec_flags |= SEC_DEBUGGING;
1319
4.55k
#endif
1320
4.55k
    break;
1321
2.88k
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
2.88k
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
118
      result = false;
1325
2.88k
    break;
1326
29.4k
  default:
1327
    /* Silently ignore for now.  */
1328
29.4k
    break;
1329
75.4k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
75.4k
      if (unhandled != NULL)
1333
3.64k
  {
1334
3.64k
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
3.64k
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
3.64k
       abfd, name, unhandled, flag);
1338
3.64k
    result = false;
1339
3.64k
  }
1340
75.4k
    }
1341
1342
10.9k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
10.9k
      && (startswith (name, ".sbss")
1344
0
    || startswith (name, ".sdata")))
1345
0
    sec_flags |= SEC_SMALL_DATA;
1346
1347
#if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE)
1348
  /* As a GNU extension, if the name begins with .gnu.linkonce, we
1349
     only link a single copy of the section.  This is used to support
1350
     g++.  g++ will emit each template expansion in its own section.
1351
     The symbols will be defined as weak, so that multiple definitions
1352
     are permitted.  The GNU linker extension is to actually discard
1353
     all but one of the sections.  */
1354
  if (startswith (name, ".gnu.linkonce"))
1355
    sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
1356
#endif
1357
1358
10.9k
  if (flags_ptr)
1359
10.9k
    * flags_ptr = sec_flags;
1360
1361
10.9k
  return result;
1362
10.9k
}
pe-sh.c:styp_to_sec_flags
Line
Count
Source
1191
20.3k
{
1192
20.3k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
20.3k
  unsigned long styp_flags = internal_s->s_flags;
1194
20.3k
  flagword sec_flags;
1195
20.3k
  bool result = true;
1196
20.3k
  bool is_dbg = false;
1197
1198
20.3k
  if (startswith (name, DOT_DEBUG)
1199
20.3k
      || startswith (name, DOT_ZDEBUG)
1200
20.3k
#ifdef COFF_LONG_SECTION_NAMES
1201
20.3k
      || startswith (name, GNU_LINKONCE_WI)
1202
20.3k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
20.3k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
20.3k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
20.3k
      || startswith (name, GNU_DEBUGLINK)
1207
20.3k
      || startswith (name, GNU_DEBUGALTLINK)
1208
20.3k
#endif
1209
20.3k
      || startswith (name, ".stab"))
1210
620
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
20.3k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
20.3k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
17.9k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
150k
  while (styp_flags)
1220
129k
    {
1221
129k
      unsigned long flag = styp_flags & - styp_flags;
1222
129k
      char * unhandled = NULL;
1223
1224
129k
      styp_flags &= ~ flag;
1225
1226
      /* We infer from the distinct read/write/execute bits the settings
1227
   of some of the bfd flags; the actual values, should we need them,
1228
   are also in pei_section_data (abfd, section)->pe_flags.  */
1229
1230
129k
      switch (flag)
1231
129k
  {
1232
2.38k
  case STYP_DSECT:
1233
2.38k
    unhandled = "STYP_DSECT";
1234
2.38k
    break;
1235
2.47k
  case STYP_GROUP:
1236
2.47k
    unhandled = "STYP_GROUP";
1237
2.47k
    break;
1238
2.75k
  case STYP_COPY:
1239
2.75k
    unhandled = "STYP_COPY";
1240
2.75k
    break;
1241
2.40k
  case STYP_OVER:
1242
2.40k
    unhandled = "STYP_OVER";
1243
2.40k
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
5.68k
  case STYP_NOLOAD:
1246
5.68k
    sec_flags |= SEC_NEVER_LOAD;
1247
5.68k
    break;
1248
0
#endif
1249
2.39k
  case IMAGE_SCN_MEM_READ:
1250
2.39k
    sec_flags &= ~SEC_COFF_NOREAD;
1251
2.39k
    break;
1252
3.44k
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
3.44k
    break;
1255
2.12k
  case IMAGE_SCN_LNK_OTHER:
1256
2.12k
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
2.12k
    break;
1258
2.74k
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
2.74k
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
2.74k
    break;
1261
4.89k
  case IMAGE_SCN_MEM_NOT_PAGED:
1262
    /* Generate a warning message rather using the 'unhandled'
1263
       variable as this will allow some .sys files generate by
1264
       other toolchains to be processed.  See bugzilla issue 196.  */
1265
    /* xgettext:c-format */
1266
4.89k
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
4.89k
        " %s in section %s"),
1268
4.89k
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
4.89k
    break;
1270
5.60k
  case IMAGE_SCN_MEM_EXECUTE:
1271
5.60k
    sec_flags |= SEC_CODE;
1272
5.60k
    break;
1273
3.42k
  case IMAGE_SCN_MEM_WRITE:
1274
3.42k
    sec_flags &= ~ SEC_READONLY;
1275
3.42k
    break;
1276
5.06k
  case IMAGE_SCN_MEM_DISCARDABLE:
1277
    /* The MS PE spec says that debug sections are DISCARDABLE,
1278
       but the presence of a DISCARDABLE flag does not necessarily
1279
       mean that a given section contains debug information.  Thus
1280
       we only set the SEC_DEBUGGING flag on sections that we
1281
       recognise as containing debug information.  */
1282
5.06k
       if (is_dbg
1283
5.06k
#ifdef _COMMENT
1284
5.06k
        || strcmp (name, _COMMENT) == 0
1285
5.06k
#endif
1286
5.06k
        )
1287
202
      {
1288
202
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
202
      }
1290
5.06k
    break;
1291
2.89k
  case IMAGE_SCN_MEM_SHARED:
1292
2.89k
    sec_flags |= SEC_COFF_SHARED;
1293
2.89k
    break;
1294
3.49k
  case IMAGE_SCN_LNK_REMOVE:
1295
3.49k
    if (!is_dbg)
1296
3.13k
      sec_flags |= SEC_EXCLUDE;
1297
3.49k
    break;
1298
5.70k
  case IMAGE_SCN_CNT_CODE:
1299
5.70k
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
5.70k
    break;
1301
3.90k
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
3.90k
    if (is_dbg)
1303
351
      sec_flags |= SEC_DEBUGGING;
1304
3.55k
    else
1305
3.55k
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
3.90k
    break;
1307
2.88k
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
2.88k
    sec_flags |= SEC_ALLOC;
1309
2.88k
    break;
1310
3.47k
  case IMAGE_SCN_LNK_INFO:
1311
    /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is
1312
       defined.  coff_compute_section_file_positions uses
1313
       COFF_PAGE_SIZE to ensure that the low order bits of the
1314
       section VMA and the file offset match.  If we don't know
1315
       COFF_PAGE_SIZE, we can't ensure the correct correspondence,
1316
       and demand page loading of the file will fail.  */
1317
#ifdef COFF_PAGE_SIZE
1318
    sec_flags |= SEC_DEBUGGING;
1319
#endif
1320
3.47k
    break;
1321
6.58k
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
6.58k
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
541
      result = false;
1325
6.58k
    break;
1326
55.5k
  default:
1327
    /* Silently ignore for now.  */
1328
55.5k
    break;
1329
129k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
129k
      if (unhandled != NULL)
1333
14.8k
  {
1334
14.8k
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
14.8k
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
14.8k
       abfd, name, unhandled, flag);
1338
14.8k
    result = false;
1339
14.8k
  }
1340
129k
    }
1341
1342
20.3k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
20.3k
      && (startswith (name, ".sbss")
1344
0
    || startswith (name, ".sdata")))
1345
0
    sec_flags |= SEC_SMALL_DATA;
1346
1347
#if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE)
1348
  /* As a GNU extension, if the name begins with .gnu.linkonce, we
1349
     only link a single copy of the section.  This is used to support
1350
     g++.  g++ will emit each template expansion in its own section.
1351
     The symbols will be defined as weak, so that multiple definitions
1352
     are permitted.  The GNU linker extension is to actually discard
1353
     all but one of the sections.  */
1354
  if (startswith (name, ".gnu.linkonce"))
1355
    sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
1356
#endif
1357
1358
20.3k
  if (flags_ptr)
1359
20.3k
    * flags_ptr = sec_flags;
1360
1361
20.3k
  return result;
1362
20.3k
}
pei-arm-wince.c:styp_to_sec_flags
Line
Count
Source
1191
23.1k
{
1192
23.1k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
23.1k
  unsigned long styp_flags = internal_s->s_flags;
1194
23.1k
  flagword sec_flags;
1195
23.1k
  bool result = true;
1196
23.1k
  bool is_dbg = false;
1197
1198
23.1k
  if (startswith (name, DOT_DEBUG)
1199
23.1k
      || startswith (name, DOT_ZDEBUG)
1200
23.1k
#ifdef COFF_LONG_SECTION_NAMES
1201
23.1k
      || startswith (name, GNU_LINKONCE_WI)
1202
23.1k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
23.1k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
23.1k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
23.1k
      || startswith (name, GNU_DEBUGLINK)
1207
23.1k
      || startswith (name, GNU_DEBUGALTLINK)
1208
23.1k
#endif
1209
23.1k
      || startswith (name, ".stab"))
1210
2.21k
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
23.1k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
23.1k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
18.3k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
157k
  while (styp_flags)
1220
134k
    {
1221
134k
      unsigned long flag = styp_flags & - styp_flags;
1222
134k
      char * unhandled = NULL;
1223
1224
134k
      styp_flags &= ~ flag;
1225
1226
      /* We infer from the distinct read/write/execute bits the settings
1227
   of some of the bfd flags; the actual values, should we need them,
1228
   are also in pei_section_data (abfd, section)->pe_flags.  */
1229
1230
134k
      switch (flag)
1231
134k
  {
1232
1.57k
  case STYP_DSECT:
1233
1.57k
    unhandled = "STYP_DSECT";
1234
1.57k
    break;
1235
1.40k
  case STYP_GROUP:
1236
1.40k
    unhandled = "STYP_GROUP";
1237
1.40k
    break;
1238
1.73k
  case STYP_COPY:
1239
1.73k
    unhandled = "STYP_COPY";
1240
1.73k
    break;
1241
2.08k
  case STYP_OVER:
1242
2.08k
    unhandled = "STYP_OVER";
1243
2.08k
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
4.94k
  case STYP_NOLOAD:
1246
4.94k
    sec_flags |= SEC_NEVER_LOAD;
1247
4.94k
    break;
1248
0
#endif
1249
4.79k
  case IMAGE_SCN_MEM_READ:
1250
4.79k
    sec_flags &= ~SEC_COFF_NOREAD;
1251
4.79k
    break;
1252
3.99k
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
3.99k
    break;
1255
1.99k
  case IMAGE_SCN_LNK_OTHER:
1256
1.99k
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
1.99k
    break;
1258
1.69k
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
1.69k
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
1.69k
    break;
1261
5.44k
  case IMAGE_SCN_MEM_NOT_PAGED:
1262
    /* Generate a warning message rather using the 'unhandled'
1263
       variable as this will allow some .sys files generate by
1264
       other toolchains to be processed.  See bugzilla issue 196.  */
1265
    /* xgettext:c-format */
1266
5.44k
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
5.44k
        " %s in section %s"),
1268
5.44k
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
5.44k
    break;
1270
4.97k
  case IMAGE_SCN_MEM_EXECUTE:
1271
4.97k
    sec_flags |= SEC_CODE;
1272
4.97k
    break;
1273
4.06k
  case IMAGE_SCN_MEM_WRITE:
1274
4.06k
    sec_flags &= ~ SEC_READONLY;
1275
4.06k
    break;
1276
5.90k
  case IMAGE_SCN_MEM_DISCARDABLE:
1277
    /* The MS PE spec says that debug sections are DISCARDABLE,
1278
       but the presence of a DISCARDABLE flag does not necessarily
1279
       mean that a given section contains debug information.  Thus
1280
       we only set the SEC_DEBUGGING flag on sections that we
1281
       recognise as containing debug information.  */
1282
5.90k
       if (is_dbg
1283
5.90k
#ifdef _COMMENT
1284
5.90k
        || strcmp (name, _COMMENT) == 0
1285
5.90k
#endif
1286
5.90k
        )
1287
892
      {
1288
892
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
892
      }
1290
5.90k
    break;
1291
3.53k
  case IMAGE_SCN_MEM_SHARED:
1292
3.53k
    sec_flags |= SEC_COFF_SHARED;
1293
3.53k
    break;
1294
7.12k
  case IMAGE_SCN_LNK_REMOVE:
1295
7.12k
    if (!is_dbg)
1296
6.50k
      sec_flags |= SEC_EXCLUDE;
1297
7.12k
    break;
1298
4.16k
  case IMAGE_SCN_CNT_CODE:
1299
4.16k
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
4.16k
    break;
1301
3.47k
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
3.47k
    if (is_dbg)
1303
372
      sec_flags |= SEC_DEBUGGING;
1304
3.10k
    else
1305
3.10k
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
3.47k
    break;
1307
3.90k
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
3.90k
    sec_flags |= SEC_ALLOC;
1309
3.90k
    break;
1310
6.30k
  case IMAGE_SCN_LNK_INFO:
1311
    /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is
1312
       defined.  coff_compute_section_file_positions uses
1313
       COFF_PAGE_SIZE to ensure that the low order bits of the
1314
       section VMA and the file offset match.  If we don't know
1315
       COFF_PAGE_SIZE, we can't ensure the correct correspondence,
1316
       and demand page loading of the file will fail.  */
1317
6.30k
#ifdef COFF_PAGE_SIZE
1318
6.30k
    sec_flags |= SEC_DEBUGGING;
1319
6.30k
#endif
1320
6.30k
    break;
1321
5.31k
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
5.31k
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
481
      result = false;
1325
5.31k
    break;
1326
56.2k
  default:
1327
    /* Silently ignore for now.  */
1328
56.2k
    break;
1329
134k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
134k
      if (unhandled != NULL)
1333
10.4k
  {
1334
10.4k
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
10.4k
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
10.4k
       abfd, name, unhandled, flag);
1338
10.4k
    result = false;
1339
10.4k
  }
1340
134k
    }
1341
1342
23.1k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
23.1k
      && (startswith (name, ".sbss")
1344
0
    || startswith (name, ".sdata")))
1345
0
    sec_flags |= SEC_SMALL_DATA;
1346
1347
#if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE)
1348
  /* As a GNU extension, if the name begins with .gnu.linkonce, we
1349
     only link a single copy of the section.  This is used to support
1350
     g++.  g++ will emit each template expansion in its own section.
1351
     The symbols will be defined as weak, so that multiple definitions
1352
     are permitted.  The GNU linker extension is to actually discard
1353
     all but one of the sections.  */
1354
  if (startswith (name, ".gnu.linkonce"))
1355
    sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
1356
#endif
1357
1358
23.1k
  if (flags_ptr)
1359
23.1k
    * flags_ptr = sec_flags;
1360
1361
23.1k
  return result;
1362
23.1k
}
pei-arm.c:styp_to_sec_flags
Line
Count
Source
1191
28.4k
{
1192
28.4k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
28.4k
  unsigned long styp_flags = internal_s->s_flags;
1194
28.4k
  flagword sec_flags;
1195
28.4k
  bool result = true;
1196
28.4k
  bool is_dbg = false;
1197
1198
28.4k
  if (startswith (name, DOT_DEBUG)
1199
28.4k
      || startswith (name, DOT_ZDEBUG)
1200
28.4k
#ifdef COFF_LONG_SECTION_NAMES
1201
28.4k
      || startswith (name, GNU_LINKONCE_WI)
1202
28.4k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
28.4k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
28.4k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
28.4k
      || startswith (name, GNU_DEBUGLINK)
1207
28.4k
      || startswith (name, GNU_DEBUGALTLINK)
1208
28.4k
#endif
1209
28.4k
      || startswith (name, ".stab"))
1210
2.21k
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
28.4k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
28.4k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
23.4k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
171k
  while (styp_flags)
1220
142k
    {
1221
142k
      unsigned long flag = styp_flags & - styp_flags;
1222
142k
      char * unhandled = NULL;
1223
1224
142k
      styp_flags &= ~ flag;
1225
1226
      /* We infer from the distinct read/write/execute bits the settings
1227
   of some of the bfd flags; the actual values, should we need them,
1228
   are also in pei_section_data (abfd, section)->pe_flags.  */
1229
1230
142k
      switch (flag)
1231
142k
  {
1232
2.18k
  case STYP_DSECT:
1233
2.18k
    unhandled = "STYP_DSECT";
1234
2.18k
    break;
1235
1.60k
  case STYP_GROUP:
1236
1.60k
    unhandled = "STYP_GROUP";
1237
1.60k
    break;
1238
2.24k
  case STYP_COPY:
1239
2.24k
    unhandled = "STYP_COPY";
1240
2.24k
    break;
1241
1.78k
  case STYP_OVER:
1242
1.78k
    unhandled = "STYP_OVER";
1243
1.78k
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
4.78k
  case STYP_NOLOAD:
1246
4.78k
    sec_flags |= SEC_NEVER_LOAD;
1247
4.78k
    break;
1248
0
#endif
1249
4.98k
  case IMAGE_SCN_MEM_READ:
1250
4.98k
    sec_flags &= ~SEC_COFF_NOREAD;
1251
4.98k
    break;
1252
4.44k
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
4.44k
    break;
1255
2.88k
  case IMAGE_SCN_LNK_OTHER:
1256
2.88k
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
2.88k
    break;
1258
2.06k
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
2.06k
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
2.06k
    break;
1261
5.27k
  case IMAGE_SCN_MEM_NOT_PAGED:
1262
    /* Generate a warning message rather using the 'unhandled'
1263
       variable as this will allow some .sys files generate by
1264
       other toolchains to be processed.  See bugzilla issue 196.  */
1265
    /* xgettext:c-format */
1266
5.27k
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
5.27k
        " %s in section %s"),
1268
5.27k
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
5.27k
    break;
1270
5.11k
  case IMAGE_SCN_MEM_EXECUTE:
1271
5.11k
    sec_flags |= SEC_CODE;
1272
5.11k
    break;
1273
4.54k
  case IMAGE_SCN_MEM_WRITE:
1274
4.54k
    sec_flags &= ~ SEC_READONLY;
1275
4.54k
    break;
1276
6.35k
  case IMAGE_SCN_MEM_DISCARDABLE:
1277
    /* The MS PE spec says that debug sections are DISCARDABLE,
1278
       but the presence of a DISCARDABLE flag does not necessarily
1279
       mean that a given section contains debug information.  Thus
1280
       we only set the SEC_DEBUGGING flag on sections that we
1281
       recognise as containing debug information.  */
1282
6.35k
       if (is_dbg
1283
6.35k
#ifdef _COMMENT
1284
6.35k
        || strcmp (name, _COMMENT) == 0
1285
6.35k
#endif
1286
6.35k
        )
1287
1.16k
      {
1288
1.16k
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
1.16k
      }
1290
6.35k
    break;
1291
3.08k
  case IMAGE_SCN_MEM_SHARED:
1292
3.08k
    sec_flags |= SEC_COFF_SHARED;
1293
3.08k
    break;
1294
6.38k
  case IMAGE_SCN_LNK_REMOVE:
1295
6.38k
    if (!is_dbg)
1296
5.76k
      sec_flags |= SEC_EXCLUDE;
1297
6.38k
    break;
1298
5.62k
  case IMAGE_SCN_CNT_CODE:
1299
5.62k
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
5.62k
    break;
1301
3.64k
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
3.64k
    if (is_dbg)
1303
372
      sec_flags |= SEC_DEBUGGING;
1304
3.26k
    else
1305
3.26k
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
3.64k
    break;
1307
3.73k
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
3.73k
    sec_flags |= SEC_ALLOC;
1309
3.73k
    break;
1310
4.96k
  case IMAGE_SCN_LNK_INFO:
1311
    /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is
1312
       defined.  coff_compute_section_file_positions uses
1313
       COFF_PAGE_SIZE to ensure that the low order bits of the
1314
       section VMA and the file offset match.  If we don't know
1315
       COFF_PAGE_SIZE, we can't ensure the correct correspondence,
1316
       and demand page loading of the file will fail.  */
1317
4.96k
#ifdef COFF_PAGE_SIZE
1318
4.96k
    sec_flags |= SEC_DEBUGGING;
1319
4.96k
#endif
1320
4.96k
    break;
1321
6.33k
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
6.33k
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
482
      result = false;
1325
6.33k
    break;
1326
60.6k
  default:
1327
    /* Silently ignore for now.  */
1328
60.6k
    break;
1329
142k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
142k
      if (unhandled != NULL)
1333
12.7k
  {
1334
12.7k
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
12.7k
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
12.7k
       abfd, name, unhandled, flag);
1338
12.7k
    result = false;
1339
12.7k
  }
1340
142k
    }
1341
1342
28.4k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
28.4k
      && (startswith (name, ".sbss")
1344
0
    || startswith (name, ".sdata")))
1345
0
    sec_flags |= SEC_SMALL_DATA;
1346
1347
#if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE)
1348
  /* As a GNU extension, if the name begins with .gnu.linkonce, we
1349
     only link a single copy of the section.  This is used to support
1350
     g++.  g++ will emit each template expansion in its own section.
1351
     The symbols will be defined as weak, so that multiple definitions
1352
     are permitted.  The GNU linker extension is to actually discard
1353
     all but one of the sections.  */
1354
  if (startswith (name, ".gnu.linkonce"))
1355
    sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
1356
#endif
1357
1358
28.4k
  if (flags_ptr)
1359
28.4k
    * flags_ptr = sec_flags;
1360
1361
28.4k
  return result;
1362
28.4k
}
pei-mcore.c:styp_to_sec_flags
Line
Count
Source
1191
25.3k
{
1192
25.3k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
25.3k
  unsigned long styp_flags = internal_s->s_flags;
1194
25.3k
  flagword sec_flags;
1195
25.3k
  bool result = true;
1196
25.3k
  bool is_dbg = false;
1197
1198
25.3k
  if (startswith (name, DOT_DEBUG)
1199
25.3k
      || startswith (name, DOT_ZDEBUG)
1200
25.3k
#ifdef COFF_LONG_SECTION_NAMES
1201
25.3k
      || startswith (name, GNU_LINKONCE_WI)
1202
25.3k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
25.3k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
25.3k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
25.3k
      || startswith (name, GNU_DEBUGLINK)
1207
25.3k
      || startswith (name, GNU_DEBUGALTLINK)
1208
25.3k
#endif
1209
25.3k
      || startswith (name, ".stab"))
1210
438
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
25.3k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
25.3k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
20.8k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
138k
  while (styp_flags)
1220
112k
    {
1221
112k
      unsigned long flag = styp_flags & - styp_flags;
1222
112k
      char * unhandled = NULL;
1223
1224
112k
      styp_flags &= ~ flag;
1225
1226
      /* We infer from the distinct read/write/execute bits the settings
1227
   of some of the bfd flags; the actual values, should we need them,
1228
   are also in pei_section_data (abfd, section)->pe_flags.  */
1229
1230
112k
      switch (flag)
1231
112k
  {
1232
1.49k
  case STYP_DSECT:
1233
1.49k
    unhandled = "STYP_DSECT";
1234
1.49k
    break;
1235
1.16k
  case STYP_GROUP:
1236
1.16k
    unhandled = "STYP_GROUP";
1237
1.16k
    break;
1238
2.06k
  case STYP_COPY:
1239
2.06k
    unhandled = "STYP_COPY";
1240
2.06k
    break;
1241
1.93k
  case STYP_OVER:
1242
1.93k
    unhandled = "STYP_OVER";
1243
1.93k
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
3.22k
  case STYP_NOLOAD:
1246
3.22k
    sec_flags |= SEC_NEVER_LOAD;
1247
3.22k
    break;
1248
0
#endif
1249
4.46k
  case IMAGE_SCN_MEM_READ:
1250
4.46k
    sec_flags &= ~SEC_COFF_NOREAD;
1251
4.46k
    break;
1252
1.92k
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
1.92k
    break;
1255
1.62k
  case IMAGE_SCN_LNK_OTHER:
1256
1.62k
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
1.62k
    break;
1258
1.49k
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
1.49k
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
1.49k
    break;
1261
3.32k
  case IMAGE_SCN_MEM_NOT_PAGED:
1262
    /* Generate a warning message rather using the 'unhandled'
1263
       variable as this will allow some .sys files generate by
1264
       other toolchains to be processed.  See bugzilla issue 196.  */
1265
    /* xgettext:c-format */
1266
3.32k
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
3.32k
        " %s in section %s"),
1268
3.32k
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
3.32k
    break;
1270
4.76k
  case IMAGE_SCN_MEM_EXECUTE:
1271
4.76k
    sec_flags |= SEC_CODE;
1272
4.76k
    break;
1273
2.99k
  case IMAGE_SCN_MEM_WRITE:
1274
2.99k
    sec_flags &= ~ SEC_READONLY;
1275
2.99k
    break;
1276
5.33k
  case IMAGE_SCN_MEM_DISCARDABLE:
1277
    /* The MS PE spec says that debug sections are DISCARDABLE,
1278
       but the presence of a DISCARDABLE flag does not necessarily
1279
       mean that a given section contains debug information.  Thus
1280
       we only set the SEC_DEBUGGING flag on sections that we
1281
       recognise as containing debug information.  */
1282
5.33k
       if (is_dbg
1283
5.33k
#ifdef _COMMENT
1284
5.33k
        || strcmp (name, _COMMENT) == 0
1285
5.33k
#endif
1286
5.33k
        )
1287
623
      {
1288
623
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
623
      }
1290
5.33k
    break;
1291
3.57k
  case IMAGE_SCN_MEM_SHARED:
1292
3.57k
    sec_flags |= SEC_COFF_SHARED;
1293
3.57k
    break;
1294
5.21k
  case IMAGE_SCN_LNK_REMOVE:
1295
5.21k
    if (!is_dbg)
1296
4.97k
      sec_flags |= SEC_EXCLUDE;
1297
5.21k
    break;
1298
4.92k
  case IMAGE_SCN_CNT_CODE:
1299
4.92k
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
4.92k
    break;
1301
3.30k
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
3.30k
    if (is_dbg)
1303
248
      sec_flags |= SEC_DEBUGGING;
1304
3.05k
    else
1305
3.05k
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
3.30k
    break;
1307
1.78k
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
1.78k
    sec_flags |= SEC_ALLOC;
1309
1.78k
    break;
1310
4.28k
  case IMAGE_SCN_LNK_INFO:
1311
    /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is
1312
       defined.  coff_compute_section_file_positions uses
1313
       COFF_PAGE_SIZE to ensure that the low order bits of the
1314
       section VMA and the file offset match.  If we don't know
1315
       COFF_PAGE_SIZE, we can't ensure the correct correspondence,
1316
       and demand page loading of the file will fail.  */
1317
4.28k
#ifdef COFF_PAGE_SIZE
1318
4.28k
    sec_flags |= SEC_DEBUGGING;
1319
4.28k
#endif
1320
4.28k
    break;
1321
6.88k
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
6.88k
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
480
      result = false;
1325
6.88k
    break;
1326
47.0k
  default:
1327
    /* Silently ignore for now.  */
1328
47.0k
    break;
1329
112k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
112k
      if (unhandled != NULL)
1333
9.78k
  {
1334
9.78k
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
9.78k
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
9.78k
       abfd, name, unhandled, flag);
1338
9.78k
    result = false;
1339
9.78k
  }
1340
112k
    }
1341
1342
25.3k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
25.3k
      && (startswith (name, ".sbss")
1344
0
    || startswith (name, ".sdata")))
1345
0
    sec_flags |= SEC_SMALL_DATA;
1346
1347
#if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE)
1348
  /* As a GNU extension, if the name begins with .gnu.linkonce, we
1349
     only link a single copy of the section.  This is used to support
1350
     g++.  g++ will emit each template expansion in its own section.
1351
     The symbols will be defined as weak, so that multiple definitions
1352
     are permitted.  The GNU linker extension is to actually discard
1353
     all but one of the sections.  */
1354
  if (startswith (name, ".gnu.linkonce"))
1355
    sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
1356
#endif
1357
1358
25.3k
  if (flags_ptr)
1359
25.3k
    * flags_ptr = sec_flags;
1360
1361
25.3k
  return result;
1362
25.3k
}
pei-sh.c:styp_to_sec_flags
Line
Count
Source
1191
28.2k
{
1192
28.2k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
28.2k
  unsigned long styp_flags = internal_s->s_flags;
1194
28.2k
  flagword sec_flags;
1195
28.2k
  bool result = true;
1196
28.2k
  bool is_dbg = false;
1197
1198
28.2k
  if (startswith (name, DOT_DEBUG)
1199
28.2k
      || startswith (name, DOT_ZDEBUG)
1200
28.2k
#ifdef COFF_LONG_SECTION_NAMES
1201
28.2k
      || startswith (name, GNU_LINKONCE_WI)
1202
28.2k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
28.2k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
28.2k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
28.2k
      || startswith (name, GNU_DEBUGLINK)
1207
28.2k
      || startswith (name, GNU_DEBUGALTLINK)
1208
28.2k
#endif
1209
28.2k
      || startswith (name, ".stab"))
1210
774
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
28.2k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
28.2k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
24.8k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
134k
  while (styp_flags)
1220
105k
    {
1221
105k
      unsigned long flag = styp_flags & - styp_flags;
1222
105k
      char * unhandled = NULL;
1223
1224
105k
      styp_flags &= ~ flag;
1225
1226
      /* We infer from the distinct read/write/execute bits the settings
1227
   of some of the bfd flags; the actual values, should we need them,
1228
   are also in pei_section_data (abfd, section)->pe_flags.  */
1229
1230
105k
      switch (flag)
1231
105k
  {
1232
1.78k
  case STYP_DSECT:
1233
1.78k
    unhandled = "STYP_DSECT";
1234
1.78k
    break;
1235
1.89k
  case STYP_GROUP:
1236
1.89k
    unhandled = "STYP_GROUP";
1237
1.89k
    break;
1238
1.68k
  case STYP_COPY:
1239
1.68k
    unhandled = "STYP_COPY";
1240
1.68k
    break;
1241
1.89k
  case STYP_OVER:
1242
1.89k
    unhandled = "STYP_OVER";
1243
1.89k
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
3.49k
  case STYP_NOLOAD:
1246
3.49k
    sec_flags |= SEC_NEVER_LOAD;
1247
3.49k
    break;
1248
0
#endif
1249
3.41k
  case IMAGE_SCN_MEM_READ:
1250
3.41k
    sec_flags &= ~SEC_COFF_NOREAD;
1251
3.41k
    break;
1252
3.27k
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
3.27k
    break;
1255
1.43k
  case IMAGE_SCN_LNK_OTHER:
1256
1.43k
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
1.43k
    break;
1258
2.66k
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
2.66k
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
2.66k
    break;
1261
3.36k
  case IMAGE_SCN_MEM_NOT_PAGED:
1262
    /* Generate a warning message rather using the 'unhandled'
1263
       variable as this will allow some .sys files generate by
1264
       other toolchains to be processed.  See bugzilla issue 196.  */
1265
    /* xgettext:c-format */
1266
3.36k
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
3.36k
        " %s in section %s"),
1268
3.36k
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
3.36k
    break;
1270
3.98k
  case IMAGE_SCN_MEM_EXECUTE:
1271
3.98k
    sec_flags |= SEC_CODE;
1272
3.98k
    break;
1273
2.12k
  case IMAGE_SCN_MEM_WRITE:
1274
2.12k
    sec_flags &= ~ SEC_READONLY;
1275
2.12k
    break;
1276
3.36k
  case IMAGE_SCN_MEM_DISCARDABLE:
1277
    /* The MS PE spec says that debug sections are DISCARDABLE,
1278
       but the presence of a DISCARDABLE flag does not necessarily
1279
       mean that a given section contains debug information.  Thus
1280
       we only set the SEC_DEBUGGING flag on sections that we
1281
       recognise as containing debug information.  */
1282
3.36k
       if (is_dbg
1283
3.36k
#ifdef _COMMENT
1284
3.36k
        || strcmp (name, _COMMENT) == 0
1285
3.36k
#endif
1286
3.36k
        )
1287
470
      {
1288
470
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
470
      }
1290
3.36k
    break;
1291
3.10k
  case IMAGE_SCN_MEM_SHARED:
1292
3.10k
    sec_flags |= SEC_COFF_SHARED;
1293
3.10k
    break;
1294
3.16k
  case IMAGE_SCN_LNK_REMOVE:
1295
3.16k
    if (!is_dbg)
1296
2.90k
      sec_flags |= SEC_EXCLUDE;
1297
3.16k
    break;
1298
4.02k
  case IMAGE_SCN_CNT_CODE:
1299
4.02k
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
4.02k
    break;
1301
3.75k
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
3.75k
    if (is_dbg)
1303
283
      sec_flags |= SEC_DEBUGGING;
1304
3.47k
    else
1305
3.47k
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
3.75k
    break;
1307
1.63k
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
1.63k
    sec_flags |= SEC_ALLOC;
1309
1.63k
    break;
1310
4.69k
  case IMAGE_SCN_LNK_INFO:
1311
    /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is
1312
       defined.  coff_compute_section_file_positions uses
1313
       COFF_PAGE_SIZE to ensure that the low order bits of the
1314
       section VMA and the file offset match.  If we don't know
1315
       COFF_PAGE_SIZE, we can't ensure the correct correspondence,
1316
       and demand page loading of the file will fail.  */
1317
4.69k
#ifdef COFF_PAGE_SIZE
1318
4.69k
    sec_flags |= SEC_DEBUGGING;
1319
4.69k
#endif
1320
4.69k
    break;
1321
3.66k
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
3.66k
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
476
      result = false;
1325
3.66k
    break;
1326
47.5k
  default:
1327
    /* Silently ignore for now.  */
1328
47.5k
    break;
1329
105k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
105k
      if (unhandled != NULL)
1333
11.3k
  {
1334
11.3k
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
11.3k
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
11.3k
       abfd, name, unhandled, flag);
1338
11.3k
    result = false;
1339
11.3k
  }
1340
105k
    }
1341
1342
28.2k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
28.2k
      && (startswith (name, ".sbss")
1344
0
    || startswith (name, ".sdata")))
1345
0
    sec_flags |= SEC_SMALL_DATA;
1346
1347
#if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE)
1348
  /* As a GNU extension, if the name begins with .gnu.linkonce, we
1349
     only link a single copy of the section.  This is used to support
1350
     g++.  g++ will emit each template expansion in its own section.
1351
     The symbols will be defined as weak, so that multiple definitions
1352
     are permitted.  The GNU linker extension is to actually discard
1353
     all but one of the sections.  */
1354
  if (startswith (name, ".gnu.linkonce"))
1355
    sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
1356
#endif
1357
1358
28.2k
  if (flags_ptr)
1359
28.2k
    * flags_ptr = sec_flags;
1360
1361
28.2k
  return result;
1362
28.2k
}
1363
1364
#endif /* COFF_WITH_PE */
1365
1366
0
#define get_index(symbol) ((symbol)->udata.i)
1367
1368
/*
1369
INTERNAL_DEFINITION
1370
  bfd_coff_backend_data
1371
1372
INTERNAL
1373
.{* COFF symbol classifications.  *}
1374
.
1375
.enum coff_symbol_classification
1376
.{
1377
.  {* Global symbol.  *}
1378
.  COFF_SYMBOL_GLOBAL,
1379
.  {* Common symbol.  *}
1380
.  COFF_SYMBOL_COMMON,
1381
.  {* Undefined symbol.  *}
1382
.  COFF_SYMBOL_UNDEFINED,
1383
.  {* Local symbol.  *}
1384
.  COFF_SYMBOL_LOCAL,
1385
.  {* PE section symbol.  *}
1386
.  COFF_SYMBOL_PE_SECTION
1387
.};
1388
.
1389
.typedef asection * (*coff_gc_mark_hook_fn)
1390
.  (asection *, struct bfd_link_info *, struct internal_reloc *,
1391
.   struct coff_link_hash_entry *, struct internal_syment *);
1392
.
1393
1394
Special entry points for gdb to swap in coff symbol table parts:
1395
1396
CODE_FRAGMENT
1397
.typedef struct
1398
.{
1399
.  void (*_bfd_coff_swap_aux_in)
1400
.    (bfd *, void *, int, int, int, int, void *);
1401
.
1402
.  void (*_bfd_coff_swap_sym_in)
1403
.    (bfd *, void *, void *);
1404
.
1405
.  void (*_bfd_coff_swap_lineno_in)
1406
.    (bfd *, void *, void *);
1407
.
1408
.  unsigned int (*_bfd_coff_swap_aux_out)
1409
.    (bfd *, void *, int, int, int, int, void *);
1410
.
1411
.  unsigned int (*_bfd_coff_swap_sym_out)
1412
.    (bfd *, void *, void *);
1413
.
1414
.  unsigned int (*_bfd_coff_swap_lineno_out)
1415
.    (bfd *, void *, void *);
1416
.
1417
.  unsigned int (*_bfd_coff_swap_reloc_out)
1418
.    (bfd *, void *, void *);
1419
.
1420
.  unsigned int (*_bfd_coff_swap_filehdr_out)
1421
.    (bfd *, void *, void *);
1422
.
1423
.  unsigned int (*_bfd_coff_swap_aouthdr_out)
1424
.    (bfd *, void *, void *);
1425
.
1426
.  unsigned int (*_bfd_coff_swap_scnhdr_out)
1427
.    (bfd *, void *, void *);
1428
.
1429
.  unsigned int _bfd_filhsz;
1430
.  unsigned int _bfd_aoutsz;
1431
.  unsigned int _bfd_scnhsz;
1432
.  unsigned int _bfd_symesz;
1433
.  unsigned int _bfd_auxesz;
1434
.  unsigned int _bfd_relsz;
1435
.  unsigned int _bfd_linesz;
1436
.  unsigned int _bfd_filnmlen;
1437
.  bool _bfd_coff_long_filenames;
1438
.
1439
.  bool _bfd_coff_long_section_names;
1440
.  bool (*_bfd_coff_set_long_section_names)
1441
.    (bfd *, int);
1442
.
1443
.  unsigned int _bfd_coff_default_section_alignment_power;
1444
.  bool _bfd_coff_force_symnames_in_strings;
1445
.  unsigned int _bfd_coff_debug_string_prefix_length;
1446
.  unsigned int _bfd_coff_max_nscns;
1447
.
1448
.  void (*_bfd_coff_swap_filehdr_in)
1449
.    (bfd *, void *, void *);
1450
.
1451
.  void (*_bfd_coff_swap_aouthdr_in)
1452
.    (bfd *, void *, void *);
1453
.
1454
.  void (*_bfd_coff_swap_scnhdr_in)
1455
.    (bfd *, void *, void *);
1456
.
1457
.  void (*_bfd_coff_swap_reloc_in)
1458
.    (bfd *abfd, void *, void *);
1459
.
1460
.  bool (*_bfd_coff_bad_format_hook)
1461
.    (bfd *, void *);
1462
.
1463
.  bool (*_bfd_coff_set_arch_mach_hook)
1464
.    (bfd *, void *);
1465
.
1466
.  void * (*_bfd_coff_mkobject_hook)
1467
.    (bfd *, void *, void *);
1468
.
1469
.  bool (*_bfd_styp_to_sec_flags_hook)
1470
.    (bfd *, void *, const char *, asection *, flagword *);
1471
.
1472
.  void (*_bfd_set_alignment_hook)
1473
.    (bfd *, asection *, void *);
1474
.
1475
.  bool (*_bfd_coff_slurp_symbol_table)
1476
.    (bfd *);
1477
.
1478
.  bool (*_bfd_coff_symname_in_debug)
1479
.    (bfd *, struct internal_syment *);
1480
.
1481
.  bool (*_bfd_coff_pointerize_aux_hook)
1482
.    (bfd *, combined_entry_type *, combined_entry_type *,
1483
.     unsigned int, combined_entry_type *);
1484
.
1485
.  bool (*_bfd_coff_print_aux)
1486
.    (bfd *, FILE *, combined_entry_type *, combined_entry_type *,
1487
.     combined_entry_type *, unsigned int);
1488
.
1489
.  bool (*_bfd_coff_reloc16_extra_cases)
1490
.    (bfd *, struct bfd_link_info *, struct bfd_link_order *, arelent *,
1491
.     bfd_byte *, size_t *, size_t *);
1492
.
1493
.  int (*_bfd_coff_reloc16_estimate)
1494
.    (bfd *, asection *, arelent *, unsigned int,
1495
.     struct bfd_link_info *);
1496
.
1497
.  enum coff_symbol_classification (*_bfd_coff_classify_symbol)
1498
.    (bfd *, struct internal_syment *);
1499
.
1500
.  bool (*_bfd_coff_compute_section_file_positions)
1501
.    (bfd *);
1502
.
1503
.  bool (*_bfd_coff_start_final_link)
1504
.    (bfd *, struct bfd_link_info *);
1505
.
1506
.  bool (*_bfd_coff_relocate_section)
1507
.    (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
1508
.     struct internal_reloc *, struct internal_syment *, asection **);
1509
.
1510
.  reloc_howto_type *(*_bfd_coff_rtype_to_howto)
1511
.    (bfd *, asection *, struct internal_reloc *,
1512
.     struct coff_link_hash_entry *, struct internal_syment *, bfd_vma *);
1513
.
1514
.  bool (*_bfd_coff_adjust_symndx)
1515
.    (bfd *, struct bfd_link_info *, bfd *, asection *,
1516
.     struct internal_reloc *, bool *);
1517
.
1518
.  bool (*_bfd_coff_link_add_one_symbol)
1519
.    (struct bfd_link_info *, bfd *, const char *, flagword,
1520
.     asection *, bfd_vma, const char *, bool, bool,
1521
.     struct bfd_link_hash_entry **);
1522
.
1523
.  bool (*_bfd_coff_link_output_has_begun)
1524
.    (bfd *, struct coff_final_link_info *);
1525
.
1526
.  bool (*_bfd_coff_final_link_postscript)
1527
.    (bfd *, struct coff_final_link_info *);
1528
.
1529
.  bool (*_bfd_coff_print_pdata)
1530
.    (bfd *, void *);
1531
.
1532
.} bfd_coff_backend_data;
1533
.
1534
1535
INTERNAL
1536
.#define coff_backend_info(abfd) \
1537
.  ((const bfd_coff_backend_data *) (abfd)->xvec->backend_data)
1538
.
1539
.#define bfd_coff_swap_aux_in(a,e,t,c,ind,num,i) \
1540
.  ((coff_backend_info (a)->_bfd_coff_swap_aux_in) (a,e,t,c,ind,num,i))
1541
.
1542
.#define bfd_coff_swap_sym_in(a,e,i) \
1543
.  ((coff_backend_info (a)->_bfd_coff_swap_sym_in) (a,e,i))
1544
.
1545
.#define bfd_coff_swap_lineno_in(a,e,i) \
1546
.  ((coff_backend_info ( a)->_bfd_coff_swap_lineno_in) (a,e,i))
1547
.
1548
.#define bfd_coff_swap_reloc_out(abfd, i, o) \
1549
.  ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_out) (abfd, i, o))
1550
.
1551
.#define bfd_coff_swap_lineno_out(abfd, i, o) \
1552
.  ((coff_backend_info (abfd)->_bfd_coff_swap_lineno_out) (abfd, i, o))
1553
.
1554
.#define bfd_coff_swap_aux_out(a,i,t,c,ind,num,o) \
1555
.  ((coff_backend_info (a)->_bfd_coff_swap_aux_out) (a,i,t,c,ind,num,o))
1556
.
1557
.#define bfd_coff_swap_sym_out(abfd, i,o) \
1558
.  ((coff_backend_info (abfd)->_bfd_coff_swap_sym_out) (abfd, i, o))
1559
.
1560
.#define bfd_coff_swap_scnhdr_out(abfd, i,o) \
1561
.  ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_out) (abfd, i, o))
1562
.
1563
.#define bfd_coff_swap_filehdr_out(abfd, i,o) \
1564
.  ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_out) (abfd, i, o))
1565
.
1566
.#define bfd_coff_swap_aouthdr_out(abfd, i,o) \
1567
.  ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_out) (abfd, i, o))
1568
.
1569
.#define bfd_coff_filhsz(abfd) (coff_backend_info (abfd)->_bfd_filhsz)
1570
.#define bfd_coff_aoutsz(abfd) (coff_backend_info (abfd)->_bfd_aoutsz)
1571
.#define bfd_coff_scnhsz(abfd) (coff_backend_info (abfd)->_bfd_scnhsz)
1572
.#define bfd_coff_symesz(abfd) (coff_backend_info (abfd)->_bfd_symesz)
1573
.#define bfd_coff_auxesz(abfd) (coff_backend_info (abfd)->_bfd_auxesz)
1574
.#define bfd_coff_relsz(abfd)  (coff_backend_info (abfd)->_bfd_relsz)
1575
.#define bfd_coff_linesz(abfd) (coff_backend_info (abfd)->_bfd_linesz)
1576
.#define bfd_coff_filnmlen(abfd) (coff_backend_info (abfd)->_bfd_filnmlen)
1577
.#define bfd_coff_long_filenames(abfd) \
1578
.  (coff_backend_info (abfd)->_bfd_coff_long_filenames)
1579
.#define bfd_coff_long_section_names(abfd) \
1580
.  (coff_data (abfd)->long_section_names)
1581
.#define bfd_coff_set_long_section_names(abfd, enable) \
1582
.  ((coff_backend_info (abfd)->_bfd_coff_set_long_section_names) (abfd, enable))
1583
.#define bfd_coff_default_section_alignment_power(abfd) \
1584
.  (coff_backend_info (abfd)->_bfd_coff_default_section_alignment_power)
1585
.#define bfd_coff_max_nscns(abfd) \
1586
.  (coff_backend_info (abfd)->_bfd_coff_max_nscns)
1587
.
1588
.#define bfd_coff_swap_filehdr_in(abfd, i,o) \
1589
.  ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_in) (abfd, i, o))
1590
.
1591
.#define bfd_coff_swap_aouthdr_in(abfd, i,o) \
1592
.  ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_in) (abfd, i, o))
1593
.
1594
.#define bfd_coff_swap_scnhdr_in(abfd, i,o) \
1595
.  ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_in) (abfd, i, o))
1596
.
1597
.#define bfd_coff_swap_reloc_in(abfd, i, o) \
1598
.  ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_in) (abfd, i, o))
1599
.
1600
.#define bfd_coff_bad_format_hook(abfd, filehdr) \
1601
.  ((coff_backend_info (abfd)->_bfd_coff_bad_format_hook) (abfd, filehdr))
1602
.
1603
.#define bfd_coff_set_arch_mach_hook(abfd, filehdr)\
1604
.  ((coff_backend_info (abfd)->_bfd_coff_set_arch_mach_hook) (abfd, filehdr))
1605
.#define bfd_coff_mkobject_hook(abfd, filehdr, aouthdr)\
1606
.  ((coff_backend_info (abfd)->_bfd_coff_mkobject_hook)\
1607
.   (abfd, filehdr, aouthdr))
1608
.
1609
.#define bfd_coff_styp_to_sec_flags_hook(abfd, scnhdr, name, section, flags_ptr)\
1610
.  ((coff_backend_info (abfd)->_bfd_styp_to_sec_flags_hook)\
1611
.   (abfd, scnhdr, name, section, flags_ptr))
1612
.
1613
.#define bfd_coff_set_alignment_hook(abfd, sec, scnhdr)\
1614
.  ((coff_backend_info (abfd)->_bfd_set_alignment_hook) (abfd, sec, scnhdr))
1615
.
1616
.#define bfd_coff_slurp_symbol_table(abfd)\
1617
.  ((coff_backend_info (abfd)->_bfd_coff_slurp_symbol_table) (abfd))
1618
.
1619
.#define bfd_coff_symname_in_debug(abfd, sym)\
1620
.  ((coff_backend_info (abfd)->_bfd_coff_symname_in_debug) (abfd, sym))
1621
.
1622
.#define bfd_coff_force_symnames_in_strings(abfd)\
1623
.  (coff_backend_info (abfd)->_bfd_coff_force_symnames_in_strings)
1624
.
1625
.#define bfd_coff_debug_string_prefix_length(abfd)\
1626
.  (coff_backend_info (abfd)->_bfd_coff_debug_string_prefix_length)
1627
.
1628
.#define bfd_coff_print_aux(abfd, file, base, symbol, aux, indaux)\
1629
.  ((coff_backend_info (abfd)->_bfd_coff_print_aux)\
1630
.   (abfd, file, base, symbol, aux, indaux))
1631
.
1632
.#define bfd_coff_reloc16_extra_cases(abfd, link_info, link_order,\
1633
.             reloc, data, src_ptr, dst_ptr)\
1634
.  ((coff_backend_info (abfd)->_bfd_coff_reloc16_extra_cases)\
1635
.   (abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr))
1636
.
1637
.#define bfd_coff_reloc16_estimate(abfd, section, reloc, shrink, link_info)\
1638
.  ((coff_backend_info (abfd)->_bfd_coff_reloc16_estimate)\
1639
.   (abfd, section, reloc, shrink, link_info))
1640
.
1641
.#define bfd_coff_classify_symbol(abfd, sym)\
1642
.  ((coff_backend_info (abfd)->_bfd_coff_classify_symbol)\
1643
.   (abfd, sym))
1644
.
1645
.#define bfd_coff_compute_section_file_positions(abfd)\
1646
.  ((coff_backend_info (abfd)->_bfd_coff_compute_section_file_positions)\
1647
.   (abfd))
1648
.
1649
.#define bfd_coff_start_final_link(obfd, info)\
1650
.  ((coff_backend_info (obfd)->_bfd_coff_start_final_link)\
1651
.   (obfd, info))
1652
.#define bfd_coff_relocate_section(obfd,info,ibfd,o,con,rel,isyms,secs)\
1653
.  ((coff_backend_info (ibfd)->_bfd_coff_relocate_section)\
1654
.   (obfd, info, ibfd, o, con, rel, isyms, secs))
1655
.#define bfd_coff_rtype_to_howto(abfd, sec, rel, h, sym, addendp)\
1656
.  ((coff_backend_info (abfd)->_bfd_coff_rtype_to_howto)\
1657
.   (abfd, sec, rel, h, sym, addendp))
1658
.#define bfd_coff_adjust_symndx(obfd, info, ibfd, sec, rel, adjustedp)\
1659
.  ((coff_backend_info (abfd)->_bfd_coff_adjust_symndx)\
1660
.   (obfd, info, ibfd, sec, rel, adjustedp))
1661
.#define bfd_coff_link_add_one_symbol(info, abfd, name, flags, section,\
1662
.             value, string, cp, coll, hashp)\
1663
.  ((coff_backend_info (abfd)->_bfd_coff_link_add_one_symbol)\
1664
.   (info, abfd, name, flags, section, value, string, cp, coll, hashp))
1665
.
1666
.#define bfd_coff_link_output_has_begun(a,p) \
1667
.  ((coff_backend_info (a)->_bfd_coff_link_output_has_begun) (a, p))
1668
.#define bfd_coff_final_link_postscript(a,p) \
1669
.  ((coff_backend_info (a)->_bfd_coff_final_link_postscript) (a, p))
1670
.
1671
.#define bfd_coff_have_print_pdata(a) \
1672
.  (coff_backend_info (a)->_bfd_coff_print_pdata)
1673
.#define bfd_coff_print_pdata(a,p) \
1674
.  ((coff_backend_info (a)->_bfd_coff_print_pdata) (a, p))
1675
.
1676
.{* Macro: Returns true if the bfd is a PE executable as opposed to a
1677
.   PE object file.  *}
1678
.#define bfd_pei_p(abfd) \
1679
.  (startswith ((abfd)->xvec->name, "pei-"))
1680
*/
1681
1682
/* See whether the magic number matches.  */
1683
1684
static bool
1685
coff_bad_format_hook (bfd * abfd ATTRIBUTE_UNUSED, void * filehdr)
1686
7.29M
{
1687
7.29M
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
7.29M
  if (BADMAG (*internal_f))
1690
7.08M
    return false;
1691
1692
210k
  return true;
1693
7.29M
}
pei-i386.c:coff_bad_format_hook
Line
Count
Source
1686
71.7k
{
1687
71.7k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
71.7k
  if (BADMAG (*internal_f))
1690
59.9k
    return false;
1691
1692
11.8k
  return true;
1693
71.7k
}
pe-x86_64.c:coff_bad_format_hook
Line
Count
Source
1686
504k
{
1687
504k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
504k
  if (BADMAG (*internal_f))
1690
487k
    return false;
1691
1692
16.9k
  return true;
1693
504k
}
pei-x86_64.c:coff_bad_format_hook
Line
Count
Source
1686
72.4k
{
1687
72.4k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
72.4k
  if (BADMAG (*internal_f))
1690
61.2k
    return false;
1691
1692
11.1k
  return true;
1693
72.4k
}
coff-x86_64.c:coff_bad_format_hook
Line
Count
Source
1686
258k
{
1687
258k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
258k
  if (BADMAG (*internal_f))
1690
246k
    return false;
1691
1692
12.7k
  return true;
1693
258k
}
Unexecuted instantiation: coff64-rs6000.c:coff_bad_format_hook
pe-aarch64.c:coff_bad_format_hook
Line
Count
Source
1686
258k
{
1687
258k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
258k
  if (BADMAG (*internal_f))
1690
253k
    return false;
1691
1692
5.21k
  return true;
1693
258k
}
pei-aarch64.c:coff_bad_format_hook
Line
Count
Source
1686
69.9k
{
1687
69.9k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
69.9k
  if (BADMAG (*internal_f))
1690
64.3k
    return false;
1691
1692
5.64k
  return true;
1693
69.9k
}
pei-ia64.c:coff_bad_format_hook
Line
Count
Source
1686
68.3k
{
1687
68.3k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
68.3k
  if (BADMAG (*internal_f))
1690
61.4k
    return false;
1691
1692
6.91k
  return true;
1693
68.3k
}
pei-loongarch64.c:coff_bad_format_hook
Line
Count
Source
1686
69.9k
{
1687
69.9k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
69.9k
  if (BADMAG (*internal_f))
1690
61.9k
    return false;
1691
1692
7.98k
  return true;
1693
69.9k
}
cf-i386lynx.c:coff_bad_format_hook
Line
Count
Source
1686
258k
{
1687
258k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
258k
  if (BADMAG (*internal_f))
1690
250k
    return false;
1691
1692
8.53k
  return true;
1693
258k
}
coff-go32.c:coff_bad_format_hook
Line
Count
Source
1686
258k
{
1687
258k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
258k
  if (BADMAG (*internal_f))
1690
250k
    return false;
1691
1692
8.22k
  return true;
1693
258k
}
coff-i386.c:coff_bad_format_hook
Line
Count
Source
1686
258k
{
1687
258k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
258k
  if (BADMAG (*internal_f))
1690
250k
    return false;
1691
1692
8.22k
  return true;
1693
258k
}
coff-rs6000.c:coff_bad_format_hook
Line
Count
Source
1686
258k
{
1687
258k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
258k
  if (BADMAG (*internal_f))
1690
250k
    return false;
1691
1692
8.22k
  return true;
1693
258k
}
coff-sh.c:coff_bad_format_hook
Line
Count
Source
1686
1.00M
{
1687
1.00M
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
1.00M
  if (BADMAG (*internal_f))
1690
990k
    return false;
1691
1692
13.7k
  return true;
1693
1.00M
}
coff-stgo32.c:coff_bad_format_hook
Line
Count
Source
1686
347
{
1687
347
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
347
  if (BADMAG (*internal_f))
1690
5
    return false;
1691
1692
342
  return true;
1693
347
}
coff-tic30.c:coff_bad_format_hook
Line
Count
Source
1686
258k
{
1687
258k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
258k
  if (BADMAG (*internal_f))
1690
254k
    return false;
1691
1692
4.56k
  return true;
1693
258k
}
Unexecuted instantiation: coff-tic4x.c:coff_bad_format_hook
coff-tic54x.c:coff_bad_format_hook
Line
Count
Source
1686
515k
{
1687
515k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
515k
  if (BADMAG (*internal_f))
1690
515k
    return false;
1691
1692
2
  return true;
1693
515k
}
coff-z80.c:coff_bad_format_hook
Line
Count
Source
1686
258k
{
1687
258k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
258k
  if (BADMAG (*internal_f))
1690
255k
    return false;
1691
1692
3.14k
  return true;
1693
258k
}
coff-z8k.c:coff_bad_format_hook
Line
Count
Source
1686
258k
{
1687
258k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
258k
  if (BADMAG (*internal_f))
1690
254k
    return false;
1691
1692
4.36k
  return true;
1693
258k
}
pe-arm-wince.c:coff_bad_format_hook
Line
Count
Source
1686
517k
{
1687
517k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
517k
  if (BADMAG (*internal_f))
1690
514k
    return false;
1691
1692
3.18k
  return true;
1693
517k
}
pe-arm.c:coff_bad_format_hook
Line
Count
Source
1686
517k
{
1687
517k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
517k
  if (BADMAG (*internal_f))
1690
514k
    return false;
1691
1692
3.18k
  return true;
1693
517k
}
pe-i386.c:coff_bad_format_hook
Line
Count
Source
1686
500k
{
1687
500k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
500k
  if (BADMAG (*internal_f))
1690
491k
    return false;
1691
1692
9.32k
  return true;
1693
500k
}
pe-mcore.c:coff_bad_format_hook
Line
Count
Source
1686
517k
{
1687
517k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
517k
  if (BADMAG (*internal_f))
1690
513k
    return false;
1691
1692
4.16k
  return true;
1693
517k
}
pe-sh.c:coff_bad_format_hook
Line
Count
Source
1686
258k
{
1687
258k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
258k
  if (BADMAG (*internal_f))
1690
251k
    return false;
1691
1692
7.10k
  return true;
1693
258k
}
pei-arm-wince.c:coff_bad_format_hook
Line
Count
Source
1686
69.9k
{
1687
69.9k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
69.9k
  if (BADMAG (*internal_f))
1690
55.4k
    return false;
1691
1692
14.5k
  return true;
1693
69.9k
}
pei-arm.c:coff_bad_format_hook
Line
Count
Source
1686
69.9k
{
1687
69.9k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
69.9k
  if (BADMAG (*internal_f))
1690
55.4k
    return false;
1691
1692
14.5k
  return true;
1693
69.9k
}
pei-mcore.c:coff_bad_format_hook
Line
Count
Source
1686
69.9k
{
1687
69.9k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
69.9k
  if (BADMAG (*internal_f))
1690
61.0k
    return false;
1691
1692
8.91k
  return true;
1693
69.9k
}
pei-sh.c:coff_bad_format_hook
Line
Count
Source
1686
69.9k
{
1687
69.9k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
69.9k
  if (BADMAG (*internal_f))
1690
62.5k
    return false;
1691
1692
7.41k
  return true;
1693
69.9k
}
1694
1695
#ifdef TICOFF
1696
static bool
1697
ticoff0_bad_format_hook (bfd *abfd ATTRIBUTE_UNUSED, void * filehdr)
1698
517k
{
1699
517k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1700
1701
517k
  if (COFF0_BADMAG (*internal_f))
1702
507k
    return false;
1703
1704
9.76k
  return true;
1705
517k
}
Unexecuted instantiation: coff-tic4x.c:ticoff0_bad_format_hook
coff-tic54x.c:ticoff0_bad_format_hook
Line
Count
Source
1698
517k
{
1699
517k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1700
1701
517k
  if (COFF0_BADMAG (*internal_f))
1702
507k
    return false;
1703
1704
9.76k
  return true;
1705
517k
}
1706
#endif
1707
1708
#ifdef TICOFF
1709
static bool
1710
ticoff1_bad_format_hook (bfd *abfd ATTRIBUTE_UNUSED, void * filehdr)
1711
515k
{
1712
515k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1713
1714
515k
  if (COFF1_BADMAG (*internal_f))
1715
514k
    return false;
1716
1717
1.34k
  return true;
1718
515k
}
Unexecuted instantiation: coff-tic4x.c:ticoff1_bad_format_hook
coff-tic54x.c:ticoff1_bad_format_hook
Line
Count
Source
1711
515k
{
1712
515k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1713
1714
515k
  if (COFF1_BADMAG (*internal_f))
1715
514k
    return false;
1716
1717
1.34k
  return true;
1718
515k
}
1719
#endif
1720
1721
/* Check whether this section uses an alignment other than the
1722
   default.  */
1723
1724
static void
1725
coff_set_custom_section_alignment (bfd *abfd ATTRIBUTE_UNUSED,
1726
           asection *section,
1727
           const struct coff_section_alignment_entry *alignment_table,
1728
           const unsigned int table_size)
1729
16.6M
{
1730
16.6M
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
16.6M
  unsigned int i;
1732
1733
89.1M
  for (i = 0; i < table_size; ++i)
1734
72.5M
    {
1735
72.5M
      const char *secname = bfd_section_name (section);
1736
1737
72.5M
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
72.5M
    ? strcmp (alignment_table[i].name, secname) == 0
1739
72.5M
    : strncmp (alignment_table[i].name, secname,
1740
38.3M
         alignment_table[i].comparison_length) == 0)
1741
83.6k
  break;
1742
72.5M
    }
1743
16.6M
  if (i >= table_size)
1744
16.5M
    return;
1745
1746
83.6k
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
83.6k
      && default_alignment < alignment_table[i].default_alignment_min)
1748
35.7k
    return;
1749
1750
47.8k
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
0
      && default_alignment > alignment_table[i].default_alignment_max
1753
#endif
1754
47.8k
      )
1755
0
    return;
1756
1757
47.8k
  section->alignment_power = alignment_table[i].alignment_power;
1758
47.8k
}
pei-i386.c:coff_set_custom_section_alignment
Line
Count
Source
1729
122k
{
1730
122k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
122k
  unsigned int i;
1732
1733
1.08M
  for (i = 0; i < table_size; ++i)
1734
967k
    {
1735
967k
      const char *secname = bfd_section_name (section);
1736
1737
967k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
967k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
967k
    : strncmp (alignment_table[i].name, secname,
1740
606k
         alignment_table[i].comparison_length) == 0)
1741
3.36k
  break;
1742
967k
    }
1743
122k
  if (i >= table_size)
1744
119k
    return;
1745
1746
3.36k
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
3.36k
      && default_alignment < alignment_table[i].default_alignment_min)
1748
555
    return;
1749
1750
2.80k
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
2.80k
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
2.80k
      && default_alignment > alignment_table[i].default_alignment_max
1753
2.80k
#endif
1754
2.80k
      )
1755
0
    return;
1756
1757
2.80k
  section->alignment_power = alignment_table[i].alignment_power;
1758
2.80k
}
pe-x86_64.c:coff_set_custom_section_alignment
Line
Count
Source
1729
43.1k
{
1730
43.1k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
43.1k
  unsigned int i;
1732
1733
582k
  for (i = 0; i < table_size; ++i)
1734
544k
    {
1735
544k
      const char *secname = bfd_section_name (section);
1736
1737
544k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
544k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
544k
    : strncmp (alignment_table[i].name, secname,
1740
381k
         alignment_table[i].comparison_length) == 0)
1741
4.91k
  break;
1742
544k
    }
1743
43.1k
  if (i >= table_size)
1744
38.2k
    return;
1745
1746
4.91k
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
4.91k
      && default_alignment < alignment_table[i].default_alignment_min)
1748
3.42k
    return;
1749
1750
1.48k
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
1.48k
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
1.48k
      && default_alignment > alignment_table[i].default_alignment_max
1753
1.48k
#endif
1754
1.48k
      )
1755
0
    return;
1756
1757
1.48k
  section->alignment_power = alignment_table[i].alignment_power;
1758
1.48k
}
pei-x86_64.c:coff_set_custom_section_alignment
Line
Count
Source
1729
27.6k
{
1730
27.6k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
27.6k
  unsigned int i;
1732
1733
325k
  for (i = 0; i < table_size; ++i)
1734
302k
    {
1735
302k
      const char *secname = bfd_section_name (section);
1736
1737
302k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
302k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
302k
    : strncmp (alignment_table[i].name, secname,
1740
204k
         alignment_table[i].comparison_length) == 0)
1741
4.85k
  break;
1742
302k
    }
1743
27.6k
  if (i >= table_size)
1744
22.8k
    return;
1745
1746
4.85k
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
4.85k
      && default_alignment < alignment_table[i].default_alignment_min)
1748
389
    return;
1749
1750
4.46k
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
4.46k
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
4.46k
      && default_alignment > alignment_table[i].default_alignment_max
1753
4.46k
#endif
1754
4.46k
      )
1755
0
    return;
1756
1757
4.46k
  section->alignment_power = alignment_table[i].alignment_power;
1758
4.46k
}
coff-x86_64.c:coff_set_custom_section_alignment
Line
Count
Source
1729
3.19M
{
1730
3.19M
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
3.19M
  unsigned int i;
1732
1733
15.9M
  for (i = 0; i < table_size; ++i)
1734
12.7M
    {
1735
12.7M
      const char *secname = bfd_section_name (section);
1736
1737
12.7M
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
12.7M
    ? strcmp (alignment_table[i].name, secname) == 0
1739
12.7M
    : strncmp (alignment_table[i].name, secname,
1740
6.38M
         alignment_table[i].comparison_length) == 0)
1741
13.7k
  break;
1742
12.7M
    }
1743
3.19M
  if (i >= table_size)
1744
3.17M
    return;
1745
1746
13.7k
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
13.7k
      && default_alignment < alignment_table[i].default_alignment_min)
1748
10.5k
    return;
1749
1750
3.14k
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
3.14k
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
3.14k
      && default_alignment > alignment_table[i].default_alignment_max
1753
3.14k
#endif
1754
3.14k
      )
1755
0
    return;
1756
1757
3.14k
  section->alignment_power = alignment_table[i].alignment_power;
1758
3.14k
}
coff64-rs6000.c:coff_set_custom_section_alignment
Line
Count
Source
1729
871k
{
1730
871k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
871k
  unsigned int i;
1732
1733
4.35M
  for (i = 0; i < table_size; ++i)
1734
3.48M
    {
1735
3.48M
      const char *secname = bfd_section_name (section);
1736
1737
3.48M
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
3.48M
    ? strcmp (alignment_table[i].name, secname) == 0
1739
3.48M
    : strncmp (alignment_table[i].name, secname,
1740
1.74M
         alignment_table[i].comparison_length) == 0)
1741
2.29k
  break;
1742
3.48M
    }
1743
871k
  if (i >= table_size)
1744
869k
    return;
1745
1746
2.29k
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
2.29k
      && default_alignment < alignment_table[i].default_alignment_min)
1748
0
    return;
1749
1750
2.29k
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
2.29k
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
2.29k
      && default_alignment > alignment_table[i].default_alignment_max
1753
2.29k
#endif
1754
2.29k
      )
1755
0
    return;
1756
1757
2.29k
  section->alignment_power = alignment_table[i].alignment_power;
1758
2.29k
}
pe-aarch64.c:coff_set_custom_section_alignment
Line
Count
Source
1729
36.0k
{
1730
36.0k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
36.0k
  unsigned int i;
1732
1733
464k
  for (i = 0; i < table_size; ++i)
1734
429k
    {
1735
429k
      const char *secname = bfd_section_name (section);
1736
1737
429k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
429k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
429k
    : strncmp (alignment_table[i].name, secname,
1740
178k
         alignment_table[i].comparison_length) == 0)
1741
1.06k
  break;
1742
429k
    }
1743
36.0k
  if (i >= table_size)
1744
34.9k
    return;
1745
1746
1.06k
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
1.06k
      && default_alignment < alignment_table[i].default_alignment_min)
1748
448
    return;
1749
1750
615
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
615
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
615
      && default_alignment > alignment_table[i].default_alignment_max
1753
615
#endif
1754
615
      )
1755
0
    return;
1756
1757
615
  section->alignment_power = alignment_table[i].alignment_power;
1758
615
}
pei-aarch64.c:coff_set_custom_section_alignment
Line
Count
Source
1729
12.5k
{
1730
12.5k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
12.5k
  unsigned int i;
1732
1733
148k
  for (i = 0; i < table_size; ++i)
1734
138k
    {
1735
138k
      const char *secname = bfd_section_name (section);
1736
1737
138k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
138k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
138k
    : strncmp (alignment_table[i].name, secname,
1740
56.0k
         alignment_table[i].comparison_length) == 0)
1741
2.09k
  break;
1742
138k
    }
1743
12.5k
  if (i >= table_size)
1744
10.4k
    return;
1745
1746
2.09k
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
2.09k
      && default_alignment < alignment_table[i].default_alignment_min)
1748
286
    return;
1749
1750
1.80k
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
1.80k
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
1.80k
      && default_alignment > alignment_table[i].default_alignment_max
1753
1.80k
#endif
1754
1.80k
      )
1755
0
    return;
1756
1757
1.80k
  section->alignment_power = alignment_table[i].alignment_power;
1758
1.80k
}
pei-ia64.c:coff_set_custom_section_alignment
Line
Count
Source
1729
16.7k
{
1730
16.7k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
16.7k
  unsigned int i;
1732
1733
82.3k
  for (i = 0; i < table_size; ++i)
1734
66.1k
    {
1735
66.1k
      const char *secname = bfd_section_name (section);
1736
1737
66.1k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
66.1k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
66.1k
    : strncmp (alignment_table[i].name, secname,
1740
33.2k
         alignment_table[i].comparison_length) == 0)
1741
505
  break;
1742
66.1k
    }
1743
16.7k
  if (i >= table_size)
1744
16.2k
    return;
1745
1746
505
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
505
      && default_alignment < alignment_table[i].default_alignment_min)
1748
265
    return;
1749
1750
240
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
240
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
240
      && default_alignment > alignment_table[i].default_alignment_max
1753
240
#endif
1754
240
      )
1755
0
    return;
1756
1757
240
  section->alignment_power = alignment_table[i].alignment_power;
1758
240
}
pei-loongarch64.c:coff_set_custom_section_alignment
Line
Count
Source
1729
16.1k
{
1730
16.1k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
16.1k
  unsigned int i;
1732
1733
198k
  for (i = 0; i < table_size; ++i)
1734
184k
    {
1735
184k
      const char *secname = bfd_section_name (section);
1736
1737
184k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
184k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
184k
    : strncmp (alignment_table[i].name, secname,
1740
76.0k
         alignment_table[i].comparison_length) == 0)
1741
1.91k
  break;
1742
184k
    }
1743
16.1k
  if (i >= table_size)
1744
14.2k
    return;
1745
1746
1.91k
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
1.91k
      && default_alignment < alignment_table[i].default_alignment_min)
1748
314
    return;
1749
1750
1.60k
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
1.60k
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
1.60k
      && default_alignment > alignment_table[i].default_alignment_max
1753
1.60k
#endif
1754
1.60k
      )
1755
0
    return;
1756
1757
1.60k
  section->alignment_power = alignment_table[i].alignment_power;
1758
1.60k
}
cf-i386lynx.c:coff_set_custom_section_alignment
Line
Count
Source
1729
400k
{
1730
400k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
400k
  unsigned int i;
1732
1733
1.99M
  for (i = 0; i < table_size; ++i)
1734
1.59M
    {
1735
1.59M
      const char *secname = bfd_section_name (section);
1736
1737
1.59M
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
1.59M
    ? strcmp (alignment_table[i].name, secname) == 0
1739
1.59M
    : strncmp (alignment_table[i].name, secname,
1740
799k
         alignment_table[i].comparison_length) == 0)
1741
1.89k
  break;
1742
1.59M
    }
1743
400k
  if (i >= table_size)
1744
398k
    return;
1745
1746
1.89k
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
1.89k
      && default_alignment < alignment_table[i].default_alignment_min)
1748
955
    return;
1749
1750
942
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
942
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
942
      && default_alignment > alignment_table[i].default_alignment_max
1753
942
#endif
1754
942
      )
1755
0
    return;
1756
1757
942
  section->alignment_power = alignment_table[i].alignment_power;
1758
942
}
coff-go32.c:coff_set_custom_section_alignment
Line
Count
Source
1729
342k
{
1730
342k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
342k
  unsigned int i;
1732
1733
5.45M
  for (i = 0; i < table_size; ++i)
1734
5.11M
    {
1735
5.11M
      const char *secname = bfd_section_name (section);
1736
1737
5.11M
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
5.11M
    ? strcmp (alignment_table[i].name, secname) == 0
1739
5.11M
    : strncmp (alignment_table[i].name, secname,
1740
4.43M
         alignment_table[i].comparison_length) == 0)
1741
3.36k
  break;
1742
5.11M
    }
1743
342k
  if (i >= table_size)
1744
339k
    return;
1745
1746
3.36k
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
3.36k
      && default_alignment < alignment_table[i].default_alignment_min)
1748
704
    return;
1749
1750
2.66k
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
2.66k
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
2.66k
      && default_alignment > alignment_table[i].default_alignment_max
1753
2.66k
#endif
1754
2.66k
      )
1755
0
    return;
1756
1757
2.66k
  section->alignment_power = alignment_table[i].alignment_power;
1758
2.66k
}
coff-i386.c:coff_set_custom_section_alignment
Line
Count
Source
1729
386k
{
1730
386k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
386k
  unsigned int i;
1732
1733
1.92M
  for (i = 0; i < table_size; ++i)
1734
1.54M
    {
1735
1.54M
      const char *secname = bfd_section_name (section);
1736
1737
1.54M
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
1.54M
    ? strcmp (alignment_table[i].name, secname) == 0
1739
1.54M
    : strncmp (alignment_table[i].name, secname,
1740
772k
         alignment_table[i].comparison_length) == 0)
1741
1.52k
  break;
1742
1.54M
    }
1743
386k
  if (i >= table_size)
1744
384k
    return;
1745
1746
1.52k
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
1.52k
      && default_alignment < alignment_table[i].default_alignment_min)
1748
799
    return;
1749
1750
730
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
730
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
730
      && default_alignment > alignment_table[i].default_alignment_max
1753
730
#endif
1754
730
      )
1755
0
    return;
1756
1757
730
  section->alignment_power = alignment_table[i].alignment_power;
1758
730
}
coff-rs6000.c:coff_set_custom_section_alignment
Line
Count
Source
1729
3.72M
{
1730
3.72M
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
3.72M
  unsigned int i;
1732
1733
18.6M
  for (i = 0; i < table_size; ++i)
1734
14.9M
    {
1735
14.9M
      const char *secname = bfd_section_name (section);
1736
1737
14.9M
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
14.9M
    ? strcmp (alignment_table[i].name, secname) == 0
1739
14.9M
    : strncmp (alignment_table[i].name, secname,
1740
7.45M
         alignment_table[i].comparison_length) == 0)
1741
6.92k
  break;
1742
14.9M
    }
1743
3.72M
  if (i >= table_size)
1744
3.72M
    return;
1745
1746
6.92k
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
6.92k
      && default_alignment < alignment_table[i].default_alignment_min)
1748
0
    return;
1749
1750
6.92k
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
6.92k
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
6.92k
      && default_alignment > alignment_table[i].default_alignment_max
1753
6.92k
#endif
1754
6.92k
      )
1755
0
    return;
1756
1757
6.92k
  section->alignment_power = alignment_table[i].alignment_power;
1758
6.92k
}
coff-sh.c:coff_set_custom_section_alignment
Line
Count
Source
1729
2.81M
{
1730
2.81M
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
2.81M
  unsigned int i;
1732
1733
14.0M
  for (i = 0; i < table_size; ++i)
1734
11.2M
    {
1735
11.2M
      const char *secname = bfd_section_name (section);
1736
1737
11.2M
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
11.2M
    ? strcmp (alignment_table[i].name, secname) == 0
1739
11.2M
    : strncmp (alignment_table[i].name, secname,
1740
5.62M
         alignment_table[i].comparison_length) == 0)
1741
7.34k
  break;
1742
11.2M
    }
1743
2.81M
  if (i >= table_size)
1744
2.80M
    return;
1745
1746
7.34k
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
7.34k
      && default_alignment < alignment_table[i].default_alignment_min)
1748
0
    return;
1749
1750
7.34k
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
7.34k
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
7.34k
      && default_alignment > alignment_table[i].default_alignment_max
1753
7.34k
#endif
1754
7.34k
      )
1755
0
    return;
1756
1757
7.34k
  section->alignment_power = alignment_table[i].alignment_power;
1758
7.34k
}
coff-stgo32.c:coff_set_custom_section_alignment
Line
Count
Source
1729
14.4k
{
1730
14.4k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
14.4k
  unsigned int i;
1732
1733
128k
  for (i = 0; i < table_size; ++i)
1734
114k
    {
1735
114k
      const char *secname = bfd_section_name (section);
1736
1737
114k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
114k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
114k
    : strncmp (alignment_table[i].name, secname,
1740
57.3k
         alignment_table[i].comparison_length) == 0)
1741
470
  break;
1742
114k
    }
1743
14.4k
  if (i >= table_size)
1744
14.0k
    return;
1745
1746
470
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
470
      && default_alignment < alignment_table[i].default_alignment_min)
1748
158
    return;
1749
1750
312
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
312
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
312
      && default_alignment > alignment_table[i].default_alignment_max
1753
312
#endif
1754
312
      )
1755
0
    return;
1756
1757
312
  section->alignment_power = alignment_table[i].alignment_power;
1758
312
}
coff-tic30.c:coff_set_custom_section_alignment
Line
Count
Source
1729
1.22M
{
1730
1.22M
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
1.22M
  unsigned int i;
1732
1733
6.12M
  for (i = 0; i < table_size; ++i)
1734
4.90M
    {
1735
4.90M
      const char *secname = bfd_section_name (section);
1736
1737
4.90M
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
4.90M
    ? strcmp (alignment_table[i].name, secname) == 0
1739
4.90M
    : strncmp (alignment_table[i].name, secname,
1740
2.45M
         alignment_table[i].comparison_length) == 0)
1741
3.45k
  break;
1742
4.90M
    }
1743
1.22M
  if (i >= table_size)
1744
1.22M
    return;
1745
1746
3.45k
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
3.45k
      && default_alignment < alignment_table[i].default_alignment_min)
1748
2.18k
    return;
1749
1750
1.27k
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
1.27k
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
1.27k
      && default_alignment > alignment_table[i].default_alignment_max
1753
1.27k
#endif
1754
1.27k
      )
1755
0
    return;
1756
1757
1.27k
  section->alignment_power = alignment_table[i].alignment_power;
1758
1.27k
}
Unexecuted instantiation: coff-tic4x.c:coff_set_custom_section_alignment
coff-tic54x.c:coff_set_custom_section_alignment
Line
Count
Source
1729
2.71M
{
1730
2.71M
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
2.71M
  unsigned int i;
1732
1733
13.5M
  for (i = 0; i < table_size; ++i)
1734
10.8M
    {
1735
10.8M
      const char *secname = bfd_section_name (section);
1736
1737
10.8M
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
10.8M
    ? strcmp (alignment_table[i].name, secname) == 0
1739
10.8M
    : strncmp (alignment_table[i].name, secname,
1740
5.43M
         alignment_table[i].comparison_length) == 0)
1741
4.96k
  break;
1742
10.8M
    }
1743
2.71M
  if (i >= table_size)
1744
2.71M
    return;
1745
1746
4.96k
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
4.96k
      && default_alignment < alignment_table[i].default_alignment_min)
1748
4.96k
    return;
1749
1750
0
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
      && default_alignment > alignment_table[i].default_alignment_max
1753
#endif
1754
0
      )
1755
0
    return;
1756
1757
0
  section->alignment_power = alignment_table[i].alignment_power;
1758
0
}
coff-z80.c:coff_set_custom_section_alignment
Line
Count
Source
1729
142k
{
1730
142k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
142k
  unsigned int i;
1732
1733
712k
  for (i = 0; i < table_size; ++i)
1734
570k
    {
1735
570k
      const char *secname = bfd_section_name (section);
1736
1737
570k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
570k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
570k
    : strncmp (alignment_table[i].name, secname,
1740
285k
         alignment_table[i].comparison_length) == 0)
1741
184
  break;
1742
570k
    }
1743
142k
  if (i >= table_size)
1744
142k
    return;
1745
1746
184
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
184
      && default_alignment < alignment_table[i].default_alignment_min)
1748
184
    return;
1749
1750
0
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
      && default_alignment > alignment_table[i].default_alignment_max
1753
#endif
1754
0
      )
1755
0
    return;
1756
1757
0
  section->alignment_power = alignment_table[i].alignment_power;
1758
0
}
coff-z8k.c:coff_set_custom_section_alignment
Line
Count
Source
1729
365k
{
1730
365k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
365k
  unsigned int i;
1732
1733
1.81M
  for (i = 0; i < table_size; ++i)
1734
1.45M
    {
1735
1.45M
      const char *secname = bfd_section_name (section);
1736
1737
1.45M
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
1.45M
    ? strcmp (alignment_table[i].name, secname) == 0
1739
1.45M
    : strncmp (alignment_table[i].name, secname,
1740
730k
         alignment_table[i].comparison_length) == 0)
1741
5.12k
  break;
1742
1.45M
    }
1743
365k
  if (i >= table_size)
1744
360k
    return;
1745
1746
5.12k
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
5.12k
      && default_alignment < alignment_table[i].default_alignment_min)
1748
3.55k
    return;
1749
1750
1.57k
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
1.57k
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
1.57k
      && default_alignment > alignment_table[i].default_alignment_max
1753
1.57k
#endif
1754
1.57k
      )
1755
0
    return;
1756
1757
1.57k
  section->alignment_power = alignment_table[i].alignment_power;
1758
1.57k
}
pe-arm-wince.c:coff_set_custom_section_alignment
Line
Count
Source
1729
11.0k
{
1730
11.0k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
11.0k
  unsigned int i;
1732
1733
150k
  for (i = 0; i < table_size; ++i)
1734
140k
    {
1735
140k
      const char *secname = bfd_section_name (section);
1736
1737
140k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
140k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
140k
    : strncmp (alignment_table[i].name, secname,
1740
65.6k
         alignment_table[i].comparison_length) == 0)
1741
1.13k
  break;
1742
140k
    }
1743
11.0k
  if (i >= table_size)
1744
9.87k
    return;
1745
1746
1.13k
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
1.13k
      && default_alignment < alignment_table[i].default_alignment_min)
1748
921
    return;
1749
1750
218
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
218
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
218
      && default_alignment > alignment_table[i].default_alignment_max
1753
218
#endif
1754
218
      )
1755
0
    return;
1756
1757
218
  section->alignment_power = alignment_table[i].alignment_power;
1758
218
}
pe-arm.c:coff_set_custom_section_alignment
Line
Count
Source
1729
11.0k
{
1730
11.0k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
11.0k
  unsigned int i;
1732
1733
150k
  for (i = 0; i < table_size; ++i)
1734
140k
    {
1735
140k
      const char *secname = bfd_section_name (section);
1736
1737
140k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
140k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
140k
    : strncmp (alignment_table[i].name, secname,
1740
65.6k
         alignment_table[i].comparison_length) == 0)
1741
1.13k
  break;
1742
140k
    }
1743
11.0k
  if (i >= table_size)
1744
9.87k
    return;
1745
1746
1.13k
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
1.13k
      && default_alignment < alignment_table[i].default_alignment_min)
1748
921
    return;
1749
1750
218
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
218
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
218
      && default_alignment > alignment_table[i].default_alignment_max
1753
218
#endif
1754
218
      )
1755
0
    return;
1756
1757
218
  section->alignment_power = alignment_table[i].alignment_power;
1758
218
}
pe-i386.c:coff_set_custom_section_alignment
Line
Count
Source
1729
16.7k
{
1730
16.7k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
16.7k
  unsigned int i;
1732
1733
160k
  for (i = 0; i < table_size; ++i)
1734
145k
    {
1735
145k
      const char *secname = bfd_section_name (section);
1736
1737
145k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
145k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
145k
    : strncmp (alignment_table[i].name, secname,
1740
98.2k
         alignment_table[i].comparison_length) == 0)
1741
1.49k
  break;
1742
145k
    }
1743
16.7k
  if (i >= table_size)
1744
15.2k
    return;
1745
1746
1.49k
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
1.49k
      && default_alignment < alignment_table[i].default_alignment_min)
1748
448
    return;
1749
1750
1.04k
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
1.04k
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
1.04k
      && default_alignment > alignment_table[i].default_alignment_max
1753
1.04k
#endif
1754
1.04k
      )
1755
0
    return;
1756
1757
1.04k
  section->alignment_power = alignment_table[i].alignment_power;
1758
1.04k
}
pe-mcore.c:coff_set_custom_section_alignment
Line
Count
Source
1729
11.8k
{
1730
11.8k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
11.8k
  unsigned int i;
1732
1733
56.5k
  for (i = 0; i < table_size; ++i)
1734
45.5k
    {
1735
45.5k
      const char *secname = bfd_section_name (section);
1736
1737
45.5k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
45.5k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
45.5k
    : strncmp (alignment_table[i].name, secname,
1740
23.4k
         alignment_table[i].comparison_length) == 0)
1741
844
  break;
1742
45.5k
    }
1743
11.8k
  if (i >= table_size)
1744
11.0k
    return;
1745
1746
844
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
844
      && default_alignment < alignment_table[i].default_alignment_min)
1748
455
    return;
1749
1750
389
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
389
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
389
      && default_alignment > alignment_table[i].default_alignment_max
1753
389
#endif
1754
389
      )
1755
0
    return;
1756
1757
389
  section->alignment_power = alignment_table[i].alignment_power;
1758
389
}
pe-sh.c:coff_set_custom_section_alignment
Line
Count
Source
1729
20.7k
{
1730
20.7k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
20.7k
  unsigned int i;
1732
1733
101k
  for (i = 0; i < table_size; ++i)
1734
81.4k
    {
1735
81.4k
      const char *secname = bfd_section_name (section);
1736
1737
81.4k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
81.4k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
81.4k
    : strncmp (alignment_table[i].name, secname,
1740
41.1k
         alignment_table[i].comparison_length) == 0)
1741
515
  break;
1742
81.4k
    }
1743
20.7k
  if (i >= table_size)
1744
20.1k
    return;
1745
1746
515
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
515
      && default_alignment < alignment_table[i].default_alignment_min)
1748
206
    return;
1749
1750
309
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
309
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
309
      && default_alignment > alignment_table[i].default_alignment_max
1753
309
#endif
1754
309
      )
1755
0
    return;
1756
1757
309
  section->alignment_power = alignment_table[i].alignment_power;
1758
309
}
pei-arm-wince.c:coff_set_custom_section_alignment
Line
Count
Source
1729
23.2k
{
1730
23.2k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
23.2k
  unsigned int i;
1732
1733
292k
  for (i = 0; i < table_size; ++i)
1734
271k
    {
1735
271k
      const char *secname = bfd_section_name (section);
1736
1737
271k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
271k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
271k
    : strncmp (alignment_table[i].name, secname,
1740
113k
         alignment_table[i].comparison_length) == 0)
1741
2.25k
  break;
1742
271k
    }
1743
23.2k
  if (i >= table_size)
1744
21.0k
    return;
1745
1746
2.25k
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
2.25k
      && default_alignment < alignment_table[i].default_alignment_min)
1748
1.11k
    return;
1749
1750
1.14k
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
1.14k
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
1.14k
      && default_alignment > alignment_table[i].default_alignment_max
1753
1.14k
#endif
1754
1.14k
      )
1755
0
    return;
1756
1757
1.14k
  section->alignment_power = alignment_table[i].alignment_power;
1758
1.14k
}
pei-arm.c:coff_set_custom_section_alignment
Line
Count
Source
1729
31.2k
{
1730
31.2k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
31.2k
  unsigned int i;
1732
1733
374k
  for (i = 0; i < table_size; ++i)
1734
347k
    {
1735
347k
      const char *secname = bfd_section_name (section);
1736
1737
347k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
347k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
347k
    : strncmp (alignment_table[i].name, secname,
1740
141k
         alignment_table[i].comparison_length) == 0)
1741
4.94k
  break;
1742
347k
    }
1743
31.2k
  if (i >= table_size)
1744
26.2k
    return;
1745
1746
4.94k
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
4.94k
      && default_alignment < alignment_table[i].default_alignment_min)
1748
1.11k
    return;
1749
1750
3.83k
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
3.83k
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
3.83k
      && default_alignment > alignment_table[i].default_alignment_max
1753
3.83k
#endif
1754
3.83k
      )
1755
0
    return;
1756
1757
3.83k
  section->alignment_power = alignment_table[i].alignment_power;
1758
3.83k
}
pei-mcore.c:coff_set_custom_section_alignment
Line
Count
Source
1729
26.2k
{
1730
26.2k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
26.2k
  unsigned int i;
1732
1733
129k
  for (i = 0; i < table_size; ++i)
1734
104k
    {
1735
104k
      const char *secname = bfd_section_name (section);
1736
1737
104k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
104k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
104k
    : strncmp (alignment_table[i].name, secname,
1740
52.2k
         alignment_table[i].comparison_length) == 0)
1741
526
  break;
1742
104k
    }
1743
26.2k
  if (i >= table_size)
1744
25.6k
    return;
1745
1746
526
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
526
      && default_alignment < alignment_table[i].default_alignment_min)
1748
393
    return;
1749
1750
133
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
133
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
133
      && default_alignment > alignment_table[i].default_alignment_max
1753
133
#endif
1754
133
      )
1755
0
    return;
1756
1757
133
  section->alignment_power = alignment_table[i].alignment_power;
1758
133
}
pei-sh.c:coff_set_custom_section_alignment
Line
Count
Source
1729
32.0k
{
1730
32.0k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
32.0k
  unsigned int i;
1732
1733
157k
  for (i = 0; i < table_size; ++i)
1734
126k
    {
1735
126k
      const char *secname = bfd_section_name (section);
1736
1737
126k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
126k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
126k
    : strncmp (alignment_table[i].name, secname,
1740
63.7k
         alignment_table[i].comparison_length) == 0)
1741
746
  break;
1742
126k
    }
1743
32.0k
  if (i >= table_size)
1744
31.2k
    return;
1745
1746
746
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
746
      && default_alignment < alignment_table[i].default_alignment_min)
1748
429
    return;
1749
1750
317
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
317
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
317
      && default_alignment > alignment_table[i].default_alignment_max
1753
317
#endif
1754
317
      )
1755
0
    return;
1756
1757
317
  section->alignment_power = alignment_table[i].alignment_power;
1758
317
}
1759
1760
/* Custom section alignment records.  */
1761
1762
static const struct coff_section_alignment_entry
1763
coff_section_alignment_table[] =
1764
{
1765
#ifdef COFF_SECTION_ALIGNMENT_ENTRIES
1766
  COFF_SECTION_ALIGNMENT_ENTRIES,
1767
#endif
1768
  /* There must not be any gaps between .stabstr sections.  */
1769
  { COFF_SECTION_NAME_PARTIAL_MATCH (".stabstr"),
1770
    1, COFF_ALIGNMENT_FIELD_EMPTY, 0 },
1771
  /* The .stab section must be aligned to 2**2 at most, to avoid gaps.  */
1772
  { COFF_SECTION_NAME_PARTIAL_MATCH (".stab"),
1773
    3, COFF_ALIGNMENT_FIELD_EMPTY, 2 },
1774
  /* Similarly for the .ctors and .dtors sections.  */
1775
  { COFF_SECTION_NAME_EXACT_MATCH (".ctors"),
1776
    3, COFF_ALIGNMENT_FIELD_EMPTY, 2 },
1777
  { COFF_SECTION_NAME_EXACT_MATCH (".dtors"),
1778
    3, COFF_ALIGNMENT_FIELD_EMPTY, 2 }
1779
};
1780
1781
static const unsigned int coff_section_alignment_table_size =
1782
  sizeof coff_section_alignment_table / sizeof coff_section_alignment_table[0];
1783
1784
/* Initialize a section structure with information peculiar to this
1785
   particular implementation of COFF.  */
1786
1787
static bool
1788
coff_new_section_hook (bfd * abfd, asection * section)
1789
16.6M
{
1790
16.6M
  combined_entry_type *native;
1791
16.6M
  size_t amt;
1792
16.6M
  unsigned char sclass = C_STAT;
1793
1794
16.6M
  section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1795
1796
#ifdef RS6000COFF_C
1797
4.60M
  if (bfd_xcoff_text_align_power (abfd) != 0
1798
4.60M
      && strcmp (bfd_section_name (section), ".text") == 0)
1799
3.64k
    section->alignment_power = bfd_xcoff_text_align_power (abfd);
1800
4.59M
  else if (bfd_xcoff_data_align_power (abfd) != 0
1801
4.59M
      && strcmp (bfd_section_name (section), ".data") == 0)
1802
3.12k
    section->alignment_power = bfd_xcoff_data_align_power (abfd);
1803
4.59M
  else
1804
4.59M
    {
1805
4.59M
      int i;
1806
1807
55.1M
      for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++)
1808
50.5M
  if (strcmp (bfd_section_name (section),
1809
50.5M
        xcoff_dwsect_names[i].xcoff_name) == 0)
1810
3.28k
    {
1811
3.28k
      section->alignment_power = 0;
1812
3.28k
      sclass = C_DWARF;
1813
3.28k
      break;
1814
3.28k
    }
1815
4.59M
    }
1816
#endif
1817
1818
  /* Set up the section symbol.  */
1819
16.6M
  if (!_bfd_generic_new_section_hook (abfd, section))
1820
0
    return false;
1821
1822
  /* Allocate aux records for section symbols, to store size and
1823
     related info.
1824
1825
     @@ The 10 is a guess at a plausible maximum number of aux entries
1826
     (but shouldn't be a constant).  */
1827
16.6M
  amt = sizeof (combined_entry_type) * 10;
1828
16.6M
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
16.6M
  if (native == NULL)
1830
0
    return false;
1831
1832
  /* We don't need to set up n_name, n_value, or n_scnum in the native
1833
     symbol information, since they'll be overridden by the BFD symbol
1834
     anyhow.  However, we do need to set the type and storage class,
1835
     in case this symbol winds up getting written out.  The value 0
1836
     for n_numaux is already correct.  */
1837
1838
16.6M
  native->is_sym = true;
1839
16.6M
  native->u.syment.n_type = T_NULL;
1840
16.6M
  native->u.syment.n_sclass = sclass;
1841
1842
16.6M
  coffsymbol (section->symbol)->native = native;
1843
1844
16.6M
  coff_set_custom_section_alignment (abfd, section,
1845
16.6M
             coff_section_alignment_table,
1846
16.6M
             coff_section_alignment_table_size);
1847
1848
16.6M
  return true;
1849
16.6M
}
pei-i386.c:coff_new_section_hook
Line
Count
Source
1789
122k
{
1790
122k
  combined_entry_type *native;
1791
122k
  size_t amt;
1792
122k
  unsigned char sclass = C_STAT;
1793
1794
122k
  section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1795
1796
#ifdef RS6000COFF_C
1797
  if (bfd_xcoff_text_align_power (abfd) != 0
1798
      && strcmp (bfd_section_name (section), ".text") == 0)
1799
    section->alignment_power = bfd_xcoff_text_align_power (abfd);
1800
  else if (bfd_xcoff_data_align_power (abfd) != 0
1801
      && strcmp (bfd_section_name (section), ".data") == 0)
1802
    section->alignment_power = bfd_xcoff_data_align_power (abfd);
1803
  else
1804
    {
1805
      int i;
1806
1807
      for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++)
1808
  if (strcmp (bfd_section_name (section),
1809
        xcoff_dwsect_names[i].xcoff_name) == 0)
1810
    {
1811
      section->alignment_power = 0;
1812
      sclass = C_DWARF;
1813
      break;
1814
    }
1815
    }
1816
#endif
1817
1818
  /* Set up the section symbol.  */
1819
122k
  if (!_bfd_generic_new_section_hook (abfd, section))
1820
0
    return false;
1821
1822
  /* Allocate aux records for section symbols, to store size and
1823
     related info.
1824
1825
     @@ The 10 is a guess at a plausible maximum number of aux entries
1826
     (but shouldn't be a constant).  */
1827
122k
  amt = sizeof (combined_entry_type) * 10;
1828
122k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
122k
  if (native == NULL)
1830
0
    return false;
1831
1832
  /* We don't need to set up n_name, n_value, or n_scnum in the native
1833
     symbol information, since they'll be overridden by the BFD symbol
1834
     anyhow.  However, we do need to set the type and storage class,
1835
     in case this symbol winds up getting written out.  The value 0
1836
     for n_numaux is already correct.  */
1837
1838
122k
  native->is_sym = true;
1839
122k
  native->u.syment.n_type = T_NULL;
1840
122k
  native->u.syment.n_sclass = sclass;
1841
1842
122k
  coffsymbol (section->symbol)->native = native;
1843
1844
122k
  coff_set_custom_section_alignment (abfd, section,
1845
122k
             coff_section_alignment_table,
1846
122k
             coff_section_alignment_table_size);
1847
1848
122k
  return true;
1849
122k
}
pe-x86_64.c:coff_new_section_hook
Line
Count
Source
1789
43.1k
{
1790
43.1k
  combined_entry_type *native;
1791
43.1k
  size_t amt;
1792
43.1k
  unsigned char sclass = C_STAT;
1793
1794
43.1k
  section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1795
1796
#ifdef RS6000COFF_C
1797
  if (bfd_xcoff_text_align_power (abfd) != 0
1798
      && strcmp (bfd_section_name (section), ".text") == 0)
1799
    section->alignment_power = bfd_xcoff_text_align_power (abfd);
1800
  else if (bfd_xcoff_data_align_power (abfd) != 0
1801
      && strcmp (bfd_section_name (section), ".data") == 0)
1802
    section->alignment_power = bfd_xcoff_data_align_power (abfd);
1803
  else
1804
    {
1805
      int i;
1806
1807
      for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++)
1808
  if (strcmp (bfd_section_name (section),
1809
        xcoff_dwsect_names[i].xcoff_name) == 0)
1810
    {
1811
      section->alignment_power = 0;
1812
      sclass = C_DWARF;
1813
      break;
1814
    }
1815
    }
1816
#endif
1817
1818
  /* Set up the section symbol.  */
1819
43.1k
  if (!_bfd_generic_new_section_hook (abfd, section))
1820
0
    return false;
1821
1822
  /* Allocate aux records for section symbols, to store size and
1823
     related info.
1824
1825
     @@ The 10 is a guess at a plausible maximum number of aux entries
1826
     (but shouldn't be a constant).  */
1827
43.1k
  amt = sizeof (combined_entry_type) * 10;
1828
43.1k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
43.1k
  if (native == NULL)
1830
0
    return false;
1831
1832
  /* We don't need to set up n_name, n_value, or n_scnum in the native
1833
     symbol information, since they'll be overridden by the BFD symbol
1834
     anyhow.  However, we do need to set the type and storage class,
1835
     in case this symbol winds up getting written out.  The value 0
1836
     for n_numaux is already correct.  */
1837
1838
43.1k
  native->is_sym = true;
1839
43.1k
  native->u.syment.n_type = T_NULL;
1840
43.1k
  native->u.syment.n_sclass = sclass;
1841
1842
43.1k
  coffsymbol (section->symbol)->native = native;
1843
1844
43.1k
  coff_set_custom_section_alignment (abfd, section,
1845
43.1k
             coff_section_alignment_table,
1846
43.1k
             coff_section_alignment_table_size);
1847
1848
43.1k
  return true;
1849
43.1k
}
pei-x86_64.c:coff_new_section_hook
Line
Count
Source
1789
27.6k
{
1790
27.6k
  combined_entry_type *native;
1791
27.6k
  size_t amt;
1792
27.6k
  unsigned char sclass = C_STAT;
1793
1794
27.6k
  section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1795
1796
#ifdef RS6000COFF_C
1797
  if (bfd_xcoff_text_align_power (abfd) != 0
1798
      && strcmp (bfd_section_name (section), ".text") == 0)
1799
    section->alignment_power = bfd_xcoff_text_align_power (abfd);
1800
  else if (bfd_xcoff_data_align_power (abfd) != 0
1801
      && strcmp (bfd_section_name (section), ".data") == 0)
1802
    section->alignment_power = bfd_xcoff_data_align_power (abfd);
1803
  else
1804
    {
1805
      int i;
1806
1807
      for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++)
1808
  if (strcmp (bfd_section_name (section),
1809
        xcoff_dwsect_names[i].xcoff_name) == 0)
1810
    {
1811
      section->alignment_power = 0;
1812
      sclass = C_DWARF;
1813
      break;
1814
    }
1815
    }
1816
#endif
1817
1818
  /* Set up the section symbol.  */
1819
27.6k
  if (!_bfd_generic_new_section_hook (abfd, section))
1820
0
    return false;
1821
1822
  /* Allocate aux records for section symbols, to store size and
1823
     related info.
1824
1825
     @@ The 10 is a guess at a plausible maximum number of aux entries
1826
     (but shouldn't be a constant).  */
1827
27.6k
  amt = sizeof (combined_entry_type) * 10;
1828
27.6k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
27.6k
  if (native == NULL)
1830
0
    return false;
1831
1832
  /* We don't need to set up n_name, n_value, or n_scnum in the native
1833
     symbol information, since they'll be overridden by the BFD symbol
1834
     anyhow.  However, we do need to set the type and storage class,
1835
     in case this symbol winds up getting written out.  The value 0
1836
     for n_numaux is already correct.  */
1837
1838
27.6k
  native->is_sym = true;
1839
27.6k
  native->u.syment.n_type = T_NULL;
1840
27.6k
  native->u.syment.n_sclass = sclass;
1841
1842
27.6k
  coffsymbol (section->symbol)->native = native;
1843
1844
27.6k
  coff_set_custom_section_alignment (abfd, section,
1845
27.6k
             coff_section_alignment_table,
1846
27.6k
             coff_section_alignment_table_size);
1847
1848
27.6k
  return true;
1849
27.6k
}
coff-x86_64.c:coff_new_section_hook
Line
Count
Source
1789
3.19M
{
1790
3.19M
  combined_entry_type *native;
1791
3.19M
  size_t amt;
1792
3.19M
  unsigned char sclass = C_STAT;
1793
1794
3.19M
  section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1795
1796
#ifdef RS6000COFF_C
1797
  if (bfd_xcoff_text_align_power (abfd) != 0
1798
      && strcmp (bfd_section_name (section), ".text") == 0)
1799
    section->alignment_power = bfd_xcoff_text_align_power (abfd);
1800
  else if (bfd_xcoff_data_align_power (abfd) != 0
1801
      && strcmp (bfd_section_name (section), ".data") == 0)
1802
    section->alignment_power = bfd_xcoff_data_align_power (abfd);
1803
  else
1804
    {
1805
      int i;
1806
1807
      for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++)
1808
  if (strcmp (bfd_section_name (section),
1809
        xcoff_dwsect_names[i].xcoff_name) == 0)
1810
    {
1811
      section->alignment_power = 0;
1812
      sclass = C_DWARF;
1813
      break;
1814
    }
1815
    }
1816
#endif
1817
1818
  /* Set up the section symbol.  */
1819
3.19M
  if (!_bfd_generic_new_section_hook (abfd, section))
1820
0
    return false;
1821
1822
  /* Allocate aux records for section symbols, to store size and
1823
     related info.
1824
1825
     @@ The 10 is a guess at a plausible maximum number of aux entries
1826
     (but shouldn't be a constant).  */
1827
3.19M
  amt = sizeof (combined_entry_type) * 10;
1828
3.19M
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
3.19M
  if (native == NULL)
1830
0
    return false;
1831
1832
  /* We don't need to set up n_name, n_value, or n_scnum in the native
1833
     symbol information, since they'll be overridden by the BFD symbol
1834
     anyhow.  However, we do need to set the type and storage class,
1835
     in case this symbol winds up getting written out.  The value 0
1836
     for n_numaux is already correct.  */
1837
1838
3.19M
  native->is_sym = true;
1839
3.19M
  native->u.syment.n_type = T_NULL;
1840
3.19M
  native->u.syment.n_sclass = sclass;
1841
1842
3.19M
  coffsymbol (section->symbol)->native = native;
1843
1844
3.19M
  coff_set_custom_section_alignment (abfd, section,
1845
3.19M
             coff_section_alignment_table,
1846
3.19M
             coff_section_alignment_table_size);
1847
1848
3.19M
  return true;
1849
3.19M
}
coff64-rs6000.c:coff_new_section_hook
Line
Count
Source
1789
871k
{
1790
871k
  combined_entry_type *native;
1791
871k
  size_t amt;
1792
871k
  unsigned char sclass = C_STAT;
1793
1794
871k
  section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1795
1796
871k
#ifdef RS6000COFF_C
1797
871k
  if (bfd_xcoff_text_align_power (abfd) != 0
1798
871k
      && strcmp (bfd_section_name (section), ".text") == 0)
1799
1.22k
    section->alignment_power = bfd_xcoff_text_align_power (abfd);
1800
870k
  else if (bfd_xcoff_data_align_power (abfd) != 0
1801
870k
      && strcmp (bfd_section_name (section), ".data") == 0)
1802
708
    section->alignment_power = bfd_xcoff_data_align_power (abfd);
1803
869k
  else
1804
869k
    {
1805
869k
      int i;
1806
1807
10.4M
      for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++)
1808
9.56M
  if (strcmp (bfd_section_name (section),
1809
9.56M
        xcoff_dwsect_names[i].xcoff_name) == 0)
1810
923
    {
1811
923
      section->alignment_power = 0;
1812
923
      sclass = C_DWARF;
1813
923
      break;
1814
923
    }
1815
869k
    }
1816
871k
#endif
1817
1818
  /* Set up the section symbol.  */
1819
871k
  if (!_bfd_generic_new_section_hook (abfd, section))
1820
0
    return false;
1821
1822
  /* Allocate aux records for section symbols, to store size and
1823
     related info.
1824
1825
     @@ The 10 is a guess at a plausible maximum number of aux entries
1826
     (but shouldn't be a constant).  */
1827
871k
  amt = sizeof (combined_entry_type) * 10;
1828
871k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
871k
  if (native == NULL)
1830
0
    return false;
1831
1832
  /* We don't need to set up n_name, n_value, or n_scnum in the native
1833
     symbol information, since they'll be overridden by the BFD symbol
1834
     anyhow.  However, we do need to set the type and storage class,
1835
     in case this symbol winds up getting written out.  The value 0
1836
     for n_numaux is already correct.  */
1837
1838
871k
  native->is_sym = true;
1839
871k
  native->u.syment.n_type = T_NULL;
1840
871k
  native->u.syment.n_sclass = sclass;
1841
1842
871k
  coffsymbol (section->symbol)->native = native;
1843
1844
871k
  coff_set_custom_section_alignment (abfd, section,
1845
871k
             coff_section_alignment_table,
1846
871k
             coff_section_alignment_table_size);
1847
1848
871k
  return true;
1849
871k
}
pe-aarch64.c:coff_new_section_hook
Line
Count
Source
1789
36.0k
{
1790
36.0k
  combined_entry_type *native;
1791
36.0k
  size_t amt;
1792
36.0k
  unsigned char sclass = C_STAT;
1793
1794
36.0k
  section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1795
1796
#ifdef RS6000COFF_C
1797
  if (bfd_xcoff_text_align_power (abfd) != 0
1798
      && strcmp (bfd_section_name (section), ".text") == 0)
1799
    section->alignment_power = bfd_xcoff_text_align_power (abfd);
1800
  else if (bfd_xcoff_data_align_power (abfd) != 0
1801
      && strcmp (bfd_section_name (section), ".data") == 0)
1802
    section->alignment_power = bfd_xcoff_data_align_power (abfd);
1803
  else
1804
    {
1805
      int i;
1806
1807
      for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++)
1808
  if (strcmp (bfd_section_name (section),
1809
        xcoff_dwsect_names[i].xcoff_name) == 0)
1810
    {
1811
      section->alignment_power = 0;
1812
      sclass = C_DWARF;
1813
      break;
1814
    }
1815
    }
1816
#endif
1817
1818
  /* Set up the section symbol.  */
1819
36.0k
  if (!_bfd_generic_new_section_hook (abfd, section))
1820
0
    return false;
1821
1822
  /* Allocate aux records for section symbols, to store size and
1823
     related info.
1824
1825
     @@ The 10 is a guess at a plausible maximum number of aux entries
1826
     (but shouldn't be a constant).  */
1827
36.0k
  amt = sizeof (combined_entry_type) * 10;
1828
36.0k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
36.0k
  if (native == NULL)
1830
0
    return false;
1831
1832
  /* We don't need to set up n_name, n_value, or n_scnum in the native
1833
     symbol information, since they'll be overridden by the BFD symbol
1834
     anyhow.  However, we do need to set the type and storage class,
1835
     in case this symbol winds up getting written out.  The value 0
1836
     for n_numaux is already correct.  */
1837
1838
36.0k
  native->is_sym = true;
1839
36.0k
  native->u.syment.n_type = T_NULL;
1840
36.0k
  native->u.syment.n_sclass = sclass;
1841
1842
36.0k
  coffsymbol (section->symbol)->native = native;
1843
1844
36.0k
  coff_set_custom_section_alignment (abfd, section,
1845
36.0k
             coff_section_alignment_table,
1846
36.0k
             coff_section_alignment_table_size);
1847
1848
36.0k
  return true;
1849
36.0k
}
pei-aarch64.c:coff_new_section_hook
Line
Count
Source
1789
12.5k
{
1790
12.5k
  combined_entry_type *native;
1791
12.5k
  size_t amt;
1792
12.5k
  unsigned char sclass = C_STAT;
1793
1794
12.5k
  section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1795
1796
#ifdef RS6000COFF_C
1797
  if (bfd_xcoff_text_align_power (abfd) != 0
1798
      && strcmp (bfd_section_name (section), ".text") == 0)
1799
    section->alignment_power = bfd_xcoff_text_align_power (abfd);
1800
  else if (bfd_xcoff_data_align_power (abfd) != 0
1801
      && strcmp (bfd_section_name (section), ".data") == 0)
1802
    section->alignment_power = bfd_xcoff_data_align_power (abfd);
1803
  else
1804
    {
1805
      int i;
1806
1807
      for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++)
1808
  if (strcmp (bfd_section_name (section),
1809
        xcoff_dwsect_names[i].xcoff_name) == 0)
1810
    {
1811
      section->alignment_power = 0;
1812
      sclass = C_DWARF;
1813
      break;
1814
    }
1815
    }
1816
#endif
1817
1818
  /* Set up the section symbol.  */
1819
12.5k
  if (!_bfd_generic_new_section_hook (abfd, section))
1820
0
    return false;
1821
1822
  /* Allocate aux records for section symbols, to store size and
1823
     related info.
1824
1825
     @@ The 10 is a guess at a plausible maximum number of aux entries
1826
     (but shouldn't be a constant).  */
1827
12.5k
  amt = sizeof (combined_entry_type) * 10;
1828
12.5k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
12.5k
  if (native == NULL)
1830
0
    return false;
1831
1832
  /* We don't need to set up n_name, n_value, or n_scnum in the native
1833
     symbol information, since they'll be overridden by the BFD symbol
1834
     anyhow.  However, we do need to set the type and storage class,
1835
     in case this symbol winds up getting written out.  The value 0
1836
     for n_numaux is already correct.  */
1837
1838
12.5k
  native->is_sym = true;
1839
12.5k
  native->u.syment.n_type = T_NULL;
1840
12.5k
  native->u.syment.n_sclass = sclass;
1841
1842
12.5k
  coffsymbol (section->symbol)->native = native;
1843
1844
12.5k
  coff_set_custom_section_alignment (abfd, section,
1845
12.5k
             coff_section_alignment_table,
1846
12.5k
             coff_section_alignment_table_size);
1847
1848
12.5k
  return true;
1849
12.5k
}
pei-ia64.c:coff_new_section_hook
Line
Count
Source
1789
16.7k
{
1790
16.7k
  combined_entry_type *native;
1791
16.7k
  size_t amt;
1792
16.7k
  unsigned char sclass = C_STAT;
1793
1794
16.7k
  section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1795
1796
#ifdef RS6000COFF_C
1797
  if (bfd_xcoff_text_align_power (abfd) != 0
1798
      && strcmp (bfd_section_name (section), ".text") == 0)
1799
    section->alignment_power = bfd_xcoff_text_align_power (abfd);
1800
  else if (bfd_xcoff_data_align_power (abfd) != 0
1801
      && strcmp (bfd_section_name (section), ".data") == 0)
1802
    section->alignment_power = bfd_xcoff_data_align_power (abfd);
1803
  else
1804
    {
1805
      int i;
1806
1807
      for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++)
1808
  if (strcmp (bfd_section_name (section),
1809
        xcoff_dwsect_names[i].xcoff_name) == 0)
1810
    {
1811
      section->alignment_power = 0;
1812
      sclass = C_DWARF;
1813
      break;
1814
    }
1815
    }
1816
#endif
1817
1818
  /* Set up the section symbol.  */
1819
16.7k
  if (!_bfd_generic_new_section_hook (abfd, section))
1820
0
    return false;
1821
1822
  /* Allocate aux records for section symbols, to store size and
1823
     related info.
1824
1825
     @@ The 10 is a guess at a plausible maximum number of aux entries
1826
     (but shouldn't be a constant).  */
1827
16.7k
  amt = sizeof (combined_entry_type) * 10;
1828
16.7k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
16.7k
  if (native == NULL)
1830
0
    return false;
1831
1832
  /* We don't need to set up n_name, n_value, or n_scnum in the native
1833
     symbol information, since they'll be overridden by the BFD symbol
1834
     anyhow.  However, we do need to set the type and storage class,
1835
     in case this symbol winds up getting written out.  The value 0
1836
     for n_numaux is already correct.  */
1837
1838
16.7k
  native->is_sym = true;
1839
16.7k
  native->u.syment.n_type = T_NULL;
1840
16.7k
  native->u.syment.n_sclass = sclass;
1841
1842
16.7k
  coffsymbol (section->symbol)->native = native;
1843
1844
16.7k
  coff_set_custom_section_alignment (abfd, section,
1845
16.7k
             coff_section_alignment_table,
1846
16.7k
             coff_section_alignment_table_size);
1847
1848
16.7k
  return true;
1849
16.7k
}
pei-loongarch64.c:coff_new_section_hook
Line
Count
Source
1789
16.1k
{
1790
16.1k
  combined_entry_type *native;
1791
16.1k
  size_t amt;
1792
16.1k
  unsigned char sclass = C_STAT;
1793
1794
16.1k
  section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1795
1796
#ifdef RS6000COFF_C
1797
  if (bfd_xcoff_text_align_power (abfd) != 0
1798
      && strcmp (bfd_section_name (section), ".text") == 0)
1799
    section->alignment_power = bfd_xcoff_text_align_power (abfd);
1800
  else if (bfd_xcoff_data_align_power (abfd) != 0
1801
      && strcmp (bfd_section_name (section), ".data") == 0)
1802
    section->alignment_power = bfd_xcoff_data_align_power (abfd);
1803
  else
1804
    {
1805
      int i;
1806
1807
      for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++)
1808
  if (strcmp (bfd_section_name (section),
1809
        xcoff_dwsect_names[i].xcoff_name) == 0)
1810
    {
1811
      section->alignment_power = 0;
1812
      sclass = C_DWARF;
1813
      break;
1814
    }
1815
    }
1816
#endif
1817
1818
  /* Set up the section symbol.  */
1819
16.1k
  if (!_bfd_generic_new_section_hook (abfd, section))
1820
0
    return false;
1821
1822
  /* Allocate aux records for section symbols, to store size and
1823
     related info.
1824
1825
     @@ The 10 is a guess at a plausible maximum number of aux entries
1826
     (but shouldn't be a constant).  */
1827
16.1k
  amt = sizeof (combined_entry_type) * 10;
1828
16.1k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
16.1k
  if (native == NULL)
1830
0
    return false;
1831
1832
  /* We don't need to set up n_name, n_value, or n_scnum in the native
1833
     symbol information, since they'll be overridden by the BFD symbol
1834
     anyhow.  However, we do need to set the type and storage class,
1835
     in case this symbol winds up getting written out.  The value 0
1836
     for n_numaux is already correct.  */
1837
1838
16.1k
  native->is_sym = true;
1839
16.1k
  native->u.syment.n_type = T_NULL;
1840
16.1k
  native->u.syment.n_sclass = sclass;
1841
1842
16.1k
  coffsymbol (section->symbol)->native = native;
1843
1844
16.1k
  coff_set_custom_section_alignment (abfd, section,
1845
16.1k
             coff_section_alignment_table,
1846
16.1k
             coff_section_alignment_table_size);
1847
1848
16.1k
  return true;
1849
16.1k
}
cf-i386lynx.c:coff_new_section_hook
Line
Count
Source
1789
400k
{
1790
400k
  combined_entry_type *native;
1791
400k
  size_t amt;
1792
400k
  unsigned char sclass = C_STAT;
1793
1794
400k
  section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1795
1796
#ifdef RS6000COFF_C
1797
  if (bfd_xcoff_text_align_power (abfd) != 0
1798
      && strcmp (bfd_section_name (section), ".text") == 0)
1799
    section->alignment_power = bfd_xcoff_text_align_power (abfd);
1800
  else if (bfd_xcoff_data_align_power (abfd) != 0
1801
      && strcmp (bfd_section_name (section), ".data") == 0)
1802
    section->alignment_power = bfd_xcoff_data_align_power (abfd);
1803
  else
1804
    {
1805
      int i;
1806
1807
      for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++)
1808
  if (strcmp (bfd_section_name (section),
1809
        xcoff_dwsect_names[i].xcoff_name) == 0)
1810
    {
1811
      section->alignment_power = 0;
1812
      sclass = C_DWARF;
1813
      break;
1814
    }
1815
    }
1816
#endif
1817
1818
  /* Set up the section symbol.  */
1819
400k
  if (!_bfd_generic_new_section_hook (abfd, section))
1820
0
    return false;
1821
1822
  /* Allocate aux records for section symbols, to store size and
1823
     related info.
1824
1825
     @@ The 10 is a guess at a plausible maximum number of aux entries
1826
     (but shouldn't be a constant).  */
1827
400k
  amt = sizeof (combined_entry_type) * 10;
1828
400k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
400k
  if (native == NULL)
1830
0
    return false;
1831
1832
  /* We don't need to set up n_name, n_value, or n_scnum in the native
1833
     symbol information, since they'll be overridden by the BFD symbol
1834
     anyhow.  However, we do need to set the type and storage class,
1835
     in case this symbol winds up getting written out.  The value 0
1836
     for n_numaux is already correct.  */
1837
1838
400k
  native->is_sym = true;
1839
400k
  native->u.syment.n_type = T_NULL;
1840
400k
  native->u.syment.n_sclass = sclass;
1841
1842
400k
  coffsymbol (section->symbol)->native = native;
1843
1844
400k
  coff_set_custom_section_alignment (abfd, section,
1845
400k
             coff_section_alignment_table,
1846
400k
             coff_section_alignment_table_size);
1847
1848
400k
  return true;
1849
400k
}
coff-go32.c:coff_new_section_hook
Line
Count
Source
1789
342k
{
1790
342k
  combined_entry_type *native;
1791
342k
  size_t amt;
1792
342k
  unsigned char sclass = C_STAT;
1793
1794
342k
  section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1795
1796
#ifdef RS6000COFF_C
1797
  if (bfd_xcoff_text_align_power (abfd) != 0
1798
      && strcmp (bfd_section_name (section), ".text") == 0)
1799
    section->alignment_power = bfd_xcoff_text_align_power (abfd);
1800
  else if (bfd_xcoff_data_align_power (abfd) != 0
1801
      && strcmp (bfd_section_name (section), ".data") == 0)
1802
    section->alignment_power = bfd_xcoff_data_align_power (abfd);
1803
  else
1804
    {
1805
      int i;
1806
1807
      for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++)
1808
  if (strcmp (bfd_section_name (section),
1809
        xcoff_dwsect_names[i].xcoff_name) == 0)
1810
    {
1811
      section->alignment_power = 0;
1812
      sclass = C_DWARF;
1813
      break;
1814
    }
1815
    }
1816
#endif
1817
1818
  /* Set up the section symbol.  */
1819
342k
  if (!_bfd_generic_new_section_hook (abfd, section))
1820
0
    return false;
1821
1822
  /* Allocate aux records for section symbols, to store size and
1823
     related info.
1824
1825
     @@ The 10 is a guess at a plausible maximum number of aux entries
1826
     (but shouldn't be a constant).  */
1827
342k
  amt = sizeof (combined_entry_type) * 10;
1828
342k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
342k
  if (native == NULL)
1830
0
    return false;
1831
1832
  /* We don't need to set up n_name, n_value, or n_scnum in the native
1833
     symbol information, since they'll be overridden by the BFD symbol
1834
     anyhow.  However, we do need to set the type and storage class,
1835
     in case this symbol winds up getting written out.  The value 0
1836
     for n_numaux is already correct.  */
1837
1838
342k
  native->is_sym = true;
1839
342k
  native->u.syment.n_type = T_NULL;
1840
342k
  native->u.syment.n_sclass = sclass;
1841
1842
342k
  coffsymbol (section->symbol)->native = native;
1843
1844
342k
  coff_set_custom_section_alignment (abfd, section,
1845
342k
             coff_section_alignment_table,
1846
342k
             coff_section_alignment_table_size);
1847
1848
342k
  return true;
1849
342k
}
coff-i386.c:coff_new_section_hook
Line
Count
Source
1789
386k
{
1790
386k
  combined_entry_type *native;
1791
386k
  size_t amt;
1792
386k
  unsigned char sclass = C_STAT;
1793
1794
386k
  section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1795
1796
#ifdef RS6000COFF_C
1797
  if (bfd_xcoff_text_align_power (abfd) != 0
1798
      && strcmp (bfd_section_name (section), ".text") == 0)
1799
    section->alignment_power = bfd_xcoff_text_align_power (abfd);
1800
  else if (bfd_xcoff_data_align_power (abfd) != 0
1801
      && strcmp (bfd_section_name (section), ".data") == 0)
1802
    section->alignment_power = bfd_xcoff_data_align_power (abfd);
1803
  else
1804
    {
1805
      int i;
1806
1807
      for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++)
1808
  if (strcmp (bfd_section_name (section),
1809
        xcoff_dwsect_names[i].xcoff_name) == 0)
1810
    {
1811
      section->alignment_power = 0;
1812
      sclass = C_DWARF;
1813
      break;
1814
    }
1815
    }
1816
#endif
1817
1818
  /* Set up the section symbol.  */
1819
386k
  if (!_bfd_generic_new_section_hook (abfd, section))
1820
0
    return false;
1821
1822
  /* Allocate aux records for section symbols, to store size and
1823
     related info.
1824
1825
     @@ The 10 is a guess at a plausible maximum number of aux entries
1826
     (but shouldn't be a constant).  */
1827
386k
  amt = sizeof (combined_entry_type) * 10;
1828
386k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
386k
  if (native == NULL)
1830
0
    return false;
1831
1832
  /* We don't need to set up n_name, n_value, or n_scnum in the native
1833
     symbol information, since they'll be overridden by the BFD symbol
1834
     anyhow.  However, we do need to set the type and storage class,
1835
     in case this symbol winds up getting written out.  The value 0
1836
     for n_numaux is already correct.  */
1837
1838
386k
  native->is_sym = true;
1839
386k
  native->u.syment.n_type = T_NULL;
1840
386k
  native->u.syment.n_sclass = sclass;
1841
1842
386k
  coffsymbol (section->symbol)->native = native;
1843
1844
386k
  coff_set_custom_section_alignment (abfd, section,
1845
386k
             coff_section_alignment_table,
1846
386k
             coff_section_alignment_table_size);
1847
1848
386k
  return true;
1849
386k
}
coff-rs6000.c:coff_new_section_hook
Line
Count
Source
1789
3.72M
{
1790
3.72M
  combined_entry_type *native;
1791
3.72M
  size_t amt;
1792
3.72M
  unsigned char sclass = C_STAT;
1793
1794
3.72M
  section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1795
1796
3.72M
#ifdef RS6000COFF_C
1797
3.72M
  if (bfd_xcoff_text_align_power (abfd) != 0
1798
3.72M
      && strcmp (bfd_section_name (section), ".text") == 0)
1799
2.41k
    section->alignment_power = bfd_xcoff_text_align_power (abfd);
1800
3.72M
  else if (bfd_xcoff_data_align_power (abfd) != 0
1801
3.72M
      && strcmp (bfd_section_name (section), ".data") == 0)
1802
2.41k
    section->alignment_power = bfd_xcoff_data_align_power (abfd);
1803
3.72M
  else
1804
3.72M
    {
1805
3.72M
      int i;
1806
1807
44.6M
      for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++)
1808
40.9M
  if (strcmp (bfd_section_name (section),
1809
40.9M
        xcoff_dwsect_names[i].xcoff_name) == 0)
1810
2.36k
    {
1811
2.36k
      section->alignment_power = 0;
1812
2.36k
      sclass = C_DWARF;
1813
2.36k
      break;
1814
2.36k
    }
1815
3.72M
    }
1816
3.72M
#endif
1817
1818
  /* Set up the section symbol.  */
1819
3.72M
  if (!_bfd_generic_new_section_hook (abfd, section))
1820
0
    return false;
1821
1822
  /* Allocate aux records for section symbols, to store size and
1823
     related info.
1824
1825
     @@ The 10 is a guess at a plausible maximum number of aux entries
1826
     (but shouldn't be a constant).  */
1827
3.72M
  amt = sizeof (combined_entry_type) * 10;
1828
3.72M
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
3.72M
  if (native == NULL)
1830
0
    return false;
1831
1832
  /* We don't need to set up n_name, n_value, or n_scnum in the native
1833
     symbol information, since they'll be overridden by the BFD symbol
1834
     anyhow.  However, we do need to set the type and storage class,
1835
     in case this symbol winds up getting written out.  The value 0
1836
     for n_numaux is already correct.  */
1837
1838
3.72M
  native->is_sym = true;
1839
3.72M
  native->u.syment.n_type = T_NULL;
1840
3.72M
  native->u.syment.n_sclass = sclass;
1841
1842
3.72M
  coffsymbol (section->symbol)->native = native;
1843
1844
3.72M
  coff_set_custom_section_alignment (abfd, section,
1845
3.72M
             coff_section_alignment_table,
1846
3.72M
             coff_section_alignment_table_size);
1847
1848
3.72M
  return true;
1849
3.72M
}
coff-sh.c:coff_new_section_hook
Line
Count
Source
1789
2.81M
{
1790
2.81M
  combined_entry_type *native;
1791
2.81M
  size_t amt;
1792
2.81M
  unsigned char sclass = C_STAT;
1793
1794
2.81M
  section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1795
1796
#ifdef RS6000COFF_C
1797
  if (bfd_xcoff_text_align_power (abfd) != 0
1798
      && strcmp (bfd_section_name (section), ".text") == 0)
1799
    section->alignment_power = bfd_xcoff_text_align_power (abfd);
1800
  else if (bfd_xcoff_data_align_power (abfd) != 0
1801
      && strcmp (bfd_section_name (section), ".data") == 0)
1802
    section->alignment_power = bfd_xcoff_data_align_power (abfd);
1803
  else
1804
    {
1805
      int i;
1806
1807
      for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++)
1808
  if (strcmp (bfd_section_name (section),
1809
        xcoff_dwsect_names[i].xcoff_name) == 0)
1810
    {
1811
      section->alignment_power = 0;
1812
      sclass = C_DWARF;
1813
      break;
1814
    }
1815
    }
1816
#endif
1817
1818
  /* Set up the section symbol.  */
1819
2.81M
  if (!_bfd_generic_new_section_hook (abfd, section))
1820
0
    return false;
1821
1822
  /* Allocate aux records for section symbols, to store size and
1823
     related info.
1824
1825
     @@ The 10 is a guess at a plausible maximum number of aux entries
1826
     (but shouldn't be a constant).  */
1827
2.81M
  amt = sizeof (combined_entry_type) * 10;
1828
2.81M
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
2.81M
  if (native == NULL)
1830
0
    return false;
1831
1832
  /* We don't need to set up n_name, n_value, or n_scnum in the native
1833
     symbol information, since they'll be overridden by the BFD symbol
1834
     anyhow.  However, we do need to set the type and storage class,
1835
     in case this symbol winds up getting written out.  The value 0
1836
     for n_numaux is already correct.  */
1837
1838
2.81M
  native->is_sym = true;
1839
2.81M
  native->u.syment.n_type = T_NULL;
1840
2.81M
  native->u.syment.n_sclass = sclass;
1841
1842
2.81M
  coffsymbol (section->symbol)->native = native;
1843
1844
2.81M
  coff_set_custom_section_alignment (abfd, section,
1845
2.81M
             coff_section_alignment_table,
1846
2.81M
             coff_section_alignment_table_size);
1847
1848
2.81M
  return true;
1849
2.81M
}
coff-stgo32.c:coff_new_section_hook
Line
Count
Source
1789
14.4k
{
1790
14.4k
  combined_entry_type *native;
1791
14.4k
  size_t amt;
1792
14.4k
  unsigned char sclass = C_STAT;
1793
1794
14.4k
  section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1795
1796
#ifdef RS6000COFF_C
1797
  if (bfd_xcoff_text_align_power (abfd) != 0
1798
      && strcmp (bfd_section_name (section), ".text") == 0)
1799
    section->alignment_power = bfd_xcoff_text_align_power (abfd);
1800
  else if (bfd_xcoff_data_align_power (abfd) != 0
1801
      && strcmp (bfd_section_name (section), ".data") == 0)
1802
    section->alignment_power = bfd_xcoff_data_align_power (abfd);
1803
  else
1804
    {
1805
      int i;
1806
1807
      for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++)
1808
  if (strcmp (bfd_section_name (section),
1809
        xcoff_dwsect_names[i].xcoff_name) == 0)
1810
    {
1811
      section->alignment_power = 0;
1812
      sclass = C_DWARF;
1813
      break;
1814
    }
1815
    }
1816
#endif
1817
1818
  /* Set up the section symbol.  */
1819
14.4k
  if (!_bfd_generic_new_section_hook (abfd, section))
1820
0
    return false;
1821
1822
  /* Allocate aux records for section symbols, to store size and
1823
     related info.
1824
1825
     @@ The 10 is a guess at a plausible maximum number of aux entries
1826
     (but shouldn't be a constant).  */
1827
14.4k
  amt = sizeof (combined_entry_type) * 10;
1828
14.4k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
14.4k
  if (native == NULL)
1830
0
    return false;
1831
1832
  /* We don't need to set up n_name, n_value, or n_scnum in the native
1833
     symbol information, since they'll be overridden by the BFD symbol
1834
     anyhow.  However, we do need to set the type and storage class,
1835
     in case this symbol winds up getting written out.  The value 0
1836
     for n_numaux is already correct.  */
1837
1838
14.4k
  native->is_sym = true;
1839
14.4k
  native->u.syment.n_type = T_NULL;
1840
14.4k
  native->u.syment.n_sclass = sclass;
1841
1842
14.4k
  coffsymbol (section->symbol)->native = native;
1843
1844
14.4k
  coff_set_custom_section_alignment (abfd, section,
1845
14.4k
             coff_section_alignment_table,
1846
14.4k
             coff_section_alignment_table_size);
1847
1848
14.4k
  return true;
1849
14.4k
}
coff-tic30.c:coff_new_section_hook
Line
Count
Source
1789
1.22M
{
1790
1.22M
  combined_entry_type *native;
1791
1.22M
  size_t amt;
1792
1.22M
  unsigned char sclass = C_STAT;
1793
1794
1.22M
  section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1795
1796
#ifdef RS6000COFF_C
1797
  if (bfd_xcoff_text_align_power (abfd) != 0
1798
      && strcmp (bfd_section_name (section), ".text") == 0)
1799
    section->alignment_power = bfd_xcoff_text_align_power (abfd);
1800
  else if (bfd_xcoff_data_align_power (abfd) != 0
1801
      && strcmp (bfd_section_name (section), ".data") == 0)
1802
    section->alignment_power = bfd_xcoff_data_align_power (abfd);
1803
  else
1804
    {
1805
      int i;
1806
1807
      for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++)
1808
  if (strcmp (bfd_section_name (section),
1809
        xcoff_dwsect_names[i].xcoff_name) == 0)
1810
    {
1811
      section->alignment_power = 0;
1812
      sclass = C_DWARF;
1813
      break;
1814
    }
1815
    }
1816
#endif
1817
1818
  /* Set up the section symbol.  */
1819
1.22M
  if (!_bfd_generic_new_section_hook (abfd, section))
1820
0
    return false;
1821
1822
  /* Allocate aux records for section symbols, to store size and
1823
     related info.
1824
1825
     @@ The 10 is a guess at a plausible maximum number of aux entries
1826
     (but shouldn't be a constant).  */
1827
1.22M
  amt = sizeof (combined_entry_type) * 10;
1828
1.22M
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
1.22M
  if (native == NULL)
1830
0
    return false;
1831
1832
  /* We don't need to set up n_name, n_value, or n_scnum in the native
1833
     symbol information, since they'll be overridden by the BFD symbol
1834
     anyhow.  However, we do need to set the type and storage class,
1835
     in case this symbol winds up getting written out.  The value 0
1836
     for n_numaux is already correct.  */
1837
1838
1.22M
  native->is_sym = true;
1839
1.22M
  native->u.syment.n_type = T_NULL;
1840
1.22M
  native->u.syment.n_sclass = sclass;
1841
1842
1.22M
  coffsymbol (section->symbol)->native = native;
1843
1844
1.22M
  coff_set_custom_section_alignment (abfd, section,
1845
1.22M
             coff_section_alignment_table,
1846
1.22M
             coff_section_alignment_table_size);
1847
1848
1.22M
  return true;
1849
1.22M
}
Unexecuted instantiation: coff-tic4x.c:coff_new_section_hook
coff-tic54x.c:coff_new_section_hook
Line
Count
Source
1789
2.71M
{
1790
2.71M
  combined_entry_type *native;
1791
2.71M
  size_t amt;
1792
2.71M
  unsigned char sclass = C_STAT;
1793
1794
2.71M
  section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1795
1796
#ifdef RS6000COFF_C
1797
  if (bfd_xcoff_text_align_power (abfd) != 0
1798
      && strcmp (bfd_section_name (section), ".text") == 0)
1799
    section->alignment_power = bfd_xcoff_text_align_power (abfd);
1800
  else if (bfd_xcoff_data_align_power (abfd) != 0
1801
      && strcmp (bfd_section_name (section), ".data") == 0)
1802
    section->alignment_power = bfd_xcoff_data_align_power (abfd);
1803
  else
1804
    {
1805
      int i;
1806
1807
      for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++)
1808
  if (strcmp (bfd_section_name (section),
1809
        xcoff_dwsect_names[i].xcoff_name) == 0)
1810
    {
1811
      section->alignment_power = 0;
1812
      sclass = C_DWARF;
1813
      break;
1814
    }
1815
    }
1816
#endif
1817
1818
  /* Set up the section symbol.  */
1819
2.71M
  if (!_bfd_generic_new_section_hook (abfd, section))
1820
0
    return false;
1821
1822
  /* Allocate aux records for section symbols, to store size and
1823
     related info.
1824
1825
     @@ The 10 is a guess at a plausible maximum number of aux entries
1826
     (but shouldn't be a constant).  */
1827
2.71M
  amt = sizeof (combined_entry_type) * 10;
1828
2.71M
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
2.71M
  if (native == NULL)
1830
0
    return false;
1831
1832
  /* We don't need to set up n_name, n_value, or n_scnum in the native
1833
     symbol information, since they'll be overridden by the BFD symbol
1834
     anyhow.  However, we do need to set the type and storage class,
1835
     in case this symbol winds up getting written out.  The value 0
1836
     for n_numaux is already correct.  */
1837
1838
2.71M
  native->is_sym = true;
1839
2.71M
  native->u.syment.n_type = T_NULL;
1840
2.71M
  native->u.syment.n_sclass = sclass;
1841
1842
2.71M
  coffsymbol (section->symbol)->native = native;
1843
1844
2.71M
  coff_set_custom_section_alignment (abfd, section,
1845
2.71M
             coff_section_alignment_table,
1846
2.71M
             coff_section_alignment_table_size);
1847
1848
2.71M
  return true;
1849
2.71M
}
coff-z80.c:coff_new_section_hook
Line
Count
Source
1789
142k
{
1790
142k
  combined_entry_type *native;
1791
142k
  size_t amt;
1792
142k
  unsigned char sclass = C_STAT;
1793
1794
142k
  section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1795
1796
#ifdef RS6000COFF_C
1797
  if (bfd_xcoff_text_align_power (abfd) != 0
1798
      && strcmp (bfd_section_name (section), ".text") == 0)
1799
    section->alignment_power = bfd_xcoff_text_align_power (abfd);
1800
  else if (bfd_xcoff_data_align_power (abfd) != 0
1801
      && strcmp (bfd_section_name (section), ".data") == 0)
1802
    section->alignment_power = bfd_xcoff_data_align_power (abfd);
1803
  else
1804
    {
1805
      int i;
1806
1807
      for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++)
1808
  if (strcmp (bfd_section_name (section),
1809
        xcoff_dwsect_names[i].xcoff_name) == 0)
1810
    {
1811
      section->alignment_power = 0;
1812
      sclass = C_DWARF;
1813
      break;
1814
    }
1815
    }
1816
#endif
1817
1818
  /* Set up the section symbol.  */
1819
142k
  if (!_bfd_generic_new_section_hook (abfd, section))
1820
0
    return false;
1821
1822
  /* Allocate aux records for section symbols, to store size and
1823
     related info.
1824
1825
     @@ The 10 is a guess at a plausible maximum number of aux entries
1826
     (but shouldn't be a constant).  */
1827
142k
  amt = sizeof (combined_entry_type) * 10;
1828
142k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
142k
  if (native == NULL)
1830
0
    return false;
1831
1832
  /* We don't need to set up n_name, n_value, or n_scnum in the native
1833
     symbol information, since they'll be overridden by the BFD symbol
1834
     anyhow.  However, we do need to set the type and storage class,
1835
     in case this symbol winds up getting written out.  The value 0
1836
     for n_numaux is already correct.  */
1837
1838
142k
  native->is_sym = true;
1839
142k
  native->u.syment.n_type = T_NULL;
1840
142k
  native->u.syment.n_sclass = sclass;
1841
1842
142k
  coffsymbol (section->symbol)->native = native;
1843
1844
142k
  coff_set_custom_section_alignment (abfd, section,
1845
142k
             coff_section_alignment_table,
1846
142k
             coff_section_alignment_table_size);
1847
1848
142k
  return true;
1849
142k
}
coff-z8k.c:coff_new_section_hook
Line
Count
Source
1789
365k
{
1790
365k
  combined_entry_type *native;
1791
365k
  size_t amt;
1792
365k
  unsigned char sclass = C_STAT;
1793
1794
365k
  section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1795
1796
#ifdef RS6000COFF_C
1797
  if (bfd_xcoff_text_align_power (abfd) != 0
1798
      && strcmp (bfd_section_name (section), ".text") == 0)
1799
    section->alignment_power = bfd_xcoff_text_align_power (abfd);
1800
  else if (bfd_xcoff_data_align_power (abfd) != 0
1801
      && strcmp (bfd_section_name (section), ".data") == 0)
1802
    section->alignment_power = bfd_xcoff_data_align_power (abfd);
1803
  else
1804
    {
1805
      int i;
1806
1807
      for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++)
1808
  if (strcmp (bfd_section_name (section),
1809
        xcoff_dwsect_names[i].xcoff_name) == 0)
1810
    {
1811
      section->alignment_power = 0;
1812
      sclass = C_DWARF;
1813
      break;
1814
    }
1815
    }
1816
#endif
1817
1818
  /* Set up the section symbol.  */
1819
365k
  if (!_bfd_generic_new_section_hook (abfd, section))
1820
0
    return false;
1821
1822
  /* Allocate aux records for section symbols, to store size and
1823
     related info.
1824
1825
     @@ The 10 is a guess at a plausible maximum number of aux entries
1826
     (but shouldn't be a constant).  */
1827
365k
  amt = sizeof (combined_entry_type) * 10;
1828
365k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
365k
  if (native == NULL)
1830
0
    return false;
1831
1832
  /* We don't need to set up n_name, n_value, or n_scnum in the native
1833
     symbol information, since they'll be overridden by the BFD symbol
1834
     anyhow.  However, we do need to set the type and storage class,
1835
     in case this symbol winds up getting written out.  The value 0
1836
     for n_numaux is already correct.  */
1837
1838
365k
  native->is_sym = true;
1839
365k
  native->u.syment.n_type = T_NULL;
1840
365k
  native->u.syment.n_sclass = sclass;
1841
1842
365k
  coffsymbol (section->symbol)->native = native;
1843
1844
365k
  coff_set_custom_section_alignment (abfd, section,
1845
365k
             coff_section_alignment_table,
1846
365k
             coff_section_alignment_table_size);
1847
1848
365k
  return true;
1849
365k
}
pe-arm-wince.c:coff_new_section_hook
Line
Count
Source
1789
11.0k
{
1790
11.0k
  combined_entry_type *native;
1791
11.0k
  size_t amt;
1792
11.0k
  unsigned char sclass = C_STAT;
1793
1794
11.0k
  section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1795
1796
#ifdef RS6000COFF_C
1797
  if (bfd_xcoff_text_align_power (abfd) != 0
1798
      && strcmp (bfd_section_name (section), ".text") == 0)
1799
    section->alignment_power = bfd_xcoff_text_align_power (abfd);
1800
  else if (bfd_xcoff_data_align_power (abfd) != 0
1801
      && strcmp (bfd_section_name (section), ".data") == 0)
1802
    section->alignment_power = bfd_xcoff_data_align_power (abfd);
1803
  else
1804
    {
1805
      int i;
1806
1807
      for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++)
1808
  if (strcmp (bfd_section_name (section),
1809
        xcoff_dwsect_names[i].xcoff_name) == 0)
1810
    {
1811
      section->alignment_power = 0;
1812
      sclass = C_DWARF;
1813
      break;
1814
    }
1815
    }
1816
#endif
1817
1818
  /* Set up the section symbol.  */
1819
11.0k
  if (!_bfd_generic_new_section_hook (abfd, section))
1820
0
    return false;
1821
1822
  /* Allocate aux records for section symbols, to store size and
1823
     related info.
1824
1825
     @@ The 10 is a guess at a plausible maximum number of aux entries
1826
     (but shouldn't be a constant).  */
1827
11.0k
  amt = sizeof (combined_entry_type) * 10;
1828
11.0k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
11.0k
  if (native == NULL)
1830
0
    return false;
1831
1832
  /* We don't need to set up n_name, n_value, or n_scnum in the native
1833
     symbol information, since they'll be overridden by the BFD symbol
1834
     anyhow.  However, we do need to set the type and storage class,
1835
     in case this symbol winds up getting written out.  The value 0
1836
     for n_numaux is already correct.  */
1837
1838
11.0k
  native->is_sym = true;
1839
11.0k
  native->u.syment.n_type = T_NULL;
1840
11.0k
  native->u.syment.n_sclass = sclass;
1841
1842
11.0k
  coffsymbol (section->symbol)->native = native;
1843
1844
11.0k
  coff_set_custom_section_alignment (abfd, section,
1845
11.0k
             coff_section_alignment_table,
1846
11.0k
             coff_section_alignment_table_size);
1847
1848
11.0k
  return true;
1849
11.0k
}
pe-arm.c:coff_new_section_hook
Line
Count
Source
1789
11.0k
{
1790
11.0k
  combined_entry_type *native;
1791
11.0k
  size_t amt;
1792
11.0k
  unsigned char sclass = C_STAT;
1793
1794
11.0k
  section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1795
1796
#ifdef RS6000COFF_C
1797
  if (bfd_xcoff_text_align_power (abfd) != 0
1798
      && strcmp (bfd_section_name (section), ".text") == 0)
1799
    section->alignment_power = bfd_xcoff_text_align_power (abfd);
1800
  else if (bfd_xcoff_data_align_power (abfd) != 0
1801
      && strcmp (bfd_section_name (section), ".data") == 0)
1802
    section->alignment_power = bfd_xcoff_data_align_power (abfd);
1803
  else
1804
    {
1805
      int i;
1806
1807
      for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++)
1808
  if (strcmp (bfd_section_name (section),
1809
        xcoff_dwsect_names[i].xcoff_name) == 0)
1810
    {
1811
      section->alignment_power = 0;
1812
      sclass = C_DWARF;
1813
      break;
1814
    }
1815
    }
1816
#endif
1817
1818
  /* Set up the section symbol.  */
1819
11.0k
  if (!_bfd_generic_new_section_hook (abfd, section))
1820
0
    return false;
1821
1822
  /* Allocate aux records for section symbols, to store size and
1823
     related info.
1824
1825
     @@ The 10 is a guess at a plausible maximum number of aux entries
1826
     (but shouldn't be a constant).  */
1827
11.0k
  amt = sizeof (combined_entry_type) * 10;
1828
11.0k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
11.0k
  if (native == NULL)
1830
0
    return false;
1831
1832
  /* We don't need to set up n_name, n_value, or n_scnum in the native
1833
     symbol information, since they'll be overridden by the BFD symbol
1834
     anyhow.  However, we do need to set the type and storage class,
1835
     in case this symbol winds up getting written out.  The value 0
1836
     for n_numaux is already correct.  */
1837
1838
11.0k
  native->is_sym = true;
1839
11.0k
  native->u.syment.n_type = T_NULL;
1840
11.0k
  native->u.syment.n_sclass = sclass;
1841
1842
11.0k
  coffsymbol (section->symbol)->native = native;
1843
1844
11.0k
  coff_set_custom_section_alignment (abfd, section,
1845
11.0k
             coff_section_alignment_table,
1846
11.0k
             coff_section_alignment_table_size);
1847
1848
11.0k
  return true;
1849
11.0k
}
pe-i386.c:coff_new_section_hook
Line
Count
Source
1789
16.7k
{
1790
16.7k
  combined_entry_type *native;
1791
16.7k
  size_t amt;
1792
16.7k
  unsigned char sclass = C_STAT;
1793
1794
16.7k
  section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1795
1796
#ifdef RS6000COFF_C
1797
  if (bfd_xcoff_text_align_power (abfd) != 0
1798
      && strcmp (bfd_section_name (section), ".text") == 0)
1799
    section->alignment_power = bfd_xcoff_text_align_power (abfd);
1800
  else if (bfd_xcoff_data_align_power (abfd) != 0
1801
      && strcmp (bfd_section_name (section), ".data") == 0)
1802
    section->alignment_power = bfd_xcoff_data_align_power (abfd);
1803
  else
1804
    {
1805
      int i;
1806
1807
      for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++)
1808
  if (strcmp (bfd_section_name (section),
1809
        xcoff_dwsect_names[i].xcoff_name) == 0)
1810
    {
1811
      section->alignment_power = 0;
1812
      sclass = C_DWARF;
1813
      break;
1814
    }
1815
    }
1816
#endif
1817
1818
  /* Set up the section symbol.  */
1819
16.7k
  if (!_bfd_generic_new_section_hook (abfd, section))
1820
0
    return false;
1821
1822
  /* Allocate aux records for section symbols, to store size and
1823
     related info.
1824
1825
     @@ The 10 is a guess at a plausible maximum number of aux entries
1826
     (but shouldn't be a constant).  */
1827
16.7k
  amt = sizeof (combined_entry_type) * 10;
1828
16.7k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
16.7k
  if (native == NULL)
1830
0
    return false;
1831
1832
  /* We don't need to set up n_name, n_value, or n_scnum in the native
1833
     symbol information, since they'll be overridden by the BFD symbol
1834
     anyhow.  However, we do need to set the type and storage class,
1835
     in case this symbol winds up getting written out.  The value 0
1836
     for n_numaux is already correct.  */
1837
1838
16.7k
  native->is_sym = true;
1839
16.7k
  native->u.syment.n_type = T_NULL;
1840
16.7k
  native->u.syment.n_sclass = sclass;
1841
1842
16.7k
  coffsymbol (section->symbol)->native = native;
1843
1844
16.7k
  coff_set_custom_section_alignment (abfd, section,
1845
16.7k
             coff_section_alignment_table,
1846
16.7k
             coff_section_alignment_table_size);
1847
1848
16.7k
  return true;
1849
16.7k
}
pe-mcore.c:coff_new_section_hook
Line
Count
Source
1789
11.8k
{
1790
11.8k
  combined_entry_type *native;
1791
11.8k
  size_t amt;
1792
11.8k
  unsigned char sclass = C_STAT;
1793
1794
11.8k
  section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1795
1796
#ifdef RS6000COFF_C
1797
  if (bfd_xcoff_text_align_power (abfd) != 0
1798
      && strcmp (bfd_section_name (section), ".text") == 0)
1799
    section->alignment_power = bfd_xcoff_text_align_power (abfd);
1800
  else if (bfd_xcoff_data_align_power (abfd) != 0
1801
      && strcmp (bfd_section_name (section), ".data") == 0)
1802
    section->alignment_power = bfd_xcoff_data_align_power (abfd);
1803
  else
1804
    {
1805
      int i;
1806
1807
      for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++)
1808
  if (strcmp (bfd_section_name (section),
1809
        xcoff_dwsect_names[i].xcoff_name) == 0)
1810
    {
1811
      section->alignment_power = 0;
1812
      sclass = C_DWARF;
1813
      break;
1814
    }
1815
    }
1816
#endif
1817
1818
  /* Set up the section symbol.  */
1819
11.8k
  if (!_bfd_generic_new_section_hook (abfd, section))
1820
0
    return false;
1821
1822
  /* Allocate aux records for section symbols, to store size and
1823
     related info.
1824
1825
     @@ The 10 is a guess at a plausible maximum number of aux entries
1826
     (but shouldn't be a constant).  */
1827
11.8k
  amt = sizeof (combined_entry_type) * 10;
1828
11.8k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
11.8k
  if (native == NULL)
1830
0
    return false;
1831
1832
  /* We don't need to set up n_name, n_value, or n_scnum in the native
1833
     symbol information, since they'll be overridden by the BFD symbol
1834
     anyhow.  However, we do need to set the type and storage class,
1835
     in case this symbol winds up getting written out.  The value 0
1836
     for n_numaux is already correct.  */
1837
1838
11.8k
  native->is_sym = true;
1839
11.8k
  native->u.syment.n_type = T_NULL;
1840
11.8k
  native->u.syment.n_sclass = sclass;
1841
1842
11.8k
  coffsymbol (section->symbol)->native = native;
1843
1844
11.8k
  coff_set_custom_section_alignment (abfd, section,
1845
11.8k
             coff_section_alignment_table,
1846
11.8k
             coff_section_alignment_table_size);
1847
1848
11.8k
  return true;
1849
11.8k
}
pe-sh.c:coff_new_section_hook
Line
Count
Source
1789
20.7k
{
1790
20.7k
  combined_entry_type *native;
1791
20.7k
  size_t amt;
1792
20.7k
  unsigned char sclass = C_STAT;
1793
1794
20.7k
  section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1795
1796
#ifdef RS6000COFF_C
1797
  if (bfd_xcoff_text_align_power (abfd) != 0
1798
      && strcmp (bfd_section_name (section), ".text") == 0)
1799
    section->alignment_power = bfd_xcoff_text_align_power (abfd);
1800
  else if (bfd_xcoff_data_align_power (abfd) != 0
1801
      && strcmp (bfd_section_name (section), ".data") == 0)
1802
    section->alignment_power = bfd_xcoff_data_align_power (abfd);
1803
  else
1804
    {
1805
      int i;
1806
1807
      for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++)
1808
  if (strcmp (bfd_section_name (section),
1809
        xcoff_dwsect_names[i].xcoff_name) == 0)
1810
    {
1811
      section->alignment_power = 0;
1812
      sclass = C_DWARF;
1813
      break;
1814
    }
1815
    }
1816
#endif
1817
1818
  /* Set up the section symbol.  */
1819
20.7k
  if (!_bfd_generic_new_section_hook (abfd, section))
1820
0
    return false;
1821
1822
  /* Allocate aux records for section symbols, to store size and
1823
     related info.
1824
1825
     @@ The 10 is a guess at a plausible maximum number of aux entries
1826
     (but shouldn't be a constant).  */
1827
20.7k
  amt = sizeof (combined_entry_type) * 10;
1828
20.7k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
20.7k
  if (native == NULL)
1830
0
    return false;
1831
1832
  /* We don't need to set up n_name, n_value, or n_scnum in the native
1833
     symbol information, since they'll be overridden by the BFD symbol
1834
     anyhow.  However, we do need to set the type and storage class,
1835
     in case this symbol winds up getting written out.  The value 0
1836
     for n_numaux is already correct.  */
1837
1838
20.7k
  native->is_sym = true;
1839
20.7k
  native->u.syment.n_type = T_NULL;
1840
20.7k
  native->u.syment.n_sclass = sclass;
1841
1842
20.7k
  coffsymbol (section->symbol)->native = native;
1843
1844
20.7k
  coff_set_custom_section_alignment (abfd, section,
1845
20.7k
             coff_section_alignment_table,
1846
20.7k
             coff_section_alignment_table_size);
1847
1848
20.7k
  return true;
1849
20.7k
}
pei-arm-wince.c:coff_new_section_hook
Line
Count
Source
1789
23.2k
{
1790
23.2k
  combined_entry_type *native;
1791
23.2k
  size_t amt;
1792
23.2k
  unsigned char sclass = C_STAT;
1793
1794
23.2k
  section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1795
1796
#ifdef RS6000COFF_C
1797
  if (bfd_xcoff_text_align_power (abfd) != 0
1798
      && strcmp (bfd_section_name (section), ".text") == 0)
1799
    section->alignment_power = bfd_xcoff_text_align_power (abfd);
1800
  else if (bfd_xcoff_data_align_power (abfd) != 0
1801
      && strcmp (bfd_section_name (section), ".data") == 0)
1802
    section->alignment_power = bfd_xcoff_data_align_power (abfd);
1803
  else
1804
    {
1805
      int i;
1806
1807
      for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++)
1808
  if (strcmp (bfd_section_name (section),
1809
        xcoff_dwsect_names[i].xcoff_name) == 0)
1810
    {
1811
      section->alignment_power = 0;
1812
      sclass = C_DWARF;
1813
      break;
1814
    }
1815
    }
1816
#endif
1817
1818
  /* Set up the section symbol.  */
1819
23.2k
  if (!_bfd_generic_new_section_hook (abfd, section))
1820
0
    return false;
1821
1822
  /* Allocate aux records for section symbols, to store size and
1823
     related info.
1824
1825
     @@ The 10 is a guess at a plausible maximum number of aux entries
1826
     (but shouldn't be a constant).  */
1827
23.2k
  amt = sizeof (combined_entry_type) * 10;
1828
23.2k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
23.2k
  if (native == NULL)
1830
0
    return false;
1831
1832
  /* We don't need to set up n_name, n_value, or n_scnum in the native
1833
     symbol information, since they'll be overridden by the BFD symbol
1834
     anyhow.  However, we do need to set the type and storage class,
1835
     in case this symbol winds up getting written out.  The value 0
1836
     for n_numaux is already correct.  */
1837
1838
23.2k
  native->is_sym = true;
1839
23.2k
  native->u.syment.n_type = T_NULL;
1840
23.2k
  native->u.syment.n_sclass = sclass;
1841
1842
23.2k
  coffsymbol (section->symbol)->native = native;
1843
1844
23.2k
  coff_set_custom_section_alignment (abfd, section,
1845
23.2k
             coff_section_alignment_table,
1846
23.2k
             coff_section_alignment_table_size);
1847
1848
23.2k
  return true;
1849
23.2k
}
pei-arm.c:coff_new_section_hook
Line
Count
Source
1789
31.2k
{
1790
31.2k
  combined_entry_type *native;
1791
31.2k
  size_t amt;
1792
31.2k
  unsigned char sclass = C_STAT;
1793
1794
31.2k
  section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1795
1796
#ifdef RS6000COFF_C
1797
  if (bfd_xcoff_text_align_power (abfd) != 0
1798
      && strcmp (bfd_section_name (section), ".text") == 0)
1799
    section->alignment_power = bfd_xcoff_text_align_power (abfd);
1800
  else if (bfd_xcoff_data_align_power (abfd) != 0
1801
      && strcmp (bfd_section_name (section), ".data") == 0)
1802
    section->alignment_power = bfd_xcoff_data_align_power (abfd);
1803
  else
1804
    {
1805
      int i;
1806
1807
      for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++)
1808
  if (strcmp (bfd_section_name (section),
1809
        xcoff_dwsect_names[i].xcoff_name) == 0)
1810
    {
1811
      section->alignment_power = 0;
1812
      sclass = C_DWARF;
1813
      break;
1814
    }
1815
    }
1816
#endif
1817
1818
  /* Set up the section symbol.  */
1819
31.2k
  if (!_bfd_generic_new_section_hook (abfd, section))
1820
0
    return false;
1821
1822
  /* Allocate aux records for section symbols, to store size and
1823
     related info.
1824
1825
     @@ The 10 is a guess at a plausible maximum number of aux entries
1826
     (but shouldn't be a constant).  */
1827
31.2k
  amt = sizeof (combined_entry_type) * 10;
1828
31.2k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
31.2k
  if (native == NULL)
1830
0
    return false;
1831
1832
  /* We don't need to set up n_name, n_value, or n_scnum in the native
1833
     symbol information, since they'll be overridden by the BFD symbol
1834
     anyhow.  However, we do need to set the type and storage class,
1835
     in case this symbol winds up getting written out.  The value 0
1836
     for n_numaux is already correct.  */
1837
1838
31.2k
  native->is_sym = true;
1839
31.2k
  native->u.syment.n_type = T_NULL;
1840
31.2k
  native->u.syment.n_sclass = sclass;
1841
1842
31.2k
  coffsymbol (section->symbol)->native = native;
1843
1844
31.2k
  coff_set_custom_section_alignment (abfd, section,
1845
31.2k
             coff_section_alignment_table,
1846
31.2k
             coff_section_alignment_table_size);
1847
1848
31.2k
  return true;
1849
31.2k
}
pei-mcore.c:coff_new_section_hook
Line
Count
Source
1789
26.2k
{
1790
26.2k
  combined_entry_type *native;
1791
26.2k
  size_t amt;
1792
26.2k
  unsigned char sclass = C_STAT;
1793
1794
26.2k
  section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1795
1796
#ifdef RS6000COFF_C
1797
  if (bfd_xcoff_text_align_power (abfd) != 0
1798
      && strcmp (bfd_section_name (section), ".text") == 0)
1799
    section->alignment_power = bfd_xcoff_text_align_power (abfd);
1800
  else if (bfd_xcoff_data_align_power (abfd) != 0
1801
      && strcmp (bfd_section_name (section), ".data") == 0)
1802
    section->alignment_power = bfd_xcoff_data_align_power (abfd);
1803
  else
1804
    {
1805
      int i;
1806
1807
      for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++)
1808
  if (strcmp (bfd_section_name (section),
1809
        xcoff_dwsect_names[i].xcoff_name) == 0)
1810
    {
1811
      section->alignment_power = 0;
1812
      sclass = C_DWARF;
1813
      break;
1814
    }
1815
    }
1816
#endif
1817
1818
  /* Set up the section symbol.  */
1819
26.2k
  if (!_bfd_generic_new_section_hook (abfd, section))
1820
0
    return false;
1821
1822
  /* Allocate aux records for section symbols, to store size and
1823
     related info.
1824
1825
     @@ The 10 is a guess at a plausible maximum number of aux entries
1826
     (but shouldn't be a constant).  */
1827
26.2k
  amt = sizeof (combined_entry_type) * 10;
1828
26.2k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
26.2k
  if (native == NULL)
1830
0
    return false;
1831
1832
  /* We don't need to set up n_name, n_value, or n_scnum in the native
1833
     symbol information, since they'll be overridden by the BFD symbol
1834
     anyhow.  However, we do need to set the type and storage class,
1835
     in case this symbol winds up getting written out.  The value 0
1836
     for n_numaux is already correct.  */
1837
1838
26.2k
  native->is_sym = true;
1839
26.2k
  native->u.syment.n_type = T_NULL;
1840
26.2k
  native->u.syment.n_sclass = sclass;
1841
1842
26.2k
  coffsymbol (section->symbol)->native = native;
1843
1844
26.2k
  coff_set_custom_section_alignment (abfd, section,
1845
26.2k
             coff_section_alignment_table,
1846
26.2k
             coff_section_alignment_table_size);
1847
1848
26.2k
  return true;
1849
26.2k
}
pei-sh.c:coff_new_section_hook
Line
Count
Source
1789
32.0k
{
1790
32.0k
  combined_entry_type *native;
1791
32.0k
  size_t amt;
1792
32.0k
  unsigned char sclass = C_STAT;
1793
1794
32.0k
  section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1795
1796
#ifdef RS6000COFF_C
1797
  if (bfd_xcoff_text_align_power (abfd) != 0
1798
      && strcmp (bfd_section_name (section), ".text") == 0)
1799
    section->alignment_power = bfd_xcoff_text_align_power (abfd);
1800
  else if (bfd_xcoff_data_align_power (abfd) != 0
1801
      && strcmp (bfd_section_name (section), ".data") == 0)
1802
    section->alignment_power = bfd_xcoff_data_align_power (abfd);
1803
  else
1804
    {
1805
      int i;
1806
1807
      for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++)
1808
  if (strcmp (bfd_section_name (section),
1809
        xcoff_dwsect_names[i].xcoff_name) == 0)
1810
    {
1811
      section->alignment_power = 0;
1812
      sclass = C_DWARF;
1813
      break;
1814
    }
1815
    }
1816
#endif
1817
1818
  /* Set up the section symbol.  */
1819
32.0k
  if (!_bfd_generic_new_section_hook (abfd, section))
1820
0
    return false;
1821
1822
  /* Allocate aux records for section symbols, to store size and
1823
     related info.
1824
1825
     @@ The 10 is a guess at a plausible maximum number of aux entries
1826
     (but shouldn't be a constant).  */
1827
32.0k
  amt = sizeof (combined_entry_type) * 10;
1828
32.0k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
32.0k
  if (native == NULL)
1830
0
    return false;
1831
1832
  /* We don't need to set up n_name, n_value, or n_scnum in the native
1833
     symbol information, since they'll be overridden by the BFD symbol
1834
     anyhow.  However, we do need to set the type and storage class,
1835
     in case this symbol winds up getting written out.  The value 0
1836
     for n_numaux is already correct.  */
1837
1838
32.0k
  native->is_sym = true;
1839
32.0k
  native->u.syment.n_type = T_NULL;
1840
32.0k
  native->u.syment.n_sclass = sclass;
1841
1842
32.0k
  coffsymbol (section->symbol)->native = native;
1843
1844
32.0k
  coff_set_custom_section_alignment (abfd, section,
1845
32.0k
             coff_section_alignment_table,
1846
32.0k
             coff_section_alignment_table_size);
1847
1848
32.0k
  return true;
1849
32.0k
}
1850
1851
#ifdef COFF_ALIGN_IN_SECTION_HEADER
1852
1853
/* Set the alignment of a BFD section.  */
1854
1855
static void
1856
coff_set_alignment_hook (bfd * abfd ATTRIBUTE_UNUSED,
1857
       asection * section,
1858
       void * scnhdr)
1859
2.86M
{
1860
2.86M
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1861
2.86M
  unsigned int i;
1862
1863
2.86M
#ifdef COFF_DECODE_ALIGNMENT
1864
2.86M
  i = COFF_DECODE_ALIGNMENT(hdr->s_flags);
1865
2.86M
#endif
1866
2.86M
  section->alignment_power = i;
1867
1868
#ifdef coff_set_section_load_page
1869
2.71M
  coff_set_section_load_page (section, hdr->s_page);
1870
#endif
1871
2.86M
}
Unexecuted instantiation: coff-tic4x.c:coff_set_alignment_hook
coff-tic54x.c:coff_set_alignment_hook
Line
Count
Source
1859
2.71M
{
1860
2.71M
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1861
2.71M
  unsigned int i;
1862
1863
2.71M
#ifdef COFF_DECODE_ALIGNMENT
1864
2.71M
  i = COFF_DECODE_ALIGNMENT(hdr->s_flags);
1865
2.71M
#endif
1866
2.71M
  section->alignment_power = i;
1867
1868
2.71M
#ifdef coff_set_section_load_page
1869
2.71M
  coff_set_section_load_page (section, hdr->s_page);
1870
2.71M
#endif
1871
2.71M
}
coff-z80.c:coff_set_alignment_hook
Line
Count
Source
1859
142k
{
1860
142k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1861
142k
  unsigned int i;
1862
1863
142k
#ifdef COFF_DECODE_ALIGNMENT
1864
142k
  i = COFF_DECODE_ALIGNMENT(hdr->s_flags);
1865
142k
#endif
1866
142k
  section->alignment_power = i;
1867
1868
#ifdef coff_set_section_load_page
1869
  coff_set_section_load_page (section, hdr->s_page);
1870
#endif
1871
142k
}
1872
1873
#else /* ! COFF_ALIGN_IN_SECTION_HEADER */
1874
#ifdef COFF_WITH_PE
1875
1876
static void
1877
coff_set_alignment_hook (bfd * abfd ATTRIBUTE_UNUSED,
1878
       asection * section,
1879
       void * scnhdr)
1880
439k
{
1881
439k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
439k
  size_t amt;
1883
439k
  unsigned int alignment_power_const
1884
439k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
439k
  switch (alignment_power_const)
1887
439k
    {
1888
10.4k
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
14.1k
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
27.4k
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
29.3k
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
43.3k
    case IMAGE_SCN_ALIGN_512BYTES:
1893
56.1k
    case IMAGE_SCN_ALIGN_256BYTES:
1894
63.0k
    case IMAGE_SCN_ALIGN_128BYTES:
1895
71.4k
    case IMAGE_SCN_ALIGN_64BYTES:
1896
92.2k
    case IMAGE_SCN_ALIGN_32BYTES:
1897
95.6k
    case IMAGE_SCN_ALIGN_16BYTES:
1898
105k
    case IMAGE_SCN_ALIGN_8BYTES:
1899
116k
    case IMAGE_SCN_ALIGN_4BYTES:
1900
137k
    case IMAGE_SCN_ALIGN_2BYTES:
1901
142k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
142k
      section->alignment_power
1903
142k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
142k
      break;
1905
297k
    default:
1906
297k
      break;
1907
439k
    }
1908
1909
  /* In a PE image file, the s_paddr field holds the virtual size of a
1910
     section, while the s_size field holds the raw size.  We also keep
1911
     the original section flag value, since not every bit can be
1912
     mapped onto a generic BFD section bit.  */
1913
439k
  if (coff_section_data (abfd, section) == NULL)
1914
439k
    {
1915
439k
      amt = sizeof (struct coff_section_tdata);
1916
439k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
439k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
439k
    }
1921
1922
439k
  if (pei_section_data (abfd, section) == NULL)
1923
439k
    {
1924
439k
      amt = sizeof (struct pei_section_tdata);
1925
439k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
439k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
439k
    }
1930
439k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
439k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
439k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
439k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
61.3k
    {
1938
61.3k
      struct external_reloc dst;
1939
61.3k
      struct internal_reloc n;
1940
61.3k
      file_ptr oldpos = bfd_tell (abfd);
1941
61.3k
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
61.3k
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
61.3k
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
39.4k
  return;
1947
1948
21.8k
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
21.8k
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
21.8k
      if (n.r_vaddr < 0x10000)
1952
8.77k
  {
1953
8.77k
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
8.77k
    bfd_set_error (bfd_error_bad_value);
1955
8.77k
    return;
1956
8.77k
  }
1957
13.0k
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
13.0k
      section->rel_filepos += relsz;
1959
13.0k
    }
1960
378k
  else if (hdr->s_nreloc == 0xffff)
1961
3.60k
    _bfd_error_handler
1962
3.60k
      (_("%pB: warning: claims to have 0xffff relocs, without overflow"),
1963
3.60k
       abfd);
1964
439k
}
pei-i386.c:coff_set_alignment_hook
Line
Count
Source
1880
121k
{
1881
121k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
121k
  size_t amt;
1883
121k
  unsigned int alignment_power_const
1884
121k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
121k
  switch (alignment_power_const)
1887
121k
    {
1888
127
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
762
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
3.64k
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
3.64k
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
4.48k
    case IMAGE_SCN_ALIGN_512BYTES:
1893
14.0k
    case IMAGE_SCN_ALIGN_256BYTES:
1894
14.3k
    case IMAGE_SCN_ALIGN_128BYTES:
1895
14.5k
    case IMAGE_SCN_ALIGN_64BYTES:
1896
16.2k
    case IMAGE_SCN_ALIGN_32BYTES:
1897
16.7k
    case IMAGE_SCN_ALIGN_16BYTES:
1898
17.5k
    case IMAGE_SCN_ALIGN_8BYTES:
1899
18.0k
    case IMAGE_SCN_ALIGN_4BYTES:
1900
19.9k
    case IMAGE_SCN_ALIGN_2BYTES:
1901
20.0k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
20.0k
      section->alignment_power
1903
20.0k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
20.0k
      break;
1905
101k
    default:
1906
101k
      break;
1907
121k
    }
1908
1909
  /* In a PE image file, the s_paddr field holds the virtual size of a
1910
     section, while the s_size field holds the raw size.  We also keep
1911
     the original section flag value, since not every bit can be
1912
     mapped onto a generic BFD section bit.  */
1913
121k
  if (coff_section_data (abfd, section) == NULL)
1914
121k
    {
1915
121k
      amt = sizeof (struct coff_section_tdata);
1916
121k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
121k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
121k
    }
1921
1922
121k
  if (pei_section_data (abfd, section) == NULL)
1923
121k
    {
1924
121k
      amt = sizeof (struct pei_section_tdata);
1925
121k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
121k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
121k
    }
1930
121k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
121k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
121k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
121k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
6.18k
    {
1938
6.18k
      struct external_reloc dst;
1939
6.18k
      struct internal_reloc n;
1940
6.18k
      file_ptr oldpos = bfd_tell (abfd);
1941
6.18k
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
6.18k
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
6.18k
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
2.55k
  return;
1947
1948
3.62k
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
3.62k
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
3.62k
      if (n.r_vaddr < 0x10000)
1952
2.13k
  {
1953
2.13k
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
2.13k
    bfd_set_error (bfd_error_bad_value);
1955
2.13k
    return;
1956
2.13k
  }
1957
1.48k
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
1.48k
      section->rel_filepos += relsz;
1959
1.48k
    }
1960
115k
  else if (hdr->s_nreloc == 0xffff)
1961
0
    _bfd_error_handler
1962
0
      (_("%pB: warning: claims to have 0xffff relocs, without overflow"),
1963
0
       abfd);
1964
121k
}
pe-x86_64.c:coff_set_alignment_hook
Line
Count
Source
1880
42.2k
{
1881
42.2k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
42.2k
  size_t amt;
1883
42.2k
  unsigned int alignment_power_const
1884
42.2k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
42.2k
  switch (alignment_power_const)
1887
42.2k
    {
1888
651
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
895
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
1.56k
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
1.67k
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
3.49k
    case IMAGE_SCN_ALIGN_512BYTES:
1893
4.04k
    case IMAGE_SCN_ALIGN_256BYTES:
1894
4.21k
    case IMAGE_SCN_ALIGN_128BYTES:
1895
5.95k
    case IMAGE_SCN_ALIGN_64BYTES:
1896
10.1k
    case IMAGE_SCN_ALIGN_32BYTES:
1897
10.1k
    case IMAGE_SCN_ALIGN_16BYTES:
1898
11.5k
    case IMAGE_SCN_ALIGN_8BYTES:
1899
16.3k
    case IMAGE_SCN_ALIGN_4BYTES:
1900
19.7k
    case IMAGE_SCN_ALIGN_2BYTES:
1901
20.3k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
20.3k
      section->alignment_power
1903
20.3k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
20.3k
      break;
1905
21.9k
    default:
1906
21.9k
      break;
1907
42.2k
    }
1908
1909
  /* In a PE image file, the s_paddr field holds the virtual size of a
1910
     section, while the s_size field holds the raw size.  We also keep
1911
     the original section flag value, since not every bit can be
1912
     mapped onto a generic BFD section bit.  */
1913
42.2k
  if (coff_section_data (abfd, section) == NULL)
1914
42.2k
    {
1915
42.2k
      amt = sizeof (struct coff_section_tdata);
1916
42.2k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
42.2k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
42.2k
    }
1921
1922
42.2k
  if (pei_section_data (abfd, section) == NULL)
1923
42.2k
    {
1924
42.2k
      amt = sizeof (struct pei_section_tdata);
1925
42.2k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
42.2k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
42.2k
    }
1930
42.2k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
42.2k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
42.2k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
42.2k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
6.53k
    {
1938
6.53k
      struct external_reloc dst;
1939
6.53k
      struct internal_reloc n;
1940
6.53k
      file_ptr oldpos = bfd_tell (abfd);
1941
6.53k
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
6.53k
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
6.53k
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
5.18k
  return;
1947
1948
1.35k
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
1.35k
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
1.35k
      if (n.r_vaddr < 0x10000)
1952
416
  {
1953
416
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
416
    bfd_set_error (bfd_error_bad_value);
1955
416
    return;
1956
416
  }
1957
934
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
934
      section->rel_filepos += relsz;
1959
934
    }
1960
35.7k
  else if (hdr->s_nreloc == 0xffff)
1961
1.34k
    _bfd_error_handler
1962
1.34k
      (_("%pB: warning: claims to have 0xffff relocs, without overflow"),
1963
1.34k
       abfd);
1964
42.2k
}
pei-x86_64.c:coff_set_alignment_hook
Line
Count
Source
1880
23.6k
{
1881
23.6k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
23.6k
  size_t amt;
1883
23.6k
  unsigned int alignment_power_const
1884
23.6k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
23.6k
  switch (alignment_power_const)
1887
23.6k
    {
1888
1.47k
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
1.58k
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
2.30k
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
2.41k
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
3.20k
    case IMAGE_SCN_ALIGN_512BYTES:
1893
3.22k
    case IMAGE_SCN_ALIGN_256BYTES:
1894
4.16k
    case IMAGE_SCN_ALIGN_128BYTES:
1895
4.52k
    case IMAGE_SCN_ALIGN_64BYTES:
1896
5.65k
    case IMAGE_SCN_ALIGN_32BYTES:
1897
5.77k
    case IMAGE_SCN_ALIGN_16BYTES:
1898
6.96k
    case IMAGE_SCN_ALIGN_8BYTES:
1899
7.21k
    case IMAGE_SCN_ALIGN_4BYTES:
1900
9.28k
    case IMAGE_SCN_ALIGN_2BYTES:
1901
9.39k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
9.39k
      section->alignment_power
1903
9.39k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
9.39k
      break;
1905
14.2k
    default:
1906
14.2k
      break;
1907
23.6k
    }
1908
1909
  /* In a PE image file, the s_paddr field holds the virtual size of a
1910
     section, while the s_size field holds the raw size.  We also keep
1911
     the original section flag value, since not every bit can be
1912
     mapped onto a generic BFD section bit.  */
1913
23.6k
  if (coff_section_data (abfd, section) == NULL)
1914
23.6k
    {
1915
23.6k
      amt = sizeof (struct coff_section_tdata);
1916
23.6k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
23.6k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
23.6k
    }
1921
1922
23.6k
  if (pei_section_data (abfd, section) == NULL)
1923
23.6k
    {
1924
23.6k
      amt = sizeof (struct pei_section_tdata);
1925
23.6k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
23.6k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
23.6k
    }
1930
23.6k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
23.6k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
23.6k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
23.6k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
2.96k
    {
1938
2.96k
      struct external_reloc dst;
1939
2.96k
      struct internal_reloc n;
1940
2.96k
      file_ptr oldpos = bfd_tell (abfd);
1941
2.96k
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
2.96k
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
2.96k
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
1.65k
  return;
1947
1948
1.31k
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
1.31k
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
1.31k
      if (n.r_vaddr < 0x10000)
1952
395
  {
1953
395
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
395
    bfd_set_error (bfd_error_bad_value);
1955
395
    return;
1956
395
  }
1957
917
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
917
      section->rel_filepos += relsz;
1959
917
    }
1960
20.6k
  else if (hdr->s_nreloc == 0xffff)
1961
0
    _bfd_error_handler
1962
0
      (_("%pB: warning: claims to have 0xffff relocs, without overflow"),
1963
0
       abfd);
1964
23.6k
}
pe-aarch64.c:coff_set_alignment_hook
Line
Count
Source
1880
35.8k
{
1881
35.8k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
35.8k
  size_t amt;
1883
35.8k
  unsigned int alignment_power_const
1884
35.8k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
35.8k
  switch (alignment_power_const)
1887
35.8k
    {
1888
21
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
22
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
6.04k
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
6.28k
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
9.26k
    case IMAGE_SCN_ALIGN_512BYTES:
1893
9.51k
    case IMAGE_SCN_ALIGN_256BYTES:
1894
10.4k
    case IMAGE_SCN_ALIGN_128BYTES:
1895
12.8k
    case IMAGE_SCN_ALIGN_64BYTES:
1896
13.3k
    case IMAGE_SCN_ALIGN_32BYTES:
1897
13.4k
    case IMAGE_SCN_ALIGN_16BYTES:
1898
13.4k
    case IMAGE_SCN_ALIGN_8BYTES:
1899
13.5k
    case IMAGE_SCN_ALIGN_4BYTES:
1900
13.9k
    case IMAGE_SCN_ALIGN_2BYTES:
1901
14.2k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
14.2k
      section->alignment_power
1903
14.2k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
14.2k
      break;
1905
21.6k
    default:
1906
21.6k
      break;
1907
35.8k
    }
1908
1909
  /* In a PE image file, the s_paddr field holds the virtual size of a
1910
     section, while the s_size field holds the raw size.  We also keep
1911
     the original section flag value, since not every bit can be
1912
     mapped onto a generic BFD section bit.  */
1913
35.8k
  if (coff_section_data (abfd, section) == NULL)
1914
35.8k
    {
1915
35.8k
      amt = sizeof (struct coff_section_tdata);
1916
35.8k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
35.8k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
35.8k
    }
1921
1922
35.8k
  if (pei_section_data (abfd, section) == NULL)
1923
35.8k
    {
1924
35.8k
      amt = sizeof (struct pei_section_tdata);
1925
35.8k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
35.8k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
35.8k
    }
1930
35.8k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
35.8k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
35.8k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
35.8k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
4.54k
    {
1938
4.54k
      struct external_reloc dst;
1939
4.54k
      struct internal_reloc n;
1940
4.54k
      file_ptr oldpos = bfd_tell (abfd);
1941
4.54k
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
4.54k
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
4.54k
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
3.82k
  return;
1947
1948
716
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
716
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
716
      if (n.r_vaddr < 0x10000)
1952
343
  {
1953
343
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
343
    bfd_set_error (bfd_error_bad_value);
1955
343
    return;
1956
343
  }
1957
373
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
373
      section->rel_filepos += relsz;
1959
373
    }
1960
31.3k
  else if (hdr->s_nreloc == 0xffff)
1961
478
    _bfd_error_handler
1962
478
      (_("%pB: warning: claims to have 0xffff relocs, without overflow"),
1963
478
       abfd);
1964
35.8k
}
pei-aarch64.c:coff_set_alignment_hook
Line
Count
Source
1880
10.4k
{
1881
10.4k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
10.4k
  size_t amt;
1883
10.4k
  unsigned int alignment_power_const
1884
10.4k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
10.4k
  switch (alignment_power_const)
1887
10.4k
    {
1888
114
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
117
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
322
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
324
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
1.01k
    case IMAGE_SCN_ALIGN_512BYTES:
1893
1.02k
    case IMAGE_SCN_ALIGN_256BYTES:
1894
1.04k
    case IMAGE_SCN_ALIGN_128BYTES:
1895
1.76k
    case IMAGE_SCN_ALIGN_64BYTES:
1896
2.35k
    case IMAGE_SCN_ALIGN_32BYTES:
1897
2.37k
    case IMAGE_SCN_ALIGN_16BYTES:
1898
3.19k
    case IMAGE_SCN_ALIGN_8BYTES:
1899
3.47k
    case IMAGE_SCN_ALIGN_4BYTES:
1900
3.50k
    case IMAGE_SCN_ALIGN_2BYTES:
1901
3.58k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
3.58k
      section->alignment_power
1903
3.58k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
3.58k
      break;
1905
6.87k
    default:
1906
6.87k
      break;
1907
10.4k
    }
1908
1909
  /* In a PE image file, the s_paddr field holds the virtual size of a
1910
     section, while the s_size field holds the raw size.  We also keep
1911
     the original section flag value, since not every bit can be
1912
     mapped onto a generic BFD section bit.  */
1913
10.4k
  if (coff_section_data (abfd, section) == NULL)
1914
10.4k
    {
1915
10.4k
      amt = sizeof (struct coff_section_tdata);
1916
10.4k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
10.4k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
10.4k
    }
1921
1922
10.4k
  if (pei_section_data (abfd, section) == NULL)
1923
10.4k
    {
1924
10.4k
      amt = sizeof (struct pei_section_tdata);
1925
10.4k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
10.4k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
10.4k
    }
1930
10.4k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
10.4k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
10.4k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
10.4k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
2.09k
    {
1938
2.09k
      struct external_reloc dst;
1939
2.09k
      struct internal_reloc n;
1940
2.09k
      file_ptr oldpos = bfd_tell (abfd);
1941
2.09k
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
2.09k
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
2.09k
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
1.16k
  return;
1947
1948
937
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
937
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
937
      if (n.r_vaddr < 0x10000)
1952
365
  {
1953
365
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
365
    bfd_set_error (bfd_error_bad_value);
1955
365
    return;
1956
365
  }
1957
572
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
572
      section->rel_filepos += relsz;
1959
572
    }
1960
8.35k
  else if (hdr->s_nreloc == 0xffff)
1961
0
    _bfd_error_handler
1962
0
      (_("%pB: warning: claims to have 0xffff relocs, without overflow"),
1963
0
       abfd);
1964
10.4k
}
pei-ia64.c:coff_set_alignment_hook
Line
Count
Source
1880
16.6k
{
1881
16.6k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
16.6k
  size_t amt;
1883
16.6k
  unsigned int alignment_power_const
1884
16.6k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
16.6k
  switch (alignment_power_const)
1887
16.6k
    {
1888
306
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
310
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
341
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
346
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
493
    case IMAGE_SCN_ALIGN_512BYTES:
1893
753
    case IMAGE_SCN_ALIGN_256BYTES:
1894
1.27k
    case IMAGE_SCN_ALIGN_128BYTES:
1895
1.82k
    case IMAGE_SCN_ALIGN_64BYTES:
1896
3.55k
    case IMAGE_SCN_ALIGN_32BYTES:
1897
3.56k
    case IMAGE_SCN_ALIGN_16BYTES:
1898
4.28k
    case IMAGE_SCN_ALIGN_8BYTES:
1899
4.28k
    case IMAGE_SCN_ALIGN_4BYTES:
1900
5.30k
    case IMAGE_SCN_ALIGN_2BYTES:
1901
5.46k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
5.46k
      section->alignment_power
1903
5.46k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
5.46k
      break;
1905
11.1k
    default:
1906
11.1k
      break;
1907
16.6k
    }
1908
1909
  /* In a PE image file, the s_paddr field holds the virtual size of a
1910
     section, while the s_size field holds the raw size.  We also keep
1911
     the original section flag value, since not every bit can be
1912
     mapped onto a generic BFD section bit.  */
1913
16.6k
  if (coff_section_data (abfd, section) == NULL)
1914
16.6k
    {
1915
16.6k
      amt = sizeof (struct coff_section_tdata);
1916
16.6k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
16.6k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
16.6k
    }
1921
1922
16.6k
  if (pei_section_data (abfd, section) == NULL)
1923
16.6k
    {
1924
16.6k
      amt = sizeof (struct pei_section_tdata);
1925
16.6k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
16.6k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
16.6k
    }
1930
16.6k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
16.6k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
16.6k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
16.6k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
3.19k
    {
1938
3.19k
      struct external_reloc dst;
1939
3.19k
      struct internal_reloc n;
1940
3.19k
      file_ptr oldpos = bfd_tell (abfd);
1941
3.19k
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
3.19k
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
3.19k
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
1.84k
  return;
1947
1948
1.34k
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
1.34k
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
1.34k
      if (n.r_vaddr < 0x10000)
1952
600
  {
1953
600
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
600
    bfd_set_error (bfd_error_bad_value);
1955
600
    return;
1956
600
  }
1957
744
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
744
      section->rel_filepos += relsz;
1959
744
    }
1960
13.4k
  else if (hdr->s_nreloc == 0xffff)
1961
0
    _bfd_error_handler
1962
0
      (_("%pB: warning: claims to have 0xffff relocs, without overflow"),
1963
0
       abfd);
1964
16.6k
}
pei-loongarch64.c:coff_set_alignment_hook
Line
Count
Source
1880
14.1k
{
1881
14.1k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
14.1k
  size_t amt;
1883
14.1k
  unsigned int alignment_power_const
1884
14.1k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
14.1k
  switch (alignment_power_const)
1887
14.1k
    {
1888
3.07k
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
3.09k
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
3.38k
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
3.65k
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
4.27k
    case IMAGE_SCN_ALIGN_512BYTES:
1893
4.28k
    case IMAGE_SCN_ALIGN_256BYTES:
1894
4.63k
    case IMAGE_SCN_ALIGN_128BYTES:
1895
5.02k
    case IMAGE_SCN_ALIGN_64BYTES:
1896
5.67k
    case IMAGE_SCN_ALIGN_32BYTES:
1897
5.91k
    case IMAGE_SCN_ALIGN_16BYTES:
1898
6.05k
    case IMAGE_SCN_ALIGN_8BYTES:
1899
6.07k
    case IMAGE_SCN_ALIGN_4BYTES:
1900
6.63k
    case IMAGE_SCN_ALIGN_2BYTES:
1901
6.79k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
6.79k
      section->alignment_power
1903
6.79k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
6.79k
      break;
1905
7.32k
    default:
1906
7.32k
      break;
1907
14.1k
    }
1908
1909
  /* In a PE image file, the s_paddr field holds the virtual size of a
1910
     section, while the s_size field holds the raw size.  We also keep
1911
     the original section flag value, since not every bit can be
1912
     mapped onto a generic BFD section bit.  */
1913
14.1k
  if (coff_section_data (abfd, section) == NULL)
1914
14.1k
    {
1915
14.1k
      amt = sizeof (struct coff_section_tdata);
1916
14.1k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
14.1k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
14.1k
    }
1921
1922
14.1k
  if (pei_section_data (abfd, section) == NULL)
1923
14.1k
    {
1924
14.1k
      amt = sizeof (struct pei_section_tdata);
1925
14.1k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
14.1k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
14.1k
    }
1930
14.1k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
14.1k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
14.1k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
14.1k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
3.13k
    {
1938
3.13k
      struct external_reloc dst;
1939
3.13k
      struct internal_reloc n;
1940
3.13k
      file_ptr oldpos = bfd_tell (abfd);
1941
3.13k
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
3.13k
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
3.13k
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
2.18k
  return;
1947
1948
958
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
958
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
958
      if (n.r_vaddr < 0x10000)
1952
342
  {
1953
342
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
342
    bfd_set_error (bfd_error_bad_value);
1955
342
    return;
1956
342
  }
1957
616
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
616
      section->rel_filepos += relsz;
1959
616
    }
1960
10.9k
  else if (hdr->s_nreloc == 0xffff)
1961
0
    _bfd_error_handler
1962
0
      (_("%pB: warning: claims to have 0xffff relocs, without overflow"),
1963
0
       abfd);
1964
14.1k
}
pe-arm-wince.c:coff_set_alignment_hook
Line
Count
Source
1880
10.9k
{
1881
10.9k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
10.9k
  size_t amt;
1883
10.9k
  unsigned int alignment_power_const
1884
10.9k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
10.9k
  switch (alignment_power_const)
1887
10.9k
    {
1888
365
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
365
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
392
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
399
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
1.54k
    case IMAGE_SCN_ALIGN_512BYTES:
1893
1.64k
    case IMAGE_SCN_ALIGN_256BYTES:
1894
2.27k
    case IMAGE_SCN_ALIGN_128BYTES:
1895
2.38k
    case IMAGE_SCN_ALIGN_64BYTES:
1896
2.53k
    case IMAGE_SCN_ALIGN_32BYTES:
1897
2.64k
    case IMAGE_SCN_ALIGN_16BYTES:
1898
2.86k
    case IMAGE_SCN_ALIGN_8BYTES:
1899
2.98k
    case IMAGE_SCN_ALIGN_4BYTES:
1900
3.24k
    case IMAGE_SCN_ALIGN_2BYTES:
1901
3.45k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
3.45k
      section->alignment_power
1903
3.45k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
3.45k
      break;
1905
7.54k
    default:
1906
7.54k
      break;
1907
10.9k
    }
1908
1909
  /* In a PE image file, the s_paddr field holds the virtual size of a
1910
     section, while the s_size field holds the raw size.  We also keep
1911
     the original section flag value, since not every bit can be
1912
     mapped onto a generic BFD section bit.  */
1913
10.9k
  if (coff_section_data (abfd, section) == NULL)
1914
10.9k
    {
1915
10.9k
      amt = sizeof (struct coff_section_tdata);
1916
10.9k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
10.9k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
10.9k
    }
1921
1922
10.9k
  if (pei_section_data (abfd, section) == NULL)
1923
10.9k
    {
1924
10.9k
      amt = sizeof (struct pei_section_tdata);
1925
10.9k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
10.9k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
10.9k
    }
1930
10.9k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
10.9k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
10.9k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
10.9k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
1.88k
    {
1938
1.88k
      struct external_reloc dst;
1939
1.88k
      struct internal_reloc n;
1940
1.88k
      file_ptr oldpos = bfd_tell (abfd);
1941
1.88k
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
1.88k
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
1.88k
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
1.01k
  return;
1947
1948
868
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
868
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
868
      if (n.r_vaddr < 0x10000)
1952
116
  {
1953
116
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
116
    bfd_set_error (bfd_error_bad_value);
1955
116
    return;
1956
116
  }
1957
752
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
752
      section->rel_filepos += relsz;
1959
752
    }
1960
9.11k
  else if (hdr->s_nreloc == 0xffff)
1961
424
    _bfd_error_handler
1962
424
      (_("%pB: warning: claims to have 0xffff relocs, without overflow"),
1963
424
       abfd);
1964
10.9k
}
pe-arm.c:coff_set_alignment_hook
Line
Count
Source
1880
10.9k
{
1881
10.9k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
10.9k
  size_t amt;
1883
10.9k
  unsigned int alignment_power_const
1884
10.9k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
10.9k
  switch (alignment_power_const)
1887
10.9k
    {
1888
365
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
365
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
392
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
399
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
1.54k
    case IMAGE_SCN_ALIGN_512BYTES:
1893
1.64k
    case IMAGE_SCN_ALIGN_256BYTES:
1894
2.27k
    case IMAGE_SCN_ALIGN_128BYTES:
1895
2.38k
    case IMAGE_SCN_ALIGN_64BYTES:
1896
2.53k
    case IMAGE_SCN_ALIGN_32BYTES:
1897
2.64k
    case IMAGE_SCN_ALIGN_16BYTES:
1898
2.86k
    case IMAGE_SCN_ALIGN_8BYTES:
1899
2.98k
    case IMAGE_SCN_ALIGN_4BYTES:
1900
3.24k
    case IMAGE_SCN_ALIGN_2BYTES:
1901
3.45k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
3.45k
      section->alignment_power
1903
3.45k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
3.45k
      break;
1905
7.54k
    default:
1906
7.54k
      break;
1907
10.9k
    }
1908
1909
  /* In a PE image file, the s_paddr field holds the virtual size of a
1910
     section, while the s_size field holds the raw size.  We also keep
1911
     the original section flag value, since not every bit can be
1912
     mapped onto a generic BFD section bit.  */
1913
10.9k
  if (coff_section_data (abfd, section) == NULL)
1914
10.9k
    {
1915
10.9k
      amt = sizeof (struct coff_section_tdata);
1916
10.9k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
10.9k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
10.9k
    }
1921
1922
10.9k
  if (pei_section_data (abfd, section) == NULL)
1923
10.9k
    {
1924
10.9k
      amt = sizeof (struct pei_section_tdata);
1925
10.9k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
10.9k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
10.9k
    }
1930
10.9k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
10.9k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
10.9k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
10.9k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
1.88k
    {
1938
1.88k
      struct external_reloc dst;
1939
1.88k
      struct internal_reloc n;
1940
1.88k
      file_ptr oldpos = bfd_tell (abfd);
1941
1.88k
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
1.88k
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
1.88k
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
1.01k
  return;
1947
1948
868
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
868
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
868
      if (n.r_vaddr < 0x10000)
1952
116
  {
1953
116
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
116
    bfd_set_error (bfd_error_bad_value);
1955
116
    return;
1956
116
  }
1957
752
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
752
      section->rel_filepos += relsz;
1959
752
    }
1960
9.11k
  else if (hdr->s_nreloc == 0xffff)
1961
424
    _bfd_error_handler
1962
424
      (_("%pB: warning: claims to have 0xffff relocs, without overflow"),
1963
424
       abfd);
1964
10.9k
}
pe-i386.c:coff_set_alignment_hook
Line
Count
Source
1880
16.5k
{
1881
16.5k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
16.5k
  size_t amt;
1883
16.5k
  unsigned int alignment_power_const
1884
16.5k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
16.5k
  switch (alignment_power_const)
1887
16.5k
    {
1888
476
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
484
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
532
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
1.05k
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
1.41k
    case IMAGE_SCN_ALIGN_512BYTES:
1893
1.45k
    case IMAGE_SCN_ALIGN_256BYTES:
1894
1.58k
    case IMAGE_SCN_ALIGN_128BYTES:
1895
1.96k
    case IMAGE_SCN_ALIGN_64BYTES:
1896
4.03k
    case IMAGE_SCN_ALIGN_32BYTES:
1897
4.15k
    case IMAGE_SCN_ALIGN_16BYTES:
1898
5.05k
    case IMAGE_SCN_ALIGN_8BYTES:
1899
5.58k
    case IMAGE_SCN_ALIGN_4BYTES:
1900
5.95k
    case IMAGE_SCN_ALIGN_2BYTES:
1901
7.01k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
7.01k
      section->alignment_power
1903
7.01k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
7.01k
      break;
1905
9.57k
    default:
1906
9.57k
      break;
1907
16.5k
    }
1908
1909
  /* In a PE image file, the s_paddr field holds the virtual size of a
1910
     section, while the s_size field holds the raw size.  We also keep
1911
     the original section flag value, since not every bit can be
1912
     mapped onto a generic BFD section bit.  */
1913
16.5k
  if (coff_section_data (abfd, section) == NULL)
1914
16.5k
    {
1915
16.5k
      amt = sizeof (struct coff_section_tdata);
1916
16.5k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
16.5k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
16.5k
    }
1921
1922
16.5k
  if (pei_section_data (abfd, section) == NULL)
1923
16.5k
    {
1924
16.5k
      amt = sizeof (struct pei_section_tdata);
1925
16.5k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
16.5k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
16.5k
    }
1930
16.5k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
16.5k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
16.5k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
16.5k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
2.77k
    {
1938
2.77k
      struct external_reloc dst;
1939
2.77k
      struct internal_reloc n;
1940
2.77k
      file_ptr oldpos = bfd_tell (abfd);
1941
2.77k
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
2.77k
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
2.77k
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
1.64k
  return;
1947
1948
1.13k
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
1.13k
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
1.13k
      if (n.r_vaddr < 0x10000)
1952
543
  {
1953
543
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
543
    bfd_set_error (bfd_error_bad_value);
1955
543
    return;
1956
543
  }
1957
588
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
588
      section->rel_filepos += relsz;
1959
588
    }
1960
13.8k
  else if (hdr->s_nreloc == 0xffff)
1961
460
    _bfd_error_handler
1962
460
      (_("%pB: warning: claims to have 0xffff relocs, without overflow"),
1963
460
       abfd);
1964
16.5k
}
pe-mcore.c:coff_set_alignment_hook
Line
Count
Source
1880
10.9k
{
1881
10.9k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
10.9k
  size_t amt;
1883
10.9k
  unsigned int alignment_power_const
1884
10.9k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
10.9k
  switch (alignment_power_const)
1887
10.9k
    {
1888
39
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
40
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
419
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
632
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
1.42k
    case IMAGE_SCN_ALIGN_512BYTES:
1893
1.67k
    case IMAGE_SCN_ALIGN_256BYTES:
1894
2.27k
    case IMAGE_SCN_ALIGN_128BYTES:
1895
2.27k
    case IMAGE_SCN_ALIGN_64BYTES:
1896
2.86k
    case IMAGE_SCN_ALIGN_32BYTES:
1897
3.00k
    case IMAGE_SCN_ALIGN_16BYTES:
1898
3.65k
    case IMAGE_SCN_ALIGN_8BYTES:
1899
3.76k
    case IMAGE_SCN_ALIGN_4BYTES:
1900
4.14k
    case IMAGE_SCN_ALIGN_2BYTES:
1901
4.25k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
4.25k
      section->alignment_power
1903
4.25k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
4.25k
      break;
1905
6.71k
    default:
1906
6.71k
      break;
1907
10.9k
    }
1908
1909
  /* In a PE image file, the s_paddr field holds the virtual size of a
1910
     section, while the s_size field holds the raw size.  We also keep
1911
     the original section flag value, since not every bit can be
1912
     mapped onto a generic BFD section bit.  */
1913
10.9k
  if (coff_section_data (abfd, section) == NULL)
1914
10.9k
    {
1915
10.9k
      amt = sizeof (struct coff_section_tdata);
1916
10.9k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
10.9k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
10.9k
    }
1921
1922
10.9k
  if (pei_section_data (abfd, section) == NULL)
1923
10.9k
    {
1924
10.9k
      amt = sizeof (struct pei_section_tdata);
1925
10.9k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
10.9k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
10.9k
    }
1930
10.9k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
10.9k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
10.9k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
10.9k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
2.35k
    {
1938
2.35k
      struct external_reloc dst;
1939
2.35k
      struct internal_reloc n;
1940
2.35k
      file_ptr oldpos = bfd_tell (abfd);
1941
2.35k
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
2.35k
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
2.35k
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
1.75k
  return;
1947
1948
598
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
598
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
598
      if (n.r_vaddr < 0x10000)
1952
105
  {
1953
105
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
105
    bfd_set_error (bfd_error_bad_value);
1955
105
    return;
1956
105
  }
1957
493
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
493
      section->rel_filepos += relsz;
1959
493
    }
1960
8.61k
  else if (hdr->s_nreloc == 0xffff)
1961
230
    _bfd_error_handler
1962
230
      (_("%pB: warning: claims to have 0xffff relocs, without overflow"),
1963
230
       abfd);
1964
10.9k
}
pe-sh.c:coff_set_alignment_hook
Line
Count
Source
1880
20.3k
{
1881
20.3k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
20.3k
  size_t amt;
1883
20.3k
  unsigned int alignment_power_const
1884
20.3k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
20.3k
  switch (alignment_power_const)
1887
20.3k
    {
1888
1.65k
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
1.97k
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
1.99k
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
2.01k
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
2.56k
    case IMAGE_SCN_ALIGN_512BYTES:
1893
2.57k
    case IMAGE_SCN_ALIGN_256BYTES:
1894
3.19k
    case IMAGE_SCN_ALIGN_128BYTES:
1895
3.62k
    case IMAGE_SCN_ALIGN_64BYTES:
1896
5.72k
    case IMAGE_SCN_ALIGN_32BYTES:
1897
5.84k
    case IMAGE_SCN_ALIGN_16BYTES:
1898
5.92k
    case IMAGE_SCN_ALIGN_8BYTES:
1899
6.31k
    case IMAGE_SCN_ALIGN_4BYTES:
1900
8.98k
    case IMAGE_SCN_ALIGN_2BYTES:
1901
9.93k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
9.93k
      section->alignment_power
1903
9.93k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
9.93k
      break;
1905
10.4k
    default:
1906
10.4k
      break;
1907
20.3k
    }
1908
1909
  /* In a PE image file, the s_paddr field holds the virtual size of a
1910
     section, while the s_size field holds the raw size.  We also keep
1911
     the original section flag value, since not every bit can be
1912
     mapped onto a generic BFD section bit.  */
1913
20.3k
  if (coff_section_data (abfd, section) == NULL)
1914
20.3k
    {
1915
20.3k
      amt = sizeof (struct coff_section_tdata);
1916
20.3k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
20.3k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
20.3k
    }
1921
1922
20.3k
  if (pei_section_data (abfd, section) == NULL)
1923
20.3k
    {
1924
20.3k
      amt = sizeof (struct pei_section_tdata);
1925
20.3k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
20.3k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
20.3k
    }
1930
20.3k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
20.3k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
20.3k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
20.3k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
3.94k
    {
1938
3.94k
      struct external_reloc dst;
1939
3.94k
      struct internal_reloc n;
1940
3.94k
      file_ptr oldpos = bfd_tell (abfd);
1941
3.94k
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
3.94k
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
3.94k
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
2.95k
  return;
1947
1948
989
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
989
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
989
      if (n.r_vaddr < 0x10000)
1952
316
  {
1953
316
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
316
    bfd_set_error (bfd_error_bad_value);
1955
316
    return;
1956
316
  }
1957
673
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
673
      section->rel_filepos += relsz;
1959
673
    }
1960
16.4k
  else if (hdr->s_nreloc == 0xffff)
1961
244
    _bfd_error_handler
1962
244
      (_("%pB: warning: claims to have 0xffff relocs, without overflow"),
1963
244
       abfd);
1964
20.3k
}
pei-arm-wince.c:coff_set_alignment_hook
Line
Count
Source
1880
23.1k
{
1881
23.1k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
23.1k
  size_t amt;
1883
23.1k
  unsigned int alignment_power_const
1884
23.1k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
23.1k
  switch (alignment_power_const)
1887
23.1k
    {
1888
530
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
1.43k
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
2.57k
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
2.82k
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
3.28k
    case IMAGE_SCN_ALIGN_512BYTES:
1893
3.78k
    case IMAGE_SCN_ALIGN_256BYTES:
1894
4.40k
    case IMAGE_SCN_ALIGN_128BYTES:
1895
4.63k
    case IMAGE_SCN_ALIGN_64BYTES:
1896
5.08k
    case IMAGE_SCN_ALIGN_32BYTES:
1897
5.30k
    case IMAGE_SCN_ALIGN_16BYTES:
1898
5.73k
    case IMAGE_SCN_ALIGN_8BYTES:
1899
6.46k
    case IMAGE_SCN_ALIGN_4BYTES:
1900
8.61k
    case IMAGE_SCN_ALIGN_2BYTES:
1901
8.63k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
8.63k
      section->alignment_power
1903
8.63k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
8.63k
      break;
1905
14.4k
    default:
1906
14.4k
      break;
1907
23.1k
    }
1908
1909
  /* In a PE image file, the s_paddr field holds the virtual size of a
1910
     section, while the s_size field holds the raw size.  We also keep
1911
     the original section flag value, since not every bit can be
1912
     mapped onto a generic BFD section bit.  */
1913
23.1k
  if (coff_section_data (abfd, section) == NULL)
1914
23.1k
    {
1915
23.1k
      amt = sizeof (struct coff_section_tdata);
1916
23.1k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
23.1k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
23.1k
    }
1921
1922
23.1k
  if (pei_section_data (abfd, section) == NULL)
1923
23.1k
    {
1924
23.1k
      amt = sizeof (struct pei_section_tdata);
1925
23.1k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
23.1k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
23.1k
    }
1930
23.1k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
23.1k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
23.1k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
23.1k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
5.96k
    {
1938
5.96k
      struct external_reloc dst;
1939
5.96k
      struct internal_reloc n;
1940
5.96k
      file_ptr oldpos = bfd_tell (abfd);
1941
5.96k
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
5.96k
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
5.96k
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
3.69k
  return;
1947
1948
2.26k
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
2.26k
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
2.26k
      if (n.r_vaddr < 0x10000)
1952
1.28k
  {
1953
1.28k
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
1.28k
    bfd_set_error (bfd_error_bad_value);
1955
1.28k
    return;
1956
1.28k
  }
1957
987
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
987
      section->rel_filepos += relsz;
1959
987
    }
1960
17.1k
  else if (hdr->s_nreloc == 0xffff)
1961
0
    _bfd_error_handler
1962
0
      (_("%pB: warning: claims to have 0xffff relocs, without overflow"),
1963
0
       abfd);
1964
23.1k
}
pei-arm.c:coff_set_alignment_hook
Line
Count
Source
1880
28.4k
{
1881
28.4k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
28.4k
  size_t amt;
1883
28.4k
  unsigned int alignment_power_const
1884
28.4k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
28.4k
  switch (alignment_power_const)
1887
28.4k
    {
1888
534
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
1.57k
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
2.23k
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
2.39k
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
3.39k
    case IMAGE_SCN_ALIGN_512BYTES:
1893
4.08k
    case IMAGE_SCN_ALIGN_256BYTES:
1894
4.46k
    case IMAGE_SCN_ALIGN_128BYTES:
1895
4.69k
    case IMAGE_SCN_ALIGN_64BYTES:
1896
4.94k
    case IMAGE_SCN_ALIGN_32BYTES:
1897
5.10k
    case IMAGE_SCN_ALIGN_16BYTES:
1898
5.63k
    case IMAGE_SCN_ALIGN_8BYTES:
1899
6.79k
    case IMAGE_SCN_ALIGN_4BYTES:
1900
9.23k
    case IMAGE_SCN_ALIGN_2BYTES:
1901
9.34k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
9.34k
      section->alignment_power
1903
9.34k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
9.34k
      break;
1905
19.0k
    default:
1906
19.0k
      break;
1907
28.4k
    }
1908
1909
  /* In a PE image file, the s_paddr field holds the virtual size of a
1910
     section, while the s_size field holds the raw size.  We also keep
1911
     the original section flag value, since not every bit can be
1912
     mapped onto a generic BFD section bit.  */
1913
28.4k
  if (coff_section_data (abfd, section) == NULL)
1914
28.4k
    {
1915
28.4k
      amt = sizeof (struct coff_section_tdata);
1916
28.4k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
28.4k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
28.4k
    }
1921
1922
28.4k
  if (pei_section_data (abfd, section) == NULL)
1923
28.4k
    {
1924
28.4k
      amt = sizeof (struct pei_section_tdata);
1925
28.4k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
28.4k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
28.4k
    }
1930
28.4k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
28.4k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
28.4k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
28.4k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
5.67k
    {
1938
5.67k
      struct external_reloc dst;
1939
5.67k
      struct internal_reloc n;
1940
5.67k
      file_ptr oldpos = bfd_tell (abfd);
1941
5.67k
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
5.67k
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
5.67k
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
3.83k
  return;
1947
1948
1.84k
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
1.84k
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
1.84k
      if (n.r_vaddr < 0x10000)
1952
708
  {
1953
708
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
708
    bfd_set_error (bfd_error_bad_value);
1955
708
    return;
1956
708
  }
1957
1.13k
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
1.13k
      section->rel_filepos += relsz;
1959
1.13k
    }
1960
22.7k
  else if (hdr->s_nreloc == 0xffff)
1961
0
    _bfd_error_handler
1962
0
      (_("%pB: warning: claims to have 0xffff relocs, without overflow"),
1963
0
       abfd);
1964
28.4k
}
pei-mcore.c:coff_set_alignment_hook
Line
Count
Source
1880
25.3k
{
1881
25.3k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
25.3k
  size_t amt;
1883
25.3k
  unsigned int alignment_power_const
1884
25.3k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
25.3k
  switch (alignment_power_const)
1887
25.3k
    {
1888
146
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
560
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
712
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
739
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
761
    case IMAGE_SCN_ALIGN_512BYTES:
1893
783
    case IMAGE_SCN_ALIGN_256BYTES:
1894
927
    case IMAGE_SCN_ALIGN_128BYTES:
1895
1.14k
    case IMAGE_SCN_ALIGN_64BYTES:
1896
2.57k
    case IMAGE_SCN_ALIGN_32BYTES:
1897
2.92k
    case IMAGE_SCN_ALIGN_16BYTES:
1898
4.11k
    case IMAGE_SCN_ALIGN_8BYTES:
1899
4.86k
    case IMAGE_SCN_ALIGN_4BYTES:
1900
7.33k
    case IMAGE_SCN_ALIGN_2BYTES:
1901
7.51k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
7.51k
      section->alignment_power
1903
7.51k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
7.51k
      break;
1905
17.8k
    default:
1906
17.8k
      break;
1907
25.3k
    }
1908
1909
  /* In a PE image file, the s_paddr field holds the virtual size of a
1910
     section, while the s_size field holds the raw size.  We also keep
1911
     the original section flag value, since not every bit can be
1912
     mapped onto a generic BFD section bit.  */
1913
25.3k
  if (coff_section_data (abfd, section) == NULL)
1914
25.3k
    {
1915
25.3k
      amt = sizeof (struct coff_section_tdata);
1916
25.3k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
25.3k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
25.3k
    }
1921
1922
25.3k
  if (pei_section_data (abfd, section) == NULL)
1923
25.3k
    {
1924
25.3k
      amt = sizeof (struct pei_section_tdata);
1925
25.3k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
25.3k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
25.3k
    }
1930
25.3k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
25.3k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
25.3k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
25.3k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
5.33k
    {
1938
5.33k
      struct external_reloc dst;
1939
5.33k
      struct internal_reloc n;
1940
5.33k
      file_ptr oldpos = bfd_tell (abfd);
1941
5.33k
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
5.33k
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
5.33k
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
3.47k
  return;
1947
1948
1.85k
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
1.85k
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
1.85k
      if (n.r_vaddr < 0x10000)
1952
634
  {
1953
634
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
634
    bfd_set_error (bfd_error_bad_value);
1955
634
    return;
1956
634
  }
1957
1.22k
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
1.22k
      section->rel_filepos += relsz;
1959
1.22k
    }
1960
20.0k
  else if (hdr->s_nreloc == 0xffff)
1961
0
    _bfd_error_handler
1962
0
      (_("%pB: warning: claims to have 0xffff relocs, without overflow"),
1963
0
       abfd);
1964
25.3k
}
pei-sh.c:coff_set_alignment_hook
Line
Count
Source
1880
28.2k
{
1881
28.2k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
28.2k
  size_t amt;
1883
28.2k
  unsigned int alignment_power_const
1884
28.2k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
28.2k
  switch (alignment_power_const)
1887
28.2k
    {
1888
568
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
576
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
589
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
599
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
1.20k
    case IMAGE_SCN_ALIGN_512BYTES:
1893
1.55k
    case IMAGE_SCN_ALIGN_256BYTES:
1894
1.57k
    case IMAGE_SCN_ALIGN_128BYTES:
1895
1.82k
    case IMAGE_SCN_ALIGN_64BYTES:
1896
5.00k
    case IMAGE_SCN_ALIGN_32BYTES:
1897
6.04k
    case IMAGE_SCN_ALIGN_16BYTES:
1898
7.00k
    case IMAGE_SCN_ALIGN_8BYTES:
1899
7.59k
    case IMAGE_SCN_ALIGN_4BYTES:
1900
8.26k
    case IMAGE_SCN_ALIGN_2BYTES:
1901
8.73k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
8.73k
      section->alignment_power
1903
8.73k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
8.73k
      break;
1905
19.4k
    default:
1906
19.4k
      break;
1907
28.2k
    }
1908
1909
  /* In a PE image file, the s_paddr field holds the virtual size of a
1910
     section, while the s_size field holds the raw size.  We also keep
1911
     the original section flag value, since not every bit can be
1912
     mapped onto a generic BFD section bit.  */
1913
28.2k
  if (coff_section_data (abfd, section) == NULL)
1914
28.2k
    {
1915
28.2k
      amt = sizeof (struct coff_section_tdata);
1916
28.2k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
28.2k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
28.2k
    }
1921
1922
28.2k
  if (pei_section_data (abfd, section) == NULL)
1923
28.2k
    {
1924
28.2k
      amt = sizeof (struct pei_section_tdata);
1925
28.2k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
28.2k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
28.2k
    }
1930
28.2k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
28.2k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
28.2k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
28.2k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
2.86k
    {
1938
2.86k
      struct external_reloc dst;
1939
2.86k
      struct internal_reloc n;
1940
2.86k
      file_ptr oldpos = bfd_tell (abfd);
1941
2.86k
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
2.86k
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
2.86k
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
1.65k
  return;
1947
1948
1.21k
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
1.21k
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
1.21k
      if (n.r_vaddr < 0x10000)
1952
356
  {
1953
356
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
356
    bfd_set_error (bfd_error_bad_value);
1955
356
    return;
1956
356
  }
1957
858
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
858
      section->rel_filepos += relsz;
1959
858
    }
1960
25.3k
  else if (hdr->s_nreloc == 0xffff)
1961
0
    _bfd_error_handler
1962
0
      (_("%pB: warning: claims to have 0xffff relocs, without overflow"),
1963
0
       abfd);
1964
28.2k
}
1965
#undef ALIGN_SET
1966
#undef ELIFALIGN_SET
1967
1968
#else /* ! COFF_WITH_PE */
1969
#ifdef RS6000COFF_C
1970
1971
/* We grossly abuse this function to handle XCOFF overflow headers.
1972
   When we see one, we correct the reloc and line number counts in the
1973
   real header, and remove the section we just created.  */
1974
1975
static void
1976
coff_set_alignment_hook (bfd *abfd, asection *section, void * scnhdr)
1977
4.60M
{
1978
4.60M
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1979
4.60M
  asection *real_sec;
1980
1981
4.60M
  if ((hdr->s_flags & STYP_OVRFLO) == 0)
1982
3.86M
    return;
1983
1984
739k
  real_sec = coff_section_from_bfd_index (abfd, (int) hdr->s_nreloc);
1985
739k
  if (real_sec == NULL)
1986
0
    return;
1987
1988
739k
  real_sec->reloc_count = hdr->s_paddr;
1989
739k
  real_sec->lineno_count = hdr->s_vaddr;
1990
1991
739k
  if (!bfd_section_removed_from_list (abfd, section))
1992
739k
    {
1993
739k
      bfd_section_list_remove (abfd, section);
1994
739k
      --abfd->section_count;
1995
739k
    }
1996
739k
}
coff64-rs6000.c:coff_set_alignment_hook
Line
Count
Source
1977
871k
{
1978
871k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1979
871k
  asection *real_sec;
1980
1981
871k
  if ((hdr->s_flags & STYP_OVRFLO) == 0)
1982
746k
    return;
1983
1984
124k
  real_sec = coff_section_from_bfd_index (abfd, (int) hdr->s_nreloc);
1985
124k
  if (real_sec == NULL)
1986
0
    return;
1987
1988
124k
  real_sec->reloc_count = hdr->s_paddr;
1989
124k
  real_sec->lineno_count = hdr->s_vaddr;
1990
1991
124k
  if (!bfd_section_removed_from_list (abfd, section))
1992
124k
    {
1993
124k
      bfd_section_list_remove (abfd, section);
1994
124k
      --abfd->section_count;
1995
124k
    }
1996
124k
}
coff-rs6000.c:coff_set_alignment_hook
Line
Count
Source
1977
3.72M
{
1978
3.72M
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1979
3.72M
  asection *real_sec;
1980
1981
3.72M
  if ((hdr->s_flags & STYP_OVRFLO) == 0)
1982
3.11M
    return;
1983
1984
615k
  real_sec = coff_section_from_bfd_index (abfd, (int) hdr->s_nreloc);
1985
615k
  if (real_sec == NULL)
1986
0
    return;
1987
1988
615k
  real_sec->reloc_count = hdr->s_paddr;
1989
615k
  real_sec->lineno_count = hdr->s_vaddr;
1990
1991
615k
  if (!bfd_section_removed_from_list (abfd, section))
1992
615k
    {
1993
615k
      bfd_section_list_remove (abfd, section);
1994
615k
      --abfd->section_count;
1995
615k
    }
1996
615k
}
1997
1998
#else /* ! RS6000COFF_C */
1999
#if defined (COFF_GO32_EXE) || defined (COFF_GO32)
2000
2001
static void
2002
coff_set_alignment_hook (bfd * abfd, asection * section, void * scnhdr)
2003
357k
{
2004
357k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
2005
2006
  /* Check for extended relocs.  */
2007
357k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
2008
99.5k
    {
2009
99.5k
      struct external_reloc dst;
2010
99.5k
      struct internal_reloc n;
2011
99.5k
      const file_ptr oldpos = bfd_tell (abfd);
2012
99.5k
      const bfd_size_type relsz = bfd_coff_relsz (abfd);
2013
2014
99.5k
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
2015
0
  return;
2016
99.5k
      if (bfd_read (& dst, relsz, abfd) != relsz)
2017
80.8k
  return;
2018
2019
18.7k
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
2020
18.7k
      if (bfd_seek (abfd, oldpos, 0) != 0)
2021
0
  return;
2022
18.7k
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
2023
18.7k
      section->rel_filepos += relsz;
2024
18.7k
    }
2025
257k
  else if (hdr->s_nreloc == 0xffff)
2026
4.49k
    _bfd_error_handler
2027
4.49k
      (_("%pB: warning: claims to have 0xffff relocs, without overflow"),
2028
4.49k
       abfd);
2029
357k
}
coff-go32.c:coff_set_alignment_hook
Line
Count
Source
2003
342k
{
2004
342k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
2005
2006
  /* Check for extended relocs.  */
2007
342k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
2008
95.6k
    {
2009
95.6k
      struct external_reloc dst;
2010
95.6k
      struct internal_reloc n;
2011
95.6k
      const file_ptr oldpos = bfd_tell (abfd);
2012
95.6k
      const bfd_size_type relsz = bfd_coff_relsz (abfd);
2013
2014
95.6k
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
2015
0
  return;
2016
95.6k
      if (bfd_read (& dst, relsz, abfd) != relsz)
2017
77.8k
  return;
2018
2019
17.7k
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
2020
17.7k
      if (bfd_seek (abfd, oldpos, 0) != 0)
2021
0
  return;
2022
17.7k
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
2023
17.7k
      section->rel_filepos += relsz;
2024
17.7k
    }
2025
247k
  else if (hdr->s_nreloc == 0xffff)
2026
3.96k
    _bfd_error_handler
2027
3.96k
      (_("%pB: warning: claims to have 0xffff relocs, without overflow"),
2028
3.96k
       abfd);
2029
342k
}
coff-stgo32.c:coff_set_alignment_hook
Line
Count
Source
2003
14.4k
{
2004
14.4k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
2005
2006
  /* Check for extended relocs.  */
2007
14.4k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
2008
3.90k
    {
2009
3.90k
      struct external_reloc dst;
2010
3.90k
      struct internal_reloc n;
2011
3.90k
      const file_ptr oldpos = bfd_tell (abfd);
2012
3.90k
      const bfd_size_type relsz = bfd_coff_relsz (abfd);
2013
2014
3.90k
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
2015
0
  return;
2016
3.90k
      if (bfd_read (& dst, relsz, abfd) != relsz)
2017
2.98k
  return;
2018
2019
919
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
2020
919
      if (bfd_seek (abfd, oldpos, 0) != 0)
2021
0
  return;
2022
919
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
2023
919
      section->rel_filepos += relsz;
2024
919
    }
2025
10.5k
  else if (hdr->s_nreloc == 0xffff)
2026
523
    _bfd_error_handler
2027
523
      (_("%pB: warning: claims to have 0xffff relocs, without overflow"),
2028
523
       abfd);
2029
14.4k
}
2030
2031
#else /* ! COFF_GO32_EXE && ! COFF_GO32 */
2032
2033
static void
2034
coff_set_alignment_hook (bfd *abfd ATTRIBUTE_UNUSED,
2035
       asection *section ATTRIBUTE_UNUSED,
2036
       void *scnhdr ATTRIBUTE_UNUSED)
2037
8.38M
{
2038
8.38M
}
coff-x86_64.c:coff_set_alignment_hook
Line
Count
Source
2037
3.19M
{
2038
3.19M
}
cf-i386lynx.c:coff_set_alignment_hook
Line
Count
Source
2037
400k
{
2038
400k
}
coff-i386.c:coff_set_alignment_hook
Line
Count
Source
2037
386k
{
2038
386k
}
coff-sh.c:coff_set_alignment_hook
Line
Count
Source
2037
2.81M
{
2038
2.81M
}
coff-tic30.c:coff_set_alignment_hook
Line
Count
Source
2037
1.22M
{
2038
1.22M
}
coff-z8k.c:coff_set_alignment_hook
Line
Count
Source
2037
365k
{
2038
365k
}
2039
2040
#endif /* ! COFF_GO32_EXE && ! COFF_GO32 */
2041
#endif /* ! RS6000COFF_C */
2042
#endif /* ! COFF_WITH_PE */
2043
#endif /* ! COFF_ALIGN_IN_SECTION_HEADER */
2044
2045
#ifndef coff_mkobject
2046
2047
static bool
2048
coff_mkobject (bfd * abfd)
2049
63.5k
{
2050
63.5k
  coff_data_type *coff;
2051
63.5k
  size_t amt = sizeof (coff_data_type);
2052
2053
63.5k
  abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt);
2054
63.5k
  if (abfd->tdata.coff_obj_data == NULL)
2055
0
    return false;
2056
2057
63.5k
  coff = coff_data (abfd);
2058
63.5k
  coff->symbols = NULL;
2059
63.5k
  coff->conversion_table = NULL;
2060
63.5k
  coff->raw_syments = NULL;
2061
63.5k
  coff->relocbase = 0;
2062
63.5k
  coff->local_toc_sym_map = 0;
2063
2064
63.5k
  bfd_coff_long_section_names (abfd)
2065
63.5k
    = coff_backend_info (abfd)->_bfd_coff_long_section_names;
2066
2067
/*  make_abs_section(abfd);*/
2068
2069
63.5k
  return true;
2070
63.5k
}
coff-x86_64.c:coff_mkobject
Line
Count
Source
2049
12.5k
{
2050
12.5k
  coff_data_type *coff;
2051
12.5k
  size_t amt = sizeof (coff_data_type);
2052
2053
12.5k
  abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt);
2054
12.5k
  if (abfd->tdata.coff_obj_data == NULL)
2055
0
    return false;
2056
2057
12.5k
  coff = coff_data (abfd);
2058
12.5k
  coff->symbols = NULL;
2059
12.5k
  coff->conversion_table = NULL;
2060
12.5k
  coff->raw_syments = NULL;
2061
12.5k
  coff->relocbase = 0;
2062
12.5k
  coff->local_toc_sym_map = 0;
2063
2064
12.5k
  bfd_coff_long_section_names (abfd)
2065
12.5k
    = coff_backend_info (abfd)->_bfd_coff_long_section_names;
2066
2067
/*  make_abs_section(abfd);*/
2068
2069
12.5k
  return true;
2070
12.5k
}
cf-i386lynx.c:coff_mkobject
Line
Count
Source
2049
7.70k
{
2050
7.70k
  coff_data_type *coff;
2051
7.70k
  size_t amt = sizeof (coff_data_type);
2052
2053
7.70k
  abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt);
2054
7.70k
  if (abfd->tdata.coff_obj_data == NULL)
2055
0
    return false;
2056
2057
7.70k
  coff = coff_data (abfd);
2058
7.70k
  coff->symbols = NULL;
2059
7.70k
  coff->conversion_table = NULL;
2060
7.70k
  coff->raw_syments = NULL;
2061
7.70k
  coff->relocbase = 0;
2062
7.70k
  coff->local_toc_sym_map = 0;
2063
2064
7.70k
  bfd_coff_long_section_names (abfd)
2065
7.70k
    = coff_backend_info (abfd)->_bfd_coff_long_section_names;
2066
2067
/*  make_abs_section(abfd);*/
2068
2069
7.70k
  return true;
2070
7.70k
}
coff-i386.c:coff_mkobject
Line
Count
Source
2049
7.39k
{
2050
7.39k
  coff_data_type *coff;
2051
7.39k
  size_t amt = sizeof (coff_data_type);
2052
2053
7.39k
  abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt);
2054
7.39k
  if (abfd->tdata.coff_obj_data == NULL)
2055
0
    return false;
2056
2057
7.39k
  coff = coff_data (abfd);
2058
7.39k
  coff->symbols = NULL;
2059
7.39k
  coff->conversion_table = NULL;
2060
7.39k
  coff->raw_syments = NULL;
2061
7.39k
  coff->relocbase = 0;
2062
7.39k
  coff->local_toc_sym_map = 0;
2063
2064
7.39k
  bfd_coff_long_section_names (abfd)
2065
7.39k
    = coff_backend_info (abfd)->_bfd_coff_long_section_names;
2066
2067
/*  make_abs_section(abfd);*/
2068
2069
7.39k
  return true;
2070
7.39k
}
coff-sh.c:coff_mkobject
Line
Count
Source
2049
12.7k
{
2050
12.7k
  coff_data_type *coff;
2051
12.7k
  size_t amt = sizeof (coff_data_type);
2052
2053
12.7k
  abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt);
2054
12.7k
  if (abfd->tdata.coff_obj_data == NULL)
2055
0
    return false;
2056
2057
12.7k
  coff = coff_data (abfd);
2058
12.7k
  coff->symbols = NULL;
2059
12.7k
  coff->conversion_table = NULL;
2060
12.7k
  coff->raw_syments = NULL;
2061
12.7k
  coff->relocbase = 0;
2062
12.7k
  coff->local_toc_sym_map = 0;
2063
2064
12.7k
  bfd_coff_long_section_names (abfd)
2065
12.7k
    = coff_backend_info (abfd)->_bfd_coff_long_section_names;
2066
2067
/*  make_abs_section(abfd);*/
2068
2069
12.7k
  return true;
2070
12.7k
}
coff-tic30.c:coff_mkobject
Line
Count
Source
2049
4.56k
{
2050
4.56k
  coff_data_type *coff;
2051
4.56k
  size_t amt = sizeof (coff_data_type);
2052
2053
4.56k
  abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt);
2054
4.56k
  if (abfd->tdata.coff_obj_data == NULL)
2055
0
    return false;
2056
2057
4.56k
  coff = coff_data (abfd);
2058
4.56k
  coff->symbols = NULL;
2059
4.56k
  coff->conversion_table = NULL;
2060
4.56k
  coff->raw_syments = NULL;
2061
4.56k
  coff->relocbase = 0;
2062
4.56k
  coff->local_toc_sym_map = 0;
2063
2064
4.56k
  bfd_coff_long_section_names (abfd)
2065
4.56k
    = coff_backend_info (abfd)->_bfd_coff_long_section_names;
2066
2067
/*  make_abs_section(abfd);*/
2068
2069
4.56k
  return true;
2070
4.56k
}
Unexecuted instantiation: coff-tic4x.c:coff_mkobject
coff-tic54x.c:coff_mkobject
Line
Count
Source
2049
11.1k
{
2050
11.1k
  coff_data_type *coff;
2051
11.1k
  size_t amt = sizeof (coff_data_type);
2052
2053
11.1k
  abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt);
2054
11.1k
  if (abfd->tdata.coff_obj_data == NULL)
2055
0
    return false;
2056
2057
11.1k
  coff = coff_data (abfd);
2058
11.1k
  coff->symbols = NULL;
2059
11.1k
  coff->conversion_table = NULL;
2060
11.1k
  coff->raw_syments = NULL;
2061
11.1k
  coff->relocbase = 0;
2062
11.1k
  coff->local_toc_sym_map = 0;
2063
2064
11.1k
  bfd_coff_long_section_names (abfd)
2065
11.1k
    = coff_backend_info (abfd)->_bfd_coff_long_section_names;
2066
2067
/*  make_abs_section(abfd);*/
2068
2069
11.1k
  return true;
2070
11.1k
}
coff-z80.c:coff_mkobject
Line
Count
Source
2049
3.14k
{
2050
3.14k
  coff_data_type *coff;
2051
3.14k
  size_t amt = sizeof (coff_data_type);
2052
2053
3.14k
  abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt);
2054
3.14k
  if (abfd->tdata.coff_obj_data == NULL)
2055
0
    return false;
2056
2057
3.14k
  coff = coff_data (abfd);
2058
3.14k
  coff->symbols = NULL;
2059
3.14k
  coff->conversion_table = NULL;
2060
3.14k
  coff->raw_syments = NULL;
2061
3.14k
  coff->relocbase = 0;
2062
3.14k
  coff->local_toc_sym_map = 0;
2063
2064
3.14k
  bfd_coff_long_section_names (abfd)
2065
3.14k
    = coff_backend_info (abfd)->_bfd_coff_long_section_names;
2066
2067
/*  make_abs_section(abfd);*/
2068
2069
3.14k
  return true;
2070
3.14k
}
coff-z8k.c:coff_mkobject
Line
Count
Source
2049
4.35k
{
2050
4.35k
  coff_data_type *coff;
2051
4.35k
  size_t amt = sizeof (coff_data_type);
2052
2053
4.35k
  abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt);
2054
4.35k
  if (abfd->tdata.coff_obj_data == NULL)
2055
0
    return false;
2056
2057
4.35k
  coff = coff_data (abfd);
2058
4.35k
  coff->symbols = NULL;
2059
4.35k
  coff->conversion_table = NULL;
2060
4.35k
  coff->raw_syments = NULL;
2061
4.35k
  coff->relocbase = 0;
2062
4.35k
  coff->local_toc_sym_map = 0;
2063
2064
4.35k
  bfd_coff_long_section_names (abfd)
2065
4.35k
    = coff_backend_info (abfd)->_bfd_coff_long_section_names;
2066
2067
/*  make_abs_section(abfd);*/
2068
2069
4.35k
  return true;
2070
4.35k
}
2071
#endif
2072
2073
/* Create the COFF backend specific information.  */
2074
2075
#ifndef coff_mkobject_hook
2076
static void *
2077
coff_mkobject_hook (bfd * abfd,
2078
        void * filehdr,
2079
        void * aouthdr ATTRIBUTE_UNUSED)
2080
87.4k
{
2081
87.4k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2082
87.4k
  coff_data_type *coff;
2083
2084
87.4k
  if (! coff_mkobject (abfd))
2085
0
    return NULL;
2086
2087
87.4k
  coff = coff_data (abfd);
2088
2089
87.4k
  coff->sym_filepos = internal_f->f_symptr;
2090
2091
  /* These members communicate important constants about the symbol
2092
     table to GDB's symbol-reading code.  These `constants'
2093
     unfortunately vary among coff implementations...  */
2094
87.4k
  coff->local_n_btmask = N_BTMASK;
2095
87.4k
  coff->local_n_btshft = N_BTSHFT;
2096
87.4k
  coff->local_n_tmask = N_TMASK;
2097
87.4k
  coff->local_n_tshift = N_TSHIFT;
2098
87.4k
  coff->local_symesz = bfd_coff_symesz (abfd);
2099
87.4k
  coff->local_auxesz = bfd_coff_auxesz (abfd);
2100
87.4k
  coff->local_linesz = bfd_coff_linesz (abfd);
2101
2102
87.4k
  coff->timestamp = internal_f->f_timdat;
2103
2104
87.4k
  obj_raw_syment_count (abfd) =
2105
87.4k
    obj_conv_table_size (abfd) =
2106
87.4k
      internal_f->f_nsyms;
2107
2108
#ifdef RS6000COFF_C
2109
16.1k
  if ((internal_f->f_flags & F_SHROBJ) != 0)
2110
7.12k
    abfd->flags |= DYNAMIC;
2111
16.1k
  if (aouthdr != NULL && internal_f->f_opthdr >= bfd_coff_aoutsz (abfd))
2112
7.24k
    {
2113
7.24k
      struct internal_aouthdr *internal_a =
2114
7.24k
  (struct internal_aouthdr *) aouthdr;
2115
7.24k
      struct xcoff_tdata *xcoff;
2116
2117
7.24k
      xcoff = xcoff_data (abfd);
2118
# ifdef U803XTOCMAGIC
2119
5.37k
      xcoff->xcoff64 = internal_f->f_magic == U803XTOCMAGIC;
2120
# else
2121
      xcoff->xcoff64 = 0;
2122
# endif
2123
7.24k
      xcoff->full_aouthdr = true;
2124
7.24k
      xcoff->toc = internal_a->o_toc;
2125
7.24k
      xcoff->sntoc = internal_a->o_sntoc;
2126
7.24k
      xcoff->snentry = internal_a->o_snentry;
2127
7.24k
      bfd_xcoff_text_align_power (abfd) = internal_a->o_algntext;
2128
7.24k
      bfd_xcoff_data_align_power (abfd) = internal_a->o_algndata;
2129
7.24k
      xcoff->modtype = internal_a->o_modtype;
2130
7.24k
      xcoff->cputype = internal_a->o_cputype;
2131
7.24k
      xcoff->maxdata = internal_a->o_maxdata;
2132
7.24k
      xcoff->maxstack = internal_a->o_maxstack;
2133
7.24k
    }
2134
#endif
2135
2136
#ifdef ARM
2137
  /* Set the flags field from the COFF header read in.  */
2138
  if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags))
2139
    coff->flags = 0;
2140
#endif
2141
2142
#ifdef COFF_WITH_PE
2143
  /* FIXME: I'm not sure this is ever executed, since peicode.h
2144
     defines coff_mkobject_hook.  */
2145
  if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0)
2146
    abfd->flags |= HAS_DEBUG;
2147
#endif
2148
2149
87.4k
  return coff;
2150
87.4k
}
coff-x86_64.c:coff_mkobject_hook
Line
Count
Source
2080
12.5k
{
2081
12.5k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2082
12.5k
  coff_data_type *coff;
2083
2084
12.5k
  if (! coff_mkobject (abfd))
2085
0
    return NULL;
2086
2087
12.5k
  coff = coff_data (abfd);
2088
2089
12.5k
  coff->sym_filepos = internal_f->f_symptr;
2090
2091
  /* These members communicate important constants about the symbol
2092
     table to GDB's symbol-reading code.  These `constants'
2093
     unfortunately vary among coff implementations...  */
2094
12.5k
  coff->local_n_btmask = N_BTMASK;
2095
12.5k
  coff->local_n_btshft = N_BTSHFT;
2096
12.5k
  coff->local_n_tmask = N_TMASK;
2097
12.5k
  coff->local_n_tshift = N_TSHIFT;
2098
12.5k
  coff->local_symesz = bfd_coff_symesz (abfd);
2099
12.5k
  coff->local_auxesz = bfd_coff_auxesz (abfd);
2100
12.5k
  coff->local_linesz = bfd_coff_linesz (abfd);
2101
2102
12.5k
  coff->timestamp = internal_f->f_timdat;
2103
2104
12.5k
  obj_raw_syment_count (abfd) =
2105
12.5k
    obj_conv_table_size (abfd) =
2106
12.5k
      internal_f->f_nsyms;
2107
2108
#ifdef RS6000COFF_C
2109
  if ((internal_f->f_flags & F_SHROBJ) != 0)
2110
    abfd->flags |= DYNAMIC;
2111
  if (aouthdr != NULL && internal_f->f_opthdr >= bfd_coff_aoutsz (abfd))
2112
    {
2113
      struct internal_aouthdr *internal_a =
2114
  (struct internal_aouthdr *) aouthdr;
2115
      struct xcoff_tdata *xcoff;
2116
2117
      xcoff = xcoff_data (abfd);
2118
# ifdef U803XTOCMAGIC
2119
      xcoff->xcoff64 = internal_f->f_magic == U803XTOCMAGIC;
2120
# else
2121
      xcoff->xcoff64 = 0;
2122
# endif
2123
      xcoff->full_aouthdr = true;
2124
      xcoff->toc = internal_a->o_toc;
2125
      xcoff->sntoc = internal_a->o_sntoc;
2126
      xcoff->snentry = internal_a->o_snentry;
2127
      bfd_xcoff_text_align_power (abfd) = internal_a->o_algntext;
2128
      bfd_xcoff_data_align_power (abfd) = internal_a->o_algndata;
2129
      xcoff->modtype = internal_a->o_modtype;
2130
      xcoff->cputype = internal_a->o_cputype;
2131
      xcoff->maxdata = internal_a->o_maxdata;
2132
      xcoff->maxstack = internal_a->o_maxstack;
2133
    }
2134
#endif
2135
2136
#ifdef ARM
2137
  /* Set the flags field from the COFF header read in.  */
2138
  if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags))
2139
    coff->flags = 0;
2140
#endif
2141
2142
#ifdef COFF_WITH_PE
2143
  /* FIXME: I'm not sure this is ever executed, since peicode.h
2144
     defines coff_mkobject_hook.  */
2145
  if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0)
2146
    abfd->flags |= HAS_DEBUG;
2147
#endif
2148
2149
12.5k
  return coff;
2150
12.5k
}
coff64-rs6000.c:coff_mkobject_hook
Line
Count
Source
2080
7.92k
{
2081
7.92k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2082
7.92k
  coff_data_type *coff;
2083
2084
7.92k
  if (! coff_mkobject (abfd))
2085
0
    return NULL;
2086
2087
7.92k
  coff = coff_data (abfd);
2088
2089
7.92k
  coff->sym_filepos = internal_f->f_symptr;
2090
2091
  /* These members communicate important constants about the symbol
2092
     table to GDB's symbol-reading code.  These `constants'
2093
     unfortunately vary among coff implementations...  */
2094
7.92k
  coff->local_n_btmask = N_BTMASK;
2095
7.92k
  coff->local_n_btshft = N_BTSHFT;
2096
7.92k
  coff->local_n_tmask = N_TMASK;
2097
7.92k
  coff->local_n_tshift = N_TSHIFT;
2098
7.92k
  coff->local_symesz = bfd_coff_symesz (abfd);
2099
7.92k
  coff->local_auxesz = bfd_coff_auxesz (abfd);
2100
7.92k
  coff->local_linesz = bfd_coff_linesz (abfd);
2101
2102
7.92k
  coff->timestamp = internal_f->f_timdat;
2103
2104
7.92k
  obj_raw_syment_count (abfd) =
2105
7.92k
    obj_conv_table_size (abfd) =
2106
7.92k
      internal_f->f_nsyms;
2107
2108
7.92k
#ifdef RS6000COFF_C
2109
7.92k
  if ((internal_f->f_flags & F_SHROBJ) != 0)
2110
5.59k
    abfd->flags |= DYNAMIC;
2111
7.92k
  if (aouthdr != NULL && internal_f->f_opthdr >= bfd_coff_aoutsz (abfd))
2112
5.37k
    {
2113
5.37k
      struct internal_aouthdr *internal_a =
2114
5.37k
  (struct internal_aouthdr *) aouthdr;
2115
5.37k
      struct xcoff_tdata *xcoff;
2116
2117
5.37k
      xcoff = xcoff_data (abfd);
2118
5.37k
# ifdef U803XTOCMAGIC
2119
5.37k
      xcoff->xcoff64 = internal_f->f_magic == U803XTOCMAGIC;
2120
# else
2121
      xcoff->xcoff64 = 0;
2122
# endif
2123
5.37k
      xcoff->full_aouthdr = true;
2124
5.37k
      xcoff->toc = internal_a->o_toc;
2125
5.37k
      xcoff->sntoc = internal_a->o_sntoc;
2126
5.37k
      xcoff->snentry = internal_a->o_snentry;
2127
5.37k
      bfd_xcoff_text_align_power (abfd) = internal_a->o_algntext;
2128
5.37k
      bfd_xcoff_data_align_power (abfd) = internal_a->o_algndata;
2129
5.37k
      xcoff->modtype = internal_a->o_modtype;
2130
5.37k
      xcoff->cputype = internal_a->o_cputype;
2131
5.37k
      xcoff->maxdata = internal_a->o_maxdata;
2132
5.37k
      xcoff->maxstack = internal_a->o_maxstack;
2133
5.37k
    }
2134
7.92k
#endif
2135
2136
#ifdef ARM
2137
  /* Set the flags field from the COFF header read in.  */
2138
  if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags))
2139
    coff->flags = 0;
2140
#endif
2141
2142
#ifdef COFF_WITH_PE
2143
  /* FIXME: I'm not sure this is ever executed, since peicode.h
2144
     defines coff_mkobject_hook.  */
2145
  if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0)
2146
    abfd->flags |= HAS_DEBUG;
2147
#endif
2148
2149
7.92k
  return coff;
2150
7.92k
}
cf-i386lynx.c:coff_mkobject_hook
Line
Count
Source
2080
7.70k
{
2081
7.70k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2082
7.70k
  coff_data_type *coff;
2083
2084
7.70k
  if (! coff_mkobject (abfd))
2085
0
    return NULL;
2086
2087
7.70k
  coff = coff_data (abfd);
2088
2089
7.70k
  coff->sym_filepos = internal_f->f_symptr;
2090
2091
  /* These members communicate important constants about the symbol
2092
     table to GDB's symbol-reading code.  These `constants'
2093
     unfortunately vary among coff implementations...  */
2094
7.70k
  coff->local_n_btmask = N_BTMASK;
2095
7.70k
  coff->local_n_btshft = N_BTSHFT;
2096
7.70k
  coff->local_n_tmask = N_TMASK;
2097
7.70k
  coff->local_n_tshift = N_TSHIFT;
2098
7.70k
  coff->local_symesz = bfd_coff_symesz (abfd);
2099
7.70k
  coff->local_auxesz = bfd_coff_auxesz (abfd);
2100
7.70k
  coff->local_linesz = bfd_coff_linesz (abfd);
2101
2102
7.70k
  coff->timestamp = internal_f->f_timdat;
2103
2104
7.70k
  obj_raw_syment_count (abfd) =
2105
7.70k
    obj_conv_table_size (abfd) =
2106
7.70k
      internal_f->f_nsyms;
2107
2108
#ifdef RS6000COFF_C
2109
  if ((internal_f->f_flags & F_SHROBJ) != 0)
2110
    abfd->flags |= DYNAMIC;
2111
  if (aouthdr != NULL && internal_f->f_opthdr >= bfd_coff_aoutsz (abfd))
2112
    {
2113
      struct internal_aouthdr *internal_a =
2114
  (struct internal_aouthdr *) aouthdr;
2115
      struct xcoff_tdata *xcoff;
2116
2117
      xcoff = xcoff_data (abfd);
2118
# ifdef U803XTOCMAGIC
2119
      xcoff->xcoff64 = internal_f->f_magic == U803XTOCMAGIC;
2120
# else
2121
      xcoff->xcoff64 = 0;
2122
# endif
2123
      xcoff->full_aouthdr = true;
2124
      xcoff->toc = internal_a->o_toc;
2125
      xcoff->sntoc = internal_a->o_sntoc;
2126
      xcoff->snentry = internal_a->o_snentry;
2127
      bfd_xcoff_text_align_power (abfd) = internal_a->o_algntext;
2128
      bfd_xcoff_data_align_power (abfd) = internal_a->o_algndata;
2129
      xcoff->modtype = internal_a->o_modtype;
2130
      xcoff->cputype = internal_a->o_cputype;
2131
      xcoff->maxdata = internal_a->o_maxdata;
2132
      xcoff->maxstack = internal_a->o_maxstack;
2133
    }
2134
#endif
2135
2136
#ifdef ARM
2137
  /* Set the flags field from the COFF header read in.  */
2138
  if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags))
2139
    coff->flags = 0;
2140
#endif
2141
2142
#ifdef COFF_WITH_PE
2143
  /* FIXME: I'm not sure this is ever executed, since peicode.h
2144
     defines coff_mkobject_hook.  */
2145
  if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0)
2146
    abfd->flags |= HAS_DEBUG;
2147
#endif
2148
2149
7.70k
  return coff;
2150
7.70k
}
coff-go32.c:coff_mkobject_hook
Line
Count
Source
2080
7.39k
{
2081
7.39k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2082
7.39k
  coff_data_type *coff;
2083
2084
7.39k
  if (! coff_mkobject (abfd))
2085
0
    return NULL;
2086
2087
7.39k
  coff = coff_data (abfd);
2088
2089
7.39k
  coff->sym_filepos = internal_f->f_symptr;
2090
2091
  /* These members communicate important constants about the symbol
2092
     table to GDB's symbol-reading code.  These `constants'
2093
     unfortunately vary among coff implementations...  */
2094
7.39k
  coff->local_n_btmask = N_BTMASK;
2095
7.39k
  coff->local_n_btshft = N_BTSHFT;
2096
7.39k
  coff->local_n_tmask = N_TMASK;
2097
7.39k
  coff->local_n_tshift = N_TSHIFT;
2098
7.39k
  coff->local_symesz = bfd_coff_symesz (abfd);
2099
7.39k
  coff->local_auxesz = bfd_coff_auxesz (abfd);
2100
7.39k
  coff->local_linesz = bfd_coff_linesz (abfd);
2101
2102
7.39k
  coff->timestamp = internal_f->f_timdat;
2103
2104
7.39k
  obj_raw_syment_count (abfd) =
2105
7.39k
    obj_conv_table_size (abfd) =
2106
7.39k
      internal_f->f_nsyms;
2107
2108
#ifdef RS6000COFF_C
2109
  if ((internal_f->f_flags & F_SHROBJ) != 0)
2110
    abfd->flags |= DYNAMIC;
2111
  if (aouthdr != NULL && internal_f->f_opthdr >= bfd_coff_aoutsz (abfd))
2112
    {
2113
      struct internal_aouthdr *internal_a =
2114
  (struct internal_aouthdr *) aouthdr;
2115
      struct xcoff_tdata *xcoff;
2116
2117
      xcoff = xcoff_data (abfd);
2118
# ifdef U803XTOCMAGIC
2119
      xcoff->xcoff64 = internal_f->f_magic == U803XTOCMAGIC;
2120
# else
2121
      xcoff->xcoff64 = 0;
2122
# endif
2123
      xcoff->full_aouthdr = true;
2124
      xcoff->toc = internal_a->o_toc;
2125
      xcoff->sntoc = internal_a->o_sntoc;
2126
      xcoff->snentry = internal_a->o_snentry;
2127
      bfd_xcoff_text_align_power (abfd) = internal_a->o_algntext;
2128
      bfd_xcoff_data_align_power (abfd) = internal_a->o_algndata;
2129
      xcoff->modtype = internal_a->o_modtype;
2130
      xcoff->cputype = internal_a->o_cputype;
2131
      xcoff->maxdata = internal_a->o_maxdata;
2132
      xcoff->maxstack = internal_a->o_maxstack;
2133
    }
2134
#endif
2135
2136
#ifdef ARM
2137
  /* Set the flags field from the COFF header read in.  */
2138
  if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags))
2139
    coff->flags = 0;
2140
#endif
2141
2142
#ifdef COFF_WITH_PE
2143
  /* FIXME: I'm not sure this is ever executed, since peicode.h
2144
     defines coff_mkobject_hook.  */
2145
  if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0)
2146
    abfd->flags |= HAS_DEBUG;
2147
#endif
2148
2149
7.39k
  return coff;
2150
7.39k
}
coff-i386.c:coff_mkobject_hook
Line
Count
Source
2080
7.39k
{
2081
7.39k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2082
7.39k
  coff_data_type *coff;
2083
2084
7.39k
  if (! coff_mkobject (abfd))
2085
0
    return NULL;
2086
2087
7.39k
  coff = coff_data (abfd);
2088
2089
7.39k
  coff->sym_filepos = internal_f->f_symptr;
2090
2091
  /* These members communicate important constants about the symbol
2092
     table to GDB's symbol-reading code.  These `constants'
2093
     unfortunately vary among coff implementations...  */
2094
7.39k
  coff->local_n_btmask = N_BTMASK;
2095
7.39k
  coff->local_n_btshft = N_BTSHFT;
2096
7.39k
  coff->local_n_tmask = N_TMASK;
2097
7.39k
  coff->local_n_tshift = N_TSHIFT;
2098
7.39k
  coff->local_symesz = bfd_coff_symesz (abfd);
2099
7.39k
  coff->local_auxesz = bfd_coff_auxesz (abfd);
2100
7.39k
  coff->local_linesz = bfd_coff_linesz (abfd);
2101
2102
7.39k
  coff->timestamp = internal_f->f_timdat;
2103
2104
7.39k
  obj_raw_syment_count (abfd) =
2105
7.39k
    obj_conv_table_size (abfd) =
2106
7.39k
      internal_f->f_nsyms;
2107
2108
#ifdef RS6000COFF_C
2109
  if ((internal_f->f_flags & F_SHROBJ) != 0)
2110
    abfd->flags |= DYNAMIC;
2111
  if (aouthdr != NULL && internal_f->f_opthdr >= bfd_coff_aoutsz (abfd))
2112
    {
2113
      struct internal_aouthdr *internal_a =
2114
  (struct internal_aouthdr *) aouthdr;
2115
      struct xcoff_tdata *xcoff;
2116
2117
      xcoff = xcoff_data (abfd);
2118
# ifdef U803XTOCMAGIC
2119
      xcoff->xcoff64 = internal_f->f_magic == U803XTOCMAGIC;
2120
# else
2121
      xcoff->xcoff64 = 0;
2122
# endif
2123
      xcoff->full_aouthdr = true;
2124
      xcoff->toc = internal_a->o_toc;
2125
      xcoff->sntoc = internal_a->o_sntoc;
2126
      xcoff->snentry = internal_a->o_snentry;
2127
      bfd_xcoff_text_align_power (abfd) = internal_a->o_algntext;
2128
      bfd_xcoff_data_align_power (abfd) = internal_a->o_algndata;
2129
      xcoff->modtype = internal_a->o_modtype;
2130
      xcoff->cputype = internal_a->o_cputype;
2131
      xcoff->maxdata = internal_a->o_maxdata;
2132
      xcoff->maxstack = internal_a->o_maxstack;
2133
    }
2134
#endif
2135
2136
#ifdef ARM
2137
  /* Set the flags field from the COFF header read in.  */
2138
  if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags))
2139
    coff->flags = 0;
2140
#endif
2141
2142
#ifdef COFF_WITH_PE
2143
  /* FIXME: I'm not sure this is ever executed, since peicode.h
2144
     defines coff_mkobject_hook.  */
2145
  if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0)
2146
    abfd->flags |= HAS_DEBUG;
2147
#endif
2148
2149
7.39k
  return coff;
2150
7.39k
}
coff-rs6000.c:coff_mkobject_hook
Line
Count
Source
2080
8.22k
{
2081
8.22k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2082
8.22k
  coff_data_type *coff;
2083
2084
8.22k
  if (! coff_mkobject (abfd))
2085
0
    return NULL;
2086
2087
8.22k
  coff = coff_data (abfd);
2088
2089
8.22k
  coff->sym_filepos = internal_f->f_symptr;
2090
2091
  /* These members communicate important constants about the symbol
2092
     table to GDB's symbol-reading code.  These `constants'
2093
     unfortunately vary among coff implementations...  */
2094
8.22k
  coff->local_n_btmask = N_BTMASK;
2095
8.22k
  coff->local_n_btshft = N_BTSHFT;
2096
8.22k
  coff->local_n_tmask = N_TMASK;
2097
8.22k
  coff->local_n_tshift = N_TSHIFT;
2098
8.22k
  coff->local_symesz = bfd_coff_symesz (abfd);
2099
8.22k
  coff->local_auxesz = bfd_coff_auxesz (abfd);
2100
8.22k
  coff->local_linesz = bfd_coff_linesz (abfd);
2101
2102
8.22k
  coff->timestamp = internal_f->f_timdat;
2103
2104
8.22k
  obj_raw_syment_count (abfd) =
2105
8.22k
    obj_conv_table_size (abfd) =
2106
8.22k
      internal_f->f_nsyms;
2107
2108
8.22k
#ifdef RS6000COFF_C
2109
8.22k
  if ((internal_f->f_flags & F_SHROBJ) != 0)
2110
1.52k
    abfd->flags |= DYNAMIC;
2111
8.22k
  if (aouthdr != NULL && internal_f->f_opthdr >= bfd_coff_aoutsz (abfd))
2112
1.87k
    {
2113
1.87k
      struct internal_aouthdr *internal_a =
2114
1.87k
  (struct internal_aouthdr *) aouthdr;
2115
1.87k
      struct xcoff_tdata *xcoff;
2116
2117
1.87k
      xcoff = xcoff_data (abfd);
2118
# ifdef U803XTOCMAGIC
2119
      xcoff->xcoff64 = internal_f->f_magic == U803XTOCMAGIC;
2120
# else
2121
1.87k
      xcoff->xcoff64 = 0;
2122
1.87k
# endif
2123
1.87k
      xcoff->full_aouthdr = true;
2124
1.87k
      xcoff->toc = internal_a->o_toc;
2125
1.87k
      xcoff->sntoc = internal_a->o_sntoc;
2126
1.87k
      xcoff->snentry = internal_a->o_snentry;
2127
1.87k
      bfd_xcoff_text_align_power (abfd) = internal_a->o_algntext;
2128
1.87k
      bfd_xcoff_data_align_power (abfd) = internal_a->o_algndata;
2129
1.87k
      xcoff->modtype = internal_a->o_modtype;
2130
1.87k
      xcoff->cputype = internal_a->o_cputype;
2131
1.87k
      xcoff->maxdata = internal_a->o_maxdata;
2132
1.87k
      xcoff->maxstack = internal_a->o_maxstack;
2133
1.87k
    }
2134
8.22k
#endif
2135
2136
#ifdef ARM
2137
  /* Set the flags field from the COFF header read in.  */
2138
  if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags))
2139
    coff->flags = 0;
2140
#endif
2141
2142
#ifdef COFF_WITH_PE
2143
  /* FIXME: I'm not sure this is ever executed, since peicode.h
2144
     defines coff_mkobject_hook.  */
2145
  if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0)
2146
    abfd->flags |= HAS_DEBUG;
2147
#endif
2148
2149
8.22k
  return coff;
2150
8.22k
}
coff-sh.c:coff_mkobject_hook
Line
Count
Source
2080
12.7k
{
2081
12.7k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2082
12.7k
  coff_data_type *coff;
2083
2084
12.7k
  if (! coff_mkobject (abfd))
2085
0
    return NULL;
2086
2087
12.7k
  coff = coff_data (abfd);
2088
2089
12.7k
  coff->sym_filepos = internal_f->f_symptr;
2090
2091
  /* These members communicate important constants about the symbol
2092
     table to GDB's symbol-reading code.  These `constants'
2093
     unfortunately vary among coff implementations...  */
2094
12.7k
  coff->local_n_btmask = N_BTMASK;
2095
12.7k
  coff->local_n_btshft = N_BTSHFT;
2096
12.7k
  coff->local_n_tmask = N_TMASK;
2097
12.7k
  coff->local_n_tshift = N_TSHIFT;
2098
12.7k
  coff->local_symesz = bfd_coff_symesz (abfd);
2099
12.7k
  coff->local_auxesz = bfd_coff_auxesz (abfd);
2100
12.7k
  coff->local_linesz = bfd_coff_linesz (abfd);
2101
2102
12.7k
  coff->timestamp = internal_f->f_timdat;
2103
2104
12.7k
  obj_raw_syment_count (abfd) =
2105
12.7k
    obj_conv_table_size (abfd) =
2106
12.7k
      internal_f->f_nsyms;
2107
2108
#ifdef RS6000COFF_C
2109
  if ((internal_f->f_flags & F_SHROBJ) != 0)
2110
    abfd->flags |= DYNAMIC;
2111
  if (aouthdr != NULL && internal_f->f_opthdr >= bfd_coff_aoutsz (abfd))
2112
    {
2113
      struct internal_aouthdr *internal_a =
2114
  (struct internal_aouthdr *) aouthdr;
2115
      struct xcoff_tdata *xcoff;
2116
2117
      xcoff = xcoff_data (abfd);
2118
# ifdef U803XTOCMAGIC
2119
      xcoff->xcoff64 = internal_f->f_magic == U803XTOCMAGIC;
2120
# else
2121
      xcoff->xcoff64 = 0;
2122
# endif
2123
      xcoff->full_aouthdr = true;
2124
      xcoff->toc = internal_a->o_toc;
2125
      xcoff->sntoc = internal_a->o_sntoc;
2126
      xcoff->snentry = internal_a->o_snentry;
2127
      bfd_xcoff_text_align_power (abfd) = internal_a->o_algntext;
2128
      bfd_xcoff_data_align_power (abfd) = internal_a->o_algndata;
2129
      xcoff->modtype = internal_a->o_modtype;
2130
      xcoff->cputype = internal_a->o_cputype;
2131
      xcoff->maxdata = internal_a->o_maxdata;
2132
      xcoff->maxstack = internal_a->o_maxstack;
2133
    }
2134
#endif
2135
2136
#ifdef ARM
2137
  /* Set the flags field from the COFF header read in.  */
2138
  if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags))
2139
    coff->flags = 0;
2140
#endif
2141
2142
#ifdef COFF_WITH_PE
2143
  /* FIXME: I'm not sure this is ever executed, since peicode.h
2144
     defines coff_mkobject_hook.  */
2145
  if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0)
2146
    abfd->flags |= HAS_DEBUG;
2147
#endif
2148
2149
12.7k
  return coff;
2150
12.7k
}
coff-stgo32.c:coff_mkobject_hook
Line
Count
Source
2080
342
{
2081
342
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2082
342
  coff_data_type *coff;
2083
2084
342
  if (! coff_mkobject (abfd))
2085
0
    return NULL;
2086
2087
342
  coff = coff_data (abfd);
2088
2089
342
  coff->sym_filepos = internal_f->f_symptr;
2090
2091
  /* These members communicate important constants about the symbol
2092
     table to GDB's symbol-reading code.  These `constants'
2093
     unfortunately vary among coff implementations...  */
2094
342
  coff->local_n_btmask = N_BTMASK;
2095
342
  coff->local_n_btshft = N_BTSHFT;
2096
342
  coff->local_n_tmask = N_TMASK;
2097
342
  coff->local_n_tshift = N_TSHIFT;
2098
342
  coff->local_symesz = bfd_coff_symesz (abfd);
2099
342
  coff->local_auxesz = bfd_coff_auxesz (abfd);
2100
342
  coff->local_linesz = bfd_coff_linesz (abfd);
2101
2102
342
  coff->timestamp = internal_f->f_timdat;
2103
2104
342
  obj_raw_syment_count (abfd) =
2105
342
    obj_conv_table_size (abfd) =
2106
342
      internal_f->f_nsyms;
2107
2108
#ifdef RS6000COFF_C
2109
  if ((internal_f->f_flags & F_SHROBJ) != 0)
2110
    abfd->flags |= DYNAMIC;
2111
  if (aouthdr != NULL && internal_f->f_opthdr >= bfd_coff_aoutsz (abfd))
2112
    {
2113
      struct internal_aouthdr *internal_a =
2114
  (struct internal_aouthdr *) aouthdr;
2115
      struct xcoff_tdata *xcoff;
2116
2117
      xcoff = xcoff_data (abfd);
2118
# ifdef U803XTOCMAGIC
2119
      xcoff->xcoff64 = internal_f->f_magic == U803XTOCMAGIC;
2120
# else
2121
      xcoff->xcoff64 = 0;
2122
# endif
2123
      xcoff->full_aouthdr = true;
2124
      xcoff->toc = internal_a->o_toc;
2125
      xcoff->sntoc = internal_a->o_sntoc;
2126
      xcoff->snentry = internal_a->o_snentry;
2127
      bfd_xcoff_text_align_power (abfd) = internal_a->o_algntext;
2128
      bfd_xcoff_data_align_power (abfd) = internal_a->o_algndata;
2129
      xcoff->modtype = internal_a->o_modtype;
2130
      xcoff->cputype = internal_a->o_cputype;
2131
      xcoff->maxdata = internal_a->o_maxdata;
2132
      xcoff->maxstack = internal_a->o_maxstack;
2133
    }
2134
#endif
2135
2136
#ifdef ARM
2137
  /* Set the flags field from the COFF header read in.  */
2138
  if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags))
2139
    coff->flags = 0;
2140
#endif
2141
2142
#ifdef COFF_WITH_PE
2143
  /* FIXME: I'm not sure this is ever executed, since peicode.h
2144
     defines coff_mkobject_hook.  */
2145
  if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0)
2146
    abfd->flags |= HAS_DEBUG;
2147
#endif
2148
2149
342
  return coff;
2150
342
}
coff-tic30.c:coff_mkobject_hook
Line
Count
Source
2080
4.56k
{
2081
4.56k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2082
4.56k
  coff_data_type *coff;
2083
2084
4.56k
  if (! coff_mkobject (abfd))
2085
0
    return NULL;
2086
2087
4.56k
  coff = coff_data (abfd);
2088
2089
4.56k
  coff->sym_filepos = internal_f->f_symptr;
2090
2091
  /* These members communicate important constants about the symbol
2092
     table to GDB's symbol-reading code.  These `constants'
2093
     unfortunately vary among coff implementations...  */
2094
4.56k
  coff->local_n_btmask = N_BTMASK;
2095
4.56k
  coff->local_n_btshft = N_BTSHFT;
2096
4.56k
  coff->local_n_tmask = N_TMASK;
2097
4.56k
  coff->local_n_tshift = N_TSHIFT;
2098
4.56k
  coff->local_symesz = bfd_coff_symesz (abfd);
2099
4.56k
  coff->local_auxesz = bfd_coff_auxesz (abfd);
2100
4.56k
  coff->local_linesz = bfd_coff_linesz (abfd);
2101
2102
4.56k
  coff->timestamp = internal_f->f_timdat;
2103
2104
4.56k
  obj_raw_syment_count (abfd) =
2105
4.56k
    obj_conv_table_size (abfd) =
2106
4.56k
      internal_f->f_nsyms;
2107
2108
#ifdef RS6000COFF_C
2109
  if ((internal_f->f_flags & F_SHROBJ) != 0)
2110
    abfd->flags |= DYNAMIC;
2111
  if (aouthdr != NULL && internal_f->f_opthdr >= bfd_coff_aoutsz (abfd))
2112
    {
2113
      struct internal_aouthdr *internal_a =
2114
  (struct internal_aouthdr *) aouthdr;
2115
      struct xcoff_tdata *xcoff;
2116
2117
      xcoff = xcoff_data (abfd);
2118
# ifdef U803XTOCMAGIC
2119
      xcoff->xcoff64 = internal_f->f_magic == U803XTOCMAGIC;
2120
# else
2121
      xcoff->xcoff64 = 0;
2122
# endif
2123
      xcoff->full_aouthdr = true;
2124
      xcoff->toc = internal_a->o_toc;
2125
      xcoff->sntoc = internal_a->o_sntoc;
2126
      xcoff->snentry = internal_a->o_snentry;
2127
      bfd_xcoff_text_align_power (abfd) = internal_a->o_algntext;
2128
      bfd_xcoff_data_align_power (abfd) = internal_a->o_algndata;
2129
      xcoff->modtype = internal_a->o_modtype;
2130
      xcoff->cputype = internal_a->o_cputype;
2131
      xcoff->maxdata = internal_a->o_maxdata;
2132
      xcoff->maxstack = internal_a->o_maxstack;
2133
    }
2134
#endif
2135
2136
#ifdef ARM
2137
  /* Set the flags field from the COFF header read in.  */
2138
  if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags))
2139
    coff->flags = 0;
2140
#endif
2141
2142
#ifdef COFF_WITH_PE
2143
  /* FIXME: I'm not sure this is ever executed, since peicode.h
2144
     defines coff_mkobject_hook.  */
2145
  if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0)
2146
    abfd->flags |= HAS_DEBUG;
2147
#endif
2148
2149
4.56k
  return coff;
2150
4.56k
}
Unexecuted instantiation: coff-tic4x.c:coff_mkobject_hook
coff-tic54x.c:coff_mkobject_hook
Line
Count
Source
2080
11.1k
{
2081
11.1k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2082
11.1k
  coff_data_type *coff;
2083
2084
11.1k
  if (! coff_mkobject (abfd))
2085
0
    return NULL;
2086
2087
11.1k
  coff = coff_data (abfd);
2088
2089
11.1k
  coff->sym_filepos = internal_f->f_symptr;
2090
2091
  /* These members communicate important constants about the symbol
2092
     table to GDB's symbol-reading code.  These `constants'
2093
     unfortunately vary among coff implementations...  */
2094
11.1k
  coff->local_n_btmask = N_BTMASK;
2095
11.1k
  coff->local_n_btshft = N_BTSHFT;
2096
11.1k
  coff->local_n_tmask = N_TMASK;
2097
11.1k
  coff->local_n_tshift = N_TSHIFT;
2098
11.1k
  coff->local_symesz = bfd_coff_symesz (abfd);
2099
11.1k
  coff->local_auxesz = bfd_coff_auxesz (abfd);
2100
11.1k
  coff->local_linesz = bfd_coff_linesz (abfd);
2101
2102
11.1k
  coff->timestamp = internal_f->f_timdat;
2103
2104
11.1k
  obj_raw_syment_count (abfd) =
2105
11.1k
    obj_conv_table_size (abfd) =
2106
11.1k
      internal_f->f_nsyms;
2107
2108
#ifdef RS6000COFF_C
2109
  if ((internal_f->f_flags & F_SHROBJ) != 0)
2110
    abfd->flags |= DYNAMIC;
2111
  if (aouthdr != NULL && internal_f->f_opthdr >= bfd_coff_aoutsz (abfd))
2112
    {
2113
      struct internal_aouthdr *internal_a =
2114
  (struct internal_aouthdr *) aouthdr;
2115
      struct xcoff_tdata *xcoff;
2116
2117
      xcoff = xcoff_data (abfd);
2118
# ifdef U803XTOCMAGIC
2119
      xcoff->xcoff64 = internal_f->f_magic == U803XTOCMAGIC;
2120
# else
2121
      xcoff->xcoff64 = 0;
2122
# endif
2123
      xcoff->full_aouthdr = true;
2124
      xcoff->toc = internal_a->o_toc;
2125
      xcoff->sntoc = internal_a->o_sntoc;
2126
      xcoff->snentry = internal_a->o_snentry;
2127
      bfd_xcoff_text_align_power (abfd) = internal_a->o_algntext;
2128
      bfd_xcoff_data_align_power (abfd) = internal_a->o_algndata;
2129
      xcoff->modtype = internal_a->o_modtype;
2130
      xcoff->cputype = internal_a->o_cputype;
2131
      xcoff->maxdata = internal_a->o_maxdata;
2132
      xcoff->maxstack = internal_a->o_maxstack;
2133
    }
2134
#endif
2135
2136
#ifdef ARM
2137
  /* Set the flags field from the COFF header read in.  */
2138
  if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags))
2139
    coff->flags = 0;
2140
#endif
2141
2142
#ifdef COFF_WITH_PE
2143
  /* FIXME: I'm not sure this is ever executed, since peicode.h
2144
     defines coff_mkobject_hook.  */
2145
  if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0)
2146
    abfd->flags |= HAS_DEBUG;
2147
#endif
2148
2149
11.1k
  return coff;
2150
11.1k
}
coff-z80.c:coff_mkobject_hook
Line
Count
Source
2080
3.14k
{
2081
3.14k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2082
3.14k
  coff_data_type *coff;
2083
2084
3.14k
  if (! coff_mkobject (abfd))
2085
0
    return NULL;
2086
2087
3.14k
  coff = coff_data (abfd);
2088
2089
3.14k
  coff->sym_filepos = internal_f->f_symptr;
2090
2091
  /* These members communicate important constants about the symbol
2092
     table to GDB's symbol-reading code.  These `constants'
2093
     unfortunately vary among coff implementations...  */
2094
3.14k
  coff->local_n_btmask = N_BTMASK;
2095
3.14k
  coff->local_n_btshft = N_BTSHFT;
2096
3.14k
  coff->local_n_tmask = N_TMASK;
2097
3.14k
  coff->local_n_tshift = N_TSHIFT;
2098
3.14k
  coff->local_symesz = bfd_coff_symesz (abfd);
2099
3.14k
  coff->local_auxesz = bfd_coff_auxesz (abfd);
2100
3.14k
  coff->local_linesz = bfd_coff_linesz (abfd);
2101
2102
3.14k
  coff->timestamp = internal_f->f_timdat;
2103
2104
3.14k
  obj_raw_syment_count (abfd) =
2105
3.14k
    obj_conv_table_size (abfd) =
2106
3.14k
      internal_f->f_nsyms;
2107
2108
#ifdef RS6000COFF_C
2109
  if ((internal_f->f_flags & F_SHROBJ) != 0)
2110
    abfd->flags |= DYNAMIC;
2111
  if (aouthdr != NULL && internal_f->f_opthdr >= bfd_coff_aoutsz (abfd))
2112
    {
2113
      struct internal_aouthdr *internal_a =
2114
  (struct internal_aouthdr *) aouthdr;
2115
      struct xcoff_tdata *xcoff;
2116
2117
      xcoff = xcoff_data (abfd);
2118
# ifdef U803XTOCMAGIC
2119
      xcoff->xcoff64 = internal_f->f_magic == U803XTOCMAGIC;
2120
# else
2121
      xcoff->xcoff64 = 0;
2122
# endif
2123
      xcoff->full_aouthdr = true;
2124
      xcoff->toc = internal_a->o_toc;
2125
      xcoff->sntoc = internal_a->o_sntoc;
2126
      xcoff->snentry = internal_a->o_snentry;
2127
      bfd_xcoff_text_align_power (abfd) = internal_a->o_algntext;
2128
      bfd_xcoff_data_align_power (abfd) = internal_a->o_algndata;
2129
      xcoff->modtype = internal_a->o_modtype;
2130
      xcoff->cputype = internal_a->o_cputype;
2131
      xcoff->maxdata = internal_a->o_maxdata;
2132
      xcoff->maxstack = internal_a->o_maxstack;
2133
    }
2134
#endif
2135
2136
#ifdef ARM
2137
  /* Set the flags field from the COFF header read in.  */
2138
  if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags))
2139
    coff->flags = 0;
2140
#endif
2141
2142
#ifdef COFF_WITH_PE
2143
  /* FIXME: I'm not sure this is ever executed, since peicode.h
2144
     defines coff_mkobject_hook.  */
2145
  if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0)
2146
    abfd->flags |= HAS_DEBUG;
2147
#endif
2148
2149
3.14k
  return coff;
2150
3.14k
}
coff-z8k.c:coff_mkobject_hook
Line
Count
Source
2080
4.35k
{
2081
4.35k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2082
4.35k
  coff_data_type *coff;
2083
2084
4.35k
  if (! coff_mkobject (abfd))
2085
0
    return NULL;
2086
2087
4.35k
  coff = coff_data (abfd);
2088
2089
4.35k
  coff->sym_filepos = internal_f->f_symptr;
2090
2091
  /* These members communicate important constants about the symbol
2092
     table to GDB's symbol-reading code.  These `constants'
2093
     unfortunately vary among coff implementations...  */
2094
4.35k
  coff->local_n_btmask = N_BTMASK;
2095
4.35k
  coff->local_n_btshft = N_BTSHFT;
2096
4.35k
  coff->local_n_tmask = N_TMASK;
2097
4.35k
  coff->local_n_tshift = N_TSHIFT;
2098
4.35k
  coff->local_symesz = bfd_coff_symesz (abfd);
2099
4.35k
  coff->local_auxesz = bfd_coff_auxesz (abfd);
2100
4.35k
  coff->local_linesz = bfd_coff_linesz (abfd);
2101
2102
4.35k
  coff->timestamp = internal_f->f_timdat;
2103
2104
4.35k
  obj_raw_syment_count (abfd) =
2105
4.35k
    obj_conv_table_size (abfd) =
2106
4.35k
      internal_f->f_nsyms;
2107
2108
#ifdef RS6000COFF_C
2109
  if ((internal_f->f_flags & F_SHROBJ) != 0)
2110
    abfd->flags |= DYNAMIC;
2111
  if (aouthdr != NULL && internal_f->f_opthdr >= bfd_coff_aoutsz (abfd))
2112
    {
2113
      struct internal_aouthdr *internal_a =
2114
  (struct internal_aouthdr *) aouthdr;
2115
      struct xcoff_tdata *xcoff;
2116
2117
      xcoff = xcoff_data (abfd);
2118
# ifdef U803XTOCMAGIC
2119
      xcoff->xcoff64 = internal_f->f_magic == U803XTOCMAGIC;
2120
# else
2121
      xcoff->xcoff64 = 0;
2122
# endif
2123
      xcoff->full_aouthdr = true;
2124
      xcoff->toc = internal_a->o_toc;
2125
      xcoff->sntoc = internal_a->o_sntoc;
2126
      xcoff->snentry = internal_a->o_snentry;
2127
      bfd_xcoff_text_align_power (abfd) = internal_a->o_algntext;
2128
      bfd_xcoff_data_align_power (abfd) = internal_a->o_algndata;
2129
      xcoff->modtype = internal_a->o_modtype;
2130
      xcoff->cputype = internal_a->o_cputype;
2131
      xcoff->maxdata = internal_a->o_maxdata;
2132
      xcoff->maxstack = internal_a->o_maxstack;
2133
    }
2134
#endif
2135
2136
#ifdef ARM
2137
  /* Set the flags field from the COFF header read in.  */
2138
  if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags))
2139
    coff->flags = 0;
2140
#endif
2141
2142
#ifdef COFF_WITH_PE
2143
  /* FIXME: I'm not sure this is ever executed, since peicode.h
2144
     defines coff_mkobject_hook.  */
2145
  if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0)
2146
    abfd->flags |= HAS_DEBUG;
2147
#endif
2148
2149
4.35k
  return coff;
2150
4.35k
}
2151
#endif
2152
2153
/* Determine the machine architecture and type.  FIXME: This is target
2154
   dependent because the magic numbers are defined in the target
2155
   dependent header files.  But there is no particular need for this.
2156
   If the magic numbers were moved to a separate file, this function
2157
   would be target independent and would also be much more successful
2158
   at linking together COFF files for different architectures.  */
2159
2160
static bool
2161
coff_set_arch_mach_hook (bfd *abfd, void * filehdr)
2162
202k
{
2163
202k
  unsigned long machine;
2164
202k
  enum bfd_architecture arch;
2165
202k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
202k
  machine = 0;
2169
202k
  switch (internal_f->f_magic)
2170
202k
    {
2171
#ifdef I386MAGIC
2172
35.6k
    case I386MAGIC:
2173
37.2k
    case I386PTXMAGIC:
2174
38.8k
    case I386AIXMAGIC:   /* Danbury PS/2 AIX C Compiler.  */
2175
39.1k
    case LYNXCOFFMAGIC:
2176
39.3k
    case I386_APPLE_MAGIC:
2177
39.3k
    case I386_FREEBSD_MAGIC:
2178
39.3k
    case I386_LINUX_MAGIC:
2179
39.6k
    case I386_NETBSD_MAGIC:
2180
39.6k
      arch = bfd_arch_i386;
2181
39.6k
      break;
2182
0
#endif
2183
#ifdef AMD64MAGIC
2184
3.21k
    case AMD64MAGIC:
2185
39.5k
    case AMD64_APPLE_MAGIC:
2186
39.5k
    case AMD64_FREEBSD_MAGIC:
2187
39.6k
    case AMD64_LINUX_MAGIC:
2188
39.6k
    case AMD64_NETBSD_MAGIC:
2189
39.6k
      arch = bfd_arch_i386;
2190
39.6k
      machine = bfd_mach_x86_64;
2191
39.6k
      break;
2192
0
#endif
2193
#ifdef IA64MAGIC
2194
5.78k
    case IA64MAGIC:
2195
5.78k
      arch = bfd_arch_ia64;
2196
5.78k
      break;
2197
0
#endif
2198
#ifdef ARMMAGIC
2199
16.3k
    case ARMMAGIC:
2200
17.6k
    case ARMPEMAGIC:
2201
22.3k
    case THUMBPEMAGIC:
2202
22.3k
      arch = bfd_arch_arm;
2203
22.3k
      machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION);
2204
22.3k
      if (machine == bfd_mach_arm_unknown)
2205
22.3k
  {
2206
22.3k
    switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK)
2207
22.3k
      {
2208
2.18k
      case F_ARM_2:  machine = bfd_mach_arm_2;  break;
2209
3.30k
      case F_ARM_2a: machine = bfd_mach_arm_2a; break;
2210
60
      case F_ARM_3:  machine = bfd_mach_arm_3;  break;
2211
12.1k
      default:
2212
12.2k
      case F_ARM_3M: machine = bfd_mach_arm_3M; break;
2213
625
      case F_ARM_4:  machine = bfd_mach_arm_4;  break;
2214
1.66k
      case F_ARM_4T: machine = bfd_mach_arm_4T; break;
2215
        /* The COFF header does not have enough bits available
2216
     to cover all the different ARM architectures.  So
2217
     we interpret F_ARM_5, the highest flag value to mean
2218
     "the highest ARM architecture known to BFD" which is
2219
     currently the XScale.  */
2220
2.29k
      case F_ARM_5:  machine = bfd_mach_arm_XScale;  break;
2221
22.3k
      }
2222
22.3k
  }
2223
22.3k
      break;
2224
22.3k
#endif
2225
#ifdef AARCH64MAGIC
2226
10.0k
    case AARCH64MAGIC:
2227
10.0k
      arch = bfd_arch_aarch64;
2228
10.0k
      machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK;
2229
10.0k
      break;
2230
0
#endif
2231
#ifdef LOONGARCH64MAGIC
2232
6.70k
    case LOONGARCH64MAGIC:
2233
6.70k
      arch = bfd_arch_loongarch;
2234
6.70k
      machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK;
2235
6.70k
      break;
2236
0
#endif
2237
#ifdef Z80MAGIC
2238
3.13k
    case Z80MAGIC:
2239
3.13k
      arch = bfd_arch_z80;
2240
3.13k
      switch (internal_f->f_flags & F_MACHMASK)
2241
3.13k
  {
2242
172
  case bfd_mach_z80strict << 12:
2243
662
  case bfd_mach_z80 << 12:
2244
707
  case bfd_mach_z80n << 12:
2245
1.74k
  case bfd_mach_z80full << 12:
2246
2.01k
  case bfd_mach_r800 << 12:
2247
2.61k
  case bfd_mach_gbz80 << 12:
2248
2.77k
  case bfd_mach_z180 << 12:
2249
2.93k
  case bfd_mach_ez80_z80 << 12:
2250
3.03k
  case bfd_mach_ez80_adl << 12:
2251
3.03k
    machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12;
2252
3.03k
    break;
2253
102
  default:
2254
102
    return false;
2255
3.13k
  }
2256
3.03k
      break;
2257
3.03k
#endif
2258
#ifdef Z8KMAGIC
2259
4.35k
    case Z8KMAGIC:
2260
4.35k
      arch = bfd_arch_z8k;
2261
4.35k
      switch (internal_f->f_flags & F_MACHMASK)
2262
4.35k
  {
2263
1.08k
  case F_Z8001:
2264
1.08k
    machine = bfd_mach_z8001;
2265
1.08k
    break;
2266
3.16k
  case F_Z8002:
2267
3.16k
    machine = bfd_mach_z8002;
2268
3.16k
    break;
2269
105
  default:
2270
105
    return false;
2271
4.35k
  }
2272
4.24k
      break;
2273
4.24k
#endif
2274
2275
#ifdef RS6000COFF_C
2276
#ifdef XCOFF64
2277
7.55k
    case U64_TOCMAGIC:
2278
7.81k
    case U803XTOCMAGIC:
2279
#else
2280
1.84k
    case U802ROMAGIC:
2281
2.57k
    case U802WRMAGIC:
2282
8.11k
    case U802TOCMAGIC:
2283
#endif
2284
8.11k
      {
2285
8.11k
  int cputype;
2286
2287
15.9k
  if (xcoff_data (abfd)->cputype != -1)
2288
7.12k
    cputype = xcoff_data (abfd)->cputype & 0xff;
2289
8.80k
  else
2290
8.80k
    {
2291
      /* We did not get a value from the a.out header.  If the
2292
         file has not been stripped, we may be able to get the
2293
         architecture information from the first symbol, if it
2294
         is a .file symbol.  */
2295
8.80k
      if (obj_raw_syment_count (abfd) == 0)
2296
3.48k
        cputype = 0;
2297
5.31k
      else
2298
5.31k
        {
2299
5.31k
    bfd_byte *buf;
2300
5.31k
    struct internal_syment sym;
2301
5.31k
    bfd_size_type amt = bfd_coff_symesz (abfd);
2302
2303
5.31k
    if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
2304
110
      return false;
2305
5.20k
    buf = _bfd_malloc_and_read (abfd, amt, amt);
2306
5.20k
    if (buf == NULL)
2307
121
      return false;
2308
5.08k
    bfd_coff_swap_sym_in (abfd, buf, & sym);
2309
5.08k
    if (sym.n_sclass == C_FILE)
2310
147
      cputype = sym.n_type & 0xff;
2311
4.93k
    else
2312
4.93k
      cputype = 0;
2313
5.08k
    free (buf);
2314
5.08k
        }
2315
8.80k
    }
2316
2317
  /* FIXME: We don't handle all cases here.  */
2318
15.7k
  switch (cputype)
2319
15.7k
    {
2320
3.87k
    default:
2321
13.1k
    case 0:
2322
13.1k
      arch = bfd_xcoff_architecture (abfd);
2323
13.1k
      machine = bfd_xcoff_machine (abfd);
2324
13.1k
      break;
2325
2326
979
    case 1:
2327
979
      arch = bfd_arch_powerpc;
2328
979
      machine = bfd_mach_ppc_601;
2329
979
      break;
2330
241
    case 2: /* 64 bit PowerPC */
2331
241
      arch = bfd_arch_powerpc;
2332
241
      machine = bfd_mach_ppc_620;
2333
241
      break;
2334
1.31k
    case 3:
2335
1.31k
      arch = bfd_arch_powerpc;
2336
1.31k
      machine = bfd_mach_ppc;
2337
1.31k
      break;
2338
3
    case 4:
2339
3
      arch = bfd_arch_rs6000;
2340
3
      machine = bfd_mach_rs6k;
2341
3
      break;
2342
15.7k
    }
2343
15.7k
      }
2344
15.7k
      break;
2345
15.7k
#endif
2346
2347
#ifdef SH_ARCH_MAGIC_BIG
2348
18.6k
    case SH_ARCH_MAGIC_BIG:
2349
21.5k
    case SH_ARCH_MAGIC_LITTLE:
2350
#ifdef COFF_WITH_PE
2351
13.9k
    case SH_ARCH_MAGIC_WINCE:
2352
#endif
2353
13.9k
      arch = bfd_arch_sh;
2354
13.9k
      break;
2355
0
#endif
2356
2357
#ifdef MIPS_ARCH_MAGIC_WINCE
2358
    case MIPS_ARCH_MAGIC_WINCE:
2359
      arch = bfd_arch_mips;
2360
      break;
2361
#endif
2362
2363
#ifdef SPARCMAGIC
2364
    case SPARCMAGIC:
2365
#ifdef LYNXCOFFMAGIC
2366
    case LYNXCOFFMAGIC:
2367
#endif
2368
      arch = bfd_arch_sparc;
2369
      break;
2370
#endif
2371
2372
#ifdef TIC30MAGIC
2373
4.46k
    case TIC30MAGIC:
2374
4.46k
      arch = bfd_arch_tic30;
2375
4.46k
      break;
2376
0
#endif
2377
2378
#ifdef TICOFF0MAGIC
2379
#ifdef TICOFF_TARGET_ARCH
2380
      /* This TI COFF section should be used by all new TI COFF v0 targets.  */
2381
9.45k
    case TICOFF0MAGIC:
2382
9.45k
      arch = TICOFF_TARGET_ARCH;
2383
9.45k
      machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2384
9.45k
      break;
2385
0
#endif
2386
0
#endif
2387
2388
#ifdef TICOFF1MAGIC
2389
      /* This TI COFF section should be used by all new TI COFF v1/2 targets.  */
2390
      /* TI COFF1 and COFF2 use the target_id field to specify which arch.  */
2391
1.34k
    case TICOFF1MAGIC:
2392
1.34k
    case TICOFF2MAGIC:
2393
1.34k
      switch (internal_f->f_target_id)
2394
1.34k
  {
2395
0
#ifdef TI_TARGET_ID
2396
1.34k
  case TI_TARGET_ID:
2397
1.34k
    arch = TICOFF_TARGET_ARCH;
2398
1.34k
    machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2399
1.34k
    break;
2400
0
#endif
2401
0
  default:
2402
0
    arch = bfd_arch_obscure;
2403
0
    _bfd_error_handler
2404
0
      (_("unrecognized TI COFF target id '0x%x'"),
2405
0
       internal_f->f_target_id);
2406
0
    break;
2407
1.34k
  }
2408
1.34k
      break;
2409
1.34k
#endif
2410
2411
#ifdef MCOREMAGIC
2412
11.9k
    case MCOREMAGIC:
2413
11.9k
      arch = bfd_arch_mcore;
2414
11.9k
      break;
2415
0
#endif
2416
2417
1.57k
    default:      /* Unreadable input file type.  */
2418
1.57k
      arch = bfd_arch_obscure;
2419
1.57k
      break;
2420
202k
    }
2421
2422
202k
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
202k
  return true;
2424
202k
}
pei-i386.c:coff_set_arch_mach_hook
Line
Count
Source
2162
11.0k
{
2163
11.0k
  unsigned long machine;
2164
11.0k
  enum bfd_architecture arch;
2165
11.0k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
11.0k
  machine = 0;
2169
11.0k
  switch (internal_f->f_magic)
2170
11.0k
    {
2171
0
#ifdef I386MAGIC
2172
9.64k
    case I386MAGIC:
2173
10.6k
    case I386PTXMAGIC:
2174
11.0k
    case I386AIXMAGIC:   /* Danbury PS/2 AIX C Compiler.  */
2175
11.0k
    case LYNXCOFFMAGIC:
2176
11.0k
    case I386_APPLE_MAGIC:
2177
11.0k
    case I386_FREEBSD_MAGIC:
2178
11.0k
    case I386_LINUX_MAGIC:
2179
11.0k
    case I386_NETBSD_MAGIC:
2180
11.0k
      arch = bfd_arch_i386;
2181
11.0k
      break;
2182
0
#endif
2183
#ifdef AMD64MAGIC
2184
    case AMD64MAGIC:
2185
    case AMD64_APPLE_MAGIC:
2186
    case AMD64_FREEBSD_MAGIC:
2187
    case AMD64_LINUX_MAGIC:
2188
    case AMD64_NETBSD_MAGIC:
2189
      arch = bfd_arch_i386;
2190
      machine = bfd_mach_x86_64;
2191
      break;
2192
#endif
2193
#ifdef IA64MAGIC
2194
    case IA64MAGIC:
2195
      arch = bfd_arch_ia64;
2196
      break;
2197
#endif
2198
#ifdef ARMMAGIC
2199
    case ARMMAGIC:
2200
    case ARMPEMAGIC:
2201
    case THUMBPEMAGIC:
2202
      arch = bfd_arch_arm;
2203
      machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION);
2204
      if (machine == bfd_mach_arm_unknown)
2205
  {
2206
    switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK)
2207
      {
2208
      case F_ARM_2:  machine = bfd_mach_arm_2;  break;
2209
      case F_ARM_2a: machine = bfd_mach_arm_2a; break;
2210
      case F_ARM_3:  machine = bfd_mach_arm_3;  break;
2211
      default:
2212
      case F_ARM_3M: machine = bfd_mach_arm_3M; break;
2213
      case F_ARM_4:  machine = bfd_mach_arm_4;  break;
2214
      case F_ARM_4T: machine = bfd_mach_arm_4T; break;
2215
        /* The COFF header does not have enough bits available
2216
     to cover all the different ARM architectures.  So
2217
     we interpret F_ARM_5, the highest flag value to mean
2218
     "the highest ARM architecture known to BFD" which is
2219
     currently the XScale.  */
2220
      case F_ARM_5:  machine = bfd_mach_arm_XScale;  break;
2221
      }
2222
  }
2223
      break;
2224
#endif
2225
#ifdef AARCH64MAGIC
2226
    case AARCH64MAGIC:
2227
      arch = bfd_arch_aarch64;
2228
      machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK;
2229
      break;
2230
#endif
2231
#ifdef LOONGARCH64MAGIC
2232
    case LOONGARCH64MAGIC:
2233
      arch = bfd_arch_loongarch;
2234
      machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK;
2235
      break;
2236
#endif
2237
#ifdef Z80MAGIC
2238
    case Z80MAGIC:
2239
      arch = bfd_arch_z80;
2240
      switch (internal_f->f_flags & F_MACHMASK)
2241
  {
2242
  case bfd_mach_z80strict << 12:
2243
  case bfd_mach_z80 << 12:
2244
  case bfd_mach_z80n << 12:
2245
  case bfd_mach_z80full << 12:
2246
  case bfd_mach_r800 << 12:
2247
  case bfd_mach_gbz80 << 12:
2248
  case bfd_mach_z180 << 12:
2249
  case bfd_mach_ez80_z80 << 12:
2250
  case bfd_mach_ez80_adl << 12:
2251
    machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12;
2252
    break;
2253
  default:
2254
    return false;
2255
  }
2256
      break;
2257
#endif
2258
#ifdef Z8KMAGIC
2259
    case Z8KMAGIC:
2260
      arch = bfd_arch_z8k;
2261
      switch (internal_f->f_flags & F_MACHMASK)
2262
  {
2263
  case F_Z8001:
2264
    machine = bfd_mach_z8001;
2265
    break;
2266
  case F_Z8002:
2267
    machine = bfd_mach_z8002;
2268
    break;
2269
  default:
2270
    return false;
2271
  }
2272
      break;
2273
#endif
2274
2275
#ifdef RS6000COFF_C
2276
#ifdef XCOFF64
2277
    case U64_TOCMAGIC:
2278
    case U803XTOCMAGIC:
2279
#else
2280
    case U802ROMAGIC:
2281
    case U802WRMAGIC:
2282
    case U802TOCMAGIC:
2283
#endif
2284
      {
2285
  int cputype;
2286
2287
  if (xcoff_data (abfd)->cputype != -1)
2288
    cputype = xcoff_data (abfd)->cputype & 0xff;
2289
  else
2290
    {
2291
      /* We did not get a value from the a.out header.  If the
2292
         file has not been stripped, we may be able to get the
2293
         architecture information from the first symbol, if it
2294
         is a .file symbol.  */
2295
      if (obj_raw_syment_count (abfd) == 0)
2296
        cputype = 0;
2297
      else
2298
        {
2299
    bfd_byte *buf;
2300
    struct internal_syment sym;
2301
    bfd_size_type amt = bfd_coff_symesz (abfd);
2302
2303
    if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
2304
      return false;
2305
    buf = _bfd_malloc_and_read (abfd, amt, amt);
2306
    if (buf == NULL)
2307
      return false;
2308
    bfd_coff_swap_sym_in (abfd, buf, & sym);
2309
    if (sym.n_sclass == C_FILE)
2310
      cputype = sym.n_type & 0xff;
2311
    else
2312
      cputype = 0;
2313
    free (buf);
2314
        }
2315
    }
2316
2317
  /* FIXME: We don't handle all cases here.  */
2318
  switch (cputype)
2319
    {
2320
    default:
2321
    case 0:
2322
      arch = bfd_xcoff_architecture (abfd);
2323
      machine = bfd_xcoff_machine (abfd);
2324
      break;
2325
2326
    case 1:
2327
      arch = bfd_arch_powerpc;
2328
      machine = bfd_mach_ppc_601;
2329
      break;
2330
    case 2: /* 64 bit PowerPC */
2331
      arch = bfd_arch_powerpc;
2332
      machine = bfd_mach_ppc_620;
2333
      break;
2334
    case 3:
2335
      arch = bfd_arch_powerpc;
2336
      machine = bfd_mach_ppc;
2337
      break;
2338
    case 4:
2339
      arch = bfd_arch_rs6000;
2340
      machine = bfd_mach_rs6k;
2341
      break;
2342
    }
2343
      }
2344
      break;
2345
#endif
2346
2347
#ifdef SH_ARCH_MAGIC_BIG
2348
    case SH_ARCH_MAGIC_BIG:
2349
    case SH_ARCH_MAGIC_LITTLE:
2350
#ifdef COFF_WITH_PE
2351
    case SH_ARCH_MAGIC_WINCE:
2352
#endif
2353
      arch = bfd_arch_sh;
2354
      break;
2355
#endif
2356
2357
#ifdef MIPS_ARCH_MAGIC_WINCE
2358
    case MIPS_ARCH_MAGIC_WINCE:
2359
      arch = bfd_arch_mips;
2360
      break;
2361
#endif
2362
2363
#ifdef SPARCMAGIC
2364
    case SPARCMAGIC:
2365
#ifdef LYNXCOFFMAGIC
2366
    case LYNXCOFFMAGIC:
2367
#endif
2368
      arch = bfd_arch_sparc;
2369
      break;
2370
#endif
2371
2372
#ifdef TIC30MAGIC
2373
    case TIC30MAGIC:
2374
      arch = bfd_arch_tic30;
2375
      break;
2376
#endif
2377
2378
#ifdef TICOFF0MAGIC
2379
#ifdef TICOFF_TARGET_ARCH
2380
      /* This TI COFF section should be used by all new TI COFF v0 targets.  */
2381
    case TICOFF0MAGIC:
2382
      arch = TICOFF_TARGET_ARCH;
2383
      machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2384
      break;
2385
#endif
2386
#endif
2387
2388
#ifdef TICOFF1MAGIC
2389
      /* This TI COFF section should be used by all new TI COFF v1/2 targets.  */
2390
      /* TI COFF1 and COFF2 use the target_id field to specify which arch.  */
2391
    case TICOFF1MAGIC:
2392
    case TICOFF2MAGIC:
2393
      switch (internal_f->f_target_id)
2394
  {
2395
#ifdef TI_TARGET_ID
2396
  case TI_TARGET_ID:
2397
    arch = TICOFF_TARGET_ARCH;
2398
    machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2399
    break;
2400
#endif
2401
  default:
2402
    arch = bfd_arch_obscure;
2403
    _bfd_error_handler
2404
      (_("unrecognized TI COFF target id '0x%x'"),
2405
       internal_f->f_target_id);
2406
    break;
2407
  }
2408
      break;
2409
#endif
2410
2411
#ifdef MCOREMAGIC
2412
    case MCOREMAGIC:
2413
      arch = bfd_arch_mcore;
2414
      break;
2415
#endif
2416
2417
0
    default:      /* Unreadable input file type.  */
2418
0
      arch = bfd_arch_obscure;
2419
0
      break;
2420
11.0k
    }
2421
2422
11.0k
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
11.0k
  return true;
2424
11.0k
}
pe-x86_64.c:coff_set_arch_mach_hook
Line
Count
Source
2162
15.7k
{
2163
15.7k
  unsigned long machine;
2164
15.7k
  enum bfd_architecture arch;
2165
15.7k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
15.7k
  machine = 0;
2169
15.7k
  switch (internal_f->f_magic)
2170
15.7k
    {
2171
#ifdef I386MAGIC
2172
    case I386MAGIC:
2173
    case I386PTXMAGIC:
2174
    case I386AIXMAGIC:    /* Danbury PS/2 AIX C Compiler.  */
2175
    case LYNXCOFFMAGIC:
2176
    case I386_APPLE_MAGIC:
2177
    case I386_FREEBSD_MAGIC:
2178
    case I386_LINUX_MAGIC:
2179
    case I386_NETBSD_MAGIC:
2180
      arch = bfd_arch_i386;
2181
      break;
2182
#endif
2183
0
#ifdef AMD64MAGIC
2184
65
    case AMD64MAGIC:
2185
15.7k
    case AMD64_APPLE_MAGIC:
2186
15.7k
    case AMD64_FREEBSD_MAGIC:
2187
15.7k
    case AMD64_LINUX_MAGIC:
2188
15.7k
    case AMD64_NETBSD_MAGIC:
2189
15.7k
      arch = bfd_arch_i386;
2190
15.7k
      machine = bfd_mach_x86_64;
2191
15.7k
      break;
2192
0
#endif
2193
#ifdef IA64MAGIC
2194
    case IA64MAGIC:
2195
      arch = bfd_arch_ia64;
2196
      break;
2197
#endif
2198
#ifdef ARMMAGIC
2199
    case ARMMAGIC:
2200
    case ARMPEMAGIC:
2201
    case THUMBPEMAGIC:
2202
      arch = bfd_arch_arm;
2203
      machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION);
2204
      if (machine == bfd_mach_arm_unknown)
2205
  {
2206
    switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK)
2207
      {
2208
      case F_ARM_2:  machine = bfd_mach_arm_2;  break;
2209
      case F_ARM_2a: machine = bfd_mach_arm_2a; break;
2210
      case F_ARM_3:  machine = bfd_mach_arm_3;  break;
2211
      default:
2212
      case F_ARM_3M: machine = bfd_mach_arm_3M; break;
2213
      case F_ARM_4:  machine = bfd_mach_arm_4;  break;
2214
      case F_ARM_4T: machine = bfd_mach_arm_4T; break;
2215
        /* The COFF header does not have enough bits available
2216
     to cover all the different ARM architectures.  So
2217
     we interpret F_ARM_5, the highest flag value to mean
2218
     "the highest ARM architecture known to BFD" which is
2219
     currently the XScale.  */
2220
      case F_ARM_5:  machine = bfd_mach_arm_XScale;  break;
2221
      }
2222
  }
2223
      break;
2224
#endif
2225
#ifdef AARCH64MAGIC
2226
    case AARCH64MAGIC:
2227
      arch = bfd_arch_aarch64;
2228
      machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK;
2229
      break;
2230
#endif
2231
#ifdef LOONGARCH64MAGIC
2232
    case LOONGARCH64MAGIC:
2233
      arch = bfd_arch_loongarch;
2234
      machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK;
2235
      break;
2236
#endif
2237
#ifdef Z80MAGIC
2238
    case Z80MAGIC:
2239
      arch = bfd_arch_z80;
2240
      switch (internal_f->f_flags & F_MACHMASK)
2241
  {
2242
  case bfd_mach_z80strict << 12:
2243
  case bfd_mach_z80 << 12:
2244
  case bfd_mach_z80n << 12:
2245
  case bfd_mach_z80full << 12:
2246
  case bfd_mach_r800 << 12:
2247
  case bfd_mach_gbz80 << 12:
2248
  case bfd_mach_z180 << 12:
2249
  case bfd_mach_ez80_z80 << 12:
2250
  case bfd_mach_ez80_adl << 12:
2251
    machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12;
2252
    break;
2253
  default:
2254
    return false;
2255
  }
2256
      break;
2257
#endif
2258
#ifdef Z8KMAGIC
2259
    case Z8KMAGIC:
2260
      arch = bfd_arch_z8k;
2261
      switch (internal_f->f_flags & F_MACHMASK)
2262
  {
2263
  case F_Z8001:
2264
    machine = bfd_mach_z8001;
2265
    break;
2266
  case F_Z8002:
2267
    machine = bfd_mach_z8002;
2268
    break;
2269
  default:
2270
    return false;
2271
  }
2272
      break;
2273
#endif
2274
2275
#ifdef RS6000COFF_C
2276
#ifdef XCOFF64
2277
    case U64_TOCMAGIC:
2278
    case U803XTOCMAGIC:
2279
#else
2280
    case U802ROMAGIC:
2281
    case U802WRMAGIC:
2282
    case U802TOCMAGIC:
2283
#endif
2284
      {
2285
  int cputype;
2286
2287
  if (xcoff_data (abfd)->cputype != -1)
2288
    cputype = xcoff_data (abfd)->cputype & 0xff;
2289
  else
2290
    {
2291
      /* We did not get a value from the a.out header.  If the
2292
         file has not been stripped, we may be able to get the
2293
         architecture information from the first symbol, if it
2294
         is a .file symbol.  */
2295
      if (obj_raw_syment_count (abfd) == 0)
2296
        cputype = 0;
2297
      else
2298
        {
2299
    bfd_byte *buf;
2300
    struct internal_syment sym;
2301
    bfd_size_type amt = bfd_coff_symesz (abfd);
2302
2303
    if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
2304
      return false;
2305
    buf = _bfd_malloc_and_read (abfd, amt, amt);
2306
    if (buf == NULL)
2307
      return false;
2308
    bfd_coff_swap_sym_in (abfd, buf, & sym);
2309
    if (sym.n_sclass == C_FILE)
2310
      cputype = sym.n_type & 0xff;
2311
    else
2312
      cputype = 0;
2313
    free (buf);
2314
        }
2315
    }
2316
2317
  /* FIXME: We don't handle all cases here.  */
2318
  switch (cputype)
2319
    {
2320
    default:
2321
    case 0:
2322
      arch = bfd_xcoff_architecture (abfd);
2323
      machine = bfd_xcoff_machine (abfd);
2324
      break;
2325
2326
    case 1:
2327
      arch = bfd_arch_powerpc;
2328
      machine = bfd_mach_ppc_601;
2329
      break;
2330
    case 2: /* 64 bit PowerPC */
2331
      arch = bfd_arch_powerpc;
2332
      machine = bfd_mach_ppc_620;
2333
      break;
2334
    case 3:
2335
      arch = bfd_arch_powerpc;
2336
      machine = bfd_mach_ppc;
2337
      break;
2338
    case 4:
2339
      arch = bfd_arch_rs6000;
2340
      machine = bfd_mach_rs6k;
2341
      break;
2342
    }
2343
      }
2344
      break;
2345
#endif
2346
2347
#ifdef SH_ARCH_MAGIC_BIG
2348
    case SH_ARCH_MAGIC_BIG:
2349
    case SH_ARCH_MAGIC_LITTLE:
2350
#ifdef COFF_WITH_PE
2351
    case SH_ARCH_MAGIC_WINCE:
2352
#endif
2353
      arch = bfd_arch_sh;
2354
      break;
2355
#endif
2356
2357
#ifdef MIPS_ARCH_MAGIC_WINCE
2358
    case MIPS_ARCH_MAGIC_WINCE:
2359
      arch = bfd_arch_mips;
2360
      break;
2361
#endif
2362
2363
#ifdef SPARCMAGIC
2364
    case SPARCMAGIC:
2365
#ifdef LYNXCOFFMAGIC
2366
    case LYNXCOFFMAGIC:
2367
#endif
2368
      arch = bfd_arch_sparc;
2369
      break;
2370
#endif
2371
2372
#ifdef TIC30MAGIC
2373
    case TIC30MAGIC:
2374
      arch = bfd_arch_tic30;
2375
      break;
2376
#endif
2377
2378
#ifdef TICOFF0MAGIC
2379
#ifdef TICOFF_TARGET_ARCH
2380
      /* This TI COFF section should be used by all new TI COFF v0 targets.  */
2381
    case TICOFF0MAGIC:
2382
      arch = TICOFF_TARGET_ARCH;
2383
      machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2384
      break;
2385
#endif
2386
#endif
2387
2388
#ifdef TICOFF1MAGIC
2389
      /* This TI COFF section should be used by all new TI COFF v1/2 targets.  */
2390
      /* TI COFF1 and COFF2 use the target_id field to specify which arch.  */
2391
    case TICOFF1MAGIC:
2392
    case TICOFF2MAGIC:
2393
      switch (internal_f->f_target_id)
2394
  {
2395
#ifdef TI_TARGET_ID
2396
  case TI_TARGET_ID:
2397
    arch = TICOFF_TARGET_ARCH;
2398
    machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2399
    break;
2400
#endif
2401
  default:
2402
    arch = bfd_arch_obscure;
2403
    _bfd_error_handler
2404
      (_("unrecognized TI COFF target id '0x%x'"),
2405
       internal_f->f_target_id);
2406
    break;
2407
  }
2408
      break;
2409
#endif
2410
2411
#ifdef MCOREMAGIC
2412
    case MCOREMAGIC:
2413
      arch = bfd_arch_mcore;
2414
      break;
2415
#endif
2416
2417
0
    default:      /* Unreadable input file type.  */
2418
0
      arch = bfd_arch_obscure;
2419
0
      break;
2420
15.7k
    }
2421
2422
15.7k
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
15.7k
  return true;
2424
15.7k
}
pei-x86_64.c:coff_set_arch_mach_hook
Line
Count
Source
2162
11.3k
{
2163
11.3k
  unsigned long machine;
2164
11.3k
  enum bfd_architecture arch;
2165
11.3k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
11.3k
  machine = 0;
2169
11.3k
  switch (internal_f->f_magic)
2170
11.3k
    {
2171
#ifdef I386MAGIC
2172
    case I386MAGIC:
2173
    case I386PTXMAGIC:
2174
    case I386AIXMAGIC:    /* Danbury PS/2 AIX C Compiler.  */
2175
    case LYNXCOFFMAGIC:
2176
    case I386_APPLE_MAGIC:
2177
    case I386_FREEBSD_MAGIC:
2178
    case I386_LINUX_MAGIC:
2179
    case I386_NETBSD_MAGIC:
2180
      arch = bfd_arch_i386;
2181
      break;
2182
#endif
2183
0
#ifdef AMD64MAGIC
2184
3.10k
    case AMD64MAGIC:
2185
11.2k
    case AMD64_APPLE_MAGIC:
2186
11.2k
    case AMD64_FREEBSD_MAGIC:
2187
11.2k
    case AMD64_LINUX_MAGIC:
2188
11.3k
    case AMD64_NETBSD_MAGIC:
2189
11.3k
      arch = bfd_arch_i386;
2190
11.3k
      machine = bfd_mach_x86_64;
2191
11.3k
      break;
2192
0
#endif
2193
#ifdef IA64MAGIC
2194
    case IA64MAGIC:
2195
      arch = bfd_arch_ia64;
2196
      break;
2197
#endif
2198
#ifdef ARMMAGIC
2199
    case ARMMAGIC:
2200
    case ARMPEMAGIC:
2201
    case THUMBPEMAGIC:
2202
      arch = bfd_arch_arm;
2203
      machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION);
2204
      if (machine == bfd_mach_arm_unknown)
2205
  {
2206
    switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK)
2207
      {
2208
      case F_ARM_2:  machine = bfd_mach_arm_2;  break;
2209
      case F_ARM_2a: machine = bfd_mach_arm_2a; break;
2210
      case F_ARM_3:  machine = bfd_mach_arm_3;  break;
2211
      default:
2212
      case F_ARM_3M: machine = bfd_mach_arm_3M; break;
2213
      case F_ARM_4:  machine = bfd_mach_arm_4;  break;
2214
      case F_ARM_4T: machine = bfd_mach_arm_4T; break;
2215
        /* The COFF header does not have enough bits available
2216
     to cover all the different ARM architectures.  So
2217
     we interpret F_ARM_5, the highest flag value to mean
2218
     "the highest ARM architecture known to BFD" which is
2219
     currently the XScale.  */
2220
      case F_ARM_5:  machine = bfd_mach_arm_XScale;  break;
2221
      }
2222
  }
2223
      break;
2224
#endif
2225
#ifdef AARCH64MAGIC
2226
    case AARCH64MAGIC:
2227
      arch = bfd_arch_aarch64;
2228
      machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK;
2229
      break;
2230
#endif
2231
#ifdef LOONGARCH64MAGIC
2232
    case LOONGARCH64MAGIC:
2233
      arch = bfd_arch_loongarch;
2234
      machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK;
2235
      break;
2236
#endif
2237
#ifdef Z80MAGIC
2238
    case Z80MAGIC:
2239
      arch = bfd_arch_z80;
2240
      switch (internal_f->f_flags & F_MACHMASK)
2241
  {
2242
  case bfd_mach_z80strict << 12:
2243
  case bfd_mach_z80 << 12:
2244
  case bfd_mach_z80n << 12:
2245
  case bfd_mach_z80full << 12:
2246
  case bfd_mach_r800 << 12:
2247
  case bfd_mach_gbz80 << 12:
2248
  case bfd_mach_z180 << 12:
2249
  case bfd_mach_ez80_z80 << 12:
2250
  case bfd_mach_ez80_adl << 12:
2251
    machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12;
2252
    break;
2253
  default:
2254
    return false;
2255
  }
2256
      break;
2257
#endif
2258
#ifdef Z8KMAGIC
2259
    case Z8KMAGIC:
2260
      arch = bfd_arch_z8k;
2261
      switch (internal_f->f_flags & F_MACHMASK)
2262
  {
2263
  case F_Z8001:
2264
    machine = bfd_mach_z8001;
2265
    break;
2266
  case F_Z8002:
2267
    machine = bfd_mach_z8002;
2268
    break;
2269
  default:
2270
    return false;
2271
  }
2272
      break;
2273
#endif
2274
2275
#ifdef RS6000COFF_C
2276
#ifdef XCOFF64
2277
    case U64_TOCMAGIC:
2278
    case U803XTOCMAGIC:
2279
#else
2280
    case U802ROMAGIC:
2281
    case U802WRMAGIC:
2282
    case U802TOCMAGIC:
2283
#endif
2284
      {
2285
  int cputype;
2286
2287
  if (xcoff_data (abfd)->cputype != -1)
2288
    cputype = xcoff_data (abfd)->cputype & 0xff;
2289
  else
2290
    {
2291
      /* We did not get a value from the a.out header.  If the
2292
         file has not been stripped, we may be able to get the
2293
         architecture information from the first symbol, if it
2294
         is a .file symbol.  */
2295
      if (obj_raw_syment_count (abfd) == 0)
2296
        cputype = 0;
2297
      else
2298
        {
2299
    bfd_byte *buf;
2300
    struct internal_syment sym;
2301
    bfd_size_type amt = bfd_coff_symesz (abfd);
2302
2303
    if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
2304
      return false;
2305
    buf = _bfd_malloc_and_read (abfd, amt, amt);
2306
    if (buf == NULL)
2307
      return false;
2308
    bfd_coff_swap_sym_in (abfd, buf, & sym);
2309
    if (sym.n_sclass == C_FILE)
2310
      cputype = sym.n_type & 0xff;
2311
    else
2312
      cputype = 0;
2313
    free (buf);
2314
        }
2315
    }
2316
2317
  /* FIXME: We don't handle all cases here.  */
2318
  switch (cputype)
2319
    {
2320
    default:
2321
    case 0:
2322
      arch = bfd_xcoff_architecture (abfd);
2323
      machine = bfd_xcoff_machine (abfd);
2324
      break;
2325
2326
    case 1:
2327
      arch = bfd_arch_powerpc;
2328
      machine = bfd_mach_ppc_601;
2329
      break;
2330
    case 2: /* 64 bit PowerPC */
2331
      arch = bfd_arch_powerpc;
2332
      machine = bfd_mach_ppc_620;
2333
      break;
2334
    case 3:
2335
      arch = bfd_arch_powerpc;
2336
      machine = bfd_mach_ppc;
2337
      break;
2338
    case 4:
2339
      arch = bfd_arch_rs6000;
2340
      machine = bfd_mach_rs6k;
2341
      break;
2342
    }
2343
      }
2344
      break;
2345
#endif
2346
2347
#ifdef SH_ARCH_MAGIC_BIG
2348
    case SH_ARCH_MAGIC_BIG:
2349
    case SH_ARCH_MAGIC_LITTLE:
2350
#ifdef COFF_WITH_PE
2351
    case SH_ARCH_MAGIC_WINCE:
2352
#endif
2353
      arch = bfd_arch_sh;
2354
      break;
2355
#endif
2356
2357
#ifdef MIPS_ARCH_MAGIC_WINCE
2358
    case MIPS_ARCH_MAGIC_WINCE:
2359
      arch = bfd_arch_mips;
2360
      break;
2361
#endif
2362
2363
#ifdef SPARCMAGIC
2364
    case SPARCMAGIC:
2365
#ifdef LYNXCOFFMAGIC
2366
    case LYNXCOFFMAGIC:
2367
#endif
2368
      arch = bfd_arch_sparc;
2369
      break;
2370
#endif
2371
2372
#ifdef TIC30MAGIC
2373
    case TIC30MAGIC:
2374
      arch = bfd_arch_tic30;
2375
      break;
2376
#endif
2377
2378
#ifdef TICOFF0MAGIC
2379
#ifdef TICOFF_TARGET_ARCH
2380
      /* This TI COFF section should be used by all new TI COFF v0 targets.  */
2381
    case TICOFF0MAGIC:
2382
      arch = TICOFF_TARGET_ARCH;
2383
      machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2384
      break;
2385
#endif
2386
#endif
2387
2388
#ifdef TICOFF1MAGIC
2389
      /* This TI COFF section should be used by all new TI COFF v1/2 targets.  */
2390
      /* TI COFF1 and COFF2 use the target_id field to specify which arch.  */
2391
    case TICOFF1MAGIC:
2392
    case TICOFF2MAGIC:
2393
      switch (internal_f->f_target_id)
2394
  {
2395
#ifdef TI_TARGET_ID
2396
  case TI_TARGET_ID:
2397
    arch = TICOFF_TARGET_ARCH;
2398
    machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2399
    break;
2400
#endif
2401
  default:
2402
    arch = bfd_arch_obscure;
2403
    _bfd_error_handler
2404
      (_("unrecognized TI COFF target id '0x%x'"),
2405
       internal_f->f_target_id);
2406
    break;
2407
  }
2408
      break;
2409
#endif
2410
2411
#ifdef MCOREMAGIC
2412
    case MCOREMAGIC:
2413
      arch = bfd_arch_mcore;
2414
      break;
2415
#endif
2416
2417
0
    default:      /* Unreadable input file type.  */
2418
0
      arch = bfd_arch_obscure;
2419
0
      break;
2420
11.3k
    }
2421
2422
11.3k
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
11.3k
  return true;
2424
11.3k
}
coff-x86_64.c:coff_set_arch_mach_hook
Line
Count
Source
2162
12.5k
{
2163
12.5k
  unsigned long machine;
2164
12.5k
  enum bfd_architecture arch;
2165
12.5k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
12.5k
  machine = 0;
2169
12.5k
  switch (internal_f->f_magic)
2170
12.5k
    {
2171
#ifdef I386MAGIC
2172
    case I386MAGIC:
2173
    case I386PTXMAGIC:
2174
    case I386AIXMAGIC:    /* Danbury PS/2 AIX C Compiler.  */
2175
    case LYNXCOFFMAGIC:
2176
    case I386_APPLE_MAGIC:
2177
    case I386_FREEBSD_MAGIC:
2178
    case I386_LINUX_MAGIC:
2179
    case I386_NETBSD_MAGIC:
2180
      arch = bfd_arch_i386;
2181
      break;
2182
#endif
2183
0
#ifdef AMD64MAGIC
2184
41
    case AMD64MAGIC:
2185
12.5k
    case AMD64_APPLE_MAGIC:
2186
12.5k
    case AMD64_FREEBSD_MAGIC:
2187
12.5k
    case AMD64_LINUX_MAGIC:
2188
12.5k
    case AMD64_NETBSD_MAGIC:
2189
12.5k
      arch = bfd_arch_i386;
2190
12.5k
      machine = bfd_mach_x86_64;
2191
12.5k
      break;
2192
0
#endif
2193
#ifdef IA64MAGIC
2194
    case IA64MAGIC:
2195
      arch = bfd_arch_ia64;
2196
      break;
2197
#endif
2198
#ifdef ARMMAGIC
2199
    case ARMMAGIC:
2200
    case ARMPEMAGIC:
2201
    case THUMBPEMAGIC:
2202
      arch = bfd_arch_arm;
2203
      machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION);
2204
      if (machine == bfd_mach_arm_unknown)
2205
  {
2206
    switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK)
2207
      {
2208
      case F_ARM_2:  machine = bfd_mach_arm_2;  break;
2209
      case F_ARM_2a: machine = bfd_mach_arm_2a; break;
2210
      case F_ARM_3:  machine = bfd_mach_arm_3;  break;
2211
      default:
2212
      case F_ARM_3M: machine = bfd_mach_arm_3M; break;
2213
      case F_ARM_4:  machine = bfd_mach_arm_4;  break;
2214
      case F_ARM_4T: machine = bfd_mach_arm_4T; break;
2215
        /* The COFF header does not have enough bits available
2216
     to cover all the different ARM architectures.  So
2217
     we interpret F_ARM_5, the highest flag value to mean
2218
     "the highest ARM architecture known to BFD" which is
2219
     currently the XScale.  */
2220
      case F_ARM_5:  machine = bfd_mach_arm_XScale;  break;
2221
      }
2222
  }
2223
      break;
2224
#endif
2225
#ifdef AARCH64MAGIC
2226
    case AARCH64MAGIC:
2227
      arch = bfd_arch_aarch64;
2228
      machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK;
2229
      break;
2230
#endif
2231
#ifdef LOONGARCH64MAGIC
2232
    case LOONGARCH64MAGIC:
2233
      arch = bfd_arch_loongarch;
2234
      machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK;
2235
      break;
2236
#endif
2237
#ifdef Z80MAGIC
2238
    case Z80MAGIC:
2239
      arch = bfd_arch_z80;
2240
      switch (internal_f->f_flags & F_MACHMASK)
2241
  {
2242
  case bfd_mach_z80strict << 12:
2243
  case bfd_mach_z80 << 12:
2244
  case bfd_mach_z80n << 12:
2245
  case bfd_mach_z80full << 12:
2246
  case bfd_mach_r800 << 12:
2247
  case bfd_mach_gbz80 << 12:
2248
  case bfd_mach_z180 << 12:
2249
  case bfd_mach_ez80_z80 << 12:
2250
  case bfd_mach_ez80_adl << 12:
2251
    machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12;
2252
    break;
2253
  default:
2254
    return false;
2255
  }
2256
      break;
2257
#endif
2258
#ifdef Z8KMAGIC
2259
    case Z8KMAGIC:
2260
      arch = bfd_arch_z8k;
2261
      switch (internal_f->f_flags & F_MACHMASK)
2262
  {
2263
  case F_Z8001:
2264
    machine = bfd_mach_z8001;
2265
    break;
2266
  case F_Z8002:
2267
    machine = bfd_mach_z8002;
2268
    break;
2269
  default:
2270
    return false;
2271
  }
2272
      break;
2273
#endif
2274
2275
#ifdef RS6000COFF_C
2276
#ifdef XCOFF64
2277
    case U64_TOCMAGIC:
2278
    case U803XTOCMAGIC:
2279
#else
2280
    case U802ROMAGIC:
2281
    case U802WRMAGIC:
2282
    case U802TOCMAGIC:
2283
#endif
2284
      {
2285
  int cputype;
2286
2287
  if (xcoff_data (abfd)->cputype != -1)
2288
    cputype = xcoff_data (abfd)->cputype & 0xff;
2289
  else
2290
    {
2291
      /* We did not get a value from the a.out header.  If the
2292
         file has not been stripped, we may be able to get the
2293
         architecture information from the first symbol, if it
2294
         is a .file symbol.  */
2295
      if (obj_raw_syment_count (abfd) == 0)
2296
        cputype = 0;
2297
      else
2298
        {
2299
    bfd_byte *buf;
2300
    struct internal_syment sym;
2301
    bfd_size_type amt = bfd_coff_symesz (abfd);
2302
2303
    if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
2304
      return false;
2305
    buf = _bfd_malloc_and_read (abfd, amt, amt);
2306
    if (buf == NULL)
2307
      return false;
2308
    bfd_coff_swap_sym_in (abfd, buf, & sym);
2309
    if (sym.n_sclass == C_FILE)
2310
      cputype = sym.n_type & 0xff;
2311
    else
2312
      cputype = 0;
2313
    free (buf);
2314
        }
2315
    }
2316
2317
  /* FIXME: We don't handle all cases here.  */
2318
  switch (cputype)
2319
    {
2320
    default:
2321
    case 0:
2322
      arch = bfd_xcoff_architecture (abfd);
2323
      machine = bfd_xcoff_machine (abfd);
2324
      break;
2325
2326
    case 1:
2327
      arch = bfd_arch_powerpc;
2328
      machine = bfd_mach_ppc_601;
2329
      break;
2330
    case 2: /* 64 bit PowerPC */
2331
      arch = bfd_arch_powerpc;
2332
      machine = bfd_mach_ppc_620;
2333
      break;
2334
    case 3:
2335
      arch = bfd_arch_powerpc;
2336
      machine = bfd_mach_ppc;
2337
      break;
2338
    case 4:
2339
      arch = bfd_arch_rs6000;
2340
      machine = bfd_mach_rs6k;
2341
      break;
2342
    }
2343
      }
2344
      break;
2345
#endif
2346
2347
#ifdef SH_ARCH_MAGIC_BIG
2348
    case SH_ARCH_MAGIC_BIG:
2349
    case SH_ARCH_MAGIC_LITTLE:
2350
#ifdef COFF_WITH_PE
2351
    case SH_ARCH_MAGIC_WINCE:
2352
#endif
2353
      arch = bfd_arch_sh;
2354
      break;
2355
#endif
2356
2357
#ifdef MIPS_ARCH_MAGIC_WINCE
2358
    case MIPS_ARCH_MAGIC_WINCE:
2359
      arch = bfd_arch_mips;
2360
      break;
2361
#endif
2362
2363
#ifdef SPARCMAGIC
2364
    case SPARCMAGIC:
2365
#ifdef LYNXCOFFMAGIC
2366
    case LYNXCOFFMAGIC:
2367
#endif
2368
      arch = bfd_arch_sparc;
2369
      break;
2370
#endif
2371
2372
#ifdef TIC30MAGIC
2373
    case TIC30MAGIC:
2374
      arch = bfd_arch_tic30;
2375
      break;
2376
#endif
2377
2378
#ifdef TICOFF0MAGIC
2379
#ifdef TICOFF_TARGET_ARCH
2380
      /* This TI COFF section should be used by all new TI COFF v0 targets.  */
2381
    case TICOFF0MAGIC:
2382
      arch = TICOFF_TARGET_ARCH;
2383
      machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2384
      break;
2385
#endif
2386
#endif
2387
2388
#ifdef TICOFF1MAGIC
2389
      /* This TI COFF section should be used by all new TI COFF v1/2 targets.  */
2390
      /* TI COFF1 and COFF2 use the target_id field to specify which arch.  */
2391
    case TICOFF1MAGIC:
2392
    case TICOFF2MAGIC:
2393
      switch (internal_f->f_target_id)
2394
  {
2395
#ifdef TI_TARGET_ID
2396
  case TI_TARGET_ID:
2397
    arch = TICOFF_TARGET_ARCH;
2398
    machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2399
    break;
2400
#endif
2401
  default:
2402
    arch = bfd_arch_obscure;
2403
    _bfd_error_handler
2404
      (_("unrecognized TI COFF target id '0x%x'"),
2405
       internal_f->f_target_id);
2406
    break;
2407
  }
2408
      break;
2409
#endif
2410
2411
#ifdef MCOREMAGIC
2412
    case MCOREMAGIC:
2413
      arch = bfd_arch_mcore;
2414
      break;
2415
#endif
2416
2417
0
    default:      /* Unreadable input file type.  */
2418
0
      arch = bfd_arch_obscure;
2419
0
      break;
2420
12.5k
    }
2421
2422
12.5k
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
12.5k
  return true;
2424
12.5k
}
coff64-rs6000.c:coff_set_arch_mach_hook
Line
Count
Source
2162
7.81k
{
2163
7.81k
  unsigned long machine;
2164
7.81k
  enum bfd_architecture arch;
2165
7.81k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
7.81k
  machine = 0;
2169
7.81k
  switch (internal_f->f_magic)
2170
7.81k
    {
2171
#ifdef I386MAGIC
2172
    case I386MAGIC:
2173
    case I386PTXMAGIC:
2174
    case I386AIXMAGIC:    /* Danbury PS/2 AIX C Compiler.  */
2175
    case LYNXCOFFMAGIC:
2176
    case I386_APPLE_MAGIC:
2177
    case I386_FREEBSD_MAGIC:
2178
    case I386_LINUX_MAGIC:
2179
    case I386_NETBSD_MAGIC:
2180
      arch = bfd_arch_i386;
2181
      break;
2182
#endif
2183
#ifdef AMD64MAGIC
2184
    case AMD64MAGIC:
2185
    case AMD64_APPLE_MAGIC:
2186
    case AMD64_FREEBSD_MAGIC:
2187
    case AMD64_LINUX_MAGIC:
2188
    case AMD64_NETBSD_MAGIC:
2189
      arch = bfd_arch_i386;
2190
      machine = bfd_mach_x86_64;
2191
      break;
2192
#endif
2193
#ifdef IA64MAGIC
2194
    case IA64MAGIC:
2195
      arch = bfd_arch_ia64;
2196
      break;
2197
#endif
2198
#ifdef ARMMAGIC
2199
    case ARMMAGIC:
2200
    case ARMPEMAGIC:
2201
    case THUMBPEMAGIC:
2202
      arch = bfd_arch_arm;
2203
      machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION);
2204
      if (machine == bfd_mach_arm_unknown)
2205
  {
2206
    switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK)
2207
      {
2208
      case F_ARM_2:  machine = bfd_mach_arm_2;  break;
2209
      case F_ARM_2a: machine = bfd_mach_arm_2a; break;
2210
      case F_ARM_3:  machine = bfd_mach_arm_3;  break;
2211
      default:
2212
      case F_ARM_3M: machine = bfd_mach_arm_3M; break;
2213
      case F_ARM_4:  machine = bfd_mach_arm_4;  break;
2214
      case F_ARM_4T: machine = bfd_mach_arm_4T; break;
2215
        /* The COFF header does not have enough bits available
2216
     to cover all the different ARM architectures.  So
2217
     we interpret F_ARM_5, the highest flag value to mean
2218
     "the highest ARM architecture known to BFD" which is
2219
     currently the XScale.  */
2220
      case F_ARM_5:  machine = bfd_mach_arm_XScale;  break;
2221
      }
2222
  }
2223
      break;
2224
#endif
2225
#ifdef AARCH64MAGIC
2226
    case AARCH64MAGIC:
2227
      arch = bfd_arch_aarch64;
2228
      machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK;
2229
      break;
2230
#endif
2231
#ifdef LOONGARCH64MAGIC
2232
    case LOONGARCH64MAGIC:
2233
      arch = bfd_arch_loongarch;
2234
      machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK;
2235
      break;
2236
#endif
2237
#ifdef Z80MAGIC
2238
    case Z80MAGIC:
2239
      arch = bfd_arch_z80;
2240
      switch (internal_f->f_flags & F_MACHMASK)
2241
  {
2242
  case bfd_mach_z80strict << 12:
2243
  case bfd_mach_z80 << 12:
2244
  case bfd_mach_z80n << 12:
2245
  case bfd_mach_z80full << 12:
2246
  case bfd_mach_r800 << 12:
2247
  case bfd_mach_gbz80 << 12:
2248
  case bfd_mach_z180 << 12:
2249
  case bfd_mach_ez80_z80 << 12:
2250
  case bfd_mach_ez80_adl << 12:
2251
    machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12;
2252
    break;
2253
  default:
2254
    return false;
2255
  }
2256
      break;
2257
#endif
2258
#ifdef Z8KMAGIC
2259
    case Z8KMAGIC:
2260
      arch = bfd_arch_z8k;
2261
      switch (internal_f->f_flags & F_MACHMASK)
2262
  {
2263
  case F_Z8001:
2264
    machine = bfd_mach_z8001;
2265
    break;
2266
  case F_Z8002:
2267
    machine = bfd_mach_z8002;
2268
    break;
2269
  default:
2270
    return false;
2271
  }
2272
      break;
2273
#endif
2274
2275
0
#ifdef RS6000COFF_C
2276
0
#ifdef XCOFF64
2277
7.55k
    case U64_TOCMAGIC:
2278
7.81k
    case U803XTOCMAGIC:
2279
#else
2280
    case U802ROMAGIC:
2281
    case U802WRMAGIC:
2282
    case U802TOCMAGIC:
2283
#endif
2284
7.81k
      {
2285
7.81k
  int cputype;
2286
2287
7.81k
  if (xcoff_data (abfd)->cputype != -1)
2288
5.26k
    cputype = xcoff_data (abfd)->cputype & 0xff;
2289
2.54k
  else
2290
2.54k
    {
2291
      /* We did not get a value from the a.out header.  If the
2292
         file has not been stripped, we may be able to get the
2293
         architecture information from the first symbol, if it
2294
         is a .file symbol.  */
2295
2.54k
      if (obj_raw_syment_count (abfd) == 0)
2296
1.70k
        cputype = 0;
2297
849
      else
2298
849
        {
2299
849
    bfd_byte *buf;
2300
849
    struct internal_syment sym;
2301
849
    bfd_size_type amt = bfd_coff_symesz (abfd);
2302
2303
849
    if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
2304
110
      return false;
2305
739
    buf = _bfd_malloc_and_read (abfd, amt, amt);
2306
739
    if (buf == NULL)
2307
7
      return false;
2308
732
    bfd_coff_swap_sym_in (abfd, buf, & sym);
2309
732
    if (sym.n_sclass == C_FILE)
2310
2
      cputype = sym.n_type & 0xff;
2311
730
    else
2312
730
      cputype = 0;
2313
732
    free (buf);
2314
732
        }
2315
2.54k
    }
2316
2317
  /* FIXME: We don't handle all cases here.  */
2318
7.69k
  switch (cputype)
2319
7.69k
    {
2320
2.38k
    default:
2321
5.43k
    case 0:
2322
5.43k
      arch = bfd_xcoff_architecture (abfd);
2323
5.43k
      machine = bfd_xcoff_machine (abfd);
2324
5.43k
      break;
2325
2326
842
    case 1:
2327
842
      arch = bfd_arch_powerpc;
2328
842
      machine = bfd_mach_ppc_601;
2329
842
      break;
2330
102
    case 2: /* 64 bit PowerPC */
2331
102
      arch = bfd_arch_powerpc;
2332
102
      machine = bfd_mach_ppc_620;
2333
102
      break;
2334
1.31k
    case 3:
2335
1.31k
      arch = bfd_arch_powerpc;
2336
1.31k
      machine = bfd_mach_ppc;
2337
1.31k
      break;
2338
2
    case 4:
2339
2
      arch = bfd_arch_rs6000;
2340
2
      machine = bfd_mach_rs6k;
2341
2
      break;
2342
7.69k
    }
2343
7.69k
      }
2344
7.69k
      break;
2345
7.69k
#endif
2346
2347
#ifdef SH_ARCH_MAGIC_BIG
2348
    case SH_ARCH_MAGIC_BIG:
2349
    case SH_ARCH_MAGIC_LITTLE:
2350
#ifdef COFF_WITH_PE
2351
    case SH_ARCH_MAGIC_WINCE:
2352
#endif
2353
      arch = bfd_arch_sh;
2354
      break;
2355
#endif
2356
2357
#ifdef MIPS_ARCH_MAGIC_WINCE
2358
    case MIPS_ARCH_MAGIC_WINCE:
2359
      arch = bfd_arch_mips;
2360
      break;
2361
#endif
2362
2363
#ifdef SPARCMAGIC
2364
    case SPARCMAGIC:
2365
#ifdef LYNXCOFFMAGIC
2366
    case LYNXCOFFMAGIC:
2367
#endif
2368
      arch = bfd_arch_sparc;
2369
      break;
2370
#endif
2371
2372
#ifdef TIC30MAGIC
2373
    case TIC30MAGIC:
2374
      arch = bfd_arch_tic30;
2375
      break;
2376
#endif
2377
2378
#ifdef TICOFF0MAGIC
2379
#ifdef TICOFF_TARGET_ARCH
2380
      /* This TI COFF section should be used by all new TI COFF v0 targets.  */
2381
    case TICOFF0MAGIC:
2382
      arch = TICOFF_TARGET_ARCH;
2383
      machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2384
      break;
2385
#endif
2386
#endif
2387
2388
#ifdef TICOFF1MAGIC
2389
      /* This TI COFF section should be used by all new TI COFF v1/2 targets.  */
2390
      /* TI COFF1 and COFF2 use the target_id field to specify which arch.  */
2391
    case TICOFF1MAGIC:
2392
    case TICOFF2MAGIC:
2393
      switch (internal_f->f_target_id)
2394
  {
2395
#ifdef TI_TARGET_ID
2396
  case TI_TARGET_ID:
2397
    arch = TICOFF_TARGET_ARCH;
2398
    machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2399
    break;
2400
#endif
2401
  default:
2402
    arch = bfd_arch_obscure;
2403
    _bfd_error_handler
2404
      (_("unrecognized TI COFF target id '0x%x'"),
2405
       internal_f->f_target_id);
2406
    break;
2407
  }
2408
      break;
2409
#endif
2410
2411
#ifdef MCOREMAGIC
2412
    case MCOREMAGIC:
2413
      arch = bfd_arch_mcore;
2414
      break;
2415
#endif
2416
2417
7.69k
    default:      /* Unreadable input file type.  */
2418
0
      arch = bfd_arch_obscure;
2419
0
      break;
2420
7.81k
    }
2421
2422
7.69k
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
7.69k
  return true;
2424
7.81k
}
pe-aarch64.c:coff_set_arch_mach_hook
Line
Count
Source
2162
5.10k
{
2163
5.10k
  unsigned long machine;
2164
5.10k
  enum bfd_architecture arch;
2165
5.10k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
5.10k
  machine = 0;
2169
5.10k
  switch (internal_f->f_magic)
2170
5.10k
    {
2171
#ifdef I386MAGIC
2172
    case I386MAGIC:
2173
    case I386PTXMAGIC:
2174
    case I386AIXMAGIC:    /* Danbury PS/2 AIX C Compiler.  */
2175
    case LYNXCOFFMAGIC:
2176
    case I386_APPLE_MAGIC:
2177
    case I386_FREEBSD_MAGIC:
2178
    case I386_LINUX_MAGIC:
2179
    case I386_NETBSD_MAGIC:
2180
      arch = bfd_arch_i386;
2181
      break;
2182
#endif
2183
#ifdef AMD64MAGIC
2184
    case AMD64MAGIC:
2185
    case AMD64_APPLE_MAGIC:
2186
    case AMD64_FREEBSD_MAGIC:
2187
    case AMD64_LINUX_MAGIC:
2188
    case AMD64_NETBSD_MAGIC:
2189
      arch = bfd_arch_i386;
2190
      machine = bfd_mach_x86_64;
2191
      break;
2192
#endif
2193
#ifdef IA64MAGIC
2194
    case IA64MAGIC:
2195
      arch = bfd_arch_ia64;
2196
      break;
2197
#endif
2198
#ifdef ARMMAGIC
2199
    case ARMMAGIC:
2200
    case ARMPEMAGIC:
2201
    case THUMBPEMAGIC:
2202
      arch = bfd_arch_arm;
2203
      machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION);
2204
      if (machine == bfd_mach_arm_unknown)
2205
  {
2206
    switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK)
2207
      {
2208
      case F_ARM_2:  machine = bfd_mach_arm_2;  break;
2209
      case F_ARM_2a: machine = bfd_mach_arm_2a; break;
2210
      case F_ARM_3:  machine = bfd_mach_arm_3;  break;
2211
      default:
2212
      case F_ARM_3M: machine = bfd_mach_arm_3M; break;
2213
      case F_ARM_4:  machine = bfd_mach_arm_4;  break;
2214
      case F_ARM_4T: machine = bfd_mach_arm_4T; break;
2215
        /* The COFF header does not have enough bits available
2216
     to cover all the different ARM architectures.  So
2217
     we interpret F_ARM_5, the highest flag value to mean
2218
     "the highest ARM architecture known to BFD" which is
2219
     currently the XScale.  */
2220
      case F_ARM_5:  machine = bfd_mach_arm_XScale;  break;
2221
      }
2222
  }
2223
      break;
2224
#endif
2225
0
#ifdef AARCH64MAGIC
2226
5.10k
    case AARCH64MAGIC:
2227
5.10k
      arch = bfd_arch_aarch64;
2228
5.10k
      machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK;
2229
5.10k
      break;
2230
0
#endif
2231
#ifdef LOONGARCH64MAGIC
2232
    case LOONGARCH64MAGIC:
2233
      arch = bfd_arch_loongarch;
2234
      machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK;
2235
      break;
2236
#endif
2237
#ifdef Z80MAGIC
2238
    case Z80MAGIC:
2239
      arch = bfd_arch_z80;
2240
      switch (internal_f->f_flags & F_MACHMASK)
2241
  {
2242
  case bfd_mach_z80strict << 12:
2243
  case bfd_mach_z80 << 12:
2244
  case bfd_mach_z80n << 12:
2245
  case bfd_mach_z80full << 12:
2246
  case bfd_mach_r800 << 12:
2247
  case bfd_mach_gbz80 << 12:
2248
  case bfd_mach_z180 << 12:
2249
  case bfd_mach_ez80_z80 << 12:
2250
  case bfd_mach_ez80_adl << 12:
2251
    machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12;
2252
    break;
2253
  default:
2254
    return false;
2255
  }
2256
      break;
2257
#endif
2258
#ifdef Z8KMAGIC
2259
    case Z8KMAGIC:
2260
      arch = bfd_arch_z8k;
2261
      switch (internal_f->f_flags & F_MACHMASK)
2262
  {
2263
  case F_Z8001:
2264
    machine = bfd_mach_z8001;
2265
    break;
2266
  case F_Z8002:
2267
    machine = bfd_mach_z8002;
2268
    break;
2269
  default:
2270
    return false;
2271
  }
2272
      break;
2273
#endif
2274
2275
#ifdef RS6000COFF_C
2276
#ifdef XCOFF64
2277
    case U64_TOCMAGIC:
2278
    case U803XTOCMAGIC:
2279
#else
2280
    case U802ROMAGIC:
2281
    case U802WRMAGIC:
2282
    case U802TOCMAGIC:
2283
#endif
2284
      {
2285
  int cputype;
2286
2287
  if (xcoff_data (abfd)->cputype != -1)
2288
    cputype = xcoff_data (abfd)->cputype & 0xff;
2289
  else
2290
    {
2291
      /* We did not get a value from the a.out header.  If the
2292
         file has not been stripped, we may be able to get the
2293
         architecture information from the first symbol, if it
2294
         is a .file symbol.  */
2295
      if (obj_raw_syment_count (abfd) == 0)
2296
        cputype = 0;
2297
      else
2298
        {
2299
    bfd_byte *buf;
2300
    struct internal_syment sym;
2301
    bfd_size_type amt = bfd_coff_symesz (abfd);
2302
2303
    if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
2304
      return false;
2305
    buf = _bfd_malloc_and_read (abfd, amt, amt);
2306
    if (buf == NULL)
2307
      return false;
2308
    bfd_coff_swap_sym_in (abfd, buf, & sym);
2309
    if (sym.n_sclass == C_FILE)
2310
      cputype = sym.n_type & 0xff;
2311
    else
2312
      cputype = 0;
2313
    free (buf);
2314
        }
2315
    }
2316
2317
  /* FIXME: We don't handle all cases here.  */
2318
  switch (cputype)
2319
    {
2320
    default:
2321
    case 0:
2322
      arch = bfd_xcoff_architecture (abfd);
2323
      machine = bfd_xcoff_machine (abfd);
2324
      break;
2325
2326
    case 1:
2327
      arch = bfd_arch_powerpc;
2328
      machine = bfd_mach_ppc_601;
2329
      break;
2330
    case 2: /* 64 bit PowerPC */
2331
      arch = bfd_arch_powerpc;
2332
      machine = bfd_mach_ppc_620;
2333
      break;
2334
    case 3:
2335
      arch = bfd_arch_powerpc;
2336
      machine = bfd_mach_ppc;
2337
      break;
2338
    case 4:
2339
      arch = bfd_arch_rs6000;
2340
      machine = bfd_mach_rs6k;
2341
      break;
2342
    }
2343
      }
2344
      break;
2345
#endif
2346
2347
#ifdef SH_ARCH_MAGIC_BIG
2348
    case SH_ARCH_MAGIC_BIG:
2349
    case SH_ARCH_MAGIC_LITTLE:
2350
#ifdef COFF_WITH_PE
2351
    case SH_ARCH_MAGIC_WINCE:
2352
#endif
2353
      arch = bfd_arch_sh;
2354
      break;
2355
#endif
2356
2357
#ifdef MIPS_ARCH_MAGIC_WINCE
2358
    case MIPS_ARCH_MAGIC_WINCE:
2359
      arch = bfd_arch_mips;
2360
      break;
2361
#endif
2362
2363
#ifdef SPARCMAGIC
2364
    case SPARCMAGIC:
2365
#ifdef LYNXCOFFMAGIC
2366
    case LYNXCOFFMAGIC:
2367
#endif
2368
      arch = bfd_arch_sparc;
2369
      break;
2370
#endif
2371
2372
#ifdef TIC30MAGIC
2373
    case TIC30MAGIC:
2374
      arch = bfd_arch_tic30;
2375
      break;
2376
#endif
2377
2378
#ifdef TICOFF0MAGIC
2379
#ifdef TICOFF_TARGET_ARCH
2380
      /* This TI COFF section should be used by all new TI COFF v0 targets.  */
2381
    case TICOFF0MAGIC:
2382
      arch = TICOFF_TARGET_ARCH;
2383
      machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2384
      break;
2385
#endif
2386
#endif
2387
2388
#ifdef TICOFF1MAGIC
2389
      /* This TI COFF section should be used by all new TI COFF v1/2 targets.  */
2390
      /* TI COFF1 and COFF2 use the target_id field to specify which arch.  */
2391
    case TICOFF1MAGIC:
2392
    case TICOFF2MAGIC:
2393
      switch (internal_f->f_target_id)
2394
  {
2395
#ifdef TI_TARGET_ID
2396
  case TI_TARGET_ID:
2397
    arch = TICOFF_TARGET_ARCH;
2398
    machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2399
    break;
2400
#endif
2401
  default:
2402
    arch = bfd_arch_obscure;
2403
    _bfd_error_handler
2404
      (_("unrecognized TI COFF target id '0x%x'"),
2405
       internal_f->f_target_id);
2406
    break;
2407
  }
2408
      break;
2409
#endif
2410
2411
#ifdef MCOREMAGIC
2412
    case MCOREMAGIC:
2413
      arch = bfd_arch_mcore;
2414
      break;
2415
#endif
2416
2417
0
    default:      /* Unreadable input file type.  */
2418
0
      arch = bfd_arch_obscure;
2419
0
      break;
2420
5.10k
    }
2421
2422
5.10k
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
5.10k
  return true;
2424
5.10k
}
pei-aarch64.c:coff_set_arch_mach_hook
Line
Count
Source
2162
4.92k
{
2163
4.92k
  unsigned long machine;
2164
4.92k
  enum bfd_architecture arch;
2165
4.92k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
4.92k
  machine = 0;
2169
4.92k
  switch (internal_f->f_magic)
2170
4.92k
    {
2171
#ifdef I386MAGIC
2172
    case I386MAGIC:
2173
    case I386PTXMAGIC:
2174
    case I386AIXMAGIC:    /* Danbury PS/2 AIX C Compiler.  */
2175
    case LYNXCOFFMAGIC:
2176
    case I386_APPLE_MAGIC:
2177
    case I386_FREEBSD_MAGIC:
2178
    case I386_LINUX_MAGIC:
2179
    case I386_NETBSD_MAGIC:
2180
      arch = bfd_arch_i386;
2181
      break;
2182
#endif
2183
#ifdef AMD64MAGIC
2184
    case AMD64MAGIC:
2185
    case AMD64_APPLE_MAGIC:
2186
    case AMD64_FREEBSD_MAGIC:
2187
    case AMD64_LINUX_MAGIC:
2188
    case AMD64_NETBSD_MAGIC:
2189
      arch = bfd_arch_i386;
2190
      machine = bfd_mach_x86_64;
2191
      break;
2192
#endif
2193
#ifdef IA64MAGIC
2194
    case IA64MAGIC:
2195
      arch = bfd_arch_ia64;
2196
      break;
2197
#endif
2198
#ifdef ARMMAGIC
2199
    case ARMMAGIC:
2200
    case ARMPEMAGIC:
2201
    case THUMBPEMAGIC:
2202
      arch = bfd_arch_arm;
2203
      machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION);
2204
      if (machine == bfd_mach_arm_unknown)
2205
  {
2206
    switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK)
2207
      {
2208
      case F_ARM_2:  machine = bfd_mach_arm_2;  break;
2209
      case F_ARM_2a: machine = bfd_mach_arm_2a; break;
2210
      case F_ARM_3:  machine = bfd_mach_arm_3;  break;
2211
      default:
2212
      case F_ARM_3M: machine = bfd_mach_arm_3M; break;
2213
      case F_ARM_4:  machine = bfd_mach_arm_4;  break;
2214
      case F_ARM_4T: machine = bfd_mach_arm_4T; break;
2215
        /* The COFF header does not have enough bits available
2216
     to cover all the different ARM architectures.  So
2217
     we interpret F_ARM_5, the highest flag value to mean
2218
     "the highest ARM architecture known to BFD" which is
2219
     currently the XScale.  */
2220
      case F_ARM_5:  machine = bfd_mach_arm_XScale;  break;
2221
      }
2222
  }
2223
      break;
2224
#endif
2225
0
#ifdef AARCH64MAGIC
2226
4.92k
    case AARCH64MAGIC:
2227
4.92k
      arch = bfd_arch_aarch64;
2228
4.92k
      machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK;
2229
4.92k
      break;
2230
0
#endif
2231
#ifdef LOONGARCH64MAGIC
2232
    case LOONGARCH64MAGIC:
2233
      arch = bfd_arch_loongarch;
2234
      machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK;
2235
      break;
2236
#endif
2237
#ifdef Z80MAGIC
2238
    case Z80MAGIC:
2239
      arch = bfd_arch_z80;
2240
      switch (internal_f->f_flags & F_MACHMASK)
2241
  {
2242
  case bfd_mach_z80strict << 12:
2243
  case bfd_mach_z80 << 12:
2244
  case bfd_mach_z80n << 12:
2245
  case bfd_mach_z80full << 12:
2246
  case bfd_mach_r800 << 12:
2247
  case bfd_mach_gbz80 << 12:
2248
  case bfd_mach_z180 << 12:
2249
  case bfd_mach_ez80_z80 << 12:
2250
  case bfd_mach_ez80_adl << 12:
2251
    machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12;
2252
    break;
2253
  default:
2254
    return false;
2255
  }
2256
      break;
2257
#endif
2258
#ifdef Z8KMAGIC
2259
    case Z8KMAGIC:
2260
      arch = bfd_arch_z8k;
2261
      switch (internal_f->f_flags & F_MACHMASK)
2262
  {
2263
  case F_Z8001:
2264
    machine = bfd_mach_z8001;
2265
    break;
2266
  case F_Z8002:
2267
    machine = bfd_mach_z8002;
2268
    break;
2269
  default:
2270
    return false;
2271
  }
2272
      break;
2273
#endif
2274
2275
#ifdef RS6000COFF_C
2276
#ifdef XCOFF64
2277
    case U64_TOCMAGIC:
2278
    case U803XTOCMAGIC:
2279
#else
2280
    case U802ROMAGIC:
2281
    case U802WRMAGIC:
2282
    case U802TOCMAGIC:
2283
#endif
2284
      {
2285
  int cputype;
2286
2287
  if (xcoff_data (abfd)->cputype != -1)
2288
    cputype = xcoff_data (abfd)->cputype & 0xff;
2289
  else
2290
    {
2291
      /* We did not get a value from the a.out header.  If the
2292
         file has not been stripped, we may be able to get the
2293
         architecture information from the first symbol, if it
2294
         is a .file symbol.  */
2295
      if (obj_raw_syment_count (abfd) == 0)
2296
        cputype = 0;
2297
      else
2298
        {
2299
    bfd_byte *buf;
2300
    struct internal_syment sym;
2301
    bfd_size_type amt = bfd_coff_symesz (abfd);
2302
2303
    if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
2304
      return false;
2305
    buf = _bfd_malloc_and_read (abfd, amt, amt);
2306
    if (buf == NULL)
2307
      return false;
2308
    bfd_coff_swap_sym_in (abfd, buf, & sym);
2309
    if (sym.n_sclass == C_FILE)
2310
      cputype = sym.n_type & 0xff;
2311
    else
2312
      cputype = 0;
2313
    free (buf);
2314
        }
2315
    }
2316
2317
  /* FIXME: We don't handle all cases here.  */
2318
  switch (cputype)
2319
    {
2320
    default:
2321
    case 0:
2322
      arch = bfd_xcoff_architecture (abfd);
2323
      machine = bfd_xcoff_machine (abfd);
2324
      break;
2325
2326
    case 1:
2327
      arch = bfd_arch_powerpc;
2328
      machine = bfd_mach_ppc_601;
2329
      break;
2330
    case 2: /* 64 bit PowerPC */
2331
      arch = bfd_arch_powerpc;
2332
      machine = bfd_mach_ppc_620;
2333
      break;
2334
    case 3:
2335
      arch = bfd_arch_powerpc;
2336
      machine = bfd_mach_ppc;
2337
      break;
2338
    case 4:
2339
      arch = bfd_arch_rs6000;
2340
      machine = bfd_mach_rs6k;
2341
      break;
2342
    }
2343
      }
2344
      break;
2345
#endif
2346
2347
#ifdef SH_ARCH_MAGIC_BIG
2348
    case SH_ARCH_MAGIC_BIG:
2349
    case SH_ARCH_MAGIC_LITTLE:
2350
#ifdef COFF_WITH_PE
2351
    case SH_ARCH_MAGIC_WINCE:
2352
#endif
2353
      arch = bfd_arch_sh;
2354
      break;
2355
#endif
2356
2357
#ifdef MIPS_ARCH_MAGIC_WINCE
2358
    case MIPS_ARCH_MAGIC_WINCE:
2359
      arch = bfd_arch_mips;
2360
      break;
2361
#endif
2362
2363
#ifdef SPARCMAGIC
2364
    case SPARCMAGIC:
2365
#ifdef LYNXCOFFMAGIC
2366
    case LYNXCOFFMAGIC:
2367
#endif
2368
      arch = bfd_arch_sparc;
2369
      break;
2370
#endif
2371
2372
#ifdef TIC30MAGIC
2373
    case TIC30MAGIC:
2374
      arch = bfd_arch_tic30;
2375
      break;
2376
#endif
2377
2378
#ifdef TICOFF0MAGIC
2379
#ifdef TICOFF_TARGET_ARCH
2380
      /* This TI COFF section should be used by all new TI COFF v0 targets.  */
2381
    case TICOFF0MAGIC:
2382
      arch = TICOFF_TARGET_ARCH;
2383
      machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2384
      break;
2385
#endif
2386
#endif
2387
2388
#ifdef TICOFF1MAGIC
2389
      /* This TI COFF section should be used by all new TI COFF v1/2 targets.  */
2390
      /* TI COFF1 and COFF2 use the target_id field to specify which arch.  */
2391
    case TICOFF1MAGIC:
2392
    case TICOFF2MAGIC:
2393
      switch (internal_f->f_target_id)
2394
  {
2395
#ifdef TI_TARGET_ID
2396
  case TI_TARGET_ID:
2397
    arch = TICOFF_TARGET_ARCH;
2398
    machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2399
    break;
2400
#endif
2401
  default:
2402
    arch = bfd_arch_obscure;
2403
    _bfd_error_handler
2404
      (_("unrecognized TI COFF target id '0x%x'"),
2405
       internal_f->f_target_id);
2406
    break;
2407
  }
2408
      break;
2409
#endif
2410
2411
#ifdef MCOREMAGIC
2412
    case MCOREMAGIC:
2413
      arch = bfd_arch_mcore;
2414
      break;
2415
#endif
2416
2417
0
    default:      /* Unreadable input file type.  */
2418
0
      arch = bfd_arch_obscure;
2419
0
      break;
2420
4.92k
    }
2421
2422
4.92k
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
4.92k
  return true;
2424
4.92k
}
pei-ia64.c:coff_set_arch_mach_hook
Line
Count
Source
2162
5.78k
{
2163
5.78k
  unsigned long machine;
2164
5.78k
  enum bfd_architecture arch;
2165
5.78k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
5.78k
  machine = 0;
2169
5.78k
  switch (internal_f->f_magic)
2170
5.78k
    {
2171
#ifdef I386MAGIC
2172
    case I386MAGIC:
2173
    case I386PTXMAGIC:
2174
    case I386AIXMAGIC:    /* Danbury PS/2 AIX C Compiler.  */
2175
    case LYNXCOFFMAGIC:
2176
    case I386_APPLE_MAGIC:
2177
    case I386_FREEBSD_MAGIC:
2178
    case I386_LINUX_MAGIC:
2179
    case I386_NETBSD_MAGIC:
2180
      arch = bfd_arch_i386;
2181
      break;
2182
#endif
2183
#ifdef AMD64MAGIC
2184
    case AMD64MAGIC:
2185
    case AMD64_APPLE_MAGIC:
2186
    case AMD64_FREEBSD_MAGIC:
2187
    case AMD64_LINUX_MAGIC:
2188
    case AMD64_NETBSD_MAGIC:
2189
      arch = bfd_arch_i386;
2190
      machine = bfd_mach_x86_64;
2191
      break;
2192
#endif
2193
0
#ifdef IA64MAGIC
2194
5.78k
    case IA64MAGIC:
2195
5.78k
      arch = bfd_arch_ia64;
2196
5.78k
      break;
2197
0
#endif
2198
#ifdef ARMMAGIC
2199
    case ARMMAGIC:
2200
    case ARMPEMAGIC:
2201
    case THUMBPEMAGIC:
2202
      arch = bfd_arch_arm;
2203
      machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION);
2204
      if (machine == bfd_mach_arm_unknown)
2205
  {
2206
    switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK)
2207
      {
2208
      case F_ARM_2:  machine = bfd_mach_arm_2;  break;
2209
      case F_ARM_2a: machine = bfd_mach_arm_2a; break;
2210
      case F_ARM_3:  machine = bfd_mach_arm_3;  break;
2211
      default:
2212
      case F_ARM_3M: machine = bfd_mach_arm_3M; break;
2213
      case F_ARM_4:  machine = bfd_mach_arm_4;  break;
2214
      case F_ARM_4T: machine = bfd_mach_arm_4T; break;
2215
        /* The COFF header does not have enough bits available
2216
     to cover all the different ARM architectures.  So
2217
     we interpret F_ARM_5, the highest flag value to mean
2218
     "the highest ARM architecture known to BFD" which is
2219
     currently the XScale.  */
2220
      case F_ARM_5:  machine = bfd_mach_arm_XScale;  break;
2221
      }
2222
  }
2223
      break;
2224
#endif
2225
#ifdef AARCH64MAGIC
2226
    case AARCH64MAGIC:
2227
      arch = bfd_arch_aarch64;
2228
      machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK;
2229
      break;
2230
#endif
2231
#ifdef LOONGARCH64MAGIC
2232
    case LOONGARCH64MAGIC:
2233
      arch = bfd_arch_loongarch;
2234
      machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK;
2235
      break;
2236
#endif
2237
#ifdef Z80MAGIC
2238
    case Z80MAGIC:
2239
      arch = bfd_arch_z80;
2240
      switch (internal_f->f_flags & F_MACHMASK)
2241
  {
2242
  case bfd_mach_z80strict << 12:
2243
  case bfd_mach_z80 << 12:
2244
  case bfd_mach_z80n << 12:
2245
  case bfd_mach_z80full << 12:
2246
  case bfd_mach_r800 << 12:
2247
  case bfd_mach_gbz80 << 12:
2248
  case bfd_mach_z180 << 12:
2249
  case bfd_mach_ez80_z80 << 12:
2250
  case bfd_mach_ez80_adl << 12:
2251
    machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12;
2252
    break;
2253
  default:
2254
    return false;
2255
  }
2256
      break;
2257
#endif
2258
#ifdef Z8KMAGIC
2259
    case Z8KMAGIC:
2260
      arch = bfd_arch_z8k;
2261
      switch (internal_f->f_flags & F_MACHMASK)
2262
  {
2263
  case F_Z8001:
2264
    machine = bfd_mach_z8001;
2265
    break;
2266
  case F_Z8002:
2267
    machine = bfd_mach_z8002;
2268
    break;
2269
  default:
2270
    return false;
2271
  }
2272
      break;
2273
#endif
2274
2275
#ifdef RS6000COFF_C
2276
#ifdef XCOFF64
2277
    case U64_TOCMAGIC:
2278
    case U803XTOCMAGIC:
2279
#else
2280
    case U802ROMAGIC:
2281
    case U802WRMAGIC:
2282
    case U802TOCMAGIC:
2283
#endif
2284
      {
2285
  int cputype;
2286
2287
  if (xcoff_data (abfd)->cputype != -1)
2288
    cputype = xcoff_data (abfd)->cputype & 0xff;
2289
  else
2290
    {
2291
      /* We did not get a value from the a.out header.  If the
2292
         file has not been stripped, we may be able to get the
2293
         architecture information from the first symbol, if it
2294
         is a .file symbol.  */
2295
      if (obj_raw_syment_count (abfd) == 0)
2296
        cputype = 0;
2297
      else
2298
        {
2299
    bfd_byte *buf;
2300
    struct internal_syment sym;
2301
    bfd_size_type amt = bfd_coff_symesz (abfd);
2302
2303
    if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
2304
      return false;
2305
    buf = _bfd_malloc_and_read (abfd, amt, amt);
2306
    if (buf == NULL)
2307
      return false;
2308
    bfd_coff_swap_sym_in (abfd, buf, & sym);
2309
    if (sym.n_sclass == C_FILE)
2310
      cputype = sym.n_type & 0xff;
2311
    else
2312
      cputype = 0;
2313
    free (buf);
2314
        }
2315
    }
2316
2317
  /* FIXME: We don't handle all cases here.  */
2318
  switch (cputype)
2319
    {
2320
    default:
2321
    case 0:
2322
      arch = bfd_xcoff_architecture (abfd);
2323
      machine = bfd_xcoff_machine (abfd);
2324
      break;
2325
2326
    case 1:
2327
      arch = bfd_arch_powerpc;
2328
      machine = bfd_mach_ppc_601;
2329
      break;
2330
    case 2: /* 64 bit PowerPC */
2331
      arch = bfd_arch_powerpc;
2332
      machine = bfd_mach_ppc_620;
2333
      break;
2334
    case 3:
2335
      arch = bfd_arch_powerpc;
2336
      machine = bfd_mach_ppc;
2337
      break;
2338
    case 4:
2339
      arch = bfd_arch_rs6000;
2340
      machine = bfd_mach_rs6k;
2341
      break;
2342
    }
2343
      }
2344
      break;
2345
#endif
2346
2347
#ifdef SH_ARCH_MAGIC_BIG
2348
    case SH_ARCH_MAGIC_BIG:
2349
    case SH_ARCH_MAGIC_LITTLE:
2350
#ifdef COFF_WITH_PE
2351
    case SH_ARCH_MAGIC_WINCE:
2352
#endif
2353
      arch = bfd_arch_sh;
2354
      break;
2355
#endif
2356
2357
#ifdef MIPS_ARCH_MAGIC_WINCE
2358
    case MIPS_ARCH_MAGIC_WINCE:
2359
      arch = bfd_arch_mips;
2360
      break;
2361
#endif
2362
2363
#ifdef SPARCMAGIC
2364
    case SPARCMAGIC:
2365
#ifdef LYNXCOFFMAGIC
2366
    case LYNXCOFFMAGIC:
2367
#endif
2368
      arch = bfd_arch_sparc;
2369
      break;
2370
#endif
2371
2372
#ifdef TIC30MAGIC
2373
    case TIC30MAGIC:
2374
      arch = bfd_arch_tic30;
2375
      break;
2376
#endif
2377
2378
#ifdef TICOFF0MAGIC
2379
#ifdef TICOFF_TARGET_ARCH
2380
      /* This TI COFF section should be used by all new TI COFF v0 targets.  */
2381
    case TICOFF0MAGIC:
2382
      arch = TICOFF_TARGET_ARCH;
2383
      machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2384
      break;
2385
#endif
2386
#endif
2387
2388
#ifdef TICOFF1MAGIC
2389
      /* This TI COFF section should be used by all new TI COFF v1/2 targets.  */
2390
      /* TI COFF1 and COFF2 use the target_id field to specify which arch.  */
2391
    case TICOFF1MAGIC:
2392
    case TICOFF2MAGIC:
2393
      switch (internal_f->f_target_id)
2394
  {
2395
#ifdef TI_TARGET_ID
2396
  case TI_TARGET_ID:
2397
    arch = TICOFF_TARGET_ARCH;
2398
    machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2399
    break;
2400
#endif
2401
  default:
2402
    arch = bfd_arch_obscure;
2403
    _bfd_error_handler
2404
      (_("unrecognized TI COFF target id '0x%x'"),
2405
       internal_f->f_target_id);
2406
    break;
2407
  }
2408
      break;
2409
#endif
2410
2411
#ifdef MCOREMAGIC
2412
    case MCOREMAGIC:
2413
      arch = bfd_arch_mcore;
2414
      break;
2415
#endif
2416
2417
0
    default:      /* Unreadable input file type.  */
2418
0
      arch = bfd_arch_obscure;
2419
0
      break;
2420
5.78k
    }
2421
2422
5.78k
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
5.78k
  return true;
2424
5.78k
}
pei-loongarch64.c:coff_set_arch_mach_hook
Line
Count
Source
2162
6.70k
{
2163
6.70k
  unsigned long machine;
2164
6.70k
  enum bfd_architecture arch;
2165
6.70k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
6.70k
  machine = 0;
2169
6.70k
  switch (internal_f->f_magic)
2170
6.70k
    {
2171
#ifdef I386MAGIC
2172
    case I386MAGIC:
2173
    case I386PTXMAGIC:
2174
    case I386AIXMAGIC:    /* Danbury PS/2 AIX C Compiler.  */
2175
    case LYNXCOFFMAGIC:
2176
    case I386_APPLE_MAGIC:
2177
    case I386_FREEBSD_MAGIC:
2178
    case I386_LINUX_MAGIC:
2179
    case I386_NETBSD_MAGIC:
2180
      arch = bfd_arch_i386;
2181
      break;
2182
#endif
2183
#ifdef AMD64MAGIC
2184
    case AMD64MAGIC:
2185
    case AMD64_APPLE_MAGIC:
2186
    case AMD64_FREEBSD_MAGIC:
2187
    case AMD64_LINUX_MAGIC:
2188
    case AMD64_NETBSD_MAGIC:
2189
      arch = bfd_arch_i386;
2190
      machine = bfd_mach_x86_64;
2191
      break;
2192
#endif
2193
#ifdef IA64MAGIC
2194
    case IA64MAGIC:
2195
      arch = bfd_arch_ia64;
2196
      break;
2197
#endif
2198
#ifdef ARMMAGIC
2199
    case ARMMAGIC:
2200
    case ARMPEMAGIC:
2201
    case THUMBPEMAGIC:
2202
      arch = bfd_arch_arm;
2203
      machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION);
2204
      if (machine == bfd_mach_arm_unknown)
2205
  {
2206
    switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK)
2207
      {
2208
      case F_ARM_2:  machine = bfd_mach_arm_2;  break;
2209
      case F_ARM_2a: machine = bfd_mach_arm_2a; break;
2210
      case F_ARM_3:  machine = bfd_mach_arm_3;  break;
2211
      default:
2212
      case F_ARM_3M: machine = bfd_mach_arm_3M; break;
2213
      case F_ARM_4:  machine = bfd_mach_arm_4;  break;
2214
      case F_ARM_4T: machine = bfd_mach_arm_4T; break;
2215
        /* The COFF header does not have enough bits available
2216
     to cover all the different ARM architectures.  So
2217
     we interpret F_ARM_5, the highest flag value to mean
2218
     "the highest ARM architecture known to BFD" which is
2219
     currently the XScale.  */
2220
      case F_ARM_5:  machine = bfd_mach_arm_XScale;  break;
2221
      }
2222
  }
2223
      break;
2224
#endif
2225
#ifdef AARCH64MAGIC
2226
    case AARCH64MAGIC:
2227
      arch = bfd_arch_aarch64;
2228
      machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK;
2229
      break;
2230
#endif
2231
0
#ifdef LOONGARCH64MAGIC
2232
6.70k
    case LOONGARCH64MAGIC:
2233
6.70k
      arch = bfd_arch_loongarch;
2234
6.70k
      machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK;
2235
6.70k
      break;
2236
0
#endif
2237
#ifdef Z80MAGIC
2238
    case Z80MAGIC:
2239
      arch = bfd_arch_z80;
2240
      switch (internal_f->f_flags & F_MACHMASK)
2241
  {
2242
  case bfd_mach_z80strict << 12:
2243
  case bfd_mach_z80 << 12:
2244
  case bfd_mach_z80n << 12:
2245
  case bfd_mach_z80full << 12:
2246
  case bfd_mach_r800 << 12:
2247
  case bfd_mach_gbz80 << 12:
2248
  case bfd_mach_z180 << 12:
2249
  case bfd_mach_ez80_z80 << 12:
2250
  case bfd_mach_ez80_adl << 12:
2251
    machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12;
2252
    break;
2253
  default:
2254
    return false;
2255
  }
2256
      break;
2257
#endif
2258
#ifdef Z8KMAGIC
2259
    case Z8KMAGIC:
2260
      arch = bfd_arch_z8k;
2261
      switch (internal_f->f_flags & F_MACHMASK)
2262
  {
2263
  case F_Z8001:
2264
    machine = bfd_mach_z8001;
2265
    break;
2266
  case F_Z8002:
2267
    machine = bfd_mach_z8002;
2268
    break;
2269
  default:
2270
    return false;
2271
  }
2272
      break;
2273
#endif
2274
2275
#ifdef RS6000COFF_C
2276
#ifdef XCOFF64
2277
    case U64_TOCMAGIC:
2278
    case U803XTOCMAGIC:
2279
#else
2280
    case U802ROMAGIC:
2281
    case U802WRMAGIC:
2282
    case U802TOCMAGIC:
2283
#endif
2284
      {
2285
  int cputype;
2286
2287
  if (xcoff_data (abfd)->cputype != -1)
2288
    cputype = xcoff_data (abfd)->cputype & 0xff;
2289
  else
2290
    {
2291
      /* We did not get a value from the a.out header.  If the
2292
         file has not been stripped, we may be able to get the
2293
         architecture information from the first symbol, if it
2294
         is a .file symbol.  */
2295
      if (obj_raw_syment_count (abfd) == 0)
2296
        cputype = 0;
2297
      else
2298
        {
2299
    bfd_byte *buf;
2300
    struct internal_syment sym;
2301
    bfd_size_type amt = bfd_coff_symesz (abfd);
2302
2303
    if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
2304
      return false;
2305
    buf = _bfd_malloc_and_read (abfd, amt, amt);
2306
    if (buf == NULL)
2307
      return false;
2308
    bfd_coff_swap_sym_in (abfd, buf, & sym);
2309
    if (sym.n_sclass == C_FILE)
2310
      cputype = sym.n_type & 0xff;
2311
    else
2312
      cputype = 0;
2313
    free (buf);
2314
        }
2315
    }
2316
2317
  /* FIXME: We don't handle all cases here.  */
2318
  switch (cputype)
2319
    {
2320
    default:
2321
    case 0:
2322
      arch = bfd_xcoff_architecture (abfd);
2323
      machine = bfd_xcoff_machine (abfd);
2324
      break;
2325
2326
    case 1:
2327
      arch = bfd_arch_powerpc;
2328
      machine = bfd_mach_ppc_601;
2329
      break;
2330
    case 2: /* 64 bit PowerPC */
2331
      arch = bfd_arch_powerpc;
2332
      machine = bfd_mach_ppc_620;
2333
      break;
2334
    case 3:
2335
      arch = bfd_arch_powerpc;
2336
      machine = bfd_mach_ppc;
2337
      break;
2338
    case 4:
2339
      arch = bfd_arch_rs6000;
2340
      machine = bfd_mach_rs6k;
2341
      break;
2342
    }
2343
      }
2344
      break;
2345
#endif
2346
2347
#ifdef SH_ARCH_MAGIC_BIG
2348
    case SH_ARCH_MAGIC_BIG:
2349
    case SH_ARCH_MAGIC_LITTLE:
2350
#ifdef COFF_WITH_PE
2351
    case SH_ARCH_MAGIC_WINCE:
2352
#endif
2353
      arch = bfd_arch_sh;
2354
      break;
2355
#endif
2356
2357
#ifdef MIPS_ARCH_MAGIC_WINCE
2358
    case MIPS_ARCH_MAGIC_WINCE:
2359
      arch = bfd_arch_mips;
2360
      break;
2361
#endif
2362
2363
#ifdef SPARCMAGIC
2364
    case SPARCMAGIC:
2365
#ifdef LYNXCOFFMAGIC
2366
    case LYNXCOFFMAGIC:
2367
#endif
2368
      arch = bfd_arch_sparc;
2369
      break;
2370
#endif
2371
2372
#ifdef TIC30MAGIC
2373
    case TIC30MAGIC:
2374
      arch = bfd_arch_tic30;
2375
      break;
2376
#endif
2377
2378
#ifdef TICOFF0MAGIC
2379
#ifdef TICOFF_TARGET_ARCH
2380
      /* This TI COFF section should be used by all new TI COFF v0 targets.  */
2381
    case TICOFF0MAGIC:
2382
      arch = TICOFF_TARGET_ARCH;
2383
      machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2384
      break;
2385
#endif
2386
#endif
2387
2388
#ifdef TICOFF1MAGIC
2389
      /* This TI COFF section should be used by all new TI COFF v1/2 targets.  */
2390
      /* TI COFF1 and COFF2 use the target_id field to specify which arch.  */
2391
    case TICOFF1MAGIC:
2392
    case TICOFF2MAGIC:
2393
      switch (internal_f->f_target_id)
2394
  {
2395
#ifdef TI_TARGET_ID
2396
  case TI_TARGET_ID:
2397
    arch = TICOFF_TARGET_ARCH;
2398
    machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2399
    break;
2400
#endif
2401
  default:
2402
    arch = bfd_arch_obscure;
2403
    _bfd_error_handler
2404
      (_("unrecognized TI COFF target id '0x%x'"),
2405
       internal_f->f_target_id);
2406
    break;
2407
  }
2408
      break;
2409
#endif
2410
2411
#ifdef MCOREMAGIC
2412
    case MCOREMAGIC:
2413
      arch = bfd_arch_mcore;
2414
      break;
2415
#endif
2416
2417
0
    default:      /* Unreadable input file type.  */
2418
0
      arch = bfd_arch_obscure;
2419
0
      break;
2420
6.70k
    }
2421
2422
6.70k
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
6.70k
  return true;
2424
6.70k
}
cf-i386lynx.c:coff_set_arch_mach_hook
Line
Count
Source
2162
7.07k
{
2163
7.07k
  unsigned long machine;
2164
7.07k
  enum bfd_architecture arch;
2165
7.07k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
7.07k
  machine = 0;
2169
7.07k
  switch (internal_f->f_magic)
2170
7.07k
    {
2171
0
#ifdef I386MAGIC
2172
6.46k
    case I386MAGIC:
2173
6.61k
    case I386PTXMAGIC:
2174
6.90k
    case I386AIXMAGIC:   /* Danbury PS/2 AIX C Compiler.  */
2175
6.96k
    case LYNXCOFFMAGIC:
2176
6.96k
    case I386_APPLE_MAGIC:
2177
6.96k
    case I386_FREEBSD_MAGIC:
2178
6.97k
    case I386_LINUX_MAGIC:
2179
7.07k
    case I386_NETBSD_MAGIC:
2180
7.07k
      arch = bfd_arch_i386;
2181
7.07k
      break;
2182
0
#endif
2183
#ifdef AMD64MAGIC
2184
    case AMD64MAGIC:
2185
    case AMD64_APPLE_MAGIC:
2186
    case AMD64_FREEBSD_MAGIC:
2187
    case AMD64_LINUX_MAGIC:
2188
    case AMD64_NETBSD_MAGIC:
2189
      arch = bfd_arch_i386;
2190
      machine = bfd_mach_x86_64;
2191
      break;
2192
#endif
2193
#ifdef IA64MAGIC
2194
    case IA64MAGIC:
2195
      arch = bfd_arch_ia64;
2196
      break;
2197
#endif
2198
#ifdef ARMMAGIC
2199
    case ARMMAGIC:
2200
    case ARMPEMAGIC:
2201
    case THUMBPEMAGIC:
2202
      arch = bfd_arch_arm;
2203
      machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION);
2204
      if (machine == bfd_mach_arm_unknown)
2205
  {
2206
    switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK)
2207
      {
2208
      case F_ARM_2:  machine = bfd_mach_arm_2;  break;
2209
      case F_ARM_2a: machine = bfd_mach_arm_2a; break;
2210
      case F_ARM_3:  machine = bfd_mach_arm_3;  break;
2211
      default:
2212
      case F_ARM_3M: machine = bfd_mach_arm_3M; break;
2213
      case F_ARM_4:  machine = bfd_mach_arm_4;  break;
2214
      case F_ARM_4T: machine = bfd_mach_arm_4T; break;
2215
        /* The COFF header does not have enough bits available
2216
     to cover all the different ARM architectures.  So
2217
     we interpret F_ARM_5, the highest flag value to mean
2218
     "the highest ARM architecture known to BFD" which is
2219
     currently the XScale.  */
2220
      case F_ARM_5:  machine = bfd_mach_arm_XScale;  break;
2221
      }
2222
  }
2223
      break;
2224
#endif
2225
#ifdef AARCH64MAGIC
2226
    case AARCH64MAGIC:
2227
      arch = bfd_arch_aarch64;
2228
      machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK;
2229
      break;
2230
#endif
2231
#ifdef LOONGARCH64MAGIC
2232
    case LOONGARCH64MAGIC:
2233
      arch = bfd_arch_loongarch;
2234
      machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK;
2235
      break;
2236
#endif
2237
#ifdef Z80MAGIC
2238
    case Z80MAGIC:
2239
      arch = bfd_arch_z80;
2240
      switch (internal_f->f_flags & F_MACHMASK)
2241
  {
2242
  case bfd_mach_z80strict << 12:
2243
  case bfd_mach_z80 << 12:
2244
  case bfd_mach_z80n << 12:
2245
  case bfd_mach_z80full << 12:
2246
  case bfd_mach_r800 << 12:
2247
  case bfd_mach_gbz80 << 12:
2248
  case bfd_mach_z180 << 12:
2249
  case bfd_mach_ez80_z80 << 12:
2250
  case bfd_mach_ez80_adl << 12:
2251
    machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12;
2252
    break;
2253
  default:
2254
    return false;
2255
  }
2256
      break;
2257
#endif
2258
#ifdef Z8KMAGIC
2259
    case Z8KMAGIC:
2260
      arch = bfd_arch_z8k;
2261
      switch (internal_f->f_flags & F_MACHMASK)
2262
  {
2263
  case F_Z8001:
2264
    machine = bfd_mach_z8001;
2265
    break;
2266
  case F_Z8002:
2267
    machine = bfd_mach_z8002;
2268
    break;
2269
  default:
2270
    return false;
2271
  }
2272
      break;
2273
#endif
2274
2275
#ifdef RS6000COFF_C
2276
#ifdef XCOFF64
2277
    case U64_TOCMAGIC:
2278
    case U803XTOCMAGIC:
2279
#else
2280
    case U802ROMAGIC:
2281
    case U802WRMAGIC:
2282
    case U802TOCMAGIC:
2283
#endif
2284
      {
2285
  int cputype;
2286
2287
  if (xcoff_data (abfd)->cputype != -1)
2288
    cputype = xcoff_data (abfd)->cputype & 0xff;
2289
  else
2290
    {
2291
      /* We did not get a value from the a.out header.  If the
2292
         file has not been stripped, we may be able to get the
2293
         architecture information from the first symbol, if it
2294
         is a .file symbol.  */
2295
      if (obj_raw_syment_count (abfd) == 0)
2296
        cputype = 0;
2297
      else
2298
        {
2299
    bfd_byte *buf;
2300
    struct internal_syment sym;
2301
    bfd_size_type amt = bfd_coff_symesz (abfd);
2302
2303
    if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
2304
      return false;
2305
    buf = _bfd_malloc_and_read (abfd, amt, amt);
2306
    if (buf == NULL)
2307
      return false;
2308
    bfd_coff_swap_sym_in (abfd, buf, & sym);
2309
    if (sym.n_sclass == C_FILE)
2310
      cputype = sym.n_type & 0xff;
2311
    else
2312
      cputype = 0;
2313
    free (buf);
2314
        }
2315
    }
2316
2317
  /* FIXME: We don't handle all cases here.  */
2318
  switch (cputype)
2319
    {
2320
    default:
2321
    case 0:
2322
      arch = bfd_xcoff_architecture (abfd);
2323
      machine = bfd_xcoff_machine (abfd);
2324
      break;
2325
2326
    case 1:
2327
      arch = bfd_arch_powerpc;
2328
      machine = bfd_mach_ppc_601;
2329
      break;
2330
    case 2: /* 64 bit PowerPC */
2331
      arch = bfd_arch_powerpc;
2332
      machine = bfd_mach_ppc_620;
2333
      break;
2334
    case 3:
2335
      arch = bfd_arch_powerpc;
2336
      machine = bfd_mach_ppc;
2337
      break;
2338
    case 4:
2339
      arch = bfd_arch_rs6000;
2340
      machine = bfd_mach_rs6k;
2341
      break;
2342
    }
2343
      }
2344
      break;
2345
#endif
2346
2347
#ifdef SH_ARCH_MAGIC_BIG
2348
    case SH_ARCH_MAGIC_BIG:
2349
    case SH_ARCH_MAGIC_LITTLE:
2350
#ifdef COFF_WITH_PE
2351
    case SH_ARCH_MAGIC_WINCE:
2352
#endif
2353
      arch = bfd_arch_sh;
2354
      break;
2355
#endif
2356
2357
#ifdef MIPS_ARCH_MAGIC_WINCE
2358
    case MIPS_ARCH_MAGIC_WINCE:
2359
      arch = bfd_arch_mips;
2360
      break;
2361
#endif
2362
2363
#ifdef SPARCMAGIC
2364
    case SPARCMAGIC:
2365
#ifdef LYNXCOFFMAGIC
2366
    case LYNXCOFFMAGIC:
2367
#endif
2368
      arch = bfd_arch_sparc;
2369
      break;
2370
#endif
2371
2372
#ifdef TIC30MAGIC
2373
    case TIC30MAGIC:
2374
      arch = bfd_arch_tic30;
2375
      break;
2376
#endif
2377
2378
#ifdef TICOFF0MAGIC
2379
#ifdef TICOFF_TARGET_ARCH
2380
      /* This TI COFF section should be used by all new TI COFF v0 targets.  */
2381
    case TICOFF0MAGIC:
2382
      arch = TICOFF_TARGET_ARCH;
2383
      machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2384
      break;
2385
#endif
2386
#endif
2387
2388
#ifdef TICOFF1MAGIC
2389
      /* This TI COFF section should be used by all new TI COFF v1/2 targets.  */
2390
      /* TI COFF1 and COFF2 use the target_id field to specify which arch.  */
2391
    case TICOFF1MAGIC:
2392
    case TICOFF2MAGIC:
2393
      switch (internal_f->f_target_id)
2394
  {
2395
#ifdef TI_TARGET_ID
2396
  case TI_TARGET_ID:
2397
    arch = TICOFF_TARGET_ARCH;
2398
    machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2399
    break;
2400
#endif
2401
  default:
2402
    arch = bfd_arch_obscure;
2403
    _bfd_error_handler
2404
      (_("unrecognized TI COFF target id '0x%x'"),
2405
       internal_f->f_target_id);
2406
    break;
2407
  }
2408
      break;
2409
#endif
2410
2411
#ifdef MCOREMAGIC
2412
    case MCOREMAGIC:
2413
      arch = bfd_arch_mcore;
2414
      break;
2415
#endif
2416
2417
0
    default:      /* Unreadable input file type.  */
2418
0
      arch = bfd_arch_obscure;
2419
0
      break;
2420
7.07k
    }
2421
2422
7.07k
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
7.07k
  return true;
2424
7.07k
}
coff-go32.c:coff_set_arch_mach_hook
Line
Count
Source
2162
6.76k
{
2163
6.76k
  unsigned long machine;
2164
6.76k
  enum bfd_architecture arch;
2165
6.76k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
6.76k
  machine = 0;
2169
6.76k
  switch (internal_f->f_magic)
2170
6.76k
    {
2171
0
#ifdef I386MAGIC
2172
6.39k
    case I386MAGIC:
2173
6.41k
    case I386PTXMAGIC:
2174
6.70k
    case I386AIXMAGIC:   /* Danbury PS/2 AIX C Compiler.  */
2175
6.76k
    case LYNXCOFFMAGIC:
2176
6.76k
    case I386_APPLE_MAGIC:
2177
6.76k
    case I386_FREEBSD_MAGIC:
2178
6.76k
    case I386_LINUX_MAGIC:
2179
6.76k
    case I386_NETBSD_MAGIC:
2180
6.76k
      arch = bfd_arch_i386;
2181
6.76k
      break;
2182
0
#endif
2183
#ifdef AMD64MAGIC
2184
    case AMD64MAGIC:
2185
    case AMD64_APPLE_MAGIC:
2186
    case AMD64_FREEBSD_MAGIC:
2187
    case AMD64_LINUX_MAGIC:
2188
    case AMD64_NETBSD_MAGIC:
2189
      arch = bfd_arch_i386;
2190
      machine = bfd_mach_x86_64;
2191
      break;
2192
#endif
2193
#ifdef IA64MAGIC
2194
    case IA64MAGIC:
2195
      arch = bfd_arch_ia64;
2196
      break;
2197
#endif
2198
#ifdef ARMMAGIC
2199
    case ARMMAGIC:
2200
    case ARMPEMAGIC:
2201
    case THUMBPEMAGIC:
2202
      arch = bfd_arch_arm;
2203
      machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION);
2204
      if (machine == bfd_mach_arm_unknown)
2205
  {
2206
    switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK)
2207
      {
2208
      case F_ARM_2:  machine = bfd_mach_arm_2;  break;
2209
      case F_ARM_2a: machine = bfd_mach_arm_2a; break;
2210
      case F_ARM_3:  machine = bfd_mach_arm_3;  break;
2211
      default:
2212
      case F_ARM_3M: machine = bfd_mach_arm_3M; break;
2213
      case F_ARM_4:  machine = bfd_mach_arm_4;  break;
2214
      case F_ARM_4T: machine = bfd_mach_arm_4T; break;
2215
        /* The COFF header does not have enough bits available
2216
     to cover all the different ARM architectures.  So
2217
     we interpret F_ARM_5, the highest flag value to mean
2218
     "the highest ARM architecture known to BFD" which is
2219
     currently the XScale.  */
2220
      case F_ARM_5:  machine = bfd_mach_arm_XScale;  break;
2221
      }
2222
  }
2223
      break;
2224
#endif
2225
#ifdef AARCH64MAGIC
2226
    case AARCH64MAGIC:
2227
      arch = bfd_arch_aarch64;
2228
      machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK;
2229
      break;
2230
#endif
2231
#ifdef LOONGARCH64MAGIC
2232
    case LOONGARCH64MAGIC:
2233
      arch = bfd_arch_loongarch;
2234
      machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK;
2235
      break;
2236
#endif
2237
#ifdef Z80MAGIC
2238
    case Z80MAGIC:
2239
      arch = bfd_arch_z80;
2240
      switch (internal_f->f_flags & F_MACHMASK)
2241
  {
2242
  case bfd_mach_z80strict << 12:
2243
  case bfd_mach_z80 << 12:
2244
  case bfd_mach_z80n << 12:
2245
  case bfd_mach_z80full << 12:
2246
  case bfd_mach_r800 << 12:
2247
  case bfd_mach_gbz80 << 12:
2248
  case bfd_mach_z180 << 12:
2249
  case bfd_mach_ez80_z80 << 12:
2250
  case bfd_mach_ez80_adl << 12:
2251
    machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12;
2252
    break;
2253
  default:
2254
    return false;
2255
  }
2256
      break;
2257
#endif
2258
#ifdef Z8KMAGIC
2259
    case Z8KMAGIC:
2260
      arch = bfd_arch_z8k;
2261
      switch (internal_f->f_flags & F_MACHMASK)
2262
  {
2263
  case F_Z8001:
2264
    machine = bfd_mach_z8001;
2265
    break;
2266
  case F_Z8002:
2267
    machine = bfd_mach_z8002;
2268
    break;
2269
  default:
2270
    return false;
2271
  }
2272
      break;
2273
#endif
2274
2275
#ifdef RS6000COFF_C
2276
#ifdef XCOFF64
2277
    case U64_TOCMAGIC:
2278
    case U803XTOCMAGIC:
2279
#else
2280
    case U802ROMAGIC:
2281
    case U802WRMAGIC:
2282
    case U802TOCMAGIC:
2283
#endif
2284
      {
2285
  int cputype;
2286
2287
  if (xcoff_data (abfd)->cputype != -1)
2288
    cputype = xcoff_data (abfd)->cputype & 0xff;
2289
  else
2290
    {
2291
      /* We did not get a value from the a.out header.  If the
2292
         file has not been stripped, we may be able to get the
2293
         architecture information from the first symbol, if it
2294
         is a .file symbol.  */
2295
      if (obj_raw_syment_count (abfd) == 0)
2296
        cputype = 0;
2297
      else
2298
        {
2299
    bfd_byte *buf;
2300
    struct internal_syment sym;
2301
    bfd_size_type amt = bfd_coff_symesz (abfd);
2302
2303
    if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
2304
      return false;
2305
    buf = _bfd_malloc_and_read (abfd, amt, amt);
2306
    if (buf == NULL)
2307
      return false;
2308
    bfd_coff_swap_sym_in (abfd, buf, & sym);
2309
    if (sym.n_sclass == C_FILE)
2310
      cputype = sym.n_type & 0xff;
2311
    else
2312
      cputype = 0;
2313
    free (buf);
2314
        }
2315
    }
2316
2317
  /* FIXME: We don't handle all cases here.  */
2318
  switch (cputype)
2319
    {
2320
    default:
2321
    case 0:
2322
      arch = bfd_xcoff_architecture (abfd);
2323
      machine = bfd_xcoff_machine (abfd);
2324
      break;
2325
2326
    case 1:
2327
      arch = bfd_arch_powerpc;
2328
      machine = bfd_mach_ppc_601;
2329
      break;
2330
    case 2: /* 64 bit PowerPC */
2331
      arch = bfd_arch_powerpc;
2332
      machine = bfd_mach_ppc_620;
2333
      break;
2334
    case 3:
2335
      arch = bfd_arch_powerpc;
2336
      machine = bfd_mach_ppc;
2337
      break;
2338
    case 4:
2339
      arch = bfd_arch_rs6000;
2340
      machine = bfd_mach_rs6k;
2341
      break;
2342
    }
2343
      }
2344
      break;
2345
#endif
2346
2347
#ifdef SH_ARCH_MAGIC_BIG
2348
    case SH_ARCH_MAGIC_BIG:
2349
    case SH_ARCH_MAGIC_LITTLE:
2350
#ifdef COFF_WITH_PE
2351
    case SH_ARCH_MAGIC_WINCE:
2352
#endif
2353
      arch = bfd_arch_sh;
2354
      break;
2355
#endif
2356
2357
#ifdef MIPS_ARCH_MAGIC_WINCE
2358
    case MIPS_ARCH_MAGIC_WINCE:
2359
      arch = bfd_arch_mips;
2360
      break;
2361
#endif
2362
2363
#ifdef SPARCMAGIC
2364
    case SPARCMAGIC:
2365
#ifdef LYNXCOFFMAGIC
2366
    case LYNXCOFFMAGIC:
2367
#endif
2368
      arch = bfd_arch_sparc;
2369
      break;
2370
#endif
2371
2372
#ifdef TIC30MAGIC
2373
    case TIC30MAGIC:
2374
      arch = bfd_arch_tic30;
2375
      break;
2376
#endif
2377
2378
#ifdef TICOFF0MAGIC
2379
#ifdef TICOFF_TARGET_ARCH
2380
      /* This TI COFF section should be used by all new TI COFF v0 targets.  */
2381
    case TICOFF0MAGIC:
2382
      arch = TICOFF_TARGET_ARCH;
2383
      machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2384
      break;
2385
#endif
2386
#endif
2387
2388
#ifdef TICOFF1MAGIC
2389
      /* This TI COFF section should be used by all new TI COFF v1/2 targets.  */
2390
      /* TI COFF1 and COFF2 use the target_id field to specify which arch.  */
2391
    case TICOFF1MAGIC:
2392
    case TICOFF2MAGIC:
2393
      switch (internal_f->f_target_id)
2394
  {
2395
#ifdef TI_TARGET_ID
2396
  case TI_TARGET_ID:
2397
    arch = TICOFF_TARGET_ARCH;
2398
    machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2399
    break;
2400
#endif
2401
  default:
2402
    arch = bfd_arch_obscure;
2403
    _bfd_error_handler
2404
      (_("unrecognized TI COFF target id '0x%x'"),
2405
       internal_f->f_target_id);
2406
    break;
2407
  }
2408
      break;
2409
#endif
2410
2411
#ifdef MCOREMAGIC
2412
    case MCOREMAGIC:
2413
      arch = bfd_arch_mcore;
2414
      break;
2415
#endif
2416
2417
0
    default:      /* Unreadable input file type.  */
2418
0
      arch = bfd_arch_obscure;
2419
0
      break;
2420
6.76k
    }
2421
2422
6.76k
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
6.76k
  return true;
2424
6.76k
}
coff-i386.c:coff_set_arch_mach_hook
Line
Count
Source
2162
6.76k
{
2163
6.76k
  unsigned long machine;
2164
6.76k
  enum bfd_architecture arch;
2165
6.76k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
6.76k
  machine = 0;
2169
6.76k
  switch (internal_f->f_magic)
2170
6.76k
    {
2171
0
#ifdef I386MAGIC
2172
6.39k
    case I386MAGIC:
2173
6.41k
    case I386PTXMAGIC:
2174
6.70k
    case I386AIXMAGIC:   /* Danbury PS/2 AIX C Compiler.  */
2175
6.76k
    case LYNXCOFFMAGIC:
2176
6.76k
    case I386_APPLE_MAGIC:
2177
6.76k
    case I386_FREEBSD_MAGIC:
2178
6.76k
    case I386_LINUX_MAGIC:
2179
6.76k
    case I386_NETBSD_MAGIC:
2180
6.76k
      arch = bfd_arch_i386;
2181
6.76k
      break;
2182
0
#endif
2183
#ifdef AMD64MAGIC
2184
    case AMD64MAGIC:
2185
    case AMD64_APPLE_MAGIC:
2186
    case AMD64_FREEBSD_MAGIC:
2187
    case AMD64_LINUX_MAGIC:
2188
    case AMD64_NETBSD_MAGIC:
2189
      arch = bfd_arch_i386;
2190
      machine = bfd_mach_x86_64;
2191
      break;
2192
#endif
2193
#ifdef IA64MAGIC
2194
    case IA64MAGIC:
2195
      arch = bfd_arch_ia64;
2196
      break;
2197
#endif
2198
#ifdef ARMMAGIC
2199
    case ARMMAGIC:
2200
    case ARMPEMAGIC:
2201
    case THUMBPEMAGIC:
2202
      arch = bfd_arch_arm;
2203
      machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION);
2204
      if (machine == bfd_mach_arm_unknown)
2205
  {
2206
    switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK)
2207
      {
2208
      case F_ARM_2:  machine = bfd_mach_arm_2;  break;
2209
      case F_ARM_2a: machine = bfd_mach_arm_2a; break;
2210
      case F_ARM_3:  machine = bfd_mach_arm_3;  break;
2211
      default:
2212
      case F_ARM_3M: machine = bfd_mach_arm_3M; break;
2213
      case F_ARM_4:  machine = bfd_mach_arm_4;  break;
2214
      case F_ARM_4T: machine = bfd_mach_arm_4T; break;
2215
        /* The COFF header does not have enough bits available
2216
     to cover all the different ARM architectures.  So
2217
     we interpret F_ARM_5, the highest flag value to mean
2218
     "the highest ARM architecture known to BFD" which is
2219
     currently the XScale.  */
2220
      case F_ARM_5:  machine = bfd_mach_arm_XScale;  break;
2221
      }
2222
  }
2223
      break;
2224
#endif
2225
#ifdef AARCH64MAGIC
2226
    case AARCH64MAGIC:
2227
      arch = bfd_arch_aarch64;
2228
      machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK;
2229
      break;
2230
#endif
2231
#ifdef LOONGARCH64MAGIC
2232
    case LOONGARCH64MAGIC:
2233
      arch = bfd_arch_loongarch;
2234
      machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK;
2235
      break;
2236
#endif
2237
#ifdef Z80MAGIC
2238
    case Z80MAGIC:
2239
      arch = bfd_arch_z80;
2240
      switch (internal_f->f_flags & F_MACHMASK)
2241
  {
2242
  case bfd_mach_z80strict << 12:
2243
  case bfd_mach_z80 << 12:
2244
  case bfd_mach_z80n << 12:
2245
  case bfd_mach_z80full << 12:
2246
  case bfd_mach_r800 << 12:
2247
  case bfd_mach_gbz80 << 12:
2248
  case bfd_mach_z180 << 12:
2249
  case bfd_mach_ez80_z80 << 12:
2250
  case bfd_mach_ez80_adl << 12:
2251
    machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12;
2252
    break;
2253
  default:
2254
    return false;
2255
  }
2256
      break;
2257
#endif
2258
#ifdef Z8KMAGIC
2259
    case Z8KMAGIC:
2260
      arch = bfd_arch_z8k;
2261
      switch (internal_f->f_flags & F_MACHMASK)
2262
  {
2263
  case F_Z8001:
2264
    machine = bfd_mach_z8001;
2265
    break;
2266
  case F_Z8002:
2267
    machine = bfd_mach_z8002;
2268
    break;
2269
  default:
2270
    return false;
2271
  }
2272
      break;
2273
#endif
2274
2275
#ifdef RS6000COFF_C
2276
#ifdef XCOFF64
2277
    case U64_TOCMAGIC:
2278
    case U803XTOCMAGIC:
2279
#else
2280
    case U802ROMAGIC:
2281
    case U802WRMAGIC:
2282
    case U802TOCMAGIC:
2283
#endif
2284
      {
2285
  int cputype;
2286
2287
  if (xcoff_data (abfd)->cputype != -1)
2288
    cputype = xcoff_data (abfd)->cputype & 0xff;
2289
  else
2290
    {
2291
      /* We did not get a value from the a.out header.  If the
2292
         file has not been stripped, we may be able to get the
2293
         architecture information from the first symbol, if it
2294
         is a .file symbol.  */
2295
      if (obj_raw_syment_count (abfd) == 0)
2296
        cputype = 0;
2297
      else
2298
        {
2299
    bfd_byte *buf;
2300
    struct internal_syment sym;
2301
    bfd_size_type amt = bfd_coff_symesz (abfd);
2302
2303
    if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
2304
      return false;
2305
    buf = _bfd_malloc_and_read (abfd, amt, amt);
2306
    if (buf == NULL)
2307
      return false;
2308
    bfd_coff_swap_sym_in (abfd, buf, & sym);
2309
    if (sym.n_sclass == C_FILE)
2310
      cputype = sym.n_type & 0xff;
2311
    else
2312
      cputype = 0;
2313
    free (buf);
2314
        }
2315
    }
2316
2317
  /* FIXME: We don't handle all cases here.  */
2318
  switch (cputype)
2319
    {
2320
    default:
2321
    case 0:
2322
      arch = bfd_xcoff_architecture (abfd);
2323
      machine = bfd_xcoff_machine (abfd);
2324
      break;
2325
2326
    case 1:
2327
      arch = bfd_arch_powerpc;
2328
      machine = bfd_mach_ppc_601;
2329
      break;
2330
    case 2: /* 64 bit PowerPC */
2331
      arch = bfd_arch_powerpc;
2332
      machine = bfd_mach_ppc_620;
2333
      break;
2334
    case 3:
2335
      arch = bfd_arch_powerpc;
2336
      machine = bfd_mach_ppc;
2337
      break;
2338
    case 4:
2339
      arch = bfd_arch_rs6000;
2340
      machine = bfd_mach_rs6k;
2341
      break;
2342
    }
2343
      }
2344
      break;
2345
#endif
2346
2347
#ifdef SH_ARCH_MAGIC_BIG
2348
    case SH_ARCH_MAGIC_BIG:
2349
    case SH_ARCH_MAGIC_LITTLE:
2350
#ifdef COFF_WITH_PE
2351
    case SH_ARCH_MAGIC_WINCE:
2352
#endif
2353
      arch = bfd_arch_sh;
2354
      break;
2355
#endif
2356
2357
#ifdef MIPS_ARCH_MAGIC_WINCE
2358
    case MIPS_ARCH_MAGIC_WINCE:
2359
      arch = bfd_arch_mips;
2360
      break;
2361
#endif
2362
2363
#ifdef SPARCMAGIC
2364
    case SPARCMAGIC:
2365
#ifdef LYNXCOFFMAGIC
2366
    case LYNXCOFFMAGIC:
2367
#endif
2368
      arch = bfd_arch_sparc;
2369
      break;
2370
#endif
2371
2372
#ifdef TIC30MAGIC
2373
    case TIC30MAGIC:
2374
      arch = bfd_arch_tic30;
2375
      break;
2376
#endif
2377
2378
#ifdef TICOFF0MAGIC
2379
#ifdef TICOFF_TARGET_ARCH
2380
      /* This TI COFF section should be used by all new TI COFF v0 targets.  */
2381
    case TICOFF0MAGIC:
2382
      arch = TICOFF_TARGET_ARCH;
2383
      machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2384
      break;
2385
#endif
2386
#endif
2387
2388
#ifdef TICOFF1MAGIC
2389
      /* This TI COFF section should be used by all new TI COFF v1/2 targets.  */
2390
      /* TI COFF1 and COFF2 use the target_id field to specify which arch.  */
2391
    case TICOFF1MAGIC:
2392
    case TICOFF2MAGIC:
2393
      switch (internal_f->f_target_id)
2394
  {
2395
#ifdef TI_TARGET_ID
2396
  case TI_TARGET_ID:
2397
    arch = TICOFF_TARGET_ARCH;
2398
    machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2399
    break;
2400
#endif
2401
  default:
2402
    arch = bfd_arch_obscure;
2403
    _bfd_error_handler
2404
      (_("unrecognized TI COFF target id '0x%x'"),
2405
       internal_f->f_target_id);
2406
    break;
2407
  }
2408
      break;
2409
#endif
2410
2411
#ifdef MCOREMAGIC
2412
    case MCOREMAGIC:
2413
      arch = bfd_arch_mcore;
2414
      break;
2415
#endif
2416
2417
0
    default:      /* Unreadable input file type.  */
2418
0
      arch = bfd_arch_obscure;
2419
0
      break;
2420
6.76k
    }
2421
2422
6.76k
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
6.76k
  return true;
2424
6.76k
}
coff-rs6000.c:coff_set_arch_mach_hook
Line
Count
Source
2162
8.11k
{
2163
8.11k
  unsigned long machine;
2164
8.11k
  enum bfd_architecture arch;
2165
8.11k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
8.11k
  machine = 0;
2169
8.11k
  switch (internal_f->f_magic)
2170
8.11k
    {
2171
#ifdef I386MAGIC
2172
    case I386MAGIC:
2173
    case I386PTXMAGIC:
2174
    case I386AIXMAGIC:    /* Danbury PS/2 AIX C Compiler.  */
2175
    case LYNXCOFFMAGIC:
2176
    case I386_APPLE_MAGIC:
2177
    case I386_FREEBSD_MAGIC:
2178
    case I386_LINUX_MAGIC:
2179
    case I386_NETBSD_MAGIC:
2180
      arch = bfd_arch_i386;
2181
      break;
2182
#endif
2183
#ifdef AMD64MAGIC
2184
    case AMD64MAGIC:
2185
    case AMD64_APPLE_MAGIC:
2186
    case AMD64_FREEBSD_MAGIC:
2187
    case AMD64_LINUX_MAGIC:
2188
    case AMD64_NETBSD_MAGIC:
2189
      arch = bfd_arch_i386;
2190
      machine = bfd_mach_x86_64;
2191
      break;
2192
#endif
2193
#ifdef IA64MAGIC
2194
    case IA64MAGIC:
2195
      arch = bfd_arch_ia64;
2196
      break;
2197
#endif
2198
#ifdef ARMMAGIC
2199
    case ARMMAGIC:
2200
    case ARMPEMAGIC:
2201
    case THUMBPEMAGIC:
2202
      arch = bfd_arch_arm;
2203
      machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION);
2204
      if (machine == bfd_mach_arm_unknown)
2205
  {
2206
    switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK)
2207
      {
2208
      case F_ARM_2:  machine = bfd_mach_arm_2;  break;
2209
      case F_ARM_2a: machine = bfd_mach_arm_2a; break;
2210
      case F_ARM_3:  machine = bfd_mach_arm_3;  break;
2211
      default:
2212
      case F_ARM_3M: machine = bfd_mach_arm_3M; break;
2213
      case F_ARM_4:  machine = bfd_mach_arm_4;  break;
2214
      case F_ARM_4T: machine = bfd_mach_arm_4T; break;
2215
        /* The COFF header does not have enough bits available
2216
     to cover all the different ARM architectures.  So
2217
     we interpret F_ARM_5, the highest flag value to mean
2218
     "the highest ARM architecture known to BFD" which is
2219
     currently the XScale.  */
2220
      case F_ARM_5:  machine = bfd_mach_arm_XScale;  break;
2221
      }
2222
  }
2223
      break;
2224
#endif
2225
#ifdef AARCH64MAGIC
2226
    case AARCH64MAGIC:
2227
      arch = bfd_arch_aarch64;
2228
      machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK;
2229
      break;
2230
#endif
2231
#ifdef LOONGARCH64MAGIC
2232
    case LOONGARCH64MAGIC:
2233
      arch = bfd_arch_loongarch;
2234
      machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK;
2235
      break;
2236
#endif
2237
#ifdef Z80MAGIC
2238
    case Z80MAGIC:
2239
      arch = bfd_arch_z80;
2240
      switch (internal_f->f_flags & F_MACHMASK)
2241
  {
2242
  case bfd_mach_z80strict << 12:
2243
  case bfd_mach_z80 << 12:
2244
  case bfd_mach_z80n << 12:
2245
  case bfd_mach_z80full << 12:
2246
  case bfd_mach_r800 << 12:
2247
  case bfd_mach_gbz80 << 12:
2248
  case bfd_mach_z180 << 12:
2249
  case bfd_mach_ez80_z80 << 12:
2250
  case bfd_mach_ez80_adl << 12:
2251
    machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12;
2252
    break;
2253
  default:
2254
    return false;
2255
  }
2256
      break;
2257
#endif
2258
#ifdef Z8KMAGIC
2259
    case Z8KMAGIC:
2260
      arch = bfd_arch_z8k;
2261
      switch (internal_f->f_flags & F_MACHMASK)
2262
  {
2263
  case F_Z8001:
2264
    machine = bfd_mach_z8001;
2265
    break;
2266
  case F_Z8002:
2267
    machine = bfd_mach_z8002;
2268
    break;
2269
  default:
2270
    return false;
2271
  }
2272
      break;
2273
#endif
2274
2275
0
#ifdef RS6000COFF_C
2276
#ifdef XCOFF64
2277
    case U64_TOCMAGIC:
2278
    case U803XTOCMAGIC:
2279
#else
2280
1.84k
    case U802ROMAGIC:
2281
2.57k
    case U802WRMAGIC:
2282
8.11k
    case U802TOCMAGIC:
2283
8.11k
#endif
2284
8.11k
      {
2285
8.11k
  int cputype;
2286
2287
8.11k
  if (xcoff_data (abfd)->cputype != -1)
2288
1.86k
    cputype = xcoff_data (abfd)->cputype & 0xff;
2289
6.25k
  else
2290
6.25k
    {
2291
      /* We did not get a value from the a.out header.  If the
2292
         file has not been stripped, we may be able to get the
2293
         architecture information from the first symbol, if it
2294
         is a .file symbol.  */
2295
6.25k
      if (obj_raw_syment_count (abfd) == 0)
2296
1.78k
        cputype = 0;
2297
4.46k
      else
2298
4.46k
        {
2299
4.46k
    bfd_byte *buf;
2300
4.46k
    struct internal_syment sym;
2301
4.46k
    bfd_size_type amt = bfd_coff_symesz (abfd);
2302
2303
4.46k
    if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
2304
0
      return false;
2305
4.46k
    buf = _bfd_malloc_and_read (abfd, amt, amt);
2306
4.46k
    if (buf == NULL)
2307
114
      return false;
2308
4.35k
    bfd_coff_swap_sym_in (abfd, buf, & sym);
2309
4.35k
    if (sym.n_sclass == C_FILE)
2310
145
      cputype = sym.n_type & 0xff;
2311
4.20k
    else
2312
4.20k
      cputype = 0;
2313
4.35k
    free (buf);
2314
4.35k
        }
2315
6.25k
    }
2316
2317
  /* FIXME: We don't handle all cases here.  */
2318
8.00k
  switch (cputype)
2319
8.00k
    {
2320
1.49k
    default:
2321
7.72k
    case 0:
2322
7.72k
      arch = bfd_xcoff_architecture (abfd);
2323
7.72k
      machine = bfd_xcoff_machine (abfd);
2324
7.72k
      break;
2325
2326
137
    case 1:
2327
137
      arch = bfd_arch_powerpc;
2328
137
      machine = bfd_mach_ppc_601;
2329
137
      break;
2330
139
    case 2: /* 64 bit PowerPC */
2331
139
      arch = bfd_arch_powerpc;
2332
139
      machine = bfd_mach_ppc_620;
2333
139
      break;
2334
1
    case 3:
2335
1
      arch = bfd_arch_powerpc;
2336
1
      machine = bfd_mach_ppc;
2337
1
      break;
2338
1
    case 4:
2339
1
      arch = bfd_arch_rs6000;
2340
1
      machine = bfd_mach_rs6k;
2341
1
      break;
2342
8.00k
    }
2343
8.00k
      }
2344
8.00k
      break;
2345
8.00k
#endif
2346
2347
#ifdef SH_ARCH_MAGIC_BIG
2348
    case SH_ARCH_MAGIC_BIG:
2349
    case SH_ARCH_MAGIC_LITTLE:
2350
#ifdef COFF_WITH_PE
2351
    case SH_ARCH_MAGIC_WINCE:
2352
#endif
2353
      arch = bfd_arch_sh;
2354
      break;
2355
#endif
2356
2357
#ifdef MIPS_ARCH_MAGIC_WINCE
2358
    case MIPS_ARCH_MAGIC_WINCE:
2359
      arch = bfd_arch_mips;
2360
      break;
2361
#endif
2362
2363
#ifdef SPARCMAGIC
2364
    case SPARCMAGIC:
2365
#ifdef LYNXCOFFMAGIC
2366
    case LYNXCOFFMAGIC:
2367
#endif
2368
      arch = bfd_arch_sparc;
2369
      break;
2370
#endif
2371
2372
#ifdef TIC30MAGIC
2373
    case TIC30MAGIC:
2374
      arch = bfd_arch_tic30;
2375
      break;
2376
#endif
2377
2378
#ifdef TICOFF0MAGIC
2379
#ifdef TICOFF_TARGET_ARCH
2380
      /* This TI COFF section should be used by all new TI COFF v0 targets.  */
2381
    case TICOFF0MAGIC:
2382
      arch = TICOFF_TARGET_ARCH;
2383
      machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2384
      break;
2385
#endif
2386
#endif
2387
2388
#ifdef TICOFF1MAGIC
2389
      /* This TI COFF section should be used by all new TI COFF v1/2 targets.  */
2390
      /* TI COFF1 and COFF2 use the target_id field to specify which arch.  */
2391
    case TICOFF1MAGIC:
2392
    case TICOFF2MAGIC:
2393
      switch (internal_f->f_target_id)
2394
  {
2395
#ifdef TI_TARGET_ID
2396
  case TI_TARGET_ID:
2397
    arch = TICOFF_TARGET_ARCH;
2398
    machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2399
    break;
2400
#endif
2401
  default:
2402
    arch = bfd_arch_obscure;
2403
    _bfd_error_handler
2404
      (_("unrecognized TI COFF target id '0x%x'"),
2405
       internal_f->f_target_id);
2406
    break;
2407
  }
2408
      break;
2409
#endif
2410
2411
#ifdef MCOREMAGIC
2412
    case MCOREMAGIC:
2413
      arch = bfd_arch_mcore;
2414
      break;
2415
#endif
2416
2417
8.00k
    default:      /* Unreadable input file type.  */
2418
0
      arch = bfd_arch_obscure;
2419
0
      break;
2420
8.11k
    }
2421
2422
8.00k
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
8.00k
  return true;
2424
8.11k
}
coff-sh.c:coff_set_arch_mach_hook
Line
Count
Source
2162
12.0k
{
2163
12.0k
  unsigned long machine;
2164
12.0k
  enum bfd_architecture arch;
2165
12.0k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
12.0k
  machine = 0;
2169
12.0k
  switch (internal_f->f_magic)
2170
12.0k
    {
2171
#ifdef I386MAGIC
2172
    case I386MAGIC:
2173
    case I386PTXMAGIC:
2174
    case I386AIXMAGIC:    /* Danbury PS/2 AIX C Compiler.  */
2175
    case LYNXCOFFMAGIC:
2176
    case I386_APPLE_MAGIC:
2177
    case I386_FREEBSD_MAGIC:
2178
    case I386_LINUX_MAGIC:
2179
    case I386_NETBSD_MAGIC:
2180
      arch = bfd_arch_i386;
2181
      break;
2182
#endif
2183
#ifdef AMD64MAGIC
2184
    case AMD64MAGIC:
2185
    case AMD64_APPLE_MAGIC:
2186
    case AMD64_FREEBSD_MAGIC:
2187
    case AMD64_LINUX_MAGIC:
2188
    case AMD64_NETBSD_MAGIC:
2189
      arch = bfd_arch_i386;
2190
      machine = bfd_mach_x86_64;
2191
      break;
2192
#endif
2193
#ifdef IA64MAGIC
2194
    case IA64MAGIC:
2195
      arch = bfd_arch_ia64;
2196
      break;
2197
#endif
2198
#ifdef ARMMAGIC
2199
    case ARMMAGIC:
2200
    case ARMPEMAGIC:
2201
    case THUMBPEMAGIC:
2202
      arch = bfd_arch_arm;
2203
      machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION);
2204
      if (machine == bfd_mach_arm_unknown)
2205
  {
2206
    switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK)
2207
      {
2208
      case F_ARM_2:  machine = bfd_mach_arm_2;  break;
2209
      case F_ARM_2a: machine = bfd_mach_arm_2a; break;
2210
      case F_ARM_3:  machine = bfd_mach_arm_3;  break;
2211
      default:
2212
      case F_ARM_3M: machine = bfd_mach_arm_3M; break;
2213
      case F_ARM_4:  machine = bfd_mach_arm_4;  break;
2214
      case F_ARM_4T: machine = bfd_mach_arm_4T; break;
2215
        /* The COFF header does not have enough bits available
2216
     to cover all the different ARM architectures.  So
2217
     we interpret F_ARM_5, the highest flag value to mean
2218
     "the highest ARM architecture known to BFD" which is
2219
     currently the XScale.  */
2220
      case F_ARM_5:  machine = bfd_mach_arm_XScale;  break;
2221
      }
2222
  }
2223
      break;
2224
#endif
2225
#ifdef AARCH64MAGIC
2226
    case AARCH64MAGIC:
2227
      arch = bfd_arch_aarch64;
2228
      machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK;
2229
      break;
2230
#endif
2231
#ifdef LOONGARCH64MAGIC
2232
    case LOONGARCH64MAGIC:
2233
      arch = bfd_arch_loongarch;
2234
      machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK;
2235
      break;
2236
#endif
2237
#ifdef Z80MAGIC
2238
    case Z80MAGIC:
2239
      arch = bfd_arch_z80;
2240
      switch (internal_f->f_flags & F_MACHMASK)
2241
  {
2242
  case bfd_mach_z80strict << 12:
2243
  case bfd_mach_z80 << 12:
2244
  case bfd_mach_z80n << 12:
2245
  case bfd_mach_z80full << 12:
2246
  case bfd_mach_r800 << 12:
2247
  case bfd_mach_gbz80 << 12:
2248
  case bfd_mach_z180 << 12:
2249
  case bfd_mach_ez80_z80 << 12:
2250
  case bfd_mach_ez80_adl << 12:
2251
    machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12;
2252
    break;
2253
  default:
2254
    return false;
2255
  }
2256
      break;
2257
#endif
2258
#ifdef Z8KMAGIC
2259
    case Z8KMAGIC:
2260
      arch = bfd_arch_z8k;
2261
      switch (internal_f->f_flags & F_MACHMASK)
2262
  {
2263
  case F_Z8001:
2264
    machine = bfd_mach_z8001;
2265
    break;
2266
  case F_Z8002:
2267
    machine = bfd_mach_z8002;
2268
    break;
2269
  default:
2270
    return false;
2271
  }
2272
      break;
2273
#endif
2274
2275
#ifdef RS6000COFF_C
2276
#ifdef XCOFF64
2277
    case U64_TOCMAGIC:
2278
    case U803XTOCMAGIC:
2279
#else
2280
    case U802ROMAGIC:
2281
    case U802WRMAGIC:
2282
    case U802TOCMAGIC:
2283
#endif
2284
      {
2285
  int cputype;
2286
2287
  if (xcoff_data (abfd)->cputype != -1)
2288
    cputype = xcoff_data (abfd)->cputype & 0xff;
2289
  else
2290
    {
2291
      /* We did not get a value from the a.out header.  If the
2292
         file has not been stripped, we may be able to get the
2293
         architecture information from the first symbol, if it
2294
         is a .file symbol.  */
2295
      if (obj_raw_syment_count (abfd) == 0)
2296
        cputype = 0;
2297
      else
2298
        {
2299
    bfd_byte *buf;
2300
    struct internal_syment sym;
2301
    bfd_size_type amt = bfd_coff_symesz (abfd);
2302
2303
    if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
2304
      return false;
2305
    buf = _bfd_malloc_and_read (abfd, amt, amt);
2306
    if (buf == NULL)
2307
      return false;
2308
    bfd_coff_swap_sym_in (abfd, buf, & sym);
2309
    if (sym.n_sclass == C_FILE)
2310
      cputype = sym.n_type & 0xff;
2311
    else
2312
      cputype = 0;
2313
    free (buf);
2314
        }
2315
    }
2316
2317
  /* FIXME: We don't handle all cases here.  */
2318
  switch (cputype)
2319
    {
2320
    default:
2321
    case 0:
2322
      arch = bfd_xcoff_architecture (abfd);
2323
      machine = bfd_xcoff_machine (abfd);
2324
      break;
2325
2326
    case 1:
2327
      arch = bfd_arch_powerpc;
2328
      machine = bfd_mach_ppc_601;
2329
      break;
2330
    case 2: /* 64 bit PowerPC */
2331
      arch = bfd_arch_powerpc;
2332
      machine = bfd_mach_ppc_620;
2333
      break;
2334
    case 3:
2335
      arch = bfd_arch_powerpc;
2336
      machine = bfd_mach_ppc;
2337
      break;
2338
    case 4:
2339
      arch = bfd_arch_rs6000;
2340
      machine = bfd_mach_rs6k;
2341
      break;
2342
    }
2343
      }
2344
      break;
2345
#endif
2346
2347
0
#ifdef SH_ARCH_MAGIC_BIG
2348
10.1k
    case SH_ARCH_MAGIC_BIG:
2349
12.0k
    case SH_ARCH_MAGIC_LITTLE:
2350
#ifdef COFF_WITH_PE
2351
    case SH_ARCH_MAGIC_WINCE:
2352
#endif
2353
12.0k
      arch = bfd_arch_sh;
2354
12.0k
      break;
2355
0
#endif
2356
2357
#ifdef MIPS_ARCH_MAGIC_WINCE
2358
    case MIPS_ARCH_MAGIC_WINCE:
2359
      arch = bfd_arch_mips;
2360
      break;
2361
#endif
2362
2363
#ifdef SPARCMAGIC
2364
    case SPARCMAGIC:
2365
#ifdef LYNXCOFFMAGIC
2366
    case LYNXCOFFMAGIC:
2367
#endif
2368
      arch = bfd_arch_sparc;
2369
      break;
2370
#endif
2371
2372
#ifdef TIC30MAGIC
2373
    case TIC30MAGIC:
2374
      arch = bfd_arch_tic30;
2375
      break;
2376
#endif
2377
2378
#ifdef TICOFF0MAGIC
2379
#ifdef TICOFF_TARGET_ARCH
2380
      /* This TI COFF section should be used by all new TI COFF v0 targets.  */
2381
    case TICOFF0MAGIC:
2382
      arch = TICOFF_TARGET_ARCH;
2383
      machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2384
      break;
2385
#endif
2386
#endif
2387
2388
#ifdef TICOFF1MAGIC
2389
      /* This TI COFF section should be used by all new TI COFF v1/2 targets.  */
2390
      /* TI COFF1 and COFF2 use the target_id field to specify which arch.  */
2391
    case TICOFF1MAGIC:
2392
    case TICOFF2MAGIC:
2393
      switch (internal_f->f_target_id)
2394
  {
2395
#ifdef TI_TARGET_ID
2396
  case TI_TARGET_ID:
2397
    arch = TICOFF_TARGET_ARCH;
2398
    machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2399
    break;
2400
#endif
2401
  default:
2402
    arch = bfd_arch_obscure;
2403
    _bfd_error_handler
2404
      (_("unrecognized TI COFF target id '0x%x'"),
2405
       internal_f->f_target_id);
2406
    break;
2407
  }
2408
      break;
2409
#endif
2410
2411
#ifdef MCOREMAGIC
2412
    case MCOREMAGIC:
2413
      arch = bfd_arch_mcore;
2414
      break;
2415
#endif
2416
2417
61
    default:      /* Unreadable input file type.  */
2418
61
      arch = bfd_arch_obscure;
2419
61
      break;
2420
12.0k
    }
2421
2422
12.0k
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
12.0k
  return true;
2424
12.0k
}
coff-stgo32.c:coff_set_arch_mach_hook
Line
Count
Source
2162
327
{
2163
327
  unsigned long machine;
2164
327
  enum bfd_architecture arch;
2165
327
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
327
  machine = 0;
2169
327
  switch (internal_f->f_magic)
2170
327
    {
2171
0
#ifdef I386MAGIC
2172
78
    case I386MAGIC:
2173
211
    case I386PTXMAGIC:
2174
215
    case I386AIXMAGIC:   /* Danbury PS/2 AIX C Compiler.  */
2175
216
    case LYNXCOFFMAGIC:
2176
216
    case I386_APPLE_MAGIC:
2177
216
    case I386_FREEBSD_MAGIC:
2178
216
    case I386_LINUX_MAGIC:
2179
327
    case I386_NETBSD_MAGIC:
2180
327
      arch = bfd_arch_i386;
2181
327
      break;
2182
0
#endif
2183
#ifdef AMD64MAGIC
2184
    case AMD64MAGIC:
2185
    case AMD64_APPLE_MAGIC:
2186
    case AMD64_FREEBSD_MAGIC:
2187
    case AMD64_LINUX_MAGIC:
2188
    case AMD64_NETBSD_MAGIC:
2189
      arch = bfd_arch_i386;
2190
      machine = bfd_mach_x86_64;
2191
      break;
2192
#endif
2193
#ifdef IA64MAGIC
2194
    case IA64MAGIC:
2195
      arch = bfd_arch_ia64;
2196
      break;
2197
#endif
2198
#ifdef ARMMAGIC
2199
    case ARMMAGIC:
2200
    case ARMPEMAGIC:
2201
    case THUMBPEMAGIC:
2202
      arch = bfd_arch_arm;
2203
      machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION);
2204
      if (machine == bfd_mach_arm_unknown)
2205
  {
2206
    switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK)
2207
      {
2208
      case F_ARM_2:  machine = bfd_mach_arm_2;  break;
2209
      case F_ARM_2a: machine = bfd_mach_arm_2a; break;
2210
      case F_ARM_3:  machine = bfd_mach_arm_3;  break;
2211
      default:
2212
      case F_ARM_3M: machine = bfd_mach_arm_3M; break;
2213
      case F_ARM_4:  machine = bfd_mach_arm_4;  break;
2214
      case F_ARM_4T: machine = bfd_mach_arm_4T; break;
2215
        /* The COFF header does not have enough bits available
2216
     to cover all the different ARM architectures.  So
2217
     we interpret F_ARM_5, the highest flag value to mean
2218
     "the highest ARM architecture known to BFD" which is
2219
     currently the XScale.  */
2220
      case F_ARM_5:  machine = bfd_mach_arm_XScale;  break;
2221
      }
2222
  }
2223
      break;
2224
#endif
2225
#ifdef AARCH64MAGIC
2226
    case AARCH64MAGIC:
2227
      arch = bfd_arch_aarch64;
2228
      machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK;
2229
      break;
2230
#endif
2231
#ifdef LOONGARCH64MAGIC
2232
    case LOONGARCH64MAGIC:
2233
      arch = bfd_arch_loongarch;
2234
      machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK;
2235
      break;
2236
#endif
2237
#ifdef Z80MAGIC
2238
    case Z80MAGIC:
2239
      arch = bfd_arch_z80;
2240
      switch (internal_f->f_flags & F_MACHMASK)
2241
  {
2242
  case bfd_mach_z80strict << 12:
2243
  case bfd_mach_z80 << 12:
2244
  case bfd_mach_z80n << 12:
2245
  case bfd_mach_z80full << 12:
2246
  case bfd_mach_r800 << 12:
2247
  case bfd_mach_gbz80 << 12:
2248
  case bfd_mach_z180 << 12:
2249
  case bfd_mach_ez80_z80 << 12:
2250
  case bfd_mach_ez80_adl << 12:
2251
    machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12;
2252
    break;
2253
  default:
2254
    return false;
2255
  }
2256
      break;
2257
#endif
2258
#ifdef Z8KMAGIC
2259
    case Z8KMAGIC:
2260
      arch = bfd_arch_z8k;
2261
      switch (internal_f->f_flags & F_MACHMASK)
2262
  {
2263
  case F_Z8001:
2264
    machine = bfd_mach_z8001;
2265
    break;
2266
  case F_Z8002:
2267
    machine = bfd_mach_z8002;
2268
    break;
2269
  default:
2270
    return false;
2271
  }
2272
      break;
2273
#endif
2274
2275
#ifdef RS6000COFF_C
2276
#ifdef XCOFF64
2277
    case U64_TOCMAGIC:
2278
    case U803XTOCMAGIC:
2279
#else
2280
    case U802ROMAGIC:
2281
    case U802WRMAGIC:
2282
    case U802TOCMAGIC:
2283
#endif
2284
      {
2285
  int cputype;
2286
2287
  if (xcoff_data (abfd)->cputype != -1)
2288
    cputype = xcoff_data (abfd)->cputype & 0xff;
2289
  else
2290
    {
2291
      /* We did not get a value from the a.out header.  If the
2292
         file has not been stripped, we may be able to get the
2293
         architecture information from the first symbol, if it
2294
         is a .file symbol.  */
2295
      if (obj_raw_syment_count (abfd) == 0)
2296
        cputype = 0;
2297
      else
2298
        {
2299
    bfd_byte *buf;
2300
    struct internal_syment sym;
2301
    bfd_size_type amt = bfd_coff_symesz (abfd);
2302
2303
    if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
2304
      return false;
2305
    buf = _bfd_malloc_and_read (abfd, amt, amt);
2306
    if (buf == NULL)
2307
      return false;
2308
    bfd_coff_swap_sym_in (abfd, buf, & sym);
2309
    if (sym.n_sclass == C_FILE)
2310
      cputype = sym.n_type & 0xff;
2311
    else
2312
      cputype = 0;
2313
    free (buf);
2314
        }
2315
    }
2316
2317
  /* FIXME: We don't handle all cases here.  */
2318
  switch (cputype)
2319
    {
2320
    default:
2321
    case 0:
2322
      arch = bfd_xcoff_architecture (abfd);
2323
      machine = bfd_xcoff_machine (abfd);
2324
      break;
2325
2326
    case 1:
2327
      arch = bfd_arch_powerpc;
2328
      machine = bfd_mach_ppc_601;
2329
      break;
2330
    case 2: /* 64 bit PowerPC */
2331
      arch = bfd_arch_powerpc;
2332
      machine = bfd_mach_ppc_620;
2333
      break;
2334
    case 3:
2335
      arch = bfd_arch_powerpc;
2336
      machine = bfd_mach_ppc;
2337
      break;
2338
    case 4:
2339
      arch = bfd_arch_rs6000;
2340
      machine = bfd_mach_rs6k;
2341
      break;
2342
    }
2343
      }
2344
      break;
2345
#endif
2346
2347
#ifdef SH_ARCH_MAGIC_BIG
2348
    case SH_ARCH_MAGIC_BIG:
2349
    case SH_ARCH_MAGIC_LITTLE:
2350
#ifdef COFF_WITH_PE
2351
    case SH_ARCH_MAGIC_WINCE:
2352
#endif
2353
      arch = bfd_arch_sh;
2354
      break;
2355
#endif
2356
2357
#ifdef MIPS_ARCH_MAGIC_WINCE
2358
    case MIPS_ARCH_MAGIC_WINCE:
2359
      arch = bfd_arch_mips;
2360
      break;
2361
#endif
2362
2363
#ifdef SPARCMAGIC
2364
    case SPARCMAGIC:
2365
#ifdef LYNXCOFFMAGIC
2366
    case LYNXCOFFMAGIC:
2367
#endif
2368
      arch = bfd_arch_sparc;
2369
      break;
2370
#endif
2371
2372
#ifdef TIC30MAGIC
2373
    case TIC30MAGIC:
2374
      arch = bfd_arch_tic30;
2375
      break;
2376
#endif
2377
2378
#ifdef TICOFF0MAGIC
2379
#ifdef TICOFF_TARGET_ARCH
2380
      /* This TI COFF section should be used by all new TI COFF v0 targets.  */
2381
    case TICOFF0MAGIC:
2382
      arch = TICOFF_TARGET_ARCH;
2383
      machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2384
      break;
2385
#endif
2386
#endif
2387
2388
#ifdef TICOFF1MAGIC
2389
      /* This TI COFF section should be used by all new TI COFF v1/2 targets.  */
2390
      /* TI COFF1 and COFF2 use the target_id field to specify which arch.  */
2391
    case TICOFF1MAGIC:
2392
    case TICOFF2MAGIC:
2393
      switch (internal_f->f_target_id)
2394
  {
2395
#ifdef TI_TARGET_ID
2396
  case TI_TARGET_ID:
2397
    arch = TICOFF_TARGET_ARCH;
2398
    machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2399
    break;
2400
#endif
2401
  default:
2402
    arch = bfd_arch_obscure;
2403
    _bfd_error_handler
2404
      (_("unrecognized TI COFF target id '0x%x'"),
2405
       internal_f->f_target_id);
2406
    break;
2407
  }
2408
      break;
2409
#endif
2410
2411
#ifdef MCOREMAGIC
2412
    case MCOREMAGIC:
2413
      arch = bfd_arch_mcore;
2414
      break;
2415
#endif
2416
2417
0
    default:      /* Unreadable input file type.  */
2418
0
      arch = bfd_arch_obscure;
2419
0
      break;
2420
327
    }
2421
2422
327
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
327
  return true;
2424
327
}
coff-tic30.c:coff_set_arch_mach_hook
Line
Count
Source
2162
4.46k
{
2163
4.46k
  unsigned long machine;
2164
4.46k
  enum bfd_architecture arch;
2165
4.46k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
4.46k
  machine = 0;
2169
4.46k
  switch (internal_f->f_magic)
2170
4.46k
    {
2171
#ifdef I386MAGIC
2172
    case I386MAGIC:
2173
    case I386PTXMAGIC:
2174
    case I386AIXMAGIC:    /* Danbury PS/2 AIX C Compiler.  */
2175
    case LYNXCOFFMAGIC:
2176
    case I386_APPLE_MAGIC:
2177
    case I386_FREEBSD_MAGIC:
2178
    case I386_LINUX_MAGIC:
2179
    case I386_NETBSD_MAGIC:
2180
      arch = bfd_arch_i386;
2181
      break;
2182
#endif
2183
#ifdef AMD64MAGIC
2184
    case AMD64MAGIC:
2185
    case AMD64_APPLE_MAGIC:
2186
    case AMD64_FREEBSD_MAGIC:
2187
    case AMD64_LINUX_MAGIC:
2188
    case AMD64_NETBSD_MAGIC:
2189
      arch = bfd_arch_i386;
2190
      machine = bfd_mach_x86_64;
2191
      break;
2192
#endif
2193
#ifdef IA64MAGIC
2194
    case IA64MAGIC:
2195
      arch = bfd_arch_ia64;
2196
      break;
2197
#endif
2198
#ifdef ARMMAGIC
2199
    case ARMMAGIC:
2200
    case ARMPEMAGIC:
2201
    case THUMBPEMAGIC:
2202
      arch = bfd_arch_arm;
2203
      machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION);
2204
      if (machine == bfd_mach_arm_unknown)
2205
  {
2206
    switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK)
2207
      {
2208
      case F_ARM_2:  machine = bfd_mach_arm_2;  break;
2209
      case F_ARM_2a: machine = bfd_mach_arm_2a; break;
2210
      case F_ARM_3:  machine = bfd_mach_arm_3;  break;
2211
      default:
2212
      case F_ARM_3M: machine = bfd_mach_arm_3M; break;
2213
      case F_ARM_4:  machine = bfd_mach_arm_4;  break;
2214
      case F_ARM_4T: machine = bfd_mach_arm_4T; break;
2215
        /* The COFF header does not have enough bits available
2216
     to cover all the different ARM architectures.  So
2217
     we interpret F_ARM_5, the highest flag value to mean
2218
     "the highest ARM architecture known to BFD" which is
2219
     currently the XScale.  */
2220
      case F_ARM_5:  machine = bfd_mach_arm_XScale;  break;
2221
      }
2222
  }
2223
      break;
2224
#endif
2225
#ifdef AARCH64MAGIC
2226
    case AARCH64MAGIC:
2227
      arch = bfd_arch_aarch64;
2228
      machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK;
2229
      break;
2230
#endif
2231
#ifdef LOONGARCH64MAGIC
2232
    case LOONGARCH64MAGIC:
2233
      arch = bfd_arch_loongarch;
2234
      machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK;
2235
      break;
2236
#endif
2237
#ifdef Z80MAGIC
2238
    case Z80MAGIC:
2239
      arch = bfd_arch_z80;
2240
      switch (internal_f->f_flags & F_MACHMASK)
2241
  {
2242
  case bfd_mach_z80strict << 12:
2243
  case bfd_mach_z80 << 12:
2244
  case bfd_mach_z80n << 12:
2245
  case bfd_mach_z80full << 12:
2246
  case bfd_mach_r800 << 12:
2247
  case bfd_mach_gbz80 << 12:
2248
  case bfd_mach_z180 << 12:
2249
  case bfd_mach_ez80_z80 << 12:
2250
  case bfd_mach_ez80_adl << 12:
2251
    machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12;
2252
    break;
2253
  default:
2254
    return false;
2255
  }
2256
      break;
2257
#endif
2258
#ifdef Z8KMAGIC
2259
    case Z8KMAGIC:
2260
      arch = bfd_arch_z8k;
2261
      switch (internal_f->f_flags & F_MACHMASK)
2262
  {
2263
  case F_Z8001:
2264
    machine = bfd_mach_z8001;
2265
    break;
2266
  case F_Z8002:
2267
    machine = bfd_mach_z8002;
2268
    break;
2269
  default:
2270
    return false;
2271
  }
2272
      break;
2273
#endif
2274
2275
#ifdef RS6000COFF_C
2276
#ifdef XCOFF64
2277
    case U64_TOCMAGIC:
2278
    case U803XTOCMAGIC:
2279
#else
2280
    case U802ROMAGIC:
2281
    case U802WRMAGIC:
2282
    case U802TOCMAGIC:
2283
#endif
2284
      {
2285
  int cputype;
2286
2287
  if (xcoff_data (abfd)->cputype != -1)
2288
    cputype = xcoff_data (abfd)->cputype & 0xff;
2289
  else
2290
    {
2291
      /* We did not get a value from the a.out header.  If the
2292
         file has not been stripped, we may be able to get the
2293
         architecture information from the first symbol, if it
2294
         is a .file symbol.  */
2295
      if (obj_raw_syment_count (abfd) == 0)
2296
        cputype = 0;
2297
      else
2298
        {
2299
    bfd_byte *buf;
2300
    struct internal_syment sym;
2301
    bfd_size_type amt = bfd_coff_symesz (abfd);
2302
2303
    if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
2304
      return false;
2305
    buf = _bfd_malloc_and_read (abfd, amt, amt);
2306
    if (buf == NULL)
2307
      return false;
2308
    bfd_coff_swap_sym_in (abfd, buf, & sym);
2309
    if (sym.n_sclass == C_FILE)
2310
      cputype = sym.n_type & 0xff;
2311
    else
2312
      cputype = 0;
2313
    free (buf);
2314
        }
2315
    }
2316
2317
  /* FIXME: We don't handle all cases here.  */
2318
  switch (cputype)
2319
    {
2320
    default:
2321
    case 0:
2322
      arch = bfd_xcoff_architecture (abfd);
2323
      machine = bfd_xcoff_machine (abfd);
2324
      break;
2325
2326
    case 1:
2327
      arch = bfd_arch_powerpc;
2328
      machine = bfd_mach_ppc_601;
2329
      break;
2330
    case 2: /* 64 bit PowerPC */
2331
      arch = bfd_arch_powerpc;
2332
      machine = bfd_mach_ppc_620;
2333
      break;
2334
    case 3:
2335
      arch = bfd_arch_powerpc;
2336
      machine = bfd_mach_ppc;
2337
      break;
2338
    case 4:
2339
      arch = bfd_arch_rs6000;
2340
      machine = bfd_mach_rs6k;
2341
      break;
2342
    }
2343
      }
2344
      break;
2345
#endif
2346
2347
#ifdef SH_ARCH_MAGIC_BIG
2348
    case SH_ARCH_MAGIC_BIG:
2349
    case SH_ARCH_MAGIC_LITTLE:
2350
#ifdef COFF_WITH_PE
2351
    case SH_ARCH_MAGIC_WINCE:
2352
#endif
2353
      arch = bfd_arch_sh;
2354
      break;
2355
#endif
2356
2357
#ifdef MIPS_ARCH_MAGIC_WINCE
2358
    case MIPS_ARCH_MAGIC_WINCE:
2359
      arch = bfd_arch_mips;
2360
      break;
2361
#endif
2362
2363
#ifdef SPARCMAGIC
2364
    case SPARCMAGIC:
2365
#ifdef LYNXCOFFMAGIC
2366
    case LYNXCOFFMAGIC:
2367
#endif
2368
      arch = bfd_arch_sparc;
2369
      break;
2370
#endif
2371
2372
0
#ifdef TIC30MAGIC
2373
4.46k
    case TIC30MAGIC:
2374
4.46k
      arch = bfd_arch_tic30;
2375
4.46k
      break;
2376
0
#endif
2377
2378
#ifdef TICOFF0MAGIC
2379
#ifdef TICOFF_TARGET_ARCH
2380
      /* This TI COFF section should be used by all new TI COFF v0 targets.  */
2381
    case TICOFF0MAGIC:
2382
      arch = TICOFF_TARGET_ARCH;
2383
      machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2384
      break;
2385
#endif
2386
#endif
2387
2388
#ifdef TICOFF1MAGIC
2389
      /* This TI COFF section should be used by all new TI COFF v1/2 targets.  */
2390
      /* TI COFF1 and COFF2 use the target_id field to specify which arch.  */
2391
    case TICOFF1MAGIC:
2392
    case TICOFF2MAGIC:
2393
      switch (internal_f->f_target_id)
2394
  {
2395
#ifdef TI_TARGET_ID
2396
  case TI_TARGET_ID:
2397
    arch = TICOFF_TARGET_ARCH;
2398
    machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2399
    break;
2400
#endif
2401
  default:
2402
    arch = bfd_arch_obscure;
2403
    _bfd_error_handler
2404
      (_("unrecognized TI COFF target id '0x%x'"),
2405
       internal_f->f_target_id);
2406
    break;
2407
  }
2408
      break;
2409
#endif
2410
2411
#ifdef MCOREMAGIC
2412
    case MCOREMAGIC:
2413
      arch = bfd_arch_mcore;
2414
      break;
2415
#endif
2416
2417
0
    default:      /* Unreadable input file type.  */
2418
0
      arch = bfd_arch_obscure;
2419
0
      break;
2420
4.46k
    }
2421
2422
4.46k
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
4.46k
  return true;
2424
4.46k
}
Unexecuted instantiation: coff-tic4x.c:coff_set_arch_mach_hook
coff-tic54x.c:coff_set_arch_mach_hook
Line
Count
Source
2162
10.7k
{
2163
10.7k
  unsigned long machine;
2164
10.7k
  enum bfd_architecture arch;
2165
10.7k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
10.7k
  machine = 0;
2169
10.7k
  switch (internal_f->f_magic)
2170
10.7k
    {
2171
#ifdef I386MAGIC
2172
    case I386MAGIC:
2173
    case I386PTXMAGIC:
2174
    case I386AIXMAGIC:    /* Danbury PS/2 AIX C Compiler.  */
2175
    case LYNXCOFFMAGIC:
2176
    case I386_APPLE_MAGIC:
2177
    case I386_FREEBSD_MAGIC:
2178
    case I386_LINUX_MAGIC:
2179
    case I386_NETBSD_MAGIC:
2180
      arch = bfd_arch_i386;
2181
      break;
2182
#endif
2183
#ifdef AMD64MAGIC
2184
    case AMD64MAGIC:
2185
    case AMD64_APPLE_MAGIC:
2186
    case AMD64_FREEBSD_MAGIC:
2187
    case AMD64_LINUX_MAGIC:
2188
    case AMD64_NETBSD_MAGIC:
2189
      arch = bfd_arch_i386;
2190
      machine = bfd_mach_x86_64;
2191
      break;
2192
#endif
2193
#ifdef IA64MAGIC
2194
    case IA64MAGIC:
2195
      arch = bfd_arch_ia64;
2196
      break;
2197
#endif
2198
#ifdef ARMMAGIC
2199
    case ARMMAGIC:
2200
    case ARMPEMAGIC:
2201
    case THUMBPEMAGIC:
2202
      arch = bfd_arch_arm;
2203
      machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION);
2204
      if (machine == bfd_mach_arm_unknown)
2205
  {
2206
    switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK)
2207
      {
2208
      case F_ARM_2:  machine = bfd_mach_arm_2;  break;
2209
      case F_ARM_2a: machine = bfd_mach_arm_2a; break;
2210
      case F_ARM_3:  machine = bfd_mach_arm_3;  break;
2211
      default:
2212
      case F_ARM_3M: machine = bfd_mach_arm_3M; break;
2213
      case F_ARM_4:  machine = bfd_mach_arm_4;  break;
2214
      case F_ARM_4T: machine = bfd_mach_arm_4T; break;
2215
        /* The COFF header does not have enough bits available
2216
     to cover all the different ARM architectures.  So
2217
     we interpret F_ARM_5, the highest flag value to mean
2218
     "the highest ARM architecture known to BFD" which is
2219
     currently the XScale.  */
2220
      case F_ARM_5:  machine = bfd_mach_arm_XScale;  break;
2221
      }
2222
  }
2223
      break;
2224
#endif
2225
#ifdef AARCH64MAGIC
2226
    case AARCH64MAGIC:
2227
      arch = bfd_arch_aarch64;
2228
      machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK;
2229
      break;
2230
#endif
2231
#ifdef LOONGARCH64MAGIC
2232
    case LOONGARCH64MAGIC:
2233
      arch = bfd_arch_loongarch;
2234
      machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK;
2235
      break;
2236
#endif
2237
#ifdef Z80MAGIC
2238
    case Z80MAGIC:
2239
      arch = bfd_arch_z80;
2240
      switch (internal_f->f_flags & F_MACHMASK)
2241
  {
2242
  case bfd_mach_z80strict << 12:
2243
  case bfd_mach_z80 << 12:
2244
  case bfd_mach_z80n << 12:
2245
  case bfd_mach_z80full << 12:
2246
  case bfd_mach_r800 << 12:
2247
  case bfd_mach_gbz80 << 12:
2248
  case bfd_mach_z180 << 12:
2249
  case bfd_mach_ez80_z80 << 12:
2250
  case bfd_mach_ez80_adl << 12:
2251
    machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12;
2252
    break;
2253
  default:
2254
    return false;
2255
  }
2256
      break;
2257
#endif
2258
#ifdef Z8KMAGIC
2259
    case Z8KMAGIC:
2260
      arch = bfd_arch_z8k;
2261
      switch (internal_f->f_flags & F_MACHMASK)
2262
  {
2263
  case F_Z8001:
2264
    machine = bfd_mach_z8001;
2265
    break;
2266
  case F_Z8002:
2267
    machine = bfd_mach_z8002;
2268
    break;
2269
  default:
2270
    return false;
2271
  }
2272
      break;
2273
#endif
2274
2275
#ifdef RS6000COFF_C
2276
#ifdef XCOFF64
2277
    case U64_TOCMAGIC:
2278
    case U803XTOCMAGIC:
2279
#else
2280
    case U802ROMAGIC:
2281
    case U802WRMAGIC:
2282
    case U802TOCMAGIC:
2283
#endif
2284
      {
2285
  int cputype;
2286
2287
  if (xcoff_data (abfd)->cputype != -1)
2288
    cputype = xcoff_data (abfd)->cputype & 0xff;
2289
  else
2290
    {
2291
      /* We did not get a value from the a.out header.  If the
2292
         file has not been stripped, we may be able to get the
2293
         architecture information from the first symbol, if it
2294
         is a .file symbol.  */
2295
      if (obj_raw_syment_count (abfd) == 0)
2296
        cputype = 0;
2297
      else
2298
        {
2299
    bfd_byte *buf;
2300
    struct internal_syment sym;
2301
    bfd_size_type amt = bfd_coff_symesz (abfd);
2302
2303
    if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
2304
      return false;
2305
    buf = _bfd_malloc_and_read (abfd, amt, amt);
2306
    if (buf == NULL)
2307
      return false;
2308
    bfd_coff_swap_sym_in (abfd, buf, & sym);
2309
    if (sym.n_sclass == C_FILE)
2310
      cputype = sym.n_type & 0xff;
2311
    else
2312
      cputype = 0;
2313
    free (buf);
2314
        }
2315
    }
2316
2317
  /* FIXME: We don't handle all cases here.  */
2318
  switch (cputype)
2319
    {
2320
    default:
2321
    case 0:
2322
      arch = bfd_xcoff_architecture (abfd);
2323
      machine = bfd_xcoff_machine (abfd);
2324
      break;
2325
2326
    case 1:
2327
      arch = bfd_arch_powerpc;
2328
      machine = bfd_mach_ppc_601;
2329
      break;
2330
    case 2: /* 64 bit PowerPC */
2331
      arch = bfd_arch_powerpc;
2332
      machine = bfd_mach_ppc_620;
2333
      break;
2334
    case 3:
2335
      arch = bfd_arch_powerpc;
2336
      machine = bfd_mach_ppc;
2337
      break;
2338
    case 4:
2339
      arch = bfd_arch_rs6000;
2340
      machine = bfd_mach_rs6k;
2341
      break;
2342
    }
2343
      }
2344
      break;
2345
#endif
2346
2347
#ifdef SH_ARCH_MAGIC_BIG
2348
    case SH_ARCH_MAGIC_BIG:
2349
    case SH_ARCH_MAGIC_LITTLE:
2350
#ifdef COFF_WITH_PE
2351
    case SH_ARCH_MAGIC_WINCE:
2352
#endif
2353
      arch = bfd_arch_sh;
2354
      break;
2355
#endif
2356
2357
#ifdef MIPS_ARCH_MAGIC_WINCE
2358
    case MIPS_ARCH_MAGIC_WINCE:
2359
      arch = bfd_arch_mips;
2360
      break;
2361
#endif
2362
2363
#ifdef SPARCMAGIC
2364
    case SPARCMAGIC:
2365
#ifdef LYNXCOFFMAGIC
2366
    case LYNXCOFFMAGIC:
2367
#endif
2368
      arch = bfd_arch_sparc;
2369
      break;
2370
#endif
2371
2372
#ifdef TIC30MAGIC
2373
    case TIC30MAGIC:
2374
      arch = bfd_arch_tic30;
2375
      break;
2376
#endif
2377
2378
0
#ifdef TICOFF0MAGIC
2379
0
#ifdef TICOFF_TARGET_ARCH
2380
      /* This TI COFF section should be used by all new TI COFF v0 targets.  */
2381
9.45k
    case TICOFF0MAGIC:
2382
9.45k
      arch = TICOFF_TARGET_ARCH;
2383
9.45k
      machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2384
9.45k
      break;
2385
0
#endif
2386
0
#endif
2387
2388
0
#ifdef TICOFF1MAGIC
2389
      /* This TI COFF section should be used by all new TI COFF v1/2 targets.  */
2390
      /* TI COFF1 and COFF2 use the target_id field to specify which arch.  */
2391
1.34k
    case TICOFF1MAGIC:
2392
1.34k
    case TICOFF2MAGIC:
2393
1.34k
      switch (internal_f->f_target_id)
2394
1.34k
  {
2395
0
#ifdef TI_TARGET_ID
2396
1.34k
  case TI_TARGET_ID:
2397
1.34k
    arch = TICOFF_TARGET_ARCH;
2398
1.34k
    machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2399
1.34k
    break;
2400
0
#endif
2401
0
  default:
2402
0
    arch = bfd_arch_obscure;
2403
0
    _bfd_error_handler
2404
0
      (_("unrecognized TI COFF target id '0x%x'"),
2405
0
       internal_f->f_target_id);
2406
0
    break;
2407
1.34k
  }
2408
1.34k
      break;
2409
1.34k
#endif
2410
2411
#ifdef MCOREMAGIC
2412
    case MCOREMAGIC:
2413
      arch = bfd_arch_mcore;
2414
      break;
2415
#endif
2416
2417
1.34k
    default:      /* Unreadable input file type.  */
2418
0
      arch = bfd_arch_obscure;
2419
0
      break;
2420
10.7k
    }
2421
2422
10.7k
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
10.7k
  return true;
2424
10.7k
}
coff-z80.c:coff_set_arch_mach_hook
Line
Count
Source
2162
3.13k
{
2163
3.13k
  unsigned long machine;
2164
3.13k
  enum bfd_architecture arch;
2165
3.13k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
3.13k
  machine = 0;
2169
3.13k
  switch (internal_f->f_magic)
2170
3.13k
    {
2171
#ifdef I386MAGIC
2172
    case I386MAGIC:
2173
    case I386PTXMAGIC:
2174
    case I386AIXMAGIC:    /* Danbury PS/2 AIX C Compiler.  */
2175
    case LYNXCOFFMAGIC:
2176
    case I386_APPLE_MAGIC:
2177
    case I386_FREEBSD_MAGIC:
2178
    case I386_LINUX_MAGIC:
2179
    case I386_NETBSD_MAGIC:
2180
      arch = bfd_arch_i386;
2181
      break;
2182
#endif
2183
#ifdef AMD64MAGIC
2184
    case AMD64MAGIC:
2185
    case AMD64_APPLE_MAGIC:
2186
    case AMD64_FREEBSD_MAGIC:
2187
    case AMD64_LINUX_MAGIC:
2188
    case AMD64_NETBSD_MAGIC:
2189
      arch = bfd_arch_i386;
2190
      machine = bfd_mach_x86_64;
2191
      break;
2192
#endif
2193
#ifdef IA64MAGIC
2194
    case IA64MAGIC:
2195
      arch = bfd_arch_ia64;
2196
      break;
2197
#endif
2198
#ifdef ARMMAGIC
2199
    case ARMMAGIC:
2200
    case ARMPEMAGIC:
2201
    case THUMBPEMAGIC:
2202
      arch = bfd_arch_arm;
2203
      machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION);
2204
      if (machine == bfd_mach_arm_unknown)
2205
  {
2206
    switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK)
2207
      {
2208
      case F_ARM_2:  machine = bfd_mach_arm_2;  break;
2209
      case F_ARM_2a: machine = bfd_mach_arm_2a; break;
2210
      case F_ARM_3:  machine = bfd_mach_arm_3;  break;
2211
      default:
2212
      case F_ARM_3M: machine = bfd_mach_arm_3M; break;
2213
      case F_ARM_4:  machine = bfd_mach_arm_4;  break;
2214
      case F_ARM_4T: machine = bfd_mach_arm_4T; break;
2215
        /* The COFF header does not have enough bits available
2216
     to cover all the different ARM architectures.  So
2217
     we interpret F_ARM_5, the highest flag value to mean
2218
     "the highest ARM architecture known to BFD" which is
2219
     currently the XScale.  */
2220
      case F_ARM_5:  machine = bfd_mach_arm_XScale;  break;
2221
      }
2222
  }
2223
      break;
2224
#endif
2225
#ifdef AARCH64MAGIC
2226
    case AARCH64MAGIC:
2227
      arch = bfd_arch_aarch64;
2228
      machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK;
2229
      break;
2230
#endif
2231
#ifdef LOONGARCH64MAGIC
2232
    case LOONGARCH64MAGIC:
2233
      arch = bfd_arch_loongarch;
2234
      machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK;
2235
      break;
2236
#endif
2237
0
#ifdef Z80MAGIC
2238
3.13k
    case Z80MAGIC:
2239
3.13k
      arch = bfd_arch_z80;
2240
3.13k
      switch (internal_f->f_flags & F_MACHMASK)
2241
3.13k
  {
2242
172
  case bfd_mach_z80strict << 12:
2243
662
  case bfd_mach_z80 << 12:
2244
707
  case bfd_mach_z80n << 12:
2245
1.74k
  case bfd_mach_z80full << 12:
2246
2.01k
  case bfd_mach_r800 << 12:
2247
2.61k
  case bfd_mach_gbz80 << 12:
2248
2.77k
  case bfd_mach_z180 << 12:
2249
2.93k
  case bfd_mach_ez80_z80 << 12:
2250
3.03k
  case bfd_mach_ez80_adl << 12:
2251
3.03k
    machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12;
2252
3.03k
    break;
2253
102
  default:
2254
102
    return false;
2255
3.13k
  }
2256
3.03k
      break;
2257
3.03k
#endif
2258
#ifdef Z8KMAGIC
2259
    case Z8KMAGIC:
2260
      arch = bfd_arch_z8k;
2261
      switch (internal_f->f_flags & F_MACHMASK)
2262
  {
2263
  case F_Z8001:
2264
    machine = bfd_mach_z8001;
2265
    break;
2266
  case F_Z8002:
2267
    machine = bfd_mach_z8002;
2268
    break;
2269
  default:
2270
    return false;
2271
  }
2272
      break;
2273
#endif
2274
2275
#ifdef RS6000COFF_C
2276
#ifdef XCOFF64
2277
    case U64_TOCMAGIC:
2278
    case U803XTOCMAGIC:
2279
#else
2280
    case U802ROMAGIC:
2281
    case U802WRMAGIC:
2282
    case U802TOCMAGIC:
2283
#endif
2284
      {
2285
  int cputype;
2286
2287
  if (xcoff_data (abfd)->cputype != -1)
2288
    cputype = xcoff_data (abfd)->cputype & 0xff;
2289
  else
2290
    {
2291
      /* We did not get a value from the a.out header.  If the
2292
         file has not been stripped, we may be able to get the
2293
         architecture information from the first symbol, if it
2294
         is a .file symbol.  */
2295
      if (obj_raw_syment_count (abfd) == 0)
2296
        cputype = 0;
2297
      else
2298
        {
2299
    bfd_byte *buf;
2300
    struct internal_syment sym;
2301
    bfd_size_type amt = bfd_coff_symesz (abfd);
2302
2303
    if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
2304
      return false;
2305
    buf = _bfd_malloc_and_read (abfd, amt, amt);
2306
    if (buf == NULL)
2307
      return false;
2308
    bfd_coff_swap_sym_in (abfd, buf, & sym);
2309
    if (sym.n_sclass == C_FILE)
2310
      cputype = sym.n_type & 0xff;
2311
    else
2312
      cputype = 0;
2313
    free (buf);
2314
        }
2315
    }
2316
2317
  /* FIXME: We don't handle all cases here.  */
2318
  switch (cputype)
2319
    {
2320
    default:
2321
    case 0:
2322
      arch = bfd_xcoff_architecture (abfd);
2323
      machine = bfd_xcoff_machine (abfd);
2324
      break;
2325
2326
    case 1:
2327
      arch = bfd_arch_powerpc;
2328
      machine = bfd_mach_ppc_601;
2329
      break;
2330
    case 2: /* 64 bit PowerPC */
2331
      arch = bfd_arch_powerpc;
2332
      machine = bfd_mach_ppc_620;
2333
      break;
2334
    case 3:
2335
      arch = bfd_arch_powerpc;
2336
      machine = bfd_mach_ppc;
2337
      break;
2338
    case 4:
2339
      arch = bfd_arch_rs6000;
2340
      machine = bfd_mach_rs6k;
2341
      break;
2342
    }
2343
      }
2344
      break;
2345
#endif
2346
2347
#ifdef SH_ARCH_MAGIC_BIG
2348
    case SH_ARCH_MAGIC_BIG:
2349
    case SH_ARCH_MAGIC_LITTLE:
2350
#ifdef COFF_WITH_PE
2351
    case SH_ARCH_MAGIC_WINCE:
2352
#endif
2353
      arch = bfd_arch_sh;
2354
      break;
2355
#endif
2356
2357
#ifdef MIPS_ARCH_MAGIC_WINCE
2358
    case MIPS_ARCH_MAGIC_WINCE:
2359
      arch = bfd_arch_mips;
2360
      break;
2361
#endif
2362
2363
#ifdef SPARCMAGIC
2364
    case SPARCMAGIC:
2365
#ifdef LYNXCOFFMAGIC
2366
    case LYNXCOFFMAGIC:
2367
#endif
2368
      arch = bfd_arch_sparc;
2369
      break;
2370
#endif
2371
2372
#ifdef TIC30MAGIC
2373
    case TIC30MAGIC:
2374
      arch = bfd_arch_tic30;
2375
      break;
2376
#endif
2377
2378
#ifdef TICOFF0MAGIC
2379
#ifdef TICOFF_TARGET_ARCH
2380
      /* This TI COFF section should be used by all new TI COFF v0 targets.  */
2381
    case TICOFF0MAGIC:
2382
      arch = TICOFF_TARGET_ARCH;
2383
      machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2384
      break;
2385
#endif
2386
#endif
2387
2388
#ifdef TICOFF1MAGIC
2389
      /* This TI COFF section should be used by all new TI COFF v1/2 targets.  */
2390
      /* TI COFF1 and COFF2 use the target_id field to specify which arch.  */
2391
    case TICOFF1MAGIC:
2392
    case TICOFF2MAGIC:
2393
      switch (internal_f->f_target_id)
2394
  {
2395
#ifdef TI_TARGET_ID
2396
  case TI_TARGET_ID:
2397
    arch = TICOFF_TARGET_ARCH;
2398
    machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2399
    break;
2400
#endif
2401
  default:
2402
    arch = bfd_arch_obscure;
2403
    _bfd_error_handler
2404
      (_("unrecognized TI COFF target id '0x%x'"),
2405
       internal_f->f_target_id);
2406
    break;
2407
  }
2408
      break;
2409
#endif
2410
2411
#ifdef MCOREMAGIC
2412
    case MCOREMAGIC:
2413
      arch = bfd_arch_mcore;
2414
      break;
2415
#endif
2416
2417
3.03k
    default:      /* Unreadable input file type.  */
2418
0
      arch = bfd_arch_obscure;
2419
0
      break;
2420
3.13k
    }
2421
2422
3.03k
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
3.03k
  return true;
2424
3.13k
}
coff-z8k.c:coff_set_arch_mach_hook
Line
Count
Source
2162
4.35k
{
2163
4.35k
  unsigned long machine;
2164
4.35k
  enum bfd_architecture arch;
2165
4.35k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
4.35k
  machine = 0;
2169
4.35k
  switch (internal_f->f_magic)
2170
4.35k
    {
2171
#ifdef I386MAGIC
2172
    case I386MAGIC:
2173
    case I386PTXMAGIC:
2174
    case I386AIXMAGIC:    /* Danbury PS/2 AIX C Compiler.  */
2175
    case LYNXCOFFMAGIC:
2176
    case I386_APPLE_MAGIC:
2177
    case I386_FREEBSD_MAGIC:
2178
    case I386_LINUX_MAGIC:
2179
    case I386_NETBSD_MAGIC:
2180
      arch = bfd_arch_i386;
2181
      break;
2182
#endif
2183
#ifdef AMD64MAGIC
2184
    case AMD64MAGIC:
2185
    case AMD64_APPLE_MAGIC:
2186
    case AMD64_FREEBSD_MAGIC:
2187
    case AMD64_LINUX_MAGIC:
2188
    case AMD64_NETBSD_MAGIC:
2189
      arch = bfd_arch_i386;
2190
      machine = bfd_mach_x86_64;
2191
      break;
2192
#endif
2193
#ifdef IA64MAGIC
2194
    case IA64MAGIC:
2195
      arch = bfd_arch_ia64;
2196
      break;
2197
#endif
2198
#ifdef ARMMAGIC
2199
    case ARMMAGIC:
2200
    case ARMPEMAGIC:
2201
    case THUMBPEMAGIC:
2202
      arch = bfd_arch_arm;
2203
      machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION);
2204
      if (machine == bfd_mach_arm_unknown)
2205
  {
2206
    switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK)
2207
      {
2208
      case F_ARM_2:  machine = bfd_mach_arm_2;  break;
2209
      case F_ARM_2a: machine = bfd_mach_arm_2a; break;
2210
      case F_ARM_3:  machine = bfd_mach_arm_3;  break;
2211
      default:
2212
      case F_ARM_3M: machine = bfd_mach_arm_3M; break;
2213
      case F_ARM_4:  machine = bfd_mach_arm_4;  break;
2214
      case F_ARM_4T: machine = bfd_mach_arm_4T; break;
2215
        /* The COFF header does not have enough bits available
2216
     to cover all the different ARM architectures.  So
2217
     we interpret F_ARM_5, the highest flag value to mean
2218
     "the highest ARM architecture known to BFD" which is
2219
     currently the XScale.  */
2220
      case F_ARM_5:  machine = bfd_mach_arm_XScale;  break;
2221
      }
2222
  }
2223
      break;
2224
#endif
2225
#ifdef AARCH64MAGIC
2226
    case AARCH64MAGIC:
2227
      arch = bfd_arch_aarch64;
2228
      machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK;
2229
      break;
2230
#endif
2231
#ifdef LOONGARCH64MAGIC
2232
    case LOONGARCH64MAGIC:
2233
      arch = bfd_arch_loongarch;
2234
      machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK;
2235
      break;
2236
#endif
2237
#ifdef Z80MAGIC
2238
    case Z80MAGIC:
2239
      arch = bfd_arch_z80;
2240
      switch (internal_f->f_flags & F_MACHMASK)
2241
  {
2242
  case bfd_mach_z80strict << 12:
2243
  case bfd_mach_z80 << 12:
2244
  case bfd_mach_z80n << 12:
2245
  case bfd_mach_z80full << 12:
2246
  case bfd_mach_r800 << 12:
2247
  case bfd_mach_gbz80 << 12:
2248
  case bfd_mach_z180 << 12:
2249
  case bfd_mach_ez80_z80 << 12:
2250
  case bfd_mach_ez80_adl << 12:
2251
    machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12;
2252
    break;
2253
  default:
2254
    return false;
2255
  }
2256
      break;
2257
#endif
2258
0
#ifdef Z8KMAGIC
2259
4.35k
    case Z8KMAGIC:
2260
4.35k
      arch = bfd_arch_z8k;
2261
4.35k
      switch (internal_f->f_flags & F_MACHMASK)
2262
4.35k
  {
2263
1.08k
  case F_Z8001:
2264
1.08k
    machine = bfd_mach_z8001;
2265
1.08k
    break;
2266
3.16k
  case F_Z8002:
2267
3.16k
    machine = bfd_mach_z8002;
2268
3.16k
    break;
2269
105
  default:
2270
105
    return false;
2271
4.35k
  }
2272
4.24k
      break;
2273
4.24k
#endif
2274
2275
#ifdef RS6000COFF_C
2276
#ifdef XCOFF64
2277
    case U64_TOCMAGIC:
2278
    case U803XTOCMAGIC:
2279
#else
2280
    case U802ROMAGIC:
2281
    case U802WRMAGIC:
2282
    case U802TOCMAGIC:
2283
#endif
2284
      {
2285
  int cputype;
2286
2287
  if (xcoff_data (abfd)->cputype != -1)
2288
    cputype = xcoff_data (abfd)->cputype & 0xff;
2289
  else
2290
    {
2291
      /* We did not get a value from the a.out header.  If the
2292
         file has not been stripped, we may be able to get the
2293
         architecture information from the first symbol, if it
2294
         is a .file symbol.  */
2295
      if (obj_raw_syment_count (abfd) == 0)
2296
        cputype = 0;
2297
      else
2298
        {
2299
    bfd_byte *buf;
2300
    struct internal_syment sym;
2301
    bfd_size_type amt = bfd_coff_symesz (abfd);
2302
2303
    if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
2304
      return false;
2305
    buf = _bfd_malloc_and_read (abfd, amt, amt);
2306
    if (buf == NULL)
2307
      return false;
2308
    bfd_coff_swap_sym_in (abfd, buf, & sym);
2309
    if (sym.n_sclass == C_FILE)
2310
      cputype = sym.n_type & 0xff;
2311
    else
2312
      cputype = 0;
2313
    free (buf);
2314
        }
2315
    }
2316
2317
  /* FIXME: We don't handle all cases here.  */
2318
  switch (cputype)
2319
    {
2320
    default:
2321
    case 0:
2322
      arch = bfd_xcoff_architecture (abfd);
2323
      machine = bfd_xcoff_machine (abfd);
2324
      break;
2325
2326
    case 1:
2327
      arch = bfd_arch_powerpc;
2328
      machine = bfd_mach_ppc_601;
2329
      break;
2330
    case 2: /* 64 bit PowerPC */
2331
      arch = bfd_arch_powerpc;
2332
      machine = bfd_mach_ppc_620;
2333
      break;
2334
    case 3:
2335
      arch = bfd_arch_powerpc;
2336
      machine = bfd_mach_ppc;
2337
      break;
2338
    case 4:
2339
      arch = bfd_arch_rs6000;
2340
      machine = bfd_mach_rs6k;
2341
      break;
2342
    }
2343
      }
2344
      break;
2345
#endif
2346
2347
#ifdef SH_ARCH_MAGIC_BIG
2348
    case SH_ARCH_MAGIC_BIG:
2349
    case SH_ARCH_MAGIC_LITTLE:
2350
#ifdef COFF_WITH_PE
2351
    case SH_ARCH_MAGIC_WINCE:
2352
#endif
2353
      arch = bfd_arch_sh;
2354
      break;
2355
#endif
2356
2357
#ifdef MIPS_ARCH_MAGIC_WINCE
2358
    case MIPS_ARCH_MAGIC_WINCE:
2359
      arch = bfd_arch_mips;
2360
      break;
2361
#endif
2362
2363
#ifdef SPARCMAGIC
2364
    case SPARCMAGIC:
2365
#ifdef LYNXCOFFMAGIC
2366
    case LYNXCOFFMAGIC:
2367
#endif
2368
      arch = bfd_arch_sparc;
2369
      break;
2370
#endif
2371
2372
#ifdef TIC30MAGIC
2373
    case TIC30MAGIC:
2374
      arch = bfd_arch_tic30;
2375
      break;
2376
#endif
2377
2378
#ifdef TICOFF0MAGIC
2379
#ifdef TICOFF_TARGET_ARCH
2380
      /* This TI COFF section should be used by all new TI COFF v0 targets.  */
2381
    case TICOFF0MAGIC:
2382
      arch = TICOFF_TARGET_ARCH;
2383
      machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2384
      break;
2385
#endif
2386
#endif
2387
2388
#ifdef TICOFF1MAGIC
2389
      /* This TI COFF section should be used by all new TI COFF v1/2 targets.  */
2390
      /* TI COFF1 and COFF2 use the target_id field to specify which arch.  */
2391
    case TICOFF1MAGIC:
2392
    case TICOFF2MAGIC:
2393
      switch (internal_f->f_target_id)
2394
  {
2395
#ifdef TI_TARGET_ID
2396
  case TI_TARGET_ID:
2397
    arch = TICOFF_TARGET_ARCH;
2398
    machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2399
    break;
2400
#endif
2401
  default:
2402
    arch = bfd_arch_obscure;
2403
    _bfd_error_handler
2404
      (_("unrecognized TI COFF target id '0x%x'"),
2405
       internal_f->f_target_id);
2406
    break;
2407
  }
2408
      break;
2409
#endif
2410
2411
#ifdef MCOREMAGIC
2412
    case MCOREMAGIC:
2413
      arch = bfd_arch_mcore;
2414
      break;
2415
#endif
2416
2417
4.24k
    default:      /* Unreadable input file type.  */
2418
0
      arch = bfd_arch_obscure;
2419
0
      break;
2420
4.35k
    }
2421
2422
4.24k
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
4.24k
  return true;
2424
4.35k
}
pe-arm-wince.c:coff_set_arch_mach_hook
Line
Count
Source
2162
2.65k
{
2163
2.65k
  unsigned long machine;
2164
2.65k
  enum bfd_architecture arch;
2165
2.65k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
2.65k
  machine = 0;
2169
2.65k
  switch (internal_f->f_magic)
2170
2.65k
    {
2171
#ifdef I386MAGIC
2172
    case I386MAGIC:
2173
    case I386PTXMAGIC:
2174
    case I386AIXMAGIC:    /* Danbury PS/2 AIX C Compiler.  */
2175
    case LYNXCOFFMAGIC:
2176
    case I386_APPLE_MAGIC:
2177
    case I386_FREEBSD_MAGIC:
2178
    case I386_LINUX_MAGIC:
2179
    case I386_NETBSD_MAGIC:
2180
      arch = bfd_arch_i386;
2181
      break;
2182
#endif
2183
#ifdef AMD64MAGIC
2184
    case AMD64MAGIC:
2185
    case AMD64_APPLE_MAGIC:
2186
    case AMD64_FREEBSD_MAGIC:
2187
    case AMD64_LINUX_MAGIC:
2188
    case AMD64_NETBSD_MAGIC:
2189
      arch = bfd_arch_i386;
2190
      machine = bfd_mach_x86_64;
2191
      break;
2192
#endif
2193
#ifdef IA64MAGIC
2194
    case IA64MAGIC:
2195
      arch = bfd_arch_ia64;
2196
      break;
2197
#endif
2198
0
#ifdef ARMMAGIC
2199
1.89k
    case ARMMAGIC:
2200
2.02k
    case ARMPEMAGIC:
2201
2.13k
    case THUMBPEMAGIC:
2202
2.13k
      arch = bfd_arch_arm;
2203
2.13k
      machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION);
2204
2.13k
      if (machine == bfd_mach_arm_unknown)
2205
2.13k
  {
2206
2.13k
    switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK)
2207
2.13k
      {
2208
118
      case F_ARM_2:  machine = bfd_mach_arm_2;  break;
2209
12
      case F_ARM_2a: machine = bfd_mach_arm_2a; break;
2210
11
      case F_ARM_3:  machine = bfd_mach_arm_3;  break;
2211
1.85k
      default:
2212
1.86k
      case F_ARM_3M: machine = bfd_mach_arm_3M; break;
2213
8
      case F_ARM_4:  machine = bfd_mach_arm_4;  break;
2214
110
      case F_ARM_4T: machine = bfd_mach_arm_4T; break;
2215
        /* The COFF header does not have enough bits available
2216
     to cover all the different ARM architectures.  So
2217
     we interpret F_ARM_5, the highest flag value to mean
2218
     "the highest ARM architecture known to BFD" which is
2219
     currently the XScale.  */
2220
10
      case F_ARM_5:  machine = bfd_mach_arm_XScale;  break;
2221
2.13k
      }
2222
2.13k
  }
2223
2.13k
      break;
2224
2.13k
#endif
2225
#ifdef AARCH64MAGIC
2226
    case AARCH64MAGIC:
2227
      arch = bfd_arch_aarch64;
2228
      machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK;
2229
      break;
2230
#endif
2231
#ifdef LOONGARCH64MAGIC
2232
    case LOONGARCH64MAGIC:
2233
      arch = bfd_arch_loongarch;
2234
      machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK;
2235
      break;
2236
#endif
2237
#ifdef Z80MAGIC
2238
    case Z80MAGIC:
2239
      arch = bfd_arch_z80;
2240
      switch (internal_f->f_flags & F_MACHMASK)
2241
  {
2242
  case bfd_mach_z80strict << 12:
2243
  case bfd_mach_z80 << 12:
2244
  case bfd_mach_z80n << 12:
2245
  case bfd_mach_z80full << 12:
2246
  case bfd_mach_r800 << 12:
2247
  case bfd_mach_gbz80 << 12:
2248
  case bfd_mach_z180 << 12:
2249
  case bfd_mach_ez80_z80 << 12:
2250
  case bfd_mach_ez80_adl << 12:
2251
    machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12;
2252
    break;
2253
  default:
2254
    return false;
2255
  }
2256
      break;
2257
#endif
2258
#ifdef Z8KMAGIC
2259
    case Z8KMAGIC:
2260
      arch = bfd_arch_z8k;
2261
      switch (internal_f->f_flags & F_MACHMASK)
2262
  {
2263
  case F_Z8001:
2264
    machine = bfd_mach_z8001;
2265
    break;
2266
  case F_Z8002:
2267
    machine = bfd_mach_z8002;
2268
    break;
2269
  default:
2270
    return false;
2271
  }
2272
      break;
2273
#endif
2274
2275
#ifdef RS6000COFF_C
2276
#ifdef XCOFF64
2277
    case U64_TOCMAGIC:
2278
    case U803XTOCMAGIC:
2279
#else
2280
    case U802ROMAGIC:
2281
    case U802WRMAGIC:
2282
    case U802TOCMAGIC:
2283
#endif
2284
      {
2285
  int cputype;
2286
2287
  if (xcoff_data (abfd)->cputype != -1)
2288
    cputype = xcoff_data (abfd)->cputype & 0xff;
2289
  else
2290
    {
2291
      /* We did not get a value from the a.out header.  If the
2292
         file has not been stripped, we may be able to get the
2293
         architecture information from the first symbol, if it
2294
         is a .file symbol.  */
2295
      if (obj_raw_syment_count (abfd) == 0)
2296
        cputype = 0;
2297
      else
2298
        {
2299
    bfd_byte *buf;
2300
    struct internal_syment sym;
2301
    bfd_size_type amt = bfd_coff_symesz (abfd);
2302
2303
    if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
2304
      return false;
2305
    buf = _bfd_malloc_and_read (abfd, amt, amt);
2306
    if (buf == NULL)
2307
      return false;
2308
    bfd_coff_swap_sym_in (abfd, buf, & sym);
2309
    if (sym.n_sclass == C_FILE)
2310
      cputype = sym.n_type & 0xff;
2311
    else
2312
      cputype = 0;
2313
    free (buf);
2314
        }
2315
    }
2316
2317
  /* FIXME: We don't handle all cases here.  */
2318
  switch (cputype)
2319
    {
2320
    default:
2321
    case 0:
2322
      arch = bfd_xcoff_architecture (abfd);
2323
      machine = bfd_xcoff_machine (abfd);
2324
      break;
2325
2326
    case 1:
2327
      arch = bfd_arch_powerpc;
2328
      machine = bfd_mach_ppc_601;
2329
      break;
2330
    case 2: /* 64 bit PowerPC */
2331
      arch = bfd_arch_powerpc;
2332
      machine = bfd_mach_ppc_620;
2333
      break;
2334
    case 3:
2335
      arch = bfd_arch_powerpc;
2336
      machine = bfd_mach_ppc;
2337
      break;
2338
    case 4:
2339
      arch = bfd_arch_rs6000;
2340
      machine = bfd_mach_rs6k;
2341
      break;
2342
    }
2343
      }
2344
      break;
2345
#endif
2346
2347
#ifdef SH_ARCH_MAGIC_BIG
2348
    case SH_ARCH_MAGIC_BIG:
2349
    case SH_ARCH_MAGIC_LITTLE:
2350
#ifdef COFF_WITH_PE
2351
    case SH_ARCH_MAGIC_WINCE:
2352
#endif
2353
      arch = bfd_arch_sh;
2354
      break;
2355
#endif
2356
2357
#ifdef MIPS_ARCH_MAGIC_WINCE
2358
    case MIPS_ARCH_MAGIC_WINCE:
2359
      arch = bfd_arch_mips;
2360
      break;
2361
#endif
2362
2363
#ifdef SPARCMAGIC
2364
    case SPARCMAGIC:
2365
#ifdef LYNXCOFFMAGIC
2366
    case LYNXCOFFMAGIC:
2367
#endif
2368
      arch = bfd_arch_sparc;
2369
      break;
2370
#endif
2371
2372
#ifdef TIC30MAGIC
2373
    case TIC30MAGIC:
2374
      arch = bfd_arch_tic30;
2375
      break;
2376
#endif
2377
2378
#ifdef TICOFF0MAGIC
2379
#ifdef TICOFF_TARGET_ARCH
2380
      /* This TI COFF section should be used by all new TI COFF v0 targets.  */
2381
    case TICOFF0MAGIC:
2382
      arch = TICOFF_TARGET_ARCH;
2383
      machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2384
      break;
2385
#endif
2386
#endif
2387
2388
#ifdef TICOFF1MAGIC
2389
      /* This TI COFF section should be used by all new TI COFF v1/2 targets.  */
2390
      /* TI COFF1 and COFF2 use the target_id field to specify which arch.  */
2391
    case TICOFF1MAGIC:
2392
    case TICOFF2MAGIC:
2393
      switch (internal_f->f_target_id)
2394
  {
2395
#ifdef TI_TARGET_ID
2396
  case TI_TARGET_ID:
2397
    arch = TICOFF_TARGET_ARCH;
2398
    machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2399
    break;
2400
#endif
2401
  default:
2402
    arch = bfd_arch_obscure;
2403
    _bfd_error_handler
2404
      (_("unrecognized TI COFF target id '0x%x'"),
2405
       internal_f->f_target_id);
2406
    break;
2407
  }
2408
      break;
2409
#endif
2410
2411
#ifdef MCOREMAGIC
2412
    case MCOREMAGIC:
2413
      arch = bfd_arch_mcore;
2414
      break;
2415
#endif
2416
2417
2.13k
    default:      /* Unreadable input file type.  */
2418
521
      arch = bfd_arch_obscure;
2419
521
      break;
2420
2.65k
    }
2421
2422
2.65k
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
2.65k
  return true;
2424
2.65k
}
pe-arm.c:coff_set_arch_mach_hook
Line
Count
Source
2162
2.65k
{
2163
2.65k
  unsigned long machine;
2164
2.65k
  enum bfd_architecture arch;
2165
2.65k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
2.65k
  machine = 0;
2169
2.65k
  switch (internal_f->f_magic)
2170
2.65k
    {
2171
#ifdef I386MAGIC
2172
    case I386MAGIC:
2173
    case I386PTXMAGIC:
2174
    case I386AIXMAGIC:    /* Danbury PS/2 AIX C Compiler.  */
2175
    case LYNXCOFFMAGIC:
2176
    case I386_APPLE_MAGIC:
2177
    case I386_FREEBSD_MAGIC:
2178
    case I386_LINUX_MAGIC:
2179
    case I386_NETBSD_MAGIC:
2180
      arch = bfd_arch_i386;
2181
      break;
2182
#endif
2183
#ifdef AMD64MAGIC
2184
    case AMD64MAGIC:
2185
    case AMD64_APPLE_MAGIC:
2186
    case AMD64_FREEBSD_MAGIC:
2187
    case AMD64_LINUX_MAGIC:
2188
    case AMD64_NETBSD_MAGIC:
2189
      arch = bfd_arch_i386;
2190
      machine = bfd_mach_x86_64;
2191
      break;
2192
#endif
2193
#ifdef IA64MAGIC
2194
    case IA64MAGIC:
2195
      arch = bfd_arch_ia64;
2196
      break;
2197
#endif
2198
0
#ifdef ARMMAGIC
2199
1.89k
    case ARMMAGIC:
2200
2.02k
    case ARMPEMAGIC:
2201
2.13k
    case THUMBPEMAGIC:
2202
2.13k
      arch = bfd_arch_arm;
2203
2.13k
      machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION);
2204
2.13k
      if (machine == bfd_mach_arm_unknown)
2205
2.13k
  {
2206
2.13k
    switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK)
2207
2.13k
      {
2208
118
      case F_ARM_2:  machine = bfd_mach_arm_2;  break;
2209
12
      case F_ARM_2a: machine = bfd_mach_arm_2a; break;
2210
11
      case F_ARM_3:  machine = bfd_mach_arm_3;  break;
2211
1.85k
      default:
2212
1.86k
      case F_ARM_3M: machine = bfd_mach_arm_3M; break;
2213
8
      case F_ARM_4:  machine = bfd_mach_arm_4;  break;
2214
110
      case F_ARM_4T: machine = bfd_mach_arm_4T; break;
2215
        /* The COFF header does not have enough bits available
2216
     to cover all the different ARM architectures.  So
2217
     we interpret F_ARM_5, the highest flag value to mean
2218
     "the highest ARM architecture known to BFD" which is
2219
     currently the XScale.  */
2220
10
      case F_ARM_5:  machine = bfd_mach_arm_XScale;  break;
2221
2.13k
      }
2222
2.13k
  }
2223
2.13k
      break;
2224
2.13k
#endif
2225
#ifdef AARCH64MAGIC
2226
    case AARCH64MAGIC:
2227
      arch = bfd_arch_aarch64;
2228
      machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK;
2229
      break;
2230
#endif
2231
#ifdef LOONGARCH64MAGIC
2232
    case LOONGARCH64MAGIC:
2233
      arch = bfd_arch_loongarch;
2234
      machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK;
2235
      break;
2236
#endif
2237
#ifdef Z80MAGIC
2238
    case Z80MAGIC:
2239
      arch = bfd_arch_z80;
2240
      switch (internal_f->f_flags & F_MACHMASK)
2241
  {
2242
  case bfd_mach_z80strict << 12:
2243
  case bfd_mach_z80 << 12:
2244
  case bfd_mach_z80n << 12:
2245
  case bfd_mach_z80full << 12:
2246
  case bfd_mach_r800 << 12:
2247
  case bfd_mach_gbz80 << 12:
2248
  case bfd_mach_z180 << 12:
2249
  case bfd_mach_ez80_z80 << 12:
2250
  case bfd_mach_ez80_adl << 12:
2251
    machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12;
2252
    break;
2253
  default:
2254
    return false;
2255
  }
2256
      break;
2257
#endif
2258
#ifdef Z8KMAGIC
2259
    case Z8KMAGIC:
2260
      arch = bfd_arch_z8k;
2261
      switch (internal_f->f_flags & F_MACHMASK)
2262
  {
2263
  case F_Z8001:
2264
    machine = bfd_mach_z8001;
2265
    break;
2266
  case F_Z8002:
2267
    machine = bfd_mach_z8002;
2268
    break;
2269
  default:
2270
    return false;
2271
  }
2272
      break;
2273
#endif
2274
2275
#ifdef RS6000COFF_C
2276
#ifdef XCOFF64
2277
    case U64_TOCMAGIC:
2278
    case U803XTOCMAGIC:
2279
#else
2280
    case U802ROMAGIC:
2281
    case U802WRMAGIC:
2282
    case U802TOCMAGIC:
2283
#endif
2284
      {
2285
  int cputype;
2286
2287
  if (xcoff_data (abfd)->cputype != -1)
2288
    cputype = xcoff_data (abfd)->cputype & 0xff;
2289
  else
2290
    {
2291
      /* We did not get a value from the a.out header.  If the
2292
         file has not been stripped, we may be able to get the
2293
         architecture information from the first symbol, if it
2294
         is a .file symbol.  */
2295
      if (obj_raw_syment_count (abfd) == 0)
2296
        cputype = 0;
2297
      else
2298
        {
2299
    bfd_byte *buf;
2300
    struct internal_syment sym;
2301
    bfd_size_type amt = bfd_coff_symesz (abfd);
2302
2303
    if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
2304
      return false;
2305
    buf = _bfd_malloc_and_read (abfd, amt, amt);
2306
    if (buf == NULL)
2307
      return false;
2308
    bfd_coff_swap_sym_in (abfd, buf, & sym);
2309
    if (sym.n_sclass == C_FILE)
2310
      cputype = sym.n_type & 0xff;
2311
    else
2312
      cputype = 0;
2313
    free (buf);
2314
        }
2315
    }
2316
2317
  /* FIXME: We don't handle all cases here.  */
2318
  switch (cputype)
2319
    {
2320
    default:
2321
    case 0:
2322
      arch = bfd_xcoff_architecture (abfd);
2323
      machine = bfd_xcoff_machine (abfd);
2324
      break;
2325
2326
    case 1:
2327
      arch = bfd_arch_powerpc;
2328
      machine = bfd_mach_ppc_601;
2329
      break;
2330
    case 2: /* 64 bit PowerPC */
2331
      arch = bfd_arch_powerpc;
2332
      machine = bfd_mach_ppc_620;
2333
      break;
2334
    case 3:
2335
      arch = bfd_arch_powerpc;
2336
      machine = bfd_mach_ppc;
2337
      break;
2338
    case 4:
2339
      arch = bfd_arch_rs6000;
2340
      machine = bfd_mach_rs6k;
2341
      break;
2342
    }
2343
      }
2344
      break;
2345
#endif
2346
2347
#ifdef SH_ARCH_MAGIC_BIG
2348
    case SH_ARCH_MAGIC_BIG:
2349
    case SH_ARCH_MAGIC_LITTLE:
2350
#ifdef COFF_WITH_PE
2351
    case SH_ARCH_MAGIC_WINCE:
2352
#endif
2353
      arch = bfd_arch_sh;
2354
      break;
2355
#endif
2356
2357
#ifdef MIPS_ARCH_MAGIC_WINCE
2358
    case MIPS_ARCH_MAGIC_WINCE:
2359
      arch = bfd_arch_mips;
2360
      break;
2361
#endif
2362
2363
#ifdef SPARCMAGIC
2364
    case SPARCMAGIC:
2365
#ifdef LYNXCOFFMAGIC
2366
    case LYNXCOFFMAGIC:
2367
#endif
2368
      arch = bfd_arch_sparc;
2369
      break;
2370
#endif
2371
2372
#ifdef TIC30MAGIC
2373
    case TIC30MAGIC:
2374
      arch = bfd_arch_tic30;
2375
      break;
2376
#endif
2377
2378
#ifdef TICOFF0MAGIC
2379
#ifdef TICOFF_TARGET_ARCH
2380
      /* This TI COFF section should be used by all new TI COFF v0 targets.  */
2381
    case TICOFF0MAGIC:
2382
      arch = TICOFF_TARGET_ARCH;
2383
      machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2384
      break;
2385
#endif
2386
#endif
2387
2388
#ifdef TICOFF1MAGIC
2389
      /* This TI COFF section should be used by all new TI COFF v1/2 targets.  */
2390
      /* TI COFF1 and COFF2 use the target_id field to specify which arch.  */
2391
    case TICOFF1MAGIC:
2392
    case TICOFF2MAGIC:
2393
      switch (internal_f->f_target_id)
2394
  {
2395
#ifdef TI_TARGET_ID
2396
  case TI_TARGET_ID:
2397
    arch = TICOFF_TARGET_ARCH;
2398
    machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2399
    break;
2400
#endif
2401
  default:
2402
    arch = bfd_arch_obscure;
2403
    _bfd_error_handler
2404
      (_("unrecognized TI COFF target id '0x%x'"),
2405
       internal_f->f_target_id);
2406
    break;
2407
  }
2408
      break;
2409
#endif
2410
2411
#ifdef MCOREMAGIC
2412
    case MCOREMAGIC:
2413
      arch = bfd_arch_mcore;
2414
      break;
2415
#endif
2416
2417
2.13k
    default:      /* Unreadable input file type.  */
2418
521
      arch = bfd_arch_obscure;
2419
521
      break;
2420
2.65k
    }
2421
2422
2.65k
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
2.65k
  return true;
2424
2.65k
}
pe-i386.c:coff_set_arch_mach_hook
Line
Count
Source
2162
7.68k
{
2163
7.68k
  unsigned long machine;
2164
7.68k
  enum bfd_architecture arch;
2165
7.68k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
7.68k
  machine = 0;
2169
7.68k
  switch (internal_f->f_magic)
2170
7.68k
    {
2171
0
#ifdef I386MAGIC
2172
6.71k
    case I386MAGIC:
2173
6.86k
    case I386PTXMAGIC:
2174
7.28k
    case I386AIXMAGIC:   /* Danbury PS/2 AIX C Compiler.  */
2175
7.34k
    case LYNXCOFFMAGIC:
2176
7.58k
    case I386_APPLE_MAGIC:
2177
7.58k
    case I386_FREEBSD_MAGIC:
2178
7.58k
    case I386_LINUX_MAGIC:
2179
7.68k
    case I386_NETBSD_MAGIC:
2180
7.68k
      arch = bfd_arch_i386;
2181
7.68k
      break;
2182
0
#endif
2183
#ifdef AMD64MAGIC
2184
    case AMD64MAGIC:
2185
    case AMD64_APPLE_MAGIC:
2186
    case AMD64_FREEBSD_MAGIC:
2187
    case AMD64_LINUX_MAGIC:
2188
    case AMD64_NETBSD_MAGIC:
2189
      arch = bfd_arch_i386;
2190
      machine = bfd_mach_x86_64;
2191
      break;
2192
#endif
2193
#ifdef IA64MAGIC
2194
    case IA64MAGIC:
2195
      arch = bfd_arch_ia64;
2196
      break;
2197
#endif
2198
#ifdef ARMMAGIC
2199
    case ARMMAGIC:
2200
    case ARMPEMAGIC:
2201
    case THUMBPEMAGIC:
2202
      arch = bfd_arch_arm;
2203
      machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION);
2204
      if (machine == bfd_mach_arm_unknown)
2205
  {
2206
    switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK)
2207
      {
2208
      case F_ARM_2:  machine = bfd_mach_arm_2;  break;
2209
      case F_ARM_2a: machine = bfd_mach_arm_2a; break;
2210
      case F_ARM_3:  machine = bfd_mach_arm_3;  break;
2211
      default:
2212
      case F_ARM_3M: machine = bfd_mach_arm_3M; break;
2213
      case F_ARM_4:  machine = bfd_mach_arm_4;  break;
2214
      case F_ARM_4T: machine = bfd_mach_arm_4T; break;
2215
        /* The COFF header does not have enough bits available
2216
     to cover all the different ARM architectures.  So
2217
     we interpret F_ARM_5, the highest flag value to mean
2218
     "the highest ARM architecture known to BFD" which is
2219
     currently the XScale.  */
2220
      case F_ARM_5:  machine = bfd_mach_arm_XScale;  break;
2221
      }
2222
  }
2223
      break;
2224
#endif
2225
#ifdef AARCH64MAGIC
2226
    case AARCH64MAGIC:
2227
      arch = bfd_arch_aarch64;
2228
      machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK;
2229
      break;
2230
#endif
2231
#ifdef LOONGARCH64MAGIC
2232
    case LOONGARCH64MAGIC:
2233
      arch = bfd_arch_loongarch;
2234
      machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK;
2235
      break;
2236
#endif
2237
#ifdef Z80MAGIC
2238
    case Z80MAGIC:
2239
      arch = bfd_arch_z80;
2240
      switch (internal_f->f_flags & F_MACHMASK)
2241
  {
2242
  case bfd_mach_z80strict << 12:
2243
  case bfd_mach_z80 << 12:
2244
  case bfd_mach_z80n << 12:
2245
  case bfd_mach_z80full << 12:
2246
  case bfd_mach_r800 << 12:
2247
  case bfd_mach_gbz80 << 12:
2248
  case bfd_mach_z180 << 12:
2249
  case bfd_mach_ez80_z80 << 12:
2250
  case bfd_mach_ez80_adl << 12:
2251
    machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12;
2252
    break;
2253
  default:
2254
    return false;
2255
  }
2256
      break;
2257
#endif
2258
#ifdef Z8KMAGIC
2259
    case Z8KMAGIC:
2260
      arch = bfd_arch_z8k;
2261
      switch (internal_f->f_flags & F_MACHMASK)
2262
  {
2263
  case F_Z8001:
2264
    machine = bfd_mach_z8001;
2265
    break;
2266
  case F_Z8002:
2267
    machine = bfd_mach_z8002;
2268
    break;
2269
  default:
2270
    return false;
2271
  }
2272
      break;
2273
#endif
2274
2275
#ifdef RS6000COFF_C
2276
#ifdef XCOFF64
2277
    case U64_TOCMAGIC:
2278
    case U803XTOCMAGIC:
2279
#else
2280
    case U802ROMAGIC:
2281
    case U802WRMAGIC:
2282
    case U802TOCMAGIC:
2283
#endif
2284
      {
2285
  int cputype;
2286
2287
  if (xcoff_data (abfd)->cputype != -1)
2288
    cputype = xcoff_data (abfd)->cputype & 0xff;
2289
  else
2290
    {
2291
      /* We did not get a value from the a.out header.  If the
2292
         file has not been stripped, we may be able to get the
2293
         architecture information from the first symbol, if it
2294
         is a .file symbol.  */
2295
      if (obj_raw_syment_count (abfd) == 0)
2296
        cputype = 0;
2297
      else
2298
        {
2299
    bfd_byte *buf;
2300
    struct internal_syment sym;
2301
    bfd_size_type amt = bfd_coff_symesz (abfd);
2302
2303
    if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
2304
      return false;
2305
    buf = _bfd_malloc_and_read (abfd, amt, amt);
2306
    if (buf == NULL)
2307
      return false;
2308
    bfd_coff_swap_sym_in (abfd, buf, & sym);
2309
    if (sym.n_sclass == C_FILE)
2310
      cputype = sym.n_type & 0xff;
2311
    else
2312
      cputype = 0;
2313
    free (buf);
2314
        }
2315
    }
2316
2317
  /* FIXME: We don't handle all cases here.  */
2318
  switch (cputype)
2319
    {
2320
    default:
2321
    case 0:
2322
      arch = bfd_xcoff_architecture (abfd);
2323
      machine = bfd_xcoff_machine (abfd);
2324
      break;
2325
2326
    case 1:
2327
      arch = bfd_arch_powerpc;
2328
      machine = bfd_mach_ppc_601;
2329
      break;
2330
    case 2: /* 64 bit PowerPC */
2331
      arch = bfd_arch_powerpc;
2332
      machine = bfd_mach_ppc_620;
2333
      break;
2334
    case 3:
2335
      arch = bfd_arch_powerpc;
2336
      machine = bfd_mach_ppc;
2337
      break;
2338
    case 4:
2339
      arch = bfd_arch_rs6000;
2340
      machine = bfd_mach_rs6k;
2341
      break;
2342
    }
2343
      }
2344
      break;
2345
#endif
2346
2347
#ifdef SH_ARCH_MAGIC_BIG
2348
    case SH_ARCH_MAGIC_BIG:
2349
    case SH_ARCH_MAGIC_LITTLE:
2350
#ifdef COFF_WITH_PE
2351
    case SH_ARCH_MAGIC_WINCE:
2352
#endif
2353
      arch = bfd_arch_sh;
2354
      break;
2355
#endif
2356
2357
#ifdef MIPS_ARCH_MAGIC_WINCE
2358
    case MIPS_ARCH_MAGIC_WINCE:
2359
      arch = bfd_arch_mips;
2360
      break;
2361
#endif
2362
2363
#ifdef SPARCMAGIC
2364
    case SPARCMAGIC:
2365
#ifdef LYNXCOFFMAGIC
2366
    case LYNXCOFFMAGIC:
2367
#endif
2368
      arch = bfd_arch_sparc;
2369
      break;
2370
#endif
2371
2372
#ifdef TIC30MAGIC
2373
    case TIC30MAGIC:
2374
      arch = bfd_arch_tic30;
2375
      break;
2376
#endif
2377
2378
#ifdef TICOFF0MAGIC
2379
#ifdef TICOFF_TARGET_ARCH
2380
      /* This TI COFF section should be used by all new TI COFF v0 targets.  */
2381
    case TICOFF0MAGIC:
2382
      arch = TICOFF_TARGET_ARCH;
2383
      machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2384
      break;
2385
#endif
2386
#endif
2387
2388
#ifdef TICOFF1MAGIC
2389
      /* This TI COFF section should be used by all new TI COFF v1/2 targets.  */
2390
      /* TI COFF1 and COFF2 use the target_id field to specify which arch.  */
2391
    case TICOFF1MAGIC:
2392
    case TICOFF2MAGIC:
2393
      switch (internal_f->f_target_id)
2394
  {
2395
#ifdef TI_TARGET_ID
2396
  case TI_TARGET_ID:
2397
    arch = TICOFF_TARGET_ARCH;
2398
    machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2399
    break;
2400
#endif
2401
  default:
2402
    arch = bfd_arch_obscure;
2403
    _bfd_error_handler
2404
      (_("unrecognized TI COFF target id '0x%x'"),
2405
       internal_f->f_target_id);
2406
    break;
2407
  }
2408
      break;
2409
#endif
2410
2411
#ifdef MCOREMAGIC
2412
    case MCOREMAGIC:
2413
      arch = bfd_arch_mcore;
2414
      break;
2415
#endif
2416
2417
0
    default:      /* Unreadable input file type.  */
2418
0
      arch = bfd_arch_obscure;
2419
0
      break;
2420
7.68k
    }
2421
2422
7.68k
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
7.68k
  return true;
2424
7.68k
}
pe-mcore.c:coff_set_arch_mach_hook
Line
Count
Source
2162
3.85k
{
2163
3.85k
  unsigned long machine;
2164
3.85k
  enum bfd_architecture arch;
2165
3.85k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
3.85k
  machine = 0;
2169
3.85k
  switch (internal_f->f_magic)
2170
3.85k
    {
2171
#ifdef I386MAGIC
2172
    case I386MAGIC:
2173
    case I386PTXMAGIC:
2174
    case I386AIXMAGIC:    /* Danbury PS/2 AIX C Compiler.  */
2175
    case LYNXCOFFMAGIC:
2176
    case I386_APPLE_MAGIC:
2177
    case I386_FREEBSD_MAGIC:
2178
    case I386_LINUX_MAGIC:
2179
    case I386_NETBSD_MAGIC:
2180
      arch = bfd_arch_i386;
2181
      break;
2182
#endif
2183
#ifdef AMD64MAGIC
2184
    case AMD64MAGIC:
2185
    case AMD64_APPLE_MAGIC:
2186
    case AMD64_FREEBSD_MAGIC:
2187
    case AMD64_LINUX_MAGIC:
2188
    case AMD64_NETBSD_MAGIC:
2189
      arch = bfd_arch_i386;
2190
      machine = bfd_mach_x86_64;
2191
      break;
2192
#endif
2193
#ifdef IA64MAGIC
2194
    case IA64MAGIC:
2195
      arch = bfd_arch_ia64;
2196
      break;
2197
#endif
2198
#ifdef ARMMAGIC
2199
    case ARMMAGIC:
2200
    case ARMPEMAGIC:
2201
    case THUMBPEMAGIC:
2202
      arch = bfd_arch_arm;
2203
      machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION);
2204
      if (machine == bfd_mach_arm_unknown)
2205
  {
2206
    switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK)
2207
      {
2208
      case F_ARM_2:  machine = bfd_mach_arm_2;  break;
2209
      case F_ARM_2a: machine = bfd_mach_arm_2a; break;
2210
      case F_ARM_3:  machine = bfd_mach_arm_3;  break;
2211
      default:
2212
      case F_ARM_3M: machine = bfd_mach_arm_3M; break;
2213
      case F_ARM_4:  machine = bfd_mach_arm_4;  break;
2214
      case F_ARM_4T: machine = bfd_mach_arm_4T; break;
2215
        /* The COFF header does not have enough bits available
2216
     to cover all the different ARM architectures.  So
2217
     we interpret F_ARM_5, the highest flag value to mean
2218
     "the highest ARM architecture known to BFD" which is
2219
     currently the XScale.  */
2220
      case F_ARM_5:  machine = bfd_mach_arm_XScale;  break;
2221
      }
2222
  }
2223
      break;
2224
#endif
2225
#ifdef AARCH64MAGIC
2226
    case AARCH64MAGIC:
2227
      arch = bfd_arch_aarch64;
2228
      machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK;
2229
      break;
2230
#endif
2231
#ifdef LOONGARCH64MAGIC
2232
    case LOONGARCH64MAGIC:
2233
      arch = bfd_arch_loongarch;
2234
      machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK;
2235
      break;
2236
#endif
2237
#ifdef Z80MAGIC
2238
    case Z80MAGIC:
2239
      arch = bfd_arch_z80;
2240
      switch (internal_f->f_flags & F_MACHMASK)
2241
  {
2242
  case bfd_mach_z80strict << 12:
2243
  case bfd_mach_z80 << 12:
2244
  case bfd_mach_z80n << 12:
2245
  case bfd_mach_z80full << 12:
2246
  case bfd_mach_r800 << 12:
2247
  case bfd_mach_gbz80 << 12:
2248
  case bfd_mach_z180 << 12:
2249
  case bfd_mach_ez80_z80 << 12:
2250
  case bfd_mach_ez80_adl << 12:
2251
    machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12;
2252
    break;
2253
  default:
2254
    return false;
2255
  }
2256
      break;
2257
#endif
2258
#ifdef Z8KMAGIC
2259
    case Z8KMAGIC:
2260
      arch = bfd_arch_z8k;
2261
      switch (internal_f->f_flags & F_MACHMASK)
2262
  {
2263
  case F_Z8001:
2264
    machine = bfd_mach_z8001;
2265
    break;
2266
  case F_Z8002:
2267
    machine = bfd_mach_z8002;
2268
    break;
2269
  default:
2270
    return false;
2271
  }
2272
      break;
2273
#endif
2274
2275
#ifdef RS6000COFF_C
2276
#ifdef XCOFF64
2277
    case U64_TOCMAGIC:
2278
    case U803XTOCMAGIC:
2279
#else
2280
    case U802ROMAGIC:
2281
    case U802WRMAGIC:
2282
    case U802TOCMAGIC:
2283
#endif
2284
      {
2285
  int cputype;
2286
2287
  if (xcoff_data (abfd)->cputype != -1)
2288
    cputype = xcoff_data (abfd)->cputype & 0xff;
2289
  else
2290
    {
2291
      /* We did not get a value from the a.out header.  If the
2292
         file has not been stripped, we may be able to get the
2293
         architecture information from the first symbol, if it
2294
         is a .file symbol.  */
2295
      if (obj_raw_syment_count (abfd) == 0)
2296
        cputype = 0;
2297
      else
2298
        {
2299
    bfd_byte *buf;
2300
    struct internal_syment sym;
2301
    bfd_size_type amt = bfd_coff_symesz (abfd);
2302
2303
    if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
2304
      return false;
2305
    buf = _bfd_malloc_and_read (abfd, amt, amt);
2306
    if (buf == NULL)
2307
      return false;
2308
    bfd_coff_swap_sym_in (abfd, buf, & sym);
2309
    if (sym.n_sclass == C_FILE)
2310
      cputype = sym.n_type & 0xff;
2311
    else
2312
      cputype = 0;
2313
    free (buf);
2314
        }
2315
    }
2316
2317
  /* FIXME: We don't handle all cases here.  */
2318
  switch (cputype)
2319
    {
2320
    default:
2321
    case 0:
2322
      arch = bfd_xcoff_architecture (abfd);
2323
      machine = bfd_xcoff_machine (abfd);
2324
      break;
2325
2326
    case 1:
2327
      arch = bfd_arch_powerpc;
2328
      machine = bfd_mach_ppc_601;
2329
      break;
2330
    case 2: /* 64 bit PowerPC */
2331
      arch = bfd_arch_powerpc;
2332
      machine = bfd_mach_ppc_620;
2333
      break;
2334
    case 3:
2335
      arch = bfd_arch_powerpc;
2336
      machine = bfd_mach_ppc;
2337
      break;
2338
    case 4:
2339
      arch = bfd_arch_rs6000;
2340
      machine = bfd_mach_rs6k;
2341
      break;
2342
    }
2343
      }
2344
      break;
2345
#endif
2346
2347
#ifdef SH_ARCH_MAGIC_BIG
2348
    case SH_ARCH_MAGIC_BIG:
2349
    case SH_ARCH_MAGIC_LITTLE:
2350
#ifdef COFF_WITH_PE
2351
    case SH_ARCH_MAGIC_WINCE:
2352
#endif
2353
      arch = bfd_arch_sh;
2354
      break;
2355
#endif
2356
2357
#ifdef MIPS_ARCH_MAGIC_WINCE
2358
    case MIPS_ARCH_MAGIC_WINCE:
2359
      arch = bfd_arch_mips;
2360
      break;
2361
#endif
2362
2363
#ifdef SPARCMAGIC
2364
    case SPARCMAGIC:
2365
#ifdef LYNXCOFFMAGIC
2366
    case LYNXCOFFMAGIC:
2367
#endif
2368
      arch = bfd_arch_sparc;
2369
      break;
2370
#endif
2371
2372
#ifdef TIC30MAGIC
2373
    case TIC30MAGIC:
2374
      arch = bfd_arch_tic30;
2375
      break;
2376
#endif
2377
2378
#ifdef TICOFF0MAGIC
2379
#ifdef TICOFF_TARGET_ARCH
2380
      /* This TI COFF section should be used by all new TI COFF v0 targets.  */
2381
    case TICOFF0MAGIC:
2382
      arch = TICOFF_TARGET_ARCH;
2383
      machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2384
      break;
2385
#endif
2386
#endif
2387
2388
#ifdef TICOFF1MAGIC
2389
      /* This TI COFF section should be used by all new TI COFF v1/2 targets.  */
2390
      /* TI COFF1 and COFF2 use the target_id field to specify which arch.  */
2391
    case TICOFF1MAGIC:
2392
    case TICOFF2MAGIC:
2393
      switch (internal_f->f_target_id)
2394
  {
2395
#ifdef TI_TARGET_ID
2396
  case TI_TARGET_ID:
2397
    arch = TICOFF_TARGET_ARCH;
2398
    machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2399
    break;
2400
#endif
2401
  default:
2402
    arch = bfd_arch_obscure;
2403
    _bfd_error_handler
2404
      (_("unrecognized TI COFF target id '0x%x'"),
2405
       internal_f->f_target_id);
2406
    break;
2407
  }
2408
      break;
2409
#endif
2410
2411
0
#ifdef MCOREMAGIC
2412
3.85k
    case MCOREMAGIC:
2413
3.85k
      arch = bfd_arch_mcore;
2414
3.85k
      break;
2415
0
#endif
2416
2417
0
    default:      /* Unreadable input file type.  */
2418
0
      arch = bfd_arch_obscure;
2419
0
      break;
2420
3.85k
    }
2421
2422
3.85k
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
3.85k
  return true;
2424
3.85k
}
pe-sh.c:coff_set_arch_mach_hook
Line
Count
Source
2162
6.78k
{
2163
6.78k
  unsigned long machine;
2164
6.78k
  enum bfd_architecture arch;
2165
6.78k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
6.78k
  machine = 0;
2169
6.78k
  switch (internal_f->f_magic)
2170
6.78k
    {
2171
#ifdef I386MAGIC
2172
    case I386MAGIC:
2173
    case I386PTXMAGIC:
2174
    case I386AIXMAGIC:    /* Danbury PS/2 AIX C Compiler.  */
2175
    case LYNXCOFFMAGIC:
2176
    case I386_APPLE_MAGIC:
2177
    case I386_FREEBSD_MAGIC:
2178
    case I386_LINUX_MAGIC:
2179
    case I386_NETBSD_MAGIC:
2180
      arch = bfd_arch_i386;
2181
      break;
2182
#endif
2183
#ifdef AMD64MAGIC
2184
    case AMD64MAGIC:
2185
    case AMD64_APPLE_MAGIC:
2186
    case AMD64_FREEBSD_MAGIC:
2187
    case AMD64_LINUX_MAGIC:
2188
    case AMD64_NETBSD_MAGIC:
2189
      arch = bfd_arch_i386;
2190
      machine = bfd_mach_x86_64;
2191
      break;
2192
#endif
2193
#ifdef IA64MAGIC
2194
    case IA64MAGIC:
2195
      arch = bfd_arch_ia64;
2196
      break;
2197
#endif
2198
#ifdef ARMMAGIC
2199
    case ARMMAGIC:
2200
    case ARMPEMAGIC:
2201
    case THUMBPEMAGIC:
2202
      arch = bfd_arch_arm;
2203
      machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION);
2204
      if (machine == bfd_mach_arm_unknown)
2205
  {
2206
    switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK)
2207
      {
2208
      case F_ARM_2:  machine = bfd_mach_arm_2;  break;
2209
      case F_ARM_2a: machine = bfd_mach_arm_2a; break;
2210
      case F_ARM_3:  machine = bfd_mach_arm_3;  break;
2211
      default:
2212
      case F_ARM_3M: machine = bfd_mach_arm_3M; break;
2213
      case F_ARM_4:  machine = bfd_mach_arm_4;  break;
2214
      case F_ARM_4T: machine = bfd_mach_arm_4T; break;
2215
        /* The COFF header does not have enough bits available
2216
     to cover all the different ARM architectures.  So
2217
     we interpret F_ARM_5, the highest flag value to mean
2218
     "the highest ARM architecture known to BFD" which is
2219
     currently the XScale.  */
2220
      case F_ARM_5:  machine = bfd_mach_arm_XScale;  break;
2221
      }
2222
  }
2223
      break;
2224
#endif
2225
#ifdef AARCH64MAGIC
2226
    case AARCH64MAGIC:
2227
      arch = bfd_arch_aarch64;
2228
      machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK;
2229
      break;
2230
#endif
2231
#ifdef LOONGARCH64MAGIC
2232
    case LOONGARCH64MAGIC:
2233
      arch = bfd_arch_loongarch;
2234
      machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK;
2235
      break;
2236
#endif
2237
#ifdef Z80MAGIC
2238
    case Z80MAGIC:
2239
      arch = bfd_arch_z80;
2240
      switch (internal_f->f_flags & F_MACHMASK)
2241
  {
2242
  case bfd_mach_z80strict << 12:
2243
  case bfd_mach_z80 << 12:
2244
  case bfd_mach_z80n << 12:
2245
  case bfd_mach_z80full << 12:
2246
  case bfd_mach_r800 << 12:
2247
  case bfd_mach_gbz80 << 12:
2248
  case bfd_mach_z180 << 12:
2249
  case bfd_mach_ez80_z80 << 12:
2250
  case bfd_mach_ez80_adl << 12:
2251
    machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12;
2252
    break;
2253
  default:
2254
    return false;
2255
  }
2256
      break;
2257
#endif
2258
#ifdef Z8KMAGIC
2259
    case Z8KMAGIC:
2260
      arch = bfd_arch_z8k;
2261
      switch (internal_f->f_flags & F_MACHMASK)
2262
  {
2263
  case F_Z8001:
2264
    machine = bfd_mach_z8001;
2265
    break;
2266
  case F_Z8002:
2267
    machine = bfd_mach_z8002;
2268
    break;
2269
  default:
2270
    return false;
2271
  }
2272
      break;
2273
#endif
2274
2275
#ifdef RS6000COFF_C
2276
#ifdef XCOFF64
2277
    case U64_TOCMAGIC:
2278
    case U803XTOCMAGIC:
2279
#else
2280
    case U802ROMAGIC:
2281
    case U802WRMAGIC:
2282
    case U802TOCMAGIC:
2283
#endif
2284
      {
2285
  int cputype;
2286
2287
  if (xcoff_data (abfd)->cputype != -1)
2288
    cputype = xcoff_data (abfd)->cputype & 0xff;
2289
  else
2290
    {
2291
      /* We did not get a value from the a.out header.  If the
2292
         file has not been stripped, we may be able to get the
2293
         architecture information from the first symbol, if it
2294
         is a .file symbol.  */
2295
      if (obj_raw_syment_count (abfd) == 0)
2296
        cputype = 0;
2297
      else
2298
        {
2299
    bfd_byte *buf;
2300
    struct internal_syment sym;
2301
    bfd_size_type amt = bfd_coff_symesz (abfd);
2302
2303
    if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
2304
      return false;
2305
    buf = _bfd_malloc_and_read (abfd, amt, amt);
2306
    if (buf == NULL)
2307
      return false;
2308
    bfd_coff_swap_sym_in (abfd, buf, & sym);
2309
    if (sym.n_sclass == C_FILE)
2310
      cputype = sym.n_type & 0xff;
2311
    else
2312
      cputype = 0;
2313
    free (buf);
2314
        }
2315
    }
2316
2317
  /* FIXME: We don't handle all cases here.  */
2318
  switch (cputype)
2319
    {
2320
    default:
2321
    case 0:
2322
      arch = bfd_xcoff_architecture (abfd);
2323
      machine = bfd_xcoff_machine (abfd);
2324
      break;
2325
2326
    case 1:
2327
      arch = bfd_arch_powerpc;
2328
      machine = bfd_mach_ppc_601;
2329
      break;
2330
    case 2: /* 64 bit PowerPC */
2331
      arch = bfd_arch_powerpc;
2332
      machine = bfd_mach_ppc_620;
2333
      break;
2334
    case 3:
2335
      arch = bfd_arch_powerpc;
2336
      machine = bfd_mach_ppc;
2337
      break;
2338
    case 4:
2339
      arch = bfd_arch_rs6000;
2340
      machine = bfd_mach_rs6k;
2341
      break;
2342
    }
2343
      }
2344
      break;
2345
#endif
2346
2347
0
#ifdef SH_ARCH_MAGIC_BIG
2348
5.75k
    case SH_ARCH_MAGIC_BIG:
2349
6.72k
    case SH_ARCH_MAGIC_LITTLE:
2350
6.72k
#ifdef COFF_WITH_PE
2351
6.78k
    case SH_ARCH_MAGIC_WINCE:
2352
6.78k
#endif
2353
6.78k
      arch = bfd_arch_sh;
2354
6.78k
      break;
2355
0
#endif
2356
2357
#ifdef MIPS_ARCH_MAGIC_WINCE
2358
    case MIPS_ARCH_MAGIC_WINCE:
2359
      arch = bfd_arch_mips;
2360
      break;
2361
#endif
2362
2363
#ifdef SPARCMAGIC
2364
    case SPARCMAGIC:
2365
#ifdef LYNXCOFFMAGIC
2366
    case LYNXCOFFMAGIC:
2367
#endif
2368
      arch = bfd_arch_sparc;
2369
      break;
2370
#endif
2371
2372
#ifdef TIC30MAGIC
2373
    case TIC30MAGIC:
2374
      arch = bfd_arch_tic30;
2375
      break;
2376
#endif
2377
2378
#ifdef TICOFF0MAGIC
2379
#ifdef TICOFF_TARGET_ARCH
2380
      /* This TI COFF section should be used by all new TI COFF v0 targets.  */
2381
    case TICOFF0MAGIC:
2382
      arch = TICOFF_TARGET_ARCH;
2383
      machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2384
      break;
2385
#endif
2386
#endif
2387
2388
#ifdef TICOFF1MAGIC
2389
      /* This TI COFF section should be used by all new TI COFF v1/2 targets.  */
2390
      /* TI COFF1 and COFF2 use the target_id field to specify which arch.  */
2391
    case TICOFF1MAGIC:
2392
    case TICOFF2MAGIC:
2393
      switch (internal_f->f_target_id)
2394
  {
2395
#ifdef TI_TARGET_ID
2396
  case TI_TARGET_ID:
2397
    arch = TICOFF_TARGET_ARCH;
2398
    machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2399
    break;
2400
#endif
2401
  default:
2402
    arch = bfd_arch_obscure;
2403
    _bfd_error_handler
2404
      (_("unrecognized TI COFF target id '0x%x'"),
2405
       internal_f->f_target_id);
2406
    break;
2407
  }
2408
      break;
2409
#endif
2410
2411
#ifdef MCOREMAGIC
2412
    case MCOREMAGIC:
2413
      arch = bfd_arch_mcore;
2414
      break;
2415
#endif
2416
2417
0
    default:      /* Unreadable input file type.  */
2418
0
      arch = bfd_arch_obscure;
2419
0
      break;
2420
6.78k
    }
2421
2422
6.78k
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
6.78k
  return true;
2424
6.78k
}
pei-arm-wince.c:coff_set_arch_mach_hook
Line
Count
Source
2162
8.90k
{
2163
8.90k
  unsigned long machine;
2164
8.90k
  enum bfd_architecture arch;
2165
8.90k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
8.90k
  machine = 0;
2169
8.90k
  switch (internal_f->f_magic)
2170
8.90k
    {
2171
#ifdef I386MAGIC
2172
    case I386MAGIC:
2173
    case I386PTXMAGIC:
2174
    case I386AIXMAGIC:    /* Danbury PS/2 AIX C Compiler.  */
2175
    case LYNXCOFFMAGIC:
2176
    case I386_APPLE_MAGIC:
2177
    case I386_FREEBSD_MAGIC:
2178
    case I386_LINUX_MAGIC:
2179
    case I386_NETBSD_MAGIC:
2180
      arch = bfd_arch_i386;
2181
      break;
2182
#endif
2183
#ifdef AMD64MAGIC
2184
    case AMD64MAGIC:
2185
    case AMD64_APPLE_MAGIC:
2186
    case AMD64_FREEBSD_MAGIC:
2187
    case AMD64_LINUX_MAGIC:
2188
    case AMD64_NETBSD_MAGIC:
2189
      arch = bfd_arch_i386;
2190
      machine = bfd_mach_x86_64;
2191
      break;
2192
#endif
2193
#ifdef IA64MAGIC
2194
    case IA64MAGIC:
2195
      arch = bfd_arch_ia64;
2196
      break;
2197
#endif
2198
0
#ifdef ARMMAGIC
2199
5.95k
    case ARMMAGIC:
2200
6.25k
    case ARMPEMAGIC:
2201
8.79k
    case THUMBPEMAGIC:
2202
8.79k
      arch = bfd_arch_arm;
2203
8.79k
      machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION);
2204
8.79k
      if (machine == bfd_mach_arm_unknown)
2205
8.79k
  {
2206
8.79k
    switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK)
2207
8.79k
      {
2208
617
      case F_ARM_2:  machine = bfd_mach_arm_2;  break;
2209
1.55k
      case F_ARM_2a: machine = bfd_mach_arm_2a; break;
2210
19
      case F_ARM_3:  machine = bfd_mach_arm_3;  break;
2211
4.15k
      default:
2212
4.19k
      case F_ARM_3M: machine = bfd_mach_arm_3M; break;
2213
250
      case F_ARM_4:  machine = bfd_mach_arm_4;  break;
2214
1.08k
      case F_ARM_4T: machine = bfd_mach_arm_4T; break;
2215
        /* The COFF header does not have enough bits available
2216
     to cover all the different ARM architectures.  So
2217
     we interpret F_ARM_5, the highest flag value to mean
2218
     "the highest ARM architecture known to BFD" which is
2219
     currently the XScale.  */
2220
1.06k
      case F_ARM_5:  machine = bfd_mach_arm_XScale;  break;
2221
8.79k
      }
2222
8.79k
  }
2223
8.79k
      break;
2224
8.79k
#endif
2225
#ifdef AARCH64MAGIC
2226
    case AARCH64MAGIC:
2227
      arch = bfd_arch_aarch64;
2228
      machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK;
2229
      break;
2230
#endif
2231
#ifdef LOONGARCH64MAGIC
2232
    case LOONGARCH64MAGIC:
2233
      arch = bfd_arch_loongarch;
2234
      machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK;
2235
      break;
2236
#endif
2237
#ifdef Z80MAGIC
2238
    case Z80MAGIC:
2239
      arch = bfd_arch_z80;
2240
      switch (internal_f->f_flags & F_MACHMASK)
2241
  {
2242
  case bfd_mach_z80strict << 12:
2243
  case bfd_mach_z80 << 12:
2244
  case bfd_mach_z80n << 12:
2245
  case bfd_mach_z80full << 12:
2246
  case bfd_mach_r800 << 12:
2247
  case bfd_mach_gbz80 << 12:
2248
  case bfd_mach_z180 << 12:
2249
  case bfd_mach_ez80_z80 << 12:
2250
  case bfd_mach_ez80_adl << 12:
2251
    machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12;
2252
    break;
2253
  default:
2254
    return false;
2255
  }
2256
      break;
2257
#endif
2258
#ifdef Z8KMAGIC
2259
    case Z8KMAGIC:
2260
      arch = bfd_arch_z8k;
2261
      switch (internal_f->f_flags & F_MACHMASK)
2262
  {
2263
  case F_Z8001:
2264
    machine = bfd_mach_z8001;
2265
    break;
2266
  case F_Z8002:
2267
    machine = bfd_mach_z8002;
2268
    break;
2269
  default:
2270
    return false;
2271
  }
2272
      break;
2273
#endif
2274
2275
#ifdef RS6000COFF_C
2276
#ifdef XCOFF64
2277
    case U64_TOCMAGIC:
2278
    case U803XTOCMAGIC:
2279
#else
2280
    case U802ROMAGIC:
2281
    case U802WRMAGIC:
2282
    case U802TOCMAGIC:
2283
#endif
2284
      {
2285
  int cputype;
2286
2287
  if (xcoff_data (abfd)->cputype != -1)
2288
    cputype = xcoff_data (abfd)->cputype & 0xff;
2289
  else
2290
    {
2291
      /* We did not get a value from the a.out header.  If the
2292
         file has not been stripped, we may be able to get the
2293
         architecture information from the first symbol, if it
2294
         is a .file symbol.  */
2295
      if (obj_raw_syment_count (abfd) == 0)
2296
        cputype = 0;
2297
      else
2298
        {
2299
    bfd_byte *buf;
2300
    struct internal_syment sym;
2301
    bfd_size_type amt = bfd_coff_symesz (abfd);
2302
2303
    if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
2304
      return false;
2305
    buf = _bfd_malloc_and_read (abfd, amt, amt);
2306
    if (buf == NULL)
2307
      return false;
2308
    bfd_coff_swap_sym_in (abfd, buf, & sym);
2309
    if (sym.n_sclass == C_FILE)
2310
      cputype = sym.n_type & 0xff;
2311
    else
2312
      cputype = 0;
2313
    free (buf);
2314
        }
2315
    }
2316
2317
  /* FIXME: We don't handle all cases here.  */
2318
  switch (cputype)
2319
    {
2320
    default:
2321
    case 0:
2322
      arch = bfd_xcoff_architecture (abfd);
2323
      machine = bfd_xcoff_machine (abfd);
2324
      break;
2325
2326
    case 1:
2327
      arch = bfd_arch_powerpc;
2328
      machine = bfd_mach_ppc_601;
2329
      break;
2330
    case 2: /* 64 bit PowerPC */
2331
      arch = bfd_arch_powerpc;
2332
      machine = bfd_mach_ppc_620;
2333
      break;
2334
    case 3:
2335
      arch = bfd_arch_powerpc;
2336
      machine = bfd_mach_ppc;
2337
      break;
2338
    case 4:
2339
      arch = bfd_arch_rs6000;
2340
      machine = bfd_mach_rs6k;
2341
      break;
2342
    }
2343
      }
2344
      break;
2345
#endif
2346
2347
#ifdef SH_ARCH_MAGIC_BIG
2348
    case SH_ARCH_MAGIC_BIG:
2349
    case SH_ARCH_MAGIC_LITTLE:
2350
#ifdef COFF_WITH_PE
2351
    case SH_ARCH_MAGIC_WINCE:
2352
#endif
2353
      arch = bfd_arch_sh;
2354
      break;
2355
#endif
2356
2357
#ifdef MIPS_ARCH_MAGIC_WINCE
2358
    case MIPS_ARCH_MAGIC_WINCE:
2359
      arch = bfd_arch_mips;
2360
      break;
2361
#endif
2362
2363
#ifdef SPARCMAGIC
2364
    case SPARCMAGIC:
2365
#ifdef LYNXCOFFMAGIC
2366
    case LYNXCOFFMAGIC:
2367
#endif
2368
      arch = bfd_arch_sparc;
2369
      break;
2370
#endif
2371
2372
#ifdef TIC30MAGIC
2373
    case TIC30MAGIC:
2374
      arch = bfd_arch_tic30;
2375
      break;
2376
#endif
2377
2378
#ifdef TICOFF0MAGIC
2379
#ifdef TICOFF_TARGET_ARCH
2380
      /* This TI COFF section should be used by all new TI COFF v0 targets.  */
2381
    case TICOFF0MAGIC:
2382
      arch = TICOFF_TARGET_ARCH;
2383
      machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2384
      break;
2385
#endif
2386
#endif
2387
2388
#ifdef TICOFF1MAGIC
2389
      /* This TI COFF section should be used by all new TI COFF v1/2 targets.  */
2390
      /* TI COFF1 and COFF2 use the target_id field to specify which arch.  */
2391
    case TICOFF1MAGIC:
2392
    case TICOFF2MAGIC:
2393
      switch (internal_f->f_target_id)
2394
  {
2395
#ifdef TI_TARGET_ID
2396
  case TI_TARGET_ID:
2397
    arch = TICOFF_TARGET_ARCH;
2398
    machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2399
    break;
2400
#endif
2401
  default:
2402
    arch = bfd_arch_obscure;
2403
    _bfd_error_handler
2404
      (_("unrecognized TI COFF target id '0x%x'"),
2405
       internal_f->f_target_id);
2406
    break;
2407
  }
2408
      break;
2409
#endif
2410
2411
#ifdef MCOREMAGIC
2412
    case MCOREMAGIC:
2413
      arch = bfd_arch_mcore;
2414
      break;
2415
#endif
2416
2417
8.79k
    default:      /* Unreadable input file type.  */
2418
113
      arch = bfd_arch_obscure;
2419
113
      break;
2420
8.90k
    }
2421
2422
8.90k
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
8.90k
  return true;
2424
8.90k
}
pei-arm.c:coff_set_arch_mach_hook
Line
Count
Source
2162
9.64k
{
2163
9.64k
  unsigned long machine;
2164
9.64k
  enum bfd_architecture arch;
2165
9.64k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
9.64k
  machine = 0;
2169
9.64k
  switch (internal_f->f_magic)
2170
9.64k
    {
2171
#ifdef I386MAGIC
2172
    case I386MAGIC:
2173
    case I386PTXMAGIC:
2174
    case I386AIXMAGIC:    /* Danbury PS/2 AIX C Compiler.  */
2175
    case LYNXCOFFMAGIC:
2176
    case I386_APPLE_MAGIC:
2177
    case I386_FREEBSD_MAGIC:
2178
    case I386_LINUX_MAGIC:
2179
    case I386_NETBSD_MAGIC:
2180
      arch = bfd_arch_i386;
2181
      break;
2182
#endif
2183
#ifdef AMD64MAGIC
2184
    case AMD64MAGIC:
2185
    case AMD64_APPLE_MAGIC:
2186
    case AMD64_FREEBSD_MAGIC:
2187
    case AMD64_LINUX_MAGIC:
2188
    case AMD64_NETBSD_MAGIC:
2189
      arch = bfd_arch_i386;
2190
      machine = bfd_mach_x86_64;
2191
      break;
2192
#endif
2193
#ifdef IA64MAGIC
2194
    case IA64MAGIC:
2195
      arch = bfd_arch_ia64;
2196
      break;
2197
#endif
2198
0
#ifdef ARMMAGIC
2199
6.58k
    case ARMMAGIC:
2200
7.36k
    case ARMPEMAGIC:
2201
9.28k
    case THUMBPEMAGIC:
2202
9.28k
      arch = bfd_arch_arm;
2203
9.28k
      machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION);
2204
9.28k
      if (machine == bfd_mach_arm_unknown)
2205
9.28k
  {
2206
9.28k
    switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK)
2207
9.28k
      {
2208
1.33k
      case F_ARM_2:  machine = bfd_mach_arm_2;  break;
2209
1.72k
      case F_ARM_2a: machine = bfd_mach_arm_2a; break;
2210
19
      case F_ARM_3:  machine = bfd_mach_arm_3;  break;
2211
4.23k
      default:
2212
4.27k
      case F_ARM_3M: machine = bfd_mach_arm_3M; break;
2213
359
      case F_ARM_4:  machine = bfd_mach_arm_4;  break;
2214
364
      case F_ARM_4T: machine = bfd_mach_arm_4T; break;
2215
        /* The COFF header does not have enough bits available
2216
     to cover all the different ARM architectures.  So
2217
     we interpret F_ARM_5, the highest flag value to mean
2218
     "the highest ARM architecture known to BFD" which is
2219
     currently the XScale.  */
2220
1.20k
      case F_ARM_5:  machine = bfd_mach_arm_XScale;  break;
2221
9.28k
      }
2222
9.28k
  }
2223
9.28k
      break;
2224
9.28k
#endif
2225
#ifdef AARCH64MAGIC
2226
    case AARCH64MAGIC:
2227
      arch = bfd_arch_aarch64;
2228
      machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK;
2229
      break;
2230
#endif
2231
#ifdef LOONGARCH64MAGIC
2232
    case LOONGARCH64MAGIC:
2233
      arch = bfd_arch_loongarch;
2234
      machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK;
2235
      break;
2236
#endif
2237
#ifdef Z80MAGIC
2238
    case Z80MAGIC:
2239
      arch = bfd_arch_z80;
2240
      switch (internal_f->f_flags & F_MACHMASK)
2241
  {
2242
  case bfd_mach_z80strict << 12:
2243
  case bfd_mach_z80 << 12:
2244
  case bfd_mach_z80n << 12:
2245
  case bfd_mach_z80full << 12:
2246
  case bfd_mach_r800 << 12:
2247
  case bfd_mach_gbz80 << 12:
2248
  case bfd_mach_z180 << 12:
2249
  case bfd_mach_ez80_z80 << 12:
2250
  case bfd_mach_ez80_adl << 12:
2251
    machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12;
2252
    break;
2253
  default:
2254
    return false;
2255
  }
2256
      break;
2257
#endif
2258
#ifdef Z8KMAGIC
2259
    case Z8KMAGIC:
2260
      arch = bfd_arch_z8k;
2261
      switch (internal_f->f_flags & F_MACHMASK)
2262
  {
2263
  case F_Z8001:
2264
    machine = bfd_mach_z8001;
2265
    break;
2266
  case F_Z8002:
2267
    machine = bfd_mach_z8002;
2268
    break;
2269
  default:
2270
    return false;
2271
  }
2272
      break;
2273
#endif
2274
2275
#ifdef RS6000COFF_C
2276
#ifdef XCOFF64
2277
    case U64_TOCMAGIC:
2278
    case U803XTOCMAGIC:
2279
#else
2280
    case U802ROMAGIC:
2281
    case U802WRMAGIC:
2282
    case U802TOCMAGIC:
2283
#endif
2284
      {
2285
  int cputype;
2286
2287
  if (xcoff_data (abfd)->cputype != -1)
2288
    cputype = xcoff_data (abfd)->cputype & 0xff;
2289
  else
2290
    {
2291
      /* We did not get a value from the a.out header.  If the
2292
         file has not been stripped, we may be able to get the
2293
         architecture information from the first symbol, if it
2294
         is a .file symbol.  */
2295
      if (obj_raw_syment_count (abfd) == 0)
2296
        cputype = 0;
2297
      else
2298
        {
2299
    bfd_byte *buf;
2300
    struct internal_syment sym;
2301
    bfd_size_type amt = bfd_coff_symesz (abfd);
2302
2303
    if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
2304
      return false;
2305
    buf = _bfd_malloc_and_read (abfd, amt, amt);
2306
    if (buf == NULL)
2307
      return false;
2308
    bfd_coff_swap_sym_in (abfd, buf, & sym);
2309
    if (sym.n_sclass == C_FILE)
2310
      cputype = sym.n_type & 0xff;
2311
    else
2312
      cputype = 0;
2313
    free (buf);
2314
        }
2315
    }
2316
2317
  /* FIXME: We don't handle all cases here.  */
2318
  switch (cputype)
2319
    {
2320
    default:
2321
    case 0:
2322
      arch = bfd_xcoff_architecture (abfd);
2323
      machine = bfd_xcoff_machine (abfd);
2324
      break;
2325
2326
    case 1:
2327
      arch = bfd_arch_powerpc;
2328
      machine = bfd_mach_ppc_601;
2329
      break;
2330
    case 2: /* 64 bit PowerPC */
2331
      arch = bfd_arch_powerpc;
2332
      machine = bfd_mach_ppc_620;
2333
      break;
2334
    case 3:
2335
      arch = bfd_arch_powerpc;
2336
      machine = bfd_mach_ppc;
2337
      break;
2338
    case 4:
2339
      arch = bfd_arch_rs6000;
2340
      machine = bfd_mach_rs6k;
2341
      break;
2342
    }
2343
      }
2344
      break;
2345
#endif
2346
2347
#ifdef SH_ARCH_MAGIC_BIG
2348
    case SH_ARCH_MAGIC_BIG:
2349
    case SH_ARCH_MAGIC_LITTLE:
2350
#ifdef COFF_WITH_PE
2351
    case SH_ARCH_MAGIC_WINCE:
2352
#endif
2353
      arch = bfd_arch_sh;
2354
      break;
2355
#endif
2356
2357
#ifdef MIPS_ARCH_MAGIC_WINCE
2358
    case MIPS_ARCH_MAGIC_WINCE:
2359
      arch = bfd_arch_mips;
2360
      break;
2361
#endif
2362
2363
#ifdef SPARCMAGIC
2364
    case SPARCMAGIC:
2365
#ifdef LYNXCOFFMAGIC
2366
    case LYNXCOFFMAGIC:
2367
#endif
2368
      arch = bfd_arch_sparc;
2369
      break;
2370
#endif
2371
2372
#ifdef TIC30MAGIC
2373
    case TIC30MAGIC:
2374
      arch = bfd_arch_tic30;
2375
      break;
2376
#endif
2377
2378
#ifdef TICOFF0MAGIC
2379
#ifdef TICOFF_TARGET_ARCH
2380
      /* This TI COFF section should be used by all new TI COFF v0 targets.  */
2381
    case TICOFF0MAGIC:
2382
      arch = TICOFF_TARGET_ARCH;
2383
      machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2384
      break;
2385
#endif
2386
#endif
2387
2388
#ifdef TICOFF1MAGIC
2389
      /* This TI COFF section should be used by all new TI COFF v1/2 targets.  */
2390
      /* TI COFF1 and COFF2 use the target_id field to specify which arch.  */
2391
    case TICOFF1MAGIC:
2392
    case TICOFF2MAGIC:
2393
      switch (internal_f->f_target_id)
2394
  {
2395
#ifdef TI_TARGET_ID
2396
  case TI_TARGET_ID:
2397
    arch = TICOFF_TARGET_ARCH;
2398
    machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2399
    break;
2400
#endif
2401
  default:
2402
    arch = bfd_arch_obscure;
2403
    _bfd_error_handler
2404
      (_("unrecognized TI COFF target id '0x%x'"),
2405
       internal_f->f_target_id);
2406
    break;
2407
  }
2408
      break;
2409
#endif
2410
2411
#ifdef MCOREMAGIC
2412
    case MCOREMAGIC:
2413
      arch = bfd_arch_mcore;
2414
      break;
2415
#endif
2416
2417
9.28k
    default:      /* Unreadable input file type.  */
2418
357
      arch = bfd_arch_obscure;
2419
357
      break;
2420
9.64k
    }
2421
2422
9.64k
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
9.64k
  return true;
2424
9.64k
}
pei-mcore.c:coff_set_arch_mach_hook
Line
Count
Source
2162
8.12k
{
2163
8.12k
  unsigned long machine;
2164
8.12k
  enum bfd_architecture arch;
2165
8.12k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
8.12k
  machine = 0;
2169
8.12k
  switch (internal_f->f_magic)
2170
8.12k
    {
2171
#ifdef I386MAGIC
2172
    case I386MAGIC:
2173
    case I386PTXMAGIC:
2174
    case I386AIXMAGIC:    /* Danbury PS/2 AIX C Compiler.  */
2175
    case LYNXCOFFMAGIC:
2176
    case I386_APPLE_MAGIC:
2177
    case I386_FREEBSD_MAGIC:
2178
    case I386_LINUX_MAGIC:
2179
    case I386_NETBSD_MAGIC:
2180
      arch = bfd_arch_i386;
2181
      break;
2182
#endif
2183
#ifdef AMD64MAGIC
2184
    case AMD64MAGIC:
2185
    case AMD64_APPLE_MAGIC:
2186
    case AMD64_FREEBSD_MAGIC:
2187
    case AMD64_LINUX_MAGIC:
2188
    case AMD64_NETBSD_MAGIC:
2189
      arch = bfd_arch_i386;
2190
      machine = bfd_mach_x86_64;
2191
      break;
2192
#endif
2193
#ifdef IA64MAGIC
2194
    case IA64MAGIC:
2195
      arch = bfd_arch_ia64;
2196
      break;
2197
#endif
2198
#ifdef ARMMAGIC
2199
    case ARMMAGIC:
2200
    case ARMPEMAGIC:
2201
    case THUMBPEMAGIC:
2202
      arch = bfd_arch_arm;
2203
      machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION);
2204
      if (machine == bfd_mach_arm_unknown)
2205
  {
2206
    switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK)
2207
      {
2208
      case F_ARM_2:  machine = bfd_mach_arm_2;  break;
2209
      case F_ARM_2a: machine = bfd_mach_arm_2a; break;
2210
      case F_ARM_3:  machine = bfd_mach_arm_3;  break;
2211
      default:
2212
      case F_ARM_3M: machine = bfd_mach_arm_3M; break;
2213
      case F_ARM_4:  machine = bfd_mach_arm_4;  break;
2214
      case F_ARM_4T: machine = bfd_mach_arm_4T; break;
2215
        /* The COFF header does not have enough bits available
2216
     to cover all the different ARM architectures.  So
2217
     we interpret F_ARM_5, the highest flag value to mean
2218
     "the highest ARM architecture known to BFD" which is
2219
     currently the XScale.  */
2220
      case F_ARM_5:  machine = bfd_mach_arm_XScale;  break;
2221
      }
2222
  }
2223
      break;
2224
#endif
2225
#ifdef AARCH64MAGIC
2226
    case AARCH64MAGIC:
2227
      arch = bfd_arch_aarch64;
2228
      machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK;
2229
      break;
2230
#endif
2231
#ifdef LOONGARCH64MAGIC
2232
    case LOONGARCH64MAGIC:
2233
      arch = bfd_arch_loongarch;
2234
      machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK;
2235
      break;
2236
#endif
2237
#ifdef Z80MAGIC
2238
    case Z80MAGIC:
2239
      arch = bfd_arch_z80;
2240
      switch (internal_f->f_flags & F_MACHMASK)
2241
  {
2242
  case bfd_mach_z80strict << 12:
2243
  case bfd_mach_z80 << 12:
2244
  case bfd_mach_z80n << 12:
2245
  case bfd_mach_z80full << 12:
2246
  case bfd_mach_r800 << 12:
2247
  case bfd_mach_gbz80 << 12:
2248
  case bfd_mach_z180 << 12:
2249
  case bfd_mach_ez80_z80 << 12:
2250
  case bfd_mach_ez80_adl << 12:
2251
    machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12;
2252
    break;
2253
  default:
2254
    return false;
2255
  }
2256
      break;
2257
#endif
2258
#ifdef Z8KMAGIC
2259
    case Z8KMAGIC:
2260
      arch = bfd_arch_z8k;
2261
      switch (internal_f->f_flags & F_MACHMASK)
2262
  {
2263
  case F_Z8001:
2264
    machine = bfd_mach_z8001;
2265
    break;
2266
  case F_Z8002:
2267
    machine = bfd_mach_z8002;
2268
    break;
2269
  default:
2270
    return false;
2271
  }
2272
      break;
2273
#endif
2274
2275
#ifdef RS6000COFF_C
2276
#ifdef XCOFF64
2277
    case U64_TOCMAGIC:
2278
    case U803XTOCMAGIC:
2279
#else
2280
    case U802ROMAGIC:
2281
    case U802WRMAGIC:
2282
    case U802TOCMAGIC:
2283
#endif
2284
      {
2285
  int cputype;
2286
2287
  if (xcoff_data (abfd)->cputype != -1)
2288
    cputype = xcoff_data (abfd)->cputype & 0xff;
2289
  else
2290
    {
2291
      /* We did not get a value from the a.out header.  If the
2292
         file has not been stripped, we may be able to get the
2293
         architecture information from the first symbol, if it
2294
         is a .file symbol.  */
2295
      if (obj_raw_syment_count (abfd) == 0)
2296
        cputype = 0;
2297
      else
2298
        {
2299
    bfd_byte *buf;
2300
    struct internal_syment sym;
2301
    bfd_size_type amt = bfd_coff_symesz (abfd);
2302
2303
    if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
2304
      return false;
2305
    buf = _bfd_malloc_and_read (abfd, amt, amt);
2306
    if (buf == NULL)
2307
      return false;
2308
    bfd_coff_swap_sym_in (abfd, buf, & sym);
2309
    if (sym.n_sclass == C_FILE)
2310
      cputype = sym.n_type & 0xff;
2311
    else
2312
      cputype = 0;
2313
    free (buf);
2314
        }
2315
    }
2316
2317
  /* FIXME: We don't handle all cases here.  */
2318
  switch (cputype)
2319
    {
2320
    default:
2321
    case 0:
2322
      arch = bfd_xcoff_architecture (abfd);
2323
      machine = bfd_xcoff_machine (abfd);
2324
      break;
2325
2326
    case 1:
2327
      arch = bfd_arch_powerpc;
2328
      machine = bfd_mach_ppc_601;
2329
      break;
2330
    case 2: /* 64 bit PowerPC */
2331
      arch = bfd_arch_powerpc;
2332
      machine = bfd_mach_ppc_620;
2333
      break;
2334
    case 3:
2335
      arch = bfd_arch_powerpc;
2336
      machine = bfd_mach_ppc;
2337
      break;
2338
    case 4:
2339
      arch = bfd_arch_rs6000;
2340
      machine = bfd_mach_rs6k;
2341
      break;
2342
    }
2343
      }
2344
      break;
2345
#endif
2346
2347
#ifdef SH_ARCH_MAGIC_BIG
2348
    case SH_ARCH_MAGIC_BIG:
2349
    case SH_ARCH_MAGIC_LITTLE:
2350
#ifdef COFF_WITH_PE
2351
    case SH_ARCH_MAGIC_WINCE:
2352
#endif
2353
      arch = bfd_arch_sh;
2354
      break;
2355
#endif
2356
2357
#ifdef MIPS_ARCH_MAGIC_WINCE
2358
    case MIPS_ARCH_MAGIC_WINCE:
2359
      arch = bfd_arch_mips;
2360
      break;
2361
#endif
2362
2363
#ifdef SPARCMAGIC
2364
    case SPARCMAGIC:
2365
#ifdef LYNXCOFFMAGIC
2366
    case LYNXCOFFMAGIC:
2367
#endif
2368
      arch = bfd_arch_sparc;
2369
      break;
2370
#endif
2371
2372
#ifdef TIC30MAGIC
2373
    case TIC30MAGIC:
2374
      arch = bfd_arch_tic30;
2375
      break;
2376
#endif
2377
2378
#ifdef TICOFF0MAGIC
2379
#ifdef TICOFF_TARGET_ARCH
2380
      /* This TI COFF section should be used by all new TI COFF v0 targets.  */
2381
    case TICOFF0MAGIC:
2382
      arch = TICOFF_TARGET_ARCH;
2383
      machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2384
      break;
2385
#endif
2386
#endif
2387
2388
#ifdef TICOFF1MAGIC
2389
      /* This TI COFF section should be used by all new TI COFF v1/2 targets.  */
2390
      /* TI COFF1 and COFF2 use the target_id field to specify which arch.  */
2391
    case TICOFF1MAGIC:
2392
    case TICOFF2MAGIC:
2393
      switch (internal_f->f_target_id)
2394
  {
2395
#ifdef TI_TARGET_ID
2396
  case TI_TARGET_ID:
2397
    arch = TICOFF_TARGET_ARCH;
2398
    machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2399
    break;
2400
#endif
2401
  default:
2402
    arch = bfd_arch_obscure;
2403
    _bfd_error_handler
2404
      (_("unrecognized TI COFF target id '0x%x'"),
2405
       internal_f->f_target_id);
2406
    break;
2407
  }
2408
      break;
2409
#endif
2410
2411
0
#ifdef MCOREMAGIC
2412
8.12k
    case MCOREMAGIC:
2413
8.12k
      arch = bfd_arch_mcore;
2414
8.12k
      break;
2415
0
#endif
2416
2417
0
    default:      /* Unreadable input file type.  */
2418
0
      arch = bfd_arch_obscure;
2419
0
      break;
2420
8.12k
    }
2421
2422
8.12k
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
8.12k
  return true;
2424
8.12k
}
pei-sh.c:coff_set_arch_mach_hook
Line
Count
Source
2162
7.19k
{
2163
7.19k
  unsigned long machine;
2164
7.19k
  enum bfd_architecture arch;
2165
7.19k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
7.19k
  machine = 0;
2169
7.19k
  switch (internal_f->f_magic)
2170
7.19k
    {
2171
#ifdef I386MAGIC
2172
    case I386MAGIC:
2173
    case I386PTXMAGIC:
2174
    case I386AIXMAGIC:    /* Danbury PS/2 AIX C Compiler.  */
2175
    case LYNXCOFFMAGIC:
2176
    case I386_APPLE_MAGIC:
2177
    case I386_FREEBSD_MAGIC:
2178
    case I386_LINUX_MAGIC:
2179
    case I386_NETBSD_MAGIC:
2180
      arch = bfd_arch_i386;
2181
      break;
2182
#endif
2183
#ifdef AMD64MAGIC
2184
    case AMD64MAGIC:
2185
    case AMD64_APPLE_MAGIC:
2186
    case AMD64_FREEBSD_MAGIC:
2187
    case AMD64_LINUX_MAGIC:
2188
    case AMD64_NETBSD_MAGIC:
2189
      arch = bfd_arch_i386;
2190
      machine = bfd_mach_x86_64;
2191
      break;
2192
#endif
2193
#ifdef IA64MAGIC
2194
    case IA64MAGIC:
2195
      arch = bfd_arch_ia64;
2196
      break;
2197
#endif
2198
#ifdef ARMMAGIC
2199
    case ARMMAGIC:
2200
    case ARMPEMAGIC:
2201
    case THUMBPEMAGIC:
2202
      arch = bfd_arch_arm;
2203
      machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION);
2204
      if (machine == bfd_mach_arm_unknown)
2205
  {
2206
    switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK)
2207
      {
2208
      case F_ARM_2:  machine = bfd_mach_arm_2;  break;
2209
      case F_ARM_2a: machine = bfd_mach_arm_2a; break;
2210
      case F_ARM_3:  machine = bfd_mach_arm_3;  break;
2211
      default:
2212
      case F_ARM_3M: machine = bfd_mach_arm_3M; break;
2213
      case F_ARM_4:  machine = bfd_mach_arm_4;  break;
2214
      case F_ARM_4T: machine = bfd_mach_arm_4T; break;
2215
        /* The COFF header does not have enough bits available
2216
     to cover all the different ARM architectures.  So
2217
     we interpret F_ARM_5, the highest flag value to mean
2218
     "the highest ARM architecture known to BFD" which is
2219
     currently the XScale.  */
2220
      case F_ARM_5:  machine = bfd_mach_arm_XScale;  break;
2221
      }
2222
  }
2223
      break;
2224
#endif
2225
#ifdef AARCH64MAGIC
2226
    case AARCH64MAGIC:
2227
      arch = bfd_arch_aarch64;
2228
      machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK;
2229
      break;
2230
#endif
2231
#ifdef LOONGARCH64MAGIC
2232
    case LOONGARCH64MAGIC:
2233
      arch = bfd_arch_loongarch;
2234
      machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK;
2235
      break;
2236
#endif
2237
#ifdef Z80MAGIC
2238
    case Z80MAGIC:
2239
      arch = bfd_arch_z80;
2240
      switch (internal_f->f_flags & F_MACHMASK)
2241
  {
2242
  case bfd_mach_z80strict << 12:
2243
  case bfd_mach_z80 << 12:
2244
  case bfd_mach_z80n << 12:
2245
  case bfd_mach_z80full << 12:
2246
  case bfd_mach_r800 << 12:
2247
  case bfd_mach_gbz80 << 12:
2248
  case bfd_mach_z180 << 12:
2249
  case bfd_mach_ez80_z80 << 12:
2250
  case bfd_mach_ez80_adl << 12:
2251
    machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12;
2252
    break;
2253
  default:
2254
    return false;
2255
  }
2256
      break;
2257
#endif
2258
#ifdef Z8KMAGIC
2259
    case Z8KMAGIC:
2260
      arch = bfd_arch_z8k;
2261
      switch (internal_f->f_flags & F_MACHMASK)
2262
  {
2263
  case F_Z8001:
2264
    machine = bfd_mach_z8001;
2265
    break;
2266
  case F_Z8002:
2267
    machine = bfd_mach_z8002;
2268
    break;
2269
  default:
2270
    return false;
2271
  }
2272
      break;
2273
#endif
2274
2275
#ifdef RS6000COFF_C
2276
#ifdef XCOFF64
2277
    case U64_TOCMAGIC:
2278
    case U803XTOCMAGIC:
2279
#else
2280
    case U802ROMAGIC:
2281
    case U802WRMAGIC:
2282
    case U802TOCMAGIC:
2283
#endif
2284
      {
2285
  int cputype;
2286
2287
  if (xcoff_data (abfd)->cputype != -1)
2288
    cputype = xcoff_data (abfd)->cputype & 0xff;
2289
  else
2290
    {
2291
      /* We did not get a value from the a.out header.  If the
2292
         file has not been stripped, we may be able to get the
2293
         architecture information from the first symbol, if it
2294
         is a .file symbol.  */
2295
      if (obj_raw_syment_count (abfd) == 0)
2296
        cputype = 0;
2297
      else
2298
        {
2299
    bfd_byte *buf;
2300
    struct internal_syment sym;
2301
    bfd_size_type amt = bfd_coff_symesz (abfd);
2302
2303
    if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
2304
      return false;
2305
    buf = _bfd_malloc_and_read (abfd, amt, amt);
2306
    if (buf == NULL)
2307
      return false;
2308
    bfd_coff_swap_sym_in (abfd, buf, & sym);
2309
    if (sym.n_sclass == C_FILE)
2310
      cputype = sym.n_type & 0xff;
2311
    else
2312
      cputype = 0;
2313
    free (buf);
2314
        }
2315
    }
2316
2317
  /* FIXME: We don't handle all cases here.  */
2318
  switch (cputype)
2319
    {
2320
    default:
2321
    case 0:
2322
      arch = bfd_xcoff_architecture (abfd);
2323
      machine = bfd_xcoff_machine (abfd);
2324
      break;
2325
2326
    case 1:
2327
      arch = bfd_arch_powerpc;
2328
      machine = bfd_mach_ppc_601;
2329
      break;
2330
    case 2: /* 64 bit PowerPC */
2331
      arch = bfd_arch_powerpc;
2332
      machine = bfd_mach_ppc_620;
2333
      break;
2334
    case 3:
2335
      arch = bfd_arch_powerpc;
2336
      machine = bfd_mach_ppc;
2337
      break;
2338
    case 4:
2339
      arch = bfd_arch_rs6000;
2340
      machine = bfd_mach_rs6k;
2341
      break;
2342
    }
2343
      }
2344
      break;
2345
#endif
2346
2347
0
#ifdef SH_ARCH_MAGIC_BIG
2348
2.71k
    case SH_ARCH_MAGIC_BIG:
2349
2.76k
    case SH_ARCH_MAGIC_LITTLE:
2350
2.76k
#ifdef COFF_WITH_PE
2351
7.19k
    case SH_ARCH_MAGIC_WINCE:
2352
7.19k
#endif
2353
7.19k
      arch = bfd_arch_sh;
2354
7.19k
      break;
2355
0
#endif
2356
2357
#ifdef MIPS_ARCH_MAGIC_WINCE
2358
    case MIPS_ARCH_MAGIC_WINCE:
2359
      arch = bfd_arch_mips;
2360
      break;
2361
#endif
2362
2363
#ifdef SPARCMAGIC
2364
    case SPARCMAGIC:
2365
#ifdef LYNXCOFFMAGIC
2366
    case LYNXCOFFMAGIC:
2367
#endif
2368
      arch = bfd_arch_sparc;
2369
      break;
2370
#endif
2371
2372
#ifdef TIC30MAGIC
2373
    case TIC30MAGIC:
2374
      arch = bfd_arch_tic30;
2375
      break;
2376
#endif
2377
2378
#ifdef TICOFF0MAGIC
2379
#ifdef TICOFF_TARGET_ARCH
2380
      /* This TI COFF section should be used by all new TI COFF v0 targets.  */
2381
    case TICOFF0MAGIC:
2382
      arch = TICOFF_TARGET_ARCH;
2383
      machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2384
      break;
2385
#endif
2386
#endif
2387
2388
#ifdef TICOFF1MAGIC
2389
      /* This TI COFF section should be used by all new TI COFF v1/2 targets.  */
2390
      /* TI COFF1 and COFF2 use the target_id field to specify which arch.  */
2391
    case TICOFF1MAGIC:
2392
    case TICOFF2MAGIC:
2393
      switch (internal_f->f_target_id)
2394
  {
2395
#ifdef TI_TARGET_ID
2396
  case TI_TARGET_ID:
2397
    arch = TICOFF_TARGET_ARCH;
2398
    machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2399
    break;
2400
#endif
2401
  default:
2402
    arch = bfd_arch_obscure;
2403
    _bfd_error_handler
2404
      (_("unrecognized TI COFF target id '0x%x'"),
2405
       internal_f->f_target_id);
2406
    break;
2407
  }
2408
      break;
2409
#endif
2410
2411
#ifdef MCOREMAGIC
2412
    case MCOREMAGIC:
2413
      arch = bfd_arch_mcore;
2414
      break;
2415
#endif
2416
2417
0
    default:      /* Unreadable input file type.  */
2418
0
      arch = bfd_arch_obscure;
2419
0
      break;
2420
7.19k
    }
2421
2422
7.19k
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
7.19k
  return true;
2424
7.19k
}
2425
2426
static bool
2427
symname_in_debug_hook (bfd *abfd ATTRIBUTE_UNUSED,
2428
           struct internal_syment *sym ATTRIBUTE_UNUSED)
2429
557k
{
2430
#ifdef SYMNAME_IN_DEBUG
2431
160k
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
  return false;
2434
#endif
2435
557k
}
pei-i386.c:symname_in_debug_hook
Line
Count
Source
2429
10.1k
{
2430
#ifdef SYMNAME_IN_DEBUG
2431
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
10.1k
  return false;
2434
10.1k
#endif
2435
10.1k
}
pe-x86_64.c:symname_in_debug_hook
Line
Count
Source
2429
13.9k
{
2430
#ifdef SYMNAME_IN_DEBUG
2431
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
13.9k
  return false;
2434
13.9k
#endif
2435
13.9k
}
pei-x86_64.c:symname_in_debug_hook
Line
Count
Source
2429
12.2k
{
2430
#ifdef SYMNAME_IN_DEBUG
2431
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
12.2k
  return false;
2434
12.2k
#endif
2435
12.2k
}
coff-x86_64.c:symname_in_debug_hook
Line
Count
Source
2429
9.47k
{
2430
#ifdef SYMNAME_IN_DEBUG
2431
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
9.47k
  return false;
2434
9.47k
#endif
2435
9.47k
}
coff64-rs6000.c:symname_in_debug_hook
Line
Count
Source
2429
91.2k
{
2430
91.2k
#ifdef SYMNAME_IN_DEBUG
2431
91.2k
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
  return false;
2434
#endif
2435
91.2k
}
pe-aarch64.c:symname_in_debug_hook
Line
Count
Source
2429
29.9k
{
2430
#ifdef SYMNAME_IN_DEBUG
2431
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
29.9k
  return false;
2434
29.9k
#endif
2435
29.9k
}
pei-aarch64.c:symname_in_debug_hook
Line
Count
Source
2429
22.1k
{
2430
#ifdef SYMNAME_IN_DEBUG
2431
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
22.1k
  return false;
2434
22.1k
#endif
2435
22.1k
}
pei-ia64.c:symname_in_debug_hook
Line
Count
Source
2429
20.0k
{
2430
#ifdef SYMNAME_IN_DEBUG
2431
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
20.0k
  return false;
2434
20.0k
#endif
2435
20.0k
}
pei-loongarch64.c:symname_in_debug_hook
Line
Count
Source
2429
23.7k
{
2430
#ifdef SYMNAME_IN_DEBUG
2431
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
23.7k
  return false;
2434
23.7k
#endif
2435
23.7k
}
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
2429
69.3k
{
2430
69.3k
#ifdef SYMNAME_IN_DEBUG
2431
69.3k
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
  return false;
2434
#endif
2435
69.3k
}
coff-sh.c:symname_in_debug_hook
Line
Count
Source
2429
20.5k
{
2430
#ifdef SYMNAME_IN_DEBUG
2431
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
20.5k
  return false;
2434
20.5k
#endif
2435
20.5k
}
Unexecuted instantiation: coff-stgo32.c:symname_in_debug_hook
coff-tic30.c:symname_in_debug_hook
Line
Count
Source
2429
15.3k
{
2430
#ifdef SYMNAME_IN_DEBUG
2431
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
15.3k
  return false;
2434
15.3k
#endif
2435
15.3k
}
Unexecuted instantiation: coff-tic4x.c:symname_in_debug_hook
coff-tic54x.c:symname_in_debug_hook
Line
Count
Source
2429
33.0k
{
2430
#ifdef SYMNAME_IN_DEBUG
2431
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
33.0k
  return false;
2434
33.0k
#endif
2435
33.0k
}
coff-z80.c:symname_in_debug_hook
Line
Count
Source
2429
8.55k
{
2430
#ifdef SYMNAME_IN_DEBUG
2431
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
8.55k
  return false;
2434
8.55k
#endif
2435
8.55k
}
coff-z8k.c:symname_in_debug_hook
Line
Count
Source
2429
39.4k
{
2430
#ifdef SYMNAME_IN_DEBUG
2431
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
39.4k
  return false;
2434
39.4k
#endif
2435
39.4k
}
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
2429
40.6k
{
2430
#ifdef SYMNAME_IN_DEBUG
2431
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
40.6k
  return false;
2434
40.6k
#endif
2435
40.6k
}
pe-mcore.c:symname_in_debug_hook
Line
Count
Source
2429
31.9k
{
2430
#ifdef SYMNAME_IN_DEBUG
2431
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
31.9k
  return false;
2434
31.9k
#endif
2435
31.9k
}
pe-sh.c:symname_in_debug_hook
Line
Count
Source
2429
13.7k
{
2430
#ifdef SYMNAME_IN_DEBUG
2431
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
13.7k
  return false;
2434
13.7k
#endif
2435
13.7k
}
pei-arm-wince.c:symname_in_debug_hook
Line
Count
Source
2429
11.4k
{
2430
#ifdef SYMNAME_IN_DEBUG
2431
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
11.4k
  return false;
2434
11.4k
#endif
2435
11.4k
}
pei-arm.c:symname_in_debug_hook
Line
Count
Source
2429
13.2k
{
2430
#ifdef SYMNAME_IN_DEBUG
2431
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
13.2k
  return false;
2434
13.2k
#endif
2435
13.2k
}
pei-mcore.c:symname_in_debug_hook
Line
Count
Source
2429
8.88k
{
2430
#ifdef SYMNAME_IN_DEBUG
2431
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
8.88k
  return false;
2434
8.88k
#endif
2435
8.88k
}
pei-sh.c:symname_in_debug_hook
Line
Count
Source
2429
17.9k
{
2430
#ifdef SYMNAME_IN_DEBUG
2431
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
17.9k
  return false;
2434
17.9k
#endif
2435
17.9k
}
2436
2437
#ifdef RS6000COFF_C
2438
2439
#ifdef XCOFF64
2440
#define FORCE_SYMNAMES_IN_STRINGS
2441
#endif
2442
2443
/* Handle the csect auxent of a C_EXT, C_AIX_WEAKEXT or C_HIDEXT symbol.  */
2444
2445
static bool
2446
coff_pointerize_aux_hook (bfd *abfd ATTRIBUTE_UNUSED,
2447
        combined_entry_type *table_base,
2448
        combined_entry_type *symbol,
2449
        unsigned int indaux,
2450
        combined_entry_type *aux)
2451
1.50M
{
2452
1.50M
  BFD_ASSERT (symbol->is_sym);
2453
1.50M
  int n_sclass = symbol->u.syment.n_sclass;
2454
2455
1.50M
  if (CSECT_SYM_P (n_sclass)
2456
1.50M
      && indaux + 1 == symbol->u.syment.n_numaux)
2457
4.75k
    {
2458
4.75k
      BFD_ASSERT (! aux->is_sym);
2459
4.75k
      if (SMTYP_SMTYP (aux->u.auxent.x_csect.x_smtyp) == XTY_LD
2460
4.75k
    && aux->u.auxent.x_csect.x_scnlen.u64 < obj_raw_syment_count (abfd))
2461
2.18k
  {
2462
2.18k
    aux->u.auxent.x_csect.x_scnlen.p =
2463
2.18k
      table_base + aux->u.auxent.x_csect.x_scnlen.u64;
2464
2.18k
    aux->fix_scnlen = 1;
2465
2.18k
  }
2466
2467
      /* Return TRUE to indicate that the caller should not do any
2468
   further work on this auxent.  */
2469
4.75k
      return true;
2470
4.75k
    }
2471
2472
  /* Return FALSE to indicate that this auxent should be handled by
2473
     the caller.  */
2474
1.49M
  return false;
2475
1.50M
}
coff64-rs6000.c:coff_pointerize_aux_hook
Line
Count
Source
2451
633k
{
2452
633k
  BFD_ASSERT (symbol->is_sym);
2453
633k
  int n_sclass = symbol->u.syment.n_sclass;
2454
2455
633k
  if (CSECT_SYM_P (n_sclass)
2456
633k
      && indaux + 1 == symbol->u.syment.n_numaux)
2457
1.95k
    {
2458
1.95k
      BFD_ASSERT (! aux->is_sym);
2459
1.95k
      if (SMTYP_SMTYP (aux->u.auxent.x_csect.x_smtyp) == XTY_LD
2460
1.95k
    && aux->u.auxent.x_csect.x_scnlen.u64 < obj_raw_syment_count (abfd))
2461
1
  {
2462
1
    aux->u.auxent.x_csect.x_scnlen.p =
2463
1
      table_base + aux->u.auxent.x_csect.x_scnlen.u64;
2464
1
    aux->fix_scnlen = 1;
2465
1
  }
2466
2467
      /* Return TRUE to indicate that the caller should not do any
2468
   further work on this auxent.  */
2469
1.95k
      return true;
2470
1.95k
    }
2471
2472
  /* Return FALSE to indicate that this auxent should be handled by
2473
     the caller.  */
2474
631k
  return false;
2475
633k
}
coff-rs6000.c:coff_pointerize_aux_hook
Line
Count
Source
2451
870k
{
2452
870k
  BFD_ASSERT (symbol->is_sym);
2453
870k
  int n_sclass = symbol->u.syment.n_sclass;
2454
2455
870k
  if (CSECT_SYM_P (n_sclass)
2456
870k
      && indaux + 1 == symbol->u.syment.n_numaux)
2457
2.80k
    {
2458
2.80k
      BFD_ASSERT (! aux->is_sym);
2459
2.80k
      if (SMTYP_SMTYP (aux->u.auxent.x_csect.x_smtyp) == XTY_LD
2460
2.80k
    && aux->u.auxent.x_csect.x_scnlen.u64 < obj_raw_syment_count (abfd))
2461
2.18k
  {
2462
2.18k
    aux->u.auxent.x_csect.x_scnlen.p =
2463
2.18k
      table_base + aux->u.auxent.x_csect.x_scnlen.u64;
2464
2.18k
    aux->fix_scnlen = 1;
2465
2.18k
  }
2466
2467
      /* Return TRUE to indicate that the caller should not do any
2468
   further work on this auxent.  */
2469
2.80k
      return true;
2470
2.80k
    }
2471
2472
  /* Return FALSE to indicate that this auxent should be handled by
2473
     the caller.  */
2474
867k
  return false;
2475
870k
}
2476
2477
#else
2478
#define coff_pointerize_aux_hook 0
2479
#endif /* ! RS6000COFF_C */
2480
2481
/* Print an aux entry.  This returns TRUE if it has printed it.  */
2482
2483
static bool
2484
coff_print_aux (bfd *abfd ATTRIBUTE_UNUSED,
2485
    FILE *file ATTRIBUTE_UNUSED,
2486
    combined_entry_type *table_base ATTRIBUTE_UNUSED,
2487
    combined_entry_type *symbol ATTRIBUTE_UNUSED,
2488
    combined_entry_type *aux ATTRIBUTE_UNUSED,
2489
    unsigned int indaux ATTRIBUTE_UNUSED)
2490
0
{
2491
0
  BFD_ASSERT (symbol->is_sym);
2492
0
  BFD_ASSERT (! aux->is_sym);
2493
#ifdef RS6000COFF_C
2494
0
  if (CSECT_SYM_P (symbol->u.syment.n_sclass)
2495
0
      && indaux + 1 == symbol->u.syment.n_numaux)
2496
0
    {
2497
      /* This is a csect entry.  */
2498
0
      fprintf (file, "AUX ");
2499
0
      if (SMTYP_SMTYP (aux->u.auxent.x_csect.x_smtyp) != XTY_LD)
2500
0
  {
2501
0
    BFD_ASSERT (! aux->fix_scnlen);
2502
0
    fprintf (file, "val %5" PRIu64,
2503
0
       aux->u.auxent.x_csect.x_scnlen.u64);
2504
0
  }
2505
0
      else
2506
0
  {
2507
0
    fprintf (file, "indx ");
2508
0
    if (! aux->fix_scnlen)
2509
0
      fprintf (file, "%4" PRIu64,
2510
0
         aux->u.auxent.x_csect.x_scnlen.u64);
2511
0
    else
2512
0
      fprintf (file, "%4ld",
2513
0
         (long) (aux->u.auxent.x_csect.x_scnlen.p - table_base));
2514
0
  }
2515
0
      fprintf (file,
2516
0
         " prmhsh %u snhsh %u typ %d algn %d clss %u stb %u snstb %u",
2517
0
         aux->u.auxent.x_csect.x_parmhash,
2518
0
         (unsigned int) aux->u.auxent.x_csect.x_snhash,
2519
0
         SMTYP_SMTYP (aux->u.auxent.x_csect.x_smtyp),
2520
0
         SMTYP_ALIGN (aux->u.auxent.x_csect.x_smtyp),
2521
0
         (unsigned int) aux->u.auxent.x_csect.x_smclas,
2522
0
         aux->u.auxent.x_csect.x_stab,
2523
0
         (unsigned int) aux->u.auxent.x_csect.x_snstab);
2524
0
      return true;
2525
0
    }
2526
0
#endif
2527
2528
  /* Return FALSE to indicate that no special action was taken.  */
2529
0
  return false;
2530
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: pe-aarch64.c:coff_print_aux
Unexecuted instantiation: pei-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
2531
2532
/*
2533
SUBSUBSECTION
2534
  Writing relocations
2535
2536
  To write relocations, the back end steps though the
2537
  canonical relocation table and create an
2538
  @code{internal_reloc}. The symbol index to use is removed from
2539
  the @code{offset} field in the symbol table supplied.  The
2540
  address comes directly from the sum of the section base
2541
  address and the relocation offset; the type is dug directly
2542
  from the howto field.  Then the @code{internal_reloc} is
2543
  swapped into the shape of an @code{external_reloc} and written
2544
  out to disk.
2545
2546
*/
2547
2548
#ifdef TARG_AUX
2549
2550
2551
/* AUX's ld wants relocations to be sorted.  */
2552
static int
2553
compare_arelent_ptr (const void * x, const void * y)
2554
{
2555
  const arelent **a = (const arelent **) x;
2556
  const arelent **b = (const arelent **) y;
2557
  bfd_size_type aadr = (*a)->address;
2558
  bfd_size_type badr = (*b)->address;
2559
2560
  return (aadr < badr ? -1 : badr < aadr ? 1 : 0);
2561
}
2562
2563
#endif /* TARG_AUX */
2564
2565
static bool
2566
coff_write_relocs (bfd * abfd, int first_undef)
2567
0
{
2568
0
  asection *s;
2569
2570
0
  for (s = abfd->sections; s != NULL; s = s->next)
2571
0
    {
2572
0
      unsigned int i;
2573
0
      struct external_reloc dst;
2574
0
      arelent **p;
2575
2576
0
#ifndef TARG_AUX
2577
0
      p = s->orelocation;
2578
#else
2579
      {
2580
  /* Sort relocations before we write them out.  */
2581
  bfd_size_type amt;
2582
2583
  amt = s->reloc_count;
2584
  amt *= sizeof (arelent *);
2585
  p = bfd_malloc (amt);
2586
  if (p == NULL)
2587
    {
2588
      if (s->reloc_count > 0)
2589
        return false;
2590
    }
2591
  else
2592
    {
2593
      memcpy (p, s->orelocation, (size_t) amt);
2594
      qsort (p, s->reloc_count, sizeof (arelent *), compare_arelent_ptr);
2595
    }
2596
      }
2597
#endif
2598
2599
0
      if (bfd_seek (abfd, s->rel_filepos, SEEK_SET) != 0)
2600
0
  return false;
2601
2602
#ifdef COFF_WITH_EXTENDED_RELOC_COUNTER
2603
0
      if ((obj_pe (abfd) || obj_go32 (abfd)) && s->reloc_count >= 0xffff)
2604
0
  {
2605
    /* Encode real count here as first reloc.  */
2606
0
    struct internal_reloc n;
2607
2608
0
    memset (& n, 0, sizeof (n));
2609
    /* Add one to count *this* reloc (grr).  */
2610
0
    n.r_vaddr = s->reloc_count + 1;
2611
0
    coff_swap_reloc_out (abfd, &n, &dst);
2612
0
    if (bfd_write (&dst, bfd_coff_relsz (abfd), abfd)
2613
0
        != bfd_coff_relsz (abfd))
2614
0
      return false;
2615
0
  }
2616
0
#endif
2617
2618
0
      for (i = 0; i < s->reloc_count; i++)
2619
0
  {
2620
0
    struct internal_reloc n;
2621
0
    arelent *q = p[i];
2622
2623
0
    memset (& n, 0, sizeof (n));
2624
2625
    /* Now we've renumbered the symbols we know where the
2626
       undefined symbols live in the table.  Check the reloc
2627
       entries for symbols who's output bfd isn't the right one.
2628
       This is because the symbol was undefined (which means
2629
       that all the pointers are never made to point to the same
2630
       place). This is a bad thing,'cause the symbols attached
2631
       to the output bfd are indexed, so that the relocation
2632
       entries know which symbol index they point to.  So we
2633
       have to look up the output symbol here.  */
2634
2635
0
    if (q->sym_ptr_ptr[0] != NULL && q->sym_ptr_ptr[0]->the_bfd != abfd)
2636
0
      {
2637
0
        int j;
2638
0
        const char *sname = q->sym_ptr_ptr[0]->name;
2639
0
        asymbol **outsyms = abfd->outsymbols;
2640
2641
0
        for (j = first_undef; outsyms[j]; j++)
2642
0
    {
2643
0
      const char *intable = outsyms[j]->name;
2644
2645
0
      if (strcmp (intable, sname) == 0)
2646
0
        {
2647
          /* Got a hit, so repoint the reloc.  */
2648
0
          q->sym_ptr_ptr = outsyms + j;
2649
0
          break;
2650
0
        }
2651
0
    }
2652
0
      }
2653
2654
0
    n.r_vaddr = q->address + s->vma;
2655
2656
#ifdef R_IHCONST
2657
    /* The 29k const/consth reloc pair is a real kludge.  The consth
2658
       part doesn't have a symbol; it has an offset.  So rebuilt
2659
       that here.  */
2660
    if (q->howto->type == R_IHCONST)
2661
      n.r_symndx = q->addend;
2662
    else
2663
#endif
2664
0
      if (q->sym_ptr_ptr && q->sym_ptr_ptr[0] != NULL)
2665
0
        {
2666
#ifdef SECTION_RELATIVE_ABSOLUTE_SYMBOL_P
2667
0
    if (SECTION_RELATIVE_ABSOLUTE_SYMBOL_P (q, s))
2668
#else
2669
0
    if ((*q->sym_ptr_ptr)->section == bfd_abs_section_ptr
2670
0
        && ((*q->sym_ptr_ptr)->flags & BSF_SECTION_SYM) != 0)
2671
0
#endif
2672
      /* This is a relocation relative to the absolute symbol.  */
2673
0
      n.r_symndx = -1;
2674
0
    else
2675
0
      {
2676
0
        n.r_symndx = get_index ((*(q->sym_ptr_ptr)));
2677
        /* Check to see if the symbol reloc points to a symbol
2678
           we don't have in our symbol table.  */
2679
0
        if (n.r_symndx > obj_conv_table_size (abfd))
2680
0
          {
2681
0
      bfd_set_error (bfd_error_bad_value);
2682
      /* xgettext:c-format */
2683
0
      _bfd_error_handler (_("%pB: reloc against a non-existent"
2684
0
                " symbol index: %ld"),
2685
0
              abfd, n.r_symndx);
2686
0
      return false;
2687
0
          }
2688
0
      }
2689
0
        }
2690
2691
#ifdef SWAP_OUT_RELOC_OFFSET
2692
0
    n.r_offset = q->addend;
2693
0
#endif
2694
2695
#ifdef SELECT_RELOC
2696
    /* Work out reloc type from what is required.  */
2697
0
    if (q->howto)
2698
0
      SELECT_RELOC (n, q->howto);
2699
#else
2700
0
    if (q->howto)
2701
0
      n.r_type = q->howto->type;
2702
#endif
2703
0
    coff_swap_reloc_out (abfd, &n, &dst);
2704
2705
0
    if (bfd_write (&dst, bfd_coff_relsz (abfd), abfd)
2706
0
        != bfd_coff_relsz (abfd))
2707
0
      return false;
2708
0
  }
2709
2710
#ifdef TARG_AUX
2711
      free (p);
2712
#endif
2713
0
    }
2714
2715
0
  return true;
2716
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: pe-aarch64.c:coff_write_relocs
Unexecuted instantiation: pei-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
2717
2718
/* Set flags and magic number of a coff file from architecture and machine
2719
   type.  Result is TRUE if we can represent the arch&type, FALSE if not.  */
2720
2721
static bool
2722
coff_set_flags (bfd * abfd,
2723
    unsigned int *magicp ATTRIBUTE_UNUSED,
2724
    unsigned short *flagsp ATTRIBUTE_UNUSED)
2725
0
{
2726
0
  switch (bfd_get_arch (abfd))
2727
0
    {
2728
#ifdef Z80MAGIC
2729
0
    case bfd_arch_z80:
2730
0
      *magicp = Z80MAGIC;
2731
0
      switch (bfd_get_mach (abfd))
2732
0
  {
2733
0
  case bfd_mach_z80strict:
2734
0
  case bfd_mach_z80:
2735
0
  case bfd_mach_z80n:
2736
0
  case bfd_mach_z80full:
2737
0
  case bfd_mach_r800:
2738
0
  case bfd_mach_gbz80:
2739
0
  case bfd_mach_z180:
2740
0
  case bfd_mach_ez80_z80:
2741
0
  case bfd_mach_ez80_adl:
2742
0
    *flagsp = bfd_get_mach (abfd) << 12;
2743
0
    break;
2744
0
  default:
2745
0
    return false;
2746
0
  }
2747
0
      return true;
2748
0
#endif
2749
2750
#ifdef Z8KMAGIC
2751
0
    case bfd_arch_z8k:
2752
0
      *magicp = Z8KMAGIC;
2753
2754
0
      switch (bfd_get_mach (abfd))
2755
0
  {
2756
0
  case bfd_mach_z8001: *flagsp = F_Z8001; break;
2757
0
  case bfd_mach_z8002: *flagsp = F_Z8002; break;
2758
0
  default:       return false;
2759
0
  }
2760
0
      return true;
2761
0
#endif
2762
2763
#ifdef TIC30MAGIC
2764
0
    case bfd_arch_tic30:
2765
0
      *magicp = TIC30MAGIC;
2766
0
      return true;
2767
0
#endif
2768
2769
#ifdef TICOFF_DEFAULT_MAGIC
2770
0
    case TICOFF_TARGET_ARCH:
2771
      /* If there's no indication of which version we want, use the default.  */
2772
0
      if (!abfd->xvec )
2773
0
  *magicp = TICOFF_DEFAULT_MAGIC;
2774
0
      else
2775
0
  {
2776
    /* We may want to output in a different COFF version.  */
2777
0
    switch (abfd->xvec->name[4])
2778
0
      {
2779
0
      case '0':
2780
0
        *magicp = TICOFF0MAGIC;
2781
0
        break;
2782
0
      case '1':
2783
0
        *magicp = TICOFF1MAGIC;
2784
0
        break;
2785
0
      case '2':
2786
0
        *magicp = TICOFF2MAGIC;
2787
0
        break;
2788
0
      default:
2789
0
        return false;
2790
0
      }
2791
0
  }
2792
0
      TICOFF_TARGET_MACHINE_SET (flagsp, bfd_get_mach (abfd));
2793
0
      return true;
2794
0
#endif
2795
2796
#ifdef AARCH64MAGIC
2797
0
    case bfd_arch_aarch64:
2798
0
      * magicp = AARCH64MAGIC;
2799
0
      return true;
2800
0
#endif
2801
2802
#ifdef LOONGARCH64MAGIC
2803
0
    case bfd_arch_loongarch:
2804
0
      * magicp = LOONGARCH64MAGIC;
2805
0
      return true;
2806
0
#endif
2807
2808
#ifdef ARMMAGIC
2809
0
    case bfd_arch_arm:
2810
#ifdef ARM_WINCE
2811
      * magicp = ARMPEMAGIC;
2812
#else
2813
0
      * magicp = ARMMAGIC;
2814
0
#endif
2815
0
      * flagsp = 0;
2816
0
      if (APCS_SET (abfd))
2817
0
  {
2818
0
    if (APCS_26_FLAG (abfd))
2819
0
      * flagsp |= F_APCS26;
2820
2821
0
    if (APCS_FLOAT_FLAG (abfd))
2822
0
      * flagsp |= F_APCS_FLOAT;
2823
2824
0
    if (PIC_FLAG (abfd))
2825
0
      * flagsp |= F_PIC;
2826
0
  }
2827
0
      if (INTERWORK_SET (abfd) && INTERWORK_FLAG (abfd))
2828
0
  * flagsp |= F_INTERWORK;
2829
0
      switch (bfd_get_mach (abfd))
2830
0
  {
2831
0
  case bfd_mach_arm_2:  * flagsp |= F_ARM_2;  break;
2832
0
  case bfd_mach_arm_2a: * flagsp |= F_ARM_2a; break;
2833
0
  case bfd_mach_arm_3:  * flagsp |= F_ARM_3;  break;
2834
0
  case bfd_mach_arm_3M: * flagsp |= F_ARM_3M; break;
2835
0
  case bfd_mach_arm_4:  * flagsp |= F_ARM_4;  break;
2836
0
  case bfd_mach_arm_4T: * flagsp |= F_ARM_4T; break;
2837
0
  case bfd_mach_arm_5:  * flagsp |= F_ARM_5;  break;
2838
    /* FIXME: we do not have F_ARM vaues greater than F_ARM_5.
2839
       See also the comment in coff_set_arch_mach_hook().  */
2840
0
  case bfd_mach_arm_5T: * flagsp |= F_ARM_5;  break;
2841
0
  case bfd_mach_arm_5TE: * flagsp |= F_ARM_5; break;
2842
0
  case bfd_mach_arm_XScale: * flagsp |= F_ARM_5; break;
2843
0
  }
2844
0
      return true;
2845
0
#endif
2846
2847
#if defined(I386MAGIC) || defined(AMD64MAGIC)
2848
0
    case bfd_arch_i386:
2849
#if defined(I386MAGIC)
2850
0
      *magicp = I386MAGIC;
2851
#endif
2852
#if defined LYNXOS
2853
      /* Just overwrite the usual value if we're doing Lynx.  */
2854
0
      *magicp = LYNXCOFFMAGIC;
2855
#endif
2856
#if defined AMD64MAGIC
2857
0
      *magicp = AMD64MAGIC;
2858
#endif
2859
0
      return true;
2860
0
#endif
2861
2862
#ifdef IA64MAGIC
2863
0
    case bfd_arch_ia64:
2864
0
      *magicp = IA64MAGIC;
2865
0
      return true;
2866
0
#endif
2867
2868
#ifdef SH_ARCH_MAGIC_BIG
2869
0
    case bfd_arch_sh:
2870
#ifdef COFF_IMAGE_WITH_PE
2871
0
      *magicp = SH_ARCH_MAGIC_WINCE;
2872
#else
2873
0
      if (bfd_big_endian (abfd))
2874
0
  *magicp = SH_ARCH_MAGIC_BIG;
2875
0
      else
2876
0
  *magicp = SH_ARCH_MAGIC_LITTLE;
2877
#endif
2878
0
      return true;
2879
0
#endif
2880
2881
#ifdef MIPS_ARCH_MAGIC_WINCE
2882
    case bfd_arch_mips:
2883
      *magicp = MIPS_ARCH_MAGIC_WINCE;
2884
      return true;
2885
#endif
2886
2887
#ifdef SPARCMAGIC
2888
    case bfd_arch_sparc:
2889
      *magicp = SPARCMAGIC;
2890
#ifdef LYNXOS
2891
      /* Just overwrite the usual value if we're doing Lynx.  */
2892
      *magicp = LYNXCOFFMAGIC;
2893
#endif
2894
      return true;
2895
#endif
2896
2897
#ifdef RS6000COFF_C
2898
0
    case bfd_arch_rs6000:
2899
0
    case bfd_arch_powerpc:
2900
0
      BFD_ASSERT (bfd_get_flavour (abfd) == bfd_target_xcoff_flavour);
2901
0
      *magicp = bfd_xcoff_magic_number (abfd);
2902
0
      return true;
2903
0
#endif
2904
2905
#ifdef MCOREMAGIC
2906
0
    case bfd_arch_mcore:
2907
0
      * magicp = MCOREMAGIC;
2908
0
      return true;
2909
0
#endif
2910
2911
0
    default:      /* Unknown architecture.  */
2912
0
      break;
2913
0
    }
2914
2915
0
  return false;
2916
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: pe-aarch64.c:coff_set_flags
Unexecuted instantiation: pei-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
2917
2918
static bool
2919
coff_set_arch_mach (bfd * abfd,
2920
        enum bfd_architecture arch,
2921
        unsigned long machine)
2922
0
{
2923
0
  unsigned dummy1;
2924
0
  unsigned short dummy2;
2925
2926
0
  if (! bfd_default_set_arch_mach (abfd, arch, machine))
2927
0
    return false;
2928
2929
0
  if (arch != bfd_arch_unknown
2930
0
      && ! coff_set_flags (abfd, &dummy1, &dummy2))
2931
0
    return false;   /* We can't represent this type.  */
2932
2933
0
  return true;     /* We're easy...  */
2934
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: pe-aarch64.c:coff_set_arch_mach
Unexecuted instantiation: pei-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
2935
2936
#ifdef COFF_IMAGE_WITH_PE
2937
2938
/* This is used to sort sections by VMA, as required by PE image
2939
   files.  */
2940
2941
static int
2942
sort_by_secaddr (const void * arg1, const void * arg2)
2943
0
{
2944
0
  const asection *a = *(const asection **) arg1;
2945
0
  const asection *b = *(const asection **) arg2;
2946
2947
0
  if (a->vma < b->vma)
2948
0
    return -1;
2949
0
  else if (a->vma > b->vma)
2950
0
    return 1;
2951
2952
0
  return 0;
2953
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
2954
2955
#endif /* COFF_IMAGE_WITH_PE */
2956
2957
/* Calculate the file position for each section.  */
2958
2959
#define ALIGN_SECTIONS_IN_FILE
2960
#ifdef TICOFF
2961
#undef ALIGN_SECTIONS_IN_FILE
2962
#endif
2963
2964
static bool
2965
coff_compute_section_file_positions (bfd * abfd)
2966
0
{
2967
0
  asection *current;
2968
0
  file_ptr sofar = bfd_coff_filhsz (abfd);
2969
0
  bool align_adjust;
2970
0
  unsigned int target_index;
2971
#ifdef ALIGN_SECTIONS_IN_FILE
2972
  asection *previous = NULL;
2973
  file_ptr old_sofar;
2974
#endif
2975
2976
#ifdef COFF_IMAGE_WITH_PE
2977
  unsigned int page_size;
2978
2979
0
  if (coff_data (abfd)->link_info
2980
0
      || (pe_data (abfd) && pe_data (abfd)->pe_opthdr.FileAlignment))
2981
0
    {
2982
0
      page_size = pe_data (abfd)->pe_opthdr.FileAlignment;
2983
2984
      /* If no file alignment has been set, default to one.
2985
   This repairs 'ld -r' for arm-wince-pe target.  */
2986
0
      if (page_size == 0)
2987
0
  page_size = 1;
2988
0
    }
2989
0
  else
2990
0
    page_size = PE_DEF_FILE_ALIGNMENT;
2991
#else
2992
#ifdef COFF_PAGE_SIZE
2993
0
  unsigned int page_size = COFF_PAGE_SIZE;
2994
#endif
2995
#endif
2996
2997
#ifdef RS6000COFF_C
2998
  /* On XCOFF, if we have symbols, set up the .debug section.  */
2999
0
  if (bfd_get_symcount (abfd) > 0)
3000
0
    {
3001
0
      bfd_size_type sz;
3002
0
      bfd_size_type i, symcount;
3003
0
      asymbol **symp;
3004
3005
      sz = 0;
3006
      symcount = bfd_get_symcount (abfd);
3007
0
      for (symp = abfd->outsymbols, i = 0; i < symcount; symp++, i++)
3008
0
  {
3009
0
    coff_symbol_type *cf;
3010
3011
0
    cf = coff_symbol_from (*symp);
3012
0
    if (cf != NULL
3013
0
        && cf->native != NULL
3014
0
        && cf->native->is_sym
3015
0
        && SYMNAME_IN_DEBUG (&cf->native->u.syment))
3016
0
      {
3017
0
        size_t len;
3018
3019
0
        len = strlen (bfd_asymbol_name (*symp));
3020
0
        if (len > SYMNMLEN || bfd_coff_force_symnames_in_strings (abfd))
3021
0
    sz += len + 1 + bfd_coff_debug_string_prefix_length (abfd);
3022
0
      }
3023
0
  }
3024
0
      if (sz > 0)
3025
0
  {
3026
0
    asection *dsec;
3027
3028
0
    dsec = bfd_make_section_old_way (abfd, DOT_DEBUG);
3029
0
    if (dsec == NULL)
3030
0
      abort ();
3031
0
    dsec->size = sz;
3032
0
    dsec->flags |= SEC_HAS_CONTENTS;
3033
0
  }
3034
0
    }
3035
0
#endif
3036
3037
0
  if (bfd_get_start_address (abfd))
3038
    /*  A start address may have been added to the original file. In this
3039
  case it will need an optional header to record it.  */
3040
0
    abfd->flags |= EXEC_P;
3041
3042
0
  if (abfd->flags & EXEC_P)
3043
0
    sofar += bfd_coff_aoutsz (abfd);
3044
#ifdef RS6000COFF_C
3045
0
  else if (xcoff_data (abfd)->full_aouthdr)
3046
0
    sofar += bfd_coff_aoutsz (abfd);
3047
0
  else
3048
0
    sofar += SMALL_AOUTSZ;
3049
#endif
3050
3051
0
  sofar += abfd->section_count * bfd_coff_scnhsz (abfd);
3052
3053
#ifdef RS6000COFF_C
3054
  /* XCOFF handles overflows in the reloc and line number count fields
3055
     by allocating a new section header to hold the correct counts.  */
3056
0
  for (current = abfd->sections; current != NULL; current = current->next)
3057
0
    if (current->reloc_count >= 0xffff || current->lineno_count >= 0xffff)
3058
0
      sofar += bfd_coff_scnhsz (abfd);
3059
#endif
3060
3061
0
  if (coff_data (abfd)->section_by_target_index)
3062
0
    htab_empty (coff_data (abfd)->section_by_target_index);
3063
3064
#ifdef COFF_IMAGE_WITH_PE
3065
  {
3066
    /* PE requires the sections to be in memory order when listed in
3067
       the section headers.  It also does not like empty loadable
3068
       sections.  The sections apparently do not have to be in the
3069
       right order in the image file itself, but we do need to get the
3070
       target_index values right.  */
3071
3072
    unsigned int count;
3073
    asection **section_list;
3074
    unsigned int i;
3075
    bfd_size_type amt;
3076
3077
#ifdef COFF_PAGE_SIZE
3078
    /* Clear D_PAGED if section / file alignment aren't suitable for
3079
       paging at COFF_PAGE_SIZE granularity.  */
3080
0
   if (pe_data (abfd)->pe_opthdr.SectionAlignment < COFF_PAGE_SIZE
3081
0
       || page_size < COFF_PAGE_SIZE)
3082
0
     abfd->flags &= ~D_PAGED;
3083
#endif
3084
3085
    count = 0;
3086
0
    for (current = abfd->sections; current != NULL; current = current->next)
3087
0
      ++count;
3088
3089
    /* We allocate an extra cell to simplify the final loop.  */
3090
    amt = sizeof (struct asection *) * (count + 1);
3091
    section_list = (asection **) bfd_malloc (amt);
3092
0
    if (section_list == NULL)
3093
0
      return false;
3094
3095
0
    i = 0;
3096
0
    for (current = abfd->sections; current != NULL; current = current->next)
3097
0
      {
3098
0
  section_list[i] = current;
3099
0
  ++i;
3100
0
      }
3101
0
    section_list[i] = NULL;
3102
3103
0
    qsort (section_list, count, sizeof (asection *), sort_by_secaddr);
3104
3105
    /* Rethread the linked list into sorted order; at the same time,
3106
       assign target_index values.  */
3107
0
    target_index = 1;
3108
0
    abfd->sections = NULL;
3109
0
    abfd->section_last = NULL;
3110
0
    for (i = 0; i < count; i++)
3111
0
      {
3112
0
  current = section_list[i];
3113
0
  bfd_section_list_append (abfd, current);
3114
3115
  /* Later, if the section has zero size, we'll be throwing it
3116
     away, so we don't want to number it now.  Note that having
3117
     a zero size and having real contents are different
3118
     concepts: .bss has no contents, but (usually) non-zero
3119
     size.  */
3120
0
  if (current->size == 0)
3121
0
    {
3122
      /* Discard.  However, it still might have (valid) symbols
3123
         in it, so arbitrarily set it to section 1 (indexing is
3124
         1-based here; usually .text).  __end__ and other
3125
         contents of .endsection really have this happen.
3126
         FIXME: This seems somewhat dubious.  */
3127
0
      current->target_index = 1;
3128
0
    }
3129
0
  else
3130
0
    current->target_index = target_index++;
3131
0
      }
3132
3133
0
    free (section_list);
3134
0
  }
3135
#else /* ! COFF_IMAGE_WITH_PE */
3136
  {
3137
    /* Set the target_index field.  */
3138
    target_index = 1;
3139
0
    for (current = abfd->sections; current != NULL; current = current->next)
3140
0
      current->target_index = target_index++;
3141
  }
3142
#endif /* ! COFF_IMAGE_WITH_PE */
3143
3144
0
  if (target_index >= bfd_coff_max_nscns (abfd))
3145
0
    {
3146
0
      bfd_set_error (bfd_error_file_too_big);
3147
0
      _bfd_error_handler
3148
  /* xgettext:c-format */
3149
0
  (_("%pB: too many sections (%d)"), abfd, target_index);
3150
0
      return false;
3151
0
    }
3152
3153
0
  align_adjust = false;
3154
0
  for (current = abfd->sections;
3155
0
       current != NULL;
3156
0
       current = current->next)
3157
0
    {
3158
#ifdef COFF_IMAGE_WITH_PE
3159
      /* With PE we have to pad each section to be a multiple of its
3160
   page size too, and remember both sizes.  */
3161
0
      if (coff_section_data (abfd, current) == NULL)
3162
0
  {
3163
0
    size_t amt = sizeof (struct coff_section_tdata);
3164
3165
    current->used_by_bfd = bfd_zalloc (abfd, amt);
3166
0
    if (current->used_by_bfd == NULL)
3167
0
      return false;
3168
0
  }
3169
0
      if (pei_section_data (abfd, current) == NULL)
3170
0
  {
3171
0
    size_t amt = sizeof (struct pei_section_tdata);
3172
3173
0
    coff_section_data (abfd, current)->tdata = bfd_zalloc (abfd, amt);
3174
0
    if (coff_section_data (abfd, current)->tdata == NULL)
3175
0
      return false;
3176
0
  }
3177
0
      if (pei_section_data (abfd, current)->virt_size == 0)
3178
0
  pei_section_data (abfd, current)->virt_size = current->size;
3179
0
#endif
3180
3181
      /* Only deal with sections which have contents.  */
3182
0
      if (!(current->flags & SEC_HAS_CONTENTS))
3183
0
  continue;
3184
3185
0
      current->rawsize = current->size;
3186
3187
#ifdef COFF_IMAGE_WITH_PE
3188
      /* Make sure we skip empty sections in a PE image.  */
3189
0
      if (current->size == 0)
3190
0
  continue;
3191
0
#endif
3192
3193
      /* Align the sections in the file to the same boundary on
3194
   which they are aligned in virtual memory.  */
3195
#ifdef ALIGN_SECTIONS_IN_FILE
3196
0
      if ((abfd->flags & EXEC_P) != 0)
3197
0
  {
3198
    /* Make sure this section is aligned on the right boundary - by
3199
       padding the previous section up if necessary.  */
3200
0
    old_sofar = sofar;
3201
3202
#ifdef COFF_IMAGE_WITH_PE
3203
0
    sofar = BFD_ALIGN (sofar, page_size);
3204
#else
3205
0
    sofar = BFD_ALIGN (sofar, (bfd_vma) 1 << current->alignment_power);
3206
#endif
3207
3208
#ifdef RS6000COFF_C
3209
    /* Make sure the file offset and the vma of .text/.data are at the
3210
       same page offset, so that the file can be mmap'ed without being
3211
       relocated.  Failing that, AIX is able to load and execute the
3212
       program, but it will be silently relocated (possible as
3213
       executables are PIE).  But the relocation is slightly costly and
3214
       complexify the use of addr2line or gdb.  So better to avoid it,
3215
       like does the native linker.  Usually gnu ld makes sure that
3216
       the vma of .text is the file offset so this issue shouldn't
3217
       appear unless you are stripping such an executable.
3218
3219
       AIX loader checks the text section alignment of (vma - filepos),
3220
       and the native linker doesn't try to align the text sections.
3221
       For example:
3222
3223
       0 .text       000054cc  10000128  10000128  00000128  2**5
3224
           CONTENTS, ALLOC, LOAD, CODE
3225
3226
       Don't perform the above tweak if the previous one is .tdata,
3227
       as it will increase the memory allocated for every threads
3228
       created and not just improve performances with gdb.
3229
    */
3230
3231
0
    if ((current->flags & SEC_LOAD) != 0
3232
0
        && (!strcmp (current->name, _TEXT)
3233
0
      || !strcmp (current->name, _DATA))
3234
0
        && (previous == NULL || strcmp(previous->name, _TDATA)))
3235
0
      {
3236
0
        bfd_vma align = 4096;
3237
0
        bfd_vma sofar_off = sofar % align;
3238
0
        bfd_vma vma_off = current->vma % align;
3239
3240
0
        if (vma_off > sofar_off)
3241
0
    sofar += vma_off - sofar_off;
3242
0
        else if (vma_off < sofar_off)
3243
0
    sofar += align + vma_off - sofar_off;
3244
0
      }
3245
#endif
3246
0
    if (previous != NULL
3247
0
        && (previous->flags & SEC_LOAD) != 0)
3248
0
      previous->size += sofar - old_sofar;
3249
0
  }
3250
3251
0
#endif
3252
3253
      /* In demand paged files the low order bits of the file offset
3254
   must match the low order bits of the virtual address.  */
3255
#ifdef COFF_PAGE_SIZE
3256
0
      if ((abfd->flags & D_PAGED) != 0
3257
0
    && (current->flags & SEC_ALLOC) != 0)
3258
0
  sofar += (current->vma - (bfd_vma) sofar) % page_size;
3259
#endif
3260
0
      current->filepos = sofar;
3261
3262
#ifdef COFF_IMAGE_WITH_PE
3263
      /* Set the padded size.  */
3264
      current->size = (current->size + page_size - 1) & -page_size;
3265
#endif
3266
3267
0
      sofar += current->size;
3268
3269
#ifdef ALIGN_SECTIONS_IN_FILE
3270
      /* Make sure that this section is of the right size too.  */
3271
0
      if ((abfd->flags & EXEC_P) == 0)
3272
0
  {
3273
0
    bfd_size_type old_size;
3274
3275
0
    old_size = current->size;
3276
0
    current->size = BFD_ALIGN (current->size,
3277
0
             (bfd_vma) 1 << current->alignment_power);
3278
0
    align_adjust = current->size != old_size;
3279
0
    sofar += current->size - old_size;
3280
0
  }
3281
0
      else
3282
0
  {
3283
0
    old_sofar = sofar;
3284
#ifdef COFF_IMAGE_WITH_PE
3285
0
    sofar = BFD_ALIGN (sofar, page_size);
3286
#else
3287
0
    sofar = BFD_ALIGN (sofar, (bfd_vma) 1 << current->alignment_power);
3288
#endif
3289
0
    align_adjust = sofar != old_sofar;
3290
0
    current->size += sofar - old_sofar;
3291
0
  }
3292
#endif
3293
3294
#ifdef COFF_IMAGE_WITH_PE
3295
      /* For PE we need to make sure we pad out to the aligned
3296
   size, in case the caller only writes out data to the
3297
   unaligned size.  */
3298
0
      if (pei_section_data (abfd, current)->virt_size < current->size)
3299
0
  align_adjust = true;
3300
#endif
3301
3302
#ifdef _LIB
3303
      /* Force .lib sections to start at zero.  The vma is then
3304
   incremented in coff_set_section_contents.  This is right for
3305
   SVR3.2.  */
3306
0
      if (strcmp (current->name, _LIB) == 0)
3307
0
  bfd_set_section_vma (current, 0);
3308
#endif
3309
3310
#ifdef ALIGN_SECTIONS_IN_FILE
3311
      previous = current;
3312
#endif
3313
0
    }
3314
3315
  /* It is now safe to write to the output file.  If we needed an
3316
     alignment adjustment for the last section, then make sure that
3317
     there is a byte at offset sofar.  If there are no symbols and no
3318
     relocs, then nothing follows the last section.  If we don't force
3319
     the last byte out, then the file may appear to be truncated.  */
3320
0
  if (align_adjust)
3321
0
    {
3322
0
      bfd_byte b;
3323
3324
0
      b = 0;
3325
0
      if (bfd_seek (abfd, sofar - 1, SEEK_SET) != 0
3326
0
    || bfd_write (&b, 1, abfd) != 1)
3327
0
  return false;
3328
0
    }
3329
3330
  /* Make sure the relocations are aligned.  We don't need to make
3331
     sure that this byte exists, because it will only matter if there
3332
     really are relocs.  */
3333
0
  sofar = BFD_ALIGN (sofar,
3334
0
         (bfd_vma) 1 << COFF_DEFAULT_SECTION_ALIGNMENT_POWER);
3335
3336
0
  obj_relocbase (abfd) = sofar;
3337
0
  abfd->output_has_begun = true;
3338
3339
0
  return true;
3340
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: pe-aarch64.c:coff_compute_section_file_positions
Unexecuted instantiation: pei-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
3341
3342
#ifdef COFF_IMAGE_WITH_PE
3343
3344
static bool
3345
coff_read_word (bfd *abfd, unsigned int *value, unsigned int *pelength)
3346
0
{
3347
0
  unsigned char b[2];
3348
0
  int status;
3349
3350
0
  status = bfd_read (b, 2, abfd);
3351
0
  if (status < 1)
3352
0
    {
3353
0
      *value = 0;
3354
0
      return false;
3355
0
    }
3356
3357
0
  if (status == 1)
3358
0
    *value = (unsigned int) b[0];
3359
0
  else
3360
0
    *value = (unsigned int) (b[0] + (b[1] << 8));
3361
3362
0
  *pelength += status;
3363
3364
0
  return true;
3365
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
3366
3367
/* Read a two byte number from buffer B returning the result in VALUE.
3368
   No more than BUF_SIZE bytes will be read.
3369
   Returns true upobn success, false otherwise.
3370
   If successful, increases the value stored in PELENGTH by the number
3371
   of bytes read.  */
3372
3373
static bool
3374
coff_read_word_from_buffer (unsigned char *  b,
3375
          int              buf_size,
3376
                            unsigned int *   value,
3377
          unsigned int *   pelength)
3378
0
{
3379
0
  if (buf_size < 1)
3380
0
    {
3381
0
      *value = 0;
3382
0
      return false;
3383
0
    }
3384
3385
0
  if (buf_size == 1)
3386
0
    {
3387
0
      *value = (unsigned int)b[0];
3388
0
      *pelength += 1;
3389
0
    }
3390
0
  else
3391
0
    {
3392
0
      *value = (unsigned int)(b[0] + (b[1] << 8));
3393
0
      *pelength += 2;
3394
0
    }
3395
3396
0
  return true;
3397
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
3398
3399
0
#define COFF_CHECKSUM_BUFFER_SIZE 0x800000
3400
3401
static unsigned int
3402
coff_compute_checksum (bfd *abfd, unsigned int *pelength)
3403
0
{
3404
0
  file_ptr filepos;
3405
0
  unsigned int value;
3406
0
  unsigned int total;
3407
0
  unsigned char *buf;
3408
0
  int buf_size;
3409
3410
0
  total = 0;
3411
0
  *pelength = 0;
3412
0
  filepos = (file_ptr) 0;
3413
0
  buf = (unsigned char *) bfd_malloc (COFF_CHECKSUM_BUFFER_SIZE);
3414
0
  if (buf == NULL)
3415
0
    return 0;
3416
0
  buf_size = 0;
3417
3418
0
  do
3419
0
    {
3420
0
      unsigned char *cur_buf;
3421
0
      int cur_buf_size;
3422
3423
0
      if (bfd_seek (abfd, filepos, SEEK_SET) != 0)
3424
0
  return 0;
3425
3426
0
      buf_size = bfd_read (buf, COFF_CHECKSUM_BUFFER_SIZE, abfd);
3427
0
      cur_buf_size = buf_size;
3428
0
      cur_buf = buf;
3429
3430
0
      while (cur_buf_size > 0)
3431
0
        {
3432
0
          coff_read_word_from_buffer (cur_buf, cur_buf_size, &value, pelength);
3433
0
          cur_buf += 2;
3434
0
          cur_buf_size -= 2;
3435
0
          total += value;
3436
0
          total = 0xffff & (total + (total >> 0x10));
3437
0
        }
3438
3439
0
      filepos += buf_size;
3440
0
    }
3441
0
  while (buf_size > 0);
3442
3443
0
  free (buf);
3444
3445
0
  return (0xffff & (total + (total >> 0x10)));
3446
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
3447
3448
static bool
3449
coff_apply_checksum (bfd *abfd)
3450
0
{
3451
0
  unsigned int computed;
3452
0
  unsigned int checksum = 0;
3453
0
  unsigned int peheader;
3454
0
  unsigned int pelength;
3455
3456
0
  if (bfd_seek (abfd, 0x3c, SEEK_SET) != 0)
3457
0
    return false;
3458
3459
0
  if (!coff_read_word (abfd, &peheader, &pelength))
3460
0
    return false;
3461
3462
0
  if (bfd_seek (abfd, peheader + 0x58, SEEK_SET) != 0)
3463
0
    return false;
3464
3465
0
  checksum = 0;
3466
0
  if (bfd_write (&checksum, 4, abfd) != 4)
3467
0
    return false;
3468
3469
0
  if (bfd_seek (abfd, peheader, SEEK_SET) != 0)
3470
0
    return false;
3471
3472
0
  computed = coff_compute_checksum (abfd, &pelength);
3473
3474
0
  checksum = computed + pelength;
3475
3476
0
  if (bfd_seek (abfd, peheader + 0x58, SEEK_SET) != 0)
3477
0
    return false;
3478
3479
0
  return bfd_write (&checksum, 4, abfd) == 4;
3480
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
3481
3482
#endif /* COFF_IMAGE_WITH_PE */
3483
3484
static bool
3485
coff_write_object_contents (bfd * abfd)
3486
0
{
3487
0
  asection *current;
3488
0
  bool hasrelocs = false;
3489
0
  bool haslinno = false;
3490
#ifdef COFF_IMAGE_WITH_PE
3491
  bool hasdebug = false;
3492
#endif
3493
0
  file_ptr scn_base;
3494
0
  file_ptr reloc_base;
3495
0
  file_ptr lineno_base;
3496
0
  file_ptr sym_base;
3497
0
  unsigned long reloc_size = 0, reloc_count = 0;
3498
0
  unsigned long lnno_size = 0;
3499
0
  bool long_section_names;
3500
0
  asection *text_sec = NULL;
3501
0
  asection *data_sec = NULL;
3502
0
  asection *bss_sec = NULL;
3503
#ifdef RS6000COFF_C
3504
  asection *tdata_sec = NULL;
3505
  asection *tbss_sec = NULL;
3506
#endif
3507
0
  struct internal_filehdr internal_f;
3508
0
  struct internal_aouthdr internal_a;
3509
#ifdef COFF_LONG_SECTION_NAMES
3510
0
  size_t string_size = STRING_SIZE_SIZE;
3511
#endif
3512
3513
0
  bfd_set_error (bfd_error_system_call);
3514
3515
  /* Make a pass through the symbol table to count line number entries and
3516
     put them into the correct asections.  */
3517
0
  lnno_size = coff_count_linenumbers (abfd) * bfd_coff_linesz (abfd);
3518
3519
0
  if (! abfd->output_has_begun)
3520
0
    {
3521
0
      if (! coff_compute_section_file_positions (abfd))
3522
0
  return false;
3523
0
    }
3524
3525
0
  reloc_base = obj_relocbase (abfd);
3526
3527
  /* Work out the size of the reloc and linno areas.  */
3528
3529
0
  for (current = abfd->sections; current != NULL; current =
3530
0
       current->next)
3531
0
    {
3532
#ifdef COFF_WITH_EXTENDED_RELOC_COUNTER
3533
      /* We store the actual reloc count in the first reloc's addr.  */
3534
0
      if ((obj_pe (abfd) || obj_go32 (abfd)) && current->reloc_count >= 0xffff)
3535
0
  reloc_count ++;
3536
#endif
3537
0
      reloc_count += current->reloc_count;
3538
0
    }
3539
3540
0
  reloc_size = reloc_count * bfd_coff_relsz (abfd);
3541
3542
0
  lineno_base = reloc_base + reloc_size;
3543
0
  sym_base = lineno_base + lnno_size;
3544
3545
  /* Indicate in each section->line_filepos its actual file address.  */
3546
0
  for (current = abfd->sections; current != NULL; current =
3547
0
       current->next)
3548
0
    {
3549
0
      if (current->lineno_count)
3550
0
  {
3551
0
    current->line_filepos = lineno_base;
3552
0
    current->moving_line_filepos = lineno_base;
3553
0
    lineno_base += current->lineno_count * bfd_coff_linesz (abfd);
3554
0
  }
3555
0
      else
3556
0
  current->line_filepos = 0;
3557
3558
0
      if (current->reloc_count)
3559
0
  {
3560
0
    current->rel_filepos = reloc_base;
3561
0
    reloc_base += current->reloc_count * bfd_coff_relsz (abfd);
3562
#ifdef COFF_WITH_EXTENDED_RELOC_COUNTER
3563
    /* Extra reloc to hold real count.  */
3564
0
    if ((obj_pe (abfd) || obj_go32 (abfd)) && current->reloc_count >= 0xffff)
3565
0
      reloc_base += bfd_coff_relsz (abfd);
3566
#endif
3567
0
  }
3568
0
      else
3569
0
  current->rel_filepos = 0;
3570
0
    }
3571
3572
  /* Write section headers to the file.  */
3573
0
  internal_f.f_nscns = 0;
3574
3575
0
  if ((abfd->flags & EXEC_P) != 0)
3576
0
    scn_base = bfd_coff_filhsz (abfd) + bfd_coff_aoutsz (abfd);
3577
0
  else
3578
0
    {
3579
0
      scn_base = bfd_coff_filhsz (abfd);
3580
#ifdef RS6000COFF_C
3581
#ifndef XCOFF64
3582
0
      if (xcoff_data (abfd)->full_aouthdr)
3583
0
  scn_base += bfd_coff_aoutsz (abfd);
3584
0
      else
3585
0
  scn_base += SMALL_AOUTSZ;
3586
#endif
3587
#endif
3588
0
    }
3589
3590
0
  if (bfd_seek (abfd, scn_base, SEEK_SET) != 0)
3591
0
    return false;
3592
3593
0
  long_section_names = false;
3594
0
  for (current = abfd->sections;
3595
0
       current != NULL;
3596
0
       current = current->next)
3597
0
    {
3598
0
      struct internal_scnhdr section;
3599
#ifdef COFF_IMAGE_WITH_PE
3600
      bool is_reloc_section = false;
3601
3602
0
      if (strcmp (current->name, DOT_RELOC) == 0)
3603
0
  {
3604
0
    is_reloc_section = true;
3605
0
    hasrelocs = true;
3606
0
    pe_data (abfd)->has_reloc_section = 1;
3607
0
  }
3608
#endif
3609
3610
0
      internal_f.f_nscns++;
3611
3612
0
      strncpy (section.s_name, current->name, SCNNMLEN);
3613
3614
#ifdef COFF_LONG_SECTION_NAMES
3615
      /* Handle long section names as in PE.  This must be compatible
3616
   with the code in coff_write_symbols and _bfd_coff_final_link.  */
3617
0
      if (bfd_coff_long_section_names (abfd))
3618
0
  {
3619
0
    size_t len;
3620
3621
    len = strlen (current->name);
3622
0
    if (len > SCNNMLEN)
3623
0
      {
3624
3625
        /* An inherent limitation of the /nnnnnnn notation used to indicate
3626
     the offset of the long name in the string table is that we
3627
     cannot address entries beyone the ten million byte boundary.  */
3628
0
        if (string_size < 10000000)
3629
0
    {
3630
      /* The s_name field is defined to be NUL-padded but need not
3631
         be NUL-terminated.  We use a temporary buffer so that we
3632
         can still sprintf all eight chars without splatting a
3633
         terminating NUL over the first byte of the following
3634
         member (s_paddr).  */
3635
      /* PR 21096: The +20 is to stop a bogus warning from gcc7
3636
         about a possible buffer overflow.  */
3637
      char s_name_buf[SCNNMLEN + 1 + 20];
3638
3639
      /* We do not need to use snprintf here as we have already
3640
         verified that string_size is not too big, plus we have
3641
         an overlarge buffer, just in case.  */
3642
0
      sprintf (s_name_buf, "/%lu", (unsigned long) string_size);
3643
      /* Then strncpy takes care of any padding for us.  */
3644
0
      strncpy (section.s_name, s_name_buf, SCNNMLEN);
3645
0
    }
3646
0
        else
3647
#ifdef COFF_WITH_PE
3648
0
    {
3649
      /* PE use a base 64 encoding for long section names whose
3650
         index is very large.  But contrary to RFC 4648, there is
3651
         no padding: 6 characters must be generated.  */
3652
0
      static const char base64[] =
3653
0
        "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
3654
0
        "abcdefghijklmnopqrstuvwxyz"
3655
0
        "0123456789+/";
3656
0
      unsigned long off = string_size;
3657
0
      unsigned i;
3658
3659
0
      section.s_name[0] = '/';
3660
0
      section.s_name[1] = '/';
3661
0
      for (i = SCNNMLEN - 1; i >= 2; i--)
3662
0
        {
3663
0
          section.s_name[i] = base64[off & 0x3f];
3664
0
          off >>= 6;
3665
0
        }
3666
0
    }
3667
#endif
3668
0
        if (string_size > 0xffffffffUL - (len + 1)
3669
#ifndef COFF_WITH_PE
3670
0
      || string_size >= 10000000
3671
#endif
3672
0
      )
3673
0
    {
3674
0
      bfd_set_error (bfd_error_file_too_big);
3675
0
      _bfd_error_handler
3676
        /* xgettext:c-format */
3677
0
        (_("%pB: section %pA: string table overflow at offset %ld"),
3678
0
        abfd, current, (unsigned long) string_size);
3679
0
      return false;
3680
0
    }
3681
3682
0
        string_size += len + 1;
3683
0
        long_section_names = true;
3684
0
      }
3685
0
  }
3686
0
#endif
3687
3688
#ifdef _LIB
3689
      /* Always set s_vaddr of .lib to 0.  This is right for SVR3.2
3690
   Ian Taylor <ian@cygnus.com>.  */
3691
0
      if (strcmp (current->name, _LIB) == 0)
3692
0
  section.s_vaddr = 0;
3693
0
      else
3694
0
#endif
3695
0
      section.s_vaddr = current->vma;
3696
0
      section.s_paddr = current->lma;
3697
0
      section.s_size =  current->size;
3698
#ifdef coff_get_section_load_page
3699
0
      section.s_page = coff_get_section_load_page (current);
3700
#else
3701
      section.s_page = 0;
3702
#endif
3703
3704
#ifdef COFF_WITH_PE
3705
      section.s_paddr = 0;
3706
#endif
3707
#ifdef COFF_IMAGE_WITH_PE
3708
      /* Reminder: s_paddr holds the virtual size of the section.  */
3709
0
      if (coff_section_data (abfd, current) != NULL
3710
0
    && pei_section_data (abfd, current) != NULL)
3711
0
  section.s_paddr = pei_section_data (abfd, current)->virt_size;
3712
0
      else
3713
0
  section.s_paddr = 0;
3714
#endif
3715
3716
      /* If this section has no size or is unloadable then the scnptr
3717
   will be 0 too.  */
3718
0
      if (current->size == 0
3719
0
    || (current->flags & (SEC_LOAD | SEC_HAS_CONTENTS)) == 0)
3720
0
  section.s_scnptr = 0;
3721
0
      else
3722
0
  section.s_scnptr = current->filepos;
3723
3724
0
      section.s_relptr = current->rel_filepos;
3725
0
      section.s_lnnoptr = current->line_filepos;
3726
0
      section.s_nreloc = current->reloc_count;
3727
0
      section.s_nlnno = current->lineno_count;
3728
#ifndef COFF_IMAGE_WITH_PE
3729
      /* In PEI, relocs come in the .reloc section.  */
3730
0
      if (current->reloc_count != 0)
3731
0
  hasrelocs = true;
3732
#endif
3733
0
      if (current->lineno_count != 0)
3734
0
  haslinno = true;
3735
#ifdef COFF_IMAGE_WITH_PE
3736
0
      if ((current->flags & SEC_DEBUGGING) != 0
3737
0
    && ! is_reloc_section)
3738
0
  hasdebug = true;
3739
#endif
3740
3741
#ifdef RS6000COFF_C
3742
#ifndef XCOFF64
3743
      /* Indicate the use of an XCOFF overflow section header.  */
3744
0
      if (current->reloc_count >= 0xffff || current->lineno_count >= 0xffff)
3745
0
  {
3746
0
    section.s_nreloc = 0xffff;
3747
0
    section.s_nlnno = 0xffff;
3748
0
  }
3749
#endif
3750
#endif
3751
3752
0
      section.s_flags = sec_to_styp_flags (current->name, current->flags);
3753
3754
0
      if (!strcmp (current->name, _TEXT))
3755
0
  text_sec = current;
3756
0
      else if (!strcmp (current->name, _DATA))
3757
0
  data_sec = current;
3758
0
      else if (!strcmp (current->name, _BSS))
3759
0
  bss_sec = current;
3760
#ifdef RS6000COFF_C
3761
0
      else if (!strcmp (current->name, _TDATA))
3762
0
  tdata_sec = current;
3763
0
      else if (!strcmp (current->name, _TBSS))
3764
0
  tbss_sec = current;
3765
#endif
3766
3767
3768
#ifdef COFF_ENCODE_ALIGNMENT
3769
0
      if (COFF_ENCODE_ALIGNMENT (abfd, section, current->alignment_power)
3770
0
    && (COFF_DECODE_ALIGNMENT (section.s_flags)
3771
0
        != current->alignment_power))
3772
0
  {
3773
0
    bool warn = (coff_data (abfd)->link_info
3774
0
           && !bfd_link_relocatable (coff_data (abfd)->link_info));
3775
3776
0
    _bfd_error_handler
3777
      /* xgettext:c-format */
3778
0
      (_("%pB:%s section %s: alignment 2**%u not representable"),
3779
0
       abfd, warn ? " warning:" : "", current->name,
3780
0
       current->alignment_power);
3781
0
    if (!warn)
3782
0
      {
3783
0
        bfd_set_error (bfd_error_nonrepresentable_section);
3784
0
        return false;
3785
0
      }
3786
0
  }
3787
0
#endif
3788
3789
#ifdef COFF_IMAGE_WITH_PE
3790
      /* Suppress output of the sections if they are null.  ld
3791
   includes the bss and data sections even if there is no size
3792
   assigned to them.  NT loader doesn't like it if these section
3793
   headers are included if the sections themselves are not
3794
   needed.  See also coff_compute_section_file_positions.  */
3795
0
      if (section.s_size == 0)
3796
0
  internal_f.f_nscns--;
3797
0
      else
3798
0
#endif
3799
0
  {
3800
0
    SCNHDR buff;
3801
0
    bfd_size_type amt = bfd_coff_scnhsz (abfd);
3802
3803
0
    if (bfd_coff_swap_scnhdr_out (abfd, &section, &buff) == 0
3804
0
        || bfd_write (& buff, amt, abfd) != amt)
3805
0
      return false;
3806
0
  }
3807
3808
#ifdef COFF_WITH_PE
3809
      /* PE stores COMDAT section information in the symbol table.  If
3810
   this section is supposed to have some COMDAT info, track down
3811
   the symbol in the symbol table and modify it.  */
3812
0
      if ((current->flags & SEC_LINK_ONCE) != 0)
3813
0
  {
3814
0
    unsigned int i, count;
3815
0
    asymbol **psym;
3816
0
    coff_symbol_type *csym = NULL;
3817
0
    asymbol **psymsec;
3818
3819
    psymsec = NULL;
3820
    count = bfd_get_symcount (abfd);
3821
0
    for (i = 0, psym = abfd->outsymbols; i < count; i++, psym++)
3822
0
      {
3823
0
        if ((*psym)->section != current)
3824
0
    continue;
3825
3826
        /* Remember the location of the first symbol in this
3827
     section.  */
3828
0
        if (psymsec == NULL)
3829
0
    psymsec = psym;
3830
3831
        /* See if this is the section symbol.  */
3832
0
        if (strcmp ((*psym)->name, current->name) == 0)
3833
0
    {
3834
0
      csym = coff_symbol_from (*psym);
3835
0
      if (csym == NULL
3836
0
          || csym->native == NULL
3837
0
          || ! csym->native->is_sym
3838
0
          || csym->native->u.syment.n_numaux < 1
3839
0
          || csym->native->u.syment.n_sclass != C_STAT
3840
0
          || csym->native->u.syment.n_type != T_NULL)
3841
0
        continue;
3842
3843
      /* Here *PSYM is the section symbol for CURRENT.  */
3844
3845
0
      break;
3846
0
    }
3847
0
      }
3848
3849
    /* Did we find it?
3850
       Note that we might not if we're converting the file from
3851
       some other object file format.  */
3852
0
    if (i < count)
3853
0
      {
3854
0
        combined_entry_type *aux;
3855
3856
        /* We don't touch the x_checksum field.  The
3857
     x_associated field is not currently supported.  */
3858
3859
0
        aux = csym->native + 1;
3860
0
        BFD_ASSERT (! aux->is_sym);
3861
0
        switch (current->flags & SEC_LINK_DUPLICATES)
3862
0
    {
3863
0
    case SEC_LINK_DUPLICATES_DISCARD:
3864
0
      aux->u.auxent.x_scn.x_comdat = IMAGE_COMDAT_SELECT_ANY;
3865
0
      break;
3866
3867
0
    case SEC_LINK_DUPLICATES_ONE_ONLY:
3868
0
      aux->u.auxent.x_scn.x_comdat =
3869
0
        IMAGE_COMDAT_SELECT_NODUPLICATES;
3870
0
      break;
3871
3872
0
    case SEC_LINK_DUPLICATES_SAME_SIZE:
3873
0
      aux->u.auxent.x_scn.x_comdat =
3874
0
        IMAGE_COMDAT_SELECT_SAME_SIZE;
3875
0
      break;
3876
3877
0
    case SEC_LINK_DUPLICATES_SAME_CONTENTS:
3878
0
      aux->u.auxent.x_scn.x_comdat =
3879
0
        IMAGE_COMDAT_SELECT_EXACT_MATCH;
3880
0
      break;
3881
0
    }
3882
3883
        /* The COMDAT symbol must be the first symbol from this
3884
     section in the symbol table.  In order to make this
3885
     work, we move the COMDAT symbol before the first
3886
     symbol we found in the search above.  It's OK to
3887
     rearrange the symbol table at this point, because
3888
     coff_renumber_symbols is going to rearrange it
3889
     further and fix up all the aux entries.  */
3890
0
        if (psym != psymsec)
3891
0
    {
3892
0
      asymbol *hold;
3893
0
      asymbol **pcopy;
3894
3895
0
      hold = *psym;
3896
0
      for (pcopy = psym; pcopy > psymsec; pcopy--)
3897
0
        pcopy[0] = pcopy[-1];
3898
0
      *psymsec = hold;
3899
0
    }
3900
0
      }
3901
0
  }
3902
#endif /* COFF_WITH_PE */
3903
0
    }
3904
3905
#ifdef RS6000COFF_C
3906
#ifndef XCOFF64
3907
  /* XCOFF handles overflows in the reloc and line number count fields
3908
     by creating a new section header to hold the correct values.  */
3909
0
  for (current = abfd->sections; current != NULL; current = current->next)
3910
0
    {
3911
0
      if (current->reloc_count >= 0xffff || current->lineno_count >= 0xffff)
3912
0
  {
3913
0
    struct internal_scnhdr scnhdr;
3914
0
    SCNHDR buff;
3915
0
    bfd_size_type amt;
3916
3917
0
    internal_f.f_nscns++;
3918
0
    memcpy (scnhdr.s_name, ".ovrflo", 8);
3919
0
    scnhdr.s_paddr = current->reloc_count;
3920
0
    scnhdr.s_vaddr = current->lineno_count;
3921
0
    scnhdr.s_size = 0;
3922
0
    scnhdr.s_scnptr = 0;
3923
0
    scnhdr.s_relptr = current->rel_filepos;
3924
0
    scnhdr.s_lnnoptr = current->line_filepos;
3925
0
    scnhdr.s_nreloc = current->target_index;
3926
0
    scnhdr.s_nlnno = current->target_index;
3927
0
    scnhdr.s_flags = STYP_OVRFLO;
3928
0
    amt = bfd_coff_scnhsz (abfd);
3929
0
    if (bfd_coff_swap_scnhdr_out (abfd, &scnhdr, &buff) == 0
3930
0
        || bfd_write (& buff, amt, abfd) != amt)
3931
0
      return false;
3932
0
  }
3933
0
    }
3934
0
#endif
3935
#endif
3936
3937
#if defined (COFF_GO32_EXE) || defined (COFF_GO32)
3938
  /* Pad section headers.  */
3939
0
  if ((abfd->flags & EXEC_P) != 0)
3940
0
    {
3941
0
      asection *s = abfd->sections;
3942
0
      while (s != NULL && s->filepos == 0)
3943
0
  s = s->next;
3944
0
      if (s != NULL)
3945
0
  {
3946
0
    file_ptr cur_ptr
3947
0
      = scn_base + abfd->section_count * bfd_coff_scnhsz (abfd);
3948
0
    file_ptr fill_size = s->filepos - cur_ptr;
3949
0
    if (fill_size > 0)
3950
0
      {
3951
0
        bfd_byte *b = bfd_zmalloc (fill_size);
3952
0
        if (!b)
3953
0
    return false;
3954
0
        if (bfd_write (b, fill_size, abfd) != (ufile_ptr) fill_size)
3955
0
    {
3956
0
      free (b);
3957
0
      return false;
3958
0
    }
3959
0
        free (b);
3960
0
      }
3961
0
  }
3962
0
    }
3963
0
#endif
3964
3965
  /* OK, now set up the filehdr...  */
3966
3967
  /* Don't include the internal abs section in the section count */
3968
3969
  /* We will NOT put a fucking timestamp in the header here. Every time you
3970
     put it back, I will come in and take it out again.  I'm sorry.  This
3971
     field does not belong here.  We fill it with a 0 so it compares the
3972
     same but is not a reasonable time. -- gnu@cygnus.com  */
3973
0
  internal_f.f_timdat = 0;
3974
0
  internal_f.f_flags = 0;
3975
3976
0
  if (abfd->flags & EXEC_P)
3977
0
    internal_f.f_opthdr = bfd_coff_aoutsz (abfd);
3978
0
  else
3979
0
    {
3980
0
      internal_f.f_opthdr = 0;
3981
#ifdef RS6000COFF_C
3982
#ifndef XCOFF64
3983
0
      if (xcoff_data (abfd)->full_aouthdr)
3984
0
  internal_f.f_opthdr = bfd_coff_aoutsz (abfd);
3985
0
      else
3986
0
  internal_f.f_opthdr = SMALL_AOUTSZ;
3987
#endif
3988
#endif
3989
0
    }
3990
3991
0
  if (!hasrelocs)
3992
0
    internal_f.f_flags |= F_RELFLG;
3993
0
  if (!haslinno)
3994
0
    internal_f.f_flags |= F_LNNO;
3995
0
  if (abfd->flags & EXEC_P)
3996
0
    internal_f.f_flags |= F_EXEC;
3997
#ifdef COFF_IMAGE_WITH_PE
3998
0
  if (! hasdebug)
3999
0
    internal_f.f_flags |= IMAGE_FILE_DEBUG_STRIPPED;
4000
0
  if (pe_data (abfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE)
4001
0
    internal_f.f_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE;
4002
#endif
4003
4004
#if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64)
4005
#ifdef COFF_WITH_PE
4006
0
  internal_f.f_flags |= IMAGE_FILE_32BIT_MACHINE;
4007
#else
4008
0
  if (bfd_little_endian (abfd))
4009
0
    internal_f.f_flags |= F_AR32WR;
4010
0
  else
4011
0
    internal_f.f_flags |= F_AR32W;
4012
#endif
4013
#endif
4014
4015
#ifdef TI_TARGET_ID
4016
  /* Target id is used in TI COFF v1 and later; COFF0 won't use this field,
4017
     but it doesn't hurt to set it internally.  */
4018
0
  internal_f.f_target_id = TI_TARGET_ID;
4019
#endif
4020
4021
  /* FIXME, should do something about the other byte orders and
4022
     architectures.  */
4023
4024
#ifdef RS6000COFF_C
4025
0
  if ((abfd->flags & DYNAMIC) != 0)
4026
0
    internal_f.f_flags |= F_SHROBJ;
4027
0
  if (bfd_get_section_by_name (abfd, _LOADER) != NULL)
4028
0
    internal_f.f_flags |= F_DYNLOAD;
4029
#endif
4030
4031
0
  memset (&internal_a, 0, sizeof internal_a);
4032
4033
  /* Set up architecture-dependent stuff.  */
4034
0
  {
4035
0
    unsigned int magic = 0;
4036
0
    unsigned short flags = 0;
4037
4038
0
    coff_set_flags (abfd, &magic, &flags);
4039
0
    internal_f.f_magic = magic;
4040
0
    internal_f.f_flags |= flags;
4041
    /* ...and the "opt"hdr...  */
4042
4043
#ifdef TICOFF_AOUT_MAGIC
4044
0
    internal_a.magic = TICOFF_AOUT_MAGIC;
4045
#define __A_MAGIC_SET__
4046
#endif
4047
4048
#if defined(ARM)
4049
#define __A_MAGIC_SET__
4050
0
    internal_a.magic = ZMAGIC;
4051
#endif
4052
4053
#if defined(AARCH64)
4054
#define __A_MAGIC_SET__
4055
0
    internal_a.magic = ZMAGIC;
4056
#endif
4057
4058
#if defined(LOONGARCH64)
4059
#define __A_MAGIC_SET__
4060
0
    internal_a.magic = ZMAGIC;
4061
#endif
4062
4063
#if defined MCORE_PE
4064
#define __A_MAGIC_SET__
4065
0
    internal_a.magic = IMAGE_NT_OPTIONAL_HDR_MAGIC;
4066
#endif
4067
4068
#if defined(I386)
4069
#define __A_MAGIC_SET__
4070
#if defined LYNXOS
4071
0
    internal_a.magic = LYNXCOFFMAGIC;
4072
#elif defined AMD64
4073
0
    internal_a.magic = IMAGE_NT_OPTIONAL_HDR64_MAGIC;
4074
#else
4075
0
    internal_a.magic = ZMAGIC;
4076
#endif
4077
#endif /* I386 */
4078
4079
#if defined(IA64)
4080
#define __A_MAGIC_SET__
4081
0
    internal_a.magic = PE32PMAGIC;
4082
#endif /* IA64 */
4083
4084
#if defined(SPARC)
4085
#define __A_MAGIC_SET__
4086
#if defined(LYNXOS)
4087
    internal_a.magic = LYNXCOFFMAGIC;
4088
#endif /* LYNXOS */
4089
#endif /* SPARC */
4090
4091
#ifdef RS6000COFF_C
4092
#define __A_MAGIC_SET__
4093
0
    internal_a.magic = (abfd->flags & D_PAGED) ? RS6K_AOUTHDR_ZMAGIC :
4094
0
    (abfd->flags & WP_TEXT) ? RS6K_AOUTHDR_NMAGIC :
4095
0
    RS6K_AOUTHDR_OMAGIC;
4096
#endif
4097
4098
#if defined(SH) && defined(COFF_WITH_PE)
4099
#define __A_MAGIC_SET__
4100
0
    internal_a.magic = SH_PE_MAGIC;
4101
#endif
4102
4103
#if defined(MIPS) && defined(COFF_WITH_PE)
4104
#define __A_MAGIC_SET__
4105
    internal_a.magic = MIPS_PE_MAGIC;
4106
#endif
4107
4108
#ifndef __A_MAGIC_SET__
4109
#include "Your aouthdr magic number is not being set!"
4110
#else
4111
0
#undef __A_MAGIC_SET__
4112
0
#endif
4113
0
  }
4114
4115
#ifdef RS6000COFF_C
4116
  /* XCOFF 32bit needs this to have new behaviour for n_type field.  */
4117
  internal_a.vstamp = 2;
4118
#else
4119
  /* FIXME: Does anybody ever set this to another value?  */
4120
  internal_a.vstamp = 0;
4121
#endif
4122
4123
  /* Now should write relocs, strings, syms.  */
4124
0
  obj_sym_filepos (abfd) = sym_base;
4125
4126
0
  if (bfd_get_symcount (abfd) != 0)
4127
0
    {
4128
0
      int firstundef;
4129
4130
0
      if (!coff_renumber_symbols (abfd, &firstundef))
4131
0
  return false;
4132
0
      coff_mangle_symbols (abfd);
4133
0
      if (! coff_write_symbols (abfd))
4134
0
  return false;
4135
0
      if (! coff_write_linenumbers (abfd))
4136
0
  return false;
4137
0
      if (! coff_write_relocs (abfd, firstundef))
4138
0
  return false;
4139
0
    }
4140
#ifdef COFF_LONG_SECTION_NAMES
4141
0
  else if (long_section_names && ! obj_coff_strings_written (abfd))
4142
0
    {
4143
      /* If we have long section names we have to write out the string
4144
   table even if there are no symbols.  */
4145
0
      if (! coff_write_symbols (abfd))
4146
0
  return false;
4147
0
    }
4148
0
#endif
4149
  /* If bfd_get_symcount (abfd) != 0, then we are not using the COFF
4150
     backend linker, and obj_raw_syment_count is not valid until after
4151
     coff_write_symbols is called.  */
4152
0
  if (obj_raw_syment_count (abfd) != 0)
4153
0
    {
4154
0
      internal_f.f_symptr = sym_base;
4155
#ifdef RS6000COFF_C
4156
      /* AIX appears to require that F_RELFLG not be set if there are
4157
   local symbols but no relocations.  */
4158
0
      internal_f.f_flags &=~ F_RELFLG;
4159
#endif
4160
0
    }
4161
0
  else
4162
0
    {
4163
0
      if (long_section_names)
4164
0
  internal_f.f_symptr = sym_base;
4165
0
      else
4166
0
  internal_f.f_symptr = 0;
4167
0
      internal_f.f_flags |= F_LSYMS;
4168
0
    }
4169
4170
0
  if (text_sec)
4171
0
    {
4172
0
      internal_a.tsize = text_sec->size;
4173
0
      internal_a.text_start = internal_a.tsize ? text_sec->vma : 0;
4174
0
    }
4175
0
  if (data_sec)
4176
0
    {
4177
0
      internal_a.dsize = data_sec->size;
4178
0
      internal_a.data_start = internal_a.dsize ? data_sec->vma : 0;
4179
0
    }
4180
0
  if (bss_sec)
4181
0
    {
4182
0
      internal_a.bsize = bss_sec->size;
4183
0
      if (internal_a.bsize && bss_sec->vma < internal_a.data_start)
4184
0
  internal_a.data_start = bss_sec->vma;
4185
0
    }
4186
4187
0
  internal_a.entry = bfd_get_start_address (abfd);
4188
0
  internal_f.f_nsyms = obj_raw_syment_count (abfd);
4189
4190
#ifdef RS6000COFF_C
4191
0
  if (xcoff_data (abfd)->full_aouthdr)
4192
0
    {
4193
0
      bfd_vma toc;
4194
0
      asection *loader_sec;
4195
4196
      internal_a.vstamp = 2;
4197
4198
0
      internal_a.o_snentry = xcoff_data (abfd)->snentry;
4199
0
      if (internal_a.o_snentry == 0)
4200
0
  internal_a.entry = (bfd_vma) -1;
4201
4202
0
      if (text_sec != NULL)
4203
0
  {
4204
0
    internal_a.o_sntext = text_sec->target_index;
4205
0
    internal_a.o_algntext = bfd_section_alignment (text_sec);
4206
0
  }
4207
0
      else
4208
0
  {
4209
0
    internal_a.o_sntext = 0;
4210
0
    internal_a.o_algntext = 0;
4211
0
  }
4212
0
      if (data_sec != NULL)
4213
0
  {
4214
0
    internal_a.o_sndata = data_sec->target_index;
4215
0
    internal_a.o_algndata = bfd_section_alignment (data_sec);
4216
0
  }
4217
0
      else
4218
0
  {
4219
0
    internal_a.o_sndata = 0;
4220
0
    internal_a.o_algndata = 0;
4221
0
  }
4222
      loader_sec = bfd_get_section_by_name (abfd, ".loader");
4223
0
      if (loader_sec != NULL)
4224
0
  internal_a.o_snloader = loader_sec->target_index;
4225
0
      else
4226
0
  internal_a.o_snloader = 0;
4227
0
      if (bss_sec != NULL)
4228
0
  internal_a.o_snbss = bss_sec->target_index;
4229
0
      else
4230
0
  internal_a.o_snbss = 0;
4231
4232
0
      if (tdata_sec != NULL)
4233
0
  {
4234
0
    internal_a.o_sntdata = tdata_sec->target_index;
4235
    /* TODO: o_flags should be set to RS6K_AOUTHDR_TLS_LE
4236
       if there is at least one R_TLS_LE relocations.  */
4237
0
    internal_a.o_flags = 0;
4238
#ifdef XCOFF64
4239
    internal_a.o_x64flags = 0;
4240
#endif
4241
0
  }
4242
0
      else
4243
0
  {
4244
0
    internal_a.o_sntdata = 0;
4245
0
    internal_a.o_flags = 0;
4246
#ifdef XCOFF64
4247
    internal_a.o_x64flags = 0;
4248
#endif
4249
0
  }
4250
0
      if (tbss_sec != NULL)
4251
0
    internal_a.o_sntbss = tbss_sec->target_index;
4252
0
      else
4253
0
    internal_a.o_sntbss = 0;
4254
4255
0
      toc = xcoff_data (abfd)->toc;
4256
      internal_a.o_toc = toc;
4257
0
      internal_a.o_sntoc = xcoff_data (abfd)->sntoc;
4258
4259
0
      internal_a.o_modtype = xcoff_data (abfd)->modtype;
4260
0
      if (xcoff_data (abfd)->cputype != -1)
4261
0
  internal_a.o_cputype = xcoff_data (abfd)->cputype;
4262
0
      else
4263
0
  {
4264
0
    switch (bfd_get_arch (abfd))
4265
0
      {
4266
0
      case bfd_arch_rs6000:
4267
0
        internal_a.o_cputype = 4;
4268
0
        break;
4269
0
      case bfd_arch_powerpc:
4270
0
        if (bfd_get_mach (abfd) == bfd_mach_ppc)
4271
0
    internal_a.o_cputype = 3;
4272
0
        else if (bfd_get_mach (abfd) == bfd_mach_ppc_620)
4273
0
    internal_a.o_cputype = 2;
4274
0
        else
4275
0
    internal_a.o_cputype = 1;
4276
0
        break;
4277
0
      default:
4278
0
        abort ();
4279
0
      }
4280
0
  }
4281
0
      internal_a.o_maxstack = xcoff_data (abfd)->maxstack;
4282
0
      internal_a.o_maxdata = xcoff_data (abfd)->maxdata;
4283
0
    }
4284
0
#endif
4285
4286
#ifdef COFF_WITH_PE
4287
  {
4288
    /* After object contents are finalized so we can compute a reasonable hash,
4289
       but before header is written so we can update it to point to debug directory.  */
4290
0
    struct pe_tdata *pe = pe_data (abfd);
4291
4292
0
    if (pe->build_id.after_write_object_contents != NULL)
4293
0
      (*pe->build_id.after_write_object_contents) (abfd);
4294
  }
4295
#endif
4296
4297
  /* Now write header.  */
4298
0
  if (bfd_seek (abfd, 0, SEEK_SET) != 0)
4299
0
    return false;
4300
4301
0
  {
4302
0
    char * buff;
4303
0
    bfd_size_type amount = bfd_coff_filhsz (abfd);
4304
4305
0
    buff = (char *) bfd_malloc (amount);
4306
0
    if (buff == NULL)
4307
0
      return false;
4308
4309
0
    bfd_coff_swap_filehdr_out (abfd, & internal_f, buff);
4310
0
    amount = bfd_write (buff, amount, abfd);
4311
4312
0
    free (buff);
4313
4314
0
    if (amount != bfd_coff_filhsz (abfd))
4315
0
      return false;
4316
0
  }
4317
4318
0
  if (abfd->flags & EXEC_P)
4319
0
    {
4320
      /* Note that peicode.h fills in a PEAOUTHDR, not an AOUTHDR.
4321
   include/coff/pe.h sets AOUTSZ == sizeof (PEAOUTHDR)).  */
4322
0
      char * buff;
4323
0
      bfd_size_type amount = bfd_coff_aoutsz (abfd);
4324
4325
0
      buff = (char *) bfd_malloc (amount);
4326
0
      if (buff == NULL)
4327
0
  return false;
4328
4329
0
      coff_swap_aouthdr_out (abfd, & internal_a, buff);
4330
0
      amount = bfd_write (buff, amount, abfd);
4331
4332
0
      free (buff);
4333
4334
0
      if (amount != bfd_coff_aoutsz (abfd))
4335
0
  return false;
4336
4337
#ifdef COFF_IMAGE_WITH_PE
4338
0
      if (! coff_apply_checksum (abfd))
4339
0
  return false;
4340
#endif
4341
0
    }
4342
#ifdef RS6000COFF_C
4343
#ifndef XCOFF64
4344
  else
4345
0
    {
4346
0
      AOUTHDR buff;
4347
0
      size_t size;
4348
4349
      /* XCOFF32 seems to always write at least a small a.out header.  */
4350
0
      coff_swap_aouthdr_out (abfd, & internal_a, & buff);
4351
0
      if (xcoff_data (abfd)->full_aouthdr)
4352
0
  size = bfd_coff_aoutsz (abfd);
4353
0
      else
4354
0
  size = SMALL_AOUTSZ;
4355
0
      if (bfd_write (&buff, size, abfd) != size)
4356
0
  return false;
4357
0
    }
4358
0
#endif
4359
#endif
4360
4361
0
  return true;
4362
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: pe-aarch64.c:coff_write_object_contents
Unexecuted instantiation: pei-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
4363
4364
static bool
4365
coff_set_section_contents (bfd * abfd,
4366
         sec_ptr section,
4367
         const void * location,
4368
         file_ptr offset,
4369
         bfd_size_type count)
4370
0
{
4371
0
  if (! abfd->output_has_begun) /* Set by bfd.c handler.  */
4372
0
    {
4373
0
      if (! coff_compute_section_file_positions (abfd))
4374
0
  return false;
4375
0
    }
4376
4377
#if defined(_LIB) && !defined(TARG_AUX)
4378
   /* The physical address field of a .lib section is used to hold the
4379
      number of shared libraries in the section.  This code counts the
4380
      number of sections being written, and increments the lma field
4381
      with the number.
4382
4383
      I have found no documentation on the contents of this section.
4384
      Experimentation indicates that the section contains zero or more
4385
      records, each of which has the following structure:
4386
4387
      - a (four byte) word holding the length of this record, in words,
4388
      - a word that always seems to be set to "2",
4389
      - the path to a shared library, null-terminated and then padded
4390
  to a whole word boundary.
4391
4392
      bfd_assert calls have been added to alert if an attempt is made
4393
      to write a section which doesn't follow these assumptions.  The
4394
      code has been tested on ISC 4.1 by me, and on SCO by Robert Lipe
4395
      <robertl@arnet.com> (Thanks!).
4396
4397
      Gvran Uddeborg <gvran@uddeborg.pp.se>.  */
4398
0
    if (strcmp (section->name, _LIB) == 0)
4399
0
      {
4400
0
  bfd_byte *rec, *recend;
4401
4402
  rec = (bfd_byte *) location;
4403
  recend = rec + count;
4404
0
  while (recend - rec >= 4)
4405
0
    {
4406
0
      size_t len = bfd_get_32 (abfd, rec);
4407
0
      if (len == 0 || len > (size_t) (recend - rec) / 4)
4408
0
        break;
4409
0
      rec += len * 4;
4410
0
      ++section->lma;
4411
0
    }
4412
4413
0
  BFD_ASSERT (rec == recend);
4414
0
      }
4415
0
#endif
4416
4417
  /* Don't write out bss sections - one way to do this is to
4418
       see if the filepos has not been set.  */
4419
0
  if (section->filepos == 0)
4420
0
    return true;
4421
4422
0
  if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0)
4423
0
    return false;
4424
4425
0
  if (count == 0)
4426
0
    return true;
4427
4428
0
  return bfd_write (location, count, abfd) == count;
4429
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: pe-aarch64.c:coff_set_section_contents
Unexecuted instantiation: pei-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
4430
4431
static void *
4432
buy_and_read (bfd *abfd, file_ptr where,
4433
        bfd_size_type nmemb, bfd_size_type size)
4434
3.94k
{
4435
3.94k
  size_t amt;
4436
4437
3.94k
  if (_bfd_mul_overflow (nmemb, size, &amt))
4438
0
    {
4439
0
      bfd_set_error (bfd_error_file_too_big);
4440
0
      return NULL;
4441
0
    }
4442
3.94k
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
81
    return NULL;
4444
3.86k
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
3.94k
}
pei-i386.c:buy_and_read
Line
Count
Source
4434
112
{
4435
112
  size_t amt;
4436
4437
112
  if (_bfd_mul_overflow (nmemb, size, &amt))
4438
0
    {
4439
0
      bfd_set_error (bfd_error_file_too_big);
4440
0
      return NULL;
4441
0
    }
4442
112
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
0
    return NULL;
4444
112
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
112
}
pe-x86_64.c:buy_and_read
Line
Count
Source
4434
185
{
4435
185
  size_t amt;
4436
4437
185
  if (_bfd_mul_overflow (nmemb, size, &amt))
4438
0
    {
4439
0
      bfd_set_error (bfd_error_file_too_big);
4440
0
      return NULL;
4441
0
    }
4442
185
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
0
    return NULL;
4444
185
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
185
}
pei-x86_64.c:buy_and_read
Line
Count
Source
4434
115
{
4435
115
  size_t amt;
4436
4437
115
  if (_bfd_mul_overflow (nmemb, size, &amt))
4438
0
    {
4439
0
      bfd_set_error (bfd_error_file_too_big);
4440
0
      return NULL;
4441
0
    }
4442
115
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
0
    return NULL;
4444
115
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
115
}
coff-x86_64.c:buy_and_read
Line
Count
Source
4434
256
{
4435
256
  size_t amt;
4436
4437
256
  if (_bfd_mul_overflow (nmemb, size, &amt))
4438
0
    {
4439
0
      bfd_set_error (bfd_error_file_too_big);
4440
0
      return NULL;
4441
0
    }
4442
256
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
0
    return NULL;
4444
256
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
256
}
coff64-rs6000.c:buy_and_read
Line
Count
Source
4434
313
{
4435
313
  size_t amt;
4436
4437
313
  if (_bfd_mul_overflow (nmemb, size, &amt))
4438
0
    {
4439
0
      bfd_set_error (bfd_error_file_too_big);
4440
0
      return NULL;
4441
0
    }
4442
313
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
81
    return NULL;
4444
232
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
313
}
pe-aarch64.c:buy_and_read
Line
Count
Source
4434
157
{
4435
157
  size_t amt;
4436
4437
157
  if (_bfd_mul_overflow (nmemb, size, &amt))
4438
0
    {
4439
0
      bfd_set_error (bfd_error_file_too_big);
4440
0
      return NULL;
4441
0
    }
4442
157
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
0
    return NULL;
4444
157
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
157
}
pei-aarch64.c:buy_and_read
Line
Count
Source
4434
145
{
4435
145
  size_t amt;
4436
4437
145
  if (_bfd_mul_overflow (nmemb, size, &amt))
4438
0
    {
4439
0
      bfd_set_error (bfd_error_file_too_big);
4440
0
      return NULL;
4441
0
    }
4442
145
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
0
    return NULL;
4444
145
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
145
}
pei-ia64.c:buy_and_read
Line
Count
Source
4434
199
{
4435
199
  size_t amt;
4436
4437
199
  if (_bfd_mul_overflow (nmemb, size, &amt))
4438
0
    {
4439
0
      bfd_set_error (bfd_error_file_too_big);
4440
0
      return NULL;
4441
0
    }
4442
199
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
0
    return NULL;
4444
199
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
199
}
pei-loongarch64.c:buy_and_read
Line
Count
Source
4434
125
{
4435
125
  size_t amt;
4436
4437
125
  if (_bfd_mul_overflow (nmemb, size, &amt))
4438
0
    {
4439
0
      bfd_set_error (bfd_error_file_too_big);
4440
0
      return NULL;
4441
0
    }
4442
125
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
0
    return NULL;
4444
125
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
125
}
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
4434
236
{
4435
236
  size_t amt;
4436
4437
236
  if (_bfd_mul_overflow (nmemb, size, &amt))
4438
0
    {
4439
0
      bfd_set_error (bfd_error_file_too_big);
4440
0
      return NULL;
4441
0
    }
4442
236
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
0
    return NULL;
4444
236
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
236
}
coff-sh.c:buy_and_read
Line
Count
Source
4434
301
{
4435
301
  size_t amt;
4436
4437
301
  if (_bfd_mul_overflow (nmemb, size, &amt))
4438
0
    {
4439
0
      bfd_set_error (bfd_error_file_too_big);
4440
0
      return NULL;
4441
0
    }
4442
301
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
0
    return NULL;
4444
301
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
301
}
Unexecuted instantiation: coff-stgo32.c:buy_and_read
coff-tic30.c:buy_and_read
Line
Count
Source
4434
365
{
4435
365
  size_t amt;
4436
4437
365
  if (_bfd_mul_overflow (nmemb, size, &amt))
4438
0
    {
4439
0
      bfd_set_error (bfd_error_file_too_big);
4440
0
      return NULL;
4441
0
    }
4442
365
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
0
    return NULL;
4444
365
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
365
}
Unexecuted instantiation: coff-tic4x.c:buy_and_read
coff-tic54x.c:buy_and_read
Line
Count
Source
4434
206
{
4435
206
  size_t amt;
4436
4437
206
  if (_bfd_mul_overflow (nmemb, size, &amt))
4438
0
    {
4439
0
      bfd_set_error (bfd_error_file_too_big);
4440
0
      return NULL;
4441
0
    }
4442
206
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
0
    return NULL;
4444
206
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
206
}
coff-z80.c:buy_and_read
Line
Count
Source
4434
210
{
4435
210
  size_t amt;
4436
4437
210
  if (_bfd_mul_overflow (nmemb, size, &amt))
4438
0
    {
4439
0
      bfd_set_error (bfd_error_file_too_big);
4440
0
      return NULL;
4441
0
    }
4442
210
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
0
    return NULL;
4444
210
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
210
}
coff-z8k.c:buy_and_read
Line
Count
Source
4434
213
{
4435
213
  size_t amt;
4436
4437
213
  if (_bfd_mul_overflow (nmemb, size, &amt))
4438
0
    {
4439
0
      bfd_set_error (bfd_error_file_too_big);
4440
0
      return NULL;
4441
0
    }
4442
213
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
0
    return NULL;
4444
213
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
213
}
Unexecuted instantiation: pe-arm-wince.c:buy_and_read
Unexecuted instantiation: pe-arm.c:buy_and_read
pe-i386.c:buy_and_read
Line
Count
Source
4434
86
{
4435
86
  size_t amt;
4436
4437
86
  if (_bfd_mul_overflow (nmemb, size, &amt))
4438
0
    {
4439
0
      bfd_set_error (bfd_error_file_too_big);
4440
0
      return NULL;
4441
0
    }
4442
86
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
0
    return NULL;
4444
86
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
86
}
pe-mcore.c:buy_and_read
Line
Count
Source
4434
94
{
4435
94
  size_t amt;
4436
4437
94
  if (_bfd_mul_overflow (nmemb, size, &amt))
4438
0
    {
4439
0
      bfd_set_error (bfd_error_file_too_big);
4440
0
      return NULL;
4441
0
    }
4442
94
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
0
    return NULL;
4444
94
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
94
}
pe-sh.c:buy_and_read
Line
Count
Source
4434
137
{
4435
137
  size_t amt;
4436
4437
137
  if (_bfd_mul_overflow (nmemb, size, &amt))
4438
0
    {
4439
0
      bfd_set_error (bfd_error_file_too_big);
4440
0
      return NULL;
4441
0
    }
4442
137
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
0
    return NULL;
4444
137
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
137
}
pei-arm-wince.c:buy_and_read
Line
Count
Source
4434
101
{
4435
101
  size_t amt;
4436
4437
101
  if (_bfd_mul_overflow (nmemb, size, &amt))
4438
0
    {
4439
0
      bfd_set_error (bfd_error_file_too_big);
4440
0
      return NULL;
4441
0
    }
4442
101
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
0
    return NULL;
4444
101
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
101
}
pei-arm.c:buy_and_read
Line
Count
Source
4434
164
{
4435
164
  size_t amt;
4436
4437
164
  if (_bfd_mul_overflow (nmemb, size, &amt))
4438
0
    {
4439
0
      bfd_set_error (bfd_error_file_too_big);
4440
0
      return NULL;
4441
0
    }
4442
164
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
0
    return NULL;
4444
164
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
164
}
pei-mcore.c:buy_and_read
Line
Count
Source
4434
104
{
4435
104
  size_t amt;
4436
4437
104
  if (_bfd_mul_overflow (nmemb, size, &amt))
4438
0
    {
4439
0
      bfd_set_error (bfd_error_file_too_big);
4440
0
      return NULL;
4441
0
    }
4442
104
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
0
    return NULL;
4444
104
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
104
}
pei-sh.c:buy_and_read
Line
Count
Source
4434
121
{
4435
121
  size_t amt;
4436
4437
121
  if (_bfd_mul_overflow (nmemb, size, &amt))
4438
0
    {
4439
0
      bfd_set_error (bfd_error_file_too_big);
4440
0
      return NULL;
4441
0
    }
4442
121
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
0
    return NULL;
4444
121
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
121
}
4446
4447
/*
4448
SUBSUBSECTION
4449
  Reading linenumbers
4450
4451
  Creating the linenumber table is done by reading in the entire
4452
  coff linenumber table, and creating another table for internal use.
4453
4454
  A coff linenumber table is structured so that each function
4455
  is marked as having a line number of 0. Each line within the
4456
  function is an offset from the first line in the function. The
4457
  base of the line number information for the table is stored in
4458
  the symbol associated with the function.
4459
4460
  Note: The PE format uses line number 0 for a flag indicating a
4461
  new source file.
4462
4463
  The information is copied from the external to the internal
4464
  table, and each symbol which marks a function is marked by
4465
  pointing its...
4466
4467
  How does this work ?
4468
*/
4469
4470
static int
4471
coff_sort_func_alent (const void * arg1, const void * arg2)
4472
4.00M
{
4473
4.00M
  const alent *al1 = *(const alent **) arg1;
4474
4.00M
  const alent *al2 = *(const alent **) arg2;
4475
4.00M
  const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym);
4476
4.00M
  const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym);
4477
4478
4.00M
  if (s1 == NULL || s2 == NULL)
4479
0
    return 0;
4480
4.00M
  if (s1->symbol.value < s2->symbol.value)
4481
66.1k
    return -1;
4482
3.94M
  else if (s1->symbol.value > s2->symbol.value)
4483
977k
    return 1;
4484
4485
2.96M
  return 0;
4486
4.00M
}
pei-i386.c:coff_sort_func_alent
Line
Count
Source
4472
270k
{
4473
270k
  const alent *al1 = *(const alent **) arg1;
4474
270k
  const alent *al2 = *(const alent **) arg2;
4475
270k
  const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym);
4476
270k
  const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym);
4477
4478
270k
  if (s1 == NULL || s2 == NULL)
4479
0
    return 0;
4480
270k
  if (s1->symbol.value < s2->symbol.value)
4481
5.03k
    return -1;
4482
265k
  else if (s1->symbol.value > s2->symbol.value)
4483
58.5k
    return 1;
4484
4485
206k
  return 0;
4486
270k
}
pe-x86_64.c:coff_sort_func_alent
Line
Count
Source
4472
18.8k
{
4473
18.8k
  const alent *al1 = *(const alent **) arg1;
4474
18.8k
  const alent *al2 = *(const alent **) arg2;
4475
18.8k
  const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym);
4476
18.8k
  const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym);
4477
4478
18.8k
  if (s1 == NULL || s2 == NULL)
4479
0
    return 0;
4480
18.8k
  if (s1->symbol.value < s2->symbol.value)
4481
382
    return -1;
4482
18.4k
  else if (s1->symbol.value > s2->symbol.value)
4483
2.59k
    return 1;
4484
4485
15.8k
  return 0;
4486
18.8k
}
pei-x86_64.c:coff_sort_func_alent
Line
Count
Source
4472
213k
{
4473
213k
  const alent *al1 = *(const alent **) arg1;
4474
213k
  const alent *al2 = *(const alent **) arg2;
4475
213k
  const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym);
4476
213k
  const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym);
4477
4478
213k
  if (s1 == NULL || s2 == NULL)
4479
0
    return 0;
4480
213k
  if (s1->symbol.value < s2->symbol.value)
4481
3.52k
    return -1;
4482
209k
  else if (s1->symbol.value > s2->symbol.value)
4483
50.3k
    return 1;
4484
4485
159k
  return 0;
4486
213k
}
coff-x86_64.c:coff_sort_func_alent
Line
Count
Source
4472
47.9k
{
4473
47.9k
  const alent *al1 = *(const alent **) arg1;
4474
47.9k
  const alent *al2 = *(const alent **) arg2;
4475
47.9k
  const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym);
4476
47.9k
  const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym);
4477
4478
47.9k
  if (s1 == NULL || s2 == NULL)
4479
0
    return 0;
4480
47.9k
  if (s1->symbol.value < s2->symbol.value)
4481
1.25k
    return -1;
4482
46.7k
  else if (s1->symbol.value > s2->symbol.value)
4483
12.7k
    return 1;
4484
4485
34.0k
  return 0;
4486
47.9k
}
coff64-rs6000.c:coff_sort_func_alent
Line
Count
Source
4472
195k
{
4473
195k
  const alent *al1 = *(const alent **) arg1;
4474
195k
  const alent *al2 = *(const alent **) arg2;
4475
195k
  const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym);
4476
195k
  const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym);
4477
4478
195k
  if (s1 == NULL || s2 == NULL)
4479
0
    return 0;
4480
195k
  if (s1->symbol.value < s2->symbol.value)
4481
2.42k
    return -1;
4482
193k
  else if (s1->symbol.value > s2->symbol.value)
4483
41.4k
    return 1;
4484
4485
151k
  return 0;
4486
195k
}
pe-aarch64.c:coff_sort_func_alent
Line
Count
Source
4472
54.6k
{
4473
54.6k
  const alent *al1 = *(const alent **) arg1;
4474
54.6k
  const alent *al2 = *(const alent **) arg2;
4475
54.6k
  const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym);
4476
54.6k
  const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym);
4477
4478
54.6k
  if (s1 == NULL || s2 == NULL)
4479
0
    return 0;
4480
54.6k
  if (s1->symbol.value < s2->symbol.value)
4481
2.59k
    return -1;
4482
52.0k
  else if (s1->symbol.value > s2->symbol.value)
4483
19.4k
    return 1;
4484
4485
32.6k
  return 0;
4486
54.6k
}
pei-aarch64.c:coff_sort_func_alent
Line
Count
Source
4472
430k
{
4473
430k
  const alent *al1 = *(const alent **) arg1;
4474
430k
  const alent *al2 = *(const alent **) arg2;
4475
430k
  const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym);
4476
430k
  const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym);
4477
4478
430k
  if (s1 == NULL || s2 == NULL)
4479
0
    return 0;
4480
430k
  if (s1->symbol.value < s2->symbol.value)
4481
6.10k
    return -1;
4482
424k
  else if (s1->symbol.value > s2->symbol.value)
4483
46.0k
    return 1;
4484
4485
378k
  return 0;
4486
430k
}
pei-ia64.c:coff_sort_func_alent
Line
Count
Source
4472
114k
{
4473
114k
  const alent *al1 = *(const alent **) arg1;
4474
114k
  const alent *al2 = *(const alent **) arg2;
4475
114k
  const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym);
4476
114k
  const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym);
4477
4478
114k
  if (s1 == NULL || s2 == NULL)
4479
0
    return 0;
4480
114k
  if (s1->symbol.value < s2->symbol.value)
4481
2.16k
    return -1;
4482
112k
  else if (s1->symbol.value > s2->symbol.value)
4483
22.3k
    return 1;
4484
4485
89.7k
  return 0;
4486
114k
}
pei-loongarch64.c:coff_sort_func_alent
Line
Count
Source
4472
497k
{
4473
497k
  const alent *al1 = *(const alent **) arg1;
4474
497k
  const alent *al2 = *(const alent **) arg2;
4475
497k
  const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym);
4476
497k
  const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym);
4477
4478
497k
  if (s1 == NULL || s2 == NULL)
4479
0
    return 0;
4480
497k
  if (s1->symbol.value < s2->symbol.value)
4481
6.35k
    return -1;
4482
490k
  else if (s1->symbol.value > s2->symbol.value)
4483
174k
    return 1;
4484
4485
316k
  return 0;
4486
497k
}
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
4472
50.5k
{
4473
50.5k
  const alent *al1 = *(const alent **) arg1;
4474
50.5k
  const alent *al2 = *(const alent **) arg2;
4475
50.5k
  const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym);
4476
50.5k
  const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym);
4477
4478
50.5k
  if (s1 == NULL || s2 == NULL)
4479
0
    return 0;
4480
50.5k
  if (s1->symbol.value < s2->symbol.value)
4481
1.00k
    return -1;
4482
49.5k
  else if (s1->symbol.value > s2->symbol.value)
4483
7.86k
    return 1;
4484
4485
41.6k
  return 0;
4486
50.5k
}
coff-sh.c:coff_sort_func_alent
Line
Count
Source
4472
82.6k
{
4473
82.6k
  const alent *al1 = *(const alent **) arg1;
4474
82.6k
  const alent *al2 = *(const alent **) arg2;
4475
82.6k
  const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym);
4476
82.6k
  const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym);
4477
4478
82.6k
  if (s1 == NULL || s2 == NULL)
4479
0
    return 0;
4480
82.6k
  if (s1->symbol.value < s2->symbol.value)
4481
3.11k
    return -1;
4482
79.4k
  else if (s1->symbol.value > s2->symbol.value)
4483
22.4k
    return 1;
4484
4485
57.0k
  return 0;
4486
82.6k
}
Unexecuted instantiation: coff-stgo32.c:coff_sort_func_alent
coff-tic30.c:coff_sort_func_alent
Line
Count
Source
4472
40.4k
{
4473
40.4k
  const alent *al1 = *(const alent **) arg1;
4474
40.4k
  const alent *al2 = *(const alent **) arg2;
4475
40.4k
  const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym);
4476
40.4k
  const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym);
4477
4478
40.4k
  if (s1 == NULL || s2 == NULL)
4479
0
    return 0;
4480
40.4k
  if (s1->symbol.value < s2->symbol.value)
4481
646
    return -1;
4482
39.7k
  else if (s1->symbol.value > s2->symbol.value)
4483
8.38k
    return 1;
4484
4485
31.4k
  return 0;
4486
40.4k
}
Unexecuted instantiation: coff-tic4x.c:coff_sort_func_alent
coff-tic54x.c:coff_sort_func_alent
Line
Count
Source
4472
163k
{
4473
163k
  const alent *al1 = *(const alent **) arg1;
4474
163k
  const alent *al2 = *(const alent **) arg2;
4475
163k
  const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym);
4476
163k
  const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym);
4477
4478
163k
  if (s1 == NULL || s2 == NULL)
4479
0
    return 0;
4480
163k
  if (s1->symbol.value < s2->symbol.value)
4481
2.21k
    return -1;
4482
161k
  else if (s1->symbol.value > s2->symbol.value)
4483
41.7k
    return 1;
4484
4485
119k
  return 0;
4486
163k
}
coff-z80.c:coff_sort_func_alent
Line
Count
Source
4472
132k
{
4473
132k
  const alent *al1 = *(const alent **) arg1;
4474
132k
  const alent *al2 = *(const alent **) arg2;
4475
132k
  const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym);
4476
132k
  const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym);
4477
4478
132k
  if (s1 == NULL || s2 == NULL)
4479
0
    return 0;
4480
132k
  if (s1->symbol.value < s2->symbol.value)
4481
782
    return -1;
4482
131k
  else if (s1->symbol.value > s2->symbol.value)
4483
19.4k
    return 1;
4484
4485
112k
  return 0;
4486
132k
}
coff-z8k.c:coff_sort_func_alent
Line
Count
Source
4472
209k
{
4473
209k
  const alent *al1 = *(const alent **) arg1;
4474
209k
  const alent *al2 = *(const alent **) arg2;
4475
209k
  const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym);
4476
209k
  const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym);
4477
4478
209k
  if (s1 == NULL || s2 == NULL)
4479
0
    return 0;
4480
209k
  if (s1->symbol.value < s2->symbol.value)
4481
2.78k
    return -1;
4482
206k
  else if (s1->symbol.value > s2->symbol.value)
4483
68.0k
    return 1;
4484
4485
138k
  return 0;
4486
209k
}
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
4472
137k
{
4473
137k
  const alent *al1 = *(const alent **) arg1;
4474
137k
  const alent *al2 = *(const alent **) arg2;
4475
137k
  const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym);
4476
137k
  const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym);
4477
4478
137k
  if (s1 == NULL || s2 == NULL)
4479
0
    return 0;
4480
137k
  if (s1->symbol.value < s2->symbol.value)
4481
3.65k
    return -1;
4482
134k
  else if (s1->symbol.value > s2->symbol.value)
4483
33.1k
    return 1;
4484
4485
101k
  return 0;
4486
137k
}
pe-mcore.c:coff_sort_func_alent
Line
Count
Source
4472
338k
{
4473
338k
  const alent *al1 = *(const alent **) arg1;
4474
338k
  const alent *al2 = *(const alent **) arg2;
4475
338k
  const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym);
4476
338k
  const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym);
4477
4478
338k
  if (s1 == NULL || s2 == NULL)
4479
0
    return 0;
4480
338k
  if (s1->symbol.value < s2->symbol.value)
4481
1.68k
    return -1;
4482
337k
  else if (s1->symbol.value > s2->symbol.value)
4483
102k
    return 1;
4484
4485
234k
  return 0;
4486
338k
}
pe-sh.c:coff_sort_func_alent
Line
Count
Source
4472
121k
{
4473
121k
  const alent *al1 = *(const alent **) arg1;
4474
121k
  const alent *al2 = *(const alent **) arg2;
4475
121k
  const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym);
4476
121k
  const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym);
4477
4478
121k
  if (s1 == NULL || s2 == NULL)
4479
0
    return 0;
4480
121k
  if (s1->symbol.value < s2->symbol.value)
4481
2.41k
    return -1;
4482
118k
  else if (s1->symbol.value > s2->symbol.value)
4483
40.6k
    return 1;
4484
4485
78.0k
  return 0;
4486
121k
}
pei-arm-wince.c:coff_sort_func_alent
Line
Count
Source
4472
344k
{
4473
344k
  const alent *al1 = *(const alent **) arg1;
4474
344k
  const alent *al2 = *(const alent **) arg2;
4475
344k
  const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym);
4476
344k
  const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym);
4477
4478
344k
  if (s1 == NULL || s2 == NULL)
4479
0
    return 0;
4480
344k
  if (s1->symbol.value < s2->symbol.value)
4481
5.81k
    return -1;
4482
338k
  else if (s1->symbol.value > s2->symbol.value)
4483
73.6k
    return 1;
4484
4485
265k
  return 0;
4486
344k
}
pei-arm.c:coff_sort_func_alent
Line
Count
Source
4472
346k
{
4473
346k
  const alent *al1 = *(const alent **) arg1;
4474
346k
  const alent *al2 = *(const alent **) arg2;
4475
346k
  const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym);
4476
346k
  const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym);
4477
4478
346k
  if (s1 == NULL || s2 == NULL)
4479
0
    return 0;
4480
346k
  if (s1->symbol.value < s2->symbol.value)
4481
8.19k
    return -1;
4482
338k
  else if (s1->symbol.value > s2->symbol.value)
4483
95.0k
    return 1;
4484
4485
243k
  return 0;
4486
346k
}
pei-mcore.c:coff_sort_func_alent
Line
Count
Source
4472
113k
{
4473
113k
  const alent *al1 = *(const alent **) arg1;
4474
113k
  const alent *al2 = *(const alent **) arg2;
4475
113k
  const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym);
4476
113k
  const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym);
4477
4478
113k
  if (s1 == NULL || s2 == NULL)
4479
0
    return 0;
4480
113k
  if (s1->symbol.value < s2->symbol.value)
4481
2.00k
    return -1;
4482
111k
  else if (s1->symbol.value > s2->symbol.value)
4483
13.2k
    return 1;
4484
4485
97.7k
  return 0;
4486
113k
}
pei-sh.c:coff_sort_func_alent
Line
Count
Source
4472
85.7k
{
4473
85.7k
  const alent *al1 = *(const alent **) arg1;
4474
85.7k
  const alent *al2 = *(const alent **) arg2;
4475
85.7k
  const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym);
4476
85.7k
  const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym);
4477
4478
85.7k
  if (s1 == NULL || s2 == NULL)
4479
0
    return 0;
4480
85.7k
  if (s1->symbol.value < s2->symbol.value)
4481
2.00k
    return -1;
4482
83.7k
  else if (s1->symbol.value > s2->symbol.value)
4483
22.5k
    return 1;
4484
4485
61.2k
  return 0;
4486
85.7k
}
4487
4488
static bool
4489
coff_slurp_line_table (bfd *abfd, asection *asect)
4490
11.7k
{
4491
11.7k
  LINENO *native_lineno;
4492
11.7k
  alent *lineno_cache;
4493
11.7k
  unsigned int counter;
4494
11.7k
  alent *cache_ptr;
4495
11.7k
  bfd_vma prev_offset = 0;
4496
11.7k
  bool ordered = true;
4497
11.7k
  unsigned int nbr_func;
4498
11.7k
  LINENO *src;
4499
11.7k
  bool have_func;
4500
11.7k
  bool ret = true;
4501
11.7k
  size_t amt;
4502
4503
11.7k
  if (asect->lineno_count == 0)
4504
7.95k
    return true;
4505
4506
3.82k
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
3.82k
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
3.82k
             asect->lineno_count,
4510
3.82k
             bfd_coff_linesz (abfd));
4511
3.82k
  if (native_lineno == NULL)
4512
1.74k
    {
4513
1.74k
      _bfd_error_handler
4514
1.74k
  (_("%pB: warning: line number table read failed"), abfd);
4515
1.74k
      return false;
4516
1.74k
    }
4517
4518
2.08k
  if (_bfd_mul_overflow (asect->lineno_count + 1, sizeof (alent), &amt))
4519
0
    {
4520
0
      bfd_set_error (bfd_error_file_too_big);
4521
0
      free (native_lineno);
4522
0
      return false;
4523
0
    }
4524
2.08k
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
2.08k
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
2.08k
  cache_ptr = lineno_cache;
4532
2.08k
  asect->lineno = lineno_cache;
4533
2.08k
  src = native_lineno;
4534
2.08k
  nbr_func = 0;
4535
2.08k
  have_func = false;
4536
4537
3.94M
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
3.93M
    {
4539
3.93M
      struct internal_lineno dst;
4540
4541
3.93M
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
3.93M
      cache_ptr->line_number = dst.l_lnno;
4543
      /* Appease memory checkers that get all excited about
4544
   uninitialised memory when copying alents if u.offset is
4545
   larger than u.sym.  (64-bit BFD on 32-bit host.)  */
4546
3.93M
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
3.93M
      if (cache_ptr->line_number == 0)
4549
1.56M
  {
4550
1.56M
    combined_entry_type * ent;
4551
1.56M
    unsigned long symndx;
4552
1.56M
    coff_symbol_type *sym;
4553
4554
1.56M
    have_func = false;
4555
1.56M
    symndx = dst.l_addr.l_symndx;
4556
1.56M
    if (symndx >= obj_raw_syment_count (abfd))
4557
779k
      {
4558
779k
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
779k
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
779k
     abfd, symndx, counter);
4562
779k
        cache_ptr->line_number = -1;
4563
779k
        ret = false;
4564
779k
        continue;
4565
779k
      }
4566
4567
782k
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
782k
    if (! ent->is_sym)
4571
147k
      {
4572
147k
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
147k
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
147k
     abfd, symndx, counter);
4576
147k
        cache_ptr->line_number = -1;
4577
147k
        ret = false;
4578
147k
        continue;
4579
147k
      }
4580
634k
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
634k
    if (sym < obj_symbols (abfd)
4584
634k
        || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd))
4585
0
      {
4586
0
        _bfd_error_handler
4587
    /* xgettext:c-format */
4588
0
    (_("%pB: warning: illegal symbol in line number entry %d"),
4589
0
     abfd, counter);
4590
0
        cache_ptr->line_number = -1;
4591
0
        ret = false;
4592
0
        continue;
4593
0
      }
4594
4595
634k
    have_func = true;
4596
634k
    nbr_func++;
4597
634k
    cache_ptr->u.sym = (asymbol *) sym;
4598
634k
    if (sym->lineno != NULL)
4599
622k
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
622k
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
622k
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
634k
    sym->lineno = cache_ptr;
4605
634k
    if (sym->symbol.value < prev_offset)
4606
21.3k
      ordered = false;
4607
634k
    prev_offset = sym->symbol.value;
4608
634k
  }
4609
2.37M
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
1.59M
  continue;
4613
777k
      else
4614
777k
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
1.41M
      cache_ptr++;
4616
1.41M
    }
4617
4618
2.08k
  asect->lineno_count = cache_ptr - lineno_cache;
4619
2.08k
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
2.08k
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
2.08k
  if (!ordered)
4624
1.23k
    {
4625
      /* Sort the table.  */
4626
1.23k
      alent **func_table;
4627
1.23k
      alent *n_lineno_cache;
4628
4629
      /* Create a table of functions.  */
4630
1.23k
      if (_bfd_mul_overflow (nbr_func, sizeof (alent *), &amt))
4631
0
  {
4632
0
    bfd_set_error (bfd_error_file_too_big);
4633
0
    ret = false;
4634
0
  }
4635
1.23k
      else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL)
4636
1.23k
  {
4637
1.23k
    alent **p = func_table;
4638
1.23k
    unsigned int i;
4639
4640
1.35M
    for (i = 0; i < asect->lineno_count; i++)
4641
1.35M
      if (lineno_cache[i].line_number == 0)
4642
604k
        *p++ = &lineno_cache[i];
4643
4644
1.23k
    BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func);
4645
4646
    /* Sort by functions.  */
4647
1.23k
    qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent);
4648
4649
    /* Create the new sorted table.  */
4650
1.23k
    if (_bfd_mul_overflow (asect->lineno_count, sizeof (alent), &amt))
4651
0
      {
4652
0
        bfd_set_error (bfd_error_file_too_big);
4653
0
        ret = false;
4654
0
      }
4655
1.23k
    else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL)
4656
1.23k
      {
4657
1.23k
        alent *n_cache_ptr = n_lineno_cache;
4658
4659
605k
        for (i = 0; i < nbr_func; i++)
4660
604k
    {
4661
604k
      coff_symbol_type *sym;
4662
604k
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
604k
      sym = (coff_symbol_type *) old_ptr->u.sym;
4666
      /* PR binutils/17512: Point the lineno to where
4667
         this entry will be after the memcpy below.  */
4668
604k
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
604k
      do
4671
1.35M
        *n_cache_ptr++ = *old_ptr++;
4672
1.35M
      while (old_ptr->line_number != 0);
4673
604k
    }
4674
4675
1.23k
        memcpy (lineno_cache, n_lineno_cache,
4676
1.23k
          asect->lineno_count * sizeof (alent));
4677
1.23k
      }
4678
0
    else
4679
0
      ret = false;
4680
1.23k
    bfd_release (abfd, func_table);
4681
1.23k
  }
4682
0
      else
4683
0
  ret = false;
4684
1.23k
    }
4685
4686
2.08k
  return ret;
4687
2.08k
}
pei-i386.c:coff_slurp_line_table
Line
Count
Source
4490
208
{
4491
208
  LINENO *native_lineno;
4492
208
  alent *lineno_cache;
4493
208
  unsigned int counter;
4494
208
  alent *cache_ptr;
4495
208
  bfd_vma prev_offset = 0;
4496
208
  bool ordered = true;
4497
208
  unsigned int nbr_func;
4498
208
  LINENO *src;
4499
208
  bool have_func;
4500
208
  bool ret = true;
4501
208
  size_t amt;
4502
4503
208
  if (asect->lineno_count == 0)
4504
96
    return true;
4505
4506
112
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
112
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
112
             asect->lineno_count,
4510
112
             bfd_coff_linesz (abfd));
4511
112
  if (native_lineno == NULL)
4512
68
    {
4513
68
      _bfd_error_handler
4514
68
  (_("%pB: warning: line number table read failed"), abfd);
4515
68
      return false;
4516
68
    }
4517
4518
44
  if (_bfd_mul_overflow (asect->lineno_count + 1, sizeof (alent), &amt))
4519
0
    {
4520
0
      bfd_set_error (bfd_error_file_too_big);
4521
0
      free (native_lineno);
4522
0
      return false;
4523
0
    }
4524
44
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
44
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
44
  cache_ptr = lineno_cache;
4532
44
  asect->lineno = lineno_cache;
4533
44
  src = native_lineno;
4534
44
  nbr_func = 0;
4535
44
  have_func = false;
4536
4537
125k
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
125k
    {
4539
125k
      struct internal_lineno dst;
4540
4541
125k
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
125k
      cache_ptr->line_number = dst.l_lnno;
4543
      /* Appease memory checkers that get all excited about
4544
   uninitialised memory when copying alents if u.offset is
4545
   larger than u.sym.  (64-bit BFD on 32-bit host.)  */
4546
125k
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
125k
      if (cache_ptr->line_number == 0)
4549
64.3k
  {
4550
64.3k
    combined_entry_type * ent;
4551
64.3k
    unsigned long symndx;
4552
64.3k
    coff_symbol_type *sym;
4553
4554
64.3k
    have_func = false;
4555
64.3k
    symndx = dst.l_addr.l_symndx;
4556
64.3k
    if (symndx >= obj_raw_syment_count (abfd))
4557
23.3k
      {
4558
23.3k
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
23.3k
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
23.3k
     abfd, symndx, counter);
4562
23.3k
        cache_ptr->line_number = -1;
4563
23.3k
        ret = false;
4564
23.3k
        continue;
4565
23.3k
      }
4566
4567
40.9k
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
40.9k
    if (! ent->is_sym)
4571
3.60k
      {
4572
3.60k
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
3.60k
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
3.60k
     abfd, symndx, counter);
4576
3.60k
        cache_ptr->line_number = -1;
4577
3.60k
        ret = false;
4578
3.60k
        continue;
4579
3.60k
      }
4580
37.3k
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
37.3k
    if (sym < obj_symbols (abfd)
4584
37.3k
        || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd))
4585
0
      {
4586
0
        _bfd_error_handler
4587
    /* xgettext:c-format */
4588
0
    (_("%pB: warning: illegal symbol in line number entry %d"),
4589
0
     abfd, counter);
4590
0
        cache_ptr->line_number = -1;
4591
0
        ret = false;
4592
0
        continue;
4593
0
      }
4594
4595
37.3k
    have_func = true;
4596
37.3k
    nbr_func++;
4597
37.3k
    cache_ptr->u.sym = (asymbol *) sym;
4598
37.3k
    if (sym->lineno != NULL)
4599
36.7k
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
36.7k
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
36.7k
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
37.3k
    sym->lineno = cache_ptr;
4605
37.3k
    if (sym->symbol.value < prev_offset)
4606
1.24k
      ordered = false;
4607
37.3k
    prev_offset = sym->symbol.value;
4608
37.3k
  }
4609
61.2k
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
32.6k
  continue;
4613
28.5k
      else
4614
28.5k
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
65.9k
      cache_ptr++;
4616
65.9k
    }
4617
4618
44
  asect->lineno_count = cache_ptr - lineno_cache;
4619
44
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
44
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
44
  if (!ordered)
4624
32
    {
4625
      /* Sort the table.  */
4626
32
      alent **func_table;
4627
32
      alent *n_lineno_cache;
4628
4629
      /* Create a table of functions.  */
4630
32
      if (_bfd_mul_overflow (nbr_func, sizeof (alent *), &amt))
4631
0
  {
4632
0
    bfd_set_error (bfd_error_file_too_big);
4633
0
    ret = false;
4634
0
  }
4635
32
      else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL)
4636
32
  {
4637
32
    alent **p = func_table;
4638
32
    unsigned int i;
4639
4640
65.9k
    for (i = 0; i < asect->lineno_count; i++)
4641
65.9k
      if (lineno_cache[i].line_number == 0)
4642
37.3k
        *p++ = &lineno_cache[i];
4643
4644
32
    BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func);
4645
4646
    /* Sort by functions.  */
4647
32
    qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent);
4648
4649
    /* Create the new sorted table.  */
4650
32
    if (_bfd_mul_overflow (asect->lineno_count, sizeof (alent), &amt))
4651
0
      {
4652
0
        bfd_set_error (bfd_error_file_too_big);
4653
0
        ret = false;
4654
0
      }
4655
32
    else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL)
4656
32
      {
4657
32
        alent *n_cache_ptr = n_lineno_cache;
4658
4659
37.3k
        for (i = 0; i < nbr_func; i++)
4660
37.3k
    {
4661
37.3k
      coff_symbol_type *sym;
4662
37.3k
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
37.3k
      sym = (coff_symbol_type *) old_ptr->u.sym;
4666
      /* PR binutils/17512: Point the lineno to where
4667
         this entry will be after the memcpy below.  */
4668
37.3k
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
37.3k
      do
4671
65.9k
        *n_cache_ptr++ = *old_ptr++;
4672
65.9k
      while (old_ptr->line_number != 0);
4673
37.3k
    }
4674
4675
32
        memcpy (lineno_cache, n_lineno_cache,
4676
32
          asect->lineno_count * sizeof (alent));
4677
32
      }
4678
0
    else
4679
0
      ret = false;
4680
32
    bfd_release (abfd, func_table);
4681
32
  }
4682
0
      else
4683
0
  ret = false;
4684
32
    }
4685
4686
44
  return ret;
4687
44
}
pe-x86_64.c:coff_slurp_line_table
Line
Count
Source
4490
629
{
4491
629
  LINENO *native_lineno;
4492
629
  alent *lineno_cache;
4493
629
  unsigned int counter;
4494
629
  alent *cache_ptr;
4495
629
  bfd_vma prev_offset = 0;
4496
629
  bool ordered = true;
4497
629
  unsigned int nbr_func;
4498
629
  LINENO *src;
4499
629
  bool have_func;
4500
629
  bool ret = true;
4501
629
  size_t amt;
4502
4503
629
  if (asect->lineno_count == 0)
4504
444
    return true;
4505
4506
185
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
185
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
185
             asect->lineno_count,
4510
185
             bfd_coff_linesz (abfd));
4511
185
  if (native_lineno == NULL)
4512
83
    {
4513
83
      _bfd_error_handler
4514
83
  (_("%pB: warning: line number table read failed"), abfd);
4515
83
      return false;
4516
83
    }
4517
4518
102
  if (_bfd_mul_overflow (asect->lineno_count + 1, sizeof (alent), &amt))
4519
0
    {
4520
0
      bfd_set_error (bfd_error_file_too_big);
4521
0
      free (native_lineno);
4522
0
      return false;
4523
0
    }
4524
102
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
102
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
102
  cache_ptr = lineno_cache;
4532
102
  asect->lineno = lineno_cache;
4533
102
  src = native_lineno;
4534
102
  nbr_func = 0;
4535
102
  have_func = false;
4536
4537
18.5k
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
18.4k
    {
4539
18.4k
      struct internal_lineno dst;
4540
4541
18.4k
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
18.4k
      cache_ptr->line_number = dst.l_lnno;
4543
      /* Appease memory checkers that get all excited about
4544
   uninitialised memory when copying alents if u.offset is
4545
   larger than u.sym.  (64-bit BFD on 32-bit host.)  */
4546
18.4k
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
18.4k
      if (cache_ptr->line_number == 0)
4549
10.1k
  {
4550
10.1k
    combined_entry_type * ent;
4551
10.1k
    unsigned long symndx;
4552
10.1k
    coff_symbol_type *sym;
4553
4554
10.1k
    have_func = false;
4555
10.1k
    symndx = dst.l_addr.l_symndx;
4556
10.1k
    if (symndx >= obj_raw_syment_count (abfd))
4557
4.55k
      {
4558
4.55k
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
4.55k
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
4.55k
     abfd, symndx, counter);
4562
4.55k
        cache_ptr->line_number = -1;
4563
4.55k
        ret = false;
4564
4.55k
        continue;
4565
4.55k
      }
4566
4567
5.63k
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
5.63k
    if (! ent->is_sym)
4571
323
      {
4572
323
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
323
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
323
     abfd, symndx, counter);
4576
323
        cache_ptr->line_number = -1;
4577
323
        ret = false;
4578
323
        continue;
4579
323
      }
4580
5.30k
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
5.30k
    if (sym < obj_symbols (abfd)
4584
5.30k
        || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd))
4585
0
      {
4586
0
        _bfd_error_handler
4587
    /* xgettext:c-format */
4588
0
    (_("%pB: warning: illegal symbol in line number entry %d"),
4589
0
     abfd, counter);
4590
0
        cache_ptr->line_number = -1;
4591
0
        ret = false;
4592
0
        continue;
4593
0
      }
4594
4595
5.30k
    have_func = true;
4596
5.30k
    nbr_func++;
4597
5.30k
    cache_ptr->u.sym = (asymbol *) sym;
4598
5.30k
    if (sym->lineno != NULL)
4599
5.10k
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
5.10k
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
5.10k
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
5.30k
    sym->lineno = cache_ptr;
4605
5.30k
    if (sym->symbol.value < prev_offset)
4606
177
      ordered = false;
4607
5.30k
    prev_offset = sym->symbol.value;
4608
5.30k
  }
4609
8.29k
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
4.86k
  continue;
4613
3.42k
      else
4614
3.42k
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
8.73k
      cache_ptr++;
4616
8.73k
    }
4617
4618
102
  asect->lineno_count = cache_ptr - lineno_cache;
4619
102
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
102
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
102
  if (!ordered)
4624
40
    {
4625
      /* Sort the table.  */
4626
40
      alent **func_table;
4627
40
      alent *n_lineno_cache;
4628
4629
      /* Create a table of functions.  */
4630
40
      if (_bfd_mul_overflow (nbr_func, sizeof (alent *), &amt))
4631
0
  {
4632
0
    bfd_set_error (bfd_error_file_too_big);
4633
0
    ret = false;
4634
0
  }
4635
40
      else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL)
4636
40
  {
4637
40
    alent **p = func_table;
4638
40
    unsigned int i;
4639
4640
6.89k
    for (i = 0; i < asect->lineno_count; i++)
4641
6.85k
      if (lineno_cache[i].line_number == 0)
4642
4.17k
        *p++ = &lineno_cache[i];
4643
4644
40
    BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func);
4645
4646
    /* Sort by functions.  */
4647
40
    qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent);
4648
4649
    /* Create the new sorted table.  */
4650
40
    if (_bfd_mul_overflow (asect->lineno_count, sizeof (alent), &amt))
4651
0
      {
4652
0
        bfd_set_error (bfd_error_file_too_big);
4653
0
        ret = false;
4654
0
      }
4655
40
    else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL)
4656
40
      {
4657
40
        alent *n_cache_ptr = n_lineno_cache;
4658
4659
4.21k
        for (i = 0; i < nbr_func; i++)
4660
4.17k
    {
4661
4.17k
      coff_symbol_type *sym;
4662
4.17k
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
4.17k
      sym = (coff_symbol_type *) old_ptr->u.sym;
4666
      /* PR binutils/17512: Point the lineno to where
4667
         this entry will be after the memcpy below.  */
4668
4.17k
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
4.17k
      do
4671
6.85k
        *n_cache_ptr++ = *old_ptr++;
4672
6.85k
      while (old_ptr->line_number != 0);
4673
4.17k
    }
4674
4675
40
        memcpy (lineno_cache, n_lineno_cache,
4676
40
          asect->lineno_count * sizeof (alent));
4677
40
      }
4678
0
    else
4679
0
      ret = false;
4680
40
    bfd_release (abfd, func_table);
4681
40
  }
4682
0
      else
4683
0
  ret = false;
4684
40
    }
4685
4686
102
  return ret;
4687
102
}
pei-x86_64.c:coff_slurp_line_table
Line
Count
Source
4490
153
{
4491
153
  LINENO *native_lineno;
4492
153
  alent *lineno_cache;
4493
153
  unsigned int counter;
4494
153
  alent *cache_ptr;
4495
153
  bfd_vma prev_offset = 0;
4496
153
  bool ordered = true;
4497
153
  unsigned int nbr_func;
4498
153
  LINENO *src;
4499
153
  bool have_func;
4500
153
  bool ret = true;
4501
153
  size_t amt;
4502
4503
153
  if (asect->lineno_count == 0)
4504
38
    return true;
4505
4506
115
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
115
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
115
             asect->lineno_count,
4510
115
             bfd_coff_linesz (abfd));
4511
115
  if (native_lineno == NULL)
4512
48
    {
4513
48
      _bfd_error_handler
4514
48
  (_("%pB: warning: line number table read failed"), abfd);
4515
48
      return false;
4516
48
    }
4517
4518
67
  if (_bfd_mul_overflow (asect->lineno_count + 1, sizeof (alent), &amt))
4519
0
    {
4520
0
      bfd_set_error (bfd_error_file_too_big);
4521
0
      free (native_lineno);
4522
0
      return false;
4523
0
    }
4524
67
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
67
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
67
  cache_ptr = lineno_cache;
4532
67
  asect->lineno = lineno_cache;
4533
67
  src = native_lineno;
4534
67
  nbr_func = 0;
4535
67
  have_func = false;
4536
4537
190k
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
190k
    {
4539
190k
      struct internal_lineno dst;
4540
4541
190k
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
190k
      cache_ptr->line_number = dst.l_lnno;
4543
      /* Appease memory checkers that get all excited about
4544
   uninitialised memory when copying alents if u.offset is
4545
   larger than u.sym.  (64-bit BFD on 32-bit host.)  */
4546
190k
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
190k
      if (cache_ptr->line_number == 0)
4549
86.0k
  {
4550
86.0k
    combined_entry_type * ent;
4551
86.0k
    unsigned long symndx;
4552
86.0k
    coff_symbol_type *sym;
4553
4554
86.0k
    have_func = false;
4555
86.0k
    symndx = dst.l_addr.l_symndx;
4556
86.0k
    if (symndx >= obj_raw_syment_count (abfd))
4557
47.1k
      {
4558
47.1k
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
47.1k
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
47.1k
     abfd, symndx, counter);
4562
47.1k
        cache_ptr->line_number = -1;
4563
47.1k
        ret = false;
4564
47.1k
        continue;
4565
47.1k
      }
4566
4567
38.9k
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
38.9k
    if (! ent->is_sym)
4571
7.11k
      {
4572
7.11k
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
7.11k
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
7.11k
     abfd, symndx, counter);
4576
7.11k
        cache_ptr->line_number = -1;
4577
7.11k
        ret = false;
4578
7.11k
        continue;
4579
7.11k
      }
4580
31.8k
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
31.8k
    if (sym < obj_symbols (abfd)
4584
31.8k
        || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd))
4585
0
      {
4586
0
        _bfd_error_handler
4587
    /* xgettext:c-format */
4588
0
    (_("%pB: warning: illegal symbol in line number entry %d"),
4589
0
     abfd, counter);
4590
0
        cache_ptr->line_number = -1;
4591
0
        ret = false;
4592
0
        continue;
4593
0
      }
4594
4595
31.8k
    have_func = true;
4596
31.8k
    nbr_func++;
4597
31.8k
    cache_ptr->u.sym = (asymbol *) sym;
4598
31.8k
    if (sym->lineno != NULL)
4599
31.3k
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
31.3k
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
31.3k
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
31.8k
    sym->lineno = cache_ptr;
4605
31.8k
    if (sym->symbol.value < prev_offset)
4606
966
      ordered = false;
4607
31.8k
    prev_offset = sym->symbol.value;
4608
31.8k
  }
4609
104k
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
70.1k
  continue;
4613
34.0k
      else
4614
34.0k
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
65.8k
      cache_ptr++;
4616
65.8k
    }
4617
4618
67
  asect->lineno_count = cache_ptr - lineno_cache;
4619
67
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
67
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
67
  if (!ordered)
4624
44
    {
4625
      /* Sort the table.  */
4626
44
      alent **func_table;
4627
44
      alent *n_lineno_cache;
4628
4629
      /* Create a table of functions.  */
4630
44
      if (_bfd_mul_overflow (nbr_func, sizeof (alent *), &amt))
4631
0
  {
4632
0
    bfd_set_error (bfd_error_file_too_big);
4633
0
    ret = false;
4634
0
  }
4635
44
      else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL)
4636
44
  {
4637
44
    alent **p = func_table;
4638
44
    unsigned int i;
4639
4640
65.8k
    for (i = 0; i < asect->lineno_count; i++)
4641
65.7k
      if (lineno_cache[i].line_number == 0)
4642
31.7k
        *p++ = &lineno_cache[i];
4643
4644
44
    BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func);
4645
4646
    /* Sort by functions.  */
4647
44
    qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent);
4648
4649
    /* Create the new sorted table.  */
4650
44
    if (_bfd_mul_overflow (asect->lineno_count, sizeof (alent), &amt))
4651
0
      {
4652
0
        bfd_set_error (bfd_error_file_too_big);
4653
0
        ret = false;
4654
0
      }
4655
44
    else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL)
4656
44
      {
4657
44
        alent *n_cache_ptr = n_lineno_cache;
4658
4659
31.7k
        for (i = 0; i < nbr_func; i++)
4660
31.7k
    {
4661
31.7k
      coff_symbol_type *sym;
4662
31.7k
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
31.7k
      sym = (coff_symbol_type *) old_ptr->u.sym;
4666
      /* PR binutils/17512: Point the lineno to where
4667
         this entry will be after the memcpy below.  */
4668
31.7k
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
31.7k
      do
4671
65.7k
        *n_cache_ptr++ = *old_ptr++;
4672
65.7k
      while (old_ptr->line_number != 0);
4673
31.7k
    }
4674
4675
44
        memcpy (lineno_cache, n_lineno_cache,
4676
44
          asect->lineno_count * sizeof (alent));
4677
44
      }
4678
0
    else
4679
0
      ret = false;
4680
44
    bfd_release (abfd, func_table);
4681
44
  }
4682
0
      else
4683
0
  ret = false;
4684
44
    }
4685
4686
67
  return ret;
4687
67
}
coff-x86_64.c:coff_slurp_line_table
Line
Count
Source
4490
893
{
4491
893
  LINENO *native_lineno;
4492
893
  alent *lineno_cache;
4493
893
  unsigned int counter;
4494
893
  alent *cache_ptr;
4495
893
  bfd_vma prev_offset = 0;
4496
893
  bool ordered = true;
4497
893
  unsigned int nbr_func;
4498
893
  LINENO *src;
4499
893
  bool have_func;
4500
893
  bool ret = true;
4501
893
  size_t amt;
4502
4503
893
  if (asect->lineno_count == 0)
4504
646
    return true;
4505
4506
247
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
247
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
247
             asect->lineno_count,
4510
247
             bfd_coff_linesz (abfd));
4511
247
  if (native_lineno == NULL)
4512
133
    {
4513
133
      _bfd_error_handler
4514
133
  (_("%pB: warning: line number table read failed"), abfd);
4515
133
      return false;
4516
133
    }
4517
4518
114
  if (_bfd_mul_overflow (asect->lineno_count + 1, sizeof (alent), &amt))
4519
0
    {
4520
0
      bfd_set_error (bfd_error_file_too_big);
4521
0
      free (native_lineno);
4522
0
      return false;
4523
0
    }
4524
114
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
114
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
114
  cache_ptr = lineno_cache;
4532
114
  asect->lineno = lineno_cache;
4533
114
  src = native_lineno;
4534
114
  nbr_func = 0;
4535
114
  have_func = false;
4536
4537
49.9k
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
49.8k
    {
4539
49.8k
      struct internal_lineno dst;
4540
4541
49.8k
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
49.8k
      cache_ptr->line_number = dst.l_lnno;
4543
      /* Appease memory checkers that get all excited about
4544
   uninitialised memory when copying alents if u.offset is
4545
   larger than u.sym.  (64-bit BFD on 32-bit host.)  */
4546
49.8k
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
49.8k
      if (cache_ptr->line_number == 0)
4549
22.2k
  {
4550
22.2k
    combined_entry_type * ent;
4551
22.2k
    unsigned long symndx;
4552
22.2k
    coff_symbol_type *sym;
4553
4554
22.2k
    have_func = false;
4555
22.2k
    symndx = dst.l_addr.l_symndx;
4556
22.2k
    if (symndx >= obj_raw_syment_count (abfd))
4557
10.9k
      {
4558
10.9k
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
10.9k
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
10.9k
     abfd, symndx, counter);
4562
10.9k
        cache_ptr->line_number = -1;
4563
10.9k
        ret = false;
4564
10.9k
        continue;
4565
10.9k
      }
4566
4567
11.3k
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
11.3k
    if (! ent->is_sym)
4571
1.76k
      {
4572
1.76k
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
1.76k
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
1.76k
     abfd, symndx, counter);
4576
1.76k
        cache_ptr->line_number = -1;
4577
1.76k
        ret = false;
4578
1.76k
        continue;
4579
1.76k
      }
4580
9.60k
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
9.60k
    if (sym < obj_symbols (abfd)
4584
9.60k
        || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd))
4585
0
      {
4586
0
        _bfd_error_handler
4587
    /* xgettext:c-format */
4588
0
    (_("%pB: warning: illegal symbol in line number entry %d"),
4589
0
     abfd, counter);
4590
0
        cache_ptr->line_number = -1;
4591
0
        ret = false;
4592
0
        continue;
4593
0
      }
4594
4595
9.60k
    have_func = true;
4596
9.60k
    nbr_func++;
4597
9.60k
    cache_ptr->u.sym = (asymbol *) sym;
4598
9.60k
    if (sym->lineno != NULL)
4599
9.33k
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
9.33k
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
9.33k
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
9.60k
    sym->lineno = cache_ptr;
4605
9.60k
    if (sym->symbol.value < prev_offset)
4606
442
      ordered = false;
4607
9.60k
    prev_offset = sym->symbol.value;
4608
9.60k
  }
4609
27.6k
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
18.4k
  continue;
4613
9.14k
      else
4614
9.14k
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
18.7k
      cache_ptr++;
4616
18.7k
    }
4617
4618
114
  asect->lineno_count = cache_ptr - lineno_cache;
4619
114
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
114
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
114
  if (!ordered)
4624
56
    {
4625
      /* Sort the table.  */
4626
56
      alent **func_table;
4627
56
      alent *n_lineno_cache;
4628
4629
      /* Create a table of functions.  */
4630
56
      if (_bfd_mul_overflow (nbr_func, sizeof (alent *), &amt))
4631
0
  {
4632
0
    bfd_set_error (bfd_error_file_too_big);
4633
0
    ret = false;
4634
0
  }
4635
56
      else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL)
4636
56
  {
4637
56
    alent **p = func_table;
4638
56
    unsigned int i;
4639
4640
17.5k
    for (i = 0; i < asect->lineno_count; i++)
4641
17.5k
      if (lineno_cache[i].line_number == 0)
4642
8.75k
        *p++ = &lineno_cache[i];
4643
4644
56
    BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func);
4645
4646
    /* Sort by functions.  */
4647
56
    qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent);
4648
4649
    /* Create the new sorted table.  */
4650
56
    if (_bfd_mul_overflow (asect->lineno_count, sizeof (alent), &amt))
4651
0
      {
4652
0
        bfd_set_error (bfd_error_file_too_big);
4653
0
        ret = false;
4654
0
      }
4655
56
    else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL)
4656
56
      {
4657
56
        alent *n_cache_ptr = n_lineno_cache;
4658
4659
8.81k
        for (i = 0; i < nbr_func; i++)
4660
8.75k
    {
4661
8.75k
      coff_symbol_type *sym;
4662
8.75k
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
8.75k
      sym = (coff_symbol_type *) old_ptr->u.sym;
4666
      /* PR binutils/17512: Point the lineno to where
4667
         this entry will be after the memcpy below.  */
4668
8.75k
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
8.75k
      do
4671
17.5k
        *n_cache_ptr++ = *old_ptr++;
4672
17.5k
      while (old_ptr->line_number != 0);
4673
8.75k
    }
4674
4675
56
        memcpy (lineno_cache, n_lineno_cache,
4676
56
          asect->lineno_count * sizeof (alent));
4677
56
      }
4678
0
    else
4679
0
      ret = false;
4680
56
    bfd_release (abfd, func_table);
4681
56
  }
4682
0
      else
4683
0
  ret = false;
4684
56
    }
4685
4686
114
  return ret;
4687
114
}
coff64-rs6000.c:coff_slurp_line_table
Line
Count
Source
4490
1.27k
{
4491
1.27k
  LINENO *native_lineno;
4492
1.27k
  alent *lineno_cache;
4493
1.27k
  unsigned int counter;
4494
1.27k
  alent *cache_ptr;
4495
1.27k
  bfd_vma prev_offset = 0;
4496
1.27k
  bool ordered = true;
4497
1.27k
  unsigned int nbr_func;
4498
1.27k
  LINENO *src;
4499
1.27k
  bool have_func;
4500
1.27k
  bool ret = true;
4501
1.27k
  size_t amt;
4502
4503
1.27k
  if (asect->lineno_count == 0)
4504
966
    return true;
4505
4506
313
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
313
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
313
             asect->lineno_count,
4510
313
             bfd_coff_linesz (abfd));
4511
313
  if (native_lineno == NULL)
4512
190
    {
4513
190
      _bfd_error_handler
4514
190
  (_("%pB: warning: line number table read failed"), abfd);
4515
190
      return false;
4516
190
    }
4517
4518
123
  if (_bfd_mul_overflow (asect->lineno_count + 1, sizeof (alent), &amt))
4519
0
    {
4520
0
      bfd_set_error (bfd_error_file_too_big);
4521
0
      free (native_lineno);
4522
0
      return false;
4523
0
    }
4524
123
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
123
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
123
  cache_ptr = lineno_cache;
4532
123
  asect->lineno = lineno_cache;
4533
123
  src = native_lineno;
4534
123
  nbr_func = 0;
4535
123
  have_func = false;
4536
4537
221k
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
221k
    {
4539
221k
      struct internal_lineno dst;
4540
4541
221k
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
221k
      cache_ptr->line_number = dst.l_lnno;
4543
      /* Appease memory checkers that get all excited about
4544
   uninitialised memory when copying alents if u.offset is
4545
   larger than u.sym.  (64-bit BFD on 32-bit host.)  */
4546
221k
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
221k
      if (cache_ptr->line_number == 0)
4549
60.7k
  {
4550
60.7k
    combined_entry_type * ent;
4551
60.7k
    unsigned long symndx;
4552
60.7k
    coff_symbol_type *sym;
4553
4554
60.7k
    have_func = false;
4555
60.7k
    symndx = dst.l_addr.l_symndx;
4556
60.7k
    if (symndx >= obj_raw_syment_count (abfd))
4557
23.5k
      {
4558
23.5k
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
23.5k
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
23.5k
     abfd, symndx, counter);
4562
23.5k
        cache_ptr->line_number = -1;
4563
23.5k
        ret = false;
4564
23.5k
        continue;
4565
23.5k
      }
4566
4567
37.2k
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
37.2k
    if (! ent->is_sym)
4571
2.86k
      {
4572
2.86k
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
2.86k
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
2.86k
     abfd, symndx, counter);
4576
2.86k
        cache_ptr->line_number = -1;
4577
2.86k
        ret = false;
4578
2.86k
        continue;
4579
2.86k
      }
4580
34.3k
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
34.3k
    if (sym < obj_symbols (abfd)
4584
34.3k
        || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd))
4585
0
      {
4586
0
        _bfd_error_handler
4587
    /* xgettext:c-format */
4588
0
    (_("%pB: warning: illegal symbol in line number entry %d"),
4589
0
     abfd, counter);
4590
0
        cache_ptr->line_number = -1;
4591
0
        ret = false;
4592
0
        continue;
4593
0
      }
4594
4595
34.3k
    have_func = true;
4596
34.3k
    nbr_func++;
4597
34.3k
    cache_ptr->u.sym = (asymbol *) sym;
4598
34.3k
    if (sym->lineno != NULL)
4599
33.8k
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
33.8k
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
33.8k
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
34.3k
    sym->lineno = cache_ptr;
4605
34.3k
    if (sym->symbol.value < prev_offset)
4606
772
      ordered = false;
4607
34.3k
    prev_offset = sym->symbol.value;
4608
34.3k
  }
4609
160k
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
93.0k
  continue;
4613
67.5k
      else
4614
67.5k
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
101k
      cache_ptr++;
4616
101k
    }
4617
4618
123
  asect->lineno_count = cache_ptr - lineno_cache;
4619
123
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
123
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
123
  if (!ordered)
4624
62
    {
4625
      /* Sort the table.  */
4626
62
      alent **func_table;
4627
62
      alent *n_lineno_cache;
4628
4629
      /* Create a table of functions.  */
4630
62
      if (_bfd_mul_overflow (nbr_func, sizeof (alent *), &amt))
4631
0
  {
4632
0
    bfd_set_error (bfd_error_file_too_big);
4633
0
    ret = false;
4634
0
  }
4635
62
      else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL)
4636
62
  {
4637
62
    alent **p = func_table;
4638
62
    unsigned int i;
4639
4640
90.0k
    for (i = 0; i < asect->lineno_count; i++)
4641
89.9k
      if (lineno_cache[i].line_number == 0)
4642
30.8k
        *p++ = &lineno_cache[i];
4643
4644
62
    BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func);
4645
4646
    /* Sort by functions.  */
4647
62
    qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent);
4648
4649
    /* Create the new sorted table.  */
4650
62
    if (_bfd_mul_overflow (asect->lineno_count, sizeof (alent), &amt))
4651
0
      {
4652
0
        bfd_set_error (bfd_error_file_too_big);
4653
0
        ret = false;
4654
0
      }
4655
62
    else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL)
4656
62
      {
4657
62
        alent *n_cache_ptr = n_lineno_cache;
4658
4659
30.8k
        for (i = 0; i < nbr_func; i++)
4660
30.8k
    {
4661
30.8k
      coff_symbol_type *sym;
4662
30.8k
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
30.8k
      sym = (coff_symbol_type *) old_ptr->u.sym;
4666
      /* PR binutils/17512: Point the lineno to where
4667
         this entry will be after the memcpy below.  */
4668
30.8k
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
30.8k
      do
4671
89.9k
        *n_cache_ptr++ = *old_ptr++;
4672
89.9k
      while (old_ptr->line_number != 0);
4673
30.8k
    }
4674
4675
62
        memcpy (lineno_cache, n_lineno_cache,
4676
62
          asect->lineno_count * sizeof (alent));
4677
62
      }
4678
0
    else
4679
0
      ret = false;
4680
62
    bfd_release (abfd, func_table);
4681
62
  }
4682
0
      else
4683
0
  ret = false;
4684
62
    }
4685
4686
123
  return ret;
4687
123
}
pe-aarch64.c:coff_slurp_line_table
Line
Count
Source
4490
290
{
4491
290
  LINENO *native_lineno;
4492
290
  alent *lineno_cache;
4493
290
  unsigned int counter;
4494
290
  alent *cache_ptr;
4495
290
  bfd_vma prev_offset = 0;
4496
290
  bool ordered = true;
4497
290
  unsigned int nbr_func;
4498
290
  LINENO *src;
4499
290
  bool have_func;
4500
290
  bool ret = true;
4501
290
  size_t amt;
4502
4503
290
  if (asect->lineno_count == 0)
4504
133
    return true;
4505
4506
157
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
157
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
157
             asect->lineno_count,
4510
157
             bfd_coff_linesz (abfd));
4511
157
  if (native_lineno == NULL)
4512
83
    {
4513
83
      _bfd_error_handler
4514
83
  (_("%pB: warning: line number table read failed"), abfd);
4515
83
      return false;
4516
83
    }
4517
4518
74
  if (_bfd_mul_overflow (asect->lineno_count + 1, sizeof (alent), &amt))
4519
0
    {
4520
0
      bfd_set_error (bfd_error_file_too_big);
4521
0
      free (native_lineno);
4522
0
      return false;
4523
0
    }
4524
74
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
74
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
74
  cache_ptr = lineno_cache;
4532
74
  asect->lineno = lineno_cache;
4533
74
  src = native_lineno;
4534
74
  nbr_func = 0;
4535
74
  have_func = false;
4536
4537
46.0k
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
46.0k
    {
4539
46.0k
      struct internal_lineno dst;
4540
4541
46.0k
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
46.0k
      cache_ptr->line_number = dst.l_lnno;
4543
      /* Appease memory checkers that get all excited about
4544
   uninitialised memory when copying alents if u.offset is
4545
   larger than u.sym.  (64-bit BFD on 32-bit host.)  */
4546
46.0k
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
46.0k
      if (cache_ptr->line_number == 0)
4549
22.7k
  {
4550
22.7k
    combined_entry_type * ent;
4551
22.7k
    unsigned long symndx;
4552
22.7k
    coff_symbol_type *sym;
4553
4554
22.7k
    have_func = false;
4555
22.7k
    symndx = dst.l_addr.l_symndx;
4556
22.7k
    if (symndx >= obj_raw_syment_count (abfd))
4557
13.4k
      {
4558
13.4k
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
13.4k
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
13.4k
     abfd, symndx, counter);
4562
13.4k
        cache_ptr->line_number = -1;
4563
13.4k
        ret = false;
4564
13.4k
        continue;
4565
13.4k
      }
4566
4567
9.34k
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
9.34k
    if (! ent->is_sym)
4571
1.10k
      {
4572
1.10k
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
1.10k
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
1.10k
     abfd, symndx, counter);
4576
1.10k
        cache_ptr->line_number = -1;
4577
1.10k
        ret = false;
4578
1.10k
        continue;
4579
1.10k
      }
4580
8.24k
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
8.24k
    if (sym < obj_symbols (abfd)
4584
8.24k
        || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd))
4585
0
      {
4586
0
        _bfd_error_handler
4587
    /* xgettext:c-format */
4588
0
    (_("%pB: warning: illegal symbol in line number entry %d"),
4589
0
     abfd, counter);
4590
0
        cache_ptr->line_number = -1;
4591
0
        ret = false;
4592
0
        continue;
4593
0
      }
4594
4595
8.24k
    have_func = true;
4596
8.24k
    nbr_func++;
4597
8.24k
    cache_ptr->u.sym = (asymbol *) sym;
4598
8.24k
    if (sym->lineno != NULL)
4599
7.95k
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
7.95k
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
7.95k
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
8.24k
    sym->lineno = cache_ptr;
4605
8.24k
    if (sym->symbol.value < prev_offset)
4606
654
      ordered = false;
4607
8.24k
    prev_offset = sym->symbol.value;
4608
8.24k
  }
4609
23.2k
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
15.6k
  continue;
4613
7.54k
      else
4614
7.54k
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
15.7k
      cache_ptr++;
4616
15.7k
    }
4617
4618
74
  asect->lineno_count = cache_ptr - lineno_cache;
4619
74
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
74
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
74
  if (!ordered)
4624
33
    {
4625
      /* Sort the table.  */
4626
33
      alent **func_table;
4627
33
      alent *n_lineno_cache;
4628
4629
      /* Create a table of functions.  */
4630
33
      if (_bfd_mul_overflow (nbr_func, sizeof (alent *), &amt))
4631
0
  {
4632
0
    bfd_set_error (bfd_error_file_too_big);
4633
0
    ret = false;
4634
0
  }
4635
33
      else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL)
4636
33
  {
4637
33
    alent **p = func_table;
4638
33
    unsigned int i;
4639
4640
15.5k
    for (i = 0; i < asect->lineno_count; i++)
4641
15.5k
      if (lineno_cache[i].line_number == 0)
4642
8.10k
        *p++ = &lineno_cache[i];
4643
4644
33
    BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func);
4645
4646
    /* Sort by functions.  */
4647
33
    qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent);
4648
4649
    /* Create the new sorted table.  */
4650
33
    if (_bfd_mul_overflow (asect->lineno_count, sizeof (alent), &amt))
4651
0
      {
4652
0
        bfd_set_error (bfd_error_file_too_big);
4653
0
        ret = false;
4654
0
      }
4655
33
    else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL)
4656
33
      {
4657
33
        alent *n_cache_ptr = n_lineno_cache;
4658
4659
8.13k
        for (i = 0; i < nbr_func; i++)
4660
8.10k
    {
4661
8.10k
      coff_symbol_type *sym;
4662
8.10k
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
8.10k
      sym = (coff_symbol_type *) old_ptr->u.sym;
4666
      /* PR binutils/17512: Point the lineno to where
4667
         this entry will be after the memcpy below.  */
4668
8.10k
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
8.10k
      do
4671
15.5k
        *n_cache_ptr++ = *old_ptr++;
4672
15.5k
      while (old_ptr->line_number != 0);
4673
8.10k
    }
4674
4675
33
        memcpy (lineno_cache, n_lineno_cache,
4676
33
          asect->lineno_count * sizeof (alent));
4677
33
      }
4678
0
    else
4679
0
      ret = false;
4680
33
    bfd_release (abfd, func_table);
4681
33
  }
4682
0
      else
4683
0
  ret = false;
4684
33
    }
4685
4686
74
  return ret;
4687
74
}
pei-aarch64.c:coff_slurp_line_table
Line
Count
Source
4490
198
{
4491
198
  LINENO *native_lineno;
4492
198
  alent *lineno_cache;
4493
198
  unsigned int counter;
4494
198
  alent *cache_ptr;
4495
198
  bfd_vma prev_offset = 0;
4496
198
  bool ordered = true;
4497
198
  unsigned int nbr_func;
4498
198
  LINENO *src;
4499
198
  bool have_func;
4500
198
  bool ret = true;
4501
198
  size_t amt;
4502
4503
198
  if (asect->lineno_count == 0)
4504
53
    return true;
4505
4506
145
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
145
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
145
             asect->lineno_count,
4510
145
             bfd_coff_linesz (abfd));
4511
145
  if (native_lineno == NULL)
4512
67
    {
4513
67
      _bfd_error_handler
4514
67
  (_("%pB: warning: line number table read failed"), abfd);
4515
67
      return false;
4516
67
    }
4517
4518
78
  if (_bfd_mul_overflow (asect->lineno_count + 1, sizeof (alent), &amt))
4519
0
    {
4520
0
      bfd_set_error (bfd_error_file_too_big);
4521
0
      free (native_lineno);
4522
0
      return false;
4523
0
    }
4524
78
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
78
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
78
  cache_ptr = lineno_cache;
4532
78
  asect->lineno = lineno_cache;
4533
78
  src = native_lineno;
4534
78
  nbr_func = 0;
4535
78
  have_func = false;
4536
4537
472k
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
472k
    {
4539
472k
      struct internal_lineno dst;
4540
4541
472k
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
472k
      cache_ptr->line_number = dst.l_lnno;
4543
      /* Appease memory checkers that get all excited about
4544
   uninitialised memory when copying alents if u.offset is
4545
   larger than u.sym.  (64-bit BFD on 32-bit host.)  */
4546
472k
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
472k
      if (cache_ptr->line_number == 0)
4549
203k
  {
4550
203k
    combined_entry_type * ent;
4551
203k
    unsigned long symndx;
4552
203k
    coff_symbol_type *sym;
4553
4554
203k
    have_func = false;
4555
203k
    symndx = dst.l_addr.l_symndx;
4556
203k
    if (symndx >= obj_raw_syment_count (abfd))
4557
104k
      {
4558
104k
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
104k
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
104k
     abfd, symndx, counter);
4562
104k
        cache_ptr->line_number = -1;
4563
104k
        ret = false;
4564
104k
        continue;
4565
104k
      }
4566
4567
98.6k
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
98.6k
    if (! ent->is_sym)
4571
25.7k
      {
4572
25.7k
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
25.7k
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
25.7k
     abfd, symndx, counter);
4576
25.7k
        cache_ptr->line_number = -1;
4577
25.7k
        ret = false;
4578
25.7k
        continue;
4579
25.7k
      }
4580
72.8k
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
72.8k
    if (sym < obj_symbols (abfd)
4584
72.8k
        || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd))
4585
0
      {
4586
0
        _bfd_error_handler
4587
    /* xgettext:c-format */
4588
0
    (_("%pB: warning: illegal symbol in line number entry %d"),
4589
0
     abfd, counter);
4590
0
        cache_ptr->line_number = -1;
4591
0
        ret = false;
4592
0
        continue;
4593
0
      }
4594
4595
72.8k
    have_func = true;
4596
72.8k
    nbr_func++;
4597
72.8k
    cache_ptr->u.sym = (asymbol *) sym;
4598
72.8k
    if (sym->lineno != NULL)
4599
71.5k
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
71.5k
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
71.5k
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
72.8k
    sym->lineno = cache_ptr;
4605
72.8k
    if (sym->symbol.value < prev_offset)
4606
1.52k
      ordered = false;
4607
72.8k
    prev_offset = sym->symbol.value;
4608
72.8k
  }
4609
269k
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
179k
  continue;
4613
89.5k
      else
4614
89.5k
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
162k
      cache_ptr++;
4616
162k
    }
4617
4618
78
  asect->lineno_count = cache_ptr - lineno_cache;
4619
78
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
78
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
78
  if (!ordered)
4624
65
    {
4625
      /* Sort the table.  */
4626
65
      alent **func_table;
4627
65
      alent *n_lineno_cache;
4628
4629
      /* Create a table of functions.  */
4630
65
      if (_bfd_mul_overflow (nbr_func, sizeof (alent *), &amt))
4631
0
  {
4632
0
    bfd_set_error (bfd_error_file_too_big);
4633
0
    ret = false;
4634
0
  }
4635
65
      else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL)
4636
65
  {
4637
65
    alent **p = func_table;
4638
65
    unsigned int i;
4639
4640
161k
    for (i = 0; i < asect->lineno_count; i++)
4641
161k
      if (lineno_cache[i].line_number == 0)
4642
72.3k
        *p++ = &lineno_cache[i];
4643
4644
65
    BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func);
4645
4646
    /* Sort by functions.  */
4647
65
    qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent);
4648
4649
    /* Create the new sorted table.  */
4650
65
    if (_bfd_mul_overflow (asect->lineno_count, sizeof (alent), &amt))
4651
0
      {
4652
0
        bfd_set_error (bfd_error_file_too_big);
4653
0
        ret = false;
4654
0
      }
4655
65
    else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL)
4656
65
      {
4657
65
        alent *n_cache_ptr = n_lineno_cache;
4658
4659
72.4k
        for (i = 0; i < nbr_func; i++)
4660
72.3k
    {
4661
72.3k
      coff_symbol_type *sym;
4662
72.3k
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
72.3k
      sym = (coff_symbol_type *) old_ptr->u.sym;
4666
      /* PR binutils/17512: Point the lineno to where
4667
         this entry will be after the memcpy below.  */
4668
72.3k
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
72.3k
      do
4671
161k
        *n_cache_ptr++ = *old_ptr++;
4672
161k
      while (old_ptr->line_number != 0);
4673
72.3k
    }
4674
4675
65
        memcpy (lineno_cache, n_lineno_cache,
4676
65
          asect->lineno_count * sizeof (alent));
4677
65
      }
4678
0
    else
4679
0
      ret = false;
4680
65
    bfd_release (abfd, func_table);
4681
65
  }
4682
0
      else
4683
0
  ret = false;
4684
65
    }
4685
4686
78
  return ret;
4687
78
}
pei-ia64.c:coff_slurp_line_table
Line
Count
Source
4490
492
{
4491
492
  LINENO *native_lineno;
4492
492
  alent *lineno_cache;
4493
492
  unsigned int counter;
4494
492
  alent *cache_ptr;
4495
492
  bfd_vma prev_offset = 0;
4496
492
  bool ordered = true;
4497
492
  unsigned int nbr_func;
4498
492
  LINENO *src;
4499
492
  bool have_func;
4500
492
  bool ret = true;
4501
492
  size_t amt;
4502
4503
492
  if (asect->lineno_count == 0)
4504
293
    return true;
4505
4506
199
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
199
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
199
             asect->lineno_count,
4510
199
             bfd_coff_linesz (abfd));
4511
199
  if (native_lineno == NULL)
4512
89
    {
4513
89
      _bfd_error_handler
4514
89
  (_("%pB: warning: line number table read failed"), abfd);
4515
89
      return false;
4516
89
    }
4517
4518
110
  if (_bfd_mul_overflow (asect->lineno_count + 1, sizeof (alent), &amt))
4519
0
    {
4520
0
      bfd_set_error (bfd_error_file_too_big);
4521
0
      free (native_lineno);
4522
0
      return false;
4523
0
    }
4524
110
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
110
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
110
  cache_ptr = lineno_cache;
4532
110
  asect->lineno = lineno_cache;
4533
110
  src = native_lineno;
4534
110
  nbr_func = 0;
4535
110
  have_func = false;
4536
4537
116k
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
116k
    {
4539
116k
      struct internal_lineno dst;
4540
4541
116k
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
116k
      cache_ptr->line_number = dst.l_lnno;
4543
      /* Appease memory checkers that get all excited about
4544
   uninitialised memory when copying alents if u.offset is
4545
   larger than u.sym.  (64-bit BFD on 32-bit host.)  */
4546
116k
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
116k
      if (cache_ptr->line_number == 0)
4549
53.1k
  {
4550
53.1k
    combined_entry_type * ent;
4551
53.1k
    unsigned long symndx;
4552
53.1k
    coff_symbol_type *sym;
4553
4554
53.1k
    have_func = false;
4555
53.1k
    symndx = dst.l_addr.l_symndx;
4556
53.1k
    if (symndx >= obj_raw_syment_count (abfd))
4557
27.3k
      {
4558
27.3k
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
27.3k
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
27.3k
     abfd, symndx, counter);
4562
27.3k
        cache_ptr->line_number = -1;
4563
27.3k
        ret = false;
4564
27.3k
        continue;
4565
27.3k
      }
4566
4567
25.7k
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
25.7k
    if (! ent->is_sym)
4571
4.61k
      {
4572
4.61k
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
4.61k
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
4.61k
     abfd, symndx, counter);
4576
4.61k
        cache_ptr->line_number = -1;
4577
4.61k
        ret = false;
4578
4.61k
        continue;
4579
4.61k
      }
4580
21.1k
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
21.1k
    if (sym < obj_symbols (abfd)
4584
21.1k
        || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd))
4585
0
      {
4586
0
        _bfd_error_handler
4587
    /* xgettext:c-format */
4588
0
    (_("%pB: warning: illegal symbol in line number entry %d"),
4589
0
     abfd, counter);
4590
0
        cache_ptr->line_number = -1;
4591
0
        ret = false;
4592
0
        continue;
4593
0
      }
4594
4595
21.1k
    have_func = true;
4596
21.1k
    nbr_func++;
4597
21.1k
    cache_ptr->u.sym = (asymbol *) sym;
4598
21.1k
    if (sym->lineno != NULL)
4599
20.7k
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
20.7k
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
20.7k
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
21.1k
    sym->lineno = cache_ptr;
4605
21.1k
    if (sym->symbol.value < prev_offset)
4606
759
      ordered = false;
4607
21.1k
    prev_offset = sym->symbol.value;
4608
21.1k
  }
4609
63.5k
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
43.7k
  continue;
4613
19.8k
      else
4614
19.8k
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
40.9k
      cache_ptr++;
4616
40.9k
    }
4617
4618
110
  asect->lineno_count = cache_ptr - lineno_cache;
4619
110
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
110
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
110
  if (!ordered)
4624
63
    {
4625
      /* Sort the table.  */
4626
63
      alent **func_table;
4627
63
      alent *n_lineno_cache;
4628
4629
      /* Create a table of functions.  */
4630
63
      if (_bfd_mul_overflow (nbr_func, sizeof (alent *), &amt))
4631
0
  {
4632
0
    bfd_set_error (bfd_error_file_too_big);
4633
0
    ret = false;
4634
0
  }
4635
63
      else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL)
4636
63
  {
4637
63
    alent **p = func_table;
4638
63
    unsigned int i;
4639
4640
40.1k
    for (i = 0; i < asect->lineno_count; i++)
4641
40.1k
      if (lineno_cache[i].line_number == 0)
4642
20.6k
        *p++ = &lineno_cache[i];
4643
4644
63
    BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func);
4645
4646
    /* Sort by functions.  */
4647
63
    qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent);
4648
4649
    /* Create the new sorted table.  */
4650
63
    if (_bfd_mul_overflow (asect->lineno_count, sizeof (alent), &amt))
4651
0
      {
4652
0
        bfd_set_error (bfd_error_file_too_big);
4653
0
        ret = false;
4654
0
      }
4655
63
    else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL)
4656
63
      {
4657
63
        alent *n_cache_ptr = n_lineno_cache;
4658
4659
20.7k
        for (i = 0; i < nbr_func; i++)
4660
20.6k
    {
4661
20.6k
      coff_symbol_type *sym;
4662
20.6k
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
20.6k
      sym = (coff_symbol_type *) old_ptr->u.sym;
4666
      /* PR binutils/17512: Point the lineno to where
4667
         this entry will be after the memcpy below.  */
4668
20.6k
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
20.6k
      do
4671
40.1k
        *n_cache_ptr++ = *old_ptr++;
4672
40.1k
      while (old_ptr->line_number != 0);
4673
20.6k
    }
4674
4675
63
        memcpy (lineno_cache, n_lineno_cache,
4676
63
          asect->lineno_count * sizeof (alent));
4677
63
      }
4678
0
    else
4679
0
      ret = false;
4680
63
    bfd_release (abfd, func_table);
4681
63
  }
4682
0
      else
4683
0
  ret = false;
4684
63
    }
4685
4686
110
  return ret;
4687
110
}
pei-loongarch64.c:coff_slurp_line_table
Line
Count
Source
4490
176
{
4491
176
  LINENO *native_lineno;
4492
176
  alent *lineno_cache;
4493
176
  unsigned int counter;
4494
176
  alent *cache_ptr;
4495
176
  bfd_vma prev_offset = 0;
4496
176
  bool ordered = true;
4497
176
  unsigned int nbr_func;
4498
176
  LINENO *src;
4499
176
  bool have_func;
4500
176
  bool ret = true;
4501
176
  size_t amt;
4502
4503
176
  if (asect->lineno_count == 0)
4504
51
    return true;
4505
4506
125
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
125
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
125
             asect->lineno_count,
4510
125
             bfd_coff_linesz (abfd));
4511
125
  if (native_lineno == NULL)
4512
62
    {
4513
62
      _bfd_error_handler
4514
62
  (_("%pB: warning: line number table read failed"), abfd);
4515
62
      return false;
4516
62
    }
4517
4518
63
  if (_bfd_mul_overflow (asect->lineno_count + 1, sizeof (alent), &amt))
4519
0
    {
4520
0
      bfd_set_error (bfd_error_file_too_big);
4521
0
      free (native_lineno);
4522
0
      return false;
4523
0
    }
4524
63
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
63
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
63
  cache_ptr = lineno_cache;
4532
63
  asect->lineno = lineno_cache;
4533
63
  src = native_lineno;
4534
63
  nbr_func = 0;
4535
63
  have_func = false;
4536
4537
376k
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
376k
    {
4539
376k
      struct internal_lineno dst;
4540
4541
376k
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
376k
      cache_ptr->line_number = dst.l_lnno;
4543
      /* Appease memory checkers that get all excited about
4544
   uninitialised memory when copying alents if u.offset is
4545
   larger than u.sym.  (64-bit BFD on 32-bit host.)  */
4546
376k
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
376k
      if (cache_ptr->line_number == 0)
4549
171k
  {
4550
171k
    combined_entry_type * ent;
4551
171k
    unsigned long symndx;
4552
171k
    coff_symbol_type *sym;
4553
4554
171k
    have_func = false;
4555
171k
    symndx = dst.l_addr.l_symndx;
4556
171k
    if (symndx >= obj_raw_syment_count (abfd))
4557
85.2k
      {
4558
85.2k
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
85.2k
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
85.2k
     abfd, symndx, counter);
4562
85.2k
        cache_ptr->line_number = -1;
4563
85.2k
        ret = false;
4564
85.2k
        continue;
4565
85.2k
      }
4566
4567
85.7k
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
85.7k
    if (! ent->is_sym)
4571
29.1k
      {
4572
29.1k
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
29.1k
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
29.1k
     abfd, symndx, counter);
4576
29.1k
        cache_ptr->line_number = -1;
4577
29.1k
        ret = false;
4578
29.1k
        continue;
4579
29.1k
      }
4580
56.6k
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
56.6k
    if (sym < obj_symbols (abfd)
4584
56.6k
        || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd))
4585
0
      {
4586
0
        _bfd_error_handler
4587
    /* xgettext:c-format */
4588
0
    (_("%pB: warning: illegal symbol in line number entry %d"),
4589
0
     abfd, counter);
4590
0
        cache_ptr->line_number = -1;
4591
0
        ret = false;
4592
0
        continue;
4593
0
      }
4594
4595
56.6k
    have_func = true;
4596
56.6k
    nbr_func++;
4597
56.6k
    cache_ptr->u.sym = (asymbol *) sym;
4598
56.6k
    if (sym->lineno != NULL)
4599
55.9k
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
55.9k
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
55.9k
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
56.6k
    sym->lineno = cache_ptr;
4605
56.6k
    if (sym->symbol.value < prev_offset)
4606
2.21k
      ordered = false;
4607
56.6k
    prev_offset = sym->symbol.value;
4608
56.6k
  }
4609
205k
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
144k
  continue;
4613
61.2k
      else
4614
61.2k
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
117k
      cache_ptr++;
4616
117k
    }
4617
4618
63
  asect->lineno_count = cache_ptr - lineno_cache;
4619
63
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
63
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
63
  if (!ordered)
4624
54
    {
4625
      /* Sort the table.  */
4626
54
      alent **func_table;
4627
54
      alent *n_lineno_cache;
4628
4629
      /* Create a table of functions.  */
4630
54
      if (_bfd_mul_overflow (nbr_func, sizeof (alent *), &amt))
4631
0
  {
4632
0
    bfd_set_error (bfd_error_file_too_big);
4633
0
    ret = false;
4634
0
  }
4635
54
      else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL)
4636
54
  {
4637
54
    alent **p = func_table;
4638
54
    unsigned int i;
4639
4640
117k
    for (i = 0; i < asect->lineno_count; i++)
4641
117k
      if (lineno_cache[i].line_number == 0)
4642
56.4k
        *p++ = &lineno_cache[i];
4643
4644
54
    BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func);
4645
4646
    /* Sort by functions.  */
4647
54
    qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent);
4648
4649
    /* Create the new sorted table.  */
4650
54
    if (_bfd_mul_overflow (asect->lineno_count, sizeof (alent), &amt))
4651
0
      {
4652
0
        bfd_set_error (bfd_error_file_too_big);
4653
0
        ret = false;
4654
0
      }
4655
54
    else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL)
4656
54
      {
4657
54
        alent *n_cache_ptr = n_lineno_cache;
4658
4659
56.4k
        for (i = 0; i < nbr_func; i++)
4660
56.4k
    {
4661
56.4k
      coff_symbol_type *sym;
4662
56.4k
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
56.4k
      sym = (coff_symbol_type *) old_ptr->u.sym;
4666
      /* PR binutils/17512: Point the lineno to where
4667
         this entry will be after the memcpy below.  */
4668
56.4k
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
56.4k
      do
4671
117k
        *n_cache_ptr++ = *old_ptr++;
4672
117k
      while (old_ptr->line_number != 0);
4673
56.4k
    }
4674
4675
54
        memcpy (lineno_cache, n_lineno_cache,
4676
54
          asect->lineno_count * sizeof (alent));
4677
54
      }
4678
0
    else
4679
0
      ret = false;
4680
54
    bfd_release (abfd, func_table);
4681
54
  }
4682
0
      else
4683
0
  ret = false;
4684
54
    }
4685
4686
63
  return ret;
4687
63
}
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
4490
461
{
4491
461
  LINENO *native_lineno;
4492
461
  alent *lineno_cache;
4493
461
  unsigned int counter;
4494
461
  alent *cache_ptr;
4495
461
  bfd_vma prev_offset = 0;
4496
461
  bool ordered = true;
4497
461
  unsigned int nbr_func;
4498
461
  LINENO *src;
4499
461
  bool have_func;
4500
461
  bool ret = true;
4501
461
  size_t amt;
4502
4503
461
  if (asect->lineno_count == 0)
4504
225
    return true;
4505
4506
236
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
236
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
236
             asect->lineno_count,
4510
236
             bfd_coff_linesz (abfd));
4511
236
  if (native_lineno == NULL)
4512
144
    {
4513
144
      _bfd_error_handler
4514
144
  (_("%pB: warning: line number table read failed"), abfd);
4515
144
      return false;
4516
144
    }
4517
4518
92
  if (_bfd_mul_overflow (asect->lineno_count + 1, sizeof (alent), &amt))
4519
0
    {
4520
0
      bfd_set_error (bfd_error_file_too_big);
4521
0
      free (native_lineno);
4522
0
      return false;
4523
0
    }
4524
92
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
92
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
92
  cache_ptr = lineno_cache;
4532
92
  asect->lineno = lineno_cache;
4533
92
  src = native_lineno;
4534
92
  nbr_func = 0;
4535
92
  have_func = false;
4536
4537
72.0k
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
71.9k
    {
4539
71.9k
      struct internal_lineno dst;
4540
4541
71.9k
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
71.9k
      cache_ptr->line_number = dst.l_lnno;
4543
      /* Appease memory checkers that get all excited about
4544
   uninitialised memory when copying alents if u.offset is
4545
   larger than u.sym.  (64-bit BFD on 32-bit host.)  */
4546
71.9k
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
71.9k
      if (cache_ptr->line_number == 0)
4549
29.4k
  {
4550
29.4k
    combined_entry_type * ent;
4551
29.4k
    unsigned long symndx;
4552
29.4k
    coff_symbol_type *sym;
4553
4554
29.4k
    have_func = false;
4555
29.4k
    symndx = dst.l_addr.l_symndx;
4556
29.4k
    if (symndx >= obj_raw_syment_count (abfd))
4557
13.9k
      {
4558
13.9k
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
13.9k
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
13.9k
     abfd, symndx, counter);
4562
13.9k
        cache_ptr->line_number = -1;
4563
13.9k
        ret = false;
4564
13.9k
        continue;
4565
13.9k
      }
4566
4567
15.4k
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
15.4k
    if (! ent->is_sym)
4571
2.63k
      {
4572
2.63k
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
2.63k
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
2.63k
     abfd, symndx, counter);
4576
2.63k
        cache_ptr->line_number = -1;
4577
2.63k
        ret = false;
4578
2.63k
        continue;
4579
2.63k
      }
4580
12.8k
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
12.8k
    if (sym < obj_symbols (abfd)
4584
12.8k
        || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd))
4585
0
      {
4586
0
        _bfd_error_handler
4587
    /* xgettext:c-format */
4588
0
    (_("%pB: warning: illegal symbol in line number entry %d"),
4589
0
     abfd, counter);
4590
0
        cache_ptr->line_number = -1;
4591
0
        ret = false;
4592
0
        continue;
4593
0
      }
4594
4595
12.8k
    have_func = true;
4596
12.8k
    nbr_func++;
4597
12.8k
    cache_ptr->u.sym = (asymbol *) sym;
4598
12.8k
    if (sym->lineno != NULL)
4599
12.5k
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
12.5k
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
12.5k
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
12.8k
    sym->lineno = cache_ptr;
4605
12.8k
    if (sym->symbol.value < prev_offset)
4606
616
      ordered = false;
4607
12.8k
    prev_offset = sym->symbol.value;
4608
12.8k
  }
4609
42.5k
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
24.9k
  continue;
4613
17.5k
      else
4614
17.5k
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
30.3k
      cache_ptr++;
4616
30.3k
    }
4617
4618
92
  asect->lineno_count = cache_ptr - lineno_cache;
4619
92
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
92
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
92
  if (!ordered)
4624
43
    {
4625
      /* Sort the table.  */
4626
43
      alent **func_table;
4627
43
      alent *n_lineno_cache;
4628
4629
      /* Create a table of functions.  */
4630
43
      if (_bfd_mul_overflow (nbr_func, sizeof (alent *), &amt))
4631
0
  {
4632
0
    bfd_set_error (bfd_error_file_too_big);
4633
0
    ret = false;
4634
0
  }
4635
43
      else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL)
4636
43
  {
4637
43
    alent **p = func_table;
4638
43
    unsigned int i;
4639
4640
21.4k
    for (i = 0; i < asect->lineno_count; i++)
4641
21.3k
      if (lineno_cache[i].line_number == 0)
4642
9.61k
        *p++ = &lineno_cache[i];
4643
4644
43
    BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func);
4645
4646
    /* Sort by functions.  */
4647
43
    qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent);
4648
4649
    /* Create the new sorted table.  */
4650
43
    if (_bfd_mul_overflow (asect->lineno_count, sizeof (alent), &amt))
4651
0
      {
4652
0
        bfd_set_error (bfd_error_file_too_big);
4653
0
        ret = false;
4654
0
      }
4655
43
    else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL)
4656
43
      {
4657
43
        alent *n_cache_ptr = n_lineno_cache;
4658
4659
9.65k
        for (i = 0; i < nbr_func; i++)
4660
9.61k
    {
4661
9.61k
      coff_symbol_type *sym;
4662
9.61k
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
9.61k
      sym = (coff_symbol_type *) old_ptr->u.sym;
4666
      /* PR binutils/17512: Point the lineno to where
4667
         this entry will be after the memcpy below.  */
4668
9.61k
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
9.61k
      do
4671
21.3k
        *n_cache_ptr++ = *old_ptr++;
4672
21.3k
      while (old_ptr->line_number != 0);
4673
9.61k
    }
4674
4675
43
        memcpy (lineno_cache, n_lineno_cache,
4676
43
          asect->lineno_count * sizeof (alent));
4677
43
      }
4678
0
    else
4679
0
      ret = false;
4680
43
    bfd_release (abfd, func_table);
4681
43
  }
4682
0
      else
4683
0
  ret = false;
4684
43
    }
4685
4686
92
  return ret;
4687
92
}
coff-sh.c:coff_slurp_line_table
Line
Count
Source
4490
1.07k
{
4491
1.07k
  LINENO *native_lineno;
4492
1.07k
  alent *lineno_cache;
4493
1.07k
  unsigned int counter;
4494
1.07k
  alent *cache_ptr;
4495
1.07k
  bfd_vma prev_offset = 0;
4496
1.07k
  bool ordered = true;
4497
1.07k
  unsigned int nbr_func;
4498
1.07k
  LINENO *src;
4499
1.07k
  bool have_func;
4500
1.07k
  bool ret = true;
4501
1.07k
  size_t amt;
4502
4503
1.07k
  if (asect->lineno_count == 0)
4504
835
    return true;
4505
4506
244
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
244
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
244
             asect->lineno_count,
4510
244
             bfd_coff_linesz (abfd));
4511
244
  if (native_lineno == NULL)
4512
151
    {
4513
151
      _bfd_error_handler
4514
151
  (_("%pB: warning: line number table read failed"), abfd);
4515
151
      return false;
4516
151
    }
4517
4518
93
  if (_bfd_mul_overflow (asect->lineno_count + 1, sizeof (alent), &amt))
4519
0
    {
4520
0
      bfd_set_error (bfd_error_file_too_big);
4521
0
      free (native_lineno);
4522
0
      return false;
4523
0
    }
4524
93
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
93
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
93
  cache_ptr = lineno_cache;
4532
93
  asect->lineno = lineno_cache;
4533
93
  src = native_lineno;
4534
93
  nbr_func = 0;
4535
93
  have_func = false;
4536
4537
186k
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
186k
    {
4539
186k
      struct internal_lineno dst;
4540
4541
186k
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
186k
      cache_ptr->line_number = dst.l_lnno;
4543
      /* Appease memory checkers that get all excited about
4544
   uninitialised memory when copying alents if u.offset is
4545
   larger than u.sym.  (64-bit BFD on 32-bit host.)  */
4546
186k
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
186k
      if (cache_ptr->line_number == 0)
4549
39.0k
  {
4550
39.0k
    combined_entry_type * ent;
4551
39.0k
    unsigned long symndx;
4552
39.0k
    coff_symbol_type *sym;
4553
4554
39.0k
    have_func = false;
4555
39.0k
    symndx = dst.l_addr.l_symndx;
4556
39.0k
    if (symndx >= obj_raw_syment_count (abfd))
4557
18.4k
      {
4558
18.4k
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
18.4k
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
18.4k
     abfd, symndx, counter);
4562
18.4k
        cache_ptr->line_number = -1;
4563
18.4k
        ret = false;
4564
18.4k
        continue;
4565
18.4k
      }
4566
4567
20.5k
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
20.5k
    if (! ent->is_sym)
4571
7.10k
      {
4572
7.10k
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
7.10k
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
7.10k
     abfd, symndx, counter);
4576
7.10k
        cache_ptr->line_number = -1;
4577
7.10k
        ret = false;
4578
7.10k
        continue;
4579
7.10k
      }
4580
13.4k
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
13.4k
    if (sym < obj_symbols (abfd)
4584
13.4k
        || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd))
4585
0
      {
4586
0
        _bfd_error_handler
4587
    /* xgettext:c-format */
4588
0
    (_("%pB: warning: illegal symbol in line number entry %d"),
4589
0
     abfd, counter);
4590
0
        cache_ptr->line_number = -1;
4591
0
        ret = false;
4592
0
        continue;
4593
0
      }
4594
4595
13.4k
    have_func = true;
4596
13.4k
    nbr_func++;
4597
13.4k
    cache_ptr->u.sym = (asymbol *) sym;
4598
13.4k
    if (sym->lineno != NULL)
4599
12.7k
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
12.7k
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
12.7k
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
13.4k
    sym->lineno = cache_ptr;
4605
13.4k
    if (sym->symbol.value < prev_offset)
4606
785
      ordered = false;
4607
13.4k
    prev_offset = sym->symbol.value;
4608
13.4k
  }
4609
147k
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
113k
  continue;
4613
33.8k
      else
4614
33.8k
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
47.3k
      cache_ptr++;
4616
47.3k
    }
4617
4618
93
  asect->lineno_count = cache_ptr - lineno_cache;
4619
93
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
93
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
93
  if (!ordered)
4624
42
    {
4625
      /* Sort the table.  */
4626
42
      alent **func_table;
4627
42
      alent *n_lineno_cache;
4628
4629
      /* Create a table of functions.  */
4630
42
      if (_bfd_mul_overflow (nbr_func, sizeof (alent *), &amt))
4631
0
  {
4632
0
    bfd_set_error (bfd_error_file_too_big);
4633
0
    ret = false;
4634
0
  }
4635
42
      else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL)
4636
42
  {
4637
42
    alent **p = func_table;
4638
42
    unsigned int i;
4639
4640
45.7k
    for (i = 0; i < asect->lineno_count; i++)
4641
45.6k
      if (lineno_cache[i].line_number == 0)
4642
12.8k
        *p++ = &lineno_cache[i];
4643
4644
42
    BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func);
4645
4646
    /* Sort by functions.  */
4647
42
    qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent);
4648
4649
    /* Create the new sorted table.  */
4650
42
    if (_bfd_mul_overflow (asect->lineno_count, sizeof (alent), &amt))
4651
0
      {
4652
0
        bfd_set_error (bfd_error_file_too_big);
4653
0
        ret = false;
4654
0
      }
4655
42
    else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL)
4656
42
      {
4657
42
        alent *n_cache_ptr = n_lineno_cache;
4658
4659
12.8k
        for (i = 0; i < nbr_func; i++)
4660
12.8k
    {
4661
12.8k
      coff_symbol_type *sym;
4662
12.8k
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
12.8k
      sym = (coff_symbol_type *) old_ptr->u.sym;
4666
      /* PR binutils/17512: Point the lineno to where
4667
         this entry will be after the memcpy below.  */
4668
12.8k
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
12.8k
      do
4671
45.6k
        *n_cache_ptr++ = *old_ptr++;
4672
45.6k
      while (old_ptr->line_number != 0);
4673
12.8k
    }
4674
4675
42
        memcpy (lineno_cache, n_lineno_cache,
4676
42
          asect->lineno_count * sizeof (alent));
4677
42
      }
4678
0
    else
4679
0
      ret = false;
4680
42
    bfd_release (abfd, func_table);
4681
42
  }
4682
0
      else
4683
0
  ret = false;
4684
42
    }
4685
4686
93
  return ret;
4687
93
}
Unexecuted instantiation: coff-stgo32.c:coff_slurp_line_table
coff-tic30.c:coff_slurp_line_table
Line
Count
Source
4490
1.45k
{
4491
1.45k
  LINENO *native_lineno;
4492
1.45k
  alent *lineno_cache;
4493
1.45k
  unsigned int counter;
4494
1.45k
  alent *cache_ptr;
4495
1.45k
  bfd_vma prev_offset = 0;
4496
1.45k
  bool ordered = true;
4497
1.45k
  unsigned int nbr_func;
4498
1.45k
  LINENO *src;
4499
1.45k
  bool have_func;
4500
1.45k
  bool ret = true;
4501
1.45k
  size_t amt;
4502
4503
1.45k
  if (asect->lineno_count == 0)
4504
1.13k
    return true;
4505
4506
317
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
317
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
317
             asect->lineno_count,
4510
317
             bfd_coff_linesz (abfd));
4511
317
  if (native_lineno == NULL)
4512
120
    {
4513
120
      _bfd_error_handler
4514
120
  (_("%pB: warning: line number table read failed"), abfd);
4515
120
      return false;
4516
120
    }
4517
4518
197
  if (_bfd_mul_overflow (asect->lineno_count + 1, sizeof (alent), &amt))
4519
0
    {
4520
0
      bfd_set_error (bfd_error_file_too_big);
4521
0
      free (native_lineno);
4522
0
      return false;
4523
0
    }
4524
197
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
197
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
197
  cache_ptr = lineno_cache;
4532
197
  asect->lineno = lineno_cache;
4533
197
  src = native_lineno;
4534
197
  nbr_func = 0;
4535
197
  have_func = false;
4536
4537
115k
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
115k
    {
4539
115k
      struct internal_lineno dst;
4540
4541
115k
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
115k
      cache_ptr->line_number = dst.l_lnno;
4543
      /* Appease memory checkers that get all excited about
4544
   uninitialised memory when copying alents if u.offset is
4545
   larger than u.sym.  (64-bit BFD on 32-bit host.)  */
4546
115k
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
115k
      if (cache_ptr->line_number == 0)
4549
27.3k
  {
4550
27.3k
    combined_entry_type * ent;
4551
27.3k
    unsigned long symndx;
4552
27.3k
    coff_symbol_type *sym;
4553
4554
27.3k
    have_func = false;
4555
27.3k
    symndx = dst.l_addr.l_symndx;
4556
27.3k
    if (symndx >= obj_raw_syment_count (abfd))
4557
14.1k
      {
4558
14.1k
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
14.1k
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
14.1k
     abfd, symndx, counter);
4562
14.1k
        cache_ptr->line_number = -1;
4563
14.1k
        ret = false;
4564
14.1k
        continue;
4565
14.1k
      }
4566
4567
13.1k
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
13.1k
    if (! ent->is_sym)
4571
3.01k
      {
4572
3.01k
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
3.01k
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
3.01k
     abfd, symndx, counter);
4576
3.01k
        cache_ptr->line_number = -1;
4577
3.01k
        ret = false;
4578
3.01k
        continue;
4579
3.01k
      }
4580
10.1k
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
10.1k
    if (sym < obj_symbols (abfd)
4584
10.1k
        || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd))
4585
0
      {
4586
0
        _bfd_error_handler
4587
    /* xgettext:c-format */
4588
0
    (_("%pB: warning: illegal symbol in line number entry %d"),
4589
0
     abfd, counter);
4590
0
        cache_ptr->line_number = -1;
4591
0
        ret = false;
4592
0
        continue;
4593
0
      }
4594
4595
10.1k
    have_func = true;
4596
10.1k
    nbr_func++;
4597
10.1k
    cache_ptr->u.sym = (asymbol *) sym;
4598
10.1k
    if (sym->lineno != NULL)
4599
9.68k
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
9.68k
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
9.68k
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
10.1k
    sym->lineno = cache_ptr;
4605
10.1k
    if (sym->symbol.value < prev_offset)
4606
374
      ordered = false;
4607
10.1k
    prev_offset = sym->symbol.value;
4608
10.1k
  }
4609
88.4k
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
65.6k
  continue;
4613
22.7k
      else
4614
22.7k
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
32.9k
      cache_ptr++;
4616
32.9k
    }
4617
4618
197
  asect->lineno_count = cache_ptr - lineno_cache;
4619
197
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
197
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
197
  if (!ordered)
4624
84
    {
4625
      /* Sort the table.  */
4626
84
      alent **func_table;
4627
84
      alent *n_lineno_cache;
4628
4629
      /* Create a table of functions.  */
4630
84
      if (_bfd_mul_overflow (nbr_func, sizeof (alent *), &amt))
4631
0
  {
4632
0
    bfd_set_error (bfd_error_file_too_big);
4633
0
    ret = false;
4634
0
  }
4635
84
      else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL)
4636
84
  {
4637
84
    alent **p = func_table;
4638
84
    unsigned int i;
4639
4640
29.5k
    for (i = 0; i < asect->lineno_count; i++)
4641
29.5k
      if (lineno_cache[i].line_number == 0)
4642
8.72k
        *p++ = &lineno_cache[i];
4643
4644
84
    BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func);
4645
4646
    /* Sort by functions.  */
4647
84
    qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent);
4648
4649
    /* Create the new sorted table.  */
4650
84
    if (_bfd_mul_overflow (asect->lineno_count, sizeof (alent), &amt))
4651
0
      {
4652
0
        bfd_set_error (bfd_error_file_too_big);
4653
0
        ret = false;
4654
0
      }
4655
84
    else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL)
4656
84
      {
4657
84
        alent *n_cache_ptr = n_lineno_cache;
4658
4659
8.80k
        for (i = 0; i < nbr_func; i++)
4660
8.72k
    {
4661
8.72k
      coff_symbol_type *sym;
4662
8.72k
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
8.72k
      sym = (coff_symbol_type *) old_ptr->u.sym;
4666
      /* PR binutils/17512: Point the lineno to where
4667
         this entry will be after the memcpy below.  */
4668
8.72k
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
8.72k
      do
4671
29.5k
        *n_cache_ptr++ = *old_ptr++;
4672
29.5k
      while (old_ptr->line_number != 0);
4673
8.72k
    }
4674
4675
84
        memcpy (lineno_cache, n_lineno_cache,
4676
84
          asect->lineno_count * sizeof (alent));
4677
84
      }
4678
0
    else
4679
0
      ret = false;
4680
84
    bfd_release (abfd, func_table);
4681
84
  }
4682
0
      else
4683
0
  ret = false;
4684
84
    }
4685
4686
197
  return ret;
4687
197
}
Unexecuted instantiation: coff-tic4x.c:coff_slurp_line_table
coff-tic54x.c:coff_slurp_line_table
Line
Count
Source
4490
864
{
4491
864
  LINENO *native_lineno;
4492
864
  alent *lineno_cache;
4493
864
  unsigned int counter;
4494
864
  alent *cache_ptr;
4495
864
  bfd_vma prev_offset = 0;
4496
864
  bool ordered = true;
4497
864
  unsigned int nbr_func;
4498
864
  LINENO *src;
4499
864
  bool have_func;
4500
864
  bool ret = true;
4501
864
  size_t amt;
4502
4503
864
  if (asect->lineno_count == 0)
4504
658
    return true;
4505
4506
206
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
206
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
206
             asect->lineno_count,
4510
206
             bfd_coff_linesz (abfd));
4511
206
  if (native_lineno == NULL)
4512
108
    {
4513
108
      _bfd_error_handler
4514
108
  (_("%pB: warning: line number table read failed"), abfd);
4515
108
      return false;
4516
108
    }
4517
4518
98
  if (_bfd_mul_overflow (asect->lineno_count + 1, sizeof (alent), &amt))
4519
0
    {
4520
0
      bfd_set_error (bfd_error_file_too_big);
4521
0
      free (native_lineno);
4522
0
      return false;
4523
0
    }
4524
98
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
98
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
98
  cache_ptr = lineno_cache;
4532
98
  asect->lineno = lineno_cache;
4533
98
  src = native_lineno;
4534
98
  nbr_func = 0;
4535
98
  have_func = false;
4536
4537
150k
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
150k
    {
4539
150k
      struct internal_lineno dst;
4540
4541
150k
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
150k
      cache_ptr->line_number = dst.l_lnno;
4543
      /* Appease memory checkers that get all excited about
4544
   uninitialised memory when copying alents if u.offset is
4545
   larger than u.sym.  (64-bit BFD on 32-bit host.)  */
4546
150k
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
150k
      if (cache_ptr->line_number == 0)
4549
64.3k
  {
4550
64.3k
    combined_entry_type * ent;
4551
64.3k
    unsigned long symndx;
4552
64.3k
    coff_symbol_type *sym;
4553
4554
64.3k
    have_func = false;
4555
64.3k
    symndx = dst.l_addr.l_symndx;
4556
64.3k
    if (symndx >= obj_raw_syment_count (abfd))
4557
34.9k
      {
4558
34.9k
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
34.9k
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
34.9k
     abfd, symndx, counter);
4562
34.9k
        cache_ptr->line_number = -1;
4563
34.9k
        ret = false;
4564
34.9k
        continue;
4565
34.9k
      }
4566
4567
29.4k
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
29.4k
    if (! ent->is_sym)
4571
5.61k
      {
4572
5.61k
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
5.61k
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
5.61k
     abfd, symndx, counter);
4576
5.61k
        cache_ptr->line_number = -1;
4577
5.61k
        ret = false;
4578
5.61k
        continue;
4579
5.61k
      }
4580
23.7k
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
23.7k
    if (sym < obj_symbols (abfd)
4584
23.7k
        || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd))
4585
0
      {
4586
0
        _bfd_error_handler
4587
    /* xgettext:c-format */
4588
0
    (_("%pB: warning: illegal symbol in line number entry %d"),
4589
0
     abfd, counter);
4590
0
        cache_ptr->line_number = -1;
4591
0
        ret = false;
4592
0
        continue;
4593
0
      }
4594
4595
23.7k
    have_func = true;
4596
23.7k
    nbr_func++;
4597
23.7k
    cache_ptr->u.sym = (asymbol *) sym;
4598
23.7k
    if (sym->lineno != NULL)
4599
23.3k
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
23.3k
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
23.3k
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
23.7k
    sym->lineno = cache_ptr;
4605
23.7k
    if (sym->symbol.value < prev_offset)
4606
787
      ordered = false;
4607
23.7k
    prev_offset = sym->symbol.value;
4608
23.7k
  }
4609
86.1k
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
57.7k
  continue;
4613
28.3k
      else
4614
28.3k
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
52.1k
      cache_ptr++;
4616
52.1k
    }
4617
4618
98
  asect->lineno_count = cache_ptr - lineno_cache;
4619
98
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
98
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
98
  if (!ordered)
4624
68
    {
4625
      /* Sort the table.  */
4626
68
      alent **func_table;
4627
68
      alent *n_lineno_cache;
4628
4629
      /* Create a table of functions.  */
4630
68
      if (_bfd_mul_overflow (nbr_func, sizeof (alent *), &amt))
4631
0
  {
4632
0
    bfd_set_error (bfd_error_file_too_big);
4633
0
    ret = false;
4634
0
  }
4635
68
      else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL)
4636
68
  {
4637
68
    alent **p = func_table;
4638
68
    unsigned int i;
4639
4640
51.7k
    for (i = 0; i < asect->lineno_count; i++)
4641
51.6k
      if (lineno_cache[i].line_number == 0)
4642
23.5k
        *p++ = &lineno_cache[i];
4643
4644
68
    BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func);
4645
4646
    /* Sort by functions.  */
4647
68
    qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent);
4648
4649
    /* Create the new sorted table.  */
4650
68
    if (_bfd_mul_overflow (asect->lineno_count, sizeof (alent), &amt))
4651
0
      {
4652
0
        bfd_set_error (bfd_error_file_too_big);
4653
0
        ret = false;
4654
0
      }
4655
68
    else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL)
4656
68
      {
4657
68
        alent *n_cache_ptr = n_lineno_cache;
4658
4659
23.5k
        for (i = 0; i < nbr_func; i++)
4660
23.5k
    {
4661
23.5k
      coff_symbol_type *sym;
4662
23.5k
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
23.5k
      sym = (coff_symbol_type *) old_ptr->u.sym;
4666
      /* PR binutils/17512: Point the lineno to where
4667
         this entry will be after the memcpy below.  */
4668
23.5k
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
23.5k
      do
4671
51.6k
        *n_cache_ptr++ = *old_ptr++;
4672
51.6k
      while (old_ptr->line_number != 0);
4673
23.5k
    }
4674
4675
68
        memcpy (lineno_cache, n_lineno_cache,
4676
68
          asect->lineno_count * sizeof (alent));
4677
68
      }
4678
0
    else
4679
0
      ret = false;
4680
68
    bfd_release (abfd, func_table);
4681
68
  }
4682
0
      else
4683
0
  ret = false;
4684
68
    }
4685
4686
98
  return ret;
4687
98
}
coff-z80.c:coff_slurp_line_table
Line
Count
Source
4490
781
{
4491
781
  LINENO *native_lineno;
4492
781
  alent *lineno_cache;
4493
781
  unsigned int counter;
4494
781
  alent *cache_ptr;
4495
781
  bfd_vma prev_offset = 0;
4496
781
  bool ordered = true;
4497
781
  unsigned int nbr_func;
4498
781
  LINENO *src;
4499
781
  bool have_func;
4500
781
  bool ret = true;
4501
781
  size_t amt;
4502
4503
781
  if (asect->lineno_count == 0)
4504
574
    return true;
4505
4506
207
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
207
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
207
             asect->lineno_count,
4510
207
             bfd_coff_linesz (abfd));
4511
207
  if (native_lineno == NULL)
4512
107
    {
4513
107
      _bfd_error_handler
4514
107
  (_("%pB: warning: line number table read failed"), abfd);
4515
107
      return false;
4516
107
    }
4517
4518
100
  if (_bfd_mul_overflow (asect->lineno_count + 1, sizeof (alent), &amt))
4519
0
    {
4520
0
      bfd_set_error (bfd_error_file_too_big);
4521
0
      free (native_lineno);
4522
0
      return false;
4523
0
    }
4524
100
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
100
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
100
  cache_ptr = lineno_cache;
4532
100
  asect->lineno = lineno_cache;
4533
100
  src = native_lineno;
4534
100
  nbr_func = 0;
4535
100
  have_func = false;
4536
4537
165k
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
165k
    {
4539
165k
      struct internal_lineno dst;
4540
4541
165k
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
165k
      cache_ptr->line_number = dst.l_lnno;
4543
      /* Appease memory checkers that get all excited about
4544
   uninitialised memory when copying alents if u.offset is
4545
   larger than u.sym.  (64-bit BFD on 32-bit host.)  */
4546
165k
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
165k
      if (cache_ptr->line_number == 0)
4549
43.9k
  {
4550
43.9k
    combined_entry_type * ent;
4551
43.9k
    unsigned long symndx;
4552
43.9k
    coff_symbol_type *sym;
4553
4554
43.9k
    have_func = false;
4555
43.9k
    symndx = dst.l_addr.l_symndx;
4556
43.9k
    if (symndx >= obj_raw_syment_count (abfd))
4557
16.9k
      {
4558
16.9k
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
16.9k
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
16.9k
     abfd, symndx, counter);
4562
16.9k
        cache_ptr->line_number = -1;
4563
16.9k
        ret = false;
4564
16.9k
        continue;
4565
16.9k
      }
4566
4567
27.0k
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
27.0k
    if (! ent->is_sym)
4571
3.64k
      {
4572
3.64k
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
3.64k
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
3.64k
     abfd, symndx, counter);
4576
3.64k
        cache_ptr->line_number = -1;
4577
3.64k
        ret = false;
4578
3.64k
        continue;
4579
3.64k
      }
4580
23.3k
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
23.3k
    if (sym < obj_symbols (abfd)
4584
23.3k
        || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd))
4585
0
      {
4586
0
        _bfd_error_handler
4587
    /* xgettext:c-format */
4588
0
    (_("%pB: warning: illegal symbol in line number entry %d"),
4589
0
     abfd, counter);
4590
0
        cache_ptr->line_number = -1;
4591
0
        ret = false;
4592
0
        continue;
4593
0
      }
4594
4595
23.3k
    have_func = true;
4596
23.3k
    nbr_func++;
4597
23.3k
    cache_ptr->u.sym = (asymbol *) sym;
4598
23.3k
    if (sym->lineno != NULL)
4599
22.7k
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
22.7k
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
22.7k
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
23.3k
    sym->lineno = cache_ptr;
4605
23.3k
    if (sym->symbol.value < prev_offset)
4606
452
      ordered = false;
4607
23.3k
    prev_offset = sym->symbol.value;
4608
23.3k
  }
4609
121k
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
75.5k
  continue;
4613
46.2k
      else
4614
46.2k
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
69.5k
      cache_ptr++;
4616
69.5k
    }
4617
4618
100
  asect->lineno_count = cache_ptr - lineno_cache;
4619
100
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
100
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
100
  if (!ordered)
4624
56
    {
4625
      /* Sort the table.  */
4626
56
      alent **func_table;
4627
56
      alent *n_lineno_cache;
4628
4629
      /* Create a table of functions.  */
4630
56
      if (_bfd_mul_overflow (nbr_func, sizeof (alent *), &amt))
4631
0
  {
4632
0
    bfd_set_error (bfd_error_file_too_big);
4633
0
    ret = false;
4634
0
  }
4635
56
      else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL)
4636
56
  {
4637
56
    alent **p = func_table;
4638
56
    unsigned int i;
4639
4640
66.4k
    for (i = 0; i < asect->lineno_count; i++)
4641
66.4k
      if (lineno_cache[i].line_number == 0)
4642
22.5k
        *p++ = &lineno_cache[i];
4643
4644
56
    BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func);
4645
4646
    /* Sort by functions.  */
4647
56
    qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent);
4648
4649
    /* Create the new sorted table.  */
4650
56
    if (_bfd_mul_overflow (asect->lineno_count, sizeof (alent), &amt))
4651
0
      {
4652
0
        bfd_set_error (bfd_error_file_too_big);
4653
0
        ret = false;
4654
0
      }
4655
56
    else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL)
4656
56
      {
4657
56
        alent *n_cache_ptr = n_lineno_cache;
4658
4659
22.6k
        for (i = 0; i < nbr_func; i++)
4660
22.5k
    {
4661
22.5k
      coff_symbol_type *sym;
4662
22.5k
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
22.5k
      sym = (coff_symbol_type *) old_ptr->u.sym;
4666
      /* PR binutils/17512: Point the lineno to where
4667
         this entry will be after the memcpy below.  */
4668
22.5k
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
22.5k
      do
4671
66.4k
        *n_cache_ptr++ = *old_ptr++;
4672
66.4k
      while (old_ptr->line_number != 0);
4673
22.5k
    }
4674
4675
56
        memcpy (lineno_cache, n_lineno_cache,
4676
56
          asect->lineno_count * sizeof (alent));
4677
56
      }
4678
0
    else
4679
0
      ret = false;
4680
56
    bfd_release (abfd, func_table);
4681
56
  }
4682
0
      else
4683
0
  ret = false;
4684
56
    }
4685
4686
100
  return ret;
4687
100
}
coff-z8k.c:coff_slurp_line_table
Line
Count
Source
4490
1.18k
{
4491
1.18k
  LINENO *native_lineno;
4492
1.18k
  alent *lineno_cache;
4493
1.18k
  unsigned int counter;
4494
1.18k
  alent *cache_ptr;
4495
1.18k
  bfd_vma prev_offset = 0;
4496
1.18k
  bool ordered = true;
4497
1.18k
  unsigned int nbr_func;
4498
1.18k
  LINENO *src;
4499
1.18k
  bool have_func;
4500
1.18k
  bool ret = true;
4501
1.18k
  size_t amt;
4502
4503
1.18k
  if (asect->lineno_count == 0)
4504
968
    return true;
4505
4506
212
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
212
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
212
             asect->lineno_count,
4510
212
             bfd_coff_linesz (abfd));
4511
212
  if (native_lineno == NULL)
4512
92
    {
4513
92
      _bfd_error_handler
4514
92
  (_("%pB: warning: line number table read failed"), abfd);
4515
92
      return false;
4516
92
    }
4517
4518
120
  if (_bfd_mul_overflow (asect->lineno_count + 1, sizeof (alent), &amt))
4519
0
    {
4520
0
      bfd_set_error (bfd_error_file_too_big);
4521
0
      free (native_lineno);
4522
0
      return false;
4523
0
    }
4524
120
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
120
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
120
  cache_ptr = lineno_cache;
4532
120
  asect->lineno = lineno_cache;
4533
120
  src = native_lineno;
4534
120
  nbr_func = 0;
4535
120
  have_func = false;
4536
4537
356k
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
356k
    {
4539
356k
      struct internal_lineno dst;
4540
4541
356k
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
356k
      cache_ptr->line_number = dst.l_lnno;
4543
      /* Appease memory checkers that get all excited about
4544
   uninitialised memory when copying alents if u.offset is
4545
   larger than u.sym.  (64-bit BFD on 32-bit host.)  */
4546
356k
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
356k
      if (cache_ptr->line_number == 0)
4549
85.2k
  {
4550
85.2k
    combined_entry_type * ent;
4551
85.2k
    unsigned long symndx;
4552
85.2k
    coff_symbol_type *sym;
4553
4554
85.2k
    have_func = false;
4555
85.2k
    symndx = dst.l_addr.l_symndx;
4556
85.2k
    if (symndx >= obj_raw_syment_count (abfd))
4557
51.4k
      {
4558
51.4k
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
51.4k
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
51.4k
     abfd, symndx, counter);
4562
51.4k
        cache_ptr->line_number = -1;
4563
51.4k
        ret = false;
4564
51.4k
        continue;
4565
51.4k
      }
4566
4567
33.7k
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
33.7k
    if (! ent->is_sym)
4571
5.96k
      {
4572
5.96k
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
5.96k
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
5.96k
     abfd, symndx, counter);
4576
5.96k
        cache_ptr->line_number = -1;
4577
5.96k
        ret = false;
4578
5.96k
        continue;
4579
5.96k
      }
4580
27.8k
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
27.8k
    if (sym < obj_symbols (abfd)
4584
27.8k
        || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd))
4585
0
      {
4586
0
        _bfd_error_handler
4587
    /* xgettext:c-format */
4588
0
    (_("%pB: warning: illegal symbol in line number entry %d"),
4589
0
     abfd, counter);
4590
0
        cache_ptr->line_number = -1;
4591
0
        ret = false;
4592
0
        continue;
4593
0
      }
4594
4595
27.8k
    have_func = true;
4596
27.8k
    nbr_func++;
4597
27.8k
    cache_ptr->u.sym = (asymbol *) sym;
4598
27.8k
    if (sym->lineno != NULL)
4599
27.1k
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
27.1k
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
27.1k
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
27.8k
    sym->lineno = cache_ptr;
4605
27.8k
    if (sym->symbol.value < prev_offset)
4606
1.24k
      ordered = false;
4607
27.8k
    prev_offset = sym->symbol.value;
4608
27.8k
  }
4609
271k
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
196k
  continue;
4613
74.5k
      else
4614
74.5k
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
102k
      cache_ptr++;
4616
102k
    }
4617
4618
120
  asect->lineno_count = cache_ptr - lineno_cache;
4619
120
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
120
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
120
  if (!ordered)
4624
50
    {
4625
      /* Sort the table.  */
4626
50
      alent **func_table;
4627
50
      alent *n_lineno_cache;
4628
4629
      /* Create a table of functions.  */
4630
50
      if (_bfd_mul_overflow (nbr_func, sizeof (alent *), &amt))
4631
0
  {
4632
0
    bfd_set_error (bfd_error_file_too_big);
4633
0
    ret = false;
4634
0
  }
4635
50
      else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL)
4636
50
  {
4637
50
    alent **p = func_table;
4638
50
    unsigned int i;
4639
4640
101k
    for (i = 0; i < asect->lineno_count; i++)
4641
101k
      if (lineno_cache[i].line_number == 0)
4642
27.4k
        *p++ = &lineno_cache[i];
4643
4644
50
    BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func);
4645
4646
    /* Sort by functions.  */
4647
50
    qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent);
4648
4649
    /* Create the new sorted table.  */
4650
50
    if (_bfd_mul_overflow (asect->lineno_count, sizeof (alent), &amt))
4651
0
      {
4652
0
        bfd_set_error (bfd_error_file_too_big);
4653
0
        ret = false;
4654
0
      }
4655
50
    else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL)
4656
50
      {
4657
50
        alent *n_cache_ptr = n_lineno_cache;
4658
4659
27.4k
        for (i = 0; i < nbr_func; i++)
4660
27.4k
    {
4661
27.4k
      coff_symbol_type *sym;
4662
27.4k
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
27.4k
      sym = (coff_symbol_type *) old_ptr->u.sym;
4666
      /* PR binutils/17512: Point the lineno to where
4667
         this entry will be after the memcpy below.  */
4668
27.4k
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
27.4k
      do
4671
101k
        *n_cache_ptr++ = *old_ptr++;
4672
101k
      while (old_ptr->line_number != 0);
4673
27.4k
    }
4674
4675
50
        memcpy (lineno_cache, n_lineno_cache,
4676
50
          asect->lineno_count * sizeof (alent));
4677
50
      }
4678
0
    else
4679
0
      ret = false;
4680
50
    bfd_release (abfd, func_table);
4681
50
  }
4682
0
      else
4683
0
  ret = false;
4684
50
    }
4685
4686
120
  return ret;
4687
120
}
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
4490
206
{
4491
206
  LINENO *native_lineno;
4492
206
  alent *lineno_cache;
4493
206
  unsigned int counter;
4494
206
  alent *cache_ptr;
4495
206
  bfd_vma prev_offset = 0;
4496
206
  bool ordered = true;
4497
206
  unsigned int nbr_func;
4498
206
  LINENO *src;
4499
206
  bool have_func;
4500
206
  bool ret = true;
4501
206
  size_t amt;
4502
4503
206
  if (asect->lineno_count == 0)
4504
120
    return true;
4505
4506
86
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
86
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
86
             asect->lineno_count,
4510
86
             bfd_coff_linesz (abfd));
4511
86
  if (native_lineno == NULL)
4512
10
    {
4513
10
      _bfd_error_handler
4514
10
  (_("%pB: warning: line number table read failed"), abfd);
4515
10
      return false;
4516
10
    }
4517
4518
76
  if (_bfd_mul_overflow (asect->lineno_count + 1, sizeof (alent), &amt))
4519
0
    {
4520
0
      bfd_set_error (bfd_error_file_too_big);
4521
0
      free (native_lineno);
4522
0
      return false;
4523
0
    }
4524
76
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
76
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
76
  cache_ptr = lineno_cache;
4532
76
  asect->lineno = lineno_cache;
4533
76
  src = native_lineno;
4534
76
  nbr_func = 0;
4535
76
  have_func = false;
4536
4537
117k
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
117k
    {
4539
117k
      struct internal_lineno dst;
4540
4541
117k
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
117k
      cache_ptr->line_number = dst.l_lnno;
4543
      /* Appease memory checkers that get all excited about
4544
   uninitialised memory when copying alents if u.offset is
4545
   larger than u.sym.  (64-bit BFD on 32-bit host.)  */
4546
117k
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
117k
      if (cache_ptr->line_number == 0)
4549
56.6k
  {
4550
56.6k
    combined_entry_type * ent;
4551
56.6k
    unsigned long symndx;
4552
56.6k
    coff_symbol_type *sym;
4553
4554
56.6k
    have_func = false;
4555
56.6k
    symndx = dst.l_addr.l_symndx;
4556
56.6k
    if (symndx >= obj_raw_syment_count (abfd))
4557
27.8k
      {
4558
27.8k
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
27.8k
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
27.8k
     abfd, symndx, counter);
4562
27.8k
        cache_ptr->line_number = -1;
4563
27.8k
        ret = false;
4564
27.8k
        continue;
4565
27.8k
      }
4566
4567
28.7k
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
28.7k
    if (! ent->is_sym)
4571
4.51k
      {
4572
4.51k
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
4.51k
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
4.51k
     abfd, symndx, counter);
4576
4.51k
        cache_ptr->line_number = -1;
4577
4.51k
        ret = false;
4578
4.51k
        continue;
4579
4.51k
      }
4580
24.2k
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
24.2k
    if (sym < obj_symbols (abfd)
4584
24.2k
        || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd))
4585
0
      {
4586
0
        _bfd_error_handler
4587
    /* xgettext:c-format */
4588
0
    (_("%pB: warning: illegal symbol in line number entry %d"),
4589
0
     abfd, counter);
4590
0
        cache_ptr->line_number = -1;
4591
0
        ret = false;
4592
0
        continue;
4593
0
      }
4594
4595
24.2k
    have_func = true;
4596
24.2k
    nbr_func++;
4597
24.2k
    cache_ptr->u.sym = (asymbol *) sym;
4598
24.2k
    if (sym->lineno != NULL)
4599
23.6k
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
23.6k
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
23.6k
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
24.2k
    sym->lineno = cache_ptr;
4605
24.2k
    if (sym->symbol.value < prev_offset)
4606
1.14k
      ordered = false;
4607
24.2k
    prev_offset = sym->symbol.value;
4608
24.2k
  }
4609
60.5k
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
40.8k
  continue;
4613
19.6k
      else
4614
19.6k
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
43.8k
      cache_ptr++;
4616
43.8k
    }
4617
4618
76
  asect->lineno_count = cache_ptr - lineno_cache;
4619
76
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
76
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
76
  if (!ordered)
4624
70
    {
4625
      /* Sort the table.  */
4626
70
      alent **func_table;
4627
70
      alent *n_lineno_cache;
4628
4629
      /* Create a table of functions.  */
4630
70
      if (_bfd_mul_overflow (nbr_func, sizeof (alent *), &amt))
4631
0
  {
4632
0
    bfd_set_error (bfd_error_file_too_big);
4633
0
    ret = false;
4634
0
  }
4635
70
      else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL)
4636
70
  {
4637
70
    alent **p = func_table;
4638
70
    unsigned int i;
4639
4640
43.9k
    for (i = 0; i < asect->lineno_count; i++)
4641
43.8k
      if (lineno_cache[i].line_number == 0)
4642
24.2k
        *p++ = &lineno_cache[i];
4643
4644
70
    BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func);
4645
4646
    /* Sort by functions.  */
4647
70
    qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent);
4648
4649
    /* Create the new sorted table.  */
4650
70
    if (_bfd_mul_overflow (asect->lineno_count, sizeof (alent), &amt))
4651
0
      {
4652
0
        bfd_set_error (bfd_error_file_too_big);
4653
0
        ret = false;
4654
0
      }
4655
70
    else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL)
4656
70
      {
4657
70
        alent *n_cache_ptr = n_lineno_cache;
4658
4659
24.3k
        for (i = 0; i < nbr_func; i++)
4660
24.2k
    {
4661
24.2k
      coff_symbol_type *sym;
4662
24.2k
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
24.2k
      sym = (coff_symbol_type *) old_ptr->u.sym;
4666
      /* PR binutils/17512: Point the lineno to where
4667
         this entry will be after the memcpy below.  */
4668
24.2k
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
24.2k
      do
4671
43.8k
        *n_cache_ptr++ = *old_ptr++;
4672
43.8k
      while (old_ptr->line_number != 0);
4673
24.2k
    }
4674
4675
70
        memcpy (lineno_cache, n_lineno_cache,
4676
70
          asect->lineno_count * sizeof (alent));
4677
70
      }
4678
0
    else
4679
0
      ret = false;
4680
70
    bfd_release (abfd, func_table);
4681
70
  }
4682
0
      else
4683
0
  ret = false;
4684
70
    }
4685
4686
76
  return ret;
4687
76
}
pe-mcore.c:coff_slurp_line_table
Line
Count
Source
4490
214
{
4491
214
  LINENO *native_lineno;
4492
214
  alent *lineno_cache;
4493
214
  unsigned int counter;
4494
214
  alent *cache_ptr;
4495
214
  bfd_vma prev_offset = 0;
4496
214
  bool ordered = true;
4497
214
  unsigned int nbr_func;
4498
214
  LINENO *src;
4499
214
  bool have_func;
4500
214
  bool ret = true;
4501
214
  size_t amt;
4502
4503
214
  if (asect->lineno_count == 0)
4504
120
    return true;
4505
4506
94
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
94
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
94
             asect->lineno_count,
4510
94
             bfd_coff_linesz (abfd));
4511
94
  if (native_lineno == NULL)
4512
20
    {
4513
20
      _bfd_error_handler
4514
20
  (_("%pB: warning: line number table read failed"), abfd);
4515
20
      return false;
4516
20
    }
4517
4518
74
  if (_bfd_mul_overflow (asect->lineno_count + 1, sizeof (alent), &amt))
4519
0
    {
4520
0
      bfd_set_error (bfd_error_file_too_big);
4521
0
      free (native_lineno);
4522
0
      return false;
4523
0
    }
4524
74
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
74
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
74
  cache_ptr = lineno_cache;
4532
74
  asect->lineno = lineno_cache;
4533
74
  src = native_lineno;
4534
74
  nbr_func = 0;
4535
74
  have_func = false;
4536
4537
277k
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
277k
    {
4539
277k
      struct internal_lineno dst;
4540
4541
277k
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
277k
      cache_ptr->line_number = dst.l_lnno;
4543
      /* Appease memory checkers that get all excited about
4544
   uninitialised memory when copying alents if u.offset is
4545
   larger than u.sym.  (64-bit BFD on 32-bit host.)  */
4546
277k
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
277k
      if (cache_ptr->line_number == 0)
4549
115k
  {
4550
115k
    combined_entry_type * ent;
4551
115k
    unsigned long symndx;
4552
115k
    coff_symbol_type *sym;
4553
4554
115k
    have_func = false;
4555
115k
    symndx = dst.l_addr.l_symndx;
4556
115k
    if (symndx >= obj_raw_syment_count (abfd))
4557
58.5k
      {
4558
58.5k
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
58.5k
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
58.5k
     abfd, symndx, counter);
4562
58.5k
        cache_ptr->line_number = -1;
4563
58.5k
        ret = false;
4564
58.5k
        continue;
4565
58.5k
      }
4566
4567
56.9k
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
56.9k
    if (! ent->is_sym)
4571
9.94k
      {
4572
9.94k
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
9.94k
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
9.94k
     abfd, symndx, counter);
4576
9.94k
        cache_ptr->line_number = -1;
4577
9.94k
        ret = false;
4578
9.94k
        continue;
4579
9.94k
      }
4580
46.9k
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
46.9k
    if (sym < obj_symbols (abfd)
4584
46.9k
        || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd))
4585
0
      {
4586
0
        _bfd_error_handler
4587
    /* xgettext:c-format */
4588
0
    (_("%pB: warning: illegal symbol in line number entry %d"),
4589
0
     abfd, counter);
4590
0
        cache_ptr->line_number = -1;
4591
0
        ret = false;
4592
0
        continue;
4593
0
      }
4594
4595
46.9k
    have_func = true;
4596
46.9k
    nbr_func++;
4597
46.9k
    cache_ptr->u.sym = (asymbol *) sym;
4598
46.9k
    if (sym->lineno != NULL)
4599
46.4k
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
46.4k
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
46.4k
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
46.9k
    sym->lineno = cache_ptr;
4605
46.9k
    if (sym->symbol.value < prev_offset)
4606
907
      ordered = false;
4607
46.9k
    prev_offset = sym->symbol.value;
4608
46.9k
  }
4609
161k
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
107k
  continue;
4613
53.7k
      else
4614
53.7k
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
100k
      cache_ptr++;
4616
100k
    }
4617
4618
74
  asect->lineno_count = cache_ptr - lineno_cache;
4619
74
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
74
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
74
  if (!ordered)
4624
57
    {
4625
      /* Sort the table.  */
4626
57
      alent **func_table;
4627
57
      alent *n_lineno_cache;
4628
4629
      /* Create a table of functions.  */
4630
57
      if (_bfd_mul_overflow (nbr_func, sizeof (alent *), &amt))
4631
0
  {
4632
0
    bfd_set_error (bfd_error_file_too_big);
4633
0
    ret = false;
4634
0
  }
4635
57
      else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL)
4636
57
  {
4637
57
    alent **p = func_table;
4638
57
    unsigned int i;
4639
4640
97.6k
    for (i = 0; i < asect->lineno_count; i++)
4641
97.6k
      if (lineno_cache[i].line_number == 0)
4642
45.3k
        *p++ = &lineno_cache[i];
4643
4644
57
    BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func);
4645
4646
    /* Sort by functions.  */
4647
57
    qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent);
4648
4649
    /* Create the new sorted table.  */
4650
57
    if (_bfd_mul_overflow (asect->lineno_count, sizeof (alent), &amt))
4651
0
      {
4652
0
        bfd_set_error (bfd_error_file_too_big);
4653
0
        ret = false;
4654
0
      }
4655
57
    else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL)
4656
57
      {
4657
57
        alent *n_cache_ptr = n_lineno_cache;
4658
4659
45.4k
        for (i = 0; i < nbr_func; i++)
4660
45.3k
    {
4661
45.3k
      coff_symbol_type *sym;
4662
45.3k
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
45.3k
      sym = (coff_symbol_type *) old_ptr->u.sym;
4666
      /* PR binutils/17512: Point the lineno to where
4667
         this entry will be after the memcpy below.  */
4668
45.3k
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
45.3k
      do
4671
97.6k
        *n_cache_ptr++ = *old_ptr++;
4672
97.6k
      while (old_ptr->line_number != 0);
4673
45.3k
    }
4674
4675
57
        memcpy (lineno_cache, n_lineno_cache,
4676
57
          asect->lineno_count * sizeof (alent));
4677
57
      }
4678
0
    else
4679
0
      ret = false;
4680
57
    bfd_release (abfd, func_table);
4681
57
  }
4682
0
      else
4683
0
  ret = false;
4684
57
    }
4685
4686
74
  return ret;
4687
74
}
pe-sh.c:coff_slurp_line_table
Line
Count
Source
4490
237
{
4491
237
  LINENO *native_lineno;
4492
237
  alent *lineno_cache;
4493
237
  unsigned int counter;
4494
237
  alent *cache_ptr;
4495
237
  bfd_vma prev_offset = 0;
4496
237
  bool ordered = true;
4497
237
  unsigned int nbr_func;
4498
237
  LINENO *src;
4499
237
  bool have_func;
4500
237
  bool ret = true;
4501
237
  size_t amt;
4502
4503
237
  if (asect->lineno_count == 0)
4504
100
    return true;
4505
4506
137
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
137
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
137
             asect->lineno_count,
4510
137
             bfd_coff_linesz (abfd));
4511
137
  if (native_lineno == NULL)
4512
45
    {
4513
45
      _bfd_error_handler
4514
45
  (_("%pB: warning: line number table read failed"), abfd);
4515
45
      return false;
4516
45
    }
4517
4518
92
  if (_bfd_mul_overflow (asect->lineno_count + 1, sizeof (alent), &amt))
4519
0
    {
4520
0
      bfd_set_error (bfd_error_file_too_big);
4521
0
      free (native_lineno);
4522
0
      return false;
4523
0
    }
4524
92
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
92
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
92
  cache_ptr = lineno_cache;
4532
92
  asect->lineno = lineno_cache;
4533
92
  src = native_lineno;
4534
92
  nbr_func = 0;
4535
92
  have_func = false;
4536
4537
103k
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
103k
    {
4539
103k
      struct internal_lineno dst;
4540
4541
103k
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
103k
      cache_ptr->line_number = dst.l_lnno;
4543
      /* Appease memory checkers that get all excited about
4544
   uninitialised memory when copying alents if u.offset is
4545
   larger than u.sym.  (64-bit BFD on 32-bit host.)  */
4546
103k
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
103k
      if (cache_ptr->line_number == 0)
4549
40.4k
  {
4550
40.4k
    combined_entry_type * ent;
4551
40.4k
    unsigned long symndx;
4552
40.4k
    coff_symbol_type *sym;
4553
4554
40.4k
    have_func = false;
4555
40.4k
    symndx = dst.l_addr.l_symndx;
4556
40.4k
    if (symndx >= obj_raw_syment_count (abfd))
4557
20.1k
      {
4558
20.1k
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
20.1k
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
20.1k
     abfd, symndx, counter);
4562
20.1k
        cache_ptr->line_number = -1;
4563
20.1k
        ret = false;
4564
20.1k
        continue;
4565
20.1k
      }
4566
4567
20.2k
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
20.2k
    if (! ent->is_sym)
4571
3.71k
      {
4572
3.71k
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
3.71k
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
3.71k
     abfd, symndx, counter);
4576
3.71k
        cache_ptr->line_number = -1;
4577
3.71k
        ret = false;
4578
3.71k
        continue;
4579
3.71k
      }
4580
16.5k
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
16.5k
    if (sym < obj_symbols (abfd)
4584
16.5k
        || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd))
4585
0
      {
4586
0
        _bfd_error_handler
4587
    /* xgettext:c-format */
4588
0
    (_("%pB: warning: illegal symbol in line number entry %d"),
4589
0
     abfd, counter);
4590
0
        cache_ptr->line_number = -1;
4591
0
        ret = false;
4592
0
        continue;
4593
0
      }
4594
4595
16.5k
    have_func = true;
4596
16.5k
    nbr_func++;
4597
16.5k
    cache_ptr->u.sym = (asymbol *) sym;
4598
16.5k
    if (sym->lineno != NULL)
4599
16.2k
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
16.2k
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
16.2k
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
16.5k
    sym->lineno = cache_ptr;
4605
16.5k
    if (sym->symbol.value < prev_offset)
4606
770
      ordered = false;
4607
16.5k
    prev_offset = sym->symbol.value;
4608
16.5k
  }
4609
62.9k
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
40.1k
  continue;
4613
22.7k
      else
4614
22.7k
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
39.3k
      cache_ptr++;
4616
39.3k
    }
4617
4618
92
  asect->lineno_count = cache_ptr - lineno_cache;
4619
92
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
92
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
92
  if (!ordered)
4624
38
    {
4625
      /* Sort the table.  */
4626
38
      alent **func_table;
4627
38
      alent *n_lineno_cache;
4628
4629
      /* Create a table of functions.  */
4630
38
      if (_bfd_mul_overflow (nbr_func, sizeof (alent *), &amt))
4631
0
  {
4632
0
    bfd_set_error (bfd_error_file_too_big);
4633
0
    ret = false;
4634
0
  }
4635
38
      else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL)
4636
38
  {
4637
38
    alent **p = func_table;
4638
38
    unsigned int i;
4639
4640
36.8k
    for (i = 0; i < asect->lineno_count; i++)
4641
36.8k
      if (lineno_cache[i].line_number == 0)
4642
15.6k
        *p++ = &lineno_cache[i];
4643
4644
38
    BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func);
4645
4646
    /* Sort by functions.  */
4647
38
    qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent);
4648
4649
    /* Create the new sorted table.  */
4650
38
    if (_bfd_mul_overflow (asect->lineno_count, sizeof (alent), &amt))
4651
0
      {
4652
0
        bfd_set_error (bfd_error_file_too_big);
4653
0
        ret = false;
4654
0
      }
4655
38
    else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL)
4656
38
      {
4657
38
        alent *n_cache_ptr = n_lineno_cache;
4658
4659
15.7k
        for (i = 0; i < nbr_func; i++)
4660
15.6k
    {
4661
15.6k
      coff_symbol_type *sym;
4662
15.6k
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
15.6k
      sym = (coff_symbol_type *) old_ptr->u.sym;
4666
      /* PR binutils/17512: Point the lineno to where
4667
         this entry will be after the memcpy below.  */
4668
15.6k
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
15.6k
      do
4671
36.8k
        *n_cache_ptr++ = *old_ptr++;
4672
36.8k
      while (old_ptr->line_number != 0);
4673
15.6k
    }
4674
4675
38
        memcpy (lineno_cache, n_lineno_cache,
4676
38
          asect->lineno_count * sizeof (alent));
4677
38
      }
4678
0
    else
4679
0
      ret = false;
4680
38
    bfd_release (abfd, func_table);
4681
38
  }
4682
0
      else
4683
0
  ret = false;
4684
38
    }
4685
4686
92
  return ret;
4687
92
}
pei-arm-wince.c:coff_slurp_line_table
Line
Count
Source
4490
118
{
4491
118
  LINENO *native_lineno;
4492
118
  alent *lineno_cache;
4493
118
  unsigned int counter;
4494
118
  alent *cache_ptr;
4495
118
  bfd_vma prev_offset = 0;
4496
118
  bool ordered = true;
4497
118
  unsigned int nbr_func;
4498
118
  LINENO *src;
4499
118
  bool have_func;
4500
118
  bool ret = true;
4501
118
  size_t amt;
4502
4503
118
  if (asect->lineno_count == 0)
4504
17
    return true;
4505
4506
101
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
101
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
101
             asect->lineno_count,
4510
101
             bfd_coff_linesz (abfd));
4511
101
  if (native_lineno == NULL)
4512
6
    {
4513
6
      _bfd_error_handler
4514
6
  (_("%pB: warning: line number table read failed"), abfd);
4515
6
      return false;
4516
6
    }
4517
4518
95
  if (_bfd_mul_overflow (asect->lineno_count + 1, sizeof (alent), &amt))
4519
0
    {
4520
0
      bfd_set_error (bfd_error_file_too_big);
4521
0
      free (native_lineno);
4522
0
      return false;
4523
0
    }
4524
95
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
95
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
95
  cache_ptr = lineno_cache;
4532
95
  asect->lineno = lineno_cache;
4533
95
  src = native_lineno;
4534
95
  nbr_func = 0;
4535
95
  have_func = false;
4536
4537
352k
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
351k
    {
4539
351k
      struct internal_lineno dst;
4540
4541
351k
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
351k
      cache_ptr->line_number = dst.l_lnno;
4543
      /* Appease memory checkers that get all excited about
4544
   uninitialised memory when copying alents if u.offset is
4545
   larger than u.sym.  (64-bit BFD on 32-bit host.)  */
4546
351k
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
351k
      if (cache_ptr->line_number == 0)
4549
162k
  {
4550
162k
    combined_entry_type * ent;
4551
162k
    unsigned long symndx;
4552
162k
    coff_symbol_type *sym;
4553
4554
162k
    have_func = false;
4555
162k
    symndx = dst.l_addr.l_symndx;
4556
162k
    if (symndx >= obj_raw_syment_count (abfd))
4557
79.3k
      {
4558
79.3k
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
79.3k
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
79.3k
     abfd, symndx, counter);
4562
79.3k
        cache_ptr->line_number = -1;
4563
79.3k
        ret = false;
4564
79.3k
        continue;
4565
79.3k
      }
4566
4567
82.7k
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
82.7k
    if (! ent->is_sym)
4571
13.6k
      {
4572
13.6k
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
13.6k
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
13.6k
     abfd, symndx, counter);
4576
13.6k
        cache_ptr->line_number = -1;
4577
13.6k
        ret = false;
4578
13.6k
        continue;
4579
13.6k
      }
4580
69.1k
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
69.1k
    if (sym < obj_symbols (abfd)
4584
69.1k
        || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd))
4585
0
      {
4586
0
        _bfd_error_handler
4587
    /* xgettext:c-format */
4588
0
    (_("%pB: warning: illegal symbol in line number entry %d"),
4589
0
     abfd, counter);
4590
0
        cache_ptr->line_number = -1;
4591
0
        ret = false;
4592
0
        continue;
4593
0
      }
4594
4595
69.1k
    have_func = true;
4596
69.1k
    nbr_func++;
4597
69.1k
    cache_ptr->u.sym = (asymbol *) sym;
4598
69.1k
    if (sym->lineno != NULL)
4599
67.9k
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
67.9k
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
67.9k
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
69.1k
    sym->lineno = cache_ptr;
4605
69.1k
    if (sym->symbol.value < prev_offset)
4606
1.97k
      ordered = false;
4607
69.1k
    prev_offset = sym->symbol.value;
4608
69.1k
  }
4609
189k
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
132k
  continue;
4613
57.5k
      else
4614
57.5k
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
126k
      cache_ptr++;
4616
126k
    }
4617
4618
95
  asect->lineno_count = cache_ptr - lineno_cache;
4619
95
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
95
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
95
  if (!ordered)
4624
81
    {
4625
      /* Sort the table.  */
4626
81
      alent **func_table;
4627
81
      alent *n_lineno_cache;
4628
4629
      /* Create a table of functions.  */
4630
81
      if (_bfd_mul_overflow (nbr_func, sizeof (alent *), &amt))
4631
0
  {
4632
0
    bfd_set_error (bfd_error_file_too_big);
4633
0
    ret = false;
4634
0
  }
4635
81
      else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL)
4636
81
  {
4637
81
    alent **p = func_table;
4638
81
    unsigned int i;
4639
4640
114k
    for (i = 0; i < asect->lineno_count; i++)
4641
114k
      if (lineno_cache[i].line_number == 0)
4642
58.1k
        *p++ = &lineno_cache[i];
4643
4644
81
    BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func);
4645
4646
    /* Sort by functions.  */
4647
81
    qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent);
4648
4649
    /* Create the new sorted table.  */
4650
81
    if (_bfd_mul_overflow (asect->lineno_count, sizeof (alent), &amt))
4651
0
      {
4652
0
        bfd_set_error (bfd_error_file_too_big);
4653
0
        ret = false;
4654
0
      }
4655
81
    else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL)
4656
81
      {
4657
81
        alent *n_cache_ptr = n_lineno_cache;
4658
4659
58.2k
        for (i = 0; i < nbr_func; i++)
4660
58.1k
    {
4661
58.1k
      coff_symbol_type *sym;
4662
58.1k
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
58.1k
      sym = (coff_symbol_type *) old_ptr->u.sym;
4666
      /* PR binutils/17512: Point the lineno to where
4667
         this entry will be after the memcpy below.  */
4668
58.1k
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
58.1k
      do
4671
114k
        *n_cache_ptr++ = *old_ptr++;
4672
114k
      while (old_ptr->line_number != 0);
4673
58.1k
    }
4674
4675
81
        memcpy (lineno_cache, n_lineno_cache,
4676
81
          asect->lineno_count * sizeof (alent));
4677
81
      }
4678
0
    else
4679
0
      ret = false;
4680
81
    bfd_release (abfd, func_table);
4681
81
  }
4682
0
      else
4683
0
  ret = false;
4684
81
    }
4685
4686
95
  return ret;
4687
95
}
pei-arm.c:coff_slurp_line_table
Line
Count
Source
4490
430
{
4491
430
  LINENO *native_lineno;
4492
430
  alent *lineno_cache;
4493
430
  unsigned int counter;
4494
430
  alent *cache_ptr;
4495
430
  bfd_vma prev_offset = 0;
4496
430
  bool ordered = true;
4497
430
  unsigned int nbr_func;
4498
430
  LINENO *src;
4499
430
  bool have_func;
4500
430
  bool ret = true;
4501
430
  size_t amt;
4502
4503
430
  if (asect->lineno_count == 0)
4504
266
    return true;
4505
4506
164
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
164
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
164
             asect->lineno_count,
4510
164
             bfd_coff_linesz (abfd));
4511
164
  if (native_lineno == NULL)
4512
54
    {
4513
54
      _bfd_error_handler
4514
54
  (_("%pB: warning: line number table read failed"), abfd);
4515
54
      return false;
4516
54
    }
4517
4518
110
  if (_bfd_mul_overflow (asect->lineno_count + 1, sizeof (alent), &amt))
4519
0
    {
4520
0
      bfd_set_error (bfd_error_file_too_big);
4521
0
      free (native_lineno);
4522
0
      return false;
4523
0
    }
4524
110
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
110
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
110
  cache_ptr = lineno_cache;
4532
110
  asect->lineno = lineno_cache;
4533
110
  src = native_lineno;
4534
110
  nbr_func = 0;
4535
110
  have_func = false;
4536
4537
249k
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
249k
    {
4539
249k
      struct internal_lineno dst;
4540
4541
249k
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
249k
      cache_ptr->line_number = dst.l_lnno;
4543
      /* Appease memory checkers that get all excited about
4544
   uninitialised memory when copying alents if u.offset is
4545
   larger than u.sym.  (64-bit BFD on 32-bit host.)  */
4546
249k
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
249k
      if (cache_ptr->line_number == 0)
4549
127k
  {
4550
127k
    combined_entry_type * ent;
4551
127k
    unsigned long symndx;
4552
127k
    coff_symbol_type *sym;
4553
4554
127k
    have_func = false;
4555
127k
    symndx = dst.l_addr.l_symndx;
4556
127k
    if (symndx >= obj_raw_syment_count (abfd))
4557
62.8k
      {
4558
62.8k
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
62.8k
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
62.8k
     abfd, symndx, counter);
4562
62.8k
        cache_ptr->line_number = -1;
4563
62.8k
        ret = false;
4564
62.8k
        continue;
4565
62.8k
      }
4566
4567
64.9k
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
64.9k
    if (! ent->is_sym)
4571
10.0k
      {
4572
10.0k
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
10.0k
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
10.0k
     abfd, symndx, counter);
4576
10.0k
        cache_ptr->line_number = -1;
4577
10.0k
        ret = false;
4578
10.0k
        continue;
4579
10.0k
      }
4580
54.8k
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
54.8k
    if (sym < obj_symbols (abfd)
4584
54.8k
        || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd))
4585
0
      {
4586
0
        _bfd_error_handler
4587
    /* xgettext:c-format */
4588
0
    (_("%pB: warning: illegal symbol in line number entry %d"),
4589
0
     abfd, counter);
4590
0
        cache_ptr->line_number = -1;
4591
0
        ret = false;
4592
0
        continue;
4593
0
      }
4594
4595
54.8k
    have_func = true;
4596
54.8k
    nbr_func++;
4597
54.8k
    cache_ptr->u.sym = (asymbol *) sym;
4598
54.8k
    if (sym->lineno != NULL)
4599
53.4k
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
53.4k
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
53.4k
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
54.8k
    sym->lineno = cache_ptr;
4605
54.8k
    if (sym->symbol.value < prev_offset)
4606
2.34k
      ordered = false;
4607
54.8k
    prev_offset = sym->symbol.value;
4608
54.8k
  }
4609
121k
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
82.3k
  continue;
4613
39.6k
      else
4614
39.6k
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
94.4k
      cache_ptr++;
4616
94.4k
    }
4617
4618
110
  asect->lineno_count = cache_ptr - lineno_cache;
4619
110
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
110
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
110
  if (!ordered)
4624
85
    {
4625
      /* Sort the table.  */
4626
85
      alent **func_table;
4627
85
      alent *n_lineno_cache;
4628
4629
      /* Create a table of functions.  */
4630
85
      if (_bfd_mul_overflow (nbr_func, sizeof (alent *), &amt))
4631
0
  {
4632
0
    bfd_set_error (bfd_error_file_too_big);
4633
0
    ret = false;
4634
0
  }
4635
85
      else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL)
4636
85
  {
4637
85
    alent **p = func_table;
4638
85
    unsigned int i;
4639
4640
91.5k
    for (i = 0; i < asect->lineno_count; i++)
4641
91.4k
      if (lineno_cache[i].line_number == 0)
4642
53.0k
        *p++ = &lineno_cache[i];
4643
4644
85
    BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func);
4645
4646
    /* Sort by functions.  */
4647
85
    qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent);
4648
4649
    /* Create the new sorted table.  */
4650
85
    if (_bfd_mul_overflow (asect->lineno_count, sizeof (alent), &amt))
4651
0
      {
4652
0
        bfd_set_error (bfd_error_file_too_big);
4653
0
        ret = false;
4654
0
      }
4655
85
    else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL)
4656
85
      {
4657
85
        alent *n_cache_ptr = n_lineno_cache;
4658
4659
53.1k
        for (i = 0; i < nbr_func; i++)
4660
53.0k
    {
4661
53.0k
      coff_symbol_type *sym;
4662
53.0k
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
53.0k
      sym = (coff_symbol_type *) old_ptr->u.sym;
4666
      /* PR binutils/17512: Point the lineno to where
4667
         this entry will be after the memcpy below.  */
4668
53.0k
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
53.0k
      do
4671
91.4k
        *n_cache_ptr++ = *old_ptr++;
4672
91.4k
      while (old_ptr->line_number != 0);
4673
53.0k
    }
4674
4675
85
        memcpy (lineno_cache, n_lineno_cache,
4676
85
          asect->lineno_count * sizeof (alent));
4677
85
      }
4678
0
    else
4679
0
      ret = false;
4680
85
    bfd_release (abfd, func_table);
4681
85
  }
4682
0
      else
4683
0
  ret = false;
4684
85
    }
4685
4686
110
  return ret;
4687
110
}
pei-mcore.c:coff_slurp_line_table
Line
Count
Source
4490
234
{
4491
234
  LINENO *native_lineno;
4492
234
  alent *lineno_cache;
4493
234
  unsigned int counter;
4494
234
  alent *cache_ptr;
4495
234
  bfd_vma prev_offset = 0;
4496
234
  bool ordered = true;
4497
234
  unsigned int nbr_func;
4498
234
  LINENO *src;
4499
234
  bool have_func;
4500
234
  bool ret = true;
4501
234
  size_t amt;
4502
4503
234
  if (asect->lineno_count == 0)
4504
130
    return true;
4505
4506
104
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
104
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
104
             asect->lineno_count,
4510
104
             bfd_coff_linesz (abfd));
4511
104
  if (native_lineno == NULL)
4512
32
    {
4513
32
      _bfd_error_handler
4514
32
  (_("%pB: warning: line number table read failed"), abfd);
4515
32
      return false;
4516
32
    }
4517
4518
72
  if (_bfd_mul_overflow (asect->lineno_count + 1, sizeof (alent), &amt))
4519
0
    {
4520
0
      bfd_set_error (bfd_error_file_too_big);
4521
0
      free (native_lineno);
4522
0
      return false;
4523
0
    }
4524
72
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
72
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
72
  cache_ptr = lineno_cache;
4532
72
  asect->lineno = lineno_cache;
4533
72
  src = native_lineno;
4534
72
  nbr_func = 0;
4535
72
  have_func = false;
4536
4537
86.0k
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
86.0k
    {
4539
86.0k
      struct internal_lineno dst;
4540
4541
86.0k
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
86.0k
      cache_ptr->line_number = dst.l_lnno;
4543
      /* Appease memory checkers that get all excited about
4544
   uninitialised memory when copying alents if u.offset is
4545
   larger than u.sym.  (64-bit BFD on 32-bit host.)  */
4546
86.0k
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
86.0k
      if (cache_ptr->line_number == 0)
4549
38.4k
  {
4550
38.4k
    combined_entry_type * ent;
4551
38.4k
    unsigned long symndx;
4552
38.4k
    coff_symbol_type *sym;
4553
4554
38.4k
    have_func = false;
4555
38.4k
    symndx = dst.l_addr.l_symndx;
4556
38.4k
    if (symndx >= obj_raw_syment_count (abfd))
4557
18.8k
      {
4558
18.8k
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
18.8k
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
18.8k
     abfd, symndx, counter);
4562
18.8k
        cache_ptr->line_number = -1;
4563
18.8k
        ret = false;
4564
18.8k
        continue;
4565
18.8k
      }
4566
4567
19.6k
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
19.6k
    if (! ent->is_sym)
4571
643
      {
4572
643
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
643
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
643
     abfd, symndx, counter);
4576
643
        cache_ptr->line_number = -1;
4577
643
        ret = false;
4578
643
        continue;
4579
643
      }
4580
19.0k
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
19.0k
    if (sym < obj_symbols (abfd)
4584
19.0k
        || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd))
4585
0
      {
4586
0
        _bfd_error_handler
4587
    /* xgettext:c-format */
4588
0
    (_("%pB: warning: illegal symbol in line number entry %d"),
4589
0
     abfd, counter);
4590
0
        cache_ptr->line_number = -1;
4591
0
        ret = false;
4592
0
        continue;
4593
0
      }
4594
4595
19.0k
    have_func = true;
4596
19.0k
    nbr_func++;
4597
19.0k
    cache_ptr->u.sym = (asymbol *) sym;
4598
19.0k
    if (sym->lineno != NULL)
4599
18.8k
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
18.8k
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
18.8k
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
19.0k
    sym->lineno = cache_ptr;
4605
19.0k
    if (sym->symbol.value < prev_offset)
4606
510
      ordered = false;
4607
19.0k
    prev_offset = sym->symbol.value;
4608
19.0k
  }
4609
47.5k
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
27.2k
  continue;
4613
20.2k
      else
4614
20.2k
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
39.3k
      cache_ptr++;
4616
39.3k
    }
4617
4618
72
  asect->lineno_count = cache_ptr - lineno_cache;
4619
72
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
72
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
72
  if (!ordered)
4624
47
    {
4625
      /* Sort the table.  */
4626
47
      alent **func_table;
4627
47
      alent *n_lineno_cache;
4628
4629
      /* Create a table of functions.  */
4630
47
      if (_bfd_mul_overflow (nbr_func, sizeof (alent *), &amt))
4631
0
  {
4632
0
    bfd_set_error (bfd_error_file_too_big);
4633
0
    ret = false;
4634
0
  }
4635
47
      else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL)
4636
47
  {
4637
47
    alent **p = func_table;
4638
47
    unsigned int i;
4639
4640
38.7k
    for (i = 0; i < asect->lineno_count; i++)
4641
38.6k
      if (lineno_cache[i].line_number == 0)
4642
18.5k
        *p++ = &lineno_cache[i];
4643
4644
47
    BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func);
4645
4646
    /* Sort by functions.  */
4647
47
    qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent);
4648
4649
    /* Create the new sorted table.  */
4650
47
    if (_bfd_mul_overflow (asect->lineno_count, sizeof (alent), &amt))
4651
0
      {
4652
0
        bfd_set_error (bfd_error_file_too_big);
4653
0
        ret = false;
4654
0
      }
4655
47
    else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL)
4656
47
      {
4657
47
        alent *n_cache_ptr = n_lineno_cache;
4658
4659
18.5k
        for (i = 0; i < nbr_func; i++)
4660
18.5k
    {
4661
18.5k
      coff_symbol_type *sym;
4662
18.5k
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
18.5k
      sym = (coff_symbol_type *) old_ptr->u.sym;
4666
      /* PR binutils/17512: Point the lineno to where
4667
         this entry will be after the memcpy below.  */
4668
18.5k
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
18.5k
      do
4671
38.6k
        *n_cache_ptr++ = *old_ptr++;
4672
38.6k
      while (old_ptr->line_number != 0);
4673
18.5k
    }
4674
4675
47
        memcpy (lineno_cache, n_lineno_cache,
4676
47
          asect->lineno_count * sizeof (alent));
4677
47
      }
4678
0
    else
4679
0
      ret = false;
4680
47
    bfd_release (abfd, func_table);
4681
47
  }
4682
0
      else
4683
0
  ret = false;
4684
47
    }
4685
4686
72
  return ret;
4687
72
}
pei-sh.c:coff_slurp_line_table
Line
Count
Source
4490
208
{
4491
208
  LINENO *native_lineno;
4492
208
  alent *lineno_cache;
4493
208
  unsigned int counter;
4494
208
  alent *cache_ptr;
4495
208
  bfd_vma prev_offset = 0;
4496
208
  bool ordered = true;
4497
208
  unsigned int nbr_func;
4498
208
  LINENO *src;
4499
208
  bool have_func;
4500
208
  bool ret = true;
4501
208
  size_t amt;
4502
4503
208
  if (asect->lineno_count == 0)
4504
87
    return true;
4505
4506
121
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
121
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
121
             asect->lineno_count,
4510
121
             bfd_coff_linesz (abfd));
4511
121
  if (native_lineno == NULL)
4512
32
    {
4513
32
      _bfd_error_handler
4514
32
  (_("%pB: warning: line number table read failed"), abfd);
4515
32
      return false;
4516
32
    }
4517
4518
89
  if (_bfd_mul_overflow (asect->lineno_count + 1, sizeof (alent), &amt))
4519
0
    {
4520
0
      bfd_set_error (bfd_error_file_too_big);
4521
0
      free (native_lineno);
4522
0
      return false;
4523
0
    }
4524
89
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
89
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
89
  cache_ptr = lineno_cache;
4532
89
  asect->lineno = lineno_cache;
4533
89
  src = native_lineno;
4534
89
  nbr_func = 0;
4535
89
  have_func = false;
4536
4537
89.0k
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
88.9k
    {
4539
88.9k
      struct internal_lineno dst;
4540
4541
88.9k
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
88.9k
      cache_ptr->line_number = dst.l_lnno;
4543
      /* Appease memory checkers that get all excited about
4544
   uninitialised memory when copying alents if u.offset is
4545
   larger than u.sym.  (64-bit BFD on 32-bit host.)  */
4546
88.9k
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
88.9k
      if (cache_ptr->line_number == 0)
4549
38.3k
  {
4550
38.3k
    combined_entry_type * ent;
4551
38.3k
    unsigned long symndx;
4552
38.3k
    coff_symbol_type *sym;
4553
4554
38.3k
    have_func = false;
4555
38.3k
    symndx = dst.l_addr.l_symndx;
4556
38.3k
    if (symndx >= obj_raw_syment_count (abfd))
4557
22.1k
      {
4558
22.1k
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
22.1k
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
22.1k
     abfd, symndx, counter);
4562
22.1k
        cache_ptr->line_number = -1;
4563
22.1k
        ret = false;
4564
22.1k
        continue;
4565
22.1k
      }
4566
4567
16.1k
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
16.1k
    if (! ent->is_sym)
4571
1.13k
      {
4572
1.13k
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
1.13k
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
1.13k
     abfd, symndx, counter);
4576
1.13k
        cache_ptr->line_number = -1;
4577
1.13k
        ret = false;
4578
1.13k
        continue;
4579
1.13k
      }
4580
15.0k
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
15.0k
    if (sym < obj_symbols (abfd)
4584
15.0k
        || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd))
4585
0
      {
4586
0
        _bfd_error_handler
4587
    /* xgettext:c-format */
4588
0
    (_("%pB: warning: illegal symbol in line number entry %d"),
4589
0
     abfd, counter);
4590
0
        cache_ptr->line_number = -1;
4591
0
        ret = false;
4592
0
        continue;
4593
0
      }
4594
4595
15.0k
    have_func = true;
4596
15.0k
    nbr_func++;
4597
15.0k
    cache_ptr->u.sym = (asymbol *) sym;
4598
15.0k
    if (sym->lineno != NULL)
4599
14.6k
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
14.6k
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
14.6k
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
15.0k
    sym->lineno = cache_ptr;
4605
15.0k
    if (sym->symbol.value < prev_offset)
4606
689
      ordered = false;
4607
15.0k
    prev_offset = sym->symbol.value;
4608
15.0k
  }
4609
50.6k
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
30.6k
  continue;
4613
19.9k
      else
4614
19.9k
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
35.0k
      cache_ptr++;
4616
35.0k
    }
4617
4618
89
  asect->lineno_count = cache_ptr - lineno_cache;
4619
89
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
89
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
89
  if (!ordered)
4624
64
    {
4625
      /* Sort the table.  */
4626
64
      alent **func_table;
4627
64
      alent *n_lineno_cache;
4628
4629
      /* Create a table of functions.  */
4630
64
      if (_bfd_mul_overflow (nbr_func, sizeof (alent *), &amt))
4631
0
  {
4632
0
    bfd_set_error (bfd_error_file_too_big);
4633
0
    ret = false;
4634
0
  }
4635
64
      else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL)
4636
64
  {
4637
64
    alent **p = func_table;
4638
64
    unsigned int i;
4639
4640
34.0k
    for (i = 0; i < asect->lineno_count; i++)
4641
33.9k
      if (lineno_cache[i].line_number == 0)
4642
14.6k
        *p++ = &lineno_cache[i];
4643
4644
64
    BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func);
4645
4646
    /* Sort by functions.  */
4647
64
    qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent);
4648
4649
    /* Create the new sorted table.  */
4650
64
    if (_bfd_mul_overflow (asect->lineno_count, sizeof (alent), &amt))
4651
0
      {
4652
0
        bfd_set_error (bfd_error_file_too_big);
4653
0
        ret = false;
4654
0
      }
4655
64
    else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL)
4656
64
      {
4657
64
        alent *n_cache_ptr = n_lineno_cache;
4658
4659
14.7k
        for (i = 0; i < nbr_func; i++)
4660
14.6k
    {
4661
14.6k
      coff_symbol_type *sym;
4662
14.6k
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
14.6k
      sym = (coff_symbol_type *) old_ptr->u.sym;
4666
      /* PR binutils/17512: Point the lineno to where
4667
         this entry will be after the memcpy below.  */
4668
14.6k
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
14.6k
      do
4671
33.9k
        *n_cache_ptr++ = *old_ptr++;
4672
33.9k
      while (old_ptr->line_number != 0);
4673
14.6k
    }
4674
4675
64
        memcpy (lineno_cache, n_lineno_cache,
4676
64
          asect->lineno_count * sizeof (alent));
4677
64
      }
4678
0
    else
4679
0
      ret = false;
4680
64
    bfd_release (abfd, func_table);
4681
64
  }
4682
0
      else
4683
0
  ret = false;
4684
64
    }
4685
4686
89
  return ret;
4687
89
}
4688
4689
/* Slurp in the symbol table, converting it to generic form.  Note
4690
   that if coff_relocate_section is defined, the linker will read
4691
   symbols via coff_link_add_symbols, rather than via this routine.  */
4692
4693
static bool
4694
coff_slurp_symbol_table (bfd * abfd)
4695
6.78k
{
4696
6.78k
  combined_entry_type *native_symbols;
4697
6.78k
  coff_symbol_type *cached_area;
4698
6.78k
  unsigned int *table_ptr;
4699
6.78k
  unsigned int number_of_symbols = 0;
4700
6.78k
  bool ret = true;
4701
6.78k
  size_t amt;
4702
4703
6.78k
  if (obj_symbols (abfd))
4704
387
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
6.39k
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
2.18k
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
4.21k
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
4.21k
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
4.21k
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
4.21k
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
4.21k
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
4.21k
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
4.21k
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
4.21k
  if (table_ptr == NULL)
4729
0
    return false;
4730
4.21k
  else
4731
4.21k
    {
4732
4.21k
      coff_symbol_type *dst = cached_area;
4733
4.21k
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
4.21k
      unsigned int this_index = 0;
4735
4736
1.23M
      while (this_index < last_native_index)
4737
1.22M
  {
4738
1.22M
    combined_entry_type *src = native_symbols + this_index;
4739
1.22M
    table_ptr[this_index] = number_of_symbols;
4740
4741
1.22M
    dst->symbol.the_bfd = abfd;
4742
1.22M
    BFD_ASSERT (src->is_sym);
4743
1.22M
    dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset);
4744
    /* We use the native name field to point to the cached field.  */
4745
1.22M
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
1.22M
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
1.22M
                 src->u.syment.n_scnum);
4748
1.22M
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
1.22M
    dst->symbol.value = 0;
4751
1.22M
    dst->done_lineno = false;
4752
4753
1.22M
    switch (src->u.syment.n_sclass)
4754
1.22M
      {
4755
24.7k
      case C_EXT:
4756
26.1k
      case C_WEAKEXT:
4757
#if defined ARM
4758
642
      case C_THUMBEXT:
4759
651
      case C_THUMBEXTFUNC:
4760
#endif
4761
#ifdef RS6000COFF_C
4762
6.39k
      case C_HIDEXT:
4763
6.39k
#ifndef AIX_WEAK_SUPPORT
4764
8.35k
      case C_AIX_WEAKEXT:
4765
#endif
4766
#endif
4767
8.35k
#ifdef C_SYSTEM
4768
30.9k
      case C_SYSTEM: /* System Wide variable.  */
4769
30.9k
#endif
4770
#ifdef COFF_WITH_PE
4771
      /* In PE, 0x68 (104) denotes a section symbol.  */
4772
15.2k
      case C_SECTION:
4773
      /* In PE, 0x69 (105) denotes a weak external symbol.  */
4774
23.7k
      case C_NT_WEAK:
4775
#endif
4776
23.7k
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
23.7k
    {
4778
33.0k
    case COFF_SYMBOL_GLOBAL:
4779
33.0k
      dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
4780
#if defined COFF_WITH_PE
4781
      /* PE sets the symbol to a value relative to the
4782
         start of the section.  */
4783
      dst->symbol.value = src->u.syment.n_value;
4784
#else
4785
      dst->symbol.value = (src->u.syment.n_value
4786
               - dst->symbol.section->vma);
4787
#endif
4788
33.0k
      if (ISFCN ((src->u.syment.n_type)))
4789
        /* A function ext does not go at the end of a
4790
           file.  */
4791
858
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4792
33.0k
      break;
4793
4794
5.13k
    case COFF_SYMBOL_COMMON:
4795
5.13k
      dst->symbol.section = bfd_com_section_ptr;
4796
5.13k
      dst->symbol.value = src->u.syment.n_value;
4797
5.13k
      break;
4798
4799
1.09k
    case COFF_SYMBOL_UNDEFINED:
4800
1.09k
      dst->symbol.section = bfd_und_section_ptr;
4801
1.09k
      dst->symbol.value = 0;
4802
1.09k
      break;
4803
4804
0
    case COFF_SYMBOL_PE_SECTION:
4805
0
      dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM;
4806
0
      dst->symbol.value = 0;
4807
0
      break;
4808
4809
285
    case COFF_SYMBOL_LOCAL:
4810
285
      dst->symbol.flags = BSF_LOCAL;
4811
#if defined COFF_WITH_PE
4812
      /* PE sets the symbol to a value relative to the
4813
         start of the section.  */
4814
      dst->symbol.value = src->u.syment.n_value;
4815
#else
4816
      dst->symbol.value = (src->u.syment.n_value
4817
               - dst->symbol.section->vma);
4818
#endif
4819
285
      if (ISFCN ((src->u.syment.n_type)))
4820
12
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4821
285
      break;
4822
23.7k
    }
4823
4824
#ifdef RS6000COFF_C
4825
        /* A symbol with a csect entry should not go at the end.  */
4826
8.63k
        if (src->u.syment.n_numaux > 0)
4827
4.57k
    dst->symbol.flags |= BSF_NOT_AT_END;
4828
#endif
4829
4830
#ifdef COFF_WITH_PE
4831
23.7k
        if (src->u.syment.n_sclass == C_NT_WEAK)
4832
8.52k
    dst->symbol.flags |= BSF_WEAK;
4833
4834
23.7k
        if (src->u.syment.n_sclass == C_SECTION
4835
23.7k
      && src->u.syment.n_scnum > 0)
4836
0
    dst->symbol.flags = BSF_LOCAL;
4837
#endif
4838
39.6k
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
#ifdef RS6000COFF_C
4840
8.31k
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
#endif
4842
7.22k
      )
4843
3.32k
    dst->symbol.flags |= BSF_WEAK;
4844
4845
7.22k
        break;
4846
4847
12.8k
      case C_STAT:  /* Static.  */
4848
#if defined ARM
4849
1.03k
      case C_THUMBSTAT:    /* Thumb static.  */
4850
1.04k
      case C_THUMBLABEL:   /* Thumb label.  */
4851
1.06k
      case C_THUMBSTATFUNC:/* Thumb static function.  */
4852
#endif
4853
#ifdef RS6000COFF_C
4854
4.65k
      case C_DWARF:  /* A label in a dwarf section.  */
4855
7.54k
      case C_INFO:  /* A label in a comment section.  */
4856
#endif
4857
27.9k
      case C_LABEL:  /* Label.  */
4858
27.9k
        if (src->u.syment.n_scnum == N_DEBUG)
4859
3
    dst->symbol.flags = BSF_DEBUGGING;
4860
27.9k
        else
4861
27.9k
    dst->symbol.flags = BSF_LOCAL;
4862
4863
        /* Base the value as an index from the base of the
4864
     section, if there is one.  */
4865
27.9k
        if (dst->symbol.section)
4866
27.9k
    {
4867
#if defined COFF_WITH_PE
4868
      /* PE sets the symbol to a value relative to the
4869
         start of the section.  */
4870
      dst->symbol.value = src->u.syment.n_value;
4871
#else
4872
      dst->symbol.value = (src->u.syment.n_value
4873
               - dst->symbol.section->vma);
4874
#endif
4875
27.9k
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
27.9k
        break;
4879
4880
8.04k
      case C_FILE: /* File name.  */
4881
8.04k
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
12.3k
      case C_MOS:   /* Member of structure.  */
4884
17.5k
      case C_EOS:   /* End of structure.  */
4885
20.2k
      case C_REGPARM: /* Register parameter.  */
4886
27.6k
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
31.4k
      case C_TPDEF: /* Type definition.  */
4889
35.6k
      case C_ARG:
4890
95.1k
      case C_AUTO: /* Automatic variable.  */
4891
98.3k
      case C_FIELD: /* Bit field.  */
4892
101k
      case C_ENTAG: /* Enumeration tag.  */
4893
108k
      case C_MOE:   /* Member of enumeration.  */
4894
111k
      case C_MOU:   /* Member of union.  */
4895
115k
      case C_UNTAG: /* Union tag.  */
4896
120k
      case C_STRTAG: /* Structure tag.  */
4897
#ifdef RS6000COFF_C
4898
28.9k
      case C_GSYM:
4899
29.0k
      case C_LSYM:
4900
29.1k
      case C_PSYM:
4901
29.3k
      case C_RSYM:
4902
29.4k
      case C_RPSYM:
4903
29.6k
      case C_STSYM:
4904
29.8k
      case C_TCSYM:
4905
29.9k
      case C_BCOMM:
4906
30.1k
      case C_ECOML:
4907
30.4k
      case C_ECOMM:
4908
30.6k
      case C_DECL:
4909
30.6k
      case C_ENTRY:
4910
30.7k
      case C_FUN:
4911
31.4k
      case C_ESTAT:
4912
#endif
4913
124k
        dst->symbol.flags |= BSF_DEBUGGING;
4914
31.4k
        dst->symbol.value = (src->u.syment.n_value);
4915
31.4k
        break;
4916
4917
#ifdef RS6000COFF_C
4918
2.15k
      case C_BINCL: /* Beginning of include file.  */
4919
3.52k
      case C_EINCL: /* Ending of include file.  */
4920
        /* The value is actually a pointer into the line numbers
4921
     of the file.  We locate the line number entry, and
4922
     set the section to the section which contains it, and
4923
     the value to the index in that section.  */
4924
3.52k
        {
4925
3.52k
    asection *sec;
4926
4927
3.52k
    dst->symbol.flags = BSF_DEBUGGING;
4928
1.77M
    for (sec = abfd->sections; sec != NULL; sec = sec->next)
4929
1.77M
      if (sec->line_filepos <= (file_ptr) src->u.syment.n_value
4930
1.77M
          && ((file_ptr) (sec->line_filepos
4931
1.53M
              + sec->lineno_count * bfd_coff_linesz (abfd))
4932
1.53M
        > (file_ptr) src->u.syment.n_value))
4933
1.74k
        break;
4934
3.52k
    if (sec == NULL)
4935
1.78k
      dst->symbol.value = 0;
4936
1.74k
    else
4937
1.74k
      {
4938
1.74k
        dst->symbol.section = sec;
4939
1.74k
        dst->symbol.value = ((src->u.syment.n_value
4940
1.74k
            - sec->line_filepos)
4941
1.74k
           / bfd_coff_linesz (abfd));
4942
1.74k
        src->fix_line = 1;
4943
1.74k
      }
4944
3.52k
        }
4945
3.52k
        break;
4946
4947
63
      case C_BSTAT:
4948
63
        dst->symbol.flags = BSF_DEBUGGING;
4949
4950
63
        if (src->u.syment.n_value >= obj_raw_syment_count (abfd))
4951
47
    dst->symbol.value = 0;
4952
16
        else
4953
16
    {
4954
      /* The value is actually a symbol index.  Save a pointer
4955
         to the symbol instead of the index.  FIXME: This
4956
         should use a union.  */
4957
16
      src->u.syment.n_value
4958
16
        = (uintptr_t) (native_symbols + src->u.syment.n_value);
4959
16
      dst->symbol.value = src->u.syment.n_value;
4960
16
      src->fix_value = 1;
4961
16
    }
4962
63
        break;
4963
0
#endif
4964
4965
3.14k
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
23.5k
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
28.1k
      case C_EFCN: /* Physical end of function.  */
4968
#if defined COFF_WITH_PE
4969
        /* PE sets the symbol to a value relative to the start
4970
     of the section.  */
4971
        dst->symbol.value = src->u.syment.n_value;
4972
15.9k
        if (strcmp (dst->symbol.name, ".bf") != 0)
4973
15.9k
    {
4974
      /* PE uses funny values for .ef and .lf; don't
4975
         relocate them.  */
4976
15.9k
      dst->symbol.flags = BSF_DEBUGGING;
4977
15.9k
    }
4978
3
        else
4979
3
    dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC;
4980
#else
4981
        /* Base the value as an index from the base of the
4982
     section.  */
4983
12.1k
        dst->symbol.flags = BSF_LOCAL;
4984
        dst->symbol.value = (src->u.syment.n_value
4985
           - dst->symbol.section->vma);
4986
#endif
4987
28.1k
        break;
4988
4989
2.28k
      case C_STATLAB: /* Static load time label.  */
4990
2.28k
        dst->symbol.value = src->u.syment.n_value;
4991
2.28k
        dst->symbol.flags = BSF_GLOBAL;
4992
2.28k
        break;
4993
4994
753k
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
753k
        if (src->u.syment.n_type == 0
4998
753k
      && src->u.syment.n_value == 0
4999
753k
      && src->u.syment.n_scnum == 0)
5000
149k
    break;
5001
#ifdef RS6000COFF_C
5002
        /* XCOFF specific: deleted entry.  */
5003
146k
        if (src->u.syment.n_value == C_NULL_VALUE)
5004
1
    break;
5005
146k
#endif
5006
        /* Fall through.  */
5007
604k
      case C_EXTDEF: /* External definition.  */
5008
605k
      case C_ULABEL: /* Undefined label.  */
5009
606k
      case C_USTATIC: /* Undefined static.  */
5010
#ifndef COFF_WITH_PE
5011
      /* C_LINE in regular coff is 0x68.  NT has taken over this storage
5012
         class to represent a section symbol.  */
5013
299k
      case C_LINE: /* line # reformatted as symbol table entry.  */
5014
        /* NT uses 0x67 for a weak symbol, not C_ALIAS.  */
5015
304k
      case C_ALIAS: /* Duplicate tag.  */
5016
304k
#endif
5017
        /* New storage classes for TI COFF.  */
5018
#ifdef TICOFF
5019
38.1k
      case C_UEXT: /* Tentative external definition.  */
5020
#endif
5021
616k
      case C_EXTLAB: /* External load time label.  */
5022
853k
      default:
5023
853k
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
853k
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
853k
     abfd, src->u.syment.n_sclass,
5027
853k
     dst->symbol.section->name, dst->symbol.name);
5028
853k
        ret = false;
5029
        /* Fall through.  */
5030
854k
      case C_HIDDEN: /* Ext symbol in dmert public lib.  */
5031
        /* PR 20722: These symbols can also be generated by
5032
     building DLLs with --gc-sections enabled.  */
5033
854k
        dst->symbol.flags = BSF_DEBUGGING;
5034
854k
        dst->symbol.value = (src->u.syment.n_value);
5035
854k
        break;
5036
1.22M
      }
5037
5038
1.22M
    dst->native = src;
5039
1.22M
    dst->symbol.udata.i = 0;
5040
1.22M
    dst->lineno = NULL;
5041
5042
1.22M
    this_index += (src->u.syment.n_numaux) + 1;
5043
1.22M
    dst++;
5044
1.22M
    number_of_symbols++;
5045
1.22M
  }
5046
4.21k
    }
5047
5048
4.21k
  obj_symbols (abfd) = cached_area;
5049
4.21k
  obj_raw_syments (abfd) = native_symbols;
5050
5051
4.21k
  abfd->symcount = number_of_symbols;
5052
4.21k
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
4.21k
  {
5055
4.21k
    asection *p;
5056
5057
4.21k
    p = abfd->sections;
5058
12.4k
    while (p)
5059
11.7k
      {
5060
11.7k
  if (! coff_slurp_line_table (abfd, p))
5061
3.51k
    return false;
5062
8.26k
  p = p->next;
5063
8.26k
      }
5064
4.21k
  }
5065
5066
695
  return ret;
5067
4.21k
}
pei-i386.c:coff_slurp_symbol_table
Line
Count
Source
4695
185
{
4696
185
  combined_entry_type *native_symbols;
4697
185
  coff_symbol_type *cached_area;
4698
185
  unsigned int *table_ptr;
4699
185
  unsigned int number_of_symbols = 0;
4700
185
  bool ret = true;
4701
185
  size_t amt;
4702
4703
185
  if (obj_symbols (abfd))
4704
13
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
172
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
57
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
115
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
115
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
115
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
115
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
115
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
115
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
115
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
115
  if (table_ptr == NULL)
4729
0
    return false;
4730
115
  else
4731
115
    {
4732
115
      coff_symbol_type *dst = cached_area;
4733
115
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
115
      unsigned int this_index = 0;
4735
4736
30.7k
      while (this_index < last_native_index)
4737
30.5k
  {
4738
30.5k
    combined_entry_type *src = native_symbols + this_index;
4739
30.5k
    table_ptr[this_index] = number_of_symbols;
4740
4741
30.5k
    dst->symbol.the_bfd = abfd;
4742
30.5k
    BFD_ASSERT (src->is_sym);
4743
30.5k
    dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset);
4744
    /* We use the native name field to point to the cached field.  */
4745
30.5k
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
30.5k
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
30.5k
                 src->u.syment.n_scnum);
4748
30.5k
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
30.5k
    dst->symbol.value = 0;
4751
30.5k
    dst->done_lineno = false;
4752
4753
30.5k
    switch (src->u.syment.n_sclass)
4754
30.5k
      {
4755
579
      case C_EXT:
4756
675
      case C_WEAKEXT:
4757
#if defined ARM
4758
      case C_THUMBEXT:
4759
      case C_THUMBEXTFUNC:
4760
#endif
4761
#ifdef RS6000COFF_C
4762
      case C_HIDEXT:
4763
#ifndef AIX_WEAK_SUPPORT
4764
      case C_AIX_WEAKEXT:
4765
#endif
4766
#endif
4767
675
#ifdef C_SYSTEM
4768
696
      case C_SYSTEM: /* System Wide variable.  */
4769
696
#endif
4770
696
#ifdef COFF_WITH_PE
4771
      /* In PE, 0x68 (104) denotes a section symbol.  */
4772
698
      case C_SECTION:
4773
      /* In PE, 0x69 (105) denotes a weak external symbol.  */
4774
986
      case C_NT_WEAK:
4775
986
#endif
4776
986
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
986
    {
4778
915
    case COFF_SYMBOL_GLOBAL:
4779
915
      dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
4780
915
#if defined COFF_WITH_PE
4781
      /* PE sets the symbol to a value relative to the
4782
         start of the section.  */
4783
915
      dst->symbol.value = src->u.syment.n_value;
4784
#else
4785
      dst->symbol.value = (src->u.syment.n_value
4786
               - dst->symbol.section->vma);
4787
#endif
4788
915
      if (ISFCN ((src->u.syment.n_type)))
4789
        /* A function ext does not go at the end of a
4790
           file.  */
4791
20
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4792
915
      break;
4793
4794
45
    case COFF_SYMBOL_COMMON:
4795
45
      dst->symbol.section = bfd_com_section_ptr;
4796
45
      dst->symbol.value = src->u.syment.n_value;
4797
45
      break;
4798
4799
26
    case COFF_SYMBOL_UNDEFINED:
4800
26
      dst->symbol.section = bfd_und_section_ptr;
4801
26
      dst->symbol.value = 0;
4802
26
      break;
4803
4804
0
    case COFF_SYMBOL_PE_SECTION:
4805
0
      dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM;
4806
0
      dst->symbol.value = 0;
4807
0
      break;
4808
4809
0
    case COFF_SYMBOL_LOCAL:
4810
0
      dst->symbol.flags = BSF_LOCAL;
4811
0
#if defined COFF_WITH_PE
4812
      /* PE sets the symbol to a value relative to the
4813
         start of the section.  */
4814
0
      dst->symbol.value = src->u.syment.n_value;
4815
#else
4816
      dst->symbol.value = (src->u.syment.n_value
4817
               - dst->symbol.section->vma);
4818
#endif
4819
0
      if (ISFCN ((src->u.syment.n_type)))
4820
0
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4821
0
      break;
4822
986
    }
4823
4824
#ifdef RS6000COFF_C
4825
        /* A symbol with a csect entry should not go at the end.  */
4826
        if (src->u.syment.n_numaux > 0)
4827
    dst->symbol.flags |= BSF_NOT_AT_END;
4828
#endif
4829
4830
986
#ifdef COFF_WITH_PE
4831
986
        if (src->u.syment.n_sclass == C_NT_WEAK)
4832
288
    dst->symbol.flags |= BSF_WEAK;
4833
4834
986
        if (src->u.syment.n_sclass == C_SECTION
4835
986
      && src->u.syment.n_scnum > 0)
4836
0
    dst->symbol.flags = BSF_LOCAL;
4837
986
#endif
4838
986
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
#ifdef RS6000COFF_C
4840
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
#endif
4842
986
      )
4843
96
    dst->symbol.flags |= BSF_WEAK;
4844
4845
986
        break;
4846
4847
769
      case C_STAT:  /* Static.  */
4848
#if defined ARM
4849
      case C_THUMBSTAT:    /* Thumb static.  */
4850
      case C_THUMBLABEL:   /* Thumb label.  */
4851
      case C_THUMBSTATFUNC:/* Thumb static function.  */
4852
#endif
4853
#ifdef RS6000COFF_C
4854
      case C_DWARF:  /* A label in a dwarf section.  */
4855
      case C_INFO:   /* A label in a comment section.  */
4856
#endif
4857
792
      case C_LABEL:  /* Label.  */
4858
792
        if (src->u.syment.n_scnum == N_DEBUG)
4859
0
    dst->symbol.flags = BSF_DEBUGGING;
4860
792
        else
4861
792
    dst->symbol.flags = BSF_LOCAL;
4862
4863
        /* Base the value as an index from the base of the
4864
     section, if there is one.  */
4865
792
        if (dst->symbol.section)
4866
792
    {
4867
792
#if defined COFF_WITH_PE
4868
      /* PE sets the symbol to a value relative to the
4869
         start of the section.  */
4870
792
      dst->symbol.value = src->u.syment.n_value;
4871
#else
4872
      dst->symbol.value = (src->u.syment.n_value
4873
               - dst->symbol.section->vma);
4874
#endif
4875
792
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
792
        break;
4879
4880
140
      case C_FILE: /* File name.  */
4881
140
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
262
      case C_MOS:   /* Member of structure.  */
4884
316
      case C_EOS:   /* End of structure.  */
4885
431
      case C_REGPARM: /* Register parameter.  */
4886
534
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
649
      case C_TPDEF: /* Type definition.  */
4889
775
      case C_ARG:
4890
1.59k
      case C_AUTO: /* Automatic variable.  */
4891
1.77k
      case C_FIELD: /* Bit field.  */
4892
1.80k
      case C_ENTAG: /* Enumeration tag.  */
4893
1.93k
      case C_MOE:   /* Member of enumeration.  */
4894
2.01k
      case C_MOU:   /* Member of union.  */
4895
2.09k
      case C_UNTAG: /* Union tag.  */
4896
2.18k
      case C_STRTAG: /* Structure tag.  */
4897
#ifdef RS6000COFF_C
4898
      case C_GSYM:
4899
      case C_LSYM:
4900
      case C_PSYM:
4901
      case C_RSYM:
4902
      case C_RPSYM:
4903
      case C_STSYM:
4904
      case C_TCSYM:
4905
      case C_BCOMM:
4906
      case C_ECOML:
4907
      case C_ECOMM:
4908
      case C_DECL:
4909
      case C_ENTRY:
4910
      case C_FUN:
4911
      case C_ESTAT:
4912
#endif
4913
2.18k
        dst->symbol.flags |= BSF_DEBUGGING;
4914
2.18k
        dst->symbol.value = (src->u.syment.n_value);
4915
2.18k
        break;
4916
4917
#ifdef RS6000COFF_C
4918
      case C_BINCL: /* Beginning of include file.  */
4919
      case C_EINCL: /* Ending of include file.  */
4920
        /* The value is actually a pointer into the line numbers
4921
     of the file.  We locate the line number entry, and
4922
     set the section to the section which contains it, and
4923
     the value to the index in that section.  */
4924
        {
4925
    asection *sec;
4926
4927
    dst->symbol.flags = BSF_DEBUGGING;
4928
    for (sec = abfd->sections; sec != NULL; sec = sec->next)
4929
      if (sec->line_filepos <= (file_ptr) src->u.syment.n_value
4930
          && ((file_ptr) (sec->line_filepos
4931
              + sec->lineno_count * bfd_coff_linesz (abfd))
4932
        > (file_ptr) src->u.syment.n_value))
4933
        break;
4934
    if (sec == NULL)
4935
      dst->symbol.value = 0;
4936
    else
4937
      {
4938
        dst->symbol.section = sec;
4939
        dst->symbol.value = ((src->u.syment.n_value
4940
            - sec->line_filepos)
4941
           / bfd_coff_linesz (abfd));
4942
        src->fix_line = 1;
4943
      }
4944
        }
4945
        break;
4946
4947
      case C_BSTAT:
4948
        dst->symbol.flags = BSF_DEBUGGING;
4949
4950
        if (src->u.syment.n_value >= obj_raw_syment_count (abfd))
4951
    dst->symbol.value = 0;
4952
        else
4953
    {
4954
      /* The value is actually a symbol index.  Save a pointer
4955
         to the symbol instead of the index.  FIXME: This
4956
         should use a union.  */
4957
      src->u.syment.n_value
4958
        = (uintptr_t) (native_symbols + src->u.syment.n_value);
4959
      dst->symbol.value = src->u.syment.n_value;
4960
      src->fix_value = 1;
4961
    }
4962
        break;
4963
#endif
4964
4965
94
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
590
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
684
      case C_EFCN: /* Physical end of function.  */
4968
684
#if defined COFF_WITH_PE
4969
        /* PE sets the symbol to a value relative to the start
4970
     of the section.  */
4971
684
        dst->symbol.value = src->u.syment.n_value;
4972
684
        if (strcmp (dst->symbol.name, ".bf") != 0)
4973
684
    {
4974
      /* PE uses funny values for .ef and .lf; don't
4975
         relocate them.  */
4976
684
      dst->symbol.flags = BSF_DEBUGGING;
4977
684
    }
4978
0
        else
4979
0
    dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC;
4980
#else
4981
        /* Base the value as an index from the base of the
4982
     section.  */
4983
        dst->symbol.flags = BSF_LOCAL;
4984
        dst->symbol.value = (src->u.syment.n_value
4985
           - dst->symbol.section->vma);
4986
#endif
4987
684
        break;
4988
4989
105
      case C_STATLAB: /* Static load time label.  */
4990
105
        dst->symbol.value = src->u.syment.n_value;
4991
105
        dst->symbol.flags = BSF_GLOBAL;
4992
105
        break;
4993
4994
20.2k
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
20.2k
        if (src->u.syment.n_type == 0
4998
20.2k
      && src->u.syment.n_value == 0
4999
20.2k
      && src->u.syment.n_scnum == 0)
5000
8.93k
    break;
5001
#ifdef RS6000COFF_C
5002
        /* XCOFF specific: deleted entry.  */
5003
        if (src->u.syment.n_value == C_NULL_VALUE)
5004
    break;
5005
#endif
5006
        /* Fall through.  */
5007
11.3k
      case C_EXTDEF: /* External definition.  */
5008
11.3k
      case C_ULABEL: /* Undefined label.  */
5009
11.3k
      case C_USTATIC: /* Undefined static.  */
5010
#ifndef COFF_WITH_PE
5011
      /* C_LINE in regular coff is 0x68.  NT has taken over this storage
5012
         class to represent a section symbol.  */
5013
      case C_LINE:  /* line # reformatted as symbol table entry.  */
5014
        /* NT uses 0x67 for a weak symbol, not C_ALIAS.  */
5015
      case C_ALIAS: /* Duplicate tag.  */
5016
#endif
5017
        /* New storage classes for TI COFF.  */
5018
#ifdef TICOFF
5019
      case C_UEXT:  /* Tentative external definition.  */
5020
#endif
5021
11.3k
      case C_EXTLAB: /* External load time label.  */
5022
16.8k
      default:
5023
16.8k
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
16.8k
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
16.8k
     abfd, src->u.syment.n_sclass,
5027
16.8k
     dst->symbol.section->name, dst->symbol.name);
5028
16.8k
        ret = false;
5029
        /* Fall through.  */
5030
16.9k
      case C_HIDDEN: /* Ext symbol in dmert public lib.  */
5031
        /* PR 20722: These symbols can also be generated by
5032
     building DLLs with --gc-sections enabled.  */
5033
16.9k
        dst->symbol.flags = BSF_DEBUGGING;
5034
16.9k
        dst->symbol.value = (src->u.syment.n_value);
5035
16.9k
        break;
5036
30.5k
      }
5037
5038
30.5k
    dst->native = src;
5039
30.5k
    dst->symbol.udata.i = 0;
5040
30.5k
    dst->lineno = NULL;
5041
5042
30.5k
    this_index += (src->u.syment.n_numaux) + 1;
5043
30.5k
    dst++;
5044
30.5k
    number_of_symbols++;
5045
30.5k
  }
5046
115
    }
5047
5048
115
  obj_symbols (abfd) = cached_area;
5049
115
  obj_raw_syments (abfd) = native_symbols;
5050
5051
115
  abfd->symcount = number_of_symbols;
5052
115
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
115
  {
5055
115
    asection *p;
5056
5057
115
    p = abfd->sections;
5058
216
    while (p)
5059
208
      {
5060
208
  if (! coff_slurp_line_table (abfd, p))
5061
107
    return false;
5062
101
  p = p->next;
5063
101
      }
5064
115
  }
5065
5066
8
  return ret;
5067
115
}
pe-x86_64.c:coff_slurp_symbol_table
Line
Count
Source
4695
372
{
4696
372
  combined_entry_type *native_symbols;
4697
372
  coff_symbol_type *cached_area;
4698
372
  unsigned int *table_ptr;
4699
372
  unsigned int number_of_symbols = 0;
4700
372
  bool ret = true;
4701
372
  size_t amt;
4702
4703
372
  if (obj_symbols (abfd))
4704
19
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
353
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
127
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
226
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
226
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
226
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
226
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
226
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
226
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
226
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
226
  if (table_ptr == NULL)
4729
0
    return false;
4730
226
  else
4731
226
    {
4732
226
      coff_symbol_type *dst = cached_area;
4733
226
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
226
      unsigned int this_index = 0;
4735
4736
33.4k
      while (this_index < last_native_index)
4737
33.2k
  {
4738
33.2k
    combined_entry_type *src = native_symbols + this_index;
4739
33.2k
    table_ptr[this_index] = number_of_symbols;
4740
4741
33.2k
    dst->symbol.the_bfd = abfd;
4742
33.2k
    BFD_ASSERT (src->is_sym);
4743
33.2k
    dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset);
4744
    /* We use the native name field to point to the cached field.  */
4745
33.2k
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
33.2k
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
33.2k
                 src->u.syment.n_scnum);
4748
33.2k
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
33.2k
    dst->symbol.value = 0;
4751
33.2k
    dst->done_lineno = false;
4752
4753
33.2k
    switch (src->u.syment.n_sclass)
4754
33.2k
      {
4755
1.22k
      case C_EXT:
4756
1.26k
      case C_WEAKEXT:
4757
#if defined ARM
4758
      case C_THUMBEXT:
4759
      case C_THUMBEXTFUNC:
4760
#endif
4761
#ifdef RS6000COFF_C
4762
      case C_HIDEXT:
4763
#ifndef AIX_WEAK_SUPPORT
4764
      case C_AIX_WEAKEXT:
4765
#endif
4766
#endif
4767
1.26k
#ifdef C_SYSTEM
4768
1.42k
      case C_SYSTEM: /* System Wide variable.  */
4769
1.42k
#endif
4770
1.42k
#ifdef COFF_WITH_PE
4771
      /* In PE, 0x68 (104) denotes a section symbol.  */
4772
1.43k
      case C_SECTION:
4773
      /* In PE, 0x69 (105) denotes a weak external symbol.  */
4774
1.67k
      case C_NT_WEAK:
4775
1.67k
#endif
4776
1.67k
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
1.67k
    {
4778
1.44k
    case COFF_SYMBOL_GLOBAL:
4779
1.44k
      dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
4780
1.44k
#if defined COFF_WITH_PE
4781
      /* PE sets the symbol to a value relative to the
4782
         start of the section.  */
4783
1.44k
      dst->symbol.value = src->u.syment.n_value;
4784
#else
4785
      dst->symbol.value = (src->u.syment.n_value
4786
               - dst->symbol.section->vma);
4787
#endif
4788
1.44k
      if (ISFCN ((src->u.syment.n_type)))
4789
        /* A function ext does not go at the end of a
4790
           file.  */
4791
22
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4792
1.44k
      break;
4793
4794
141
    case COFF_SYMBOL_COMMON:
4795
141
      dst->symbol.section = bfd_com_section_ptr;
4796
141
      dst->symbol.value = src->u.syment.n_value;
4797
141
      break;
4798
4799
88
    case COFF_SYMBOL_UNDEFINED:
4800
88
      dst->symbol.section = bfd_und_section_ptr;
4801
88
      dst->symbol.value = 0;
4802
88
      break;
4803
4804
0
    case COFF_SYMBOL_PE_SECTION:
4805
0
      dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM;
4806
0
      dst->symbol.value = 0;
4807
0
      break;
4808
4809
0
    case COFF_SYMBOL_LOCAL:
4810
0
      dst->symbol.flags = BSF_LOCAL;
4811
0
#if defined COFF_WITH_PE
4812
      /* PE sets the symbol to a value relative to the
4813
         start of the section.  */
4814
0
      dst->symbol.value = src->u.syment.n_value;
4815
#else
4816
      dst->symbol.value = (src->u.syment.n_value
4817
               - dst->symbol.section->vma);
4818
#endif
4819
0
      if (ISFCN ((src->u.syment.n_type)))
4820
0
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4821
0
      break;
4822
1.67k
    }
4823
4824
#ifdef RS6000COFF_C
4825
        /* A symbol with a csect entry should not go at the end.  */
4826
        if (src->u.syment.n_numaux > 0)
4827
    dst->symbol.flags |= BSF_NOT_AT_END;
4828
#endif
4829
4830
1.67k
#ifdef COFF_WITH_PE
4831
1.67k
        if (src->u.syment.n_sclass == C_NT_WEAK)
4832
235
    dst->symbol.flags |= BSF_WEAK;
4833
4834
1.67k
        if (src->u.syment.n_sclass == C_SECTION
4835
1.67k
      && src->u.syment.n_scnum > 0)
4836
0
    dst->symbol.flags = BSF_LOCAL;
4837
1.67k
#endif
4838
1.67k
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
#ifdef RS6000COFF_C
4840
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
#endif
4842
1.67k
      )
4843
39
    dst->symbol.flags |= BSF_WEAK;
4844
4845
1.67k
        break;
4846
4847
323
      case C_STAT:  /* Static.  */
4848
#if defined ARM
4849
      case C_THUMBSTAT:    /* Thumb static.  */
4850
      case C_THUMBLABEL:   /* Thumb label.  */
4851
      case C_THUMBSTATFUNC:/* Thumb static function.  */
4852
#endif
4853
#ifdef RS6000COFF_C
4854
      case C_DWARF:  /* A label in a dwarf section.  */
4855
      case C_INFO:   /* A label in a comment section.  */
4856
#endif
4857
605
      case C_LABEL:  /* Label.  */
4858
605
        if (src->u.syment.n_scnum == N_DEBUG)
4859
0
    dst->symbol.flags = BSF_DEBUGGING;
4860
605
        else
4861
605
    dst->symbol.flags = BSF_LOCAL;
4862
4863
        /* Base the value as an index from the base of the
4864
     section, if there is one.  */
4865
605
        if (dst->symbol.section)
4866
605
    {
4867
605
#if defined COFF_WITH_PE
4868
      /* PE sets the symbol to a value relative to the
4869
         start of the section.  */
4870
605
      dst->symbol.value = src->u.syment.n_value;
4871
#else
4872
      dst->symbol.value = (src->u.syment.n_value
4873
               - dst->symbol.section->vma);
4874
#endif
4875
605
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
605
        break;
4879
4880
143
      case C_FILE: /* File name.  */
4881
143
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
289
      case C_MOS:   /* Member of structure.  */
4884
365
      case C_EOS:   /* End of structure.  */
4885
462
      case C_REGPARM: /* Register parameter.  */
4886
1.01k
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
1.28k
      case C_TPDEF: /* Type definition.  */
4889
1.60k
      case C_ARG:
4890
3.81k
      case C_AUTO: /* Automatic variable.  */
4891
4.02k
      case C_FIELD: /* Bit field.  */
4892
4.15k
      case C_ENTAG: /* Enumeration tag.  */
4893
4.52k
      case C_MOE:   /* Member of enumeration.  */
4894
4.59k
      case C_MOU:   /* Member of union.  */
4895
4.72k
      case C_UNTAG: /* Union tag.  */
4896
4.90k
      case C_STRTAG: /* Structure tag.  */
4897
#ifdef RS6000COFF_C
4898
      case C_GSYM:
4899
      case C_LSYM:
4900
      case C_PSYM:
4901
      case C_RSYM:
4902
      case C_RPSYM:
4903
      case C_STSYM:
4904
      case C_TCSYM:
4905
      case C_BCOMM:
4906
      case C_ECOML:
4907
      case C_ECOMM:
4908
      case C_DECL:
4909
      case C_ENTRY:
4910
      case C_FUN:
4911
      case C_ESTAT:
4912
#endif
4913
4.90k
        dst->symbol.flags |= BSF_DEBUGGING;
4914
4.90k
        dst->symbol.value = (src->u.syment.n_value);
4915
4.90k
        break;
4916
4917
#ifdef RS6000COFF_C
4918
      case C_BINCL: /* Beginning of include file.  */
4919
      case C_EINCL: /* Ending of include file.  */
4920
        /* The value is actually a pointer into the line numbers
4921
     of the file.  We locate the line number entry, and
4922
     set the section to the section which contains it, and
4923
     the value to the index in that section.  */
4924
        {
4925
    asection *sec;
4926
4927
    dst->symbol.flags = BSF_DEBUGGING;
4928
    for (sec = abfd->sections; sec != NULL; sec = sec->next)
4929
      if (sec->line_filepos <= (file_ptr) src->u.syment.n_value
4930
          && ((file_ptr) (sec->line_filepos
4931
              + sec->lineno_count * bfd_coff_linesz (abfd))
4932
        > (file_ptr) src->u.syment.n_value))
4933
        break;
4934
    if (sec == NULL)
4935
      dst->symbol.value = 0;
4936
    else
4937
      {
4938
        dst->symbol.section = sec;
4939
        dst->symbol.value = ((src->u.syment.n_value
4940
            - sec->line_filepos)
4941
           / bfd_coff_linesz (abfd));
4942
        src->fix_line = 1;
4943
      }
4944
        }
4945
        break;
4946
4947
      case C_BSTAT:
4948
        dst->symbol.flags = BSF_DEBUGGING;
4949
4950
        if (src->u.syment.n_value >= obj_raw_syment_count (abfd))
4951
    dst->symbol.value = 0;
4952
        else
4953
    {
4954
      /* The value is actually a symbol index.  Save a pointer
4955
         to the symbol instead of the index.  FIXME: This
4956
         should use a union.  */
4957
      src->u.syment.n_value
4958
        = (uintptr_t) (native_symbols + src->u.syment.n_value);
4959
      dst->symbol.value = src->u.syment.n_value;
4960
      src->fix_value = 1;
4961
    }
4962
        break;
4963
#endif
4964
4965
71
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
338
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
505
      case C_EFCN: /* Physical end of function.  */
4968
505
#if defined COFF_WITH_PE
4969
        /* PE sets the symbol to a value relative to the start
4970
     of the section.  */
4971
505
        dst->symbol.value = src->u.syment.n_value;
4972
505
        if (strcmp (dst->symbol.name, ".bf") != 0)
4973
505
    {
4974
      /* PE uses funny values for .ef and .lf; don't
4975
         relocate them.  */
4976
505
      dst->symbol.flags = BSF_DEBUGGING;
4977
505
    }
4978
0
        else
4979
0
    dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC;
4980
#else
4981
        /* Base the value as an index from the base of the
4982
     section.  */
4983
        dst->symbol.flags = BSF_LOCAL;
4984
        dst->symbol.value = (src->u.syment.n_value
4985
           - dst->symbol.section->vma);
4986
#endif
4987
505
        break;
4988
4989
104
      case C_STATLAB: /* Static load time label.  */
4990
104
        dst->symbol.value = src->u.syment.n_value;
4991
104
        dst->symbol.flags = BSF_GLOBAL;
4992
104
        break;
4993
4994
19.3k
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
19.3k
        if (src->u.syment.n_type == 0
4998
19.3k
      && src->u.syment.n_value == 0
4999
19.3k
      && src->u.syment.n_scnum == 0)
5000
3.29k
    break;
5001
#ifdef RS6000COFF_C
5002
        /* XCOFF specific: deleted entry.  */
5003
        if (src->u.syment.n_value == C_NULL_VALUE)
5004
    break;
5005
#endif
5006
        /* Fall through.  */
5007
16.0k
      case C_EXTDEF: /* External definition.  */
5008
16.0k
      case C_ULABEL: /* Undefined label.  */
5009
16.1k
      case C_USTATIC: /* Undefined static.  */
5010
#ifndef COFF_WITH_PE
5011
      /* C_LINE in regular coff is 0x68.  NT has taken over this storage
5012
         class to represent a section symbol.  */
5013
      case C_LINE:  /* line # reformatted as symbol table entry.  */
5014
        /* NT uses 0x67 for a weak symbol, not C_ALIAS.  */
5015
      case C_ALIAS: /* Duplicate tag.  */
5016
#endif
5017
        /* New storage classes for TI COFF.  */
5018
#ifdef TICOFF
5019
      case C_UEXT:  /* Tentative external definition.  */
5020
#endif
5021
16.1k
      case C_EXTLAB: /* External load time label.  */
5022
22.1k
      default:
5023
22.1k
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
22.1k
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
22.1k
     abfd, src->u.syment.n_sclass,
5027
22.1k
     dst->symbol.section->name, dst->symbol.name);
5028
22.1k
        ret = false;
5029
        /* Fall through.  */
5030
22.1k
      case C_HIDDEN: /* Ext symbol in dmert public lib.  */
5031
        /* PR 20722: These symbols can also be generated by
5032
     building DLLs with --gc-sections enabled.  */
5033
22.1k
        dst->symbol.flags = BSF_DEBUGGING;
5034
22.1k
        dst->symbol.value = (src->u.syment.n_value);
5035
22.1k
        break;
5036
33.2k
      }
5037
5038
33.2k
    dst->native = src;
5039
33.2k
    dst->symbol.udata.i = 0;
5040
33.2k
    dst->lineno = NULL;
5041
5042
33.2k
    this_index += (src->u.syment.n_numaux) + 1;
5043
33.2k
    dst++;
5044
33.2k
    number_of_symbols++;
5045
33.2k
  }
5046
226
    }
5047
5048
226
  obj_symbols (abfd) = cached_area;
5049
226
  obj_raw_syments (abfd) = native_symbols;
5050
5051
226
  abfd->symcount = number_of_symbols;
5052
226
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
226
  {
5055
226
    asection *p;
5056
5057
226
    p = abfd->sections;
5058
683
    while (p)
5059
629
      {
5060
629
  if (! coff_slurp_line_table (abfd, p))
5061
172
    return false;
5062
457
  p = p->next;
5063
457
      }
5064
226
  }
5065
5066
54
  return ret;
5067
226
}
pei-x86_64.c:coff_slurp_symbol_table
Line
Count
Source
4695
221
{
4696
221
  combined_entry_type *native_symbols;
4697
221
  coff_symbol_type *cached_area;
4698
221
  unsigned int *table_ptr;
4699
221
  unsigned int number_of_symbols = 0;
4700
221
  bool ret = true;
4701
221
  size_t amt;
4702
4703
221
  if (obj_symbols (abfd))
4704
18
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
203
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
85
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
118
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
118
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
118
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
118
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
118
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
118
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
118
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
118
  if (table_ptr == NULL)
4729
0
    return false;
4730
118
  else
4731
118
    {
4732
118
      coff_symbol_type *dst = cached_area;
4733
118
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
118
      unsigned int this_index = 0;
4735
4736
29.8k
      while (this_index < last_native_index)
4737
29.7k
  {
4738
29.7k
    combined_entry_type *src = native_symbols + this_index;
4739
29.7k
    table_ptr[this_index] = number_of_symbols;
4740
4741
29.7k
    dst->symbol.the_bfd = abfd;
4742
29.7k
    BFD_ASSERT (src->is_sym);
4743
29.7k
    dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset);
4744
    /* We use the native name field to point to the cached field.  */
4745
29.7k
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
29.7k
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
29.7k
                 src->u.syment.n_scnum);
4748
29.7k
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
29.7k
    dst->symbol.value = 0;
4751
29.7k
    dst->done_lineno = false;
4752
4753
29.7k
    switch (src->u.syment.n_sclass)
4754
29.7k
      {
4755
425
      case C_EXT:
4756
434
      case C_WEAKEXT:
4757
#if defined ARM
4758
      case C_THUMBEXT:
4759
      case C_THUMBEXTFUNC:
4760
#endif
4761
#ifdef RS6000COFF_C
4762
      case C_HIDEXT:
4763
#ifndef AIX_WEAK_SUPPORT
4764
      case C_AIX_WEAKEXT:
4765
#endif
4766
#endif
4767
434
#ifdef C_SYSTEM
4768
454
      case C_SYSTEM: /* System Wide variable.  */
4769
454
#endif
4770
454
#ifdef COFF_WITH_PE
4771
      /* In PE, 0x68 (104) denotes a section symbol.  */
4772
457
      case C_SECTION:
4773
      /* In PE, 0x69 (105) denotes a weak external symbol.  */
4774
956
      case C_NT_WEAK:
4775
956
#endif
4776
956
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
956
    {
4778
861
    case COFF_SYMBOL_GLOBAL:
4779
861
      dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
4780
861
#if defined COFF_WITH_PE
4781
      /* PE sets the symbol to a value relative to the
4782
         start of the section.  */
4783
861
      dst->symbol.value = src->u.syment.n_value;
4784
#else
4785
      dst->symbol.value = (src->u.syment.n_value
4786
               - dst->symbol.section->vma);
4787
#endif
4788
861
      if (ISFCN ((src->u.syment.n_type)))
4789
        /* A function ext does not go at the end of a
4790
           file.  */
4791
27
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4792
861
      break;
4793
4794
73
    case COFF_SYMBOL_COMMON:
4795
73
      dst->symbol.section = bfd_com_section_ptr;
4796
73
      dst->symbol.value = src->u.syment.n_value;
4797
73
      break;
4798
4799
22
    case COFF_SYMBOL_UNDEFINED:
4800
22
      dst->symbol.section = bfd_und_section_ptr;
4801
22
      dst->symbol.value = 0;
4802
22
      break;
4803
4804
0
    case COFF_SYMBOL_PE_SECTION:
4805
0
      dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM;
4806
0
      dst->symbol.value = 0;
4807
0
      break;
4808
4809
0
    case COFF_SYMBOL_LOCAL:
4810
0
      dst->symbol.flags = BSF_LOCAL;
4811
0
#if defined COFF_WITH_PE
4812
      /* PE sets the symbol to a value relative to the
4813
         start of the section.  */
4814
0
      dst->symbol.value = src->u.syment.n_value;
4815
#else
4816
      dst->symbol.value = (src->u.syment.n_value
4817
               - dst->symbol.section->vma);
4818
#endif
4819
0
      if (ISFCN ((src->u.syment.n_type)))
4820
0
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4821
0
      break;
4822
956
    }
4823
4824
#ifdef RS6000COFF_C
4825
        /* A symbol with a csect entry should not go at the end.  */
4826
        if (src->u.syment.n_numaux > 0)
4827
    dst->symbol.flags |= BSF_NOT_AT_END;
4828
#endif
4829
4830
956
#ifdef COFF_WITH_PE
4831
956
        if (src->u.syment.n_sclass == C_NT_WEAK)
4832
499
    dst->symbol.flags |= BSF_WEAK;
4833
4834
956
        if (src->u.syment.n_sclass == C_SECTION
4835
956
      && src->u.syment.n_scnum > 0)
4836
0
    dst->symbol.flags = BSF_LOCAL;
4837
956
#endif
4838
956
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
#ifdef RS6000COFF_C
4840
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
#endif
4842
956
      )
4843
9
    dst->symbol.flags |= BSF_WEAK;
4844
4845
956
        break;
4846
4847
404
      case C_STAT:  /* Static.  */
4848
#if defined ARM
4849
      case C_THUMBSTAT:    /* Thumb static.  */
4850
      case C_THUMBLABEL:   /* Thumb label.  */
4851
      case C_THUMBSTATFUNC:/* Thumb static function.  */
4852
#endif
4853
#ifdef RS6000COFF_C
4854
      case C_DWARF:  /* A label in a dwarf section.  */
4855
      case C_INFO:   /* A label in a comment section.  */
4856
#endif
4857
469
      case C_LABEL:  /* Label.  */
4858
469
        if (src->u.syment.n_scnum == N_DEBUG)
4859
0
    dst->symbol.flags = BSF_DEBUGGING;
4860
469
        else
4861
469
    dst->symbol.flags = BSF_LOCAL;
4862
4863
        /* Base the value as an index from the base of the
4864
     section, if there is one.  */
4865
469
        if (dst->symbol.section)
4866
469
    {
4867
469
#if defined COFF_WITH_PE
4868
      /* PE sets the symbol to a value relative to the
4869
         start of the section.  */
4870
469
      dst->symbol.value = src->u.syment.n_value;
4871
#else
4872
      dst->symbol.value = (src->u.syment.n_value
4873
               - dst->symbol.section->vma);
4874
#endif
4875
469
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
469
        break;
4879
4880
196
      case C_FILE: /* File name.  */
4881
196
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
266
      case C_MOS:   /* Member of structure.  */
4884
400
      case C_EOS:   /* End of structure.  */
4885
461
      case C_REGPARM: /* Register parameter.  */
4886
526
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
611
      case C_TPDEF: /* Type definition.  */
4889
644
      case C_ARG:
4890
1.32k
      case C_AUTO: /* Automatic variable.  */
4891
1.36k
      case C_FIELD: /* Bit field.  */
4892
1.39k
      case C_ENTAG: /* Enumeration tag.  */
4893
1.47k
      case C_MOE:   /* Member of enumeration.  */
4894
1.48k
      case C_MOU:   /* Member of union.  */
4895
1.51k
      case C_UNTAG: /* Union tag.  */
4896
1.58k
      case C_STRTAG: /* Structure tag.  */
4897
#ifdef RS6000COFF_C
4898
      case C_GSYM:
4899
      case C_LSYM:
4900
      case C_PSYM:
4901
      case C_RSYM:
4902
      case C_RPSYM:
4903
      case C_STSYM:
4904
      case C_TCSYM:
4905
      case C_BCOMM:
4906
      case C_ECOML:
4907
      case C_ECOMM:
4908
      case C_DECL:
4909
      case C_ENTRY:
4910
      case C_FUN:
4911
      case C_ESTAT:
4912
#endif
4913
1.58k
        dst->symbol.flags |= BSF_DEBUGGING;
4914
1.58k
        dst->symbol.value = (src->u.syment.n_value);
4915
1.58k
        break;
4916
4917
#ifdef RS6000COFF_C
4918
      case C_BINCL: /* Beginning of include file.  */
4919
      case C_EINCL: /* Ending of include file.  */
4920
        /* The value is actually a pointer into the line numbers
4921
     of the file.  We locate the line number entry, and
4922
     set the section to the section which contains it, and
4923
     the value to the index in that section.  */
4924
        {
4925
    asection *sec;
4926
4927
    dst->symbol.flags = BSF_DEBUGGING;
4928
    for (sec = abfd->sections; sec != NULL; sec = sec->next)
4929
      if (sec->line_filepos <= (file_ptr) src->u.syment.n_value
4930
          && ((file_ptr) (sec->line_filepos
4931
              + sec->lineno_count * bfd_coff_linesz (abfd))
4932
        > (file_ptr) src->u.syment.n_value))
4933
        break;
4934
    if (sec == NULL)
4935
      dst->symbol.value = 0;
4936
    else
4937
      {
4938
        dst->symbol.section = sec;
4939
        dst->symbol.value = ((src->u.syment.n_value
4940
            - sec->line_filepos)
4941
           / bfd_coff_linesz (abfd));
4942
        src->fix_line = 1;
4943
      }
4944
        }
4945
        break;
4946
4947
      case C_BSTAT:
4948
        dst->symbol.flags = BSF_DEBUGGING;
4949
4950
        if (src->u.syment.n_value >= obj_raw_syment_count (abfd))
4951
    dst->symbol.value = 0;
4952
        else
4953
    {
4954
      /* The value is actually a symbol index.  Save a pointer
4955
         to the symbol instead of the index.  FIXME: This
4956
         should use a union.  */
4957
      src->u.syment.n_value
4958
        = (uintptr_t) (native_symbols + src->u.syment.n_value);
4959
      dst->symbol.value = src->u.syment.n_value;
4960
      src->fix_value = 1;
4961
    }
4962
        break;
4963
#endif
4964
4965
90
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
836
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
936
      case C_EFCN: /* Physical end of function.  */
4968
936
#if defined COFF_WITH_PE
4969
        /* PE sets the symbol to a value relative to the start
4970
     of the section.  */
4971
936
        dst->symbol.value = src->u.syment.n_value;
4972
936
        if (strcmp (dst->symbol.name, ".bf") != 0)
4973
936
    {
4974
      /* PE uses funny values for .ef and .lf; don't
4975
         relocate them.  */
4976
936
      dst->symbol.flags = BSF_DEBUGGING;
4977
936
    }
4978
0
        else
4979
0
    dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC;
4980
#else
4981
        /* Base the value as an index from the base of the
4982
     section.  */
4983
        dst->symbol.flags = BSF_LOCAL;
4984
        dst->symbol.value = (src->u.syment.n_value
4985
           - dst->symbol.section->vma);
4986
#endif
4987
936
        break;
4988
4989
50
      case C_STATLAB: /* Static load time label.  */
4990
50
        dst->symbol.value = src->u.syment.n_value;
4991
50
        dst->symbol.flags = BSF_GLOBAL;
4992
50
        break;
4993
4994
18.6k
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
18.6k
        if (src->u.syment.n_type == 0
4998
18.6k
      && src->u.syment.n_value == 0
4999
18.6k
      && src->u.syment.n_scnum == 0)
5000
5.21k
    break;
5001
#ifdef RS6000COFF_C
5002
        /* XCOFF specific: deleted entry.  */
5003
        if (src->u.syment.n_value == C_NULL_VALUE)
5004
    break;
5005
#endif
5006
        /* Fall through.  */
5007
13.4k
      case C_EXTDEF: /* External definition.  */
5008
13.4k
      case C_ULABEL: /* Undefined label.  */
5009
13.4k
      case C_USTATIC: /* Undefined static.  */
5010
#ifndef COFF_WITH_PE
5011
      /* C_LINE in regular coff is 0x68.  NT has taken over this storage
5012
         class to represent a section symbol.  */
5013
      case C_LINE:  /* line # reformatted as symbol table entry.  */
5014
        /* NT uses 0x67 for a weak symbol, not C_ALIAS.  */
5015
      case C_ALIAS: /* Duplicate tag.  */
5016
#endif
5017
        /* New storage classes for TI COFF.  */
5018
#ifdef TICOFF
5019
      case C_UEXT:  /* Tentative external definition.  */
5020
#endif
5021
13.4k
      case C_EXTLAB: /* External load time label.  */
5022
20.5k
      default:
5023
20.5k
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
20.5k
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
20.5k
     abfd, src->u.syment.n_sclass,
5027
20.5k
     dst->symbol.section->name, dst->symbol.name);
5028
20.5k
        ret = false;
5029
        /* Fall through.  */
5030
20.5k
      case C_HIDDEN: /* Ext symbol in dmert public lib.  */
5031
        /* PR 20722: These symbols can also be generated by
5032
     building DLLs with --gc-sections enabled.  */
5033
20.5k
        dst->symbol.flags = BSF_DEBUGGING;
5034
20.5k
        dst->symbol.value = (src->u.syment.n_value);
5035
20.5k
        break;
5036
29.7k
      }
5037
5038
29.7k
    dst->native = src;
5039
29.7k
    dst->symbol.udata.i = 0;
5040
29.7k
    dst->lineno = NULL;
5041
5042
29.7k
    this_index += (src->u.syment.n_numaux) + 1;
5043
29.7k
    dst++;
5044
29.7k
    number_of_symbols++;
5045
29.7k
  }
5046
118
    }
5047
5048
118
  obj_symbols (abfd) = cached_area;
5049
118
  obj_raw_syments (abfd) = native_symbols;
5050
5051
118
  abfd->symcount = number_of_symbols;
5052
118
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
118
  {
5055
118
    asection *p;
5056
5057
118
    p = abfd->sections;
5058
161
    while (p)
5059
153
      {
5060
153
  if (! coff_slurp_line_table (abfd, p))
5061
110
    return false;
5062
43
  p = p->next;
5063
43
      }
5064
118
  }
5065
5066
8
  return ret;
5067
118
}
coff-x86_64.c:coff_slurp_symbol_table
Line
Count
Source
4695
526
{
4696
526
  combined_entry_type *native_symbols;
4697
526
  coff_symbol_type *cached_area;
4698
526
  unsigned int *table_ptr;
4699
526
  unsigned int number_of_symbols = 0;
4700
526
  bool ret = true;
4701
526
  size_t amt;
4702
4703
526
  if (obj_symbols (abfd))
4704
27
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
499
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
228
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
271
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
271
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
271
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
271
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
271
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
271
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
271
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
271
  if (table_ptr == NULL)
4729
0
    return false;
4730
271
  else
4731
271
    {
4732
271
      coff_symbol_type *dst = cached_area;
4733
271
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
271
      unsigned int this_index = 0;
4735
4736
24.8k
      while (this_index < last_native_index)
4737
24.5k
  {
4738
24.5k
    combined_entry_type *src = native_symbols + this_index;
4739
24.5k
    table_ptr[this_index] = number_of_symbols;
4740
4741
24.5k
    dst->symbol.the_bfd = abfd;
4742
24.5k
    BFD_ASSERT (src->is_sym);
4743
24.5k
    dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset);
4744
    /* We use the native name field to point to the cached field.  */
4745
24.5k
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
24.5k
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
24.5k
                 src->u.syment.n_scnum);
4748
24.5k
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
24.5k
    dst->symbol.value = 0;
4751
24.5k
    dst->done_lineno = false;
4752
4753
24.5k
    switch (src->u.syment.n_sclass)
4754
24.5k
      {
4755
766
      case C_EXT:
4756
784
      case C_WEAKEXT:
4757
#if defined ARM
4758
      case C_THUMBEXT:
4759
      case C_THUMBEXTFUNC:
4760
#endif
4761
#ifdef RS6000COFF_C
4762
      case C_HIDEXT:
4763
#ifndef AIX_WEAK_SUPPORT
4764
      case C_AIX_WEAKEXT:
4765
#endif
4766
#endif
4767
784
#ifdef C_SYSTEM
4768
862
      case C_SYSTEM: /* System Wide variable.  */
4769
862
#endif
4770
#ifdef COFF_WITH_PE
4771
      /* In PE, 0x68 (104) denotes a section symbol.  */
4772
      case C_SECTION:
4773
      /* In PE, 0x69 (105) denotes a weak external symbol.  */
4774
      case C_NT_WEAK:
4775
#endif
4776
862
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
862
    {
4778
650
    case COFF_SYMBOL_GLOBAL:
4779
650
      dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
4780
#if defined COFF_WITH_PE
4781
      /* PE sets the symbol to a value relative to the
4782
         start of the section.  */
4783
      dst->symbol.value = src->u.syment.n_value;
4784
#else
4785
650
      dst->symbol.value = (src->u.syment.n_value
4786
650
               - dst->symbol.section->vma);
4787
650
#endif
4788
650
      if (ISFCN ((src->u.syment.n_type)))
4789
        /* A function ext does not go at the end of a
4790
           file.  */
4791
2
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4792
650
      break;
4793
4794
201
    case COFF_SYMBOL_COMMON:
4795
201
      dst->symbol.section = bfd_com_section_ptr;
4796
201
      dst->symbol.value = src->u.syment.n_value;
4797
201
      break;
4798
4799
11
    case COFF_SYMBOL_UNDEFINED:
4800
11
      dst->symbol.section = bfd_und_section_ptr;
4801
11
      dst->symbol.value = 0;
4802
11
      break;
4803
4804
0
    case COFF_SYMBOL_PE_SECTION:
4805
0
      dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM;
4806
0
      dst->symbol.value = 0;
4807
0
      break;
4808
4809
0
    case COFF_SYMBOL_LOCAL:
4810
0
      dst->symbol.flags = BSF_LOCAL;
4811
#if defined COFF_WITH_PE
4812
      /* PE sets the symbol to a value relative to the
4813
         start of the section.  */
4814
      dst->symbol.value = src->u.syment.n_value;
4815
#else
4816
0
      dst->symbol.value = (src->u.syment.n_value
4817
0
               - dst->symbol.section->vma);
4818
0
#endif
4819
0
      if (ISFCN ((src->u.syment.n_type)))
4820
0
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4821
0
      break;
4822
862
    }
4823
4824
#ifdef RS6000COFF_C
4825
        /* A symbol with a csect entry should not go at the end.  */
4826
        if (src->u.syment.n_numaux > 0)
4827
    dst->symbol.flags |= BSF_NOT_AT_END;
4828
#endif
4829
4830
#ifdef COFF_WITH_PE
4831
        if (src->u.syment.n_sclass == C_NT_WEAK)
4832
    dst->symbol.flags |= BSF_WEAK;
4833
4834
        if (src->u.syment.n_sclass == C_SECTION
4835
      && src->u.syment.n_scnum > 0)
4836
    dst->symbol.flags = BSF_LOCAL;
4837
#endif
4838
862
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
#ifdef RS6000COFF_C
4840
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
#endif
4842
862
      )
4843
18
    dst->symbol.flags |= BSF_WEAK;
4844
4845
862
        break;
4846
4847
82
      case C_STAT:  /* Static.  */
4848
#if defined ARM
4849
      case C_THUMBSTAT:    /* Thumb static.  */
4850
      case C_THUMBLABEL:   /* Thumb label.  */
4851
      case C_THUMBSTATFUNC:/* Thumb static function.  */
4852
#endif
4853
#ifdef RS6000COFF_C
4854
      case C_DWARF:  /* A label in a dwarf section.  */
4855
      case C_INFO:   /* A label in a comment section.  */
4856
#endif
4857
593
      case C_LABEL:  /* Label.  */
4858
593
        if (src->u.syment.n_scnum == N_DEBUG)
4859
0
    dst->symbol.flags = BSF_DEBUGGING;
4860
593
        else
4861
593
    dst->symbol.flags = BSF_LOCAL;
4862
4863
        /* Base the value as an index from the base of the
4864
     section, if there is one.  */
4865
593
        if (dst->symbol.section)
4866
593
    {
4867
#if defined COFF_WITH_PE
4868
      /* PE sets the symbol to a value relative to the
4869
         start of the section.  */
4870
      dst->symbol.value = src->u.syment.n_value;
4871
#else
4872
593
      dst->symbol.value = (src->u.syment.n_value
4873
593
               - dst->symbol.section->vma);
4874
593
#endif
4875
593
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
593
        break;
4879
4880
161
      case C_FILE: /* File name.  */
4881
161
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
281
      case C_MOS:   /* Member of structure.  */
4884
406
      case C_EOS:   /* End of structure.  */
4885
957
      case C_REGPARM: /* Register parameter.  */
4886
1.32k
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
1.43k
      case C_TPDEF: /* Type definition.  */
4889
1.55k
      case C_ARG:
4890
2.57k
      case C_AUTO: /* Automatic variable.  */
4891
2.64k
      case C_FIELD: /* Bit field.  */
4892
2.80k
      case C_ENTAG: /* Enumeration tag.  */
4893
2.96k
      case C_MOE:   /* Member of enumeration.  */
4894
3.02k
      case C_MOU:   /* Member of union.  */
4895
3.13k
      case C_UNTAG: /* Union tag.  */
4896
3.17k
      case C_STRTAG: /* Structure tag.  */
4897
#ifdef RS6000COFF_C
4898
      case C_GSYM:
4899
      case C_LSYM:
4900
      case C_PSYM:
4901
      case C_RSYM:
4902
      case C_RPSYM:
4903
      case C_STSYM:
4904
      case C_TCSYM:
4905
      case C_BCOMM:
4906
      case C_ECOML:
4907
      case C_ECOMM:
4908
      case C_DECL:
4909
      case C_ENTRY:
4910
      case C_FUN:
4911
      case C_ESTAT:
4912
#endif
4913
3.17k
        dst->symbol.flags |= BSF_DEBUGGING;
4914
3.17k
        dst->symbol.value = (src->u.syment.n_value);
4915
3.17k
        break;
4916
4917
#ifdef RS6000COFF_C
4918
      case C_BINCL: /* Beginning of include file.  */
4919
      case C_EINCL: /* Ending of include file.  */
4920
        /* The value is actually a pointer into the line numbers
4921
     of the file.  We locate the line number entry, and
4922
     set the section to the section which contains it, and
4923
     the value to the index in that section.  */
4924
        {
4925
    asection *sec;
4926
4927
    dst->symbol.flags = BSF_DEBUGGING;
4928
    for (sec = abfd->sections; sec != NULL; sec = sec->next)
4929
      if (sec->line_filepos <= (file_ptr) src->u.syment.n_value
4930
          && ((file_ptr) (sec->line_filepos
4931
              + sec->lineno_count * bfd_coff_linesz (abfd))
4932
        > (file_ptr) src->u.syment.n_value))
4933
        break;
4934
    if (sec == NULL)
4935
      dst->symbol.value = 0;
4936
    else
4937
      {
4938
        dst->symbol.section = sec;
4939
        dst->symbol.value = ((src->u.syment.n_value
4940
            - sec->line_filepos)
4941
           / bfd_coff_linesz (abfd));
4942
        src->fix_line = 1;
4943
      }
4944
        }
4945
        break;
4946
4947
      case C_BSTAT:
4948
        dst->symbol.flags = BSF_DEBUGGING;
4949
4950
        if (src->u.syment.n_value >= obj_raw_syment_count (abfd))
4951
    dst->symbol.value = 0;
4952
        else
4953
    {
4954
      /* The value is actually a symbol index.  Save a pointer
4955
         to the symbol instead of the index.  FIXME: This
4956
         should use a union.  */
4957
      src->u.syment.n_value
4958
        = (uintptr_t) (native_symbols + src->u.syment.n_value);
4959
      dst->symbol.value = src->u.syment.n_value;
4960
      src->fix_value = 1;
4961
    }
4962
        break;
4963
#endif
4964
4965
128
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
432
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
551
      case C_EFCN: /* Physical end of function.  */
4968
#if defined COFF_WITH_PE
4969
        /* PE sets the symbol to a value relative to the start
4970
     of the section.  */
4971
        dst->symbol.value = src->u.syment.n_value;
4972
        if (strcmp (dst->symbol.name, ".bf") != 0)
4973
    {
4974
      /* PE uses funny values for .ef and .lf; don't
4975
         relocate them.  */
4976
      dst->symbol.flags = BSF_DEBUGGING;
4977
    }
4978
        else
4979
    dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC;
4980
#else
4981
        /* Base the value as an index from the base of the
4982
     section.  */
4983
551
        dst->symbol.flags = BSF_LOCAL;
4984
551
        dst->symbol.value = (src->u.syment.n_value
4985
551
           - dst->symbol.section->vma);
4986
551
#endif
4987
551
        break;
4988
4989
19
      case C_STATLAB: /* Static load time label.  */
4990
19
        dst->symbol.value = src->u.syment.n_value;
4991
19
        dst->symbol.flags = BSF_GLOBAL;
4992
19
        break;
4993
4994
14.7k
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
14.7k
        if (src->u.syment.n_type == 0
4998
14.7k
      && src->u.syment.n_value == 0
4999
14.7k
      && src->u.syment.n_scnum == 0)
5000
2.92k
    break;
5001
#ifdef RS6000COFF_C
5002
        /* XCOFF specific: deleted entry.  */
5003
        if (src->u.syment.n_value == C_NULL_VALUE)
5004
    break;
5005
#endif
5006
        /* Fall through.  */
5007
11.8k
      case C_EXTDEF: /* External definition.  */
5008
11.8k
      case C_ULABEL: /* Undefined label.  */
5009
11.8k
      case C_USTATIC: /* Undefined static.  */
5010
11.8k
#ifndef COFF_WITH_PE
5011
      /* C_LINE in regular coff is 0x68.  NT has taken over this storage
5012
         class to represent a section symbol.  */
5013
12.0k
      case C_LINE: /* line # reformatted as symbol table entry.  */
5014
        /* NT uses 0x67 for a weak symbol, not C_ALIAS.  */
5015
12.1k
      case C_ALIAS: /* Duplicate tag.  */
5016
12.1k
#endif
5017
        /* New storage classes for TI COFF.  */
5018
#ifdef TICOFF
5019
      case C_UEXT:  /* Tentative external definition.  */
5020
#endif
5021
12.1k
      case C_EXTLAB: /* External load time label.  */
5022
16.3k
      default:
5023
16.3k
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
16.3k
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
16.3k
     abfd, src->u.syment.n_sclass,
5027
16.3k
     dst->symbol.section->name, dst->symbol.name);
5028
16.3k
        ret = false;
5029
        /* Fall through.  */
5030
16.4k
      case C_HIDDEN: /* Ext symbol in dmert public lib.  */
5031
        /* PR 20722: These symbols can also be generated by
5032
     building DLLs with --gc-sections enabled.  */
5033
16.4k
        dst->symbol.flags = BSF_DEBUGGING;
5034
16.4k
        dst->symbol.value = (src->u.syment.n_value);
5035
16.4k
        break;
5036
24.5k
      }
5037
5038
24.5k
    dst->native = src;
5039
24.5k
    dst->symbol.udata.i = 0;
5040
24.5k
    dst->lineno = NULL;
5041
5042
24.5k
    this_index += (src->u.syment.n_numaux) + 1;
5043
24.5k
    dst++;
5044
24.5k
    number_of_symbols++;
5045
24.5k
  }
5046
271
    }
5047
5048
271
  obj_symbols (abfd) = cached_area;
5049
271
  obj_raw_syments (abfd) = native_symbols;
5050
5051
271
  abfd->symcount = number_of_symbols;
5052
271
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
271
  {
5055
271
    asection *p;
5056
5057
271
    p = abfd->sections;
5058
932
    while (p)
5059
893
      {
5060
893
  if (! coff_slurp_line_table (abfd, p))
5061
232
    return false;
5062
661
  p = p->next;
5063
661
      }
5064
271
  }
5065
5066
39
  return ret;
5067
271
}
coff64-rs6000.c:coff_slurp_symbol_table
Line
Count
Source
4695
527
{
4696
527
  combined_entry_type *native_symbols;
4697
527
  coff_symbol_type *cached_area;
4698
527
  unsigned int *table_ptr;
4699
527
  unsigned int number_of_symbols = 0;
4700
527
  bool ret = true;
4701
527
  size_t amt;
4702
4703
527
  if (obj_symbols (abfd))
4704
7
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
520
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
184
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
336
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
336
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
336
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
336
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
336
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
336
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
336
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
336
  if (table_ptr == NULL)
4729
0
    return false;
4730
336
  else
4731
336
    {
4732
336
      coff_symbol_type *dst = cached_area;
4733
336
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
336
      unsigned int this_index = 0;
4735
4736
121k
      while (this_index < last_native_index)
4737
121k
  {
4738
121k
    combined_entry_type *src = native_symbols + this_index;
4739
121k
    table_ptr[this_index] = number_of_symbols;
4740
4741
121k
    dst->symbol.the_bfd = abfd;
4742
121k
    BFD_ASSERT (src->is_sym);
4743
121k
    dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset);
4744
    /* We use the native name field to point to the cached field.  */
4745
121k
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
121k
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
121k
                 src->u.syment.n_scnum);
4748
121k
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
121k
    dst->symbol.value = 0;
4751
121k
    dst->done_lineno = false;
4752
4753
121k
    switch (src->u.syment.n_sclass)
4754
121k
      {
4755
2.50k
      case C_EXT:
4756
2.60k
      case C_WEAKEXT:
4757
#if defined ARM
4758
      case C_THUMBEXT:
4759
      case C_THUMBEXTFUNC:
4760
#endif
4761
2.60k
#ifdef RS6000COFF_C
4762
2.74k
      case C_HIDEXT:
4763
2.74k
#ifndef AIX_WEAK_SUPPORT
4764
3.89k
      case C_AIX_WEAKEXT:
4765
3.89k
#endif
4766
3.89k
#endif
4767
3.89k
#ifdef C_SYSTEM
4768
4.07k
      case C_SYSTEM: /* System Wide variable.  */
4769
4.07k
#endif
4770
#ifdef COFF_WITH_PE
4771
      /* In PE, 0x68 (104) denotes a section symbol.  */
4772
      case C_SECTION:
4773
      /* In PE, 0x69 (105) denotes a weak external symbol.  */
4774
      case C_NT_WEAK:
4775
#endif
4776
4.07k
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
4.07k
    {
4778
2.97k
    case COFF_SYMBOL_GLOBAL:
4779
2.97k
      dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
4780
#if defined COFF_WITH_PE
4781
      /* PE sets the symbol to a value relative to the
4782
         start of the section.  */
4783
      dst->symbol.value = src->u.syment.n_value;
4784
#else
4785
2.97k
      dst->symbol.value = (src->u.syment.n_value
4786
2.97k
               - dst->symbol.section->vma);
4787
2.97k
#endif
4788
2.97k
      if (ISFCN ((src->u.syment.n_type)))
4789
        /* A function ext does not go at the end of a
4790
           file.  */
4791
21
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4792
2.97k
      break;
4793
4794
797
    case COFF_SYMBOL_COMMON:
4795
797
      dst->symbol.section = bfd_com_section_ptr;
4796
797
      dst->symbol.value = src->u.syment.n_value;
4797
797
      break;
4798
4799
158
    case COFF_SYMBOL_UNDEFINED:
4800
158
      dst->symbol.section = bfd_und_section_ptr;
4801
158
      dst->symbol.value = 0;
4802
158
      break;
4803
4804
0
    case COFF_SYMBOL_PE_SECTION:
4805
0
      dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM;
4806
0
      dst->symbol.value = 0;
4807
0
      break;
4808
4809
140
    case COFF_SYMBOL_LOCAL:
4810
140
      dst->symbol.flags = BSF_LOCAL;
4811
#if defined COFF_WITH_PE
4812
      /* PE sets the symbol to a value relative to the
4813
         start of the section.  */
4814
      dst->symbol.value = src->u.syment.n_value;
4815
#else
4816
140
      dst->symbol.value = (src->u.syment.n_value
4817
140
               - dst->symbol.section->vma);
4818
140
#endif
4819
140
      if (ISFCN ((src->u.syment.n_type)))
4820
5
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4821
140
      break;
4822
4.07k
    }
4823
4824
4.07k
#ifdef RS6000COFF_C
4825
        /* A symbol with a csect entry should not go at the end.  */
4826
4.07k
        if (src->u.syment.n_numaux > 0)
4827
1.83k
    dst->symbol.flags |= BSF_NOT_AT_END;
4828
4.07k
#endif
4829
4830
#ifdef COFF_WITH_PE
4831
        if (src->u.syment.n_sclass == C_NT_WEAK)
4832
    dst->symbol.flags |= BSF_WEAK;
4833
4834
        if (src->u.syment.n_sclass == C_SECTION
4835
      && src->u.syment.n_scnum > 0)
4836
    dst->symbol.flags = BSF_LOCAL;
4837
#endif
4838
4.07k
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
4.07k
#ifdef RS6000COFF_C
4840
4.07k
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
4.07k
#endif
4842
4.07k
      )
4843
1.24k
    dst->symbol.flags |= BSF_WEAK;
4844
4845
4.07k
        break;
4846
4847
403
      case C_STAT:  /* Static.  */
4848
#if defined ARM
4849
      case C_THUMBSTAT:    /* Thumb static.  */
4850
      case C_THUMBLABEL:   /* Thumb label.  */
4851
      case C_THUMBSTATFUNC:/* Thumb static function.  */
4852
#endif
4853
403
#ifdef RS6000COFF_C
4854
2.71k
      case C_DWARF:  /* A label in a dwarf section.  */
4855
4.50k
      case C_INFO:  /* A label in a comment section.  */
4856
4.50k
#endif
4857
4.84k
      case C_LABEL:  /* Label.  */
4858
4.84k
        if (src->u.syment.n_scnum == N_DEBUG)
4859
2
    dst->symbol.flags = BSF_DEBUGGING;
4860
4.84k
        else
4861
4.84k
    dst->symbol.flags = BSF_LOCAL;
4862
4863
        /* Base the value as an index from the base of the
4864
     section, if there is one.  */
4865
4.84k
        if (dst->symbol.section)
4866
4.84k
    {
4867
#if defined COFF_WITH_PE
4868
      /* PE sets the symbol to a value relative to the
4869
         start of the section.  */
4870
      dst->symbol.value = src->u.syment.n_value;
4871
#else
4872
4.84k
      dst->symbol.value = (src->u.syment.n_value
4873
4.84k
               - dst->symbol.section->vma);
4874
4.84k
#endif
4875
4.84k
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
4.84k
        break;
4879
4880
1.24k
      case C_FILE: /* File name.  */
4881
1.24k
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
1.49k
      case C_MOS:   /* Member of structure.  */
4884
1.93k
      case C_EOS:   /* End of structure.  */
4885
2.00k
      case C_REGPARM: /* Register parameter.  */
4886
2.67k
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
3.06k
      case C_TPDEF: /* Type definition.  */
4889
3.38k
      case C_ARG:
4890
8.55k
      case C_AUTO: /* Automatic variable.  */
4891
8.71k
      case C_FIELD: /* Bit field.  */
4892
8.95k
      case C_ENTAG: /* Enumeration tag.  */
4893
10.4k
      case C_MOE:   /* Member of enumeration.  */
4894
10.5k
      case C_MOU:   /* Member of union.  */
4895
10.7k
      case C_UNTAG: /* Union tag.  */
4896
10.9k
      case C_STRTAG: /* Structure tag.  */
4897
10.9k
#ifdef RS6000COFF_C
4898
11.1k
      case C_GSYM:
4899
11.2k
      case C_LSYM:
4900
11.2k
      case C_PSYM:
4901
11.2k
      case C_RSYM:
4902
11.3k
      case C_RPSYM:
4903
11.4k
      case C_STSYM:
4904
11.5k
      case C_TCSYM:
4905
11.6k
      case C_BCOMM:
4906
11.6k
      case C_ECOML:
4907
11.7k
      case C_ECOMM:
4908
11.8k
      case C_DECL:
4909
11.9k
      case C_ENTRY:
4910
11.9k
      case C_FUN:
4911
12.1k
      case C_ESTAT:
4912
12.1k
#endif
4913
12.1k
        dst->symbol.flags |= BSF_DEBUGGING;
4914
12.1k
        dst->symbol.value = (src->u.syment.n_value);
4915
12.1k
        break;
4916
4917
0
#ifdef RS6000COFF_C
4918
1.33k
      case C_BINCL: /* Beginning of include file.  */
4919
2.30k
      case C_EINCL: /* Ending of include file.  */
4920
        /* The value is actually a pointer into the line numbers
4921
     of the file.  We locate the line number entry, and
4922
     set the section to the section which contains it, and
4923
     the value to the index in that section.  */
4924
2.30k
        {
4925
2.30k
    asection *sec;
4926
4927
2.30k
    dst->symbol.flags = BSF_DEBUGGING;
4928
1.66M
    for (sec = abfd->sections; sec != NULL; sec = sec->next)
4929
1.66M
      if (sec->line_filepos <= (file_ptr) src->u.syment.n_value
4930
1.66M
          && ((file_ptr) (sec->line_filepos
4931
1.47M
              + sec->lineno_count * bfd_coff_linesz (abfd))
4932
1.47M
        > (file_ptr) src->u.syment.n_value))
4933
1.46k
        break;
4934
2.30k
    if (sec == NULL)
4935
840
      dst->symbol.value = 0;
4936
1.46k
    else
4937
1.46k
      {
4938
1.46k
        dst->symbol.section = sec;
4939
1.46k
        dst->symbol.value = ((src->u.syment.n_value
4940
1.46k
            - sec->line_filepos)
4941
1.46k
           / bfd_coff_linesz (abfd));
4942
1.46k
        src->fix_line = 1;
4943
1.46k
      }
4944
2.30k
        }
4945
2.30k
        break;
4946
4947
32
      case C_BSTAT:
4948
32
        dst->symbol.flags = BSF_DEBUGGING;
4949
4950
32
        if (src->u.syment.n_value >= obj_raw_syment_count (abfd))
4951
30
    dst->symbol.value = 0;
4952
2
        else
4953
2
    {
4954
      /* The value is actually a symbol index.  Save a pointer
4955
         to the symbol instead of the index.  FIXME: This
4956
         should use a union.  */
4957
2
      src->u.syment.n_value
4958
2
        = (uintptr_t) (native_symbols + src->u.syment.n_value);
4959
2
      dst->symbol.value = src->u.syment.n_value;
4960
2
      src->fix_value = 1;
4961
2
    }
4962
32
        break;
4963
0
#endif
4964
4965
293
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
3.26k
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
3.52k
      case C_EFCN: /* Physical end of function.  */
4968
#if defined COFF_WITH_PE
4969
        /* PE sets the symbol to a value relative to the start
4970
     of the section.  */
4971
        dst->symbol.value = src->u.syment.n_value;
4972
        if (strcmp (dst->symbol.name, ".bf") != 0)
4973
    {
4974
      /* PE uses funny values for .ef and .lf; don't
4975
         relocate them.  */
4976
      dst->symbol.flags = BSF_DEBUGGING;
4977
    }
4978
        else
4979
    dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC;
4980
#else
4981
        /* Base the value as an index from the base of the
4982
     section.  */
4983
3.52k
        dst->symbol.flags = BSF_LOCAL;
4984
3.52k
        dst->symbol.value = (src->u.syment.n_value
4985
3.52k
           - dst->symbol.section->vma);
4986
3.52k
#endif
4987
3.52k
        break;
4988
4989
280
      case C_STATLAB: /* Static load time label.  */
4990
280
        dst->symbol.value = src->u.syment.n_value;
4991
280
        dst->symbol.flags = BSF_GLOBAL;
4992
280
        break;
4993
4994
71.7k
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
71.7k
        if (src->u.syment.n_type == 0
4998
71.7k
      && src->u.syment.n_value == 0
4999
71.7k
      && src->u.syment.n_scnum == 0)
5000
10.4k
    break;
5001
61.2k
#ifdef RS6000COFF_C
5002
        /* XCOFF specific: deleted entry.  */
5003
61.2k
        if (src->u.syment.n_value == C_NULL_VALUE)
5004
1
    break;
5005
61.2k
#endif
5006
        /* Fall through.  */
5007
61.3k
      case C_EXTDEF: /* External definition.  */
5008
61.3k
      case C_ULABEL: /* Undefined label.  */
5009
61.4k
      case C_USTATIC: /* Undefined static.  */
5010
61.4k
#ifndef COFF_WITH_PE
5011
      /* C_LINE in regular coff is 0x68.  NT has taken over this storage
5012
         class to represent a section symbol.  */
5013
62.9k
      case C_LINE: /* line # reformatted as symbol table entry.  */
5014
        /* NT uses 0x67 for a weak symbol, not C_ALIAS.  */
5015
64.9k
      case C_ALIAS: /* Duplicate tag.  */
5016
64.9k
#endif
5017
        /* New storage classes for TI COFF.  */
5018
#ifdef TICOFF
5019
      case C_UEXT:  /* Tentative external definition.  */
5020
#endif
5021
64.9k
      case C_EXTLAB: /* External load time label.  */
5022
83.6k
      default:
5023
83.6k
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
83.6k
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
83.6k
     abfd, src->u.syment.n_sclass,
5027
83.6k
     dst->symbol.section->name, dst->symbol.name);
5028
83.6k
        ret = false;
5029
        /* Fall through.  */
5030
83.6k
      case C_HIDDEN: /* Ext symbol in dmert public lib.  */
5031
        /* PR 20722: These symbols can also be generated by
5032
     building DLLs with --gc-sections enabled.  */
5033
83.6k
        dst->symbol.flags = BSF_DEBUGGING;
5034
83.6k
        dst->symbol.value = (src->u.syment.n_value);
5035
83.6k
        break;
5036
121k
      }
5037
5038
121k
    dst->native = src;
5039
121k
    dst->symbol.udata.i = 0;
5040
121k
    dst->lineno = NULL;
5041
5042
121k
    this_index += (src->u.syment.n_numaux) + 1;
5043
121k
    dst++;
5044
121k
    number_of_symbols++;
5045
121k
  }
5046
336
    }
5047
5048
336
  obj_symbols (abfd) = cached_area;
5049
336
  obj_raw_syments (abfd) = native_symbols;
5050
5051
336
  abfd->symcount = number_of_symbols;
5052
336
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
336
  {
5055
336
    asection *p;
5056
5057
336
    p = abfd->sections;
5058
1.30k
    while (p)
5059
1.27k
      {
5060
1.27k
  if (! coff_slurp_line_table (abfd, p))
5061
306
    return false;
5062
973
  p = p->next;
5063
973
      }
5064
336
  }
5065
5066
30
  return ret;
5067
336
}
pe-aarch64.c:coff_slurp_symbol_table
Line
Count
Source
4695
275
{
4696
275
  combined_entry_type *native_symbols;
4697
275
  coff_symbol_type *cached_area;
4698
275
  unsigned int *table_ptr;
4699
275
  unsigned int number_of_symbols = 0;
4700
275
  bool ret = true;
4701
275
  size_t amt;
4702
4703
275
  if (obj_symbols (abfd))
4704
14
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
261
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
60
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
201
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
201
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
201
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
201
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
201
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
201
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
201
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
201
  if (table_ptr == NULL)
4729
0
    return false;
4730
201
  else
4731
201
    {
4732
201
      coff_symbol_type *dst = cached_area;
4733
201
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
201
      unsigned int this_index = 0;
4735
4736
71.8k
      while (this_index < last_native_index)
4737
71.6k
  {
4738
71.6k
    combined_entry_type *src = native_symbols + this_index;
4739
71.6k
    table_ptr[this_index] = number_of_symbols;
4740
4741
71.6k
    dst->symbol.the_bfd = abfd;
4742
71.6k
    BFD_ASSERT (src->is_sym);
4743
71.6k
    dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset);
4744
    /* We use the native name field to point to the cached field.  */
4745
71.6k
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
71.6k
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
71.6k
                 src->u.syment.n_scnum);
4748
71.6k
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
71.6k
    dst->symbol.value = 0;
4751
71.6k
    dst->done_lineno = false;
4752
4753
71.6k
    switch (src->u.syment.n_sclass)
4754
71.6k
      {
4755
790
      case C_EXT:
4756
883
      case C_WEAKEXT:
4757
#if defined ARM
4758
      case C_THUMBEXT:
4759
      case C_THUMBEXTFUNC:
4760
#endif
4761
#ifdef RS6000COFF_C
4762
      case C_HIDEXT:
4763
#ifndef AIX_WEAK_SUPPORT
4764
      case C_AIX_WEAKEXT:
4765
#endif
4766
#endif
4767
883
#ifdef C_SYSTEM
4768
929
      case C_SYSTEM: /* System Wide variable.  */
4769
929
#endif
4770
929
#ifdef COFF_WITH_PE
4771
      /* In PE, 0x68 (104) denotes a section symbol.  */
4772
936
      case C_SECTION:
4773
      /* In PE, 0x69 (105) denotes a weak external symbol.  */
4774
2.00k
      case C_NT_WEAK:
4775
2.00k
#endif
4776
2.00k
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
2.00k
    {
4778
1.79k
    case COFF_SYMBOL_GLOBAL:
4779
1.79k
      dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
4780
1.79k
#if defined COFF_WITH_PE
4781
      /* PE sets the symbol to a value relative to the
4782
         start of the section.  */
4783
1.79k
      dst->symbol.value = src->u.syment.n_value;
4784
#else
4785
      dst->symbol.value = (src->u.syment.n_value
4786
               - dst->symbol.section->vma);
4787
#endif
4788
1.79k
      if (ISFCN ((src->u.syment.n_type)))
4789
        /* A function ext does not go at the end of a
4790
           file.  */
4791
25
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4792
1.79k
      break;
4793
4794
174
    case COFF_SYMBOL_COMMON:
4795
174
      dst->symbol.section = bfd_com_section_ptr;
4796
174
      dst->symbol.value = src->u.syment.n_value;
4797
174
      break;
4798
4799
37
    case COFF_SYMBOL_UNDEFINED:
4800
37
      dst->symbol.section = bfd_und_section_ptr;
4801
37
      dst->symbol.value = 0;
4802
37
      break;
4803
4804
0
    case COFF_SYMBOL_PE_SECTION:
4805
0
      dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM;
4806
0
      dst->symbol.value = 0;
4807
0
      break;
4808
4809
0
    case COFF_SYMBOL_LOCAL:
4810
0
      dst->symbol.flags = BSF_LOCAL;
4811
0
#if defined COFF_WITH_PE
4812
      /* PE sets the symbol to a value relative to the
4813
         start of the section.  */
4814
0
      dst->symbol.value = src->u.syment.n_value;
4815
#else
4816
      dst->symbol.value = (src->u.syment.n_value
4817
               - dst->symbol.section->vma);
4818
#endif
4819
0
      if (ISFCN ((src->u.syment.n_type)))
4820
0
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4821
0
      break;
4822
2.00k
    }
4823
4824
#ifdef RS6000COFF_C
4825
        /* A symbol with a csect entry should not go at the end.  */
4826
        if (src->u.syment.n_numaux > 0)
4827
    dst->symbol.flags |= BSF_NOT_AT_END;
4828
#endif
4829
4830
2.00k
#ifdef COFF_WITH_PE
4831
2.00k
        if (src->u.syment.n_sclass == C_NT_WEAK)
4832
1.06k
    dst->symbol.flags |= BSF_WEAK;
4833
4834
2.00k
        if (src->u.syment.n_sclass == C_SECTION
4835
2.00k
      && src->u.syment.n_scnum > 0)
4836
0
    dst->symbol.flags = BSF_LOCAL;
4837
2.00k
#endif
4838
2.00k
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
#ifdef RS6000COFF_C
4840
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
#endif
4842
2.00k
      )
4843
93
    dst->symbol.flags |= BSF_WEAK;
4844
4845
2.00k
        break;
4846
4847
1.15k
      case C_STAT:  /* Static.  */
4848
#if defined ARM
4849
      case C_THUMBSTAT:    /* Thumb static.  */
4850
      case C_THUMBLABEL:   /* Thumb label.  */
4851
      case C_THUMBSTATFUNC:/* Thumb static function.  */
4852
#endif
4853
#ifdef RS6000COFF_C
4854
      case C_DWARF:  /* A label in a dwarf section.  */
4855
      case C_INFO:   /* A label in a comment section.  */
4856
#endif
4857
1.26k
      case C_LABEL:  /* Label.  */
4858
1.26k
        if (src->u.syment.n_scnum == N_DEBUG)
4859
1
    dst->symbol.flags = BSF_DEBUGGING;
4860
1.26k
        else
4861
1.26k
    dst->symbol.flags = BSF_LOCAL;
4862
4863
        /* Base the value as an index from the base of the
4864
     section, if there is one.  */
4865
1.26k
        if (dst->symbol.section)
4866
1.26k
    {
4867
1.26k
#if defined COFF_WITH_PE
4868
      /* PE sets the symbol to a value relative to the
4869
         start of the section.  */
4870
1.26k
      dst->symbol.value = src->u.syment.n_value;
4871
#else
4872
      dst->symbol.value = (src->u.syment.n_value
4873
               - dst->symbol.section->vma);
4874
#endif
4875
1.26k
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
1.26k
        break;
4879
4880
588
      case C_FILE: /* File name.  */
4881
588
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
768
      case C_MOS:   /* Member of structure.  */
4884
1.03k
      case C_EOS:   /* End of structure.  */
4885
1.14k
      case C_REGPARM: /* Register parameter.  */
4886
1.37k
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
1.57k
      case C_TPDEF: /* Type definition.  */
4889
1.83k
      case C_ARG:
4890
4.74k
      case C_AUTO: /* Automatic variable.  */
4891
4.88k
      case C_FIELD: /* Bit field.  */
4892
5.16k
      case C_ENTAG: /* Enumeration tag.  */
4893
5.41k
      case C_MOE:   /* Member of enumeration.  */
4894
5.80k
      case C_MOU:   /* Member of union.  */
4895
6.36k
      case C_UNTAG: /* Union tag.  */
4896
6.58k
      case C_STRTAG: /* Structure tag.  */
4897
#ifdef RS6000COFF_C
4898
      case C_GSYM:
4899
      case C_LSYM:
4900
      case C_PSYM:
4901
      case C_RSYM:
4902
      case C_RPSYM:
4903
      case C_STSYM:
4904
      case C_TCSYM:
4905
      case C_BCOMM:
4906
      case C_ECOML:
4907
      case C_ECOMM:
4908
      case C_DECL:
4909
      case C_ENTRY:
4910
      case C_FUN:
4911
      case C_ESTAT:
4912
#endif
4913
6.58k
        dst->symbol.flags |= BSF_DEBUGGING;
4914
6.58k
        dst->symbol.value = (src->u.syment.n_value);
4915
6.58k
        break;
4916
4917
#ifdef RS6000COFF_C
4918
      case C_BINCL: /* Beginning of include file.  */
4919
      case C_EINCL: /* Ending of include file.  */
4920
        /* The value is actually a pointer into the line numbers
4921
     of the file.  We locate the line number entry, and
4922
     set the section to the section which contains it, and
4923
     the value to the index in that section.  */
4924
        {
4925
    asection *sec;
4926
4927
    dst->symbol.flags = BSF_DEBUGGING;
4928
    for (sec = abfd->sections; sec != NULL; sec = sec->next)
4929
      if (sec->line_filepos <= (file_ptr) src->u.syment.n_value
4930
          && ((file_ptr) (sec->line_filepos
4931
              + sec->lineno_count * bfd_coff_linesz (abfd))
4932
        > (file_ptr) src->u.syment.n_value))
4933
        break;
4934
    if (sec == NULL)
4935
      dst->symbol.value = 0;
4936
    else
4937
      {
4938
        dst->symbol.section = sec;
4939
        dst->symbol.value = ((src->u.syment.n_value
4940
            - sec->line_filepos)
4941
           / bfd_coff_linesz (abfd));
4942
        src->fix_line = 1;
4943
      }
4944
        }
4945
        break;
4946
4947
      case C_BSTAT:
4948
        dst->symbol.flags = BSF_DEBUGGING;
4949
4950
        if (src->u.syment.n_value >= obj_raw_syment_count (abfd))
4951
    dst->symbol.value = 0;
4952
        else
4953
    {
4954
      /* The value is actually a symbol index.  Save a pointer
4955
         to the symbol instead of the index.  FIXME: This
4956
         should use a union.  */
4957
      src->u.syment.n_value
4958
        = (uintptr_t) (native_symbols + src->u.syment.n_value);
4959
      dst->symbol.value = src->u.syment.n_value;
4960
      src->fix_value = 1;
4961
    }
4962
        break;
4963
#endif
4964
4965
193
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
1.67k
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
1.91k
      case C_EFCN: /* Physical end of function.  */
4968
1.91k
#if defined COFF_WITH_PE
4969
        /* PE sets the symbol to a value relative to the start
4970
     of the section.  */
4971
1.91k
        dst->symbol.value = src->u.syment.n_value;
4972
1.91k
        if (strcmp (dst->symbol.name, ".bf") != 0)
4973
1.91k
    {
4974
      /* PE uses funny values for .ef and .lf; don't
4975
         relocate them.  */
4976
1.91k
      dst->symbol.flags = BSF_DEBUGGING;
4977
1.91k
    }
4978
0
        else
4979
0
    dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC;
4980
#else
4981
        /* Base the value as an index from the base of the
4982
     section.  */
4983
        dst->symbol.flags = BSF_LOCAL;
4984
        dst->symbol.value = (src->u.syment.n_value
4985
           - dst->symbol.section->vma);
4986
#endif
4987
1.91k
        break;
4988
4989
61
      case C_STATLAB: /* Static load time label.  */
4990
61
        dst->symbol.value = src->u.syment.n_value;
4991
61
        dst->symbol.flags = BSF_GLOBAL;
4992
61
        break;
4993
4994
43.7k
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
43.7k
        if (src->u.syment.n_type == 0
4998
43.7k
      && src->u.syment.n_value == 0
4999
43.7k
      && src->u.syment.n_scnum == 0)
5000
9.81k
    break;
5001
#ifdef RS6000COFF_C
5002
        /* XCOFF specific: deleted entry.  */
5003
        if (src->u.syment.n_value == C_NULL_VALUE)
5004
    break;
5005
#endif
5006
        /* Fall through.  */
5007
33.9k
      case C_EXTDEF: /* External definition.  */
5008
34.0k
      case C_ULABEL: /* Undefined label.  */
5009
34.0k
      case C_USTATIC: /* Undefined static.  */
5010
#ifndef COFF_WITH_PE
5011
      /* C_LINE in regular coff is 0x68.  NT has taken over this storage
5012
         class to represent a section symbol.  */
5013
      case C_LINE:  /* line # reformatted as symbol table entry.  */
5014
        /* NT uses 0x67 for a weak symbol, not C_ALIAS.  */
5015
      case C_ALIAS: /* Duplicate tag.  */
5016
#endif
5017
        /* New storage classes for TI COFF.  */
5018
#ifdef TICOFF
5019
      case C_UEXT:  /* Tentative external definition.  */
5020
#endif
5021
34.1k
      case C_EXTLAB: /* External load time label.  */
5022
49.9k
      default:
5023
49.9k
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
49.9k
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
49.9k
     abfd, src->u.syment.n_sclass,
5027
49.9k
     dst->symbol.section->name, dst->symbol.name);
5028
49.9k
        ret = false;
5029
        /* Fall through.  */
5030
49.9k
      case C_HIDDEN: /* Ext symbol in dmert public lib.  */
5031
        /* PR 20722: These symbols can also be generated by
5032
     building DLLs with --gc-sections enabled.  */
5033
49.9k
        dst->symbol.flags = BSF_DEBUGGING;
5034
49.9k
        dst->symbol.value = (src->u.syment.n_value);
5035
49.9k
        break;
5036
71.6k
      }
5037
5038
71.6k
    dst->native = src;
5039
71.6k
    dst->symbol.udata.i = 0;
5040
71.6k
    dst->lineno = NULL;
5041
5042
71.6k
    this_index += (src->u.syment.n_numaux) + 1;
5043
71.6k
    dst++;
5044
71.6k
    number_of_symbols++;
5045
71.6k
  }
5046
201
    }
5047
5048
201
  obj_symbols (abfd) = cached_area;
5049
201
  obj_raw_syments (abfd) = native_symbols;
5050
5051
201
  abfd->symcount = number_of_symbols;
5052
201
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
201
  {
5055
201
    asection *p;
5056
5057
201
    p = abfd->sections;
5058
356
    while (p)
5059
290
      {
5060
290
  if (! coff_slurp_line_table (abfd, p))
5061
135
    return false;
5062
155
  p = p->next;
5063
155
      }
5064
201
  }
5065
5066
66
  return ret;
5067
201
}
pei-aarch64.c:coff_slurp_symbol_table
Line
Count
Source
4695
239
{
4696
239
  combined_entry_type *native_symbols;
4697
239
  coff_symbol_type *cached_area;
4698
239
  unsigned int *table_ptr;
4699
239
  unsigned int number_of_symbols = 0;
4700
239
  bool ret = true;
4701
239
  size_t amt;
4702
4703
239
  if (obj_symbols (abfd))
4704
16
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
223
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
78
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
145
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
145
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
145
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
145
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
145
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
145
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
145
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
145
  if (table_ptr == NULL)
4729
0
    return false;
4730
145
  else
4731
145
    {
4732
145
      coff_symbol_type *dst = cached_area;
4733
145
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
145
      unsigned int this_index = 0;
4735
4736
51.6k
      while (this_index < last_native_index)
4737
51.4k
  {
4738
51.4k
    combined_entry_type *src = native_symbols + this_index;
4739
51.4k
    table_ptr[this_index] = number_of_symbols;
4740
4741
51.4k
    dst->symbol.the_bfd = abfd;
4742
51.4k
    BFD_ASSERT (src->is_sym);
4743
51.4k
    dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset);
4744
    /* We use the native name field to point to the cached field.  */
4745
51.4k
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
51.4k
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
51.4k
                 src->u.syment.n_scnum);
4748
51.4k
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
51.4k
    dst->symbol.value = 0;
4751
51.4k
    dst->done_lineno = false;
4752
4753
51.4k
    switch (src->u.syment.n_sclass)
4754
51.4k
      {
4755
1.01k
      case C_EXT:
4756
1.04k
      case C_WEAKEXT:
4757
#if defined ARM
4758
      case C_THUMBEXT:
4759
      case C_THUMBEXTFUNC:
4760
#endif
4761
#ifdef RS6000COFF_C
4762
      case C_HIDEXT:
4763
#ifndef AIX_WEAK_SUPPORT
4764
      case C_AIX_WEAKEXT:
4765
#endif
4766
#endif
4767
1.04k
#ifdef C_SYSTEM
4768
1.25k
      case C_SYSTEM: /* System Wide variable.  */
4769
1.25k
#endif
4770
1.25k
#ifdef COFF_WITH_PE
4771
      /* In PE, 0x68 (104) denotes a section symbol.  */
4772
1.26k
      case C_SECTION:
4773
      /* In PE, 0x69 (105) denotes a weak external symbol.  */
4774
1.92k
      case C_NT_WEAK:
4775
1.92k
#endif
4776
1.92k
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
1.92k
    {
4778
1.46k
    case COFF_SYMBOL_GLOBAL:
4779
1.46k
      dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
4780
1.46k
#if defined COFF_WITH_PE
4781
      /* PE sets the symbol to a value relative to the
4782
         start of the section.  */
4783
1.46k
      dst->symbol.value = src->u.syment.n_value;
4784
#else
4785
      dst->symbol.value = (src->u.syment.n_value
4786
               - dst->symbol.section->vma);
4787
#endif
4788
1.46k
      if (ISFCN ((src->u.syment.n_type)))
4789
        /* A function ext does not go at the end of a
4790
           file.  */
4791
54
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4792
1.46k
      break;
4793
4794
411
    case COFF_SYMBOL_COMMON:
4795
411
      dst->symbol.section = bfd_com_section_ptr;
4796
411
      dst->symbol.value = src->u.syment.n_value;
4797
411
      break;
4798
4799
49
    case COFF_SYMBOL_UNDEFINED:
4800
49
      dst->symbol.section = bfd_und_section_ptr;
4801
49
      dst->symbol.value = 0;
4802
49
      break;
4803
4804
0
    case COFF_SYMBOL_PE_SECTION:
4805
0
      dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM;
4806
0
      dst->symbol.value = 0;
4807
0
      break;
4808
4809
0
    case COFF_SYMBOL_LOCAL:
4810
0
      dst->symbol.flags = BSF_LOCAL;
4811
0
#if defined COFF_WITH_PE
4812
      /* PE sets the symbol to a value relative to the
4813
         start of the section.  */
4814
0
      dst->symbol.value = src->u.syment.n_value;
4815
#else
4816
      dst->symbol.value = (src->u.syment.n_value
4817
               - dst->symbol.section->vma);
4818
#endif
4819
0
      if (ISFCN ((src->u.syment.n_type)))
4820
0
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4821
0
      break;
4822
1.92k
    }
4823
4824
#ifdef RS6000COFF_C
4825
        /* A symbol with a csect entry should not go at the end.  */
4826
        if (src->u.syment.n_numaux > 0)
4827
    dst->symbol.flags |= BSF_NOT_AT_END;
4828
#endif
4829
4830
1.92k
#ifdef COFF_WITH_PE
4831
1.92k
        if (src->u.syment.n_sclass == C_NT_WEAK)
4832
657
    dst->symbol.flags |= BSF_WEAK;
4833
4834
1.92k
        if (src->u.syment.n_sclass == C_SECTION
4835
1.92k
      && src->u.syment.n_scnum > 0)
4836
0
    dst->symbol.flags = BSF_LOCAL;
4837
1.92k
#endif
4838
1.92k
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
#ifdef RS6000COFF_C
4840
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
#endif
4842
1.92k
      )
4843
34
    dst->symbol.flags |= BSF_WEAK;
4844
4845
1.92k
        break;
4846
4847
725
      case C_STAT:  /* Static.  */
4848
#if defined ARM
4849
      case C_THUMBSTAT:    /* Thumb static.  */
4850
      case C_THUMBLABEL:   /* Thumb label.  */
4851
      case C_THUMBSTATFUNC:/* Thumb static function.  */
4852
#endif
4853
#ifdef RS6000COFF_C
4854
      case C_DWARF:  /* A label in a dwarf section.  */
4855
      case C_INFO:   /* A label in a comment section.  */
4856
#endif
4857
789
      case C_LABEL:  /* Label.  */
4858
789
        if (src->u.syment.n_scnum == N_DEBUG)
4859
0
    dst->symbol.flags = BSF_DEBUGGING;
4860
789
        else
4861
789
    dst->symbol.flags = BSF_LOCAL;
4862
4863
        /* Base the value as an index from the base of the
4864
     section, if there is one.  */
4865
789
        if (dst->symbol.section)
4866
789
    {
4867
789
#if defined COFF_WITH_PE
4868
      /* PE sets the symbol to a value relative to the
4869
         start of the section.  */
4870
789
      dst->symbol.value = src->u.syment.n_value;
4871
#else
4872
      dst->symbol.value = (src->u.syment.n_value
4873
               - dst->symbol.section->vma);
4874
#endif
4875
789
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
789
        break;
4879
4880
406
      case C_FILE: /* File name.  */
4881
406
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
672
      case C_MOS:   /* Member of structure.  */
4884
905
      case C_EOS:   /* End of structure.  */
4885
984
      case C_REGPARM: /* Register parameter.  */
4886
1.09k
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
1.19k
      case C_TPDEF: /* Type definition.  */
4889
1.22k
      case C_ARG:
4890
3.07k
      case C_AUTO: /* Automatic variable.  */
4891
3.14k
      case C_FIELD: /* Bit field.  */
4892
3.66k
      case C_ENTAG: /* Enumeration tag.  */
4893
3.90k
      case C_MOE:   /* Member of enumeration.  */
4894
3.97k
      case C_MOU:   /* Member of union.  */
4895
4.27k
      case C_UNTAG: /* Union tag.  */
4896
4.63k
      case C_STRTAG: /* Structure tag.  */
4897
#ifdef RS6000COFF_C
4898
      case C_GSYM:
4899
      case C_LSYM:
4900
      case C_PSYM:
4901
      case C_RSYM:
4902
      case C_RPSYM:
4903
      case C_STSYM:
4904
      case C_TCSYM:
4905
      case C_BCOMM:
4906
      case C_ECOML:
4907
      case C_ECOMM:
4908
      case C_DECL:
4909
      case C_ENTRY:
4910
      case C_FUN:
4911
      case C_ESTAT:
4912
#endif
4913
4.63k
        dst->symbol.flags |= BSF_DEBUGGING;
4914
4.63k
        dst->symbol.value = (src->u.syment.n_value);
4915
4.63k
        break;
4916
4917
#ifdef RS6000COFF_C
4918
      case C_BINCL: /* Beginning of include file.  */
4919
      case C_EINCL: /* Ending of include file.  */
4920
        /* The value is actually a pointer into the line numbers
4921
     of the file.  We locate the line number entry, and
4922
     set the section to the section which contains it, and
4923
     the value to the index in that section.  */
4924
        {
4925
    asection *sec;
4926
4927
    dst->symbol.flags = BSF_DEBUGGING;
4928
    for (sec = abfd->sections; sec != NULL; sec = sec->next)
4929
      if (sec->line_filepos <= (file_ptr) src->u.syment.n_value
4930
          && ((file_ptr) (sec->line_filepos
4931
              + sec->lineno_count * bfd_coff_linesz (abfd))
4932
        > (file_ptr) src->u.syment.n_value))
4933
        break;
4934
    if (sec == NULL)
4935
      dst->symbol.value = 0;
4936
    else
4937
      {
4938
        dst->symbol.section = sec;
4939
        dst->symbol.value = ((src->u.syment.n_value
4940
            - sec->line_filepos)
4941
           / bfd_coff_linesz (abfd));
4942
        src->fix_line = 1;
4943
      }
4944
        }
4945
        break;
4946
4947
      case C_BSTAT:
4948
        dst->symbol.flags = BSF_DEBUGGING;
4949
4950
        if (src->u.syment.n_value >= obj_raw_syment_count (abfd))
4951
    dst->symbol.value = 0;
4952
        else
4953
    {
4954
      /* The value is actually a symbol index.  Save a pointer
4955
         to the symbol instead of the index.  FIXME: This
4956
         should use a union.  */
4957
      src->u.syment.n_value
4958
        = (uintptr_t) (native_symbols + src->u.syment.n_value);
4959
      dst->symbol.value = src->u.syment.n_value;
4960
      src->fix_value = 1;
4961
    }
4962
        break;
4963
#endif
4964
4965
108
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
988
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
1.23k
      case C_EFCN: /* Physical end of function.  */
4968
1.23k
#if defined COFF_WITH_PE
4969
        /* PE sets the symbol to a value relative to the start
4970
     of the section.  */
4971
1.23k
        dst->symbol.value = src->u.syment.n_value;
4972
1.23k
        if (strcmp (dst->symbol.name, ".bf") != 0)
4973
1.23k
    {
4974
      /* PE uses funny values for .ef and .lf; don't
4975
         relocate them.  */
4976
1.23k
      dst->symbol.flags = BSF_DEBUGGING;
4977
1.23k
    }
4978
0
        else
4979
0
    dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC;
4980
#else
4981
        /* Base the value as an index from the base of the
4982
     section.  */
4983
        dst->symbol.flags = BSF_LOCAL;
4984
        dst->symbol.value = (src->u.syment.n_value
4985
           - dst->symbol.section->vma);
4986
#endif
4987
1.23k
        break;
4988
4989
114
      case C_STATLAB: /* Static load time label.  */
4990
114
        dst->symbol.value = src->u.syment.n_value;
4991
114
        dst->symbol.flags = BSF_GLOBAL;
4992
114
        break;
4993
4994
32.2k
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
32.2k
        if (src->u.syment.n_type == 0
4998
32.2k
      && src->u.syment.n_value == 0
4999
32.2k
      && src->u.syment.n_scnum == 0)
5000
6.56k
    break;
5001
#ifdef RS6000COFF_C
5002
        /* XCOFF specific: deleted entry.  */
5003
        if (src->u.syment.n_value == C_NULL_VALUE)
5004
    break;
5005
#endif
5006
        /* Fall through.  */
5007
25.7k
      case C_EXTDEF: /* External definition.  */
5008
25.8k
      case C_ULABEL: /* Undefined label.  */
5009
25.9k
      case C_USTATIC: /* Undefined static.  */
5010
#ifndef COFF_WITH_PE
5011
      /* C_LINE in regular coff is 0x68.  NT has taken over this storage
5012
         class to represent a section symbol.  */
5013
      case C_LINE:  /* line # reformatted as symbol table entry.  */
5014
        /* NT uses 0x67 for a weak symbol, not C_ALIAS.  */
5015
      case C_ALIAS: /* Duplicate tag.  */
5016
#endif
5017
        /* New storage classes for TI COFF.  */
5018
#ifdef TICOFF
5019
      case C_UEXT:  /* Tentative external definition.  */
5020
#endif
5021
25.9k
      case C_EXTLAB: /* External load time label.  */
5022
36.2k
      default:
5023
36.2k
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
36.2k
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
36.2k
     abfd, src->u.syment.n_sclass,
5027
36.2k
     dst->symbol.section->name, dst->symbol.name);
5028
36.2k
        ret = false;
5029
        /* Fall through.  */
5030
36.2k
      case C_HIDDEN: /* Ext symbol in dmert public lib.  */
5031
        /* PR 20722: These symbols can also be generated by
5032
     building DLLs with --gc-sections enabled.  */
5033
36.2k
        dst->symbol.flags = BSF_DEBUGGING;
5034
36.2k
        dst->symbol.value = (src->u.syment.n_value);
5035
36.2k
        break;
5036
51.4k
      }
5037
5038
51.4k
    dst->native = src;
5039
51.4k
    dst->symbol.udata.i = 0;
5040
51.4k
    dst->lineno = NULL;
5041
5042
51.4k
    this_index += (src->u.syment.n_numaux) + 1;
5043
51.4k
    dst++;
5044
51.4k
    number_of_symbols++;
5045
51.4k
  }
5046
145
    }
5047
5048
145
  obj_symbols (abfd) = cached_area;
5049
145
  obj_raw_syments (abfd) = native_symbols;
5050
5051
145
  abfd->symcount = number_of_symbols;
5052
145
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
145
  {
5055
145
    asection *p;
5056
5057
145
    p = abfd->sections;
5058
204
    while (p)
5059
198
      {
5060
198
  if (! coff_slurp_line_table (abfd, p))
5061
139
    return false;
5062
59
  p = p->next;
5063
59
      }
5064
145
  }
5065
5066
6
  return ret;
5067
145
}
pei-ia64.c:coff_slurp_symbol_table
Line
Count
Source
4695
294
{
4696
294
  combined_entry_type *native_symbols;
4697
294
  coff_symbol_type *cached_area;
4698
294
  unsigned int *table_ptr;
4699
294
  unsigned int number_of_symbols = 0;
4700
294
  bool ret = true;
4701
294
  size_t amt;
4702
4703
294
  if (obj_symbols (abfd))
4704
2
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
292
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
121
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
171
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
171
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
171
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
171
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
171
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
171
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
171
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
171
  if (table_ptr == NULL)
4729
0
    return false;
4730
171
  else
4731
171
    {
4732
171
      coff_symbol_type *dst = cached_area;
4733
171
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
171
      unsigned int this_index = 0;
4735
4736
45.6k
      while (this_index < last_native_index)
4737
45.4k
  {
4738
45.4k
    combined_entry_type *src = native_symbols + this_index;
4739
45.4k
    table_ptr[this_index] = number_of_symbols;
4740
4741
45.4k
    dst->symbol.the_bfd = abfd;
4742
45.4k
    BFD_ASSERT (src->is_sym);
4743
45.4k
    dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset);
4744
    /* We use the native name field to point to the cached field.  */
4745
45.4k
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
45.4k
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
45.4k
                 src->u.syment.n_scnum);
4748
45.4k
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
45.4k
    dst->symbol.value = 0;
4751
45.4k
    dst->done_lineno = false;
4752
4753
45.4k
    switch (src->u.syment.n_sclass)
4754
45.4k
      {
4755
856
      case C_EXT:
4756
929
      case C_WEAKEXT:
4757
#if defined ARM
4758
      case C_THUMBEXT:
4759
      case C_THUMBEXTFUNC:
4760
#endif
4761
#ifdef RS6000COFF_C
4762
      case C_HIDEXT:
4763
#ifndef AIX_WEAK_SUPPORT
4764
      case C_AIX_WEAKEXT:
4765
#endif
4766
#endif
4767
929
#ifdef C_SYSTEM
4768
962
      case C_SYSTEM: /* System Wide variable.  */
4769
962
#endif
4770
962
#ifdef COFF_WITH_PE
4771
      /* In PE, 0x68 (104) denotes a section symbol.  */
4772
977
      case C_SECTION:
4773
      /* In PE, 0x69 (105) denotes a weak external symbol.  */
4774
1.82k
      case C_NT_WEAK:
4775
1.82k
#endif
4776
1.82k
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
1.82k
    {
4778
1.65k
    case COFF_SYMBOL_GLOBAL:
4779
1.65k
      dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
4780
1.65k
#if defined COFF_WITH_PE
4781
      /* PE sets the symbol to a value relative to the
4782
         start of the section.  */
4783
1.65k
      dst->symbol.value = src->u.syment.n_value;
4784
#else
4785
      dst->symbol.value = (src->u.syment.n_value
4786
               - dst->symbol.section->vma);
4787
#endif
4788
1.65k
      if (ISFCN ((src->u.syment.n_type)))
4789
        /* A function ext does not go at the end of a
4790
           file.  */
4791
82
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4792
1.65k
      break;
4793
4794
132
    case COFF_SYMBOL_COMMON:
4795
132
      dst->symbol.section = bfd_com_section_ptr;
4796
132
      dst->symbol.value = src->u.syment.n_value;
4797
132
      break;
4798
4799
35
    case COFF_SYMBOL_UNDEFINED:
4800
35
      dst->symbol.section = bfd_und_section_ptr;
4801
35
      dst->symbol.value = 0;
4802
35
      break;
4803
4804
0
    case COFF_SYMBOL_PE_SECTION:
4805
0
      dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM;
4806
0
      dst->symbol.value = 0;
4807
0
      break;
4808
4809
0
    case COFF_SYMBOL_LOCAL:
4810
0
      dst->symbol.flags = BSF_LOCAL;
4811
0
#if defined COFF_WITH_PE
4812
      /* PE sets the symbol to a value relative to the
4813
         start of the section.  */
4814
0
      dst->symbol.value = src->u.syment.n_value;
4815
#else
4816
      dst->symbol.value = (src->u.syment.n_value
4817
               - dst->symbol.section->vma);
4818
#endif
4819
0
      if (ISFCN ((src->u.syment.n_type)))
4820
0
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4821
0
      break;
4822
1.82k
    }
4823
4824
#ifdef RS6000COFF_C
4825
        /* A symbol with a csect entry should not go at the end.  */
4826
        if (src->u.syment.n_numaux > 0)
4827
    dst->symbol.flags |= BSF_NOT_AT_END;
4828
#endif
4829
4830
1.82k
#ifdef COFF_WITH_PE
4831
1.82k
        if (src->u.syment.n_sclass == C_NT_WEAK)
4832
846
    dst->symbol.flags |= BSF_WEAK;
4833
4834
1.82k
        if (src->u.syment.n_sclass == C_SECTION
4835
1.82k
      && src->u.syment.n_scnum > 0)
4836
0
    dst->symbol.flags = BSF_LOCAL;
4837
1.82k
#endif
4838
1.82k
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
#ifdef RS6000COFF_C
4840
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
#endif
4842
1.82k
      )
4843
73
    dst->symbol.flags |= BSF_WEAK;
4844
4845
1.82k
        break;
4846
4847
631
      case C_STAT:  /* Static.  */
4848
#if defined ARM
4849
      case C_THUMBSTAT:    /* Thumb static.  */
4850
      case C_THUMBLABEL:   /* Thumb label.  */
4851
      case C_THUMBSTATFUNC:/* Thumb static function.  */
4852
#endif
4853
#ifdef RS6000COFF_C
4854
      case C_DWARF:  /* A label in a dwarf section.  */
4855
      case C_INFO:   /* A label in a comment section.  */
4856
#endif
4857
767
      case C_LABEL:  /* Label.  */
4858
767
        if (src->u.syment.n_scnum == N_DEBUG)
4859
0
    dst->symbol.flags = BSF_DEBUGGING;
4860
767
        else
4861
767
    dst->symbol.flags = BSF_LOCAL;
4862
4863
        /* Base the value as an index from the base of the
4864
     section, if there is one.  */
4865
767
        if (dst->symbol.section)
4866
767
    {
4867
767
#if defined COFF_WITH_PE
4868
      /* PE sets the symbol to a value relative to the
4869
         start of the section.  */
4870
767
      dst->symbol.value = src->u.syment.n_value;
4871
#else
4872
      dst->symbol.value = (src->u.syment.n_value
4873
               - dst->symbol.section->vma);
4874
#endif
4875
767
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
767
        break;
4879
4880
401
      case C_FILE: /* File name.  */
4881
401
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
502
      case C_MOS:   /* Member of structure.  */
4884
787
      case C_EOS:   /* End of structure.  */
4885
861
      case C_REGPARM: /* Register parameter.  */
4886
1.00k
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
1.20k
      case C_TPDEF: /* Type definition.  */
4889
1.32k
      case C_ARG:
4890
2.97k
      case C_AUTO: /* Automatic variable.  */
4891
3.12k
      case C_FIELD: /* Bit field.  */
4892
3.29k
      case C_ENTAG: /* Enumeration tag.  */
4893
3.49k
      case C_MOE:   /* Member of enumeration.  */
4894
3.57k
      case C_MOU:   /* Member of union.  */
4895
3.70k
      case C_UNTAG: /* Union tag.  */
4896
3.91k
      case C_STRTAG: /* Structure tag.  */
4897
#ifdef RS6000COFF_C
4898
      case C_GSYM:
4899
      case C_LSYM:
4900
      case C_PSYM:
4901
      case C_RSYM:
4902
      case C_RPSYM:
4903
      case C_STSYM:
4904
      case C_TCSYM:
4905
      case C_BCOMM:
4906
      case C_ECOML:
4907
      case C_ECOMM:
4908
      case C_DECL:
4909
      case C_ENTRY:
4910
      case C_FUN:
4911
      case C_ESTAT:
4912
#endif
4913
3.91k
        dst->symbol.flags |= BSF_DEBUGGING;
4914
3.91k
        dst->symbol.value = (src->u.syment.n_value);
4915
3.91k
        break;
4916
4917
#ifdef RS6000COFF_C
4918
      case C_BINCL: /* Beginning of include file.  */
4919
      case C_EINCL: /* Ending of include file.  */
4920
        /* The value is actually a pointer into the line numbers
4921
     of the file.  We locate the line number entry, and
4922
     set the section to the section which contains it, and
4923
     the value to the index in that section.  */
4924
        {
4925
    asection *sec;
4926
4927
    dst->symbol.flags = BSF_DEBUGGING;
4928
    for (sec = abfd->sections; sec != NULL; sec = sec->next)
4929
      if (sec->line_filepos <= (file_ptr) src->u.syment.n_value
4930
          && ((file_ptr) (sec->line_filepos
4931
              + sec->lineno_count * bfd_coff_linesz (abfd))
4932
        > (file_ptr) src->u.syment.n_value))
4933
        break;
4934
    if (sec == NULL)
4935
      dst->symbol.value = 0;
4936
    else
4937
      {
4938
        dst->symbol.section = sec;
4939
        dst->symbol.value = ((src->u.syment.n_value
4940
            - sec->line_filepos)
4941
           / bfd_coff_linesz (abfd));
4942
        src->fix_line = 1;
4943
      }
4944
        }
4945
        break;
4946
4947
      case C_BSTAT:
4948
        dst->symbol.flags = BSF_DEBUGGING;
4949
4950
        if (src->u.syment.n_value >= obj_raw_syment_count (abfd))
4951
    dst->symbol.value = 0;
4952
        else
4953
    {
4954
      /* The value is actually a symbol index.  Save a pointer
4955
         to the symbol instead of the index.  FIXME: This
4956
         should use a union.  */
4957
      src->u.syment.n_value
4958
        = (uintptr_t) (native_symbols + src->u.syment.n_value);
4959
      dst->symbol.value = src->u.syment.n_value;
4960
      src->fix_value = 1;
4961
    }
4962
        break;
4963
#endif
4964
4965
164
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
1.13k
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
1.32k
      case C_EFCN: /* Physical end of function.  */
4968
1.32k
#if defined COFF_WITH_PE
4969
        /* PE sets the symbol to a value relative to the start
4970
     of the section.  */
4971
1.32k
        dst->symbol.value = src->u.syment.n_value;
4972
1.32k
        if (strcmp (dst->symbol.name, ".bf") != 0)
4973
1.32k
    {
4974
      /* PE uses funny values for .ef and .lf; don't
4975
         relocate them.  */
4976
1.32k
      dst->symbol.flags = BSF_DEBUGGING;
4977
1.32k
    }
4978
0
        else
4979
0
    dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC;
4980
#else
4981
        /* Base the value as an index from the base of the
4982
     section.  */
4983
        dst->symbol.flags = BSF_LOCAL;
4984
        dst->symbol.value = (src->u.syment.n_value
4985
           - dst->symbol.section->vma);
4986
#endif
4987
1.32k
        break;
4988
4989
48
      case C_STATLAB: /* Static load time label.  */
4990
48
        dst->symbol.value = src->u.syment.n_value;
4991
48
        dst->symbol.flags = BSF_GLOBAL;
4992
48
        break;
4993
4994
26.5k
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
26.5k
        if (src->u.syment.n_type == 0
4998
26.5k
      && src->u.syment.n_value == 0
4999
26.5k
      && src->u.syment.n_scnum == 0)
5000
4.14k
    break;
5001
#ifdef RS6000COFF_C
5002
        /* XCOFF specific: deleted entry.  */
5003
        if (src->u.syment.n_value == C_NULL_VALUE)
5004
    break;
5005
#endif
5006
        /* Fall through.  */
5007
22.4k
      case C_EXTDEF: /* External definition.  */
5008
22.5k
      case C_ULABEL: /* Undefined label.  */
5009
22.5k
      case C_USTATIC: /* Undefined static.  */
5010
#ifndef COFF_WITH_PE
5011
      /* C_LINE in regular coff is 0x68.  NT has taken over this storage
5012
         class to represent a section symbol.  */
5013
      case C_LINE:  /* line # reformatted as symbol table entry.  */
5014
        /* NT uses 0x67 for a weak symbol, not C_ALIAS.  */
5015
      case C_ALIAS: /* Duplicate tag.  */
5016
#endif
5017
        /* New storage classes for TI COFF.  */
5018
#ifdef TICOFF
5019
      case C_UEXT:  /* Tentative external definition.  */
5020
#endif
5021
22.5k
      case C_EXTLAB: /* External load time label.  */
5022
33.4k
      default:
5023
33.4k
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
33.4k
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
33.4k
     abfd, src->u.syment.n_sclass,
5027
33.4k
     dst->symbol.section->name, dst->symbol.name);
5028
33.4k
        ret = false;
5029
        /* Fall through.  */
5030
33.4k
      case C_HIDDEN: /* Ext symbol in dmert public lib.  */
5031
        /* PR 20722: These symbols can also be generated by
5032
     building DLLs with --gc-sections enabled.  */
5033
33.4k
        dst->symbol.flags = BSF_DEBUGGING;
5034
33.4k
        dst->symbol.value = (src->u.syment.n_value);
5035
33.4k
        break;
5036
45.4k
      }
5037
5038
45.4k
    dst->native = src;
5039
45.4k
    dst->symbol.udata.i = 0;
5040
45.4k
    dst->lineno = NULL;
5041
5042
45.4k
    this_index += (src->u.syment.n_numaux) + 1;
5043
45.4k
    dst++;
5044
45.4k
    number_of_symbols++;
5045
45.4k
  }
5046
171
    }
5047
5048
171
  obj_symbols (abfd) = cached_area;
5049
171
  obj_raw_syments (abfd) = native_symbols;
5050
5051
171
  abfd->symcount = number_of_symbols;
5052
171
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
171
  {
5055
171
    asection *p;
5056
5057
171
    p = abfd->sections;
5058
506
    while (p)
5059
492
      {
5060
492
  if (! coff_slurp_line_table (abfd, p))
5061
157
    return false;
5062
335
  p = p->next;
5063
335
      }
5064
171
  }
5065
5066
14
  return ret;
5067
171
}
pei-loongarch64.c:coff_slurp_symbol_table
Line
Count
Source
4695
240
{
4696
240
  combined_entry_type *native_symbols;
4697
240
  coff_symbol_type *cached_area;
4698
240
  unsigned int *table_ptr;
4699
240
  unsigned int number_of_symbols = 0;
4700
240
  bool ret = true;
4701
240
  size_t amt;
4702
4703
240
  if (obj_symbols (abfd))
4704
18
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
222
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
92
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
130
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
130
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
130
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
130
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
130
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
130
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
130
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
130
  if (table_ptr == NULL)
4729
0
    return false;
4730
130
  else
4731
130
    {
4732
130
      coff_symbol_type *dst = cached_area;
4733
130
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
130
      unsigned int this_index = 0;
4735
4736
52.1k
      while (this_index < last_native_index)
4737
52.0k
  {
4738
52.0k
    combined_entry_type *src = native_symbols + this_index;
4739
52.0k
    table_ptr[this_index] = number_of_symbols;
4740
4741
52.0k
    dst->symbol.the_bfd = abfd;
4742
52.0k
    BFD_ASSERT (src->is_sym);
4743
52.0k
    dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset);
4744
    /* We use the native name field to point to the cached field.  */
4745
52.0k
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
52.0k
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
52.0k
                 src->u.syment.n_scnum);
4748
52.0k
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
52.0k
    dst->symbol.value = 0;
4751
52.0k
    dst->done_lineno = false;
4752
4753
52.0k
    switch (src->u.syment.n_sclass)
4754
52.0k
      {
4755
798
      case C_EXT:
4756
835
      case C_WEAKEXT:
4757
#if defined ARM
4758
      case C_THUMBEXT:
4759
      case C_THUMBEXTFUNC:
4760
#endif
4761
#ifdef RS6000COFF_C
4762
      case C_HIDEXT:
4763
#ifndef AIX_WEAK_SUPPORT
4764
      case C_AIX_WEAKEXT:
4765
#endif
4766
#endif
4767
835
#ifdef C_SYSTEM
4768
1.03k
      case C_SYSTEM: /* System Wide variable.  */
4769
1.03k
#endif
4770
1.03k
#ifdef COFF_WITH_PE
4771
      /* In PE, 0x68 (104) denotes a section symbol.  */
4772
1.04k
      case C_SECTION:
4773
      /* In PE, 0x69 (105) denotes a weak external symbol.  */
4774
1.52k
      case C_NT_WEAK:
4775
1.52k
#endif
4776
1.52k
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
1.52k
    {
4778
1.11k
    case COFF_SYMBOL_GLOBAL:
4779
1.11k
      dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
4780
1.11k
#if defined COFF_WITH_PE
4781
      /* PE sets the symbol to a value relative to the
4782
         start of the section.  */
4783
1.11k
      dst->symbol.value = src->u.syment.n_value;
4784
#else
4785
      dst->symbol.value = (src->u.syment.n_value
4786
               - dst->symbol.section->vma);
4787
#endif
4788
1.11k
      if (ISFCN ((src->u.syment.n_type)))
4789
        /* A function ext does not go at the end of a
4790
           file.  */
4791
25
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4792
1.11k
      break;
4793
4794
272
    case COFF_SYMBOL_COMMON:
4795
272
      dst->symbol.section = bfd_com_section_ptr;
4796
272
      dst->symbol.value = src->u.syment.n_value;
4797
272
      break;
4798
4799
143
    case COFF_SYMBOL_UNDEFINED:
4800
143
      dst->symbol.section = bfd_und_section_ptr;
4801
143
      dst->symbol.value = 0;
4802
143
      break;
4803
4804
0
    case COFF_SYMBOL_PE_SECTION:
4805
0
      dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM;
4806
0
      dst->symbol.value = 0;
4807
0
      break;
4808
4809
0
    case COFF_SYMBOL_LOCAL:
4810
0
      dst->symbol.flags = BSF_LOCAL;
4811
0
#if defined COFF_WITH_PE
4812
      /* PE sets the symbol to a value relative to the
4813
         start of the section.  */
4814
0
      dst->symbol.value = src->u.syment.n_value;
4815
#else
4816
      dst->symbol.value = (src->u.syment.n_value
4817
               - dst->symbol.section->vma);
4818
#endif
4819
0
      if (ISFCN ((src->u.syment.n_type)))
4820
0
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4821
0
      break;
4822
1.52k
    }
4823
4824
#ifdef RS6000COFF_C
4825
        /* A symbol with a csect entry should not go at the end.  */
4826
        if (src->u.syment.n_numaux > 0)
4827
    dst->symbol.flags |= BSF_NOT_AT_END;
4828
#endif
4829
4830
1.52k
#ifdef COFF_WITH_PE
4831
1.52k
        if (src->u.syment.n_sclass == C_NT_WEAK)
4832
480
    dst->symbol.flags |= BSF_WEAK;
4833
4834
1.52k
        if (src->u.syment.n_sclass == C_SECTION
4835
1.52k
      && src->u.syment.n_scnum > 0)
4836
0
    dst->symbol.flags = BSF_LOCAL;
4837
1.52k
#endif
4838
1.52k
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
#ifdef RS6000COFF_C
4840
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
#endif
4842
1.52k
      )
4843
37
    dst->symbol.flags |= BSF_WEAK;
4844
4845
1.52k
        break;
4846
4847
692
      case C_STAT:  /* Static.  */
4848
#if defined ARM
4849
      case C_THUMBSTAT:    /* Thumb static.  */
4850
      case C_THUMBLABEL:   /* Thumb label.  */
4851
      case C_THUMBSTATFUNC:/* Thumb static function.  */
4852
#endif
4853
#ifdef RS6000COFF_C
4854
      case C_DWARF:  /* A label in a dwarf section.  */
4855
      case C_INFO:   /* A label in a comment section.  */
4856
#endif
4857
904
      case C_LABEL:  /* Label.  */
4858
904
        if (src->u.syment.n_scnum == N_DEBUG)
4859
0
    dst->symbol.flags = BSF_DEBUGGING;
4860
904
        else
4861
904
    dst->symbol.flags = BSF_LOCAL;
4862
4863
        /* Base the value as an index from the base of the
4864
     section, if there is one.  */
4865
904
        if (dst->symbol.section)
4866
904
    {
4867
904
#if defined COFF_WITH_PE
4868
      /* PE sets the symbol to a value relative to the
4869
         start of the section.  */
4870
904
      dst->symbol.value = src->u.syment.n_value;
4871
#else
4872
      dst->symbol.value = (src->u.syment.n_value
4873
               - dst->symbol.section->vma);
4874
#endif
4875
904
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
904
        break;
4879
4880
378
      case C_FILE: /* File name.  */
4881
378
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
633
      case C_MOS:   /* Member of structure.  */
4884
773
      case C_EOS:   /* End of structure.  */
4885
901
      case C_REGPARM: /* Register parameter.  */
4886
1.06k
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
1.15k
      case C_TPDEF: /* Type definition.  */
4889
1.22k
      case C_ARG:
4890
4.07k
      case C_AUTO: /* Automatic variable.  */
4891
4.38k
      case C_FIELD: /* Bit field.  */
4892
4.56k
      case C_ENTAG: /* Enumeration tag.  */
4893
4.73k
      case C_MOE:   /* Member of enumeration.  */
4894
4.87k
      case C_MOU:   /* Member of union.  */
4895
5.00k
      case C_UNTAG: /* Union tag.  */
4896
5.35k
      case C_STRTAG: /* Structure tag.  */
4897
#ifdef RS6000COFF_C
4898
      case C_GSYM:
4899
      case C_LSYM:
4900
      case C_PSYM:
4901
      case C_RSYM:
4902
      case C_RPSYM:
4903
      case C_STSYM:
4904
      case C_TCSYM:
4905
      case C_BCOMM:
4906
      case C_ECOML:
4907
      case C_ECOMM:
4908
      case C_DECL:
4909
      case C_ENTRY:
4910
      case C_FUN:
4911
      case C_ESTAT:
4912
#endif
4913
5.35k
        dst->symbol.flags |= BSF_DEBUGGING;
4914
5.35k
        dst->symbol.value = (src->u.syment.n_value);
4915
5.35k
        break;
4916
4917
#ifdef RS6000COFF_C
4918
      case C_BINCL: /* Beginning of include file.  */
4919
      case C_EINCL: /* Ending of include file.  */
4920
        /* The value is actually a pointer into the line numbers
4921
     of the file.  We locate the line number entry, and
4922
     set the section to the section which contains it, and
4923
     the value to the index in that section.  */
4924
        {
4925
    asection *sec;
4926
4927
    dst->symbol.flags = BSF_DEBUGGING;
4928
    for (sec = abfd->sections; sec != NULL; sec = sec->next)
4929
      if (sec->line_filepos <= (file_ptr) src->u.syment.n_value
4930
          && ((file_ptr) (sec->line_filepos
4931
              + sec->lineno_count * bfd_coff_linesz (abfd))
4932
        > (file_ptr) src->u.syment.n_value))
4933
        break;
4934
    if (sec == NULL)
4935
      dst->symbol.value = 0;
4936
    else
4937
      {
4938
        dst->symbol.section = sec;
4939
        dst->symbol.value = ((src->u.syment.n_value
4940
            - sec->line_filepos)
4941
           / bfd_coff_linesz (abfd));
4942
        src->fix_line = 1;
4943
      }
4944
        }
4945
        break;
4946
4947
      case C_BSTAT:
4948
        dst->symbol.flags = BSF_DEBUGGING;
4949
4950
        if (src->u.syment.n_value >= obj_raw_syment_count (abfd))
4951
    dst->symbol.value = 0;
4952
        else
4953
    {
4954
      /* The value is actually a symbol index.  Save a pointer
4955
         to the symbol instead of the index.  FIXME: This
4956
         should use a union.  */
4957
      src->u.syment.n_value
4958
        = (uintptr_t) (native_symbols + src->u.syment.n_value);
4959
      dst->symbol.value = src->u.syment.n_value;
4960
      src->fix_value = 1;
4961
    }
4962
        break;
4963
#endif
4964
4965
115
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
835
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
1.07k
      case C_EFCN: /* Physical end of function.  */
4968
1.07k
#if defined COFF_WITH_PE
4969
        /* PE sets the symbol to a value relative to the start
4970
     of the section.  */
4971
1.07k
        dst->symbol.value = src->u.syment.n_value;
4972
1.07k
        if (strcmp (dst->symbol.name, ".bf") != 0)
4973
1.07k
    {
4974
      /* PE uses funny values for .ef and .lf; don't
4975
         relocate them.  */
4976
1.07k
      dst->symbol.flags = BSF_DEBUGGING;
4977
1.07k
    }
4978
0
        else
4979
0
    dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC;
4980
#else
4981
        /* Base the value as an index from the base of the
4982
     section.  */
4983
        dst->symbol.flags = BSF_LOCAL;
4984
        dst->symbol.value = (src->u.syment.n_value
4985
           - dst->symbol.section->vma);
4986
#endif
4987
1.07k
        break;
4988
4989
52
      case C_STATLAB: /* Static load time label.  */
4990
52
        dst->symbol.value = src->u.syment.n_value;
4991
52
        dst->symbol.flags = BSF_GLOBAL;
4992
52
        break;
4993
4994
32.8k
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
32.8k
        if (src->u.syment.n_type == 0
4998
32.8k
      && src->u.syment.n_value == 0
4999
32.8k
      && src->u.syment.n_scnum == 0)
5000
3.47k
    break;
5001
#ifdef RS6000COFF_C
5002
        /* XCOFF specific: deleted entry.  */
5003
        if (src->u.syment.n_value == C_NULL_VALUE)
5004
    break;
5005
#endif
5006
        /* Fall through.  */
5007
29.3k
      case C_EXTDEF: /* External definition.  */
5008
29.3k
      case C_ULABEL: /* Undefined label.  */
5009
29.4k
      case C_USTATIC: /* Undefined static.  */
5010
#ifndef COFF_WITH_PE
5011
      /* C_LINE in regular coff is 0x68.  NT has taken over this storage
5012
         class to represent a section symbol.  */
5013
      case C_LINE:  /* line # reformatted as symbol table entry.  */
5014
        /* NT uses 0x67 for a weak symbol, not C_ALIAS.  */
5015
      case C_ALIAS: /* Duplicate tag.  */
5016
#endif
5017
        /* New storage classes for TI COFF.  */
5018
#ifdef TICOFF
5019
      case C_UEXT:  /* Tentative external definition.  */
5020
#endif
5021
29.4k
      case C_EXTLAB: /* External load time label.  */
5022
39.6k
      default:
5023
39.6k
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
39.6k
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
39.6k
     abfd, src->u.syment.n_sclass,
5027
39.6k
     dst->symbol.section->name, dst->symbol.name);
5028
39.6k
        ret = false;
5029
        /* Fall through.  */
5030
39.6k
      case C_HIDDEN: /* Ext symbol in dmert public lib.  */
5031
        /* PR 20722: These symbols can also be generated by
5032
     building DLLs with --gc-sections enabled.  */
5033
39.6k
        dst->symbol.flags = BSF_DEBUGGING;
5034
39.6k
        dst->symbol.value = (src->u.syment.n_value);
5035
39.6k
        break;
5036
52.0k
      }
5037
5038
52.0k
    dst->native = src;
5039
52.0k
    dst->symbol.udata.i = 0;
5040
52.0k
    dst->lineno = NULL;
5041
5042
52.0k
    this_index += (src->u.syment.n_numaux) + 1;
5043
52.0k
    dst++;
5044
52.0k
    number_of_symbols++;
5045
52.0k
  }
5046
130
    }
5047
5048
130
  obj_symbols (abfd) = cached_area;
5049
130
  obj_raw_syments (abfd) = native_symbols;
5050
5051
130
  abfd->symcount = number_of_symbols;
5052
130
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
130
  {
5055
130
    asection *p;
5056
5057
130
    p = abfd->sections;
5058
182
    while (p)
5059
176
      {
5060
176
  if (! coff_slurp_line_table (abfd, p))
5061
124
    return false;
5062
52
  p = p->next;
5063
52
      }
5064
130
  }
5065
5066
6
  return ret;
5067
130
}
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
4695
493
{
4696
493
  combined_entry_type *native_symbols;
4697
493
  coff_symbol_type *cached_area;
4698
493
  unsigned int *table_ptr;
4699
493
  unsigned int number_of_symbols = 0;
4700
493
  bool ret = true;
4701
493
  size_t amt;
4702
4703
493
  if (obj_symbols (abfd))
4704
23
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
470
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
177
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
293
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
293
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
293
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
293
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
293
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
293
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
293
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
293
  if (table_ptr == NULL)
4729
0
    return false;
4730
293
  else
4731
293
    {
4732
293
      coff_symbol_type *dst = cached_area;
4733
293
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
293
      unsigned int this_index = 0;
4735
4736
161k
      while (this_index < last_native_index)
4737
161k
  {
4738
161k
    combined_entry_type *src = native_symbols + this_index;
4739
161k
    table_ptr[this_index] = number_of_symbols;
4740
4741
161k
    dst->symbol.the_bfd = abfd;
4742
161k
    BFD_ASSERT (src->is_sym);
4743
161k
    dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset);
4744
    /* We use the native name field to point to the cached field.  */
4745
161k
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
161k
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
161k
                 src->u.syment.n_scnum);
4748
161k
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
161k
    dst->symbol.value = 0;
4751
161k
    dst->done_lineno = false;
4752
4753
161k
    switch (src->u.syment.n_sclass)
4754
161k
      {
4755
3.26k
      case C_EXT:
4756
3.48k
      case C_WEAKEXT:
4757
#if defined ARM
4758
      case C_THUMBEXT:
4759
      case C_THUMBEXTFUNC:
4760
#endif
4761
3.48k
#ifdef RS6000COFF_C
4762
3.64k
      case C_HIDEXT:
4763
3.64k
#ifndef AIX_WEAK_SUPPORT
4764
4.46k
      case C_AIX_WEAKEXT:
4765
4.46k
#endif
4766
4.46k
#endif
4767
4.46k
#ifdef C_SYSTEM
4768
4.55k
      case C_SYSTEM: /* System Wide variable.  */
4769
4.55k
#endif
4770
#ifdef COFF_WITH_PE
4771
      /* In PE, 0x68 (104) denotes a section symbol.  */
4772
      case C_SECTION:
4773
      /* In PE, 0x69 (105) denotes a weak external symbol.  */
4774
      case C_NT_WEAK:
4775
#endif
4776
4.55k
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
4.55k
    {
4778
3.48k
    case COFF_SYMBOL_GLOBAL:
4779
3.48k
      dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
4780
#if defined COFF_WITH_PE
4781
      /* PE sets the symbol to a value relative to the
4782
         start of the section.  */
4783
      dst->symbol.value = src->u.syment.n_value;
4784
#else
4785
3.48k
      dst->symbol.value = (src->u.syment.n_value
4786
3.48k
               - dst->symbol.section->vma);
4787
3.48k
#endif
4788
3.48k
      if (ISFCN ((src->u.syment.n_type)))
4789
        /* A function ext does not go at the end of a
4790
           file.  */
4791
32
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4792
3.48k
      break;
4793
4794
891
    case COFF_SYMBOL_COMMON:
4795
891
      dst->symbol.section = bfd_com_section_ptr;
4796
891
      dst->symbol.value = src->u.syment.n_value;
4797
891
      break;
4798
4799
39
    case COFF_SYMBOL_UNDEFINED:
4800
39
      dst->symbol.section = bfd_und_section_ptr;
4801
39
      dst->symbol.value = 0;
4802
39
      break;
4803
4804
0
    case COFF_SYMBOL_PE_SECTION:
4805
0
      dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM;
4806
0
      dst->symbol.value = 0;
4807
0
      break;
4808
4809
145
    case COFF_SYMBOL_LOCAL:
4810
145
      dst->symbol.flags = BSF_LOCAL;
4811
#if defined COFF_WITH_PE
4812
      /* PE sets the symbol to a value relative to the
4813
         start of the section.  */
4814
      dst->symbol.value = src->u.syment.n_value;
4815
#else
4816
145
      dst->symbol.value = (src->u.syment.n_value
4817
145
               - dst->symbol.section->vma);
4818
145
#endif
4819
145
      if (ISFCN ((src->u.syment.n_type)))
4820
7
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4821
145
      break;
4822
4.55k
    }
4823
4824
4.55k
#ifdef RS6000COFF_C
4825
        /* A symbol with a csect entry should not go at the end.  */
4826
4.55k
        if (src->u.syment.n_numaux > 0)
4827
2.74k
    dst->symbol.flags |= BSF_NOT_AT_END;
4828
4.55k
#endif
4829
4830
#ifdef COFF_WITH_PE
4831
        if (src->u.syment.n_sclass == C_NT_WEAK)
4832
    dst->symbol.flags |= BSF_WEAK;
4833
4834
        if (src->u.syment.n_sclass == C_SECTION
4835
      && src->u.syment.n_scnum > 0)
4836
    dst->symbol.flags = BSF_LOCAL;
4837
#endif
4838
4.55k
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
4.55k
#ifdef RS6000COFF_C
4840
4.55k
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
4.55k
#endif
4842
4.55k
      )
4843
1.03k
    dst->symbol.flags |= BSF_WEAK;
4844
4845
4.55k
        break;
4846
4847
360
      case C_STAT:  /* Static.  */
4848
#if defined ARM
4849
      case C_THUMBSTAT:    /* Thumb static.  */
4850
      case C_THUMBLABEL:   /* Thumb label.  */
4851
      case C_THUMBSTATFUNC:/* Thumb static function.  */
4852
#endif
4853
360
#ifdef RS6000COFF_C
4854
1.93k
      case C_DWARF:  /* A label in a dwarf section.  */
4855
3.03k
      case C_INFO:  /* A label in a comment section.  */
4856
3.03k
#endif
4857
3.21k
      case C_LABEL:  /* Label.  */
4858
3.21k
        if (src->u.syment.n_scnum == N_DEBUG)
4859
0
    dst->symbol.flags = BSF_DEBUGGING;
4860
3.21k
        else
4861
3.21k
    dst->symbol.flags = BSF_LOCAL;
4862
4863
        /* Base the value as an index from the base of the
4864
     section, if there is one.  */
4865
3.21k
        if (dst->symbol.section)
4866
3.21k
    {
4867
#if defined COFF_WITH_PE
4868
      /* PE sets the symbol to a value relative to the
4869
         start of the section.  */
4870
      dst->symbol.value = src->u.syment.n_value;
4871
#else
4872
3.21k
      dst->symbol.value = (src->u.syment.n_value
4873
3.21k
               - dst->symbol.section->vma);
4874
3.21k
#endif
4875
3.21k
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
3.21k
        break;
4879
4880
620
      case C_FILE: /* File name.  */
4881
620
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
790
      case C_MOS:   /* Member of structure.  */
4884
2.27k
      case C_EOS:   /* End of structure.  */
4885
2.36k
      case C_REGPARM: /* Register parameter.  */
4886
3.12k
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
3.26k
      case C_TPDEF: /* Type definition.  */
4889
3.78k
      case C_ARG:
4890
14.9k
      case C_AUTO: /* Automatic variable.  */
4891
15.1k
      case C_FIELD: /* Bit field.  */
4892
15.4k
      case C_ENTAG: /* Enumeration tag.  */
4893
16.2k
      case C_MOE:   /* Member of enumeration.  */
4894
16.6k
      case C_MOU:   /* Member of union.  */
4895
16.7k
      case C_UNTAG: /* Union tag.  */
4896
17.0k
      case C_STRTAG: /* Structure tag.  */
4897
17.0k
#ifdef RS6000COFF_C
4898
17.7k
      case C_GSYM:
4899
17.8k
      case C_LSYM:
4900
17.9k
      case C_PSYM:
4901
18.0k
      case C_RSYM:
4902
18.1k
      case C_RPSYM:
4903
18.2k
      case C_STSYM:
4904
18.2k
      case C_TCSYM:
4905
18.2k
      case C_BCOMM:
4906
18.4k
      case C_ECOML:
4907
18.6k
      case C_ECOMM:
4908
18.7k
      case C_DECL:
4909
18.7k
      case C_ENTRY:
4910
18.8k
      case C_FUN:
4911
19.3k
      case C_ESTAT:
4912
19.3k
#endif
4913
19.3k
        dst->symbol.flags |= BSF_DEBUGGING;
4914
19.3k
        dst->symbol.value = (src->u.syment.n_value);
4915
19.3k
        break;
4916
4917
0
#ifdef RS6000COFF_C
4918
816
      case C_BINCL: /* Beginning of include file.  */
4919
1.21k
      case C_EINCL: /* Ending of include file.  */
4920
        /* The value is actually a pointer into the line numbers
4921
     of the file.  We locate the line number entry, and
4922
     set the section to the section which contains it, and
4923
     the value to the index in that section.  */
4924
1.21k
        {
4925
1.21k
    asection *sec;
4926
4927
1.21k
    dst->symbol.flags = BSF_DEBUGGING;
4928
107k
    for (sec = abfd->sections; sec != NULL; sec = sec->next)
4929
106k
      if (sec->line_filepos <= (file_ptr) src->u.syment.n_value
4930
106k
          && ((file_ptr) (sec->line_filepos
4931
65.7k
              + sec->lineno_count * bfd_coff_linesz (abfd))
4932
65.7k
        > (file_ptr) src->u.syment.n_value))
4933
279
        break;
4934
1.21k
    if (sec == NULL)
4935
940
      dst->symbol.value = 0;
4936
279
    else
4937
279
      {
4938
279
        dst->symbol.section = sec;
4939
279
        dst->symbol.value = ((src->u.syment.n_value
4940
279
            - sec->line_filepos)
4941
279
           / bfd_coff_linesz (abfd));
4942
279
        src->fix_line = 1;
4943
279
      }
4944
1.21k
        }
4945
1.21k
        break;
4946
4947
31
      case C_BSTAT:
4948
31
        dst->symbol.flags = BSF_DEBUGGING;
4949
4950
31
        if (src->u.syment.n_value >= obj_raw_syment_count (abfd))
4951
17
    dst->symbol.value = 0;
4952
14
        else
4953
14
    {
4954
      /* The value is actually a symbol index.  Save a pointer
4955
         to the symbol instead of the index.  FIXME: This
4956
         should use a union.  */
4957
14
      src->u.syment.n_value
4958
14
        = (uintptr_t) (native_symbols + src->u.syment.n_value);
4959
14
      dst->symbol.value = src->u.syment.n_value;
4960
14
      src->fix_value = 1;
4961
14
    }
4962
31
        break;
4963
0
#endif
4964
4965
349
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
2.09k
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
2.47k
      case C_EFCN: /* Physical end of function.  */
4968
#if defined COFF_WITH_PE
4969
        /* PE sets the symbol to a value relative to the start
4970
     of the section.  */
4971
        dst->symbol.value = src->u.syment.n_value;
4972
        if (strcmp (dst->symbol.name, ".bf") != 0)
4973
    {
4974
      /* PE uses funny values for .ef and .lf; don't
4975
         relocate them.  */
4976
      dst->symbol.flags = BSF_DEBUGGING;
4977
    }
4978
        else
4979
    dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC;
4980
#else
4981
        /* Base the value as an index from the base of the
4982
     section.  */
4983
2.47k
        dst->symbol.flags = BSF_LOCAL;
4984
2.47k
        dst->symbol.value = (src->u.syment.n_value
4985
2.47k
           - dst->symbol.section->vma);
4986
2.47k
#endif
4987
2.47k
        break;
4988
4989
233
      case C_STATLAB: /* Static load time label.  */
4990
233
        dst->symbol.value = src->u.syment.n_value;
4991
233
        dst->symbol.flags = BSF_GLOBAL;
4992
233
        break;
4993
4994
104k
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
104k
        if (src->u.syment.n_type == 0
4998
104k
      && src->u.syment.n_value == 0
4999
104k
      && src->u.syment.n_scnum == 0)
5000
18.8k
    break;
5001
85.6k
#ifdef RS6000COFF_C
5002
        /* XCOFF specific: deleted entry.  */
5003
85.6k
        if (src->u.syment.n_value == C_NULL_VALUE)
5004
0
    break;
5005
85.6k
#endif
5006
        /* Fall through.  */
5007
85.7k
      case C_EXTDEF: /* External definition.  */
5008
85.8k
      case C_ULABEL: /* Undefined label.  */
5009
85.8k
      case C_USTATIC: /* Undefined static.  */
5010
85.8k
#ifndef COFF_WITH_PE
5011
      /* C_LINE in regular coff is 0x68.  NT has taken over this storage
5012
         class to represent a section symbol.  */
5013
86.5k
      case C_LINE: /* line # reformatted as symbol table entry.  */
5014
        /* NT uses 0x67 for a weak symbol, not C_ALIAS.  */
5015
87.6k
      case C_ALIAS: /* Duplicate tag.  */
5016
87.6k
#endif
5017
        /* New storage classes for TI COFF.  */
5018
#ifdef TICOFF
5019
      case C_UEXT:  /* Tentative external definition.  */
5020
#endif
5021
87.7k
      case C_EXTLAB: /* External load time label.  */
5022
111k
      default:
5023
111k
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
111k
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
111k
     abfd, src->u.syment.n_sclass,
5027
111k
     dst->symbol.section->name, dst->symbol.name);
5028
111k
        ret = false;
5029
        /* Fall through.  */
5030
111k
      case C_HIDDEN: /* Ext symbol in dmert public lib.  */
5031
        /* PR 20722: These symbols can also be generated by
5032
     building DLLs with --gc-sections enabled.  */
5033
111k
        dst->symbol.flags = BSF_DEBUGGING;
5034
111k
        dst->symbol.value = (src->u.syment.n_value);
5035
111k
        break;
5036
161k
      }
5037
5038
161k
    dst->native = src;
5039
161k
    dst->symbol.udata.i = 0;
5040
161k
    dst->lineno = NULL;
5041
5042
161k
    this_index += (src->u.syment.n_numaux) + 1;
5043
161k
    dst++;
5044
161k
    number_of_symbols++;
5045
161k
  }
5046
293
    }
5047
5048
293
  obj_symbols (abfd) = cached_area;
5049
293
  obj_raw_syments (abfd) = native_symbols;
5050
5051
293
  abfd->symcount = number_of_symbols;
5052
293
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
293
  {
5055
293
    asection *p;
5056
5057
293
    p = abfd->sections;
5058
528
    while (p)
5059
461
      {
5060
461
  if (! coff_slurp_line_table (abfd, p))
5061
226
    return false;
5062
235
  p = p->next;
5063
235
      }
5064
293
  }
5065
5066
67
  return ret;
5067
293
}
coff-sh.c:coff_slurp_symbol_table
Line
Count
Source
4695
600
{
4696
600
  combined_entry_type *native_symbols;
4697
600
  coff_symbol_type *cached_area;
4698
600
  unsigned int *table_ptr;
4699
600
  unsigned int number_of_symbols = 0;
4700
600
  bool ret = true;
4701
600
  size_t amt;
4702
4703
600
  if (obj_symbols (abfd))
4704
88
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
512
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
253
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
259
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
259
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
259
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
259
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
259
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
259
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
259
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
259
  if (table_ptr == NULL)
4729
0
    return false;
4730
259
  else
4731
259
    {
4732
259
      coff_symbol_type *dst = cached_area;
4733
259
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
259
      unsigned int this_index = 0;
4735
4736
46.9k
      while (this_index < last_native_index)
4737
46.6k
  {
4738
46.6k
    combined_entry_type *src = native_symbols + this_index;
4739
46.6k
    table_ptr[this_index] = number_of_symbols;
4740
4741
46.6k
    dst->symbol.the_bfd = abfd;
4742
46.6k
    BFD_ASSERT (src->is_sym);
4743
46.6k
    dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset);
4744
    /* We use the native name field to point to the cached field.  */
4745
46.6k
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
46.6k
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
46.6k
                 src->u.syment.n_scnum);
4748
46.6k
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
46.6k
    dst->symbol.value = 0;
4751
46.6k
    dst->done_lineno = false;
4752
4753
46.6k
    switch (src->u.syment.n_sclass)
4754
46.6k
      {
4755
840
      case C_EXT:
4756
870
      case C_WEAKEXT:
4757
#if defined ARM
4758
      case C_THUMBEXT:
4759
      case C_THUMBEXTFUNC:
4760
#endif
4761
#ifdef RS6000COFF_C
4762
      case C_HIDEXT:
4763
#ifndef AIX_WEAK_SUPPORT
4764
      case C_AIX_WEAKEXT:
4765
#endif
4766
#endif
4767
870
#ifdef C_SYSTEM
4768
994
      case C_SYSTEM: /* System Wide variable.  */
4769
994
#endif
4770
#ifdef COFF_WITH_PE
4771
      /* In PE, 0x68 (104) denotes a section symbol.  */
4772
      case C_SECTION:
4773
      /* In PE, 0x69 (105) denotes a weak external symbol.  */
4774
      case C_NT_WEAK:
4775
#endif
4776
994
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
994
    {
4778
882
    case COFF_SYMBOL_GLOBAL:
4779
882
      dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
4780
#if defined COFF_WITH_PE
4781
      /* PE sets the symbol to a value relative to the
4782
         start of the section.  */
4783
      dst->symbol.value = src->u.syment.n_value;
4784
#else
4785
882
      dst->symbol.value = (src->u.syment.n_value
4786
882
               - dst->symbol.section->vma);
4787
882
#endif
4788
882
      if (ISFCN ((src->u.syment.n_type)))
4789
        /* A function ext does not go at the end of a
4790
           file.  */
4791
8
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4792
882
      break;
4793
4794
95
    case COFF_SYMBOL_COMMON:
4795
95
      dst->symbol.section = bfd_com_section_ptr;
4796
95
      dst->symbol.value = src->u.syment.n_value;
4797
95
      break;
4798
4799
17
    case COFF_SYMBOL_UNDEFINED:
4800
17
      dst->symbol.section = bfd_und_section_ptr;
4801
17
      dst->symbol.value = 0;
4802
17
      break;
4803
4804
0
    case COFF_SYMBOL_PE_SECTION:
4805
0
      dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM;
4806
0
      dst->symbol.value = 0;
4807
0
      break;
4808
4809
0
    case COFF_SYMBOL_LOCAL:
4810
0
      dst->symbol.flags = BSF_LOCAL;
4811
#if defined COFF_WITH_PE
4812
      /* PE sets the symbol to a value relative to the
4813
         start of the section.  */
4814
      dst->symbol.value = src->u.syment.n_value;
4815
#else
4816
0
      dst->symbol.value = (src->u.syment.n_value
4817
0
               - dst->symbol.section->vma);
4818
0
#endif
4819
0
      if (ISFCN ((src->u.syment.n_type)))
4820
0
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4821
0
      break;
4822
994
    }
4823
4824
#ifdef RS6000COFF_C
4825
        /* A symbol with a csect entry should not go at the end.  */
4826
        if (src->u.syment.n_numaux > 0)
4827
    dst->symbol.flags |= BSF_NOT_AT_END;
4828
#endif
4829
4830
#ifdef COFF_WITH_PE
4831
        if (src->u.syment.n_sclass == C_NT_WEAK)
4832
    dst->symbol.flags |= BSF_WEAK;
4833
4834
        if (src->u.syment.n_sclass == C_SECTION
4835
      && src->u.syment.n_scnum > 0)
4836
    dst->symbol.flags = BSF_LOCAL;
4837
#endif
4838
994
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
#ifdef RS6000COFF_C
4840
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
#endif
4842
994
      )
4843
30
    dst->symbol.flags |= BSF_WEAK;
4844
4845
994
        break;
4846
4847
440
      case C_STAT:  /* Static.  */
4848
#if defined ARM
4849
      case C_THUMBSTAT:    /* Thumb static.  */
4850
      case C_THUMBLABEL:   /* Thumb label.  */
4851
      case C_THUMBSTATFUNC:/* Thumb static function.  */
4852
#endif
4853
#ifdef RS6000COFF_C
4854
      case C_DWARF:  /* A label in a dwarf section.  */
4855
      case C_INFO:   /* A label in a comment section.  */
4856
#endif
4857
1.27k
      case C_LABEL:  /* Label.  */
4858
1.27k
        if (src->u.syment.n_scnum == N_DEBUG)
4859
0
    dst->symbol.flags = BSF_DEBUGGING;
4860
1.27k
        else
4861
1.27k
    dst->symbol.flags = BSF_LOCAL;
4862
4863
        /* Base the value as an index from the base of the
4864
     section, if there is one.  */
4865
1.27k
        if (dst->symbol.section)
4866
1.27k
    {
4867
#if defined COFF_WITH_PE
4868
      /* PE sets the symbol to a value relative to the
4869
         start of the section.  */
4870
      dst->symbol.value = src->u.syment.n_value;
4871
#else
4872
1.27k
      dst->symbol.value = (src->u.syment.n_value
4873
1.27k
               - dst->symbol.section->vma);
4874
1.27k
#endif
4875
1.27k
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
1.27k
        break;
4879
4880
447
      case C_FILE: /* File name.  */
4881
447
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
503
      case C_MOS:   /* Member of structure.  */
4884
732
      case C_EOS:   /* End of structure.  */
4885
800
      case C_REGPARM: /* Register parameter.  */
4886
927
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
1.01k
      case C_TPDEF: /* Type definition.  */
4889
1.21k
      case C_ARG:
4890
3.14k
      case C_AUTO: /* Automatic variable.  */
4891
3.23k
      case C_FIELD: /* Bit field.  */
4892
3.29k
      case C_ENTAG: /* Enumeration tag.  */
4893
3.46k
      case C_MOE:   /* Member of enumeration.  */
4894
3.49k
      case C_MOU:   /* Member of union.  */
4895
3.52k
      case C_UNTAG: /* Union tag.  */
4896
3.59k
      case C_STRTAG: /* Structure tag.  */
4897
#ifdef RS6000COFF_C
4898
      case C_GSYM:
4899
      case C_LSYM:
4900
      case C_PSYM:
4901
      case C_RSYM:
4902
      case C_RPSYM:
4903
      case C_STSYM:
4904
      case C_TCSYM:
4905
      case C_BCOMM:
4906
      case C_ECOML:
4907
      case C_ECOMM:
4908
      case C_DECL:
4909
      case C_ENTRY:
4910
      case C_FUN:
4911
      case C_ESTAT:
4912
#endif
4913
3.59k
        dst->symbol.flags |= BSF_DEBUGGING;
4914
3.59k
        dst->symbol.value = (src->u.syment.n_value);
4915
3.59k
        break;
4916
4917
#ifdef RS6000COFF_C
4918
      case C_BINCL: /* Beginning of include file.  */
4919
      case C_EINCL: /* Ending of include file.  */
4920
        /* The value is actually a pointer into the line numbers
4921
     of the file.  We locate the line number entry, and
4922
     set the section to the section which contains it, and
4923
     the value to the index in that section.  */
4924
        {
4925
    asection *sec;
4926
4927
    dst->symbol.flags = BSF_DEBUGGING;
4928
    for (sec = abfd->sections; sec != NULL; sec = sec->next)
4929
      if (sec->line_filepos <= (file_ptr) src->u.syment.n_value
4930
          && ((file_ptr) (sec->line_filepos
4931
              + sec->lineno_count * bfd_coff_linesz (abfd))
4932
        > (file_ptr) src->u.syment.n_value))
4933
        break;
4934
    if (sec == NULL)
4935
      dst->symbol.value = 0;
4936
    else
4937
      {
4938
        dst->symbol.section = sec;
4939
        dst->symbol.value = ((src->u.syment.n_value
4940
            - sec->line_filepos)
4941
           / bfd_coff_linesz (abfd));
4942
        src->fix_line = 1;
4943
      }
4944
        }
4945
        break;
4946
4947
      case C_BSTAT:
4948
        dst->symbol.flags = BSF_DEBUGGING;
4949
4950
        if (src->u.syment.n_value >= obj_raw_syment_count (abfd))
4951
    dst->symbol.value = 0;
4952
        else
4953
    {
4954
      /* The value is actually a symbol index.  Save a pointer
4955
         to the symbol instead of the index.  FIXME: This
4956
         should use a union.  */
4957
      src->u.syment.n_value
4958
        = (uintptr_t) (native_symbols + src->u.syment.n_value);
4959
      dst->symbol.value = src->u.syment.n_value;
4960
      src->fix_value = 1;
4961
    }
4962
        break;
4963
#endif
4964
4965
90
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
1.29k
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
1.44k
      case C_EFCN: /* Physical end of function.  */
4968
#if defined COFF_WITH_PE
4969
        /* PE sets the symbol to a value relative to the start
4970
     of the section.  */
4971
        dst->symbol.value = src->u.syment.n_value;
4972
        if (strcmp (dst->symbol.name, ".bf") != 0)
4973
    {
4974
      /* PE uses funny values for .ef and .lf; don't
4975
         relocate them.  */
4976
      dst->symbol.flags = BSF_DEBUGGING;
4977
    }
4978
        else
4979
    dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC;
4980
#else
4981
        /* Base the value as an index from the base of the
4982
     section.  */
4983
1.44k
        dst->symbol.flags = BSF_LOCAL;
4984
1.44k
        dst->symbol.value = (src->u.syment.n_value
4985
1.44k
           - dst->symbol.section->vma);
4986
1.44k
#endif
4987
1.44k
        break;
4988
4989
55
      case C_STATLAB: /* Static load time label.  */
4990
55
        dst->symbol.value = src->u.syment.n_value;
4991
55
        dst->symbol.flags = BSF_GLOBAL;
4992
55
        break;
4993
4994
27.1k
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
27.1k
        if (src->u.syment.n_type == 0
4998
27.1k
      && src->u.syment.n_value == 0
4999
27.1k
      && src->u.syment.n_scnum == 0)
5000
4.38k
    break;
5001
#ifdef RS6000COFF_C
5002
        /* XCOFF specific: deleted entry.  */
5003
        if (src->u.syment.n_value == C_NULL_VALUE)
5004
    break;
5005
#endif
5006
        /* Fall through.  */
5007
22.8k
      case C_EXTDEF: /* External definition.  */
5008
22.8k
      case C_ULABEL: /* Undefined label.  */
5009
22.8k
      case C_USTATIC: /* Undefined static.  */
5010
22.8k
#ifndef COFF_WITH_PE
5011
      /* C_LINE in regular coff is 0x68.  NT has taken over this storage
5012
         class to represent a section symbol.  */
5013
23.4k
      case C_LINE: /* line # reformatted as symbol table entry.  */
5014
        /* NT uses 0x67 for a weak symbol, not C_ALIAS.  */
5015
24.1k
      case C_ALIAS: /* Duplicate tag.  */
5016
24.1k
#endif
5017
        /* New storage classes for TI COFF.  */
5018
#ifdef TICOFF
5019
      case C_UEXT:  /* Tentative external definition.  */
5020
#endif
5021
24.1k
      case C_EXTLAB: /* External load time label.  */
5022
34.8k
      default:
5023
34.8k
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
34.8k
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
34.8k
     abfd, src->u.syment.n_sclass,
5027
34.8k
     dst->symbol.section->name, dst->symbol.name);
5028
34.8k
        ret = false;
5029
        /* Fall through.  */
5030
34.9k
      case C_HIDDEN: /* Ext symbol in dmert public lib.  */
5031
        /* PR 20722: These symbols can also be generated by
5032
     building DLLs with --gc-sections enabled.  */
5033
34.9k
        dst->symbol.flags = BSF_DEBUGGING;
5034
34.9k
        dst->symbol.value = (src->u.syment.n_value);
5035
34.9k
        break;
5036
46.6k
      }
5037
5038
46.6k
    dst->native = src;
5039
46.6k
    dst->symbol.udata.i = 0;
5040
46.6k
    dst->lineno = NULL;
5041
5042
46.6k
    this_index += (src->u.syment.n_numaux) + 1;
5043
46.6k
    dst++;
5044
46.6k
    number_of_symbols++;
5045
46.6k
  }
5046
259
    }
5047
5048
259
  obj_symbols (abfd) = cached_area;
5049
259
  obj_raw_syments (abfd) = native_symbols;
5050
5051
259
  abfd->symcount = number_of_symbols;
5052
259
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
259
  {
5055
259
    asection *p;
5056
5057
259
    p = abfd->sections;
5058
1.12k
    while (p)
5059
1.07k
      {
5060
1.07k
  if (! coff_slurp_line_table (abfd, p))
5061
211
    return false;
5062
868
  p = p->next;
5063
868
      }
5064
259
  }
5065
5066
48
  return ret;
5067
259
}
Unexecuted instantiation: coff-stgo32.c:coff_slurp_symbol_table
coff-tic30.c:coff_slurp_symbol_table
Line
Count
Source
4695
572
{
4696
572
  combined_entry_type *native_symbols;
4697
572
  coff_symbol_type *cached_area;
4698
572
  unsigned int *table_ptr;
4699
572
  unsigned int number_of_symbols = 0;
4700
572
  bool ret = true;
4701
572
  size_t amt;
4702
4703
572
  if (obj_symbols (abfd))
4704
83
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
489
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
179
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
310
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
310
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
310
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
310
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
310
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
310
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
310
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
310
  if (table_ptr == NULL)
4729
0
    return false;
4730
310
  else
4731
310
    {
4732
310
      coff_symbol_type *dst = cached_area;
4733
310
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
310
      unsigned int this_index = 0;
4735
4736
37.2k
      while (this_index < last_native_index)
4737
36.9k
  {
4738
36.9k
    combined_entry_type *src = native_symbols + this_index;
4739
36.9k
    table_ptr[this_index] = number_of_symbols;
4740
4741
36.9k
    dst->symbol.the_bfd = abfd;
4742
36.9k
    BFD_ASSERT (src->is_sym);
4743
36.9k
    dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset);
4744
    /* We use the native name field to point to the cached field.  */
4745
36.9k
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
36.9k
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
36.9k
                 src->u.syment.n_scnum);
4748
36.9k
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
36.9k
    dst->symbol.value = 0;
4751
36.9k
    dst->done_lineno = false;
4752
4753
36.9k
    switch (src->u.syment.n_sclass)
4754
36.9k
      {
4755
506
      case C_EXT:
4756
560
      case C_WEAKEXT:
4757
#if defined ARM
4758
      case C_THUMBEXT:
4759
      case C_THUMBEXTFUNC:
4760
#endif
4761
#ifdef RS6000COFF_C
4762
      case C_HIDEXT:
4763
#ifndef AIX_WEAK_SUPPORT
4764
      case C_AIX_WEAKEXT:
4765
#endif
4766
#endif
4767
560
#ifdef C_SYSTEM
4768
666
      case C_SYSTEM: /* System Wide variable.  */
4769
666
#endif
4770
#ifdef COFF_WITH_PE
4771
      /* In PE, 0x68 (104) denotes a section symbol.  */
4772
      case C_SECTION:
4773
      /* In PE, 0x69 (105) denotes a weak external symbol.  */
4774
      case C_NT_WEAK:
4775
#endif
4776
666
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
666
    {
4778
580
    case COFF_SYMBOL_GLOBAL:
4779
580
      dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
4780
#if defined COFF_WITH_PE
4781
      /* PE sets the symbol to a value relative to the
4782
         start of the section.  */
4783
      dst->symbol.value = src->u.syment.n_value;
4784
#else
4785
580
      dst->symbol.value = (src->u.syment.n_value
4786
580
               - dst->symbol.section->vma);
4787
580
#endif
4788
580
      if (ISFCN ((src->u.syment.n_type)))
4789
        /* A function ext does not go at the end of a
4790
           file.  */
4791
19
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4792
580
      break;
4793
4794
77
    case COFF_SYMBOL_COMMON:
4795
77
      dst->symbol.section = bfd_com_section_ptr;
4796
77
      dst->symbol.value = src->u.syment.n_value;
4797
77
      break;
4798
4799
9
    case COFF_SYMBOL_UNDEFINED:
4800
9
      dst->symbol.section = bfd_und_section_ptr;
4801
9
      dst->symbol.value = 0;
4802
9
      break;
4803
4804
0
    case COFF_SYMBOL_PE_SECTION:
4805
0
      dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM;
4806
0
      dst->symbol.value = 0;
4807
0
      break;
4808
4809
0
    case COFF_SYMBOL_LOCAL:
4810
0
      dst->symbol.flags = BSF_LOCAL;
4811
#if defined COFF_WITH_PE
4812
      /* PE sets the symbol to a value relative to the
4813
         start of the section.  */
4814
      dst->symbol.value = src->u.syment.n_value;
4815
#else
4816
0
      dst->symbol.value = (src->u.syment.n_value
4817
0
               - dst->symbol.section->vma);
4818
0
#endif
4819
0
      if (ISFCN ((src->u.syment.n_type)))
4820
0
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4821
0
      break;
4822
666
    }
4823
4824
#ifdef RS6000COFF_C
4825
        /* A symbol with a csect entry should not go at the end.  */
4826
        if (src->u.syment.n_numaux > 0)
4827
    dst->symbol.flags |= BSF_NOT_AT_END;
4828
#endif
4829
4830
#ifdef COFF_WITH_PE
4831
        if (src->u.syment.n_sclass == C_NT_WEAK)
4832
    dst->symbol.flags |= BSF_WEAK;
4833
4834
        if (src->u.syment.n_sclass == C_SECTION
4835
      && src->u.syment.n_scnum > 0)
4836
    dst->symbol.flags = BSF_LOCAL;
4837
#endif
4838
666
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
#ifdef RS6000COFF_C
4840
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
#endif
4842
666
      )
4843
54
    dst->symbol.flags |= BSF_WEAK;
4844
4845
666
        break;
4846
4847
200
      case C_STAT:  /* Static.  */
4848
#if defined ARM
4849
      case C_THUMBSTAT:    /* Thumb static.  */
4850
      case C_THUMBLABEL:   /* Thumb label.  */
4851
      case C_THUMBSTATFUNC:/* Thumb static function.  */
4852
#endif
4853
#ifdef RS6000COFF_C
4854
      case C_DWARF:  /* A label in a dwarf section.  */
4855
      case C_INFO:   /* A label in a comment section.  */
4856
#endif
4857
319
      case C_LABEL:  /* Label.  */
4858
319
        if (src->u.syment.n_scnum == N_DEBUG)
4859
0
    dst->symbol.flags = BSF_DEBUGGING;
4860
319
        else
4861
319
    dst->symbol.flags = BSF_LOCAL;
4862
4863
        /* Base the value as an index from the base of the
4864
     section, if there is one.  */
4865
319
        if (dst->symbol.section)
4866
319
    {
4867
#if defined COFF_WITH_PE
4868
      /* PE sets the symbol to a value relative to the
4869
         start of the section.  */
4870
      dst->symbol.value = src->u.syment.n_value;
4871
#else
4872
319
      dst->symbol.value = (src->u.syment.n_value
4873
319
               - dst->symbol.section->vma);
4874
319
#endif
4875
319
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
319
        break;
4879
4880
192
      case C_FILE: /* File name.  */
4881
192
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
277
      case C_MOS:   /* Member of structure.  */
4884
370
      case C_EOS:   /* End of structure.  */
4885
440
      case C_REGPARM: /* Register parameter.  */
4886
953
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
1.01k
      case C_TPDEF: /* Type definition.  */
4889
1.08k
      case C_ARG:
4890
2.84k
      case C_AUTO: /* Automatic variable.  */
4891
2.99k
      case C_FIELD: /* Bit field.  */
4892
3.04k
      case C_ENTAG: /* Enumeration tag.  */
4893
3.21k
      case C_MOE:   /* Member of enumeration.  */
4894
3.31k
      case C_MOU:   /* Member of union.  */
4895
3.42k
      case C_UNTAG: /* Union tag.  */
4896
3.60k
      case C_STRTAG: /* Structure tag.  */
4897
#ifdef RS6000COFF_C
4898
      case C_GSYM:
4899
      case C_LSYM:
4900
      case C_PSYM:
4901
      case C_RSYM:
4902
      case C_RPSYM:
4903
      case C_STSYM:
4904
      case C_TCSYM:
4905
      case C_BCOMM:
4906
      case C_ECOML:
4907
      case C_ECOMM:
4908
      case C_DECL:
4909
      case C_ENTRY:
4910
      case C_FUN:
4911
      case C_ESTAT:
4912
#endif
4913
3.60k
        dst->symbol.flags |= BSF_DEBUGGING;
4914
3.60k
        dst->symbol.value = (src->u.syment.n_value);
4915
3.60k
        break;
4916
4917
#ifdef RS6000COFF_C
4918
      case C_BINCL: /* Beginning of include file.  */
4919
      case C_EINCL: /* Ending of include file.  */
4920
        /* The value is actually a pointer into the line numbers
4921
     of the file.  We locate the line number entry, and
4922
     set the section to the section which contains it, and
4923
     the value to the index in that section.  */
4924
        {
4925
    asection *sec;
4926
4927
    dst->symbol.flags = BSF_DEBUGGING;
4928
    for (sec = abfd->sections; sec != NULL; sec = sec->next)
4929
      if (sec->line_filepos <= (file_ptr) src->u.syment.n_value
4930
          && ((file_ptr) (sec->line_filepos
4931
              + sec->lineno_count * bfd_coff_linesz (abfd))
4932
        > (file_ptr) src->u.syment.n_value))
4933
        break;
4934
    if (sec == NULL)
4935
      dst->symbol.value = 0;
4936
    else
4937
      {
4938
        dst->symbol.section = sec;
4939
        dst->symbol.value = ((src->u.syment.n_value
4940
            - sec->line_filepos)
4941
           / bfd_coff_linesz (abfd));
4942
        src->fix_line = 1;
4943
      }
4944
        }
4945
        break;
4946
4947
      case C_BSTAT:
4948
        dst->symbol.flags = BSF_DEBUGGING;
4949
4950
        if (src->u.syment.n_value >= obj_raw_syment_count (abfd))
4951
    dst->symbol.value = 0;
4952
        else
4953
    {
4954
      /* The value is actually a symbol index.  Save a pointer
4955
         to the symbol instead of the index.  FIXME: This
4956
         should use a union.  */
4957
      src->u.syment.n_value
4958
        = (uintptr_t) (native_symbols + src->u.syment.n_value);
4959
      dst->symbol.value = src->u.syment.n_value;
4960
      src->fix_value = 1;
4961
    }
4962
        break;
4963
#endif
4964
4965
108
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
614
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
767
      case C_EFCN: /* Physical end of function.  */
4968
#if defined COFF_WITH_PE
4969
        /* PE sets the symbol to a value relative to the start
4970
     of the section.  */
4971
        dst->symbol.value = src->u.syment.n_value;
4972
        if (strcmp (dst->symbol.name, ".bf") != 0)
4973
    {
4974
      /* PE uses funny values for .ef and .lf; don't
4975
         relocate them.  */
4976
      dst->symbol.flags = BSF_DEBUGGING;
4977
    }
4978
        else
4979
    dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC;
4980
#else
4981
        /* Base the value as an index from the base of the
4982
     section.  */
4983
767
        dst->symbol.flags = BSF_LOCAL;
4984
767
        dst->symbol.value = (src->u.syment.n_value
4985
767
           - dst->symbol.section->vma);
4986
767
#endif
4987
767
        break;
4988
4989
226
      case C_STATLAB: /* Static load time label.  */
4990
226
        dst->symbol.value = src->u.syment.n_value;
4991
226
        dst->symbol.flags = BSF_GLOBAL;
4992
226
        break;
4993
4994
23.2k
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
23.2k
        if (src->u.syment.n_type == 0
4998
23.2k
      && src->u.syment.n_value == 0
4999
23.2k
      && src->u.syment.n_scnum == 0)
5000
5.17k
    break;
5001
#ifdef RS6000COFF_C
5002
        /* XCOFF specific: deleted entry.  */
5003
        if (src->u.syment.n_value == C_NULL_VALUE)
5004
    break;
5005
#endif
5006
        /* Fall through.  */
5007
18.0k
      case C_EXTDEF: /* External definition.  */
5008
18.1k
      case C_ULABEL: /* Undefined label.  */
5009
18.1k
      case C_USTATIC: /* Undefined static.  */
5010
18.1k
#ifndef COFF_WITH_PE
5011
      /* C_LINE in regular coff is 0x68.  NT has taken over this storage
5012
         class to represent a section symbol.  */
5013
18.4k
      case C_LINE: /* line # reformatted as symbol table entry.  */
5014
        /* NT uses 0x67 for a weak symbol, not C_ALIAS.  */
5015
18.6k
      case C_ALIAS: /* Duplicate tag.  */
5016
18.6k
#endif
5017
        /* New storage classes for TI COFF.  */
5018
#ifdef TICOFF
5019
      case C_UEXT:  /* Tentative external definition.  */
5020
#endif
5021
18.6k
      case C_EXTLAB: /* External load time label.  */
5022
26.1k
      default:
5023
26.1k
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
26.1k
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
26.1k
     abfd, src->u.syment.n_sclass,
5027
26.1k
     dst->symbol.section->name, dst->symbol.name);
5028
26.1k
        ret = false;
5029
        /* Fall through.  */
5030
26.1k
      case C_HIDDEN: /* Ext symbol in dmert public lib.  */
5031
        /* PR 20722: These symbols can also be generated by
5032
     building DLLs with --gc-sections enabled.  */
5033
26.1k
        dst->symbol.flags = BSF_DEBUGGING;
5034
26.1k
        dst->symbol.value = (src->u.syment.n_value);
5035
26.1k
        break;
5036
36.9k
      }
5037
5038
36.9k
    dst->native = src;
5039
36.9k
    dst->symbol.udata.i = 0;
5040
36.9k
    dst->lineno = NULL;
5041
5042
36.9k
    this_index += (src->u.syment.n_numaux) + 1;
5043
36.9k
    dst++;
5044
36.9k
    number_of_symbols++;
5045
36.9k
  }
5046
310
    }
5047
5048
310
  obj_symbols (abfd) = cached_area;
5049
310
  obj_raw_syments (abfd) = native_symbols;
5050
5051
310
  abfd->symcount = number_of_symbols;
5052
310
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
310
  {
5055
310
    asection *p;
5056
5057
310
    p = abfd->sections;
5058
1.51k
    while (p)
5059
1.45k
      {
5060
1.45k
  if (! coff_slurp_line_table (abfd, p))
5061
256
    return false;
5062
1.20k
  p = p->next;
5063
1.20k
      }
5064
310
  }
5065
5066
54
  return ret;
5067
310
}
Unexecuted instantiation: coff-tic4x.c:coff_slurp_symbol_table
coff-tic54x.c:coff_slurp_symbol_table
Line
Count
Source
4695
438
{
4696
438
  combined_entry_type *native_symbols;
4697
438
  coff_symbol_type *cached_area;
4698
438
  unsigned int *table_ptr;
4699
438
  unsigned int number_of_symbols = 0;
4700
438
  bool ret = true;
4701
438
  size_t amt;
4702
4703
438
  if (obj_symbols (abfd))
4704
6
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
432
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
200
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
232
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
232
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
232
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
232
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
232
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
232
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
232
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
232
  if (table_ptr == NULL)
4729
0
    return false;
4730
232
  else
4731
232
    {
4732
232
      coff_symbol_type *dst = cached_area;
4733
232
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
232
      unsigned int this_index = 0;
4735
4736
82.2k
      while (this_index < last_native_index)
4737
81.9k
  {
4738
81.9k
    combined_entry_type *src = native_symbols + this_index;
4739
81.9k
    table_ptr[this_index] = number_of_symbols;
4740
4741
81.9k
    dst->symbol.the_bfd = abfd;
4742
81.9k
    BFD_ASSERT (src->is_sym);
4743
81.9k
    dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset);
4744
    /* We use the native name field to point to the cached field.  */
4745
81.9k
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
81.9k
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
81.9k
                 src->u.syment.n_scnum);
4748
81.9k
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
81.9k
    dst->symbol.value = 0;
4751
81.9k
    dst->done_lineno = false;
4752
4753
81.9k
    switch (src->u.syment.n_sclass)
4754
81.9k
      {
4755
1.88k
      case C_EXT:
4756
1.96k
      case C_WEAKEXT:
4757
#if defined ARM
4758
      case C_THUMBEXT:
4759
      case C_THUMBEXTFUNC:
4760
#endif
4761
#ifdef RS6000COFF_C
4762
      case C_HIDEXT:
4763
#ifndef AIX_WEAK_SUPPORT
4764
      case C_AIX_WEAKEXT:
4765
#endif
4766
#endif
4767
1.96k
#ifdef C_SYSTEM
4768
2.27k
      case C_SYSTEM: /* System Wide variable.  */
4769
2.27k
#endif
4770
#ifdef COFF_WITH_PE
4771
      /* In PE, 0x68 (104) denotes a section symbol.  */
4772
      case C_SECTION:
4773
      /* In PE, 0x69 (105) denotes a weak external symbol.  */
4774
      case C_NT_WEAK:
4775
#endif
4776
2.27k
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
2.27k
    {
4778
1.76k
    case COFF_SYMBOL_GLOBAL:
4779
1.76k
      dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
4780
#if defined COFF_WITH_PE
4781
      /* PE sets the symbol to a value relative to the
4782
         start of the section.  */
4783
      dst->symbol.value = src->u.syment.n_value;
4784
#else
4785
1.76k
      dst->symbol.value = (src->u.syment.n_value
4786
1.76k
               - dst->symbol.section->vma);
4787
1.76k
#endif
4788
1.76k
      if (ISFCN ((src->u.syment.n_type)))
4789
        /* A function ext does not go at the end of a
4790
           file.  */
4791
23
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4792
1.76k
      break;
4793
4794
413
    case COFF_SYMBOL_COMMON:
4795
413
      dst->symbol.section = bfd_com_section_ptr;
4796
413
      dst->symbol.value = src->u.syment.n_value;
4797
413
      break;
4798
4799
106
    case COFF_SYMBOL_UNDEFINED:
4800
106
      dst->symbol.section = bfd_und_section_ptr;
4801
106
      dst->symbol.value = 0;
4802
106
      break;
4803
4804
0
    case COFF_SYMBOL_PE_SECTION:
4805
0
      dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM;
4806
0
      dst->symbol.value = 0;
4807
0
      break;
4808
4809
0
    case COFF_SYMBOL_LOCAL:
4810
0
      dst->symbol.flags = BSF_LOCAL;
4811
#if defined COFF_WITH_PE
4812
      /* PE sets the symbol to a value relative to the
4813
         start of the section.  */
4814
      dst->symbol.value = src->u.syment.n_value;
4815
#else
4816
0
      dst->symbol.value = (src->u.syment.n_value
4817
0
               - dst->symbol.section->vma);
4818
0
#endif
4819
0
      if (ISFCN ((src->u.syment.n_type)))
4820
0
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4821
0
      break;
4822
2.27k
    }
4823
4824
#ifdef RS6000COFF_C
4825
        /* A symbol with a csect entry should not go at the end.  */
4826
        if (src->u.syment.n_numaux > 0)
4827
    dst->symbol.flags |= BSF_NOT_AT_END;
4828
#endif
4829
4830
#ifdef COFF_WITH_PE
4831
        if (src->u.syment.n_sclass == C_NT_WEAK)
4832
    dst->symbol.flags |= BSF_WEAK;
4833
4834
        if (src->u.syment.n_sclass == C_SECTION
4835
      && src->u.syment.n_scnum > 0)
4836
    dst->symbol.flags = BSF_LOCAL;
4837
#endif
4838
2.27k
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
#ifdef RS6000COFF_C
4840
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
#endif
4842
2.27k
      )
4843
85
    dst->symbol.flags |= BSF_WEAK;
4844
4845
2.27k
        break;
4846
4847
868
      case C_STAT:  /* Static.  */
4848
#if defined ARM
4849
      case C_THUMBSTAT:    /* Thumb static.  */
4850
      case C_THUMBLABEL:   /* Thumb label.  */
4851
      case C_THUMBSTATFUNC:/* Thumb static function.  */
4852
#endif
4853
#ifdef RS6000COFF_C
4854
      case C_DWARF:  /* A label in a dwarf section.  */
4855
      case C_INFO:   /* A label in a comment section.  */
4856
#endif
4857
2.05k
      case C_LABEL:  /* Label.  */
4858
2.05k
        if (src->u.syment.n_scnum == N_DEBUG)
4859
0
    dst->symbol.flags = BSF_DEBUGGING;
4860
2.05k
        else
4861
2.05k
    dst->symbol.flags = BSF_LOCAL;
4862
4863
        /* Base the value as an index from the base of the
4864
     section, if there is one.  */
4865
2.05k
        if (dst->symbol.section)
4866
2.05k
    {
4867
#if defined COFF_WITH_PE
4868
      /* PE sets the symbol to a value relative to the
4869
         start of the section.  */
4870
      dst->symbol.value = src->u.syment.n_value;
4871
#else
4872
2.05k
      dst->symbol.value = (src->u.syment.n_value
4873
2.05k
               - dst->symbol.section->vma);
4874
2.05k
#endif
4875
2.05k
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
2.05k
        break;
4879
4880
494
      case C_FILE: /* File name.  */
4881
494
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
762
      case C_MOS:   /* Member of structure.  */
4884
939
      case C_EOS:   /* End of structure.  */
4885
1.14k
      case C_REGPARM: /* Register parameter.  */
4886
1.66k
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
1.89k
      case C_TPDEF: /* Type definition.  */
4889
2.39k
      case C_ARG:
4890
5.99k
      case C_AUTO: /* Automatic variable.  */
4891
6.26k
      case C_FIELD: /* Bit field.  */
4892
6.51k
      case C_ENTAG: /* Enumeration tag.  */
4893
7.23k
      case C_MOE:   /* Member of enumeration.  */
4894
7.72k
      case C_MOU:   /* Member of union.  */
4895
8.55k
      case C_UNTAG: /* Union tag.  */
4896
8.86k
      case C_STRTAG: /* Structure tag.  */
4897
#ifdef RS6000COFF_C
4898
      case C_GSYM:
4899
      case C_LSYM:
4900
      case C_PSYM:
4901
      case C_RSYM:
4902
      case C_RPSYM:
4903
      case C_STSYM:
4904
      case C_TCSYM:
4905
      case C_BCOMM:
4906
      case C_ECOML:
4907
      case C_ECOMM:
4908
      case C_DECL:
4909
      case C_ENTRY:
4910
      case C_FUN:
4911
      case C_ESTAT:
4912
#endif
4913
8.86k
        dst->symbol.flags |= BSF_DEBUGGING;
4914
8.86k
        dst->symbol.value = (src->u.syment.n_value);
4915
8.86k
        break;
4916
4917
#ifdef RS6000COFF_C
4918
      case C_BINCL: /* Beginning of include file.  */
4919
      case C_EINCL: /* Ending of include file.  */
4920
        /* The value is actually a pointer into the line numbers
4921
     of the file.  We locate the line number entry, and
4922
     set the section to the section which contains it, and
4923
     the value to the index in that section.  */
4924
        {
4925
    asection *sec;
4926
4927
    dst->symbol.flags = BSF_DEBUGGING;
4928
    for (sec = abfd->sections; sec != NULL; sec = sec->next)
4929
      if (sec->line_filepos <= (file_ptr) src->u.syment.n_value
4930
          && ((file_ptr) (sec->line_filepos
4931
              + sec->lineno_count * bfd_coff_linesz (abfd))
4932
        > (file_ptr) src->u.syment.n_value))
4933
        break;
4934
    if (sec == NULL)
4935
      dst->symbol.value = 0;
4936
    else
4937
      {
4938
        dst->symbol.section = sec;
4939
        dst->symbol.value = ((src->u.syment.n_value
4940
            - sec->line_filepos)
4941
           / bfd_coff_linesz (abfd));
4942
        src->fix_line = 1;
4943
      }
4944
        }
4945
        break;
4946
4947
      case C_BSTAT:
4948
        dst->symbol.flags = BSF_DEBUGGING;
4949
4950
        if (src->u.syment.n_value >= obj_raw_syment_count (abfd))
4951
    dst->symbol.value = 0;
4952
        else
4953
    {
4954
      /* The value is actually a symbol index.  Save a pointer
4955
         to the symbol instead of the index.  FIXME: This
4956
         should use a union.  */
4957
      src->u.syment.n_value
4958
        = (uintptr_t) (native_symbols + src->u.syment.n_value);
4959
      dst->symbol.value = src->u.syment.n_value;
4960
      src->fix_value = 1;
4961
    }
4962
        break;
4963
#endif
4964
4965
163
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
1.10k
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
1.62k
      case C_EFCN: /* Physical end of function.  */
4968
#if defined COFF_WITH_PE
4969
        /* PE sets the symbol to a value relative to the start
4970
     of the section.  */
4971
        dst->symbol.value = src->u.syment.n_value;
4972
        if (strcmp (dst->symbol.name, ".bf") != 0)
4973
    {
4974
      /* PE uses funny values for .ef and .lf; don't
4975
         relocate them.  */
4976
      dst->symbol.flags = BSF_DEBUGGING;
4977
    }
4978
        else
4979
    dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC;
4980
#else
4981
        /* Base the value as an index from the base of the
4982
     section.  */
4983
1.62k
        dst->symbol.flags = BSF_LOCAL;
4984
1.62k
        dst->symbol.value = (src->u.syment.n_value
4985
1.62k
           - dst->symbol.section->vma);
4986
1.62k
#endif
4987
1.62k
        break;
4988
4989
169
      case C_STATLAB: /* Static load time label.  */
4990
169
        dst->symbol.value = src->u.syment.n_value;
4991
169
        dst->symbol.flags = BSF_GLOBAL;
4992
169
        break;
4993
4994
49.3k
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
49.3k
        if (src->u.syment.n_type == 0
4998
49.3k
      && src->u.syment.n_value == 0
4999
49.3k
      && src->u.syment.n_scnum == 0)
5000
12.6k
    break;
5001
#ifdef RS6000COFF_C
5002
        /* XCOFF specific: deleted entry.  */
5003
        if (src->u.syment.n_value == C_NULL_VALUE)
5004
    break;
5005
#endif
5006
        /* Fall through.  */
5007
36.8k
      case C_EXTDEF: /* External definition.  */
5008
37.0k
      case C_ULABEL: /* Undefined label.  */
5009
37.1k
      case C_USTATIC: /* Undefined static.  */
5010
37.1k
#ifndef COFF_WITH_PE
5011
      /* C_LINE in regular coff is 0x68.  NT has taken over this storage
5012
         class to represent a section symbol.  */
5013
37.4k
      case C_LINE: /* line # reformatted as symbol table entry.  */
5014
        /* NT uses 0x67 for a weak symbol, not C_ALIAS.  */
5015
38.0k
      case C_ALIAS: /* Duplicate tag.  */
5016
38.0k
#endif
5017
        /* New storage classes for TI COFF.  */
5018
38.0k
#ifdef TICOFF
5019
38.1k
      case C_UEXT: /* Tentative external definition.  */
5020
38.1k
#endif
5021
38.1k
      case C_EXTLAB: /* External load time label.  */
5022
54.2k
      default:
5023
54.2k
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
54.2k
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
54.2k
     abfd, src->u.syment.n_sclass,
5027
54.2k
     dst->symbol.section->name, dst->symbol.name);
5028
54.2k
        ret = false;
5029
        /* Fall through.  */
5030
54.3k
      case C_HIDDEN: /* Ext symbol in dmert public lib.  */
5031
        /* PR 20722: These symbols can also be generated by
5032
     building DLLs with --gc-sections enabled.  */
5033
54.3k
        dst->symbol.flags = BSF_DEBUGGING;
5034
54.3k
        dst->symbol.value = (src->u.syment.n_value);
5035
54.3k
        break;
5036
81.9k
      }
5037
5038
81.9k
    dst->native = src;
5039
81.9k
    dst->symbol.udata.i = 0;
5040
81.9k
    dst->lineno = NULL;
5041
5042
81.9k
    this_index += (src->u.syment.n_numaux) + 1;
5043
81.9k
    dst++;
5044
81.9k
    number_of_symbols++;
5045
81.9k
  }
5046
232
    }
5047
5048
232
  obj_symbols (abfd) = cached_area;
5049
232
  obj_raw_syments (abfd) = native_symbols;
5050
5051
232
  abfd->symcount = number_of_symbols;
5052
232
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
232
  {
5055
232
    asection *p;
5056
5057
232
    p = abfd->sections;
5058
898
    while (p)
5059
864
      {
5060
864
  if (! coff_slurp_line_table (abfd, p))
5061
198
    return false;
5062
666
  p = p->next;
5063
666
      }
5064
232
  }
5065
5066
34
  return ret;
5067
232
}
coff-z80.c:coff_slurp_symbol_table
Line
Count
Source
4695
349
{
4696
349
  combined_entry_type *native_symbols;
4697
349
  coff_symbol_type *cached_area;
4698
349
  unsigned int *table_ptr;
4699
349
  unsigned int number_of_symbols = 0;
4700
349
  bool ret = true;
4701
349
  size_t amt;
4702
4703
349
  if (obj_symbols (abfd))
4704
13
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
336
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
118
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
218
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
218
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
218
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
218
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
218
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
218
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
218
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
218
  if (table_ptr == NULL)
4729
0
    return false;
4730
218
  else
4731
218
    {
4732
218
      coff_symbol_type *dst = cached_area;
4733
218
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
218
      unsigned int this_index = 0;
4735
4736
24.5k
      while (this_index < last_native_index)
4737
24.3k
  {
4738
24.3k
    combined_entry_type *src = native_symbols + this_index;
4739
24.3k
    table_ptr[this_index] = number_of_symbols;
4740
4741
24.3k
    dst->symbol.the_bfd = abfd;
4742
24.3k
    BFD_ASSERT (src->is_sym);
4743
24.3k
    dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset);
4744
    /* We use the native name field to point to the cached field.  */
4745
24.3k
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
24.3k
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
24.3k
                 src->u.syment.n_scnum);
4748
24.3k
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
24.3k
    dst->symbol.value = 0;
4751
24.3k
    dst->done_lineno = false;
4752
4753
24.3k
    switch (src->u.syment.n_sclass)
4754
24.3k
      {
4755
522
      case C_EXT:
4756
549
      case C_WEAKEXT:
4757
#if defined ARM
4758
      case C_THUMBEXT:
4759
      case C_THUMBEXTFUNC:
4760
#endif
4761
#ifdef RS6000COFF_C
4762
      case C_HIDEXT:
4763
#ifndef AIX_WEAK_SUPPORT
4764
      case C_AIX_WEAKEXT:
4765
#endif
4766
#endif
4767
549
#ifdef C_SYSTEM
4768
595
      case C_SYSTEM: /* System Wide variable.  */
4769
595
#endif
4770
#ifdef COFF_WITH_PE
4771
      /* In PE, 0x68 (104) denotes a section symbol.  */
4772
      case C_SECTION:
4773
      /* In PE, 0x69 (105) denotes a weak external symbol.  */
4774
      case C_NT_WEAK:
4775
#endif
4776
595
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
595
    {
4778
482
    case COFF_SYMBOL_GLOBAL:
4779
482
      dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
4780
#if defined COFF_WITH_PE
4781
      /* PE sets the symbol to a value relative to the
4782
         start of the section.  */
4783
      dst->symbol.value = src->u.syment.n_value;
4784
#else
4785
482
      dst->symbol.value = (src->u.syment.n_value
4786
482
               - dst->symbol.section->vma);
4787
482
#endif
4788
482
      if (ISFCN ((src->u.syment.n_type)))
4789
        /* A function ext does not go at the end of a
4790
           file.  */
4791
8
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4792
482
      break;
4793
4794
86
    case COFF_SYMBOL_COMMON:
4795
86
      dst->symbol.section = bfd_com_section_ptr;
4796
86
      dst->symbol.value = src->u.syment.n_value;
4797
86
      break;
4798
4799
27
    case COFF_SYMBOL_UNDEFINED:
4800
27
      dst->symbol.section = bfd_und_section_ptr;
4801
27
      dst->symbol.value = 0;
4802
27
      break;
4803
4804
0
    case COFF_SYMBOL_PE_SECTION:
4805
0
      dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM;
4806
0
      dst->symbol.value = 0;
4807
0
      break;
4808
4809
0
    case COFF_SYMBOL_LOCAL:
4810
0
      dst->symbol.flags = BSF_LOCAL;
4811
#if defined COFF_WITH_PE
4812
      /* PE sets the symbol to a value relative to the
4813
         start of the section.  */
4814
      dst->symbol.value = src->u.syment.n_value;
4815
#else
4816
0
      dst->symbol.value = (src->u.syment.n_value
4817
0
               - dst->symbol.section->vma);
4818
0
#endif
4819
0
      if (ISFCN ((src->u.syment.n_type)))
4820
0
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4821
0
      break;
4822
595
    }
4823
4824
#ifdef RS6000COFF_C
4825
        /* A symbol with a csect entry should not go at the end.  */
4826
        if (src->u.syment.n_numaux > 0)
4827
    dst->symbol.flags |= BSF_NOT_AT_END;
4828
#endif
4829
4830
#ifdef COFF_WITH_PE
4831
        if (src->u.syment.n_sclass == C_NT_WEAK)
4832
    dst->symbol.flags |= BSF_WEAK;
4833
4834
        if (src->u.syment.n_sclass == C_SECTION
4835
      && src->u.syment.n_scnum > 0)
4836
    dst->symbol.flags = BSF_LOCAL;
4837
#endif
4838
595
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
#ifdef RS6000COFF_C
4840
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
#endif
4842
595
      )
4843
27
    dst->symbol.flags |= BSF_WEAK;
4844
4845
595
        break;
4846
4847
373
      case C_STAT:  /* Static.  */
4848
#if defined ARM
4849
      case C_THUMBSTAT:    /* Thumb static.  */
4850
      case C_THUMBLABEL:   /* Thumb label.  */
4851
      case C_THUMBSTATFUNC:/* Thumb static function.  */
4852
#endif
4853
#ifdef RS6000COFF_C
4854
      case C_DWARF:  /* A label in a dwarf section.  */
4855
      case C_INFO:   /* A label in a comment section.  */
4856
#endif
4857
541
      case C_LABEL:  /* Label.  */
4858
541
        if (src->u.syment.n_scnum == N_DEBUG)
4859
0
    dst->symbol.flags = BSF_DEBUGGING;
4860
541
        else
4861
541
    dst->symbol.flags = BSF_LOCAL;
4862
4863
        /* Base the value as an index from the base of the
4864
     section, if there is one.  */
4865
541
        if (dst->symbol.section)
4866
541
    {
4867
#if defined COFF_WITH_PE
4868
      /* PE sets the symbol to a value relative to the
4869
         start of the section.  */
4870
      dst->symbol.value = src->u.syment.n_value;
4871
#else
4872
541
      dst->symbol.value = (src->u.syment.n_value
4873
541
               - dst->symbol.section->vma);
4874
541
#endif
4875
541
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
541
        break;
4879
4880
140
      case C_FILE: /* File name.  */
4881
140
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
332
      case C_MOS:   /* Member of structure.  */
4884
430
      case C_EOS:   /* End of structure.  */
4885
529
      case C_REGPARM: /* Register parameter.  */
4886
620
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
1.00k
      case C_TPDEF: /* Type definition.  */
4889
1.17k
      case C_ARG:
4890
2.06k
      case C_AUTO: /* Automatic variable.  */
4891
2.17k
      case C_FIELD: /* Bit field.  */
4892
2.29k
      case C_ENTAG: /* Enumeration tag.  */
4893
2.44k
      case C_MOE:   /* Member of enumeration.  */
4894
2.50k
      case C_MOU:   /* Member of union.  */
4895
2.61k
      case C_UNTAG: /* Union tag.  */
4896
2.76k
      case C_STRTAG: /* Structure tag.  */
4897
#ifdef RS6000COFF_C
4898
      case C_GSYM:
4899
      case C_LSYM:
4900
      case C_PSYM:
4901
      case C_RSYM:
4902
      case C_RPSYM:
4903
      case C_STSYM:
4904
      case C_TCSYM:
4905
      case C_BCOMM:
4906
      case C_ECOML:
4907
      case C_ECOMM:
4908
      case C_DECL:
4909
      case C_ENTRY:
4910
      case C_FUN:
4911
      case C_ESTAT:
4912
#endif
4913
2.76k
        dst->symbol.flags |= BSF_DEBUGGING;
4914
2.76k
        dst->symbol.value = (src->u.syment.n_value);
4915
2.76k
        break;
4916
4917
#ifdef RS6000COFF_C
4918
      case C_BINCL: /* Beginning of include file.  */
4919
      case C_EINCL: /* Ending of include file.  */
4920
        /* The value is actually a pointer into the line numbers
4921
     of the file.  We locate the line number entry, and
4922
     set the section to the section which contains it, and
4923
     the value to the index in that section.  */
4924
        {
4925
    asection *sec;
4926
4927
    dst->symbol.flags = BSF_DEBUGGING;
4928
    for (sec = abfd->sections; sec != NULL; sec = sec->next)
4929
      if (sec->line_filepos <= (file_ptr) src->u.syment.n_value
4930
          && ((file_ptr) (sec->line_filepos
4931
              + sec->lineno_count * bfd_coff_linesz (abfd))
4932
        > (file_ptr) src->u.syment.n_value))
4933
        break;
4934
    if (sec == NULL)
4935
      dst->symbol.value = 0;
4936
    else
4937
      {
4938
        dst->symbol.section = sec;
4939
        dst->symbol.value = ((src->u.syment.n_value
4940
            - sec->line_filepos)
4941
           / bfd_coff_linesz (abfd));
4942
        src->fix_line = 1;
4943
      }
4944
        }
4945
        break;
4946
4947
      case C_BSTAT:
4948
        dst->symbol.flags = BSF_DEBUGGING;
4949
4950
        if (src->u.syment.n_value >= obj_raw_syment_count (abfd))
4951
    dst->symbol.value = 0;
4952
        else
4953
    {
4954
      /* The value is actually a symbol index.  Save a pointer
4955
         to the symbol instead of the index.  FIXME: This
4956
         should use a union.  */
4957
      src->u.syment.n_value
4958
        = (uintptr_t) (native_symbols + src->u.syment.n_value);
4959
      dst->symbol.value = src->u.syment.n_value;
4960
      src->fix_value = 1;
4961
    }
4962
        break;
4963
#endif
4964
4965
46
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
385
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
502
      case C_EFCN: /* Physical end of function.  */
4968
#if defined COFF_WITH_PE
4969
        /* PE sets the symbol to a value relative to the start
4970
     of the section.  */
4971
        dst->symbol.value = src->u.syment.n_value;
4972
        if (strcmp (dst->symbol.name, ".bf") != 0)
4973
    {
4974
      /* PE uses funny values for .ef and .lf; don't
4975
         relocate them.  */
4976
      dst->symbol.flags = BSF_DEBUGGING;
4977
    }
4978
        else
4979
    dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC;
4980
#else
4981
        /* Base the value as an index from the base of the
4982
     section.  */
4983
502
        dst->symbol.flags = BSF_LOCAL;
4984
502
        dst->symbol.value = (src->u.syment.n_value
4985
502
           - dst->symbol.section->vma);
4986
502
#endif
4987
502
        break;
4988
4989
89
      case C_STATLAB: /* Static load time label.  */
4990
89
        dst->symbol.value = src->u.syment.n_value;
4991
89
        dst->symbol.flags = BSF_GLOBAL;
4992
89
        break;
4993
4994
15.3k
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
15.3k
        if (src->u.syment.n_type == 0
4998
15.3k
      && src->u.syment.n_value == 0
4999
15.3k
      && src->u.syment.n_scnum == 0)
5000
5.33k
    break;
5001
#ifdef RS6000COFF_C
5002
        /* XCOFF specific: deleted entry.  */
5003
        if (src->u.syment.n_value == C_NULL_VALUE)
5004
    break;
5005
#endif
5006
        /* Fall through.  */
5007
10.0k
      case C_EXTDEF: /* External definition.  */
5008
10.0k
      case C_ULABEL: /* Undefined label.  */
5009
10.0k
      case C_USTATIC: /* Undefined static.  */
5010
10.0k
#ifndef COFF_WITH_PE
5011
      /* C_LINE in regular coff is 0x68.  NT has taken over this storage
5012
         class to represent a section symbol.  */
5013
10.2k
      case C_LINE: /* line # reformatted as symbol table entry.  */
5014
        /* NT uses 0x67 for a weak symbol, not C_ALIAS.  */
5015
10.4k
      case C_ALIAS: /* Duplicate tag.  */
5016
10.4k
#endif
5017
        /* New storage classes for TI COFF.  */
5018
#ifdef TICOFF
5019
      case C_UEXT:  /* Tentative external definition.  */
5020
#endif
5021
10.4k
      case C_EXTLAB: /* External load time label.  */
5022
14.4k
      default:
5023
14.4k
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
14.4k
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
14.4k
     abfd, src->u.syment.n_sclass,
5027
14.4k
     dst->symbol.section->name, dst->symbol.name);
5028
14.4k
        ret = false;
5029
        /* Fall through.  */
5030
14.5k
      case C_HIDDEN: /* Ext symbol in dmert public lib.  */
5031
        /* PR 20722: These symbols can also be generated by
5032
     building DLLs with --gc-sections enabled.  */
5033
14.5k
        dst->symbol.flags = BSF_DEBUGGING;
5034
14.5k
        dst->symbol.value = (src->u.syment.n_value);
5035
14.5k
        break;
5036
24.3k
      }
5037
5038
24.3k
    dst->native = src;
5039
24.3k
    dst->symbol.udata.i = 0;
5040
24.3k
    dst->lineno = NULL;
5041
5042
24.3k
    this_index += (src->u.syment.n_numaux) + 1;
5043
24.3k
    dst++;
5044
24.3k
    number_of_symbols++;
5045
24.3k
  }
5046
218
    }
5047
5048
218
  obj_symbols (abfd) = cached_area;
5049
218
  obj_raw_syments (abfd) = native_symbols;
5050
5051
218
  abfd->symcount = number_of_symbols;
5052
218
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
218
  {
5055
218
    asection *p;
5056
5057
218
    p = abfd->sections;
5058
800
    while (p)
5059
781
      {
5060
781
  if (! coff_slurp_line_table (abfd, p))
5061
199
    return false;
5062
582
  p = p->next;
5063
582
      }
5064
218
  }
5065
5066
19
  return ret;
5067
218
}
coff-z8k.c:coff_slurp_symbol_table
Line
Count
Source
4695
315
{
4696
315
  combined_entry_type *native_symbols;
4697
315
  coff_symbol_type *cached_area;
4698
315
  unsigned int *table_ptr;
4699
315
  unsigned int number_of_symbols = 0;
4700
315
  bool ret = true;
4701
315
  size_t amt;
4702
4703
315
  if (obj_symbols (abfd))
4704
13
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
302
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
113
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
189
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
189
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
189
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
189
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
189
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
189
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
189
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
189
  if (table_ptr == NULL)
4729
0
    return false;
4730
189
  else
4731
189
    {
4732
189
      coff_symbol_type *dst = cached_area;
4733
189
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
189
      unsigned int this_index = 0;
4735
4736
83.4k
      while (this_index < last_native_index)
4737
83.2k
  {
4738
83.2k
    combined_entry_type *src = native_symbols + this_index;
4739
83.2k
    table_ptr[this_index] = number_of_symbols;
4740
4741
83.2k
    dst->symbol.the_bfd = abfd;
4742
83.2k
    BFD_ASSERT (src->is_sym);
4743
83.2k
    dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset);
4744
    /* We use the native name field to point to the cached field.  */
4745
83.2k
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
83.2k
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
83.2k
                 src->u.syment.n_scnum);
4748
83.2k
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
83.2k
    dst->symbol.value = 0;
4751
83.2k
    dst->done_lineno = false;
4752
4753
83.2k
    switch (src->u.syment.n_sclass)
4754
83.2k
      {
4755
1.60k
      case C_EXT:
4756
1.74k
      case C_WEAKEXT:
4757
#if defined ARM
4758
      case C_THUMBEXT:
4759
      case C_THUMBEXTFUNC:
4760
#endif
4761
#ifdef RS6000COFF_C
4762
      case C_HIDEXT:
4763
#ifndef AIX_WEAK_SUPPORT
4764
      case C_AIX_WEAKEXT:
4765
#endif
4766
#endif
4767
1.74k
#ifdef C_SYSTEM
4768
1.83k
      case C_SYSTEM: /* System Wide variable.  */
4769
1.83k
#endif
4770
#ifdef COFF_WITH_PE
4771
      /* In PE, 0x68 (104) denotes a section symbol.  */
4772
      case C_SECTION:
4773
      /* In PE, 0x69 (105) denotes a weak external symbol.  */
4774
      case C_NT_WEAK:
4775
#endif
4776
1.83k
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
1.83k
    {
4778
1.39k
    case COFF_SYMBOL_GLOBAL:
4779
1.39k
      dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
4780
#if defined COFF_WITH_PE
4781
      /* PE sets the symbol to a value relative to the
4782
         start of the section.  */
4783
      dst->symbol.value = src->u.syment.n_value;
4784
#else
4785
1.39k
      dst->symbol.value = (src->u.syment.n_value
4786
1.39k
               - dst->symbol.section->vma);
4787
1.39k
#endif
4788
1.39k
      if (ISFCN ((src->u.syment.n_type)))
4789
        /* A function ext does not go at the end of a
4790
           file.  */
4791
4
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4792
1.39k
      break;
4793
4794
404
    case COFF_SYMBOL_COMMON:
4795
404
      dst->symbol.section = bfd_com_section_ptr;
4796
404
      dst->symbol.value = src->u.syment.n_value;
4797
404
      break;
4798
4799
31
    case COFF_SYMBOL_UNDEFINED:
4800
31
      dst->symbol.section = bfd_und_section_ptr;
4801
31
      dst->symbol.value = 0;
4802
31
      break;
4803
4804
0
    case COFF_SYMBOL_PE_SECTION:
4805
0
      dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM;
4806
0
      dst->symbol.value = 0;
4807
0
      break;
4808
4809
0
    case COFF_SYMBOL_LOCAL:
4810
0
      dst->symbol.flags = BSF_LOCAL;
4811
#if defined COFF_WITH_PE
4812
      /* PE sets the symbol to a value relative to the
4813
         start of the section.  */
4814
      dst->symbol.value = src->u.syment.n_value;
4815
#else
4816
0
      dst->symbol.value = (src->u.syment.n_value
4817
0
               - dst->symbol.section->vma);
4818
0
#endif
4819
0
      if (ISFCN ((src->u.syment.n_type)))
4820
0
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4821
0
      break;
4822
1.83k
    }
4823
4824
#ifdef RS6000COFF_C
4825
        /* A symbol with a csect entry should not go at the end.  */
4826
        if (src->u.syment.n_numaux > 0)
4827
    dst->symbol.flags |= BSF_NOT_AT_END;
4828
#endif
4829
4830
#ifdef COFF_WITH_PE
4831
        if (src->u.syment.n_sclass == C_NT_WEAK)
4832
    dst->symbol.flags |= BSF_WEAK;
4833
4834
        if (src->u.syment.n_sclass == C_SECTION
4835
      && src->u.syment.n_scnum > 0)
4836
    dst->symbol.flags = BSF_LOCAL;
4837
#endif
4838
1.83k
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
#ifdef RS6000COFF_C
4840
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
#endif
4842
1.83k
      )
4843
142
    dst->symbol.flags |= BSF_WEAK;
4844
4845
1.83k
        break;
4846
4847
273
      case C_STAT:  /* Static.  */
4848
#if defined ARM
4849
      case C_THUMBSTAT:    /* Thumb static.  */
4850
      case C_THUMBLABEL:   /* Thumb label.  */
4851
      case C_THUMBSTATFUNC:/* Thumb static function.  */
4852
#endif
4853
#ifdef RS6000COFF_C
4854
      case C_DWARF:  /* A label in a dwarf section.  */
4855
      case C_INFO:   /* A label in a comment section.  */
4856
#endif
4857
397
      case C_LABEL:  /* Label.  */
4858
397
        if (src->u.syment.n_scnum == N_DEBUG)
4859
0
    dst->symbol.flags = BSF_DEBUGGING;
4860
397
        else
4861
397
    dst->symbol.flags = BSF_LOCAL;
4862
4863
        /* Base the value as an index from the base of the
4864
     section, if there is one.  */
4865
397
        if (dst->symbol.section)
4866
397
    {
4867
#if defined COFF_WITH_PE
4868
      /* PE sets the symbol to a value relative to the
4869
         start of the section.  */
4870
      dst->symbol.value = src->u.syment.n_value;
4871
#else
4872
397
      dst->symbol.value = (src->u.syment.n_value
4873
397
               - dst->symbol.section->vma);
4874
397
#endif
4875
397
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
397
        break;
4879
4880
240
      case C_FILE: /* File name.  */
4881
240
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
430
      case C_MOS:   /* Member of structure.  */
4884
568
      case C_EOS:   /* End of structure.  */
4885
706
      case C_REGPARM: /* Register parameter.  */
4886
1.38k
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
1.50k
      case C_TPDEF: /* Type definition.  */
4889
1.57k
      case C_ARG:
4890
9.26k
      case C_AUTO: /* Automatic variable.  */
4891
9.38k
      case C_FIELD: /* Bit field.  */
4892
9.46k
      case C_ENTAG: /* Enumeration tag.  */
4893
10.0k
      case C_MOE:   /* Member of enumeration.  */
4894
10.3k
      case C_MOU:   /* Member of union.  */
4895
10.5k
      case C_UNTAG: /* Union tag.  */
4896
10.6k
      case C_STRTAG: /* Structure tag.  */
4897
#ifdef RS6000COFF_C
4898
      case C_GSYM:
4899
      case C_LSYM:
4900
      case C_PSYM:
4901
      case C_RSYM:
4902
      case C_RPSYM:
4903
      case C_STSYM:
4904
      case C_TCSYM:
4905
      case C_BCOMM:
4906
      case C_ECOML:
4907
      case C_ECOMM:
4908
      case C_DECL:
4909
      case C_ENTRY:
4910
      case C_FUN:
4911
      case C_ESTAT:
4912
#endif
4913
10.6k
        dst->symbol.flags |= BSF_DEBUGGING;
4914
10.6k
        dst->symbol.value = (src->u.syment.n_value);
4915
10.6k
        break;
4916
4917
#ifdef RS6000COFF_C
4918
      case C_BINCL: /* Beginning of include file.  */
4919
      case C_EINCL: /* Ending of include file.  */
4920
        /* The value is actually a pointer into the line numbers
4921
     of the file.  We locate the line number entry, and
4922
     set the section to the section which contains it, and
4923
     the value to the index in that section.  */
4924
        {
4925
    asection *sec;
4926
4927
    dst->symbol.flags = BSF_DEBUGGING;
4928
    for (sec = abfd->sections; sec != NULL; sec = sec->next)
4929
      if (sec->line_filepos <= (file_ptr) src->u.syment.n_value
4930
          && ((file_ptr) (sec->line_filepos
4931
              + sec->lineno_count * bfd_coff_linesz (abfd))
4932
        > (file_ptr) src->u.syment.n_value))
4933
        break;
4934
    if (sec == NULL)
4935
      dst->symbol.value = 0;
4936
    else
4937
      {
4938
        dst->symbol.section = sec;
4939
        dst->symbol.value = ((src->u.syment.n_value
4940
            - sec->line_filepos)
4941
           / bfd_coff_linesz (abfd));
4942
        src->fix_line = 1;
4943
      }
4944
        }
4945
        break;
4946
4947
      case C_BSTAT:
4948
        dst->symbol.flags = BSF_DEBUGGING;
4949
4950
        if (src->u.syment.n_value >= obj_raw_syment_count (abfd))
4951
    dst->symbol.value = 0;
4952
        else
4953
    {
4954
      /* The value is actually a symbol index.  Save a pointer
4955
         to the symbol instead of the index.  FIXME: This
4956
         should use a union.  */
4957
      src->u.syment.n_value
4958
        = (uintptr_t) (native_symbols + src->u.syment.n_value);
4959
      dst->symbol.value = src->u.syment.n_value;
4960
      src->fix_value = 1;
4961
    }
4962
        break;
4963
#endif
4964
4965
164
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
954
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
1.25k
      case C_EFCN: /* Physical end of function.  */
4968
#if defined COFF_WITH_PE
4969
        /* PE sets the symbol to a value relative to the start
4970
     of the section.  */
4971
        dst->symbol.value = src->u.syment.n_value;
4972
        if (strcmp (dst->symbol.name, ".bf") != 0)
4973
    {
4974
      /* PE uses funny values for .ef and .lf; don't
4975
         relocate them.  */
4976
      dst->symbol.flags = BSF_DEBUGGING;
4977
    }
4978
        else
4979
    dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC;
4980
#else
4981
        /* Base the value as an index from the base of the
4982
     section.  */
4983
1.25k
        dst->symbol.flags = BSF_LOCAL;
4984
1.25k
        dst->symbol.value = (src->u.syment.n_value
4985
1.25k
           - dst->symbol.section->vma);
4986
1.25k
#endif
4987
1.25k
        break;
4988
4989
46
      case C_STATLAB: /* Static load time label.  */
4990
46
        dst->symbol.value = src->u.syment.n_value;
4991
46
        dst->symbol.flags = BSF_GLOBAL;
4992
46
        break;
4993
4994
51.0k
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
51.0k
        if (src->u.syment.n_type == 0
4998
51.0k
      && src->u.syment.n_value == 0
4999
51.0k
      && src->u.syment.n_scnum == 0)
5000
3.32k
    break;
5001
#ifdef RS6000COFF_C
5002
        /* XCOFF specific: deleted entry.  */
5003
        if (src->u.syment.n_value == C_NULL_VALUE)
5004
    break;
5005
#endif
5006
        /* Fall through.  */
5007
47.8k
      case C_EXTDEF: /* External definition.  */
5008
47.9k
      case C_ULABEL: /* Undefined label.  */
5009
47.9k
      case C_USTATIC: /* Undefined static.  */
5010
47.9k
#ifndef COFF_WITH_PE
5011
      /* C_LINE in regular coff is 0x68.  NT has taken over this storage
5012
         class to represent a section symbol.  */
5013
48.3k
      case C_LINE: /* line # reformatted as symbol table entry.  */
5014
        /* NT uses 0x67 for a weak symbol, not C_ALIAS.  */
5015
48.8k
      case C_ALIAS: /* Duplicate tag.  */
5016
48.8k
#endif
5017
        /* New storage classes for TI COFF.  */
5018
#ifdef TICOFF
5019
      case C_UEXT:  /* Tentative external definition.  */
5020
#endif
5021
48.8k
      case C_EXTLAB: /* External load time label.  */
5022
65.5k
      default:
5023
65.5k
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
65.5k
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
65.5k
     abfd, src->u.syment.n_sclass,
5027
65.5k
     dst->symbol.section->name, dst->symbol.name);
5028
65.5k
        ret = false;
5029
        /* Fall through.  */
5030
65.6k
      case C_HIDDEN: /* Ext symbol in dmert public lib.  */
5031
        /* PR 20722: These symbols can also be generated by
5032
     building DLLs with --gc-sections enabled.  */
5033
65.6k
        dst->symbol.flags = BSF_DEBUGGING;
5034
65.6k
        dst->symbol.value = (src->u.syment.n_value);
5035
65.6k
        break;
5036
83.2k
      }
5037
5038
83.2k
    dst->native = src;
5039
83.2k
    dst->symbol.udata.i = 0;
5040
83.2k
    dst->lineno = NULL;
5041
5042
83.2k
    this_index += (src->u.syment.n_numaux) + 1;
5043
83.2k
    dst++;
5044
83.2k
    number_of_symbols++;
5045
83.2k
  }
5046
189
    }
5047
5048
189
  obj_symbols (abfd) = cached_area;
5049
189
  obj_raw_syments (abfd) = native_symbols;
5050
5051
189
  abfd->symcount = number_of_symbols;
5052
189
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
189
  {
5055
189
    asection *p;
5056
5057
189
    p = abfd->sections;
5058
1.20k
    while (p)
5059
1.18k
      {
5060
1.18k
  if (! coff_slurp_line_table (abfd, p))
5061
161
    return false;
5062
1.01k
  p = p->next;
5063
1.01k
      }
5064
189
  }
5065
5066
28
  return ret;
5067
189
}
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
4695
135
{
4696
135
  combined_entry_type *native_symbols;
4697
135
  coff_symbol_type *cached_area;
4698
135
  unsigned int *table_ptr;
4699
135
  unsigned int number_of_symbols = 0;
4700
135
  bool ret = true;
4701
135
  size_t amt;
4702
4703
135
  if (obj_symbols (abfd))
4704
2
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
133
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
5
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
128
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
128
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
128
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
128
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
128
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
128
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
128
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
128
  if (table_ptr == NULL)
4729
0
    return false;
4730
128
  else
4731
128
    {
4732
128
      coff_symbol_type *dst = cached_area;
4733
128
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
128
      unsigned int this_index = 0;
4735
4736
94.8k
      while (this_index < last_native_index)
4737
94.7k
  {
4738
94.7k
    combined_entry_type *src = native_symbols + this_index;
4739
94.7k
    table_ptr[this_index] = number_of_symbols;
4740
4741
94.7k
    dst->symbol.the_bfd = abfd;
4742
94.7k
    BFD_ASSERT (src->is_sym);
4743
94.7k
    dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset);
4744
    /* We use the native name field to point to the cached field.  */
4745
94.7k
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
94.7k
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
94.7k
                 src->u.syment.n_scnum);
4748
94.7k
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
94.7k
    dst->symbol.value = 0;
4751
94.7k
    dst->done_lineno = false;
4752
4753
94.7k
    switch (src->u.syment.n_sclass)
4754
94.7k
      {
4755
2.62k
      case C_EXT:
4756
2.74k
      case C_WEAKEXT:
4757
#if defined ARM
4758
      case C_THUMBEXT:
4759
      case C_THUMBEXTFUNC:
4760
#endif
4761
#ifdef RS6000COFF_C
4762
      case C_HIDEXT:
4763
#ifndef AIX_WEAK_SUPPORT
4764
      case C_AIX_WEAKEXT:
4765
#endif
4766
#endif
4767
2.74k
#ifdef C_SYSTEM
4768
2.93k
      case C_SYSTEM: /* System Wide variable.  */
4769
2.93k
#endif
4770
2.93k
#ifdef COFF_WITH_PE
4771
      /* In PE, 0x68 (104) denotes a section symbol.  */
4772
2.97k
      case C_SECTION:
4773
      /* In PE, 0x69 (105) denotes a weak external symbol.  */
4774
4.14k
      case C_NT_WEAK:
4775
4.14k
#endif
4776
4.14k
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
4.14k
    {
4778
3.72k
    case COFF_SYMBOL_GLOBAL:
4779
3.72k
      dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
4780
3.72k
#if defined COFF_WITH_PE
4781
      /* PE sets the symbol to a value relative to the
4782
         start of the section.  */
4783
3.72k
      dst->symbol.value = src->u.syment.n_value;
4784
#else
4785
      dst->symbol.value = (src->u.syment.n_value
4786
               - dst->symbol.section->vma);
4787
#endif
4788
3.72k
      if (ISFCN ((src->u.syment.n_type)))
4789
        /* A function ext does not go at the end of a
4790
           file.  */
4791
284
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4792
3.72k
      break;
4793
4794
321
    case COFF_SYMBOL_COMMON:
4795
321
      dst->symbol.section = bfd_com_section_ptr;
4796
321
      dst->symbol.value = src->u.syment.n_value;
4797
321
      break;
4798
4799
100
    case COFF_SYMBOL_UNDEFINED:
4800
100
      dst->symbol.section = bfd_und_section_ptr;
4801
100
      dst->symbol.value = 0;
4802
100
      break;
4803
4804
0
    case COFF_SYMBOL_PE_SECTION:
4805
0
      dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM;
4806
0
      dst->symbol.value = 0;
4807
0
      break;
4808
4809
0
    case COFF_SYMBOL_LOCAL:
4810
0
      dst->symbol.flags = BSF_LOCAL;
4811
0
#if defined COFF_WITH_PE
4812
      /* PE sets the symbol to a value relative to the
4813
         start of the section.  */
4814
0
      dst->symbol.value = src->u.syment.n_value;
4815
#else
4816
      dst->symbol.value = (src->u.syment.n_value
4817
               - dst->symbol.section->vma);
4818
#endif
4819
0
      if (ISFCN ((src->u.syment.n_type)))
4820
0
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4821
0
      break;
4822
4.14k
    }
4823
4824
#ifdef RS6000COFF_C
4825
        /* A symbol with a csect entry should not go at the end.  */
4826
        if (src->u.syment.n_numaux > 0)
4827
    dst->symbol.flags |= BSF_NOT_AT_END;
4828
#endif
4829
4830
4.14k
#ifdef COFF_WITH_PE
4831
4.14k
        if (src->u.syment.n_sclass == C_NT_WEAK)
4832
1.16k
    dst->symbol.flags |= BSF_WEAK;
4833
4834
4.14k
        if (src->u.syment.n_sclass == C_SECTION
4835
4.14k
      && src->u.syment.n_scnum > 0)
4836
0
    dst->symbol.flags = BSF_LOCAL;
4837
4.14k
#endif
4838
4.14k
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
#ifdef RS6000COFF_C
4840
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
#endif
4842
4.14k
      )
4843
120
    dst->symbol.flags |= BSF_WEAK;
4844
4845
4.14k
        break;
4846
4847
1.18k
      case C_STAT:  /* Static.  */
4848
#if defined ARM
4849
      case C_THUMBSTAT:    /* Thumb static.  */
4850
      case C_THUMBLABEL:   /* Thumb label.  */
4851
      case C_THUMBSTATFUNC:/* Thumb static function.  */
4852
#endif
4853
#ifdef RS6000COFF_C
4854
      case C_DWARF:  /* A label in a dwarf section.  */
4855
      case C_INFO:   /* A label in a comment section.  */
4856
#endif
4857
2.61k
      case C_LABEL:  /* Label.  */
4858
2.61k
        if (src->u.syment.n_scnum == N_DEBUG)
4859
0
    dst->symbol.flags = BSF_DEBUGGING;
4860
2.61k
        else
4861
2.61k
    dst->symbol.flags = BSF_LOCAL;
4862
4863
        /* Base the value as an index from the base of the
4864
     section, if there is one.  */
4865
2.61k
        if (dst->symbol.section)
4866
2.61k
    {
4867
2.61k
#if defined COFF_WITH_PE
4868
      /* PE sets the symbol to a value relative to the
4869
         start of the section.  */
4870
2.61k
      dst->symbol.value = src->u.syment.n_value;
4871
#else
4872
      dst->symbol.value = (src->u.syment.n_value
4873
               - dst->symbol.section->vma);
4874
#endif
4875
2.61k
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
2.61k
        break;
4879
4880
574
      case C_FILE: /* File name.  */
4881
574
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
779
      case C_MOS:   /* Member of structure.  */
4884
1.12k
      case C_EOS:   /* End of structure.  */
4885
1.25k
      case C_REGPARM: /* Register parameter.  */
4886
2.79k
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
3.10k
      case C_TPDEF: /* Type definition.  */
4889
3.57k
      case C_ARG:
4890
7.76k
      case C_AUTO: /* Automatic variable.  */
4891
7.88k
      case C_FIELD: /* Bit field.  */
4892
8.12k
      case C_ENTAG: /* Enumeration tag.  */
4893
8.46k
      case C_MOE:   /* Member of enumeration.  */
4894
8.59k
      case C_MOU:   /* Member of union.  */
4895
8.73k
      case C_UNTAG: /* Union tag.  */
4896
9.08k
      case C_STRTAG: /* Structure tag.  */
4897
#ifdef RS6000COFF_C
4898
      case C_GSYM:
4899
      case C_LSYM:
4900
      case C_PSYM:
4901
      case C_RSYM:
4902
      case C_RPSYM:
4903
      case C_STSYM:
4904
      case C_TCSYM:
4905
      case C_BCOMM:
4906
      case C_ECOML:
4907
      case C_ECOMM:
4908
      case C_DECL:
4909
      case C_ENTRY:
4910
      case C_FUN:
4911
      case C_ESTAT:
4912
#endif
4913
9.08k
        dst->symbol.flags |= BSF_DEBUGGING;
4914
9.08k
        dst->symbol.value = (src->u.syment.n_value);
4915
9.08k
        break;
4916
4917
#ifdef RS6000COFF_C
4918
      case C_BINCL: /* Beginning of include file.  */
4919
      case C_EINCL: /* Ending of include file.  */
4920
        /* The value is actually a pointer into the line numbers
4921
     of the file.  We locate the line number entry, and
4922
     set the section to the section which contains it, and
4923
     the value to the index in that section.  */
4924
        {
4925
    asection *sec;
4926
4927
    dst->symbol.flags = BSF_DEBUGGING;
4928
    for (sec = abfd->sections; sec != NULL; sec = sec->next)
4929
      if (sec->line_filepos <= (file_ptr) src->u.syment.n_value
4930
          && ((file_ptr) (sec->line_filepos
4931
              + sec->lineno_count * bfd_coff_linesz (abfd))
4932
        > (file_ptr) src->u.syment.n_value))
4933
        break;
4934
    if (sec == NULL)
4935
      dst->symbol.value = 0;
4936
    else
4937
      {
4938
        dst->symbol.section = sec;
4939
        dst->symbol.value = ((src->u.syment.n_value
4940
            - sec->line_filepos)
4941
           / bfd_coff_linesz (abfd));
4942
        src->fix_line = 1;
4943
      }
4944
        }
4945
        break;
4946
4947
      case C_BSTAT:
4948
        dst->symbol.flags = BSF_DEBUGGING;
4949
4950
        if (src->u.syment.n_value >= obj_raw_syment_count (abfd))
4951
    dst->symbol.value = 0;
4952
        else
4953
    {
4954
      /* The value is actually a symbol index.  Save a pointer
4955
         to the symbol instead of the index.  FIXME: This
4956
         should use a union.  */
4957
      src->u.syment.n_value
4958
        = (uintptr_t) (native_symbols + src->u.syment.n_value);
4959
      dst->symbol.value = src->u.syment.n_value;
4960
      src->fix_value = 1;
4961
    }
4962
        break;
4963
#endif
4964
4965
253
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
1.83k
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
2.21k
      case C_EFCN: /* Physical end of function.  */
4968
2.21k
#if defined COFF_WITH_PE
4969
        /* PE sets the symbol to a value relative to the start
4970
     of the section.  */
4971
2.21k
        dst->symbol.value = src->u.syment.n_value;
4972
2.21k
        if (strcmp (dst->symbol.name, ".bf") != 0)
4973
2.21k
    {
4974
      /* PE uses funny values for .ef and .lf; don't
4975
         relocate them.  */
4976
2.21k
      dst->symbol.flags = BSF_DEBUGGING;
4977
2.21k
    }
4978
0
        else
4979
0
    dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC;
4980
#else
4981
        /* Base the value as an index from the base of the
4982
     section.  */
4983
        dst->symbol.flags = BSF_LOCAL;
4984
        dst->symbol.value = (src->u.syment.n_value
4985
           - dst->symbol.section->vma);
4986
#endif
4987
2.21k
        break;
4988
4989
169
      case C_STATLAB: /* Static load time label.  */
4990
169
        dst->symbol.value = src->u.syment.n_value;
4991
169
        dst->symbol.flags = BSF_GLOBAL;
4992
169
        break;
4993
4994
56.1k
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
56.1k
        if (src->u.syment.n_type == 0
4998
56.1k
      && src->u.syment.n_value == 0
4999
56.1k
      && src->u.syment.n_scnum == 0)
5000
9.17k
    break;
5001
#ifdef RS6000COFF_C
5002
        /* XCOFF specific: deleted entry.  */
5003
        if (src->u.syment.n_value == C_NULL_VALUE)
5004
    break;
5005
#endif
5006
        /* Fall through.  */
5007
47.1k
      case C_EXTDEF: /* External definition.  */
5008
47.2k
      case C_ULABEL: /* Undefined label.  */
5009
47.3k
      case C_USTATIC: /* Undefined static.  */
5010
#ifndef COFF_WITH_PE
5011
      /* C_LINE in regular coff is 0x68.  NT has taken over this storage
5012
         class to represent a section symbol.  */
5013
      case C_LINE:  /* line # reformatted as symbol table entry.  */
5014
        /* NT uses 0x67 for a weak symbol, not C_ALIAS.  */
5015
      case C_ALIAS: /* Duplicate tag.  */
5016
#endif
5017
        /* New storage classes for TI COFF.  */
5018
#ifdef TICOFF
5019
      case C_UEXT:  /* Tentative external definition.  */
5020
#endif
5021
47.3k
      case C_EXTLAB: /* External load time label.  */
5022
67.2k
      default:
5023
67.2k
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
67.2k
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
67.2k
     abfd, src->u.syment.n_sclass,
5027
67.2k
     dst->symbol.section->name, dst->symbol.name);
5028
67.2k
        ret = false;
5029
        /* Fall through.  */
5030
67.3k
      case C_HIDDEN: /* Ext symbol in dmert public lib.  */
5031
        /* PR 20722: These symbols can also be generated by
5032
     building DLLs with --gc-sections enabled.  */
5033
67.3k
        dst->symbol.flags = BSF_DEBUGGING;
5034
67.3k
        dst->symbol.value = (src->u.syment.n_value);
5035
67.3k
        break;
5036
94.7k
      }
5037
5038
94.7k
    dst->native = src;
5039
94.7k
    dst->symbol.udata.i = 0;
5040
94.7k
    dst->lineno = NULL;
5041
5042
94.7k
    this_index += (src->u.syment.n_numaux) + 1;
5043
94.7k
    dst++;
5044
94.7k
    number_of_symbols++;
5045
94.7k
  }
5046
128
    }
5047
5048
128
  obj_symbols (abfd) = cached_area;
5049
128
  obj_raw_syments (abfd) = native_symbols;
5050
5051
128
  abfd->symcount = number_of_symbols;
5052
128
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
128
  {
5055
128
    asection *p;
5056
5057
128
    p = abfd->sections;
5058
248
    while (p)
5059
206
      {
5060
206
  if (! coff_slurp_line_table (abfd, p))
5061
86
    return false;
5062
120
  p = p->next;
5063
120
      }
5064
128
  }
5065
5066
42
  return ret;
5067
128
}
pe-mcore.c:coff_slurp_symbol_table
Line
Count
Source
4695
186
{
4696
186
  combined_entry_type *native_symbols;
4697
186
  coff_symbol_type *cached_area;
4698
186
  unsigned int *table_ptr;
4699
186
  unsigned int number_of_symbols = 0;
4700
186
  bool ret = true;
4701
186
  size_t amt;
4702
4703
186
  if (obj_symbols (abfd))
4704
11
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
175
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
23
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
152
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
152
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
152
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
152
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
152
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
152
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
152
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
152
  if (table_ptr == NULL)
4729
0
    return false;
4730
152
  else
4731
152
    {
4732
152
      coff_symbol_type *dst = cached_area;
4733
152
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
152
      unsigned int this_index = 0;
4735
4736
72.4k
      while (this_index < last_native_index)
4737
72.3k
  {
4738
72.3k
    combined_entry_type *src = native_symbols + this_index;
4739
72.3k
    table_ptr[this_index] = number_of_symbols;
4740
4741
72.3k
    dst->symbol.the_bfd = abfd;
4742
72.3k
    BFD_ASSERT (src->is_sym);
4743
72.3k
    dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset);
4744
    /* We use the native name field to point to the cached field.  */
4745
72.3k
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
72.3k
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
72.3k
                 src->u.syment.n_scnum);
4748
72.3k
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
72.3k
    dst->symbol.value = 0;
4751
72.3k
    dst->done_lineno = false;
4752
4753
72.3k
    switch (src->u.syment.n_sclass)
4754
72.3k
      {
4755
1.80k
      case C_EXT:
4756
1.89k
      case C_WEAKEXT:
4757
#if defined ARM
4758
      case C_THUMBEXT:
4759
      case C_THUMBEXTFUNC:
4760
#endif
4761
#ifdef RS6000COFF_C
4762
      case C_HIDEXT:
4763
#ifndef AIX_WEAK_SUPPORT
4764
      case C_AIX_WEAKEXT:
4765
#endif
4766
#endif
4767
1.89k
#ifdef C_SYSTEM
4768
2.14k
      case C_SYSTEM: /* System Wide variable.  */
4769
2.14k
#endif
4770
2.14k
#ifdef COFF_WITH_PE
4771
      /* In PE, 0x68 (104) denotes a section symbol.  */
4772
2.16k
      case C_SECTION:
4773
      /* In PE, 0x69 (105) denotes a weak external symbol.  */
4774
3.24k
      case C_NT_WEAK:
4775
3.24k
#endif
4776
3.24k
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
3.24k
    {
4778
2.99k
    case COFF_SYMBOL_GLOBAL:
4779
2.99k
      dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
4780
2.99k
#if defined COFF_WITH_PE
4781
      /* PE sets the symbol to a value relative to the
4782
         start of the section.  */
4783
2.99k
      dst->symbol.value = src->u.syment.n_value;
4784
#else
4785
      dst->symbol.value = (src->u.syment.n_value
4786
               - dst->symbol.section->vma);
4787
#endif
4788
2.99k
      if (ISFCN ((src->u.syment.n_type)))
4789
        /* A function ext does not go at the end of a
4790
           file.  */
4791
27
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4792
2.99k
      break;
4793
4794
208
    case COFF_SYMBOL_COMMON:
4795
208
      dst->symbol.section = bfd_com_section_ptr;
4796
208
      dst->symbol.value = src->u.syment.n_value;
4797
208
      break;
4798
4799
45
    case COFF_SYMBOL_UNDEFINED:
4800
45
      dst->symbol.section = bfd_und_section_ptr;
4801
45
      dst->symbol.value = 0;
4802
45
      break;
4803
4804
0
    case COFF_SYMBOL_PE_SECTION:
4805
0
      dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM;
4806
0
      dst->symbol.value = 0;
4807
0
      break;
4808
4809
0
    case COFF_SYMBOL_LOCAL:
4810
0
      dst->symbol.flags = BSF_LOCAL;
4811
0
#if defined COFF_WITH_PE
4812
      /* PE sets the symbol to a value relative to the
4813
         start of the section.  */
4814
0
      dst->symbol.value = src->u.syment.n_value;
4815
#else
4816
      dst->symbol.value = (src->u.syment.n_value
4817
               - dst->symbol.section->vma);
4818
#endif
4819
0
      if (ISFCN ((src->u.syment.n_type)))
4820
0
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4821
0
      break;
4822
3.24k
    }
4823
4824
#ifdef RS6000COFF_C
4825
        /* A symbol with a csect entry should not go at the end.  */
4826
        if (src->u.syment.n_numaux > 0)
4827
    dst->symbol.flags |= BSF_NOT_AT_END;
4828
#endif
4829
4830
3.24k
#ifdef COFF_WITH_PE
4831
3.24k
        if (src->u.syment.n_sclass == C_NT_WEAK)
4832
1.08k
    dst->symbol.flags |= BSF_WEAK;
4833
4834
3.24k
        if (src->u.syment.n_sclass == C_SECTION
4835
3.24k
      && src->u.syment.n_scnum > 0)
4836
0
    dst->symbol.flags = BSF_LOCAL;
4837
3.24k
#endif
4838
3.24k
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
#ifdef RS6000COFF_C
4840
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
#endif
4842
3.24k
      )
4843
96
    dst->symbol.flags |= BSF_WEAK;
4844
4845
3.24k
        break;
4846
4847
1.13k
      case C_STAT:  /* Static.  */
4848
#if defined ARM
4849
      case C_THUMBSTAT:    /* Thumb static.  */
4850
      case C_THUMBLABEL:   /* Thumb label.  */
4851
      case C_THUMBSTATFUNC:/* Thumb static function.  */
4852
#endif
4853
#ifdef RS6000COFF_C
4854
      case C_DWARF:  /* A label in a dwarf section.  */
4855
      case C_INFO:   /* A label in a comment section.  */
4856
#endif
4857
1.47k
      case C_LABEL:  /* Label.  */
4858
1.47k
        if (src->u.syment.n_scnum == N_DEBUG)
4859
0
    dst->symbol.flags = BSF_DEBUGGING;
4860
1.47k
        else
4861
1.47k
    dst->symbol.flags = BSF_LOCAL;
4862
4863
        /* Base the value as an index from the base of the
4864
     section, if there is one.  */
4865
1.47k
        if (dst->symbol.section)
4866
1.47k
    {
4867
1.47k
#if defined COFF_WITH_PE
4868
      /* PE sets the symbol to a value relative to the
4869
         start of the section.  */
4870
1.47k
      dst->symbol.value = src->u.syment.n_value;
4871
#else
4872
      dst->symbol.value = (src->u.syment.n_value
4873
               - dst->symbol.section->vma);
4874
#endif
4875
1.47k
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
1.47k
        break;
4879
4880
469
      case C_FILE: /* File name.  */
4881
469
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
866
      case C_MOS:   /* Member of structure.  */
4884
1.09k
      case C_EOS:   /* End of structure.  */
4885
1.30k
      case C_REGPARM: /* Register parameter.  */
4886
1.50k
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
1.69k
      case C_TPDEF: /* Type definition.  */
4889
1.86k
      case C_ARG:
4890
4.72k
      case C_AUTO: /* Automatic variable.  */
4891
4.94k
      case C_FIELD: /* Bit field.  */
4892
5.13k
      case C_ENTAG: /* Enumeration tag.  */
4893
5.51k
      case C_MOE:   /* Member of enumeration.  */
4894
5.64k
      case C_MOU:   /* Member of union.  */
4895
5.77k
      case C_UNTAG: /* Union tag.  */
4896
7.05k
      case C_STRTAG: /* Structure tag.  */
4897
#ifdef RS6000COFF_C
4898
      case C_GSYM:
4899
      case C_LSYM:
4900
      case C_PSYM:
4901
      case C_RSYM:
4902
      case C_RPSYM:
4903
      case C_STSYM:
4904
      case C_TCSYM:
4905
      case C_BCOMM:
4906
      case C_ECOML:
4907
      case C_ECOMM:
4908
      case C_DECL:
4909
      case C_ENTRY:
4910
      case C_FUN:
4911
      case C_ESTAT:
4912
#endif
4913
7.05k
        dst->symbol.flags |= BSF_DEBUGGING;
4914
7.05k
        dst->symbol.value = (src->u.syment.n_value);
4915
7.05k
        break;
4916
4917
#ifdef RS6000COFF_C
4918
      case C_BINCL: /* Beginning of include file.  */
4919
      case C_EINCL: /* Ending of include file.  */
4920
        /* The value is actually a pointer into the line numbers
4921
     of the file.  We locate the line number entry, and
4922
     set the section to the section which contains it, and
4923
     the value to the index in that section.  */
4924
        {
4925
    asection *sec;
4926
4927
    dst->symbol.flags = BSF_DEBUGGING;
4928
    for (sec = abfd->sections; sec != NULL; sec = sec->next)
4929
      if (sec->line_filepos <= (file_ptr) src->u.syment.n_value
4930
          && ((file_ptr) (sec->line_filepos
4931
              + sec->lineno_count * bfd_coff_linesz (abfd))
4932
        > (file_ptr) src->u.syment.n_value))
4933
        break;
4934
    if (sec == NULL)
4935
      dst->symbol.value = 0;
4936
    else
4937
      {
4938
        dst->symbol.section = sec;
4939
        dst->symbol.value = ((src->u.syment.n_value
4940
            - sec->line_filepos)
4941
           / bfd_coff_linesz (abfd));
4942
        src->fix_line = 1;
4943
      }
4944
        }
4945
        break;
4946
4947
      case C_BSTAT:
4948
        dst->symbol.flags = BSF_DEBUGGING;
4949
4950
        if (src->u.syment.n_value >= obj_raw_syment_count (abfd))
4951
    dst->symbol.value = 0;
4952
        else
4953
    {
4954
      /* The value is actually a symbol index.  Save a pointer
4955
         to the symbol instead of the index.  FIXME: This
4956
         should use a union.  */
4957
      src->u.syment.n_value
4958
        = (uintptr_t) (native_symbols + src->u.syment.n_value);
4959
      dst->symbol.value = src->u.syment.n_value;
4960
      src->fix_value = 1;
4961
    }
4962
        break;
4963
#endif
4964
4965
333
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
1.77k
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
2.07k
      case C_EFCN: /* Physical end of function.  */
4968
2.07k
#if defined COFF_WITH_PE
4969
        /* PE sets the symbol to a value relative to the start
4970
     of the section.  */
4971
2.07k
        dst->symbol.value = src->u.syment.n_value;
4972
2.07k
        if (strcmp (dst->symbol.name, ".bf") != 0)
4973
2.07k
    {
4974
      /* PE uses funny values for .ef and .lf; don't
4975
         relocate them.  */
4976
2.07k
      dst->symbol.flags = BSF_DEBUGGING;
4977
2.07k
    }
4978
0
        else
4979
0
    dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC;
4980
#else
4981
        /* Base the value as an index from the base of the
4982
     section.  */
4983
        dst->symbol.flags = BSF_LOCAL;
4984
        dst->symbol.value = (src->u.syment.n_value
4985
           - dst->symbol.section->vma);
4986
#endif
4987
2.07k
        break;
4988
4989
160
      case C_STATLAB: /* Static load time label.  */
4990
160
        dst->symbol.value = src->u.syment.n_value;
4991
160
        dst->symbol.flags = BSF_GLOBAL;
4992
160
        break;
4993
4994
41.3k
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
41.3k
        if (src->u.syment.n_type == 0
4998
41.3k
      && src->u.syment.n_value == 0
4999
41.3k
      && src->u.syment.n_scnum == 0)
5000
5.00k
    break;
5001
#ifdef RS6000COFF_C
5002
        /* XCOFF specific: deleted entry.  */
5003
        if (src->u.syment.n_value == C_NULL_VALUE)
5004
    break;
5005
#endif
5006
        /* Fall through.  */
5007
36.4k
      case C_EXTDEF: /* External definition.  */
5008
36.5k
      case C_ULABEL: /* Undefined label.  */
5009
36.5k
      case C_USTATIC: /* Undefined static.  */
5010
#ifndef COFF_WITH_PE
5011
      /* C_LINE in regular coff is 0x68.  NT has taken over this storage
5012
         class to represent a section symbol.  */
5013
      case C_LINE:  /* line # reformatted as symbol table entry.  */
5014
        /* NT uses 0x67 for a weak symbol, not C_ALIAS.  */
5015
      case C_ALIAS: /* Duplicate tag.  */
5016
#endif
5017
        /* New storage classes for TI COFF.  */
5018
#ifdef TICOFF
5019
      case C_UEXT:  /* Tentative external definition.  */
5020
#endif
5021
36.5k
      case C_EXTLAB: /* External load time label.  */
5022
53.2k
      default:
5023
53.2k
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
53.2k
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
53.2k
     abfd, src->u.syment.n_sclass,
5027
53.2k
     dst->symbol.section->name, dst->symbol.name);
5028
53.2k
        ret = false;
5029
        /* Fall through.  */
5030
53.3k
      case C_HIDDEN: /* Ext symbol in dmert public lib.  */
5031
        /* PR 20722: These symbols can also be generated by
5032
     building DLLs with --gc-sections enabled.  */
5033
53.3k
        dst->symbol.flags = BSF_DEBUGGING;
5034
53.3k
        dst->symbol.value = (src->u.syment.n_value);
5035
53.3k
        break;
5036
72.3k
      }
5037
5038
72.3k
    dst->native = src;
5039
72.3k
    dst->symbol.udata.i = 0;
5040
72.3k
    dst->lineno = NULL;
5041
5042
72.3k
    this_index += (src->u.syment.n_numaux) + 1;
5043
72.3k
    dst++;
5044
72.3k
    number_of_symbols++;
5045
72.3k
  }
5046
152
    }
5047
5048
152
  obj_symbols (abfd) = cached_area;
5049
152
  obj_raw_syments (abfd) = native_symbols;
5050
5051
152
  abfd->symcount = number_of_symbols;
5052
152
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
152
  {
5055
152
    asection *p;
5056
5057
152
    p = abfd->sections;
5058
272
    while (p)
5059
214
      {
5060
214
  if (! coff_slurp_line_table (abfd, p))
5061
94
    return false;
5062
120
  p = p->next;
5063
120
      }
5064
152
  }
5065
5066
58
  return ret;
5067
152
}
pe-sh.c:coff_slurp_symbol_table
Line
Count
Source
4695
188
{
4696
188
  combined_entry_type *native_symbols;
4697
188
  coff_symbol_type *cached_area;
4698
188
  unsigned int *table_ptr;
4699
188
  unsigned int number_of_symbols = 0;
4700
188
  bool ret = true;
4701
188
  size_t amt;
4702
4703
188
  if (obj_symbols (abfd))
4704
3
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
185
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
15
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
170
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
170
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
170
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
170
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
170
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
170
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
170
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
170
  if (table_ptr == NULL)
4729
0
    return false;
4730
170
  else
4731
170
    {
4732
170
      coff_symbol_type *dst = cached_area;
4733
170
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
170
      unsigned int this_index = 0;
4735
4736
35.8k
      while (this_index < last_native_index)
4737
35.7k
  {
4738
35.7k
    combined_entry_type *src = native_symbols + this_index;
4739
35.7k
    table_ptr[this_index] = number_of_symbols;
4740
4741
35.7k
    dst->symbol.the_bfd = abfd;
4742
35.7k
    BFD_ASSERT (src->is_sym);
4743
35.7k
    dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset);
4744
    /* We use the native name field to point to the cached field.  */
4745
35.7k
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
35.7k
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
35.7k
                 src->u.syment.n_scnum);
4748
35.7k
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
35.7k
    dst->symbol.value = 0;
4751
35.7k
    dst->done_lineno = false;
4752
4753
35.7k
    switch (src->u.syment.n_sclass)
4754
35.7k
      {
4755
774
      case C_EXT:
4756
801
      case C_WEAKEXT:
4757
#if defined ARM
4758
      case C_THUMBEXT:
4759
      case C_THUMBEXTFUNC:
4760
#endif
4761
#ifdef RS6000COFF_C
4762
      case C_HIDEXT:
4763
#ifndef AIX_WEAK_SUPPORT
4764
      case C_AIX_WEAKEXT:
4765
#endif
4766
#endif
4767
801
#ifdef C_SYSTEM
4768
937
      case C_SYSTEM: /* System Wide variable.  */
4769
937
#endif
4770
937
#ifdef COFF_WITH_PE
4771
      /* In PE, 0x68 (104) denotes a section symbol.  */
4772
949
      case C_SECTION:
4773
      /* In PE, 0x69 (105) denotes a weak external symbol.  */
4774
1.33k
      case C_NT_WEAK:
4775
1.33k
#endif
4776
1.33k
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
1.33k
    {
4778
1.14k
    case COFF_SYMBOL_GLOBAL:
4779
1.14k
      dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
4780
1.14k
#if defined COFF_WITH_PE
4781
      /* PE sets the symbol to a value relative to the
4782
         start of the section.  */
4783
1.14k
      dst->symbol.value = src->u.syment.n_value;
4784
#else
4785
      dst->symbol.value = (src->u.syment.n_value
4786
               - dst->symbol.section->vma);
4787
#endif
4788
1.14k
      if (ISFCN ((src->u.syment.n_type)))
4789
        /* A function ext does not go at the end of a
4790
           file.  */
4791
42
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4792
1.14k
      break;
4793
4794
147
    case COFF_SYMBOL_COMMON:
4795
147
      dst->symbol.section = bfd_com_section_ptr;
4796
147
      dst->symbol.value = src->u.syment.n_value;
4797
147
      break;
4798
4799
39
    case COFF_SYMBOL_UNDEFINED:
4800
39
      dst->symbol.section = bfd_und_section_ptr;
4801
39
      dst->symbol.value = 0;
4802
39
      break;
4803
4804
0
    case COFF_SYMBOL_PE_SECTION:
4805
0
      dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM;
4806
0
      dst->symbol.value = 0;
4807
0
      break;
4808
4809
0
    case COFF_SYMBOL_LOCAL:
4810
0
      dst->symbol.flags = BSF_LOCAL;
4811
0
#if defined COFF_WITH_PE
4812
      /* PE sets the symbol to a value relative to the
4813
         start of the section.  */
4814
0
      dst->symbol.value = src->u.syment.n_value;
4815
#else
4816
      dst->symbol.value = (src->u.syment.n_value
4817
               - dst->symbol.section->vma);
4818
#endif
4819
0
      if (ISFCN ((src->u.syment.n_type)))
4820
0
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4821
0
      break;
4822
1.33k
    }
4823
4824
#ifdef RS6000COFF_C
4825
        /* A symbol with a csect entry should not go at the end.  */
4826
        if (src->u.syment.n_numaux > 0)
4827
    dst->symbol.flags |= BSF_NOT_AT_END;
4828
#endif
4829
4830
1.33k
#ifdef COFF_WITH_PE
4831
1.33k
        if (src->u.syment.n_sclass == C_NT_WEAK)
4832
385
    dst->symbol.flags |= BSF_WEAK;
4833
4834
1.33k
        if (src->u.syment.n_sclass == C_SECTION
4835
1.33k
      && src->u.syment.n_scnum > 0)
4836
0
    dst->symbol.flags = BSF_LOCAL;
4837
1.33k
#endif
4838
1.33k
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
#ifdef RS6000COFF_C
4840
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
#endif
4842
1.33k
      )
4843
27
    dst->symbol.flags |= BSF_WEAK;
4844
4845
1.33k
        break;
4846
4847
1.00k
      case C_STAT:  /* Static.  */
4848
#if defined ARM
4849
      case C_THUMBSTAT:    /* Thumb static.  */
4850
      case C_THUMBLABEL:   /* Thumb label.  */
4851
      case C_THUMBSTATFUNC:/* Thumb static function.  */
4852
#endif
4853
#ifdef RS6000COFF_C
4854
      case C_DWARF:  /* A label in a dwarf section.  */
4855
      case C_INFO:   /* A label in a comment section.  */
4856
#endif
4857
2.75k
      case C_LABEL:  /* Label.  */
4858
2.75k
        if (src->u.syment.n_scnum == N_DEBUG)
4859
0
    dst->symbol.flags = BSF_DEBUGGING;
4860
2.75k
        else
4861
2.75k
    dst->symbol.flags = BSF_LOCAL;
4862
4863
        /* Base the value as an index from the base of the
4864
     section, if there is one.  */
4865
2.75k
        if (dst->symbol.section)
4866
2.75k
    {
4867
2.75k
#if defined COFF_WITH_PE
4868
      /* PE sets the symbol to a value relative to the
4869
         start of the section.  */
4870
2.75k
      dst->symbol.value = src->u.syment.n_value;
4871
#else
4872
      dst->symbol.value = (src->u.syment.n_value
4873
               - dst->symbol.section->vma);
4874
#endif
4875
2.75k
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
2.75k
        break;
4879
4880
240
      case C_FILE: /* File name.  */
4881
240
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
317
      case C_MOS:   /* Member of structure.  */
4884
418
      case C_EOS:   /* End of structure.  */
4885
560
      case C_REGPARM: /* Register parameter.  */
4886
646
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
922
      case C_TPDEF: /* Type definition.  */
4889
1.13k
      case C_ARG:
4890
2.44k
      case C_AUTO: /* Automatic variable.  */
4891
2.55k
      case C_FIELD: /* Bit field.  */
4892
2.64k
      case C_ENTAG: /* Enumeration tag.  */
4893
2.73k
      case C_MOE:   /* Member of enumeration.  */
4894
2.80k
      case C_MOU:   /* Member of union.  */
4895
2.93k
      case C_UNTAG: /* Union tag.  */
4896
3.14k
      case C_STRTAG: /* Structure tag.  */
4897
#ifdef RS6000COFF_C
4898
      case C_GSYM:
4899
      case C_LSYM:
4900
      case C_PSYM:
4901
      case C_RSYM:
4902
      case C_RPSYM:
4903
      case C_STSYM:
4904
      case C_TCSYM:
4905
      case C_BCOMM:
4906
      case C_ECOML:
4907
      case C_ECOMM:
4908
      case C_DECL:
4909
      case C_ENTRY:
4910
      case C_FUN:
4911
      case C_ESTAT:
4912
#endif
4913
3.14k
        dst->symbol.flags |= BSF_DEBUGGING;
4914
3.14k
        dst->symbol.value = (src->u.syment.n_value);
4915
3.14k
        break;
4916
4917
#ifdef RS6000COFF_C
4918
      case C_BINCL: /* Beginning of include file.  */
4919
      case C_EINCL: /* Ending of include file.  */
4920
        /* The value is actually a pointer into the line numbers
4921
     of the file.  We locate the line number entry, and
4922
     set the section to the section which contains it, and
4923
     the value to the index in that section.  */
4924
        {
4925
    asection *sec;
4926
4927
    dst->symbol.flags = BSF_DEBUGGING;
4928
    for (sec = abfd->sections; sec != NULL; sec = sec->next)
4929
      if (sec->line_filepos <= (file_ptr) src->u.syment.n_value
4930
          && ((file_ptr) (sec->line_filepos
4931
              + sec->lineno_count * bfd_coff_linesz (abfd))
4932
        > (file_ptr) src->u.syment.n_value))
4933
        break;
4934
    if (sec == NULL)
4935
      dst->symbol.value = 0;
4936
    else
4937
      {
4938
        dst->symbol.section = sec;
4939
        dst->symbol.value = ((src->u.syment.n_value
4940
            - sec->line_filepos)
4941
           / bfd_coff_linesz (abfd));
4942
        src->fix_line = 1;
4943
      }
4944
        }
4945
        break;
4946
4947
      case C_BSTAT:
4948
        dst->symbol.flags = BSF_DEBUGGING;
4949
4950
        if (src->u.syment.n_value >= obj_raw_syment_count (abfd))
4951
    dst->symbol.value = 0;
4952
        else
4953
    {
4954
      /* The value is actually a symbol index.  Save a pointer
4955
         to the symbol instead of the index.  FIXME: This
4956
         should use a union.  */
4957
      src->u.syment.n_value
4958
        = (uintptr_t) (native_symbols + src->u.syment.n_value);
4959
      dst->symbol.value = src->u.syment.n_value;
4960
      src->fix_value = 1;
4961
    }
4962
        break;
4963
#endif
4964
4965
83
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
597
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
770
      case C_EFCN: /* Physical end of function.  */
4968
770
#if defined COFF_WITH_PE
4969
        /* PE sets the symbol to a value relative to the start
4970
     of the section.  */
4971
770
        dst->symbol.value = src->u.syment.n_value;
4972
770
        if (strcmp (dst->symbol.name, ".bf") != 0)
4973
769
    {
4974
      /* PE uses funny values for .ef and .lf; don't
4975
         relocate them.  */
4976
769
      dst->symbol.flags = BSF_DEBUGGING;
4977
769
    }
4978
1
        else
4979
1
    dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC;
4980
#else
4981
        /* Base the value as an index from the base of the
4982
     section.  */
4983
        dst->symbol.flags = BSF_LOCAL;
4984
        dst->symbol.value = (src->u.syment.n_value
4985
           - dst->symbol.section->vma);
4986
#endif
4987
770
        break;
4988
4989
68
      case C_STATLAB: /* Static load time label.  */
4990
68
        dst->symbol.value = src->u.syment.n_value;
4991
68
        dst->symbol.flags = BSF_GLOBAL;
4992
68
        break;
4993
4994
20.9k
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
20.9k
        if (src->u.syment.n_type == 0
4998
20.9k
      && src->u.syment.n_value == 0
4999
20.9k
      && src->u.syment.n_scnum == 0)
5000
5.51k
    break;
5001
#ifdef RS6000COFF_C
5002
        /* XCOFF specific: deleted entry.  */
5003
        if (src->u.syment.n_value == C_NULL_VALUE)
5004
    break;
5005
#endif
5006
        /* Fall through.  */
5007
15.4k
      case C_EXTDEF: /* External definition.  */
5008
15.5k
      case C_ULABEL: /* Undefined label.  */
5009
15.5k
      case C_USTATIC: /* Undefined static.  */
5010
#ifndef COFF_WITH_PE
5011
      /* C_LINE in regular coff is 0x68.  NT has taken over this storage
5012
         class to represent a section symbol.  */
5013
      case C_LINE:  /* line # reformatted as symbol table entry.  */
5014
        /* NT uses 0x67 for a weak symbol, not C_ALIAS.  */
5015
      case C_ALIAS: /* Duplicate tag.  */
5016
#endif
5017
        /* New storage classes for TI COFF.  */
5018
#ifdef TICOFF
5019
      case C_UEXT:  /* Tentative external definition.  */
5020
#endif
5021
15.5k
      case C_EXTLAB: /* External load time label.  */
5022
22.0k
      default:
5023
22.0k
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
22.0k
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
22.0k
     abfd, src->u.syment.n_sclass,
5027
22.0k
     dst->symbol.section->name, dst->symbol.name);
5028
22.0k
        ret = false;
5029
        /* Fall through.  */
5030
22.1k
      case C_HIDDEN: /* Ext symbol in dmert public lib.  */
5031
        /* PR 20722: These symbols can also be generated by
5032
     building DLLs with --gc-sections enabled.  */
5033
22.1k
        dst->symbol.flags = BSF_DEBUGGING;
5034
22.1k
        dst->symbol.value = (src->u.syment.n_value);
5035
22.1k
        break;
5036
35.7k
      }
5037
5038
35.7k
    dst->native = src;
5039
35.7k
    dst->symbol.udata.i = 0;
5040
35.7k
    dst->lineno = NULL;
5041
5042
35.7k
    this_index += (src->u.syment.n_numaux) + 1;
5043
35.7k
    dst++;
5044
35.7k
    number_of_symbols++;
5045
35.7k
  }
5046
170
    }
5047
5048
170
  obj_symbols (abfd) = cached_area;
5049
170
  obj_raw_syments (abfd) = native_symbols;
5050
5051
170
  abfd->symcount = number_of_symbols;
5052
170
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
170
  {
5055
170
    asection *p;
5056
5057
170
    p = abfd->sections;
5058
270
    while (p)
5059
237
      {
5060
237
  if (! coff_slurp_line_table (abfd, p))
5061
137
    return false;
5062
100
  p = p->next;
5063
100
      }
5064
170
  }
5065
5066
33
  return ret;
5067
170
}
pei-arm-wince.c:coff_slurp_symbol_table
Line
Count
Source
4695
112
{
4696
112
  combined_entry_type *native_symbols;
4697
112
  coff_symbol_type *cached_area;
4698
112
  unsigned int *table_ptr;
4699
112
  unsigned int number_of_symbols = 0;
4700
112
  bool ret = true;
4701
112
  size_t amt;
4702
4703
112
  if (obj_symbols (abfd))
4704
1
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
111
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
4
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
107
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
107
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
107
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
107
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
107
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
107
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
107
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
107
  if (table_ptr == NULL)
4729
0
    return false;
4730
107
  else
4731
107
    {
4732
107
      coff_symbol_type *dst = cached_area;
4733
107
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
107
      unsigned int this_index = 0;
4735
4736
37.5k
      while (this_index < last_native_index)
4737
37.4k
  {
4738
37.4k
    combined_entry_type *src = native_symbols + this_index;
4739
37.4k
    table_ptr[this_index] = number_of_symbols;
4740
4741
37.4k
    dst->symbol.the_bfd = abfd;
4742
37.4k
    BFD_ASSERT (src->is_sym);
4743
37.4k
    dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset);
4744
    /* We use the native name field to point to the cached field.  */
4745
37.4k
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
37.4k
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
37.4k
                 src->u.syment.n_scnum);
4748
37.4k
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
37.4k
    dst->symbol.value = 0;
4751
37.4k
    dst->done_lineno = false;
4752
4753
37.4k
    switch (src->u.syment.n_sclass)
4754
37.4k
      {
4755
405
      case C_EXT:
4756
411
      case C_WEAKEXT:
4757
411
#if defined ARM
4758
424
      case C_THUMBEXT:
4759
425
      case C_THUMBEXTFUNC:
4760
425
#endif
4761
#ifdef RS6000COFF_C
4762
      case C_HIDEXT:
4763
#ifndef AIX_WEAK_SUPPORT
4764
      case C_AIX_WEAKEXT:
4765
#endif
4766
#endif
4767
425
#ifdef C_SYSTEM
4768
489
      case C_SYSTEM: /* System Wide variable.  */
4769
489
#endif
4770
489
#ifdef COFF_WITH_PE
4771
      /* In PE, 0x68 (104) denotes a section symbol.  */
4772
501
      case C_SECTION:
4773
      /* In PE, 0x69 (105) denotes a weak external symbol.  */
4774
988
      case C_NT_WEAK:
4775
988
#endif
4776
988
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
988
    {
4778
883
    case COFF_SYMBOL_GLOBAL:
4779
883
      dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
4780
883
#if defined COFF_WITH_PE
4781
      /* PE sets the symbol to a value relative to the
4782
         start of the section.  */
4783
883
      dst->symbol.value = src->u.syment.n_value;
4784
#else
4785
      dst->symbol.value = (src->u.syment.n_value
4786
               - dst->symbol.section->vma);
4787
#endif
4788
883
      if (ISFCN ((src->u.syment.n_type)))
4789
        /* A function ext does not go at the end of a
4790
           file.  */
4791
45
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4792
883
      break;
4793
4794
64
    case COFF_SYMBOL_COMMON:
4795
64
      dst->symbol.section = bfd_com_section_ptr;
4796
64
      dst->symbol.value = src->u.syment.n_value;
4797
64
      break;
4798
4799
41
    case COFF_SYMBOL_UNDEFINED:
4800
41
      dst->symbol.section = bfd_und_section_ptr;
4801
41
      dst->symbol.value = 0;
4802
41
      break;
4803
4804
0
    case COFF_SYMBOL_PE_SECTION:
4805
0
      dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM;
4806
0
      dst->symbol.value = 0;
4807
0
      break;
4808
4809
0
    case COFF_SYMBOL_LOCAL:
4810
0
      dst->symbol.flags = BSF_LOCAL;
4811
0
#if defined COFF_WITH_PE
4812
      /* PE sets the symbol to a value relative to the
4813
         start of the section.  */
4814
0
      dst->symbol.value = src->u.syment.n_value;
4815
#else
4816
      dst->symbol.value = (src->u.syment.n_value
4817
               - dst->symbol.section->vma);
4818
#endif
4819
0
      if (ISFCN ((src->u.syment.n_type)))
4820
0
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4821
0
      break;
4822
988
    }
4823
4824
#ifdef RS6000COFF_C
4825
        /* A symbol with a csect entry should not go at the end.  */
4826
        if (src->u.syment.n_numaux > 0)
4827
    dst->symbol.flags |= BSF_NOT_AT_END;
4828
#endif
4829
4830
988
#ifdef COFF_WITH_PE
4831
988
        if (src->u.syment.n_sclass == C_NT_WEAK)
4832
487
    dst->symbol.flags |= BSF_WEAK;
4833
4834
988
        if (src->u.syment.n_sclass == C_SECTION
4835
988
      && src->u.syment.n_scnum > 0)
4836
0
    dst->symbol.flags = BSF_LOCAL;
4837
988
#endif
4838
988
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
#ifdef RS6000COFF_C
4840
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
#endif
4842
988
      )
4843
6
    dst->symbol.flags |= BSF_WEAK;
4844
4845
988
        break;
4846
4847
520
      case C_STAT:  /* Static.  */
4848
520
#if defined ARM
4849
525
      case C_THUMBSTAT:    /* Thumb static.  */
4850
531
      case C_THUMBLABEL:   /* Thumb label.  */
4851
539
      case C_THUMBSTATFUNC:/* Thumb static function.  */
4852
539
#endif
4853
#ifdef RS6000COFF_C
4854
      case C_DWARF:  /* A label in a dwarf section.  */
4855
      case C_INFO:   /* A label in a comment section.  */
4856
#endif
4857
580
      case C_LABEL:  /* Label.  */
4858
580
        if (src->u.syment.n_scnum == N_DEBUG)
4859
0
    dst->symbol.flags = BSF_DEBUGGING;
4860
580
        else
4861
580
    dst->symbol.flags = BSF_LOCAL;
4862
4863
        /* Base the value as an index from the base of the
4864
     section, if there is one.  */
4865
580
        if (dst->symbol.section)
4866
580
    {
4867
580
#if defined COFF_WITH_PE
4868
      /* PE sets the symbol to a value relative to the
4869
         start of the section.  */
4870
580
      dst->symbol.value = src->u.syment.n_value;
4871
#else
4872
      dst->symbol.value = (src->u.syment.n_value
4873
               - dst->symbol.section->vma);
4874
#endif
4875
580
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
580
        break;
4879
4880
294
      case C_FILE: /* File name.  */
4881
294
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
480
      case C_MOS:   /* Member of structure.  */
4884
614
      case C_EOS:   /* End of structure.  */
4885
645
      case C_REGPARM: /* Register parameter.  */
4886
775
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
802
      case C_TPDEF: /* Type definition.  */
4889
998
      case C_ARG:
4890
1.68k
      case C_AUTO: /* Automatic variable.  */
4891
1.70k
      case C_FIELD: /* Bit field.  */
4892
1.73k
      case C_ENTAG: /* Enumeration tag.  */
4893
1.81k
      case C_MOE:   /* Member of enumeration.  */
4894
1.83k
      case C_MOU:   /* Member of union.  */
4895
1.87k
      case C_UNTAG: /* Union tag.  */
4896
1.94k
      case C_STRTAG: /* Structure tag.  */
4897
#ifdef RS6000COFF_C
4898
      case C_GSYM:
4899
      case C_LSYM:
4900
      case C_PSYM:
4901
      case C_RSYM:
4902
      case C_RPSYM:
4903
      case C_STSYM:
4904
      case C_TCSYM:
4905
      case C_BCOMM:
4906
      case C_ECOML:
4907
      case C_ECOMM:
4908
      case C_DECL:
4909
      case C_ENTRY:
4910
      case C_FUN:
4911
      case C_ESTAT:
4912
#endif
4913
1.94k
        dst->symbol.flags |= BSF_DEBUGGING;
4914
1.94k
        dst->symbol.value = (src->u.syment.n_value);
4915
1.94k
        break;
4916
4917
#ifdef RS6000COFF_C
4918
      case C_BINCL: /* Beginning of include file.  */
4919
      case C_EINCL: /* Ending of include file.  */
4920
        /* The value is actually a pointer into the line numbers
4921
     of the file.  We locate the line number entry, and
4922
     set the section to the section which contains it, and
4923
     the value to the index in that section.  */
4924
        {
4925
    asection *sec;
4926
4927
    dst->symbol.flags = BSF_DEBUGGING;
4928
    for (sec = abfd->sections; sec != NULL; sec = sec->next)
4929
      if (sec->line_filepos <= (file_ptr) src->u.syment.n_value
4930
          && ((file_ptr) (sec->line_filepos
4931
              + sec->lineno_count * bfd_coff_linesz (abfd))
4932
        > (file_ptr) src->u.syment.n_value))
4933
        break;
4934
    if (sec == NULL)
4935
      dst->symbol.value = 0;
4936
    else
4937
      {
4938
        dst->symbol.section = sec;
4939
        dst->symbol.value = ((src->u.syment.n_value
4940
            - sec->line_filepos)
4941
           / bfd_coff_linesz (abfd));
4942
        src->fix_line = 1;
4943
      }
4944
        }
4945
        break;
4946
4947
      case C_BSTAT:
4948
        dst->symbol.flags = BSF_DEBUGGING;
4949
4950
        if (src->u.syment.n_value >= obj_raw_syment_count (abfd))
4951
    dst->symbol.value = 0;
4952
        else
4953
    {
4954
      /* The value is actually a symbol index.  Save a pointer
4955
         to the symbol instead of the index.  FIXME: This
4956
         should use a union.  */
4957
      src->u.syment.n_value
4958
        = (uintptr_t) (native_symbols + src->u.syment.n_value);
4959
      dst->symbol.value = src->u.syment.n_value;
4960
      src->fix_value = 1;
4961
    }
4962
        break;
4963
#endif
4964
4965
77
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
777
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
863
      case C_EFCN: /* Physical end of function.  */
4968
863
#if defined COFF_WITH_PE
4969
        /* PE sets the symbol to a value relative to the start
4970
     of the section.  */
4971
863
        dst->symbol.value = src->u.syment.n_value;
4972
863
        if (strcmp (dst->symbol.name, ".bf") != 0)
4973
861
    {
4974
      /* PE uses funny values for .ef and .lf; don't
4975
         relocate them.  */
4976
861
      dst->symbol.flags = BSF_DEBUGGING;
4977
861
    }
4978
2
        else
4979
2
    dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC;
4980
#else
4981
        /* Base the value as an index from the base of the
4982
     section.  */
4983
        dst->symbol.flags = BSF_LOCAL;
4984
        dst->symbol.value = (src->u.syment.n_value
4985
           - dst->symbol.section->vma);
4986
#endif
4987
863
        break;
4988
4989
11
      case C_STATLAB: /* Static load time label.  */
4990
11
        dst->symbol.value = src->u.syment.n_value;
4991
11
        dst->symbol.flags = BSF_GLOBAL;
4992
11
        break;
4993
4994
26.3k
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
26.3k
        if (src->u.syment.n_type == 0
4998
26.3k
      && src->u.syment.n_value == 0
4999
26.3k
      && src->u.syment.n_scnum == 0)
5000
13.0k
    break;
5001
#ifdef RS6000COFF_C
5002
        /* XCOFF specific: deleted entry.  */
5003
        if (src->u.syment.n_value == C_NULL_VALUE)
5004
    break;
5005
#endif
5006
        /* Fall through.  */
5007
13.3k
      case C_EXTDEF: /* External definition.  */
5008
13.3k
      case C_ULABEL: /* Undefined label.  */
5009
13.3k
      case C_USTATIC: /* Undefined static.  */
5010
#ifndef COFF_WITH_PE
5011
      /* C_LINE in regular coff is 0x68.  NT has taken over this storage
5012
         class to represent a section symbol.  */
5013
      case C_LINE:  /* line # reformatted as symbol table entry.  */
5014
        /* NT uses 0x67 for a weak symbol, not C_ALIAS.  */
5015
      case C_ALIAS: /* Duplicate tag.  */
5016
#endif
5017
        /* New storage classes for TI COFF.  */
5018
#ifdef TICOFF
5019
      case C_UEXT:  /* Tentative external definition.  */
5020
#endif
5021
13.3k
      case C_EXTLAB: /* External load time label.  */
5022
19.9k
      default:
5023
19.9k
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
19.9k
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
19.9k
     abfd, src->u.syment.n_sclass,
5027
19.9k
     dst->symbol.section->name, dst->symbol.name);
5028
19.9k
        ret = false;
5029
        /* Fall through.  */
5030
19.9k
      case C_HIDDEN: /* Ext symbol in dmert public lib.  */
5031
        /* PR 20722: These symbols can also be generated by
5032
     building DLLs with --gc-sections enabled.  */
5033
19.9k
        dst->symbol.flags = BSF_DEBUGGING;
5034
19.9k
        dst->symbol.value = (src->u.syment.n_value);
5035
19.9k
        break;
5036
37.4k
      }
5037
5038
37.4k
    dst->native = src;
5039
37.4k
    dst->symbol.udata.i = 0;
5040
37.4k
    dst->lineno = NULL;
5041
5042
37.4k
    this_index += (src->u.syment.n_numaux) + 1;
5043
37.4k
    dst++;
5044
37.4k
    number_of_symbols++;
5045
37.4k
  }
5046
107
    }
5047
5048
107
  obj_symbols (abfd) = cached_area;
5049
107
  obj_raw_syments (abfd) = native_symbols;
5050
5051
107
  abfd->symcount = number_of_symbols;
5052
107
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
107
  {
5055
107
    asection *p;
5056
5057
107
    p = abfd->sections;
5058
126
    while (p)
5059
118
      {
5060
118
  if (! coff_slurp_line_table (abfd, p))
5061
99
    return false;
5062
19
  p = p->next;
5063
19
      }
5064
107
  }
5065
5066
8
  return ret;
5067
107
}
pei-arm.c:coff_slurp_symbol_table
Line
Count
Source
4695
194
{
4696
194
  combined_entry_type *native_symbols;
4697
194
  coff_symbol_type *cached_area;
4698
194
  unsigned int *table_ptr;
4699
194
  unsigned int number_of_symbols = 0;
4700
194
  bool ret = true;
4701
194
  size_t amt;
4702
4703
194
  if (obj_symbols (abfd))
4704
1
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
193
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
26
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
167
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
167
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
167
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
167
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
167
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
167
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
167
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
167
  if (table_ptr == NULL)
4729
0
    return false;
4730
167
  else
4731
167
    {
4732
167
      coff_symbol_type *dst = cached_area;
4733
167
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
167
      unsigned int this_index = 0;
4735
4736
32.7k
      while (this_index < last_native_index)
4737
32.6k
  {
4738
32.6k
    combined_entry_type *src = native_symbols + this_index;
4739
32.6k
    table_ptr[this_index] = number_of_symbols;
4740
4741
32.6k
    dst->symbol.the_bfd = abfd;
4742
32.6k
    BFD_ASSERT (src->is_sym);
4743
32.6k
    dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset);
4744
    /* We use the native name field to point to the cached field.  */
4745
32.6k
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
32.6k
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
32.6k
                 src->u.syment.n_scnum);
4748
32.6k
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
32.6k
    dst->symbol.value = 0;
4751
32.6k
    dst->done_lineno = false;
4752
4753
32.6k
    switch (src->u.syment.n_sclass)
4754
32.6k
      {
4755
187
      case C_EXT:
4756
199
      case C_WEAKEXT:
4757
199
#if defined ARM
4758
218
      case C_THUMBEXT:
4759
226
      case C_THUMBEXTFUNC:
4760
226
#endif
4761
#ifdef RS6000COFF_C
4762
      case C_HIDEXT:
4763
#ifndef AIX_WEAK_SUPPORT
4764
      case C_AIX_WEAKEXT:
4765
#endif
4766
#endif
4767
226
#ifdef C_SYSTEM
4768
245
      case C_SYSTEM: /* System Wide variable.  */
4769
245
#endif
4770
245
#ifdef COFF_WITH_PE
4771
      /* In PE, 0x68 (104) denotes a section symbol.  */
4772
249
      case C_SECTION:
4773
      /* In PE, 0x69 (105) denotes a weak external symbol.  */
4774
857
      case C_NT_WEAK:
4775
857
#endif
4776
857
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
857
    {
4778
773
    case COFF_SYMBOL_GLOBAL:
4779
773
      dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
4780
773
#if defined COFF_WITH_PE
4781
      /* PE sets the symbol to a value relative to the
4782
         start of the section.  */
4783
773
      dst->symbol.value = src->u.syment.n_value;
4784
#else
4785
      dst->symbol.value = (src->u.syment.n_value
4786
               - dst->symbol.section->vma);
4787
#endif
4788
773
      if (ISFCN ((src->u.syment.n_type)))
4789
        /* A function ext does not go at the end of a
4790
           file.  */
4791
30
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4792
773
      break;
4793
4794
60
    case COFF_SYMBOL_COMMON:
4795
60
      dst->symbol.section = bfd_com_section_ptr;
4796
60
      dst->symbol.value = src->u.syment.n_value;
4797
60
      break;
4798
4799
24
    case COFF_SYMBOL_UNDEFINED:
4800
24
      dst->symbol.section = bfd_und_section_ptr;
4801
24
      dst->symbol.value = 0;
4802
24
      break;
4803
4804
0
    case COFF_SYMBOL_PE_SECTION:
4805
0
      dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM;
4806
0
      dst->symbol.value = 0;
4807
0
      break;
4808
4809
0
    case COFF_SYMBOL_LOCAL:
4810
0
      dst->symbol.flags = BSF_LOCAL;
4811
0
#if defined COFF_WITH_PE
4812
      /* PE sets the symbol to a value relative to the
4813
         start of the section.  */
4814
0
      dst->symbol.value = src->u.syment.n_value;
4815
#else
4816
      dst->symbol.value = (src->u.syment.n_value
4817
               - dst->symbol.section->vma);
4818
#endif
4819
0
      if (ISFCN ((src->u.syment.n_type)))
4820
0
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4821
0
      break;
4822
857
    }
4823
4824
#ifdef RS6000COFF_C
4825
        /* A symbol with a csect entry should not go at the end.  */
4826
        if (src->u.syment.n_numaux > 0)
4827
    dst->symbol.flags |= BSF_NOT_AT_END;
4828
#endif
4829
4830
857
#ifdef COFF_WITH_PE
4831
857
        if (src->u.syment.n_sclass == C_NT_WEAK)
4832
608
    dst->symbol.flags |= BSF_WEAK;
4833
4834
857
        if (src->u.syment.n_sclass == C_SECTION
4835
857
      && src->u.syment.n_scnum > 0)
4836
0
    dst->symbol.flags = BSF_LOCAL;
4837
857
#endif
4838
857
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
#ifdef RS6000COFF_C
4840
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
#endif
4842
857
      )
4843
12
    dst->symbol.flags |= BSF_WEAK;
4844
4845
857
        break;
4846
4847
488
      case C_STAT:  /* Static.  */
4848
488
#if defined ARM
4849
511
      case C_THUMBSTAT:    /* Thumb static.  */
4850
517
      case C_THUMBLABEL:   /* Thumb label.  */
4851
524
      case C_THUMBSTATFUNC:/* Thumb static function.  */
4852
524
#endif
4853
#ifdef RS6000COFF_C
4854
      case C_DWARF:  /* A label in a dwarf section.  */
4855
      case C_INFO:   /* A label in a comment section.  */
4856
#endif
4857
556
      case C_LABEL:  /* Label.  */
4858
556
        if (src->u.syment.n_scnum == N_DEBUG)
4859
0
    dst->symbol.flags = BSF_DEBUGGING;
4860
556
        else
4861
556
    dst->symbol.flags = BSF_LOCAL;
4862
4863
        /* Base the value as an index from the base of the
4864
     section, if there is one.  */
4865
556
        if (dst->symbol.section)
4866
556
    {
4867
556
#if defined COFF_WITH_PE
4868
      /* PE sets the symbol to a value relative to the
4869
         start of the section.  */
4870
556
      dst->symbol.value = src->u.syment.n_value;
4871
#else
4872
      dst->symbol.value = (src->u.syment.n_value
4873
               - dst->symbol.section->vma);
4874
#endif
4875
556
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
556
        break;
4879
4880
297
      case C_FILE: /* File name.  */
4881
297
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
406
      case C_MOS:   /* Member of structure.  */
4884
504
      case C_EOS:   /* End of structure.  */
4885
591
      case C_REGPARM: /* Register parameter.  */
4886
603
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
666
      case C_TPDEF: /* Type definition.  */
4889
765
      case C_ARG:
4890
1.54k
      case C_AUTO: /* Automatic variable.  */
4891
1.56k
      case C_FIELD: /* Bit field.  */
4892
1.58k
      case C_ENTAG: /* Enumeration tag.  */
4893
1.72k
      case C_MOE:   /* Member of enumeration.  */
4894
1.76k
      case C_MOU:   /* Member of union.  */
4895
1.83k
      case C_UNTAG: /* Union tag.  */
4896
1.98k
      case C_STRTAG: /* Structure tag.  */
4897
#ifdef RS6000COFF_C
4898
      case C_GSYM:
4899
      case C_LSYM:
4900
      case C_PSYM:
4901
      case C_RSYM:
4902
      case C_RPSYM:
4903
      case C_STSYM:
4904
      case C_TCSYM:
4905
      case C_BCOMM:
4906
      case C_ECOML:
4907
      case C_ECOMM:
4908
      case C_DECL:
4909
      case C_ENTRY:
4910
      case C_FUN:
4911
      case C_ESTAT:
4912
#endif
4913
1.98k
        dst->symbol.flags |= BSF_DEBUGGING;
4914
1.98k
        dst->symbol.value = (src->u.syment.n_value);
4915
1.98k
        break;
4916
4917
#ifdef RS6000COFF_C
4918
      case C_BINCL: /* Beginning of include file.  */
4919
      case C_EINCL: /* Ending of include file.  */
4920
        /* The value is actually a pointer into the line numbers
4921
     of the file.  We locate the line number entry, and
4922
     set the section to the section which contains it, and
4923
     the value to the index in that section.  */
4924
        {
4925
    asection *sec;
4926
4927
    dst->symbol.flags = BSF_DEBUGGING;
4928
    for (sec = abfd->sections; sec != NULL; sec = sec->next)
4929
      if (sec->line_filepos <= (file_ptr) src->u.syment.n_value
4930
          && ((file_ptr) (sec->line_filepos
4931
              + sec->lineno_count * bfd_coff_linesz (abfd))
4932
        > (file_ptr) src->u.syment.n_value))
4933
        break;
4934
    if (sec == NULL)
4935
      dst->symbol.value = 0;
4936
    else
4937
      {
4938
        dst->symbol.section = sec;
4939
        dst->symbol.value = ((src->u.syment.n_value
4940
            - sec->line_filepos)
4941
           / bfd_coff_linesz (abfd));
4942
        src->fix_line = 1;
4943
      }
4944
        }
4945
        break;
4946
4947
      case C_BSTAT:
4948
        dst->symbol.flags = BSF_DEBUGGING;
4949
4950
        if (src->u.syment.n_value >= obj_raw_syment_count (abfd))
4951
    dst->symbol.value = 0;
4952
        else
4953
    {
4954
      /* The value is actually a symbol index.  Save a pointer
4955
         to the symbol instead of the index.  FIXME: This
4956
         should use a union.  */
4957
      src->u.syment.n_value
4958
        = (uintptr_t) (native_symbols + src->u.syment.n_value);
4959
      dst->symbol.value = src->u.syment.n_value;
4960
      src->fix_value = 1;
4961
    }
4962
        break;
4963
#endif
4964
4965
85
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
988
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
1.04k
      case C_EFCN: /* Physical end of function.  */
4968
1.04k
#if defined COFF_WITH_PE
4969
        /* PE sets the symbol to a value relative to the start
4970
     of the section.  */
4971
1.04k
        dst->symbol.value = src->u.syment.n_value;
4972
1.04k
        if (strcmp (dst->symbol.name, ".bf") != 0)
4973
1.04k
    {
4974
      /* PE uses funny values for .ef and .lf; don't
4975
         relocate them.  */
4976
1.04k
      dst->symbol.flags = BSF_DEBUGGING;
4977
1.04k
    }
4978
0
        else
4979
0
    dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC;
4980
#else
4981
        /* Base the value as an index from the base of the
4982
     section.  */
4983
        dst->symbol.flags = BSF_LOCAL;
4984
        dst->symbol.value = (src->u.syment.n_value
4985
           - dst->symbol.section->vma);
4986
#endif
4987
1.04k
        break;
4988
4989
47
      case C_STATLAB: /* Static load time label.  */
4990
47
        dst->symbol.value = src->u.syment.n_value;
4991
47
        dst->symbol.flags = BSF_GLOBAL;
4992
47
        break;
4993
4994
20.8k
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
20.8k
        if (src->u.syment.n_type == 0
4998
20.8k
      && src->u.syment.n_value == 0
4999
20.8k
      && src->u.syment.n_scnum == 0)
5000
5.39k
    break;
5001
#ifdef RS6000COFF_C
5002
        /* XCOFF specific: deleted entry.  */
5003
        if (src->u.syment.n_value == C_NULL_VALUE)
5004
    break;
5005
#endif
5006
        /* Fall through.  */
5007
15.4k
      case C_EXTDEF: /* External definition.  */
5008
15.4k
      case C_ULABEL: /* Undefined label.  */
5009
15.4k
      case C_USTATIC: /* Undefined static.  */
5010
#ifndef COFF_WITH_PE
5011
      /* C_LINE in regular coff is 0x68.  NT has taken over this storage
5012
         class to represent a section symbol.  */
5013
      case C_LINE:  /* line # reformatted as symbol table entry.  */
5014
        /* NT uses 0x67 for a weak symbol, not C_ALIAS.  */
5015
      case C_ALIAS: /* Duplicate tag.  */
5016
#endif
5017
        /* New storage classes for TI COFF.  */
5018
#ifdef TICOFF
5019
      case C_UEXT:  /* Tentative external definition.  */
5020
#endif
5021
15.5k
      case C_EXTLAB: /* External load time label.  */
5022
22.6k
      default:
5023
22.6k
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
22.6k
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
22.6k
     abfd, src->u.syment.n_sclass,
5027
22.6k
     dst->symbol.section->name, dst->symbol.name);
5028
22.6k
        ret = false;
5029
        /* Fall through.  */
5030
22.7k
      case C_HIDDEN: /* Ext symbol in dmert public lib.  */
5031
        /* PR 20722: These symbols can also be generated by
5032
     building DLLs with --gc-sections enabled.  */
5033
22.7k
        dst->symbol.flags = BSF_DEBUGGING;
5034
22.7k
        dst->symbol.value = (src->u.syment.n_value);
5035
22.7k
        break;
5036
32.6k
      }
5037
5038
32.6k
    dst->native = src;
5039
32.6k
    dst->symbol.udata.i = 0;
5040
32.6k
    dst->lineno = NULL;
5041
5042
32.6k
    this_index += (src->u.syment.n_numaux) + 1;
5043
32.6k
    dst++;
5044
32.6k
    number_of_symbols++;
5045
32.6k
  }
5046
167
    }
5047
5048
167
  obj_symbols (abfd) = cached_area;
5049
167
  obj_raw_syments (abfd) = native_symbols;
5050
5051
167
  abfd->symcount = number_of_symbols;
5052
167
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
167
  {
5055
167
    asection *p;
5056
5057
167
    p = abfd->sections;
5058
436
    while (p)
5059
430
      {
5060
430
  if (! coff_slurp_line_table (abfd, p))
5061
161
    return false;
5062
269
  p = p->next;
5063
269
      }
5064
167
  }
5065
5066
6
  return ret;
5067
167
}
pei-mcore.c:coff_slurp_symbol_table
Line
Count
Source
4695
156
{
4696
156
  combined_entry_type *native_symbols;
4697
156
  coff_symbol_type *cached_area;
4698
156
  unsigned int *table_ptr;
4699
156
  unsigned int number_of_symbols = 0;
4700
156
  bool ret = true;
4701
156
  size_t amt;
4702
4703
156
  if (obj_symbols (abfd))
4704
2
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
154
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
12
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
142
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
142
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
142
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
142
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
142
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
142
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
142
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
142
  if (table_ptr == NULL)
4729
0
    return false;
4730
142
  else
4731
142
    {
4732
142
      coff_symbol_type *dst = cached_area;
4733
142
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
142
      unsigned int this_index = 0;
4735
4736
22.5k
      while (this_index < last_native_index)
4737
22.4k
  {
4738
22.4k
    combined_entry_type *src = native_symbols + this_index;
4739
22.4k
    table_ptr[this_index] = number_of_symbols;
4740
4741
22.4k
    dst->symbol.the_bfd = abfd;
4742
22.4k
    BFD_ASSERT (src->is_sym);
4743
22.4k
    dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset);
4744
    /* We use the native name field to point to the cached field.  */
4745
22.4k
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
22.4k
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
22.4k
                 src->u.syment.n_scnum);
4748
22.4k
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
22.4k
    dst->symbol.value = 0;
4751
22.4k
    dst->done_lineno = false;
4752
4753
22.4k
    switch (src->u.syment.n_sclass)
4754
22.4k
      {
4755
680
      case C_EXT:
4756
693
      case C_WEAKEXT:
4757
#if defined ARM
4758
      case C_THUMBEXT:
4759
      case C_THUMBEXTFUNC:
4760
#endif
4761
#ifdef RS6000COFF_C
4762
      case C_HIDEXT:
4763
#ifndef AIX_WEAK_SUPPORT
4764
      case C_AIX_WEAKEXT:
4765
#endif
4766
#endif
4767
693
#ifdef C_SYSTEM
4768
747
      case C_SYSTEM: /* System Wide variable.  */
4769
747
#endif
4770
747
#ifdef COFF_WITH_PE
4771
      /* In PE, 0x68 (104) denotes a section symbol.  */
4772
753
      case C_SECTION:
4773
      /* In PE, 0x69 (105) denotes a weak external symbol.  */
4774
1.05k
      case C_NT_WEAK:
4775
1.05k
#endif
4776
1.05k
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
1.05k
    {
4778
1.00k
    case COFF_SYMBOL_GLOBAL:
4779
1.00k
      dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
4780
1.00k
#if defined COFF_WITH_PE
4781
      /* PE sets the symbol to a value relative to the
4782
         start of the section.  */
4783
1.00k
      dst->symbol.value = src->u.syment.n_value;
4784
#else
4785
      dst->symbol.value = (src->u.syment.n_value
4786
               - dst->symbol.section->vma);
4787
#endif
4788
1.00k
      if (ISFCN ((src->u.syment.n_type)))
4789
        /* A function ext does not go at the end of a
4790
           file.  */
4791
43
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4792
1.00k
      break;
4793
4794
23
    case COFF_SYMBOL_COMMON:
4795
23
      dst->symbol.section = bfd_com_section_ptr;
4796
23
      dst->symbol.value = src->u.syment.n_value;
4797
23
      break;
4798
4799
25
    case COFF_SYMBOL_UNDEFINED:
4800
25
      dst->symbol.section = bfd_und_section_ptr;
4801
25
      dst->symbol.value = 0;
4802
25
      break;
4803
4804
0
    case COFF_SYMBOL_PE_SECTION:
4805
0
      dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM;
4806
0
      dst->symbol.value = 0;
4807
0
      break;
4808
4809
0
    case COFF_SYMBOL_LOCAL:
4810
0
      dst->symbol.flags = BSF_LOCAL;
4811
0
#if defined COFF_WITH_PE
4812
      /* PE sets the symbol to a value relative to the
4813
         start of the section.  */
4814
0
      dst->symbol.value = src->u.syment.n_value;
4815
#else
4816
      dst->symbol.value = (src->u.syment.n_value
4817
               - dst->symbol.section->vma);
4818
#endif
4819
0
      if (ISFCN ((src->u.syment.n_type)))
4820
0
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4821
0
      break;
4822
1.05k
    }
4823
4824
#ifdef RS6000COFF_C
4825
        /* A symbol with a csect entry should not go at the end.  */
4826
        if (src->u.syment.n_numaux > 0)
4827
    dst->symbol.flags |= BSF_NOT_AT_END;
4828
#endif
4829
4830
1.05k
#ifdef COFF_WITH_PE
4831
1.05k
        if (src->u.syment.n_sclass == C_NT_WEAK)
4832
299
    dst->symbol.flags |= BSF_WEAK;
4833
4834
1.05k
        if (src->u.syment.n_sclass == C_SECTION
4835
1.05k
      && src->u.syment.n_scnum > 0)
4836
0
    dst->symbol.flags = BSF_LOCAL;
4837
1.05k
#endif
4838
1.05k
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
#ifdef RS6000COFF_C
4840
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
#endif
4842
1.05k
      )
4843
13
    dst->symbol.flags |= BSF_WEAK;
4844
4845
1.05k
        break;
4846
4847
500
      case C_STAT:  /* Static.  */
4848
#if defined ARM
4849
      case C_THUMBSTAT:    /* Thumb static.  */
4850
      case C_THUMBLABEL:   /* Thumb label.  */
4851
      case C_THUMBSTATFUNC:/* Thumb static function.  */
4852
#endif
4853
#ifdef RS6000COFF_C
4854
      case C_DWARF:  /* A label in a dwarf section.  */
4855
      case C_INFO:   /* A label in a comment section.  */
4856
#endif
4857
624
      case C_LABEL:  /* Label.  */
4858
624
        if (src->u.syment.n_scnum == N_DEBUG)
4859
0
    dst->symbol.flags = BSF_DEBUGGING;
4860
624
        else
4861
624
    dst->symbol.flags = BSF_LOCAL;
4862
4863
        /* Base the value as an index from the base of the
4864
     section, if there is one.  */
4865
624
        if (dst->symbol.section)
4866
624
    {
4867
624
#if defined COFF_WITH_PE
4868
      /* PE sets the symbol to a value relative to the
4869
         start of the section.  */
4870
624
      dst->symbol.value = src->u.syment.n_value;
4871
#else
4872
      dst->symbol.value = (src->u.syment.n_value
4873
               - dst->symbol.section->vma);
4874
#endif
4875
624
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
624
        break;
4879
4880
201
      case C_FILE: /* File name.  */
4881
201
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
953
      case C_MOS:   /* Member of structure.  */
4884
1.14k
      case C_EOS:   /* End of structure.  */
4885
1.16k
      case C_REGPARM: /* Register parameter.  */
4886
1.27k
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
1.48k
      case C_TPDEF: /* Type definition.  */
4889
1.55k
      case C_ARG:
4890
2.34k
      case C_AUTO: /* Automatic variable.  */
4891
2.37k
      case C_FIELD: /* Bit field.  */
4892
2.43k
      case C_ENTAG: /* Enumeration tag.  */
4893
2.65k
      case C_MOE:   /* Member of enumeration.  */
4894
2.69k
      case C_MOU:   /* Member of union.  */
4895
2.77k
      case C_UNTAG: /* Union tag.  */
4896
2.84k
      case C_STRTAG: /* Structure tag.  */
4897
#ifdef RS6000COFF_C
4898
      case C_GSYM:
4899
      case C_LSYM:
4900
      case C_PSYM:
4901
      case C_RSYM:
4902
      case C_RPSYM:
4903
      case C_STSYM:
4904
      case C_TCSYM:
4905
      case C_BCOMM:
4906
      case C_ECOML:
4907
      case C_ECOMM:
4908
      case C_DECL:
4909
      case C_ENTRY:
4910
      case C_FUN:
4911
      case C_ESTAT:
4912
#endif
4913
2.84k
        dst->symbol.flags |= BSF_DEBUGGING;
4914
2.84k
        dst->symbol.value = (src->u.syment.n_value);
4915
2.84k
        break;
4916
4917
#ifdef RS6000COFF_C
4918
      case C_BINCL: /* Beginning of include file.  */
4919
      case C_EINCL: /* Ending of include file.  */
4920
        /* The value is actually a pointer into the line numbers
4921
     of the file.  We locate the line number entry, and
4922
     set the section to the section which contains it, and
4923
     the value to the index in that section.  */
4924
        {
4925
    asection *sec;
4926
4927
    dst->symbol.flags = BSF_DEBUGGING;
4928
    for (sec = abfd->sections; sec != NULL; sec = sec->next)
4929
      if (sec->line_filepos <= (file_ptr) src->u.syment.n_value
4930
          && ((file_ptr) (sec->line_filepos
4931
              + sec->lineno_count * bfd_coff_linesz (abfd))
4932
        > (file_ptr) src->u.syment.n_value))
4933
        break;
4934
    if (sec == NULL)
4935
      dst->symbol.value = 0;
4936
    else
4937
      {
4938
        dst->symbol.section = sec;
4939
        dst->symbol.value = ((src->u.syment.n_value
4940
            - sec->line_filepos)
4941
           / bfd_coff_linesz (abfd));
4942
        src->fix_line = 1;
4943
      }
4944
        }
4945
        break;
4946
4947
      case C_BSTAT:
4948
        dst->symbol.flags = BSF_DEBUGGING;
4949
4950
        if (src->u.syment.n_value >= obj_raw_syment_count (abfd))
4951
    dst->symbol.value = 0;
4952
        else
4953
    {
4954
      /* The value is actually a symbol index.  Save a pointer
4955
         to the symbol instead of the index.  FIXME: This
4956
         should use a union.  */
4957
      src->u.syment.n_value
4958
        = (uintptr_t) (native_symbols + src->u.syment.n_value);
4959
      dst->symbol.value = src->u.syment.n_value;
4960
      src->fix_value = 1;
4961
    }
4962
        break;
4963
#endif
4964
4965
78
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
453
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
557
      case C_EFCN: /* Physical end of function.  */
4968
557
#if defined COFF_WITH_PE
4969
        /* PE sets the symbol to a value relative to the start
4970
     of the section.  */
4971
557
        dst->symbol.value = src->u.syment.n_value;
4972
557
        if (strcmp (dst->symbol.name, ".bf") != 0)
4973
557
    {
4974
      /* PE uses funny values for .ef and .lf; don't
4975
         relocate them.  */
4976
557
      dst->symbol.flags = BSF_DEBUGGING;
4977
557
    }
4978
0
        else
4979
0
    dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC;
4980
#else
4981
        /* Base the value as an index from the base of the
4982
     section.  */
4983
        dst->symbol.flags = BSF_LOCAL;
4984
        dst->symbol.value = (src->u.syment.n_value
4985
           - dst->symbol.section->vma);
4986
#endif
4987
557
        break;
4988
4989
36
      case C_STATLAB: /* Static load time label.  */
4990
36
        dst->symbol.value = src->u.syment.n_value;
4991
36
        dst->symbol.flags = BSF_GLOBAL;
4992
36
        break;
4993
4994
12.4k
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
12.4k
        if (src->u.syment.n_type == 0
4998
12.4k
      && src->u.syment.n_value == 0
4999
12.4k
      && src->u.syment.n_scnum == 0)
5000
3.12k
    break;
5001
#ifdef RS6000COFF_C
5002
        /* XCOFF specific: deleted entry.  */
5003
        if (src->u.syment.n_value == C_NULL_VALUE)
5004
    break;
5005
#endif
5006
        /* Fall through.  */
5007
9.38k
      case C_EXTDEF: /* External definition.  */
5008
9.39k
      case C_ULABEL: /* Undefined label.  */
5009
9.40k
      case C_USTATIC: /* Undefined static.  */
5010
#ifndef COFF_WITH_PE
5011
      /* C_LINE in regular coff is 0x68.  NT has taken over this storage
5012
         class to represent a section symbol.  */
5013
      case C_LINE:  /* line # reformatted as symbol table entry.  */
5014
        /* NT uses 0x67 for a weak symbol, not C_ALIAS.  */
5015
      case C_ALIAS: /* Duplicate tag.  */
5016
#endif
5017
        /* New storage classes for TI COFF.  */
5018
#ifdef TICOFF
5019
      case C_UEXT:  /* Tentative external definition.  */
5020
#endif
5021
9.40k
      case C_EXTLAB: /* External load time label.  */
5022
14.1k
      default:
5023
14.1k
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
14.1k
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
14.1k
     abfd, src->u.syment.n_sclass,
5027
14.1k
     dst->symbol.section->name, dst->symbol.name);
5028
14.1k
        ret = false;
5029
        /* Fall through.  */
5030
14.2k
      case C_HIDDEN: /* Ext symbol in dmert public lib.  */
5031
        /* PR 20722: These symbols can also be generated by
5032
     building DLLs with --gc-sections enabled.  */
5033
14.2k
        dst->symbol.flags = BSF_DEBUGGING;
5034
14.2k
        dst->symbol.value = (src->u.syment.n_value);
5035
14.2k
        break;
5036
22.4k
      }
5037
5038
22.4k
    dst->native = src;
5039
22.4k
    dst->symbol.udata.i = 0;
5040
22.4k
    dst->lineno = NULL;
5041
5042
22.4k
    this_index += (src->u.syment.n_numaux) + 1;
5043
22.4k
    dst++;
5044
22.4k
    number_of_symbols++;
5045
22.4k
  }
5046
142
    }
5047
5048
142
  obj_symbols (abfd) = cached_area;
5049
142
  obj_raw_syments (abfd) = native_symbols;
5050
5051
142
  abfd->symcount = number_of_symbols;
5052
142
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
142
  {
5055
142
    asection *p;
5056
5057
142
    p = abfd->sections;
5058
284
    while (p)
5059
234
      {
5060
234
  if (! coff_slurp_line_table (abfd, p))
5061
92
    return false;
5062
142
  p = p->next;
5063
142
      }
5064
142
  }
5065
5066
50
  return ret;
5067
142
}
pei-sh.c:coff_slurp_symbol_table
Line
Count
Source
4695
167
{
4696
167
  combined_entry_type *native_symbols;
4697
167
  coff_symbol_type *cached_area;
4698
167
  unsigned int *table_ptr;
4699
167
  unsigned int number_of_symbols = 0;
4700
167
  bool ret = true;
4701
167
  size_t amt;
4702
4703
167
  if (obj_symbols (abfd))
4704
7
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
160
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
27
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
133
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
133
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
133
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
133
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
133
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
133
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
133
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
133
  if (table_ptr == NULL)
4729
0
    return false;
4730
133
  else
4731
133
    {
4732
133
      coff_symbol_type *dst = cached_area;
4733
133
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
133
      unsigned int this_index = 0;
4735
4736
40.4k
      while (this_index < last_native_index)
4737
40.3k
  {
4738
40.3k
    combined_entry_type *src = native_symbols + this_index;
4739
40.3k
    table_ptr[this_index] = number_of_symbols;
4740
4741
40.3k
    dst->symbol.the_bfd = abfd;
4742
40.3k
    BFD_ASSERT (src->is_sym);
4743
40.3k
    dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset);
4744
    /* We use the native name field to point to the cached field.  */
4745
40.3k
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
40.3k
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
40.3k
                 src->u.syment.n_scnum);
4748
40.3k
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
40.3k
    dst->symbol.value = 0;
4751
40.3k
    dst->done_lineno = false;
4752
4753
40.3k
    switch (src->u.syment.n_sclass)
4754
40.3k
      {
4755
698
      case C_EXT:
4756
735
      case C_WEAKEXT:
4757
#if defined ARM
4758
      case C_THUMBEXT:
4759
      case C_THUMBEXTFUNC:
4760
#endif
4761
#ifdef RS6000COFF_C
4762
      case C_HIDEXT:
4763
#ifndef AIX_WEAK_SUPPORT
4764
      case C_AIX_WEAKEXT:
4765
#endif
4766
#endif
4767
735
#ifdef C_SYSTEM
4768
810
      case C_SYSTEM: /* System Wide variable.  */
4769
810
#endif
4770
810
#ifdef COFF_WITH_PE
4771
      /* In PE, 0x68 (104) denotes a section symbol.  */
4772
822
      case C_SECTION:
4773
      /* In PE, 0x69 (105) denotes a weak external symbol.  */
4774
1.24k
      case C_NT_WEAK:
4775
1.24k
#endif
4776
1.24k
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
1.24k
    {
4778
1.12k
    case COFF_SYMBOL_GLOBAL:
4779
1.12k
      dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
4780
1.12k
#if defined COFF_WITH_PE
4781
      /* PE sets the symbol to a value relative to the
4782
         start of the section.  */
4783
1.12k
      dst->symbol.value = src->u.syment.n_value;
4784
#else
4785
      dst->symbol.value = (src->u.syment.n_value
4786
               - dst->symbol.section->vma);
4787
#endif
4788
1.12k
      if (ISFCN ((src->u.syment.n_type)))
4789
        /* A function ext does not go at the end of a
4790
           file.  */
4791
15
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4792
1.12k
      break;
4793
4794
97
    case COFF_SYMBOL_COMMON:
4795
97
      dst->symbol.section = bfd_com_section_ptr;
4796
97
      dst->symbol.value = src->u.syment.n_value;
4797
97
      break;
4798
4799
25
    case COFF_SYMBOL_UNDEFINED:
4800
25
      dst->symbol.section = bfd_und_section_ptr;
4801
25
      dst->symbol.value = 0;
4802
25
      break;
4803
4804
0
    case COFF_SYMBOL_PE_SECTION:
4805
0
      dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM;
4806
0
      dst->symbol.value = 0;
4807
0
      break;
4808
4809
0
    case COFF_SYMBOL_LOCAL:
4810
0
      dst->symbol.flags = BSF_LOCAL;
4811
0
#if defined COFF_WITH_PE
4812
      /* PE sets the symbol to a value relative to the
4813
         start of the section.  */
4814
0
      dst->symbol.value = src->u.syment.n_value;
4815
#else
4816
      dst->symbol.value = (src->u.syment.n_value
4817
               - dst->symbol.section->vma);
4818
#endif
4819
0
      if (ISFCN ((src->u.syment.n_type)))
4820
0
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4821
0
      break;
4822
1.24k
    }
4823
4824
#ifdef RS6000COFF_C
4825
        /* A symbol with a csect entry should not go at the end.  */
4826
        if (src->u.syment.n_numaux > 0)
4827
    dst->symbol.flags |= BSF_NOT_AT_END;
4828
#endif
4829
4830
1.24k
#ifdef COFF_WITH_PE
4831
1.24k
        if (src->u.syment.n_sclass == C_NT_WEAK)
4832
420
    dst->symbol.flags |= BSF_WEAK;
4833
4834
1.24k
        if (src->u.syment.n_sclass == C_SECTION
4835
1.24k
      && src->u.syment.n_scnum > 0)
4836
0
    dst->symbol.flags = BSF_LOCAL;
4837
1.24k
#endif
4838
1.24k
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
#ifdef RS6000COFF_C
4840
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
#endif
4842
1.24k
      )
4843
37
    dst->symbol.flags |= BSF_WEAK;
4844
4845
1.24k
        break;
4846
4847
365
      case C_STAT:  /* Static.  */
4848
#if defined ARM
4849
      case C_THUMBSTAT:    /* Thumb static.  */
4850
      case C_THUMBLABEL:   /* Thumb label.  */
4851
      case C_THUMBSTATFUNC:/* Thumb static function.  */
4852
#endif
4853
#ifdef RS6000COFF_C
4854
      case C_DWARF:  /* A label in a dwarf section.  */
4855
      case C_INFO:   /* A label in a comment section.  */
4856
#endif
4857
464
      case C_LABEL:  /* Label.  */
4858
464
        if (src->u.syment.n_scnum == N_DEBUG)
4859
0
    dst->symbol.flags = BSF_DEBUGGING;
4860
464
        else
4861
464
    dst->symbol.flags = BSF_LOCAL;
4862
4863
        /* Base the value as an index from the base of the
4864
     section, if there is one.  */
4865
464
        if (dst->symbol.section)
4866
464
    {
4867
464
#if defined COFF_WITH_PE
4868
      /* PE sets the symbol to a value relative to the
4869
         start of the section.  */
4870
464
      dst->symbol.value = src->u.syment.n_value;
4871
#else
4872
      dst->symbol.value = (src->u.syment.n_value
4873
               - dst->symbol.section->vma);
4874
#endif
4875
464
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
464
        break;
4879
4880
175
      case C_FILE: /* File name.  */
4881
175
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
324
      case C_MOS:   /* Member of structure.  */
4884
404
      case C_EOS:   /* End of structure.  */
4885
527
      case C_REGPARM: /* Register parameter.  */
4886
750
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
861
      case C_TPDEF: /* Type definition.  */
4889
941
      case C_ARG:
4890
3.64k
      case C_AUTO: /* Automatic variable.  */
4891
4.02k
      case C_FIELD: /* Bit field.  */
4892
4.13k
      case C_ENTAG: /* Enumeration tag.  */
4893
4.26k
      case C_MOE:   /* Member of enumeration.  */
4894
4.59k
      case C_MOU:   /* Member of union.  */
4895
4.72k
      case C_UNTAG: /* Union tag.  */
4896
4.95k
      case C_STRTAG: /* Structure tag.  */
4897
#ifdef RS6000COFF_C
4898
      case C_GSYM:
4899
      case C_LSYM:
4900
      case C_PSYM:
4901
      case C_RSYM:
4902
      case C_RPSYM:
4903
      case C_STSYM:
4904
      case C_TCSYM:
4905
      case C_BCOMM:
4906
      case C_ECOML:
4907
      case C_ECOMM:
4908
      case C_DECL:
4909
      case C_ENTRY:
4910
      case C_FUN:
4911
      case C_ESTAT:
4912
#endif
4913
4.95k
        dst->symbol.flags |= BSF_DEBUGGING;
4914
4.95k
        dst->symbol.value = (src->u.syment.n_value);
4915
4.95k
        break;
4916
4917
#ifdef RS6000COFF_C
4918
      case C_BINCL: /* Beginning of include file.  */
4919
      case C_EINCL: /* Ending of include file.  */
4920
        /* The value is actually a pointer into the line numbers
4921
     of the file.  We locate the line number entry, and
4922
     set the section to the section which contains it, and
4923
     the value to the index in that section.  */
4924
        {
4925
    asection *sec;
4926
4927
    dst->symbol.flags = BSF_DEBUGGING;
4928
    for (sec = abfd->sections; sec != NULL; sec = sec->next)
4929
      if (sec->line_filepos <= (file_ptr) src->u.syment.n_value
4930
          && ((file_ptr) (sec->line_filepos
4931
              + sec->lineno_count * bfd_coff_linesz (abfd))
4932
        > (file_ptr) src->u.syment.n_value))
4933
        break;
4934
    if (sec == NULL)
4935
      dst->symbol.value = 0;
4936
    else
4937
      {
4938
        dst->symbol.section = sec;
4939
        dst->symbol.value = ((src->u.syment.n_value
4940
            - sec->line_filepos)
4941
           / bfd_coff_linesz (abfd));
4942
        src->fix_line = 1;
4943
      }
4944
        }
4945
        break;
4946
4947
      case C_BSTAT:
4948
        dst->symbol.flags = BSF_DEBUGGING;
4949
4950
        if (src->u.syment.n_value >= obj_raw_syment_count (abfd))
4951
    dst->symbol.value = 0;
4952
        else
4953
    {
4954
      /* The value is actually a symbol index.  Save a pointer
4955
         to the symbol instead of the index.  FIXME: This
4956
         should use a union.  */
4957
      src->u.syment.n_value
4958
        = (uintptr_t) (native_symbols + src->u.syment.n_value);
4959
      dst->symbol.value = src->u.syment.n_value;
4960
      src->fix_value = 1;
4961
    }
4962
        break;
4963
#endif
4964
4965
60
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
606
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
770
      case C_EFCN: /* Physical end of function.  */
4968
770
#if defined COFF_WITH_PE
4969
        /* PE sets the symbol to a value relative to the start
4970
     of the section.  */
4971
770
        dst->symbol.value = src->u.syment.n_value;
4972
770
        if (strcmp (dst->symbol.name, ".bf") != 0)
4973
770
    {
4974
      /* PE uses funny values for .ef and .lf; don't
4975
         relocate them.  */
4976
770
      dst->symbol.flags = BSF_DEBUGGING;
4977
770
    }
4978
0
        else
4979
0
    dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC;
4980
#else
4981
        /* Base the value as an index from the base of the
4982
     section.  */
4983
        dst->symbol.flags = BSF_LOCAL;
4984
        dst->symbol.value = (src->u.syment.n_value
4985
           - dst->symbol.section->vma);
4986
#endif
4987
770
        break;
4988
4989
144
      case C_STATLAB: /* Static load time label.  */
4990
144
        dst->symbol.value = src->u.syment.n_value;
4991
144
        dst->symbol.flags = BSF_GLOBAL;
4992
144
        break;
4993
4994
24.4k
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
24.4k
        if (src->u.syment.n_type == 0
4998
24.4k
      && src->u.syment.n_value == 0
4999
24.4k
      && src->u.syment.n_scnum == 0)
5000
4.07k
    break;
5001
#ifdef RS6000COFF_C
5002
        /* XCOFF specific: deleted entry.  */
5003
        if (src->u.syment.n_value == C_NULL_VALUE)
5004
    break;
5005
#endif
5006
        /* Fall through.  */
5007
20.4k
      case C_EXTDEF: /* External definition.  */
5008
20.4k
      case C_ULABEL: /* Undefined label.  */
5009
20.5k
      case C_USTATIC: /* Undefined static.  */
5010
#ifndef COFF_WITH_PE
5011
      /* C_LINE in regular coff is 0x68.  NT has taken over this storage
5012
         class to represent a section symbol.  */
5013
      case C_LINE:  /* line # reformatted as symbol table entry.  */
5014
        /* NT uses 0x67 for a weak symbol, not C_ALIAS.  */
5015
      case C_ALIAS: /* Duplicate tag.  */
5016
#endif
5017
        /* New storage classes for TI COFF.  */
5018
#ifdef TICOFF
5019
      case C_UEXT:  /* Tentative external definition.  */
5020
#endif
5021
20.5k
      case C_EXTLAB: /* External load time label.  */
5022
28.6k
      default:
5023
28.6k
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
28.6k
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
28.6k
     abfd, src->u.syment.n_sclass,
5027
28.6k
     dst->symbol.section->name, dst->symbol.name);
5028
28.6k
        ret = false;
5029
        /* Fall through.  */
5030
28.6k
      case C_HIDDEN: /* Ext symbol in dmert public lib.  */
5031
        /* PR 20722: These symbols can also be generated by
5032
     building DLLs with --gc-sections enabled.  */
5033
28.6k
        dst->symbol.flags = BSF_DEBUGGING;
5034
28.6k
        dst->symbol.value = (src->u.syment.n_value);
5035
28.6k
        break;
5036
40.3k
      }
5037
5038
40.3k
    dst->native = src;
5039
40.3k
    dst->symbol.udata.i = 0;
5040
40.3k
    dst->lineno = NULL;
5041
5042
40.3k
    this_index += (src->u.syment.n_numaux) + 1;
5043
40.3k
    dst++;
5044
40.3k
    number_of_symbols++;
5045
40.3k
  }
5046
133
    }
5047
5048
133
  obj_symbols (abfd) = cached_area;
5049
133
  obj_raw_syments (abfd) = native_symbols;
5050
5051
133
  abfd->symcount = number_of_symbols;
5052
133
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
133
  {
5055
133
    asection *p;
5056
5057
133
    p = abfd->sections;
5058
225
    while (p)
5059
208
      {
5060
208
  if (! coff_slurp_line_table (abfd, p))
5061
116
    return false;
5062
92
  p = p->next;
5063
92
      }
5064
133
  }
5065
5066
17
  return ret;
5067
133
}
5068
5069
/* Classify a COFF symbol.  A couple of targets have globally visible
5070
   symbols which are not class C_EXT, and this handles those.  It also
5071
   recognizes some special PE cases.  */
5072
5073
static enum coff_symbol_classification
5074
coff_classify_symbol (bfd *abfd,
5075
          struct internal_syment *syment)
5076
39.6k
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
39.6k
  switch (syment->n_sclass)
5080
39.6k
    {
5081
24.7k
    case C_EXT:
5082
26.1k
    case C_WEAKEXT:
5083
#ifdef ARM
5084
642
    case C_THUMBEXT:
5085
651
    case C_THUMBEXTFUNC:
5086
#endif
5087
#ifdef RS6000COFF_C
5088
6.39k
    case C_HIDEXT:
5089
6.39k
#ifndef AIX_WEAK_SUPPORT
5090
8.35k
    case C_AIX_WEAKEXT:
5091
#endif
5092
#endif
5093
8.35k
#ifdef C_SYSTEM
5094
30.9k
    case C_SYSTEM:
5095
30.9k
#endif
5096
#ifdef COFF_WITH_PE
5097
23.5k
    case C_NT_WEAK:
5098
#endif
5099
39.4k
      if (syment->n_scnum == 0)
5100
6.05k
  {
5101
6.05k
    if (syment->n_value == 0)
5102
927
      return COFF_SYMBOL_UNDEFINED;
5103
5.13k
    else
5104
5.13k
      return COFF_SYMBOL_COMMON;
5105
6.05k
  }
5106
#ifdef RS6000COFF_C
5107
6.74k
      if (syment->n_sclass == C_HIDEXT)
5108
285
  return COFF_SYMBOL_LOCAL;
5109
6.46k
#endif
5110
33.0k
      return COFF_SYMBOL_GLOBAL;
5111
5112
170
    default:
5113
170
      break;
5114
39.6k
    }
5115
5116
#ifdef COFF_WITH_PE
5117
170
  if (syment->n_sclass == C_STAT)
5118
0
    {
5119
0
      if (syment->n_scnum == 0)
5120
  /* The Microsoft compiler sometimes generates these if a
5121
     small static function is inlined every time it is used.
5122
     The function is discarded, but the symbol table entry
5123
     remains.  */
5124
0
  return COFF_SYMBOL_LOCAL;
5125
5126
#ifdef STRICT_PE_FORMAT
5127
      /* This is correct for Microsoft generated objects, but it
5128
   breaks gas generated objects.  */
5129
      if (syment->n_value == 0)
5130
  {
5131
    const asection *sec;
5132
    const char *name;
5133
    char buf[SYMNMLEN + 1];
5134
5135
    name = _bfd_coff_internal_syment_name (abfd, syment, buf);
5136
    sec = coff_section_from_bfd_index (abfd, syment->n_scnum);
5137
    if (sec != NULL && name != NULL
5138
        && (strcmp (bfd_section_name (sec), name) == 0))
5139
      return COFF_SYMBOL_PE_SECTION;
5140
  }
5141
#endif
5142
5143
0
      return COFF_SYMBOL_LOCAL;
5144
0
    }
5145
5146
170
  if (syment->n_sclass == C_SECTION)
5147
170
    {
5148
      /* In some cases in a DLL generated by the Microsoft linker, the
5149
   n_value field will contain garbage.  FIXME: This should
5150
   probably be handled by the swapping function instead.  */
5151
170
      syment->n_value = 0;
5152
170
      if (syment->n_scnum == 0)
5153
170
  return COFF_SYMBOL_UNDEFINED;
5154
0
      return COFF_SYMBOL_PE_SECTION;
5155
170
    }
5156
0
#endif /* COFF_WITH_PE */
5157
5158
  /* If it is not a global symbol, we presume it is a local symbol.  */
5159
0
  if (syment->n_scnum == 0)
5160
0
    {
5161
0
      char buf[SYMNMLEN + 1];
5162
5163
0
      _bfd_error_handler
5164
  /* xgettext:c-format */
5165
0
  (_("warning: %pB: local symbol `%s' has no section"),
5166
0
   abfd, _bfd_coff_internal_syment_name (abfd, syment, buf));
5167
0
    }
5168
5169
0
  return COFF_SYMBOL_LOCAL;
5170
170
}
pei-i386.c:coff_classify_symbol
Line
Count
Source
5076
986
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
986
  switch (syment->n_sclass)
5080
986
    {
5081
579
    case C_EXT:
5082
675
    case C_WEAKEXT:
5083
#ifdef ARM
5084
    case C_THUMBEXT:
5085
    case C_THUMBEXTFUNC:
5086
#endif
5087
#ifdef RS6000COFF_C
5088
    case C_HIDEXT:
5089
#ifndef AIX_WEAK_SUPPORT
5090
    case C_AIX_WEAKEXT:
5091
#endif
5092
#endif
5093
675
#ifdef C_SYSTEM
5094
696
    case C_SYSTEM:
5095
696
#endif
5096
696
#ifdef COFF_WITH_PE
5097
984
    case C_NT_WEAK:
5098
984
#endif
5099
984
      if (syment->n_scnum == 0)
5100
69
  {
5101
69
    if (syment->n_value == 0)
5102
24
      return COFF_SYMBOL_UNDEFINED;
5103
45
    else
5104
45
      return COFF_SYMBOL_COMMON;
5105
69
  }
5106
#ifdef RS6000COFF_C
5107
      if (syment->n_sclass == C_HIDEXT)
5108
  return COFF_SYMBOL_LOCAL;
5109
#endif
5110
915
      return COFF_SYMBOL_GLOBAL;
5111
5112
2
    default:
5113
2
      break;
5114
986
    }
5115
5116
2
#ifdef COFF_WITH_PE
5117
2
  if (syment->n_sclass == C_STAT)
5118
0
    {
5119
0
      if (syment->n_scnum == 0)
5120
  /* The Microsoft compiler sometimes generates these if a
5121
     small static function is inlined every time it is used.
5122
     The function is discarded, but the symbol table entry
5123
     remains.  */
5124
0
  return COFF_SYMBOL_LOCAL;
5125
5126
#ifdef STRICT_PE_FORMAT
5127
      /* This is correct for Microsoft generated objects, but it
5128
   breaks gas generated objects.  */
5129
      if (syment->n_value == 0)
5130
  {
5131
    const asection *sec;
5132
    const char *name;
5133
    char buf[SYMNMLEN + 1];
5134
5135
    name = _bfd_coff_internal_syment_name (abfd, syment, buf);
5136
    sec = coff_section_from_bfd_index (abfd, syment->n_scnum);
5137
    if (sec != NULL && name != NULL
5138
        && (strcmp (bfd_section_name (sec), name) == 0))
5139
      return COFF_SYMBOL_PE_SECTION;
5140
  }
5141
#endif
5142
5143
0
      return COFF_SYMBOL_LOCAL;
5144
0
    }
5145
5146
2
  if (syment->n_sclass == C_SECTION)
5147
2
    {
5148
      /* In some cases in a DLL generated by the Microsoft linker, the
5149
   n_value field will contain garbage.  FIXME: This should
5150
   probably be handled by the swapping function instead.  */
5151
2
      syment->n_value = 0;
5152
2
      if (syment->n_scnum == 0)
5153
2
  return COFF_SYMBOL_UNDEFINED;
5154
0
      return COFF_SYMBOL_PE_SECTION;
5155
2
    }
5156
0
#endif /* COFF_WITH_PE */
5157
5158
  /* If it is not a global symbol, we presume it is a local symbol.  */
5159
0
  if (syment->n_scnum == 0)
5160
0
    {
5161
0
      char buf[SYMNMLEN + 1];
5162
5163
0
      _bfd_error_handler
5164
  /* xgettext:c-format */
5165
0
  (_("warning: %pB: local symbol `%s' has no section"),
5166
0
   abfd, _bfd_coff_internal_syment_name (abfd, syment, buf));
5167
0
    }
5168
5169
0
  return COFF_SYMBOL_LOCAL;
5170
2
}
pe-x86_64.c:coff_classify_symbol
Line
Count
Source
5076
1.67k
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
1.67k
  switch (syment->n_sclass)
5080
1.67k
    {
5081
1.22k
    case C_EXT:
5082
1.26k
    case C_WEAKEXT:
5083
#ifdef ARM
5084
    case C_THUMBEXT:
5085
    case C_THUMBEXTFUNC:
5086
#endif
5087
#ifdef RS6000COFF_C
5088
    case C_HIDEXT:
5089
#ifndef AIX_WEAK_SUPPORT
5090
    case C_AIX_WEAKEXT:
5091
#endif
5092
#endif
5093
1.26k
#ifdef C_SYSTEM
5094
1.42k
    case C_SYSTEM:
5095
1.42k
#endif
5096
1.42k
#ifdef COFF_WITH_PE
5097
1.66k
    case C_NT_WEAK:
5098
1.66k
#endif
5099
1.66k
      if (syment->n_scnum == 0)
5100
219
  {
5101
219
    if (syment->n_value == 0)
5102
78
      return COFF_SYMBOL_UNDEFINED;
5103
141
    else
5104
141
      return COFF_SYMBOL_COMMON;
5105
219
  }
5106
#ifdef RS6000COFF_C
5107
      if (syment->n_sclass == C_HIDEXT)
5108
  return COFF_SYMBOL_LOCAL;
5109
#endif
5110
1.44k
      return COFF_SYMBOL_GLOBAL;
5111
5112
10
    default:
5113
10
      break;
5114
1.67k
    }
5115
5116
10
#ifdef COFF_WITH_PE
5117
10
  if (syment->n_sclass == C_STAT)
5118
0
    {
5119
0
      if (syment->n_scnum == 0)
5120
  /* The Microsoft compiler sometimes generates these if a
5121
     small static function is inlined every time it is used.
5122
     The function is discarded, but the symbol table entry
5123
     remains.  */
5124
0
  return COFF_SYMBOL_LOCAL;
5125
5126
#ifdef STRICT_PE_FORMAT
5127
      /* This is correct for Microsoft generated objects, but it
5128
   breaks gas generated objects.  */
5129
      if (syment->n_value == 0)
5130
  {
5131
    const asection *sec;
5132
    const char *name;
5133
    char buf[SYMNMLEN + 1];
5134
5135
    name = _bfd_coff_internal_syment_name (abfd, syment, buf);
5136
    sec = coff_section_from_bfd_index (abfd, syment->n_scnum);
5137
    if (sec != NULL && name != NULL
5138
        && (strcmp (bfd_section_name (sec), name) == 0))
5139
      return COFF_SYMBOL_PE_SECTION;
5140
  }
5141
#endif
5142
5143
0
      return COFF_SYMBOL_LOCAL;
5144
0
    }
5145
5146
10
  if (syment->n_sclass == C_SECTION)
5147
10
    {
5148
      /* In some cases in a DLL generated by the Microsoft linker, the
5149
   n_value field will contain garbage.  FIXME: This should
5150
   probably be handled by the swapping function instead.  */
5151
10
      syment->n_value = 0;
5152
10
      if (syment->n_scnum == 0)
5153
10
  return COFF_SYMBOL_UNDEFINED;
5154
0
      return COFF_SYMBOL_PE_SECTION;
5155
10
    }
5156
0
#endif /* COFF_WITH_PE */
5157
5158
  /* If it is not a global symbol, we presume it is a local symbol.  */
5159
0
  if (syment->n_scnum == 0)
5160
0
    {
5161
0
      char buf[SYMNMLEN + 1];
5162
5163
0
      _bfd_error_handler
5164
  /* xgettext:c-format */
5165
0
  (_("warning: %pB: local symbol `%s' has no section"),
5166
0
   abfd, _bfd_coff_internal_syment_name (abfd, syment, buf));
5167
0
    }
5168
5169
0
  return COFF_SYMBOL_LOCAL;
5170
10
}
pei-x86_64.c:coff_classify_symbol
Line
Count
Source
5076
956
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
956
  switch (syment->n_sclass)
5080
956
    {
5081
425
    case C_EXT:
5082
434
    case C_WEAKEXT:
5083
#ifdef ARM
5084
    case C_THUMBEXT:
5085
    case C_THUMBEXTFUNC:
5086
#endif
5087
#ifdef RS6000COFF_C
5088
    case C_HIDEXT:
5089
#ifndef AIX_WEAK_SUPPORT
5090
    case C_AIX_WEAKEXT:
5091
#endif
5092
#endif
5093
434
#ifdef C_SYSTEM
5094
454
    case C_SYSTEM:
5095
454
#endif
5096
454
#ifdef COFF_WITH_PE
5097
953
    case C_NT_WEAK:
5098
953
#endif
5099
953
      if (syment->n_scnum == 0)
5100
92
  {
5101
92
    if (syment->n_value == 0)
5102
19
      return COFF_SYMBOL_UNDEFINED;
5103
73
    else
5104
73
      return COFF_SYMBOL_COMMON;
5105
92
  }
5106
#ifdef RS6000COFF_C
5107
      if (syment->n_sclass == C_HIDEXT)
5108
  return COFF_SYMBOL_LOCAL;
5109
#endif
5110
861
      return COFF_SYMBOL_GLOBAL;
5111
5112
3
    default:
5113
3
      break;
5114
956
    }
5115
5116
3
#ifdef COFF_WITH_PE
5117
3
  if (syment->n_sclass == C_STAT)
5118
0
    {
5119
0
      if (syment->n_scnum == 0)
5120
  /* The Microsoft compiler sometimes generates these if a
5121
     small static function is inlined every time it is used.
5122
     The function is discarded, but the symbol table entry
5123
     remains.  */
5124
0
  return COFF_SYMBOL_LOCAL;
5125
5126
#ifdef STRICT_PE_FORMAT
5127
      /* This is correct for Microsoft generated objects, but it
5128
   breaks gas generated objects.  */
5129
      if (syment->n_value == 0)
5130
  {
5131
    const asection *sec;
5132
    const char *name;
5133
    char buf[SYMNMLEN + 1];
5134
5135
    name = _bfd_coff_internal_syment_name (abfd, syment, buf);
5136
    sec = coff_section_from_bfd_index (abfd, syment->n_scnum);
5137
    if (sec != NULL && name != NULL
5138
        && (strcmp (bfd_section_name (sec), name) == 0))
5139
      return COFF_SYMBOL_PE_SECTION;
5140
  }
5141
#endif
5142
5143
0
      return COFF_SYMBOL_LOCAL;
5144
0
    }
5145
5146
3
  if (syment->n_sclass == C_SECTION)
5147
3
    {
5148
      /* In some cases in a DLL generated by the Microsoft linker, the
5149
   n_value field will contain garbage.  FIXME: This should
5150
   probably be handled by the swapping function instead.  */
5151
3
      syment->n_value = 0;
5152
3
      if (syment->n_scnum == 0)
5153
3
  return COFF_SYMBOL_UNDEFINED;
5154
0
      return COFF_SYMBOL_PE_SECTION;
5155
3
    }
5156
0
#endif /* COFF_WITH_PE */
5157
5158
  /* If it is not a global symbol, we presume it is a local symbol.  */
5159
0
  if (syment->n_scnum == 0)
5160
0
    {
5161
0
      char buf[SYMNMLEN + 1];
5162
5163
0
      _bfd_error_handler
5164
  /* xgettext:c-format */
5165
0
  (_("warning: %pB: local symbol `%s' has no section"),
5166
0
   abfd, _bfd_coff_internal_syment_name (abfd, syment, buf));
5167
0
    }
5168
5169
0
  return COFF_SYMBOL_LOCAL;
5170
3
}
coff-x86_64.c:coff_classify_symbol
Line
Count
Source
5076
862
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
862
  switch (syment->n_sclass)
5080
862
    {
5081
766
    case C_EXT:
5082
784
    case C_WEAKEXT:
5083
#ifdef ARM
5084
    case C_THUMBEXT:
5085
    case C_THUMBEXTFUNC:
5086
#endif
5087
#ifdef RS6000COFF_C
5088
    case C_HIDEXT:
5089
#ifndef AIX_WEAK_SUPPORT
5090
    case C_AIX_WEAKEXT:
5091
#endif
5092
#endif
5093
784
#ifdef C_SYSTEM
5094
862
    case C_SYSTEM:
5095
862
#endif
5096
#ifdef COFF_WITH_PE
5097
    case C_NT_WEAK:
5098
#endif
5099
862
      if (syment->n_scnum == 0)
5100
212
  {
5101
212
    if (syment->n_value == 0)
5102
11
      return COFF_SYMBOL_UNDEFINED;
5103
201
    else
5104
201
      return COFF_SYMBOL_COMMON;
5105
212
  }
5106
#ifdef RS6000COFF_C
5107
      if (syment->n_sclass == C_HIDEXT)
5108
  return COFF_SYMBOL_LOCAL;
5109
#endif
5110
650
      return COFF_SYMBOL_GLOBAL;
5111
5112
0
    default:
5113
0
      break;
5114
862
    }
5115
5116
#ifdef COFF_WITH_PE
5117
  if (syment->n_sclass == C_STAT)
5118
    {
5119
      if (syment->n_scnum == 0)
5120
  /* The Microsoft compiler sometimes generates these if a
5121
     small static function is inlined every time it is used.
5122
     The function is discarded, but the symbol table entry
5123
     remains.  */
5124
  return COFF_SYMBOL_LOCAL;
5125
5126
#ifdef STRICT_PE_FORMAT
5127
      /* This is correct for Microsoft generated objects, but it
5128
   breaks gas generated objects.  */
5129
      if (syment->n_value == 0)
5130
  {
5131
    const asection *sec;
5132
    const char *name;
5133
    char buf[SYMNMLEN + 1];
5134
5135
    name = _bfd_coff_internal_syment_name (abfd, syment, buf);
5136
    sec = coff_section_from_bfd_index (abfd, syment->n_scnum);
5137
    if (sec != NULL && name != NULL
5138
        && (strcmp (bfd_section_name (sec), name) == 0))
5139
      return COFF_SYMBOL_PE_SECTION;
5140
  }
5141
#endif
5142
5143
      return COFF_SYMBOL_LOCAL;
5144
    }
5145
5146
  if (syment->n_sclass == C_SECTION)
5147
    {
5148
      /* In some cases in a DLL generated by the Microsoft linker, the
5149
   n_value field will contain garbage.  FIXME: This should
5150
   probably be handled by the swapping function instead.  */
5151
      syment->n_value = 0;
5152
      if (syment->n_scnum == 0)
5153
  return COFF_SYMBOL_UNDEFINED;
5154
      return COFF_SYMBOL_PE_SECTION;
5155
    }
5156
#endif /* COFF_WITH_PE */
5157
5158
  /* If it is not a global symbol, we presume it is a local symbol.  */
5159
0
  if (syment->n_scnum == 0)
5160
0
    {
5161
0
      char buf[SYMNMLEN + 1];
5162
5163
0
      _bfd_error_handler
5164
  /* xgettext:c-format */
5165
0
  (_("warning: %pB: local symbol `%s' has no section"),
5166
0
   abfd, _bfd_coff_internal_syment_name (abfd, syment, buf));
5167
0
    }
5168
5169
0
  return COFF_SYMBOL_LOCAL;
5170
862
}
coff64-rs6000.c:coff_classify_symbol
Line
Count
Source
5076
4.07k
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
4.07k
  switch (syment->n_sclass)
5080
4.07k
    {
5081
2.50k
    case C_EXT:
5082
2.60k
    case C_WEAKEXT:
5083
#ifdef ARM
5084
    case C_THUMBEXT:
5085
    case C_THUMBEXTFUNC:
5086
#endif
5087
2.60k
#ifdef RS6000COFF_C
5088
2.74k
    case C_HIDEXT:
5089
2.74k
#ifndef AIX_WEAK_SUPPORT
5090
3.89k
    case C_AIX_WEAKEXT:
5091
3.89k
#endif
5092
3.89k
#endif
5093
3.89k
#ifdef C_SYSTEM
5094
4.07k
    case C_SYSTEM:
5095
4.07k
#endif
5096
#ifdef COFF_WITH_PE
5097
    case C_NT_WEAK:
5098
#endif
5099
4.07k
      if (syment->n_scnum == 0)
5100
955
  {
5101
955
    if (syment->n_value == 0)
5102
158
      return COFF_SYMBOL_UNDEFINED;
5103
797
    else
5104
797
      return COFF_SYMBOL_COMMON;
5105
955
  }
5106
3.11k
#ifdef RS6000COFF_C
5107
3.11k
      if (syment->n_sclass == C_HIDEXT)
5108
140
  return COFF_SYMBOL_LOCAL;
5109
2.97k
#endif
5110
2.97k
      return COFF_SYMBOL_GLOBAL;
5111
5112
0
    default:
5113
0
      break;
5114
4.07k
    }
5115
5116
#ifdef COFF_WITH_PE
5117
  if (syment->n_sclass == C_STAT)
5118
    {
5119
      if (syment->n_scnum == 0)
5120
  /* The Microsoft compiler sometimes generates these if a
5121
     small static function is inlined every time it is used.
5122
     The function is discarded, but the symbol table entry
5123
     remains.  */
5124
  return COFF_SYMBOL_LOCAL;
5125
5126
#ifdef STRICT_PE_FORMAT
5127
      /* This is correct for Microsoft generated objects, but it
5128
   breaks gas generated objects.  */
5129
      if (syment->n_value == 0)
5130
  {
5131
    const asection *sec;
5132
    const char *name;
5133
    char buf[SYMNMLEN + 1];
5134
5135
    name = _bfd_coff_internal_syment_name (abfd, syment, buf);
5136
    sec = coff_section_from_bfd_index (abfd, syment->n_scnum);
5137
    if (sec != NULL && name != NULL
5138
        && (strcmp (bfd_section_name (sec), name) == 0))
5139
      return COFF_SYMBOL_PE_SECTION;
5140
  }
5141
#endif
5142
5143
      return COFF_SYMBOL_LOCAL;
5144
    }
5145
5146
  if (syment->n_sclass == C_SECTION)
5147
    {
5148
      /* In some cases in a DLL generated by the Microsoft linker, the
5149
   n_value field will contain garbage.  FIXME: This should
5150
   probably be handled by the swapping function instead.  */
5151
      syment->n_value = 0;
5152
      if (syment->n_scnum == 0)
5153
  return COFF_SYMBOL_UNDEFINED;
5154
      return COFF_SYMBOL_PE_SECTION;
5155
    }
5156
#endif /* COFF_WITH_PE */
5157
5158
  /* If it is not a global symbol, we presume it is a local symbol.  */
5159
0
  if (syment->n_scnum == 0)
5160
0
    {
5161
0
      char buf[SYMNMLEN + 1];
5162
5163
0
      _bfd_error_handler
5164
  /* xgettext:c-format */
5165
0
  (_("warning: %pB: local symbol `%s' has no section"),
5166
0
   abfd, _bfd_coff_internal_syment_name (abfd, syment, buf));
5167
0
    }
5168
5169
0
  return COFF_SYMBOL_LOCAL;
5170
4.07k
}
pe-aarch64.c:coff_classify_symbol
Line
Count
Source
5076
2.00k
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
2.00k
  switch (syment->n_sclass)
5080
2.00k
    {
5081
790
    case C_EXT:
5082
883
    case C_WEAKEXT:
5083
#ifdef ARM
5084
    case C_THUMBEXT:
5085
    case C_THUMBEXTFUNC:
5086
#endif
5087
#ifdef RS6000COFF_C
5088
    case C_HIDEXT:
5089
#ifndef AIX_WEAK_SUPPORT
5090
    case C_AIX_WEAKEXT:
5091
#endif
5092
#endif
5093
883
#ifdef C_SYSTEM
5094
929
    case C_SYSTEM:
5095
929
#endif
5096
929
#ifdef COFF_WITH_PE
5097
1.99k
    case C_NT_WEAK:
5098
1.99k
#endif
5099
1.99k
      if (syment->n_scnum == 0)
5100
204
  {
5101
204
    if (syment->n_value == 0)
5102
30
      return COFF_SYMBOL_UNDEFINED;
5103
174
    else
5104
174
      return COFF_SYMBOL_COMMON;
5105
204
  }
5106
#ifdef RS6000COFF_C
5107
      if (syment->n_sclass == C_HIDEXT)
5108
  return COFF_SYMBOL_LOCAL;
5109
#endif
5110
1.79k
      return COFF_SYMBOL_GLOBAL;
5111
5112
7
    default:
5113
7
      break;
5114
2.00k
    }
5115
5116
7
#ifdef COFF_WITH_PE
5117
7
  if (syment->n_sclass == C_STAT)
5118
0
    {
5119
0
      if (syment->n_scnum == 0)
5120
  /* The Microsoft compiler sometimes generates these if a
5121
     small static function is inlined every time it is used.
5122
     The function is discarded, but the symbol table entry
5123
     remains.  */
5124
0
  return COFF_SYMBOL_LOCAL;
5125
5126
#ifdef STRICT_PE_FORMAT
5127
      /* This is correct for Microsoft generated objects, but it
5128
   breaks gas generated objects.  */
5129
      if (syment->n_value == 0)
5130
  {
5131
    const asection *sec;
5132
    const char *name;
5133
    char buf[SYMNMLEN + 1];
5134
5135
    name = _bfd_coff_internal_syment_name (abfd, syment, buf);
5136
    sec = coff_section_from_bfd_index (abfd, syment->n_scnum);
5137
    if (sec != NULL && name != NULL
5138
        && (strcmp (bfd_section_name (sec), name) == 0))
5139
      return COFF_SYMBOL_PE_SECTION;
5140
  }
5141
#endif
5142
5143
0
      return COFF_SYMBOL_LOCAL;
5144
0
    }
5145
5146
7
  if (syment->n_sclass == C_SECTION)
5147
7
    {
5148
      /* In some cases in a DLL generated by the Microsoft linker, the
5149
   n_value field will contain garbage.  FIXME: This should
5150
   probably be handled by the swapping function instead.  */
5151
7
      syment->n_value = 0;
5152
7
      if (syment->n_scnum == 0)
5153
7
  return COFF_SYMBOL_UNDEFINED;
5154
0
      return COFF_SYMBOL_PE_SECTION;
5155
7
    }
5156
0
#endif /* COFF_WITH_PE */
5157
5158
  /* If it is not a global symbol, we presume it is a local symbol.  */
5159
0
  if (syment->n_scnum == 0)
5160
0
    {
5161
0
      char buf[SYMNMLEN + 1];
5162
5163
0
      _bfd_error_handler
5164
  /* xgettext:c-format */
5165
0
  (_("warning: %pB: local symbol `%s' has no section"),
5166
0
   abfd, _bfd_coff_internal_syment_name (abfd, syment, buf));
5167
0
    }
5168
5169
0
  return COFF_SYMBOL_LOCAL;
5170
7
}
pei-aarch64.c:coff_classify_symbol
Line
Count
Source
5076
1.92k
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
1.92k
  switch (syment->n_sclass)
5080
1.92k
    {
5081
1.01k
    case C_EXT:
5082
1.04k
    case C_WEAKEXT:
5083
#ifdef ARM
5084
    case C_THUMBEXT:
5085
    case C_THUMBEXTFUNC:
5086
#endif
5087
#ifdef RS6000COFF_C
5088
    case C_HIDEXT:
5089
#ifndef AIX_WEAK_SUPPORT
5090
    case C_AIX_WEAKEXT:
5091
#endif
5092
#endif
5093
1.04k
#ifdef C_SYSTEM
5094
1.25k
    case C_SYSTEM:
5095
1.25k
#endif
5096
1.25k
#ifdef COFF_WITH_PE
5097
1.90k
    case C_NT_WEAK:
5098
1.90k
#endif
5099
1.90k
      if (syment->n_scnum == 0)
5100
442
  {
5101
442
    if (syment->n_value == 0)
5102
31
      return COFF_SYMBOL_UNDEFINED;
5103
411
    else
5104
411
      return COFF_SYMBOL_COMMON;
5105
442
  }
5106
#ifdef RS6000COFF_C
5107
      if (syment->n_sclass == C_HIDEXT)
5108
  return COFF_SYMBOL_LOCAL;
5109
#endif
5110
1.46k
      return COFF_SYMBOL_GLOBAL;
5111
5112
18
    default:
5113
18
      break;
5114
1.92k
    }
5115
5116
18
#ifdef COFF_WITH_PE
5117
18
  if (syment->n_sclass == C_STAT)
5118
0
    {
5119
0
      if (syment->n_scnum == 0)
5120
  /* The Microsoft compiler sometimes generates these if a
5121
     small static function is inlined every time it is used.
5122
     The function is discarded, but the symbol table entry
5123
     remains.  */
5124
0
  return COFF_SYMBOL_LOCAL;
5125
5126
#ifdef STRICT_PE_FORMAT
5127
      /* This is correct for Microsoft generated objects, but it
5128
   breaks gas generated objects.  */
5129
      if (syment->n_value == 0)
5130
  {
5131
    const asection *sec;
5132
    const char *name;
5133
    char buf[SYMNMLEN + 1];
5134
5135
    name = _bfd_coff_internal_syment_name (abfd, syment, buf);
5136
    sec = coff_section_from_bfd_index (abfd, syment->n_scnum);
5137
    if (sec != NULL && name != NULL
5138
        && (strcmp (bfd_section_name (sec), name) == 0))
5139
      return COFF_SYMBOL_PE_SECTION;
5140
  }
5141
#endif
5142
5143
0
      return COFF_SYMBOL_LOCAL;
5144
0
    }
5145
5146
18
  if (syment->n_sclass == C_SECTION)
5147
18
    {
5148
      /* In some cases in a DLL generated by the Microsoft linker, the
5149
   n_value field will contain garbage.  FIXME: This should
5150
   probably be handled by the swapping function instead.  */
5151
18
      syment->n_value = 0;
5152
18
      if (syment->n_scnum == 0)
5153
18
  return COFF_SYMBOL_UNDEFINED;
5154
0
      return COFF_SYMBOL_PE_SECTION;
5155
18
    }
5156
0
#endif /* COFF_WITH_PE */
5157
5158
  /* If it is not a global symbol, we presume it is a local symbol.  */
5159
0
  if (syment->n_scnum == 0)
5160
0
    {
5161
0
      char buf[SYMNMLEN + 1];
5162
5163
0
      _bfd_error_handler
5164
  /* xgettext:c-format */
5165
0
  (_("warning: %pB: local symbol `%s' has no section"),
5166
0
   abfd, _bfd_coff_internal_syment_name (abfd, syment, buf));
5167
0
    }
5168
5169
0
  return COFF_SYMBOL_LOCAL;
5170
18
}
pei-ia64.c:coff_classify_symbol
Line
Count
Source
5076
1.82k
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
1.82k
  switch (syment->n_sclass)
5080
1.82k
    {
5081
856
    case C_EXT:
5082
929
    case C_WEAKEXT:
5083
#ifdef ARM
5084
    case C_THUMBEXT:
5085
    case C_THUMBEXTFUNC:
5086
#endif
5087
#ifdef RS6000COFF_C
5088
    case C_HIDEXT:
5089
#ifndef AIX_WEAK_SUPPORT
5090
    case C_AIX_WEAKEXT:
5091
#endif
5092
#endif
5093
929
#ifdef C_SYSTEM
5094
962
    case C_SYSTEM:
5095
962
#endif
5096
962
#ifdef COFF_WITH_PE
5097
1.80k
    case C_NT_WEAK:
5098
1.80k
#endif
5099
1.80k
      if (syment->n_scnum == 0)
5100
152
  {
5101
152
    if (syment->n_value == 0)
5102
20
      return COFF_SYMBOL_UNDEFINED;
5103
132
    else
5104
132
      return COFF_SYMBOL_COMMON;
5105
152
  }
5106
#ifdef RS6000COFF_C
5107
      if (syment->n_sclass == C_HIDEXT)
5108
  return COFF_SYMBOL_LOCAL;
5109
#endif
5110
1.65k
      return COFF_SYMBOL_GLOBAL;
5111
5112
15
    default:
5113
15
      break;
5114
1.82k
    }
5115
5116
15
#ifdef COFF_WITH_PE
5117
15
  if (syment->n_sclass == C_STAT)
5118
0
    {
5119
0
      if (syment->n_scnum == 0)
5120
  /* The Microsoft compiler sometimes generates these if a
5121
     small static function is inlined every time it is used.
5122
     The function is discarded, but the symbol table entry
5123
     remains.  */
5124
0
  return COFF_SYMBOL_LOCAL;
5125
5126
#ifdef STRICT_PE_FORMAT
5127
      /* This is correct for Microsoft generated objects, but it
5128
   breaks gas generated objects.  */
5129
      if (syment->n_value == 0)
5130
  {
5131
    const asection *sec;
5132
    const char *name;
5133
    char buf[SYMNMLEN + 1];
5134
5135
    name = _bfd_coff_internal_syment_name (abfd, syment, buf);
5136
    sec = coff_section_from_bfd_index (abfd, syment->n_scnum);
5137
    if (sec != NULL && name != NULL
5138
        && (strcmp (bfd_section_name (sec), name) == 0))
5139
      return COFF_SYMBOL_PE_SECTION;
5140
  }
5141
#endif
5142
5143
0
      return COFF_SYMBOL_LOCAL;
5144
0
    }
5145
5146
15
  if (syment->n_sclass == C_SECTION)
5147
15
    {
5148
      /* In some cases in a DLL generated by the Microsoft linker, the
5149
   n_value field will contain garbage.  FIXME: This should
5150
   probably be handled by the swapping function instead.  */
5151
15
      syment->n_value = 0;
5152
15
      if (syment->n_scnum == 0)
5153
15
  return COFF_SYMBOL_UNDEFINED;
5154
0
      return COFF_SYMBOL_PE_SECTION;
5155
15
    }
5156
0
#endif /* COFF_WITH_PE */
5157
5158
  /* If it is not a global symbol, we presume it is a local symbol.  */
5159
0
  if (syment->n_scnum == 0)
5160
0
    {
5161
0
      char buf[SYMNMLEN + 1];
5162
5163
0
      _bfd_error_handler
5164
  /* xgettext:c-format */
5165
0
  (_("warning: %pB: local symbol `%s' has no section"),
5166
0
   abfd, _bfd_coff_internal_syment_name (abfd, syment, buf));
5167
0
    }
5168
5169
0
  return COFF_SYMBOL_LOCAL;
5170
15
}
pei-loongarch64.c:coff_classify_symbol
Line
Count
Source
5076
1.52k
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
1.52k
  switch (syment->n_sclass)
5080
1.52k
    {
5081
798
    case C_EXT:
5082
835
    case C_WEAKEXT:
5083
#ifdef ARM
5084
    case C_THUMBEXT:
5085
    case C_THUMBEXTFUNC:
5086
#endif
5087
#ifdef RS6000COFF_C
5088
    case C_HIDEXT:
5089
#ifndef AIX_WEAK_SUPPORT
5090
    case C_AIX_WEAKEXT:
5091
#endif
5092
#endif
5093
835
#ifdef C_SYSTEM
5094
1.03k
    case C_SYSTEM:
5095
1.03k
#endif
5096
1.03k
#ifdef COFF_WITH_PE
5097
1.51k
    case C_NT_WEAK:
5098
1.51k
#endif
5099
1.51k
      if (syment->n_scnum == 0)
5100
409
  {
5101
409
    if (syment->n_value == 0)
5102
137
      return COFF_SYMBOL_UNDEFINED;
5103
272
    else
5104
272
      return COFF_SYMBOL_COMMON;
5105
409
  }
5106
#ifdef RS6000COFF_C
5107
      if (syment->n_sclass == C_HIDEXT)
5108
  return COFF_SYMBOL_LOCAL;
5109
#endif
5110
1.11k
      return COFF_SYMBOL_GLOBAL;
5111
5112
6
    default:
5113
6
      break;
5114
1.52k
    }
5115
5116
6
#ifdef COFF_WITH_PE
5117
6
  if (syment->n_sclass == C_STAT)
5118
0
    {
5119
0
      if (syment->n_scnum == 0)
5120
  /* The Microsoft compiler sometimes generates these if a
5121
     small static function is inlined every time it is used.
5122
     The function is discarded, but the symbol table entry
5123
     remains.  */
5124
0
  return COFF_SYMBOL_LOCAL;
5125
5126
#ifdef STRICT_PE_FORMAT
5127
      /* This is correct for Microsoft generated objects, but it
5128
   breaks gas generated objects.  */
5129
      if (syment->n_value == 0)
5130
  {
5131
    const asection *sec;
5132
    const char *name;
5133
    char buf[SYMNMLEN + 1];
5134
5135
    name = _bfd_coff_internal_syment_name (abfd, syment, buf);
5136
    sec = coff_section_from_bfd_index (abfd, syment->n_scnum);
5137
    if (sec != NULL && name != NULL
5138
        && (strcmp (bfd_section_name (sec), name) == 0))
5139
      return COFF_SYMBOL_PE_SECTION;
5140
  }
5141
#endif
5142
5143
0
      return COFF_SYMBOL_LOCAL;
5144
0
    }
5145
5146
6
  if (syment->n_sclass == C_SECTION)
5147
6
    {
5148
      /* In some cases in a DLL generated by the Microsoft linker, the
5149
   n_value field will contain garbage.  FIXME: This should
5150
   probably be handled by the swapping function instead.  */
5151
6
      syment->n_value = 0;
5152
6
      if (syment->n_scnum == 0)
5153
6
  return COFF_SYMBOL_UNDEFINED;
5154
0
      return COFF_SYMBOL_PE_SECTION;
5155
6
    }
5156
0
#endif /* COFF_WITH_PE */
5157
5158
  /* If it is not a global symbol, we presume it is a local symbol.  */
5159
0
  if (syment->n_scnum == 0)
5160
0
    {
5161
0
      char buf[SYMNMLEN + 1];
5162
5163
0
      _bfd_error_handler
5164
  /* xgettext:c-format */
5165
0
  (_("warning: %pB: local symbol `%s' has no section"),
5166
0
   abfd, _bfd_coff_internal_syment_name (abfd, syment, buf));
5167
0
    }
5168
5169
0
  return COFF_SYMBOL_LOCAL;
5170
6
}
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
5076
4.55k
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
4.55k
  switch (syment->n_sclass)
5080
4.55k
    {
5081
3.26k
    case C_EXT:
5082
3.48k
    case C_WEAKEXT:
5083
#ifdef ARM
5084
    case C_THUMBEXT:
5085
    case C_THUMBEXTFUNC:
5086
#endif
5087
3.48k
#ifdef RS6000COFF_C
5088
3.64k
    case C_HIDEXT:
5089
3.64k
#ifndef AIX_WEAK_SUPPORT
5090
4.46k
    case C_AIX_WEAKEXT:
5091
4.46k
#endif
5092
4.46k
#endif
5093
4.46k
#ifdef C_SYSTEM
5094
4.55k
    case C_SYSTEM:
5095
4.55k
#endif
5096
#ifdef COFF_WITH_PE
5097
    case C_NT_WEAK:
5098
#endif
5099
4.55k
      if (syment->n_scnum == 0)
5100
930
  {
5101
930
    if (syment->n_value == 0)
5102
39
      return COFF_SYMBOL_UNDEFINED;
5103
891
    else
5104
891
      return COFF_SYMBOL_COMMON;
5105
930
  }
5106
3.62k
#ifdef RS6000COFF_C
5107
3.62k
      if (syment->n_sclass == C_HIDEXT)
5108
145
  return COFF_SYMBOL_LOCAL;
5109
3.48k
#endif
5110
3.48k
      return COFF_SYMBOL_GLOBAL;
5111
5112
0
    default:
5113
0
      break;
5114
4.55k
    }
5115
5116
#ifdef COFF_WITH_PE
5117
  if (syment->n_sclass == C_STAT)
5118
    {
5119
      if (syment->n_scnum == 0)
5120
  /* The Microsoft compiler sometimes generates these if a
5121
     small static function is inlined every time it is used.
5122
     The function is discarded, but the symbol table entry
5123
     remains.  */
5124
  return COFF_SYMBOL_LOCAL;
5125
5126
#ifdef STRICT_PE_FORMAT
5127
      /* This is correct for Microsoft generated objects, but it
5128
   breaks gas generated objects.  */
5129
      if (syment->n_value == 0)
5130
  {
5131
    const asection *sec;
5132
    const char *name;
5133
    char buf[SYMNMLEN + 1];
5134
5135
    name = _bfd_coff_internal_syment_name (abfd, syment, buf);
5136
    sec = coff_section_from_bfd_index (abfd, syment->n_scnum);
5137
    if (sec != NULL && name != NULL
5138
        && (strcmp (bfd_section_name (sec), name) == 0))
5139
      return COFF_SYMBOL_PE_SECTION;
5140
  }
5141
#endif
5142
5143
      return COFF_SYMBOL_LOCAL;
5144
    }
5145
5146
  if (syment->n_sclass == C_SECTION)
5147
    {
5148
      /* In some cases in a DLL generated by the Microsoft linker, the
5149
   n_value field will contain garbage.  FIXME: This should
5150
   probably be handled by the swapping function instead.  */
5151
      syment->n_value = 0;
5152
      if (syment->n_scnum == 0)
5153
  return COFF_SYMBOL_UNDEFINED;
5154
      return COFF_SYMBOL_PE_SECTION;
5155
    }
5156
#endif /* COFF_WITH_PE */
5157
5158
  /* If it is not a global symbol, we presume it is a local symbol.  */
5159
0
  if (syment->n_scnum == 0)
5160
0
    {
5161
0
      char buf[SYMNMLEN + 1];
5162
5163
0
      _bfd_error_handler
5164
  /* xgettext:c-format */
5165
0
  (_("warning: %pB: local symbol `%s' has no section"),
5166
0
   abfd, _bfd_coff_internal_syment_name (abfd, syment, buf));
5167
0
    }
5168
5169
0
  return COFF_SYMBOL_LOCAL;
5170
4.55k
}
coff-sh.c:coff_classify_symbol
Line
Count
Source
5076
994
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
994
  switch (syment->n_sclass)
5080
994
    {
5081
840
    case C_EXT:
5082
870
    case C_WEAKEXT:
5083
#ifdef ARM
5084
    case C_THUMBEXT:
5085
    case C_THUMBEXTFUNC:
5086
#endif
5087
#ifdef RS6000COFF_C
5088
    case C_HIDEXT:
5089
#ifndef AIX_WEAK_SUPPORT
5090
    case C_AIX_WEAKEXT:
5091
#endif
5092
#endif
5093
870
#ifdef C_SYSTEM
5094
994
    case C_SYSTEM:
5095
994
#endif
5096
#ifdef COFF_WITH_PE
5097
    case C_NT_WEAK:
5098
#endif
5099
994
      if (syment->n_scnum == 0)
5100
112
  {
5101
112
    if (syment->n_value == 0)
5102
17
      return COFF_SYMBOL_UNDEFINED;
5103
95
    else
5104
95
      return COFF_SYMBOL_COMMON;
5105
112
  }
5106
#ifdef RS6000COFF_C
5107
      if (syment->n_sclass == C_HIDEXT)
5108
  return COFF_SYMBOL_LOCAL;
5109
#endif
5110
882
      return COFF_SYMBOL_GLOBAL;
5111
5112
0
    default:
5113
0
      break;
5114
994
    }
5115
5116
#ifdef COFF_WITH_PE
5117
  if (syment->n_sclass == C_STAT)
5118
    {
5119
      if (syment->n_scnum == 0)
5120
  /* The Microsoft compiler sometimes generates these if a
5121
     small static function is inlined every time it is used.
5122
     The function is discarded, but the symbol table entry
5123
     remains.  */
5124
  return COFF_SYMBOL_LOCAL;
5125
5126
#ifdef STRICT_PE_FORMAT
5127
      /* This is correct for Microsoft generated objects, but it
5128
   breaks gas generated objects.  */
5129
      if (syment->n_value == 0)
5130
  {
5131
    const asection *sec;
5132
    const char *name;
5133
    char buf[SYMNMLEN + 1];
5134
5135
    name = _bfd_coff_internal_syment_name (abfd, syment, buf);
5136
    sec = coff_section_from_bfd_index (abfd, syment->n_scnum);
5137
    if (sec != NULL && name != NULL
5138
        && (strcmp (bfd_section_name (sec), name) == 0))
5139
      return COFF_SYMBOL_PE_SECTION;
5140
  }
5141
#endif
5142
5143
      return COFF_SYMBOL_LOCAL;
5144
    }
5145
5146
  if (syment->n_sclass == C_SECTION)
5147
    {
5148
      /* In some cases in a DLL generated by the Microsoft linker, the
5149
   n_value field will contain garbage.  FIXME: This should
5150
   probably be handled by the swapping function instead.  */
5151
      syment->n_value = 0;
5152
      if (syment->n_scnum == 0)
5153
  return COFF_SYMBOL_UNDEFINED;
5154
      return COFF_SYMBOL_PE_SECTION;
5155
    }
5156
#endif /* COFF_WITH_PE */
5157
5158
  /* If it is not a global symbol, we presume it is a local symbol.  */
5159
0
  if (syment->n_scnum == 0)
5160
0
    {
5161
0
      char buf[SYMNMLEN + 1];
5162
5163
0
      _bfd_error_handler
5164
  /* xgettext:c-format */
5165
0
  (_("warning: %pB: local symbol `%s' has no section"),
5166
0
   abfd, _bfd_coff_internal_syment_name (abfd, syment, buf));
5167
0
    }
5168
5169
0
  return COFF_SYMBOL_LOCAL;
5170
994
}
Unexecuted instantiation: coff-stgo32.c:coff_classify_symbol
coff-tic30.c:coff_classify_symbol
Line
Count
Source
5076
666
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
666
  switch (syment->n_sclass)
5080
666
    {
5081
506
    case C_EXT:
5082
560
    case C_WEAKEXT:
5083
#ifdef ARM
5084
    case C_THUMBEXT:
5085
    case C_THUMBEXTFUNC:
5086
#endif
5087
#ifdef RS6000COFF_C
5088
    case C_HIDEXT:
5089
#ifndef AIX_WEAK_SUPPORT
5090
    case C_AIX_WEAKEXT:
5091
#endif
5092
#endif
5093
560
#ifdef C_SYSTEM
5094
666
    case C_SYSTEM:
5095
666
#endif
5096
#ifdef COFF_WITH_PE
5097
    case C_NT_WEAK:
5098
#endif
5099
666
      if (syment->n_scnum == 0)
5100
86
  {
5101
86
    if (syment->n_value == 0)
5102
9
      return COFF_SYMBOL_UNDEFINED;
5103
77
    else
5104
77
      return COFF_SYMBOL_COMMON;
5105
86
  }
5106
#ifdef RS6000COFF_C
5107
      if (syment->n_sclass == C_HIDEXT)
5108
  return COFF_SYMBOL_LOCAL;
5109
#endif
5110
580
      return COFF_SYMBOL_GLOBAL;
5111
5112
0
    default:
5113
0
      break;
5114
666
    }
5115
5116
#ifdef COFF_WITH_PE
5117
  if (syment->n_sclass == C_STAT)
5118
    {
5119
      if (syment->n_scnum == 0)
5120
  /* The Microsoft compiler sometimes generates these if a
5121
     small static function is inlined every time it is used.
5122
     The function is discarded, but the symbol table entry
5123
     remains.  */
5124
  return COFF_SYMBOL_LOCAL;
5125
5126
#ifdef STRICT_PE_FORMAT
5127
      /* This is correct for Microsoft generated objects, but it
5128
   breaks gas generated objects.  */
5129
      if (syment->n_value == 0)
5130
  {
5131
    const asection *sec;
5132
    const char *name;
5133
    char buf[SYMNMLEN + 1];
5134
5135
    name = _bfd_coff_internal_syment_name (abfd, syment, buf);
5136
    sec = coff_section_from_bfd_index (abfd, syment->n_scnum);
5137
    if (sec != NULL && name != NULL
5138
        && (strcmp (bfd_section_name (sec), name) == 0))
5139
      return COFF_SYMBOL_PE_SECTION;
5140
  }
5141
#endif
5142
5143
      return COFF_SYMBOL_LOCAL;
5144
    }
5145
5146
  if (syment->n_sclass == C_SECTION)
5147
    {
5148
      /* In some cases in a DLL generated by the Microsoft linker, the
5149
   n_value field will contain garbage.  FIXME: This should
5150
   probably be handled by the swapping function instead.  */
5151
      syment->n_value = 0;
5152
      if (syment->n_scnum == 0)
5153
  return COFF_SYMBOL_UNDEFINED;
5154
      return COFF_SYMBOL_PE_SECTION;
5155
    }
5156
#endif /* COFF_WITH_PE */
5157
5158
  /* If it is not a global symbol, we presume it is a local symbol.  */
5159
0
  if (syment->n_scnum == 0)
5160
0
    {
5161
0
      char buf[SYMNMLEN + 1];
5162
5163
0
      _bfd_error_handler
5164
  /* xgettext:c-format */
5165
0
  (_("warning: %pB: local symbol `%s' has no section"),
5166
0
   abfd, _bfd_coff_internal_syment_name (abfd, syment, buf));
5167
0
    }
5168
5169
0
  return COFF_SYMBOL_LOCAL;
5170
666
}
Unexecuted instantiation: coff-tic4x.c:coff_classify_symbol
coff-tic54x.c:coff_classify_symbol
Line
Count
Source
5076
2.27k
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
2.27k
  switch (syment->n_sclass)
5080
2.27k
    {
5081
1.88k
    case C_EXT:
5082
1.96k
    case C_WEAKEXT:
5083
#ifdef ARM
5084
    case C_THUMBEXT:
5085
    case C_THUMBEXTFUNC:
5086
#endif
5087
#ifdef RS6000COFF_C
5088
    case C_HIDEXT:
5089
#ifndef AIX_WEAK_SUPPORT
5090
    case C_AIX_WEAKEXT:
5091
#endif
5092
#endif
5093
1.96k
#ifdef C_SYSTEM
5094
2.27k
    case C_SYSTEM:
5095
2.27k
#endif
5096
#ifdef COFF_WITH_PE
5097
    case C_NT_WEAK:
5098
#endif
5099
2.27k
      if (syment->n_scnum == 0)
5100
519
  {
5101
519
    if (syment->n_value == 0)
5102
106
      return COFF_SYMBOL_UNDEFINED;
5103
413
    else
5104
413
      return COFF_SYMBOL_COMMON;
5105
519
  }
5106
#ifdef RS6000COFF_C
5107
      if (syment->n_sclass == C_HIDEXT)
5108
  return COFF_SYMBOL_LOCAL;
5109
#endif
5110
1.76k
      return COFF_SYMBOL_GLOBAL;
5111
5112
0
    default:
5113
0
      break;
5114
2.27k
    }
5115
5116
#ifdef COFF_WITH_PE
5117
  if (syment->n_sclass == C_STAT)
5118
    {
5119
      if (syment->n_scnum == 0)
5120
  /* The Microsoft compiler sometimes generates these if a
5121
     small static function is inlined every time it is used.
5122
     The function is discarded, but the symbol table entry
5123
     remains.  */
5124
  return COFF_SYMBOL_LOCAL;
5125
5126
#ifdef STRICT_PE_FORMAT
5127
      /* This is correct for Microsoft generated objects, but it
5128
   breaks gas generated objects.  */
5129
      if (syment->n_value == 0)
5130
  {
5131
    const asection *sec;
5132
    const char *name;
5133
    char buf[SYMNMLEN + 1];
5134
5135
    name = _bfd_coff_internal_syment_name (abfd, syment, buf);
5136
    sec = coff_section_from_bfd_index (abfd, syment->n_scnum);
5137
    if (sec != NULL && name != NULL
5138
        && (strcmp (bfd_section_name (sec), name) == 0))
5139
      return COFF_SYMBOL_PE_SECTION;
5140
  }
5141
#endif
5142
5143
      return COFF_SYMBOL_LOCAL;
5144
    }
5145
5146
  if (syment->n_sclass == C_SECTION)
5147
    {
5148
      /* In some cases in a DLL generated by the Microsoft linker, the
5149
   n_value field will contain garbage.  FIXME: This should
5150
   probably be handled by the swapping function instead.  */
5151
      syment->n_value = 0;
5152
      if (syment->n_scnum == 0)
5153
  return COFF_SYMBOL_UNDEFINED;
5154
      return COFF_SYMBOL_PE_SECTION;
5155
    }
5156
#endif /* COFF_WITH_PE */
5157
5158
  /* If it is not a global symbol, we presume it is a local symbol.  */
5159
0
  if (syment->n_scnum == 0)
5160
0
    {
5161
0
      char buf[SYMNMLEN + 1];
5162
5163
0
      _bfd_error_handler
5164
  /* xgettext:c-format */
5165
0
  (_("warning: %pB: local symbol `%s' has no section"),
5166
0
   abfd, _bfd_coff_internal_syment_name (abfd, syment, buf));
5167
0
    }
5168
5169
0
  return COFF_SYMBOL_LOCAL;
5170
2.27k
}
coff-z80.c:coff_classify_symbol
Line
Count
Source
5076
595
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
595
  switch (syment->n_sclass)
5080
595
    {
5081
522
    case C_EXT:
5082
549
    case C_WEAKEXT:
5083
#ifdef ARM
5084
    case C_THUMBEXT:
5085
    case C_THUMBEXTFUNC:
5086
#endif
5087
#ifdef RS6000COFF_C
5088
    case C_HIDEXT:
5089
#ifndef AIX_WEAK_SUPPORT
5090
    case C_AIX_WEAKEXT:
5091
#endif
5092
#endif
5093
549
#ifdef C_SYSTEM
5094
595
    case C_SYSTEM:
5095
595
#endif
5096
#ifdef COFF_WITH_PE
5097
    case C_NT_WEAK:
5098
#endif
5099
595
      if (syment->n_scnum == 0)
5100
113
  {
5101
113
    if (syment->n_value == 0)
5102
27
      return COFF_SYMBOL_UNDEFINED;
5103
86
    else
5104
86
      return COFF_SYMBOL_COMMON;
5105
113
  }
5106
#ifdef RS6000COFF_C
5107
      if (syment->n_sclass == C_HIDEXT)
5108
  return COFF_SYMBOL_LOCAL;
5109
#endif
5110
482
      return COFF_SYMBOL_GLOBAL;
5111
5112
0
    default:
5113
0
      break;
5114
595
    }
5115
5116
#ifdef COFF_WITH_PE
5117
  if (syment->n_sclass == C_STAT)
5118
    {
5119
      if (syment->n_scnum == 0)
5120
  /* The Microsoft compiler sometimes generates these if a
5121
     small static function is inlined every time it is used.
5122
     The function is discarded, but the symbol table entry
5123
     remains.  */
5124
  return COFF_SYMBOL_LOCAL;
5125
5126
#ifdef STRICT_PE_FORMAT
5127
      /* This is correct for Microsoft generated objects, but it
5128
   breaks gas generated objects.  */
5129
      if (syment->n_value == 0)
5130
  {
5131
    const asection *sec;
5132
    const char *name;
5133
    char buf[SYMNMLEN + 1];
5134
5135
    name = _bfd_coff_internal_syment_name (abfd, syment, buf);
5136
    sec = coff_section_from_bfd_index (abfd, syment->n_scnum);
5137
    if (sec != NULL && name != NULL
5138
        && (strcmp (bfd_section_name (sec), name) == 0))
5139
      return COFF_SYMBOL_PE_SECTION;
5140
  }
5141
#endif
5142
5143
      return COFF_SYMBOL_LOCAL;
5144
    }
5145
5146
  if (syment->n_sclass == C_SECTION)
5147
    {
5148
      /* In some cases in a DLL generated by the Microsoft linker, the
5149
   n_value field will contain garbage.  FIXME: This should
5150
   probably be handled by the swapping function instead.  */
5151
      syment->n_value = 0;
5152
      if (syment->n_scnum == 0)
5153
  return COFF_SYMBOL_UNDEFINED;
5154
      return COFF_SYMBOL_PE_SECTION;
5155
    }
5156
#endif /* COFF_WITH_PE */
5157
5158
  /* If it is not a global symbol, we presume it is a local symbol.  */
5159
0
  if (syment->n_scnum == 0)
5160
0
    {
5161
0
      char buf[SYMNMLEN + 1];
5162
5163
0
      _bfd_error_handler
5164
  /* xgettext:c-format */
5165
0
  (_("warning: %pB: local symbol `%s' has no section"),
5166
0
   abfd, _bfd_coff_internal_syment_name (abfd, syment, buf));
5167
0
    }
5168
5169
0
  return COFF_SYMBOL_LOCAL;
5170
595
}
coff-z8k.c:coff_classify_symbol
Line
Count
Source
5076
1.83k
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
1.83k
  switch (syment->n_sclass)
5080
1.83k
    {
5081
1.60k
    case C_EXT:
5082
1.74k
    case C_WEAKEXT:
5083
#ifdef ARM
5084
    case C_THUMBEXT:
5085
    case C_THUMBEXTFUNC:
5086
#endif
5087
#ifdef RS6000COFF_C
5088
    case C_HIDEXT:
5089
#ifndef AIX_WEAK_SUPPORT
5090
    case C_AIX_WEAKEXT:
5091
#endif
5092
#endif
5093
1.74k
#ifdef C_SYSTEM
5094
1.83k
    case C_SYSTEM:
5095
1.83k
#endif
5096
#ifdef COFF_WITH_PE
5097
    case C_NT_WEAK:
5098
#endif
5099
1.83k
      if (syment->n_scnum == 0)
5100
435
  {
5101
435
    if (syment->n_value == 0)
5102
31
      return COFF_SYMBOL_UNDEFINED;
5103
404
    else
5104
404
      return COFF_SYMBOL_COMMON;
5105
435
  }
5106
#ifdef RS6000COFF_C
5107
      if (syment->n_sclass == C_HIDEXT)
5108
  return COFF_SYMBOL_LOCAL;
5109
#endif
5110
1.39k
      return COFF_SYMBOL_GLOBAL;
5111
5112
0
    default:
5113
0
      break;
5114
1.83k
    }
5115
5116
#ifdef COFF_WITH_PE
5117
  if (syment->n_sclass == C_STAT)
5118
    {
5119
      if (syment->n_scnum == 0)
5120
  /* The Microsoft compiler sometimes generates these if a
5121
     small static function is inlined every time it is used.
5122
     The function is discarded, but the symbol table entry
5123
     remains.  */
5124
  return COFF_SYMBOL_LOCAL;
5125
5126
#ifdef STRICT_PE_FORMAT
5127
      /* This is correct for Microsoft generated objects, but it
5128
   breaks gas generated objects.  */
5129
      if (syment->n_value == 0)
5130
  {
5131
    const asection *sec;
5132
    const char *name;
5133
    char buf[SYMNMLEN + 1];
5134
5135
    name = _bfd_coff_internal_syment_name (abfd, syment, buf);
5136
    sec = coff_section_from_bfd_index (abfd, syment->n_scnum);
5137
    if (sec != NULL && name != NULL
5138
        && (strcmp (bfd_section_name (sec), name) == 0))
5139
      return COFF_SYMBOL_PE_SECTION;
5140
  }
5141
#endif
5142
5143
      return COFF_SYMBOL_LOCAL;
5144
    }
5145
5146
  if (syment->n_sclass == C_SECTION)
5147
    {
5148
      /* In some cases in a DLL generated by the Microsoft linker, the
5149
   n_value field will contain garbage.  FIXME: This should
5150
   probably be handled by the swapping function instead.  */
5151
      syment->n_value = 0;
5152
      if (syment->n_scnum == 0)
5153
  return COFF_SYMBOL_UNDEFINED;
5154
      return COFF_SYMBOL_PE_SECTION;
5155
    }
5156
#endif /* COFF_WITH_PE */
5157
5158
  /* If it is not a global symbol, we presume it is a local symbol.  */
5159
0
  if (syment->n_scnum == 0)
5160
0
    {
5161
0
      char buf[SYMNMLEN + 1];
5162
5163
0
      _bfd_error_handler
5164
  /* xgettext:c-format */
5165
0
  (_("warning: %pB: local symbol `%s' has no section"),
5166
0
   abfd, _bfd_coff_internal_syment_name (abfd, syment, buf));
5167
0
    }
5168
5169
0
  return COFF_SYMBOL_LOCAL;
5170
1.83k
}
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
5076
4.14k
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
4.14k
  switch (syment->n_sclass)
5080
4.14k
    {
5081
2.62k
    case C_EXT:
5082
2.74k
    case C_WEAKEXT:
5083
#ifdef ARM
5084
    case C_THUMBEXT:
5085
    case C_THUMBEXTFUNC:
5086
#endif
5087
#ifdef RS6000COFF_C
5088
    case C_HIDEXT:
5089
#ifndef AIX_WEAK_SUPPORT
5090
    case C_AIX_WEAKEXT:
5091
#endif
5092
#endif
5093
2.74k
#ifdef C_SYSTEM
5094
2.93k
    case C_SYSTEM:
5095
2.93k
#endif
5096
2.93k
#ifdef COFF_WITH_PE
5097
4.09k
    case C_NT_WEAK:
5098
4.09k
#endif
5099
4.09k
      if (syment->n_scnum == 0)
5100
378
  {
5101
378
    if (syment->n_value == 0)
5102
57
      return COFF_SYMBOL_UNDEFINED;
5103
321
    else
5104
321
      return COFF_SYMBOL_COMMON;
5105
378
  }
5106
#ifdef RS6000COFF_C
5107
      if (syment->n_sclass == C_HIDEXT)
5108
  return COFF_SYMBOL_LOCAL;
5109
#endif
5110
3.72k
      return COFF_SYMBOL_GLOBAL;
5111
5112
43
    default:
5113
43
      break;
5114
4.14k
    }
5115
5116
43
#ifdef COFF_WITH_PE
5117
43
  if (syment->n_sclass == C_STAT)
5118
0
    {
5119
0
      if (syment->n_scnum == 0)
5120
  /* The Microsoft compiler sometimes generates these if a
5121
     small static function is inlined every time it is used.
5122
     The function is discarded, but the symbol table entry
5123
     remains.  */
5124
0
  return COFF_SYMBOL_LOCAL;
5125
5126
#ifdef STRICT_PE_FORMAT
5127
      /* This is correct for Microsoft generated objects, but it
5128
   breaks gas generated objects.  */
5129
      if (syment->n_value == 0)
5130
  {
5131
    const asection *sec;
5132
    const char *name;
5133
    char buf[SYMNMLEN + 1];
5134
5135
    name = _bfd_coff_internal_syment_name (abfd, syment, buf);
5136
    sec = coff_section_from_bfd_index (abfd, syment->n_scnum);
5137
    if (sec != NULL && name != NULL
5138
        && (strcmp (bfd_section_name (sec), name) == 0))
5139
      return COFF_SYMBOL_PE_SECTION;
5140
  }
5141
#endif
5142
5143
0
      return COFF_SYMBOL_LOCAL;
5144
0
    }
5145
5146
43
  if (syment->n_sclass == C_SECTION)
5147
43
    {
5148
      /* In some cases in a DLL generated by the Microsoft linker, the
5149
   n_value field will contain garbage.  FIXME: This should
5150
   probably be handled by the swapping function instead.  */
5151
43
      syment->n_value = 0;
5152
43
      if (syment->n_scnum == 0)
5153
43
  return COFF_SYMBOL_UNDEFINED;
5154
0
      return COFF_SYMBOL_PE_SECTION;
5155
43
    }
5156
0
#endif /* COFF_WITH_PE */
5157
5158
  /* If it is not a global symbol, we presume it is a local symbol.  */
5159
0
  if (syment->n_scnum == 0)
5160
0
    {
5161
0
      char buf[SYMNMLEN + 1];
5162
5163
0
      _bfd_error_handler
5164
  /* xgettext:c-format */
5165
0
  (_("warning: %pB: local symbol `%s' has no section"),
5166
0
   abfd, _bfd_coff_internal_syment_name (abfd, syment, buf));
5167
0
    }
5168
5169
0
  return COFF_SYMBOL_LOCAL;
5170
43
}
pe-mcore.c:coff_classify_symbol
Line
Count
Source
5076
3.24k
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
3.24k
  switch (syment->n_sclass)
5080
3.24k
    {
5081
1.80k
    case C_EXT:
5082
1.89k
    case C_WEAKEXT:
5083
#ifdef ARM
5084
    case C_THUMBEXT:
5085
    case C_THUMBEXTFUNC:
5086
#endif
5087
#ifdef RS6000COFF_C
5088
    case C_HIDEXT:
5089
#ifndef AIX_WEAK_SUPPORT
5090
    case C_AIX_WEAKEXT:
5091
#endif
5092
#endif
5093
1.89k
#ifdef C_SYSTEM
5094
2.14k
    case C_SYSTEM:
5095
2.14k
#endif
5096
2.14k
#ifdef COFF_WITH_PE
5097
3.22k
    case C_NT_WEAK:
5098
3.22k
#endif
5099
3.22k
      if (syment->n_scnum == 0)
5100
233
  {
5101
233
    if (syment->n_value == 0)
5102
25
      return COFF_SYMBOL_UNDEFINED;
5103
208
    else
5104
208
      return COFF_SYMBOL_COMMON;
5105
233
  }
5106
#ifdef RS6000COFF_C
5107
      if (syment->n_sclass == C_HIDEXT)
5108
  return COFF_SYMBOL_LOCAL;
5109
#endif
5110
2.99k
      return COFF_SYMBOL_GLOBAL;
5111
5112
20
    default:
5113
20
      break;
5114
3.24k
    }
5115
5116
20
#ifdef COFF_WITH_PE
5117
20
  if (syment->n_sclass == C_STAT)
5118
0
    {
5119
0
      if (syment->n_scnum == 0)
5120
  /* The Microsoft compiler sometimes generates these if a
5121
     small static function is inlined every time it is used.
5122
     The function is discarded, but the symbol table entry
5123
     remains.  */
5124
0
  return COFF_SYMBOL_LOCAL;
5125
5126
#ifdef STRICT_PE_FORMAT
5127
      /* This is correct for Microsoft generated objects, but it
5128
   breaks gas generated objects.  */
5129
      if (syment->n_value == 0)
5130
  {
5131
    const asection *sec;
5132
    const char *name;
5133
    char buf[SYMNMLEN + 1];
5134
5135
    name = _bfd_coff_internal_syment_name (abfd, syment, buf);
5136
    sec = coff_section_from_bfd_index (abfd, syment->n_scnum);
5137
    if (sec != NULL && name != NULL
5138
        && (strcmp (bfd_section_name (sec), name) == 0))
5139
      return COFF_SYMBOL_PE_SECTION;
5140
  }
5141
#endif
5142
5143
0
      return COFF_SYMBOL_LOCAL;
5144
0
    }
5145
5146
20
  if (syment->n_sclass == C_SECTION)
5147
20
    {
5148
      /* In some cases in a DLL generated by the Microsoft linker, the
5149
   n_value field will contain garbage.  FIXME: This should
5150
   probably be handled by the swapping function instead.  */
5151
20
      syment->n_value = 0;
5152
20
      if (syment->n_scnum == 0)
5153
20
  return COFF_SYMBOL_UNDEFINED;
5154
0
      return COFF_SYMBOL_PE_SECTION;
5155
20
    }
5156
0
#endif /* COFF_WITH_PE */
5157
5158
  /* If it is not a global symbol, we presume it is a local symbol.  */
5159
0
  if (syment->n_scnum == 0)
5160
0
    {
5161
0
      char buf[SYMNMLEN + 1];
5162
5163
0
      _bfd_error_handler
5164
  /* xgettext:c-format */
5165
0
  (_("warning: %pB: local symbol `%s' has no section"),
5166
0
   abfd, _bfd_coff_internal_syment_name (abfd, syment, buf));
5167
0
    }
5168
5169
0
  return COFF_SYMBOL_LOCAL;
5170
20
}
pe-sh.c:coff_classify_symbol
Line
Count
Source
5076
1.33k
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
1.33k
  switch (syment->n_sclass)
5080
1.33k
    {
5081
774
    case C_EXT:
5082
801
    case C_WEAKEXT:
5083
#ifdef ARM
5084
    case C_THUMBEXT:
5085
    case C_THUMBEXTFUNC:
5086
#endif
5087
#ifdef RS6000COFF_C
5088
    case C_HIDEXT:
5089
#ifndef AIX_WEAK_SUPPORT
5090
    case C_AIX_WEAKEXT:
5091
#endif
5092
#endif
5093
801
#ifdef C_SYSTEM
5094
937
    case C_SYSTEM:
5095
937
#endif
5096
937
#ifdef COFF_WITH_PE
5097
1.32k
    case C_NT_WEAK:
5098
1.32k
#endif
5099
1.32k
      if (syment->n_scnum == 0)
5100
174
  {
5101
174
    if (syment->n_value == 0)
5102
27
      return COFF_SYMBOL_UNDEFINED;
5103
147
    else
5104
147
      return COFF_SYMBOL_COMMON;
5105
174
  }
5106
#ifdef RS6000COFF_C
5107
      if (syment->n_sclass == C_HIDEXT)
5108
  return COFF_SYMBOL_LOCAL;
5109
#endif
5110
1.14k
      return COFF_SYMBOL_GLOBAL;
5111
5112
12
    default:
5113
12
      break;
5114
1.33k
    }
5115
5116
12
#ifdef COFF_WITH_PE
5117
12
  if (syment->n_sclass == C_STAT)
5118
0
    {
5119
0
      if (syment->n_scnum == 0)
5120
  /* The Microsoft compiler sometimes generates these if a
5121
     small static function is inlined every time it is used.
5122
     The function is discarded, but the symbol table entry
5123
     remains.  */
5124
0
  return COFF_SYMBOL_LOCAL;
5125
5126
#ifdef STRICT_PE_FORMAT
5127
      /* This is correct for Microsoft generated objects, but it
5128
   breaks gas generated objects.  */
5129
      if (syment->n_value == 0)
5130
  {
5131
    const asection *sec;
5132
    const char *name;
5133
    char buf[SYMNMLEN + 1];
5134
5135
    name = _bfd_coff_internal_syment_name (abfd, syment, buf);
5136
    sec = coff_section_from_bfd_index (abfd, syment->n_scnum);
5137
    if (sec != NULL && name != NULL
5138
        && (strcmp (bfd_section_name (sec), name) == 0))
5139
      return COFF_SYMBOL_PE_SECTION;
5140
  }
5141
#endif
5142
5143
0
      return COFF_SYMBOL_LOCAL;
5144
0
    }
5145
5146
12
  if (syment->n_sclass == C_SECTION)
5147
12
    {
5148
      /* In some cases in a DLL generated by the Microsoft linker, the
5149
   n_value field will contain garbage.  FIXME: This should
5150
   probably be handled by the swapping function instead.  */
5151
12
      syment->n_value = 0;
5152
12
      if (syment->n_scnum == 0)
5153
12
  return COFF_SYMBOL_UNDEFINED;
5154
0
      return COFF_SYMBOL_PE_SECTION;
5155
12
    }
5156
0
#endif /* COFF_WITH_PE */
5157
5158
  /* If it is not a global symbol, we presume it is a local symbol.  */
5159
0
  if (syment->n_scnum == 0)
5160
0
    {
5161
0
      char buf[SYMNMLEN + 1];
5162
5163
0
      _bfd_error_handler
5164
  /* xgettext:c-format */
5165
0
  (_("warning: %pB: local symbol `%s' has no section"),
5166
0
   abfd, _bfd_coff_internal_syment_name (abfd, syment, buf));
5167
0
    }
5168
5169
0
  return COFF_SYMBOL_LOCAL;
5170
12
}
pei-arm-wince.c:coff_classify_symbol
Line
Count
Source
5076
988
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
988
  switch (syment->n_sclass)
5080
988
    {
5081
405
    case C_EXT:
5082
411
    case C_WEAKEXT:
5083
411
#ifdef ARM
5084
424
    case C_THUMBEXT:
5085
425
    case C_THUMBEXTFUNC:
5086
425
#endif
5087
#ifdef RS6000COFF_C
5088
    case C_HIDEXT:
5089
#ifndef AIX_WEAK_SUPPORT
5090
    case C_AIX_WEAKEXT:
5091
#endif
5092
#endif
5093
425
#ifdef C_SYSTEM
5094
489
    case C_SYSTEM:
5095
489
#endif
5096
489
#ifdef COFF_WITH_PE
5097
976
    case C_NT_WEAK:
5098
976
#endif
5099
976
      if (syment->n_scnum == 0)
5100
93
  {
5101
93
    if (syment->n_value == 0)
5102
29
      return COFF_SYMBOL_UNDEFINED;
5103
64
    else
5104
64
      return COFF_SYMBOL_COMMON;
5105
93
  }
5106
#ifdef RS6000COFF_C
5107
      if (syment->n_sclass == C_HIDEXT)
5108
  return COFF_SYMBOL_LOCAL;
5109
#endif
5110
883
      return COFF_SYMBOL_GLOBAL;
5111
5112
12
    default:
5113
12
      break;
5114
988
    }
5115
5116
12
#ifdef COFF_WITH_PE
5117
12
  if (syment->n_sclass == C_STAT)
5118
0
    {
5119
0
      if (syment->n_scnum == 0)
5120
  /* The Microsoft compiler sometimes generates these if a
5121
     small static function is inlined every time it is used.
5122
     The function is discarded, but the symbol table entry
5123
     remains.  */
5124
0
  return COFF_SYMBOL_LOCAL;
5125
5126
#ifdef STRICT_PE_FORMAT
5127
      /* This is correct for Microsoft generated objects, but it
5128
   breaks gas generated objects.  */
5129
      if (syment->n_value == 0)
5130
  {
5131
    const asection *sec;
5132
    const char *name;
5133
    char buf[SYMNMLEN + 1];
5134
5135
    name = _bfd_coff_internal_syment_name (abfd, syment, buf);
5136
    sec = coff_section_from_bfd_index (abfd, syment->n_scnum);
5137
    if (sec != NULL && name != NULL
5138
        && (strcmp (bfd_section_name (sec), name) == 0))
5139
      return COFF_SYMBOL_PE_SECTION;
5140
  }
5141
#endif
5142
5143
0
      return COFF_SYMBOL_LOCAL;
5144
0
    }
5145
5146
12
  if (syment->n_sclass == C_SECTION)
5147
12
    {
5148
      /* In some cases in a DLL generated by the Microsoft linker, the
5149
   n_value field will contain garbage.  FIXME: This should
5150
   probably be handled by the swapping function instead.  */
5151
12
      syment->n_value = 0;
5152
12
      if (syment->n_scnum == 0)
5153
12
  return COFF_SYMBOL_UNDEFINED;
5154
0
      return COFF_SYMBOL_PE_SECTION;
5155
12
    }
5156
0
#endif /* COFF_WITH_PE */
5157
5158
  /* If it is not a global symbol, we presume it is a local symbol.  */
5159
0
  if (syment->n_scnum == 0)
5160
0
    {
5161
0
      char buf[SYMNMLEN + 1];
5162
5163
0
      _bfd_error_handler
5164
  /* xgettext:c-format */
5165
0
  (_("warning: %pB: local symbol `%s' has no section"),
5166
0
   abfd, _bfd_coff_internal_syment_name (abfd, syment, buf));
5167
0
    }
5168
5169
0
  return COFF_SYMBOL_LOCAL;
5170
12
}
pei-arm.c:coff_classify_symbol
Line
Count
Source
5076
857
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
857
  switch (syment->n_sclass)
5080
857
    {
5081
187
    case C_EXT:
5082
199
    case C_WEAKEXT:
5083
199
#ifdef ARM
5084
218
    case C_THUMBEXT:
5085
226
    case C_THUMBEXTFUNC:
5086
226
#endif
5087
#ifdef RS6000COFF_C
5088
    case C_HIDEXT:
5089
#ifndef AIX_WEAK_SUPPORT
5090
    case C_AIX_WEAKEXT:
5091
#endif
5092
#endif
5093
226
#ifdef C_SYSTEM
5094
245
    case C_SYSTEM:
5095
245
#endif
5096
245
#ifdef COFF_WITH_PE
5097
853
    case C_NT_WEAK:
5098
853
#endif
5099
853
      if (syment->n_scnum == 0)
5100
80
  {
5101
80
    if (syment->n_value == 0)
5102
20
      return COFF_SYMBOL_UNDEFINED;
5103
60
    else
5104
60
      return COFF_SYMBOL_COMMON;
5105
80
  }
5106
#ifdef RS6000COFF_C
5107
      if (syment->n_sclass == C_HIDEXT)
5108
  return COFF_SYMBOL_LOCAL;
5109
#endif
5110
773
      return COFF_SYMBOL_GLOBAL;
5111
5112
4
    default:
5113
4
      break;
5114
857
    }
5115
5116
4
#ifdef COFF_WITH_PE
5117
4
  if (syment->n_sclass == C_STAT)
5118
0
    {
5119
0
      if (syment->n_scnum == 0)
5120
  /* The Microsoft compiler sometimes generates these if a
5121
     small static function is inlined every time it is used.
5122
     The function is discarded, but the symbol table entry
5123
     remains.  */
5124
0
  return COFF_SYMBOL_LOCAL;
5125
5126
#ifdef STRICT_PE_FORMAT
5127
      /* This is correct for Microsoft generated objects, but it
5128
   breaks gas generated objects.  */
5129
      if (syment->n_value == 0)
5130
  {
5131
    const asection *sec;
5132
    const char *name;
5133
    char buf[SYMNMLEN + 1];
5134
5135
    name = _bfd_coff_internal_syment_name (abfd, syment, buf);
5136
    sec = coff_section_from_bfd_index (abfd, syment->n_scnum);
5137
    if (sec != NULL && name != NULL
5138
        && (strcmp (bfd_section_name (sec), name) == 0))
5139
      return COFF_SYMBOL_PE_SECTION;
5140
  }
5141
#endif
5142
5143
0
      return COFF_SYMBOL_LOCAL;
5144
0
    }
5145
5146
4
  if (syment->n_sclass == C_SECTION)
5147
4
    {
5148
      /* In some cases in a DLL generated by the Microsoft linker, the
5149
   n_value field will contain garbage.  FIXME: This should
5150
   probably be handled by the swapping function instead.  */
5151
4
      syment->n_value = 0;
5152
4
      if (syment->n_scnum == 0)
5153
4
  return COFF_SYMBOL_UNDEFINED;
5154
0
      return COFF_SYMBOL_PE_SECTION;
5155
4
    }
5156
0
#endif /* COFF_WITH_PE */
5157
5158
  /* If it is not a global symbol, we presume it is a local symbol.  */
5159
0
  if (syment->n_scnum == 0)
5160
0
    {
5161
0
      char buf[SYMNMLEN + 1];
5162
5163
0
      _bfd_error_handler
5164
  /* xgettext:c-format */
5165
0
  (_("warning: %pB: local symbol `%s' has no section"),
5166
0
   abfd, _bfd_coff_internal_syment_name (abfd, syment, buf));
5167
0
    }
5168
5169
0
  return COFF_SYMBOL_LOCAL;
5170
4
}
pei-mcore.c:coff_classify_symbol
Line
Count
Source
5076
1.05k
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
1.05k
  switch (syment->n_sclass)
5080
1.05k
    {
5081
680
    case C_EXT:
5082
693
    case C_WEAKEXT:
5083
#ifdef ARM
5084
    case C_THUMBEXT:
5085
    case C_THUMBEXTFUNC:
5086
#endif
5087
#ifdef RS6000COFF_C
5088
    case C_HIDEXT:
5089
#ifndef AIX_WEAK_SUPPORT
5090
    case C_AIX_WEAKEXT:
5091
#endif
5092
#endif
5093
693
#ifdef C_SYSTEM
5094
747
    case C_SYSTEM:
5095
747
#endif
5096
747
#ifdef COFF_WITH_PE
5097
1.04k
    case C_NT_WEAK:
5098
1.04k
#endif
5099
1.04k
      if (syment->n_scnum == 0)
5100
42
  {
5101
42
    if (syment->n_value == 0)
5102
19
      return COFF_SYMBOL_UNDEFINED;
5103
23
    else
5104
23
      return COFF_SYMBOL_COMMON;
5105
42
  }
5106
#ifdef RS6000COFF_C
5107
      if (syment->n_sclass == C_HIDEXT)
5108
  return COFF_SYMBOL_LOCAL;
5109
#endif
5110
1.00k
      return COFF_SYMBOL_GLOBAL;
5111
5112
6
    default:
5113
6
      break;
5114
1.05k
    }
5115
5116
6
#ifdef COFF_WITH_PE
5117
6
  if (syment->n_sclass == C_STAT)
5118
0
    {
5119
0
      if (syment->n_scnum == 0)
5120
  /* The Microsoft compiler sometimes generates these if a
5121
     small static function is inlined every time it is used.
5122
     The function is discarded, but the symbol table entry
5123
     remains.  */
5124
0
  return COFF_SYMBOL_LOCAL;
5125
5126
#ifdef STRICT_PE_FORMAT
5127
      /* This is correct for Microsoft generated objects, but it
5128
   breaks gas generated objects.  */
5129
      if (syment->n_value == 0)
5130
  {
5131
    const asection *sec;
5132
    const char *name;
5133
    char buf[SYMNMLEN + 1];
5134
5135
    name = _bfd_coff_internal_syment_name (abfd, syment, buf);
5136
    sec = coff_section_from_bfd_index (abfd, syment->n_scnum);
5137
    if (sec != NULL && name != NULL
5138
        && (strcmp (bfd_section_name (sec), name) == 0))
5139
      return COFF_SYMBOL_PE_SECTION;
5140
  }
5141
#endif
5142
5143
0
      return COFF_SYMBOL_LOCAL;
5144
0
    }
5145
5146
6
  if (syment->n_sclass == C_SECTION)
5147
6
    {
5148
      /* In some cases in a DLL generated by the Microsoft linker, the
5149
   n_value field will contain garbage.  FIXME: This should
5150
   probably be handled by the swapping function instead.  */
5151
6
      syment->n_value = 0;
5152
6
      if (syment->n_scnum == 0)
5153
6
  return COFF_SYMBOL_UNDEFINED;
5154
0
      return COFF_SYMBOL_PE_SECTION;
5155
6
    }
5156
0
#endif /* COFF_WITH_PE */
5157
5158
  /* If it is not a global symbol, we presume it is a local symbol.  */
5159
0
  if (syment->n_scnum == 0)
5160
0
    {
5161
0
      char buf[SYMNMLEN + 1];
5162
5163
0
      _bfd_error_handler
5164
  /* xgettext:c-format */
5165
0
  (_("warning: %pB: local symbol `%s' has no section"),
5166
0
   abfd, _bfd_coff_internal_syment_name (abfd, syment, buf));
5167
0
    }
5168
5169
0
  return COFF_SYMBOL_LOCAL;
5170
6
}
pei-sh.c:coff_classify_symbol
Line
Count
Source
5076
1.24k
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
1.24k
  switch (syment->n_sclass)
5080
1.24k
    {
5081
698
    case C_EXT:
5082
735
    case C_WEAKEXT:
5083
#ifdef ARM
5084
    case C_THUMBEXT:
5085
    case C_THUMBEXTFUNC:
5086
#endif
5087
#ifdef RS6000COFF_C
5088
    case C_HIDEXT:
5089
#ifndef AIX_WEAK_SUPPORT
5090
    case C_AIX_WEAKEXT:
5091
#endif
5092
#endif
5093
735
#ifdef C_SYSTEM
5094
810
    case C_SYSTEM:
5095
810
#endif
5096
810
#ifdef COFF_WITH_PE
5097
1.23k
    case C_NT_WEAK:
5098
1.23k
#endif
5099
1.23k
      if (syment->n_scnum == 0)
5100
110
  {
5101
110
    if (syment->n_value == 0)
5102
13
      return COFF_SYMBOL_UNDEFINED;
5103
97
    else
5104
97
      return COFF_SYMBOL_COMMON;
5105
110
  }
5106
#ifdef RS6000COFF_C
5107
      if (syment->n_sclass == C_HIDEXT)
5108
  return COFF_SYMBOL_LOCAL;
5109
#endif
5110
1.12k
      return COFF_SYMBOL_GLOBAL;
5111
5112
12
    default:
5113
12
      break;
5114
1.24k
    }
5115
5116
12
#ifdef COFF_WITH_PE
5117
12
  if (syment->n_sclass == C_STAT)
5118
0
    {
5119
0
      if (syment->n_scnum == 0)
5120
  /* The Microsoft compiler sometimes generates these if a
5121
     small static function is inlined every time it is used.
5122
     The function is discarded, but the symbol table entry
5123
     remains.  */
5124
0
  return COFF_SYMBOL_LOCAL;
5125
5126
#ifdef STRICT_PE_FORMAT
5127
      /* This is correct for Microsoft generated objects, but it
5128
   breaks gas generated objects.  */
5129
      if (syment->n_value == 0)
5130
  {
5131
    const asection *sec;
5132
    const char *name;
5133
    char buf[SYMNMLEN + 1];
5134
5135
    name = _bfd_coff_internal_syment_name (abfd, syment, buf);
5136
    sec = coff_section_from_bfd_index (abfd, syment->n_scnum);
5137
    if (sec != NULL && name != NULL
5138
        && (strcmp (bfd_section_name (sec), name) == 0))
5139
      return COFF_SYMBOL_PE_SECTION;
5140
  }
5141
#endif
5142
5143
0
      return COFF_SYMBOL_LOCAL;
5144
0
    }
5145
5146
12
  if (syment->n_sclass == C_SECTION)
5147
12
    {
5148
      /* In some cases in a DLL generated by the Microsoft linker, the
5149
   n_value field will contain garbage.  FIXME: This should
5150
   probably be handled by the swapping function instead.  */
5151
12
      syment->n_value = 0;
5152
12
      if (syment->n_scnum == 0)
5153
12
  return COFF_SYMBOL_UNDEFINED;
5154
0
      return COFF_SYMBOL_PE_SECTION;
5155
12
    }
5156
0
#endif /* COFF_WITH_PE */
5157
5158
  /* If it is not a global symbol, we presume it is a local symbol.  */
5159
0
  if (syment->n_scnum == 0)
5160
0
    {
5161
0
      char buf[SYMNMLEN + 1];
5162
5163
0
      _bfd_error_handler
5164
  /* xgettext:c-format */
5165
0
  (_("warning: %pB: local symbol `%s' has no section"),
5166
0
   abfd, _bfd_coff_internal_syment_name (abfd, syment, buf));
5167
0
    }
5168
5169
0
  return COFF_SYMBOL_LOCAL;
5170
12
}
5171
5172
/*
5173
SUBSUBSECTION
5174
  Reading relocations
5175
5176
  Coff relocations are easily transformed into the internal BFD form
5177
  (@code{arelent}).
5178
5179
  Reading a coff relocation table is done in the following stages:
5180
5181
  o Read the entire coff relocation table into memory.
5182
5183
  o Process each relocation in turn; first swap it from the
5184
  external to the internal form.
5185
5186
  o Turn the symbol referenced in the relocation's symbol index
5187
  into a pointer into the canonical symbol table.
5188
  This table is the same as the one returned by a call to
5189
  @code{bfd_canonicalize_symtab}. The back end will call that
5190
  routine and save the result if a canonicalization hasn't been done.
5191
5192
  o The reloc index is turned into a pointer to a howto
5193
  structure, in a back end specific way. For instance, the 386
5194
  uses the @code{r_type} to directly produce an index
5195
  into a howto table vector.
5196
5197
  o Note that @code{arelent.addend} for COFF is often not what
5198
  most people understand as a relocation addend, but rather an
5199
  adjustment to the relocation addend stored in section contents
5200
  of relocatable object files.  The value found in section
5201
  contents may also be confusing, depending on both symbol value
5202
  and addend somewhat similar to the field value for a
5203
  final-linked object.  See @code{CALC_ADDEND}.
5204
*/
5205
5206
#ifdef COFF_WITH_PE
5207
0
#define COFF_PE_ADDEND_BIAS(ptr) 0 /* Symbol value not stored in raw data.  */
5208
#else
5209
74
#define COFF_PE_ADDEND_BIAS(ptr) ((ptr)->value)
5210
#endif
5211
5212
#ifndef CALC_ADDEND
5213
#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr)    \
5214
0
  {               \
5215
0
    coff_symbol_type *coffsym = NULL;       \
5216
0
                \
5217
0
    if (ptr && bfd_asymbol_bfd (ptr) != abfd)     \
5218
0
      coffsym = (obj_symbols (abfd)       \
5219
0
     + (cache_ptr->sym_ptr_ptr - symbols));   \
5220
0
    else if (ptr)           \
5221
0
      coffsym = coff_symbol_from (ptr);       \
5222
0
    if (coffsym != NULL            \
5223
0
  && coffsym->native->is_sym        \
5224
0
  && coffsym->native->u.syment.n_scnum == 0)   \
5225
0
      cache_ptr->addend = 0;         \
5226
0
    else if (ptr && bfd_asymbol_bfd (ptr) == abfd    \
5227
0
       && ptr->section != NULL)       \
5228
0
      cache_ptr->addend = - (ptr->section->vma      \
5229
0
           + COFF_PE_ADDEND_BIAS (ptr));  \
5230
0
    else              \
5231
0
      cache_ptr->addend = 0;         \
5232
0
  }
5233
#endif
5234
5235
static bool
5236
coff_slurp_reloc_table (bfd * abfd, sec_ptr asect, asymbol ** symbols)
5237
295
{
5238
295
  bfd_byte *native_relocs;
5239
295
  arelent *reloc_cache;
5240
295
  arelent *cache_ptr;
5241
295
  unsigned int idx;
5242
295
  size_t amt;
5243
5244
295
  if (asect->relocation)
5245
0
    return true;
5246
295
  if (asect->reloc_count == 0)
5247
161
    return true;
5248
134
  if (asect->flags & SEC_CONSTRUCTOR)
5249
0
    return true;
5250
134
  if (!coff_slurp_symbol_table (abfd))
5251
16
    return false;
5252
5253
118
  native_relocs = (bfd_byte *) buy_and_read (abfd, asect->rel_filepos,
5254
118
               asect->reloc_count,
5255
118
               bfd_coff_relsz (abfd));
5256
118
  if (native_relocs == NULL)
5257
17
    return false;
5258
5259
101
  if (_bfd_mul_overflow (asect->reloc_count, sizeof (arelent), &amt))
5260
0
    {
5261
0
      bfd_set_error (bfd_error_file_too_big);
5262
0
      return false;
5263
0
    }
5264
101
  reloc_cache = (arelent *) bfd_alloc (abfd, amt);
5265
101
  if (reloc_cache == NULL)
5266
0
    {
5267
0
      free (native_relocs);
5268
0
      return false;
5269
0
    }
5270
5271
842
  for (idx = 0; idx < asect->reloc_count; idx++)
5272
828
    {
5273
828
      struct internal_reloc dst;
5274
828
      void *src;
5275
#ifndef RELOC_PROCESSING
5276
      asymbol *ptr;
5277
#endif
5278
5279
828
      cache_ptr = reloc_cache + idx;
5280
828
      src = native_relocs + idx * (size_t) bfd_coff_relsz (abfd);
5281
5282
828
      dst.r_offset = 0;
5283
828
      bfd_coff_swap_reloc_in (abfd, src, &dst);
5284
5285
#ifdef RELOC_PROCESSING
5286
204
      RELOC_PROCESSING (cache_ptr, &dst, symbols, abfd, asect);
5287
#else
5288
      cache_ptr->address = dst.r_vaddr;
5289
5290
624
      if (dst.r_symndx != -1 && symbols != NULL)
5291
288
  {
5292
288
    if (dst.r_symndx < 0 || dst.r_symndx >= obj_conv_table_size (abfd))
5293
111
      {
5294
111
        _bfd_error_handler
5295
    /* xgettext:c-format */
5296
111
    (_("%pB: warning: illegal symbol index %ld in relocs"),
5297
111
     abfd, dst.r_symndx);
5298
111
        cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
5299
111
        ptr = NULL;
5300
111
      }
5301
177
    else
5302
177
      {
5303
177
        cache_ptr->sym_ptr_ptr = (symbols
5304
177
          + obj_convert (abfd)[dst.r_symndx]);
5305
177
        ptr = *(cache_ptr->sym_ptr_ptr);
5306
177
      }
5307
288
  }
5308
336
      else
5309
336
  {
5310
336
    cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
5311
336
    ptr = NULL;
5312
336
  }
5313
5314
      /* The symbols definitions that we have read in have been
5315
   relocated as if their sections started at 0. But the offsets
5316
   refering to the symbols in the raw data have not been
5317
   modified, so we have to have a negative addend to compensate.
5318
5319
   Note that symbols which used to be common must be left alone.  */
5320
5321
      /* Calculate any reloc addend by looking at the symbol.  */
5322
624
      CALC_ADDEND (abfd, ptr, dst, cache_ptr);
5323
      (void) ptr;
5324
5325
      cache_ptr->address -= asect->vma;
5326
      /* !! cache_ptr->section = NULL;*/
5327
5328
      /* Fill in the cache_ptr->howto field from dst.r_type.  */
5329
624
      RTYPE2HOWTO (cache_ptr, &dst);
5330
#endif  /* RELOC_PROCESSING */
5331
5332
828
      if (cache_ptr->howto == NULL)
5333
87
  {
5334
87
    _bfd_error_handler
5335
      /* xgettext:c-format */
5336
87
      (_("%pB: illegal relocation type %d at address %#" PRIx64),
5337
87
       abfd, dst.r_type, (uint64_t) dst.r_vaddr);
5338
87
    bfd_set_error (bfd_error_bad_value);
5339
87
    free (native_relocs);
5340
87
    return false;
5341
87
  }
5342
828
    }
5343
5344
14
  free (native_relocs);
5345
14
  asect->relocation = reloc_cache;
5346
14
  return true;
5347
101
}
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
coff-x86_64.c:coff_slurp_reloc_table
Line
Count
Source
5237
12
{
5238
12
  bfd_byte *native_relocs;
5239
12
  arelent *reloc_cache;
5240
12
  arelent *cache_ptr;
5241
12
  unsigned int idx;
5242
12
  size_t amt;
5243
5244
12
  if (asect->relocation)
5245
0
    return true;
5246
12
  if (asect->reloc_count == 0)
5247
2
    return true;
5248
10
  if (asect->flags & SEC_CONSTRUCTOR)
5249
0
    return true;
5250
10
  if (!coff_slurp_symbol_table (abfd))
5251
1
    return false;
5252
5253
9
  native_relocs = (bfd_byte *) buy_and_read (abfd, asect->rel_filepos,
5254
9
               asect->reloc_count,
5255
9
               bfd_coff_relsz (abfd));
5256
9
  if (native_relocs == NULL)
5257
1
    return false;
5258
5259
8
  if (_bfd_mul_overflow (asect->reloc_count, sizeof (arelent), &amt))
5260
0
    {
5261
0
      bfd_set_error (bfd_error_file_too_big);
5262
0
      return false;
5263
0
    }
5264
8
  reloc_cache = (arelent *) bfd_alloc (abfd, amt);
5265
8
  if (reloc_cache == NULL)
5266
0
    {
5267
0
      free (native_relocs);
5268
0
      return false;
5269
0
    }
5270
5271
45
  for (idx = 0; idx < asect->reloc_count; idx++)
5272
44
    {
5273
44
      struct internal_reloc dst;
5274
44
      void *src;
5275
44
#ifndef RELOC_PROCESSING
5276
44
      asymbol *ptr;
5277
44
#endif
5278
5279
44
      cache_ptr = reloc_cache + idx;
5280
44
      src = native_relocs + idx * (size_t) bfd_coff_relsz (abfd);
5281
5282
44
      dst.r_offset = 0;
5283
44
      bfd_coff_swap_reloc_in (abfd, src, &dst);
5284
5285
#ifdef RELOC_PROCESSING
5286
      RELOC_PROCESSING (cache_ptr, &dst, symbols, abfd, asect);
5287
#else
5288
44
      cache_ptr->address = dst.r_vaddr;
5289
5290
44
      if (dst.r_symndx != -1 && symbols != NULL)
5291
0
  {
5292
0
    if (dst.r_symndx < 0 || dst.r_symndx >= obj_conv_table_size (abfd))
5293
0
      {
5294
0
        _bfd_error_handler
5295
    /* xgettext:c-format */
5296
0
    (_("%pB: warning: illegal symbol index %ld in relocs"),
5297
0
     abfd, dst.r_symndx);
5298
0
        cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
5299
0
        ptr = NULL;
5300
0
      }
5301
0
    else
5302
0
      {
5303
0
        cache_ptr->sym_ptr_ptr = (symbols
5304
0
          + obj_convert (abfd)[dst.r_symndx]);
5305
0
        ptr = *(cache_ptr->sym_ptr_ptr);
5306
0
      }
5307
0
  }
5308
44
      else
5309
44
  {
5310
44
    cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
5311
44
    ptr = NULL;
5312
44
  }
5313
5314
      /* The symbols definitions that we have read in have been
5315
   relocated as if their sections started at 0. But the offsets
5316
   refering to the symbols in the raw data have not been
5317
   modified, so we have to have a negative addend to compensate.
5318
5319
   Note that symbols which used to be common must be left alone.  */
5320
5321
      /* Calculate any reloc addend by looking at the symbol.  */
5322
44
      CALC_ADDEND (abfd, ptr, dst, cache_ptr);
5323
44
      (void) ptr;
5324
5325
44
      cache_ptr->address -= asect->vma;
5326
      /* !! cache_ptr->section = NULL;*/
5327
5328
      /* Fill in the cache_ptr->howto field from dst.r_type.  */
5329
44
      RTYPE2HOWTO (cache_ptr, &dst);
5330
44
#endif  /* RELOC_PROCESSING */
5331
5332
44
      if (cache_ptr->howto == NULL)
5333
7
  {
5334
7
    _bfd_error_handler
5335
      /* xgettext:c-format */
5336
7
      (_("%pB: illegal relocation type %d at address %#" PRIx64),
5337
7
       abfd, dst.r_type, (uint64_t) dst.r_vaddr);
5338
7
    bfd_set_error (bfd_error_bad_value);
5339
7
    free (native_relocs);
5340
7
    return false;
5341
7
  }
5342
44
    }
5343
5344
1
  free (native_relocs);
5345
1
  asect->relocation = reloc_cache;
5346
1
  return true;
5347
8
}
Unexecuted instantiation: coff64-rs6000.c:coff_slurp_reloc_table
Unexecuted instantiation: pe-aarch64.c:coff_slurp_reloc_table
Unexecuted instantiation: pei-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
coff-sh.c:coff_slurp_reloc_table
Line
Count
Source
5237
158
{
5238
158
  bfd_byte *native_relocs;
5239
158
  arelent *reloc_cache;
5240
158
  arelent *cache_ptr;
5241
158
  unsigned int idx;
5242
158
  size_t amt;
5243
5244
158
  if (asect->relocation)
5245
0
    return true;
5246
158
  if (asect->reloc_count == 0)
5247
97
    return true;
5248
61
  if (asect->flags & SEC_CONSTRUCTOR)
5249
0
    return true;
5250
61
  if (!coff_slurp_symbol_table (abfd))
5251
4
    return false;
5252
5253
57
  native_relocs = (bfd_byte *) buy_and_read (abfd, asect->rel_filepos,
5254
57
               asect->reloc_count,
5255
57
               bfd_coff_relsz (abfd));
5256
57
  if (native_relocs == NULL)
5257
6
    return false;
5258
5259
51
  if (_bfd_mul_overflow (asect->reloc_count, sizeof (arelent), &amt))
5260
0
    {
5261
0
      bfd_set_error (bfd_error_file_too_big);
5262
0
      return false;
5263
0
    }
5264
51
  reloc_cache = (arelent *) bfd_alloc (abfd, amt);
5265
51
  if (reloc_cache == NULL)
5266
0
    {
5267
0
      free (native_relocs);
5268
0
      return false;
5269
0
    }
5270
5271
591
  for (idx = 0; idx < asect->reloc_count; idx++)
5272
580
    {
5273
580
      struct internal_reloc dst;
5274
580
      void *src;
5275
580
#ifndef RELOC_PROCESSING
5276
580
      asymbol *ptr;
5277
580
#endif
5278
5279
580
      cache_ptr = reloc_cache + idx;
5280
580
      src = native_relocs + idx * (size_t) bfd_coff_relsz (abfd);
5281
5282
580
      dst.r_offset = 0;
5283
580
      bfd_coff_swap_reloc_in (abfd, src, &dst);
5284
5285
#ifdef RELOC_PROCESSING
5286
      RELOC_PROCESSING (cache_ptr, &dst, symbols, abfd, asect);
5287
#else
5288
580
      cache_ptr->address = dst.r_vaddr;
5289
5290
580
      if (dst.r_symndx != -1 && symbols != NULL)
5291
288
  {
5292
288
    if (dst.r_symndx < 0 || dst.r_symndx >= obj_conv_table_size (abfd))
5293
111
      {
5294
111
        _bfd_error_handler
5295
    /* xgettext:c-format */
5296
111
    (_("%pB: warning: illegal symbol index %ld in relocs"),
5297
111
     abfd, dst.r_symndx);
5298
111
        cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
5299
111
        ptr = NULL;
5300
111
      }
5301
177
    else
5302
177
      {
5303
177
        cache_ptr->sym_ptr_ptr = (symbols
5304
177
          + obj_convert (abfd)[dst.r_symndx]);
5305
177
        ptr = *(cache_ptr->sym_ptr_ptr);
5306
177
      }
5307
288
  }
5308
292
      else
5309
292
  {
5310
292
    cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
5311
292
    ptr = NULL;
5312
292
  }
5313
5314
      /* The symbols definitions that we have read in have been
5315
   relocated as if their sections started at 0. But the offsets
5316
   refering to the symbols in the raw data have not been
5317
   modified, so we have to have a negative addend to compensate.
5318
5319
   Note that symbols which used to be common must be left alone.  */
5320
5321
      /* Calculate any reloc addend by looking at the symbol.  */
5322
580
      CALC_ADDEND (abfd, ptr, dst, cache_ptr);
5323
580
      (void) ptr;
5324
5325
580
      cache_ptr->address -= asect->vma;
5326
      /* !! cache_ptr->section = NULL;*/
5327
5328
      /* Fill in the cache_ptr->howto field from dst.r_type.  */
5329
580
      RTYPE2HOWTO (cache_ptr, &dst);
5330
580
#endif  /* RELOC_PROCESSING */
5331
5332
580
      if (cache_ptr->howto == NULL)
5333
40
  {
5334
40
    _bfd_error_handler
5335
      /* xgettext:c-format */
5336
40
      (_("%pB: illegal relocation type %d at address %#" PRIx64),
5337
40
       abfd, dst.r_type, (uint64_t) dst.r_vaddr);
5338
40
    bfd_set_error (bfd_error_bad_value);
5339
40
    free (native_relocs);
5340
40
    return false;
5341
40
  }
5342
580
    }
5343
5344
11
  free (native_relocs);
5345
11
  asect->relocation = reloc_cache;
5346
11
  return true;
5347
51
}
Unexecuted instantiation: coff-stgo32.c:coff_slurp_reloc_table
coff-tic30.c:coff_slurp_reloc_table
Line
Count
Source
5237
54
{
5238
54
  bfd_byte *native_relocs;
5239
54
  arelent *reloc_cache;
5240
54
  arelent *cache_ptr;
5241
54
  unsigned int idx;
5242
54
  size_t amt;
5243
5244
54
  if (asect->relocation)
5245
0
    return true;
5246
54
  if (asect->reloc_count == 0)
5247
3
    return true;
5248
51
  if (asect->flags & SEC_CONSTRUCTOR)
5249
0
    return true;
5250
51
  if (!coff_slurp_symbol_table (abfd))
5251
3
    return false;
5252
5253
48
  native_relocs = (bfd_byte *) buy_and_read (abfd, asect->rel_filepos,
5254
48
               asect->reloc_count,
5255
48
               bfd_coff_relsz (abfd));
5256
48
  if (native_relocs == NULL)
5257
9
    return false;
5258
5259
39
  if (_bfd_mul_overflow (asect->reloc_count, sizeof (arelent), &amt))
5260
0
    {
5261
0
      bfd_set_error (bfd_error_file_too_big);
5262
0
      return false;
5263
0
    }
5264
39
  reloc_cache = (arelent *) bfd_alloc (abfd, amt);
5265
39
  if (reloc_cache == NULL)
5266
0
    {
5267
0
      free (native_relocs);
5268
0
      return false;
5269
0
    }
5270
5271
202
  for (idx = 0; idx < asect->reloc_count; idx++)
5272
200
    {
5273
200
      struct internal_reloc dst;
5274
200
      void *src;
5275
#ifndef RELOC_PROCESSING
5276
      asymbol *ptr;
5277
#endif
5278
5279
200
      cache_ptr = reloc_cache + idx;
5280
200
      src = native_relocs + idx * (size_t) bfd_coff_relsz (abfd);
5281
5282
200
      dst.r_offset = 0;
5283
200
      bfd_coff_swap_reloc_in (abfd, src, &dst);
5284
5285
200
#ifdef RELOC_PROCESSING
5286
200
      RELOC_PROCESSING (cache_ptr, &dst, symbols, abfd, asect);
5287
#else
5288
      cache_ptr->address = dst.r_vaddr;
5289
5290
      if (dst.r_symndx != -1 && symbols != NULL)
5291
  {
5292
    if (dst.r_symndx < 0 || dst.r_symndx >= obj_conv_table_size (abfd))
5293
      {
5294
        _bfd_error_handler
5295
    /* xgettext:c-format */
5296
    (_("%pB: warning: illegal symbol index %ld in relocs"),
5297
     abfd, dst.r_symndx);
5298
        cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
5299
        ptr = NULL;
5300
      }
5301
    else
5302
      {
5303
        cache_ptr->sym_ptr_ptr = (symbols
5304
          + obj_convert (abfd)[dst.r_symndx]);
5305
        ptr = *(cache_ptr->sym_ptr_ptr);
5306
      }
5307
  }
5308
      else
5309
  {
5310
    cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
5311
    ptr = NULL;
5312
  }
5313
5314
      /* The symbols definitions that we have read in have been
5315
   relocated as if their sections started at 0. But the offsets
5316
   refering to the symbols in the raw data have not been
5317
   modified, so we have to have a negative addend to compensate.
5318
5319
   Note that symbols which used to be common must be left alone.  */
5320
5321
      /* Calculate any reloc addend by looking at the symbol.  */
5322
      CALC_ADDEND (abfd, ptr, dst, cache_ptr);
5323
      (void) ptr;
5324
5325
      cache_ptr->address -= asect->vma;
5326
      /* !! cache_ptr->section = NULL;*/
5327
5328
      /* Fill in the cache_ptr->howto field from dst.r_type.  */
5329
      RTYPE2HOWTO (cache_ptr, &dst);
5330
#endif  /* RELOC_PROCESSING */
5331
5332
200
      if (cache_ptr->howto == NULL)
5333
37
  {
5334
37
    _bfd_error_handler
5335
      /* xgettext:c-format */
5336
37
      (_("%pB: illegal relocation type %d at address %#" PRIx64),
5337
37
       abfd, dst.r_type, (uint64_t) dst.r_vaddr);
5338
37
    bfd_set_error (bfd_error_bad_value);
5339
37
    free (native_relocs);
5340
37
    return false;
5341
37
  }
5342
200
    }
5343
5344
2
  free (native_relocs);
5345
2
  asect->relocation = reloc_cache;
5346
2
  return true;
5347
39
}
Unexecuted instantiation: coff-tic4x.c:coff_slurp_reloc_table
coff-tic54x.c:coff_slurp_reloc_table
Line
Count
Source
5237
43
{
5238
43
  bfd_byte *native_relocs;
5239
43
  arelent *reloc_cache;
5240
43
  arelent *cache_ptr;
5241
43
  unsigned int idx;
5242
43
  size_t amt;
5243
5244
43
  if (asect->relocation)
5245
0
    return true;
5246
43
  if (asect->reloc_count == 0)
5247
42
    return true;
5248
1
  if (asect->flags & SEC_CONSTRUCTOR)
5249
0
    return true;
5250
1
  if (!coff_slurp_symbol_table (abfd))
5251
1
    return false;
5252
5253
0
  native_relocs = (bfd_byte *) buy_and_read (abfd, asect->rel_filepos,
5254
0
               asect->reloc_count,
5255
0
               bfd_coff_relsz (abfd));
5256
0
  if (native_relocs == NULL)
5257
0
    return false;
5258
5259
0
  if (_bfd_mul_overflow (asect->reloc_count, sizeof (arelent), &amt))
5260
0
    {
5261
0
      bfd_set_error (bfd_error_file_too_big);
5262
0
      return false;
5263
0
    }
5264
0
  reloc_cache = (arelent *) bfd_alloc (abfd, amt);
5265
0
  if (reloc_cache == NULL)
5266
0
    {
5267
0
      free (native_relocs);
5268
0
      return false;
5269
0
    }
5270
5271
0
  for (idx = 0; idx < asect->reloc_count; idx++)
5272
0
    {
5273
0
      struct internal_reloc dst;
5274
0
      void *src;
5275
#ifndef RELOC_PROCESSING
5276
      asymbol *ptr;
5277
#endif
5278
5279
0
      cache_ptr = reloc_cache + idx;
5280
0
      src = native_relocs + idx * (size_t) bfd_coff_relsz (abfd);
5281
5282
0
      dst.r_offset = 0;
5283
0
      bfd_coff_swap_reloc_in (abfd, src, &dst);
5284
5285
0
#ifdef RELOC_PROCESSING
5286
0
      RELOC_PROCESSING (cache_ptr, &dst, symbols, abfd, asect);
5287
#else
5288
      cache_ptr->address = dst.r_vaddr;
5289
5290
      if (dst.r_symndx != -1 && symbols != NULL)
5291
  {
5292
    if (dst.r_symndx < 0 || dst.r_symndx >= obj_conv_table_size (abfd))
5293
      {
5294
        _bfd_error_handler
5295
    /* xgettext:c-format */
5296
    (_("%pB: warning: illegal symbol index %ld in relocs"),
5297
     abfd, dst.r_symndx);
5298
        cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
5299
        ptr = NULL;
5300
      }
5301
    else
5302
      {
5303
        cache_ptr->sym_ptr_ptr = (symbols
5304
          + obj_convert (abfd)[dst.r_symndx]);
5305
        ptr = *(cache_ptr->sym_ptr_ptr);
5306
      }
5307
  }
5308
      else
5309
  {
5310
    cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
5311
    ptr = NULL;
5312
  }
5313
5314
      /* The symbols definitions that we have read in have been
5315
   relocated as if their sections started at 0. But the offsets
5316
   refering to the symbols in the raw data have not been
5317
   modified, so we have to have a negative addend to compensate.
5318
5319
   Note that symbols which used to be common must be left alone.  */
5320
5321
      /* Calculate any reloc addend by looking at the symbol.  */
5322
      CALC_ADDEND (abfd, ptr, dst, cache_ptr);
5323
      (void) ptr;
5324
5325
      cache_ptr->address -= asect->vma;
5326
      /* !! cache_ptr->section = NULL;*/
5327
5328
      /* Fill in the cache_ptr->howto field from dst.r_type.  */
5329
      RTYPE2HOWTO (cache_ptr, &dst);
5330
#endif  /* RELOC_PROCESSING */
5331
5332
0
      if (cache_ptr->howto == NULL)
5333
0
  {
5334
0
    _bfd_error_handler
5335
      /* xgettext:c-format */
5336
0
      (_("%pB: illegal relocation type %d at address %#" PRIx64),
5337
0
       abfd, dst.r_type, (uint64_t) dst.r_vaddr);
5338
0
    bfd_set_error (bfd_error_bad_value);
5339
0
    free (native_relocs);
5340
0
    return false;
5341
0
  }
5342
0
    }
5343
5344
0
  free (native_relocs);
5345
0
  asect->relocation = reloc_cache;
5346
0
  return true;
5347
0
}
coff-z80.c:coff_slurp_reloc_table
Line
Count
Source
5237
14
{
5238
14
  bfd_byte *native_relocs;
5239
14
  arelent *reloc_cache;
5240
14
  arelent *cache_ptr;
5241
14
  unsigned int idx;
5242
14
  size_t amt;
5243
5244
14
  if (asect->relocation)
5245
0
    return true;
5246
14
  if (asect->reloc_count == 0)
5247
9
    return true;
5248
5
  if (asect->flags & SEC_CONSTRUCTOR)
5249
0
    return true;
5250
5
  if (!coff_slurp_symbol_table (abfd))
5251
2
    return false;
5252
5253
3
  native_relocs = (bfd_byte *) buy_and_read (abfd, asect->rel_filepos,
5254
3
               asect->reloc_count,
5255
3
               bfd_coff_relsz (abfd));
5256
3
  if (native_relocs == NULL)
5257
1
    return false;
5258
5259
2
  if (_bfd_mul_overflow (asect->reloc_count, sizeof (arelent), &amt))
5260
0
    {
5261
0
      bfd_set_error (bfd_error_file_too_big);
5262
0
      return false;
5263
0
    }
5264
2
  reloc_cache = (arelent *) bfd_alloc (abfd, amt);
5265
2
  if (reloc_cache == NULL)
5266
0
    {
5267
0
      free (native_relocs);
5268
0
      return false;
5269
0
    }
5270
5271
3
  for (idx = 0; idx < asect->reloc_count; idx++)
5272
3
    {
5273
3
      struct internal_reloc dst;
5274
3
      void *src;
5275
#ifndef RELOC_PROCESSING
5276
      asymbol *ptr;
5277
#endif
5278
5279
3
      cache_ptr = reloc_cache + idx;
5280
3
      src = native_relocs + idx * (size_t) bfd_coff_relsz (abfd);
5281
5282
3
      dst.r_offset = 0;
5283
3
      bfd_coff_swap_reloc_in (abfd, src, &dst);
5284
5285
3
#ifdef RELOC_PROCESSING
5286
3
      RELOC_PROCESSING (cache_ptr, &dst, symbols, abfd, asect);
5287
#else
5288
      cache_ptr->address = dst.r_vaddr;
5289
5290
      if (dst.r_symndx != -1 && symbols != NULL)
5291
  {
5292
    if (dst.r_symndx < 0 || dst.r_symndx >= obj_conv_table_size (abfd))
5293
      {
5294
        _bfd_error_handler
5295
    /* xgettext:c-format */
5296
    (_("%pB: warning: illegal symbol index %ld in relocs"),
5297
     abfd, dst.r_symndx);
5298
        cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
5299
        ptr = NULL;
5300
      }
5301
    else
5302
      {
5303
        cache_ptr->sym_ptr_ptr = (symbols
5304
          + obj_convert (abfd)[dst.r_symndx]);
5305
        ptr = *(cache_ptr->sym_ptr_ptr);
5306
      }
5307
  }
5308
      else
5309
  {
5310
    cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
5311
    ptr = NULL;
5312
  }
5313
5314
      /* The symbols definitions that we have read in have been
5315
   relocated as if their sections started at 0. But the offsets
5316
   refering to the symbols in the raw data have not been
5317
   modified, so we have to have a negative addend to compensate.
5318
5319
   Note that symbols which used to be common must be left alone.  */
5320
5321
      /* Calculate any reloc addend by looking at the symbol.  */
5322
      CALC_ADDEND (abfd, ptr, dst, cache_ptr);
5323
      (void) ptr;
5324
5325
      cache_ptr->address -= asect->vma;
5326
      /* !! cache_ptr->section = NULL;*/
5327
5328
      /* Fill in the cache_ptr->howto field from dst.r_type.  */
5329
      RTYPE2HOWTO (cache_ptr, &dst);
5330
#endif  /* RELOC_PROCESSING */
5331
5332
3
      if (cache_ptr->howto == NULL)
5333
2
  {
5334
2
    _bfd_error_handler
5335
      /* xgettext:c-format */
5336
2
      (_("%pB: illegal relocation type %d at address %#" PRIx64),
5337
2
       abfd, dst.r_type, (uint64_t) dst.r_vaddr);
5338
2
    bfd_set_error (bfd_error_bad_value);
5339
2
    free (native_relocs);
5340
2
    return false;
5341
2
  }
5342
3
    }
5343
5344
0
  free (native_relocs);
5345
0
  asect->relocation = reloc_cache;
5346
0
  return true;
5347
2
}
coff-z8k.c:coff_slurp_reloc_table
Line
Count
Source
5237
14
{
5238
14
  bfd_byte *native_relocs;
5239
14
  arelent *reloc_cache;
5240
14
  arelent *cache_ptr;
5241
14
  unsigned int idx;
5242
14
  size_t amt;
5243
5244
14
  if (asect->relocation)
5245
0
    return true;
5246
14
  if (asect->reloc_count == 0)
5247
8
    return true;
5248
6
  if (asect->flags & SEC_CONSTRUCTOR)
5249
0
    return true;
5250
6
  if (!coff_slurp_symbol_table (abfd))
5251
5
    return false;
5252
5253
1
  native_relocs = (bfd_byte *) buy_and_read (abfd, asect->rel_filepos,
5254
1
               asect->reloc_count,
5255
1
               bfd_coff_relsz (abfd));
5256
1
  if (native_relocs == NULL)
5257
0
    return false;
5258
5259
1
  if (_bfd_mul_overflow (asect->reloc_count, sizeof (arelent), &amt))
5260
0
    {
5261
0
      bfd_set_error (bfd_error_file_too_big);
5262
0
      return false;
5263
0
    }
5264
1
  reloc_cache = (arelent *) bfd_alloc (abfd, amt);
5265
1
  if (reloc_cache == NULL)
5266
0
    {
5267
0
      free (native_relocs);
5268
0
      return false;
5269
0
    }
5270
5271
1
  for (idx = 0; idx < asect->reloc_count; idx++)
5272
1
    {
5273
1
      struct internal_reloc dst;
5274
1
      void *src;
5275
#ifndef RELOC_PROCESSING
5276
      asymbol *ptr;
5277
#endif
5278
5279
1
      cache_ptr = reloc_cache + idx;
5280
1
      src = native_relocs + idx * (size_t) bfd_coff_relsz (abfd);
5281
5282
1
      dst.r_offset = 0;
5283
1
      bfd_coff_swap_reloc_in (abfd, src, &dst);
5284
5285
1
#ifdef RELOC_PROCESSING
5286
1
      RELOC_PROCESSING (cache_ptr, &dst, symbols, abfd, asect);
5287
#else
5288
      cache_ptr->address = dst.r_vaddr;
5289
5290
      if (dst.r_symndx != -1 && symbols != NULL)
5291
  {
5292
    if (dst.r_symndx < 0 || dst.r_symndx >= obj_conv_table_size (abfd))
5293
      {
5294
        _bfd_error_handler
5295
    /* xgettext:c-format */
5296
    (_("%pB: warning: illegal symbol index %ld in relocs"),
5297
     abfd, dst.r_symndx);
5298
        cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
5299
        ptr = NULL;
5300
      }
5301
    else
5302
      {
5303
        cache_ptr->sym_ptr_ptr = (symbols
5304
          + obj_convert (abfd)[dst.r_symndx]);
5305
        ptr = *(cache_ptr->sym_ptr_ptr);
5306
      }
5307
  }
5308
      else
5309
  {
5310
    cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
5311
    ptr = NULL;
5312
  }
5313
5314
      /* The symbols definitions that we have read in have been
5315
   relocated as if their sections started at 0. But the offsets
5316
   refering to the symbols in the raw data have not been
5317
   modified, so we have to have a negative addend to compensate.
5318
5319
   Note that symbols which used to be common must be left alone.  */
5320
5321
      /* Calculate any reloc addend by looking at the symbol.  */
5322
      CALC_ADDEND (abfd, ptr, dst, cache_ptr);
5323
      (void) ptr;
5324
5325
      cache_ptr->address -= asect->vma;
5326
      /* !! cache_ptr->section = NULL;*/
5327
5328
      /* Fill in the cache_ptr->howto field from dst.r_type.  */
5329
      RTYPE2HOWTO (cache_ptr, &dst);
5330
#endif  /* RELOC_PROCESSING */
5331
5332
1
      if (cache_ptr->howto == NULL)
5333
1
  {
5334
1
    _bfd_error_handler
5335
      /* xgettext:c-format */
5336
1
      (_("%pB: illegal relocation type %d at address %#" PRIx64),
5337
1
       abfd, dst.r_type, (uint64_t) dst.r_vaddr);
5338
1
    bfd_set_error (bfd_error_bad_value);
5339
1
    free (native_relocs);
5340
1
    return false;
5341
1
  }
5342
1
    }
5343
5344
0
  free (native_relocs);
5345
0
  asect->relocation = reloc_cache;
5346
0
  return true;
5347
1
}
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
5348
5349
#ifndef coff_rtype_to_howto
5350
#ifdef RTYPE2HOWTO
5351
5352
/* Get the howto structure for a reloc.  This is only used if the file
5353
   including this one defines coff_relocate_section to be
5354
   _bfd_coff_generic_relocate_section, so it is OK if it does not
5355
   always work.  It is the responsibility of the including file to
5356
   make sure it is reasonable if it is needed.  */
5357
5358
static reloc_howto_type *
5359
coff_rtype_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
5360
         asection *sec ATTRIBUTE_UNUSED,
5361
         struct internal_reloc *rel ATTRIBUTE_UNUSED,
5362
         struct coff_link_hash_entry *h ATTRIBUTE_UNUSED,
5363
         struct internal_syment *sym ATTRIBUTE_UNUSED,
5364
         bfd_vma *addendp ATTRIBUTE_UNUSED)
5365
0
{
5366
0
  arelent genrel;
5367
5368
0
  genrel.howto = NULL;
5369
0
  RTYPE2HOWTO (&genrel, rel);
5370
0
  return genrel.howto;
5371
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
5372
5373
#else /* ! defined (RTYPE2HOWTO) */
5374
5375
#define coff_rtype_to_howto NULL
5376
5377
#endif /* ! defined (RTYPE2HOWTO) */
5378
#endif /* ! defined (coff_rtype_to_howto) */
5379
5380
/* This is stupid.  This function should be a boolean predicate.  */
5381
5382
static long
5383
coff_canonicalize_reloc (bfd * abfd,
5384
       sec_ptr section,
5385
       arelent ** relptr,
5386
       asymbol ** symbols)
5387
295
{
5388
295
  arelent *tblptr = section->relocation;
5389
295
  unsigned int count = 0;
5390
5391
295
  if (section->flags & SEC_CONSTRUCTOR)
5392
0
    {
5393
      /* This section has relocs made up by us, they are not in the
5394
   file, so take them out of their chain and place them into
5395
   the data area provided.  */
5396
0
      arelent_chain *chain = section->constructor_chain;
5397
5398
0
      for (count = 0; count < section->reloc_count; count++)
5399
0
  {
5400
0
    *relptr++ = &chain->relent;
5401
0
    chain = chain->next;
5402
0
  }
5403
0
    }
5404
295
  else
5405
295
    {
5406
295
      if (! coff_slurp_reloc_table (abfd, section, symbols))
5407
120
  return -1;
5408
5409
175
      tblptr = section->relocation;
5410
5411
451
      for (; count++ < section->reloc_count;)
5412
276
  *relptr++ = tblptr++;
5413
175
    }
5414
175
  *relptr = 0;
5415
175
  return section->reloc_count;
5416
295
}
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
coff-x86_64.c:coff_canonicalize_reloc
Line
Count
Source
5387
12
{
5388
12
  arelent *tblptr = section->relocation;
5389
12
  unsigned int count = 0;
5390
5391
12
  if (section->flags & SEC_CONSTRUCTOR)
5392
0
    {
5393
      /* This section has relocs made up by us, they are not in the
5394
   file, so take them out of their chain and place them into
5395
   the data area provided.  */
5396
0
      arelent_chain *chain = section->constructor_chain;
5397
5398
0
      for (count = 0; count < section->reloc_count; count++)
5399
0
  {
5400
0
    *relptr++ = &chain->relent;
5401
0
    chain = chain->next;
5402
0
  }
5403
0
    }
5404
12
  else
5405
12
    {
5406
12
      if (! coff_slurp_reloc_table (abfd, section, symbols))
5407
9
  return -1;
5408
5409
3
      tblptr = section->relocation;
5410
5411
4
      for (; count++ < section->reloc_count;)
5412
1
  *relptr++ = tblptr++;
5413
3
    }
5414
3
  *relptr = 0;
5415
3
  return section->reloc_count;
5416
12
}
Unexecuted instantiation: coff64-rs6000.c:coff_canonicalize_reloc
Unexecuted instantiation: pe-aarch64.c:coff_canonicalize_reloc
Unexecuted instantiation: pei-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
coff-sh.c:coff_canonicalize_reloc
Line
Count
Source
5387
158
{
5388
158
  arelent *tblptr = section->relocation;
5389
158
  unsigned int count = 0;
5390
5391
158
  if (section->flags & SEC_CONSTRUCTOR)
5392
0
    {
5393
      /* This section has relocs made up by us, they are not in the
5394
   file, so take them out of their chain and place them into
5395
   the data area provided.  */
5396
0
      arelent_chain *chain = section->constructor_chain;
5397
5398
0
      for (count = 0; count < section->reloc_count; count++)
5399
0
  {
5400
0
    *relptr++ = &chain->relent;
5401
0
    chain = chain->next;
5402
0
  }
5403
0
    }
5404
158
  else
5405
158
    {
5406
158
      if (! coff_slurp_reloc_table (abfd, section, symbols))
5407
50
  return -1;
5408
5409
108
      tblptr = section->relocation;
5410
5411
319
      for (; count++ < section->reloc_count;)
5412
211
  *relptr++ = tblptr++;
5413
108
    }
5414
108
  *relptr = 0;
5415
108
  return section->reloc_count;
5416
158
}
Unexecuted instantiation: coff-stgo32.c:coff_canonicalize_reloc
coff-tic30.c:coff_canonicalize_reloc
Line
Count
Source
5387
54
{
5388
54
  arelent *tblptr = section->relocation;
5389
54
  unsigned int count = 0;
5390
5391
54
  if (section->flags & SEC_CONSTRUCTOR)
5392
0
    {
5393
      /* This section has relocs made up by us, they are not in the
5394
   file, so take them out of their chain and place them into
5395
   the data area provided.  */
5396
0
      arelent_chain *chain = section->constructor_chain;
5397
5398
0
      for (count = 0; count < section->reloc_count; count++)
5399
0
  {
5400
0
    *relptr++ = &chain->relent;
5401
0
    chain = chain->next;
5402
0
  }
5403
0
    }
5404
54
  else
5405
54
    {
5406
54
      if (! coff_slurp_reloc_table (abfd, section, symbols))
5407
49
  return -1;
5408
5409
5
      tblptr = section->relocation;
5410
5411
69
      for (; count++ < section->reloc_count;)
5412
64
  *relptr++ = tblptr++;
5413
5
    }
5414
5
  *relptr = 0;
5415
5
  return section->reloc_count;
5416
54
}
Unexecuted instantiation: coff-tic4x.c:coff_canonicalize_reloc
coff-tic54x.c:coff_canonicalize_reloc
Line
Count
Source
5387
43
{
5388
43
  arelent *tblptr = section->relocation;
5389
43
  unsigned int count = 0;
5390
5391
43
  if (section->flags & SEC_CONSTRUCTOR)
5392
0
    {
5393
      /* This section has relocs made up by us, they are not in the
5394
   file, so take them out of their chain and place them into
5395
   the data area provided.  */
5396
0
      arelent_chain *chain = section->constructor_chain;
5397
5398
0
      for (count = 0; count < section->reloc_count; count++)
5399
0
  {
5400
0
    *relptr++ = &chain->relent;
5401
0
    chain = chain->next;
5402
0
  }
5403
0
    }
5404
43
  else
5405
43
    {
5406
43
      if (! coff_slurp_reloc_table (abfd, section, symbols))
5407
1
  return -1;
5408
5409
42
      tblptr = section->relocation;
5410
5411
42
      for (; count++ < section->reloc_count;)
5412
0
  *relptr++ = tblptr++;
5413
42
    }
5414
42
  *relptr = 0;
5415
42
  return section->reloc_count;
5416
43
}
coff-z80.c:coff_canonicalize_reloc
Line
Count
Source
5387
14
{
5388
14
  arelent *tblptr = section->relocation;
5389
14
  unsigned int count = 0;
5390
5391
14
  if (section->flags & SEC_CONSTRUCTOR)
5392
0
    {
5393
      /* This section has relocs made up by us, they are not in the
5394
   file, so take them out of their chain and place them into
5395
   the data area provided.  */
5396
0
      arelent_chain *chain = section->constructor_chain;
5397
5398
0
      for (count = 0; count < section->reloc_count; count++)
5399
0
  {
5400
0
    *relptr++ = &chain->relent;
5401
0
    chain = chain->next;
5402
0
  }
5403
0
    }
5404
14
  else
5405
14
    {
5406
14
      if (! coff_slurp_reloc_table (abfd, section, symbols))
5407
5
  return -1;
5408
5409
9
      tblptr = section->relocation;
5410
5411
9
      for (; count++ < section->reloc_count;)
5412
0
  *relptr++ = tblptr++;
5413
9
    }
5414
9
  *relptr = 0;
5415
9
  return section->reloc_count;
5416
14
}
coff-z8k.c:coff_canonicalize_reloc
Line
Count
Source
5387
14
{
5388
14
  arelent *tblptr = section->relocation;
5389
14
  unsigned int count = 0;
5390
5391
14
  if (section->flags & SEC_CONSTRUCTOR)
5392
0
    {
5393
      /* This section has relocs made up by us, they are not in the
5394
   file, so take them out of their chain and place them into
5395
   the data area provided.  */
5396
0
      arelent_chain *chain = section->constructor_chain;
5397
5398
0
      for (count = 0; count < section->reloc_count; count++)
5399
0
  {
5400
0
    *relptr++ = &chain->relent;
5401
0
    chain = chain->next;
5402
0
  }
5403
0
    }
5404
14
  else
5405
14
    {
5406
14
      if (! coff_slurp_reloc_table (abfd, section, symbols))
5407
6
  return -1;
5408
5409
8
      tblptr = section->relocation;
5410
5411
8
      for (; count++ < section->reloc_count;)
5412
0
  *relptr++ = tblptr++;
5413
8
    }
5414
8
  *relptr = 0;
5415
8
  return section->reloc_count;
5416
14
}
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
5417
5418
#ifndef coff_set_reloc
5419
#define coff_set_reloc _bfd_generic_set_reloc
5420
#endif
5421
5422
#ifndef coff_reloc16_estimate
5423
#define coff_reloc16_estimate dummy_reloc16_estimate
5424
5425
static int
5426
dummy_reloc16_estimate (bfd *abfd ATTRIBUTE_UNUSED,
5427
      asection *input_section ATTRIBUTE_UNUSED,
5428
      arelent *reloc ATTRIBUTE_UNUSED,
5429
      unsigned int shrink ATTRIBUTE_UNUSED,
5430
      struct bfd_link_info *link_info ATTRIBUTE_UNUSED)
5431
0
{
5432
0
  abort ();
5433
0
  return 0;
5434
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: pe-aarch64.c:dummy_reloc16_estimate
Unexecuted instantiation: pei-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
5435
5436
#endif
5437
5438
#ifndef coff_reloc16_extra_cases
5439
5440
#define coff_reloc16_extra_cases dummy_reloc16_extra_cases
5441
5442
static bool
5443
dummy_reloc16_extra_cases (bfd *abfd ATTRIBUTE_UNUSED,
5444
         struct bfd_link_info *link_info ATTRIBUTE_UNUSED,
5445
         struct bfd_link_order *link_order ATTRIBUTE_UNUSED,
5446
         arelent *reloc ATTRIBUTE_UNUSED,
5447
         bfd_byte *data ATTRIBUTE_UNUSED,
5448
         size_t *src_ptr ATTRIBUTE_UNUSED,
5449
         size_t *dst_ptr ATTRIBUTE_UNUSED)
5450
0
{
5451
0
  return false;
5452
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: pe-aarch64.c:dummy_reloc16_extra_cases
Unexecuted instantiation: pei-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
5453
#endif
5454
5455
/* If coff_relocate_section is defined, we can use the optimized COFF
5456
   backend linker.  Otherwise we must continue to use the old linker.  */
5457
5458
#ifdef coff_relocate_section
5459
5460
#ifndef coff_bfd_link_hash_table_create
5461
#define coff_bfd_link_hash_table_create _bfd_coff_link_hash_table_create
5462
#endif
5463
#ifndef coff_bfd_link_add_symbols
5464
#define coff_bfd_link_add_symbols _bfd_coff_link_add_symbols
5465
#endif
5466
#ifndef coff_bfd_final_link
5467
#define coff_bfd_final_link _bfd_coff_final_link
5468
#endif
5469
5470
#else /* ! defined (coff_relocate_section) */
5471
5472
#define coff_relocate_section NULL
5473
#ifndef coff_bfd_link_hash_table_create
5474
#define coff_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
5475
#endif
5476
#ifndef coff_bfd_link_add_symbols
5477
#define coff_bfd_link_add_symbols _bfd_generic_link_add_symbols
5478
#endif
5479
#define coff_bfd_final_link _bfd_generic_final_link
5480
5481
#endif /* ! defined (coff_relocate_section) */
5482
5483
#define coff_bfd_link_just_syms      _bfd_generic_link_just_syms
5484
#define coff_bfd_copy_link_hash_symbol_type \
5485
  _bfd_generic_copy_link_hash_symbol_type
5486
#define coff_bfd_link_split_section  _bfd_generic_link_split_section
5487
5488
#define coff_bfd_link_check_relocs   _bfd_generic_link_check_relocs
5489
5490
#ifndef coff_start_final_link
5491
#define coff_start_final_link NULL
5492
#endif
5493
5494
#ifndef coff_adjust_symndx
5495
#define coff_adjust_symndx NULL
5496
#endif
5497
5498
#ifndef coff_link_add_one_symbol
5499
#define coff_link_add_one_symbol _bfd_generic_link_add_one_symbol
5500
#endif
5501
5502
#ifndef coff_link_output_has_begun
5503
5504
static bool
5505
coff_link_output_has_begun (bfd * abfd,
5506
          struct coff_final_link_info * info ATTRIBUTE_UNUSED)
5507
0
{
5508
0
  return abfd->output_has_begun;
5509
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: pe-aarch64.c:coff_link_output_has_begun
Unexecuted instantiation: pei-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
5510
#endif
5511
5512
#ifndef coff_final_link_postscript
5513
5514
static bool
5515
coff_final_link_postscript (bfd * abfd ATTRIBUTE_UNUSED,
5516
          struct coff_final_link_info * pfinfo ATTRIBUTE_UNUSED)
5517
0
{
5518
0
  return true;
5519
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
5520
#endif
5521
5522
#ifndef coff_SWAP_aux_in
5523
#define coff_SWAP_aux_in coff_swap_aux_in
5524
#endif
5525
#ifndef coff_SWAP_sym_in
5526
#define coff_SWAP_sym_in coff_swap_sym_in
5527
#endif
5528
#ifndef coff_SWAP_lineno_in
5529
#define coff_SWAP_lineno_in coff_swap_lineno_in
5530
#endif
5531
#ifndef coff_SWAP_aux_out
5532
#define coff_SWAP_aux_out coff_swap_aux_out
5533
#endif
5534
#ifndef coff_SWAP_sym_out
5535
#define coff_SWAP_sym_out coff_swap_sym_out
5536
#endif
5537
#ifndef coff_SWAP_lineno_out
5538
#define coff_SWAP_lineno_out coff_swap_lineno_out
5539
#endif
5540
#ifndef coff_SWAP_reloc_out
5541
#define coff_SWAP_reloc_out coff_swap_reloc_out
5542
#endif
5543
#ifndef coff_SWAP_filehdr_out
5544
#define coff_SWAP_filehdr_out coff_swap_filehdr_out
5545
#endif
5546
#ifndef coff_SWAP_aouthdr_out
5547
#define coff_SWAP_aouthdr_out coff_swap_aouthdr_out
5548
#endif
5549
#ifndef coff_SWAP_scnhdr_out
5550
#define coff_SWAP_scnhdr_out coff_swap_scnhdr_out
5551
#endif
5552
#ifndef coff_SWAP_reloc_in
5553
#define coff_SWAP_reloc_in coff_swap_reloc_in
5554
#endif
5555
#ifndef coff_SWAP_filehdr_in
5556
#define coff_SWAP_filehdr_in coff_swap_filehdr_in
5557
#endif
5558
#ifndef coff_SWAP_aouthdr_in
5559
#define coff_SWAP_aouthdr_in coff_swap_aouthdr_in
5560
#endif
5561
#ifndef coff_SWAP_scnhdr_in
5562
#define coff_SWAP_scnhdr_in coff_swap_scnhdr_in
5563
#endif
5564
5565
#define COFF_SWAP_TABLE (void *) &bfd_coff_std_swap_table
5566
5567
static const bfd_coff_backend_data bfd_coff_std_swap_table ATTRIBUTE_UNUSED =
5568
{
5569
  coff_SWAP_aux_in, coff_SWAP_sym_in, coff_SWAP_lineno_in,
5570
  coff_SWAP_aux_out, coff_SWAP_sym_out,
5571
  coff_SWAP_lineno_out, coff_SWAP_reloc_out,
5572
  coff_SWAP_filehdr_out, coff_SWAP_aouthdr_out,
5573
  coff_SWAP_scnhdr_out,
5574
  FILHSZ, AOUTSZ, SCNHSZ, SYMESZ, AUXESZ, RELSZ, LINESZ, FILNMLEN,
5575
#ifdef COFF_LONG_FILENAMES
5576
  true,
5577
#else
5578
  false,
5579
#endif
5580
  COFF_DEFAULT_LONG_SECTION_NAMES,
5581
  COFF_DEFAULT_SECTION_ALIGNMENT_POWER,
5582
#ifdef COFF_FORCE_SYMBOLS_IN_STRINGS
5583
  true,
5584
#else
5585
  false,
5586
#endif
5587
#ifdef COFF_DEBUG_STRING_WIDE_PREFIX
5588
  4,
5589
#else
5590
  2,
5591
#endif
5592
  32768,
5593
  coff_SWAP_filehdr_in, coff_SWAP_aouthdr_in, coff_SWAP_scnhdr_in,
5594
  coff_SWAP_reloc_in, coff_bad_format_hook, coff_set_arch_mach_hook,
5595
  coff_mkobject_hook, styp_to_sec_flags, coff_set_alignment_hook,
5596
  coff_slurp_symbol_table, symname_in_debug_hook, coff_pointerize_aux_hook,
5597
  coff_print_aux, coff_reloc16_extra_cases, coff_reloc16_estimate,
5598
  coff_classify_symbol, coff_compute_section_file_positions,
5599
  coff_start_final_link, coff_relocate_section, coff_rtype_to_howto,
5600
  coff_adjust_symndx, coff_link_add_one_symbol,
5601
  coff_link_output_has_begun, coff_final_link_postscript,
5602
  bfd_pe_print_pdata
5603
};
5604
5605
#ifdef TICOFF
5606
/* COFF0 differs in file/section header size and relocation entry size.  */
5607
5608
static const bfd_coff_backend_data ticoff0_swap_table =
5609
{
5610
  coff_SWAP_aux_in, coff_SWAP_sym_in, coff_SWAP_lineno_in,
5611
  coff_SWAP_aux_out, coff_SWAP_sym_out,
5612
  coff_SWAP_lineno_out, coff_swap_reloc_v0_out,
5613
  coff_SWAP_filehdr_out, coff_SWAP_aouthdr_out,
5614
  coff_SWAP_scnhdr_out,
5615
  FILHSZ_V0, AOUTSZ, SCNHSZ_V01, SYMESZ, AUXESZ, RELSZ_V0, LINESZ, FILNMLEN,
5616
#ifdef COFF_LONG_FILENAMES
5617
  true,
5618
#else
5619
  false,
5620
#endif
5621
  COFF_DEFAULT_LONG_SECTION_NAMES,
5622
  COFF_DEFAULT_SECTION_ALIGNMENT_POWER,
5623
#ifdef COFF_FORCE_SYMBOLS_IN_STRINGS
5624
  true,
5625
#else
5626
  false,
5627
#endif
5628
#ifdef COFF_DEBUG_STRING_WIDE_PREFIX
5629
  4,
5630
#else
5631
  2,
5632
#endif
5633
  32768,
5634
  coff_SWAP_filehdr_in, coff_SWAP_aouthdr_in, coff_SWAP_scnhdr_in,
5635
  coff_swap_reloc_v0_in, ticoff0_bad_format_hook, coff_set_arch_mach_hook,
5636
  coff_mkobject_hook, styp_to_sec_flags, coff_set_alignment_hook,
5637
  coff_slurp_symbol_table, symname_in_debug_hook, coff_pointerize_aux_hook,
5638
  coff_print_aux, coff_reloc16_extra_cases, coff_reloc16_estimate,
5639
  coff_classify_symbol, coff_compute_section_file_positions,
5640
  coff_start_final_link, coff_relocate_section, coff_rtype_to_howto,
5641
  coff_adjust_symndx, coff_link_add_one_symbol,
5642
  coff_link_output_has_begun, coff_final_link_postscript,
5643
  bfd_pe_print_pdata
5644
};
5645
#endif
5646
5647
#ifdef TICOFF
5648
/* COFF1 differs in section header size.  */
5649
5650
static const bfd_coff_backend_data ticoff1_swap_table =
5651
{
5652
  coff_SWAP_aux_in, coff_SWAP_sym_in, coff_SWAP_lineno_in,
5653
  coff_SWAP_aux_out, coff_SWAP_sym_out,
5654
  coff_SWAP_lineno_out, coff_SWAP_reloc_out,
5655
  coff_SWAP_filehdr_out, coff_SWAP_aouthdr_out,
5656
  coff_SWAP_scnhdr_out,
5657
  FILHSZ, AOUTSZ, SCNHSZ_V01, SYMESZ, AUXESZ, RELSZ, LINESZ, FILNMLEN,
5658
#ifdef COFF_LONG_FILENAMES
5659
  true,
5660
#else
5661
  false,
5662
#endif
5663
  COFF_DEFAULT_LONG_SECTION_NAMES,
5664
  COFF_DEFAULT_SECTION_ALIGNMENT_POWER,
5665
#ifdef COFF_FORCE_SYMBOLS_IN_STRINGS
5666
  true,
5667
#else
5668
  false,
5669
#endif
5670
#ifdef COFF_DEBUG_STRING_WIDE_PREFIX
5671
  4,
5672
#else
5673
  2,
5674
#endif
5675
  32768,
5676
  coff_SWAP_filehdr_in, coff_SWAP_aouthdr_in, coff_SWAP_scnhdr_in,
5677
  coff_SWAP_reloc_in, ticoff1_bad_format_hook, coff_set_arch_mach_hook,
5678
  coff_mkobject_hook, styp_to_sec_flags, coff_set_alignment_hook,
5679
  coff_slurp_symbol_table, symname_in_debug_hook, coff_pointerize_aux_hook,
5680
  coff_print_aux, coff_reloc16_extra_cases, coff_reloc16_estimate,
5681
  coff_classify_symbol, coff_compute_section_file_positions,
5682
  coff_start_final_link, coff_relocate_section, coff_rtype_to_howto,
5683
  coff_adjust_symndx, coff_link_add_one_symbol,
5684
  coff_link_output_has_begun, coff_final_link_postscript,
5685
  bfd_pe_print_pdata  /* huh */
5686
};
5687
#endif
5688
5689
#ifdef COFF_WITH_PE_BIGOBJ
5690
/* The UID for bigobj files.  */
5691
5692
static const char header_bigobj_classid[16] =
5693
{
5694
  0xC7, 0xA1, 0xBA, 0xD1,
5695
  0xEE, 0xBA,
5696
  0xa9, 0x4b,
5697
  0xAF, 0x20,
5698
  0xFA, 0xF6, 0x6A, 0xA4, 0xDC, 0xB8
5699
};
5700
5701
/* Swap routines.  */
5702
5703
static void
5704
coff_bigobj_swap_filehdr_in (bfd * abfd, void * src, void * dst)
5705
483k
{
5706
483k
  struct external_ANON_OBJECT_HEADER_BIGOBJ *filehdr_src =
5707
483k
    (struct external_ANON_OBJECT_HEADER_BIGOBJ *) src;
5708
483k
  struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst;
5709
5710
483k
  filehdr_dst->f_magic  = H_GET_16 (abfd, filehdr_src->Machine);
5711
483k
  filehdr_dst->f_nscns  = H_GET_32 (abfd, filehdr_src->NumberOfSections);
5712
483k
  filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->TimeDateStamp);
5713
483k
  filehdr_dst->f_symptr =
5714
483k
    GET_FILEHDR_SYMPTR (abfd, filehdr_src->PointerToSymbolTable);
5715
483k
  filehdr_dst->f_nsyms  = H_GET_32 (abfd, filehdr_src->NumberOfSymbols);
5716
483k
  filehdr_dst->f_opthdr = 0;
5717
483k
  filehdr_dst->f_flags  = 0;
5718
5719
  /* Check other magic numbers.  */
5720
483k
  if (H_GET_16 (abfd, filehdr_src->Sig1) != IMAGE_FILE_MACHINE_UNKNOWN
5721
483k
      || H_GET_16 (abfd, filehdr_src->Sig2) != 0xffff
5722
483k
      || H_GET_16 (abfd, filehdr_src->Version) != 2
5723
483k
      || memcmp (filehdr_src->ClassID, header_bigobj_classid, 16) != 0)
5724
483k
    filehdr_dst->f_opthdr = 0xffff;
5725
5726
  /* Note that CLR metadata are ignored.  */
5727
483k
}
pe-x86_64.c:coff_bigobj_swap_filehdr_in
Line
Count
Source
5705
241k
{
5706
241k
  struct external_ANON_OBJECT_HEADER_BIGOBJ *filehdr_src =
5707
241k
    (struct external_ANON_OBJECT_HEADER_BIGOBJ *) src;
5708
241k
  struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst;
5709
5710
241k
  filehdr_dst->f_magic  = H_GET_16 (abfd, filehdr_src->Machine);
5711
241k
  filehdr_dst->f_nscns  = H_GET_32 (abfd, filehdr_src->NumberOfSections);
5712
241k
  filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->TimeDateStamp);
5713
241k
  filehdr_dst->f_symptr =
5714
241k
    GET_FILEHDR_SYMPTR (abfd, filehdr_src->PointerToSymbolTable);
5715
241k
  filehdr_dst->f_nsyms  = H_GET_32 (abfd, filehdr_src->NumberOfSymbols);
5716
241k
  filehdr_dst->f_opthdr = 0;
5717
241k
  filehdr_dst->f_flags  = 0;
5718
5719
  /* Check other magic numbers.  */
5720
241k
  if (H_GET_16 (abfd, filehdr_src->Sig1) != IMAGE_FILE_MACHINE_UNKNOWN
5721
241k
      || H_GET_16 (abfd, filehdr_src->Sig2) != 0xffff
5722
241k
      || H_GET_16 (abfd, filehdr_src->Version) != 2
5723
241k
      || memcmp (filehdr_src->ClassID, header_bigobj_classid, 16) != 0)
5724
241k
    filehdr_dst->f_opthdr = 0xffff;
5725
5726
  /* Note that CLR metadata are ignored.  */
5727
241k
}
pe-i386.c:coff_bigobj_swap_filehdr_in
Line
Count
Source
5705
241k
{
5706
241k
  struct external_ANON_OBJECT_HEADER_BIGOBJ *filehdr_src =
5707
241k
    (struct external_ANON_OBJECT_HEADER_BIGOBJ *) src;
5708
241k
  struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst;
5709
5710
241k
  filehdr_dst->f_magic  = H_GET_16 (abfd, filehdr_src->Machine);
5711
241k
  filehdr_dst->f_nscns  = H_GET_32 (abfd, filehdr_src->NumberOfSections);
5712
241k
  filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->TimeDateStamp);
5713
241k
  filehdr_dst->f_symptr =
5714
241k
    GET_FILEHDR_SYMPTR (abfd, filehdr_src->PointerToSymbolTable);
5715
241k
  filehdr_dst->f_nsyms  = H_GET_32 (abfd, filehdr_src->NumberOfSymbols);
5716
241k
  filehdr_dst->f_opthdr = 0;
5717
241k
  filehdr_dst->f_flags  = 0;
5718
5719
  /* Check other magic numbers.  */
5720
241k
  if (H_GET_16 (abfd, filehdr_src->Sig1) != IMAGE_FILE_MACHINE_UNKNOWN
5721
241k
      || H_GET_16 (abfd, filehdr_src->Sig2) != 0xffff
5722
241k
      || H_GET_16 (abfd, filehdr_src->Version) != 2
5723
241k
      || memcmp (filehdr_src->ClassID, header_bigobj_classid, 16) != 0)
5724
241k
    filehdr_dst->f_opthdr = 0xffff;
5725
5726
  /* Note that CLR metadata are ignored.  */
5727
241k
}
5728
5729
static unsigned int
5730
coff_bigobj_swap_filehdr_out (bfd *abfd, void * in, void * out)
5731
0
{
5732
0
  struct internal_filehdr *filehdr_in = (struct internal_filehdr *) in;
5733
0
  struct external_ANON_OBJECT_HEADER_BIGOBJ *filehdr_out =
5734
0
    (struct external_ANON_OBJECT_HEADER_BIGOBJ *) out;
5735
5736
0
  memset (filehdr_out, 0, sizeof (*filehdr_out));
5737
5738
0
  H_PUT_16 (abfd, IMAGE_FILE_MACHINE_UNKNOWN, filehdr_out->Sig1);
5739
0
  H_PUT_16 (abfd, 0xffff, filehdr_out->Sig2);
5740
0
  H_PUT_16 (abfd, 2, filehdr_out->Version);
5741
0
  memcpy (filehdr_out->ClassID, header_bigobj_classid, 16);
5742
0
  H_PUT_16 (abfd, filehdr_in->f_magic, filehdr_out->Machine);
5743
0
  H_PUT_32 (abfd, filehdr_in->f_nscns, filehdr_out->NumberOfSections);
5744
0
  H_PUT_32 (abfd, filehdr_in->f_timdat, filehdr_out->TimeDateStamp);
5745
0
  PUT_FILEHDR_SYMPTR (abfd, filehdr_in->f_symptr,
5746
0
          filehdr_out->PointerToSymbolTable);
5747
0
  H_PUT_32 (abfd, filehdr_in->f_nsyms, filehdr_out->NumberOfSymbols);
5748
5749
0
  return bfd_coff_filhsz (abfd);
5750
0
}
Unexecuted instantiation: pe-x86_64.c:coff_bigobj_swap_filehdr_out
Unexecuted instantiation: pe-i386.c:coff_bigobj_swap_filehdr_out
5751
5752
static void
5753
coff_bigobj_swap_sym_in (bfd * abfd, void * ext1, void * in1)
5754
0
{
5755
0
  SYMENT_BIGOBJ *ext = (SYMENT_BIGOBJ *) ext1;
5756
0
  struct internal_syment *in = (struct internal_syment *) in1;
5757
5758
0
  if (ext->e.e_name[0] == 0)
5759
0
    {
5760
0
      in->_n._n_n._n_zeroes = 0;
5761
0
      in->_n._n_n._n_offset = H_GET_32 (abfd, ext->e.e.e_offset);
5762
0
    }
5763
0
  else
5764
0
    {
5765
#if SYMNMLEN != E_SYMNMLEN
5766
#error we need to cope with truncating or extending SYMNMLEN
5767
#else
5768
0
      memcpy (in->_n._n_name, ext->e.e_name, SYMNMLEN);
5769
0
#endif
5770
0
    }
5771
5772
0
  in->n_value = H_GET_32 (abfd, ext->e_value);
5773
0
  BFD_ASSERT (sizeof (in->n_scnum) >= 4);
5774
0
  in->n_scnum = H_GET_32 (abfd, ext->e_scnum);
5775
0
  in->n_type = H_GET_16 (abfd, ext->e_type);
5776
0
  in->n_sclass = H_GET_8 (abfd, ext->e_sclass);
5777
0
  in->n_numaux = H_GET_8 (abfd, ext->e_numaux);
5778
0
}
Unexecuted instantiation: pe-x86_64.c:coff_bigobj_swap_sym_in
Unexecuted instantiation: pe-i386.c:coff_bigobj_swap_sym_in
5779
5780
static unsigned int
5781
coff_bigobj_swap_sym_out (bfd * abfd, void * inp, void * extp)
5782
0
{
5783
0
  struct internal_syment *in = (struct internal_syment *) inp;
5784
0
  SYMENT_BIGOBJ *ext = (SYMENT_BIGOBJ *) extp;
5785
5786
0
  if (in->_n._n_name[0] == 0)
5787
0
    {
5788
0
      H_PUT_32 (abfd, 0, ext->e.e.e_zeroes);
5789
0
      H_PUT_32 (abfd, in->_n._n_n._n_offset, ext->e.e.e_offset);
5790
0
    }
5791
0
  else
5792
0
    {
5793
#if SYMNMLEN != E_SYMNMLEN
5794
#error we need to cope with truncating or extending SYMNMLEN
5795
#else
5796
0
      memcpy (ext->e.e_name, in->_n._n_name, SYMNMLEN);
5797
0
#endif
5798
0
    }
5799
5800
0
  H_PUT_32 (abfd, in->n_value, ext->e_value);
5801
0
  H_PUT_32 (abfd, in->n_scnum, ext->e_scnum);
5802
5803
0
  H_PUT_16 (abfd, in->n_type, ext->e_type);
5804
0
  H_PUT_8 (abfd, in->n_sclass, ext->e_sclass);
5805
0
  H_PUT_8 (abfd, in->n_numaux, ext->e_numaux);
5806
5807
0
  return SYMESZ_BIGOBJ;
5808
0
}
Unexecuted instantiation: pe-x86_64.c:coff_bigobj_swap_sym_out
Unexecuted instantiation: pe-i386.c:coff_bigobj_swap_sym_out
5809
5810
static void
5811
coff_bigobj_swap_aux_in (bfd *abfd,
5812
       void * ext1,
5813
       int type,
5814
       int in_class,
5815
       int indx,
5816
       int numaux,
5817
       void * in1)
5818
0
{
5819
0
  AUXENT_BIGOBJ *ext = (AUXENT_BIGOBJ *) ext1;
5820
0
  union internal_auxent *in = (union internal_auxent *) in1;
5821
5822
  /* Make sure that all fields in the aux structure are
5823
     initialised.  */
5824
0
  memset (in, 0, sizeof * in);
5825
0
  switch (in_class)
5826
0
    {
5827
0
    case C_FILE:
5828
0
      if (numaux > 1)
5829
0
  {
5830
0
    if (indx == 0)
5831
0
      memcpy (in->x_file.x_n.x_fname, ext->File.Name,
5832
0
        numaux * sizeof (AUXENT_BIGOBJ));
5833
0
  }
5834
0
      else
5835
0
  memcpy (in->x_file.x_n.x_fname, ext->File.Name, sizeof (ext->File.Name));
5836
0
      break;
5837
5838
0
    case C_STAT:
5839
0
    case C_LEAFSTAT:
5840
0
    case C_HIDDEN:
5841
0
      if (type == T_NULL)
5842
0
  {
5843
0
    in->x_scn.x_scnlen = H_GET_32 (abfd, ext->Section.Length);
5844
0
    in->x_scn.x_nreloc =
5845
0
      H_GET_16 (abfd, ext->Section.NumberOfRelocations);
5846
0
    in->x_scn.x_nlinno =
5847
0
      H_GET_16 (abfd, ext->Section.NumberOfLinenumbers);
5848
0
    in->x_scn.x_checksum = H_GET_32 (abfd, ext->Section.Checksum);
5849
0
    in->x_scn.x_associated = H_GET_16 (abfd, ext->Section.Number)
5850
0
      | (H_GET_16 (abfd, ext->Section.HighNumber) << 16);
5851
0
    in->x_scn.x_comdat = H_GET_8 (abfd, ext->Section.Selection);
5852
0
    return;
5853
0
  }
5854
0
      break;
5855
5856
0
    default:
5857
0
      in->x_sym.x_tagndx.u32 = H_GET_32 (abfd, ext->Sym.WeakDefaultSymIndex);
5858
      /* Characteristics is ignored.  */
5859
0
      break;
5860
0
    }
5861
0
}
Unexecuted instantiation: pe-x86_64.c:coff_bigobj_swap_aux_in
Unexecuted instantiation: pe-i386.c:coff_bigobj_swap_aux_in
5862
5863
static unsigned int
5864
coff_bigobj_swap_aux_out (bfd * abfd,
5865
        void * inp,
5866
        int type,
5867
        int in_class,
5868
        int indx ATTRIBUTE_UNUSED,
5869
        int numaux ATTRIBUTE_UNUSED,
5870
        void * extp)
5871
0
{
5872
0
  union internal_auxent * in = (union internal_auxent *) inp;
5873
0
  AUXENT_BIGOBJ *ext = (AUXENT_BIGOBJ *) extp;
5874
5875
0
  memset (ext, 0, AUXESZ);
5876
5877
0
  switch (in_class)
5878
0
    {
5879
0
    case C_FILE:
5880
0
      memcpy (ext->File.Name, in->x_file.x_n.x_fname, sizeof (ext->File.Name));
5881
5882
0
      return AUXESZ;
5883
5884
0
    case C_STAT:
5885
0
    case C_LEAFSTAT:
5886
0
    case C_HIDDEN:
5887
0
      if (type == T_NULL)
5888
0
  {
5889
0
    H_PUT_32 (abfd, in->x_scn.x_scnlen, ext->Section.Length);
5890
0
    H_PUT_16 (abfd, in->x_scn.x_nreloc,
5891
0
        ext->Section.NumberOfRelocations);
5892
0
    H_PUT_16 (abfd, in->x_scn.x_nlinno,
5893
0
        ext->Section.NumberOfLinenumbers);
5894
0
    H_PUT_32 (abfd, in->x_scn.x_checksum, ext->Section.Checksum);
5895
0
    H_PUT_16 (abfd, in->x_scn.x_associated & 0xffff,
5896
0
        ext->Section.Number);
5897
0
    H_PUT_16 (abfd, (in->x_scn.x_associated >> 16),
5898
0
        ext->Section.HighNumber);
5899
0
    H_PUT_8 (abfd, in->x_scn.x_comdat, ext->Section.Selection);
5900
0
    return AUXESZ;
5901
0
  }
5902
0
      break;
5903
0
    }
5904
5905
0
  H_PUT_32 (abfd, in->x_sym.x_tagndx.u32, ext->Sym.WeakDefaultSymIndex);
5906
0
  H_PUT_32 (abfd, 1, ext->Sym.WeakSearchType);
5907
5908
0
  return AUXESZ;
5909
0
}
Unexecuted instantiation: pe-x86_64.c:coff_bigobj_swap_aux_out
Unexecuted instantiation: pe-i386.c:coff_bigobj_swap_aux_out
5910
5911
static const bfd_coff_backend_data bigobj_swap_table =
5912
{
5913
  coff_bigobj_swap_aux_in, coff_bigobj_swap_sym_in, coff_SWAP_lineno_in,
5914
  coff_bigobj_swap_aux_out, coff_bigobj_swap_sym_out,
5915
  coff_SWAP_lineno_out, coff_SWAP_reloc_out,
5916
  coff_bigobj_swap_filehdr_out, coff_SWAP_aouthdr_out,
5917
  coff_SWAP_scnhdr_out,
5918
  FILHSZ_BIGOBJ, AOUTSZ, SCNHSZ, SYMESZ_BIGOBJ, AUXESZ_BIGOBJ,
5919
   RELSZ, LINESZ, FILNMLEN_BIGOBJ,
5920
  true,
5921
  COFF_DEFAULT_LONG_SECTION_NAMES,
5922
  COFF_DEFAULT_SECTION_ALIGNMENT_POWER,
5923
  false,
5924
  2,
5925
  1U << 31,
5926
  coff_bigobj_swap_filehdr_in, coff_SWAP_aouthdr_in, coff_SWAP_scnhdr_in,
5927
  coff_SWAP_reloc_in, coff_bad_format_hook, coff_set_arch_mach_hook,
5928
  coff_mkobject_hook, styp_to_sec_flags, coff_set_alignment_hook,
5929
  coff_slurp_symbol_table, symname_in_debug_hook, coff_pointerize_aux_hook,
5930
  coff_print_aux, coff_reloc16_extra_cases, coff_reloc16_estimate,
5931
  coff_classify_symbol, coff_compute_section_file_positions,
5932
  coff_start_final_link, coff_relocate_section, coff_rtype_to_howto,
5933
  coff_adjust_symndx, coff_link_add_one_symbol,
5934
  coff_link_output_has_begun, coff_final_link_postscript,
5935
  bfd_pe_print_pdata  /* huh */
5936
};
5937
5938
#endif /* COFF_WITH_PE_BIGOBJ */
5939
5940
#ifndef coff_close_and_cleanup
5941
#define coff_close_and_cleanup        _bfd_generic_close_and_cleanup
5942
#endif
5943
5944
#ifndef coff_bfd_free_cached_info
5945
#define coff_bfd_free_cached_info     _bfd_coff_free_cached_info
5946
#endif
5947
5948
#ifndef coff_get_section_contents
5949
#define coff_get_section_contents     _bfd_generic_get_section_contents
5950
#endif
5951
5952
#ifndef coff_bfd_copy_private_symbol_data
5953
#define coff_bfd_copy_private_symbol_data   _bfd_generic_bfd_copy_private_symbol_data
5954
#endif
5955
5956
#ifndef coff_bfd_copy_private_header_data
5957
#define coff_bfd_copy_private_header_data   _bfd_generic_bfd_copy_private_header_data
5958
#endif
5959
5960
#ifndef coff_bfd_copy_private_section_data
5961
#define coff_bfd_copy_private_section_data  _bfd_generic_bfd_copy_private_section_data
5962
#endif
5963
5964
#ifndef coff_bfd_copy_private_bfd_data
5965
#define coff_bfd_copy_private_bfd_data      _bfd_generic_bfd_copy_private_bfd_data
5966
#endif
5967
5968
#ifndef coff_bfd_merge_private_bfd_data
5969
#define coff_bfd_merge_private_bfd_data     _bfd_generic_bfd_merge_private_bfd_data
5970
#endif
5971
5972
#ifndef coff_bfd_set_private_flags
5973
#define coff_bfd_set_private_flags      _bfd_generic_bfd_set_private_flags
5974
#endif
5975
5976
#ifndef coff_bfd_print_private_bfd_data
5977
#define coff_bfd_print_private_bfd_data     _bfd_generic_bfd_print_private_bfd_data
5978
#endif
5979
5980
#ifndef coff_bfd_is_local_label_name
5981
#define coff_bfd_is_local_label_name      _bfd_coff_is_local_label_name
5982
#endif
5983
5984
#ifndef coff_bfd_is_target_special_symbol
5985
#define coff_bfd_is_target_special_symbol   _bfd_bool_bfd_asymbol_false
5986
#endif
5987
5988
#ifndef coff_read_minisymbols
5989
#define coff_read_minisymbols       _bfd_generic_read_minisymbols
5990
#endif
5991
5992
#ifndef coff_minisymbol_to_symbol
5993
#define coff_minisymbol_to_symbol     _bfd_generic_minisymbol_to_symbol
5994
#endif
5995
5996
/* The reloc lookup routine must be supplied by each individual COFF
5997
   backend.  */
5998
#ifndef coff_bfd_reloc_type_lookup
5999
#define coff_bfd_reloc_type_lookup      _bfd_norelocs_bfd_reloc_type_lookup
6000
#endif
6001
#ifndef coff_bfd_reloc_name_lookup
6002
#define coff_bfd_reloc_name_lookup    _bfd_norelocs_bfd_reloc_name_lookup
6003
#endif
6004
6005
#ifndef coff_bfd_get_relocated_section_contents
6006
#define coff_bfd_get_relocated_section_contents \
6007
  bfd_generic_get_relocated_section_contents
6008
#endif
6009
6010
#ifndef coff_bfd_relax_section
6011
#define coff_bfd_relax_section        bfd_generic_relax_section
6012
#endif
6013
6014
#ifndef coff_bfd_gc_sections
6015
#define coff_bfd_gc_sections        bfd_coff_gc_sections
6016
#endif
6017
6018
#ifndef coff_bfd_lookup_section_flags
6019
#define coff_bfd_lookup_section_flags     bfd_generic_lookup_section_flags
6020
#endif
6021
6022
#ifndef coff_bfd_merge_sections
6023
#define coff_bfd_merge_sections       bfd_generic_merge_sections
6024
#endif
6025
6026
#ifndef coff_bfd_is_group_section
6027
#define coff_bfd_is_group_section     bfd_generic_is_group_section
6028
#endif
6029
6030
#ifndef coff_bfd_group_name
6031
#define coff_bfd_group_name       bfd_coff_group_name
6032
#endif
6033
6034
#ifndef coff_bfd_discard_group
6035
#define coff_bfd_discard_group        bfd_generic_discard_group
6036
#endif
6037
6038
#ifndef coff_section_already_linked
6039
#define coff_section_already_linked \
6040
  _bfd_coff_section_already_linked
6041
#endif
6042
6043
#ifndef coff_bfd_define_common_symbol
6044
#define coff_bfd_define_common_symbol     bfd_generic_define_common_symbol
6045
#endif
6046
6047
#ifndef coff_bfd_link_hide_symbol
6048
#define coff_bfd_link_hide_symbol     _bfd_generic_link_hide_symbol
6049
#endif
6050
6051
#ifndef coff_bfd_define_start_stop
6052
#define coff_bfd_define_start_stop      bfd_generic_define_start_stop
6053
#endif
6054
6055
#define CREATE_BIG_COFF_TARGET_VEC(VAR, NAME, EXTRA_O_FLAGS, EXTRA_S_FLAGS, UNDER, ALTERNATIVE, SWAP_TABLE) \
6056
const bfd_target VAR =              \
6057
{                 \
6058
  NAME ,                \
6059
  bfd_target_coff_flavour,            \
6060
  BFD_ENDIAN_BIG,   /* Data byte order is big.  */    \
6061
  BFD_ENDIAN_BIG,   /* Header byte order is big.  */  \
6062
  /* object flags */              \
6063
  (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG |      \
6064
   HAS_SYMS | HAS_LOCALS | WP_TEXT | EXTRA_O_FLAGS),      \
6065
  /* section flags */             \
6066
  (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | EXTRA_S_FLAGS),\
6067
  UNDER,      /* Leading symbol underscore.  */ \
6068
  '/',        /* AR_pad_char.  */     \
6069
  15,       /* AR_max_namelen.  */      \
6070
  0,        /* match priority.  */      \
6071
  TARGET_KEEP_UNUSED_SECTION_SYMBOLS, /* keep unused section symbols.  */ \
6072
                  \
6073
  /* Data conversion functions.  */         \
6074
  bfd_getb64, bfd_getb_signed_64, bfd_putb64,       \
6075
  bfd_getb32, bfd_getb_signed_32, bfd_putb32,       \
6076
  bfd_getb16, bfd_getb_signed_16, bfd_putb16,       \
6077
                  \
6078
  /* Header conversion functions.  */         \
6079
  bfd_getb64, bfd_getb_signed_64, bfd_putb64,       \
6080
  bfd_getb32, bfd_getb_signed_32, bfd_putb32,       \
6081
  bfd_getb16, bfd_getb_signed_16, bfd_putb16,       \
6082
                  \
6083
  {       /* bfd_check_format.  */    \
6084
    _bfd_dummy_target,              \
6085
    coff_object_p,              \
6086
    bfd_generic_archive_p,            \
6087
    _bfd_dummy_target             \
6088
  },                  \
6089
  {       /* bfd_set_format.  */      \
6090
    _bfd_bool_bfd_false_error,            \
6091
    coff_mkobject,              \
6092
    _bfd_generic_mkarchive,           \
6093
    _bfd_bool_bfd_false_error           \
6094
  },                  \
6095
  {       /* bfd_write_contents.  */    \
6096
    _bfd_bool_bfd_false_error,            \
6097
    coff_write_object_contents,           \
6098
    _bfd_write_archive_contents,          \
6099
    _bfd_bool_bfd_false_error           \
6100
  },                  \
6101
                  \
6102
  BFD_JUMP_TABLE_GENERIC (coff),          \
6103
  BFD_JUMP_TABLE_COPY (coff),           \
6104
  BFD_JUMP_TABLE_CORE (_bfd_nocore),          \
6105
  BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),       \
6106
  BFD_JUMP_TABLE_SYMBOLS (coff),          \
6107
  BFD_JUMP_TABLE_RELOCS (coff),           \
6108
  BFD_JUMP_TABLE_WRITE (coff),            \
6109
  BFD_JUMP_TABLE_LINK (coff),           \
6110
  BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),        \
6111
                  \
6112
  ALTERNATIVE,                \
6113
                  \
6114
  SWAP_TABLE                \
6115
};
6116
6117
#define CREATE_BIGHDR_COFF_TARGET_VEC(VAR, NAME, EXTRA_O_FLAGS, EXTRA_S_FLAGS, UNDER, ALTERNATIVE, SWAP_TABLE)  \
6118
const bfd_target VAR =              \
6119
{                 \
6120
  NAME ,                \
6121
  bfd_target_coff_flavour,            \
6122
  BFD_ENDIAN_LITTLE,    /* Data byte order is little.  */ \
6123
  BFD_ENDIAN_BIG,   /* Header byte order is big.  */  \
6124
  /* object flags */              \
6125
  (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG |      \
6126
   HAS_SYMS | HAS_LOCALS | WP_TEXT | EXTRA_O_FLAGS),      \
6127
  /* section flags */             \
6128
  (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | EXTRA_S_FLAGS),\
6129
  UNDER,      /* Leading symbol underscore.  */ \
6130
  '/',        /* AR_pad_char.  */     \
6131
  15,       /* AR_max_namelen.  */      \
6132
  0,        /* match priority.  */      \
6133
  TARGET_KEEP_UNUSED_SECTION_SYMBOLS, /* keep unused section symbols.  */ \
6134
                  \
6135
  /* Data conversion functions.  */         \
6136
  bfd_getb64, bfd_getb_signed_64, bfd_putb64,       \
6137
  bfd_getb32, bfd_getb_signed_32, bfd_putb32,       \
6138
  bfd_getb16, bfd_getb_signed_16, bfd_putb16,       \
6139
                  \
6140
  /* Header conversion functions.  */         \
6141
  bfd_getb64, bfd_getb_signed_64, bfd_putb64,       \
6142
  bfd_getb32, bfd_getb_signed_32, bfd_putb32,       \
6143
  bfd_getb16, bfd_getb_signed_16, bfd_putb16,       \
6144
                  \
6145
  {       /* bfd_check_format.  */    \
6146
    _bfd_dummy_target,              \
6147
    coff_object_p,              \
6148
    bfd_generic_archive_p,            \
6149
    _bfd_dummy_target             \
6150
  },                  \
6151
  {       /* bfd_set_format.  */      \
6152
    _bfd_bool_bfd_false_error,            \
6153
    coff_mkobject,              \
6154
    _bfd_generic_mkarchive,           \
6155
    _bfd_bool_bfd_false_error           \
6156
  },                  \
6157
  {       /* bfd_write_contents.  */    \
6158
    _bfd_bool_bfd_false_error,            \
6159
    coff_write_object_contents,           \
6160
    _bfd_write_archive_contents,          \
6161
    _bfd_bool_bfd_false_error           \
6162
  },                  \
6163
                  \
6164
  BFD_JUMP_TABLE_GENERIC (coff),          \
6165
  BFD_JUMP_TABLE_COPY (coff),           \
6166
  BFD_JUMP_TABLE_CORE (_bfd_nocore),          \
6167
  BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),       \
6168
  BFD_JUMP_TABLE_SYMBOLS (coff),          \
6169
  BFD_JUMP_TABLE_RELOCS (coff),           \
6170
  BFD_JUMP_TABLE_WRITE (coff),            \
6171
  BFD_JUMP_TABLE_LINK (coff),           \
6172
  BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),        \
6173
                  \
6174
  ALTERNATIVE,                \
6175
                  \
6176
  SWAP_TABLE                \
6177
};
6178
6179
#define CREATE_LITTLE_COFF_TARGET_VEC(VAR, NAME, EXTRA_O_FLAGS, EXTRA_S_FLAGS, UNDER, ALTERNATIVE, SWAP_TABLE)  \
6180
const bfd_target VAR =              \
6181
{                 \
6182
  NAME ,                \
6183
  bfd_target_coff_flavour,            \
6184
  BFD_ENDIAN_LITTLE,    /* Data byte order is little.  */ \
6185
  BFD_ENDIAN_LITTLE,    /* Header byte order is little.  */ \
6186
  /* object flags */            \
6187
  (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG |      \
6188
   HAS_SYMS | HAS_LOCALS | WP_TEXT | EXTRA_O_FLAGS),      \
6189
  /* section flags */           \
6190
  (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | EXTRA_S_FLAGS),\
6191
  UNDER,      /* Leading symbol underscore.  */ \
6192
  '/',        /* AR_pad_char.  */     \
6193
  15,       /* AR_max_namelen.  */      \
6194
  0,        /* match priority.  */      \
6195
  TARGET_KEEP_UNUSED_SECTION_SYMBOLS, /* keep unused section symbols.  */ \
6196
                  \
6197
  /* Data conversion functions.  */         \
6198
  bfd_getl64, bfd_getl_signed_64, bfd_putl64,       \
6199
  bfd_getl32, bfd_getl_signed_32, bfd_putl32,       \
6200
  bfd_getl16, bfd_getl_signed_16, bfd_putl16,       \
6201
  /* Header conversion functions.  */         \
6202
  bfd_getl64, bfd_getl_signed_64, bfd_putl64,       \
6203
  bfd_getl32, bfd_getl_signed_32, bfd_putl32,       \
6204
  bfd_getl16, bfd_getl_signed_16, bfd_putl16,       \
6205
                  \
6206
  {       /* bfd_check_format.  */    \
6207
    _bfd_dummy_target,              \
6208
    coff_object_p,              \
6209
    bfd_generic_archive_p,            \
6210
    _bfd_dummy_target             \
6211
  },                  \
6212
  {       /* bfd_set_format.  */      \
6213
    _bfd_bool_bfd_false_error,            \
6214
    coff_mkobject,              \
6215
    _bfd_generic_mkarchive,           \
6216
    _bfd_bool_bfd_false_error           \
6217
  },                  \
6218
  {       /* bfd_write_contents.  */    \
6219
    _bfd_bool_bfd_false_error,            \
6220
    coff_write_object_contents,           \
6221
    _bfd_write_archive_contents,          \
6222
    _bfd_bool_bfd_false_error           \
6223
  },                  \
6224
                  \
6225
  BFD_JUMP_TABLE_GENERIC (coff),          \
6226
  BFD_JUMP_TABLE_COPY (coff),           \
6227
  BFD_JUMP_TABLE_CORE (_bfd_nocore),          \
6228
  BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),       \
6229
  BFD_JUMP_TABLE_SYMBOLS (coff),          \
6230
  BFD_JUMP_TABLE_RELOCS (coff),           \
6231
  BFD_JUMP_TABLE_WRITE (coff),            \
6232
  BFD_JUMP_TABLE_LINK (coff),           \
6233
  BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),        \
6234
                  \
6235
  ALTERNATIVE,                \
6236
                  \
6237
  SWAP_TABLE                \
6238
};