Coverage Report

Created: 2023-08-28 06:25

/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
1.28M
#define DOT_DEBUG ".debug"
366
1.27M
#define DOT_ZDEBUG  ".zdebug"
367
1.00M
#define GNU_LINKONCE_WI ".gnu.linkonce.wi."
368
1.00M
#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
1.16M
{
411
1.16M
  bfd_coff_long_section_names (abfd) = enable;
412
1.16M
  return true;
413
1.16M
}
pei-i386.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-x86_64.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
88.1k
{
411
88.1k
  bfd_coff_long_section_names (abfd) = enable;
412
88.1k
  return true;
413
88.1k
}
pei-x86_64.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
3.04k
{
411
3.04k
  bfd_coff_long_section_names (abfd) = enable;
412
3.04k
  return true;
413
3.04k
}
pe-aarch64.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
4.32k
{
411
4.32k
  bfd_coff_long_section_names (abfd) = enable;
412
4.32k
  return true;
413
4.32k
}
pei-aarch64.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
14.7k
{
411
14.7k
  bfd_coff_long_section_names (abfd) = enable;
412
14.7k
  return true;
413
14.7k
}
pei-ia64.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
75.8k
{
411
75.8k
  bfd_coff_long_section_names (abfd) = enable;
412
75.8k
  return true;
413
75.8k
}
pei-loongarch64.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
2.07k
{
411
2.07k
  bfd_coff_long_section_names (abfd) = enable;
412
2.07k
  return true;
413
2.07k
}
coff-go32.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
181k
{
411
181k
  bfd_coff_long_section_names (abfd) = enable;
412
181k
  return true;
413
181k
}
Unexecuted instantiation: coff-stgo32.c:bfd_coff_set_long_section_names_allowed
pe-arm-wince.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
2.64k
{
411
2.64k
  bfd_coff_long_section_names (abfd) = enable;
412
2.64k
  return true;
413
2.64k
}
pe-arm.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
2.64k
{
411
2.64k
  bfd_coff_long_section_names (abfd) = enable;
412
2.64k
  return true;
413
2.64k
}
pe-i386.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
4.21k
{
411
4.21k
  bfd_coff_long_section_names (abfd) = enable;
412
4.21k
  return true;
413
4.21k
}
pe-mcore.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
23.2k
{
411
23.2k
  bfd_coff_long_section_names (abfd) = enable;
412
23.2k
  return true;
413
23.2k
}
pe-sh.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-arm-wince.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
43.0k
{
411
43.0k
  bfd_coff_long_section_names (abfd) = enable;
412
43.0k
  return true;
413
43.0k
}
pei-arm.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
596k
{
411
596k
  bfd_coff_long_section_names (abfd) = enable;
412
596k
  return true;
413
596k
}
pei-mcore.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
52.9k
{
411
52.9k
  bfd_coff_long_section_names (abfd) = enable;
412
52.9k
  return true;
413
52.9k
}
pei-sh.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
48.7k
{
411
48.7k
  bfd_coff_long_section_names (abfd) = enable;
412
48.7k
  return true;
413
48.7k
}
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
928k
{
419
928k
  return false;
420
928k
}
coff-x86_64.c:bfd_coff_set_long_section_names_disallowed
Line
Count
Source
418
371k
{
419
371k
  return false;
420
371k
}
coff64-rs6000.c:bfd_coff_set_long_section_names_disallowed
Line
Count
Source
418
70.8k
{
419
70.8k
  return false;
420
70.8k
}
cf-i386lynx.c:bfd_coff_set_long_section_names_disallowed
Line
Count
Source
418
187k
{
419
187k
  return false;
420
187k
}
coff-i386.c:bfd_coff_set_long_section_names_disallowed
Line
Count
Source
418
187k
{
419
187k
  return false;
420
187k
}
coff-rs6000.c:bfd_coff_set_long_section_names_disallowed
Line
Count
Source
418
28.5k
{
419
28.5k
  return false;
420
28.5k
}
coff-sh.c:bfd_coff_set_long_section_names_disallowed
Line
Count
Source
418
10.2k
{
419
10.2k
  return false;
420
10.2k
}
coff-tic30.c:bfd_coff_set_long_section_names_disallowed
Line
Count
Source
418
6.64k
{
419
6.64k
  return false;
420
6.64k
}
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
8.78k
{
419
8.78k
  return false;
420
8.78k
}
coff-z80.c:bfd_coff_set_long_section_names_disallowed
Line
Count
Source
418
54.1k
{
419
54.1k
  return false;
420
54.1k
}
coff-z8k.c:bfd_coff_set_long_section_names_disallowed
Line
Count
Source
418
3.82k
{
419
3.82k
  return false;
420
3.82k
}
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
1.10M
{
688
1.10M
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
689
1.10M
  unsigned long styp_flags = internal_s->s_flags;
690
1.10M
  flagword sec_flags = 0;
691
692
#ifdef STYP_BLOCK
693
8.78k
  if (styp_flags & STYP_BLOCK)
694
2.37k
    sec_flags |= SEC_TIC54X_BLOCK;
695
#endif
696
697
#ifdef STYP_CLINK
698
8.78k
  if (styp_flags & STYP_CLINK)
699
3.01k
    sec_flags |= SEC_TIC54X_CLINK;
700
#endif
701
702
1.10M
#ifdef STYP_NOLOAD
703
1.10M
  if (styp_flags & STYP_NOLOAD)
704
438k
    sec_flags |= SEC_NEVER_LOAD;
705
1.10M
#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.10M
  if (styp_flags & STYP_TEXT)
710
430k
    {
711
430k
      if (sec_flags & SEC_NEVER_LOAD)
712
240k
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
713
190k
      else
714
190k
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
715
430k
    }
716
679k
  else if (styp_flags & STYP_DATA)
717
192k
    {
718
192k
      if (sec_flags & SEC_NEVER_LOAD)
719
96.9k
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
720
95.1k
      else
721
95.1k
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
722
192k
    }
723
487k
  else if (styp_flags & STYP_BSS)
724
94.0k
    {
725
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
726
83.1k
      if (sec_flags & SEC_NEVER_LOAD)
727
42.4k
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
728
40.6k
      else
729
40.6k
#endif
730
51.6k
  sec_flags |= SEC_ALLOC;
731
94.0k
    }
732
393k
  else if (styp_flags & STYP_INFO)
733
53.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
#if defined (COFF_PAGE_SIZE) && !defined (COFF_ALIGN_IN_S_FLAGS)
741
44.8k
      sec_flags |= SEC_DEBUGGING;
742
#endif
743
53.6k
    }
744
339k
  else if (styp_flags & STYP_PAD)
745
29.4k
    sec_flags = 0;
746
#ifdef RS6000COFF_C
747
50.9k
  else if (styp_flags & STYP_TDATA)
748
1.84k
    {
749
1.84k
      if (sec_flags & SEC_NEVER_LOAD)
750
396
  sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY;
751
1.45k
      else
752
1.45k
  sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_LOAD | SEC_ALLOC;
753
1.84k
    }
754
49.1k
  else if (styp_flags & STYP_TBSS)
755
530
    {
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
530
  sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL;
762
530
    }
763
48.5k
  else if (styp_flags & STYP_EXCEPT)
764
5.26k
    sec_flags |= SEC_LOAD;
765
43.3k
  else if (styp_flags & STYP_LOADER)
766
1.38k
    sec_flags |= SEC_LOAD;
767
41.9k
  else if (styp_flags & STYP_TYPCHK)
768
172
    sec_flags |= SEC_LOAD;
769
41.7k
  else if (styp_flags & STYP_DWARF)
770
148
    sec_flags |= SEC_DEBUGGING;
771
41.6k
#endif
772
300k
  else if (strcmp (name, _TEXT) == 0)
773
96
    {
774
96
      if (sec_flags & SEC_NEVER_LOAD)
775
40
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
776
56
      else
777
56
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
778
96
    }
779
300k
  else if (strcmp (name, _DATA) == 0)
780
106
    {
781
106
      if (sec_flags & SEC_NEVER_LOAD)
782
44
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
783
62
      else
784
62
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
785
106
    }
786
300k
  else if (strcmp (name, _BSS) == 0)
787
74
    {
788
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
789
38
      if (sec_flags & SEC_NEVER_LOAD)
790
8
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
791
30
      else
792
30
#endif
793
66
  sec_flags |= SEC_ALLOC;
794
74
    }
795
300k
  else if (startswith (name, DOT_DEBUG)
796
300k
     || startswith (name, DOT_ZDEBUG)
797
#ifdef _COMMENT
798
255k
     || strcmp (name, _COMMENT) == 0
799
#endif
800
#ifdef COFF_LONG_SECTION_NAMES
801
26.5k
     || startswith (name, GNU_LINKONCE_WI)
802
26.5k
     || startswith (name, GNU_LINKONCE_WT)
803
#endif
804
300k
     || startswith (name, ".stab"))
805
588
    {
806
#ifdef COFF_PAGE_SIZE
807
304
      sec_flags |= SEC_DEBUGGING;
808
#endif
809
588
    }
810
#ifdef _LIB
811
255k
  else if (strcmp (name, _LIB) == 0)
812
12
    ;
813
255k
#endif
814
#ifdef _LIT
815
  else if (strcmp (name, _LIT) == 0)
816
    sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY;
817
#endif
818
255k
  else
819
299k
    sec_flags |= SEC_ALLOC | SEC_LOAD;
820
821
1.10M
#ifdef STYP_LIT     /* A29k readonly text/data section type.  */
822
1.10M
  if ((styp_flags & STYP_LIT) == STYP_LIT)
823
197k
    sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY);
824
1.10M
#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.10M
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
832
1.10M
      && (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
180k
  if (startswith (name, ".gnu.linkonce"))
844
0
    sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
845
#endif
846
847
1.10M
  if (flags_ptr == NULL)
848
0
    return false;
849
850
1.10M
  * flags_ptr = sec_flags;
851
1.10M
  return true;
852
1.10M
}
coff-x86_64.c:styp_to_sec_flags
Line
Count
Source
687
371k
{
688
371k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
689
371k
  unsigned long styp_flags = internal_s->s_flags;
690
371k
  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
371k
#ifdef STYP_NOLOAD
703
371k
  if (styp_flags & STYP_NOLOAD)
704
144k
    sec_flags |= SEC_NEVER_LOAD;
705
371k
#endif /* STYP_NOLOAD */
706
707
  /* For 386 COFF, at least, an unloadable text or data section is
708
     actually a shared library section.  */
709
371k
  if (styp_flags & STYP_TEXT)
710
145k
    {
711
145k
      if (sec_flags & SEC_NEVER_LOAD)
712
94.8k
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
713
50.3k
      else
714
50.3k
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
715
145k
    }
716
226k
  else if (styp_flags & STYP_DATA)
717
47.7k
    {
718
47.7k
      if (sec_flags & SEC_NEVER_LOAD)
719
25.0k
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
720
22.6k
      else
721
22.6k
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
722
47.7k
    }
723
178k
  else if (styp_flags & STYP_BSS)
724
23.5k
    {
725
23.5k
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
726
23.5k
      if (sec_flags & SEC_NEVER_LOAD)
727
11.8k
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
728
11.6k
      else
729
11.6k
#endif
730
11.6k
  sec_flags |= SEC_ALLOC;
731
23.5k
    }
732
154k
  else if (styp_flags & STYP_INFO)
733
12.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
12.8k
#if defined (COFF_PAGE_SIZE) && !defined (COFF_ALIGN_IN_S_FLAGS)
741
12.8k
      sec_flags |= SEC_DEBUGGING;
742
12.8k
#endif
743
12.8k
    }
744
142k
  else if (styp_flags & STYP_PAD)
745
6.21k
    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
135k
  else if (strcmp (name, _TEXT) == 0)
773
10
    {
774
10
      if (sec_flags & SEC_NEVER_LOAD)
775
2
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
776
8
      else
777
8
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
778
10
    }
779
135k
  else if (strcmp (name, _DATA) == 0)
780
10
    {
781
10
      if (sec_flags & SEC_NEVER_LOAD)
782
2
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
783
8
      else
784
8
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
785
10
    }
786
135k
  else if (strcmp (name, _BSS) == 0)
787
14
    {
788
14
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
789
14
      if (sec_flags & SEC_NEVER_LOAD)
790
2
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
791
12
      else
792
12
#endif
793
12
  sec_flags |= SEC_ALLOC;
794
14
    }
795
135k
  else if (startswith (name, DOT_DEBUG)
796
135k
     || startswith (name, DOT_ZDEBUG)
797
135k
#ifdef _COMMENT
798
135k
     || strcmp (name, _COMMENT) == 0
799
135k
#endif
800
#ifdef COFF_LONG_SECTION_NAMES
801
     || startswith (name, GNU_LINKONCE_WI)
802
     || startswith (name, GNU_LINKONCE_WT)
803
#endif
804
135k
     || startswith (name, ".stab"))
805
70
    {
806
70
#ifdef COFF_PAGE_SIZE
807
70
      sec_flags |= SEC_DEBUGGING;
808
70
#endif
809
70
    }
810
135k
#ifdef _LIB
811
135k
  else if (strcmp (name, _LIB) == 0)
812
2
    ;
813
135k
#endif
814
#ifdef _LIT
815
  else if (strcmp (name, _LIT) == 0)
816
    sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY;
817
#endif
818
135k
  else
819
135k
    sec_flags |= SEC_ALLOC | SEC_LOAD;
820
821
371k
#ifdef STYP_LIT     /* A29k readonly text/data section type.  */
822
371k
  if ((styp_flags & STYP_LIT) == STYP_LIT)
823
55.6k
    sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY);
824
371k
#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
371k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
832
371k
      && (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
371k
  if (flags_ptr == NULL)
848
0
    return false;
849
850
371k
  * flags_ptr = sec_flags;
851
371k
  return true;
852
371k
}
coff64-rs6000.c:styp_to_sec_flags
Line
Count
Source
687
70.8k
{
688
70.8k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
689
70.8k
  unsigned long styp_flags = internal_s->s_flags;
690
70.8k
  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
70.8k
#ifdef STYP_NOLOAD
703
70.8k
  if (styp_flags & STYP_NOLOAD)
704
20.9k
    sec_flags |= SEC_NEVER_LOAD;
705
70.8k
#endif /* STYP_NOLOAD */
706
707
  /* For 386 COFF, at least, an unloadable text or data section is
708
     actually a shared library section.  */
709
70.8k
  if (styp_flags & STYP_TEXT)
710
21.0k
    {
711
21.0k
      if (sec_flags & SEC_NEVER_LOAD)
712
11.0k
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
713
9.98k
      else
714
9.98k
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
715
21.0k
    }
716
49.7k
  else if (styp_flags & STYP_DATA)
717
9.84k
    {
718
9.84k
      if (sec_flags & SEC_NEVER_LOAD)
719
4.74k
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
720
5.10k
      else
721
5.10k
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
722
9.84k
    }
723
39.9k
  else if (styp_flags & STYP_BSS)
724
4.75k
    {
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
4.75k
  sec_flags |= SEC_ALLOC;
731
4.75k
    }
732
35.1k
  else if (styp_flags & STYP_INFO)
733
2.67k
    {
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
2.67k
    }
744
32.5k
  else if (styp_flags & STYP_PAD)
745
1.66k
    sec_flags = 0;
746
30.8k
#ifdef RS6000COFF_C
747
30.8k
  else if (styp_flags & STYP_TDATA)
748
1.34k
    {
749
1.34k
      if (sec_flags & SEC_NEVER_LOAD)
750
358
  sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY;
751
990
      else
752
990
  sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_LOAD | SEC_ALLOC;
753
1.34k
    }
754
29.4k
  else if (styp_flags & STYP_TBSS)
755
364
    {
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
364
  sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL;
762
364
    }
763
29.1k
  else if (styp_flags & STYP_EXCEPT)
764
4.60k
    sec_flags |= SEC_LOAD;
765
24.5k
  else if (styp_flags & STYP_LOADER)
766
788
    sec_flags |= SEC_LOAD;
767
23.7k
  else if (styp_flags & STYP_TYPCHK)
768
76
    sec_flags |= SEC_LOAD;
769
23.6k
  else if (styp_flags & STYP_DWARF)
770
36
    sec_flags |= SEC_DEBUGGING;
771
23.6k
#endif
772
23.6k
  else if (strcmp (name, _TEXT) == 0)
773
0
    {
774
0
      if (sec_flags & SEC_NEVER_LOAD)
775
0
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
776
0
      else
777
0
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
778
0
    }
779
23.6k
  else if (strcmp (name, _DATA) == 0)
780
14
    {
781
14
      if (sec_flags & SEC_NEVER_LOAD)
782
6
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
783
8
      else
784
8
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
785
14
    }
786
23.6k
  else if (strcmp (name, _BSS) == 0)
787
0
    {
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
0
  sec_flags |= SEC_ALLOC;
794
0
    }
795
23.6k
  else if (startswith (name, DOT_DEBUG)
796
23.6k
     || 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
23.6k
     || startswith (name, ".stab"))
805
36
    {
806
#ifdef COFF_PAGE_SIZE
807
      sec_flags |= SEC_DEBUGGING;
808
#endif
809
36
    }
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
23.5k
  else
819
23.5k
    sec_flags |= SEC_ALLOC | SEC_LOAD;
820
821
70.8k
#ifdef STYP_LIT     /* A29k readonly text/data section type.  */
822
70.8k
  if ((styp_flags & STYP_LIT) == STYP_LIT)
823
10.3k
    sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY);
824
70.8k
#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
70.8k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
832
70.8k
      && (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
70.8k
  if (flags_ptr == NULL)
848
0
    return false;
849
850
70.8k
  * flags_ptr = sec_flags;
851
70.8k
  return true;
852
70.8k
}
cf-i386lynx.c:styp_to_sec_flags
Line
Count
Source
687
187k
{
688
187k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
689
187k
  unsigned long styp_flags = internal_s->s_flags;
690
187k
  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
187k
#ifdef STYP_NOLOAD
703
187k
  if (styp_flags & STYP_NOLOAD)
704
82.9k
    sec_flags |= SEC_NEVER_LOAD;
705
187k
#endif /* STYP_NOLOAD */
706
707
  /* For 386 COFF, at least, an unloadable text or data section is
708
     actually a shared library section.  */
709
187k
  if (styp_flags & STYP_TEXT)
710
81.5k
    {
711
81.5k
      if (sec_flags & SEC_NEVER_LOAD)
712
41.3k
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
713
40.1k
      else
714
40.1k
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
715
81.5k
    }
716
105k
  else if (styp_flags & STYP_DATA)
717
40.7k
    {
718
40.7k
      if (sec_flags & SEC_NEVER_LOAD)
719
20.4k
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
720
20.3k
      else
721
20.3k
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
722
40.7k
    }
723
64.8k
  else if (styp_flags & STYP_BSS)
724
20.1k
    {
725
20.1k
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
726
20.1k
      if (sec_flags & SEC_NEVER_LOAD)
727
10.3k
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
728
9.80k
      else
729
9.80k
#endif
730
9.80k
  sec_flags |= SEC_ALLOC;
731
20.1k
    }
732
44.7k
  else if (styp_flags & STYP_INFO)
733
10.7k
    {
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
10.7k
#if defined (COFF_PAGE_SIZE) && !defined (COFF_ALIGN_IN_S_FLAGS)
741
10.7k
      sec_flags |= SEC_DEBUGGING;
742
10.7k
#endif
743
10.7k
    }
744
33.9k
  else if (styp_flags & STYP_PAD)
745
6.17k
    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
27.8k
  else if (strcmp (name, _TEXT) == 0)
773
12
    {
774
12
      if (sec_flags & SEC_NEVER_LOAD)
775
2
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
776
10
      else
777
10
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
778
12
    }
779
27.8k
  else if (strcmp (name, _DATA) == 0)
780
8
    {
781
8
      if (sec_flags & SEC_NEVER_LOAD)
782
2
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
783
6
      else
784
6
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
785
8
    }
786
27.8k
  else if (strcmp (name, _BSS) == 0)
787
8
    {
788
8
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
789
8
      if (sec_flags & SEC_NEVER_LOAD)
790
2
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
791
6
      else
792
6
#endif
793
6
  sec_flags |= SEC_ALLOC;
794
8
    }
795
27.7k
  else if (startswith (name, DOT_DEBUG)
796
27.7k
     || startswith (name, DOT_ZDEBUG)
797
27.7k
#ifdef _COMMENT
798
27.7k
     || strcmp (name, _COMMENT) == 0
799
27.7k
#endif
800
#ifdef COFF_LONG_SECTION_NAMES
801
     || startswith (name, GNU_LINKONCE_WI)
802
     || startswith (name, GNU_LINKONCE_WT)
803
#endif
804
27.7k
     || startswith (name, ".stab"))
805
78
    {
806
78
#ifdef COFF_PAGE_SIZE
807
78
      sec_flags |= SEC_DEBUGGING;
808
78
#endif
809
78
    }
810
27.7k
#ifdef _LIB
811
27.7k
  else if (strcmp (name, _LIB) == 0)
812
2
    ;
813
27.7k
#endif
814
#ifdef _LIT
815
  else if (strcmp (name, _LIT) == 0)
816
    sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY;
817
#endif
818
27.7k
  else
819
27.7k
    sec_flags |= SEC_ALLOC | SEC_LOAD;
820
821
187k
#ifdef STYP_LIT     /* A29k readonly text/data section type.  */
822
187k
  if ((styp_flags & STYP_LIT) == STYP_LIT)
823
40.9k
    sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY);
824
187k
#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
187k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
832
187k
      && (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
187k
  if (flags_ptr == NULL)
848
0
    return false;
849
850
187k
  * flags_ptr = sec_flags;
851
187k
  return true;
852
187k
}
coff-go32.c:styp_to_sec_flags
Line
Count
Source
687
180k
{
688
180k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
689
180k
  unsigned long styp_flags = internal_s->s_flags;
690
180k
  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
180k
#ifdef STYP_NOLOAD
703
180k
  if (styp_flags & STYP_NOLOAD)
704
80.4k
    sec_flags |= SEC_NEVER_LOAD;
705
180k
#endif /* STYP_NOLOAD */
706
707
  /* For 386 COFF, at least, an unloadable text or data section is
708
     actually a shared library section.  */
709
180k
  if (styp_flags & STYP_TEXT)
710
79.0k
    {
711
79.0k
      if (sec_flags & SEC_NEVER_LOAD)
712
40.1k
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
713
38.8k
      else
714
38.8k
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
715
79.0k
    }
716
101k
  else if (styp_flags & STYP_DATA)
717
39.4k
    {
718
39.4k
      if (sec_flags & SEC_NEVER_LOAD)
719
19.7k
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
720
19.6k
      else
721
19.6k
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
722
39.4k
    }
723
62.4k
  else if (styp_flags & STYP_BSS)
724
19.4k
    {
725
19.4k
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
726
19.4k
      if (sec_flags & SEC_NEVER_LOAD)
727
9.97k
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
728
9.46k
      else
729
9.46k
#endif
730
9.46k
  sec_flags |= SEC_ALLOC;
731
19.4k
    }
732
43.0k
  else if (styp_flags & STYP_INFO)
733
10.4k
    {
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
10.4k
#if defined (COFF_PAGE_SIZE) && !defined (COFF_ALIGN_IN_S_FLAGS)
741
10.4k
      sec_flags |= SEC_DEBUGGING;
742
10.4k
#endif
743
10.4k
    }
744
32.6k
  else if (styp_flags & STYP_PAD)
745
6.01k
    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
26.6k
  else if (strcmp (name, _TEXT) == 0)
773
12
    {
774
12
      if (sec_flags & SEC_NEVER_LOAD)
775
2
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
776
10
      else
777
10
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
778
12
    }
779
26.6k
  else if (strcmp (name, _DATA) == 0)
780
8
    {
781
8
      if (sec_flags & SEC_NEVER_LOAD)
782
2
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
783
6
      else
784
6
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
785
8
    }
786
26.5k
  else if (strcmp (name, _BSS) == 0)
787
8
    {
788
8
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
789
8
      if (sec_flags & SEC_NEVER_LOAD)
790
2
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
791
6
      else
792
6
#endif
793
6
  sec_flags |= SEC_ALLOC;
794
8
    }
795
26.5k
  else if (startswith (name, DOT_DEBUG)
796
26.5k
     || startswith (name, DOT_ZDEBUG)
797
26.5k
#ifdef _COMMENT
798
26.5k
     || strcmp (name, _COMMENT) == 0
799
26.5k
#endif
800
26.5k
#ifdef COFF_LONG_SECTION_NAMES
801
26.5k
     || startswith (name, GNU_LINKONCE_WI)
802
26.5k
     || startswith (name, GNU_LINKONCE_WT)
803
26.5k
#endif
804
26.5k
     || startswith (name, ".stab"))
805
78
    {
806
78
#ifdef COFF_PAGE_SIZE
807
78
      sec_flags |= SEC_DEBUGGING;
808
78
#endif
809
78
    }
810
26.5k
#ifdef _LIB
811
26.5k
  else if (strcmp (name, _LIB) == 0)
812
2
    ;
813
26.5k
#endif
814
#ifdef _LIT
815
  else if (strcmp (name, _LIT) == 0)
816
    sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY;
817
#endif
818
26.5k
  else
819
26.5k
    sec_flags |= SEC_ALLOC | SEC_LOAD;
820
821
180k
#ifdef STYP_LIT     /* A29k readonly text/data section type.  */
822
180k
  if ((styp_flags & STYP_LIT) == STYP_LIT)
823
39.7k
    sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY);
824
180k
#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
180k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
832
180k
      && (startswith (name, ".sbss")
833
0
    || startswith (name, ".sdata")))
834
0
    sec_flags |= SEC_SMALL_DATA;
835
836
180k
#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
180k
  if (startswith (name, ".gnu.linkonce"))
844
0
    sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
845
180k
#endif
846
847
180k
  if (flags_ptr == NULL)
848
0
    return false;
849
850
180k
  * flags_ptr = sec_flags;
851
180k
  return true;
852
180k
}
coff-i386.c:styp_to_sec_flags
Line
Count
Source
687
187k
{
688
187k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
689
187k
  unsigned long styp_flags = internal_s->s_flags;
690
187k
  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
187k
#ifdef STYP_NOLOAD
703
187k
  if (styp_flags & STYP_NOLOAD)
704
82.9k
    sec_flags |= SEC_NEVER_LOAD;
705
187k
#endif /* STYP_NOLOAD */
706
707
  /* For 386 COFF, at least, an unloadable text or data section is
708
     actually a shared library section.  */
709
187k
  if (styp_flags & STYP_TEXT)
710
81.5k
    {
711
81.5k
      if (sec_flags & SEC_NEVER_LOAD)
712
41.3k
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
713
40.1k
      else
714
40.1k
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
715
81.5k
    }
716
105k
  else if (styp_flags & STYP_DATA)
717
40.7k
    {
718
40.7k
      if (sec_flags & SEC_NEVER_LOAD)
719
20.4k
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
720
20.3k
      else
721
20.3k
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
722
40.7k
    }
723
64.8k
  else if (styp_flags & STYP_BSS)
724
20.1k
    {
725
20.1k
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
726
20.1k
      if (sec_flags & SEC_NEVER_LOAD)
727
10.3k
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
728
9.80k
      else
729
9.80k
#endif
730
9.80k
  sec_flags |= SEC_ALLOC;
731
20.1k
    }
732
44.7k
  else if (styp_flags & STYP_INFO)
733
10.7k
    {
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
10.7k
#if defined (COFF_PAGE_SIZE) && !defined (COFF_ALIGN_IN_S_FLAGS)
741
10.7k
      sec_flags |= SEC_DEBUGGING;
742
10.7k
#endif
743
10.7k
    }
744
33.9k
  else if (styp_flags & STYP_PAD)
745
6.17k
    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
27.8k
  else if (strcmp (name, _TEXT) == 0)
773
12
    {
774
12
      if (sec_flags & SEC_NEVER_LOAD)
775
2
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
776
10
      else
777
10
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
778
12
    }
779
27.8k
  else if (strcmp (name, _DATA) == 0)
780
8
    {
781
8
      if (sec_flags & SEC_NEVER_LOAD)
782
2
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
783
6
      else
784
6
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
785
8
    }
786
27.8k
  else if (strcmp (name, _BSS) == 0)
787
8
    {
788
8
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
789
8
      if (sec_flags & SEC_NEVER_LOAD)
790
2
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
791
6
      else
792
6
#endif
793
6
  sec_flags |= SEC_ALLOC;
794
8
    }
795
27.7k
  else if (startswith (name, DOT_DEBUG)
796
27.7k
     || startswith (name, DOT_ZDEBUG)
797
27.7k
#ifdef _COMMENT
798
27.7k
     || strcmp (name, _COMMENT) == 0
799
27.7k
#endif
800
#ifdef COFF_LONG_SECTION_NAMES
801
     || startswith (name, GNU_LINKONCE_WI)
802
     || startswith (name, GNU_LINKONCE_WT)
803
#endif
804
27.7k
     || startswith (name, ".stab"))
805
78
    {
806
78
#ifdef COFF_PAGE_SIZE
807
78
      sec_flags |= SEC_DEBUGGING;
808
78
#endif
809
78
    }
810
27.7k
#ifdef _LIB
811
27.7k
  else if (strcmp (name, _LIB) == 0)
812
2
    ;
813
27.7k
#endif
814
#ifdef _LIT
815
  else if (strcmp (name, _LIT) == 0)
816
    sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY;
817
#endif
818
27.7k
  else
819
27.7k
    sec_flags |= SEC_ALLOC | SEC_LOAD;
820
821
187k
#ifdef STYP_LIT     /* A29k readonly text/data section type.  */
822
187k
  if ((styp_flags & STYP_LIT) == STYP_LIT)
823
40.9k
    sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY);
824
187k
#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
187k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
832
187k
      && (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
187k
  if (flags_ptr == NULL)
848
0
    return false;
849
850
187k
  * flags_ptr = sec_flags;
851
187k
  return true;
852
187k
}
coff-rs6000.c:styp_to_sec_flags
Line
Count
Source
687
28.5k
{
688
28.5k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
689
28.5k
  unsigned long styp_flags = internal_s->s_flags;
690
28.5k
  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
28.5k
#ifdef STYP_NOLOAD
703
28.5k
  if (styp_flags & STYP_NOLOAD)
704
4.72k
    sec_flags |= SEC_NEVER_LOAD;
705
28.5k
#endif /* STYP_NOLOAD */
706
707
  /* For 386 COFF, at least, an unloadable text or data section is
708
     actually a shared library section.  */
709
28.5k
  if (styp_flags & STYP_TEXT)
710
3.43k
    {
711
3.43k
      if (sec_flags & SEC_NEVER_LOAD)
712
2.28k
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
713
1.14k
      else
714
1.14k
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
715
3.43k
    }
716
25.0k
  else if (styp_flags & STYP_DATA)
717
2.12k
    {
718
2.12k
      if (sec_flags & SEC_NEVER_LOAD)
719
642
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
720
1.48k
      else
721
1.48k
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
722
2.12k
    }
723
22.9k
  else if (styp_flags & STYP_BSS)
724
1.11k
    {
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
1.11k
  sec_flags |= SEC_ALLOC;
731
1.11k
    }
732
21.8k
  else if (styp_flags & STYP_INFO)
733
1.38k
    {
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
1.38k
    }
744
20.4k
  else if (styp_flags & STYP_PAD)
745
342
    sec_flags = 0;
746
20.1k
#ifdef RS6000COFF_C
747
20.1k
  else if (styp_flags & STYP_TDATA)
748
500
    {
749
500
      if (sec_flags & SEC_NEVER_LOAD)
750
38
  sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY;
751
462
      else
752
462
  sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_LOAD | SEC_ALLOC;
753
500
    }
754
19.6k
  else if (styp_flags & STYP_TBSS)
755
166
    {
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
166
  sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL;
762
166
    }
763
19.4k
  else if (styp_flags & STYP_EXCEPT)
764
654
    sec_flags |= SEC_LOAD;
765
18.8k
  else if (styp_flags & STYP_LOADER)
766
598
    sec_flags |= SEC_LOAD;
767
18.2k
  else if (styp_flags & STYP_TYPCHK)
768
96
    sec_flags |= SEC_LOAD;
769
18.1k
  else if (styp_flags & STYP_DWARF)
770
112
    sec_flags |= SEC_DEBUGGING;
771
18.0k
#endif
772
18.0k
  else if (strcmp (name, _TEXT) == 0)
773
8
    {
774
8
      if (sec_flags & SEC_NEVER_LOAD)
775
6
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
776
2
      else
777
2
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
778
8
    }
779
17.9k
  else if (strcmp (name, _DATA) == 0)
780
8
    {
781
8
      if (sec_flags & SEC_NEVER_LOAD)
782
2
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
783
6
      else
784
6
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
785
8
    }
786
17.9k
  else if (strcmp (name, _BSS) == 0)
787
12
    {
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
12
  sec_flags |= SEC_ALLOC;
794
12
    }
795
17.9k
  else if (startswith (name, DOT_DEBUG)
796
17.9k
     || 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
17.9k
     || startswith (name, ".stab"))
805
34
    {
806
#ifdef COFF_PAGE_SIZE
807
      sec_flags |= SEC_DEBUGGING;
808
#endif
809
34
    }
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
17.9k
  else
819
17.9k
    sec_flags |= SEC_ALLOC | SEC_LOAD;
820
821
28.5k
#ifdef STYP_LIT     /* A29k readonly text/data section type.  */
822
28.5k
  if ((styp_flags & STYP_LIT) == STYP_LIT)
823
1.23k
    sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY);
824
28.5k
#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
28.5k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
832
28.5k
      && (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
28.5k
  if (flags_ptr == NULL)
848
0
    return false;
849
850
28.5k
  * flags_ptr = sec_flags;
851
28.5k
  return true;
852
28.5k
}
coff-sh.c:styp_to_sec_flags
Line
Count
Source
687
10.2k
{
688
10.2k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
689
10.2k
  unsigned long styp_flags = internal_s->s_flags;
690
10.2k
  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
10.2k
#ifdef STYP_NOLOAD
703
10.2k
  if (styp_flags & STYP_NOLOAD)
704
2.58k
    sec_flags |= SEC_NEVER_LOAD;
705
10.2k
#endif /* STYP_NOLOAD */
706
707
  /* For 386 COFF, at least, an unloadable text or data section is
708
     actually a shared library section.  */
709
10.2k
  if (styp_flags & STYP_TEXT)
710
2.07k
    {
711
2.07k
      if (sec_flags & SEC_NEVER_LOAD)
712
906
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
713
1.16k
      else
714
1.16k
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
715
2.07k
    }
716
8.18k
  else if (styp_flags & STYP_DATA)
717
1.00k
    {
718
1.00k
      if (sec_flags & SEC_NEVER_LOAD)
719
686
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
720
322
      else
721
322
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
722
1.00k
    }
723
7.17k
  else if (styp_flags & STYP_BSS)
724
544
    {
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
544
  sec_flags |= SEC_ALLOC;
731
544
    }
732
6.63k
  else if (styp_flags & STYP_INFO)
733
626
    {
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
626
    }
744
6.00k
  else if (styp_flags & STYP_PAD)
745
214
    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
5.79k
  else if (strcmp (name, _TEXT) == 0)
773
4
    {
774
4
      if (sec_flags & SEC_NEVER_LOAD)
775
2
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
776
2
      else
777
2
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
778
4
    }
779
5.78k
  else if (strcmp (name, _DATA) == 0)
780
14
    {
781
14
      if (sec_flags & SEC_NEVER_LOAD)
782
12
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
783
2
      else
784
2
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
785
14
    }
786
5.77k
  else if (strcmp (name, _BSS) == 0)
787
10
    {
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
10
  sec_flags |= SEC_ALLOC;
794
10
    }
795
5.76k
  else if (startswith (name, DOT_DEBUG)
796
5.76k
     || startswith (name, DOT_ZDEBUG)
797
5.76k
#ifdef _COMMENT
798
5.76k
     || strcmp (name, _COMMENT) == 0
799
5.76k
#endif
800
#ifdef COFF_LONG_SECTION_NAMES
801
     || startswith (name, GNU_LINKONCE_WI)
802
     || startswith (name, GNU_LINKONCE_WT)
803
#endif
804
5.76k
     || startswith (name, ".stab"))
805
40
    {
806
#ifdef COFF_PAGE_SIZE
807
      sec_flags |= SEC_DEBUGGING;
808
#endif
809
40
    }
810
5.72k
#ifdef _LIB
811
5.72k
  else if (strcmp (name, _LIB) == 0)
812
0
    ;
813
5.72k
#endif
814
#ifdef _LIT
815
  else if (strcmp (name, _LIT) == 0)
816
    sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY;
817
#endif
818
5.72k
  else
819
5.72k
    sec_flags |= SEC_ALLOC | SEC_LOAD;
820
821
10.2k
#ifdef STYP_LIT     /* A29k readonly text/data section type.  */
822
10.2k
  if ((styp_flags & STYP_LIT) == STYP_LIT)
823
406
    sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY);
824
10.2k
#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
10.2k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
832
10.2k
      && (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
10.2k
  if (flags_ptr == NULL)
848
0
    return false;
849
850
10.2k
  * flags_ptr = sec_flags;
851
10.2k
  return true;
852
10.2k
}
Unexecuted instantiation: coff-stgo32.c:styp_to_sec_flags
coff-tic30.c:styp_to_sec_flags
Line
Count
Source
687
6.64k
{
688
6.64k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
689
6.64k
  unsigned long styp_flags = internal_s->s_flags;
690
6.64k
  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
6.64k
#ifdef STYP_NOLOAD
703
6.64k
  if (styp_flags & STYP_NOLOAD)
704
2.48k
    sec_flags |= SEC_NEVER_LOAD;
705
6.64k
#endif /* STYP_NOLOAD */
706
707
  /* For 386 COFF, at least, an unloadable text or data section is
708
     actually a shared library section.  */
709
6.64k
  if (styp_flags & STYP_TEXT)
710
1.85k
    {
711
1.85k
      if (sec_flags & SEC_NEVER_LOAD)
712
892
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
713
964
      else
714
964
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
715
1.85k
    }
716
4.78k
  else if (styp_flags & STYP_DATA)
717
934
    {
718
934
      if (sec_flags & SEC_NEVER_LOAD)
719
412
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
720
522
      else
721
522
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
722
934
    }
723
3.85k
  else if (styp_flags & STYP_BSS)
724
490
    {
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
490
  sec_flags |= SEC_ALLOC;
731
490
    }
732
3.36k
  else if (styp_flags & STYP_INFO)
733
1.00k
    {
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
1.00k
    }
744
2.35k
  else if (styp_flags & STYP_PAD)
745
744
    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.61k
  else if (strcmp (name, _TEXT) == 0)
773
4
    {
774
4
      if (sec_flags & SEC_NEVER_LOAD)
775
2
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
776
2
      else
777
2
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
778
4
    }
779
1.60k
  else if (strcmp (name, _DATA) == 0)
780
8
    {
781
8
      if (sec_flags & SEC_NEVER_LOAD)
782
2
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
783
6
      else
784
6
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
785
8
    }
786
1.60k
  else if (strcmp (name, _BSS) == 0)
787
4
    {
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
4
  sec_flags |= SEC_ALLOC;
794
4
    }
795
1.59k
  else if (startswith (name, DOT_DEBUG)
796
1.59k
     || startswith (name, DOT_ZDEBUG)
797
1.59k
#ifdef _COMMENT
798
1.59k
     || strcmp (name, _COMMENT) == 0
799
1.59k
#endif
800
#ifdef COFF_LONG_SECTION_NAMES
801
     || startswith (name, GNU_LINKONCE_WI)
802
     || startswith (name, GNU_LINKONCE_WT)
803
#endif
804
1.59k
     || startswith (name, ".stab"))
805
126
    {
806
#ifdef COFF_PAGE_SIZE
807
      sec_flags |= SEC_DEBUGGING;
808
#endif
809
126
    }
810
1.47k
#ifdef _LIB
811
1.47k
  else if (strcmp (name, _LIB) == 0)
812
0
    ;
813
1.47k
#endif
814
#ifdef _LIT
815
  else if (strcmp (name, _LIT) == 0)
816
    sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY;
817
#endif
818
1.47k
  else
819
1.47k
    sec_flags |= SEC_ALLOC | SEC_LOAD;
820
821
6.64k
#ifdef STYP_LIT     /* A29k readonly text/data section type.  */
822
6.64k
  if ((styp_flags & STYP_LIT) == STYP_LIT)
823
902
    sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY);
824
6.64k
#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
6.64k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
832
6.64k
      && (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
6.64k
  if (flags_ptr == NULL)
848
0
    return false;
849
850
6.64k
  * flags_ptr = sec_flags;
851
6.64k
  return true;
852
6.64k
}
Unexecuted instantiation: coff-tic4x.c:styp_to_sec_flags
coff-tic54x.c:styp_to_sec_flags
Line
Count
Source
687
8.78k
{
688
8.78k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
689
8.78k
  unsigned long styp_flags = internal_s->s_flags;
690
8.78k
  flagword sec_flags = 0;
691
692
8.78k
#ifdef STYP_BLOCK
693
8.78k
  if (styp_flags & STYP_BLOCK)
694
2.37k
    sec_flags |= SEC_TIC54X_BLOCK;
695
8.78k
#endif
696
697
8.78k
#ifdef STYP_CLINK
698
8.78k
  if (styp_flags & STYP_CLINK)
699
3.01k
    sec_flags |= SEC_TIC54X_CLINK;
700
8.78k
#endif
701
702
8.78k
#ifdef STYP_NOLOAD
703
8.78k
  if (styp_flags & STYP_NOLOAD)
704
3.02k
    sec_flags |= SEC_NEVER_LOAD;
705
8.78k
#endif /* STYP_NOLOAD */
706
707
  /* For 386 COFF, at least, an unloadable text or data section is
708
     actually a shared library section.  */
709
8.78k
  if (styp_flags & STYP_TEXT)
710
1.57k
    {
711
1.57k
      if (sec_flags & SEC_NEVER_LOAD)
712
900
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
713
678
      else
714
678
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
715
1.57k
    }
716
7.20k
  else if (styp_flags & STYP_DATA)
717
1.97k
    {
718
1.97k
      if (sec_flags & SEC_NEVER_LOAD)
719
1.58k
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
720
384
      else
721
384
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
722
1.97k
    }
723
5.23k
  else if (styp_flags & STYP_BSS)
724
646
    {
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
646
  sec_flags |= SEC_ALLOC;
731
646
    }
732
4.58k
  else if (styp_flags & STYP_INFO)
733
732
    {
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
732
    }
744
3.85k
  else if (styp_flags & STYP_PAD)
745
646
    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
3.20k
  else if (strcmp (name, _TEXT) == 0)
773
6
    {
774
6
      if (sec_flags & SEC_NEVER_LOAD)
775
6
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
776
0
      else
777
0
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
778
6
    }
779
3.20k
  else if (strcmp (name, _DATA) == 0)
780
12
    {
781
12
      if (sec_flags & SEC_NEVER_LOAD)
782
6
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
783
6
      else
784
6
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
785
12
    }
786
3.19k
  else if (strcmp (name, _BSS) == 0)
787
6
    {
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
6
  sec_flags |= SEC_ALLOC;
794
6
    }
795
3.18k
  else if (startswith (name, DOT_DEBUG)
796
3.18k
     || 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
3.18k
     || startswith (name, ".stab"))
805
12
    {
806
#ifdef COFF_PAGE_SIZE
807
      sec_flags |= SEC_DEBUGGING;
808
#endif
809
12
    }
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
3.17k
  else
819
3.17k
    sec_flags |= SEC_ALLOC | SEC_LOAD;
820
821
8.78k
#ifdef STYP_LIT     /* A29k readonly text/data section type.  */
822
8.78k
  if ((styp_flags & STYP_LIT) == STYP_LIT)
823
778
    sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY);
824
8.78k
#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
8.78k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
832
8.78k
      && (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
8.78k
  if (flags_ptr == NULL)
848
0
    return false;
849
850
8.78k
  * flags_ptr = sec_flags;
851
8.78k
  return true;
852
8.78k
}
coff-z80.c:styp_to_sec_flags
Line
Count
Source
687
54.1k
{
688
54.1k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
689
54.1k
  unsigned long styp_flags = internal_s->s_flags;
690
54.1k
  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
54.1k
#ifdef STYP_NOLOAD
703
54.1k
  if (styp_flags & STYP_NOLOAD)
704
12.8k
    sec_flags |= SEC_NEVER_LOAD;
705
54.1k
#endif /* STYP_NOLOAD */
706
707
  /* For 386 COFF, at least, an unloadable text or data section is
708
     actually a shared library section.  */
709
54.1k
  if (styp_flags & STYP_TEXT)
710
12.3k
    {
711
12.3k
      if (sec_flags & SEC_NEVER_LOAD)
712
6.22k
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
713
6.14k
      else
714
6.14k
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
715
12.3k
    }
716
41.7k
  else if (styp_flags & STYP_DATA)
717
6.91k
    {
718
6.91k
      if (sec_flags & SEC_NEVER_LOAD)
719
3.04k
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
720
3.87k
      else
721
3.87k
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
722
6.91k
    }
723
34.8k
  else if (styp_flags & STYP_BSS)
724
3.02k
    {
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.02k
  sec_flags |= SEC_ALLOC;
731
3.02k
    }
732
31.8k
  else if (styp_flags & STYP_INFO)
733
2.09k
    {
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
2.09k
    }
744
29.7k
  else if (styp_flags & STYP_PAD)
745
878
    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
28.8k
  else if (strcmp (name, _TEXT) == 0)
773
12
    {
774
12
      if (sec_flags & SEC_NEVER_LOAD)
775
6
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
776
6
      else
777
6
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
778
12
    }
779
28.8k
  else if (strcmp (name, _DATA) == 0)
780
8
    {
781
8
      if (sec_flags & SEC_NEVER_LOAD)
782
2
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
783
6
      else
784
6
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
785
8
    }
786
28.8k
  else if (strcmp (name, _BSS) == 0)
787
2
    {
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
2
  sec_flags |= SEC_ALLOC;
794
2
    }
795
28.8k
  else if (startswith (name, DOT_DEBUG)
796
28.8k
     || startswith (name, DOT_ZDEBUG)
797
28.8k
#ifdef _COMMENT
798
28.8k
     || strcmp (name, _COMMENT) == 0
799
28.8k
#endif
800
#ifdef COFF_LONG_SECTION_NAMES
801
     || startswith (name, GNU_LINKONCE_WI)
802
     || startswith (name, GNU_LINKONCE_WT)
803
#endif
804
28.8k
     || startswith (name, ".stab"))
805
14
    {
806
#ifdef COFF_PAGE_SIZE
807
      sec_flags |= SEC_DEBUGGING;
808
#endif
809
14
    }
810
28.8k
#ifdef _LIB
811
28.8k
  else if (strcmp (name, _LIB) == 0)
812
4
    ;
813
28.8k
#endif
814
#ifdef _LIT
815
  else if (strcmp (name, _LIT) == 0)
816
    sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY;
817
#endif
818
28.8k
  else
819
28.8k
    sec_flags |= SEC_ALLOC | SEC_LOAD;
820
821
54.1k
#ifdef STYP_LIT     /* A29k readonly text/data section type.  */
822
54.1k
  if ((styp_flags & STYP_LIT) == STYP_LIT)
823
6.03k
    sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY);
824
54.1k
#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
54.1k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
832
54.1k
      && (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
54.1k
  if (flags_ptr == NULL)
848
0
    return false;
849
850
54.1k
  * flags_ptr = sec_flags;
851
54.1k
  return true;
852
54.1k
}
coff-z8k.c:styp_to_sec_flags
Line
Count
Source
687
3.82k
{
688
3.82k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
689
3.82k
  unsigned long styp_flags = internal_s->s_flags;
690
3.82k
  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.82k
#ifdef STYP_NOLOAD
703
3.82k
  if (styp_flags & STYP_NOLOAD)
704
1.03k
    sec_flags |= SEC_NEVER_LOAD;
705
3.82k
#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.82k
  if (styp_flags & STYP_TEXT)
710
700
    {
711
700
      if (sec_flags & SEC_NEVER_LOAD)
712
338
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
713
362
      else
714
362
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
715
700
    }
716
3.12k
  else if (styp_flags & STYP_DATA)
717
568
    {
718
568
      if (sec_flags & SEC_NEVER_LOAD)
719
212
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
720
356
      else
721
356
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
722
568
    }
723
2.56k
  else if (styp_flags & STYP_BSS)
724
348
    {
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
348
  sec_flags |= SEC_ALLOC;
731
348
    }
732
2.21k
  else if (styp_flags & STYP_INFO)
733
316
    {
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
316
    }
744
1.89k
  else if (styp_flags & STYP_PAD)
745
434
    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.46k
  else if (strcmp (name, _TEXT) == 0)
773
16
    {
774
16
      if (sec_flags & SEC_NEVER_LOAD)
775
10
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
776
6
      else
777
6
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
778
16
    }
779
1.44k
  else if (strcmp (name, _DATA) == 0)
780
8
    {
781
8
      if (sec_flags & SEC_NEVER_LOAD)
782
6
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
783
2
      else
784
2
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
785
8
    }
786
1.43k
  else if (strcmp (name, _BSS) == 0)
787
2
    {
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
2
  sec_flags |= SEC_ALLOC;
794
2
    }
795
1.43k
  else if (startswith (name, DOT_DEBUG)
796
1.43k
     || startswith (name, DOT_ZDEBUG)
797
1.43k
#ifdef _COMMENT
798
1.43k
     || strcmp (name, _COMMENT) == 0
799
1.43k
#endif
800
#ifdef COFF_LONG_SECTION_NAMES
801
     || startswith (name, GNU_LINKONCE_WI)
802
     || startswith (name, GNU_LINKONCE_WT)
803
#endif
804
1.43k
     || startswith (name, ".stab"))
805
22
    {
806
#ifdef COFF_PAGE_SIZE
807
      sec_flags |= SEC_DEBUGGING;
808
#endif
809
22
    }
810
1.41k
#ifdef _LIB
811
1.41k
  else if (strcmp (name, _LIB) == 0)
812
0
    ;
813
1.41k
#endif
814
#ifdef _LIT
815
  else if (strcmp (name, _LIT) == 0)
816
    sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY;
817
#endif
818
1.41k
  else
819
1.41k
    sec_flags |= SEC_ALLOC | SEC_LOAD;
820
821
3.82k
#ifdef STYP_LIT     /* A29k readonly text/data section type.  */
822
3.82k
  if ((styp_flags & STYP_LIT) == STYP_LIT)
823
210
    sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY);
824
3.82k
#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.82k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
832
3.82k
      && (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.82k
  if (flags_ptr == NULL)
848
0
    return false;
849
850
3.82k
  * flags_ptr = sec_flags;
851
3.82k
  return true;
852
3.82k
}
853
854
#else /* COFF_WITH_PE */
855
856
static hashval_t
857
comdat_hashf (const void *entry)
858
55.4k
{
859
55.4k
  const struct comdat_hash_entry *fe = entry;
860
55.4k
  return fe->target_index;
861
55.4k
}
pei-i386.c:comdat_hashf
Line
Count
Source
858
1.19k
{
859
1.19k
  const struct comdat_hash_entry *fe = entry;
860
1.19k
  return fe->target_index;
861
1.19k
}
pe-x86_64.c:comdat_hashf
Line
Count
Source
858
2.27k
{
859
2.27k
  const struct comdat_hash_entry *fe = entry;
860
2.27k
  return fe->target_index;
861
2.27k
}
pei-x86_64.c:comdat_hashf
Line
Count
Source
858
1.03k
{
859
1.03k
  const struct comdat_hash_entry *fe = entry;
860
1.03k
  return fe->target_index;
861
1.03k
}
pe-aarch64.c:comdat_hashf
Line
Count
Source
858
372
{
859
372
  const struct comdat_hash_entry *fe = entry;
860
372
  return fe->target_index;
861
372
}
pei-aarch64.c:comdat_hashf
Line
Count
Source
858
1.11k
{
859
1.11k
  const struct comdat_hash_entry *fe = entry;
860
1.11k
  return fe->target_index;
861
1.11k
}
pei-ia64.c:comdat_hashf
Line
Count
Source
858
5.48k
{
859
5.48k
  const struct comdat_hash_entry *fe = entry;
860
5.48k
  return fe->target_index;
861
5.48k
}
pei-loongarch64.c:comdat_hashf
Line
Count
Source
858
1.79k
{
859
1.79k
  const struct comdat_hash_entry *fe = entry;
860
1.79k
  return fe->target_index;
861
1.79k
}
pe-arm-wince.c:comdat_hashf
Line
Count
Source
858
774
{
859
774
  const struct comdat_hash_entry *fe = entry;
860
774
  return fe->target_index;
861
774
}
pe-arm.c:comdat_hashf
Line
Count
Source
858
774
{
859
774
  const struct comdat_hash_entry *fe = entry;
860
774
  return fe->target_index;
861
774
}
pe-i386.c:comdat_hashf
Line
Count
Source
858
1.28k
{
859
1.28k
  const struct comdat_hash_entry *fe = entry;
860
1.28k
  return fe->target_index;
861
1.28k
}
pe-mcore.c:comdat_hashf
Line
Count
Source
858
1.54k
{
859
1.54k
  const struct comdat_hash_entry *fe = entry;
860
1.54k
  return fe->target_index;
861
1.54k
}
pe-sh.c:comdat_hashf
Line
Count
Source
858
6.13k
{
859
6.13k
  const struct comdat_hash_entry *fe = entry;
860
6.13k
  return fe->target_index;
861
6.13k
}
pei-arm-wince.c:comdat_hashf
Line
Count
Source
858
3.82k
{
859
3.82k
  const struct comdat_hash_entry *fe = entry;
860
3.82k
  return fe->target_index;
861
3.82k
}
pei-arm.c:comdat_hashf
Line
Count
Source
858
7.87k
{
859
7.87k
  const struct comdat_hash_entry *fe = entry;
860
7.87k
  return fe->target_index;
861
7.87k
}
pei-mcore.c:comdat_hashf
Line
Count
Source
858
16.0k
{
859
16.0k
  const struct comdat_hash_entry *fe = entry;
860
16.0k
  return fe->target_index;
861
16.0k
}
pei-sh.c:comdat_hashf
Line
Count
Source
858
3.97k
{
859
3.97k
  const struct comdat_hash_entry *fe = entry;
860
3.97k
  return fe->target_index;
861
3.97k
}
862
863
static int
864
comdat_eqf (const void *e1, const void *e2)
865
26.4k
{
866
26.4k
  const struct comdat_hash_entry *fe1 = e1;
867
26.4k
  const struct comdat_hash_entry *fe2 = e2;
868
26.4k
  return fe1->target_index == fe2->target_index;
869
26.4k
}
pei-i386.c:comdat_eqf
Line
Count
Source
865
62
{
866
62
  const struct comdat_hash_entry *fe1 = e1;
867
62
  const struct comdat_hash_entry *fe2 = e2;
868
62
  return fe1->target_index == fe2->target_index;
869
62
}
pe-x86_64.c:comdat_eqf
Line
Count
Source
865
1.90k
{
866
1.90k
  const struct comdat_hash_entry *fe1 = e1;
867
1.90k
  const struct comdat_hash_entry *fe2 = e2;
868
1.90k
  return fe1->target_index == fe2->target_index;
869
1.90k
}
pei-x86_64.c:comdat_eqf
Line
Count
Source
865
694
{
866
694
  const struct comdat_hash_entry *fe1 = e1;
867
694
  const struct comdat_hash_entry *fe2 = e2;
868
694
  return fe1->target_index == fe2->target_index;
869
694
}
pe-aarch64.c:comdat_eqf
Line
Count
Source
865
98
{
866
98
  const struct comdat_hash_entry *fe1 = e1;
867
98
  const struct comdat_hash_entry *fe2 = e2;
868
98
  return fe1->target_index == fe2->target_index;
869
98
}
pei-aarch64.c:comdat_eqf
Line
Count
Source
865
414
{
866
414
  const struct comdat_hash_entry *fe1 = e1;
867
414
  const struct comdat_hash_entry *fe2 = e2;
868
414
  return fe1->target_index == fe2->target_index;
869
414
}
pei-ia64.c:comdat_eqf
Line
Count
Source
865
388
{
866
388
  const struct comdat_hash_entry *fe1 = e1;
867
388
  const struct comdat_hash_entry *fe2 = e2;
868
388
  return fe1->target_index == fe2->target_index;
869
388
}
pei-loongarch64.c:comdat_eqf
Line
Count
Source
865
1.35k
{
866
1.35k
  const struct comdat_hash_entry *fe1 = e1;
867
1.35k
  const struct comdat_hash_entry *fe2 = e2;
868
1.35k
  return fe1->target_index == fe2->target_index;
869
1.35k
}
pe-arm-wince.c:comdat_eqf
Line
Count
Source
865
458
{
866
458
  const struct comdat_hash_entry *fe1 = e1;
867
458
  const struct comdat_hash_entry *fe2 = e2;
868
458
  return fe1->target_index == fe2->target_index;
869
458
}
pe-arm.c:comdat_eqf
Line
Count
Source
865
458
{
866
458
  const struct comdat_hash_entry *fe1 = e1;
867
458
  const struct comdat_hash_entry *fe2 = e2;
868
458
  return fe1->target_index == fe2->target_index;
869
458
}
pe-i386.c:comdat_eqf
Line
Count
Source
865
976
{
866
976
  const struct comdat_hash_entry *fe1 = e1;
867
976
  const struct comdat_hash_entry *fe2 = e2;
868
976
  return fe1->target_index == fe2->target_index;
869
976
}
pe-mcore.c:comdat_eqf
Line
Count
Source
865
752
{
866
752
  const struct comdat_hash_entry *fe1 = e1;
867
752
  const struct comdat_hash_entry *fe2 = e2;
868
752
  return fe1->target_index == fe2->target_index;
869
752
}
pe-sh.c:comdat_eqf
Line
Count
Source
865
5.22k
{
866
5.22k
  const struct comdat_hash_entry *fe1 = e1;
867
5.22k
  const struct comdat_hash_entry *fe2 = e2;
868
5.22k
  return fe1->target_index == fe2->target_index;
869
5.22k
}
pei-arm-wince.c:comdat_eqf
Line
Count
Source
865
174
{
866
174
  const struct comdat_hash_entry *fe1 = e1;
867
174
  const struct comdat_hash_entry *fe2 = e2;
868
174
  return fe1->target_index == fe2->target_index;
869
174
}
pei-arm.c:comdat_eqf
Line
Count
Source
865
394
{
866
394
  const struct comdat_hash_entry *fe1 = e1;
867
394
  const struct comdat_hash_entry *fe2 = e2;
868
394
  return fe1->target_index == fe2->target_index;
869
394
}
pei-mcore.c:comdat_eqf
Line
Count
Source
865
12.8k
{
866
12.8k
  const struct comdat_hash_entry *fe1 = e1;
867
12.8k
  const struct comdat_hash_entry *fe2 = e2;
868
12.8k
  return fe1->target_index == fe2->target_index;
869
12.8k
}
pei-sh.c:comdat_eqf
Line
Count
Source
865
304
{
866
304
  const struct comdat_hash_entry *fe1 = e1;
867
304
  const struct comdat_hash_entry *fe2 = e2;
868
304
  return fe1->target_index == fe2->target_index;
869
304
}
870
871
static void
872
comdat_delf (void *ent)
873
3.28k
{
874
3.28k
  struct comdat_hash_entry *e = ent;
875
3.28k
  free (e->symname);
876
3.28k
  free (e);
877
3.28k
}
pei-i386.c:comdat_delf
Line
Count
Source
873
70
{
874
70
  struct comdat_hash_entry *e = ent;
875
70
  free (e->symname);
876
70
  free (e);
877
70
}
pe-x86_64.c:comdat_delf
Line
Count
Source
873
514
{
874
514
  struct comdat_hash_entry *e = ent;
875
514
  free (e->symname);
876
514
  free (e);
877
514
}
pei-x86_64.c:comdat_delf
Line
Count
Source
873
256
{
874
256
  struct comdat_hash_entry *e = ent;
875
256
  free (e->symname);
876
256
  free (e);
877
256
}
pe-aarch64.c:comdat_delf
Line
Count
Source
873
102
{
874
102
  struct comdat_hash_entry *e = ent;
875
102
  free (e->symname);
876
102
  free (e);
877
102
}
pei-aarch64.c:comdat_delf
Line
Count
Source
873
160
{
874
160
  struct comdat_hash_entry *e = ent;
875
160
  free (e->symname);
876
160
  free (e);
877
160
}
pei-ia64.c:comdat_delf
Line
Count
Source
873
168
{
874
168
  struct comdat_hash_entry *e = ent;
875
168
  free (e->symname);
876
168
  free (e);
877
168
}
pei-loongarch64.c:comdat_delf
Line
Count
Source
873
464
{
874
464
  struct comdat_hash_entry *e = ent;
875
464
  free (e->symname);
876
464
  free (e);
877
464
}
pe-arm-wince.c:comdat_delf
Line
Count
Source
873
116
{
874
116
  struct comdat_hash_entry *e = ent;
875
116
  free (e->symname);
876
116
  free (e);
877
116
}
pe-arm.c:comdat_delf
Line
Count
Source
873
116
{
874
116
  struct comdat_hash_entry *e = ent;
875
116
  free (e->symname);
876
116
  free (e);
877
116
}
pe-i386.c:comdat_delf
Line
Count
Source
873
166
{
874
166
  struct comdat_hash_entry *e = ent;
875
166
  free (e->symname);
876
166
  free (e);
877
166
}
pe-mcore.c:comdat_delf
Line
Count
Source
873
122
{
874
122
  struct comdat_hash_entry *e = ent;
875
122
  free (e->symname);
876
122
  free (e);
877
122
}
pe-sh.c:comdat_delf
Line
Count
Source
873
344
{
874
344
  struct comdat_hash_entry *e = ent;
875
344
  free (e->symname);
876
344
  free (e);
877
344
}
pei-arm-wince.c:comdat_delf
Line
Count
Source
873
122
{
874
122
  struct comdat_hash_entry *e = ent;
875
122
  free (e->symname);
876
122
  free (e);
877
122
}
pei-arm.c:comdat_delf
Line
Count
Source
873
174
{
874
174
  struct comdat_hash_entry *e = ent;
875
174
  free (e->symname);
876
174
  free (e);
877
174
}
pei-mcore.c:comdat_delf
Line
Count
Source
873
224
{
874
224
  struct comdat_hash_entry *e = ent;
875
224
  free (e->symname);
876
224
  free (e);
877
224
}
pei-sh.c:comdat_delf
Line
Count
Source
873
166
{
874
166
  struct comdat_hash_entry *e = ent;
875
166
  free (e->symname);
876
166
  free (e);
877
166
}
878
879
static struct comdat_hash_entry *
880
find_flags (htab_t comdat_hash, int target_index)
881
25.9k
{
882
25.9k
  struct comdat_hash_entry needle;
883
25.9k
  needle.target_index = target_index;
884
885
25.9k
  return htab_find (comdat_hash, &needle);
886
25.9k
}
pei-i386.c:find_flags
Line
Count
Source
881
1.07k
{
882
1.07k
  struct comdat_hash_entry needle;
883
1.07k
  needle.target_index = target_index;
884
885
1.07k
  return htab_find (comdat_hash, &needle);
886
1.07k
}
pe-x86_64.c:find_flags
Line
Count
Source
881
362
{
882
362
  struct comdat_hash_entry needle;
883
362
  needle.target_index = target_index;
884
885
362
  return htab_find (comdat_hash, &needle);
886
362
}
pei-x86_64.c:find_flags
Line
Count
Source
881
212
{
882
212
  struct comdat_hash_entry needle;
883
212
  needle.target_index = target_index;
884
885
212
  return htab_find (comdat_hash, &needle);
886
212
}
pe-aarch64.c:find_flags
Line
Count
Source
881
190
{
882
190
  struct comdat_hash_entry needle;
883
190
  needle.target_index = target_index;
884
885
190
  return htab_find (comdat_hash, &needle);
886
190
}
pei-aarch64.c:find_flags
Line
Count
Source
881
648
{
882
648
  struct comdat_hash_entry needle;
883
648
  needle.target_index = target_index;
884
885
648
  return htab_find (comdat_hash, &needle);
886
648
}
pei-ia64.c:find_flags
Line
Count
Source
881
4.49k
{
882
4.49k
  struct comdat_hash_entry needle;
883
4.49k
  needle.target_index = target_index;
884
885
4.49k
  return htab_find (comdat_hash, &needle);
886
4.49k
}
pei-loongarch64.c:find_flags
Line
Count
Source
881
238
{
882
238
  struct comdat_hash_entry needle;
883
238
  needle.target_index = target_index;
884
885
238
  return htab_find (comdat_hash, &needle);
886
238
}
pe-arm-wince.c:find_flags
Line
Count
Source
881
208
{
882
208
  struct comdat_hash_entry needle;
883
208
  needle.target_index = target_index;
884
885
208
  return htab_find (comdat_hash, &needle);
886
208
}
pe-arm.c:find_flags
Line
Count
Source
881
208
{
882
208
  struct comdat_hash_entry needle;
883
208
  needle.target_index = target_index;
884
885
208
  return htab_find (comdat_hash, &needle);
886
208
}
pe-i386.c:find_flags
Line
Count
Source
881
224
{
882
224
  struct comdat_hash_entry needle;
883
224
  needle.target_index = target_index;
884
885
224
  return htab_find (comdat_hash, &needle);
886
224
}
pe-mcore.c:find_flags
Line
Count
Source
881
676
{
882
676
  struct comdat_hash_entry needle;
883
676
  needle.target_index = target_index;
884
885
676
  return htab_find (comdat_hash, &needle);
886
676
}
pe-sh.c:find_flags
Line
Count
Source
881
730
{
882
730
  struct comdat_hash_entry needle;
883
730
  needle.target_index = target_index;
884
885
730
  return htab_find (comdat_hash, &needle);
886
730
}
pei-arm-wince.c:find_flags
Line
Count
Source
881
3.07k
{
882
3.07k
  struct comdat_hash_entry needle;
883
3.07k
  needle.target_index = target_index;
884
885
3.07k
  return htab_find (comdat_hash, &needle);
886
3.07k
}
pei-arm.c:find_flags
Line
Count
Source
881
6.96k
{
882
6.96k
  struct comdat_hash_entry needle;
883
6.96k
  needle.target_index = target_index;
884
885
6.96k
  return htab_find (comdat_hash, &needle);
886
6.96k
}
pei-mcore.c:find_flags
Line
Count
Source
881
3.05k
{
882
3.05k
  struct comdat_hash_entry needle;
883
3.05k
  needle.target_index = target_index;
884
885
3.05k
  return htab_find (comdat_hash, &needle);
886
3.05k
}
pei-sh.c:find_flags
Line
Count
Source
881
3.60k
{
882
3.60k
  struct comdat_hash_entry needle;
883
3.60k
  needle.target_index = target_index;
884
885
3.60k
  return htab_find (comdat_hash, &needle);
886
3.60k
}
887
888
static bool
889
fill_comdat_hash (bfd *abfd)
890
24.7k
{
891
24.7k
  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
24.7k
  if (! _bfd_coff_get_external_symbols (abfd))
909
8.75k
    return true;
910
911
16.0k
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
16.0k
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
16.0k
  for (struct internal_syment isym;
915
50.0k
       esym < esymend;
916
33.9k
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
33.9k
    {
918
33.9k
      char buf[SYMNMLEN + 1];
919
33.9k
      const char *symname;
920
33.9k
      flagword sec_flags = SEC_LINK_ONCE;
921
922
33.9k
      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
33.9k
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
33.9k
      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
29.3k
      union internal_auxent aux;
956
957
29.3k
      struct comdat_hash_entry needle;
958
29.3k
      needle.target_index = isym.n_scnum;
959
960
29.3k
      void **slot
961
29.3k
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
29.3k
      if (slot == NULL)
963
0
  return false;
964
965
29.3k
      if (*slot == NULL)
966
5.08k
  {
967
5.08k
    if (isym.n_numaux == 0)
968
2.10k
      aux.x_scn.x_comdat = 0;
969
2.97k
    else
970
2.97k
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
2.97k
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
1.79k
    {
974
      /* xgettext:c-format */
975
1.79k
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
1.79k
          " section '%s' found"),
977
1.79k
              abfd, symname);
978
1.79k
      continue;
979
1.79k
    }
980
1.18k
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
1.18k
            isym.n_type, isym.n_sclass, 0,
982
1.18k
            isym.n_numaux, &aux);
983
1.18k
      }
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.28k
    switch (aux.x_scn.x_comdat)
998
3.28k
      {
999
36
      case IMAGE_COMDAT_SELECT_NODUPLICATES:
1000
#ifdef STRICT_PE_FORMAT
1001
        sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY;
1002
#else
1003
36
        sec_flags &= ~SEC_LINK_ONCE;
1004
36
#endif
1005
36
        break;
1006
1007
0
      case IMAGE_COMDAT_SELECT_ANY:
1008
0
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1009
0
        break;
1010
1011
26
      case IMAGE_COMDAT_SELECT_SAME_SIZE:
1012
26
        sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE;
1013
26
        break;
1014
1015
10
      case IMAGE_COMDAT_SELECT_EXACT_MATCH:
1016
        /* Not yet fully implemented ??? */
1017
10
        sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS;
1018
10
        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
24
      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
24
        sec_flags &= ~SEC_LINK_ONCE;
1031
24
#endif
1032
24
        break;
1033
1034
3.18k
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
3.18k
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
3.18k
        break;
1038
3.28k
      }
1039
1040
3.28k
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
3.28k
    if (*slot == NULL)
1042
0
      return false;
1043
3.28k
    struct comdat_hash_entry *newentry = *slot;
1044
3.28k
    newentry->sec_flags = sec_flags;
1045
3.28k
    newentry->symname = bfd_strdup (symname);
1046
3.28k
    newentry->target_index = isym.n_scnum;
1047
3.28k
    newentry->isym = isym;
1048
3.28k
    newentry->comdat_symbol = -1;
1049
3.28k
  }
1050
24.2k
      else
1051
24.2k
  {
1052
24.2k
    struct comdat_hash_entry *entry = *slot;
1053
1054
24.2k
    if (entry->comdat_symbol != -1)
1055
23.0k
      continue;
1056
1057
1.23k
    char *target_name = strchr (entry->symname, '$');
1058
1.23k
    if (target_name != NULL)
1059
8
      {
1060
        /* Gas mode: the first matching on partial name.  */
1061
1062
8
        target_name += 1;
1063
#ifndef TARGET_UNDERSCORE
1064
2
#define TARGET_UNDERSCORE 0
1065
#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
6
    {
1070
      /* Not the name we're looking for */
1071
6
      continue;
1072
6
    }
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
1.22k
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
1.22k
    entry->comdat_name = bfd_strdup (symname);
1082
1.22k
  }
1083
29.3k
    }
1084
1085
16.0k
  return true;
1086
16.0k
}
pei-i386.c:fill_comdat_hash
Line
Count
Source
890
1.05k
{
891
1.05k
  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.05k
  if (! _bfd_coff_get_external_symbols (abfd))
909
498
    return true;
910
911
560
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
560
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
560
  for (struct internal_syment isym;
915
746
       esym < esymend;
916
560
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
186
    {
918
186
      char buf[SYMNMLEN + 1];
919
186
      const char *symname;
920
186
      flagword sec_flags = SEC_LINK_ONCE;
921
922
186
      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
186
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
186
      if (symname == NULL)
949
64
  {
950
64
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
64
            abfd);
952
64
    continue;
953
64
  }
954
955
122
      union internal_auxent aux;
956
957
122
      struct comdat_hash_entry needle;
958
122
      needle.target_index = isym.n_scnum;
959
960
122
      void **slot
961
122
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
122
      if (slot == NULL)
963
0
  return false;
964
965
122
      if (*slot == NULL)
966
84
  {
967
84
    if (isym.n_numaux == 0)
968
62
      aux.x_scn.x_comdat = 0;
969
22
    else
970
22
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
22
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
14
    {
974
      /* xgettext:c-format */
975
14
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
14
          " section '%s' found"),
977
14
              abfd, symname);
978
14
      continue;
979
14
    }
980
8
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
8
            isym.n_type, isym.n_sclass, 0,
982
8
            isym.n_numaux, &aux);
983
8
      }
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
70
    switch (aux.x_scn.x_comdat)
998
70
      {
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
70
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
70
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
70
        break;
1038
70
      }
1039
1040
70
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
70
    if (*slot == NULL)
1042
0
      return false;
1043
70
    struct comdat_hash_entry *newentry = *slot;
1044
70
    newentry->sec_flags = sec_flags;
1045
70
    newentry->symname = bfd_strdup (symname);
1046
70
    newentry->target_index = isym.n_scnum;
1047
70
    newentry->isym = isym;
1048
70
    newentry->comdat_symbol = -1;
1049
70
  }
1050
38
      else
1051
38
  {
1052
38
    struct comdat_hash_entry *entry = *slot;
1053
1054
38
    if (entry->comdat_symbol != -1)
1055
20
      continue;
1056
1057
18
    char *target_name = strchr (entry->symname, '$');
1058
18
    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
18
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
18
    entry->comdat_name = bfd_strdup (symname);
1082
18
  }
1083
122
    }
1084
1085
560
  return true;
1086
560
}
pe-x86_64.c:fill_comdat_hash
Line
Count
Source
890
334
{
891
334
  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
334
  if (! _bfd_coff_get_external_symbols (abfd))
909
6
    return true;
910
911
328
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
328
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
328
  for (struct internal_syment isym;
915
2.31k
       esym < esymend;
916
1.99k
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
1.99k
    {
918
1.99k
      char buf[SYMNMLEN + 1];
919
1.99k
      const char *symname;
920
1.99k
      flagword sec_flags = SEC_LINK_ONCE;
921
922
1.99k
      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.99k
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
1.99k
      if (symname == NULL)
949
78
  {
950
78
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
78
            abfd);
952
78
    continue;
953
78
  }
954
955
1.91k
      union internal_auxent aux;
956
957
1.91k
      struct comdat_hash_entry needle;
958
1.91k
      needle.target_index = isym.n_scnum;
959
960
1.91k
      void **slot
961
1.91k
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
1.91k
      if (slot == NULL)
963
0
  return false;
964
965
1.91k
      if (*slot == NULL)
966
514
  {
967
514
    if (isym.n_numaux == 0)
968
170
      aux.x_scn.x_comdat = 0;
969
344
    else
970
344
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
344
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
0
    {
974
      /* xgettext:c-format */
975
0
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
0
          " section '%s' found"),
977
0
              abfd, symname);
978
0
      continue;
979
0
    }
980
344
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
344
            isym.n_type, isym.n_sclass, 0,
982
344
            isym.n_numaux, &aux);
983
344
      }
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
514
    switch (aux.x_scn.x_comdat)
998
514
      {
999
20
      case IMAGE_COMDAT_SELECT_NODUPLICATES:
1000
#ifdef STRICT_PE_FORMAT
1001
        sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY;
1002
#else
1003
20
        sec_flags &= ~SEC_LINK_ONCE;
1004
20
#endif
1005
20
        break;
1006
1007
0
      case IMAGE_COMDAT_SELECT_ANY:
1008
0
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1009
0
        break;
1010
1011
6
      case IMAGE_COMDAT_SELECT_SAME_SIZE:
1012
6
        sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE;
1013
6
        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
12
      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
12
        sec_flags &= ~SEC_LINK_ONCE;
1031
12
#endif
1032
12
        break;
1033
1034
470
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
470
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
470
        break;
1038
514
      }
1039
1040
514
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
514
    if (*slot == NULL)
1042
0
      return false;
1043
514
    struct comdat_hash_entry *newentry = *slot;
1044
514
    newentry->sec_flags = sec_flags;
1045
514
    newentry->symname = bfd_strdup (symname);
1046
514
    newentry->target_index = isym.n_scnum;
1047
514
    newentry->isym = isym;
1048
514
    newentry->comdat_symbol = -1;
1049
514
  }
1050
1.39k
      else
1051
1.39k
  {
1052
1.39k
    struct comdat_hash_entry *entry = *slot;
1053
1054
1.39k
    if (entry->comdat_symbol != -1)
1055
1.20k
      continue;
1056
1057
194
    char *target_name = strchr (entry->symname, '$');
1058
194
    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
194
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
194
    entry->comdat_name = bfd_strdup (symname);
1082
194
  }
1083
1.91k
    }
1084
1085
328
  return true;
1086
328
}
pei-x86_64.c:fill_comdat_hash
Line
Count
Source
890
130
{
891
130
  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
130
  if (! _bfd_coff_get_external_symbols (abfd))
909
22
    return true;
910
911
108
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
108
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
108
  for (struct internal_syment isym;
915
1.13k
       esym < esymend;
916
1.02k
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
1.02k
    {
918
1.02k
      char buf[SYMNMLEN + 1];
919
1.02k
      const char *symname;
920
1.02k
      flagword sec_flags = SEC_LINK_ONCE;
921
922
1.02k
      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.02k
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
1.02k
      if (symname == NULL)
949
202
  {
950
202
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
202
            abfd);
952
202
    continue;
953
202
  }
954
955
820
      union internal_auxent aux;
956
957
820
      struct comdat_hash_entry needle;
958
820
      needle.target_index = isym.n_scnum;
959
960
820
      void **slot
961
820
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
820
      if (slot == NULL)
963
0
  return false;
964
965
820
      if (*slot == NULL)
966
262
  {
967
262
    if (isym.n_numaux == 0)
968
146
      aux.x_scn.x_comdat = 0;
969
116
    else
970
116
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
116
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
6
    {
974
      /* xgettext:c-format */
975
6
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
6
          " section '%s' found"),
977
6
              abfd, symname);
978
6
      continue;
979
6
    }
980
110
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
110
            isym.n_type, isym.n_sclass, 0,
982
110
            isym.n_numaux, &aux);
983
110
      }
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
256
    switch (aux.x_scn.x_comdat)
998
256
      {
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
256
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
256
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
256
        break;
1038
256
      }
1039
1040
256
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
256
    if (*slot == NULL)
1042
0
      return false;
1043
256
    struct comdat_hash_entry *newentry = *slot;
1044
256
    newentry->sec_flags = sec_flags;
1045
256
    newentry->symname = bfd_strdup (symname);
1046
256
    newentry->target_index = isym.n_scnum;
1047
256
    newentry->isym = isym;
1048
256
    newentry->comdat_symbol = -1;
1049
256
  }
1050
558
      else
1051
558
  {
1052
558
    struct comdat_hash_entry *entry = *slot;
1053
1054
558
    if (entry->comdat_symbol != -1)
1055
464
      continue;
1056
1057
94
    char *target_name = strchr (entry->symname, '$');
1058
94
    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
94
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
94
    entry->comdat_name = bfd_strdup (symname);
1082
94
  }
1083
820
    }
1084
1085
108
  return true;
1086
108
}
pe-aarch64.c:fill_comdat_hash
Line
Count
Source
890
122
{
891
122
  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
122
  if (! _bfd_coff_get_external_symbols (abfd))
909
26
    return true;
910
911
96
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
96
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
96
  for (struct internal_syment isym;
915
400
       esym < esymend;
916
304
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
304
    {
918
304
      char buf[SYMNMLEN + 1];
919
304
      const char *symname;
920
304
      flagword sec_flags = SEC_LINK_ONCE;
921
922
304
      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
304
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
304
      if (symname == NULL)
949
122
  {
950
122
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
122
            abfd);
952
122
    continue;
953
122
  }
954
955
182
      union internal_auxent aux;
956
957
182
      struct comdat_hash_entry needle;
958
182
      needle.target_index = isym.n_scnum;
959
960
182
      void **slot
961
182
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
182
      if (slot == NULL)
963
0
  return false;
964
965
182
      if (*slot == NULL)
966
120
  {
967
120
    if (isym.n_numaux == 0)
968
102
      aux.x_scn.x_comdat = 0;
969
18
    else
970
18
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
18
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
18
    {
974
      /* xgettext:c-format */
975
18
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
18
          " section '%s' found"),
977
18
              abfd, symname);
978
18
      continue;
979
18
    }
980
0
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
0
            isym.n_type, isym.n_sclass, 0,
982
0
            isym.n_numaux, &aux);
983
0
      }
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
102
    switch (aux.x_scn.x_comdat)
998
102
      {
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
102
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
102
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
102
        break;
1038
102
      }
1039
1040
102
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
102
    if (*slot == NULL)
1042
0
      return false;
1043
102
    struct comdat_hash_entry *newentry = *slot;
1044
102
    newentry->sec_flags = sec_flags;
1045
102
    newentry->symname = bfd_strdup (symname);
1046
102
    newentry->target_index = isym.n_scnum;
1047
102
    newentry->isym = isym;
1048
102
    newentry->comdat_symbol = -1;
1049
102
  }
1050
62
      else
1051
62
  {
1052
62
    struct comdat_hash_entry *entry = *slot;
1053
1054
62
    if (entry->comdat_symbol != -1)
1055
40
      continue;
1056
1057
22
    char *target_name = strchr (entry->symname, '$');
1058
22
    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
22
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
22
    entry->comdat_name = bfd_strdup (symname);
1082
22
  }
1083
182
    }
1084
1085
96
  return true;
1086
96
}
pei-aarch64.c:fill_comdat_hash
Line
Count
Source
890
612
{
891
612
  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
612
  if (! _bfd_coff_get_external_symbols (abfd))
909
46
    return true;
910
911
566
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
566
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
566
  for (struct internal_syment isym;
915
1.14k
       esym < esymend;
916
578
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
578
    {
918
578
      char buf[SYMNMLEN + 1];
919
578
      const char *symname;
920
578
      flagword sec_flags = SEC_LINK_ONCE;
921
922
578
      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
578
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
578
      if (symname == NULL)
949
112
  {
950
112
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
112
            abfd);
952
112
    continue;
953
112
  }
954
955
466
      union internal_auxent aux;
956
957
466
      struct comdat_hash_entry needle;
958
466
      needle.target_index = isym.n_scnum;
959
960
466
      void **slot
961
466
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
466
      if (slot == NULL)
963
0
  return false;
964
965
466
      if (*slot == NULL)
966
176
  {
967
176
    if (isym.n_numaux == 0)
968
94
      aux.x_scn.x_comdat = 0;
969
82
    else
970
82
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
82
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
16
    {
974
      /* xgettext:c-format */
975
16
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
16
          " section '%s' found"),
977
16
              abfd, symname);
978
16
      continue;
979
16
    }
980
66
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
66
            isym.n_type, isym.n_sclass, 0,
982
66
            isym.n_numaux, &aux);
983
66
      }
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
160
    switch (aux.x_scn.x_comdat)
998
160
      {
999
4
      case IMAGE_COMDAT_SELECT_NODUPLICATES:
1000
#ifdef STRICT_PE_FORMAT
1001
        sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY;
1002
#else
1003
4
        sec_flags &= ~SEC_LINK_ONCE;
1004
4
#endif
1005
4
        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
156
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
156
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
156
        break;
1038
160
      }
1039
1040
160
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
160
    if (*slot == NULL)
1042
0
      return false;
1043
160
    struct comdat_hash_entry *newentry = *slot;
1044
160
    newentry->sec_flags = sec_flags;
1045
160
    newentry->symname = bfd_strdup (symname);
1046
160
    newentry->target_index = isym.n_scnum;
1047
160
    newentry->isym = isym;
1048
160
    newentry->comdat_symbol = -1;
1049
160
  }
1050
290
      else
1051
290
  {
1052
290
    struct comdat_hash_entry *entry = *slot;
1053
1054
290
    if (entry->comdat_symbol != -1)
1055
236
      continue;
1056
1057
54
    char *target_name = strchr (entry->symname, '$');
1058
54
    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
54
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
54
    entry->comdat_name = bfd_strdup (symname);
1082
54
  }
1083
466
    }
1084
1085
566
  return true;
1086
566
}
pei-ia64.c:fill_comdat_hash
Line
Count
Source
890
3.97k
{
891
3.97k
  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.97k
  if (! _bfd_coff_get_external_symbols (abfd))
909
2.41k
    return true;
910
911
1.55k
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
1.55k
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
1.55k
  for (struct internal_syment isym;
915
2.62k
       esym < esymend;
916
1.55k
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
1.07k
    {
918
1.07k
      char buf[SYMNMLEN + 1];
919
1.07k
      const char *symname;
920
1.07k
      flagword sec_flags = SEC_LINK_ONCE;
921
922
1.07k
      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.07k
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
1.07k
      if (symname == NULL)
949
86
  {
950
86
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
86
            abfd);
952
86
    continue;
953
86
  }
954
955
986
      union internal_auxent aux;
956
957
986
      struct comdat_hash_entry needle;
958
986
      needle.target_index = isym.n_scnum;
959
960
986
      void **slot
961
986
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
986
      if (slot == NULL)
963
0
  return false;
964
965
986
      if (*slot == NULL)
966
680
  {
967
680
    if (isym.n_numaux == 0)
968
146
      aux.x_scn.x_comdat = 0;
969
534
    else
970
534
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
534
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
512
    {
974
      /* xgettext:c-format */
975
512
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
512
          " section '%s' found"),
977
512
              abfd, symname);
978
512
      continue;
979
512
    }
980
22
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
22
            isym.n_type, isym.n_sclass, 0,
982
22
            isym.n_numaux, &aux);
983
22
      }
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
168
    switch (aux.x_scn.x_comdat)
998
168
      {
999
4
      case IMAGE_COMDAT_SELECT_NODUPLICATES:
1000
#ifdef STRICT_PE_FORMAT
1001
        sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY;
1002
#else
1003
4
        sec_flags &= ~SEC_LINK_ONCE;
1004
4
#endif
1005
4
        break;
1006
1007
0
      case IMAGE_COMDAT_SELECT_ANY:
1008
0
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1009
0
        break;
1010
1011
2
      case IMAGE_COMDAT_SELECT_SAME_SIZE:
1012
2
        sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE;
1013
2
        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
162
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
162
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
162
        break;
1038
168
      }
1039
1040
168
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
168
    if (*slot == NULL)
1042
0
      return false;
1043
168
    struct comdat_hash_entry *newentry = *slot;
1044
168
    newentry->sec_flags = sec_flags;
1045
168
    newentry->symname = bfd_strdup (symname);
1046
168
    newentry->target_index = isym.n_scnum;
1047
168
    newentry->isym = isym;
1048
168
    newentry->comdat_symbol = -1;
1049
168
  }
1050
306
      else
1051
306
  {
1052
306
    struct comdat_hash_entry *entry = *slot;
1053
1054
306
    if (entry->comdat_symbol != -1)
1055
240
      continue;
1056
1057
66
    char *target_name = strchr (entry->symname, '$');
1058
66
    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
66
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
66
    entry->comdat_name = bfd_strdup (symname);
1082
66
  }
1083
986
    }
1084
1085
1.55k
  return true;
1086
1.55k
}
pei-loongarch64.c:fill_comdat_hash
Line
Count
Source
890
154
{
891
154
  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
154
  if (! _bfd_coff_get_external_symbols (abfd))
909
34
    return true;
910
911
120
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
120
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
120
  for (struct internal_syment isym;
915
1.89k
       esym < esymend;
916
1.77k
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
1.77k
    {
918
1.77k
      char buf[SYMNMLEN + 1];
919
1.77k
      const char *symname;
920
1.77k
      flagword sec_flags = SEC_LINK_ONCE;
921
922
1.77k
      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.77k
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
1.77k
      if (symname == NULL)
949
298
  {
950
298
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
298
            abfd);
952
298
    continue;
953
298
  }
954
955
1.47k
      union internal_auxent aux;
956
957
1.47k
      struct comdat_hash_entry needle;
958
1.47k
      needle.target_index = isym.n_scnum;
959
960
1.47k
      void **slot
961
1.47k
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
1.47k
      if (slot == NULL)
963
0
  return false;
964
965
1.47k
      if (*slot == NULL)
966
486
  {
967
486
    if (isym.n_numaux == 0)
968
248
      aux.x_scn.x_comdat = 0;
969
238
    else
970
238
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
238
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
22
    {
974
      /* xgettext:c-format */
975
22
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
22
          " section '%s' found"),
977
22
              abfd, symname);
978
22
      continue;
979
22
    }
980
216
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
216
            isym.n_type, isym.n_sclass, 0,
982
216
            isym.n_numaux, &aux);
983
216
      }
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
464
    switch (aux.x_scn.x_comdat)
998
464
      {
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
8
      case IMAGE_COMDAT_SELECT_SAME_SIZE:
1012
8
        sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE;
1013
8
        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
456
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
456
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
456
        break;
1038
464
      }
1039
1040
464
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
464
    if (*slot == NULL)
1042
0
      return false;
1043
464
    struct comdat_hash_entry *newentry = *slot;
1044
464
    newentry->sec_flags = sec_flags;
1045
464
    newentry->symname = bfd_strdup (symname);
1046
464
    newentry->target_index = isym.n_scnum;
1047
464
    newentry->isym = isym;
1048
464
    newentry->comdat_symbol = -1;
1049
464
  }
1050
992
      else
1051
992
  {
1052
992
    struct comdat_hash_entry *entry = *slot;
1053
1054
992
    if (entry->comdat_symbol != -1)
1055
866
      continue;
1056
1057
126
    char *target_name = strchr (entry->symname, '$');
1058
126
    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
126
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
126
    entry->comdat_name = bfd_strdup (symname);
1082
126
  }
1083
1.47k
    }
1084
1085
120
  return true;
1086
120
}
pe-arm-wince.c:fill_comdat_hash
Line
Count
Source
890
160
{
891
160
  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
160
  if (! _bfd_coff_get_external_symbols (abfd))
909
64
    return true;
910
911
96
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
96
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
96
  for (struct internal_syment isym;
915
742
       esym < esymend;
916
646
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
646
    {
918
646
      char buf[SYMNMLEN + 1];
919
646
      const char *symname;
920
646
      flagword sec_flags = SEC_LINK_ONCE;
921
922
646
      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
646
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
646
      if (symname == NULL)
949
80
  {
950
80
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
80
            abfd);
952
80
    continue;
953
80
  }
954
955
566
      union internal_auxent aux;
956
957
566
      struct comdat_hash_entry needle;
958
566
      needle.target_index = isym.n_scnum;
959
960
566
      void **slot
961
566
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
566
      if (slot == NULL)
963
0
  return false;
964
965
566
      if (*slot == NULL)
966
164
  {
967
164
    if (isym.n_numaux == 0)
968
94
      aux.x_scn.x_comdat = 0;
969
70
    else
970
70
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
70
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
48
    {
974
      /* xgettext:c-format */
975
48
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
48
          " section '%s' found"),
977
48
              abfd, symname);
978
48
      continue;
979
48
    }
980
22
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
22
            isym.n_type, isym.n_sclass, 0,
982
22
            isym.n_numaux, &aux);
983
22
      }
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
116
    switch (aux.x_scn.x_comdat)
998
116
      {
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
2
      case IMAGE_COMDAT_SELECT_SAME_SIZE:
1012
2
        sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE;
1013
2
        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
2
      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
2
        sec_flags &= ~SEC_LINK_ONCE;
1031
2
#endif
1032
2
        break;
1033
1034
112
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
112
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
112
        break;
1038
116
      }
1039
1040
116
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
116
    if (*slot == NULL)
1042
0
      return false;
1043
116
    struct comdat_hash_entry *newentry = *slot;
1044
116
    newentry->sec_flags = sec_flags;
1045
116
    newentry->symname = bfd_strdup (symname);
1046
116
    newentry->target_index = isym.n_scnum;
1047
116
    newentry->isym = isym;
1048
116
    newentry->comdat_symbol = -1;
1049
116
  }
1050
402
      else
1051
402
  {
1052
402
    struct comdat_hash_entry *entry = *slot;
1053
1054
402
    if (entry->comdat_symbol != -1)
1055
356
      continue;
1056
1057
46
    char *target_name = strchr (entry->symname, '$');
1058
46
    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
46
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
46
    entry->comdat_name = bfd_strdup (symname);
1082
46
  }
1083
566
    }
1084
1085
96
  return true;
1086
96
}
pe-arm.c:fill_comdat_hash
Line
Count
Source
890
160
{
891
160
  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
160
  if (! _bfd_coff_get_external_symbols (abfd))
909
64
    return true;
910
911
96
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
96
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
96
  for (struct internal_syment isym;
915
742
       esym < esymend;
916
646
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
646
    {
918
646
      char buf[SYMNMLEN + 1];
919
646
      const char *symname;
920
646
      flagword sec_flags = SEC_LINK_ONCE;
921
922
646
      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
646
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
646
      if (symname == NULL)
949
80
  {
950
80
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
80
            abfd);
952
80
    continue;
953
80
  }
954
955
566
      union internal_auxent aux;
956
957
566
      struct comdat_hash_entry needle;
958
566
      needle.target_index = isym.n_scnum;
959
960
566
      void **slot
961
566
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
566
      if (slot == NULL)
963
0
  return false;
964
965
566
      if (*slot == NULL)
966
164
  {
967
164
    if (isym.n_numaux == 0)
968
94
      aux.x_scn.x_comdat = 0;
969
70
    else
970
70
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
70
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
48
    {
974
      /* xgettext:c-format */
975
48
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
48
          " section '%s' found"),
977
48
              abfd, symname);
978
48
      continue;
979
48
    }
980
22
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
22
            isym.n_type, isym.n_sclass, 0,
982
22
            isym.n_numaux, &aux);
983
22
      }
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
116
    switch (aux.x_scn.x_comdat)
998
116
      {
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
2
      case IMAGE_COMDAT_SELECT_SAME_SIZE:
1012
2
        sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE;
1013
2
        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
2
      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
2
        sec_flags &= ~SEC_LINK_ONCE;
1031
2
#endif
1032
2
        break;
1033
1034
112
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
112
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
112
        break;
1038
116
      }
1039
1040
116
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
116
    if (*slot == NULL)
1042
0
      return false;
1043
116
    struct comdat_hash_entry *newentry = *slot;
1044
116
    newentry->sec_flags = sec_flags;
1045
116
    newentry->symname = bfd_strdup (symname);
1046
116
    newentry->target_index = isym.n_scnum;
1047
116
    newentry->isym = isym;
1048
116
    newentry->comdat_symbol = -1;
1049
116
  }
1050
402
      else
1051
402
  {
1052
402
    struct comdat_hash_entry *entry = *slot;
1053
1054
402
    if (entry->comdat_symbol != -1)
1055
356
      continue;
1056
1057
46
    char *target_name = strchr (entry->symname, '$');
1058
46
    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
46
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
46
    entry->comdat_name = bfd_strdup (symname);
1082
46
  }
1083
566
    }
1084
1085
96
  return true;
1086
96
}
pe-i386.c:fill_comdat_hash
Line
Count
Source
890
190
{
891
190
  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
190
  if (! _bfd_coff_get_external_symbols (abfd))
909
96
    return true;
910
911
94
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
94
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
94
  for (struct internal_syment isym;
915
1.27k
       esym < esymend;
916
1.17k
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
1.17k
    {
918
1.17k
      char buf[SYMNMLEN + 1];
919
1.17k
      const char *symname;
920
1.17k
      flagword sec_flags = SEC_LINK_ONCE;
921
922
1.17k
      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.17k
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
1.17k
      if (symname == NULL)
949
118
  {
950
118
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
118
            abfd);
952
118
    continue;
953
118
  }
954
955
1.05k
      union internal_auxent aux;
956
957
1.05k
      struct comdat_hash_entry needle;
958
1.05k
      needle.target_index = isym.n_scnum;
959
960
1.05k
      void **slot
961
1.05k
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
1.05k
      if (slot == NULL)
963
0
  return false;
964
965
1.05k
      if (*slot == NULL)
966
172
  {
967
172
    if (isym.n_numaux == 0)
968
90
      aux.x_scn.x_comdat = 0;
969
82
    else
970
82
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
82
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
6
    {
974
      /* xgettext:c-format */
975
6
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
6
          " section '%s' found"),
977
6
              abfd, symname);
978
6
      continue;
979
6
    }
980
76
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
76
            isym.n_type, isym.n_sclass, 0,
982
76
            isym.n_numaux, &aux);
983
76
      }
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
166
    switch (aux.x_scn.x_comdat)
998
166
      {
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
2
      case IMAGE_COMDAT_SELECT_EXACT_MATCH:
1016
        /* Not yet fully implemented ??? */
1017
2
        sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS;
1018
2
        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
2
      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
2
        sec_flags &= ~SEC_LINK_ONCE;
1031
2
#endif
1032
2
        break;
1033
1034
162
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
162
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
162
        break;
1038
166
      }
1039
1040
166
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
166
    if (*slot == NULL)
1042
0
      return false;
1043
166
    struct comdat_hash_entry *newentry = *slot;
1044
166
    newentry->sec_flags = sec_flags;
1045
166
    newentry->symname = bfd_strdup (symname);
1046
166
    newentry->target_index = isym.n_scnum;
1047
166
    newentry->isym = isym;
1048
166
    newentry->comdat_symbol = -1;
1049
166
  }
1050
886
      else
1051
886
  {
1052
886
    struct comdat_hash_entry *entry = *slot;
1053
1054
886
    if (entry->comdat_symbol != -1)
1055
808
      continue;
1056
1057
78
    char *target_name = strchr (entry->symname, '$');
1058
78
    if (target_name != NULL)
1059
6
      {
1060
        /* Gas mode: the first matching on partial name.  */
1061
1062
6
        target_name += 1;
1063
#ifndef TARGET_UNDERSCORE
1064
#define TARGET_UNDERSCORE 0
1065
#endif
1066
        /* Is this the name we're looking for ?  */
1067
6
        if (strcmp (target_name,
1068
6
        symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0)
1069
6
    {
1070
      /* Not the name we're looking for */
1071
6
      continue;
1072
6
    }
1073
6
      }
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
72
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
72
    entry->comdat_name = bfd_strdup (symname);
1082
72
  }
1083
1.05k
    }
1084
1085
94
  return true;
1086
94
}
pe-mcore.c:fill_comdat_hash
Line
Count
Source
890
646
{
891
646
  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
646
  if (! _bfd_coff_get_external_symbols (abfd))
909
30
    return true;
910
911
616
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
616
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
616
  for (struct internal_syment isym;
915
1.62k
       esym < esymend;
916
1.00k
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
1.00k
    {
918
1.00k
      char buf[SYMNMLEN + 1];
919
1.00k
      const char *symname;
920
1.00k
      flagword sec_flags = SEC_LINK_ONCE;
921
922
1.00k
      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.00k
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
1.00k
      if (symname == NULL)
949
138
  {
950
138
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
138
            abfd);
952
138
    continue;
953
138
  }
954
955
868
      union internal_auxent aux;
956
957
868
      struct comdat_hash_entry needle;
958
868
      needle.target_index = isym.n_scnum;
959
960
868
      void **slot
961
868
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
868
      if (slot == NULL)
963
0
  return false;
964
965
868
      if (*slot == NULL)
966
148
  {
967
148
    if (isym.n_numaux == 0)
968
104
      aux.x_scn.x_comdat = 0;
969
44
    else
970
44
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
44
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
26
    {
974
      /* xgettext:c-format */
975
26
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
26
          " section '%s' found"),
977
26
              abfd, symname);
978
26
      continue;
979
26
    }
980
18
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
18
            isym.n_type, isym.n_sclass, 0,
982
18
            isym.n_numaux, &aux);
983
18
      }
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
122
    switch (aux.x_scn.x_comdat)
998
122
      {
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
122
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
122
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
122
        break;
1038
122
      }
1039
1040
122
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
122
    if (*slot == NULL)
1042
0
      return false;
1043
122
    struct comdat_hash_entry *newentry = *slot;
1044
122
    newentry->sec_flags = sec_flags;
1045
122
    newentry->symname = bfd_strdup (symname);
1046
122
    newentry->target_index = isym.n_scnum;
1047
122
    newentry->isym = isym;
1048
122
    newentry->comdat_symbol = -1;
1049
122
  }
1050
720
      else
1051
720
  {
1052
720
    struct comdat_hash_entry *entry = *slot;
1053
1054
720
    if (entry->comdat_symbol != -1)
1055
658
      continue;
1056
1057
62
    char *target_name = strchr (entry->symname, '$');
1058
62
    if (target_name != NULL)
1059
2
      {
1060
        /* Gas mode: the first matching on partial name.  */
1061
1062
2
        target_name += 1;
1063
2
#ifndef TARGET_UNDERSCORE
1064
2
#define TARGET_UNDERSCORE 0
1065
2
#endif
1066
        /* Is this the name we're looking for ?  */
1067
2
        if (strcmp (target_name,
1068
2
        symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0)
1069
0
    {
1070
      /* Not the name we're looking for */
1071
0
      continue;
1072
0
    }
1073
2
      }
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
62
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
62
    entry->comdat_name = bfd_strdup (symname);
1082
62
  }
1083
868
    }
1084
1085
616
  return true;
1086
616
}
pe-sh.c:fill_comdat_hash
Line
Count
Source
890
684
{
891
684
  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
684
  if (! _bfd_coff_get_external_symbols (abfd))
909
16
    return true;
910
911
668
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
668
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
668
  for (struct internal_syment isym;
915
6.12k
       esym < esymend;
916
5.45k
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
5.45k
    {
918
5.45k
      char buf[SYMNMLEN + 1];
919
5.45k
      const char *symname;
920
5.45k
      flagword sec_flags = SEC_LINK_ONCE;
921
922
5.45k
      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
5.45k
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
5.45k
      if (symname == NULL)
949
50
  {
950
50
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
50
            abfd);
952
50
    continue;
953
50
  }
954
955
5.40k
      union internal_auxent aux;
956
957
5.40k
      struct comdat_hash_entry needle;
958
5.40k
      needle.target_index = isym.n_scnum;
959
960
5.40k
      void **slot
961
5.40k
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
5.40k
      if (slot == NULL)
963
0
  return false;
964
965
5.40k
      if (*slot == NULL)
966
356
  {
967
356
    if (isym.n_numaux == 0)
968
154
      aux.x_scn.x_comdat = 0;
969
202
    else
970
202
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
202
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
12
    {
974
      /* xgettext:c-format */
975
12
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
12
          " section '%s' found"),
977
12
              abfd, symname);
978
12
      continue;
979
12
    }
980
190
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
190
            isym.n_type, isym.n_sclass, 0,
982
190
            isym.n_numaux, &aux);
983
190
      }
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
344
    switch (aux.x_scn.x_comdat)
998
344
      {
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
4
      case IMAGE_COMDAT_SELECT_SAME_SIZE:
1012
4
        sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE;
1013
4
        break;
1014
1015
2
      case IMAGE_COMDAT_SELECT_EXACT_MATCH:
1016
        /* Not yet fully implemented ??? */
1017
2
        sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS;
1018
2
        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
6
      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
6
        sec_flags &= ~SEC_LINK_ONCE;
1031
6
#endif
1032
6
        break;
1033
1034
326
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
326
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
326
        break;
1038
344
      }
1039
1040
344
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
344
    if (*slot == NULL)
1042
0
      return false;
1043
344
    struct comdat_hash_entry *newentry = *slot;
1044
344
    newentry->sec_flags = sec_flags;
1045
344
    newentry->symname = bfd_strdup (symname);
1046
344
    newentry->target_index = isym.n_scnum;
1047
344
    newentry->isym = isym;
1048
344
    newentry->comdat_symbol = -1;
1049
344
  }
1050
5.04k
      else
1051
5.04k
  {
1052
5.04k
    struct comdat_hash_entry *entry = *slot;
1053
1054
5.04k
    if (entry->comdat_symbol != -1)
1055
4.84k
      continue;
1056
1057
198
    char *target_name = strchr (entry->symname, '$');
1058
198
    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
198
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
198
    entry->comdat_name = bfd_strdup (symname);
1082
198
  }
1083
5.40k
    }
1084
1085
668
  return true;
1086
668
}
pei-arm-wince.c:fill_comdat_hash
Line
Count
Source
890
3.04k
{
891
3.04k
  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.04k
  if (! _bfd_coff_get_external_symbols (abfd))
909
1.00k
    return true;
910
911
2.04k
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
2.04k
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
2.04k
  for (struct internal_syment isym;
915
3.82k
       esym < esymend;
916
2.04k
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
1.78k
    {
918
1.78k
      char buf[SYMNMLEN + 1];
919
1.78k
      const char *symname;
920
1.78k
      flagword sec_flags = SEC_LINK_ONCE;
921
922
1.78k
      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.78k
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
1.78k
      if (symname == NULL)
949
1.03k
  {
950
1.03k
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
1.03k
            abfd);
952
1.03k
    continue;
953
1.03k
  }
954
955
754
      union internal_auxent aux;
956
957
754
      struct comdat_hash_entry needle;
958
754
      needle.target_index = isym.n_scnum;
959
960
754
      void **slot
961
754
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
754
      if (slot == NULL)
963
0
  return false;
964
965
754
      if (*slot == NULL)
966
628
  {
967
628
    if (isym.n_numaux == 0)
968
118
      aux.x_scn.x_comdat = 0;
969
510
    else
970
510
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
510
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
506
    {
974
      /* xgettext:c-format */
975
506
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
506
          " section '%s' found"),
977
506
              abfd, symname);
978
506
      continue;
979
506
    }
980
4
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
4
            isym.n_type, isym.n_sclass, 0,
982
4
            isym.n_numaux, &aux);
983
4
      }
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
122
    switch (aux.x_scn.x_comdat)
998
122
      {
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
122
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
122
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
122
        break;
1038
122
      }
1039
1040
122
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
122
    if (*slot == NULL)
1042
0
      return false;
1043
122
    struct comdat_hash_entry *newentry = *slot;
1044
122
    newentry->sec_flags = sec_flags;
1045
122
    newentry->symname = bfd_strdup (symname);
1046
122
    newentry->target_index = isym.n_scnum;
1047
122
    newentry->isym = isym;
1048
122
    newentry->comdat_symbol = -1;
1049
122
  }
1050
126
      else
1051
126
  {
1052
126
    struct comdat_hash_entry *entry = *slot;
1053
1054
126
    if (entry->comdat_symbol != -1)
1055
78
      continue;
1056
1057
48
    char *target_name = strchr (entry->symname, '$');
1058
48
    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
48
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
48
    entry->comdat_name = bfd_strdup (symname);
1082
48
  }
1083
754
    }
1084
1085
2.04k
  return true;
1086
2.04k
}
pei-arm.c:fill_comdat_hash
Line
Count
Source
890
6.92k
{
891
6.92k
  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.92k
  if (! _bfd_coff_get_external_symbols (abfd))
909
1.97k
    return true;
910
911
4.95k
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
4.95k
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
4.95k
  for (struct internal_syment isym;
915
6.89k
       esym < esymend;
916
4.95k
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
1.94k
    {
918
1.94k
      char buf[SYMNMLEN + 1];
919
1.94k
      const char *symname;
920
1.94k
      flagword sec_flags = SEC_LINK_ONCE;
921
922
1.94k
      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.94k
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
1.94k
      if (symname == NULL)
949
1.05k
  {
950
1.05k
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
1.05k
            abfd);
952
1.05k
    continue;
953
1.05k
  }
954
955
888
      union internal_auxent aux;
956
957
888
      struct comdat_hash_entry needle;
958
888
      needle.target_index = isym.n_scnum;
959
960
888
      void **slot
961
888
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
888
      if (slot == NULL)
963
0
  return false;
964
965
888
      if (*slot == NULL)
966
688
  {
967
688
    if (isym.n_numaux == 0)
968
170
      aux.x_scn.x_comdat = 0;
969
518
    else
970
518
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
518
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
514
    {
974
      /* xgettext:c-format */
975
514
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
514
          " section '%s' found"),
977
514
              abfd, symname);
978
514
      continue;
979
514
    }
980
4
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
4
            isym.n_type, isym.n_sclass, 0,
982
4
            isym.n_numaux, &aux);
983
4
      }
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
174
    switch (aux.x_scn.x_comdat)
998
174
      {
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
174
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
174
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
174
        break;
1038
174
      }
1039
1040
174
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
174
    if (*slot == NULL)
1042
0
      return false;
1043
174
    struct comdat_hash_entry *newentry = *slot;
1044
174
    newentry->sec_flags = sec_flags;
1045
174
    newentry->symname = bfd_strdup (symname);
1046
174
    newentry->target_index = isym.n_scnum;
1047
174
    newentry->isym = isym;
1048
174
    newentry->comdat_symbol = -1;
1049
174
  }
1050
200
      else
1051
200
  {
1052
200
    struct comdat_hash_entry *entry = *slot;
1053
1054
200
    if (entry->comdat_symbol != -1)
1055
142
      continue;
1056
1057
58
    char *target_name = strchr (entry->symname, '$');
1058
58
    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
58
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
58
    entry->comdat_name = bfd_strdup (symname);
1082
58
  }
1083
888
    }
1084
1085
4.95k
  return true;
1086
4.95k
}
pei-mcore.c:fill_comdat_hash
Line
Count
Source
890
3.02k
{
891
3.02k
  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.02k
  if (! _bfd_coff_get_external_symbols (abfd))
909
1.94k
    return true;
910
911
1.08k
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
1.08k
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
1.08k
  for (struct internal_syment isym;
915
14.5k
       esym < esymend;
916
13.4k
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
13.4k
    {
918
13.4k
      char buf[SYMNMLEN + 1];
919
13.4k
      const char *symname;
920
13.4k
      flagword sec_flags = SEC_LINK_ONCE;
921
922
13.4k
      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.4k
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
13.4k
      if (symname == NULL)
949
574
  {
950
574
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
574
            abfd);
952
574
    continue;
953
574
  }
954
955
12.9k
      union internal_auxent aux;
956
957
12.9k
      struct comdat_hash_entry needle;
958
12.9k
      needle.target_index = isym.n_scnum;
959
960
12.9k
      void **slot
961
12.9k
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
12.9k
      if (slot == NULL)
963
0
  return false;
964
965
12.9k
      if (*slot == NULL)
966
248
  {
967
248
    if (isym.n_numaux == 0)
968
160
      aux.x_scn.x_comdat = 0;
969
88
    else
970
88
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
88
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
24
    {
974
      /* xgettext:c-format */
975
24
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
24
          " section '%s' found"),
977
24
              abfd, symname);
978
24
      continue;
979
24
    }
980
64
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
64
            isym.n_type, isym.n_sclass, 0,
982
64
            isym.n_numaux, &aux);
983
64
      }
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
224
    switch (aux.x_scn.x_comdat)
998
224
      {
999
2
      case IMAGE_COMDAT_SELECT_NODUPLICATES:
1000
#ifdef STRICT_PE_FORMAT
1001
        sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY;
1002
#else
1003
2
        sec_flags &= ~SEC_LINK_ONCE;
1004
2
#endif
1005
2
        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
222
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
222
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
222
        break;
1038
224
      }
1039
1040
224
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
224
    if (*slot == NULL)
1042
0
      return false;
1043
224
    struct comdat_hash_entry *newentry = *slot;
1044
224
    newentry->sec_flags = sec_flags;
1045
224
    newentry->symname = bfd_strdup (symname);
1046
224
    newentry->target_index = isym.n_scnum;
1047
224
    newentry->isym = isym;
1048
224
    newentry->comdat_symbol = -1;
1049
224
  }
1050
12.6k
      else
1051
12.6k
  {
1052
12.6k
    struct comdat_hash_entry *entry = *slot;
1053
1054
12.6k
    if (entry->comdat_symbol != -1)
1055
12.6k
      continue;
1056
1057
64
    char *target_name = strchr (entry->symname, '$');
1058
64
    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
64
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
64
    entry->comdat_name = bfd_strdup (symname);
1082
64
  }
1083
12.9k
    }
1084
1085
1.08k
  return true;
1086
1.08k
}
pei-sh.c:fill_comdat_hash
Line
Count
Source
890
3.57k
{
891
3.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
3.57k
  if (! _bfd_coff_get_external_symbols (abfd))
909
516
    return true;
910
911
3.05k
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
3.05k
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
3.05k
  for (struct internal_syment isym;
915
3.96k
       esym < esymend;
916
3.05k
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
914
    {
918
914
      char buf[SYMNMLEN + 1];
919
914
      const char *symname;
920
914
      flagword sec_flags = SEC_LINK_ONCE;
921
922
914
      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
914
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
914
      if (symname == NULL)
949
548
  {
950
548
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
548
            abfd);
952
548
    continue;
953
548
  }
954
955
366
      union internal_auxent aux;
956
957
366
      struct comdat_hash_entry needle;
958
366
      needle.target_index = isym.n_scnum;
959
960
366
      void **slot
961
366
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
366
      if (slot == NULL)
963
0
  return false;
964
965
366
      if (*slot == NULL)
966
190
  {
967
190
    if (isym.n_numaux == 0)
968
150
      aux.x_scn.x_comdat = 0;
969
40
    else
970
40
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
40
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
24
    {
974
      /* xgettext:c-format */
975
24
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
24
          " section '%s' found"),
977
24
              abfd, symname);
978
24
      continue;
979
24
    }
980
16
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
16
            isym.n_type, isym.n_sclass, 0,
982
16
            isym.n_numaux, &aux);
983
16
      }
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
166
    switch (aux.x_scn.x_comdat)
998
166
      {
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
2
      case IMAGE_COMDAT_SELECT_SAME_SIZE:
1012
2
        sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE;
1013
2
        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
164
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
164
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
164
        break;
1038
166
      }
1039
1040
166
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
166
    if (*slot == NULL)
1042
0
      return false;
1043
166
    struct comdat_hash_entry *newentry = *slot;
1044
166
    newentry->sec_flags = sec_flags;
1045
166
    newentry->symname = bfd_strdup (symname);
1046
166
    newentry->target_index = isym.n_scnum;
1047
166
    newentry->isym = isym;
1048
166
    newentry->comdat_symbol = -1;
1049
166
  }
1050
176
      else
1051
176
  {
1052
176
    struct comdat_hash_entry *entry = *slot;
1053
1054
176
    if (entry->comdat_symbol != -1)
1055
120
      continue;
1056
1057
56
    char *target_name = strchr (entry->symname, '$');
1058
56
    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
56
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
56
    entry->comdat_name = bfd_strdup (symname);
1082
56
  }
1083
366
    }
1084
1085
3.05k
  return true;
1086
3.05k
}
1087
1088
static bool
1089
insert_coff_comdat_info (bfd *abfd, asection *section, const char *symname,
1090
       long symbol)
1091
204
{
1092
204
  struct coff_comdat_info *comdat;
1093
204
  size_t len = strlen (symname) + 1;
1094
1095
204
  comdat = bfd_alloc (abfd, sizeof (*comdat) + len);
1096
204
  if (comdat == NULL)
1097
0
    return false;
1098
1099
204
  coff_section_data (abfd, section)->comdat = comdat;
1100
204
  comdat->symbol = symbol;
1101
204
  char *newname = (char *) (comdat + 1);
1102
204
  comdat->name = newname;
1103
204
  memcpy (newname, symname, len);
1104
204
  return true;
1105
204
}
pei-i386.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-x86_64.c:insert_coff_comdat_info
Line
Count
Source
1091
14
{
1092
14
  struct coff_comdat_info *comdat;
1093
14
  size_t len = strlen (symname) + 1;
1094
1095
14
  comdat = bfd_alloc (abfd, sizeof (*comdat) + len);
1096
14
  if (comdat == NULL)
1097
0
    return false;
1098
1099
14
  coff_section_data (abfd, section)->comdat = comdat;
1100
14
  comdat->symbol = symbol;
1101
14
  char *newname = (char *) (comdat + 1);
1102
14
  comdat->name = newname;
1103
14
  memcpy (newname, symname, len);
1104
14
  return true;
1105
14
}
pei-x86_64.c:insert_coff_comdat_info
Line
Count
Source
1091
14
{
1092
14
  struct coff_comdat_info *comdat;
1093
14
  size_t len = strlen (symname) + 1;
1094
1095
14
  comdat = bfd_alloc (abfd, sizeof (*comdat) + len);
1096
14
  if (comdat == NULL)
1097
0
    return false;
1098
1099
14
  coff_section_data (abfd, section)->comdat = comdat;
1100
14
  comdat->symbol = symbol;
1101
14
  char *newname = (char *) (comdat + 1);
1102
14
  comdat->name = newname;
1103
14
  memcpy (newname, symname, len);
1104
14
  return true;
1105
14
}
pe-aarch64.c:insert_coff_comdat_info
Line
Count
Source
1091
6
{
1092
6
  struct coff_comdat_info *comdat;
1093
6
  size_t len = strlen (symname) + 1;
1094
1095
6
  comdat = bfd_alloc (abfd, sizeof (*comdat) + len);
1096
6
  if (comdat == NULL)
1097
0
    return false;
1098
1099
6
  coff_section_data (abfd, section)->comdat = comdat;
1100
6
  comdat->symbol = symbol;
1101
6
  char *newname = (char *) (comdat + 1);
1102
6
  comdat->name = newname;
1103
6
  memcpy (newname, symname, len);
1104
6
  return true;
1105
6
}
pei-aarch64.c:insert_coff_comdat_info
Line
Count
Source
1091
8
{
1092
8
  struct coff_comdat_info *comdat;
1093
8
  size_t len = strlen (symname) + 1;
1094
1095
8
  comdat = bfd_alloc (abfd, sizeof (*comdat) + len);
1096
8
  if (comdat == NULL)
1097
0
    return false;
1098
1099
8
  coff_section_data (abfd, section)->comdat = comdat;
1100
8
  comdat->symbol = symbol;
1101
8
  char *newname = (char *) (comdat + 1);
1102
8
  comdat->name = newname;
1103
8
  memcpy (newname, symname, len);
1104
8
  return true;
1105
8
}
pei-ia64.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
}
pei-loongarch64.c:insert_coff_comdat_info
Line
Count
Source
1091
10
{
1092
10
  struct coff_comdat_info *comdat;
1093
10
  size_t len = strlen (symname) + 1;
1094
1095
10
  comdat = bfd_alloc (abfd, sizeof (*comdat) + len);
1096
10
  if (comdat == NULL)
1097
0
    return false;
1098
1099
10
  coff_section_data (abfd, section)->comdat = comdat;
1100
10
  comdat->symbol = symbol;
1101
10
  char *newname = (char *) (comdat + 1);
1102
10
  comdat->name = newname;
1103
10
  memcpy (newname, symname, len);
1104
10
  return true;
1105
10
}
pe-arm-wince.c:insert_coff_comdat_info
Line
Count
Source
1091
8
{
1092
8
  struct coff_comdat_info *comdat;
1093
8
  size_t len = strlen (symname) + 1;
1094
1095
8
  comdat = bfd_alloc (abfd, sizeof (*comdat) + len);
1096
8
  if (comdat == NULL)
1097
0
    return false;
1098
1099
8
  coff_section_data (abfd, section)->comdat = comdat;
1100
8
  comdat->symbol = symbol;
1101
8
  char *newname = (char *) (comdat + 1);
1102
8
  comdat->name = newname;
1103
8
  memcpy (newname, symname, len);
1104
8
  return true;
1105
8
}
pe-arm.c:insert_coff_comdat_info
Line
Count
Source
1091
8
{
1092
8
  struct coff_comdat_info *comdat;
1093
8
  size_t len = strlen (symname) + 1;
1094
1095
8
  comdat = bfd_alloc (abfd, sizeof (*comdat) + len);
1096
8
  if (comdat == NULL)
1097
0
    return false;
1098
1099
8
  coff_section_data (abfd, section)->comdat = comdat;
1100
8
  comdat->symbol = symbol;
1101
8
  char *newname = (char *) (comdat + 1);
1102
8
  comdat->name = newname;
1103
8
  memcpy (newname, symname, len);
1104
8
  return true;
1105
8
}
pe-i386.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-mcore.c:insert_coff_comdat_info
Line
Count
Source
1091
6
{
1092
6
  struct coff_comdat_info *comdat;
1093
6
  size_t len = strlen (symname) + 1;
1094
1095
6
  comdat = bfd_alloc (abfd, sizeof (*comdat) + len);
1096
6
  if (comdat == NULL)
1097
0
    return false;
1098
1099
6
  coff_section_data (abfd, section)->comdat = comdat;
1100
6
  comdat->symbol = symbol;
1101
6
  char *newname = (char *) (comdat + 1);
1102
6
  comdat->name = newname;
1103
6
  memcpy (newname, symname, len);
1104
6
  return true;
1105
6
}
pe-sh.c:insert_coff_comdat_info
Line
Count
Source
1091
24
{
1092
24
  struct coff_comdat_info *comdat;
1093
24
  size_t len = strlen (symname) + 1;
1094
1095
24
  comdat = bfd_alloc (abfd, sizeof (*comdat) + len);
1096
24
  if (comdat == NULL)
1097
0
    return false;
1098
1099
24
  coff_section_data (abfd, section)->comdat = comdat;
1100
24
  comdat->symbol = symbol;
1101
24
  char *newname = (char *) (comdat + 1);
1102
24
  comdat->name = newname;
1103
24
  memcpy (newname, symname, len);
1104
24
  return true;
1105
24
}
pei-arm-wince.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-arm.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-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
20
{
1092
20
  struct coff_comdat_info *comdat;
1093
20
  size_t len = strlen (symname) + 1;
1094
1095
20
  comdat = bfd_alloc (abfd, sizeof (*comdat) + len);
1096
20
  if (comdat == NULL)
1097
0
    return false;
1098
1099
20
  coff_section_data (abfd, section)->comdat = comdat;
1100
20
  comdat->symbol = symbol;
1101
20
  char *newname = (char *) (comdat + 1);
1102
20
  comdat->name = newname;
1103
20
  memcpy (newname, symname, len);
1104
20
  return true;
1105
20
}
1106
1107
static bool
1108
handle_COMDAT (bfd *abfd, flagword *sec_flags, const char *name,
1109
         asection *section)
1110
25.9k
{
1111
25.9k
  if (pe_data (abfd)->comdat_hash == NULL)
1112
21.9k
    {
1113
21.9k
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
21.9k
             comdat_delf);
1115
21.9k
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
21.9k
    }
1118
1119
25.9k
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
24.7k
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
25.9k
  struct comdat_hash_entry *found
1124
25.9k
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
25.9k
  if (found != NULL)
1126
630
    {
1127
630
      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
630
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
630
       && BTYPE (isym.n_type) == T_NULL && isym.n_value == 0))
1143
150
  {
1144
    /* Malformed input files can trigger this test.
1145
       cf PR 21781.  */
1146
150
    _bfd_error_handler
1147
150
      (_("%pB: error: unexpected symbol '%s' in COMDAT section"),
1148
150
       abfd, found->symname);
1149
150
    return false;
1150
150
  }
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
480
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
262
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
262
            " does not match section name '%s'"),
1160
262
          abfd, found->symname, name);
1161
1162
480
      if (found->comdat_symbol != -1)
1163
204
  {
1164
204
    if (! insert_coff_comdat_info (abfd, section, found->comdat_name,
1165
204
           found->comdat_symbol))
1166
0
      return false;
1167
204
  }
1168
480
      *sec_flags = *sec_flags | found->sec_flags;
1169
480
      return true;
1170
480
    }
1171
25.3k
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
25.3k
  return true;
1173
25.9k
}
pei-i386.c:handle_COMDAT
Line
Count
Source
1110
1.07k
{
1111
1.07k
  if (pe_data (abfd)->comdat_hash == NULL)
1112
1.04k
    {
1113
1.04k
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
1.04k
             comdat_delf);
1115
1.04k
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
1.04k
    }
1118
1119
1.07k
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
1.05k
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
1.07k
  struct comdat_hash_entry *found
1124
1.07k
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
1.07k
  if (found != NULL)
1126
14
    {
1127
14
      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
14
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
14
       && BTYPE (isym.n_type) == T_NULL && isym.n_value == 0))
1143
10
  {
1144
    /* Malformed input files can trigger this test.
1145
       cf PR 21781.  */
1146
10
    _bfd_error_handler
1147
10
      (_("%pB: error: unexpected symbol '%s' in COMDAT section"),
1148
10
       abfd, found->symname);
1149
10
    return false;
1150
10
  }
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
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
0
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
0
            " does not match section name '%s'"),
1160
0
          abfd, found->symname, name);
1161
1162
4
      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
4
      *sec_flags = *sec_flags | found->sec_flags;
1169
4
      return true;
1170
4
    }
1171
1.06k
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
1.06k
  return true;
1173
1.07k
}
pe-x86_64.c:handle_COMDAT
Line
Count
Source
1110
362
{
1111
362
  if (pe_data (abfd)->comdat_hash == NULL)
1112
314
    {
1113
314
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
314
             comdat_delf);
1115
314
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
314
    }
1118
1119
362
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
334
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
362
  struct comdat_hash_entry *found
1124
362
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
362
  if (found != NULL)
1126
108
    {
1127
108
      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
108
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
108
       && BTYPE (isym.n_type) == T_NULL && isym.n_value == 0))
1143
20
  {
1144
    /* Malformed input files can trigger this test.
1145
       cf PR 21781.  */
1146
20
    _bfd_error_handler
1147
20
      (_("%pB: error: unexpected symbol '%s' in COMDAT section"),
1148
20
       abfd, found->symname);
1149
20
    return false;
1150
20
  }
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
88
      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
88
      if (found->comdat_symbol != -1)
1163
14
  {
1164
14
    if (! insert_coff_comdat_info (abfd, section, found->comdat_name,
1165
14
           found->comdat_symbol))
1166
0
      return false;
1167
14
  }
1168
88
      *sec_flags = *sec_flags | found->sec_flags;
1169
88
      return true;
1170
88
    }
1171
254
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
254
  return true;
1173
362
}
pei-x86_64.c:handle_COMDAT
Line
Count
Source
1110
212
{
1111
212
  if (pe_data (abfd)->comdat_hash == NULL)
1112
106
    {
1113
106
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
106
             comdat_delf);
1115
106
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
106
    }
1118
1119
212
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
130
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
212
  struct comdat_hash_entry *found
1124
212
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
212
  if (found != NULL)
1126
38
    {
1127
38
      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
38
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
38
       && BTYPE (isym.n_type) == T_NULL && isym.n_value == 0))
1143
8
  {
1144
    /* Malformed input files can trigger this test.
1145
       cf PR 21781.  */
1146
8
    _bfd_error_handler
1147
8
      (_("%pB: error: unexpected symbol '%s' in COMDAT section"),
1148
8
       abfd, found->symname);
1149
8
    return false;
1150
8
  }
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
30
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
6
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
6
            " does not match section name '%s'"),
1160
6
          abfd, found->symname, name);
1161
1162
30
      if (found->comdat_symbol != -1)
1163
14
  {
1164
14
    if (! insert_coff_comdat_info (abfd, section, found->comdat_name,
1165
14
           found->comdat_symbol))
1166
0
      return false;
1167
14
  }
1168
30
      *sec_flags = *sec_flags | found->sec_flags;
1169
30
      return true;
1170
30
    }
1171
174
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
174
  return true;
1173
212
}
pe-aarch64.c:handle_COMDAT
Line
Count
Source
1110
190
{
1111
190
  if (pe_data (abfd)->comdat_hash == NULL)
1112
90
    {
1113
90
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
90
             comdat_delf);
1115
90
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
90
    }
1118
1119
190
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
122
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
190
  struct comdat_hash_entry *found
1124
190
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
190
  if (found != NULL)
1126
30
    {
1127
30
      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
30
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
30
       && BTYPE (isym.n_type) == T_NULL && isym.n_value == 0))
1143
4
  {
1144
    /* Malformed input files can trigger this test.
1145
       cf PR 21781.  */
1146
4
    _bfd_error_handler
1147
4
      (_("%pB: error: unexpected symbol '%s' in COMDAT section"),
1148
4
       abfd, found->symname);
1149
4
    return false;
1150
4
  }
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
26
      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
26
      if (found->comdat_symbol != -1)
1163
6
  {
1164
6
    if (! insert_coff_comdat_info (abfd, section, found->comdat_name,
1165
6
           found->comdat_symbol))
1166
0
      return false;
1167
6
  }
1168
26
      *sec_flags = *sec_flags | found->sec_flags;
1169
26
      return true;
1170
26
    }
1171
160
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
160
  return true;
1173
190
}
pei-aarch64.c:handle_COMDAT
Line
Count
Source
1110
648
{
1111
648
  if (pe_data (abfd)->comdat_hash == NULL)
1112
596
    {
1113
596
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
596
             comdat_delf);
1115
596
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
596
    }
1118
1119
648
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
612
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
648
  struct comdat_hash_entry *found
1124
648
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
648
  if (found != NULL)
1126
32
    {
1127
32
      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
32
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
32
       && BTYPE (isym.n_type) == T_NULL && isym.n_value == 0))
1143
10
  {
1144
    /* Malformed input files can trigger this test.
1145
       cf PR 21781.  */
1146
10
    _bfd_error_handler
1147
10
      (_("%pB: error: unexpected symbol '%s' in COMDAT section"),
1148
10
       abfd, found->symname);
1149
10
    return false;
1150
10
  }
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
22
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
10
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
10
            " does not match section name '%s'"),
1160
10
          abfd, found->symname, name);
1161
1162
22
      if (found->comdat_symbol != -1)
1163
8
  {
1164
8
    if (! insert_coff_comdat_info (abfd, section, found->comdat_name,
1165
8
           found->comdat_symbol))
1166
0
      return false;
1167
8
  }
1168
22
      *sec_flags = *sec_flags | found->sec_flags;
1169
22
      return true;
1170
22
    }
1171
616
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
616
  return true;
1173
648
}
pei-ia64.c:handle_COMDAT
Line
Count
Source
1110
4.49k
{
1111
4.49k
  if (pe_data (abfd)->comdat_hash == NULL)
1112
3.96k
    {
1113
3.96k
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
3.96k
             comdat_delf);
1115
3.96k
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
3.96k
    }
1118
1119
4.49k
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
3.97k
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
4.49k
  struct comdat_hash_entry *found
1124
4.49k
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
4.49k
  if (found != NULL)
1126
62
    {
1127
62
      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
62
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
62
       && BTYPE (isym.n_type) == T_NULL && isym.n_value == 0))
1143
14
  {
1144
    /* Malformed input files can trigger this test.
1145
       cf PR 21781.  */
1146
14
    _bfd_error_handler
1147
14
      (_("%pB: error: unexpected symbol '%s' in COMDAT section"),
1148
14
       abfd, found->symname);
1149
14
    return false;
1150
14
  }
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
48
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
28
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
28
            " does not match section name '%s'"),
1160
28
          abfd, found->symname, name);
1161
1162
48
      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
48
      *sec_flags = *sec_flags | found->sec_flags;
1169
48
      return true;
1170
48
    }
1171
4.43k
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
4.43k
  return true;
1173
4.49k
}
pei-loongarch64.c:handle_COMDAT
Line
Count
Source
1110
238
{
1111
238
  if (pe_data (abfd)->comdat_hash == NULL)
1112
128
    {
1113
128
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
128
             comdat_delf);
1115
128
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
128
    }
1118
1119
238
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
154
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
238
  struct comdat_hash_entry *found
1124
238
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
238
  if (found != NULL)
1126
50
    {
1127
50
      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
50
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
50
       && BTYPE (isym.n_type) == T_NULL && isym.n_value == 0))
1143
6
  {
1144
    /* Malformed input files can trigger this test.
1145
       cf PR 21781.  */
1146
6
    _bfd_error_handler
1147
6
      (_("%pB: error: unexpected symbol '%s' in COMDAT section"),
1148
6
       abfd, found->symname);
1149
6
    return false;
1150
6
  }
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
44
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
16
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
16
            " does not match section name '%s'"),
1160
16
          abfd, found->symname, name);
1161
1162
44
      if (found->comdat_symbol != -1)
1163
10
  {
1164
10
    if (! insert_coff_comdat_info (abfd, section, found->comdat_name,
1165
10
           found->comdat_symbol))
1166
0
      return false;
1167
10
  }
1168
44
      *sec_flags = *sec_flags | found->sec_flags;
1169
44
      return true;
1170
44
    }
1171
188
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
188
  return true;
1173
238
}
pe-arm-wince.c:handle_COMDAT
Line
Count
Source
1110
208
{
1111
208
  if (pe_data (abfd)->comdat_hash == NULL)
1112
140
    {
1113
140
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
140
             comdat_delf);
1115
140
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
140
    }
1118
1119
208
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
160
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
208
  struct comdat_hash_entry *found
1124
208
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
208
  if (found != NULL)
1126
20
    {
1127
20
      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
20
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
20
       && BTYPE (isym.n_type) == T_NULL && isym.n_value == 0))
1143
6
  {
1144
    /* Malformed input files can trigger this test.
1145
       cf PR 21781.  */
1146
6
    _bfd_error_handler
1147
6
      (_("%pB: error: unexpected symbol '%s' in COMDAT section"),
1148
6
       abfd, found->symname);
1149
6
    return false;
1150
6
  }
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
14
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
8
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
8
            " does not match section name '%s'"),
1160
8
          abfd, found->symname, name);
1161
1162
14
      if (found->comdat_symbol != -1)
1163
8
  {
1164
8
    if (! insert_coff_comdat_info (abfd, section, found->comdat_name,
1165
8
           found->comdat_symbol))
1166
0
      return false;
1167
8
  }
1168
14
      *sec_flags = *sec_flags | found->sec_flags;
1169
14
      return true;
1170
14
    }
1171
188
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
188
  return true;
1173
208
}
pe-arm.c:handle_COMDAT
Line
Count
Source
1110
208
{
1111
208
  if (pe_data (abfd)->comdat_hash == NULL)
1112
140
    {
1113
140
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
140
             comdat_delf);
1115
140
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
140
    }
1118
1119
208
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
160
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
208
  struct comdat_hash_entry *found
1124
208
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
208
  if (found != NULL)
1126
20
    {
1127
20
      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
20
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
20
       && BTYPE (isym.n_type) == T_NULL && isym.n_value == 0))
1143
6
  {
1144
    /* Malformed input files can trigger this test.
1145
       cf PR 21781.  */
1146
6
    _bfd_error_handler
1147
6
      (_("%pB: error: unexpected symbol '%s' in COMDAT section"),
1148
6
       abfd, found->symname);
1149
6
    return false;
1150
6
  }
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
14
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
8
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
8
            " does not match section name '%s'"),
1160
8
          abfd, found->symname, name);
1161
1162
14
      if (found->comdat_symbol != -1)
1163
8
  {
1164
8
    if (! insert_coff_comdat_info (abfd, section, found->comdat_name,
1165
8
           found->comdat_symbol))
1166
0
      return false;
1167
8
  }
1168
14
      *sec_flags = *sec_flags | found->sec_flags;
1169
14
      return true;
1170
14
    }
1171
188
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
188
  return true;
1173
208
}
pe-i386.c:handle_COMDAT
Line
Count
Source
1110
224
{
1111
224
  if (pe_data (abfd)->comdat_hash == NULL)
1112
172
    {
1113
172
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
172
             comdat_delf);
1115
172
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
172
    }
1118
1119
224
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
190
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
224
  struct comdat_hash_entry *found
1124
224
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
224
  if (found != NULL)
1126
20
    {
1127
20
      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
20
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
20
       && BTYPE (isym.n_type) == T_NULL && isym.n_value == 0))
1143
6
  {
1144
    /* Malformed input files can trigger this test.
1145
       cf PR 21781.  */
1146
6
    _bfd_error_handler
1147
6
      (_("%pB: error: unexpected symbol '%s' in COMDAT section"),
1148
6
       abfd, found->symname);
1149
6
    return false;
1150
6
  }
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
14
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
10
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
10
            " does not match section name '%s'"),
1160
10
          abfd, found->symname, name);
1161
1162
14
      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
14
      *sec_flags = *sec_flags | found->sec_flags;
1169
14
      return true;
1170
14
    }
1171
204
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
204
  return true;
1173
224
}
pe-mcore.c:handle_COMDAT
Line
Count
Source
1110
676
{
1111
676
  if (pe_data (abfd)->comdat_hash == NULL)
1112
620
    {
1113
620
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
620
             comdat_delf);
1115
620
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
620
    }
1118
1119
676
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
646
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
676
  struct comdat_hash_entry *found
1124
676
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
676
  if (found != NULL)
1126
18
    {
1127
18
      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
18
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
18
       && BTYPE (isym.n_type) == T_NULL && isym.n_value == 0))
1143
10
  {
1144
    /* Malformed input files can trigger this test.
1145
       cf PR 21781.  */
1146
10
    _bfd_error_handler
1147
10
      (_("%pB: error: unexpected symbol '%s' in COMDAT section"),
1148
10
       abfd, found->symname);
1149
10
    return false;
1150
10
  }
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
8
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
2
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
2
            " does not match section name '%s'"),
1160
2
          abfd, found->symname, name);
1161
1162
8
      if (found->comdat_symbol != -1)
1163
6
  {
1164
6
    if (! insert_coff_comdat_info (abfd, section, found->comdat_name,
1165
6
           found->comdat_symbol))
1166
0
      return false;
1167
6
  }
1168
8
      *sec_flags = *sec_flags | found->sec_flags;
1169
8
      return true;
1170
8
    }
1171
658
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
658
  return true;
1173
676
}
pe-sh.c:handle_COMDAT
Line
Count
Source
1110
730
{
1111
730
  if (pe_data (abfd)->comdat_hash == NULL)
1112
666
    {
1113
666
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
666
             comdat_delf);
1115
666
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
666
    }
1118
1119
730
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
684
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
730
  struct comdat_hash_entry *found
1124
730
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
730
  if (found != NULL)
1126
58
    {
1127
58
      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
58
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
58
       && BTYPE (isym.n_type) == T_NULL && isym.n_value == 0))
1143
6
  {
1144
    /* Malformed input files can trigger this test.
1145
       cf PR 21781.  */
1146
6
    _bfd_error_handler
1147
6
      (_("%pB: error: unexpected symbol '%s' in COMDAT section"),
1148
6
       abfd, found->symname);
1149
6
    return false;
1150
6
  }
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
52
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
40
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
40
            " does not match section name '%s'"),
1160
40
          abfd, found->symname, name);
1161
1162
52
      if (found->comdat_symbol != -1)
1163
24
  {
1164
24
    if (! insert_coff_comdat_info (abfd, section, found->comdat_name,
1165
24
           found->comdat_symbol))
1166
0
      return false;
1167
24
  }
1168
52
      *sec_flags = *sec_flags | found->sec_flags;
1169
52
      return true;
1170
52
    }
1171
672
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
672
  return true;
1173
730
}
pei-arm-wince.c:handle_COMDAT
Line
Count
Source
1110
3.07k
{
1111
3.07k
  if (pe_data (abfd)->comdat_hash == NULL)
1112
2.53k
    {
1113
2.53k
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
2.53k
             comdat_delf);
1115
2.53k
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
2.53k
    }
1118
1119
3.07k
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
3.04k
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
3.07k
  struct comdat_hash_entry *found
1124
3.07k
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
3.07k
  if (found != NULL)
1126
44
    {
1127
44
      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
44
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
44
       && BTYPE (isym.n_type) == T_NULL && isym.n_value == 0))
1143
14
  {
1144
    /* Malformed input files can trigger this test.
1145
       cf PR 21781.  */
1146
14
    _bfd_error_handler
1147
14
      (_("%pB: error: unexpected symbol '%s' in COMDAT section"),
1148
14
       abfd, found->symname);
1149
14
    return false;
1150
14
  }
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
30
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
16
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
16
            " does not match section name '%s'"),
1160
16
          abfd, found->symname, name);
1161
1162
30
      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
30
      *sec_flags = *sec_flags | found->sec_flags;
1169
30
      return true;
1170
30
    }
1171
3.03k
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
3.03k
  return true;
1173
3.07k
}
pei-arm.c:handle_COMDAT
Line
Count
Source
1110
6.96k
{
1111
6.96k
  if (pe_data (abfd)->comdat_hash == NULL)
1112
5.92k
    {
1113
5.92k
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
5.92k
             comdat_delf);
1115
5.92k
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
5.92k
    }
1118
1119
6.96k
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
6.92k
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
6.96k
  struct comdat_hash_entry *found
1124
6.96k
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
6.96k
  if (found != NULL)
1126
46
    {
1127
46
      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
46
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
46
       && BTYPE (isym.n_type) == T_NULL && isym.n_value == 0))
1143
16
  {
1144
    /* Malformed input files can trigger this test.
1145
       cf PR 21781.  */
1146
16
    _bfd_error_handler
1147
16
      (_("%pB: error: unexpected symbol '%s' in COMDAT section"),
1148
16
       abfd, found->symname);
1149
16
    return false;
1150
16
  }
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
30
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
16
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
16
            " does not match section name '%s'"),
1160
16
          abfd, found->symname, name);
1161
1162
30
      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
30
      *sec_flags = *sec_flags | found->sec_flags;
1169
30
      return true;
1170
30
    }
1171
6.91k
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
6.91k
  return true;
1173
6.96k
}
pei-mcore.c:handle_COMDAT
Line
Count
Source
1110
3.05k
{
1111
3.05k
  if (pe_data (abfd)->comdat_hash == NULL)
1112
2.52k
    {
1113
2.52k
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
2.52k
             comdat_delf);
1115
2.52k
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
2.52k
    }
1118
1119
3.05k
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
3.02k
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
3.05k
  struct comdat_hash_entry *found
1124
3.05k
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
3.05k
  if (found != NULL)
1126
34
    {
1127
34
      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
34
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
34
       && BTYPE (isym.n_type) == T_NULL && isym.n_value == 0))
1143
10
  {
1144
    /* Malformed input files can trigger this test.
1145
       cf PR 21781.  */
1146
10
    _bfd_error_handler
1147
10
      (_("%pB: error: unexpected symbol '%s' in COMDAT section"),
1148
10
       abfd, found->symname);
1149
10
    return false;
1150
10
  }
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
24
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
10
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
10
            " does not match section name '%s'"),
1160
10
          abfd, found->symname, name);
1161
1162
24
      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
24
      *sec_flags = *sec_flags | found->sec_flags;
1169
24
      return true;
1170
24
    }
1171
3.02k
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
3.02k
  return true;
1173
3.05k
}
pei-sh.c:handle_COMDAT
Line
Count
Source
1110
3.60k
{
1111
3.60k
  if (pe_data (abfd)->comdat_hash == NULL)
1112
3.03k
    {
1113
3.03k
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
3.03k
             comdat_delf);
1115
3.03k
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
3.03k
    }
1118
1119
3.60k
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
3.57k
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
3.60k
  struct comdat_hash_entry *found
1124
3.60k
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
3.60k
  if (found != NULL)
1126
36
    {
1127
36
      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
36
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
36
       && BTYPE (isym.n_type) == T_NULL && isym.n_value == 0))
1143
4
  {
1144
    /* Malformed input files can trigger this test.
1145
       cf PR 21781.  */
1146
4
    _bfd_error_handler
1147
4
      (_("%pB: error: unexpected symbol '%s' in COMDAT section"),
1148
4
       abfd, found->symname);
1149
4
    return false;
1150
4
  }
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
32
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
20
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
20
            " does not match section name '%s'"),
1160
20
          abfd, found->symname, name);
1161
1162
32
      if (found->comdat_symbol != -1)
1163
20
  {
1164
20
    if (! insert_coff_comdat_info (abfd, section, found->comdat_name,
1165
20
           found->comdat_symbol))
1166
0
      return false;
1167
20
  }
1168
32
      *sec_flags = *sec_flags | found->sec_flags;
1169
32
      return true;
1170
32
    }
1171
3.57k
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
3.57k
  return true;
1173
3.60k
}
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
980k
{
1192
980k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
980k
  unsigned long styp_flags = internal_s->s_flags;
1194
980k
  flagword sec_flags;
1195
980k
  bool result = true;
1196
980k
  bool is_dbg = false;
1197
1198
980k
  if (startswith (name, DOT_DEBUG)
1199
980k
      || startswith (name, DOT_ZDEBUG)
1200
980k
#ifdef COFF_LONG_SECTION_NAMES
1201
980k
      || startswith (name, GNU_LINKONCE_WI)
1202
980k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
980k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
980k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
980k
      || startswith (name, GNU_DEBUGLINK)
1207
980k
      || startswith (name, GNU_DEBUGALTLINK)
1208
980k
#endif
1209
980k
      || startswith (name, ".stab"))
1210
5.96k
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
980k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
980k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
931k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
2.63M
  while (styp_flags)
1220
1.65M
    {
1221
1.65M
      unsigned long flag = styp_flags & - styp_flags;
1222
1.65M
      char * unhandled = NULL;
1223
1224
1.65M
      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
1.65M
      switch (flag)
1231
1.65M
  {
1232
17.1k
  case STYP_DSECT:
1233
17.1k
    unhandled = "STYP_DSECT";
1234
17.1k
    break;
1235
16.9k
  case STYP_GROUP:
1236
16.9k
    unhandled = "STYP_GROUP";
1237
16.9k
    break;
1238
16.6k
  case STYP_COPY:
1239
16.6k
    unhandled = "STYP_COPY";
1240
16.6k
    break;
1241
13.7k
  case STYP_OVER:
1242
13.7k
    unhandled = "STYP_OVER";
1243
13.7k
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
55.2k
  case STYP_NOLOAD:
1246
55.2k
    sec_flags |= SEC_NEVER_LOAD;
1247
55.2k
    break;
1248
0
#endif
1249
48.9k
  case IMAGE_SCN_MEM_READ:
1250
48.9k
    sec_flags &= ~SEC_COFF_NOREAD;
1251
48.9k
    break;
1252
97.5k
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
97.5k
    break;
1255
19.1k
  case IMAGE_SCN_LNK_OTHER:
1256
19.1k
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
19.1k
    break;
1258
14.1k
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
14.1k
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
14.1k
    break;
1261
107k
  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
107k
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
107k
        " %s in section %s"),
1268
107k
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
107k
    break;
1270
50.2k
  case IMAGE_SCN_MEM_EXECUTE:
1271
50.2k
    sec_flags |= SEC_CODE;
1272
50.2k
    break;
1273
93.7k
  case IMAGE_SCN_MEM_WRITE:
1274
93.7k
    sec_flags &= ~ SEC_READONLY;
1275
93.7k
    break;
1276
68.7k
  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
68.7k
       if (is_dbg
1283
68.7k
#ifdef _COMMENT
1284
68.7k
        || strcmp (name, _COMMENT) == 0
1285
68.7k
#endif
1286
68.7k
        )
1287
3.52k
      {
1288
3.52k
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
3.52k
      }
1290
68.7k
    break;
1291
38.5k
  case IMAGE_SCN_MEM_SHARED:
1292
38.5k
    sec_flags |= SEC_COFF_SHARED;
1293
38.5k
    break;
1294
94.4k
  case IMAGE_SCN_LNK_REMOVE:
1295
94.4k
    if (!is_dbg)
1296
92.0k
      sec_flags |= SEC_EXCLUDE;
1297
94.4k
    break;
1298
42.6k
  case IMAGE_SCN_CNT_CODE:
1299
42.6k
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
42.6k
    break;
1301
45.8k
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
45.8k
    if (is_dbg)
1303
2.19k
      sec_flags |= SEC_DEBUGGING;
1304
43.6k
    else
1305
43.6k
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
45.8k
    break;
1307
84.6k
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
84.6k
    sec_flags |= SEC_ALLOC;
1309
84.6k
    break;
1310
58.6k
  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
56.5k
    sec_flags |= SEC_DEBUGGING;
1319
#endif
1320
58.6k
    break;
1321
25.9k
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
25.9k
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
150
      result = false;
1325
25.9k
    break;
1326
642k
  default:
1327
    /* Silently ignore for now.  */
1328
642k
    break;
1329
1.65M
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
1.65M
      if (unhandled != NULL)
1333
97.9k
  {
1334
97.9k
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
97.9k
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
97.9k
       abfd, name, unhandled, flag);
1338
97.9k
    result = false;
1339
97.9k
  }
1340
1.65M
    }
1341
1342
980k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
980k
      && (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
106k
  if (startswith (name, ".gnu.linkonce"))
1355
0
    sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
1356
#endif
1357
1358
980k
  if (flags_ptr)
1359
980k
    * flags_ptr = sec_flags;
1360
1361
980k
  return result;
1362
980k
}
pei-i386.c:styp_to_sec_flags
Line
Count
Source
1191
11.0k
{
1192
11.0k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
11.0k
  unsigned long styp_flags = internal_s->s_flags;
1194
11.0k
  flagword sec_flags;
1195
11.0k
  bool result = true;
1196
11.0k
  bool is_dbg = false;
1197
1198
11.0k
  if (startswith (name, DOT_DEBUG)
1199
11.0k
      || startswith (name, DOT_ZDEBUG)
1200
11.0k
#ifdef COFF_LONG_SECTION_NAMES
1201
11.0k
      || startswith (name, GNU_LINKONCE_WI)
1202
11.0k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
11.0k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
11.0k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
11.0k
      || startswith (name, GNU_DEBUGLINK)
1207
11.0k
      || startswith (name, GNU_DEBUGALTLINK)
1208
11.0k
#endif
1209
11.0k
      || startswith (name, ".stab"))
1210
54
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
11.0k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
11.0k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
10.2k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
47.3k
  while (styp_flags)
1220
36.2k
    {
1221
36.2k
      unsigned long flag = styp_flags & - styp_flags;
1222
36.2k
      char * unhandled = NULL;
1223
1224
36.2k
      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
36.2k
      switch (flag)
1231
36.2k
  {
1232
1.02k
  case STYP_DSECT:
1233
1.02k
    unhandled = "STYP_DSECT";
1234
1.02k
    break;
1235
536
  case STYP_GROUP:
1236
536
    unhandled = "STYP_GROUP";
1237
536
    break;
1238
1.98k
  case STYP_COPY:
1239
1.98k
    unhandled = "STYP_COPY";
1240
1.98k
    break;
1241
528
  case STYP_OVER:
1242
528
    unhandled = "STYP_OVER";
1243
528
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
2.04k
  case STYP_NOLOAD:
1246
2.04k
    sec_flags |= SEC_NEVER_LOAD;
1247
2.04k
    break;
1248
0
#endif
1249
802
  case IMAGE_SCN_MEM_READ:
1250
802
    sec_flags &= ~SEC_COFF_NOREAD;
1251
802
    break;
1252
1.05k
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
1.05k
    break;
1255
532
  case IMAGE_SCN_LNK_OTHER:
1256
532
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
532
    break;
1258
532
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
532
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
532
    break;
1261
1.07k
  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
1.07k
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
1.07k
        " %s in section %s"),
1268
1.07k
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
1.07k
    break;
1270
1.30k
  case IMAGE_SCN_MEM_EXECUTE:
1271
1.30k
    sec_flags |= SEC_CODE;
1272
1.30k
    break;
1273
2.21k
  case IMAGE_SCN_MEM_WRITE:
1274
2.21k
    sec_flags &= ~ SEC_READONLY;
1275
2.21k
    break;
1276
2.08k
  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.08k
       if (is_dbg
1283
2.08k
#ifdef _COMMENT
1284
2.08k
        || strcmp (name, _COMMENT) == 0
1285
2.08k
#endif
1286
2.08k
        )
1287
14
      {
1288
14
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
14
      }
1290
2.08k
    break;
1291
2.00k
  case IMAGE_SCN_MEM_SHARED:
1292
2.00k
    sec_flags |= SEC_COFF_SHARED;
1293
2.00k
    break;
1294
1.06k
  case IMAGE_SCN_LNK_REMOVE:
1295
1.06k
    if (!is_dbg)
1296
1.05k
      sec_flags |= SEC_EXCLUDE;
1297
1.06k
    break;
1298
1.29k
  case IMAGE_SCN_CNT_CODE:
1299
1.29k
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
1.29k
    break;
1301
798
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
798
    if (is_dbg)
1303
26
      sec_flags |= SEC_DEBUGGING;
1304
772
    else
1305
772
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
798
    break;
1307
2.18k
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
2.18k
    sec_flags |= SEC_ALLOC;
1309
2.18k
    break;
1310
1.08k
  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
1.08k
#ifdef COFF_PAGE_SIZE
1318
1.08k
    sec_flags |= SEC_DEBUGGING;
1319
1.08k
#endif
1320
1.08k
    break;
1321
1.07k
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
1.07k
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
10
      result = false;
1325
1.07k
    break;
1326
11.0k
  default:
1327
    /* Silently ignore for now.  */
1328
11.0k
    break;
1329
36.2k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
36.2k
      if (unhandled != NULL)
1333
5.13k
  {
1334
5.13k
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
5.13k
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
5.13k
       abfd, name, unhandled, flag);
1338
5.13k
    result = false;
1339
5.13k
  }
1340
36.2k
    }
1341
1342
11.0k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
11.0k
      && (startswith (name, ".sbss")
1344
0
    || startswith (name, ".sdata")))
1345
0
    sec_flags |= SEC_SMALL_DATA;
1346
1347
11.0k
#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
11.0k
  if (startswith (name, ".gnu.linkonce"))
1355
0
    sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
1356
11.0k
#endif
1357
1358
11.0k
  if (flags_ptr)
1359
11.0k
    * flags_ptr = sec_flags;
1360
1361
11.0k
  return result;
1362
11.0k
}
pe-x86_64.c:styp_to_sec_flags
Line
Count
Source
1191
88.1k
{
1192
88.1k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
88.1k
  unsigned long styp_flags = internal_s->s_flags;
1194
88.1k
  flagword sec_flags;
1195
88.1k
  bool result = true;
1196
88.1k
  bool is_dbg = false;
1197
1198
88.1k
  if (startswith (name, DOT_DEBUG)
1199
88.1k
      || startswith (name, DOT_ZDEBUG)
1200
88.1k
#ifdef COFF_LONG_SECTION_NAMES
1201
88.1k
      || startswith (name, GNU_LINKONCE_WI)
1202
88.1k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
88.1k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
88.1k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
88.1k
      || startswith (name, GNU_DEBUGLINK)
1207
88.1k
      || startswith (name, GNU_DEBUGALTLINK)
1208
88.1k
#endif
1209
88.1k
      || startswith (name, ".stab"))
1210
100
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
88.1k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
88.1k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
74.0k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
214k
  while (styp_flags)
1220
126k
    {
1221
126k
      unsigned long flag = styp_flags & - styp_flags;
1222
126k
      char * unhandled = NULL;
1223
1224
126k
      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
126k
      switch (flag)
1231
126k
  {
1232
112
  case STYP_DSECT:
1233
112
    unhandled = "STYP_DSECT";
1234
112
    break;
1235
70
  case STYP_GROUP:
1236
70
    unhandled = "STYP_GROUP";
1237
70
    break;
1238
120
  case STYP_COPY:
1239
120
    unhandled = "STYP_COPY";
1240
120
    break;
1241
126
  case STYP_OVER:
1242
126
    unhandled = "STYP_OVER";
1243
126
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
14.7k
  case STYP_NOLOAD:
1246
14.7k
    sec_flags |= SEC_NEVER_LOAD;
1247
14.7k
    break;
1248
0
#endif
1249
14.0k
  case IMAGE_SCN_MEM_READ:
1250
14.0k
    sec_flags &= ~SEC_COFF_NOREAD;
1251
14.0k
    break;
1252
1.01k
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
1.01k
    break;
1255
64
  case IMAGE_SCN_LNK_OTHER:
1256
64
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
64
    break;
1258
66
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
66
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
66
    break;
1261
980
  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
980
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
980
        " %s in section %s"),
1268
980
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
980
    break;
1270
636
  case IMAGE_SCN_MEM_EXECUTE:
1271
636
    sec_flags |= SEC_CODE;
1272
636
    break;
1273
636
  case IMAGE_SCN_MEM_WRITE:
1274
636
    sec_flags &= ~ SEC_READONLY;
1275
636
    break;
1276
14.7k
  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
14.7k
       if (is_dbg
1283
14.7k
#ifdef _COMMENT
1284
14.7k
        || strcmp (name, _COMMENT) == 0
1285
14.7k
#endif
1286
14.7k
        )
1287
40
      {
1288
40
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
40
      }
1290
14.7k
    break;
1291
220
  case IMAGE_SCN_MEM_SHARED:
1292
220
    sec_flags |= SEC_COFF_SHARED;
1293
220
    break;
1294
1.02k
  case IMAGE_SCN_LNK_REMOVE:
1295
1.02k
    if (!is_dbg)
1296
1.01k
      sec_flags |= SEC_EXCLUDE;
1297
1.02k
    break;
1298
606
  case IMAGE_SCN_CNT_CODE:
1299
606
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
606
    break;
1301
14.1k
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
14.1k
    if (is_dbg)
1303
38
      sec_flags |= SEC_DEBUGGING;
1304
14.1k
    else
1305
14.1k
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
14.1k
    break;
1307
618
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
618
    sec_flags |= SEC_ALLOC;
1309
618
    break;
1310
14.7k
  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
14.7k
#ifdef COFF_PAGE_SIZE
1318
14.7k
    sec_flags |= SEC_DEBUGGING;
1319
14.7k
#endif
1320
14.7k
    break;
1321
362
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
362
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
20
      result = false;
1325
362
    break;
1326
47.5k
  default:
1327
    /* Silently ignore for now.  */
1328
47.5k
    break;
1329
126k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
126k
      if (unhandled != NULL)
1333
558
  {
1334
558
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
558
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
558
       abfd, name, unhandled, flag);
1338
558
    result = false;
1339
558
  }
1340
126k
    }
1341
1342
88.1k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
88.1k
      && (startswith (name, ".sbss")
1344
0
    || startswith (name, ".sdata")))
1345
0
    sec_flags |= SEC_SMALL_DATA;
1346
1347
88.1k
#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
88.1k
  if (startswith (name, ".gnu.linkonce"))
1355
0
    sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
1356
88.1k
#endif
1357
1358
88.1k
  if (flags_ptr)
1359
88.1k
    * flags_ptr = sec_flags;
1360
1361
88.1k
  return result;
1362
88.1k
}
pei-x86_64.c:styp_to_sec_flags
Line
Count
Source
1191
3.04k
{
1192
3.04k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
3.04k
  unsigned long styp_flags = internal_s->s_flags;
1194
3.04k
  flagword sec_flags;
1195
3.04k
  bool result = true;
1196
3.04k
  bool is_dbg = false;
1197
1198
3.04k
  if (startswith (name, DOT_DEBUG)
1199
3.04k
      || startswith (name, DOT_ZDEBUG)
1200
3.04k
#ifdef COFF_LONG_SECTION_NAMES
1201
3.04k
      || startswith (name, GNU_LINKONCE_WI)
1202
3.04k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
3.04k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
3.04k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
3.04k
      || startswith (name, GNU_DEBUGLINK)
1207
3.04k
      || startswith (name, GNU_DEBUGALTLINK)
1208
3.04k
#endif
1209
3.04k
      || startswith (name, ".stab"))
1210
34
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
3.04k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
3.04k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
2.22k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
19.0k
  while (styp_flags)
1220
15.9k
    {
1221
15.9k
      unsigned long flag = styp_flags & - styp_flags;
1222
15.9k
      char * unhandled = NULL;
1223
1224
15.9k
      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
15.9k
      switch (flag)
1231
15.9k
  {
1232
32
  case STYP_DSECT:
1233
32
    unhandled = "STYP_DSECT";
1234
32
    break;
1235
26
  case STYP_GROUP:
1236
26
    unhandled = "STYP_GROUP";
1237
26
    break;
1238
34
  case STYP_COPY:
1239
34
    unhandled = "STYP_COPY";
1240
34
    break;
1241
44
  case STYP_OVER:
1242
44
    unhandled = "STYP_OVER";
1243
44
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
350
  case STYP_NOLOAD:
1246
350
    sec_flags |= SEC_NEVER_LOAD;
1247
350
    break;
1248
0
#endif
1249
818
  case IMAGE_SCN_MEM_READ:
1250
818
    sec_flags &= ~SEC_COFF_NOREAD;
1251
818
    break;
1252
884
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
884
    break;
1255
46
  case IMAGE_SCN_LNK_OTHER:
1256
46
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
46
    break;
1258
34
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
34
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
34
    break;
1261
1.04k
  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
1.04k
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
1.04k
        " %s in section %s"),
1268
1.04k
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
1.04k
    break;
1270
1.02k
  case IMAGE_SCN_MEM_EXECUTE:
1271
1.02k
    sec_flags |= SEC_CODE;
1272
1.02k
    break;
1273
778
  case IMAGE_SCN_MEM_WRITE:
1274
778
    sec_flags &= ~ SEC_READONLY;
1275
778
    break;
1276
420
  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
420
       if (is_dbg
1283
420
#ifdef _COMMENT
1284
420
        || strcmp (name, _COMMENT) == 0
1285
420
#endif
1286
420
        )
1287
16
      {
1288
16
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
16
      }
1290
420
    break;
1291
118
  case IMAGE_SCN_MEM_SHARED:
1292
118
    sec_flags |= SEC_COFF_SHARED;
1293
118
    break;
1294
948
  case IMAGE_SCN_LNK_REMOVE:
1295
948
    if (!is_dbg)
1296
940
      sec_flags |= SEC_EXCLUDE;
1297
948
    break;
1298
876
  case IMAGE_SCN_CNT_CODE:
1299
876
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
876
    break;
1301
658
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
658
    if (is_dbg)
1303
28
      sec_flags |= SEC_DEBUGGING;
1304
630
    else
1305
630
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
658
    break;
1307
616
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
616
    sec_flags |= SEC_ALLOC;
1309
616
    break;
1310
438
  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
438
#ifdef COFF_PAGE_SIZE
1318
438
    sec_flags |= SEC_DEBUGGING;
1319
438
#endif
1320
438
    break;
1321
212
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
212
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
8
      result = false;
1325
212
    break;
1326
6.56k
  default:
1327
    /* Silently ignore for now.  */
1328
6.56k
    break;
1329
15.9k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
15.9k
      if (unhandled != NULL)
1333
216
  {
1334
216
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
216
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
216
       abfd, name, unhandled, flag);
1338
216
    result = false;
1339
216
  }
1340
15.9k
    }
1341
1342
3.04k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
3.04k
      && (startswith (name, ".sbss")
1344
0
    || startswith (name, ".sdata")))
1345
0
    sec_flags |= SEC_SMALL_DATA;
1346
1347
3.04k
#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
3.04k
  if (startswith (name, ".gnu.linkonce"))
1355
0
    sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
1356
3.04k
#endif
1357
1358
3.04k
  if (flags_ptr)
1359
3.04k
    * flags_ptr = sec_flags;
1360
1361
3.04k
  return result;
1362
3.04k
}
pe-aarch64.c:styp_to_sec_flags
Line
Count
Source
1191
4.28k
{
1192
4.28k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
4.28k
  unsigned long styp_flags = internal_s->s_flags;
1194
4.28k
  flagword sec_flags;
1195
4.28k
  bool result = true;
1196
4.28k
  bool is_dbg = false;
1197
1198
4.28k
  if (startswith (name, DOT_DEBUG)
1199
4.28k
      || startswith (name, DOT_ZDEBUG)
1200
4.28k
#ifdef COFF_LONG_SECTION_NAMES
1201
4.28k
      || startswith (name, GNU_LINKONCE_WI)
1202
4.28k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
4.28k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
4.28k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
4.28k
      || startswith (name, GNU_DEBUGLINK)
1207
4.28k
      || startswith (name, GNU_DEBUGALTLINK)
1208
4.28k
#endif
1209
4.28k
      || startswith (name, ".stab"))
1210
46
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
4.28k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
4.28k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
3.97k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
17.0k
  while (styp_flags)
1220
12.7k
    {
1221
12.7k
      unsigned long flag = styp_flags & - styp_flags;
1222
12.7k
      char * unhandled = NULL;
1223
1224
12.7k
      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
12.7k
      switch (flag)
1231
12.7k
  {
1232
58
  case STYP_DSECT:
1233
58
    unhandled = "STYP_DSECT";
1234
58
    break;
1235
48
  case STYP_GROUP:
1236
48
    unhandled = "STYP_GROUP";
1237
48
    break;
1238
36
  case STYP_COPY:
1239
36
    unhandled = "STYP_COPY";
1240
36
    break;
1241
72
  case STYP_OVER:
1242
72
    unhandled = "STYP_OVER";
1243
72
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
224
  case STYP_NOLOAD:
1246
224
    sec_flags |= SEC_NEVER_LOAD;
1247
224
    break;
1248
0
#endif
1249
318
  case IMAGE_SCN_MEM_READ:
1250
318
    sec_flags &= ~SEC_COFF_NOREAD;
1251
318
    break;
1252
810
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
810
    break;
1255
62
  case IMAGE_SCN_LNK_OTHER:
1256
62
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
62
    break;
1258
42
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
42
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
42
    break;
1261
1.00k
  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
1.00k
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
1.00k
        " %s in section %s"),
1268
1.00k
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
1.00k
    break;
1270
896
  case IMAGE_SCN_MEM_EXECUTE:
1271
896
    sec_flags |= SEC_CODE;
1272
896
    break;
1273
660
  case IMAGE_SCN_MEM_WRITE:
1274
660
    sec_flags &= ~ SEC_READONLY;
1275
660
    break;
1276
296
  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
296
       if (is_dbg
1283
296
#ifdef _COMMENT
1284
296
        || strcmp (name, _COMMENT) == 0
1285
296
#endif
1286
296
        )
1287
16
      {
1288
16
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
16
      }
1290
296
    break;
1291
112
  case IMAGE_SCN_MEM_SHARED:
1292
112
    sec_flags |= SEC_COFF_SHARED;
1293
112
    break;
1294
846
  case IMAGE_SCN_LNK_REMOVE:
1295
846
    if (!is_dbg)
1296
826
      sec_flags |= SEC_EXCLUDE;
1297
846
    break;
1298
788
  case IMAGE_SCN_CNT_CODE:
1299
788
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
788
    break;
1301
174
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
174
    if (is_dbg)
1303
16
      sec_flags |= SEC_DEBUGGING;
1304
158
    else
1305
158
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
174
    break;
1307
568
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
568
    sec_flags |= SEC_ALLOC;
1309
568
    break;
1310
338
  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
338
#ifdef COFF_PAGE_SIZE
1318
338
    sec_flags |= SEC_DEBUGGING;
1319
338
#endif
1320
338
    break;
1321
190
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
190
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
4
      result = false;
1325
190
    break;
1326
5.22k
  default:
1327
    /* Silently ignore for now.  */
1328
5.22k
    break;
1329
12.7k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
12.7k
      if (unhandled != NULL)
1333
318
  {
1334
318
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
318
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
318
       abfd, name, unhandled, flag);
1338
318
    result = false;
1339
318
  }
1340
12.7k
    }
1341
1342
4.28k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
4.28k
      && (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
4.28k
  if (flags_ptr)
1359
4.28k
    * flags_ptr = sec_flags;
1360
1361
4.28k
  return result;
1362
4.28k
}
pei-aarch64.c:styp_to_sec_flags
Line
Count
Source
1191
14.6k
{
1192
14.6k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
14.6k
  unsigned long styp_flags = internal_s->s_flags;
1194
14.6k
  flagword sec_flags;
1195
14.6k
  bool result = true;
1196
14.6k
  bool is_dbg = false;
1197
1198
14.6k
  if (startswith (name, DOT_DEBUG)
1199
14.6k
      || startswith (name, DOT_ZDEBUG)
1200
14.6k
#ifdef COFF_LONG_SECTION_NAMES
1201
14.6k
      || startswith (name, GNU_LINKONCE_WI)
1202
14.6k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
14.6k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
14.6k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
14.6k
      || startswith (name, GNU_DEBUGLINK)
1207
14.6k
      || startswith (name, GNU_DEBUGALTLINK)
1208
14.6k
#endif
1209
14.6k
      || startswith (name, ".stab"))
1210
30
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
14.6k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
14.6k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
13.4k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
75.8k
  while (styp_flags)
1220
61.1k
    {
1221
61.1k
      unsigned long flag = styp_flags & - styp_flags;
1222
61.1k
      char * unhandled = NULL;
1223
1224
61.1k
      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
61.1k
      switch (flag)
1231
61.1k
  {
1232
1.51k
  case STYP_DSECT:
1233
1.51k
    unhandled = "STYP_DSECT";
1234
1.51k
    break;
1235
1.50k
  case STYP_GROUP:
1236
1.50k
    unhandled = "STYP_GROUP";
1237
1.50k
    break;
1238
1.48k
  case STYP_COPY:
1239
1.48k
    unhandled = "STYP_COPY";
1240
1.48k
    break;
1241
552
  case STYP_OVER:
1242
552
    unhandled = "STYP_OVER";
1243
552
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
2.30k
  case STYP_NOLOAD:
1246
2.30k
    sec_flags |= SEC_NEVER_LOAD;
1247
2.30k
    break;
1248
0
#endif
1249
1.25k
  case IMAGE_SCN_MEM_READ:
1250
1.25k
    sec_flags &= ~SEC_COFF_NOREAD;
1251
1.25k
    break;
1252
1.55k
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
1.55k
    break;
1255
1.03k
  case IMAGE_SCN_LNK_OTHER:
1256
1.03k
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
1.03k
    break;
1258
1.98k
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
1.98k
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
1.98k
    break;
1261
2.12k
  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.12k
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
2.12k
        " %s in section %s"),
1268
2.12k
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
2.12k
    break;
1270
6.11k
  case IMAGE_SCN_MEM_EXECUTE:
1271
6.11k
    sec_flags |= SEC_CODE;
1272
6.11k
    break;
1273
656
  case IMAGE_SCN_MEM_WRITE:
1274
656
    sec_flags &= ~ SEC_READONLY;
1275
656
    break;
1276
906
  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
906
       if (is_dbg
1283
906
#ifdef _COMMENT
1284
906
        || strcmp (name, _COMMENT) == 0
1285
906
#endif
1286
906
        )
1287
24
      {
1288
24
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
24
      }
1290
906
    break;
1291
578
  case IMAGE_SCN_MEM_SHARED:
1292
578
    sec_flags |= SEC_COFF_SHARED;
1293
578
    break;
1294
622
  case IMAGE_SCN_LNK_REMOVE:
1295
622
    if (!is_dbg)
1296
620
      sec_flags |= SEC_EXCLUDE;
1297
622
    break;
1298
6.97k
  case IMAGE_SCN_CNT_CODE:
1299
6.97k
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
6.97k
    break;
1301
1.62k
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
1.62k
    if (is_dbg)
1303
28
      sec_flags |= SEC_DEBUGGING;
1304
1.59k
    else
1305
1.59k
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
1.62k
    break;
1307
1.54k
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
1.54k
    sec_flags |= SEC_ALLOC;
1309
1.54k
    break;
1310
438
  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
438
#ifdef COFF_PAGE_SIZE
1318
438
    sec_flags |= SEC_DEBUGGING;
1319
438
#endif
1320
438
    break;
1321
648
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
648
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
10
      result = false;
1325
648
    break;
1326
25.7k
  default:
1327
    /* Silently ignore for now.  */
1328
25.7k
    break;
1329
61.1k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
61.1k
      if (unhandled != NULL)
1333
8.07k
  {
1334
8.07k
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
8.07k
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
8.07k
       abfd, name, unhandled, flag);
1338
8.07k
    result = false;
1339
8.07k
  }
1340
61.1k
    }
1341
1342
14.6k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
14.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
14.6k
  if (flags_ptr)
1359
14.6k
    * flags_ptr = sec_flags;
1360
1361
14.6k
  return result;
1362
14.6k
}
pei-ia64.c:styp_to_sec_flags
Line
Count
Source
1191
72.9k
{
1192
72.9k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
72.9k
  unsigned long styp_flags = internal_s->s_flags;
1194
72.9k
  flagword sec_flags;
1195
72.9k
  bool result = true;
1196
72.9k
  bool is_dbg = false;
1197
1198
72.9k
  if (startswith (name, DOT_DEBUG)
1199
72.9k
      || startswith (name, DOT_ZDEBUG)
1200
72.9k
#ifdef COFF_LONG_SECTION_NAMES
1201
72.9k
      || startswith (name, GNU_LINKONCE_WI)
1202
72.9k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
72.9k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
72.9k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
72.9k
      || startswith (name, GNU_DEBUGLINK)
1207
72.9k
      || startswith (name, GNU_DEBUGALTLINK)
1208
72.9k
#endif
1209
72.9k
      || startswith (name, ".stab"))
1210
2.41k
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
72.9k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
72.9k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
69.0k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
318k
  while (styp_flags)
1220
245k
    {
1221
245k
      unsigned long flag = styp_flags & - styp_flags;
1222
245k
      char * unhandled = NULL;
1223
1224
245k
      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
245k
      switch (flag)
1231
245k
  {
1232
5.35k
  case STYP_DSECT:
1233
5.35k
    unhandled = "STYP_DSECT";
1234
5.35k
    break;
1235
4.86k
  case STYP_GROUP:
1236
4.86k
    unhandled = "STYP_GROUP";
1237
4.86k
    break;
1238
2.95k
  case STYP_COPY:
1239
2.95k
    unhandled = "STYP_COPY";
1240
2.95k
    break;
1241
2.93k
  case STYP_OVER:
1242
2.93k
    unhandled = "STYP_OVER";
1243
2.93k
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
12.2k
  case STYP_NOLOAD:
1246
12.2k
    sec_flags |= SEC_NEVER_LOAD;
1247
12.2k
    break;
1248
0
#endif
1249
3.92k
  case IMAGE_SCN_MEM_READ:
1250
3.92k
    sec_flags &= ~SEC_COFF_NOREAD;
1251
3.92k
    break;
1252
14.6k
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
14.6k
    break;
1255
5.83k
  case IMAGE_SCN_LNK_OTHER:
1256
5.83k
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
5.83k
    break;
1258
3.88k
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
3.88k
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
3.88k
    break;
1261
15.7k
  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
15.7k
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
15.7k
        " %s in section %s"),
1268
15.7k
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
15.7k
    break;
1270
8.33k
  case IMAGE_SCN_MEM_EXECUTE:
1271
8.33k
    sec_flags |= SEC_CODE;
1272
8.33k
    break;
1273
9.83k
  case IMAGE_SCN_MEM_WRITE:
1274
9.83k
    sec_flags &= ~ SEC_READONLY;
1275
9.83k
    break;
1276
15.2k
  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
15.2k
       if (is_dbg
1283
15.2k
#ifdef _COMMENT
1284
15.2k
        || strcmp (name, _COMMENT) == 0
1285
15.2k
#endif
1286
15.2k
        )
1287
1.44k
      {
1288
1.44k
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
1.44k
      }
1290
15.2k
    break;
1291
5.96k
  case IMAGE_SCN_MEM_SHARED:
1292
5.96k
    sec_flags |= SEC_COFF_SHARED;
1293
5.96k
    break;
1294
13.6k
  case IMAGE_SCN_LNK_REMOVE:
1295
13.6k
    if (!is_dbg)
1296
12.2k
      sec_flags |= SEC_EXCLUDE;
1297
13.6k
    break;
1298
4.89k
  case IMAGE_SCN_CNT_CODE:
1299
4.89k
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
4.89k
    break;
1301
3.90k
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
3.90k
    if (is_dbg)
1303
964
      sec_flags |= SEC_DEBUGGING;
1304
2.94k
    else
1305
2.94k
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
3.90k
    break;
1307
7.80k
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
7.80k
    sec_flags |= SEC_ALLOC;
1309
7.80k
    break;
1310
12.8k
  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
12.8k
#ifdef COFF_PAGE_SIZE
1318
12.8k
    sec_flags |= SEC_DEBUGGING;
1319
12.8k
#endif
1320
12.8k
    break;
1321
4.49k
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
4.49k
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
14
      result = false;
1325
4.49k
    break;
1326
85.9k
  default:
1327
    /* Silently ignore for now.  */
1328
85.9k
    break;
1329
245k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
245k
      if (unhandled != NULL)
1333
25.8k
  {
1334
25.8k
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
25.8k
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
25.8k
       abfd, name, unhandled, flag);
1338
25.8k
    result = false;
1339
25.8k
  }
1340
245k
    }
1341
1342
72.9k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
72.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
72.9k
  if (flags_ptr)
1359
72.9k
    * flags_ptr = sec_flags;
1360
1361
72.9k
  return result;
1362
72.9k
}
pei-loongarch64.c:styp_to_sec_flags
Line
Count
Source
1191
2.05k
{
1192
2.05k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
2.05k
  unsigned long styp_flags = internal_s->s_flags;
1194
2.05k
  flagword sec_flags;
1195
2.05k
  bool result = true;
1196
2.05k
  bool is_dbg = false;
1197
1198
2.05k
  if (startswith (name, DOT_DEBUG)
1199
2.05k
      || startswith (name, DOT_ZDEBUG)
1200
2.05k
#ifdef COFF_LONG_SECTION_NAMES
1201
2.05k
      || startswith (name, GNU_LINKONCE_WI)
1202
2.05k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
2.05k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
2.05k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
2.05k
      || startswith (name, GNU_DEBUGLINK)
1207
2.05k
      || startswith (name, GNU_DEBUGALTLINK)
1208
2.05k
#endif
1209
2.05k
      || startswith (name, ".stab"))
1210
36
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
2.05k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
2.05k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
1.55k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
10.7k
  while (styp_flags)
1220
8.73k
    {
1221
8.73k
      unsigned long flag = styp_flags & - styp_flags;
1222
8.73k
      char * unhandled = NULL;
1223
1224
8.73k
      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
8.73k
      switch (flag)
1231
8.73k
  {
1232
62
  case STYP_DSECT:
1233
62
    unhandled = "STYP_DSECT";
1234
62
    break;
1235
36
  case STYP_GROUP:
1236
36
    unhandled = "STYP_GROUP";
1237
36
    break;
1238
38
  case STYP_COPY:
1239
38
    unhandled = "STYP_COPY";
1240
38
    break;
1241
70
  case STYP_OVER:
1242
70
    unhandled = "STYP_OVER";
1243
70
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
510
  case STYP_NOLOAD:
1246
510
    sec_flags |= SEC_NEVER_LOAD;
1247
510
    break;
1248
0
#endif
1249
492
  case IMAGE_SCN_MEM_READ:
1250
492
    sec_flags &= ~SEC_COFF_NOREAD;
1251
492
    break;
1252
224
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
224
    break;
1255
80
  case IMAGE_SCN_LNK_OTHER:
1256
80
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
80
    break;
1258
40
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
40
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
40
    break;
1261
298
  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
298
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
298
        " %s in section %s"),
1268
298
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
298
    break;
1270
260
  case IMAGE_SCN_MEM_EXECUTE:
1271
260
    sec_flags |= SEC_CODE;
1272
260
    break;
1273
288
  case IMAGE_SCN_MEM_WRITE:
1274
288
    sec_flags &= ~ SEC_READONLY;
1275
288
    break;
1276
522
  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
522
       if (is_dbg
1283
522
#ifdef _COMMENT
1284
522
        || strcmp (name, _COMMENT) == 0
1285
522
#endif
1286
522
        )
1287
32
      {
1288
32
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
32
      }
1290
522
    break;
1291
86
  case IMAGE_SCN_MEM_SHARED:
1292
86
    sec_flags |= SEC_COFF_SHARED;
1293
86
    break;
1294
288
  case IMAGE_SCN_LNK_REMOVE:
1295
288
    if (!is_dbg)
1296
282
      sec_flags |= SEC_EXCLUDE;
1297
288
    break;
1298
194
  case IMAGE_SCN_CNT_CODE:
1299
194
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
194
    break;
1301
440
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
440
    if (is_dbg)
1303
30
      sec_flags |= SEC_DEBUGGING;
1304
410
    else
1305
410
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
440
    break;
1307
214
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
214
    sec_flags |= SEC_ALLOC;
1309
214
    break;
1310
608
  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
608
#ifdef COFF_PAGE_SIZE
1318
608
    sec_flags |= SEC_DEBUGGING;
1319
608
#endif
1320
608
    break;
1321
238
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
238
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
6
      result = false;
1325
238
    break;
1326
3.74k
  default:
1327
    /* Silently ignore for now.  */
1328
3.74k
    break;
1329
8.73k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
8.73k
      if (unhandled != NULL)
1333
326
  {
1334
326
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
326
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
326
       abfd, name, unhandled, flag);
1338
326
    result = false;
1339
326
  }
1340
8.73k
    }
1341
1342
2.05k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
2.05k
      && (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
2.05k
  if (flags_ptr)
1359
2.05k
    * flags_ptr = sec_flags;
1360
1361
2.05k
  return result;
1362
2.05k
}
pe-arm-wince.c:styp_to_sec_flags
Line
Count
Source
1191
2.59k
{
1192
2.59k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
2.59k
  unsigned long styp_flags = internal_s->s_flags;
1194
2.59k
  flagword sec_flags;
1195
2.59k
  bool result = true;
1196
2.59k
  bool is_dbg = false;
1197
1198
2.59k
  if (startswith (name, DOT_DEBUG)
1199
2.59k
      || startswith (name, DOT_ZDEBUG)
1200
2.59k
#ifdef COFF_LONG_SECTION_NAMES
1201
2.59k
      || startswith (name, GNU_LINKONCE_WI)
1202
2.59k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
2.59k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
2.59k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
2.59k
      || startswith (name, GNU_DEBUGLINK)
1207
2.59k
      || startswith (name, GNU_DEBUGALTLINK)
1208
2.59k
#endif
1209
2.59k
      || startswith (name, ".stab"))
1210
216
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
2.59k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
2.59k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
1.82k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
22.9k
  while (styp_flags)
1220
20.3k
    {
1221
20.3k
      unsigned long flag = styp_flags & - styp_flags;
1222
20.3k
      char * unhandled = NULL;
1223
1224
20.3k
      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
20.3k
      switch (flag)
1231
20.3k
  {
1232
102
  case STYP_DSECT:
1233
102
    unhandled = "STYP_DSECT";
1234
102
    break;
1235
100
  case STYP_GROUP:
1236
100
    unhandled = "STYP_GROUP";
1237
100
    break;
1238
110
  case STYP_COPY:
1239
110
    unhandled = "STYP_COPY";
1240
110
    break;
1241
102
  case STYP_OVER:
1242
102
    unhandled = "STYP_OVER";
1243
102
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
942
  case STYP_NOLOAD:
1246
942
    sec_flags |= SEC_NEVER_LOAD;
1247
942
    break;
1248
0
#endif
1249
772
  case IMAGE_SCN_MEM_READ:
1250
772
    sec_flags &= ~SEC_COFF_NOREAD;
1251
772
    break;
1252
1.36k
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
1.36k
    break;
1255
110
  case IMAGE_SCN_LNK_OTHER:
1256
110
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
110
    break;
1258
116
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
116
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
116
    break;
1261
1.31k
  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
1.31k
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
1.31k
        " %s in section %s"),
1268
1.31k
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
1.31k
    break;
1270
964
  case IMAGE_SCN_MEM_EXECUTE:
1271
964
    sec_flags |= SEC_CODE;
1272
964
    break;
1273
732
  case IMAGE_SCN_MEM_WRITE:
1274
732
    sec_flags &= ~ SEC_READONLY;
1275
732
    break;
1276
964
  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
964
       if (is_dbg
1283
964
#ifdef _COMMENT
1284
964
        || strcmp (name, _COMMENT) == 0
1285
964
#endif
1286
964
        )
1287
124
      {
1288
124
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
124
      }
1290
964
    break;
1291
224
  case IMAGE_SCN_MEM_SHARED:
1292
224
    sec_flags |= SEC_COFF_SHARED;
1293
224
    break;
1294
1.38k
  case IMAGE_SCN_LNK_REMOVE:
1295
1.38k
    if (!is_dbg)
1296
1.25k
      sec_flags |= SEC_EXCLUDE;
1297
1.38k
    break;
1298
858
  case IMAGE_SCN_CNT_CODE:
1299
858
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
858
    break;
1301
650
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
650
    if (is_dbg)
1303
6
      sec_flags |= SEC_DEBUGGING;
1304
644
    else
1305
644
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
650
    break;
1307
656
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
656
    sec_flags |= SEC_ALLOC;
1309
656
    break;
1310
926
  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
926
#ifdef COFF_PAGE_SIZE
1318
926
    sec_flags |= SEC_DEBUGGING;
1319
926
#endif
1320
926
    break;
1321
208
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
208
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
6
      result = false;
1325
208
    break;
1326
7.75k
  default:
1327
    /* Silently ignore for now.  */
1328
7.75k
    break;
1329
20.3k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
20.3k
      if (unhandled != NULL)
1333
640
  {
1334
640
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
640
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
640
       abfd, name, unhandled, flag);
1338
640
    result = false;
1339
640
  }
1340
20.3k
    }
1341
1342
2.59k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
2.59k
      && (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
2.59k
  if (flags_ptr)
1359
2.59k
    * flags_ptr = sec_flags;
1360
1361
2.59k
  return result;
1362
2.59k
}
pe-arm.c:styp_to_sec_flags
Line
Count
Source
1191
2.59k
{
1192
2.59k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
2.59k
  unsigned long styp_flags = internal_s->s_flags;
1194
2.59k
  flagword sec_flags;
1195
2.59k
  bool result = true;
1196
2.59k
  bool is_dbg = false;
1197
1198
2.59k
  if (startswith (name, DOT_DEBUG)
1199
2.59k
      || startswith (name, DOT_ZDEBUG)
1200
2.59k
#ifdef COFF_LONG_SECTION_NAMES
1201
2.59k
      || startswith (name, GNU_LINKONCE_WI)
1202
2.59k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
2.59k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
2.59k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
2.59k
      || startswith (name, GNU_DEBUGLINK)
1207
2.59k
      || startswith (name, GNU_DEBUGALTLINK)
1208
2.59k
#endif
1209
2.59k
      || startswith (name, ".stab"))
1210
216
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
2.59k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
2.59k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
1.82k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
22.9k
  while (styp_flags)
1220
20.3k
    {
1221
20.3k
      unsigned long flag = styp_flags & - styp_flags;
1222
20.3k
      char * unhandled = NULL;
1223
1224
20.3k
      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
20.3k
      switch (flag)
1231
20.3k
  {
1232
102
  case STYP_DSECT:
1233
102
    unhandled = "STYP_DSECT";
1234
102
    break;
1235
100
  case STYP_GROUP:
1236
100
    unhandled = "STYP_GROUP";
1237
100
    break;
1238
110
  case STYP_COPY:
1239
110
    unhandled = "STYP_COPY";
1240
110
    break;
1241
102
  case STYP_OVER:
1242
102
    unhandled = "STYP_OVER";
1243
102
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
942
  case STYP_NOLOAD:
1246
942
    sec_flags |= SEC_NEVER_LOAD;
1247
942
    break;
1248
0
#endif
1249
772
  case IMAGE_SCN_MEM_READ:
1250
772
    sec_flags &= ~SEC_COFF_NOREAD;
1251
772
    break;
1252
1.36k
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
1.36k
    break;
1255
110
  case IMAGE_SCN_LNK_OTHER:
1256
110
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
110
    break;
1258
116
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
116
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
116
    break;
1261
1.31k
  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
1.31k
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
1.31k
        " %s in section %s"),
1268
1.31k
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
1.31k
    break;
1270
964
  case IMAGE_SCN_MEM_EXECUTE:
1271
964
    sec_flags |= SEC_CODE;
1272
964
    break;
1273
732
  case IMAGE_SCN_MEM_WRITE:
1274
732
    sec_flags &= ~ SEC_READONLY;
1275
732
    break;
1276
964
  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
964
       if (is_dbg
1283
964
#ifdef _COMMENT
1284
964
        || strcmp (name, _COMMENT) == 0
1285
964
#endif
1286
964
        )
1287
124
      {
1288
124
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
124
      }
1290
964
    break;
1291
224
  case IMAGE_SCN_MEM_SHARED:
1292
224
    sec_flags |= SEC_COFF_SHARED;
1293
224
    break;
1294
1.38k
  case IMAGE_SCN_LNK_REMOVE:
1295
1.38k
    if (!is_dbg)
1296
1.25k
      sec_flags |= SEC_EXCLUDE;
1297
1.38k
    break;
1298
858
  case IMAGE_SCN_CNT_CODE:
1299
858
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
858
    break;
1301
650
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
650
    if (is_dbg)
1303
6
      sec_flags |= SEC_DEBUGGING;
1304
644
    else
1305
644
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
650
    break;
1307
656
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
656
    sec_flags |= SEC_ALLOC;
1309
656
    break;
1310
926
  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
926
#ifdef COFF_PAGE_SIZE
1318
926
    sec_flags |= SEC_DEBUGGING;
1319
926
#endif
1320
926
    break;
1321
208
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
208
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
6
      result = false;
1325
208
    break;
1326
7.75k
  default:
1327
    /* Silently ignore for now.  */
1328
7.75k
    break;
1329
20.3k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
20.3k
      if (unhandled != NULL)
1333
640
  {
1334
640
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
640
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
640
       abfd, name, unhandled, flag);
1338
640
    result = false;
1339
640
  }
1340
20.3k
    }
1341
1342
2.59k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
2.59k
      && (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
2.59k
  if (flags_ptr)
1359
2.59k
    * flags_ptr = sec_flags;
1360
1361
2.59k
  return result;
1362
2.59k
}
pe-i386.c:styp_to_sec_flags
Line
Count
Source
1191
4.17k
{
1192
4.17k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
4.17k
  unsigned long styp_flags = internal_s->s_flags;
1194
4.17k
  flagword sec_flags;
1195
4.17k
  bool result = true;
1196
4.17k
  bool is_dbg = false;
1197
1198
4.17k
  if (startswith (name, DOT_DEBUG)
1199
4.17k
      || startswith (name, DOT_ZDEBUG)
1200
4.17k
#ifdef COFF_LONG_SECTION_NAMES
1201
4.17k
      || startswith (name, GNU_LINKONCE_WI)
1202
4.17k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
4.17k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
4.17k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
4.17k
      || startswith (name, GNU_DEBUGLINK)
1207
4.17k
      || startswith (name, GNU_DEBUGALTLINK)
1208
4.17k
#endif
1209
4.17k
      || startswith (name, ".stab"))
1210
82
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
4.17k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
4.17k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
3.29k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
24.6k
  while (styp_flags)
1220
20.4k
    {
1221
20.4k
      unsigned long flag = styp_flags & - styp_flags;
1222
20.4k
      char * unhandled = NULL;
1223
1224
20.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
20.4k
      switch (flag)
1231
20.4k
  {
1232
148
  case STYP_DSECT:
1233
148
    unhandled = "STYP_DSECT";
1234
148
    break;
1235
110
  case STYP_GROUP:
1236
110
    unhandled = "STYP_GROUP";
1237
110
    break;
1238
144
  case STYP_COPY:
1239
144
    unhandled = "STYP_COPY";
1240
144
    break;
1241
132
  case STYP_OVER:
1242
132
    unhandled = "STYP_OVER";
1243
132
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
904
  case STYP_NOLOAD:
1246
904
    sec_flags |= SEC_NEVER_LOAD;
1247
904
    break;
1248
0
#endif
1249
884
  case IMAGE_SCN_MEM_READ:
1250
884
    sec_flags &= ~SEC_COFF_NOREAD;
1251
884
    break;
1252
850
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
850
    break;
1255
154
  case IMAGE_SCN_LNK_OTHER:
1256
154
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
154
    break;
1258
184
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
184
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
184
    break;
1261
1.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
1.16k
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
1.16k
        " %s in section %s"),
1268
1.16k
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
1.16k
    break;
1270
900
  case IMAGE_SCN_MEM_EXECUTE:
1271
900
    sec_flags |= SEC_CODE;
1272
900
    break;
1273
820
  case IMAGE_SCN_MEM_WRITE:
1274
820
    sec_flags &= ~ SEC_READONLY;
1275
820
    break;
1276
940
  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
940
       if (is_dbg
1283
940
#ifdef _COMMENT
1284
940
        || strcmp (name, _COMMENT) == 0
1285
940
#endif
1286
940
        )
1287
42
      {
1288
42
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
42
      }
1290
940
    break;
1291
488
  case IMAGE_SCN_MEM_SHARED:
1292
488
    sec_flags |= SEC_COFF_SHARED;
1293
488
    break;
1294
886
  case IMAGE_SCN_LNK_REMOVE:
1295
886
    if (!is_dbg)
1296
858
      sec_flags |= SEC_EXCLUDE;
1297
886
    break;
1298
832
  case IMAGE_SCN_CNT_CODE:
1299
832
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
832
    break;
1301
794
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
794
    if (is_dbg)
1303
4
      sec_flags |= SEC_DEBUGGING;
1304
790
    else
1305
790
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
794
    break;
1307
732
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
732
    sec_flags |= SEC_ALLOC;
1309
732
    break;
1310
948
  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
948
#ifdef COFF_PAGE_SIZE
1318
948
    sec_flags |= SEC_DEBUGGING;
1319
948
#endif
1320
948
    break;
1321
224
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
224
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
6
      result = false;
1325
224
    break;
1326
8.23k
  default:
1327
    /* Silently ignore for now.  */
1328
8.23k
    break;
1329
20.4k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
20.4k
      if (unhandled != NULL)
1333
872
  {
1334
872
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
872
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
872
       abfd, name, unhandled, flag);
1338
872
    result = false;
1339
872
  }
1340
20.4k
    }
1341
1342
4.17k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
4.17k
      && (startswith (name, ".sbss")
1344
0
    || startswith (name, ".sdata")))
1345
0
    sec_flags |= SEC_SMALL_DATA;
1346
1347
4.17k
#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
4.17k
  if (startswith (name, ".gnu.linkonce"))
1355
0
    sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
1356
4.17k
#endif
1357
1358
4.17k
  if (flags_ptr)
1359
4.17k
    * flags_ptr = sec_flags;
1360
1361
4.17k
  return result;
1362
4.17k
}
pe-mcore.c:styp_to_sec_flags
Line
Count
Source
1191
23.2k
{
1192
23.2k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
23.2k
  unsigned long styp_flags = internal_s->s_flags;
1194
23.2k
  flagword sec_flags;
1195
23.2k
  bool result = true;
1196
23.2k
  bool is_dbg = false;
1197
1198
23.2k
  if (startswith (name, DOT_DEBUG)
1199
23.2k
      || startswith (name, DOT_ZDEBUG)
1200
23.2k
#ifdef COFF_LONG_SECTION_NAMES
1201
23.2k
      || startswith (name, GNU_LINKONCE_WI)
1202
23.2k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
23.2k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
23.2k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
23.2k
      || startswith (name, GNU_DEBUGLINK)
1207
23.2k
      || startswith (name, GNU_DEBUGALTLINK)
1208
23.2k
#endif
1209
23.2k
      || startswith (name, ".stab"))
1210
1.10k
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
23.2k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
23.2k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
20.3k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
76.4k
  while (styp_flags)
1220
53.1k
    {
1221
53.1k
      unsigned long flag = styp_flags & - styp_flags;
1222
53.1k
      char * unhandled = NULL;
1223
1224
53.1k
      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
53.1k
      switch (flag)
1231
53.1k
  {
1232
74
  case STYP_DSECT:
1233
74
    unhandled = "STYP_DSECT";
1234
74
    break;
1235
64
  case STYP_GROUP:
1236
64
    unhandled = "STYP_GROUP";
1237
64
    break;
1238
68
  case STYP_COPY:
1239
68
    unhandled = "STYP_COPY";
1240
68
    break;
1241
72
  case STYP_OVER:
1242
72
    unhandled = "STYP_OVER";
1243
72
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
2.22k
  case STYP_NOLOAD:
1246
2.22k
    sec_flags |= SEC_NEVER_LOAD;
1247
2.22k
    break;
1248
0
#endif
1249
2.94k
  case IMAGE_SCN_MEM_READ:
1250
2.94k
    sec_flags &= ~SEC_COFF_NOREAD;
1251
2.94k
    break;
1252
1.02k
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
1.02k
    break;
1255
72
  case IMAGE_SCN_LNK_OTHER:
1256
72
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
72
    break;
1258
82
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
82
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
82
    break;
1261
1.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
1.50k
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
1.50k
        " %s in section %s"),
1268
1.50k
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
1.50k
    break;
1270
1.66k
  case IMAGE_SCN_MEM_EXECUTE:
1271
1.66k
    sec_flags |= SEC_CODE;
1272
1.66k
    break;
1273
954
  case IMAGE_SCN_MEM_WRITE:
1274
954
    sec_flags &= ~ SEC_READONLY;
1275
954
    break;
1276
4.18k
  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.18k
       if (is_dbg
1283
4.18k
#ifdef _COMMENT
1284
4.18k
        || strcmp (name, _COMMENT) == 0
1285
4.18k
#endif
1286
4.18k
        )
1287
556
      {
1288
556
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
556
      }
1290
4.18k
    break;
1291
624
  case IMAGE_SCN_MEM_SHARED:
1292
624
    sec_flags |= SEC_COFF_SHARED;
1293
624
    break;
1294
1.04k
  case IMAGE_SCN_LNK_REMOVE:
1295
1.04k
    if (!is_dbg)
1296
958
      sec_flags |= SEC_EXCLUDE;
1297
1.04k
    break;
1298
1.11k
  case IMAGE_SCN_CNT_CODE:
1299
1.11k
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
1.11k
    break;
1301
2.88k
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
2.88k
    if (is_dbg)
1303
492
      sec_flags |= SEC_DEBUGGING;
1304
2.39k
    else
1305
2.39k
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
2.88k
    break;
1307
1.39k
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
1.39k
    sec_flags |= SEC_ALLOC;
1309
1.39k
    break;
1310
2.73k
  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.73k
#ifdef COFF_PAGE_SIZE
1318
2.73k
    sec_flags |= SEC_DEBUGGING;
1319
2.73k
#endif
1320
2.73k
    break;
1321
676
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
676
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
10
      result = false;
1325
676
    break;
1326
27.7k
  default:
1327
    /* Silently ignore for now.  */
1328
27.7k
    break;
1329
53.1k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
53.1k
      if (unhandled != NULL)
1333
432
  {
1334
432
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
432
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
432
       abfd, name, unhandled, flag);
1338
432
    result = false;
1339
432
  }
1340
53.1k
    }
1341
1342
23.2k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
23.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
23.2k
  if (flags_ptr)
1359
23.2k
    * flags_ptr = sec_flags;
1360
1361
23.2k
  return result;
1362
23.2k
}
pe-sh.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
54
    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
8.97k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
48.9k
  while (styp_flags)
1220
38.5k
    {
1221
38.5k
      unsigned long flag = styp_flags & - styp_flags;
1222
38.5k
      char * unhandled = NULL;
1223
1224
38.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
38.5k
      switch (flag)
1231
38.5k
  {
1232
104
  case STYP_DSECT:
1233
104
    unhandled = "STYP_DSECT";
1234
104
    break;
1235
108
  case STYP_GROUP:
1236
108
    unhandled = "STYP_GROUP";
1237
108
    break;
1238
102
  case STYP_COPY:
1239
102
    unhandled = "STYP_COPY";
1240
102
    break;
1241
148
  case STYP_OVER:
1242
148
    unhandled = "STYP_OVER";
1243
148
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
1.97k
  case STYP_NOLOAD:
1246
1.97k
    sec_flags |= SEC_NEVER_LOAD;
1247
1.97k
    break;
1248
0
#endif
1249
1.42k
  case IMAGE_SCN_MEM_READ:
1250
1.42k
    sec_flags &= ~SEC_COFF_NOREAD;
1251
1.42k
    break;
1252
1.52k
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
1.52k
    break;
1255
178
  case IMAGE_SCN_LNK_OTHER:
1256
178
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
178
    break;
1258
164
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
164
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
164
    break;
1261
2.14k
  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.14k
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
2.14k
        " %s in section %s"),
1268
2.14k
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
2.14k
    break;
1270
1.37k
  case IMAGE_SCN_MEM_EXECUTE:
1271
1.37k
    sec_flags |= SEC_CODE;
1272
1.37k
    break;
1273
1.77k
  case IMAGE_SCN_MEM_WRITE:
1274
1.77k
    sec_flags &= ~ SEC_READONLY;
1275
1.77k
    break;
1276
3.52k
  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.52k
       if (is_dbg
1283
3.52k
#ifdef _COMMENT
1284
3.52k
        || strcmp (name, _COMMENT) == 0
1285
3.52k
#endif
1286
3.52k
        )
1287
34
      {
1288
34
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
34
      }
1290
3.52k
    break;
1291
1.64k
  case IMAGE_SCN_MEM_SHARED:
1292
1.64k
    sec_flags |= SEC_COFF_SHARED;
1293
1.64k
    break;
1294
1.61k
  case IMAGE_SCN_LNK_REMOVE:
1295
1.61k
    if (!is_dbg)
1296
1.59k
      sec_flags |= SEC_EXCLUDE;
1297
1.61k
    break;
1298
1.25k
  case IMAGE_SCN_CNT_CODE:
1299
1.25k
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
1.25k
    break;
1301
1.32k
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
1.32k
    if (is_dbg)
1303
16
      sec_flags |= SEC_DEBUGGING;
1304
1.30k
    else
1305
1.30k
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
1.32k
    break;
1307
728
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
728
    sec_flags |= SEC_ALLOC;
1309
728
    break;
1310
2.05k
  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
2.05k
    break;
1321
730
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
730
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
6
      result = false;
1325
730
    break;
1326
14.6k
  default:
1327
    /* Silently ignore for now.  */
1328
14.6k
    break;
1329
38.5k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
38.5k
      if (unhandled != NULL)
1333
804
  {
1334
804
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
804
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
804
       abfd, name, unhandled, flag);
1338
804
    result = false;
1339
804
  }
1340
38.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-arm-wince.c:styp_to_sec_flags
Line
Count
Source
1191
43.0k
{
1192
43.0k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
43.0k
  unsigned long styp_flags = internal_s->s_flags;
1194
43.0k
  flagword sec_flags;
1195
43.0k
  bool result = true;
1196
43.0k
  bool is_dbg = false;
1197
1198
43.0k
  if (startswith (name, DOT_DEBUG)
1199
43.0k
      || startswith (name, DOT_ZDEBUG)
1200
43.0k
#ifdef COFF_LONG_SECTION_NAMES
1201
43.0k
      || startswith (name, GNU_LINKONCE_WI)
1202
43.0k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
43.0k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
43.0k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
43.0k
      || startswith (name, GNU_DEBUGLINK)
1207
43.0k
      || startswith (name, GNU_DEBUGALTLINK)
1208
43.0k
#endif
1209
43.0k
      || startswith (name, ".stab"))
1210
512
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
43.0k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
43.0k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
38.9k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
209k
  while (styp_flags)
1220
166k
    {
1221
166k
      unsigned long flag = styp_flags & - styp_flags;
1222
166k
      char * unhandled = NULL;
1223
1224
166k
      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
166k
      switch (flag)
1231
166k
  {
1232
2.97k
  case STYP_DSECT:
1233
2.97k
    unhandled = "STYP_DSECT";
1234
2.97k
    break;
1235
2.94k
  case STYP_GROUP:
1236
2.94k
    unhandled = "STYP_GROUP";
1237
2.94k
    break;
1238
2.97k
  case STYP_COPY:
1239
2.97k
    unhandled = "STYP_COPY";
1240
2.97k
    break;
1241
2.45k
  case STYP_OVER:
1242
2.45k
    unhandled = "STYP_OVER";
1243
2.45k
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
4.69k
  case STYP_NOLOAD:
1246
4.69k
    sec_flags |= SEC_NEVER_LOAD;
1247
4.69k
    break;
1248
0
#endif
1249
4.12k
  case IMAGE_SCN_MEM_READ:
1250
4.12k
    sec_flags &= ~SEC_COFF_NOREAD;
1251
4.12k
    break;
1252
5.53k
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
5.53k
    break;
1255
3.44k
  case IMAGE_SCN_LNK_OTHER:
1256
3.44k
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
3.44k
    break;
1258
2.93k
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
2.93k
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
2.93k
    break;
1261
9.02k
  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
9.02k
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
9.02k
        " %s in section %s"),
1268
9.02k
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
9.02k
    break;
1270
6.13k
  case IMAGE_SCN_MEM_EXECUTE:
1271
6.13k
    sec_flags |= SEC_CODE;
1272
6.13k
    break;
1273
6.06k
  case IMAGE_SCN_MEM_WRITE:
1274
6.06k
    sec_flags &= ~ SEC_READONLY;
1275
6.06k
    break;
1276
10.0k
  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
10.0k
       if (is_dbg
1283
10.0k
#ifdef _COMMENT
1284
10.0k
        || strcmp (name, _COMMENT) == 0
1285
10.0k
#endif
1286
10.0k
        )
1287
498
      {
1288
498
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
498
      }
1290
10.0k
    break;
1291
11.8k
  case IMAGE_SCN_MEM_SHARED:
1292
11.8k
    sec_flags |= SEC_COFF_SHARED;
1293
11.8k
    break;
1294
5.08k
  case IMAGE_SCN_LNK_REMOVE:
1295
5.08k
    if (!is_dbg)
1296
5.08k
      sec_flags |= SEC_EXCLUDE;
1297
5.08k
    break;
1298
4.61k
  case IMAGE_SCN_CNT_CODE:
1299
4.61k
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
4.61k
    break;
1301
2.62k
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
2.62k
    if (is_dbg)
1303
2
      sec_flags |= SEC_DEBUGGING;
1304
2.62k
    else
1305
2.62k
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
2.62k
    break;
1307
3.54k
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
3.54k
    sec_flags |= SEC_ALLOC;
1309
3.54k
    break;
1310
4.74k
  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.74k
#ifdef COFF_PAGE_SIZE
1318
4.74k
    sec_flags |= SEC_DEBUGGING;
1319
4.74k
#endif
1320
4.74k
    break;
1321
3.07k
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
3.07k
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
14
      result = false;
1325
3.07k
    break;
1326
67.9k
  default:
1327
    /* Silently ignore for now.  */
1328
67.9k
    break;
1329
166k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
166k
      if (unhandled != NULL)
1333
17.7k
  {
1334
17.7k
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
17.7k
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
17.7k
       abfd, name, unhandled, flag);
1338
17.7k
    result = false;
1339
17.7k
  }
1340
166k
    }
1341
1342
43.0k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
43.0k
      && (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
43.0k
  if (flags_ptr)
1359
43.0k
    * flags_ptr = sec_flags;
1360
1361
43.0k
  return result;
1362
43.0k
}
pei-arm.c:styp_to_sec_flags
Line
Count
Source
1191
596k
{
1192
596k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
596k
  unsigned long styp_flags = internal_s->s_flags;
1194
596k
  flagword sec_flags;
1195
596k
  bool result = true;
1196
596k
  bool is_dbg = false;
1197
1198
596k
  if (startswith (name, DOT_DEBUG)
1199
596k
      || startswith (name, DOT_ZDEBUG)
1200
596k
#ifdef COFF_LONG_SECTION_NAMES
1201
596k
      || startswith (name, GNU_LINKONCE_WI)
1202
596k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
596k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
596k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
596k
      || startswith (name, GNU_DEBUGLINK)
1207
596k
      || startswith (name, GNU_DEBUGALTLINK)
1208
596k
#endif
1209
596k
      || startswith (name, ".stab"))
1210
506
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
596k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
596k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
584k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
1.24M
  while (styp_flags)
1220
648k
    {
1221
648k
      unsigned long flag = styp_flags & - styp_flags;
1222
648k
      char * unhandled = NULL;
1223
1224
648k
      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
648k
      switch (flag)
1231
648k
  {
1232
2.02k
  case STYP_DSECT:
1233
2.02k
    unhandled = "STYP_DSECT";
1234
2.02k
    break;
1235
2.46k
  case STYP_GROUP:
1236
2.46k
    unhandled = "STYP_GROUP";
1237
2.46k
    break;
1238
2.50k
  case STYP_COPY:
1239
2.50k
    unhandled = "STYP_COPY";
1240
2.50k
    break;
1241
2.95k
  case STYP_OVER:
1242
2.95k
    unhandled = "STYP_OVER";
1243
2.95k
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
3.34k
  case STYP_NOLOAD:
1246
3.34k
    sec_flags |= SEC_NEVER_LOAD;
1247
3.34k
    break;
1248
0
#endif
1249
11.8k
  case IMAGE_SCN_MEM_READ:
1250
11.8k
    sec_flags &= ~SEC_COFF_NOREAD;
1251
11.8k
    break;
1252
56.9k
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
56.9k
    break;
1255
4.43k
  case IMAGE_SCN_LNK_OTHER:
1256
4.43k
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
4.43k
    break;
1258
2.46k
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
2.46k
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
2.46k
    break;
1261
59.9k
  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
59.9k
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
59.9k
        " %s in section %s"),
1268
59.9k
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
59.9k
    break;
1270
14.3k
  case IMAGE_SCN_MEM_EXECUTE:
1271
14.3k
    sec_flags |= SEC_CODE;
1272
14.3k
    break;
1273
59.8k
  case IMAGE_SCN_MEM_WRITE:
1274
59.8k
    sec_flags &= ~ SEC_READONLY;
1275
59.8k
    break;
1276
6.78k
  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.78k
       if (is_dbg
1283
6.78k
#ifdef _COMMENT
1284
6.78k
        || strcmp (name, _COMMENT) == 0
1285
6.78k
#endif
1286
6.78k
        )
1287
492
      {
1288
492
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
492
      }
1290
6.78k
    break;
1291
6.98k
  case IMAGE_SCN_MEM_SHARED:
1292
6.98k
    sec_flags |= SEC_COFF_SHARED;
1293
6.98k
    break;
1294
57.5k
  case IMAGE_SCN_LNK_REMOVE:
1295
57.5k
    if (!is_dbg)
1296
57.0k
      sec_flags |= SEC_EXCLUDE;
1297
57.5k
    break;
1298
12.8k
  case IMAGE_SCN_CNT_CODE:
1299
12.8k
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
12.8k
    break;
1301
10.3k
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
10.3k
    if (is_dbg)
1303
482
      sec_flags |= SEC_DEBUGGING;
1304
9.86k
    else
1305
9.86k
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
10.3k
    break;
1307
57.3k
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
57.3k
    sec_flags |= SEC_ALLOC;
1309
57.3k
    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
6.96k
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
6.96k
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
16
      result = false;
1325
6.96k
    break;
1326
260k
  default:
1327
    /* Silently ignore for now.  */
1328
260k
    break;
1329
648k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
648k
      if (unhandled != NULL)
1333
16.8k
  {
1334
16.8k
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
16.8k
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
16.8k
       abfd, name, unhandled, flag);
1338
16.8k
    result = false;
1339
16.8k
  }
1340
648k
    }
1341
1342
596k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
596k
      && (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
596k
  if (flags_ptr)
1359
596k
    * flags_ptr = sec_flags;
1360
1361
596k
  return result;
1362
596k
}
pei-mcore.c:styp_to_sec_flags
Line
Count
Source
1191
52.9k
{
1192
52.9k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
52.9k
  unsigned long styp_flags = internal_s->s_flags;
1194
52.9k
  flagword sec_flags;
1195
52.9k
  bool result = true;
1196
52.9k
  bool is_dbg = false;
1197
1198
52.9k
  if (startswith (name, DOT_DEBUG)
1199
52.9k
      || startswith (name, DOT_ZDEBUG)
1200
52.9k
#ifdef COFF_LONG_SECTION_NAMES
1201
52.9k
      || startswith (name, GNU_LINKONCE_WI)
1202
52.9k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
52.9k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
52.9k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
52.9k
      || startswith (name, GNU_DEBUGLINK)
1207
52.9k
      || startswith (name, GNU_DEBUGALTLINK)
1208
52.9k
#endif
1209
52.9k
      || startswith (name, ".stab"))
1210
28
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
52.9k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
52.9k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
50.0k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
133k
  while (styp_flags)
1220
80.7k
    {
1221
80.7k
      unsigned long flag = styp_flags & - styp_flags;
1222
80.7k
      char * unhandled = NULL;
1223
1224
80.7k
      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
80.7k
      switch (flag)
1231
80.7k
  {
1232
2.46k
  case STYP_DSECT:
1233
2.46k
    unhandled = "STYP_DSECT";
1234
2.46k
    break;
1235
1.96k
  case STYP_GROUP:
1236
1.96k
    unhandled = "STYP_GROUP";
1237
1.96k
    break;
1238
2.46k
  case STYP_COPY:
1239
2.46k
    unhandled = "STYP_COPY";
1240
2.46k
    break;
1241
1.97k
  case STYP_OVER:
1242
1.97k
    unhandled = "STYP_OVER";
1243
1.97k
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
2.80k
  case STYP_NOLOAD:
1246
2.80k
    sec_flags |= SEC_NEVER_LOAD;
1247
2.80k
    break;
1248
0
#endif
1249
2.86k
  case IMAGE_SCN_MEM_READ:
1250
2.86k
    sec_flags &= ~SEC_COFF_NOREAD;
1251
2.86k
    break;
1252
4.22k
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
4.22k
    break;
1255
1.50k
  case IMAGE_SCN_LNK_OTHER:
1256
1.50k
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
1.50k
    break;
1258
532
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
532
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
532
    break;
1261
3.49k
  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.49k
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
3.49k
        " %s in section %s"),
1268
3.49k
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
3.49k
    break;
1270
2.68k
  case IMAGE_SCN_MEM_EXECUTE:
1271
2.68k
    sec_flags |= SEC_CODE;
1272
2.68k
    break;
1273
3.27k
  case IMAGE_SCN_MEM_WRITE:
1274
3.27k
    sec_flags &= ~ SEC_READONLY;
1275
3.27k
    break;
1276
2.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
2.03k
       if (is_dbg
1283
2.03k
#ifdef _COMMENT
1284
2.03k
        || strcmp (name, _COMMENT) == 0
1285
2.03k
#endif
1286
2.03k
        )
1287
26
      {
1288
26
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
26
      }
1290
2.03k
    break;
1291
4.00k
  case IMAGE_SCN_MEM_SHARED:
1292
4.00k
    sec_flags |= SEC_COFF_SHARED;
1293
4.00k
    break;
1294
2.43k
  case IMAGE_SCN_LNK_REMOVE:
1295
2.43k
    if (!is_dbg)
1296
2.43k
      sec_flags |= SEC_EXCLUDE;
1297
2.43k
    break;
1298
2.59k
  case IMAGE_SCN_CNT_CODE:
1299
2.59k
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
2.59k
    break;
1301
2.26k
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
2.26k
    if (is_dbg)
1303
16
      sec_flags |= SEC_DEBUGGING;
1304
2.25k
    else
1305
2.25k
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
2.26k
    break;
1307
2.62k
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
2.62k
    sec_flags |= SEC_ALLOC;
1309
2.62k
    break;
1310
3.43k
  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.43k
#ifdef COFF_PAGE_SIZE
1318
3.43k
    sec_flags |= SEC_DEBUGGING;
1319
3.43k
#endif
1320
3.43k
    break;
1321
3.05k
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
3.05k
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
10
      result = false;
1325
3.05k
    break;
1326
28.0k
  default:
1327
    /* Silently ignore for now.  */
1328
28.0k
    break;
1329
80.7k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
80.7k
      if (unhandled != NULL)
1333
10.9k
  {
1334
10.9k
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
10.9k
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
10.9k
       abfd, name, unhandled, flag);
1338
10.9k
    result = false;
1339
10.9k
  }
1340
80.7k
    }
1341
1342
52.9k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
52.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
52.9k
  if (flags_ptr)
1359
52.9k
    * flags_ptr = sec_flags;
1360
1361
52.9k
  return result;
1362
52.9k
}
pei-sh.c:styp_to_sec_flags
Line
Count
Source
1191
48.6k
{
1192
48.6k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
48.6k
  unsigned long styp_flags = internal_s->s_flags;
1194
48.6k
  flagword sec_flags;
1195
48.6k
  bool result = true;
1196
48.6k
  bool is_dbg = false;
1197
1198
48.6k
  if (startswith (name, DOT_DEBUG)
1199
48.6k
      || startswith (name, DOT_ZDEBUG)
1200
48.6k
#ifdef COFF_LONG_SECTION_NAMES
1201
48.6k
      || startswith (name, GNU_LINKONCE_WI)
1202
48.6k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
48.6k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
48.6k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
48.6k
      || startswith (name, GNU_DEBUGLINK)
1207
48.6k
      || startswith (name, GNU_DEBUGALTLINK)
1208
48.6k
#endif
1209
48.6k
      || startswith (name, ".stab"))
1210
536
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
48.6k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
48.6k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
47.0k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
146k
  while (styp_flags)
1220
97.7k
    {
1221
97.7k
      unsigned long flag = styp_flags & - styp_flags;
1222
97.7k
      char * unhandled = NULL;
1223
1224
97.7k
      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
97.7k
      switch (flag)
1231
97.7k
  {
1232
1.04k
  case STYP_DSECT:
1233
1.04k
    unhandled = "STYP_DSECT";
1234
1.04k
    break;
1235
1.97k
  case STYP_GROUP:
1236
1.97k
    unhandled = "STYP_GROUP";
1237
1.97k
    break;
1238
1.51k
  case STYP_COPY:
1239
1.51k
    unhandled = "STYP_COPY";
1240
1.51k
    break;
1241
1.52k
  case STYP_OVER:
1242
1.52k
    unhandled = "STYP_OVER";
1243
1.52k
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
5.05k
  case STYP_NOLOAD:
1246
5.05k
    sec_flags |= SEC_NEVER_LOAD;
1247
5.05k
    break;
1248
0
#endif
1249
1.61k
  case IMAGE_SCN_MEM_READ:
1250
1.61k
    sec_flags &= ~SEC_COFF_NOREAD;
1251
1.61k
    break;
1252
4.49k
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
4.49k
    break;
1255
1.53k
  case IMAGE_SCN_LNK_OTHER:
1256
1.53k
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
1.53k
    break;
1258
1.02k
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
1.02k
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
1.02k
    break;
1261
5.54k
  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.54k
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
5.54k
        " %s in section %s"),
1268
5.54k
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
5.54k
    break;
1270
2.66k
  case IMAGE_SCN_MEM_EXECUTE:
1271
2.66k
    sec_flags |= SEC_CODE;
1272
2.66k
    break;
1273
4.46k
  case IMAGE_SCN_MEM_WRITE:
1274
4.46k
    sec_flags &= ~ SEC_READONLY;
1275
4.46k
    break;
1276
5.10k
  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.10k
       if (is_dbg
1283
5.10k
#ifdef _COMMENT
1284
5.10k
        || strcmp (name, _COMMENT) == 0
1285
5.10k
#endif
1286
5.10k
        )
1287
40
      {
1288
40
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
40
      }
1290
5.10k
    break;
1291
3.52k
  case IMAGE_SCN_MEM_SHARED:
1292
3.52k
    sec_flags |= SEC_COFF_SHARED;
1293
3.52k
    break;
1294
4.57k
  case IMAGE_SCN_LNK_REMOVE:
1295
4.57k
    if (!is_dbg)
1296
4.56k
      sec_flags |= SEC_EXCLUDE;
1297
4.57k
    break;
1298
2.12k
  case IMAGE_SCN_CNT_CODE:
1299
2.12k
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
2.12k
    break;
1301
2.56k
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
2.56k
    if (is_dbg)
1303
38
      sec_flags |= SEC_DEBUGGING;
1304
2.52k
    else
1305
2.52k
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
2.56k
    break;
1307
3.47k
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
3.47k
    sec_flags |= SEC_ALLOC;
1309
3.47k
    break;
1310
6.11k
  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.11k
#ifdef COFF_PAGE_SIZE
1318
6.11k
    sec_flags |= SEC_DEBUGGING;
1319
6.11k
#endif
1320
6.11k
    break;
1321
3.60k
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
3.60k
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
4
      result = false;
1325
3.60k
    break;
1326
34.1k
  default:
1327
    /* Silently ignore for now.  */
1328
34.1k
    break;
1329
97.7k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
97.7k
      if (unhandled != NULL)
1333
8.61k
  {
1334
8.61k
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
8.61k
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
8.61k
       abfd, name, unhandled, flag);
1338
8.61k
    result = false;
1339
8.61k
  }
1340
97.7k
    }
1341
1342
48.6k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
48.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
48.6k
  if (flags_ptr)
1359
48.6k
    * flags_ptr = sec_flags;
1360
1361
48.6k
  return result;
1362
48.6k
}
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
3.59M
{
1687
3.59M
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
3.59M
  if (BADMAG (*internal_f))
1690
3.47M
    return false;
1691
1692
117k
  return true;
1693
3.59M
}
pei-i386.c:coff_bad_format_hook
Line
Count
Source
1686
73.9k
{
1687
73.9k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
73.9k
  if (BADMAG (*internal_f))
1690
67.7k
    return false;
1691
1692
6.19k
  return true;
1693
73.9k
}
pe-x86_64.c:coff_bad_format_hook
Line
Count
Source
1686
226k
{
1687
226k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
226k
  if (BADMAG (*internal_f))
1690
225k
    return false;
1691
1692
832
  return true;
1693
226k
}
pei-x86_64.c:coff_bad_format_hook
Line
Count
Source
1686
73.9k
{
1687
73.9k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
73.9k
  if (BADMAG (*internal_f))
1690
73.4k
    return false;
1691
1692
518
  return true;
1693
73.9k
}
coff-x86_64.c:coff_bad_format_hook
Line
Count
Source
1686
114k
{
1687
114k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
114k
  if (BADMAG (*internal_f))
1690
113k
    return false;
1691
1692
562
  return true;
1693
114k
}
Unexecuted instantiation: coff64-rs6000.c:coff_bad_format_hook
pe-aarch64.c:coff_bad_format_hook
Line
Count
Source
1686
114k
{
1687
114k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
114k
  if (BADMAG (*internal_f))
1690
112k
    return false;
1691
1692
1.24k
  return true;
1693
114k
}
pei-aarch64.c:coff_bad_format_hook
Line
Count
Source
1686
73.8k
{
1687
73.8k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
73.8k
  if (BADMAG (*internal_f))
1690
65.8k
    return false;
1691
1692
8.04k
  return true;
1693
73.8k
}
pei-ia64.c:coff_bad_format_hook
Line
Count
Source
1686
71.9k
{
1687
71.9k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
71.9k
  if (BADMAG (*internal_f))
1690
56.0k
    return false;
1691
1692
15.8k
  return true;
1693
71.9k
}
pei-loongarch64.c:coff_bad_format_hook
Line
Count
Source
1686
73.8k
{
1687
73.8k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
73.8k
  if (BADMAG (*internal_f))
1690
73.4k
    return false;
1691
1692
392
  return true;
1693
73.8k
}
cf-i386lynx.c:coff_bad_format_hook
Line
Count
Source
1686
114k
{
1687
114k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
114k
  if (BADMAG (*internal_f))
1690
112k
    return false;
1691
1692
1.07k
  return true;
1693
114k
}
coff-go32.c:coff_bad_format_hook
Line
Count
Source
1686
114k
{
1687
114k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
114k
  if (BADMAG (*internal_f))
1690
112k
    return false;
1691
1692
1.07k
  return true;
1693
114k
}
coff-i386.c:coff_bad_format_hook
Line
Count
Source
1686
114k
{
1687
114k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
114k
  if (BADMAG (*internal_f))
1690
112k
    return false;
1691
1692
1.07k
  return true;
1693
114k
}
coff-rs6000.c:coff_bad_format_hook
Line
Count
Source
1686
114k
{
1687
114k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
114k
  if (BADMAG (*internal_f))
1690
113k
    return false;
1691
1692
378
  return true;
1693
114k
}
coff-sh.c:coff_bad_format_hook
Line
Count
Source
1686
427k
{
1687
427k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
427k
  if (BADMAG (*internal_f))
1690
421k
    return false;
1691
1692
6.36k
  return true;
1693
427k
}
Unexecuted instantiation: coff-stgo32.c:coff_bad_format_hook
coff-tic30.c:coff_bad_format_hook
Line
Count
Source
1686
114k
{
1687
114k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
114k
  if (BADMAG (*internal_f))
1690
113k
    return false;
1691
1692
250
  return true;
1693
114k
}
Unexecuted instantiation: coff-tic4x.c:coff_bad_format_hook
coff-tic54x.c:coff_bad_format_hook
Line
Count
Source
1686
228k
{
1687
228k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
228k
  if (BADMAG (*internal_f))
1690
227k
    return false;
1691
1692
4
  return true;
1693
228k
}
coff-z80.c:coff_bad_format_hook
Line
Count
Source
1686
114k
{
1687
114k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
114k
  if (BADMAG (*internal_f))
1690
113k
    return false;
1691
1692
256
  return true;
1693
114k
}
coff-z8k.c:coff_bad_format_hook
Line
Count
Source
1686
114k
{
1687
114k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
114k
  if (BADMAG (*internal_f))
1690
113k
    return false;
1691
1692
268
  return true;
1693
114k
}
pe-arm-wince.c:coff_bad_format_hook
Line
Count
Source
1686
228k
{
1687
228k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
228k
  if (BADMAG (*internal_f))
1690
227k
    return false;
1691
1692
346
  return true;
1693
228k
}
pe-arm.c:coff_bad_format_hook
Line
Count
Source
1686
228k
{
1687
228k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
228k
  if (BADMAG (*internal_f))
1690
227k
    return false;
1691
1692
346
  return true;
1693
228k
}
pe-i386.c:coff_bad_format_hook
Line
Count
Source
1686
226k
{
1687
226k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
226k
  if (BADMAG (*internal_f))
1690
225k
    return false;
1691
1692
1.12k
  return true;
1693
226k
}
pe-mcore.c:coff_bad_format_hook
Line
Count
Source
1686
228k
{
1687
228k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
228k
  if (BADMAG (*internal_f))
1690
224k
    return false;
1691
1692
3.96k
  return true;
1693
228k
}
pe-sh.c:coff_bad_format_hook
Line
Count
Source
1686
114k
{
1687
114k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
114k
  if (BADMAG (*internal_f))
1690
110k
    return false;
1691
1692
3.39k
  return true;
1693
114k
}
pei-arm-wince.c:coff_bad_format_hook
Line
Count
Source
1686
73.8k
{
1687
73.8k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
73.8k
  if (BADMAG (*internal_f))
1690
52.6k
    return false;
1691
1692
21.2k
  return true;
1693
73.8k
}
pei-arm.c:coff_bad_format_hook
Line
Count
Source
1686
73.8k
{
1687
73.8k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
73.8k
  if (BADMAG (*internal_f))
1690
52.6k
    return false;
1691
1692
21.2k
  return true;
1693
73.8k
}
pei-mcore.c:coff_bad_format_hook
Line
Count
Source
1686
73.8k
{
1687
73.8k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
73.8k
  if (BADMAG (*internal_f))
1690
63.4k
    return false;
1691
1692
10.4k
  return true;
1693
73.8k
}
pei-sh.c:coff_bad_format_hook
Line
Count
Source
1686
73.8k
{
1687
73.8k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
73.8k
  if (BADMAG (*internal_f))
1690
62.4k
    return false;
1691
1692
11.4k
  return true;
1693
73.8k
}
1694
1695
#ifdef TICOFF
1696
static bool
1697
ticoff0_bad_format_hook (bfd *abfd ATTRIBUTE_UNUSED, void * filehdr)
1698
228k
{
1699
228k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1700
1701
228k
  if (COFF0_BADMAG (*internal_f))
1702
227k
    return false;
1703
1704
506
  return true;
1705
228k
}
Unexecuted instantiation: coff-tic4x.c:ticoff0_bad_format_hook
coff-tic54x.c:ticoff0_bad_format_hook
Line
Count
Source
1698
228k
{
1699
228k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1700
1701
228k
  if (COFF0_BADMAG (*internal_f))
1702
227k
    return false;
1703
1704
506
  return true;
1705
228k
}
1706
#endif
1707
1708
#ifdef TICOFF
1709
static bool
1710
ticoff1_bad_format_hook (bfd *abfd ATTRIBUTE_UNUSED, void * filehdr)
1711
228k
{
1712
228k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1713
1714
228k
  if (COFF1_BADMAG (*internal_f))
1715
227k
    return false;
1716
1717
10
  return true;
1718
228k
}
Unexecuted instantiation: coff-tic4x.c:ticoff1_bad_format_hook
coff-tic54x.c:ticoff1_bad_format_hook
Line
Count
Source
1711
228k
{
1712
228k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1713
1714
228k
  if (COFF1_BADMAG (*internal_f))
1715
227k
    return false;
1716
1717
10
  return true;
1718
228k
}
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
2.09M
{
1730
2.09M
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
2.09M
  unsigned int i;
1732
1733
18.6M
  for (i = 0; i < table_size; ++i)
1734
16.5M
    {
1735
16.5M
      const char *secname = bfd_section_name (section);
1736
1737
16.5M
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
16.5M
    ? strcmp (alignment_table[i].name, secname) == 0
1739
16.5M
    : strncmp (alignment_table[i].name, secname,
1740
8.84M
         alignment_table[i].comparison_length) == 0)
1741
5.66k
  break;
1742
16.5M
    }
1743
2.09M
  if (i >= table_size)
1744
2.08M
    return;
1745
1746
5.66k
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
5.66k
      && default_alignment < alignment_table[i].default_alignment_min)
1748
1.66k
    return;
1749
1750
4.00k
  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
4.00k
      )
1755
0
    return;
1756
1757
4.00k
  section->alignment_power = alignment_table[i].alignment_power;
1758
4.00k
}
pei-i386.c:coff_set_custom_section_alignment
Line
Count
Source
1729
11.1k
{
1730
11.1k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
11.1k
  unsigned int i;
1732
1733
99.4k
  for (i = 0; i < table_size; ++i)
1734
88.4k
    {
1735
88.4k
      const char *secname = bfd_section_name (section);
1736
1737
88.4k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
88.4k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
88.4k
    : strncmp (alignment_table[i].name, secname,
1740
55.3k
         alignment_table[i].comparison_length) == 0)
1741
132
  break;
1742
88.4k
    }
1743
11.1k
  if (i >= table_size)
1744
10.9k
    return;
1745
1746
132
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
132
      && default_alignment < alignment_table[i].default_alignment_min)
1748
60
    return;
1749
1750
72
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
72
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
72
      && default_alignment > alignment_table[i].default_alignment_max
1753
72
#endif
1754
72
      )
1755
0
    return;
1756
1757
72
  section->alignment_power = alignment_table[i].alignment_power;
1758
72
}
pe-x86_64.c:coff_set_custom_section_alignment
Line
Count
Source
1729
88.2k
{
1730
88.2k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
88.2k
  unsigned int i;
1732
1733
1.23M
  for (i = 0; i < table_size; ++i)
1734
1.14M
    {
1735
1.14M
      const char *secname = bfd_section_name (section);
1736
1737
1.14M
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
1.14M
    ? strcmp (alignment_table[i].name, secname) == 0
1739
1.14M
    : strncmp (alignment_table[i].name, secname,
1740
793k
         alignment_table[i].comparison_length) == 0)
1741
148
  break;
1742
1.14M
    }
1743
88.2k
  if (i >= table_size)
1744
88.0k
    return;
1745
1746
148
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
148
      && default_alignment < alignment_table[i].default_alignment_min)
1748
22
    return;
1749
1750
126
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
126
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
126
      && default_alignment > alignment_table[i].default_alignment_max
1753
126
#endif
1754
126
      )
1755
0
    return;
1756
1757
126
  section->alignment_power = alignment_table[i].alignment_power;
1758
126
}
pei-x86_64.c:coff_set_custom_section_alignment
Line
Count
Source
1729
3.09k
{
1730
3.09k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
3.09k
  unsigned int i;
1732
1733
39.1k
  for (i = 0; i < table_size; ++i)
1734
36.1k
    {
1735
36.1k
      const char *secname = bfd_section_name (section);
1736
1737
36.1k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
36.1k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
36.1k
    : strncmp (alignment_table[i].name, secname,
1740
24.1k
         alignment_table[i].comparison_length) == 0)
1741
134
  break;
1742
36.1k
    }
1743
3.09k
  if (i >= table_size)
1744
2.96k
    return;
1745
1746
134
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
134
      && default_alignment < alignment_table[i].default_alignment_min)
1748
10
    return;
1749
1750
124
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
124
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
124
      && default_alignment > alignment_table[i].default_alignment_max
1753
124
#endif
1754
124
      )
1755
0
    return;
1756
1757
124
  section->alignment_power = alignment_table[i].alignment_power;
1758
124
}
coff-x86_64.c:coff_set_custom_section_alignment
Line
Count
Source
1729
371k
{
1730
371k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
371k
  unsigned int i;
1732
1733
1.85M
  for (i = 0; i < table_size; ++i)
1734
1.48M
    {
1735
1.48M
      const char *secname = bfd_section_name (section);
1736
1737
1.48M
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
1.48M
    ? strcmp (alignment_table[i].name, secname) == 0
1739
1.48M
    : strncmp (alignment_table[i].name, secname,
1740
742k
         alignment_table[i].comparison_length) == 0)
1741
64
  break;
1742
1.48M
    }
1743
371k
  if (i >= table_size)
1744
371k
    return;
1745
1746
64
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
64
      && default_alignment < alignment_table[i].default_alignment_min)
1748
24
    return;
1749
1750
40
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
40
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
40
      && default_alignment > alignment_table[i].default_alignment_max
1753
40
#endif
1754
40
      )
1755
0
    return;
1756
1757
40
  section->alignment_power = alignment_table[i].alignment_power;
1758
40
}
coff64-rs6000.c:coff_set_custom_section_alignment
Line
Count
Source
1729
70.8k
{
1730
70.8k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
70.8k
  unsigned int i;
1732
1733
354k
  for (i = 0; i < table_size; ++i)
1734
283k
    {
1735
283k
      const char *secname = bfd_section_name (section);
1736
1737
283k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
283k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
283k
    : strncmp (alignment_table[i].name, secname,
1740
141k
         alignment_table[i].comparison_length) == 0)
1741
18
  break;
1742
283k
    }
1743
70.8k
  if (i >= table_size)
1744
70.8k
    return;
1745
1746
18
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
18
      && default_alignment < alignment_table[i].default_alignment_min)
1748
0
    return;
1749
1750
18
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
18
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
18
      && default_alignment > alignment_table[i].default_alignment_max
1753
18
#endif
1754
18
      )
1755
0
    return;
1756
1757
18
  section->alignment_power = alignment_table[i].alignment_power;
1758
18
}
pe-aarch64.c:coff_set_custom_section_alignment
Line
Count
Source
1729
4.30k
{
1730
4.30k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
4.30k
  unsigned int i;
1732
1733
55.6k
  for (i = 0; i < table_size; ++i)
1734
51.3k
    {
1735
51.3k
      const char *secname = bfd_section_name (section);
1736
1737
51.3k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
51.3k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
51.3k
    : strncmp (alignment_table[i].name, secname,
1740
21.3k
         alignment_table[i].comparison_length) == 0)
1741
50
  break;
1742
51.3k
    }
1743
4.30k
  if (i >= table_size)
1744
4.25k
    return;
1745
1746
50
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
50
      && default_alignment < alignment_table[i].default_alignment_min)
1748
10
    return;
1749
1750
40
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
40
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
40
      && default_alignment > alignment_table[i].default_alignment_max
1753
40
#endif
1754
40
      )
1755
0
    return;
1756
1757
40
  section->alignment_power = alignment_table[i].alignment_power;
1758
40
}
pei-aarch64.c:coff_set_custom_section_alignment
Line
Count
Source
1729
14.7k
{
1730
14.7k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
14.7k
  unsigned int i;
1732
1733
191k
  for (i = 0; i < table_size; ++i)
1734
176k
    {
1735
176k
      const char *secname = bfd_section_name (section);
1736
1737
176k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
176k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
176k
    : strncmp (alignment_table[i].name, secname,
1740
73.5k
         alignment_table[i].comparison_length) == 0)
1741
78
  break;
1742
176k
    }
1743
14.7k
  if (i >= table_size)
1744
14.6k
    return;
1745
1746
78
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
78
      && default_alignment < alignment_table[i].default_alignment_min)
1748
20
    return;
1749
1750
58
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
58
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
58
      && default_alignment > alignment_table[i].default_alignment_max
1753
58
#endif
1754
58
      )
1755
0
    return;
1756
1757
58
  section->alignment_power = alignment_table[i].alignment_power;
1758
58
}
pei-ia64.c:coff_set_custom_section_alignment
Line
Count
Source
1729
73.0k
{
1730
73.0k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
73.0k
  unsigned int i;
1732
1733
364k
  for (i = 0; i < table_size; ++i)
1734
291k
    {
1735
291k
      const char *secname = bfd_section_name (section);
1736
1737
291k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
291k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
291k
    : strncmp (alignment_table[i].name, secname,
1740
146k
         alignment_table[i].comparison_length) == 0)
1741
488
  break;
1742
291k
    }
1743
73.0k
  if (i >= table_size)
1744
72.5k
    return;
1745
1746
488
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
488
      && default_alignment < alignment_table[i].default_alignment_min)
1748
488
    return;
1749
1750
0
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
0
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
0
      && default_alignment > alignment_table[i].default_alignment_max
1753
0
#endif
1754
0
      )
1755
0
    return;
1756
1757
0
  section->alignment_power = alignment_table[i].alignment_power;
1758
0
}
pei-loongarch64.c:coff_set_custom_section_alignment
Line
Count
Source
1729
2.11k
{
1730
2.11k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
2.11k
  unsigned int i;
1732
1733
26.9k
  for (i = 0; i < table_size; ++i)
1734
24.9k
    {
1735
24.9k
      const char *secname = bfd_section_name (section);
1736
1737
24.9k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
24.9k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
24.9k
    : strncmp (alignment_table[i].name, secname,
1740
10.3k
         alignment_table[i].comparison_length) == 0)
1741
90
  break;
1742
24.9k
    }
1743
2.11k
  if (i >= table_size)
1744
2.02k
    return;
1745
1746
90
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
90
      && default_alignment < alignment_table[i].default_alignment_min)
1748
30
    return;
1749
1750
60
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
60
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
60
      && default_alignment > alignment_table[i].default_alignment_max
1753
60
#endif
1754
60
      )
1755
0
    return;
1756
1757
60
  section->alignment_power = alignment_table[i].alignment_power;
1758
60
}
cf-i386lynx.c:coff_set_custom_section_alignment
Line
Count
Source
1729
187k
{
1730
187k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
187k
  unsigned int i;
1732
1733
935k
  for (i = 0; i < table_size; ++i)
1734
748k
    {
1735
748k
      const char *secname = bfd_section_name (section);
1736
1737
748k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
748k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
748k
    : strncmp (alignment_table[i].name, secname,
1740
374k
         alignment_table[i].comparison_length) == 0)
1741
96
  break;
1742
748k
    }
1743
187k
  if (i >= table_size)
1744
187k
    return;
1745
1746
96
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
96
      && default_alignment < alignment_table[i].default_alignment_min)
1748
52
    return;
1749
1750
44
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
44
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
44
      && default_alignment > alignment_table[i].default_alignment_max
1753
44
#endif
1754
44
      )
1755
0
    return;
1756
1757
44
  section->alignment_power = alignment_table[i].alignment_power;
1758
44
}
coff-go32.c:coff_set_custom_section_alignment
Line
Count
Source
1729
180k
{
1730
180k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
180k
  unsigned int i;
1732
1733
2.89M
  for (i = 0; i < table_size; ++i)
1734
2.71M
    {
1735
2.71M
      const char *secname = bfd_section_name (section);
1736
1737
2.71M
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
2.71M
    ? strcmp (alignment_table[i].name, secname) == 0
1739
2.71M
    : strncmp (alignment_table[i].name, secname,
1740
2.35M
         alignment_table[i].comparison_length) == 0)
1741
136
  break;
1742
2.71M
    }
1743
180k
  if (i >= table_size)
1744
180k
    return;
1745
1746
136
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
136
      && default_alignment < alignment_table[i].default_alignment_min)
1748
52
    return;
1749
1750
84
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
84
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
84
      && default_alignment > alignment_table[i].default_alignment_max
1753
84
#endif
1754
84
      )
1755
0
    return;
1756
1757
84
  section->alignment_power = alignment_table[i].alignment_power;
1758
84
}
coff-i386.c:coff_set_custom_section_alignment
Line
Count
Source
1729
187k
{
1730
187k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
187k
  unsigned int i;
1732
1733
935k
  for (i = 0; i < table_size; ++i)
1734
748k
    {
1735
748k
      const char *secname = bfd_section_name (section);
1736
1737
748k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
748k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
748k
    : strncmp (alignment_table[i].name, secname,
1740
374k
         alignment_table[i].comparison_length) == 0)
1741
96
  break;
1742
748k
    }
1743
187k
  if (i >= table_size)
1744
187k
    return;
1745
1746
96
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
96
      && default_alignment < alignment_table[i].default_alignment_min)
1748
52
    return;
1749
1750
44
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
44
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
44
      && default_alignment > alignment_table[i].default_alignment_max
1753
44
#endif
1754
44
      )
1755
0
    return;
1756
1757
44
  section->alignment_power = alignment_table[i].alignment_power;
1758
44
}
coff-rs6000.c:coff_set_custom_section_alignment
Line
Count
Source
1729
28.5k
{
1730
28.5k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
28.5k
  unsigned int i;
1732
1733
142k
  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.0k
         alignment_table[i].comparison_length) == 0)
1741
28
  break;
1742
114k
    }
1743
28.5k
  if (i >= table_size)
1744
28.5k
    return;
1745
1746
28
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
28
      && default_alignment < alignment_table[i].default_alignment_min)
1748
0
    return;
1749
1750
28
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
28
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
28
      && default_alignment > alignment_table[i].default_alignment_max
1753
28
#endif
1754
28
      )
1755
0
    return;
1756
1757
28
  section->alignment_power = alignment_table[i].alignment_power;
1758
28
}
coff-sh.c:coff_set_custom_section_alignment
Line
Count
Source
1729
10.2k
{
1730
10.2k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
10.2k
  unsigned int i;
1732
1733
51.1k
  for (i = 0; i < table_size; ++i)
1734
40.9k
    {
1735
40.9k
      const char *secname = bfd_section_name (section);
1736
1737
40.9k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
40.9k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
40.9k
    : strncmp (alignment_table[i].name, secname,
1740
20.5k
         alignment_table[i].comparison_length) == 0)
1741
34
  break;
1742
40.9k
    }
1743
10.2k
  if (i >= table_size)
1744
10.2k
    return;
1745
1746
34
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
34
      && default_alignment < alignment_table[i].default_alignment_min)
1748
0
    return;
1749
1750
34
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
34
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
34
      && default_alignment > alignment_table[i].default_alignment_max
1753
34
#endif
1754
34
      )
1755
0
    return;
1756
1757
34
  section->alignment_power = alignment_table[i].alignment_power;
1758
34
}
Unexecuted instantiation: coff-stgo32.c:coff_set_custom_section_alignment
coff-tic30.c:coff_set_custom_section_alignment
Line
Count
Source
1729
6.64k
{
1730
6.64k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
6.64k
  unsigned int i;
1732
1733
32.5k
  for (i = 0; i < table_size; ++i)
1734
26.1k
    {
1735
26.1k
      const char *secname = bfd_section_name (section);
1736
1737
26.1k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
26.1k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
26.1k
    : strncmp (alignment_table[i].name, secname,
1740
13.1k
         alignment_table[i].comparison_length) == 0)
1741
170
  break;
1742
26.1k
    }
1743
6.64k
  if (i >= table_size)
1744
6.47k
    return;
1745
1746
170
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
170
      && default_alignment < alignment_table[i].default_alignment_min)
1748
44
    return;
1749
1750
126
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
126
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
126
      && default_alignment > alignment_table[i].default_alignment_max
1753
126
#endif
1754
126
      )
1755
0
    return;
1756
1757
126
  section->alignment_power = alignment_table[i].alignment_power;
1758
126
}
Unexecuted instantiation: coff-tic4x.c:coff_set_custom_section_alignment
coff-tic54x.c:coff_set_custom_section_alignment
Line
Count
Source
1729
8.78k
{
1730
8.78k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
8.78k
  unsigned int i;
1732
1733
43.9k
  for (i = 0; i < table_size; ++i)
1734
35.1k
    {
1735
35.1k
      const char *secname = bfd_section_name (section);
1736
1737
35.1k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
35.1k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
35.1k
    : strncmp (alignment_table[i].name, secname,
1740
17.5k
         alignment_table[i].comparison_length) == 0)
1741
0
  break;
1742
35.1k
    }
1743
8.78k
  if (i >= table_size)
1744
8.78k
    return;
1745
1746
0
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
0
      && default_alignment < alignment_table[i].default_alignment_min)
1748
0
    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
54.1k
{
1730
54.1k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
54.1k
  unsigned int i;
1732
1733
270k
  for (i = 0; i < table_size; ++i)
1734
216k
    {
1735
216k
      const char *secname = bfd_section_name (section);
1736
1737
216k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
216k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
216k
    : strncmp (alignment_table[i].name, secname,
1740
108k
         alignment_table[i].comparison_length) == 0)
1741
14
  break;
1742
216k
    }
1743
54.1k
  if (i >= table_size)
1744
54.1k
    return;
1745
1746
14
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
14
      && default_alignment < alignment_table[i].default_alignment_min)
1748
14
    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
3.82k
{
1730
3.82k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
3.82k
  unsigned int i;
1732
1733
19.0k
  for (i = 0; i < table_size; ++i)
1734
15.2k
    {
1735
15.2k
      const char *secname = bfd_section_name (section);
1736
1737
15.2k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
15.2k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
15.2k
    : strncmp (alignment_table[i].name, secname,
1740
7.64k
         alignment_table[i].comparison_length) == 0)
1741
18
  break;
1742
15.2k
    }
1743
3.82k
  if (i >= table_size)
1744
3.81k
    return;
1745
1746
18
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
18
      && default_alignment < alignment_table[i].default_alignment_min)
1748
6
    return;
1749
1750
12
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
12
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
12
      && default_alignment > alignment_table[i].default_alignment_max
1753
12
#endif
1754
12
      )
1755
0
    return;
1756
1757
12
  section->alignment_power = alignment_table[i].alignment_power;
1758
12
}
pe-arm-wince.c:coff_set_custom_section_alignment
Line
Count
Source
1729
2.61k
{
1730
2.61k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
2.61k
  unsigned int i;
1732
1733
35.5k
  for (i = 0; i < table_size; ++i)
1734
33.1k
    {
1735
33.1k
      const char *secname = bfd_section_name (section);
1736
1737
33.1k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
33.1k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
33.1k
    : strncmp (alignment_table[i].name, secname,
1740
15.3k
         alignment_table[i].comparison_length) == 0)
1741
234
  break;
1742
33.1k
    }
1743
2.61k
  if (i >= table_size)
1744
2.37k
    return;
1745
1746
234
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
234
      && default_alignment < alignment_table[i].default_alignment_min)
1748
64
    return;
1749
1750
170
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
170
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
170
      && default_alignment > alignment_table[i].default_alignment_max
1753
170
#endif
1754
170
      )
1755
0
    return;
1756
1757
170
  section->alignment_power = alignment_table[i].alignment_power;
1758
170
}
pe-arm.c:coff_set_custom_section_alignment
Line
Count
Source
1729
2.61k
{
1730
2.61k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
2.61k
  unsigned int i;
1732
1733
35.5k
  for (i = 0; i < table_size; ++i)
1734
33.1k
    {
1735
33.1k
      const char *secname = bfd_section_name (section);
1736
1737
33.1k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
33.1k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
33.1k
    : strncmp (alignment_table[i].name, secname,
1740
15.3k
         alignment_table[i].comparison_length) == 0)
1741
234
  break;
1742
33.1k
    }
1743
2.61k
  if (i >= table_size)
1744
2.37k
    return;
1745
1746
234
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
234
      && default_alignment < alignment_table[i].default_alignment_min)
1748
64
    return;
1749
1750
170
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
170
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
170
      && default_alignment > alignment_table[i].default_alignment_max
1753
170
#endif
1754
170
      )
1755
0
    return;
1756
1757
170
  section->alignment_power = alignment_table[i].alignment_power;
1758
170
}
pe-i386.c:coff_set_custom_section_alignment
Line
Count
Source
1729
4.18k
{
1730
4.18k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
4.18k
  unsigned int i;
1732
1733
41.4k
  for (i = 0; i < table_size; ++i)
1734
37.3k
    {
1735
37.3k
      const char *secname = bfd_section_name (section);
1736
1737
37.3k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
37.3k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
37.3k
    : strncmp (alignment_table[i].name, secname,
1740
24.9k
         alignment_table[i].comparison_length) == 0)
1741
84
  break;
1742
37.3k
    }
1743
4.18k
  if (i >= table_size)
1744
4.09k
    return;
1745
1746
84
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
84
      && default_alignment < alignment_table[i].default_alignment_min)
1748
40
    return;
1749
1750
44
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
44
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
44
      && default_alignment > alignment_table[i].default_alignment_max
1753
44
#endif
1754
44
      )
1755
0
    return;
1756
1757
44
  section->alignment_power = alignment_table[i].alignment_power;
1758
44
}
pe-mcore.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
115k
  for (i = 0; i < table_size; ++i)
1734
92.7k
    {
1735
92.7k
      const char *secname = bfd_section_name (section);
1736
1737
92.7k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
92.7k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
92.7k
    : strncmp (alignment_table[i].name, secname,
1740
46.4k
         alignment_table[i].comparison_length) == 0)
1741
118
  break;
1742
92.7k
    }
1743
23.2k
  if (i >= table_size)
1744
23.1k
    return;
1745
1746
118
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
118
      && default_alignment < alignment_table[i].default_alignment_min)
1748
46
    return;
1749
1750
72
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
72
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
72
      && default_alignment > alignment_table[i].default_alignment_max
1753
72
#endif
1754
72
      )
1755
0
    return;
1756
1757
72
  section->alignment_power = alignment_table[i].alignment_power;
1758
72
}
pe-sh.c:coff_set_custom_section_alignment
Line
Count
Source
1729
10.4k
{
1730
10.4k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
10.4k
  unsigned int i;
1732
1733
51.9k
  for (i = 0; i < table_size; ++i)
1734
41.5k
    {
1735
41.5k
      const char *secname = bfd_section_name (section);
1736
1737
41.5k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
41.5k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
41.5k
    : strncmp (alignment_table[i].name, secname,
1740
20.8k
         alignment_table[i].comparison_length) == 0)
1741
28
  break;
1742
41.5k
    }
1743
10.4k
  if (i >= table_size)
1744
10.3k
    return;
1745
1746
28
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
28
      && default_alignment < alignment_table[i].default_alignment_min)
1748
20
    return;
1749
1750
8
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
8
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
8
      && default_alignment > alignment_table[i].default_alignment_max
1753
8
#endif
1754
8
      )
1755
0
    return;
1756
1757
8
  section->alignment_power = alignment_table[i].alignment_power;
1758
8
}
pei-arm-wince.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
543k
  for (i = 0; i < table_size; ++i)
1734
501k
    {
1735
501k
      const char *secname = bfd_section_name (section);
1736
1737
501k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
501k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
501k
    : strncmp (alignment_table[i].name, secname,
1740
208k
         alignment_table[i].comparison_length) == 0)
1741
1.55k
  break;
1742
501k
    }
1743
43.1k
  if (i >= table_size)
1744
41.6k
    return;
1745
1746
1.55k
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
1.55k
      && default_alignment < alignment_table[i].default_alignment_min)
1748
8
    return;
1749
1750
1.55k
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
1.55k
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
1.55k
      && default_alignment > alignment_table[i].default_alignment_max
1753
1.55k
#endif
1754
1.55k
      )
1755
0
    return;
1756
1757
1.55k
  section->alignment_power = alignment_table[i].alignment_power;
1758
1.55k
}
pei-arm.c:coff_set_custom_section_alignment
Line
Count
Source
1729
596k
{
1730
596k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
596k
  unsigned int i;
1732
1733
7.73M
  for (i = 0; i < table_size; ++i)
1734
7.14M
    {
1735
7.14M
      const char *secname = bfd_section_name (section);
1736
1737
7.14M
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
7.14M
    ? strcmp (alignment_table[i].name, secname) == 0
1739
7.14M
    : strncmp (alignment_table[i].name, secname,
1740
2.97M
         alignment_table[i].comparison_length) == 0)
1741
1.07k
  break;
1742
7.14M
    }
1743
596k
  if (i >= table_size)
1744
595k
    return;
1745
1746
1.07k
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
1.07k
      && default_alignment < alignment_table[i].default_alignment_min)
1748
8
    return;
1749
1750
1.06k
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
1.06k
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
1.06k
      && default_alignment > alignment_table[i].default_alignment_max
1753
1.06k
#endif
1754
1.06k
      )
1755
0
    return;
1756
1757
1.06k
  section->alignment_power = alignment_table[i].alignment_power;
1758
1.06k
}
pei-mcore.c:coff_set_custom_section_alignment
Line
Count
Source
1729
52.9k
{
1730
52.9k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
52.9k
  unsigned int i;
1732
1733
263k
  for (i = 0; i < table_size; ++i)
1734
211k
    {
1735
211k
      const char *secname = bfd_section_name (section);
1736
1737
211k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
211k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
211k
    : strncmp (alignment_table[i].name, secname,
1740
105k
         alignment_table[i].comparison_length) == 0)
1741
500
  break;
1742
211k
    }
1743
52.9k
  if (i >= table_size)
1744
52.4k
    return;
1745
1746
500
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
500
      && default_alignment < alignment_table[i].default_alignment_min)
1748
492
    return;
1749
1750
8
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
8
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
8
      && default_alignment > alignment_table[i].default_alignment_max
1753
8
#endif
1754
8
      )
1755
0
    return;
1756
1757
8
  section->alignment_power = alignment_table[i].alignment_power;
1758
8
}
pei-sh.c:coff_set_custom_section_alignment
Line
Count
Source
1729
48.7k
{
1730
48.7k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
48.7k
  unsigned int i;
1732
1733
243k
  for (i = 0; i < table_size; ++i)
1734
194k
    {
1735
194k
      const char *secname = bfd_section_name (section);
1736
1737
194k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
194k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
194k
    : strncmp (alignment_table[i].name, secname,
1740
97.5k
         alignment_table[i].comparison_length) == 0)
1741
38
  break;
1742
194k
    }
1743
48.7k
  if (i >= table_size)
1744
48.7k
    return;
1745
1746
38
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
38
      && default_alignment < alignment_table[i].default_alignment_min)
1748
36
    return;
1749
1750
2
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
2
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
2
      && default_alignment > alignment_table[i].default_alignment_max
1753
2
#endif
1754
2
      )
1755
0
    return;
1756
1757
2
  section->alignment_power = alignment_table[i].alignment_power;
1758
2
}
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
2.09M
{
1790
2.09M
  combined_entry_type *native;
1791
2.09M
  size_t amt;
1792
2.09M
  unsigned char sclass = C_STAT;
1793
1794
2.09M
  section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1795
1796
#ifdef RS6000COFF_C
1797
99.3k
  if (bfd_xcoff_text_align_power (abfd) != 0
1798
99.3k
      && strcmp (bfd_section_name (section), ".text") == 0)
1799
10
    section->alignment_power = bfd_xcoff_text_align_power (abfd);
1800
99.3k
  else if (bfd_xcoff_data_align_power (abfd) != 0
1801
99.3k
      && strcmp (bfd_section_name (section), ".data") == 0)
1802
10
    section->alignment_power = bfd_xcoff_data_align_power (abfd);
1803
99.3k
  else
1804
99.3k
    {
1805
99.3k
      int i;
1806
1807
1.19M
      for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++)
1808
1.09M
  if (strcmp (bfd_section_name (section),
1809
1.09M
        xcoff_dwsect_names[i].xcoff_name) == 0)
1810
78
    {
1811
78
      section->alignment_power = 0;
1812
78
      sclass = C_DWARF;
1813
78
      break;
1814
78
    }
1815
99.3k
    }
1816
#endif
1817
1818
  /* Set up the section symbol.  */
1819
2.09M
  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.09M
  amt = sizeof (combined_entry_type) * 10;
1828
2.09M
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
2.09M
  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.09M
  native->is_sym = true;
1839
2.09M
  native->u.syment.n_type = T_NULL;
1840
2.09M
  native->u.syment.n_sclass = sclass;
1841
1842
2.09M
  coffsymbol (section->symbol)->native = native;
1843
1844
2.09M
  coff_set_custom_section_alignment (abfd, section,
1845
2.09M
             coff_section_alignment_table,
1846
2.09M
             coff_section_alignment_table_size);
1847
1848
2.09M
  return true;
1849
2.09M
}
pei-i386.c:coff_new_section_hook
Line
Count
Source
1789
11.1k
{
1790
11.1k
  combined_entry_type *native;
1791
11.1k
  size_t amt;
1792
11.1k
  unsigned char sclass = C_STAT;
1793
1794
11.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
11.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
11.1k
  amt = sizeof (combined_entry_type) * 10;
1828
11.1k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
11.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
11.1k
  native->is_sym = true;
1839
11.1k
  native->u.syment.n_type = T_NULL;
1840
11.1k
  native->u.syment.n_sclass = sclass;
1841
1842
11.1k
  coffsymbol (section->symbol)->native = native;
1843
1844
11.1k
  coff_set_custom_section_alignment (abfd, section,
1845
11.1k
             coff_section_alignment_table,
1846
11.1k
             coff_section_alignment_table_size);
1847
1848
11.1k
  return true;
1849
11.1k
}
pe-x86_64.c:coff_new_section_hook
Line
Count
Source
1789
88.2k
{
1790
88.2k
  combined_entry_type *native;
1791
88.2k
  size_t amt;
1792
88.2k
  unsigned char sclass = C_STAT;
1793
1794
88.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
88.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
88.2k
  amt = sizeof (combined_entry_type) * 10;
1828
88.2k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
88.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
88.2k
  native->is_sym = true;
1839
88.2k
  native->u.syment.n_type = T_NULL;
1840
88.2k
  native->u.syment.n_sclass = sclass;
1841
1842
88.2k
  coffsymbol (section->symbol)->native = native;
1843
1844
88.2k
  coff_set_custom_section_alignment (abfd, section,
1845
88.2k
             coff_section_alignment_table,
1846
88.2k
             coff_section_alignment_table_size);
1847
1848
88.2k
  return true;
1849
88.2k
}
pei-x86_64.c:coff_new_section_hook
Line
Count
Source
1789
3.09k
{
1790
3.09k
  combined_entry_type *native;
1791
3.09k
  size_t amt;
1792
3.09k
  unsigned char sclass = C_STAT;
1793
1794
3.09k
  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.09k
  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.09k
  amt = sizeof (combined_entry_type) * 10;
1828
3.09k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
3.09k
  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.09k
  native->is_sym = true;
1839
3.09k
  native->u.syment.n_type = T_NULL;
1840
3.09k
  native->u.syment.n_sclass = sclass;
1841
1842
3.09k
  coffsymbol (section->symbol)->native = native;
1843
1844
3.09k
  coff_set_custom_section_alignment (abfd, section,
1845
3.09k
             coff_section_alignment_table,
1846
3.09k
             coff_section_alignment_table_size);
1847
1848
3.09k
  return true;
1849
3.09k
}
coff-x86_64.c:coff_new_section_hook
Line
Count
Source
1789
371k
{
1790
371k
  combined_entry_type *native;
1791
371k
  size_t amt;
1792
371k
  unsigned char sclass = C_STAT;
1793
1794
371k
  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
371k
  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
371k
  amt = sizeof (combined_entry_type) * 10;
1828
371k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
371k
  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
371k
  native->is_sym = true;
1839
371k
  native->u.syment.n_type = T_NULL;
1840
371k
  native->u.syment.n_sclass = sclass;
1841
1842
371k
  coffsymbol (section->symbol)->native = native;
1843
1844
371k
  coff_set_custom_section_alignment (abfd, section,
1845
371k
             coff_section_alignment_table,
1846
371k
             coff_section_alignment_table_size);
1847
1848
371k
  return true;
1849
371k
}
coff64-rs6000.c:coff_new_section_hook
Line
Count
Source
1789
70.8k
{
1790
70.8k
  combined_entry_type *native;
1791
70.8k
  size_t amt;
1792
70.8k
  unsigned char sclass = C_STAT;
1793
1794
70.8k
  section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1795
1796
70.8k
#ifdef RS6000COFF_C
1797
70.8k
  if (bfd_xcoff_text_align_power (abfd) != 0
1798
70.8k
      && strcmp (bfd_section_name (section), ".text") == 0)
1799
2
    section->alignment_power = bfd_xcoff_text_align_power (abfd);
1800
70.8k
  else if (bfd_xcoff_data_align_power (abfd) != 0
1801
70.8k
      && strcmp (bfd_section_name (section), ".data") == 0)
1802
0
    section->alignment_power = bfd_xcoff_data_align_power (abfd);
1803
70.8k
  else
1804
70.8k
    {
1805
70.8k
      int i;
1806
1807
849k
      for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++)
1808
778k
  if (strcmp (bfd_section_name (section),
1809
778k
        xcoff_dwsect_names[i].xcoff_name) == 0)
1810
50
    {
1811
50
      section->alignment_power = 0;
1812
50
      sclass = C_DWARF;
1813
50
      break;
1814
50
    }
1815
70.8k
    }
1816
70.8k
#endif
1817
1818
  /* Set up the section symbol.  */
1819
70.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
70.8k
  amt = sizeof (combined_entry_type) * 10;
1828
70.8k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
70.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
70.8k
  native->is_sym = true;
1839
70.8k
  native->u.syment.n_type = T_NULL;
1840
70.8k
  native->u.syment.n_sclass = sclass;
1841
1842
70.8k
  coffsymbol (section->symbol)->native = native;
1843
1844
70.8k
  coff_set_custom_section_alignment (abfd, section,
1845
70.8k
             coff_section_alignment_table,
1846
70.8k
             coff_section_alignment_table_size);
1847
1848
70.8k
  return true;
1849
70.8k
}
pe-aarch64.c:coff_new_section_hook
Line
Count
Source
1789
4.30k
{
1790
4.30k
  combined_entry_type *native;
1791
4.30k
  size_t amt;
1792
4.30k
  unsigned char sclass = C_STAT;
1793
1794
4.30k
  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
4.30k
  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
4.30k
  amt = sizeof (combined_entry_type) * 10;
1828
4.30k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
4.30k
  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
4.30k
  native->is_sym = true;
1839
4.30k
  native->u.syment.n_type = T_NULL;
1840
4.30k
  native->u.syment.n_sclass = sclass;
1841
1842
4.30k
  coffsymbol (section->symbol)->native = native;
1843
1844
4.30k
  coff_set_custom_section_alignment (abfd, section,
1845
4.30k
             coff_section_alignment_table,
1846
4.30k
             coff_section_alignment_table_size);
1847
1848
4.30k
  return true;
1849
4.30k
}
pei-aarch64.c:coff_new_section_hook
Line
Count
Source
1789
14.7k
{
1790
14.7k
  combined_entry_type *native;
1791
14.7k
  size_t amt;
1792
14.7k
  unsigned char sclass = C_STAT;
1793
1794
14.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
14.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
14.7k
  amt = sizeof (combined_entry_type) * 10;
1828
14.7k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
14.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
14.7k
  native->is_sym = true;
1839
14.7k
  native->u.syment.n_type = T_NULL;
1840
14.7k
  native->u.syment.n_sclass = sclass;
1841
1842
14.7k
  coffsymbol (section->symbol)->native = native;
1843
1844
14.7k
  coff_set_custom_section_alignment (abfd, section,
1845
14.7k
             coff_section_alignment_table,
1846
14.7k
             coff_section_alignment_table_size);
1847
1848
14.7k
  return true;
1849
14.7k
}
pei-ia64.c:coff_new_section_hook
Line
Count
Source
1789
73.0k
{
1790
73.0k
  combined_entry_type *native;
1791
73.0k
  size_t amt;
1792
73.0k
  unsigned char sclass = C_STAT;
1793
1794
73.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
73.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
73.0k
  amt = sizeof (combined_entry_type) * 10;
1828
73.0k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
73.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
73.0k
  native->is_sym = true;
1839
73.0k
  native->u.syment.n_type = T_NULL;
1840
73.0k
  native->u.syment.n_sclass = sclass;
1841
1842
73.0k
  coffsymbol (section->symbol)->native = native;
1843
1844
73.0k
  coff_set_custom_section_alignment (abfd, section,
1845
73.0k
             coff_section_alignment_table,
1846
73.0k
             coff_section_alignment_table_size);
1847
1848
73.0k
  return true;
1849
73.0k
}
pei-loongarch64.c:coff_new_section_hook
Line
Count
Source
1789
2.11k
{
1790
2.11k
  combined_entry_type *native;
1791
2.11k
  size_t amt;
1792
2.11k
  unsigned char sclass = C_STAT;
1793
1794
2.11k
  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.11k
  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.11k
  amt = sizeof (combined_entry_type) * 10;
1828
2.11k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
2.11k
  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.11k
  native->is_sym = true;
1839
2.11k
  native->u.syment.n_type = T_NULL;
1840
2.11k
  native->u.syment.n_sclass = sclass;
1841
1842
2.11k
  coffsymbol (section->symbol)->native = native;
1843
1844
2.11k
  coff_set_custom_section_alignment (abfd, section,
1845
2.11k
             coff_section_alignment_table,
1846
2.11k
             coff_section_alignment_table_size);
1847
1848
2.11k
  return true;
1849
2.11k
}
cf-i386lynx.c:coff_new_section_hook
Line
Count
Source
1789
187k
{
1790
187k
  combined_entry_type *native;
1791
187k
  size_t amt;
1792
187k
  unsigned char sclass = C_STAT;
1793
1794
187k
  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
187k
  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
187k
  amt = sizeof (combined_entry_type) * 10;
1828
187k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
187k
  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
187k
  native->is_sym = true;
1839
187k
  native->u.syment.n_type = T_NULL;
1840
187k
  native->u.syment.n_sclass = sclass;
1841
1842
187k
  coffsymbol (section->symbol)->native = native;
1843
1844
187k
  coff_set_custom_section_alignment (abfd, section,
1845
187k
             coff_section_alignment_table,
1846
187k
             coff_section_alignment_table_size);
1847
1848
187k
  return true;
1849
187k
}
coff-go32.c:coff_new_section_hook
Line
Count
Source
1789
180k
{
1790
180k
  combined_entry_type *native;
1791
180k
  size_t amt;
1792
180k
  unsigned char sclass = C_STAT;
1793
1794
180k
  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
180k
  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
180k
  amt = sizeof (combined_entry_type) * 10;
1828
180k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
180k
  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
180k
  native->is_sym = true;
1839
180k
  native->u.syment.n_type = T_NULL;
1840
180k
  native->u.syment.n_sclass = sclass;
1841
1842
180k
  coffsymbol (section->symbol)->native = native;
1843
1844
180k
  coff_set_custom_section_alignment (abfd, section,
1845
180k
             coff_section_alignment_table,
1846
180k
             coff_section_alignment_table_size);
1847
1848
180k
  return true;
1849
180k
}
coff-i386.c:coff_new_section_hook
Line
Count
Source
1789
187k
{
1790
187k
  combined_entry_type *native;
1791
187k
  size_t amt;
1792
187k
  unsigned char sclass = C_STAT;
1793
1794
187k
  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
187k
  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
187k
  amt = sizeof (combined_entry_type) * 10;
1828
187k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
187k
  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
187k
  native->is_sym = true;
1839
187k
  native->u.syment.n_type = T_NULL;
1840
187k
  native->u.syment.n_sclass = sclass;
1841
1842
187k
  coffsymbol (section->symbol)->native = native;
1843
1844
187k
  coff_set_custom_section_alignment (abfd, section,
1845
187k
             coff_section_alignment_table,
1846
187k
             coff_section_alignment_table_size);
1847
1848
187k
  return true;
1849
187k
}
coff-rs6000.c:coff_new_section_hook
Line
Count
Source
1789
28.5k
{
1790
28.5k
  combined_entry_type *native;
1791
28.5k
  size_t amt;
1792
28.5k
  unsigned char sclass = C_STAT;
1793
1794
28.5k
  section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1795
1796
28.5k
#ifdef RS6000COFF_C
1797
28.5k
  if (bfd_xcoff_text_align_power (abfd) != 0
1798
28.5k
      && strcmp (bfd_section_name (section), ".text") == 0)
1799
8
    section->alignment_power = bfd_xcoff_text_align_power (abfd);
1800
28.5k
  else if (bfd_xcoff_data_align_power (abfd) != 0
1801
28.5k
      && strcmp (bfd_section_name (section), ".data") == 0)
1802
10
    section->alignment_power = bfd_xcoff_data_align_power (abfd);
1803
28.5k
  else
1804
28.5k
    {
1805
28.5k
      int i;
1806
1807
342k
      for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++)
1808
313k
  if (strcmp (bfd_section_name (section),
1809
313k
        xcoff_dwsect_names[i].xcoff_name) == 0)
1810
28
    {
1811
28
      section->alignment_power = 0;
1812
28
      sclass = C_DWARF;
1813
28
      break;
1814
28
    }
1815
28.5k
    }
1816
28.5k
#endif
1817
1818
  /* Set up the section symbol.  */
1819
28.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
28.5k
  amt = sizeof (combined_entry_type) * 10;
1828
28.5k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
28.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
28.5k
  native->is_sym = true;
1839
28.5k
  native->u.syment.n_type = T_NULL;
1840
28.5k
  native->u.syment.n_sclass = sclass;
1841
1842
28.5k
  coffsymbol (section->symbol)->native = native;
1843
1844
28.5k
  coff_set_custom_section_alignment (abfd, section,
1845
28.5k
             coff_section_alignment_table,
1846
28.5k
             coff_section_alignment_table_size);
1847
1848
28.5k
  return true;
1849
28.5k
}
coff-sh.c:coff_new_section_hook
Line
Count
Source
1789
10.2k
{
1790
10.2k
  combined_entry_type *native;
1791
10.2k
  size_t amt;
1792
10.2k
  unsigned char sclass = C_STAT;
1793
1794
10.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
10.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
10.2k
  amt = sizeof (combined_entry_type) * 10;
1828
10.2k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
10.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
10.2k
  native->is_sym = true;
1839
10.2k
  native->u.syment.n_type = T_NULL;
1840
10.2k
  native->u.syment.n_sclass = sclass;
1841
1842
10.2k
  coffsymbol (section->symbol)->native = native;
1843
1844
10.2k
  coff_set_custom_section_alignment (abfd, section,
1845
10.2k
             coff_section_alignment_table,
1846
10.2k
             coff_section_alignment_table_size);
1847
1848
10.2k
  return true;
1849
10.2k
}
Unexecuted instantiation: coff-stgo32.c:coff_new_section_hook
coff-tic30.c:coff_new_section_hook
Line
Count
Source
1789
6.64k
{
1790
6.64k
  combined_entry_type *native;
1791
6.64k
  size_t amt;
1792
6.64k
  unsigned char sclass = C_STAT;
1793
1794
6.64k
  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
6.64k
  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
6.64k
  amt = sizeof (combined_entry_type) * 10;
1828
6.64k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
6.64k
  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
6.64k
  native->is_sym = true;
1839
6.64k
  native->u.syment.n_type = T_NULL;
1840
6.64k
  native->u.syment.n_sclass = sclass;
1841
1842
6.64k
  coffsymbol (section->symbol)->native = native;
1843
1844
6.64k
  coff_set_custom_section_alignment (abfd, section,
1845
6.64k
             coff_section_alignment_table,
1846
6.64k
             coff_section_alignment_table_size);
1847
1848
6.64k
  return true;
1849
6.64k
}
Unexecuted instantiation: coff-tic4x.c:coff_new_section_hook
coff-tic54x.c:coff_new_section_hook
Line
Count
Source
1789
8.78k
{
1790
8.78k
  combined_entry_type *native;
1791
8.78k
  size_t amt;
1792
8.78k
  unsigned char sclass = C_STAT;
1793
1794
8.78k
  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
8.78k
  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
8.78k
  amt = sizeof (combined_entry_type) * 10;
1828
8.78k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
8.78k
  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
8.78k
  native->is_sym = true;
1839
8.78k
  native->u.syment.n_type = T_NULL;
1840
8.78k
  native->u.syment.n_sclass = sclass;
1841
1842
8.78k
  coffsymbol (section->symbol)->native = native;
1843
1844
8.78k
  coff_set_custom_section_alignment (abfd, section,
1845
8.78k
             coff_section_alignment_table,
1846
8.78k
             coff_section_alignment_table_size);
1847
1848
8.78k
  return true;
1849
8.78k
}
coff-z80.c:coff_new_section_hook
Line
Count
Source
1789
54.1k
{
1790
54.1k
  combined_entry_type *native;
1791
54.1k
  size_t amt;
1792
54.1k
  unsigned char sclass = C_STAT;
1793
1794
54.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
54.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
54.1k
  amt = sizeof (combined_entry_type) * 10;
1828
54.1k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
54.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
54.1k
  native->is_sym = true;
1839
54.1k
  native->u.syment.n_type = T_NULL;
1840
54.1k
  native->u.syment.n_sclass = sclass;
1841
1842
54.1k
  coffsymbol (section->symbol)->native = native;
1843
1844
54.1k
  coff_set_custom_section_alignment (abfd, section,
1845
54.1k
             coff_section_alignment_table,
1846
54.1k
             coff_section_alignment_table_size);
1847
1848
54.1k
  return true;
1849
54.1k
}
coff-z8k.c:coff_new_section_hook
Line
Count
Source
1789
3.82k
{
1790
3.82k
  combined_entry_type *native;
1791
3.82k
  size_t amt;
1792
3.82k
  unsigned char sclass = C_STAT;
1793
1794
3.82k
  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.82k
  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.82k
  amt = sizeof (combined_entry_type) * 10;
1828
3.82k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
3.82k
  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.82k
  native->is_sym = true;
1839
3.82k
  native->u.syment.n_type = T_NULL;
1840
3.82k
  native->u.syment.n_sclass = sclass;
1841
1842
3.82k
  coffsymbol (section->symbol)->native = native;
1843
1844
3.82k
  coff_set_custom_section_alignment (abfd, section,
1845
3.82k
             coff_section_alignment_table,
1846
3.82k
             coff_section_alignment_table_size);
1847
1848
3.82k
  return true;
1849
3.82k
}
pe-arm-wince.c:coff_new_section_hook
Line
Count
Source
1789
2.61k
{
1790
2.61k
  combined_entry_type *native;
1791
2.61k
  size_t amt;
1792
2.61k
  unsigned char sclass = C_STAT;
1793
1794
2.61k
  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.61k
  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.61k
  amt = sizeof (combined_entry_type) * 10;
1828
2.61k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
2.61k
  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.61k
  native->is_sym = true;
1839
2.61k
  native->u.syment.n_type = T_NULL;
1840
2.61k
  native->u.syment.n_sclass = sclass;
1841
1842
2.61k
  coffsymbol (section->symbol)->native = native;
1843
1844
2.61k
  coff_set_custom_section_alignment (abfd, section,
1845
2.61k
             coff_section_alignment_table,
1846
2.61k
             coff_section_alignment_table_size);
1847
1848
2.61k
  return true;
1849
2.61k
}
pe-arm.c:coff_new_section_hook
Line
Count
Source
1789
2.61k
{
1790
2.61k
  combined_entry_type *native;
1791
2.61k
  size_t amt;
1792
2.61k
  unsigned char sclass = C_STAT;
1793
1794
2.61k
  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.61k
  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.61k
  amt = sizeof (combined_entry_type) * 10;
1828
2.61k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
2.61k
  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.61k
  native->is_sym = true;
1839
2.61k
  native->u.syment.n_type = T_NULL;
1840
2.61k
  native->u.syment.n_sclass = sclass;
1841
1842
2.61k
  coffsymbol (section->symbol)->native = native;
1843
1844
2.61k
  coff_set_custom_section_alignment (abfd, section,
1845
2.61k
             coff_section_alignment_table,
1846
2.61k
             coff_section_alignment_table_size);
1847
1848
2.61k
  return true;
1849
2.61k
}
pe-i386.c:coff_new_section_hook
Line
Count
Source
1789
4.18k
{
1790
4.18k
  combined_entry_type *native;
1791
4.18k
  size_t amt;
1792
4.18k
  unsigned char sclass = C_STAT;
1793
1794
4.18k
  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
4.18k
  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
4.18k
  amt = sizeof (combined_entry_type) * 10;
1828
4.18k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
4.18k
  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
4.18k
  native->is_sym = true;
1839
4.18k
  native->u.syment.n_type = T_NULL;
1840
4.18k
  native->u.syment.n_sclass = sclass;
1841
1842
4.18k
  coffsymbol (section->symbol)->native = native;
1843
1844
4.18k
  coff_set_custom_section_alignment (abfd, section,
1845
4.18k
             coff_section_alignment_table,
1846
4.18k
             coff_section_alignment_table_size);
1847
1848
4.18k
  return true;
1849
4.18k
}
pe-mcore.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
}
pe-sh.c:coff_new_section_hook
Line
Count
Source
1789
10.4k
{
1790
10.4k
  combined_entry_type *native;
1791
10.4k
  size_t amt;
1792
10.4k
  unsigned char sclass = C_STAT;
1793
1794
10.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
10.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
10.4k
  amt = sizeof (combined_entry_type) * 10;
1828
10.4k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
10.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
10.4k
  native->is_sym = true;
1839
10.4k
  native->u.syment.n_type = T_NULL;
1840
10.4k
  native->u.syment.n_sclass = sclass;
1841
1842
10.4k
  coffsymbol (section->symbol)->native = native;
1843
1844
10.4k
  coff_set_custom_section_alignment (abfd, section,
1845
10.4k
             coff_section_alignment_table,
1846
10.4k
             coff_section_alignment_table_size);
1847
1848
10.4k
  return true;
1849
10.4k
}
pei-arm-wince.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-arm.c:coff_new_section_hook
Line
Count
Source
1789
596k
{
1790
596k
  combined_entry_type *native;
1791
596k
  size_t amt;
1792
596k
  unsigned char sclass = C_STAT;
1793
1794
596k
  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
596k
  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
596k
  amt = sizeof (combined_entry_type) * 10;
1828
596k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
596k
  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
596k
  native->is_sym = true;
1839
596k
  native->u.syment.n_type = T_NULL;
1840
596k
  native->u.syment.n_sclass = sclass;
1841
1842
596k
  coffsymbol (section->symbol)->native = native;
1843
1844
596k
  coff_set_custom_section_alignment (abfd, section,
1845
596k
             coff_section_alignment_table,
1846
596k
             coff_section_alignment_table_size);
1847
1848
596k
  return true;
1849
596k
}
pei-mcore.c:coff_new_section_hook
Line
Count
Source
1789
52.9k
{
1790
52.9k
  combined_entry_type *native;
1791
52.9k
  size_t amt;
1792
52.9k
  unsigned char sclass = C_STAT;
1793
1794
52.9k
  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
52.9k
  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
52.9k
  amt = sizeof (combined_entry_type) * 10;
1828
52.9k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
52.9k
  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
52.9k
  native->is_sym = true;
1839
52.9k
  native->u.syment.n_type = T_NULL;
1840
52.9k
  native->u.syment.n_sclass = sclass;
1841
1842
52.9k
  coffsymbol (section->symbol)->native = native;
1843
1844
52.9k
  coff_set_custom_section_alignment (abfd, section,
1845
52.9k
             coff_section_alignment_table,
1846
52.9k
             coff_section_alignment_table_size);
1847
1848
52.9k
  return true;
1849
52.9k
}
pei-sh.c:coff_new_section_hook
Line
Count
Source
1789
48.7k
{
1790
48.7k
  combined_entry_type *native;
1791
48.7k
  size_t amt;
1792
48.7k
  unsigned char sclass = C_STAT;
1793
1794
48.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
48.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
48.7k
  amt = sizeof (combined_entry_type) * 10;
1828
48.7k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
48.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
48.7k
  native->is_sym = true;
1839
48.7k
  native->u.syment.n_type = T_NULL;
1840
48.7k
  native->u.syment.n_sclass = sclass;
1841
1842
48.7k
  coffsymbol (section->symbol)->native = native;
1843
1844
48.7k
  coff_set_custom_section_alignment (abfd, section,
1845
48.7k
             coff_section_alignment_table,
1846
48.7k
             coff_section_alignment_table_size);
1847
1848
48.7k
  return true;
1849
48.7k
}
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
62.9k
{
1860
62.9k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1861
62.9k
  unsigned int i;
1862
1863
62.9k
#ifdef COFF_DECODE_ALIGNMENT
1864
62.9k
  i = COFF_DECODE_ALIGNMENT(hdr->s_flags);
1865
62.9k
#endif
1866
62.9k
  section->alignment_power = i;
1867
1868
#ifdef coff_set_section_load_page
1869
8.78k
  coff_set_section_load_page (section, hdr->s_page);
1870
#endif
1871
62.9k
}
Unexecuted instantiation: coff-tic4x.c:coff_set_alignment_hook
coff-tic54x.c:coff_set_alignment_hook
Line
Count
Source
1859
8.78k
{
1860
8.78k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1861
8.78k
  unsigned int i;
1862
1863
8.78k
#ifdef COFF_DECODE_ALIGNMENT
1864
8.78k
  i = COFF_DECODE_ALIGNMENT(hdr->s_flags);
1865
8.78k
#endif
1866
8.78k
  section->alignment_power = i;
1867
1868
8.78k
#ifdef coff_set_section_load_page
1869
8.78k
  coff_set_section_load_page (section, hdr->s_page);
1870
8.78k
#endif
1871
8.78k
}
coff-z80.c:coff_set_alignment_hook
Line
Count
Source
1859
54.1k
{
1860
54.1k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1861
54.1k
  unsigned int i;
1862
1863
54.1k
#ifdef COFF_DECODE_ALIGNMENT
1864
54.1k
  i = COFF_DECODE_ALIGNMENT(hdr->s_flags);
1865
54.1k
#endif
1866
54.1k
  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
54.1k
}
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
980k
{
1881
980k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
980k
  size_t amt;
1883
980k
  unsigned int alignment_power_const
1884
980k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
980k
  switch (alignment_power_const)
1887
980k
    {
1888
5.54k
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
6.63k
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
8.61k
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
12.6k
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
14.2k
    case IMAGE_SCN_ALIGN_512BYTES:
1893
18.2k
    case IMAGE_SCN_ALIGN_256BYTES:
1894
77.8k
    case IMAGE_SCN_ALIGN_128BYTES:
1895
79.6k
    case IMAGE_SCN_ALIGN_64BYTES:
1896
91.8k
    case IMAGE_SCN_ALIGN_32BYTES:
1897
92.4k
    case IMAGE_SCN_ALIGN_16BYTES:
1898
109k
    case IMAGE_SCN_ALIGN_8BYTES:
1899
117k
    case IMAGE_SCN_ALIGN_4BYTES:
1900
127k
    case IMAGE_SCN_ALIGN_2BYTES:
1901
128k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
128k
      section->alignment_power
1903
128k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
128k
      break;
1905
851k
    default:
1906
851k
      break;
1907
980k
    }
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
980k
  if (coff_section_data (abfd, section) == NULL)
1914
980k
    {
1915
980k
      amt = sizeof (struct coff_section_tdata);
1916
980k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
980k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
980k
    }
1921
1922
980k
  if (pei_section_data (abfd, section) == NULL)
1923
980k
    {
1924
980k
      amt = sizeof (struct pei_section_tdata);
1925
980k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
980k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
980k
    }
1930
980k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
980k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
980k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
980k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
46.0k
    {
1938
46.0k
      struct external_reloc dst;
1939
46.0k
      struct internal_reloc n;
1940
46.0k
      file_ptr oldpos = bfd_tell (abfd);
1941
46.0k
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
46.0k
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
46.0k
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
18.5k
  return;
1947
1948
27.4k
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
27.4k
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
27.4k
      if (n.r_vaddr < 0x10000)
1952
9.22k
  {
1953
9.22k
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
9.22k
    bfd_set_error (bfd_error_bad_value);
1955
9.22k
    return;
1956
9.22k
  }
1957
18.2k
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
18.2k
      section->rel_filepos += relsz;
1959
18.2k
    }
1960
934k
  else if (hdr->s_nreloc == 0xffff)
1961
2.18k
    _bfd_error_handler
1962
2.18k
      (_("%pB: warning: claims to have 0xffff relocs, without overflow"),
1963
2.18k
       abfd);
1964
980k
}
pei-i386.c:coff_set_alignment_hook
Line
Count
Source
1880
11.0k
{
1881
11.0k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
11.0k
  size_t amt;
1883
11.0k
  unsigned int alignment_power_const
1884
11.0k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
11.0k
  switch (alignment_power_const)
1887
11.0k
    {
1888
206
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
210
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
212
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
702
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
710
    case IMAGE_SCN_ALIGN_512BYTES:
1893
1.67k
    case IMAGE_SCN_ALIGN_256BYTES:
1894
1.68k
    case IMAGE_SCN_ALIGN_128BYTES:
1895
1.68k
    case IMAGE_SCN_ALIGN_64BYTES:
1896
1.70k
    case IMAGE_SCN_ALIGN_32BYTES:
1897
1.71k
    case IMAGE_SCN_ALIGN_16BYTES:
1898
1.75k
    case IMAGE_SCN_ALIGN_8BYTES:
1899
1.76k
    case IMAGE_SCN_ALIGN_4BYTES:
1900
1.78k
    case IMAGE_SCN_ALIGN_2BYTES:
1901
1.79k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
1.79k
      section->alignment_power
1903
1.79k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
1.79k
      break;
1905
9.27k
    default:
1906
9.27k
      break;
1907
11.0k
    }
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
11.0k
  if (coff_section_data (abfd, section) == NULL)
1914
11.0k
    {
1915
11.0k
      amt = sizeof (struct coff_section_tdata);
1916
11.0k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
11.0k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
11.0k
    }
1921
1922
11.0k
  if (pei_section_data (abfd, section) == NULL)
1923
11.0k
    {
1924
11.0k
      amt = sizeof (struct pei_section_tdata);
1925
11.0k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
11.0k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
11.0k
    }
1930
11.0k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
11.0k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
11.0k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
11.0k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
1.07k
    {
1938
1.07k
      struct external_reloc dst;
1939
1.07k
      struct internal_reloc n;
1940
1.07k
      file_ptr oldpos = bfd_tell (abfd);
1941
1.07k
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
1.07k
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
1.07k
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
562
  return;
1947
1948
516
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
516
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
516
      if (n.r_vaddr < 0x10000)
1952
18
  {
1953
18
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
18
    bfd_set_error (bfd_error_bad_value);
1955
18
    return;
1956
18
  }
1957
498
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
498
      section->rel_filepos += relsz;
1959
498
    }
1960
9.99k
  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
11.0k
}
pe-x86_64.c:coff_set_alignment_hook
Line
Count
Source
1880
88.1k
{
1881
88.1k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
88.1k
  size_t amt;
1883
88.1k
  unsigned int alignment_power_const
1884
88.1k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
88.1k
  switch (alignment_power_const)
1887
88.1k
    {
1888
150
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
150
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
152
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
160
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
166
    case IMAGE_SCN_ALIGN_512BYTES:
1893
234
    case IMAGE_SCN_ALIGN_256BYTES:
1894
570
    case IMAGE_SCN_ALIGN_128BYTES:
1895
572
    case IMAGE_SCN_ALIGN_64BYTES:
1896
610
    case IMAGE_SCN_ALIGN_32BYTES:
1897
628
    case IMAGE_SCN_ALIGN_16BYTES:
1898
14.4k
    case IMAGE_SCN_ALIGN_8BYTES:
1899
14.4k
    case IMAGE_SCN_ALIGN_4BYTES:
1900
14.7k
    case IMAGE_SCN_ALIGN_2BYTES:
1901
14.8k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
14.8k
      section->alignment_power
1903
14.8k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
14.8k
      break;
1905
73.3k
    default:
1906
73.3k
      break;
1907
88.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
88.1k
  if (coff_section_data (abfd, section) == NULL)
1914
88.1k
    {
1915
88.1k
      amt = sizeof (struct coff_section_tdata);
1916
88.1k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
88.1k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
88.1k
    }
1921
1922
88.1k
  if (pei_section_data (abfd, section) == NULL)
1923
88.1k
    {
1924
88.1k
      amt = sizeof (struct pei_section_tdata);
1925
88.1k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
88.1k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
88.1k
    }
1930
88.1k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
88.1k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
88.1k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
88.1k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
174
    {
1938
174
      struct external_reloc dst;
1939
174
      struct internal_reloc n;
1940
174
      file_ptr oldpos = bfd_tell (abfd);
1941
174
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
174
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
174
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
110
  return;
1947
1948
64
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
64
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
64
      if (n.r_vaddr < 0x10000)
1952
6
  {
1953
6
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
6
    bfd_set_error (bfd_error_bad_value);
1955
6
    return;
1956
6
  }
1957
58
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
58
      section->rel_filepos += relsz;
1959
58
    }
1960
88.0k
  else if (hdr->s_nreloc == 0xffff)
1961
46
    _bfd_error_handler
1962
46
      (_("%pB: warning: claims to have 0xffff relocs, without overflow"),
1963
46
       abfd);
1964
88.1k
}
pei-x86_64.c:coff_set_alignment_hook
Line
Count
Source
1880
3.04k
{
1881
3.04k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
3.04k
  size_t amt;
1883
3.04k
  unsigned int alignment_power_const
1884
3.04k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
3.04k
  switch (alignment_power_const)
1887
3.04k
    {
1888
564
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
564
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
574
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
582
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
590
    case IMAGE_SCN_ALIGN_512BYTES:
1893
590
    case IMAGE_SCN_ALIGN_256BYTES:
1894
594
    case IMAGE_SCN_ALIGN_128BYTES:
1895
602
    case IMAGE_SCN_ALIGN_64BYTES:
1896
608
    case IMAGE_SCN_ALIGN_32BYTES:
1897
614
    case IMAGE_SCN_ALIGN_16BYTES:
1898
654
    case IMAGE_SCN_ALIGN_8BYTES:
1899
658
    case IMAGE_SCN_ALIGN_4BYTES:
1900
916
    case IMAGE_SCN_ALIGN_2BYTES:
1901
920
    case IMAGE_SCN_ALIGN_1BYTES:
1902
920
      section->alignment_power
1903
920
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
920
      break;
1905
2.12k
    default:
1906
2.12k
      break;
1907
3.04k
    }
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
3.04k
  if (coff_section_data (abfd, section) == NULL)
1914
3.04k
    {
1915
3.04k
      amt = sizeof (struct coff_section_tdata);
1916
3.04k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
3.04k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
3.04k
    }
1921
1922
3.04k
  if (pei_section_data (abfd, section) == NULL)
1923
3.04k
    {
1924
3.04k
      amt = sizeof (struct pei_section_tdata);
1925
3.04k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
3.04k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
3.04k
    }
1930
3.04k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
3.04k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
3.04k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
3.04k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
252
    {
1938
252
      struct external_reloc dst;
1939
252
      struct internal_reloc n;
1940
252
      file_ptr oldpos = bfd_tell (abfd);
1941
252
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
252
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
252
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
100
  return;
1947
1948
152
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
152
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
152
      if (n.r_vaddr < 0x10000)
1952
14
  {
1953
14
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
14
    bfd_set_error (bfd_error_bad_value);
1955
14
    return;
1956
14
  }
1957
138
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
138
      section->rel_filepos += relsz;
1959
138
    }
1960
2.78k
  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
3.04k
}
pe-aarch64.c:coff_set_alignment_hook
Line
Count
Source
1880
4.28k
{
1881
4.28k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
4.28k
  size_t amt;
1883
4.28k
  unsigned int alignment_power_const
1884
4.28k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
4.28k
  switch (alignment_power_const)
1887
4.28k
    {
1888
26
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
30
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
62
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
64
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
582
    case IMAGE_SCN_ALIGN_512BYTES:
1893
586
    case IMAGE_SCN_ALIGN_256BYTES:
1894
588
    case IMAGE_SCN_ALIGN_128BYTES:
1895
592
    case IMAGE_SCN_ALIGN_64BYTES:
1896
664
    case IMAGE_SCN_ALIGN_32BYTES:
1897
668
    case IMAGE_SCN_ALIGN_16BYTES:
1898
746
    case IMAGE_SCN_ALIGN_8BYTES:
1899
762
    case IMAGE_SCN_ALIGN_4BYTES:
1900
920
    case IMAGE_SCN_ALIGN_2BYTES:
1901
970
    case IMAGE_SCN_ALIGN_1BYTES:
1902
970
      section->alignment_power
1903
970
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
970
      break;
1905
3.31k
    default:
1906
3.31k
      break;
1907
4.28k
    }
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
4.28k
  if (coff_section_data (abfd, section) == NULL)
1914
4.28k
    {
1915
4.28k
      amt = sizeof (struct coff_section_tdata);
1916
4.28k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
4.28k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
4.28k
    }
1921
1922
4.28k
  if (pei_section_data (abfd, section) == NULL)
1923
4.28k
    {
1924
4.28k
      amt = sizeof (struct pei_section_tdata);
1925
4.28k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
4.28k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
4.28k
    }
1930
4.28k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
4.28k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
4.28k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
4.28k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
234
    {
1938
234
      struct external_reloc dst;
1939
234
      struct internal_reloc n;
1940
234
      file_ptr oldpos = bfd_tell (abfd);
1941
234
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
234
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
234
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
134
  return;
1947
1948
100
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
100
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
100
      if (n.r_vaddr < 0x10000)
1952
56
  {
1953
56
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
56
    bfd_set_error (bfd_error_bad_value);
1955
56
    return;
1956
56
  }
1957
44
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
44
      section->rel_filepos += relsz;
1959
44
    }
1960
4.05k
  else if (hdr->s_nreloc == 0xffff)
1961
20
    _bfd_error_handler
1962
20
      (_("%pB: warning: claims to have 0xffff relocs, without overflow"),
1963
20
       abfd);
1964
4.28k
}
pei-aarch64.c:coff_set_alignment_hook
Line
Count
Source
1880
14.6k
{
1881
14.6k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
14.6k
  size_t amt;
1883
14.6k
  unsigned int alignment_power_const
1884
14.6k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
14.6k
  switch (alignment_power_const)
1887
14.6k
    {
1888
4
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
8
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
10
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
16
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
64
    case IMAGE_SCN_ALIGN_512BYTES:
1893
64
    case IMAGE_SCN_ALIGN_256BYTES:
1894
556
    case IMAGE_SCN_ALIGN_128BYTES:
1895
564
    case IMAGE_SCN_ALIGN_64BYTES:
1896
1.05k
    case IMAGE_SCN_ALIGN_32BYTES:
1897
1.06k
    case IMAGE_SCN_ALIGN_16BYTES:
1898
1.64k
    case IMAGE_SCN_ALIGN_8BYTES:
1899
2.13k
    case IMAGE_SCN_ALIGN_4BYTES:
1900
7.59k
    case IMAGE_SCN_ALIGN_2BYTES:
1901
7.60k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
7.60k
      section->alignment_power
1903
7.60k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
7.60k
      break;
1905
7.08k
    default:
1906
7.08k
      break;
1907
14.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
14.6k
  if (coff_section_data (abfd, section) == NULL)
1914
14.6k
    {
1915
14.6k
      amt = sizeof (struct coff_section_tdata);
1916
14.6k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
14.6k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
14.6k
    }
1921
1922
14.6k
  if (pei_section_data (abfd, section) == NULL)
1923
14.6k
    {
1924
14.6k
      amt = sizeof (struct pei_section_tdata);
1925
14.6k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
14.6k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
14.6k
    }
1930
14.6k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
14.6k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
14.6k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
14.6k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
1.65k
    {
1938
1.65k
      struct external_reloc dst;
1939
1.65k
      struct internal_reloc n;
1940
1.65k
      file_ptr oldpos = bfd_tell (abfd);
1941
1.65k
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
1.65k
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
1.65k
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
1.09k
  return;
1947
1948
564
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
564
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
564
      if (n.r_vaddr < 0x10000)
1952
28
  {
1953
28
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
28
    bfd_set_error (bfd_error_bad_value);
1955
28
    return;
1956
28
  }
1957
536
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
536
      section->rel_filepos += relsz;
1959
536
    }
1960
13.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
14.6k
}
pei-ia64.c:coff_set_alignment_hook
Line
Count
Source
1880
72.9k
{
1881
72.9k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
72.9k
  size_t amt;
1883
72.9k
  unsigned int alignment_power_const
1884
72.9k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
72.9k
  switch (alignment_power_const)
1887
72.9k
    {
1888
10
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
10
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
510
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
1.48k
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
1.97k
    case IMAGE_SCN_ALIGN_512BYTES:
1893
1.97k
    case IMAGE_SCN_ALIGN_256BYTES:
1894
5.89k
    case IMAGE_SCN_ALIGN_128BYTES:
1895
5.90k
    case IMAGE_SCN_ALIGN_64BYTES:
1896
7.36k
    case IMAGE_SCN_ALIGN_32BYTES:
1897
7.36k
    case IMAGE_SCN_ALIGN_16BYTES:
1898
7.36k
    case IMAGE_SCN_ALIGN_8BYTES:
1899
8.83k
    case IMAGE_SCN_ALIGN_4BYTES:
1900
9.83k
    case IMAGE_SCN_ALIGN_2BYTES:
1901
9.84k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
9.84k
      section->alignment_power
1903
9.84k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
9.84k
      break;
1905
63.1k
    default:
1906
63.1k
      break;
1907
72.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
72.9k
  if (coff_section_data (abfd, section) == NULL)
1914
72.9k
    {
1915
72.9k
      amt = sizeof (struct coff_section_tdata);
1916
72.9k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
72.9k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
72.9k
    }
1921
1922
72.9k
  if (pei_section_data (abfd, section) == NULL)
1923
72.9k
    {
1924
72.9k
      amt = sizeof (struct pei_section_tdata);
1925
72.9k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
72.9k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
72.9k
    }
1930
72.9k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
72.9k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
72.9k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
72.9k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
8.91k
    {
1938
8.91k
      struct external_reloc dst;
1939
8.91k
      struct internal_reloc n;
1940
8.91k
      file_ptr oldpos = bfd_tell (abfd);
1941
8.91k
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
8.91k
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
8.91k
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
3.47k
  return;
1947
1948
5.43k
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
5.43k
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
5.43k
      if (n.r_vaddr < 0x10000)
1952
2.98k
  {
1953
2.98k
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
2.98k
    bfd_set_error (bfd_error_bad_value);
1955
2.98k
    return;
1956
2.98k
  }
1957
2.45k
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
2.45k
      section->rel_filepos += relsz;
1959
2.45k
    }
1960
64.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
72.9k
}
pei-loongarch64.c:coff_set_alignment_hook
Line
Count
Source
1880
2.05k
{
1881
2.05k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
2.05k
  size_t amt;
1883
2.05k
  unsigned int alignment_power_const
1884
2.05k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
2.05k
  switch (alignment_power_const)
1887
2.05k
    {
1888
22
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
32
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
120
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
124
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
128
    case IMAGE_SCN_ALIGN_512BYTES:
1893
128
    case IMAGE_SCN_ALIGN_256BYTES:
1894
210
    case IMAGE_SCN_ALIGN_128BYTES:
1895
212
    case IMAGE_SCN_ALIGN_64BYTES:
1896
246
    case IMAGE_SCN_ALIGN_32BYTES:
1897
250
    case IMAGE_SCN_ALIGN_16BYTES:
1898
510
    case IMAGE_SCN_ALIGN_8BYTES:
1899
518
    case IMAGE_SCN_ALIGN_4BYTES:
1900
652
    case IMAGE_SCN_ALIGN_2BYTES:
1901
658
    case IMAGE_SCN_ALIGN_1BYTES:
1902
658
      section->alignment_power
1903
658
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
658
      break;
1905
1.39k
    default:
1906
1.39k
      break;
1907
2.05k
    }
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
2.05k
  if (coff_section_data (abfd, section) == NULL)
1914
2.05k
    {
1915
2.05k
      amt = sizeof (struct coff_section_tdata);
1916
2.05k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
2.05k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
2.05k
    }
1921
1922
2.05k
  if (pei_section_data (abfd, section) == NULL)
1923
2.05k
    {
1924
2.05k
      amt = sizeof (struct pei_section_tdata);
1925
2.05k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
2.05k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
2.05k
    }
1930
2.05k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
2.05k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
2.05k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
2.05k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
154
    {
1938
154
      struct external_reloc dst;
1939
154
      struct internal_reloc n;
1940
154
      file_ptr oldpos = bfd_tell (abfd);
1941
154
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
154
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
154
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
68
  return;
1947
1948
86
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
86
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
86
      if (n.r_vaddr < 0x10000)
1952
14
  {
1953
14
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
14
    bfd_set_error (bfd_error_bad_value);
1955
14
    return;
1956
14
  }
1957
72
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
72
      section->rel_filepos += relsz;
1959
72
    }
1960
1.89k
  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
2.05k
}
pe-arm-wince.c:coff_set_alignment_hook
Line
Count
Source
1880
2.59k
{
1881
2.59k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
2.59k
  size_t amt;
1883
2.59k
  unsigned int alignment_power_const
1884
2.59k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
2.59k
  switch (alignment_power_const)
1887
2.59k
    {
1888
538
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
562
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
602
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
606
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
624
    case IMAGE_SCN_ALIGN_512BYTES:
1893
632
    case IMAGE_SCN_ALIGN_256BYTES:
1894
706
    case IMAGE_SCN_ALIGN_128BYTES:
1895
718
    case IMAGE_SCN_ALIGN_64BYTES:
1896
764
    case IMAGE_SCN_ALIGN_32BYTES:
1897
770
    case IMAGE_SCN_ALIGN_16BYTES:
1898
772
    case IMAGE_SCN_ALIGN_8BYTES:
1899
790
    case IMAGE_SCN_ALIGN_4BYTES:
1900
1.01k
    case IMAGE_SCN_ALIGN_2BYTES:
1901
1.04k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
1.04k
      section->alignment_power
1903
1.04k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
1.04k
      break;
1905
1.55k
    default:
1906
1.55k
      break;
1907
2.59k
    }
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
2.59k
  if (coff_section_data (abfd, section) == NULL)
1914
2.59k
    {
1915
2.59k
      amt = sizeof (struct coff_section_tdata);
1916
2.59k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
2.59k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
2.59k
    }
1921
1922
2.59k
  if (pei_section_data (abfd, section) == NULL)
1923
2.59k
    {
1924
2.59k
      amt = sizeof (struct pei_section_tdata);
1925
2.59k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
2.59k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
2.59k
    }
1930
2.59k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
2.59k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
2.59k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
2.59k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
270
    {
1938
270
      struct external_reloc dst;
1939
270
      struct internal_reloc n;
1940
270
      file_ptr oldpos = bfd_tell (abfd);
1941
270
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
270
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
270
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
146
  return;
1947
1948
124
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
124
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
124
      if (n.r_vaddr < 0x10000)
1952
34
  {
1953
34
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
34
    bfd_set_error (bfd_error_bad_value);
1955
34
    return;
1956
34
  }
1957
90
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
90
      section->rel_filepos += relsz;
1959
90
    }
1960
2.32k
  else if (hdr->s_nreloc == 0xffff)
1961
26
    _bfd_error_handler
1962
26
      (_("%pB: warning: claims to have 0xffff relocs, without overflow"),
1963
26
       abfd);
1964
2.59k
}
pe-arm.c:coff_set_alignment_hook
Line
Count
Source
1880
2.59k
{
1881
2.59k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
2.59k
  size_t amt;
1883
2.59k
  unsigned int alignment_power_const
1884
2.59k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
2.59k
  switch (alignment_power_const)
1887
2.59k
    {
1888
538
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
562
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
602
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
606
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
624
    case IMAGE_SCN_ALIGN_512BYTES:
1893
632
    case IMAGE_SCN_ALIGN_256BYTES:
1894
706
    case IMAGE_SCN_ALIGN_128BYTES:
1895
718
    case IMAGE_SCN_ALIGN_64BYTES:
1896
764
    case IMAGE_SCN_ALIGN_32BYTES:
1897
770
    case IMAGE_SCN_ALIGN_16BYTES:
1898
772
    case IMAGE_SCN_ALIGN_8BYTES:
1899
790
    case IMAGE_SCN_ALIGN_4BYTES:
1900
1.01k
    case IMAGE_SCN_ALIGN_2BYTES:
1901
1.04k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
1.04k
      section->alignment_power
1903
1.04k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
1.04k
      break;
1905
1.55k
    default:
1906
1.55k
      break;
1907
2.59k
    }
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
2.59k
  if (coff_section_data (abfd, section) == NULL)
1914
2.59k
    {
1915
2.59k
      amt = sizeof (struct coff_section_tdata);
1916
2.59k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
2.59k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
2.59k
    }
1921
1922
2.59k
  if (pei_section_data (abfd, section) == NULL)
1923
2.59k
    {
1924
2.59k
      amt = sizeof (struct pei_section_tdata);
1925
2.59k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
2.59k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
2.59k
    }
1930
2.59k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
2.59k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
2.59k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
2.59k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
270
    {
1938
270
      struct external_reloc dst;
1939
270
      struct internal_reloc n;
1940
270
      file_ptr oldpos = bfd_tell (abfd);
1941
270
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
270
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
270
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
146
  return;
1947
1948
124
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
124
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
124
      if (n.r_vaddr < 0x10000)
1952
34
  {
1953
34
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
34
    bfd_set_error (bfd_error_bad_value);
1955
34
    return;
1956
34
  }
1957
90
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
90
      section->rel_filepos += relsz;
1959
90
    }
1960
2.32k
  else if (hdr->s_nreloc == 0xffff)
1961
26
    _bfd_error_handler
1962
26
      (_("%pB: warning: claims to have 0xffff relocs, without overflow"),
1963
26
       abfd);
1964
2.59k
}
pe-i386.c:coff_set_alignment_hook
Line
Count
Source
1880
4.17k
{
1881
4.17k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
4.17k
  size_t amt;
1883
4.17k
  unsigned int alignment_power_const
1884
4.17k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
4.17k
  switch (alignment_power_const)
1887
4.17k
    {
1888
392
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
396
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
404
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
408
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
442
    case IMAGE_SCN_ALIGN_512BYTES:
1893
448
    case IMAGE_SCN_ALIGN_256BYTES:
1894
484
    case IMAGE_SCN_ALIGN_128BYTES:
1895
768
    case IMAGE_SCN_ALIGN_64BYTES:
1896
804
    case IMAGE_SCN_ALIGN_32BYTES:
1897
832
    case IMAGE_SCN_ALIGN_16BYTES:
1898
884
    case IMAGE_SCN_ALIGN_8BYTES:
1899
908
    case IMAGE_SCN_ALIGN_4BYTES:
1900
984
    case IMAGE_SCN_ALIGN_2BYTES:
1901
1.01k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
1.01k
      section->alignment_power
1903
1.01k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
1.01k
      break;
1905
3.16k
    default:
1906
3.16k
      break;
1907
4.17k
    }
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
4.17k
  if (coff_section_data (abfd, section) == NULL)
1914
4.17k
    {
1915
4.17k
      amt = sizeof (struct coff_section_tdata);
1916
4.17k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
4.17k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
4.17k
    }
1921
1922
4.17k
  if (pei_section_data (abfd, section) == NULL)
1923
4.17k
    {
1924
4.17k
      amt = sizeof (struct pei_section_tdata);
1925
4.17k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
4.17k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
4.17k
    }
1930
4.17k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
4.17k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
4.17k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
4.17k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
810
    {
1938
810
      struct external_reloc dst;
1939
810
      struct internal_reloc n;
1940
810
      file_ptr oldpos = bfd_tell (abfd);
1941
810
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
810
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
810
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
472
  return;
1947
1948
338
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
338
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
338
      if (n.r_vaddr < 0x10000)
1952
14
  {
1953
14
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
14
    bfd_set_error (bfd_error_bad_value);
1955
14
    return;
1956
14
  }
1957
324
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
324
      section->rel_filepos += relsz;
1959
324
    }
1960
3.36k
  else if (hdr->s_nreloc == 0xffff)
1961
36
    _bfd_error_handler
1962
36
      (_("%pB: warning: claims to have 0xffff relocs, without overflow"),
1963
36
       abfd);
1964
4.17k
}
pe-mcore.c:coff_set_alignment_hook
Line
Count
Source
1880
23.2k
{
1881
23.2k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
23.2k
  size_t amt;
1883
23.2k
  unsigned int alignment_power_const
1884
23.2k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
23.2k
  switch (alignment_power_const)
1887
23.2k
    {
1888
1.78k
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
1.79k
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
1.80k
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
1.81k
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
1.82k
    case IMAGE_SCN_ALIGN_512BYTES:
1893
1.83k
    case IMAGE_SCN_ALIGN_256BYTES:
1894
1.88k
    case IMAGE_SCN_ALIGN_128BYTES:
1895
1.90k
    case IMAGE_SCN_ALIGN_64BYTES:
1896
1.93k
    case IMAGE_SCN_ALIGN_32BYTES:
1897
1.93k
    case IMAGE_SCN_ALIGN_16BYTES:
1898
3.45k
    case IMAGE_SCN_ALIGN_8BYTES:
1899
3.47k
    case IMAGE_SCN_ALIGN_4BYTES:
1900
4.19k
    case IMAGE_SCN_ALIGN_2BYTES:
1901
4.20k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
4.20k
      section->alignment_power
1903
4.20k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
4.20k
      break;
1905
19.0k
    default:
1906
19.0k
      break;
1907
23.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
23.2k
  if (coff_section_data (abfd, section) == NULL)
1914
23.2k
    {
1915
23.2k
      amt = sizeof (struct coff_section_tdata);
1916
23.2k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
23.2k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
23.2k
    }
1921
1922
23.2k
  if (pei_section_data (abfd, section) == NULL)
1923
23.2k
    {
1924
23.2k
      amt = sizeof (struct pei_section_tdata);
1925
23.2k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
23.2k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
23.2k
    }
1930
23.2k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
23.2k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
23.2k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
23.2k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
2.12k
    {
1938
2.12k
      struct external_reloc dst;
1939
2.12k
      struct internal_reloc n;
1940
2.12k
      file_ptr oldpos = bfd_tell (abfd);
1941
2.12k
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
2.12k
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
2.12k
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
582
  return;
1947
1948
1.54k
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
1.54k
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
1.54k
      if (n.r_vaddr < 0x10000)
1952
502
  {
1953
502
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
502
    bfd_set_error (bfd_error_bad_value);
1955
502
    return;
1956
502
  }
1957
1.04k
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
1.04k
      section->rel_filepos += relsz;
1959
1.04k
    }
1960
21.1k
  else if (hdr->s_nreloc == 0xffff)
1961
2.00k
    _bfd_error_handler
1962
2.00k
      (_("%pB: warning: claims to have 0xffff relocs, without overflow"),
1963
2.00k
       abfd);
1964
23.2k
}
pe-sh.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
42
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
532
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
1.05k
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
1.06k
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
1.07k
    case IMAGE_SCN_ALIGN_512BYTES:
1893
1.07k
    case IMAGE_SCN_ALIGN_256BYTES:
1894
1.18k
    case IMAGE_SCN_ALIGN_128BYTES:
1895
1.18k
    case IMAGE_SCN_ALIGN_64BYTES:
1896
1.69k
    case IMAGE_SCN_ALIGN_32BYTES:
1897
1.69k
    case IMAGE_SCN_ALIGN_16BYTES:
1898
1.90k
    case IMAGE_SCN_ALIGN_8BYTES:
1899
1.93k
    case IMAGE_SCN_ALIGN_4BYTES:
1900
2.09k
    case IMAGE_SCN_ALIGN_2BYTES:
1901
2.10k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
2.10k
      section->alignment_power
1903
2.10k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
2.10k
      break;
1905
8.29k
    default:
1906
8.29k
      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
1.67k
    {
1938
1.67k
      struct external_reloc dst;
1939
1.67k
      struct internal_reloc n;
1940
1.67k
      file_ptr oldpos = bfd_tell (abfd);
1941
1.67k
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
1.67k
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
1.67k
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
620
  return;
1947
1948
1.05k
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
1.05k
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
1.05k
      if (n.r_vaddr < 0x10000)
1952
514
  {
1953
514
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
514
    bfd_set_error (bfd_error_bad_value);
1955
514
    return;
1956
514
  }
1957
536
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
536
      section->rel_filepos += relsz;
1959
536
    }
1960
8.73k
  else if (hdr->s_nreloc == 0xffff)
1961
20
    _bfd_error_handler
1962
20
      (_("%pB: warning: claims to have 0xffff relocs, without overflow"),
1963
20
       abfd);
1964
10.4k
}
pei-arm-wince.c:coff_set_alignment_hook
Line
Count
Source
1880
43.0k
{
1881
43.0k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
43.0k
  size_t amt;
1883
43.0k
  unsigned int alignment_power_const
1884
43.0k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
43.0k
  switch (alignment_power_const)
1887
43.0k
    {
1888
122
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
128
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
130
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
1.59k
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
1.60k
    case IMAGE_SCN_ALIGN_512BYTES:
1893
4.01k
    case IMAGE_SCN_ALIGN_256BYTES:
1894
4.04k
    case IMAGE_SCN_ALIGN_128BYTES:
1895
4.05k
    case IMAGE_SCN_ALIGN_64BYTES:
1896
5.09k
    case IMAGE_SCN_ALIGN_32BYTES:
1897
5.10k
    case IMAGE_SCN_ALIGN_16BYTES:
1898
5.10k
    case IMAGE_SCN_ALIGN_8BYTES:
1899
6.10k
    case IMAGE_SCN_ALIGN_4BYTES:
1900
6.11k
    case IMAGE_SCN_ALIGN_2BYTES:
1901
6.13k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
6.13k
      section->alignment_power
1903
6.13k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
6.13k
      break;
1905
36.9k
    default:
1906
36.9k
      break;
1907
43.0k
    }
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
43.0k
  if (coff_section_data (abfd, section) == NULL)
1914
43.0k
    {
1915
43.0k
      amt = sizeof (struct coff_section_tdata);
1916
43.0k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
43.0k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
43.0k
    }
1921
1922
43.0k
  if (pei_section_data (abfd, section) == NULL)
1923
43.0k
    {
1924
43.0k
      amt = sizeof (struct pei_section_tdata);
1925
43.0k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
43.0k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
43.0k
    }
1930
43.0k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
43.0k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
43.0k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
43.0k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
12.7k
    {
1938
12.7k
      struct external_reloc dst;
1939
12.7k
      struct internal_reloc n;
1940
12.7k
      file_ptr oldpos = bfd_tell (abfd);
1941
12.7k
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
12.7k
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
12.7k
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
5.42k
  return;
1947
1948
7.34k
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
7.34k
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
7.34k
      if (n.r_vaddr < 0x10000)
1952
518
  {
1953
518
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
518
    bfd_set_error (bfd_error_bad_value);
1955
518
    return;
1956
518
  }
1957
6.82k
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
6.82k
      section->rel_filepos += relsz;
1959
6.82k
    }
1960
30.2k
  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
43.0k
}
pei-arm.c:coff_set_alignment_hook
Line
Count
Source
1880
596k
{
1881
596k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
596k
  size_t amt;
1883
596k
  unsigned int alignment_power_const
1884
596k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
596k
  switch (alignment_power_const)
1887
596k
    {
1888
1.10k
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
1.10k
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
1.11k
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
2.09k
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
2.10k
    case IMAGE_SCN_ALIGN_512BYTES:
1893
2.59k
    case IMAGE_SCN_ALIGN_256BYTES:
1894
56.8k
    case IMAGE_SCN_ALIGN_128BYTES:
1895
56.8k
    case IMAGE_SCN_ALIGN_64BYTES:
1896
65.1k
    case IMAGE_SCN_ALIGN_32BYTES:
1897
65.1k
    case IMAGE_SCN_ALIGN_16BYTES:
1898
65.6k
    case IMAGE_SCN_ALIGN_8BYTES:
1899
69.5k
    case IMAGE_SCN_ALIGN_4BYTES:
1900
69.5k
    case IMAGE_SCN_ALIGN_2BYTES:
1901
70.0k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
70.0k
      section->alignment_power
1903
70.0k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
70.0k
      break;
1905
526k
    default:
1906
526k
      break;
1907
596k
    }
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
596k
  if (coff_section_data (abfd, section) == NULL)
1914
596k
    {
1915
596k
      amt = sizeof (struct coff_section_tdata);
1916
596k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
596k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
596k
    }
1921
1922
596k
  if (pei_section_data (abfd, section) == NULL)
1923
596k
    {
1924
596k
      amt = sizeof (struct pei_section_tdata);
1925
596k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
596k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
596k
    }
1930
596k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
596k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
596k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
596k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
7.02k
    {
1938
7.02k
      struct external_reloc dst;
1939
7.02k
      struct internal_reloc n;
1940
7.02k
      file_ptr oldpos = bfd_tell (abfd);
1941
7.02k
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
7.02k
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
7.02k
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
3.07k
  return;
1947
1948
3.95k
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
3.95k
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
3.95k
      if (n.r_vaddr < 0x10000)
1952
1.00k
  {
1953
1.00k
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
1.00k
    bfd_set_error (bfd_error_bad_value);
1955
1.00k
    return;
1956
1.00k
  }
1957
2.95k
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
2.95k
      section->rel_filepos += relsz;
1959
2.95k
    }
1960
589k
  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
596k
}
pei-mcore.c:coff_set_alignment_hook
Line
Count
Source
1880
52.9k
{
1881
52.9k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
52.9k
  size_t amt;
1883
52.9k
  unsigned int alignment_power_const
1884
52.9k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
52.9k
  switch (alignment_power_const)
1887
52.9k
    {
1888
26
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
516
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
748
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
758
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
762
    case IMAGE_SCN_ALIGN_512BYTES:
1893
768
    case IMAGE_SCN_ALIGN_256BYTES:
1894
794
    case IMAGE_SCN_ALIGN_128BYTES:
1895
1.29k
    case IMAGE_SCN_ALIGN_64BYTES:
1896
1.39k
    case IMAGE_SCN_ALIGN_32BYTES:
1897
1.87k
    case IMAGE_SCN_ALIGN_16BYTES:
1898
1.89k
    case IMAGE_SCN_ALIGN_8BYTES:
1899
1.91k
    case IMAGE_SCN_ALIGN_4BYTES:
1900
2.41k
    case IMAGE_SCN_ALIGN_2BYTES:
1901
2.91k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
2.91k
      section->alignment_power
1903
2.91k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
2.91k
      break;
1905
50.0k
    default:
1906
50.0k
      break;
1907
52.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
52.9k
  if (coff_section_data (abfd, section) == NULL)
1914
52.9k
    {
1915
52.9k
      amt = sizeof (struct coff_section_tdata);
1916
52.9k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
52.9k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
52.9k
    }
1921
1922
52.9k
  if (pei_section_data (abfd, section) == NULL)
1923
52.9k
    {
1924
52.9k
      amt = sizeof (struct pei_section_tdata);
1925
52.9k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
52.9k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
52.9k
    }
1930
52.9k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
52.9k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
52.9k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
52.9k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
4.55k
    {
1938
4.55k
      struct external_reloc dst;
1939
4.55k
      struct internal_reloc n;
1940
4.55k
      file_ptr oldpos = bfd_tell (abfd);
1941
4.55k
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
4.55k
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
4.55k
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
1.04k
  return;
1947
1948
3.51k
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
3.51k
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
3.51k
      if (n.r_vaddr < 0x10000)
1952
1.50k
  {
1953
1.50k
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
1.50k
    bfd_set_error (bfd_error_bad_value);
1955
1.50k
    return;
1956
1.50k
  }
1957
2.01k
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
2.01k
      section->rel_filepos += relsz;
1959
2.01k
    }
1960
48.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
52.9k
}
pei-sh.c:coff_set_alignment_hook
Line
Count
Source
1880
48.6k
{
1881
48.6k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
48.6k
  size_t amt;
1883
48.6k
  unsigned int alignment_power_const
1884
48.6k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
48.6k
  switch (alignment_power_const)
1887
48.6k
    {
1888
22
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
26
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
516
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
530
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
1.02k
    case IMAGE_SCN_ALIGN_512BYTES:
1893
1.02k
    case IMAGE_SCN_ALIGN_256BYTES:
1894
1.05k
    case IMAGE_SCN_ALIGN_128BYTES:
1895
2.04k
    case IMAGE_SCN_ALIGN_64BYTES:
1896
2.06k
    case IMAGE_SCN_ALIGN_32BYTES:
1897
2.06k
    case IMAGE_SCN_ALIGN_16BYTES:
1898
2.11k
    case IMAGE_SCN_ALIGN_8BYTES:
1899
2.62k
    case IMAGE_SCN_ALIGN_4BYTES:
1900
3.20k
    case IMAGE_SCN_ALIGN_2BYTES:
1901
3.23k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
3.23k
      section->alignment_power
1903
3.23k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
3.23k
      break;
1905
45.4k
    default:
1906
45.4k
      break;
1907
48.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
48.6k
  if (coff_section_data (abfd, section) == NULL)
1914
48.6k
    {
1915
48.6k
      amt = sizeof (struct coff_section_tdata);
1916
48.6k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
48.6k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
48.6k
    }
1921
1922
48.6k
  if (pei_section_data (abfd, section) == NULL)
1923
48.6k
    {
1924
48.6k
      amt = sizeof (struct pei_section_tdata);
1925
48.6k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
48.6k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
48.6k
    }
1930
48.6k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
48.6k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
48.6k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
48.6k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
4.05k
    {
1938
4.05k
      struct external_reloc dst;
1939
4.05k
      struct internal_reloc n;
1940
4.05k
      file_ptr oldpos = bfd_tell (abfd);
1941
4.05k
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
4.05k
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
4.05k
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
1.53k
  return;
1947
1948
2.52k
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
2.52k
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
2.52k
      if (n.r_vaddr < 0x10000)
1952
1.98k
  {
1953
1.98k
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
1.98k
    bfd_set_error (bfd_error_bad_value);
1955
1.98k
    return;
1956
1.98k
  }
1957
538
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
538
      section->rel_filepos += relsz;
1959
538
    }
1960
44.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
48.6k
}
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
99.3k
{
1978
99.3k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1979
99.3k
  asection *real_sec;
1980
1981
99.3k
  if ((hdr->s_flags & STYP_OVRFLO) == 0)
1982
75.8k
    return;
1983
1984
23.5k
  real_sec = coff_section_from_bfd_index (abfd, (int) hdr->s_nreloc);
1985
23.5k
  if (real_sec == NULL)
1986
0
    return;
1987
1988
23.5k
  real_sec->reloc_count = hdr->s_paddr;
1989
23.5k
  real_sec->lineno_count = hdr->s_vaddr;
1990
1991
23.5k
  if (!bfd_section_removed_from_list (abfd, section))
1992
23.5k
    {
1993
23.5k
      bfd_section_list_remove (abfd, section);
1994
23.5k
      --abfd->section_count;
1995
23.5k
    }
1996
23.5k
}
coff64-rs6000.c:coff_set_alignment_hook
Line
Count
Source
1977
70.8k
{
1978
70.8k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1979
70.8k
  asection *real_sec;
1980
1981
70.8k
  if ((hdr->s_flags & STYP_OVRFLO) == 0)
1982
50.9k
    return;
1983
1984
19.9k
  real_sec = coff_section_from_bfd_index (abfd, (int) hdr->s_nreloc);
1985
19.9k
  if (real_sec == NULL)
1986
0
    return;
1987
1988
19.9k
  real_sec->reloc_count = hdr->s_paddr;
1989
19.9k
  real_sec->lineno_count = hdr->s_vaddr;
1990
1991
19.9k
  if (!bfd_section_removed_from_list (abfd, section))
1992
19.9k
    {
1993
19.9k
      bfd_section_list_remove (abfd, section);
1994
19.9k
      --abfd->section_count;
1995
19.9k
    }
1996
19.9k
}
coff-rs6000.c:coff_set_alignment_hook
Line
Count
Source
1977
28.5k
{
1978
28.5k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1979
28.5k
  asection *real_sec;
1980
1981
28.5k
  if ((hdr->s_flags & STYP_OVRFLO) == 0)
1982
24.9k
    return;
1983
1984
3.62k
  real_sec = coff_section_from_bfd_index (abfd, (int) hdr->s_nreloc);
1985
3.62k
  if (real_sec == NULL)
1986
0
    return;
1987
1988
3.62k
  real_sec->reloc_count = hdr->s_paddr;
1989
3.62k
  real_sec->lineno_count = hdr->s_vaddr;
1990
1991
3.62k
  if (!bfd_section_removed_from_list (abfd, section))
1992
3.62k
    {
1993
3.62k
      bfd_section_list_remove (abfd, section);
1994
3.62k
      --abfd->section_count;
1995
3.62k
    }
1996
3.62k
}
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
180k
{
2004
180k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
2005
2006
  /* Check for extended relocs.  */
2007
180k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
2008
79.0k
    {
2009
79.0k
      struct external_reloc dst;
2010
79.0k
      struct internal_reloc n;
2011
79.0k
      const file_ptr oldpos = bfd_tell (abfd);
2012
79.0k
      const bfd_size_type relsz = bfd_coff_relsz (abfd);
2013
2014
79.0k
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
2015
0
  return;
2016
79.0k
      if (bfd_read (& dst, relsz, abfd) != relsz)
2017
78.7k
  return;
2018
2019
320
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
2020
320
      if (bfd_seek (abfd, oldpos, 0) != 0)
2021
0
  return;
2022
320
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
2023
320
      section->rel_filepos += relsz;
2024
320
    }
2025
101k
  else if (hdr->s_nreloc == 0xffff)
2026
88
    _bfd_error_handler
2027
88
      (_("%pB: warning: claims to have 0xffff relocs, without overflow"),
2028
88
       abfd);
2029
180k
}
coff-go32.c:coff_set_alignment_hook
Line
Count
Source
2003
180k
{
2004
180k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
2005
2006
  /* Check for extended relocs.  */
2007
180k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
2008
79.0k
    {
2009
79.0k
      struct external_reloc dst;
2010
79.0k
      struct internal_reloc n;
2011
79.0k
      const file_ptr oldpos = bfd_tell (abfd);
2012
79.0k
      const bfd_size_type relsz = bfd_coff_relsz (abfd);
2013
2014
79.0k
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
2015
0
  return;
2016
79.0k
      if (bfd_read (& dst, relsz, abfd) != relsz)
2017
78.7k
  return;
2018
2019
320
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
2020
320
      if (bfd_seek (abfd, oldpos, 0) != 0)
2021
0
  return;
2022
320
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
2023
320
      section->rel_filepos += relsz;
2024
320
    }
2025
101k
  else if (hdr->s_nreloc == 0xffff)
2026
88
    _bfd_error_handler
2027
88
      (_("%pB: warning: claims to have 0xffff relocs, without overflow"),
2028
88
       abfd);
2029
180k
}
Unexecuted instantiation: coff-stgo32.c:coff_set_alignment_hook
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
766k
{
2038
766k
}
coff-x86_64.c:coff_set_alignment_hook
Line
Count
Source
2037
371k
{
2038
371k
}
cf-i386lynx.c:coff_set_alignment_hook
Line
Count
Source
2037
187k
{
2038
187k
}
coff-i386.c:coff_set_alignment_hook
Line
Count
Source
2037
187k
{
2038
187k
}
coff-sh.c:coff_set_alignment_hook
Line
Count
Source
2037
10.2k
{
2038
10.2k
}
coff-tic30.c:coff_set_alignment_hook
Line
Count
Source
2037
6.64k
{
2038
6.64k
}
coff-z8k.c:coff_set_alignment_hook
Line
Count
Source
2037
3.82k
{
2038
3.82k
}
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
3.13k
{
2050
3.13k
  coff_data_type *coff;
2051
3.13k
  size_t amt = sizeof (coff_data_type);
2052
2053
3.13k
  abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt);
2054
3.13k
  if (abfd->tdata.coff_obj_data == NULL)
2055
0
    return false;
2056
2057
3.13k
  coff = coff_data (abfd);
2058
3.13k
  coff->symbols = NULL;
2059
3.13k
  coff->conversion_table = NULL;
2060
3.13k
  coff->raw_syments = NULL;
2061
3.13k
  coff->relocbase = 0;
2062
3.13k
  coff->local_toc_sym_map = 0;
2063
2064
3.13k
  bfd_coff_long_section_names (abfd)
2065
3.13k
    = coff_backend_info (abfd)->_bfd_coff_long_section_names;
2066
2067
/*  make_abs_section(abfd);*/
2068
2069
3.13k
  return true;
2070
3.13k
}
coff-x86_64.c:coff_mkobject
Line
Count
Source
2049
540
{
2050
540
  coff_data_type *coff;
2051
540
  size_t amt = sizeof (coff_data_type);
2052
2053
540
  abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt);
2054
540
  if (abfd->tdata.coff_obj_data == NULL)
2055
0
    return false;
2056
2057
540
  coff = coff_data (abfd);
2058
540
  coff->symbols = NULL;
2059
540
  coff->conversion_table = NULL;
2060
540
  coff->raw_syments = NULL;
2061
540
  coff->relocbase = 0;
2062
540
  coff->local_toc_sym_map = 0;
2063
2064
540
  bfd_coff_long_section_names (abfd)
2065
540
    = coff_backend_info (abfd)->_bfd_coff_long_section_names;
2066
2067
/*  make_abs_section(abfd);*/
2068
2069
540
  return true;
2070
540
}
cf-i386lynx.c:coff_mkobject
Line
Count
Source
2049
414
{
2050
414
  coff_data_type *coff;
2051
414
  size_t amt = sizeof (coff_data_type);
2052
2053
414
  abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt);
2054
414
  if (abfd->tdata.coff_obj_data == NULL)
2055
0
    return false;
2056
2057
414
  coff = coff_data (abfd);
2058
414
  coff->symbols = NULL;
2059
414
  coff->conversion_table = NULL;
2060
414
  coff->raw_syments = NULL;
2061
414
  coff->relocbase = 0;
2062
414
  coff->local_toc_sym_map = 0;
2063
2064
414
  bfd_coff_long_section_names (abfd)
2065
414
    = coff_backend_info (abfd)->_bfd_coff_long_section_names;
2066
2067
/*  make_abs_section(abfd);*/
2068
2069
414
  return true;
2070
414
}
coff-i386.c:coff_mkobject
Line
Count
Source
2049
414
{
2050
414
  coff_data_type *coff;
2051
414
  size_t amt = sizeof (coff_data_type);
2052
2053
414
  abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt);
2054
414
  if (abfd->tdata.coff_obj_data == NULL)
2055
0
    return false;
2056
2057
414
  coff = coff_data (abfd);
2058
414
  coff->symbols = NULL;
2059
414
  coff->conversion_table = NULL;
2060
414
  coff->raw_syments = NULL;
2061
414
  coff->relocbase = 0;
2062
414
  coff->local_toc_sym_map = 0;
2063
2064
414
  bfd_coff_long_section_names (abfd)
2065
414
    = coff_backend_info (abfd)->_bfd_coff_long_section_names;
2066
2067
/*  make_abs_section(abfd);*/
2068
2069
414
  return true;
2070
414
}
coff-sh.c:coff_mkobject
Line
Count
Source
2049
476
{
2050
476
  coff_data_type *coff;
2051
476
  size_t amt = sizeof (coff_data_type);
2052
2053
476
  abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt);
2054
476
  if (abfd->tdata.coff_obj_data == NULL)
2055
0
    return false;
2056
2057
476
  coff = coff_data (abfd);
2058
476
  coff->symbols = NULL;
2059
476
  coff->conversion_table = NULL;
2060
476
  coff->raw_syments = NULL;
2061
476
  coff->relocbase = 0;
2062
476
  coff->local_toc_sym_map = 0;
2063
2064
476
  bfd_coff_long_section_names (abfd)
2065
476
    = coff_backend_info (abfd)->_bfd_coff_long_section_names;
2066
2067
/*  make_abs_section(abfd);*/
2068
2069
476
  return true;
2070
476
}
coff-tic30.c:coff_mkobject
Line
Count
Source
2049
250
{
2050
250
  coff_data_type *coff;
2051
250
  size_t amt = sizeof (coff_data_type);
2052
2053
250
  abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt);
2054
250
  if (abfd->tdata.coff_obj_data == NULL)
2055
0
    return false;
2056
2057
250
  coff = coff_data (abfd);
2058
250
  coff->symbols = NULL;
2059
250
  coff->conversion_table = NULL;
2060
250
  coff->raw_syments = NULL;
2061
250
  coff->relocbase = 0;
2062
250
  coff->local_toc_sym_map = 0;
2063
2064
250
  bfd_coff_long_section_names (abfd)
2065
250
    = coff_backend_info (abfd)->_bfd_coff_long_section_names;
2066
2067
/*  make_abs_section(abfd);*/
2068
2069
250
  return true;
2070
250
}
Unexecuted instantiation: coff-tic4x.c:coff_mkobject
coff-tic54x.c:coff_mkobject
Line
Count
Source
2049
520
{
2050
520
  coff_data_type *coff;
2051
520
  size_t amt = sizeof (coff_data_type);
2052
2053
520
  abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt);
2054
520
  if (abfd->tdata.coff_obj_data == NULL)
2055
0
    return false;
2056
2057
520
  coff = coff_data (abfd);
2058
520
  coff->symbols = NULL;
2059
520
  coff->conversion_table = NULL;
2060
520
  coff->raw_syments = NULL;
2061
520
  coff->relocbase = 0;
2062
520
  coff->local_toc_sym_map = 0;
2063
2064
520
  bfd_coff_long_section_names (abfd)
2065
520
    = coff_backend_info (abfd)->_bfd_coff_long_section_names;
2066
2067
/*  make_abs_section(abfd);*/
2068
2069
520
  return true;
2070
520
}
coff-z80.c:coff_mkobject
Line
Count
Source
2049
256
{
2050
256
  coff_data_type *coff;
2051
256
  size_t amt = sizeof (coff_data_type);
2052
2053
256
  abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt);
2054
256
  if (abfd->tdata.coff_obj_data == NULL)
2055
0
    return false;
2056
2057
256
  coff = coff_data (abfd);
2058
256
  coff->symbols = NULL;
2059
256
  coff->conversion_table = NULL;
2060
256
  coff->raw_syments = NULL;
2061
256
  coff->relocbase = 0;
2062
256
  coff->local_toc_sym_map = 0;
2063
2064
256
  bfd_coff_long_section_names (abfd)
2065
256
    = coff_backend_info (abfd)->_bfd_coff_long_section_names;
2066
2067
/*  make_abs_section(abfd);*/
2068
2069
256
  return true;
2070
256
}
coff-z8k.c:coff_mkobject
Line
Count
Source
2049
262
{
2050
262
  coff_data_type *coff;
2051
262
  size_t amt = sizeof (coff_data_type);
2052
2053
262
  abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt);
2054
262
  if (abfd->tdata.coff_obj_data == NULL)
2055
0
    return false;
2056
2057
262
  coff = coff_data (abfd);
2058
262
  coff->symbols = NULL;
2059
262
  coff->conversion_table = NULL;
2060
262
  coff->raw_syments = NULL;
2061
262
  coff->relocbase = 0;
2062
262
  coff->local_toc_sym_map = 0;
2063
2064
262
  bfd_coff_long_section_names (abfd)
2065
262
    = coff_backend_info (abfd)->_bfd_coff_long_section_names;
2066
2067
/*  make_abs_section(abfd);*/
2068
2069
262
  return true;
2070
262
}
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
4.33k
{
2081
4.33k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2082
4.33k
  coff_data_type *coff;
2083
2084
4.33k
  if (! coff_mkobject (abfd))
2085
0
    return NULL;
2086
2087
4.33k
  coff = coff_data (abfd);
2088
2089
4.33k
  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.33k
  coff->local_n_btmask = N_BTMASK;
2095
4.33k
  coff->local_n_btshft = N_BTSHFT;
2096
4.33k
  coff->local_n_tmask = N_TMASK;
2097
4.33k
  coff->local_n_tshift = N_TSHIFT;
2098
4.33k
  coff->local_symesz = bfd_coff_symesz (abfd);
2099
4.33k
  coff->local_auxesz = bfd_coff_auxesz (abfd);
2100
4.33k
  coff->local_linesz = bfd_coff_linesz (abfd);
2101
2102
4.33k
  coff->timestamp = internal_f->f_timdat;
2103
2104
4.33k
  obj_raw_syment_count (abfd) =
2105
4.33k
    obj_conv_table_size (abfd) =
2106
4.33k
      internal_f->f_nsyms;
2107
2108
#ifdef RS6000COFF_C
2109
786
  if ((internal_f->f_flags & F_SHROBJ) != 0)
2110
106
    abfd->flags |= DYNAMIC;
2111
786
  if (aouthdr != NULL && internal_f->f_opthdr >= bfd_coff_aoutsz (abfd))
2112
138
    {
2113
138
      struct internal_aouthdr *internal_a =
2114
138
  (struct internal_aouthdr *) aouthdr;
2115
138
      struct xcoff_tdata *xcoff;
2116
2117
138
      xcoff = xcoff_data (abfd);
2118
# ifdef U803XTOCMAGIC
2119
64
      xcoff->xcoff64 = internal_f->f_magic == U803XTOCMAGIC;
2120
# else
2121
      xcoff->xcoff64 = 0;
2122
# endif
2123
138
      xcoff->full_aouthdr = true;
2124
138
      xcoff->toc = internal_a->o_toc;
2125
138
      xcoff->sntoc = internal_a->o_sntoc;
2126
138
      xcoff->snentry = internal_a->o_snentry;
2127
138
      bfd_xcoff_text_align_power (abfd) = internal_a->o_algntext;
2128
138
      bfd_xcoff_data_align_power (abfd) = internal_a->o_algndata;
2129
138
      xcoff->modtype = internal_a->o_modtype;
2130
138
      xcoff->cputype = internal_a->o_cputype;
2131
138
      xcoff->maxdata = internal_a->o_maxdata;
2132
138
      xcoff->maxstack = internal_a->o_maxstack;
2133
138
    }
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.33k
  return coff;
2150
4.33k
}
coff-x86_64.c:coff_mkobject_hook
Line
Count
Source
2080
540
{
2081
540
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2082
540
  coff_data_type *coff;
2083
2084
540
  if (! coff_mkobject (abfd))
2085
0
    return NULL;
2086
2087
540
  coff = coff_data (abfd);
2088
2089
540
  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
540
  coff->local_n_btmask = N_BTMASK;
2095
540
  coff->local_n_btshft = N_BTSHFT;
2096
540
  coff->local_n_tmask = N_TMASK;
2097
540
  coff->local_n_tshift = N_TSHIFT;
2098
540
  coff->local_symesz = bfd_coff_symesz (abfd);
2099
540
  coff->local_auxesz = bfd_coff_auxesz (abfd);
2100
540
  coff->local_linesz = bfd_coff_linesz (abfd);
2101
2102
540
  coff->timestamp = internal_f->f_timdat;
2103
2104
540
  obj_raw_syment_count (abfd) =
2105
540
    obj_conv_table_size (abfd) =
2106
540
      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
540
  return coff;
2150
540
}
coff64-rs6000.c:coff_mkobject_hook
Line
Count
Source
2080
408
{
2081
408
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2082
408
  coff_data_type *coff;
2083
2084
408
  if (! coff_mkobject (abfd))
2085
0
    return NULL;
2086
2087
408
  coff = coff_data (abfd);
2088
2089
408
  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
408
  coff->local_n_btmask = N_BTMASK;
2095
408
  coff->local_n_btshft = N_BTSHFT;
2096
408
  coff->local_n_tmask = N_TMASK;
2097
408
  coff->local_n_tshift = N_TSHIFT;
2098
408
  coff->local_symesz = bfd_coff_symesz (abfd);
2099
408
  coff->local_auxesz = bfd_coff_auxesz (abfd);
2100
408
  coff->local_linesz = bfd_coff_linesz (abfd);
2101
2102
408
  coff->timestamp = internal_f->f_timdat;
2103
2104
408
  obj_raw_syment_count (abfd) =
2105
408
    obj_conv_table_size (abfd) =
2106
408
      internal_f->f_nsyms;
2107
2108
408
#ifdef RS6000COFF_C
2109
408
  if ((internal_f->f_flags & F_SHROBJ) != 0)
2110
16
    abfd->flags |= DYNAMIC;
2111
408
  if (aouthdr != NULL && internal_f->f_opthdr >= bfd_coff_aoutsz (abfd))
2112
64
    {
2113
64
      struct internal_aouthdr *internal_a =
2114
64
  (struct internal_aouthdr *) aouthdr;
2115
64
      struct xcoff_tdata *xcoff;
2116
2117
64
      xcoff = xcoff_data (abfd);
2118
64
# ifdef U803XTOCMAGIC
2119
64
      xcoff->xcoff64 = internal_f->f_magic == U803XTOCMAGIC;
2120
# else
2121
      xcoff->xcoff64 = 0;
2122
# endif
2123
64
      xcoff->full_aouthdr = true;
2124
64
      xcoff->toc = internal_a->o_toc;
2125
64
      xcoff->sntoc = internal_a->o_sntoc;
2126
64
      xcoff->snentry = internal_a->o_snentry;
2127
64
      bfd_xcoff_text_align_power (abfd) = internal_a->o_algntext;
2128
64
      bfd_xcoff_data_align_power (abfd) = internal_a->o_algndata;
2129
64
      xcoff->modtype = internal_a->o_modtype;
2130
64
      xcoff->cputype = internal_a->o_cputype;
2131
64
      xcoff->maxdata = internal_a->o_maxdata;
2132
64
      xcoff->maxstack = internal_a->o_maxstack;
2133
64
    }
2134
408
#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
408
  return coff;
2150
408
}
cf-i386lynx.c:coff_mkobject_hook
Line
Count
Source
2080
414
{
2081
414
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2082
414
  coff_data_type *coff;
2083
2084
414
  if (! coff_mkobject (abfd))
2085
0
    return NULL;
2086
2087
414
  coff = coff_data (abfd);
2088
2089
414
  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
414
  coff->local_n_btmask = N_BTMASK;
2095
414
  coff->local_n_btshft = N_BTSHFT;
2096
414
  coff->local_n_tmask = N_TMASK;
2097
414
  coff->local_n_tshift = N_TSHIFT;
2098
414
  coff->local_symesz = bfd_coff_symesz (abfd);
2099
414
  coff->local_auxesz = bfd_coff_auxesz (abfd);
2100
414
  coff->local_linesz = bfd_coff_linesz (abfd);
2101
2102
414
  coff->timestamp = internal_f->f_timdat;
2103
2104
414
  obj_raw_syment_count (abfd) =
2105
414
    obj_conv_table_size (abfd) =
2106
414
      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
414
  return coff;
2150
414
}
coff-go32.c:coff_mkobject_hook
Line
Count
Source
2080
414
{
2081
414
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2082
414
  coff_data_type *coff;
2083
2084
414
  if (! coff_mkobject (abfd))
2085
0
    return NULL;
2086
2087
414
  coff = coff_data (abfd);
2088
2089
414
  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
414
  coff->local_n_btmask = N_BTMASK;
2095
414
  coff->local_n_btshft = N_BTSHFT;
2096
414
  coff->local_n_tmask = N_TMASK;
2097
414
  coff->local_n_tshift = N_TSHIFT;
2098
414
  coff->local_symesz = bfd_coff_symesz (abfd);
2099
414
  coff->local_auxesz = bfd_coff_auxesz (abfd);
2100
414
  coff->local_linesz = bfd_coff_linesz (abfd);
2101
2102
414
  coff->timestamp = internal_f->f_timdat;
2103
2104
414
  obj_raw_syment_count (abfd) =
2105
414
    obj_conv_table_size (abfd) =
2106
414
      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
414
  return coff;
2150
414
}
coff-i386.c:coff_mkobject_hook
Line
Count
Source
2080
414
{
2081
414
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2082
414
  coff_data_type *coff;
2083
2084
414
  if (! coff_mkobject (abfd))
2085
0
    return NULL;
2086
2087
414
  coff = coff_data (abfd);
2088
2089
414
  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
414
  coff->local_n_btmask = N_BTMASK;
2095
414
  coff->local_n_btshft = N_BTSHFT;
2096
414
  coff->local_n_tmask = N_TMASK;
2097
414
  coff->local_n_tshift = N_TSHIFT;
2098
414
  coff->local_symesz = bfd_coff_symesz (abfd);
2099
414
  coff->local_auxesz = bfd_coff_auxesz (abfd);
2100
414
  coff->local_linesz = bfd_coff_linesz (abfd);
2101
2102
414
  coff->timestamp = internal_f->f_timdat;
2103
2104
414
  obj_raw_syment_count (abfd) =
2105
414
    obj_conv_table_size (abfd) =
2106
414
      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
414
  return coff;
2150
414
}
coff-rs6000.c:coff_mkobject_hook
Line
Count
Source
2080
378
{
2081
378
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2082
378
  coff_data_type *coff;
2083
2084
378
  if (! coff_mkobject (abfd))
2085
0
    return NULL;
2086
2087
378
  coff = coff_data (abfd);
2088
2089
378
  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
378
  coff->local_n_btmask = N_BTMASK;
2095
378
  coff->local_n_btshft = N_BTSHFT;
2096
378
  coff->local_n_tmask = N_TMASK;
2097
378
  coff->local_n_tshift = N_TSHIFT;
2098
378
  coff->local_symesz = bfd_coff_symesz (abfd);
2099
378
  coff->local_auxesz = bfd_coff_auxesz (abfd);
2100
378
  coff->local_linesz = bfd_coff_linesz (abfd);
2101
2102
378
  coff->timestamp = internal_f->f_timdat;
2103
2104
378
  obj_raw_syment_count (abfd) =
2105
378
    obj_conv_table_size (abfd) =
2106
378
      internal_f->f_nsyms;
2107
2108
378
#ifdef RS6000COFF_C
2109
378
  if ((internal_f->f_flags & F_SHROBJ) != 0)
2110
90
    abfd->flags |= DYNAMIC;
2111
378
  if (aouthdr != NULL && internal_f->f_opthdr >= bfd_coff_aoutsz (abfd))
2112
74
    {
2113
74
      struct internal_aouthdr *internal_a =
2114
74
  (struct internal_aouthdr *) aouthdr;
2115
74
      struct xcoff_tdata *xcoff;
2116
2117
74
      xcoff = xcoff_data (abfd);
2118
# ifdef U803XTOCMAGIC
2119
      xcoff->xcoff64 = internal_f->f_magic == U803XTOCMAGIC;
2120
# else
2121
74
      xcoff->xcoff64 = 0;
2122
74
# endif
2123
74
      xcoff->full_aouthdr = true;
2124
74
      xcoff->toc = internal_a->o_toc;
2125
74
      xcoff->sntoc = internal_a->o_sntoc;
2126
74
      xcoff->snentry = internal_a->o_snentry;
2127
74
      bfd_xcoff_text_align_power (abfd) = internal_a->o_algntext;
2128
74
      bfd_xcoff_data_align_power (abfd) = internal_a->o_algndata;
2129
74
      xcoff->modtype = internal_a->o_modtype;
2130
74
      xcoff->cputype = internal_a->o_cputype;
2131
74
      xcoff->maxdata = internal_a->o_maxdata;
2132
74
      xcoff->maxstack = internal_a->o_maxstack;
2133
74
    }
2134
378
#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
378
  return coff;
2150
378
}
coff-sh.c:coff_mkobject_hook
Line
Count
Source
2080
476
{
2081
476
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2082
476
  coff_data_type *coff;
2083
2084
476
  if (! coff_mkobject (abfd))
2085
0
    return NULL;
2086
2087
476
  coff = coff_data (abfd);
2088
2089
476
  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
476
  coff->local_n_btmask = N_BTMASK;
2095
476
  coff->local_n_btshft = N_BTSHFT;
2096
476
  coff->local_n_tmask = N_TMASK;
2097
476
  coff->local_n_tshift = N_TSHIFT;
2098
476
  coff->local_symesz = bfd_coff_symesz (abfd);
2099
476
  coff->local_auxesz = bfd_coff_auxesz (abfd);
2100
476
  coff->local_linesz = bfd_coff_linesz (abfd);
2101
2102
476
  coff->timestamp = internal_f->f_timdat;
2103
2104
476
  obj_raw_syment_count (abfd) =
2105
476
    obj_conv_table_size (abfd) =
2106
476
      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
476
  return coff;
2150
476
}
Unexecuted instantiation: coff-stgo32.c:coff_mkobject_hook
coff-tic30.c:coff_mkobject_hook
Line
Count
Source
2080
250
{
2081
250
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2082
250
  coff_data_type *coff;
2083
2084
250
  if (! coff_mkobject (abfd))
2085
0
    return NULL;
2086
2087
250
  coff = coff_data (abfd);
2088
2089
250
  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
250
  coff->local_n_btmask = N_BTMASK;
2095
250
  coff->local_n_btshft = N_BTSHFT;
2096
250
  coff->local_n_tmask = N_TMASK;
2097
250
  coff->local_n_tshift = N_TSHIFT;
2098
250
  coff->local_symesz = bfd_coff_symesz (abfd);
2099
250
  coff->local_auxesz = bfd_coff_auxesz (abfd);
2100
250
  coff->local_linesz = bfd_coff_linesz (abfd);
2101
2102
250
  coff->timestamp = internal_f->f_timdat;
2103
2104
250
  obj_raw_syment_count (abfd) =
2105
250
    obj_conv_table_size (abfd) =
2106
250
      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
250
  return coff;
2150
250
}
Unexecuted instantiation: coff-tic4x.c:coff_mkobject_hook
coff-tic54x.c:coff_mkobject_hook
Line
Count
Source
2080
520
{
2081
520
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2082
520
  coff_data_type *coff;
2083
2084
520
  if (! coff_mkobject (abfd))
2085
0
    return NULL;
2086
2087
520
  coff = coff_data (abfd);
2088
2089
520
  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
520
  coff->local_n_btmask = N_BTMASK;
2095
520
  coff->local_n_btshft = N_BTSHFT;
2096
520
  coff->local_n_tmask = N_TMASK;
2097
520
  coff->local_n_tshift = N_TSHIFT;
2098
520
  coff->local_symesz = bfd_coff_symesz (abfd);
2099
520
  coff->local_auxesz = bfd_coff_auxesz (abfd);
2100
520
  coff->local_linesz = bfd_coff_linesz (abfd);
2101
2102
520
  coff->timestamp = internal_f->f_timdat;
2103
2104
520
  obj_raw_syment_count (abfd) =
2105
520
    obj_conv_table_size (abfd) =
2106
520
      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
520
  return coff;
2150
520
}
coff-z80.c:coff_mkobject_hook
Line
Count
Source
2080
256
{
2081
256
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2082
256
  coff_data_type *coff;
2083
2084
256
  if (! coff_mkobject (abfd))
2085
0
    return NULL;
2086
2087
256
  coff = coff_data (abfd);
2088
2089
256
  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
256
  coff->local_n_btmask = N_BTMASK;
2095
256
  coff->local_n_btshft = N_BTSHFT;
2096
256
  coff->local_n_tmask = N_TMASK;
2097
256
  coff->local_n_tshift = N_TSHIFT;
2098
256
  coff->local_symesz = bfd_coff_symesz (abfd);
2099
256
  coff->local_auxesz = bfd_coff_auxesz (abfd);
2100
256
  coff->local_linesz = bfd_coff_linesz (abfd);
2101
2102
256
  coff->timestamp = internal_f->f_timdat;
2103
2104
256
  obj_raw_syment_count (abfd) =
2105
256
    obj_conv_table_size (abfd) =
2106
256
      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
256
  return coff;
2150
256
}
coff-z8k.c:coff_mkobject_hook
Line
Count
Source
2080
262
{
2081
262
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2082
262
  coff_data_type *coff;
2083
2084
262
  if (! coff_mkobject (abfd))
2085
0
    return NULL;
2086
2087
262
  coff = coff_data (abfd);
2088
2089
262
  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
262
  coff->local_n_btmask = N_BTMASK;
2095
262
  coff->local_n_btshft = N_BTSHFT;
2096
262
  coff->local_n_tmask = N_TMASK;
2097
262
  coff->local_n_tshift = N_TSHIFT;
2098
262
  coff->local_symesz = bfd_coff_symesz (abfd);
2099
262
  coff->local_auxesz = bfd_coff_auxesz (abfd);
2100
262
  coff->local_linesz = bfd_coff_linesz (abfd);
2101
2102
262
  coff->timestamp = internal_f->f_timdat;
2103
2104
262
  obj_raw_syment_count (abfd) =
2105
262
    obj_conv_table_size (abfd) =
2106
262
      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
262
  return coff;
2150
262
}
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
74.3k
{
2163
74.3k
  unsigned long machine;
2164
74.3k
  enum bfd_architecture arch;
2165
74.3k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
74.3k
  machine = 0;
2169
74.3k
  switch (internal_f->f_magic)
2170
74.3k
    {
2171
#ifdef I386MAGIC
2172
34
    case I386MAGIC:
2173
212
    case I386PTXMAGIC:
2174
294
    case I386AIXMAGIC:   /* Danbury PS/2 AIX C Compiler.  */
2175
4.89k
    case LYNXCOFFMAGIC:
2176
5.48k
    case I386_APPLE_MAGIC:
2177
5.49k
    case I386_FREEBSD_MAGIC:
2178
5.49k
    case I386_LINUX_MAGIC:
2179
5.50k
    case I386_NETBSD_MAGIC:
2180
5.50k
      arch = bfd_arch_i386;
2181
5.50k
      break;
2182
0
#endif
2183
#ifdef AMD64MAGIC
2184
680
    case AMD64MAGIC:
2185
1.78k
    case AMD64_APPLE_MAGIC:
2186
1.78k
    case AMD64_FREEBSD_MAGIC:
2187
1.78k
    case AMD64_LINUX_MAGIC:
2188
1.81k
    case AMD64_NETBSD_MAGIC:
2189
1.81k
      arch = bfd_arch_i386;
2190
1.81k
      machine = bfd_mach_x86_64;
2191
1.81k
      break;
2192
0
#endif
2193
#ifdef IA64MAGIC
2194
13.3k
    case IA64MAGIC:
2195
13.3k
      arch = bfd_arch_ia64;
2196
13.3k
      break;
2197
0
#endif
2198
#ifdef ARMMAGIC
2199
20.4k
    case ARMMAGIC:
2200
20.5k
    case ARMPEMAGIC:
2201
20.5k
    case THUMBPEMAGIC:
2202
20.5k
      arch = bfd_arch_arm;
2203
20.5k
      machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION);
2204
20.5k
      if (machine == bfd_mach_arm_unknown)
2205
20.5k
  {
2206
20.5k
    switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK)
2207
20.5k
      {
2208
512
      case F_ARM_2:  machine = bfd_mach_arm_2;  break;
2209
1.09k
      case F_ARM_2a: machine = bfd_mach_arm_2a; break;
2210
1.00k
      case F_ARM_3:  machine = bfd_mach_arm_3;  break;
2211
12.9k
      default:
2212
12.9k
      case F_ARM_3M: machine = bfd_mach_arm_3M; break;
2213
1.97k
      case F_ARM_4:  machine = bfd_mach_arm_4;  break;
2214
1.50k
      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.50k
      case F_ARM_5:  machine = bfd_mach_arm_XScale;  break;
2221
20.5k
      }
2222
20.5k
  }
2223
20.5k
      break;
2224
20.5k
#endif
2225
#ifdef AARCH64MAGIC
2226
7.81k
    case AARCH64MAGIC:
2227
7.81k
      arch = bfd_arch_aarch64;
2228
7.81k
      machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK;
2229
7.81k
      break;
2230
0
#endif
2231
#ifdef LOONGARCH64MAGIC
2232
364
    case LOONGARCH64MAGIC:
2233
364
      arch = bfd_arch_loongarch;
2234
364
      machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK;
2235
364
      break;
2236
0
#endif
2237
#ifdef Z80MAGIC
2238
254
    case Z80MAGIC:
2239
254
      arch = bfd_arch_z80;
2240
254
      switch (internal_f->f_flags & F_MACHMASK)
2241
254
  {
2242
2
  case bfd_mach_z80strict << 12:
2243
208
  case bfd_mach_z80 << 12:
2244
210
  case bfd_mach_z80n << 12:
2245
212
  case bfd_mach_z80full << 12:
2246
212
  case bfd_mach_r800 << 12:
2247
214
  case bfd_mach_gbz80 << 12:
2248
238
  case bfd_mach_z180 << 12:
2249
240
  case bfd_mach_ez80_z80 << 12:
2250
252
  case bfd_mach_ez80_adl << 12:
2251
252
    machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12;
2252
252
    break;
2253
2
  default:
2254
2
    return false;
2255
254
  }
2256
252
      break;
2257
252
#endif
2258
#ifdef Z8KMAGIC
2259
262
    case Z8KMAGIC:
2260
262
      arch = bfd_arch_z8k;
2261
262
      switch (internal_f->f_flags & F_MACHMASK)
2262
262
  {
2263
174
  case F_Z8001:
2264
174
    machine = bfd_mach_z8001;
2265
174
    break;
2266
86
  case F_Z8002:
2267
86
    machine = bfd_mach_z8002;
2268
86
    break;
2269
2
  default:
2270
2
    return false;
2271
262
  }
2272
260
      break;
2273
260
#endif
2274
2275
#ifdef RS6000COFF_C
2276
#ifdef XCOFF64
2277
370
    case U64_TOCMAGIC:
2278
404
    case U803XTOCMAGIC:
2279
#else
2280
362
    case U802ROMAGIC:
2281
364
    case U802WRMAGIC:
2282
372
    case U802TOCMAGIC:
2283
#endif
2284
372
      {
2285
372
  int cputype;
2286
2287
776
  if (xcoff_data (abfd)->cputype != -1)
2288
136
    cputype = xcoff_data (abfd)->cputype & 0xff;
2289
640
  else
2290
640
    {
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
640
      if (obj_raw_syment_count (abfd) == 0)
2296
250
        cputype = 0;
2297
390
      else
2298
390
        {
2299
390
    bfd_byte *buf;
2300
390
    struct internal_syment sym;
2301
390
    bfd_size_type amt = bfd_coff_symesz (abfd);
2302
2303
390
    if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
2304
2
      return false;
2305
388
    buf = _bfd_malloc_and_read (abfd, amt, amt);
2306
388
    if (buf == NULL)
2307
10
      return false;
2308
378
    bfd_coff_swap_sym_in (abfd, buf, & sym);
2309
378
    if (sym.n_sclass == C_FILE)
2310
32
      cputype = sym.n_type & 0xff;
2311
346
    else
2312
346
      cputype = 0;
2313
378
    free (buf);
2314
378
        }
2315
640
    }
2316
2317
  /* FIXME: We don't handle all cases here.  */
2318
764
  switch (cputype)
2319
764
    {
2320
76
    default:
2321
726
    case 0:
2322
726
      arch = bfd_xcoff_architecture (abfd);
2323
726
      machine = bfd_xcoff_machine (abfd);
2324
726
      break;
2325
2326
12
    case 1:
2327
12
      arch = bfd_arch_powerpc;
2328
12
      machine = bfd_mach_ppc_601;
2329
12
      break;
2330
6
    case 2: /* 64 bit PowerPC */
2331
6
      arch = bfd_arch_powerpc;
2332
6
      machine = bfd_mach_ppc_620;
2333
6
      break;
2334
8
    case 3:
2335
8
      arch = bfd_arch_powerpc;
2336
8
      machine = bfd_mach_ppc;
2337
8
      break;
2338
12
    case 4:
2339
12
      arch = bfd_arch_rs6000;
2340
12
      machine = bfd_mach_rs6k;
2341
12
      break;
2342
764
    }
2343
764
      }
2344
764
      break;
2345
764
#endif
2346
2347
#ifdef SH_ARCH_MAGIC_BIG
2348
11.3k
    case SH_ARCH_MAGIC_BIG:
2349
11.3k
    case SH_ARCH_MAGIC_LITTLE:
2350
#ifdef COFF_WITH_PE
2351
11.4k
    case SH_ARCH_MAGIC_WINCE:
2352
#endif
2353
11.4k
      arch = bfd_arch_sh;
2354
11.4k
      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
250
    case TIC30MAGIC:
2374
250
      arch = bfd_arch_tic30;
2375
250
      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
498
    case TICOFF0MAGIC:
2382
498
      arch = TICOFF_TARGET_ARCH;
2383
498
      machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2384
498
      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
8
    case TICOFF1MAGIC:
2392
12
    case TICOFF2MAGIC:
2393
12
      switch (internal_f->f_target_id)
2394
12
  {
2395
0
#ifdef TI_TARGET_ID
2396
12
  case TI_TARGET_ID:
2397
12
    arch = TICOFF_TARGET_ARCH;
2398
12
    machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2399
12
    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
12
  }
2408
12
      break;
2409
12
#endif
2410
2411
#ifdef MCOREMAGIC
2412
10.9k
    case MCOREMAGIC:
2413
10.9k
      arch = bfd_arch_mcore;
2414
10.9k
      break;
2415
0
#endif
2416
2417
188
    default:      /* Unreadable input file type.  */
2418
188
      arch = bfd_arch_obscure;
2419
188
      break;
2420
74.3k
    }
2421
2422
74.3k
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
74.3k
  return true;
2424
74.3k
}
pei-i386.c:coff_set_arch_mach_hook
Line
Count
Source
2162
3.29k
{
2163
3.29k
  unsigned long machine;
2164
3.29k
  enum bfd_architecture arch;
2165
3.29k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
3.29k
  machine = 0;
2169
3.29k
  switch (internal_f->f_magic)
2170
3.29k
    {
2171
0
#ifdef I386MAGIC
2172
10
    case I386MAGIC:
2173
12
    case I386PTXMAGIC:
2174
78
    case I386AIXMAGIC:   /* Danbury PS/2 AIX C Compiler.  */
2175
3.29k
    case LYNXCOFFMAGIC:
2176
3.29k
    case I386_APPLE_MAGIC:
2177
3.29k
    case I386_FREEBSD_MAGIC:
2178
3.29k
    case I386_LINUX_MAGIC:
2179
3.29k
    case I386_NETBSD_MAGIC:
2180
3.29k
      arch = bfd_arch_i386;
2181
3.29k
      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
3.29k
    }
2421
2422
3.29k
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
3.29k
  return true;
2424
3.29k
}
pe-x86_64.c:coff_set_arch_mach_hook
Line
Count
Source
2162
774
{
2163
774
  unsigned long machine;
2164
774
  enum bfd_architecture arch;
2165
774
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
774
  machine = 0;
2169
774
  switch (internal_f->f_magic)
2170
774
    {
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
104
    case AMD64MAGIC:
2185
756
    case AMD64_APPLE_MAGIC:
2186
760
    case AMD64_FREEBSD_MAGIC:
2187
760
    case AMD64_LINUX_MAGIC:
2188
774
    case AMD64_NETBSD_MAGIC:
2189
774
      arch = bfd_arch_i386;
2190
774
      machine = bfd_mach_x86_64;
2191
774
      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
774
    }
2421
2422
774
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
774
  return true;
2424
774
}
pei-x86_64.c:coff_set_arch_mach_hook
Line
Count
Source
2162
506
{
2163
506
  unsigned long machine;
2164
506
  enum bfd_architecture arch;
2165
506
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
506
  machine = 0;
2169
506
  switch (internal_f->f_magic)
2170
506
    {
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
506
    case AMD64MAGIC:
2185
506
    case AMD64_APPLE_MAGIC:
2186
506
    case AMD64_FREEBSD_MAGIC:
2187
506
    case AMD64_LINUX_MAGIC:
2188
506
    case AMD64_NETBSD_MAGIC:
2189
506
      arch = bfd_arch_i386;
2190
506
      machine = bfd_mach_x86_64;
2191
506
      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
506
    }
2421
2422
506
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
506
  return true;
2424
506
}
coff-x86_64.c:coff_set_arch_mach_hook
Line
Count
Source
2162
532
{
2163
532
  unsigned long machine;
2164
532
  enum bfd_architecture arch;
2165
532
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
532
  machine = 0;
2169
532
  switch (internal_f->f_magic)
2170
532
    {
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
70
    case AMD64MAGIC:
2185
520
    case AMD64_APPLE_MAGIC:
2186
522
    case AMD64_FREEBSD_MAGIC:
2187
522
    case AMD64_LINUX_MAGIC:
2188
532
    case AMD64_NETBSD_MAGIC:
2189
532
      arch = bfd_arch_i386;
2190
532
      machine = bfd_mach_x86_64;
2191
532
      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
532
    }
2421
2422
532
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
532
  return true;
2424
532
}
coff64-rs6000.c:coff_set_arch_mach_hook
Line
Count
Source
2162
404
{
2163
404
  unsigned long machine;
2164
404
  enum bfd_architecture arch;
2165
404
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
404
  machine = 0;
2169
404
  switch (internal_f->f_magic)
2170
404
    {
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
370
    case U64_TOCMAGIC:
2278
404
    case U803XTOCMAGIC:
2279
#else
2280
    case U802ROMAGIC:
2281
    case U802WRMAGIC:
2282
    case U802TOCMAGIC:
2283
#endif
2284
404
      {
2285
404
  int cputype;
2286
2287
404
  if (xcoff_data (abfd)->cputype != -1)
2288
64
    cputype = xcoff_data (abfd)->cputype & 0xff;
2289
340
  else
2290
340
    {
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
340
      if (obj_raw_syment_count (abfd) == 0)
2296
170
        cputype = 0;
2297
170
      else
2298
170
        {
2299
170
    bfd_byte *buf;
2300
170
    struct internal_syment sym;
2301
170
    bfd_size_type amt = bfd_coff_symesz (abfd);
2302
2303
170
    if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
2304
2
      return false;
2305
168
    buf = _bfd_malloc_and_read (abfd, amt, amt);
2306
168
    if (buf == NULL)
2307
4
      return false;
2308
164
    bfd_coff_swap_sym_in (abfd, buf, & sym);
2309
164
    if (sym.n_sclass == C_FILE)
2310
12
      cputype = sym.n_type & 0xff;
2311
152
    else
2312
152
      cputype = 0;
2313
164
    free (buf);
2314
164
        }
2315
340
    }
2316
2317
  /* FIXME: We don't handle all cases here.  */
2318
398
  switch (cputype)
2319
398
    {
2320
38
    default:
2321
384
    case 0:
2322
384
      arch = bfd_xcoff_architecture (abfd);
2323
384
      machine = bfd_xcoff_machine (abfd);
2324
384
      break;
2325
2326
2
    case 1:
2327
2
      arch = bfd_arch_powerpc;
2328
2
      machine = bfd_mach_ppc_601;
2329
2
      break;
2330
4
    case 2: /* 64 bit PowerPC */
2331
4
      arch = bfd_arch_powerpc;
2332
4
      machine = bfd_mach_ppc_620;
2333
4
      break;
2334
4
    case 3:
2335
4
      arch = bfd_arch_powerpc;
2336
4
      machine = bfd_mach_ppc;
2337
4
      break;
2338
4
    case 4:
2339
4
      arch = bfd_arch_rs6000;
2340
4
      machine = bfd_mach_rs6k;
2341
4
      break;
2342
398
    }
2343
398
      }
2344
398
      break;
2345
398
#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
398
    default:      /* Unreadable input file type.  */
2418
0
      arch = bfd_arch_obscure;
2419
0
      break;
2420
404
    }
2421
2422
398
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
398
  return true;
2424
404
}
pe-aarch64.c:coff_set_arch_mach_hook
Line
Count
Source
2162
1.24k
{
2163
1.24k
  unsigned long machine;
2164
1.24k
  enum bfd_architecture arch;
2165
1.24k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
1.24k
  machine = 0;
2169
1.24k
  switch (internal_f->f_magic)
2170
1.24k
    {
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
1.24k
    case AARCH64MAGIC:
2227
1.24k
      arch = bfd_arch_aarch64;
2228
1.24k
      machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK;
2229
1.24k
      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
1.24k
    }
2421
2422
1.24k
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
1.24k
  return true;
2424
1.24k
}
pei-aarch64.c:coff_set_arch_mach_hook
Line
Count
Source
2162
6.57k
{
2163
6.57k
  unsigned long machine;
2164
6.57k
  enum bfd_architecture arch;
2165
6.57k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
6.57k
  machine = 0;
2169
6.57k
  switch (internal_f->f_magic)
2170
6.57k
    {
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
6.57k
    case AARCH64MAGIC:
2227
6.57k
      arch = bfd_arch_aarch64;
2228
6.57k
      machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK;
2229
6.57k
      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
6.57k
    }
2421
2422
6.57k
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
6.57k
  return true;
2424
6.57k
}
pei-ia64.c:coff_set_arch_mach_hook
Line
Count
Source
2162
13.3k
{
2163
13.3k
  unsigned long machine;
2164
13.3k
  enum bfd_architecture arch;
2165
13.3k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
13.3k
  machine = 0;
2169
13.3k
  switch (internal_f->f_magic)
2170
13.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
#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
13.3k
    case IA64MAGIC:
2195
13.3k
      arch = bfd_arch_ia64;
2196
13.3k
      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
13.3k
    }
2421
2422
13.3k
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
13.3k
  return true;
2424
13.3k
}
pei-loongarch64.c:coff_set_arch_mach_hook
Line
Count
Source
2162
364
{
2163
364
  unsigned long machine;
2164
364
  enum bfd_architecture arch;
2165
364
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
364
  machine = 0;
2169
364
  switch (internal_f->f_magic)
2170
364
    {
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
364
    case LOONGARCH64MAGIC:
2233
364
      arch = bfd_arch_loongarch;
2234
364
      machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK;
2235
364
      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
364
    }
2421
2422
364
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
364
  return true;
2424
364
}
cf-i386lynx.c:coff_set_arch_mach_hook
Line
Count
Source
2162
388
{
2163
388
  unsigned long machine;
2164
388
  enum bfd_architecture arch;
2165
388
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
388
  machine = 0;
2169
388
  switch (internal_f->f_magic)
2170
388
    {
2171
0
#ifdef I386MAGIC
2172
6
    case I386MAGIC:
2173
50
    case I386PTXMAGIC:
2174
54
    case I386AIXMAGIC:   /* Danbury PS/2 AIX C Compiler.  */
2175
370
    case LYNXCOFFMAGIC:
2176
384
    case I386_APPLE_MAGIC:
2177
386
    case I386_FREEBSD_MAGIC:
2178
386
    case I386_LINUX_MAGIC:
2179
388
    case I386_NETBSD_MAGIC:
2180
388
      arch = bfd_arch_i386;
2181
388
      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
388
    }
2421
2422
388
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
388
  return true;
2424
388
}
coff-go32.c:coff_set_arch_mach_hook
Line
Count
Source
2162
388
{
2163
388
  unsigned long machine;
2164
388
  enum bfd_architecture arch;
2165
388
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
388
  machine = 0;
2169
388
  switch (internal_f->f_magic)
2170
388
    {
2171
0
#ifdef I386MAGIC
2172
6
    case I386MAGIC:
2173
50
    case I386PTXMAGIC:
2174
54
    case I386AIXMAGIC:   /* Danbury PS/2 AIX C Compiler.  */
2175
370
    case LYNXCOFFMAGIC:
2176
384
    case I386_APPLE_MAGIC:
2177
386
    case I386_FREEBSD_MAGIC:
2178
386
    case I386_LINUX_MAGIC:
2179
388
    case I386_NETBSD_MAGIC:
2180
388
      arch = bfd_arch_i386;
2181
388
      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
388
    }
2421
2422
388
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
388
  return true;
2424
388
}
coff-i386.c:coff_set_arch_mach_hook
Line
Count
Source
2162
388
{
2163
388
  unsigned long machine;
2164
388
  enum bfd_architecture arch;
2165
388
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
388
  machine = 0;
2169
388
  switch (internal_f->f_magic)
2170
388
    {
2171
0
#ifdef I386MAGIC
2172
6
    case I386MAGIC:
2173
50
    case I386PTXMAGIC:
2174
54
    case I386AIXMAGIC:   /* Danbury PS/2 AIX C Compiler.  */
2175
370
    case LYNXCOFFMAGIC:
2176
384
    case I386_APPLE_MAGIC:
2177
386
    case I386_FREEBSD_MAGIC:
2178
386
    case I386_LINUX_MAGIC:
2179
388
    case I386_NETBSD_MAGIC:
2180
388
      arch = bfd_arch_i386;
2181
388
      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
388
    }
2421
2422
388
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
388
  return true;
2424
388
}
coff-rs6000.c:coff_set_arch_mach_hook
Line
Count
Source
2162
372
{
2163
372
  unsigned long machine;
2164
372
  enum bfd_architecture arch;
2165
372
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
372
  machine = 0;
2169
372
  switch (internal_f->f_magic)
2170
372
    {
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
362
    case U802ROMAGIC:
2281
364
    case U802WRMAGIC:
2282
372
    case U802TOCMAGIC:
2283
372
#endif
2284
372
      {
2285
372
  int cputype;
2286
2287
372
  if (xcoff_data (abfd)->cputype != -1)
2288
72
    cputype = xcoff_data (abfd)->cputype & 0xff;
2289
300
  else
2290
300
    {
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
300
      if (obj_raw_syment_count (abfd) == 0)
2296
80
        cputype = 0;
2297
220
      else
2298
220
        {
2299
220
    bfd_byte *buf;
2300
220
    struct internal_syment sym;
2301
220
    bfd_size_type amt = bfd_coff_symesz (abfd);
2302
2303
220
    if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
2304
0
      return false;
2305
220
    buf = _bfd_malloc_and_read (abfd, amt, amt);
2306
220
    if (buf == NULL)
2307
6
      return false;
2308
214
    bfd_coff_swap_sym_in (abfd, buf, & sym);
2309
214
    if (sym.n_sclass == C_FILE)
2310
20
      cputype = sym.n_type & 0xff;
2311
194
    else
2312
194
      cputype = 0;
2313
214
    free (buf);
2314
214
        }
2315
300
    }
2316
2317
  /* FIXME: We don't handle all cases here.  */
2318
366
  switch (cputype)
2319
366
    {
2320
38
    default:
2321
342
    case 0:
2322
342
      arch = bfd_xcoff_architecture (abfd);
2323
342
      machine = bfd_xcoff_machine (abfd);
2324
342
      break;
2325
2326
10
    case 1:
2327
10
      arch = bfd_arch_powerpc;
2328
10
      machine = bfd_mach_ppc_601;
2329
10
      break;
2330
2
    case 2: /* 64 bit PowerPC */
2331
2
      arch = bfd_arch_powerpc;
2332
2
      machine = bfd_mach_ppc_620;
2333
2
      break;
2334
4
    case 3:
2335
4
      arch = bfd_arch_powerpc;
2336
4
      machine = bfd_mach_ppc;
2337
4
      break;
2338
8
    case 4:
2339
8
      arch = bfd_arch_rs6000;
2340
8
      machine = bfd_mach_rs6k;
2341
8
      break;
2342
366
    }
2343
366
      }
2344
366
      break;
2345
366
#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
366
    default:      /* Unreadable input file type.  */
2418
0
      arch = bfd_arch_obscure;
2419
0
      break;
2420
372
    }
2421
2422
366
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
366
  return true;
2424
372
}
coff-sh.c:coff_set_arch_mach_hook
Line
Count
Source
2162
454
{
2163
454
  unsigned long machine;
2164
454
  enum bfd_architecture arch;
2165
454
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
454
  machine = 0;
2169
454
  switch (internal_f->f_magic)
2170
454
    {
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
284
    case SH_ARCH_MAGIC_BIG:
2349
292
    case SH_ARCH_MAGIC_LITTLE:
2350
#ifdef COFF_WITH_PE
2351
    case SH_ARCH_MAGIC_WINCE:
2352
#endif
2353
292
      arch = bfd_arch_sh;
2354
292
      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
162
    default:      /* Unreadable input file type.  */
2418
162
      arch = bfd_arch_obscure;
2419
162
      break;
2420
454
    }
2421
2422
454
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
454
  return true;
2424
454
}
Unexecuted instantiation: coff-stgo32.c:coff_set_arch_mach_hook
coff-tic30.c:coff_set_arch_mach_hook
Line
Count
Source
2162
250
{
2163
250
  unsigned long machine;
2164
250
  enum bfd_architecture arch;
2165
250
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
250
  machine = 0;
2169
250
  switch (internal_f->f_magic)
2170
250
    {
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
250
    case TIC30MAGIC:
2374
250
      arch = bfd_arch_tic30;
2375
250
      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
250
    }
2421
2422
250
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
250
  return true;
2424
250
}
Unexecuted instantiation: coff-tic4x.c:coff_set_arch_mach_hook
coff-tic54x.c:coff_set_arch_mach_hook
Line
Count
Source
2162
510
{
2163
510
  unsigned long machine;
2164
510
  enum bfd_architecture arch;
2165
510
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
510
  machine = 0;
2169
510
  switch (internal_f->f_magic)
2170
510
    {
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
498
    case TICOFF0MAGIC:
2382
498
      arch = TICOFF_TARGET_ARCH;
2383
498
      machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2384
498
      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
8
    case TICOFF1MAGIC:
2392
12
    case TICOFF2MAGIC:
2393
12
      switch (internal_f->f_target_id)
2394
12
  {
2395
0
#ifdef TI_TARGET_ID
2396
12
  case TI_TARGET_ID:
2397
12
    arch = TICOFF_TARGET_ARCH;
2398
12
    machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2399
12
    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
12
  }
2408
12
      break;
2409
12
#endif
2410
2411
#ifdef MCOREMAGIC
2412
    case MCOREMAGIC:
2413
      arch = bfd_arch_mcore;
2414
      break;
2415
#endif
2416
2417
12
    default:      /* Unreadable input file type.  */
2418
0
      arch = bfd_arch_obscure;
2419
0
      break;
2420
510
    }
2421
2422
510
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
510
  return true;
2424
510
}
coff-z80.c:coff_set_arch_mach_hook
Line
Count
Source
2162
254
{
2163
254
  unsigned long machine;
2164
254
  enum bfd_architecture arch;
2165
254
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
254
  machine = 0;
2169
254
  switch (internal_f->f_magic)
2170
254
    {
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
254
    case Z80MAGIC:
2239
254
      arch = bfd_arch_z80;
2240
254
      switch (internal_f->f_flags & F_MACHMASK)
2241
254
  {
2242
2
  case bfd_mach_z80strict << 12:
2243
208
  case bfd_mach_z80 << 12:
2244
210
  case bfd_mach_z80n << 12:
2245
212
  case bfd_mach_z80full << 12:
2246
212
  case bfd_mach_r800 << 12:
2247
214
  case bfd_mach_gbz80 << 12:
2248
238
  case bfd_mach_z180 << 12:
2249
240
  case bfd_mach_ez80_z80 << 12:
2250
252
  case bfd_mach_ez80_adl << 12:
2251
252
    machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12;
2252
252
    break;
2253
2
  default:
2254
2
    return false;
2255
254
  }
2256
252
      break;
2257
252
#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
252
    default:      /* Unreadable input file type.  */
2418
0
      arch = bfd_arch_obscure;
2419
0
      break;
2420
254
    }
2421
2422
252
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
252
  return true;
2424
254
}
coff-z8k.c:coff_set_arch_mach_hook
Line
Count
Source
2162
262
{
2163
262
  unsigned long machine;
2164
262
  enum bfd_architecture arch;
2165
262
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
262
  machine = 0;
2169
262
  switch (internal_f->f_magic)
2170
262
    {
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
262
    case Z8KMAGIC:
2260
262
      arch = bfd_arch_z8k;
2261
262
      switch (internal_f->f_flags & F_MACHMASK)
2262
262
  {
2263
174
  case F_Z8001:
2264
174
    machine = bfd_mach_z8001;
2265
174
    break;
2266
86
  case F_Z8002:
2267
86
    machine = bfd_mach_z8002;
2268
86
    break;
2269
2
  default:
2270
2
    return false;
2271
262
  }
2272
260
      break;
2273
260
#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
260
    default:      /* Unreadable input file type.  */
2418
0
      arch = bfd_arch_obscure;
2419
0
      break;
2420
262
    }
2421
2422
260
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
260
  return true;
2424
262
}
pe-arm-wince.c:coff_set_arch_mach_hook
Line
Count
Source
2162
304
{
2163
304
  unsigned long machine;
2164
304
  enum bfd_architecture arch;
2165
304
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
304
  machine = 0;
2169
304
  switch (internal_f->f_magic)
2170
304
    {
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
272
    case ARMMAGIC:
2200
294
    case ARMPEMAGIC:
2201
300
    case THUMBPEMAGIC:
2202
300
      arch = bfd_arch_arm;
2203
300
      machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION);
2204
300
      if (machine == bfd_mach_arm_unknown)
2205
300
  {
2206
300
    switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK)
2207
300
      {
2208
6
      case F_ARM_2:  machine = bfd_mach_arm_2;  break;
2209
22
      case F_ARM_2a: machine = bfd_mach_arm_2a; break;
2210
16
      case F_ARM_3:  machine = bfd_mach_arm_3;  break;
2211
200
      default:
2212
202
      case F_ARM_3M: machine = bfd_mach_arm_3M; break;
2213
12
      case F_ARM_4:  machine = bfd_mach_arm_4;  break;
2214
20
      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
22
      case F_ARM_5:  machine = bfd_mach_arm_XScale;  break;
2221
300
      }
2222
300
  }
2223
300
      break;
2224
300
#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
300
    default:      /* Unreadable input file type.  */
2418
4
      arch = bfd_arch_obscure;
2419
4
      break;
2420
304
    }
2421
2422
304
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
304
  return true;
2424
304
}
pe-arm.c:coff_set_arch_mach_hook
Line
Count
Source
2162
304
{
2163
304
  unsigned long machine;
2164
304
  enum bfd_architecture arch;
2165
304
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
304
  machine = 0;
2169
304
  switch (internal_f->f_magic)
2170
304
    {
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
272
    case ARMMAGIC:
2200
294
    case ARMPEMAGIC:
2201
300
    case THUMBPEMAGIC:
2202
300
      arch = bfd_arch_arm;
2203
300
      machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION);
2204
300
      if (machine == bfd_mach_arm_unknown)
2205
300
  {
2206
300
    switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK)
2207
300
      {
2208
6
      case F_ARM_2:  machine = bfd_mach_arm_2;  break;
2209
22
      case F_ARM_2a: machine = bfd_mach_arm_2a; break;
2210
16
      case F_ARM_3:  machine = bfd_mach_arm_3;  break;
2211
200
      default:
2212
202
      case F_ARM_3M: machine = bfd_mach_arm_3M; break;
2213
12
      case F_ARM_4:  machine = bfd_mach_arm_4;  break;
2214
20
      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
22
      case F_ARM_5:  machine = bfd_mach_arm_XScale;  break;
2221
300
      }
2222
300
  }
2223
300
      break;
2224
300
#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
300
    default:      /* Unreadable input file type.  */
2418
4
      arch = bfd_arch_obscure;
2419
4
      break;
2420
304
    }
2421
2422
304
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
304
  return true;
2424
304
}
pe-i386.c:coff_set_arch_mach_hook
Line
Count
Source
2162
1.04k
{
2163
1.04k
  unsigned long machine;
2164
1.04k
  enum bfd_architecture arch;
2165
1.04k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
1.04k
  machine = 0;
2169
1.04k
  switch (internal_f->f_magic)
2170
1.04k
    {
2171
0
#ifdef I386MAGIC
2172
6
    case I386MAGIC:
2173
50
    case I386PTXMAGIC:
2174
54
    case I386AIXMAGIC:   /* Danbury PS/2 AIX C Compiler.  */
2175
490
    case LYNXCOFFMAGIC:
2176
1.04k
    case I386_APPLE_MAGIC:
2177
1.04k
    case I386_FREEBSD_MAGIC:
2178
1.04k
    case I386_LINUX_MAGIC:
2179
1.04k
    case I386_NETBSD_MAGIC:
2180
1.04k
      arch = bfd_arch_i386;
2181
1.04k
      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
1.04k
    }
2421
2422
1.04k
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
1.04k
  return true;
2424
1.04k
}
pe-mcore.c:coff_set_arch_mach_hook
Line
Count
Source
2162
3.95k
{
2163
3.95k
  unsigned long machine;
2164
3.95k
  enum bfd_architecture arch;
2165
3.95k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
3.95k
  machine = 0;
2169
3.95k
  switch (internal_f->f_magic)
2170
3.95k
    {
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.95k
    case MCOREMAGIC:
2413
3.95k
      arch = bfd_arch_mcore;
2414
3.95k
      break;
2415
0
#endif
2416
2417
0
    default:      /* Unreadable input file type.  */
2418
0
      arch = bfd_arch_obscure;
2419
0
      break;
2420
3.95k
    }
2421
2422
3.95k
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
3.95k
  return true;
2424
3.95k
}
pe-sh.c:coff_set_arch_mach_hook
Line
Count
Source
2162
3.36k
{
2163
3.36k
  unsigned long machine;
2164
3.36k
  enum bfd_architecture arch;
2165
3.36k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
3.36k
  machine = 0;
2169
3.36k
  switch (internal_f->f_magic)
2170
3.36k
    {
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
3.06k
    case SH_ARCH_MAGIC_BIG:
2349
3.06k
    case SH_ARCH_MAGIC_LITTLE:
2350
3.06k
#ifdef COFF_WITH_PE
2351
3.36k
    case SH_ARCH_MAGIC_WINCE:
2352
3.36k
#endif
2353
3.36k
      arch = bfd_arch_sh;
2354
3.36k
      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
3.36k
    }
2421
2422
3.36k
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
3.36k
  return true;
2424
3.36k
}
pei-arm-wince.c:coff_set_arch_mach_hook
Line
Count
Source
2162
9.46k
{
2163
9.46k
  unsigned long machine;
2164
9.46k
  enum bfd_architecture arch;
2165
9.46k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
9.46k
  machine = 0;
2169
9.46k
  switch (internal_f->f_magic)
2170
9.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
0
#ifdef ARMMAGIC
2199
9.43k
    case ARMMAGIC:
2200
9.45k
    case ARMPEMAGIC:
2201
9.45k
    case THUMBPEMAGIC:
2202
9.45k
      arch = bfd_arch_arm;
2203
9.45k
      machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION);
2204
9.45k
      if (machine == bfd_mach_arm_unknown)
2205
9.45k
  {
2206
9.45k
    switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK)
2207
9.45k
      {
2208
10
      case F_ARM_2:  machine = bfd_mach_arm_2;  break;
2209
38
      case F_ARM_2a: machine = bfd_mach_arm_2a; break;
2210
486
      case F_ARM_3:  machine = bfd_mach_arm_3;  break;
2211
7.44k
      default:
2212
7.44k
      case F_ARM_3M: machine = bfd_mach_arm_3M; break;
2213
490
      case F_ARM_4:  machine = bfd_mach_arm_4;  break;
2214
494
      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
488
      case F_ARM_5:  machine = bfd_mach_arm_XScale;  break;
2221
9.45k
      }
2222
9.45k
  }
2223
9.45k
      break;
2224
9.45k
#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.45k
    default:      /* Unreadable input file type.  */
2418
6
      arch = bfd_arch_obscure;
2419
6
      break;
2420
9.46k
    }
2421
2422
9.46k
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
9.46k
  return true;
2424
9.46k
}
pei-arm.c:coff_set_arch_mach_hook
Line
Count
Source
2162
10.5k
{
2163
10.5k
  unsigned long machine;
2164
10.5k
  enum bfd_architecture arch;
2165
10.5k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
10.5k
  machine = 0;
2169
10.5k
  switch (internal_f->f_magic)
2170
10.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
#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
10.4k
    case ARMMAGIC:
2200
10.4k
    case ARMPEMAGIC:
2201
10.5k
    case THUMBPEMAGIC:
2202
10.5k
      arch = bfd_arch_arm;
2203
10.5k
      machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION);
2204
10.5k
      if (machine == bfd_mach_arm_unknown)
2205
10.5k
  {
2206
10.5k
    switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK)
2207
10.5k
      {
2208
490
      case F_ARM_2:  machine = bfd_mach_arm_2;  break;
2209
1.01k
      case F_ARM_2a: machine = bfd_mach_arm_2a; break;
2210
486
      case F_ARM_3:  machine = bfd_mach_arm_3;  break;
2211
5.12k
      default:
2212
5.12k
      case F_ARM_3M: machine = bfd_mach_arm_3M; break;
2213
1.45k
      case F_ARM_4:  machine = bfd_mach_arm_4;  break;
2214
968
      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
972
      case F_ARM_5:  machine = bfd_mach_arm_XScale;  break;
2221
10.5k
      }
2222
10.5k
  }
2223
10.5k
      break;
2224
10.5k
#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
10.5k
    default:      /* Unreadable input file type.  */
2418
12
      arch = bfd_arch_obscure;
2419
12
      break;
2420
10.5k
    }
2421
2422
10.5k
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
10.5k
  return true;
2424
10.5k
}
pei-mcore.c:coff_set_arch_mach_hook
Line
Count
Source
2162
7.03k
{
2163
7.03k
  unsigned long machine;
2164
7.03k
  enum bfd_architecture arch;
2165
7.03k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
7.03k
  machine = 0;
2169
7.03k
  switch (internal_f->f_magic)
2170
7.03k
    {
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
7.03k
    case MCOREMAGIC:
2413
7.03k
      arch = bfd_arch_mcore;
2414
7.03k
      break;
2415
0
#endif
2416
2417
0
    default:      /* Unreadable input file type.  */
2418
0
      arch = bfd_arch_obscure;
2419
0
      break;
2420
7.03k
    }
2421
2422
7.03k
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
7.03k
  return true;
2424
7.03k
}
pei-sh.c:coff_set_arch_mach_hook
Line
Count
Source
2162
8.05k
{
2163
8.05k
  unsigned long machine;
2164
8.05k
  enum bfd_architecture arch;
2165
8.05k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
8.05k
  machine = 0;
2169
8.05k
  switch (internal_f->f_magic)
2170
8.05k
    {
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
7.98k
    case SH_ARCH_MAGIC_BIG:
2349
8.03k
    case SH_ARCH_MAGIC_LITTLE:
2350
8.03k
#ifdef COFF_WITH_PE
2351
8.05k
    case SH_ARCH_MAGIC_WINCE:
2352
8.05k
#endif
2353
8.05k
      arch = bfd_arch_sh;
2354
8.05k
      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
8.05k
    }
2421
2422
8.05k
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
8.05k
  return true;
2424
8.05k
}
2425
2426
static bool
2427
symname_in_debug_hook (bfd *abfd ATTRIBUTE_UNUSED,
2428
           struct internal_syment *sym ATTRIBUTE_UNUSED)
2429
882
{
2430
#ifdef SYMNAME_IN_DEBUG
2431
323
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
  return false;
2434
#endif
2435
882
}
pei-i386.c:symname_in_debug_hook
Line
Count
Source
2429
15
{
2430
#ifdef SYMNAME_IN_DEBUG
2431
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
15
  return false;
2434
15
#endif
2435
15
}
pe-x86_64.c:symname_in_debug_hook
Line
Count
Source
2429
38
{
2430
#ifdef SYMNAME_IN_DEBUG
2431
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
38
  return false;
2434
38
#endif
2435
38
}
pei-x86_64.c:symname_in_debug_hook
Line
Count
Source
2429
30
{
2430
#ifdef SYMNAME_IN_DEBUG
2431
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
30
  return false;
2434
30
#endif
2435
30
}
coff-x86_64.c:symname_in_debug_hook
Line
Count
Source
2429
18
{
2430
#ifdef SYMNAME_IN_DEBUG
2431
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
18
  return false;
2434
18
#endif
2435
18
}
coff64-rs6000.c:symname_in_debug_hook
Line
Count
Source
2429
316
{
2430
316
#ifdef SYMNAME_IN_DEBUG
2431
316
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
  return false;
2434
#endif
2435
316
}
pe-aarch64.c:symname_in_debug_hook
Line
Count
Source
2429
10
{
2430
#ifdef SYMNAME_IN_DEBUG
2431
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
10
  return false;
2434
10
#endif
2435
10
}
pei-aarch64.c:symname_in_debug_hook
Line
Count
Source
2429
28
{
2430
#ifdef SYMNAME_IN_DEBUG
2431
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
28
  return false;
2434
28
#endif
2435
28
}
pei-ia64.c:symname_in_debug_hook
Line
Count
Source
2429
12
{
2430
#ifdef SYMNAME_IN_DEBUG
2431
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
12
  return false;
2434
12
#endif
2435
12
}
pei-loongarch64.c:symname_in_debug_hook
Line
Count
Source
2429
61
{
2430
#ifdef SYMNAME_IN_DEBUG
2431
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
61
  return false;
2434
61
#endif
2435
61
}
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
7
{
2430
7
#ifdef SYMNAME_IN_DEBUG
2431
7
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
  return false;
2434
#endif
2435
7
}
coff-sh.c:symname_in_debug_hook
Line
Count
Source
2429
55
{
2430
#ifdef SYMNAME_IN_DEBUG
2431
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
55
  return false;
2434
55
#endif
2435
55
}
Unexecuted instantiation: coff-stgo32.c:symname_in_debug_hook
coff-tic30.c:symname_in_debug_hook
Line
Count
Source
2429
13
{
2430
#ifdef SYMNAME_IN_DEBUG
2431
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
13
  return false;
2434
13
#endif
2435
13
}
Unexecuted instantiation: coff-tic4x.c:symname_in_debug_hook
coff-tic54x.c:symname_in_debug_hook
Line
Count
Source
2429
57
{
2430
#ifdef SYMNAME_IN_DEBUG
2431
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
57
  return false;
2434
57
#endif
2435
57
}
coff-z80.c:symname_in_debug_hook
Line
Count
Source
2429
16
{
2430
#ifdef SYMNAME_IN_DEBUG
2431
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
16
  return false;
2434
16
#endif
2435
16
}
coff-z8k.c:symname_in_debug_hook
Line
Count
Source
2429
37
{
2430
#ifdef SYMNAME_IN_DEBUG
2431
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
37
  return false;
2434
37
#endif
2435
37
}
Unexecuted instantiation: pe-arm-wince.c:symname_in_debug_hook
Unexecuted instantiation: pe-arm.c:symname_in_debug_hook
pe-i386.c:symname_in_debug_hook
Line
Count
Source
2429
30
{
2430
#ifdef SYMNAME_IN_DEBUG
2431
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
30
  return false;
2434
30
#endif
2435
30
}
pe-mcore.c:symname_in_debug_hook
Line
Count
Source
2429
73
{
2430
#ifdef SYMNAME_IN_DEBUG
2431
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
73
  return false;
2434
73
#endif
2435
73
}
pe-sh.c:symname_in_debug_hook
Line
Count
Source
2429
37
{
2430
#ifdef SYMNAME_IN_DEBUG
2431
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
37
  return false;
2434
37
#endif
2435
37
}
pei-arm-wince.c:symname_in_debug_hook
Line
Count
Source
2429
5
{
2430
#ifdef SYMNAME_IN_DEBUG
2431
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
5
  return false;
2434
5
#endif
2435
5
}
pei-arm.c:symname_in_debug_hook
Line
Count
Source
2429
2
{
2430
#ifdef SYMNAME_IN_DEBUG
2431
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
2
  return false;
2434
2
#endif
2435
2
}
pei-mcore.c:symname_in_debug_hook
Line
Count
Source
2429
10
{
2430
#ifdef SYMNAME_IN_DEBUG
2431
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
10
  return false;
2434
10
#endif
2435
10
}
pei-sh.c:symname_in_debug_hook
Line
Count
Source
2429
12
{
2430
#ifdef SYMNAME_IN_DEBUG
2431
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
12
  return false;
2434
12
#endif
2435
12
}
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
25.7k
{
2452
25.7k
  BFD_ASSERT (symbol->is_sym);
2453
25.7k
  int n_sclass = symbol->u.syment.n_sclass;
2454
2455
25.7k
  if (CSECT_SYM_P (n_sclass)
2456
25.7k
      && indaux + 1 == symbol->u.syment.n_numaux)
2457
923
    {
2458
923
      BFD_ASSERT (! aux->is_sym);
2459
923
      if (SMTYP_SMTYP (aux->u.auxent.x_csect.x_smtyp) == XTY_LD
2460
923
    && aux->u.auxent.x_csect.x_scnlen.u64 < obj_raw_syment_count (abfd))
2461
10
  {
2462
10
    aux->u.auxent.x_csect.x_scnlen.p =
2463
10
      table_base + aux->u.auxent.x_csect.x_scnlen.u64;
2464
10
    aux->fix_scnlen = 1;
2465
10
  }
2466
2467
      /* Return TRUE to indicate that the caller should not do any
2468
   further work on this auxent.  */
2469
923
      return true;
2470
923
    }
2471
2472
  /* Return FALSE to indicate that this auxent should be handled by
2473
     the caller.  */
2474
24.8k
  return false;
2475
25.7k
}
coff64-rs6000.c:coff_pointerize_aux_hook
Line
Count
Source
2451
10.0k
{
2452
10.0k
  BFD_ASSERT (symbol->is_sym);
2453
10.0k
  int n_sclass = symbol->u.syment.n_sclass;
2454
2455
10.0k
  if (CSECT_SYM_P (n_sclass)
2456
10.0k
      && indaux + 1 == symbol->u.syment.n_numaux)
2457
70
    {
2458
70
      BFD_ASSERT (! aux->is_sym);
2459
70
      if (SMTYP_SMTYP (aux->u.auxent.x_csect.x_smtyp) == XTY_LD
2460
70
    && 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
70
      return true;
2470
70
    }
2471
2472
  /* Return FALSE to indicate that this auxent should be handled by
2473
     the caller.  */
2474
9.97k
  return false;
2475
10.0k
}
coff-rs6000.c:coff_pointerize_aux_hook
Line
Count
Source
2451
15.7k
{
2452
15.7k
  BFD_ASSERT (symbol->is_sym);
2453
15.7k
  int n_sclass = symbol->u.syment.n_sclass;
2454
2455
15.7k
  if (CSECT_SYM_P (n_sclass)
2456
15.7k
      && indaux + 1 == symbol->u.syment.n_numaux)
2457
853
    {
2458
853
      BFD_ASSERT (! aux->is_sym);
2459
853
      if (SMTYP_SMTYP (aux->u.auxent.x_csect.x_smtyp) == XTY_LD
2460
853
    && aux->u.auxent.x_csect.x_scnlen.u64 < obj_raw_syment_count (abfd))
2461
9
  {
2462
9
    aux->u.auxent.x_csect.x_scnlen.p =
2463
9
      table_base + aux->u.auxent.x_csect.x_scnlen.u64;
2464
9
    aux->fix_scnlen = 1;
2465
9
  }
2466
2467
      /* Return TRUE to indicate that the caller should not do any
2468
   further work on this auxent.  */
2469
853
      return true;
2470
853
    }
2471
2472
  /* Return FALSE to indicate that this auxent should be handled by
2473
     the caller.  */
2474
14.8k
  return false;
2475
15.7k
}
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
1.06k
{
4435
1.06k
  size_t amt;
4436
4437
1.06k
  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
1.06k
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
0
    return NULL;
4444
1.06k
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
1.06k
}
pei-i386.c:buy_and_read
Line
Count
Source
4434
24
{
4435
24
  size_t amt;
4436
4437
24
  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
24
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
0
    return NULL;
4444
24
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
24
}
pe-x86_64.c:buy_and_read
Line
Count
Source
4434
29
{
4435
29
  size_t amt;
4436
4437
29
  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
29
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
0
    return NULL;
4444
29
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
29
}
pei-x86_64.c:buy_and_read
Line
Count
Source
4434
46
{
4435
46
  size_t amt;
4436
4437
46
  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
46
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
0
    return NULL;
4444
46
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
46
}
coff-x86_64.c:buy_and_read
Line
Count
Source
4434
58
{
4435
58
  size_t amt;
4436
4437
58
  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
58
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
0
    return NULL;
4444
58
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
58
}
coff64-rs6000.c:buy_and_read
Line
Count
Source
4434
71
{
4435
71
  size_t amt;
4436
4437
71
  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
71
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
0
    return NULL;
4444
71
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
71
}
pe-aarch64.c:buy_and_read
Line
Count
Source
4434
26
{
4435
26
  size_t amt;
4436
4437
26
  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
26
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
0
    return NULL;
4444
26
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
26
}
pei-aarch64.c:buy_and_read
Line
Count
Source
4434
31
{
4435
31
  size_t amt;
4436
4437
31
  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
31
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
0
    return NULL;
4444
31
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
31
}
pei-ia64.c:buy_and_read
Line
Count
Source
4434
22
{
4435
22
  size_t amt;
4436
4437
22
  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
22
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
0
    return NULL;
4444
22
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
22
}
pei-loongarch64.c:buy_and_read
Line
Count
Source
4434
43
{
4435
43
  size_t amt;
4436
4437
43
  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
43
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
0
    return NULL;
4444
43
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
43
}
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
133
{
4435
133
  size_t amt;
4436
4437
133
  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
133
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
0
    return NULL;
4444
133
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
133
}
coff-sh.c:buy_and_read
Line
Count
Source
4434
71
{
4435
71
  size_t amt;
4436
4437
71
  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
71
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
0
    return NULL;
4444
71
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
71
}
Unexecuted instantiation: coff-stgo32.c:buy_and_read
coff-tic30.c:buy_and_read
Line
Count
Source
4434
66
{
4435
66
  size_t amt;
4436
4437
66
  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
66
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
0
    return NULL;
4444
66
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
66
}
Unexecuted instantiation: coff-tic4x.c:buy_and_read
coff-tic54x.c:buy_and_read
Line
Count
Source
4434
25
{
4435
25
  size_t amt;
4436
4437
25
  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
25
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
0
    return NULL;
4444
25
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
25
}
coff-z80.c:buy_and_read
Line
Count
Source
4434
59
{
4435
59
  size_t amt;
4436
4437
59
  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
59
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
0
    return NULL;
4444
59
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
59
}
coff-z8k.c:buy_and_read
Line
Count
Source
4434
33
{
4435
33
  size_t amt;
4436
4437
33
  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
33
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
0
    return NULL;
4444
33
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
33
}
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
80
{
4435
80
  size_t amt;
4436
4437
80
  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
80
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
0
    return NULL;
4444
80
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
80
}
pe-mcore.c:buy_and_read
Line
Count
Source
4434
39
{
4435
39
  size_t amt;
4436
4437
39
  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
39
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
0
    return NULL;
4444
39
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
39
}
pe-sh.c:buy_and_read
Line
Count
Source
4434
66
{
4435
66
  size_t amt;
4436
4437
66
  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
66
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
0
    return NULL;
4444
66
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
66
}
pei-arm-wince.c:buy_and_read
Line
Count
Source
4434
13
{
4435
13
  size_t amt;
4436
4437
13
  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
13
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
0
    return NULL;
4444
13
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
13
}
pei-arm.c:buy_and_read
Line
Count
Source
4434
39
{
4435
39
  size_t amt;
4436
4437
39
  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
39
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
0
    return NULL;
4444
39
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
39
}
pei-mcore.c:buy_and_read
Line
Count
Source
4434
53
{
4435
53
  size_t amt;
4436
4437
53
  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
53
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
0
    return NULL;
4444
53
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
53
}
pei-sh.c:buy_and_read
Line
Count
Source
4434
39
{
4435
39
  size_t amt;
4436
4437
39
  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
39
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
0
    return NULL;
4444
39
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
39
}
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
110k
{
4473
110k
  const alent *al1 = *(const alent **) arg1;
4474
110k
  const alent *al2 = *(const alent **) arg2;
4475
110k
  const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym);
4476
110k
  const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym);
4477
4478
110k
  if (s1 == NULL || s2 == NULL)
4479
0
    return 0;
4480
110k
  if (s1->symbol.value < s2->symbol.value)
4481
331
    return -1;
4482
110k
  else if (s1->symbol.value > s2->symbol.value)
4483
12.8k
    return 1;
4484
4485
97.1k
  return 0;
4486
110k
}
pei-i386.c:coff_sort_func_alent
Line
Count
Source
4472
99
{
4473
99
  const alent *al1 = *(const alent **) arg1;
4474
99
  const alent *al2 = *(const alent **) arg2;
4475
99
  const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym);
4476
99
  const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym);
4477
4478
99
  if (s1 == NULL || s2 == NULL)
4479
0
    return 0;
4480
99
  if (s1->symbol.value < s2->symbol.value)
4481
15
    return -1;
4482
84
  else if (s1->symbol.value > s2->symbol.value)
4483
11
    return 1;
4484
4485
73
  return 0;
4486
99
}
pe-x86_64.c:coff_sort_func_alent
Line
Count
Source
4472
649
{
4473
649
  const alent *al1 = *(const alent **) arg1;
4474
649
  const alent *al2 = *(const alent **) arg2;
4475
649
  const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym);
4476
649
  const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym);
4477
4478
649
  if (s1 == NULL || s2 == NULL)
4479
0
    return 0;
4480
649
  if (s1->symbol.value < s2->symbol.value)
4481
11
    return -1;
4482
638
  else if (s1->symbol.value > s2->symbol.value)
4483
147
    return 1;
4484
4485
491
  return 0;
4486
649
}
pei-x86_64.c:coff_sort_func_alent
Line
Count
Source
4472
295
{
4473
295
  const alent *al1 = *(const alent **) arg1;
4474
295
  const alent *al2 = *(const alent **) arg2;
4475
295
  const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym);
4476
295
  const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym);
4477
4478
295
  if (s1 == NULL || s2 == NULL)
4479
0
    return 0;
4480
295
  if (s1->symbol.value < s2->symbol.value)
4481
13
    return -1;
4482
282
  else if (s1->symbol.value > s2->symbol.value)
4483
113
    return 1;
4484
4485
169
  return 0;
4486
295
}
coff-x86_64.c:coff_sort_func_alent
Line
Count
Source
4472
432
{
4473
432
  const alent *al1 = *(const alent **) arg1;
4474
432
  const alent *al2 = *(const alent **) arg2;
4475
432
  const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym);
4476
432
  const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym);
4477
4478
432
  if (s1 == NULL || s2 == NULL)
4479
0
    return 0;
4480
432
  if (s1->symbol.value < s2->symbol.value)
4481
17
    return -1;
4482
415
  else if (s1->symbol.value > s2->symbol.value)
4483
96
    return 1;
4484
4485
319
  return 0;
4486
432
}
coff64-rs6000.c:coff_sort_func_alent
Line
Count
Source
4472
240
{
4473
240
  const alent *al1 = *(const alent **) arg1;
4474
240
  const alent *al2 = *(const alent **) arg2;
4475
240
  const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym);
4476
240
  const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym);
4477
4478
240
  if (s1 == NULL || s2 == NULL)
4479
0
    return 0;
4480
240
  if (s1->symbol.value < s2->symbol.value)
4481
39
    return -1;
4482
201
  else if (s1->symbol.value > s2->symbol.value)
4483
73
    return 1;
4484
4485
128
  return 0;
4486
240
}
pe-aarch64.c:coff_sort_func_alent
Line
Count
Source
4472
28
{
4473
28
  const alent *al1 = *(const alent **) arg1;
4474
28
  const alent *al2 = *(const alent **) arg2;
4475
28
  const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym);
4476
28
  const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym);
4477
4478
28
  if (s1 == NULL || s2 == NULL)
4479
0
    return 0;
4480
28
  if (s1->symbol.value < s2->symbol.value)
4481
4
    return -1;
4482
24
  else if (s1->symbol.value > s2->symbol.value)
4483
8
    return 1;
4484
4485
16
  return 0;
4486
28
}
pei-aarch64.c:coff_sort_func_alent
Line
Count
Source
4472
398
{
4473
398
  const alent *al1 = *(const alent **) arg1;
4474
398
  const alent *al2 = *(const alent **) arg2;
4475
398
  const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym);
4476
398
  const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym);
4477
4478
398
  if (s1 == NULL || s2 == NULL)
4479
0
    return 0;
4480
398
  if (s1->symbol.value < s2->symbol.value)
4481
17
    return -1;
4482
381
  else if (s1->symbol.value > s2->symbol.value)
4483
153
    return 1;
4484
4485
228
  return 0;
4486
398
}
pei-ia64.c:coff_sort_func_alent
Line
Count
Source
4472
38
{
4473
38
  const alent *al1 = *(const alent **) arg1;
4474
38
  const alent *al2 = *(const alent **) arg2;
4475
38
  const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym);
4476
38
  const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym);
4477
4478
38
  if (s1 == NULL || s2 == NULL)
4479
0
    return 0;
4480
38
  if (s1->symbol.value < s2->symbol.value)
4481
10
    return -1;
4482
28
  else if (s1->symbol.value > s2->symbol.value)
4483
11
    return 1;
4484
4485
17
  return 0;
4486
38
}
pei-loongarch64.c:coff_sort_func_alent
Line
Count
Source
4472
253
{
4473
253
  const alent *al1 = *(const alent **) arg1;
4474
253
  const alent *al2 = *(const alent **) arg2;
4475
253
  const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym);
4476
253
  const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym);
4477
4478
253
  if (s1 == NULL || s2 == NULL)
4479
0
    return 0;
4480
253
  if (s1->symbol.value < s2->symbol.value)
4481
22
    return -1;
4482
231
  else if (s1->symbol.value > s2->symbol.value)
4483
89
    return 1;
4484
4485
142
  return 0;
4486
253
}
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
74.1k
{
4473
74.1k
  const alent *al1 = *(const alent **) arg1;
4474
74.1k
  const alent *al2 = *(const alent **) arg2;
4475
74.1k
  const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym);
4476
74.1k
  const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym);
4477
4478
74.1k
  if (s1 == NULL || s2 == NULL)
4479
0
    return 0;
4480
74.1k
  if (s1->symbol.value < s2->symbol.value)
4481
72
    return -1;
4482
74.1k
  else if (s1->symbol.value > s2->symbol.value)
4483
8.35k
    return 1;
4484
4485
65.7k
  return 0;
4486
74.1k
}
coff-sh.c:coff_sort_func_alent
Line
Count
Source
4472
14.1k
{
4473
14.1k
  const alent *al1 = *(const alent **) arg1;
4474
14.1k
  const alent *al2 = *(const alent **) arg2;
4475
14.1k
  const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym);
4476
14.1k
  const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym);
4477
4478
14.1k
  if (s1 == NULL || s2 == NULL)
4479
0
    return 0;
4480
14.1k
  if (s1->symbol.value < s2->symbol.value)
4481
40
    return -1;
4482
14.1k
  else if (s1->symbol.value > s2->symbol.value)
4483
459
    return 1;
4484
4485
13.6k
  return 0;
4486
14.1k
}
Unexecuted instantiation: coff-stgo32.c:coff_sort_func_alent
coff-tic30.c:coff_sort_func_alent
Line
Count
Source
4472
602
{
4473
602
  const alent *al1 = *(const alent **) arg1;
4474
602
  const alent *al2 = *(const alent **) arg2;
4475
602
  const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym);
4476
602
  const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym);
4477
4478
602
  if (s1 == NULL || s2 == NULL)
4479
0
    return 0;
4480
602
  if (s1->symbol.value < s2->symbol.value)
4481
8
    return -1;
4482
594
  else if (s1->symbol.value > s2->symbol.value)
4483
181
    return 1;
4484
4485
413
  return 0;
4486
602
}
Unexecuted instantiation: coff-tic4x.c:coff_sort_func_alent
coff-tic54x.c:coff_sort_func_alent
Line
Count
Source
4472
1.45k
{
4473
1.45k
  const alent *al1 = *(const alent **) arg1;
4474
1.45k
  const alent *al2 = *(const alent **) arg2;
4475
1.45k
  const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym);
4476
1.45k
  const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym);
4477
4478
1.45k
  if (s1 == NULL || s2 == NULL)
4479
0
    return 0;
4480
1.45k
  if (s1->symbol.value < s2->symbol.value)
4481
6
    return -1;
4482
1.44k
  else if (s1->symbol.value > s2->symbol.value)
4483
276
    return 1;
4484
4485
1.17k
  return 0;
4486
1.45k
}
coff-z80.c:coff_sort_func_alent
Line
Count
Source
4472
163
{
4473
163
  const alent *al1 = *(const alent **) arg1;
4474
163
  const alent *al2 = *(const alent **) arg2;
4475
163
  const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym);
4476
163
  const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym);
4477
4478
163
  if (s1 == NULL || s2 == NULL)
4479
0
    return 0;
4480
163
  if (s1->symbol.value < s2->symbol.value)
4481
4
    return -1;
4482
159
  else if (s1->symbol.value > s2->symbol.value)
4483
61
    return 1;
4484
4485
98
  return 0;
4486
163
}
Unexecuted instantiation: coff-z8k.c:coff_sort_func_alent
Unexecuted instantiation: pe-arm-wince.c:coff_sort_func_alent
Unexecuted instantiation: pe-arm.c:coff_sort_func_alent
pe-i386.c:coff_sort_func_alent
Line
Count
Source
4472
16.6k
{
4473
16.6k
  const alent *al1 = *(const alent **) arg1;
4474
16.6k
  const alent *al2 = *(const alent **) arg2;
4475
16.6k
  const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym);
4476
16.6k
  const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym);
4477
4478
16.6k
  if (s1 == NULL || s2 == NULL)
4479
0
    return 0;
4480
16.6k
  if (s1->symbol.value < s2->symbol.value)
4481
14
    return -1;
4482
16.6k
  else if (s1->symbol.value > s2->symbol.value)
4483
2.58k
    return 1;
4484
4485
14.0k
  return 0;
4486
16.6k
}
pe-mcore.c:coff_sort_func_alent
Line
Count
Source
4472
115
{
4473
115
  const alent *al1 = *(const alent **) arg1;
4474
115
  const alent *al2 = *(const alent **) arg2;
4475
115
  const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym);
4476
115
  const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym);
4477
4478
115
  if (s1 == NULL || s2 == NULL)
4479
0
    return 0;
4480
115
  if (s1->symbol.value < s2->symbol.value)
4481
2
    return -1;
4482
113
  else if (s1->symbol.value > s2->symbol.value)
4483
32
    return 1;
4484
4485
81
  return 0;
4486
115
}
pe-sh.c:coff_sort_func_alent
Line
Count
Source
4472
266
{
4473
266
  const alent *al1 = *(const alent **) arg1;
4474
266
  const alent *al2 = *(const alent **) arg2;
4475
266
  const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym);
4476
266
  const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym);
4477
4478
266
  if (s1 == NULL || s2 == NULL)
4479
0
    return 0;
4480
266
  if (s1->symbol.value < s2->symbol.value)
4481
10
    return -1;
4482
256
  else if (s1->symbol.value > s2->symbol.value)
4483
100
    return 1;
4484
4485
156
  return 0;
4486
266
}
Unexecuted instantiation: pei-arm-wince.c:coff_sort_func_alent
pei-arm.c:coff_sort_func_alent
Line
Count
Source
4472
105
{
4473
105
  const alent *al1 = *(const alent **) arg1;
4474
105
  const alent *al2 = *(const alent **) arg2;
4475
105
  const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym);
4476
105
  const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym);
4477
4478
105
  if (s1 == NULL || s2 == NULL)
4479
0
    return 0;
4480
105
  if (s1->symbol.value < s2->symbol.value)
4481
3
    return -1;
4482
102
  else if (s1->symbol.value > s2->symbol.value)
4483
41
    return 1;
4484
4485
61
  return 0;
4486
105
}
pei-mcore.c:coff_sort_func_alent
Line
Count
Source
4472
46
{
4473
46
  const alent *al1 = *(const alent **) arg1;
4474
46
  const alent *al2 = *(const alent **) arg2;
4475
46
  const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym);
4476
46
  const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym);
4477
4478
46
  if (s1 == NULL || s2 == NULL)
4479
0
    return 0;
4480
46
  if (s1->symbol.value < s2->symbol.value)
4481
6
    return -1;
4482
40
  else if (s1->symbol.value > s2->symbol.value)
4483
14
    return 1;
4484
4485
26
  return 0;
4486
46
}
pei-sh.c:coff_sort_func_alent
Line
Count
Source
4472
117
{
4473
117
  const alent *al1 = *(const alent **) arg1;
4474
117
  const alent *al2 = *(const alent **) arg2;
4475
117
  const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym);
4476
117
  const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym);
4477
4478
117
  if (s1 == NULL || s2 == NULL)
4479
0
    return 0;
4480
117
  if (s1->symbol.value < s2->symbol.value)
4481
18
    return -1;
4482
99
  else if (s1->symbol.value > s2->symbol.value)
4483
18
    return 1;
4484
4485
81
  return 0;
4486
117
}
4487
4488
static bool
4489
coff_slurp_line_table (bfd *abfd, asection *asect)
4490
51.0k
{
4491
51.0k
  LINENO *native_lineno;
4492
51.0k
  alent *lineno_cache;
4493
51.0k
  unsigned int counter;
4494
51.0k
  alent *cache_ptr;
4495
51.0k
  bfd_vma prev_offset = 0;
4496
51.0k
  bool ordered = true;
4497
51.0k
  unsigned int nbr_func;
4498
51.0k
  LINENO *src;
4499
51.0k
  bool have_func;
4500
51.0k
  bool ret = true;
4501
51.0k
  size_t amt;
4502
4503
51.0k
  if (asect->lineno_count == 0)
4504
49.9k
    return true;
4505
4506
1.06k
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
1.06k
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
1.06k
             asect->lineno_count,
4510
1.06k
             bfd_coff_linesz (abfd));
4511
1.06k
  if (native_lineno == NULL)
4512
0
    {
4513
0
      _bfd_error_handler
4514
0
  (_("%pB: warning: line number table read failed"), abfd);
4515
0
      return false;
4516
0
    }
4517
4518
1.06k
  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
1.06k
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
1.06k
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
1.06k
  cache_ptr = lineno_cache;
4532
1.06k
  asect->lineno = lineno_cache;
4533
1.06k
  src = native_lineno;
4534
1.06k
  nbr_func = 0;
4535
1.06k
  have_func = false;
4536
4537
124k
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
123k
    {
4539
123k
      struct internal_lineno dst;
4540
4541
123k
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
123k
      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
123k
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
123k
      if (cache_ptr->line_number == 0)
4549
69.4k
  {
4550
69.4k
    combined_entry_type * ent;
4551
69.4k
    unsigned long symndx;
4552
69.4k
    coff_symbol_type *sym;
4553
4554
69.4k
    have_func = false;
4555
69.4k
    symndx = dst.l_addr.l_symndx;
4556
69.4k
    if (symndx >= obj_raw_syment_count (abfd))
4557
0
      {
4558
0
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
0
     abfd, symndx, counter);
4562
0
        cache_ptr->line_number = -1;
4563
0
        ret = false;
4564
0
        continue;
4565
0
      }
4566
4567
69.4k
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
69.4k
    if (! ent->is_sym)
4571
0
      {
4572
0
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
0
     abfd, symndx, counter);
4576
0
        cache_ptr->line_number = -1;
4577
0
        ret = false;
4578
0
        continue;
4579
0
      }
4580
69.4k
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
69.4k
    if (sym < obj_symbols (abfd)
4584
69.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
69.4k
    have_func = true;
4596
69.4k
    nbr_func++;
4597
69.4k
    cache_ptr->u.sym = (asymbol *) sym;
4598
69.4k
    if (sym->lineno != NULL)
4599
68.5k
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
68.5k
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
68.5k
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
69.4k
    sym->lineno = cache_ptr;
4605
69.4k
    if (sym->symbol.value < prev_offset)
4606
529
      ordered = false;
4607
69.4k
    prev_offset = sym->symbol.value;
4608
69.4k
  }
4609
53.9k
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
21.2k
  continue;
4613
32.6k
      else
4614
32.6k
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
102k
      cache_ptr++;
4616
102k
    }
4617
4618
1.06k
  asect->lineno_count = cache_ptr - lineno_cache;
4619
1.06k
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
1.06k
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
1.06k
  if (!ordered)
4624
416
    {
4625
      /* Sort the table.  */
4626
416
      alent **func_table;
4627
416
      alent *n_lineno_cache;
4628
4629
      /* Create a table of functions.  */
4630
416
      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
416
      else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL)
4636
416
  {
4637
416
    alent **p = func_table;
4638
416
    unsigned int i;
4639
4640
34.8k
    for (i = 0; i < asect->lineno_count; i++)
4641
34.4k
      if (lineno_cache[i].line_number == 0)
4642
26.3k
        *p++ = &lineno_cache[i];
4643
4644
416
    BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func);
4645
4646
    /* Sort by functions.  */
4647
416
    qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent);
4648
4649
    /* Create the new sorted table.  */
4650
416
    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
416
    else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL)
4656
416
      {
4657
416
        alent *n_cache_ptr = n_lineno_cache;
4658
4659
26.7k
        for (i = 0; i < nbr_func; i++)
4660
26.3k
    {
4661
26.3k
      coff_symbol_type *sym;
4662
26.3k
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
26.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
26.3k
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
26.3k
      do
4671
34.4k
        *n_cache_ptr++ = *old_ptr++;
4672
34.4k
      while (old_ptr->line_number != 0);
4673
26.3k
    }
4674
4675
416
        memcpy (lineno_cache, n_lineno_cache,
4676
416
          asect->lineno_count * sizeof (alent));
4677
416
      }
4678
0
    else
4679
0
      ret = false;
4680
416
    bfd_release (abfd, func_table);
4681
416
  }
4682
0
      else
4683
0
  ret = false;
4684
416
    }
4685
4686
1.06k
  return ret;
4687
1.06k
}
pei-i386.c:coff_slurp_line_table
Line
Count
Source
4490
154
{
4491
154
  LINENO *native_lineno;
4492
154
  alent *lineno_cache;
4493
154
  unsigned int counter;
4494
154
  alent *cache_ptr;
4495
154
  bfd_vma prev_offset = 0;
4496
154
  bool ordered = true;
4497
154
  unsigned int nbr_func;
4498
154
  LINENO *src;
4499
154
  bool have_func;
4500
154
  bool ret = true;
4501
154
  size_t amt;
4502
4503
154
  if (asect->lineno_count == 0)
4504
130
    return true;
4505
4506
24
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
24
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
24
             asect->lineno_count,
4510
24
             bfd_coff_linesz (abfd));
4511
24
  if (native_lineno == NULL)
4512
0
    {
4513
0
      _bfd_error_handler
4514
0
  (_("%pB: warning: line number table read failed"), abfd);
4515
0
      return false;
4516
0
    }
4517
4518
24
  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
24
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
24
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
24
  cache_ptr = lineno_cache;
4532
24
  asect->lineno = lineno_cache;
4533
24
  src = native_lineno;
4534
24
  nbr_func = 0;
4535
24
  have_func = false;
4536
4537
329
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
305
    {
4539
305
      struct internal_lineno dst;
4540
4541
305
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
305
      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
305
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
305
      if (cache_ptr->line_number == 0)
4549
122
  {
4550
122
    combined_entry_type * ent;
4551
122
    unsigned long symndx;
4552
122
    coff_symbol_type *sym;
4553
4554
122
    have_func = false;
4555
122
    symndx = dst.l_addr.l_symndx;
4556
122
    if (symndx >= obj_raw_syment_count (abfd))
4557
0
      {
4558
0
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
0
     abfd, symndx, counter);
4562
0
        cache_ptr->line_number = -1;
4563
0
        ret = false;
4564
0
        continue;
4565
0
      }
4566
4567
122
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
122
    if (! ent->is_sym)
4571
0
      {
4572
0
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
0
     abfd, symndx, counter);
4576
0
        cache_ptr->line_number = -1;
4577
0
        ret = false;
4578
0
        continue;
4579
0
      }
4580
122
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
122
    if (sym < obj_symbols (abfd)
4584
122
        || 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
122
    have_func = true;
4596
122
    nbr_func++;
4597
122
    cache_ptr->u.sym = (asymbol *) sym;
4598
122
    if (sym->lineno != NULL)
4599
100
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
100
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
100
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
122
    sym->lineno = cache_ptr;
4605
122
    if (sym->symbol.value < prev_offset)
4606
8
      ordered = false;
4607
122
    prev_offset = sym->symbol.value;
4608
122
  }
4609
183
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
85
  continue;
4613
98
      else
4614
98
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
220
      cache_ptr++;
4616
220
    }
4617
4618
24
  asect->lineno_count = cache_ptr - lineno_cache;
4619
24
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
24
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
24
  if (!ordered)
4624
7
    {
4625
      /* Sort the table.  */
4626
7
      alent **func_table;
4627
7
      alent *n_lineno_cache;
4628
4629
      /* Create a table of functions.  */
4630
7
      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
7
      else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL)
4636
7
  {
4637
7
    alent **p = func_table;
4638
7
    unsigned int i;
4639
4640
143
    for (i = 0; i < asect->lineno_count; i++)
4641
136
      if (lineno_cache[i].line_number == 0)
4642
61
        *p++ = &lineno_cache[i];
4643
4644
7
    BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func);
4645
4646
    /* Sort by functions.  */
4647
7
    qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent);
4648
4649
    /* Create the new sorted table.  */
4650
7
    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
7
    else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL)
4656
7
      {
4657
7
        alent *n_cache_ptr = n_lineno_cache;
4658
4659
68
        for (i = 0; i < nbr_func; i++)
4660
61
    {
4661
61
      coff_symbol_type *sym;
4662
61
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
61
      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
61
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
61
      do
4671
136
        *n_cache_ptr++ = *old_ptr++;
4672
136
      while (old_ptr->line_number != 0);
4673
61
    }
4674
4675
7
        memcpy (lineno_cache, n_lineno_cache,
4676
7
          asect->lineno_count * sizeof (alent));
4677
7
      }
4678
0
    else
4679
0
      ret = false;
4680
7
    bfd_release (abfd, func_table);
4681
7
  }
4682
0
      else
4683
0
  ret = false;
4684
7
    }
4685
4686
24
  return ret;
4687
24
}
pe-x86_64.c:coff_slurp_line_table
Line
Count
Source
4490
8.52k
{
4491
8.52k
  LINENO *native_lineno;
4492
8.52k
  alent *lineno_cache;
4493
8.52k
  unsigned int counter;
4494
8.52k
  alent *cache_ptr;
4495
8.52k
  bfd_vma prev_offset = 0;
4496
8.52k
  bool ordered = true;
4497
8.52k
  unsigned int nbr_func;
4498
8.52k
  LINENO *src;
4499
8.52k
  bool have_func;
4500
8.52k
  bool ret = true;
4501
8.52k
  size_t amt;
4502
4503
8.52k
  if (asect->lineno_count == 0)
4504
8.49k
    return true;
4505
4506
29
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
29
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
29
             asect->lineno_count,
4510
29
             bfd_coff_linesz (abfd));
4511
29
  if (native_lineno == NULL)
4512
0
    {
4513
0
      _bfd_error_handler
4514
0
  (_("%pB: warning: line number table read failed"), abfd);
4515
0
      return false;
4516
0
    }
4517
4518
29
  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
29
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
29
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
29
  cache_ptr = lineno_cache;
4532
29
  asect->lineno = lineno_cache;
4533
29
  src = native_lineno;
4534
29
  nbr_func = 0;
4535
29
  have_func = false;
4536
4537
737
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
708
    {
4539
708
      struct internal_lineno dst;
4540
4541
708
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
708
      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
708
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
708
      if (cache_ptr->line_number == 0)
4549
259
  {
4550
259
    combined_entry_type * ent;
4551
259
    unsigned long symndx;
4552
259
    coff_symbol_type *sym;
4553
4554
259
    have_func = false;
4555
259
    symndx = dst.l_addr.l_symndx;
4556
259
    if (symndx >= obj_raw_syment_count (abfd))
4557
0
      {
4558
0
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
0
     abfd, symndx, counter);
4562
0
        cache_ptr->line_number = -1;
4563
0
        ret = false;
4564
0
        continue;
4565
0
      }
4566
4567
259
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
259
    if (! ent->is_sym)
4571
0
      {
4572
0
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
0
     abfd, symndx, counter);
4576
0
        cache_ptr->line_number = -1;
4577
0
        ret = false;
4578
0
        continue;
4579
0
      }
4580
259
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
259
    if (sym < obj_symbols (abfd)
4584
259
        || 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
259
    have_func = true;
4596
259
    nbr_func++;
4597
259
    cache_ptr->u.sym = (asymbol *) sym;
4598
259
    if (sym->lineno != NULL)
4599
230
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
230
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
230
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
259
    sym->lineno = cache_ptr;
4605
259
    if (sym->symbol.value < prev_offset)
4606
17
      ordered = false;
4607
259
    prev_offset = sym->symbol.value;
4608
259
  }
4609
449
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
382
  continue;
4613
67
      else
4614
67
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
326
      cache_ptr++;
4616
326
    }
4617
4618
29
  asect->lineno_count = cache_ptr - lineno_cache;
4619
29
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
29
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
29
  if (!ordered)
4624
14
    {
4625
      /* Sort the table.  */
4626
14
      alent **func_table;
4627
14
      alent *n_lineno_cache;
4628
4629
      /* Create a table of functions.  */
4630
14
      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
14
      else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL)
4636
14
  {
4637
14
    alent **p = func_table;
4638
14
    unsigned int i;
4639
4640
269
    for (i = 0; i < asect->lineno_count; i++)
4641
255
      if (lineno_cache[i].line_number == 0)
4642
191
        *p++ = &lineno_cache[i];
4643
4644
14
    BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func);
4645
4646
    /* Sort by functions.  */
4647
14
    qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent);
4648
4649
    /* Create the new sorted table.  */
4650
14
    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
14
    else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL)
4656
14
      {
4657
14
        alent *n_cache_ptr = n_lineno_cache;
4658
4659
205
        for (i = 0; i < nbr_func; i++)
4660
191
    {
4661
191
      coff_symbol_type *sym;
4662
191
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
191
      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
191
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
191
      do
4671
255
        *n_cache_ptr++ = *old_ptr++;
4672
255
      while (old_ptr->line_number != 0);
4673
191
    }
4674
4675
14
        memcpy (lineno_cache, n_lineno_cache,
4676
14
          asect->lineno_count * sizeof (alent));
4677
14
      }
4678
0
    else
4679
0
      ret = false;
4680
14
    bfd_release (abfd, func_table);
4681
14
  }
4682
0
      else
4683
0
  ret = false;
4684
14
    }
4685
4686
29
  return ret;
4687
29
}
pei-x86_64.c:coff_slurp_line_table
Line
Count
Source
4490
274
{
4491
274
  LINENO *native_lineno;
4492
274
  alent *lineno_cache;
4493
274
  unsigned int counter;
4494
274
  alent *cache_ptr;
4495
274
  bfd_vma prev_offset = 0;
4496
274
  bool ordered = true;
4497
274
  unsigned int nbr_func;
4498
274
  LINENO *src;
4499
274
  bool have_func;
4500
274
  bool ret = true;
4501
274
  size_t amt;
4502
4503
274
  if (asect->lineno_count == 0)
4504
228
    return true;
4505
4506
46
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
46
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
46
             asect->lineno_count,
4510
46
             bfd_coff_linesz (abfd));
4511
46
  if (native_lineno == NULL)
4512
0
    {
4513
0
      _bfd_error_handler
4514
0
  (_("%pB: warning: line number table read failed"), abfd);
4515
0
      return false;
4516
0
    }
4517
4518
46
  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
46
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
46
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
46
  cache_ptr = lineno_cache;
4532
46
  asect->lineno = lineno_cache;
4533
46
  src = native_lineno;
4534
46
  nbr_func = 0;
4535
46
  have_func = false;
4536
4537
435
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
389
    {
4539
389
      struct internal_lineno dst;
4540
4541
389
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
389
      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
389
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
389
      if (cache_ptr->line_number == 0)
4549
186
  {
4550
186
    combined_entry_type * ent;
4551
186
    unsigned long symndx;
4552
186
    coff_symbol_type *sym;
4553
4554
186
    have_func = false;
4555
186
    symndx = dst.l_addr.l_symndx;
4556
186
    if (symndx >= obj_raw_syment_count (abfd))
4557
0
      {
4558
0
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
0
     abfd, symndx, counter);
4562
0
        cache_ptr->line_number = -1;
4563
0
        ret = false;
4564
0
        continue;
4565
0
      }
4566
4567
186
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
186
    if (! ent->is_sym)
4571
0
      {
4572
0
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
0
     abfd, symndx, counter);
4576
0
        cache_ptr->line_number = -1;
4577
0
        ret = false;
4578
0
        continue;
4579
0
      }
4580
186
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
186
    if (sym < obj_symbols (abfd)
4584
186
        || 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
186
    have_func = true;
4596
186
    nbr_func++;
4597
186
    cache_ptr->u.sym = (asymbol *) sym;
4598
186
    if (sym->lineno != NULL)
4599
136
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
136
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
136
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
186
    sym->lineno = cache_ptr;
4605
186
    if (sym->symbol.value < prev_offset)
4606
18
      ordered = false;
4607
186
    prev_offset = sym->symbol.value;
4608
186
  }
4609
203
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
114
  continue;
4613
89
      else
4614
89
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
275
      cache_ptr++;
4616
275
    }
4617
4618
46
  asect->lineno_count = cache_ptr - lineno_cache;
4619
46
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
46
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
46
  if (!ordered)
4624
16
    {
4625
      /* Sort the table.  */
4626
16
      alent **func_table;
4627
16
      alent *n_lineno_cache;
4628
4629
      /* Create a table of functions.  */
4630
16
      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
16
      else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL)
4636
16
  {
4637
16
    alent **p = func_table;
4638
16
    unsigned int i;
4639
4640
224
    for (i = 0; i < asect->lineno_count; i++)
4641
208
      if (lineno_cache[i].line_number == 0)
4642
141
        *p++ = &lineno_cache[i];
4643
4644
16
    BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func);
4645
4646
    /* Sort by functions.  */
4647
16
    qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent);
4648
4649
    /* Create the new sorted table.  */
4650
16
    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
16
    else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL)
4656
16
      {
4657
16
        alent *n_cache_ptr = n_lineno_cache;
4658
4659
157
        for (i = 0; i < nbr_func; i++)
4660
141
    {
4661
141
      coff_symbol_type *sym;
4662
141
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
141
      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
141
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
141
      do
4671
208
        *n_cache_ptr++ = *old_ptr++;
4672
208
      while (old_ptr->line_number != 0);
4673
141
    }
4674
4675
16
        memcpy (lineno_cache, n_lineno_cache,
4676
16
          asect->lineno_count * sizeof (alent));
4677
16
      }
4678
0
    else
4679
0
      ret = false;
4680
16
    bfd_release (abfd, func_table);
4681
16
  }
4682
0
      else
4683
0
  ret = false;
4684
16
    }
4685
4686
46
  return ret;
4687
46
}
coff-x86_64.c:coff_slurp_line_table
Line
Count
Source
4490
25.2k
{
4491
25.2k
  LINENO *native_lineno;
4492
25.2k
  alent *lineno_cache;
4493
25.2k
  unsigned int counter;
4494
25.2k
  alent *cache_ptr;
4495
25.2k
  bfd_vma prev_offset = 0;
4496
25.2k
  bool ordered = true;
4497
25.2k
  unsigned int nbr_func;
4498
25.2k
  LINENO *src;
4499
25.2k
  bool have_func;
4500
25.2k
  bool ret = true;
4501
25.2k
  size_t amt;
4502
4503
25.2k
  if (asect->lineno_count == 0)
4504
25.1k
    return true;
4505
4506
58
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
58
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
58
             asect->lineno_count,
4510
58
             bfd_coff_linesz (abfd));
4511
58
  if (native_lineno == NULL)
4512
0
    {
4513
0
      _bfd_error_handler
4514
0
  (_("%pB: warning: line number table read failed"), abfd);
4515
0
      return false;
4516
0
    }
4517
4518
58
  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
58
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
58
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
58
  cache_ptr = lineno_cache;
4532
58
  asect->lineno = lineno_cache;
4533
58
  src = native_lineno;
4534
58
  nbr_func = 0;
4535
58
  have_func = false;
4536
4537
4.29k
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
4.23k
    {
4539
4.23k
      struct internal_lineno dst;
4540
4541
4.23k
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
4.23k
      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
4.23k
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
4.23k
      if (cache_ptr->line_number == 0)
4549
707
  {
4550
707
    combined_entry_type * ent;
4551
707
    unsigned long symndx;
4552
707
    coff_symbol_type *sym;
4553
4554
707
    have_func = false;
4555
707
    symndx = dst.l_addr.l_symndx;
4556
707
    if (symndx >= obj_raw_syment_count (abfd))
4557
0
      {
4558
0
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
0
     abfd, symndx, counter);
4562
0
        cache_ptr->line_number = -1;
4563
0
        ret = false;
4564
0
        continue;
4565
0
      }
4566
4567
707
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
707
    if (! ent->is_sym)
4571
0
      {
4572
0
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
0
     abfd, symndx, counter);
4576
0
        cache_ptr->line_number = -1;
4577
0
        ret = false;
4578
0
        continue;
4579
0
      }
4580
707
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
707
    if (sym < obj_symbols (abfd)
4584
707
        || 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
707
    have_func = true;
4596
707
    nbr_func++;
4597
707
    cache_ptr->u.sym = (asymbol *) sym;
4598
707
    if (sym->lineno != NULL)
4599
657
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
657
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
657
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
707
    sym->lineno = cache_ptr;
4605
707
    if (sym->symbol.value < prev_offset)
4606
25
      ordered = false;
4607
707
    prev_offset = sym->symbol.value;
4608
707
  }
4609
3.52k
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
2.73k
  continue;
4613
794
      else
4614
794
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
1.50k
      cache_ptr++;
4616
1.50k
    }
4617
4618
58
  asect->lineno_count = cache_ptr - lineno_cache;
4619
58
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
58
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
58
  if (!ordered)
4624
21
    {
4625
      /* Sort the table.  */
4626
21
      alent **func_table;
4627
21
      alent *n_lineno_cache;
4628
4629
      /* Create a table of functions.  */
4630
21
      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
21
      else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL)
4636
21
  {
4637
21
    alent **p = func_table;
4638
21
    unsigned int i;
4639
4640
528
    for (i = 0; i < asect->lineno_count; i++)
4641
507
      if (lineno_cache[i].line_number == 0)
4642
191
        *p++ = &lineno_cache[i];
4643
4644
21
    BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func);
4645
4646
    /* Sort by functions.  */
4647
21
    qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent);
4648
4649
    /* Create the new sorted table.  */
4650
21
    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
21
    else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL)
4656
21
      {
4657
21
        alent *n_cache_ptr = n_lineno_cache;
4658
4659
212
        for (i = 0; i < nbr_func; i++)
4660
191
    {
4661
191
      coff_symbol_type *sym;
4662
191
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
191
      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
191
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
191
      do
4671
507
        *n_cache_ptr++ = *old_ptr++;
4672
507
      while (old_ptr->line_number != 0);
4673
191
    }
4674
4675
21
        memcpy (lineno_cache, n_lineno_cache,
4676
21
          asect->lineno_count * sizeof (alent));
4677
21
      }
4678
0
    else
4679
0
      ret = false;
4680
21
    bfd_release (abfd, func_table);
4681
21
  }
4682
0
      else
4683
0
  ret = false;
4684
21
    }
4685
4686
58
  return ret;
4687
58
}
coff64-rs6000.c:coff_slurp_line_table
Line
Count
Source
4490
1.13k
{
4491
1.13k
  LINENO *native_lineno;
4492
1.13k
  alent *lineno_cache;
4493
1.13k
  unsigned int counter;
4494
1.13k
  alent *cache_ptr;
4495
1.13k
  bfd_vma prev_offset = 0;
4496
1.13k
  bool ordered = true;
4497
1.13k
  unsigned int nbr_func;
4498
1.13k
  LINENO *src;
4499
1.13k
  bool have_func;
4500
1.13k
  bool ret = true;
4501
1.13k
  size_t amt;
4502
4503
1.13k
  if (asect->lineno_count == 0)
4504
1.05k
    return true;
4505
4506
71
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
71
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
71
             asect->lineno_count,
4510
71
             bfd_coff_linesz (abfd));
4511
71
  if (native_lineno == NULL)
4512
0
    {
4513
0
      _bfd_error_handler
4514
0
  (_("%pB: warning: line number table read failed"), abfd);
4515
0
      return false;
4516
0
    }
4517
4518
71
  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
71
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
71
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
71
  cache_ptr = lineno_cache;
4532
71
  asect->lineno = lineno_cache;
4533
71
  src = native_lineno;
4534
71
  nbr_func = 0;
4535
71
  have_func = false;
4536
4537
1.72k
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
1.65k
    {
4539
1.65k
      struct internal_lineno dst;
4540
4541
1.65k
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
1.65k
      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
1.65k
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
1.65k
      if (cache_ptr->line_number == 0)
4549
773
  {
4550
773
    combined_entry_type * ent;
4551
773
    unsigned long symndx;
4552
773
    coff_symbol_type *sym;
4553
4554
773
    have_func = false;
4555
773
    symndx = dst.l_addr.l_symndx;
4556
773
    if (symndx >= obj_raw_syment_count (abfd))
4557
0
      {
4558
0
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
0
     abfd, symndx, counter);
4562
0
        cache_ptr->line_number = -1;
4563
0
        ret = false;
4564
0
        continue;
4565
0
      }
4566
4567
773
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
773
    if (! ent->is_sym)
4571
0
      {
4572
0
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
0
     abfd, symndx, counter);
4576
0
        cache_ptr->line_number = -1;
4577
0
        ret = false;
4578
0
        continue;
4579
0
      }
4580
773
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
773
    if (sym < obj_symbols (abfd)
4584
773
        || 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
773
    have_func = true;
4596
773
    nbr_func++;
4597
773
    cache_ptr->u.sym = (asymbol *) sym;
4598
773
    if (sym->lineno != NULL)
4599
705
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
705
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
705
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
773
    sym->lineno = cache_ptr;
4605
773
    if (sym->symbol.value < prev_offset)
4606
46
      ordered = false;
4607
773
    prev_offset = sym->symbol.value;
4608
773
  }
4609
883
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
295
  continue;
4613
588
      else
4614
588
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
1.36k
      cache_ptr++;
4616
1.36k
    }
4617
4618
71
  asect->lineno_count = cache_ptr - lineno_cache;
4619
71
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
71
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
71
  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
279
    for (i = 0; i < asect->lineno_count; i++)
4641
246
      if (lineno_cache[i].line_number == 0)
4642
172
        *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
205
        for (i = 0; i < nbr_func; i++)
4660
172
    {
4661
172
      coff_symbol_type *sym;
4662
172
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
172
      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
172
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
172
      do
4671
246
        *n_cache_ptr++ = *old_ptr++;
4672
246
      while (old_ptr->line_number != 0);
4673
172
    }
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
71
  return ret;
4687
71
}
pe-aarch64.c:coff_slurp_line_table
Line
Count
Source
4490
534
{
4491
534
  LINENO *native_lineno;
4492
534
  alent *lineno_cache;
4493
534
  unsigned int counter;
4494
534
  alent *cache_ptr;
4495
534
  bfd_vma prev_offset = 0;
4496
534
  bool ordered = true;
4497
534
  unsigned int nbr_func;
4498
534
  LINENO *src;
4499
534
  bool have_func;
4500
534
  bool ret = true;
4501
534
  size_t amt;
4502
4503
534
  if (asect->lineno_count == 0)
4504
508
    return true;
4505
4506
26
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
26
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
26
             asect->lineno_count,
4510
26
             bfd_coff_linesz (abfd));
4511
26
  if (native_lineno == NULL)
4512
0
    {
4513
0
      _bfd_error_handler
4514
0
  (_("%pB: warning: line number table read failed"), abfd);
4515
0
      return false;
4516
0
    }
4517
4518
26
  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
26
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
26
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
26
  cache_ptr = lineno_cache;
4532
26
  asect->lineno = lineno_cache;
4533
26
  src = native_lineno;
4534
26
  nbr_func = 0;
4535
26
  have_func = false;
4536
4537
400
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
374
    {
4539
374
      struct internal_lineno dst;
4540
4541
374
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
374
      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
374
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
374
      if (cache_ptr->line_number == 0)
4549
220
  {
4550
220
    combined_entry_type * ent;
4551
220
    unsigned long symndx;
4552
220
    coff_symbol_type *sym;
4553
4554
220
    have_func = false;
4555
220
    symndx = dst.l_addr.l_symndx;
4556
220
    if (symndx >= obj_raw_syment_count (abfd))
4557
0
      {
4558
0
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
0
     abfd, symndx, counter);
4562
0
        cache_ptr->line_number = -1;
4563
0
        ret = false;
4564
0
        continue;
4565
0
      }
4566
4567
220
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
220
    if (! ent->is_sym)
4571
0
      {
4572
0
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
0
     abfd, symndx, counter);
4576
0
        cache_ptr->line_number = -1;
4577
0
        ret = false;
4578
0
        continue;
4579
0
      }
4580
220
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
220
    if (sym < obj_symbols (abfd)
4584
220
        || 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
220
    have_func = true;
4596
220
    nbr_func++;
4597
220
    cache_ptr->u.sym = (asymbol *) sym;
4598
220
    if (sym->lineno != NULL)
4599
194
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
194
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
194
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
220
    sym->lineno = cache_ptr;
4605
220
    if (sym->symbol.value < prev_offset)
4606
7
      ordered = false;
4607
220
    prev_offset = sym->symbol.value;
4608
220
  }
4609
154
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
122
  continue;
4613
32
      else
4614
32
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
252
      cache_ptr++;
4616
252
    }
4617
4618
26
  asect->lineno_count = cache_ptr - lineno_cache;
4619
26
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
26
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
26
  if (!ordered)
4624
7
    {
4625
      /* Sort the table.  */
4626
7
      alent **func_table;
4627
7
      alent *n_lineno_cache;
4628
4629
      /* Create a table of functions.  */
4630
7
      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
7
      else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL)
4636
7
  {
4637
7
    alent **p = func_table;
4638
7
    unsigned int i;
4639
4640
52
    for (i = 0; i < asect->lineno_count; i++)
4641
45
      if (lineno_cache[i].line_number == 0)
4642
27
        *p++ = &lineno_cache[i];
4643
4644
7
    BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func);
4645
4646
    /* Sort by functions.  */
4647
7
    qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent);
4648
4649
    /* Create the new sorted table.  */
4650
7
    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
7
    else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL)
4656
7
      {
4657
7
        alent *n_cache_ptr = n_lineno_cache;
4658
4659
34
        for (i = 0; i < nbr_func; i++)
4660
27
    {
4661
27
      coff_symbol_type *sym;
4662
27
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
27
      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
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
27
      do
4671
45
        *n_cache_ptr++ = *old_ptr++;
4672
45
      while (old_ptr->line_number != 0);
4673
27
    }
4674
4675
7
        memcpy (lineno_cache, n_lineno_cache,
4676
7
          asect->lineno_count * sizeof (alent));
4677
7
      }
4678
0
    else
4679
0
      ret = false;
4680
7
    bfd_release (abfd, func_table);
4681
7
  }
4682
0
      else
4683
0
  ret = false;
4684
7
    }
4685
4686
26
  return ret;
4687
26
}
pei-aarch64.c:coff_slurp_line_table
Line
Count
Source
4490
264
{
4491
264
  LINENO *native_lineno;
4492
264
  alent *lineno_cache;
4493
264
  unsigned int counter;
4494
264
  alent *cache_ptr;
4495
264
  bfd_vma prev_offset = 0;
4496
264
  bool ordered = true;
4497
264
  unsigned int nbr_func;
4498
264
  LINENO *src;
4499
264
  bool have_func;
4500
264
  bool ret = true;
4501
264
  size_t amt;
4502
4503
264
  if (asect->lineno_count == 0)
4504
233
    return true;
4505
4506
31
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
31
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
31
             asect->lineno_count,
4510
31
             bfd_coff_linesz (abfd));
4511
31
  if (native_lineno == NULL)
4512
0
    {
4513
0
      _bfd_error_handler
4514
0
  (_("%pB: warning: line number table read failed"), abfd);
4515
0
      return false;
4516
0
    }
4517
4518
31
  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
31
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
31
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
31
  cache_ptr = lineno_cache;
4532
31
  asect->lineno = lineno_cache;
4533
31
  src = native_lineno;
4534
31
  nbr_func = 0;
4535
31
  have_func = false;
4536
4537
303
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
272
    {
4539
272
      struct internal_lineno dst;
4540
4541
272
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
272
      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
272
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
272
      if (cache_ptr->line_number == 0)
4549
202
  {
4550
202
    combined_entry_type * ent;
4551
202
    unsigned long symndx;
4552
202
    coff_symbol_type *sym;
4553
4554
202
    have_func = false;
4555
202
    symndx = dst.l_addr.l_symndx;
4556
202
    if (symndx >= obj_raw_syment_count (abfd))
4557
0
      {
4558
0
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
0
     abfd, symndx, counter);
4562
0
        cache_ptr->line_number = -1;
4563
0
        ret = false;
4564
0
        continue;
4565
0
      }
4566
4567
202
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
202
    if (! ent->is_sym)
4571
0
      {
4572
0
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
0
     abfd, symndx, counter);
4576
0
        cache_ptr->line_number = -1;
4577
0
        ret = false;
4578
0
        continue;
4579
0
      }
4580
202
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
202
    if (sym < obj_symbols (abfd)
4584
202
        || 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
202
    have_func = true;
4596
202
    nbr_func++;
4597
202
    cache_ptr->u.sym = (asymbol *) sym;
4598
202
    if (sym->lineno != NULL)
4599
142
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
142
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
142
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
202
    sym->lineno = cache_ptr;
4605
202
    if (sym->symbol.value < prev_offset)
4606
28
      ordered = false;
4607
202
    prev_offset = sym->symbol.value;
4608
202
  }
4609
70
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
21
  continue;
4613
49
      else
4614
49
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
251
      cache_ptr++;
4616
251
    }
4617
4618
31
  asect->lineno_count = cache_ptr - lineno_cache;
4619
31
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
31
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
31
  if (!ordered)
4624
21
    {
4625
      /* Sort the table.  */
4626
21
      alent **func_table;
4627
21
      alent *n_lineno_cache;
4628
4629
      /* Create a table of functions.  */
4630
21
      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
21
      else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL)
4636
21
  {
4637
21
    alent **p = func_table;
4638
21
    unsigned int i;
4639
4640
258
    for (i = 0; i < asect->lineno_count; i++)
4641
237
      if (lineno_cache[i].line_number == 0)
4642
190
        *p++ = &lineno_cache[i];
4643
4644
21
    BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func);
4645
4646
    /* Sort by functions.  */
4647
21
    qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent);
4648
4649
    /* Create the new sorted table.  */
4650
21
    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
21
    else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL)
4656
21
      {
4657
21
        alent *n_cache_ptr = n_lineno_cache;
4658
4659
211
        for (i = 0; i < nbr_func; i++)
4660
190
    {
4661
190
      coff_symbol_type *sym;
4662
190
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
190
      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
190
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
190
      do
4671
237
        *n_cache_ptr++ = *old_ptr++;
4672
237
      while (old_ptr->line_number != 0);
4673
190
    }
4674
4675
21
        memcpy (lineno_cache, n_lineno_cache,
4676
21
          asect->lineno_count * sizeof (alent));
4677
21
      }
4678
0
    else
4679
0
      ret = false;
4680
21
    bfd_release (abfd, func_table);
4681
21
  }
4682
0
      else
4683
0
  ret = false;
4684
21
    }
4685
4686
31
  return ret;
4687
31
}
pei-ia64.c:coff_slurp_line_table
Line
Count
Source
4490
91
{
4491
91
  LINENO *native_lineno;
4492
91
  alent *lineno_cache;
4493
91
  unsigned int counter;
4494
91
  alent *cache_ptr;
4495
91
  bfd_vma prev_offset = 0;
4496
91
  bool ordered = true;
4497
91
  unsigned int nbr_func;
4498
91
  LINENO *src;
4499
91
  bool have_func;
4500
91
  bool ret = true;
4501
91
  size_t amt;
4502
4503
91
  if (asect->lineno_count == 0)
4504
69
    return true;
4505
4506
22
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
22
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
22
             asect->lineno_count,
4510
22
             bfd_coff_linesz (abfd));
4511
22
  if (native_lineno == NULL)
4512
0
    {
4513
0
      _bfd_error_handler
4514
0
  (_("%pB: warning: line number table read failed"), abfd);
4515
0
      return false;
4516
0
    }
4517
4518
22
  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
22
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
22
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
22
  cache_ptr = lineno_cache;
4532
22
  asect->lineno = lineno_cache;
4533
22
  src = native_lineno;
4534
22
  nbr_func = 0;
4535
22
  have_func = false;
4536
4537
415
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
393
    {
4539
393
      struct internal_lineno dst;
4540
4541
393
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
393
      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
393
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
393
      if (cache_ptr->line_number == 0)
4549
73
  {
4550
73
    combined_entry_type * ent;
4551
73
    unsigned long symndx;
4552
73
    coff_symbol_type *sym;
4553
4554
73
    have_func = false;
4555
73
    symndx = dst.l_addr.l_symndx;
4556
73
    if (symndx >= obj_raw_syment_count (abfd))
4557
0
      {
4558
0
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
0
     abfd, symndx, counter);
4562
0
        cache_ptr->line_number = -1;
4563
0
        ret = false;
4564
0
        continue;
4565
0
      }
4566
4567
73
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
73
    if (! ent->is_sym)
4571
0
      {
4572
0
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
0
     abfd, symndx, counter);
4576
0
        cache_ptr->line_number = -1;
4577
0
        ret = false;
4578
0
        continue;
4579
0
      }
4580
73
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
73
    if (sym < obj_symbols (abfd)
4584
73
        || 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
73
    have_func = true;
4596
73
    nbr_func++;
4597
73
    cache_ptr->u.sym = (asymbol *) sym;
4598
73
    if (sym->lineno != NULL)
4599
48
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
48
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
48
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
73
    sym->lineno = cache_ptr;
4605
73
    if (sym->symbol.value < prev_offset)
4606
10
      ordered = false;
4607
73
    prev_offset = sym->symbol.value;
4608
73
  }
4609
320
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
241
  continue;
4613
79
      else
4614
79
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
152
      cache_ptr++;
4616
152
    }
4617
4618
22
  asect->lineno_count = cache_ptr - lineno_cache;
4619
22
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
22
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
22
  if (!ordered)
4624
10
    {
4625
      /* Sort the table.  */
4626
10
      alent **func_table;
4627
10
      alent *n_lineno_cache;
4628
4629
      /* Create a table of functions.  */
4630
10
      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
10
      else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL)
4636
10
  {
4637
10
    alent **p = func_table;
4638
10
    unsigned int i;
4639
4640
87
    for (i = 0; i < asect->lineno_count; i++)
4641
77
      if (lineno_cache[i].line_number == 0)
4642
36
        *p++ = &lineno_cache[i];
4643
4644
10
    BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func);
4645
4646
    /* Sort by functions.  */
4647
10
    qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent);
4648
4649
    /* Create the new sorted table.  */
4650
10
    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
10
    else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL)
4656
10
      {
4657
10
        alent *n_cache_ptr = n_lineno_cache;
4658
4659
46
        for (i = 0; i < nbr_func; i++)
4660
36
    {
4661
36
      coff_symbol_type *sym;
4662
36
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
36
      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
36
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
36
      do
4671
77
        *n_cache_ptr++ = *old_ptr++;
4672
77
      while (old_ptr->line_number != 0);
4673
36
    }
4674
4675
10
        memcpy (lineno_cache, n_lineno_cache,
4676
10
          asect->lineno_count * sizeof (alent));
4677
10
      }
4678
0
    else
4679
0
      ret = false;
4680
10
    bfd_release (abfd, func_table);
4681
10
  }
4682
0
      else
4683
0
  ret = false;
4684
10
    }
4685
4686
22
  return ret;
4687
22
}
pei-loongarch64.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
247
    return true;
4505
4506
43
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
43
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
43
             asect->lineno_count,
4510
43
             bfd_coff_linesz (abfd));
4511
43
  if (native_lineno == NULL)
4512
0
    {
4513
0
      _bfd_error_handler
4514
0
  (_("%pB: warning: line number table read failed"), abfd);
4515
0
      return false;
4516
0
    }
4517
4518
43
  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
43
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
43
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
43
  cache_ptr = lineno_cache;
4532
43
  asect->lineno = lineno_cache;
4533
43
  src = native_lineno;
4534
43
  nbr_func = 0;
4535
43
  have_func = false;
4536
4537
1.43k
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
1.39k
    {
4539
1.39k
      struct internal_lineno dst;
4540
4541
1.39k
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
1.39k
      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
1.39k
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
1.39k
      if (cache_ptr->line_number == 0)
4549
311
  {
4550
311
    combined_entry_type * ent;
4551
311
    unsigned long symndx;
4552
311
    coff_symbol_type *sym;
4553
4554
311
    have_func = false;
4555
311
    symndx = dst.l_addr.l_symndx;
4556
311
    if (symndx >= obj_raw_syment_count (abfd))
4557
0
      {
4558
0
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
0
     abfd, symndx, counter);
4562
0
        cache_ptr->line_number = -1;
4563
0
        ret = false;
4564
0
        continue;
4565
0
      }
4566
4567
311
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
311
    if (! ent->is_sym)
4571
0
      {
4572
0
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
0
     abfd, symndx, counter);
4576
0
        cache_ptr->line_number = -1;
4577
0
        ret = false;
4578
0
        continue;
4579
0
      }
4580
311
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
311
    if (sym < obj_symbols (abfd)
4584
311
        || 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
311
    have_func = true;
4596
311
    nbr_func++;
4597
311
    cache_ptr->u.sym = (asymbol *) sym;
4598
311
    if (sym->lineno != NULL)
4599
248
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
248
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
248
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
311
    sym->lineno = cache_ptr;
4605
311
    if (sym->symbol.value < prev_offset)
4606
29
      ordered = false;
4607
311
    prev_offset = sym->symbol.value;
4608
311
  }
4609
1.07k
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
515
  continue;
4613
564
      else
4614
564
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
875
      cache_ptr++;
4616
875
    }
4617
4618
43
  asect->lineno_count = cache_ptr - lineno_cache;
4619
43
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
43
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
43
  if (!ordered)
4624
24
    {
4625
      /* Sort the table.  */
4626
24
      alent **func_table;
4627
24
      alent *n_lineno_cache;
4628
4629
      /* Create a table of functions.  */
4630
24
      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
24
      else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL)
4636
24
  {
4637
24
    alent **p = func_table;
4638
24
    unsigned int i;
4639
4640
614
    for (i = 0; i < asect->lineno_count; i++)
4641
590
      if (lineno_cache[i].line_number == 0)
4642
150
        *p++ = &lineno_cache[i];
4643
4644
24
    BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func);
4645
4646
    /* Sort by functions.  */
4647
24
    qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent);
4648
4649
    /* Create the new sorted table.  */
4650
24
    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
24
    else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL)
4656
24
      {
4657
24
        alent *n_cache_ptr = n_lineno_cache;
4658
4659
174
        for (i = 0; i < nbr_func; i++)
4660
150
    {
4661
150
      coff_symbol_type *sym;
4662
150
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
150
      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
150
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
150
      do
4671
590
        *n_cache_ptr++ = *old_ptr++;
4672
590
      while (old_ptr->line_number != 0);
4673
150
    }
4674
4675
24
        memcpy (lineno_cache, n_lineno_cache,
4676
24
          asect->lineno_count * sizeof (alent));
4677
24
      }
4678
0
    else
4679
0
      ret = false;
4680
24
    bfd_release (abfd, func_table);
4681
24
  }
4682
0
      else
4683
0
  ret = false;
4684
24
    }
4685
4686
43
  return ret;
4687
43
}
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
8.20k
{
4491
8.20k
  LINENO *native_lineno;
4492
8.20k
  alent *lineno_cache;
4493
8.20k
  unsigned int counter;
4494
8.20k
  alent *cache_ptr;
4495
8.20k
  bfd_vma prev_offset = 0;
4496
8.20k
  bool ordered = true;
4497
8.20k
  unsigned int nbr_func;
4498
8.20k
  LINENO *src;
4499
8.20k
  bool have_func;
4500
8.20k
  bool ret = true;
4501
8.20k
  size_t amt;
4502
4503
8.20k
  if (asect->lineno_count == 0)
4504
8.07k
    return true;
4505
4506
133
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
133
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
133
             asect->lineno_count,
4510
133
             bfd_coff_linesz (abfd));
4511
133
  if (native_lineno == NULL)
4512
0
    {
4513
0
      _bfd_error_handler
4514
0
  (_("%pB: warning: line number table read failed"), abfd);
4515
0
      return false;
4516
0
    }
4517
4518
133
  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
133
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
133
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
133
  cache_ptr = lineno_cache;
4532
133
  asect->lineno = lineno_cache;
4533
133
  src = native_lineno;
4534
133
  nbr_func = 0;
4535
133
  have_func = false;
4536
4537
22.2k
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
22.1k
    {
4539
22.1k
      struct internal_lineno dst;
4540
4541
22.1k
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
22.1k
      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
22.1k
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
22.1k
      if (cache_ptr->line_number == 0)
4549
21.2k
  {
4550
21.2k
    combined_entry_type * ent;
4551
21.2k
    unsigned long symndx;
4552
21.2k
    coff_symbol_type *sym;
4553
4554
21.2k
    have_func = false;
4555
21.2k
    symndx = dst.l_addr.l_symndx;
4556
21.2k
    if (symndx >= obj_raw_syment_count (abfd))
4557
0
      {
4558
0
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
0
     abfd, symndx, counter);
4562
0
        cache_ptr->line_number = -1;
4563
0
        ret = false;
4564
0
        continue;
4565
0
      }
4566
4567
21.2k
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
21.2k
    if (! ent->is_sym)
4571
0
      {
4572
0
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
0
     abfd, symndx, counter);
4576
0
        cache_ptr->line_number = -1;
4577
0
        ret = false;
4578
0
        continue;
4579
0
      }
4580
21.2k
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
21.2k
    if (sym < obj_symbols (abfd)
4584
21.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
21.2k
    have_func = true;
4596
21.2k
    nbr_func++;
4597
21.2k
    cache_ptr->u.sym = (asymbol *) sym;
4598
21.2k
    if (sym->lineno != NULL)
4599
21.1k
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
21.1k
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
21.1k
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
21.2k
    sym->lineno = cache_ptr;
4605
21.2k
    if (sym->symbol.value < prev_offset)
4606
133
      ordered = false;
4607
21.2k
    prev_offset = sym->symbol.value;
4608
21.2k
  }
4609
915
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
430
  continue;
4613
485
      else
4614
485
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
21.7k
      cache_ptr++;
4616
21.7k
    }
4617
4618
133
  asect->lineno_count = cache_ptr - lineno_cache;
4619
133
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
133
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
133
  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
17.9k
    for (i = 0; i < asect->lineno_count; i++)
4641
17.8k
      if (lineno_cache[i].line_number == 0)
4642
17.4k
        *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
17.5k
        for (i = 0; i < nbr_func; i++)
4660
17.4k
    {
4661
17.4k
      coff_symbol_type *sym;
4662
17.4k
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
17.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
17.4k
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
17.4k
      do
4671
17.8k
        *n_cache_ptr++ = *old_ptr++;
4672
17.8k
      while (old_ptr->line_number != 0);
4673
17.4k
    }
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
133
  return ret;
4687
133
}
coff-sh.c:coff_slurp_line_table
Line
Count
Source
4490
2.04k
{
4491
2.04k
  LINENO *native_lineno;
4492
2.04k
  alent *lineno_cache;
4493
2.04k
  unsigned int counter;
4494
2.04k
  alent *cache_ptr;
4495
2.04k
  bfd_vma prev_offset = 0;
4496
2.04k
  bool ordered = true;
4497
2.04k
  unsigned int nbr_func;
4498
2.04k
  LINENO *src;
4499
2.04k
  bool have_func;
4500
2.04k
  bool ret = true;
4501
2.04k
  size_t amt;
4502
4503
2.04k
  if (asect->lineno_count == 0)
4504
1.96k
    return true;
4505
4506
71
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
71
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
71
             asect->lineno_count,
4510
71
             bfd_coff_linesz (abfd));
4511
71
  if (native_lineno == NULL)
4512
0
    {
4513
0
      _bfd_error_handler
4514
0
  (_("%pB: warning: line number table read failed"), abfd);
4515
0
      return false;
4516
0
    }
4517
4518
71
  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
71
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
71
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
71
  cache_ptr = lineno_cache;
4532
71
  asect->lineno = lineno_cache;
4533
71
  src = native_lineno;
4534
71
  nbr_func = 0;
4535
71
  have_func = false;
4536
4537
18.0k
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
18.0k
    {
4539
18.0k
      struct internal_lineno dst;
4540
4541
18.0k
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
18.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
18.0k
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
18.0k
      if (cache_ptr->line_number == 0)
4549
6.56k
  {
4550
6.56k
    combined_entry_type * ent;
4551
6.56k
    unsigned long symndx;
4552
6.56k
    coff_symbol_type *sym;
4553
4554
6.56k
    have_func = false;
4555
6.56k
    symndx = dst.l_addr.l_symndx;
4556
6.56k
    if (symndx >= obj_raw_syment_count (abfd))
4557
0
      {
4558
0
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
0
     abfd, symndx, counter);
4562
0
        cache_ptr->line_number = -1;
4563
0
        ret = false;
4564
0
        continue;
4565
0
      }
4566
4567
6.56k
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
6.56k
    if (! ent->is_sym)
4571
0
      {
4572
0
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
0
     abfd, symndx, counter);
4576
0
        cache_ptr->line_number = -1;
4577
0
        ret = false;
4578
0
        continue;
4579
0
      }
4580
6.56k
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
6.56k
    if (sym < obj_symbols (abfd)
4584
6.56k
        || 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
6.56k
    have_func = true;
4596
6.56k
    nbr_func++;
4597
6.56k
    cache_ptr->u.sym = (asymbol *) sym;
4598
6.56k
    if (sym->lineno != NULL)
4599
6.50k
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
6.50k
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
6.50k
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
6.56k
    sym->lineno = cache_ptr;
4605
6.56k
    if (sym->symbol.value < prev_offset)
4606
24
      ordered = false;
4607
6.56k
    prev_offset = sym->symbol.value;
4608
6.56k
  }
4609
11.4k
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
1.85k
  continue;
4613
9.60k
      else
4614
9.60k
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
16.1k
      cache_ptr++;
4616
16.1k
    }
4617
4618
71
  asect->lineno_count = cache_ptr - lineno_cache;
4619
71
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
71
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
71
  if (!ordered)
4624
20
    {
4625
      /* Sort the table.  */
4626
20
      alent **func_table;
4627
20
      alent *n_lineno_cache;
4628
4629
      /* Create a table of functions.  */
4630
20
      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
20
      else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL)
4636
20
  {
4637
20
    alent **p = func_table;
4638
20
    unsigned int i;
4639
4640
7.34k
    for (i = 0; i < asect->lineno_count; i++)
4641
7.32k
      if (lineno_cache[i].line_number == 0)
4642
3.39k
        *p++ = &lineno_cache[i];
4643
4644
20
    BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func);
4645
4646
    /* Sort by functions.  */
4647
20
    qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent);
4648
4649
    /* Create the new sorted table.  */
4650
20
    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
20
    else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL)
4656
20
      {
4657
20
        alent *n_cache_ptr = n_lineno_cache;
4658
4659
3.41k
        for (i = 0; i < nbr_func; i++)
4660
3.39k
    {
4661
3.39k
      coff_symbol_type *sym;
4662
3.39k
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
3.39k
      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
3.39k
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
3.39k
      do
4671
7.32k
        *n_cache_ptr++ = *old_ptr++;
4672
7.32k
      while (old_ptr->line_number != 0);
4673
3.39k
    }
4674
4675
20
        memcpy (lineno_cache, n_lineno_cache,
4676
20
          asect->lineno_count * sizeof (alent));
4677
20
      }
4678
0
    else
4679
0
      ret = false;
4680
20
    bfd_release (abfd, func_table);
4681
20
  }
4682
0
      else
4683
0
  ret = false;
4684
20
    }
4685
4686
71
  return ret;
4687
71
}
Unexecuted instantiation: coff-stgo32.c:coff_slurp_line_table
coff-tic30.c:coff_slurp_line_table
Line
Count
Source
4490
140
{
4491
140
  LINENO *native_lineno;
4492
140
  alent *lineno_cache;
4493
140
  unsigned int counter;
4494
140
  alent *cache_ptr;
4495
140
  bfd_vma prev_offset = 0;
4496
140
  bool ordered = true;
4497
140
  unsigned int nbr_func;
4498
140
  LINENO *src;
4499
140
  bool have_func;
4500
140
  bool ret = true;
4501
140
  size_t amt;
4502
4503
140
  if (asect->lineno_count == 0)
4504
74
    return true;
4505
4506
66
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
66
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
66
             asect->lineno_count,
4510
66
             bfd_coff_linesz (abfd));
4511
66
  if (native_lineno == NULL)
4512
0
    {
4513
0
      _bfd_error_handler
4514
0
  (_("%pB: warning: line number table read failed"), abfd);
4515
0
      return false;
4516
0
    }
4517
4518
66
  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
66
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
66
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
66
  cache_ptr = lineno_cache;
4532
66
  asect->lineno = lineno_cache;
4533
66
  src = native_lineno;
4534
66
  nbr_func = 0;
4535
66
  have_func = false;
4536
4537
31.3k
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
31.2k
    {
4539
31.2k
      struct internal_lineno dst;
4540
4541
31.2k
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
31.2k
      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
31.2k
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
31.2k
      if (cache_ptr->line_number == 0)
4549
27.9k
  {
4550
27.9k
    combined_entry_type * ent;
4551
27.9k
    unsigned long symndx;
4552
27.9k
    coff_symbol_type *sym;
4553
4554
27.9k
    have_func = false;
4555
27.9k
    symndx = dst.l_addr.l_symndx;
4556
27.9k
    if (symndx >= obj_raw_syment_count (abfd))
4557
0
      {
4558
0
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
0
     abfd, symndx, counter);
4562
0
        cache_ptr->line_number = -1;
4563
0
        ret = false;
4564
0
        continue;
4565
0
      }
4566
4567
27.9k
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
27.9k
    if (! ent->is_sym)
4571
0
      {
4572
0
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
0
     abfd, symndx, counter);
4576
0
        cache_ptr->line_number = -1;
4577
0
        ret = false;
4578
0
        continue;
4579
0
      }
4580
27.9k
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
27.9k
    if (sym < obj_symbols (abfd)
4584
27.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
27.9k
    have_func = true;
4596
27.9k
    nbr_func++;
4597
27.9k
    cache_ptr->u.sym = (asymbol *) sym;
4598
27.9k
    if (sym->lineno != NULL)
4599
27.9k
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
27.9k
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
27.9k
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
27.9k
    sym->lineno = cache_ptr;
4605
27.9k
    if (sym->symbol.value < prev_offset)
4606
31
      ordered = false;
4607
27.9k
    prev_offset = sym->symbol.value;
4608
27.9k
  }
4609
3.25k
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
1.58k
  continue;
4613
1.66k
      else
4614
1.66k
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
29.6k
      cache_ptr++;
4616
29.6k
    }
4617
4618
66
  asect->lineno_count = cache_ptr - lineno_cache;
4619
66
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
66
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
66
  if (!ordered)
4624
26
    {
4625
      /* Sort the table.  */
4626
26
      alent **func_table;
4627
26
      alent *n_lineno_cache;
4628
4629
      /* Create a table of functions.  */
4630
26
      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
26
      else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL)
4636
26
  {
4637
26
    alent **p = func_table;
4638
26
    unsigned int i;
4639
4640
1.15k
    for (i = 0; i < asect->lineno_count; i++)
4641
1.12k
      if (lineno_cache[i].line_number == 0)
4642
238
        *p++ = &lineno_cache[i];
4643
4644
26
    BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func);
4645
4646
    /* Sort by functions.  */
4647
26
    qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent);
4648
4649
    /* Create the new sorted table.  */
4650
26
    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
26
    else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL)
4656
26
      {
4657
26
        alent *n_cache_ptr = n_lineno_cache;
4658
4659
264
        for (i = 0; i < nbr_func; i++)
4660
238
    {
4661
238
      coff_symbol_type *sym;
4662
238
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
238
      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
238
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
238
      do
4671
1.12k
        *n_cache_ptr++ = *old_ptr++;
4672
1.12k
      while (old_ptr->line_number != 0);
4673
238
    }
4674
4675
26
        memcpy (lineno_cache, n_lineno_cache,
4676
26
          asect->lineno_count * sizeof (alent));
4677
26
      }
4678
0
    else
4679
0
      ret = false;
4680
26
    bfd_release (abfd, func_table);
4681
26
  }
4682
0
      else
4683
0
  ret = false;
4684
26
    }
4685
4686
66
  return ret;
4687
66
}
Unexecuted instantiation: coff-tic4x.c:coff_slurp_line_table
coff-tic54x.c:coff_slurp_line_table
Line
Count
Source
4490
666
{
4491
666
  LINENO *native_lineno;
4492
666
  alent *lineno_cache;
4493
666
  unsigned int counter;
4494
666
  alent *cache_ptr;
4495
666
  bfd_vma prev_offset = 0;
4496
666
  bool ordered = true;
4497
666
  unsigned int nbr_func;
4498
666
  LINENO *src;
4499
666
  bool have_func;
4500
666
  bool ret = true;
4501
666
  size_t amt;
4502
4503
666
  if (asect->lineno_count == 0)
4504
641
    return true;
4505
4506
25
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
25
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
25
             asect->lineno_count,
4510
25
             bfd_coff_linesz (abfd));
4511
25
  if (native_lineno == NULL)
4512
0
    {
4513
0
      _bfd_error_handler
4514
0
  (_("%pB: warning: line number table read failed"), abfd);
4515
0
      return false;
4516
0
    }
4517
4518
25
  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
25
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
25
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
25
  cache_ptr = lineno_cache;
4532
25
  asect->lineno = lineno_cache;
4533
25
  src = native_lineno;
4534
25
  nbr_func = 0;
4535
25
  have_func = false;
4536
4537
732
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
707
    {
4539
707
      struct internal_lineno dst;
4540
4541
707
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
707
      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
707
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
707
      if (cache_ptr->line_number == 0)
4549
553
  {
4550
553
    combined_entry_type * ent;
4551
553
    unsigned long symndx;
4552
553
    coff_symbol_type *sym;
4553
4554
553
    have_func = false;
4555
553
    symndx = dst.l_addr.l_symndx;
4556
553
    if (symndx >= obj_raw_syment_count (abfd))
4557
0
      {
4558
0
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
0
     abfd, symndx, counter);
4562
0
        cache_ptr->line_number = -1;
4563
0
        ret = false;
4564
0
        continue;
4565
0
      }
4566
4567
553
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
553
    if (! ent->is_sym)
4571
0
      {
4572
0
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
0
     abfd, symndx, counter);
4576
0
        cache_ptr->line_number = -1;
4577
0
        ret = false;
4578
0
        continue;
4579
0
      }
4580
553
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
553
    if (sym < obj_symbols (abfd)
4584
553
        || 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
553
    have_func = true;
4596
553
    nbr_func++;
4597
553
    cache_ptr->u.sym = (asymbol *) sym;
4598
553
    if (sym->lineno != NULL)
4599
520
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
520
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
520
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
553
    sym->lineno = cache_ptr;
4605
553
    if (sym->symbol.value < prev_offset)
4606
17
      ordered = false;
4607
553
    prev_offset = sym->symbol.value;
4608
553
  }
4609
154
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
44
  continue;
4613
110
      else
4614
110
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
663
      cache_ptr++;
4616
663
    }
4617
4618
25
  asect->lineno_count = cache_ptr - lineno_cache;
4619
25
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
25
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
25
  if (!ordered)
4624
10
    {
4625
      /* Sort the table.  */
4626
10
      alent **func_table;
4627
10
      alent *n_lineno_cache;
4628
4629
      /* Create a table of functions.  */
4630
10
      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
10
      else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL)
4636
10
  {
4637
10
    alent **p = func_table;
4638
10
    unsigned int i;
4639
4640
549
    for (i = 0; i < asect->lineno_count; i++)
4641
539
      if (lineno_cache[i].line_number == 0)
4642
458
        *p++ = &lineno_cache[i];
4643
4644
10
    BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func);
4645
4646
    /* Sort by functions.  */
4647
10
    qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent);
4648
4649
    /* Create the new sorted table.  */
4650
10
    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
10
    else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL)
4656
10
      {
4657
10
        alent *n_cache_ptr = n_lineno_cache;
4658
4659
468
        for (i = 0; i < nbr_func; i++)
4660
458
    {
4661
458
      coff_symbol_type *sym;
4662
458
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
458
      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
458
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
458
      do
4671
539
        *n_cache_ptr++ = *old_ptr++;
4672
539
      while (old_ptr->line_number != 0);
4673
458
    }
4674
4675
10
        memcpy (lineno_cache, n_lineno_cache,
4676
10
          asect->lineno_count * sizeof (alent));
4677
10
      }
4678
0
    else
4679
0
      ret = false;
4680
10
    bfd_release (abfd, func_table);
4681
10
  }
4682
0
      else
4683
0
  ret = false;
4684
10
    }
4685
4686
25
  return ret;
4687
25
}
coff-z80.c:coff_slurp_line_table
Line
Count
Source
4490
285
{
4491
285
  LINENO *native_lineno;
4492
285
  alent *lineno_cache;
4493
285
  unsigned int counter;
4494
285
  alent *cache_ptr;
4495
285
  bfd_vma prev_offset = 0;
4496
285
  bool ordered = true;
4497
285
  unsigned int nbr_func;
4498
285
  LINENO *src;
4499
285
  bool have_func;
4500
285
  bool ret = true;
4501
285
  size_t amt;
4502
4503
285
  if (asect->lineno_count == 0)
4504
226
    return true;
4505
4506
59
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
59
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
59
             asect->lineno_count,
4510
59
             bfd_coff_linesz (abfd));
4511
59
  if (native_lineno == NULL)
4512
0
    {
4513
0
      _bfd_error_handler
4514
0
  (_("%pB: warning: line number table read failed"), abfd);
4515
0
      return false;
4516
0
    }
4517
4518
59
  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
59
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
59
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
59
  cache_ptr = lineno_cache;
4532
59
  asect->lineno = lineno_cache;
4533
59
  src = native_lineno;
4534
59
  nbr_func = 0;
4535
59
  have_func = false;
4536
4537
558
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
499
    {
4539
499
      struct internal_lineno dst;
4540
4541
499
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
499
      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
499
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
499
      if (cache_ptr->line_number == 0)
4549
251
  {
4550
251
    combined_entry_type * ent;
4551
251
    unsigned long symndx;
4552
251
    coff_symbol_type *sym;
4553
4554
251
    have_func = false;
4555
251
    symndx = dst.l_addr.l_symndx;
4556
251
    if (symndx >= obj_raw_syment_count (abfd))
4557
0
      {
4558
0
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
0
     abfd, symndx, counter);
4562
0
        cache_ptr->line_number = -1;
4563
0
        ret = false;
4564
0
        continue;
4565
0
      }
4566
4567
251
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
251
    if (! ent->is_sym)
4571
0
      {
4572
0
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
0
     abfd, symndx, counter);
4576
0
        cache_ptr->line_number = -1;
4577
0
        ret = false;
4578
0
        continue;
4579
0
      }
4580
251
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
251
    if (sym < obj_symbols (abfd)
4584
251
        || 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
251
    have_func = true;
4596
251
    nbr_func++;
4597
251
    cache_ptr->u.sym = (asymbol *) sym;
4598
251
    if (sym->lineno != NULL)
4599
213
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
213
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
213
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
251
    sym->lineno = cache_ptr;
4605
251
    if (sym->symbol.value < prev_offset)
4606
23
      ordered = false;
4607
251
    prev_offset = sym->symbol.value;
4608
251
  }
4609
248
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
161
  continue;
4613
87
      else
4614
87
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
338
      cache_ptr++;
4616
338
    }
4617
4618
59
  asect->lineno_count = cache_ptr - lineno_cache;
4619
59
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
59
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
59
  if (!ordered)
4624
23
    {
4625
      /* Sort the table.  */
4626
23
      alent **func_table;
4627
23
      alent *n_lineno_cache;
4628
4629
      /* Create a table of functions.  */
4630
23
      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
23
      else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL)
4636
23
  {
4637
23
    alent **p = func_table;
4638
23
    unsigned int i;
4639
4640
187
    for (i = 0; i < asect->lineno_count; i++)
4641
164
      if (lineno_cache[i].line_number == 0)
4642
116
        *p++ = &lineno_cache[i];
4643
4644
23
    BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func);
4645
4646
    /* Sort by functions.  */
4647
23
    qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent);
4648
4649
    /* Create the new sorted table.  */
4650
23
    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
23
    else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL)
4656
23
      {
4657
23
        alent *n_cache_ptr = n_lineno_cache;
4658
4659
139
        for (i = 0; i < nbr_func; i++)
4660
116
    {
4661
116
      coff_symbol_type *sym;
4662
116
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
116
      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
116
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
116
      do
4671
164
        *n_cache_ptr++ = *old_ptr++;
4672
164
      while (old_ptr->line_number != 0);
4673
116
    }
4674
4675
23
        memcpy (lineno_cache, n_lineno_cache,
4676
23
          asect->lineno_count * sizeof (alent));
4677
23
      }
4678
0
    else
4679
0
      ret = false;
4680
23
    bfd_release (abfd, func_table);
4681
23
  }
4682
0
      else
4683
0
  ret = false;
4684
23
    }
4685
4686
59
  return ret;
4687
59
}
coff-z8k.c:coff_slurp_line_table
Line
Count
Source
4490
475
{
4491
475
  LINENO *native_lineno;
4492
475
  alent *lineno_cache;
4493
475
  unsigned int counter;
4494
475
  alent *cache_ptr;
4495
475
  bfd_vma prev_offset = 0;
4496
475
  bool ordered = true;
4497
475
  unsigned int nbr_func;
4498
475
  LINENO *src;
4499
475
  bool have_func;
4500
475
  bool ret = true;
4501
475
  size_t amt;
4502
4503
475
  if (asect->lineno_count == 0)
4504
442
    return true;
4505
4506
33
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
33
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
33
             asect->lineno_count,
4510
33
             bfd_coff_linesz (abfd));
4511
33
  if (native_lineno == NULL)
4512
0
    {
4513
0
      _bfd_error_handler
4514
0
  (_("%pB: warning: line number table read failed"), abfd);
4515
0
      return false;
4516
0
    }
4517
4518
33
  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
33
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
33
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
33
  cache_ptr = lineno_cache;
4532
33
  asect->lineno = lineno_cache;
4533
33
  src = native_lineno;
4534
33
  nbr_func = 0;
4535
33
  have_func = false;
4536
4537
875
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
842
    {
4539
842
      struct internal_lineno dst;
4540
4541
842
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
842
      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
842
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
842
      if (cache_ptr->line_number == 0)
4549
551
  {
4550
551
    combined_entry_type * ent;
4551
551
    unsigned long symndx;
4552
551
    coff_symbol_type *sym;
4553
4554
551
    have_func = false;
4555
551
    symndx = dst.l_addr.l_symndx;
4556
551
    if (symndx >= obj_raw_syment_count (abfd))
4557
0
      {
4558
0
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
0
     abfd, symndx, counter);
4562
0
        cache_ptr->line_number = -1;
4563
0
        ret = false;
4564
0
        continue;
4565
0
      }
4566
4567
551
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
551
    if (! ent->is_sym)
4571
0
      {
4572
0
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
0
     abfd, symndx, counter);
4576
0
        cache_ptr->line_number = -1;
4577
0
        ret = false;
4578
0
        continue;
4579
0
      }
4580
551
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
551
    if (sym < obj_symbols (abfd)
4584
551
        || 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
551
    have_func = true;
4596
551
    nbr_func++;
4597
551
    cache_ptr->u.sym = (asymbol *) sym;
4598
551
    if (sym->lineno != NULL)
4599
532
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
532
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
532
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
551
    sym->lineno = cache_ptr;
4605
551
    if (sym->symbol.value < prev_offset)
4606
0
      ordered = false;
4607
551
    prev_offset = sym->symbol.value;
4608
551
  }
4609
291
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
149
  continue;
4613
142
      else
4614
142
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
693
      cache_ptr++;
4616
693
    }
4617
4618
33
  asect->lineno_count = cache_ptr - lineno_cache;
4619
33
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
33
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
33
  if (!ordered)
4624
0
    {
4625
      /* Sort the table.  */
4626
0
      alent **func_table;
4627
0
      alent *n_lineno_cache;
4628
4629
      /* Create a table of functions.  */
4630
0
      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
0
      else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL)
4636
0
  {
4637
0
    alent **p = func_table;
4638
0
    unsigned int i;
4639
4640
0
    for (i = 0; i < asect->lineno_count; i++)
4641
0
      if (lineno_cache[i].line_number == 0)
4642
0
        *p++ = &lineno_cache[i];
4643
4644
0
    BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func);
4645
4646
    /* Sort by functions.  */
4647
0
    qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent);
4648
4649
    /* Create the new sorted table.  */
4650
0
    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
0
    else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL)
4656
0
      {
4657
0
        alent *n_cache_ptr = n_lineno_cache;
4658
4659
0
        for (i = 0; i < nbr_func; i++)
4660
0
    {
4661
0
      coff_symbol_type *sym;
4662
0
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
0
      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
0
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
0
      do
4671
0
        *n_cache_ptr++ = *old_ptr++;
4672
0
      while (old_ptr->line_number != 0);
4673
0
    }
4674
4675
0
        memcpy (lineno_cache, n_lineno_cache,
4676
0
          asect->lineno_count * sizeof (alent));
4677
0
      }
4678
0
    else
4679
0
      ret = false;
4680
0
    bfd_release (abfd, func_table);
4681
0
  }
4682
0
      else
4683
0
  ret = false;
4684
0
    }
4685
4686
33
  return ret;
4687
33
}
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
742
{
4491
742
  LINENO *native_lineno;
4492
742
  alent *lineno_cache;
4493
742
  unsigned int counter;
4494
742
  alent *cache_ptr;
4495
742
  bfd_vma prev_offset = 0;
4496
742
  bool ordered = true;
4497
742
  unsigned int nbr_func;
4498
742
  LINENO *src;
4499
742
  bool have_func;
4500
742
  bool ret = true;
4501
742
  size_t amt;
4502
4503
742
  if (asect->lineno_count == 0)
4504
662
    return true;
4505
4506
80
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
80
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
80
             asect->lineno_count,
4510
80
             bfd_coff_linesz (abfd));
4511
80
  if (native_lineno == NULL)
4512
0
    {
4513
0
      _bfd_error_handler
4514
0
  (_("%pB: warning: line number table read failed"), abfd);
4515
0
      return false;
4516
0
    }
4517
4518
80
  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
80
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
80
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
80
  cache_ptr = lineno_cache;
4532
80
  asect->lineno = lineno_cache;
4533
80
  src = native_lineno;
4534
80
  nbr_func = 0;
4535
80
  have_func = false;
4536
4537
5.38k
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
5.30k
    {
4539
5.30k
      struct internal_lineno dst;
4540
4541
5.30k
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
5.30k
      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
5.30k
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
5.30k
      if (cache_ptr->line_number == 0)
4549
3.25k
  {
4550
3.25k
    combined_entry_type * ent;
4551
3.25k
    unsigned long symndx;
4552
3.25k
    coff_symbol_type *sym;
4553
4554
3.25k
    have_func = false;
4555
3.25k
    symndx = dst.l_addr.l_symndx;
4556
3.25k
    if (symndx >= obj_raw_syment_count (abfd))
4557
0
      {
4558
0
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
0
     abfd, symndx, counter);
4562
0
        cache_ptr->line_number = -1;
4563
0
        ret = false;
4564
0
        continue;
4565
0
      }
4566
4567
3.25k
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
3.25k
    if (! ent->is_sym)
4571
0
      {
4572
0
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
0
     abfd, symndx, counter);
4576
0
        cache_ptr->line_number = -1;
4577
0
        ret = false;
4578
0
        continue;
4579
0
      }
4580
3.25k
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
3.25k
    if (sym < obj_symbols (abfd)
4584
3.25k
        || 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
3.25k
    have_func = true;
4596
3.25k
    nbr_func++;
4597
3.25k
    cache_ptr->u.sym = (asymbol *) sym;
4598
3.25k
    if (sym->lineno != NULL)
4599
3.19k
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
3.19k
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
3.19k
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
3.25k
    sym->lineno = cache_ptr;
4605
3.25k
    if (sym->symbol.value < prev_offset)
4606
34
      ordered = false;
4607
3.25k
    prev_offset = sym->symbol.value;
4608
3.25k
  }
4609
2.04k
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
447
  continue;
4613
1.60k
      else
4614
1.60k
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
4.85k
      cache_ptr++;
4616
4.85k
    }
4617
4618
80
  asect->lineno_count = cache_ptr - lineno_cache;
4619
80
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
80
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
80
  if (!ordered)
4624
24
    {
4625
      /* Sort the table.  */
4626
24
      alent **func_table;
4627
24
      alent *n_lineno_cache;
4628
4629
      /* Create a table of functions.  */
4630
24
      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
24
      else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL)
4636
24
  {
4637
24
    alent **p = func_table;
4638
24
    unsigned int i;
4639
4640
4.05k
    for (i = 0; i < asect->lineno_count; i++)
4641
4.02k
      if (lineno_cache[i].line_number == 0)
4642
3.15k
        *p++ = &lineno_cache[i];
4643
4644
24
    BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func);
4645
4646
    /* Sort by functions.  */
4647
24
    qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent);
4648
4649
    /* Create the new sorted table.  */
4650
24
    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
24
    else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL)
4656
24
      {
4657
24
        alent *n_cache_ptr = n_lineno_cache;
4658
4659
3.17k
        for (i = 0; i < nbr_func; i++)
4660
3.15k
    {
4661
3.15k
      coff_symbol_type *sym;
4662
3.15k
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
3.15k
      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
3.15k
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
3.15k
      do
4671
4.02k
        *n_cache_ptr++ = *old_ptr++;
4672
4.02k
      while (old_ptr->line_number != 0);
4673
3.15k
    }
4674
4675
24
        memcpy (lineno_cache, n_lineno_cache,
4676
24
          asect->lineno_count * sizeof (alent));
4677
24
      }
4678
0
    else
4679
0
      ret = false;
4680
24
    bfd_release (abfd, func_table);
4681
24
  }
4682
0
      else
4683
0
  ret = false;
4684
24
    }
4685
4686
80
  return ret;
4687
80
}
pe-mcore.c:coff_slurp_line_table
Line
Count
Source
4490
465
{
4491
465
  LINENO *native_lineno;
4492
465
  alent *lineno_cache;
4493
465
  unsigned int counter;
4494
465
  alent *cache_ptr;
4495
465
  bfd_vma prev_offset = 0;
4496
465
  bool ordered = true;
4497
465
  unsigned int nbr_func;
4498
465
  LINENO *src;
4499
465
  bool have_func;
4500
465
  bool ret = true;
4501
465
  size_t amt;
4502
4503
465
  if (asect->lineno_count == 0)
4504
426
    return true;
4505
4506
39
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
39
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
39
             asect->lineno_count,
4510
39
             bfd_coff_linesz (abfd));
4511
39
  if (native_lineno == NULL)
4512
0
    {
4513
0
      _bfd_error_handler
4514
0
  (_("%pB: warning: line number table read failed"), abfd);
4515
0
      return false;
4516
0
    }
4517
4518
39
  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
39
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
39
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
39
  cache_ptr = lineno_cache;
4532
39
  asect->lineno = lineno_cache;
4533
39
  src = native_lineno;
4534
39
  nbr_func = 0;
4535
39
  have_func = false;
4536
4537
13.1k
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
13.0k
    {
4539
13.0k
      struct internal_lineno dst;
4540
4541
13.0k
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
13.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
13.0k
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
13.0k
      if (cache_ptr->line_number == 0)
4549
892
  {
4550
892
    combined_entry_type * ent;
4551
892
    unsigned long symndx;
4552
892
    coff_symbol_type *sym;
4553
4554
892
    have_func = false;
4555
892
    symndx = dst.l_addr.l_symndx;
4556
892
    if (symndx >= obj_raw_syment_count (abfd))
4557
0
      {
4558
0
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
0
     abfd, symndx, counter);
4562
0
        cache_ptr->line_number = -1;
4563
0
        ret = false;
4564
0
        continue;
4565
0
      }
4566
4567
892
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
892
    if (! ent->is_sym)
4571
0
      {
4572
0
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
0
     abfd, symndx, counter);
4576
0
        cache_ptr->line_number = -1;
4577
0
        ret = false;
4578
0
        continue;
4579
0
      }
4580
892
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
892
    if (sym < obj_symbols (abfd)
4584
892
        || 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
892
    have_func = true;
4596
892
    nbr_func++;
4597
892
    cache_ptr->u.sym = (asymbol *) sym;
4598
892
    if (sym->lineno != NULL)
4599
852
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
852
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
852
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
892
    sym->lineno = cache_ptr;
4605
892
    if (sym->symbol.value < prev_offset)
4606
16
      ordered = false;
4607
892
    prev_offset = sym->symbol.value;
4608
892
  }
4609
12.1k
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
5.18k
  continue;
4613
6.98k
      else
4614
6.98k
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
7.87k
      cache_ptr++;
4616
7.87k
    }
4617
4618
39
  asect->lineno_count = cache_ptr - lineno_cache;
4619
39
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
39
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
39
  if (!ordered)
4624
16
    {
4625
      /* Sort the table.  */
4626
16
      alent **func_table;
4627
16
      alent *n_lineno_cache;
4628
4629
      /* Create a table of functions.  */
4630
16
      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
16
      else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL)
4636
16
  {
4637
16
    alent **p = func_table;
4638
16
    unsigned int i;
4639
4640
161
    for (i = 0; i < asect->lineno_count; i++)
4641
145
      if (lineno_cache[i].line_number == 0)
4642
86
        *p++ = &lineno_cache[i];
4643
4644
16
    BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func);
4645
4646
    /* Sort by functions.  */
4647
16
    qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent);
4648
4649
    /* Create the new sorted table.  */
4650
16
    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
16
    else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL)
4656
16
      {
4657
16
        alent *n_cache_ptr = n_lineno_cache;
4658
4659
102
        for (i = 0; i < nbr_func; i++)
4660
86
    {
4661
86
      coff_symbol_type *sym;
4662
86
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
86
      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
86
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
86
      do
4671
145
        *n_cache_ptr++ = *old_ptr++;
4672
145
      while (old_ptr->line_number != 0);
4673
86
    }
4674
4675
16
        memcpy (lineno_cache, n_lineno_cache,
4676
16
          asect->lineno_count * sizeof (alent));
4677
16
      }
4678
0
    else
4679
0
      ret = false;
4680
16
    bfd_release (abfd, func_table);
4681
16
  }
4682
0
      else
4683
0
  ret = false;
4684
16
    }
4685
4686
39
  return ret;
4687
39
}
pe-sh.c:coff_slurp_line_table
Line
Count
Source
4490
835
{
4491
835
  LINENO *native_lineno;
4492
835
  alent *lineno_cache;
4493
835
  unsigned int counter;
4494
835
  alent *cache_ptr;
4495
835
  bfd_vma prev_offset = 0;
4496
835
  bool ordered = true;
4497
835
  unsigned int nbr_func;
4498
835
  LINENO *src;
4499
835
  bool have_func;
4500
835
  bool ret = true;
4501
835
  size_t amt;
4502
4503
835
  if (asect->lineno_count == 0)
4504
769
    return true;
4505
4506
66
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
66
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
66
             asect->lineno_count,
4510
66
             bfd_coff_linesz (abfd));
4511
66
  if (native_lineno == NULL)
4512
0
    {
4513
0
      _bfd_error_handler
4514
0
  (_("%pB: warning: line number table read failed"), abfd);
4515
0
      return false;
4516
0
    }
4517
4518
66
  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
66
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
66
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
66
  cache_ptr = lineno_cache;
4532
66
  asect->lineno = lineno_cache;
4533
66
  src = native_lineno;
4534
66
  nbr_func = 0;
4535
66
  have_func = false;
4536
4537
1.62k
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
1.55k
    {
4539
1.55k
      struct internal_lineno dst;
4540
4541
1.55k
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
1.55k
      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
1.55k
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
1.55k
      if (cache_ptr->line_number == 0)
4549
176
  {
4550
176
    combined_entry_type * ent;
4551
176
    unsigned long symndx;
4552
176
    coff_symbol_type *sym;
4553
4554
176
    have_func = false;
4555
176
    symndx = dst.l_addr.l_symndx;
4556
176
    if (symndx >= obj_raw_syment_count (abfd))
4557
0
      {
4558
0
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
0
     abfd, symndx, counter);
4562
0
        cache_ptr->line_number = -1;
4563
0
        ret = false;
4564
0
        continue;
4565
0
      }
4566
4567
176
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
176
    if (! ent->is_sym)
4571
0
      {
4572
0
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
0
     abfd, symndx, counter);
4576
0
        cache_ptr->line_number = -1;
4577
0
        ret = false;
4578
0
        continue;
4579
0
      }
4580
176
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
176
    if (sym < obj_symbols (abfd)
4584
176
        || 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
176
    have_func = true;
4596
176
    nbr_func++;
4597
176
    cache_ptr->u.sym = (asymbol *) sym;
4598
176
    if (sym->lineno != NULL)
4599
122
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
122
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
122
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
176
    sym->lineno = cache_ptr;
4605
176
    if (sym->symbol.value < prev_offset)
4606
25
      ordered = false;
4607
176
    prev_offset = sym->symbol.value;
4608
176
  }
4609
1.37k
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
870
  continue;
4613
508
      else
4614
508
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
684
      cache_ptr++;
4616
684
    }
4617
4618
66
  asect->lineno_count = cache_ptr - lineno_cache;
4619
66
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
66
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
66
  if (!ordered)
4624
22
    {
4625
      /* Sort the table.  */
4626
22
      alent **func_table;
4627
22
      alent *n_lineno_cache;
4628
4629
      /* Create a table of functions.  */
4630
22
      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
22
      else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL)
4636
22
  {
4637
22
    alent **p = func_table;
4638
22
    unsigned int i;
4639
4640
655
    for (i = 0; i < asect->lineno_count; i++)
4641
633
      if (lineno_cache[i].line_number == 0)
4642
136
        *p++ = &lineno_cache[i];
4643
4644
22
    BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func);
4645
4646
    /* Sort by functions.  */
4647
22
    qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent);
4648
4649
    /* Create the new sorted table.  */
4650
22
    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
22
    else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL)
4656
22
      {
4657
22
        alent *n_cache_ptr = n_lineno_cache;
4658
4659
158
        for (i = 0; i < nbr_func; i++)
4660
136
    {
4661
136
      coff_symbol_type *sym;
4662
136
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
136
      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
136
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
136
      do
4671
633
        *n_cache_ptr++ = *old_ptr++;
4672
633
      while (old_ptr->line_number != 0);
4673
136
    }
4674
4675
22
        memcpy (lineno_cache, n_lineno_cache,
4676
22
          asect->lineno_count * sizeof (alent));
4677
22
      }
4678
0
    else
4679
0
      ret = false;
4680
22
    bfd_release (abfd, func_table);
4681
22
  }
4682
0
      else
4683
0
  ret = false;
4684
22
    }
4685
4686
66
  return ret;
4687
66
}
pei-arm-wince.c:coff_slurp_line_table
Line
Count
Source
4490
19
{
4491
19
  LINENO *native_lineno;
4492
19
  alent *lineno_cache;
4493
19
  unsigned int counter;
4494
19
  alent *cache_ptr;
4495
19
  bfd_vma prev_offset = 0;
4496
19
  bool ordered = true;
4497
19
  unsigned int nbr_func;
4498
19
  LINENO *src;
4499
19
  bool have_func;
4500
19
  bool ret = true;
4501
19
  size_t amt;
4502
4503
19
  if (asect->lineno_count == 0)
4504
6
    return true;
4505
4506
13
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
13
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
13
             asect->lineno_count,
4510
13
             bfd_coff_linesz (abfd));
4511
13
  if (native_lineno == NULL)
4512
0
    {
4513
0
      _bfd_error_handler
4514
0
  (_("%pB: warning: line number table read failed"), abfd);
4515
0
      return false;
4516
0
    }
4517
4518
13
  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
13
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
13
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
13
  cache_ptr = lineno_cache;
4532
13
  asect->lineno = lineno_cache;
4533
13
  src = native_lineno;
4534
13
  nbr_func = 0;
4535
13
  have_func = false;
4536
4537
99
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
86
    {
4539
86
      struct internal_lineno dst;
4540
4541
86
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
86
      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
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
86
      if (cache_ptr->line_number == 0)
4549
24
  {
4550
24
    combined_entry_type * ent;
4551
24
    unsigned long symndx;
4552
24
    coff_symbol_type *sym;
4553
4554
24
    have_func = false;
4555
24
    symndx = dst.l_addr.l_symndx;
4556
24
    if (symndx >= obj_raw_syment_count (abfd))
4557
0
      {
4558
0
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
0
     abfd, symndx, counter);
4562
0
        cache_ptr->line_number = -1;
4563
0
        ret = false;
4564
0
        continue;
4565
0
      }
4566
4567
24
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
24
    if (! ent->is_sym)
4571
0
      {
4572
0
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
0
     abfd, symndx, counter);
4576
0
        cache_ptr->line_number = -1;
4577
0
        ret = false;
4578
0
        continue;
4579
0
      }
4580
24
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
24
    if (sym < obj_symbols (abfd)
4584
24
        || 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
    have_func = true;
4596
24
    nbr_func++;
4597
24
    cache_ptr->u.sym = (asymbol *) sym;
4598
24
    if (sym->lineno != NULL)
4599
16
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
16
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
16
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
24
    sym->lineno = cache_ptr;
4605
24
    if (sym->symbol.value < prev_offset)
4606
0
      ordered = false;
4607
24
    prev_offset = sym->symbol.value;
4608
24
  }
4609
62
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
37
  continue;
4613
25
      else
4614
25
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
49
      cache_ptr++;
4616
49
    }
4617
4618
13
  asect->lineno_count = cache_ptr - lineno_cache;
4619
13
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
13
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
13
  if (!ordered)
4624
0
    {
4625
      /* Sort the table.  */
4626
0
      alent **func_table;
4627
0
      alent *n_lineno_cache;
4628
4629
      /* Create a table of functions.  */
4630
0
      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
0
      else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL)
4636
0
  {
4637
0
    alent **p = func_table;
4638
0
    unsigned int i;
4639
4640
0
    for (i = 0; i < asect->lineno_count; i++)
4641
0
      if (lineno_cache[i].line_number == 0)
4642
0
        *p++ = &lineno_cache[i];
4643
4644
0
    BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func);
4645
4646
    /* Sort by functions.  */
4647
0
    qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent);
4648
4649
    /* Create the new sorted table.  */
4650
0
    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
0
    else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL)
4656
0
      {
4657
0
        alent *n_cache_ptr = n_lineno_cache;
4658
4659
0
        for (i = 0; i < nbr_func; i++)
4660
0
    {
4661
0
      coff_symbol_type *sym;
4662
0
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
0
      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
0
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
0
      do
4671
0
        *n_cache_ptr++ = *old_ptr++;
4672
0
      while (old_ptr->line_number != 0);
4673
0
    }
4674
4675
0
        memcpy (lineno_cache, n_lineno_cache,
4676
0
          asect->lineno_count * sizeof (alent));
4677
0
      }
4678
0
    else
4679
0
      ret = false;
4680
0
    bfd_release (abfd, func_table);
4681
0
  }
4682
0
      else
4683
0
  ret = false;
4684
0
    }
4685
4686
13
  return ret;
4687
13
}
pei-arm.c:coff_slurp_line_table
Line
Count
Source
4490
229
{
4491
229
  LINENO *native_lineno;
4492
229
  alent *lineno_cache;
4493
229
  unsigned int counter;
4494
229
  alent *cache_ptr;
4495
229
  bfd_vma prev_offset = 0;
4496
229
  bool ordered = true;
4497
229
  unsigned int nbr_func;
4498
229
  LINENO *src;
4499
229
  bool have_func;
4500
229
  bool ret = true;
4501
229
  size_t amt;
4502
4503
229
  if (asect->lineno_count == 0)
4504
190
    return true;
4505
4506
39
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
39
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
39
             asect->lineno_count,
4510
39
             bfd_coff_linesz (abfd));
4511
39
  if (native_lineno == NULL)
4512
0
    {
4513
0
      _bfd_error_handler
4514
0
  (_("%pB: warning: line number table read failed"), abfd);
4515
0
      return false;
4516
0
    }
4517
4518
39
  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
39
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
39
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
39
  cache_ptr = lineno_cache;
4532
39
  asect->lineno = lineno_cache;
4533
39
  src = native_lineno;
4534
39
  nbr_func = 0;
4535
39
  have_func = false;
4536
4537
19.6k
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
19.6k
    {
4539
19.6k
      struct internal_lineno dst;
4540
4541
19.6k
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
19.6k
      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
19.6k
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
19.6k
      if (cache_ptr->line_number == 0)
4549
4.94k
  {
4550
4.94k
    combined_entry_type * ent;
4551
4.94k
    unsigned long symndx;
4552
4.94k
    coff_symbol_type *sym;
4553
4554
4.94k
    have_func = false;
4555
4.94k
    symndx = dst.l_addr.l_symndx;
4556
4.94k
    if (symndx >= obj_raw_syment_count (abfd))
4557
0
      {
4558
0
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
0
     abfd, symndx, counter);
4562
0
        cache_ptr->line_number = -1;
4563
0
        ret = false;
4564
0
        continue;
4565
0
      }
4566
4567
4.94k
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
4.94k
    if (! ent->is_sym)
4571
0
      {
4572
0
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
0
     abfd, symndx, counter);
4576
0
        cache_ptr->line_number = -1;
4577
0
        ret = false;
4578
0
        continue;
4579
0
      }
4580
4.94k
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
4.94k
    if (sym < obj_symbols (abfd)
4584
4.94k
        || 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
4.94k
    have_func = true;
4596
4.94k
    nbr_func++;
4597
4.94k
    cache_ptr->u.sym = (asymbol *) sym;
4598
4.94k
    if (sym->lineno != NULL)
4599
4.90k
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
4.90k
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
4.90k
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
4.94k
    sym->lineno = cache_ptr;
4605
4.94k
    if (sym->symbol.value < prev_offset)
4606
11
      ordered = false;
4607
4.94k
    prev_offset = sym->symbol.value;
4608
4.94k
  }
4609
14.7k
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
5.83k
  continue;
4613
8.87k
      else
4614
8.87k
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
13.8k
      cache_ptr++;
4616
13.8k
    }
4617
4618
39
  asect->lineno_count = cache_ptr - lineno_cache;
4619
39
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
39
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
39
  if (!ordered)
4624
11
    {
4625
      /* Sort the table.  */
4626
11
      alent **func_table;
4627
11
      alent *n_lineno_cache;
4628
4629
      /* Create a table of functions.  */
4630
11
      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
11
      else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL)
4636
11
  {
4637
11
    alent **p = func_table;
4638
11
    unsigned int i;
4639
4640
113
    for (i = 0; i < asect->lineno_count; i++)
4641
102
      if (lineno_cache[i].line_number == 0)
4642
61
        *p++ = &lineno_cache[i];
4643
4644
11
    BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func);
4645
4646
    /* Sort by functions.  */
4647
11
    qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent);
4648
4649
    /* Create the new sorted table.  */
4650
11
    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
11
    else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL)
4656
11
      {
4657
11
        alent *n_cache_ptr = n_lineno_cache;
4658
4659
72
        for (i = 0; i < nbr_func; i++)
4660
61
    {
4661
61
      coff_symbol_type *sym;
4662
61
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
61
      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
61
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
61
      do
4671
102
        *n_cache_ptr++ = *old_ptr++;
4672
102
      while (old_ptr->line_number != 0);
4673
61
    }
4674
4675
11
        memcpy (lineno_cache, n_lineno_cache,
4676
11
          asect->lineno_count * sizeof (alent));
4677
11
      }
4678
0
    else
4679
0
      ret = false;
4680
11
    bfd_release (abfd, func_table);
4681
11
  }
4682
0
      else
4683
0
  ret = false;
4684
11
    }
4685
4686
39
  return ret;
4687
39
}
pei-mcore.c:coff_slurp_line_table
Line
Count
Source
4490
254
{
4491
254
  LINENO *native_lineno;
4492
254
  alent *lineno_cache;
4493
254
  unsigned int counter;
4494
254
  alent *cache_ptr;
4495
254
  bfd_vma prev_offset = 0;
4496
254
  bool ordered = true;
4497
254
  unsigned int nbr_func;
4498
254
  LINENO *src;
4499
254
  bool have_func;
4500
254
  bool ret = true;
4501
254
  size_t amt;
4502
4503
254
  if (asect->lineno_count == 0)
4504
201
    return true;
4505
4506
53
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
53
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
53
             asect->lineno_count,
4510
53
             bfd_coff_linesz (abfd));
4511
53
  if (native_lineno == NULL)
4512
0
    {
4513
0
      _bfd_error_handler
4514
0
  (_("%pB: warning: line number table read failed"), abfd);
4515
0
      return false;
4516
0
    }
4517
4518
53
  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
53
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
53
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
53
  cache_ptr = lineno_cache;
4532
53
  asect->lineno = lineno_cache;
4533
53
  src = native_lineno;
4534
53
  nbr_func = 0;
4535
53
  have_func = false;
4536
4537
353
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
300
    {
4539
300
      struct internal_lineno dst;
4540
4541
300
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
300
      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
300
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
300
      if (cache_ptr->line_number == 0)
4549
96
  {
4550
96
    combined_entry_type * ent;
4551
96
    unsigned long symndx;
4552
96
    coff_symbol_type *sym;
4553
4554
96
    have_func = false;
4555
96
    symndx = dst.l_addr.l_symndx;
4556
96
    if (symndx >= obj_raw_syment_count (abfd))
4557
0
      {
4558
0
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
0
     abfd, symndx, counter);
4562
0
        cache_ptr->line_number = -1;
4563
0
        ret = false;
4564
0
        continue;
4565
0
      }
4566
4567
96
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
96
    if (! ent->is_sym)
4571
0
      {
4572
0
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
0
     abfd, symndx, counter);
4576
0
        cache_ptr->line_number = -1;
4577
0
        ret = false;
4578
0
        continue;
4579
0
      }
4580
96
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
96
    if (sym < obj_symbols (abfd)
4584
96
        || 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
96
    have_func = true;
4596
96
    nbr_func++;
4597
96
    cache_ptr->u.sym = (asymbol *) sym;
4598
96
    if (sym->lineno != NULL)
4599
61
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
61
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
61
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
96
    sym->lineno = cache_ptr;
4605
96
    if (sym->symbol.value < prev_offset)
4606
12
      ordered = false;
4607
96
    prev_offset = sym->symbol.value;
4608
96
  }
4609
204
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
84
  continue;
4613
120
      else
4614
120
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
216
      cache_ptr++;
4616
216
    }
4617
4618
53
  asect->lineno_count = cache_ptr - lineno_cache;
4619
53
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
53
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
53
  if (!ordered)
4624
12
    {
4625
      /* Sort the table.  */
4626
12
      alent **func_table;
4627
12
      alent *n_lineno_cache;
4628
4629
      /* Create a table of functions.  */
4630
12
      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
12
      else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL)
4636
12
  {
4637
12
    alent **p = func_table;
4638
12
    unsigned int i;
4639
4640
98
    for (i = 0; i < asect->lineno_count; i++)
4641
86
      if (lineno_cache[i].line_number == 0)
4642
43
        *p++ = &lineno_cache[i];
4643
4644
12
    BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func);
4645
4646
    /* Sort by functions.  */
4647
12
    qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent);
4648
4649
    /* Create the new sorted table.  */
4650
12
    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
12
    else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL)
4656
12
      {
4657
12
        alent *n_cache_ptr = n_lineno_cache;
4658
4659
55
        for (i = 0; i < nbr_func; i++)
4660
43
    {
4661
43
      coff_symbol_type *sym;
4662
43
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
43
      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
43
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
43
      do
4671
86
        *n_cache_ptr++ = *old_ptr++;
4672
86
      while (old_ptr->line_number != 0);
4673
43
    }
4674
4675
12
        memcpy (lineno_cache, n_lineno_cache,
4676
12
          asect->lineno_count * sizeof (alent));
4677
12
      }
4678
0
    else
4679
0
      ret = false;
4680
12
    bfd_release (abfd, func_table);
4681
12
  }
4682
0
      else
4683
0
  ret = false;
4684
12
    }
4685
4686
53
  return ret;
4687
53
}
pei-sh.c:coff_slurp_line_table
Line
Count
Source
4490
204
{
4491
204
  LINENO *native_lineno;
4492
204
  alent *lineno_cache;
4493
204
  unsigned int counter;
4494
204
  alent *cache_ptr;
4495
204
  bfd_vma prev_offset = 0;
4496
204
  bool ordered = true;
4497
204
  unsigned int nbr_func;
4498
204
  LINENO *src;
4499
204
  bool have_func;
4500
204
  bool ret = true;
4501
204
  size_t amt;
4502
4503
204
  if (asect->lineno_count == 0)
4504
165
    return true;
4505
4506
39
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
39
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
39
             asect->lineno_count,
4510
39
             bfd_coff_linesz (abfd));
4511
39
  if (native_lineno == NULL)
4512
0
    {
4513
0
      _bfd_error_handler
4514
0
  (_("%pB: warning: line number table read failed"), abfd);
4515
0
      return false;
4516
0
    }
4517
4518
39
  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
39
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
39
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
39
  cache_ptr = lineno_cache;
4532
39
  asect->lineno = lineno_cache;
4533
39
  src = native_lineno;
4534
39
  nbr_func = 0;
4535
39
  have_func = false;
4536
4537
291
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
252
    {
4539
252
      struct internal_lineno dst;
4540
4541
252
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
252
      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
252
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
252
      if (cache_ptr->line_number == 0)
4549
98
  {
4550
98
    combined_entry_type * ent;
4551
98
    unsigned long symndx;
4552
98
    coff_symbol_type *sym;
4553
4554
98
    have_func = false;
4555
98
    symndx = dst.l_addr.l_symndx;
4556
98
    if (symndx >= obj_raw_syment_count (abfd))
4557
0
      {
4558
0
        _bfd_error_handler
4559
    /* xgettext:c-format */
4560
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4561
0
     abfd, symndx, counter);
4562
0
        cache_ptr->line_number = -1;
4563
0
        ret = false;
4564
0
        continue;
4565
0
      }
4566
4567
98
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
98
    if (! ent->is_sym)
4571
0
      {
4572
0
        _bfd_error_handler
4573
    /* xgettext:c-format */
4574
0
    (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"),
4575
0
     abfd, symndx, counter);
4576
0
        cache_ptr->line_number = -1;
4577
0
        ret = false;
4578
0
        continue;
4579
0
      }
4580
98
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
98
    if (sym < obj_symbols (abfd)
4584
98
        || 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
98
    have_func = true;
4596
98
    nbr_func++;
4597
98
    cache_ptr->u.sym = (asymbol *) sym;
4598
98
    if (sym->lineno != NULL)
4599
60
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
60
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
60
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
98
    sym->lineno = cache_ptr;
4605
98
    if (sym->symbol.value < prev_offset)
4606
15
      ordered = false;
4607
98
    prev_offset = sym->symbol.value;
4608
98
  }
4609
154
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
50
  continue;
4613
104
      else
4614
104
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
202
      cache_ptr++;
4616
202
    }
4617
4618
39
  asect->lineno_count = cache_ptr - lineno_cache;
4619
39
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
39
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
39
  if (!ordered)
4624
14
    {
4625
      /* Sort the table.  */
4626
14
      alent **func_table;
4627
14
      alent *n_lineno_cache;
4628
4629
      /* Create a table of functions.  */
4630
14
      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
14
      else if ((func_table = (alent **) bfd_alloc (abfd, amt)) != NULL)
4636
14
  {
4637
14
    alent **p = func_table;
4638
14
    unsigned int i;
4639
4640
192
    for (i = 0; i < asect->lineno_count; i++)
4641
178
      if (lineno_cache[i].line_number == 0)
4642
84
        *p++ = &lineno_cache[i];
4643
4644
14
    BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func);
4645
4646
    /* Sort by functions.  */
4647
14
    qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent);
4648
4649
    /* Create the new sorted table.  */
4650
14
    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
14
    else if ((n_lineno_cache = (alent *) bfd_alloc (abfd, amt)) != NULL)
4656
14
      {
4657
14
        alent *n_cache_ptr = n_lineno_cache;
4658
4659
98
        for (i = 0; i < nbr_func; i++)
4660
84
    {
4661
84
      coff_symbol_type *sym;
4662
84
      alent *old_ptr = func_table[i];
4663
4664
      /* Update the function entry.  */
4665
84
      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
84
      sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache);
4669
      /* Copy the function and line number entries.  */
4670
84
      do
4671
178
        *n_cache_ptr++ = *old_ptr++;
4672
178
      while (old_ptr->line_number != 0);
4673
84
    }
4674
4675
14
        memcpy (lineno_cache, n_lineno_cache,
4676
14
          asect->lineno_count * sizeof (alent));
4677
14
      }
4678
0
    else
4679
0
      ret = false;
4680
14
    bfd_release (abfd, func_table);
4681
14
  }
4682
0
      else
4683
0
  ret = false;
4684
14
    }
4685
4686
39
  return ret;
4687
39
}
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
3.05k
{
4696
3.05k
  combined_entry_type *native_symbols;
4697
3.05k
  coff_symbol_type *cached_area;
4698
3.05k
  unsigned int *table_ptr;
4699
3.05k
  unsigned int number_of_symbols = 0;
4700
3.05k
  bool ret = true;
4701
3.05k
  size_t amt;
4702
4703
3.05k
  if (obj_symbols (abfd))
4704
1.52k
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
1.52k
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
0
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
1.52k
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
1.52k
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
1.52k
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
1.52k
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
1.52k
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
1.52k
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
1.52k
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
1.52k
  if (table_ptr == NULL)
4729
0
    return false;
4730
1.52k
  else
4731
1.52k
    {
4732
1.52k
      coff_symbol_type *dst = cached_area;
4733
1.52k
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
1.52k
      unsigned int this_index = 0;
4735
4736
54.5k
      while (this_index < last_native_index)
4737
53.0k
  {
4738
53.0k
    combined_entry_type *src = native_symbols + this_index;
4739
53.0k
    table_ptr[this_index] = number_of_symbols;
4740
4741
53.0k
    dst->symbol.the_bfd = abfd;
4742
53.0k
    BFD_ASSERT (src->is_sym);
4743
53.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
53.0k
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
53.0k
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
53.0k
                 src->u.syment.n_scnum);
4748
53.0k
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
53.0k
    dst->symbol.value = 0;
4751
53.0k
    dst->done_lineno = false;
4752
4753
53.0k
    switch (src->u.syment.n_sclass)
4754
53.0k
      {
4755
3.37k
      case C_EXT:
4756
3.65k
      case C_WEAKEXT:
4757
#if defined ARM
4758
17
      case C_THUMBEXT:
4759
19
      case C_THUMBEXTFUNC:
4760
#endif
4761
#ifdef RS6000COFF_C
4762
920
      case C_HIDEXT:
4763
920
#ifndef AIX_WEAK_SUPPORT
4764
935
      case C_AIX_WEAKEXT:
4765
#endif
4766
#endif
4767
935
#ifdef C_SYSTEM
4768
4.11k
      case C_SYSTEM: /* System Wide variable.  */
4769
4.11k
#endif
4770
#ifdef COFF_WITH_PE
4771
      /* In PE, 0x68 (104) denotes a section symbol.  */
4772
1.83k
      case C_SECTION:
4773
      /* In PE, 0x69 (105) denotes a weak external symbol.  */
4774
1.98k
      case C_NT_WEAK:
4775
#endif
4776
1.98k
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
1.98k
    {
4778
3.69k
    case COFF_SYMBOL_GLOBAL:
4779
3.69k
      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
3.69k
      if (ISFCN ((src->u.syment.n_type)))
4789
        /* A function ext does not go at the end of a
4790
           file.  */
4791
259
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4792
3.69k
      break;
4793
4794
199
    case COFF_SYMBOL_COMMON:
4795
199
      dst->symbol.section = bfd_com_section_ptr;
4796
199
      dst->symbol.value = src->u.syment.n_value;
4797
199
      break;
4798
4799
391
    case COFF_SYMBOL_UNDEFINED:
4800
391
      dst->symbol.section = bfd_und_section_ptr;
4801
391
      dst->symbol.value = 0;
4802
391
      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
19
    case COFF_SYMBOL_LOCAL:
4810
19
      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
19
      if (ISFCN ((src->u.syment.n_type)))
4820
16
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4821
19
      break;
4822
1.98k
    }
4823
4824
#ifdef RS6000COFF_C
4825
        /* A symbol with a csect entry should not go at the end.  */
4826
947
        if (src->u.syment.n_numaux > 0)
4827
935
    dst->symbol.flags |= BSF_NOT_AT_END;
4828
#endif
4829
4830
#ifdef COFF_WITH_PE
4831
1.98k
        if (src->u.syment.n_sclass == C_NT_WEAK)
4832
152
    dst->symbol.flags |= BSF_WEAK;
4833
4834
1.98k
        if (src->u.syment.n_sclass == C_SECTION
4835
1.98k
      && src->u.syment.n_scnum > 0)
4836
0
    dst->symbol.flags = BSF_LOCAL;
4837
#endif
4838
4.30k
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
#ifdef RS6000COFF_C
4840
943
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
#endif
4842
1.36k
      )
4843
303
    dst->symbol.flags |= BSF_WEAK;
4844
4845
1.36k
        break;
4846
4847
1.27k
      case C_STAT:  /* Static.  */
4848
#if defined ARM
4849
29
      case C_THUMBSTAT:    /* Thumb static.  */
4850
29
      case C_THUMBLABEL:   /* Thumb label.  */
4851
29
      case C_THUMBSTATFUNC:/* Thumb static function.  */
4852
#endif
4853
#ifdef RS6000COFF_C
4854
190
      case C_DWARF:  /* A label in a dwarf section.  */
4855
195
      case C_INFO:  /* A label in a comment section.  */
4856
#endif
4857
2.83k
      case C_LABEL:  /* Label.  */
4858
2.83k
        if (src->u.syment.n_scnum == N_DEBUG)
4859
2
    dst->symbol.flags = BSF_DEBUGGING;
4860
2.83k
        else
4861
2.83k
    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.83k
        if (dst->symbol.section)
4866
2.83k
    {
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
2.83k
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
2.83k
        break;
4879
4880
369
      case C_FILE: /* File name.  */
4881
369
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
682
      case C_MOS:   /* Member of structure.  */
4884
784
      case C_EOS:   /* End of structure.  */
4885
1.07k
      case C_REGPARM: /* Register parameter.  */
4886
3.42k
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
3.85k
      case C_TPDEF: /* Type definition.  */
4889
4.31k
      case C_ARG:
4890
11.4k
      case C_AUTO: /* Automatic variable.  */
4891
11.7k
      case C_FIELD: /* Bit field.  */
4892
12.0k
      case C_ENTAG: /* Enumeration tag.  */
4893
12.2k
      case C_MOE:   /* Member of enumeration.  */
4894
13.6k
      case C_MOU:   /* Member of union.  */
4895
14.4k
      case C_UNTAG: /* Union tag.  */
4896
15.0k
      case C_STRTAG: /* Structure tag.  */
4897
#ifdef RS6000COFF_C
4898
490
      case C_GSYM:
4899
492
      case C_LSYM:
4900
493
      case C_PSYM:
4901
494
      case C_RSYM:
4902
496
      case C_RPSYM:
4903
498
      case C_STSYM:
4904
500
      case C_TCSYM:
4905
501
      case C_BCOMM:
4906
502
      case C_ECOML:
4907
503
      case C_ECOMM:
4908
504
      case C_DECL:
4909
504
      case C_ENTRY:
4910
506
      case C_FUN:
4911
545
      case C_ESTAT:
4912
#endif
4913
15.1k
        dst->symbol.flags |= BSF_DEBUGGING;
4914
545
        dst->symbol.value = (src->u.syment.n_value);
4915
545
        break;
4916
4917
#ifdef RS6000COFF_C
4918
9
      case C_BINCL: /* Beginning of include file.  */
4919
72
      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
72
        {
4925
72
    asection *sec;
4926
4927
72
    dst->symbol.flags = BSF_DEBUGGING;
4928
2.27k
    for (sec = abfd->sections; sec != NULL; sec = sec->next)
4929
2.21k
      if (sec->line_filepos <= (file_ptr) src->u.syment.n_value
4930
2.21k
          && ((file_ptr) (sec->line_filepos
4931
1.56k
              + sec->lineno_count * bfd_coff_linesz (abfd))
4932
1.56k
        > (file_ptr) src->u.syment.n_value))
4933
6
        break;
4934
72
    if (sec == NULL)
4935
66
      dst->symbol.value = 0;
4936
6
    else
4937
6
      {
4938
6
        dst->symbol.section = sec;
4939
6
        dst->symbol.value = ((src->u.syment.n_value
4940
6
            - sec->line_filepos)
4941
6
           / bfd_coff_linesz (abfd));
4942
6
        src->fix_line = 1;
4943
6
      }
4944
72
        }
4945
72
        break;
4946
4947
6
      case C_BSTAT:
4948
6
        dst->symbol.flags = BSF_DEBUGGING;
4949
4950
6
        if (src->u.syment.n_value >= obj_raw_syment_count (abfd))
4951
2
    dst->symbol.value = 0;
4952
4
        else
4953
4
    {
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
4
      src->u.syment.n_value
4958
4
        = (uintptr_t) (native_symbols + src->u.syment.n_value);
4959
4
      dst->symbol.value = src->u.syment.n_value;
4960
4
      src->fix_value = 1;
4961
4
    }
4962
6
        break;
4963
0
#endif
4964
4965
126
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
230
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
702
      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
461
        if (strcmp (dst->symbol.name, ".bf") != 0)
4973
461
    {
4974
      /* PE uses funny values for .ef and .lf; don't
4975
         relocate them.  */
4976
461
      dst->symbol.flags = BSF_DEBUGGING;
4977
461
    }
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
241
        dst->symbol.flags = BSF_LOCAL;
4984
        dst->symbol.value = (src->u.syment.n_value
4985
           - dst->symbol.section->vma);
4986
#endif
4987
702
        break;
4988
4989
344
      case C_STATLAB: /* Static load time label.  */
4990
344
        dst->symbol.value = src->u.syment.n_value;
4991
344
        dst->symbol.flags = BSF_GLOBAL;
4992
344
        break;
4993
4994
29.5k
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
29.5k
        if (src->u.syment.n_type == 0
4998
29.5k
      && src->u.syment.n_value == 0
4999
29.5k
      && src->u.syment.n_scnum == 0)
5000
29.5k
    break;
5001
#ifdef RS6000COFF_C
5002
        /* XCOFF specific: deleted entry.  */
5003
1
        if (src->u.syment.n_value == C_NULL_VALUE)
5004
1
    break;
5005
0
#endif
5006
        /* Fall through.  */
5007
0
      case C_EXTDEF: /* External definition.  */
5008
0
      case C_ULABEL: /* Undefined label.  */
5009
0
      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
0
      case C_LINE: /* line # reformatted as symbol table entry.  */
5014
        /* NT uses 0x67 for a weak symbol, not C_ALIAS.  */
5015
0
      case C_ALIAS: /* Duplicate tag.  */
5016
0
#endif
5017
        /* New storage classes for TI COFF.  */
5018
#ifdef TICOFF
5019
0
      case C_UEXT: /* Tentative external definition.  */
5020
#endif
5021
0
      case C_EXTLAB: /* External load time label.  */
5022
0
      default:
5023
0
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
0
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
0
     abfd, src->u.syment.n_sclass,
5027
0
     dst->symbol.section->name, dst->symbol.name);
5028
0
        ret = false;
5029
        /* Fall through.  */
5030
127
      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
127
        dst->symbol.flags = BSF_DEBUGGING;
5034
127
        dst->symbol.value = (src->u.syment.n_value);
5035
127
        break;
5036
53.0k
      }
5037
5038
53.0k
    dst->native = src;
5039
53.0k
    dst->symbol.udata.i = 0;
5040
53.0k
    dst->lineno = NULL;
5041
5042
53.0k
    this_index += (src->u.syment.n_numaux) + 1;
5043
53.0k
    dst++;
5044
53.0k
    number_of_symbols++;
5045
53.0k
  }
5046
1.52k
    }
5047
5048
1.52k
  obj_symbols (abfd) = cached_area;
5049
1.52k
  obj_raw_syments (abfd) = native_symbols;
5050
5051
1.52k
  abfd->symcount = number_of_symbols;
5052
1.52k
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
1.52k
  {
5055
1.52k
    asection *p;
5056
5057
1.52k
    p = abfd->sections;
5058
52.5k
    while (p)
5059
51.0k
      {
5060
51.0k
  if (! coff_slurp_line_table (abfd, p))
5061
0
    return false;
5062
51.0k
  p = p->next;
5063
51.0k
      }
5064
1.52k
  }
5065
5066
1.52k
  return ret;
5067
1.52k
}
pei-i386.c:coff_slurp_symbol_table
Line
Count
Source
4695
102
{
4696
102
  combined_entry_type *native_symbols;
4697
102
  coff_symbol_type *cached_area;
4698
102
  unsigned int *table_ptr;
4699
102
  unsigned int number_of_symbols = 0;
4700
102
  bool ret = true;
4701
102
  size_t amt;
4702
4703
102
  if (obj_symbols (abfd))
4704
51
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
51
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
0
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
51
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
51
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
51
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
51
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
51
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
51
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
51
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
51
  if (table_ptr == NULL)
4729
0
    return false;
4730
51
  else
4731
51
    {
4732
51
      coff_symbol_type *dst = cached_area;
4733
51
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
51
      unsigned int this_index = 0;
4735
4736
361
      while (this_index < last_native_index)
4737
310
  {
4738
310
    combined_entry_type *src = native_symbols + this_index;
4739
310
    table_ptr[this_index] = number_of_symbols;
4740
4741
310
    dst->symbol.the_bfd = abfd;
4742
310
    BFD_ASSERT (src->is_sym);
4743
310
    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
310
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
310
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
310
                 src->u.syment.n_scnum);
4748
310
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
310
    dst->symbol.value = 0;
4751
310
    dst->done_lineno = false;
4752
4753
310
    switch (src->u.syment.n_sclass)
4754
310
      {
4755
21
      case C_EXT:
4756
32
      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
32
#ifdef C_SYSTEM
4768
33
      case C_SYSTEM: /* System Wide variable.  */
4769
33
#endif
4770
33
#ifdef COFF_WITH_PE
4771
      /* In PE, 0x68 (104) denotes a section symbol.  */
4772
35
      case C_SECTION:
4773
      /* In PE, 0x69 (105) denotes a weak external symbol.  */
4774
40
      case C_NT_WEAK:
4775
40
#endif
4776
40
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
40
    {
4778
13
    case COFF_SYMBOL_GLOBAL:
4779
13
      dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
4780
13
#if defined COFF_WITH_PE
4781
      /* PE sets the symbol to a value relative to the
4782
         start of the section.  */
4783
13
      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
13
      if (ISFCN ((src->u.syment.n_type)))
4789
        /* A function ext does not go at the end of a
4790
           file.  */
4791
3
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4792
13
      break;
4793
4794
13
    case COFF_SYMBOL_COMMON:
4795
13
      dst->symbol.section = bfd_com_section_ptr;
4796
13
      dst->symbol.value = src->u.syment.n_value;
4797
13
      break;
4798
4799
14
    case COFF_SYMBOL_UNDEFINED:
4800
14
      dst->symbol.section = bfd_und_section_ptr;
4801
14
      dst->symbol.value = 0;
4802
14
      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
40
    }
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
40
#ifdef COFF_WITH_PE
4831
40
        if (src->u.syment.n_sclass == C_NT_WEAK)
4832
5
    dst->symbol.flags |= BSF_WEAK;
4833
4834
40
        if (src->u.syment.n_sclass == C_SECTION
4835
40
      && src->u.syment.n_scnum > 0)
4836
0
    dst->symbol.flags = BSF_LOCAL;
4837
40
#endif
4838
40
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
#ifdef RS6000COFF_C
4840
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
#endif
4842
40
      )
4843
11
    dst->symbol.flags |= BSF_WEAK;
4844
4845
40
        break;
4846
4847
11
      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
12
      case C_LABEL:  /* Label.  */
4858
12
        if (src->u.syment.n_scnum == N_DEBUG)
4859
0
    dst->symbol.flags = BSF_DEBUGGING;
4860
12
        else
4861
12
    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
12
        if (dst->symbol.section)
4866
12
    {
4867
12
#if defined COFF_WITH_PE
4868
      /* PE sets the symbol to a value relative to the
4869
         start of the section.  */
4870
12
      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
12
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
12
        break;
4879
4880
22
      case C_FILE: /* File name.  */
4881
22
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
22
      case C_MOS:   /* Member of structure.  */
4884
23
      case C_EOS:   /* End of structure.  */
4885
24
      case C_REGPARM: /* Register parameter.  */
4886
26
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
27
      case C_TPDEF: /* Type definition.  */
4889
38
      case C_ARG:
4890
43
      case C_AUTO: /* Automatic variable.  */
4891
44
      case C_FIELD: /* Bit field.  */
4892
45
      case C_ENTAG: /* Enumeration tag.  */
4893
46
      case C_MOE:   /* Member of enumeration.  */
4894
55
      case C_MOU:   /* Member of union.  */
4895
57
      case C_UNTAG: /* Union tag.  */
4896
58
      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
58
        dst->symbol.flags |= BSF_DEBUGGING;
4914
58
        dst->symbol.value = (src->u.syment.n_value);
4915
58
        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
2
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
3
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
31
      case C_EFCN: /* Physical end of function.  */
4968
31
#if defined COFF_WITH_PE
4969
        /* PE sets the symbol to a value relative to the start
4970
     of the section.  */
4971
31
        dst->symbol.value = src->u.syment.n_value;
4972
31
        if (strcmp (dst->symbol.name, ".bf") != 0)
4973
31
    {
4974
      /* PE uses funny values for .ef and .lf; don't
4975
         relocate them.  */
4976
31
      dst->symbol.flags = BSF_DEBUGGING;
4977
31
    }
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
31
        break;
4988
4989
14
      case C_STATLAB: /* Static load time label.  */
4990
14
        dst->symbol.value = src->u.syment.n_value;
4991
14
        dst->symbol.flags = BSF_GLOBAL;
4992
14
        break;
4993
4994
152
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
152
        if (src->u.syment.n_type == 0
4998
152
      && src->u.syment.n_value == 0
4999
152
      && src->u.syment.n_scnum == 0)
5000
152
    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
0
      case C_EXTDEF: /* External definition.  */
5008
0
      case C_ULABEL: /* Undefined label.  */
5009
0
      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
0
      case C_EXTLAB: /* External load time label.  */
5022
0
      default:
5023
0
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
0
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
0
     abfd, src->u.syment.n_sclass,
5027
0
     dst->symbol.section->name, dst->symbol.name);
5028
0
        ret = false;
5029
        /* Fall through.  */
5030
3
      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
3
        dst->symbol.flags = BSF_DEBUGGING;
5034
3
        dst->symbol.value = (src->u.syment.n_value);
5035
3
        break;
5036
310
      }
5037
5038
310
    dst->native = src;
5039
310
    dst->symbol.udata.i = 0;
5040
310
    dst->lineno = NULL;
5041
5042
310
    this_index += (src->u.syment.n_numaux) + 1;
5043
310
    dst++;
5044
310
    number_of_symbols++;
5045
310
  }
5046
51
    }
5047
5048
51
  obj_symbols (abfd) = cached_area;
5049
51
  obj_raw_syments (abfd) = native_symbols;
5050
5051
51
  abfd->symcount = number_of_symbols;
5052
51
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
51
  {
5055
51
    asection *p;
5056
5057
51
    p = abfd->sections;
5058
205
    while (p)
5059
154
      {
5060
154
  if (! coff_slurp_line_table (abfd, p))
5061
0
    return false;
5062
154
  p = p->next;
5063
154
      }
5064
51
  }
5065
5066
51
  return ret;
5067
51
}
pe-x86_64.c:coff_slurp_symbol_table
Line
Count
Source
4695
182
{
4696
182
  combined_entry_type *native_symbols;
4697
182
  coff_symbol_type *cached_area;
4698
182
  unsigned int *table_ptr;
4699
182
  unsigned int number_of_symbols = 0;
4700
182
  bool ret = true;
4701
182
  size_t amt;
4702
4703
182
  if (obj_symbols (abfd))
4704
91
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
91
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
0
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
91
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
91
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
91
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
91
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
91
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
91
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
91
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
91
  if (table_ptr == NULL)
4729
0
    return false;
4730
91
  else
4731
91
    {
4732
91
      coff_symbol_type *dst = cached_area;
4733
91
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
91
      unsigned int this_index = 0;
4735
4736
1.70k
      while (this_index < last_native_index)
4737
1.61k
  {
4738
1.61k
    combined_entry_type *src = native_symbols + this_index;
4739
1.61k
    table_ptr[this_index] = number_of_symbols;
4740
4741
1.61k
    dst->symbol.the_bfd = abfd;
4742
1.61k
    BFD_ASSERT (src->is_sym);
4743
1.61k
    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.61k
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
1.61k
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
1.61k
                 src->u.syment.n_scnum);
4748
1.61k
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
1.61k
    dst->symbol.value = 0;
4751
1.61k
    dst->done_lineno = false;
4752
4753
1.61k
    switch (src->u.syment.n_sclass)
4754
1.61k
      {
4755
81
      case C_EXT:
4756
94
      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
94
#ifdef C_SYSTEM
4768
95
      case C_SYSTEM: /* System Wide variable.  */
4769
95
#endif
4770
95
#ifdef COFF_WITH_PE
4771
      /* In PE, 0x68 (104) denotes a section symbol.  */
4772
99
      case C_SECTION:
4773
      /* In PE, 0x69 (105) denotes a weak external symbol.  */
4774
100
      case C_NT_WEAK:
4775
100
#endif
4776
100
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
100
    {
4778
75
    case COFF_SYMBOL_GLOBAL:
4779
75
      dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
4780
75
#if defined COFF_WITH_PE
4781
      /* PE sets the symbol to a value relative to the
4782
         start of the section.  */
4783
75
      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
75
      if (ISFCN ((src->u.syment.n_type)))
4789
        /* A function ext does not go at the end of a
4790
           file.  */
4791
11
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4792
75
      break;
4793
4794
8
    case COFF_SYMBOL_COMMON:
4795
8
      dst->symbol.section = bfd_com_section_ptr;
4796
8
      dst->symbol.value = src->u.syment.n_value;
4797
8
      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
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
100
    }
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
100
#ifdef COFF_WITH_PE
4831
100
        if (src->u.syment.n_sclass == C_NT_WEAK)
4832
1
    dst->symbol.flags |= BSF_WEAK;
4833
4834
100
        if (src->u.syment.n_sclass == C_SECTION
4835
100
      && src->u.syment.n_scnum > 0)
4836
0
    dst->symbol.flags = BSF_LOCAL;
4837
100
#endif
4838
100
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
#ifdef RS6000COFF_C
4840
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
#endif
4842
100
      )
4843
13
    dst->symbol.flags |= BSF_WEAK;
4844
4845
100
        break;
4846
4847
51
      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
74
      case C_LABEL:  /* Label.  */
4858
74
        if (src->u.syment.n_scnum == N_DEBUG)
4859
0
    dst->symbol.flags = BSF_DEBUGGING;
4860
74
        else
4861
74
    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
74
        if (dst->symbol.section)
4866
74
    {
4867
74
#if defined COFF_WITH_PE
4868
      /* PE sets the symbol to a value relative to the
4869
         start of the section.  */
4870
74
      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
74
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
74
        break;
4879
4880
10
      case C_FILE: /* File name.  */
4881
10
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
30
      case C_MOS:   /* Member of structure.  */
4884
30
      case C_EOS:   /* End of structure.  */
4885
62
      case C_REGPARM: /* Register parameter.  */
4886
79
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
96
      case C_TPDEF: /* Type definition.  */
4889
212
      case C_ARG:
4890
414
      case C_AUTO: /* Automatic variable.  */
4891
439
      case C_FIELD: /* Bit field.  */
4892
451
      case C_ENTAG: /* Enumeration tag.  */
4893
457
      case C_MOE:   /* Member of enumeration.  */
4894
473
      case C_MOU:   /* Member of union.  */
4895
501
      case C_UNTAG: /* Union tag.  */
4896
545
      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
545
        dst->symbol.flags |= BSF_DEBUGGING;
4914
545
        dst->symbol.value = (src->u.syment.n_value);
4915
545
        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
13
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
19
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
51
      case C_EFCN: /* Physical end of function.  */
4968
51
#if defined COFF_WITH_PE
4969
        /* PE sets the symbol to a value relative to the start
4970
     of the section.  */
4971
51
        dst->symbol.value = src->u.syment.n_value;
4972
51
        if (strcmp (dst->symbol.name, ".bf") != 0)
4973
51
    {
4974
      /* PE uses funny values for .ef and .lf; don't
4975
         relocate them.  */
4976
51
      dst->symbol.flags = BSF_DEBUGGING;
4977
51
    }
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
51
        break;
4988
4989
18
      case C_STATLAB: /* Static load time label.  */
4990
18
        dst->symbol.value = src->u.syment.n_value;
4991
18
        dst->symbol.flags = BSF_GLOBAL;
4992
18
        break;
4993
4994
820
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
820
        if (src->u.syment.n_type == 0
4998
820
      && src->u.syment.n_value == 0
4999
820
      && src->u.syment.n_scnum == 0)
5000
820
    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
0
      case C_EXTDEF: /* External definition.  */
5008
0
      case C_ULABEL: /* Undefined label.  */
5009
0
      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
0
      case C_EXTLAB: /* External load time label.  */
5022
0
      default:
5023
0
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
0
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
0
     abfd, src->u.syment.n_sclass,
5027
0
     dst->symbol.section->name, dst->symbol.name);
5028
0
        ret = false;
5029
        /* Fall through.  */
5030
10
      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
10
        dst->symbol.flags = BSF_DEBUGGING;
5034
10
        dst->symbol.value = (src->u.syment.n_value);
5035
10
        break;
5036
1.61k
      }
5037
5038
1.61k
    dst->native = src;
5039
1.61k
    dst->symbol.udata.i = 0;
5040
1.61k
    dst->lineno = NULL;
5041
5042
1.61k
    this_index += (src->u.syment.n_numaux) + 1;
5043
1.61k
    dst++;
5044
1.61k
    number_of_symbols++;
5045
1.61k
  }
5046
91
    }
5047
5048
91
  obj_symbols (abfd) = cached_area;
5049
91
  obj_raw_syments (abfd) = native_symbols;
5050
5051
91
  abfd->symcount = number_of_symbols;
5052
91
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
91
  {
5055
91
    asection *p;
5056
5057
91
    p = abfd->sections;
5058
8.61k
    while (p)
5059
8.52k
      {
5060
8.52k
  if (! coff_slurp_line_table (abfd, p))
5061
0
    return false;
5062
8.52k
  p = p->next;
5063
8.52k
      }
5064
91
  }
5065
5066
91
  return ret;
5067
91
}
pei-x86_64.c:coff_slurp_symbol_table
Line
Count
Source
4695
120
{
4696
120
  combined_entry_type *native_symbols;
4697
120
  coff_symbol_type *cached_area;
4698
120
  unsigned int *table_ptr;
4699
120
  unsigned int number_of_symbols = 0;
4700
120
  bool ret = true;
4701
120
  size_t amt;
4702
4703
120
  if (obj_symbols (abfd))
4704
60
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
60
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
0
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
60
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
60
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
60
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
60
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
60
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
60
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
60
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
60
  if (table_ptr == NULL)
4729
0
    return false;
4730
60
  else
4731
60
    {
4732
60
      coff_symbol_type *dst = cached_area;
4733
60
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
60
      unsigned int this_index = 0;
4735
4736
1.15k
      while (this_index < last_native_index)
4737
1.09k
  {
4738
1.09k
    combined_entry_type *src = native_symbols + this_index;
4739
1.09k
    table_ptr[this_index] = number_of_symbols;
4740
4741
1.09k
    dst->symbol.the_bfd = abfd;
4742
1.09k
    BFD_ASSERT (src->is_sym);
4743
1.09k
    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.09k
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
1.09k
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
1.09k
                 src->u.syment.n_scnum);
4748
1.09k
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
1.09k
    dst->symbol.value = 0;
4751
1.09k
    dst->done_lineno = false;
4752
4753
1.09k
    switch (src->u.syment.n_sclass)
4754
1.09k
      {
4755
110
      case C_EXT:
4756
115
      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
115
#ifdef C_SYSTEM
4768
124
      case C_SYSTEM: /* System Wide variable.  */
4769
124
#endif
4770
124
#ifdef COFF_WITH_PE
4771
      /* In PE, 0x68 (104) denotes a section symbol.  */
4772
126
      case C_SECTION:
4773
      /* In PE, 0x69 (105) denotes a weak external symbol.  */
4774
138
      case C_NT_WEAK:
4775
138
#endif
4776
138
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
138
    {
4778
107
    case COFF_SYMBOL_GLOBAL:
4779
107
      dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
4780
107
#if defined COFF_WITH_PE
4781
      /* PE sets the symbol to a value relative to the
4782
         start of the section.  */
4783
107
      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
107
      if (ISFCN ((src->u.syment.n_type)))
4789
        /* A function ext does not go at the end of a
4790
           file.  */
4791
7
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4792
107
      break;
4793
4794
12
    case COFF_SYMBOL_COMMON:
4795
12
      dst->symbol.section = bfd_com_section_ptr;
4796
12
      dst->symbol.value = src->u.syment.n_value;
4797
12
      break;
4798
4799
19
    case COFF_SYMBOL_UNDEFINED:
4800
19
      dst->symbol.section = bfd_und_section_ptr;
4801
19
      dst->symbol.value = 0;
4802
19
      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
138
    }
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
138
#ifdef COFF_WITH_PE
4831
138
        if (src->u.syment.n_sclass == C_NT_WEAK)
4832
12
    dst->symbol.flags |= BSF_WEAK;
4833
4834
138
        if (src->u.syment.n_sclass == C_SECTION
4835
138
      && src->u.syment.n_scnum > 0)
4836
0
    dst->symbol.flags = BSF_LOCAL;
4837
138
#endif
4838
138
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
#ifdef RS6000COFF_C
4840
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
#endif
4842
138
      )
4843
5
    dst->symbol.flags |= BSF_WEAK;
4844
4845
138
        break;
4846
4847
53
      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
63
      case C_LABEL:  /* Label.  */
4858
63
        if (src->u.syment.n_scnum == N_DEBUG)
4859
0
    dst->symbol.flags = BSF_DEBUGGING;
4860
63
        else
4861
63
    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
63
        if (dst->symbol.section)
4866
63
    {
4867
63
#if defined COFF_WITH_PE
4868
      /* PE sets the symbol to a value relative to the
4869
         start of the section.  */
4870
63
      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
63
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
63
        break;
4879
4880
32
      case C_FILE: /* File name.  */
4881
32
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
49
      case C_MOS:   /* Member of structure.  */
4884
50
      case C_EOS:   /* End of structure.  */
4885
50
      case C_REGPARM: /* Register parameter.  */
4886
103
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
107
      case C_TPDEF: /* Type definition.  */
4889
118
      case C_ARG:
4890
167
      case C_AUTO: /* Automatic variable.  */
4891
171
      case C_FIELD: /* Bit field.  */
4892
184
      case C_ENTAG: /* Enumeration tag.  */
4893
187
      case C_MOE:   /* Member of enumeration.  */
4894
187
      case C_MOU:   /* Member of union.  */
4895
194
      case C_UNTAG: /* Union tag.  */
4896
198
      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
198
        dst->symbol.flags |= BSF_DEBUGGING;
4914
198
        dst->symbol.value = (src->u.syment.n_value);
4915
198
        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
1
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
2
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
54
      case C_EFCN: /* Physical end of function.  */
4968
54
#if defined COFF_WITH_PE
4969
        /* PE sets the symbol to a value relative to the start
4970
     of the section.  */
4971
54
        dst->symbol.value = src->u.syment.n_value;
4972
54
        if (strcmp (dst->symbol.name, ".bf") != 0)
4973
54
    {
4974
      /* PE uses funny values for .ef and .lf; don't
4975
         relocate them.  */
4976
54
      dst->symbol.flags = BSF_DEBUGGING;
4977
54
    }
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
54
        break;
4988
4989
7
      case C_STATLAB: /* Static load time label.  */
4990
7
        dst->symbol.value = src->u.syment.n_value;
4991
7
        dst->symbol.flags = BSF_GLOBAL;
4992
7
        break;
4993
4994
627
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
627
        if (src->u.syment.n_type == 0
4998
627
      && src->u.syment.n_value == 0
4999
627
      && src->u.syment.n_scnum == 0)
5000
627
    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
0
      case C_EXTDEF: /* External definition.  */
5008
0
      case C_ULABEL: /* Undefined label.  */
5009
0
      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
0
      case C_EXTLAB: /* External load time label.  */
5022
0
      default:
5023
0
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
0
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
0
     abfd, src->u.syment.n_sclass,
5027
0
     dst->symbol.section->name, dst->symbol.name);
5028
0
        ret = false;
5029
        /* Fall through.  */
5030
7
      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
7
        dst->symbol.flags = BSF_DEBUGGING;
5034
7
        dst->symbol.value = (src->u.syment.n_value);
5035
7
        break;
5036
1.09k
      }
5037
5038
1.09k
    dst->native = src;
5039
1.09k
    dst->symbol.udata.i = 0;
5040
1.09k
    dst->lineno = NULL;
5041
5042
1.09k
    this_index += (src->u.syment.n_numaux) + 1;
5043
1.09k
    dst++;
5044
1.09k
    number_of_symbols++;
5045
1.09k
  }
5046
60
    }
5047
5048
60
  obj_symbols (abfd) = cached_area;
5049
60
  obj_raw_syments (abfd) = native_symbols;
5050
5051
60
  abfd->symcount = number_of_symbols;
5052
60
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
60
  {
5055
60
    asection *p;
5056
5057
60
    p = abfd->sections;
5058
334
    while (p)
5059
274
      {
5060
274
  if (! coff_slurp_line_table (abfd, p))
5061
0
    return false;
5062
274
  p = p->next;
5063
274
      }
5064
60
  }
5065
5066
60
  return ret;
5067
60
}
coff-x86_64.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
93
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
93
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
0
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
93
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
93
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
93
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
93
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
93
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
93
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
93
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
93
  if (table_ptr == NULL)
4729
0
    return false;
4730
93
  else
4731
93
    {
4732
93
      coff_symbol_type *dst = cached_area;
4733
93
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
93
      unsigned int this_index = 0;
4735
4736
1.86k
      while (this_index < last_native_index)
4737
1.77k
  {
4738
1.77k
    combined_entry_type *src = native_symbols + this_index;
4739
1.77k
    table_ptr[this_index] = number_of_symbols;
4740
4741
1.77k
    dst->symbol.the_bfd = abfd;
4742
1.77k
    BFD_ASSERT (src->is_sym);
4743
1.77k
    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.77k
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
1.77k
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
1.77k
                 src->u.syment.n_scnum);
4748
1.77k
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
1.77k
    dst->symbol.value = 0;
4751
1.77k
    dst->done_lineno = false;
4752
4753
1.77k
    switch (src->u.syment.n_sclass)
4754
1.77k
      {
4755
100
      case C_EXT:
4756
118
      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
118
#ifdef C_SYSTEM
4768
134
      case C_SYSTEM: /* System Wide variable.  */
4769
134
#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
134
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
134
    {
4778
112
    case COFF_SYMBOL_GLOBAL:
4779
112
      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
112
      dst->symbol.value = (src->u.syment.n_value
4786
112
               - dst->symbol.section->vma);
4787
112
#endif
4788
112
      if (ISFCN ((src->u.syment.n_type)))
4789
        /* A function ext does not go at the end of a
4790
           file.  */
4791
13
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4792
112
      break;
4793
4794
8
    case COFF_SYMBOL_COMMON:
4795
8
      dst->symbol.section = bfd_com_section_ptr;
4796
8
      dst->symbol.value = src->u.syment.n_value;
4797
8
      break;
4798
4799
14
    case COFF_SYMBOL_UNDEFINED:
4800
14
      dst->symbol.section = bfd_und_section_ptr;
4801
14
      dst->symbol.value = 0;
4802
14
      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
134
    }
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
134
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
#ifdef RS6000COFF_C
4840
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
#endif
4842
134
      )
4843
18
    dst->symbol.flags |= BSF_WEAK;
4844
4845
134
        break;
4846
4847
81
      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
94
      case C_LABEL:  /* Label.  */
4858
94
        if (src->u.syment.n_scnum == N_DEBUG)
4859
0
    dst->symbol.flags = BSF_DEBUGGING;
4860
94
        else
4861
94
    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
94
        if (dst->symbol.section)
4866
94
    {
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
94
      dst->symbol.value = (src->u.syment.n_value
4873
94
               - dst->symbol.section->vma);
4874
94
#endif
4875
94
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
94
        break;
4879
4880
11
      case C_FILE: /* File name.  */
4881
11
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
25
      case C_MOS:   /* Member of structure.  */
4884
25
      case C_EOS:   /* End of structure.  */
4885
44
      case C_REGPARM: /* Register parameter.  */
4886
69
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
83
      case C_TPDEF: /* Type definition.  */
4889
157
      case C_ARG:
4890
522
      case C_AUTO: /* Automatic variable.  */
4891
554
      case C_FIELD: /* Bit field.  */
4892
565
      case C_ENTAG: /* Enumeration tag.  */
4893
578
      case C_MOE:   /* Member of enumeration.  */
4894
595
      case C_MOU:   /* Member of union.  */
4895
624
      case C_UNTAG: /* Union tag.  */
4896
665
      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
665
        dst->symbol.flags |= BSF_DEBUGGING;
4914
665
        dst->symbol.value = (src->u.syment.n_value);
4915
665
        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
11
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
43
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
64
      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
64
        dst->symbol.flags = BSF_LOCAL;
4984
64
        dst->symbol.value = (src->u.syment.n_value
4985
64
           - dst->symbol.section->vma);
4986
64
#endif
4987
64
        break;
4988
4989
58
      case C_STATLAB: /* Static load time label.  */
4990
58
        dst->symbol.value = src->u.syment.n_value;
4991
58
        dst->symbol.flags = BSF_GLOBAL;
4992
58
        break;
4993
4994
749
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
749
        if (src->u.syment.n_type == 0
4998
749
      && src->u.syment.n_value == 0
4999
749
      && src->u.syment.n_scnum == 0)
5000
749
    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
0
      case C_EXTDEF: /* External definition.  */
5008
0
      case C_ULABEL: /* Undefined label.  */
5009
0
      case C_USTATIC: /* Undefined static.  */
5010
0
#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
0
      case C_LINE: /* line # reformatted as symbol table entry.  */
5014
        /* NT uses 0x67 for a weak symbol, not C_ALIAS.  */
5015
0
      case C_ALIAS: /* Duplicate tag.  */
5016
0
#endif
5017
        /* New storage classes for TI COFF.  */
5018
#ifdef TICOFF
5019
      case C_UEXT:  /* Tentative external definition.  */
5020
#endif
5021
0
      case C_EXTLAB: /* External load time label.  */
5022
0
      default:
5023
0
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
0
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
0
     abfd, src->u.syment.n_sclass,
5027
0
     dst->symbol.section->name, dst->symbol.name);
5028
0
        ret = false;
5029
        /* Fall through.  */
5030
9
      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
9
        dst->symbol.flags = BSF_DEBUGGING;
5034
9
        dst->symbol.value = (src->u.syment.n_value);
5035
9
        break;
5036
1.77k
      }
5037
5038
1.77k
    dst->native = src;
5039
1.77k
    dst->symbol.udata.i = 0;
5040
1.77k
    dst->lineno = NULL;
5041
5042
1.77k
    this_index += (src->u.syment.n_numaux) + 1;
5043
1.77k
    dst++;
5044
1.77k
    number_of_symbols++;
5045
1.77k
  }
5046
93
    }
5047
5048
93
  obj_symbols (abfd) = cached_area;
5049
93
  obj_raw_syments (abfd) = native_symbols;
5050
5051
93
  abfd->symcount = number_of_symbols;
5052
93
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
93
  {
5055
93
    asection *p;
5056
5057
93
    p = abfd->sections;
5058
25.3k
    while (p)
5059
25.2k
      {
5060
25.2k
  if (! coff_slurp_line_table (abfd, p))
5061
0
    return false;
5062
25.2k
  p = p->next;
5063
25.2k
      }
5064
93
  }
5065
5066
93
  return ret;
5067
93
}
coff64-rs6000.c:coff_slurp_symbol_table
Line
Count
Source
4695
164
{
4696
164
  combined_entry_type *native_symbols;
4697
164
  coff_symbol_type *cached_area;
4698
164
  unsigned int *table_ptr;
4699
164
  unsigned int number_of_symbols = 0;
4700
164
  bool ret = true;
4701
164
  size_t amt;
4702
4703
164
  if (obj_symbols (abfd))
4704
82
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
82
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
0
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
82
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
82
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
82
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
82
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
82
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
82
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
82
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
82
  if (table_ptr == NULL)
4729
0
    return false;
4730
82
  else
4731
82
    {
4732
82
      coff_symbol_type *dst = cached_area;
4733
82
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
82
      unsigned int this_index = 0;
4735
4736
1.84k
      while (this_index < last_native_index)
4737
1.76k
  {
4738
1.76k
    combined_entry_type *src = native_symbols + this_index;
4739
1.76k
    table_ptr[this_index] = number_of_symbols;
4740
4741
1.76k
    dst->symbol.the_bfd = abfd;
4742
1.76k
    BFD_ASSERT (src->is_sym);
4743
1.76k
    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.76k
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
1.76k
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
1.76k
                 src->u.syment.n_scnum);
4748
1.76k
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
1.76k
    dst->symbol.value = 0;
4751
1.76k
    dst->done_lineno = false;
4752
4753
1.76k
    switch (src->u.syment.n_sclass)
4754
1.76k
      {
4755
54
      case C_EXT:
4756
57
      case C_WEAKEXT:
4757
#if defined ARM
4758
      case C_THUMBEXT:
4759
      case C_THUMBEXTFUNC:
4760
#endif
4761
57
#ifdef RS6000COFF_C
4762
73
      case C_HIDEXT:
4763
73
#ifndef AIX_WEAK_SUPPORT
4764
78
      case C_AIX_WEAKEXT:
4765
78
#endif
4766
78
#endif
4767
78
#ifdef C_SYSTEM
4768
85
      case C_SYSTEM: /* System Wide variable.  */
4769
85
#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
85
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
85
    {
4778
57
    case COFF_SYMBOL_GLOBAL:
4779
57
      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
57
      dst->symbol.value = (src->u.syment.n_value
4786
57
               - dst->symbol.section->vma);
4787
57
#endif
4788
57
      if (ISFCN ((src->u.syment.n_type)))
4789
        /* A function ext does not go at the end of a
4790
           file.  */
4791
3
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4792
57
      break;
4793
4794
2
    case COFF_SYMBOL_COMMON:
4795
2
      dst->symbol.section = bfd_com_section_ptr;
4796
2
      dst->symbol.value = src->u.syment.n_value;
4797
2
      break;
4798
4799
10
    case COFF_SYMBOL_UNDEFINED:
4800
10
      dst->symbol.section = bfd_und_section_ptr;
4801
10
      dst->symbol.value = 0;
4802
10
      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
16
    case COFF_SYMBOL_LOCAL:
4810
16
      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
16
      dst->symbol.value = (src->u.syment.n_value
4817
16
               - dst->symbol.section->vma);
4818
16
#endif
4819
16
      if (ISFCN ((src->u.syment.n_type)))
4820
14
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4821
16
      break;
4822
85
    }
4823
4824
85
#ifdef RS6000COFF_C
4825
        /* A symbol with a csect entry should not go at the end.  */
4826
85
        if (src->u.syment.n_numaux > 0)
4827
76
    dst->symbol.flags |= BSF_NOT_AT_END;
4828
85
#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
85
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
85
#ifdef RS6000COFF_C
4840
85
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
85
#endif
4842
85
      )
4843
8
    dst->symbol.flags |= BSF_WEAK;
4844
4845
85
        break;
4846
4847
11
      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
11
#ifdef RS6000COFF_C
4854
13
      case C_DWARF:  /* A label in a dwarf section.  */
4855
13
      case C_INFO:  /* A label in a comment section.  */
4856
13
#endif
4857
22
      case C_LABEL:  /* Label.  */
4858
22
        if (src->u.syment.n_scnum == N_DEBUG)
4859
0
    dst->symbol.flags = BSF_DEBUGGING;
4860
22
        else
4861
22
    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
22
        if (dst->symbol.section)
4866
22
    {
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
22
      dst->symbol.value = (src->u.syment.n_value
4873
22
               - dst->symbol.section->vma);
4874
22
#endif
4875
22
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
22
        break;
4879
4880
6
      case C_FILE: /* File name.  */
4881
6
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
7
      case C_MOS:   /* Member of structure.  */
4884
8
      case C_EOS:   /* End of structure.  */
4885
13
      case C_REGPARM: /* Register parameter.  */
4886
36
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
43
      case C_TPDEF: /* Type definition.  */
4889
43
      case C_ARG:
4890
117
      case C_AUTO: /* Automatic variable.  */
4891
120
      case C_FIELD: /* Bit field.  */
4892
132
      case C_ENTAG: /* Enumeration tag.  */
4893
134
      case C_MOE:   /* Member of enumeration.  */
4894
158
      case C_MOU:   /* Member of union.  */
4895
166
      case C_UNTAG: /* Union tag.  */
4896
193
      case C_STRTAG: /* Structure tag.  */
4897
193
#ifdef RS6000COFF_C
4898
200
      case C_GSYM:
4899
201
      case C_LSYM:
4900
201
      case C_PSYM:
4901
201
      case C_RSYM:
4902
201
      case C_RPSYM:
4903
202
      case C_STSYM:
4904
203
      case C_TCSYM:
4905
203
      case C_BCOMM:
4906
203
      case C_ECOML:
4907
203
      case C_ECOMM:
4908
203
      case C_DECL:
4909
203
      case C_ENTRY:
4910
204
      case C_FUN:
4911
242
      case C_ESTAT:
4912
242
#endif
4913
242
        dst->symbol.flags |= BSF_DEBUGGING;
4914
242
        dst->symbol.value = (src->u.syment.n_value);
4915
242
        break;
4916
4917
0
#ifdef RS6000COFF_C
4918
5
      case C_BINCL: /* Beginning of include file.  */
4919
41
      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
41
        {
4925
41
    asection *sec;
4926
4927
41
    dst->symbol.flags = BSF_DEBUGGING;
4928
976
    for (sec = abfd->sections; sec != NULL; sec = sec->next)
4929
940
      if (sec->line_filepos <= (file_ptr) src->u.syment.n_value
4930
940
          && ((file_ptr) (sec->line_filepos
4931
676
              + sec->lineno_count * bfd_coff_linesz (abfd))
4932
676
        > (file_ptr) src->u.syment.n_value))
4933
5
        break;
4934
41
    if (sec == NULL)
4935
36
      dst->symbol.value = 0;
4936
5
    else
4937
5
      {
4938
5
        dst->symbol.section = sec;
4939
5
        dst->symbol.value = ((src->u.syment.n_value
4940
5
            - sec->line_filepos)
4941
5
           / bfd_coff_linesz (abfd));
4942
5
        src->fix_line = 1;
4943
5
      }
4944
41
        }
4945
41
        break;
4946
4947
4
      case C_BSTAT:
4948
4
        dst->symbol.flags = BSF_DEBUGGING;
4949
4950
4
        if (src->u.syment.n_value >= obj_raw_syment_count (abfd))
4951
1
    dst->symbol.value = 0;
4952
3
        else
4953
3
    {
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
3
      src->u.syment.n_value
4958
3
        = (uintptr_t) (native_symbols + src->u.syment.n_value);
4959
3
      dst->symbol.value = src->u.syment.n_value;
4960
3
      src->fix_value = 1;
4961
3
    }
4962
4
        break;
4963
0
#endif
4964
4965
10
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
11
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
28
      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
28
        dst->symbol.flags = BSF_LOCAL;
4984
28
        dst->symbol.value = (src->u.syment.n_value
4985
28
           - dst->symbol.section->vma);
4986
28
#endif
4987
28
        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
1.33k
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
1.33k
        if (src->u.syment.n_type == 0
4998
1.33k
      && src->u.syment.n_value == 0
4999
1.33k
      && src->u.syment.n_scnum == 0)
5000
1.33k
    break;
5001
0
#ifdef RS6000COFF_C
5002
        /* XCOFF specific: deleted entry.  */
5003
0
        if (src->u.syment.n_value == C_NULL_VALUE)
5004
0
    break;
5005
0
#endif
5006
        /* Fall through.  */
5007
0
      case C_EXTDEF: /* External definition.  */
5008
0
      case C_ULABEL: /* Undefined label.  */
5009
0
      case C_USTATIC: /* Undefined static.  */
5010
0
#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
0
      case C_LINE: /* line # reformatted as symbol table entry.  */
5014
        /* NT uses 0x67 for a weak symbol, not C_ALIAS.  */
5015
0
      case C_ALIAS: /* Duplicate tag.  */
5016
0
#endif
5017
        /* New storage classes for TI COFF.  */
5018
#ifdef TICOFF
5019
      case C_UEXT:  /* Tentative external definition.  */
5020
#endif
5021
0
      case C_EXTLAB: /* External load time label.  */
5022
0
      default:
5023
0
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
0
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
0
     abfd, src->u.syment.n_sclass,
5027
0
     dst->symbol.section->name, dst->symbol.name);
5028
0
        ret = false;
5029
        /* Fall through.  */
5030
3
      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
3
        dst->symbol.flags = BSF_DEBUGGING;
5034
3
        dst->symbol.value = (src->u.syment.n_value);
5035
3
        break;
5036
1.76k
      }
5037
5038
1.76k
    dst->native = src;
5039
1.76k
    dst->symbol.udata.i = 0;
5040
1.76k
    dst->lineno = NULL;
5041
5042
1.76k
    this_index += (src->u.syment.n_numaux) + 1;
5043
1.76k
    dst++;
5044
1.76k
    number_of_symbols++;
5045
1.76k
  }
5046
82
    }
5047
5048
82
  obj_symbols (abfd) = cached_area;
5049
82
  obj_raw_syments (abfd) = native_symbols;
5050
5051
82
  abfd->symcount = number_of_symbols;
5052
82
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
82
  {
5055
82
    asection *p;
5056
5057
82
    p = abfd->sections;
5058
1.21k
    while (p)
5059
1.13k
      {
5060
1.13k
  if (! coff_slurp_line_table (abfd, p))
5061
0
    return false;
5062
1.13k
  p = p->next;
5063
1.13k
      }
5064
82
  }
5065
5066
82
  return ret;
5067
82
}
pe-aarch64.c:coff_slurp_symbol_table
Line
Count
Source
4695
134
{
4696
134
  combined_entry_type *native_symbols;
4697
134
  coff_symbol_type *cached_area;
4698
134
  unsigned int *table_ptr;
4699
134
  unsigned int number_of_symbols = 0;
4700
134
  bool ret = true;
4701
134
  size_t amt;
4702
4703
134
  if (obj_symbols (abfd))
4704
67
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
67
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
0
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
67
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
67
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
67
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
67
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
67
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
67
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
67
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
67
  if (table_ptr == NULL)
4729
0
    return false;
4730
67
  else
4731
67
    {
4732
67
      coff_symbol_type *dst = cached_area;
4733
67
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
67
      unsigned int this_index = 0;
4735
4736
2.94k
      while (this_index < last_native_index)
4737
2.87k
  {
4738
2.87k
    combined_entry_type *src = native_symbols + this_index;
4739
2.87k
    table_ptr[this_index] = number_of_symbols;
4740
4741
2.87k
    dst->symbol.the_bfd = abfd;
4742
2.87k
    BFD_ASSERT (src->is_sym);
4743
2.87k
    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
2.87k
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
2.87k
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
2.87k
                 src->u.syment.n_scnum);
4748
2.87k
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
2.87k
    dst->symbol.value = 0;
4751
2.87k
    dst->done_lineno = false;
4752
4753
2.87k
    switch (src->u.syment.n_sclass)
4754
2.87k
      {
4755
104
      case C_EXT:
4756
123
      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
123
#ifdef C_SYSTEM
4768
173
      case C_SYSTEM: /* System Wide variable.  */
4769
173
#endif
4770
173
#ifdef COFF_WITH_PE
4771
      /* In PE, 0x68 (104) denotes a section symbol.  */
4772
173
      case C_SECTION:
4773
      /* In PE, 0x69 (105) denotes a weak external symbol.  */
4774
179
      case C_NT_WEAK:
4775
179
#endif
4776
179
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
179
    {
4778
159
    case COFF_SYMBOL_GLOBAL:
4779
159
      dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
4780
159
#if defined COFF_WITH_PE
4781
      /* PE sets the symbol to a value relative to the
4782
         start of the section.  */
4783
159
      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
159
      if (ISFCN ((src->u.syment.n_type)))
4789
        /* A function ext does not go at the end of a
4790
           file.  */
4791
7
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4792
159
      break;
4793
4794
6
    case COFF_SYMBOL_COMMON:
4795
6
      dst->symbol.section = bfd_com_section_ptr;
4796
6
      dst->symbol.value = src->u.syment.n_value;
4797
6
      break;
4798
4799
14
    case COFF_SYMBOL_UNDEFINED:
4800
14
      dst->symbol.section = bfd_und_section_ptr;
4801
14
      dst->symbol.value = 0;
4802
14
      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
179
    }
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
179
#ifdef COFF_WITH_PE
4831
179
        if (src->u.syment.n_sclass == C_NT_WEAK)
4832
6
    dst->symbol.flags |= BSF_WEAK;
4833
4834
179
        if (src->u.syment.n_sclass == C_SECTION
4835
179
      && src->u.syment.n_scnum > 0)
4836
0
    dst->symbol.flags = BSF_LOCAL;
4837
179
#endif
4838
179
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
#ifdef RS6000COFF_C
4840
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
#endif
4842
179
      )
4843
19
    dst->symbol.flags |= BSF_WEAK;
4844
4845
179
        break;
4846
4847
65
      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
105
      case C_LABEL:  /* Label.  */
4858
105
        if (src->u.syment.n_scnum == N_DEBUG)
4859
0
    dst->symbol.flags = BSF_DEBUGGING;
4860
105
        else
4861
105
    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
105
        if (dst->symbol.section)
4866
105
    {
4867
105
#if defined COFF_WITH_PE
4868
      /* PE sets the symbol to a value relative to the
4869
         start of the section.  */
4870
105
      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
105
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
105
        break;
4879
4880
1
      case C_FILE: /* File name.  */
4881
1
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
2
      case C_MOS:   /* Member of structure.  */
4884
3
      case C_EOS:   /* End of structure.  */
4885
41
      case C_REGPARM: /* Register parameter.  */
4886
156
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
161
      case C_TPDEF: /* Type definition.  */
4889
181
      case C_ARG:
4890
380
      case C_AUTO: /* Automatic variable.  */
4891
381
      case C_FIELD: /* Bit field.  */
4892
393
      case C_ENTAG: /* Enumeration tag.  */
4893
409
      case C_MOE:   /* Member of enumeration.  */
4894
409
      case C_MOU:   /* Member of union.  */
4895
456
      case C_UNTAG: /* Union tag.  */
4896
488
      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
488
        dst->symbol.flags |= BSF_DEBUGGING;
4914
488
        dst->symbol.value = (src->u.syment.n_value);
4915
488
        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
0
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
1
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
5
      case C_EFCN: /* Physical end of function.  */
4968
5
#if defined COFF_WITH_PE
4969
        /* PE sets the symbol to a value relative to the start
4970
     of the section.  */
4971
5
        dst->symbol.value = src->u.syment.n_value;
4972
5
        if (strcmp (dst->symbol.name, ".bf") != 0)
4973
5
    {
4974
      /* PE uses funny values for .ef and .lf; don't
4975
         relocate them.  */
4976
5
      dst->symbol.flags = BSF_DEBUGGING;
4977
5
    }
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
5
        break;
4988
4989
13
      case C_STATLAB: /* Static load time label.  */
4990
13
        dst->symbol.value = src->u.syment.n_value;
4991
13
        dst->symbol.flags = BSF_GLOBAL;
4992
13
        break;
4993
4994
2.08k
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
2.08k
        if (src->u.syment.n_type == 0
4998
2.08k
      && src->u.syment.n_value == 0
4999
2.08k
      && src->u.syment.n_scnum == 0)
5000
2.08k
    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
0
      case C_EXTDEF: /* External definition.  */
5008
0
      case C_ULABEL: /* Undefined label.  */
5009
0
      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
0
      case C_EXTLAB: /* External load time label.  */
5022
0
      default:
5023
0
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
0
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
0
     abfd, src->u.syment.n_sclass,
5027
0
     dst->symbol.section->name, dst->symbol.name);
5028
0
        ret = false;
5029
        /* Fall through.  */
5030
2
      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
2
        dst->symbol.flags = BSF_DEBUGGING;
5034
2
        dst->symbol.value = (src->u.syment.n_value);
5035
2
        break;
5036
2.87k
      }
5037
5038
2.87k
    dst->native = src;
5039
2.87k
    dst->symbol.udata.i = 0;
5040
2.87k
    dst->lineno = NULL;
5041
5042
2.87k
    this_index += (src->u.syment.n_numaux) + 1;
5043
2.87k
    dst++;
5044
2.87k
    number_of_symbols++;
5045
2.87k
  }
5046
67
    }
5047
5048
67
  obj_symbols (abfd) = cached_area;
5049
67
  obj_raw_syments (abfd) = native_symbols;
5050
5051
67
  abfd->symcount = number_of_symbols;
5052
67
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
67
  {
5055
67
    asection *p;
5056
5057
67
    p = abfd->sections;
5058
601
    while (p)
5059
534
      {
5060
534
  if (! coff_slurp_line_table (abfd, p))
5061
0
    return false;
5062
534
  p = p->next;
5063
534
      }
5064
67
  }
5065
5066
67
  return ret;
5067
67
}
pei-aarch64.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
56
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
56
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
0
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
56
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
56
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
56
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
56
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
56
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
56
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
56
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
56
  if (table_ptr == NULL)
4729
0
    return false;
4730
56
  else
4731
56
    {
4732
56
      coff_symbol_type *dst = cached_area;
4733
56
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
56
      unsigned int this_index = 0;
4735
4736
1.19k
      while (this_index < last_native_index)
4737
1.14k
  {
4738
1.14k
    combined_entry_type *src = native_symbols + this_index;
4739
1.14k
    table_ptr[this_index] = number_of_symbols;
4740
4741
1.14k
    dst->symbol.the_bfd = abfd;
4742
1.14k
    BFD_ASSERT (src->is_sym);
4743
1.14k
    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.14k
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
1.14k
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
1.14k
                 src->u.syment.n_scnum);
4748
1.14k
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
1.14k
    dst->symbol.value = 0;
4751
1.14k
    dst->done_lineno = false;
4752
4753
1.14k
    switch (src->u.syment.n_sclass)
4754
1.14k
      {
4755
93
      case C_EXT:
4756
97
      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
97
#ifdef C_SYSTEM
4768
98
      case C_SYSTEM: /* System Wide variable.  */
4769
98
#endif
4770
98
#ifdef COFF_WITH_PE
4771
      /* In PE, 0x68 (104) denotes a section symbol.  */
4772
101
      case C_SECTION:
4773
      /* In PE, 0x69 (105) denotes a weak external symbol.  */
4774
103
      case C_NT_WEAK:
4775
103
#endif
4776
103
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
103
    {
4778
83
    case COFF_SYMBOL_GLOBAL:
4779
83
      dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
4780
83
#if defined COFF_WITH_PE
4781
      /* PE sets the symbol to a value relative to the
4782
         start of the section.  */
4783
83
      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
83
      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
83
      break;
4793
4794
2
    case COFF_SYMBOL_COMMON:
4795
2
      dst->symbol.section = bfd_com_section_ptr;
4796
2
      dst->symbol.value = src->u.syment.n_value;
4797
2
      break;
4798
4799
18
    case COFF_SYMBOL_UNDEFINED:
4800
18
      dst->symbol.section = bfd_und_section_ptr;
4801
18
      dst->symbol.value = 0;
4802
18
      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
103
    }
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
103
#ifdef COFF_WITH_PE
4831
103
        if (src->u.syment.n_sclass == C_NT_WEAK)
4832
2
    dst->symbol.flags |= BSF_WEAK;
4833
4834
103
        if (src->u.syment.n_sclass == C_SECTION
4835
103
      && src->u.syment.n_scnum > 0)
4836
0
    dst->symbol.flags = BSF_LOCAL;
4837
103
#endif
4838
103
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
#ifdef RS6000COFF_C
4840
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
#endif
4842
103
      )
4843
4
    dst->symbol.flags |= BSF_WEAK;
4844
4845
103
        break;
4846
4847
50
      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
77
      case C_LABEL:  /* Label.  */
4858
77
        if (src->u.syment.n_scnum == N_DEBUG)
4859
0
    dst->symbol.flags = BSF_DEBUGGING;
4860
77
        else
4861
77
    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
77
        if (dst->symbol.section)
4866
77
    {
4867
77
#if defined COFF_WITH_PE
4868
      /* PE sets the symbol to a value relative to the
4869
         start of the section.  */
4870
77
      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
77
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
77
        break;
4879
4880
25
      case C_FILE: /* File name.  */
4881
25
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
26
      case C_MOS:   /* Member of structure.  */
4884
26
      case C_EOS:   /* End of structure.  */
4885
28
      case C_REGPARM: /* Register parameter.  */
4886
61
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
76
      case C_TPDEF: /* Type definition.  */
4889
93
      case C_ARG:
4890
182
      case C_AUTO: /* Automatic variable.  */
4891
198
      case C_FIELD: /* Bit field.  */
4892
203
      case C_ENTAG: /* Enumeration tag.  */
4893
211
      case C_MOE:   /* Member of enumeration.  */
4894
227
      case C_MOU:   /* Member of union.  */
4895
234
      case C_UNTAG: /* Union tag.  */
4896
251
      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
251
        dst->symbol.flags |= BSF_DEBUGGING;
4914
251
        dst->symbol.value = (src->u.syment.n_value);
4915
251
        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
5
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
6
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
49
      case C_EFCN: /* Physical end of function.  */
4968
49
#if defined COFF_WITH_PE
4969
        /* PE sets the symbol to a value relative to the start
4970
     of the section.  */
4971
49
        dst->symbol.value = src->u.syment.n_value;
4972
49
        if (strcmp (dst->symbol.name, ".bf") != 0)
4973
49
    {
4974
      /* PE uses funny values for .ef and .lf; don't
4975
         relocate them.  */
4976
49
      dst->symbol.flags = BSF_DEBUGGING;
4977
49
    }
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
49
        break;
4988
4989
15
      case C_STATLAB: /* Static load time label.  */
4990
15
        dst->symbol.value = src->u.syment.n_value;
4991
15
        dst->symbol.flags = BSF_GLOBAL;
4992
15
        break;
4993
4994
644
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
644
        if (src->u.syment.n_type == 0
4998
644
      && src->u.syment.n_value == 0
4999
644
      && src->u.syment.n_scnum == 0)
5000
644
    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
0
      case C_EXTDEF: /* External definition.  */
5008
0
      case C_ULABEL: /* Undefined label.  */
5009
0
      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
0
      case C_EXTLAB: /* External load time label.  */
5022
0
      default:
5023
0
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
0
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
0
     abfd, src->u.syment.n_sclass,
5027
0
     dst->symbol.section->name, dst->symbol.name);
5028
0
        ret = false;
5029
        /* Fall through.  */
5030
1
      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
1
        dst->symbol.flags = BSF_DEBUGGING;
5034
1
        dst->symbol.value = (src->u.syment.n_value);
5035
1
        break;
5036
1.14k
      }
5037
5038
1.14k
    dst->native = src;
5039
1.14k
    dst->symbol.udata.i = 0;
5040
1.14k
    dst->lineno = NULL;
5041
5042
1.14k
    this_index += (src->u.syment.n_numaux) + 1;
5043
1.14k
    dst++;
5044
1.14k
    number_of_symbols++;
5045
1.14k
  }
5046
56
    }
5047
5048
56
  obj_symbols (abfd) = cached_area;
5049
56
  obj_raw_syments (abfd) = native_symbols;
5050
5051
56
  abfd->symcount = number_of_symbols;
5052
56
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
56
  {
5055
56
    asection *p;
5056
5057
56
    p = abfd->sections;
5058
320
    while (p)
5059
264
      {
5060
264
  if (! coff_slurp_line_table (abfd, p))
5061
0
    return false;
5062
264
  p = p->next;
5063
264
      }
5064
56
  }
5065
5066
56
  return ret;
5067
56
}
pei-ia64.c:coff_slurp_symbol_table
Line
Count
Source
4695
178
{
4696
178
  combined_entry_type *native_symbols;
4697
178
  coff_symbol_type *cached_area;
4698
178
  unsigned int *table_ptr;
4699
178
  unsigned int number_of_symbols = 0;
4700
178
  bool ret = true;
4701
178
  size_t amt;
4702
4703
178
  if (obj_symbols (abfd))
4704
89
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
89
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
0
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
89
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
89
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
89
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
89
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
89
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
89
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
89
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
89
  if (table_ptr == NULL)
4729
0
    return false;
4730
89
  else
4731
89
    {
4732
89
      coff_symbol_type *dst = cached_area;
4733
89
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
89
      unsigned int this_index = 0;
4735
4736
4.69k
      while (this_index < last_native_index)
4737
4.60k
  {
4738
4.60k
    combined_entry_type *src = native_symbols + this_index;
4739
4.60k
    table_ptr[this_index] = number_of_symbols;
4740
4741
4.60k
    dst->symbol.the_bfd = abfd;
4742
4.60k
    BFD_ASSERT (src->is_sym);
4743
4.60k
    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
4.60k
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
4.60k
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
4.60k
                 src->u.syment.n_scnum);
4748
4.60k
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
4.60k
    dst->symbol.value = 0;
4751
4.60k
    dst->done_lineno = false;
4752
4753
4.60k
    switch (src->u.syment.n_sclass)
4754
4.60k
      {
4755
217
      case C_EXT:
4756
235
      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
235
#ifdef C_SYSTEM
4768
248
      case C_SYSTEM: /* System Wide variable.  */
4769
248
#endif
4770
248
#ifdef COFF_WITH_PE
4771
      /* In PE, 0x68 (104) denotes a section symbol.  */
4772
250
      case C_SECTION:
4773
      /* In PE, 0x69 (105) denotes a weak external symbol.  */
4774
285
      case C_NT_WEAK:
4775
285
#endif
4776
285
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
285
    {
4778
256
    case COFF_SYMBOL_GLOBAL:
4779
256
      dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
4780
256
#if defined COFF_WITH_PE
4781
      /* PE sets the symbol to a value relative to the
4782
         start of the section.  */
4783
256
      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
256
      if (ISFCN ((src->u.syment.n_type)))
4789
        /* A function ext does not go at the end of a
4790
           file.  */
4791
16
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4792
256
      break;
4793
4794
16
    case COFF_SYMBOL_COMMON:
4795
16
      dst->symbol.section = bfd_com_section_ptr;
4796
16
      dst->symbol.value = src->u.syment.n_value;
4797
16
      break;
4798
4799
13
    case COFF_SYMBOL_UNDEFINED:
4800
13
      dst->symbol.section = bfd_und_section_ptr;
4801
13
      dst->symbol.value = 0;
4802
13
      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
285
    }
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
285
#ifdef COFF_WITH_PE
4831
285
        if (src->u.syment.n_sclass == C_NT_WEAK)
4832
35
    dst->symbol.flags |= BSF_WEAK;
4833
4834
285
        if (src->u.syment.n_sclass == C_SECTION
4835
285
      && src->u.syment.n_scnum > 0)
4836
0
    dst->symbol.flags = BSF_LOCAL;
4837
285
#endif
4838
285
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
#ifdef RS6000COFF_C
4840
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
#endif
4842
285
      )
4843
18
    dst->symbol.flags |= BSF_WEAK;
4844
4845
285
        break;
4846
4847
233
      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
297
      case C_LABEL:  /* Label.  */
4858
297
        if (src->u.syment.n_scnum == N_DEBUG)
4859
0
    dst->symbol.flags = BSF_DEBUGGING;
4860
297
        else
4861
297
    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
297
        if (dst->symbol.section)
4866
297
    {
4867
297
#if defined COFF_WITH_PE
4868
      /* PE sets the symbol to a value relative to the
4869
         start of the section.  */
4870
297
      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
297
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
297
        break;
4879
4880
32
      case C_FILE: /* File name.  */
4881
32
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
42
      case C_MOS:   /* Member of structure.  */
4884
46
      case C_EOS:   /* End of structure.  */
4885
99
      case C_REGPARM: /* Register parameter.  */
4886
243
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
278
      case C_TPDEF: /* Type definition.  */
4889
278
      case C_ARG:
4890
634
      case C_AUTO: /* Automatic variable.  */
4891
704
      case C_FIELD: /* Bit field.  */
4892
759
      case C_ENTAG: /* Enumeration tag.  */
4893
768
      case C_MOE:   /* Member of enumeration.  */
4894
809
      case C_MOU:   /* Member of union.  */
4895
968
      case C_UNTAG: /* Union tag.  */
4896
988
      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
988
        dst->symbol.flags |= BSF_DEBUGGING;
4914
988
        dst->symbol.value = (src->u.syment.n_value);
4915
988
        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
1
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
10
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
13
      case C_EFCN: /* Physical end of function.  */
4968
13
#if defined COFF_WITH_PE
4969
        /* PE sets the symbol to a value relative to the start
4970
     of the section.  */
4971
13
        dst->symbol.value = src->u.syment.n_value;
4972
13
        if (strcmp (dst->symbol.name, ".bf") != 0)
4973
13
    {
4974
      /* PE uses funny values for .ef and .lf; don't
4975
         relocate them.  */
4976
13
      dst->symbol.flags = BSF_DEBUGGING;
4977
13
    }
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
13
        break;
4988
4989
65
      case C_STATLAB: /* Static load time label.  */
4990
65
        dst->symbol.value = src->u.syment.n_value;
4991
65
        dst->symbol.flags = BSF_GLOBAL;
4992
65
        break;
4993
4994
2.95k
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
2.95k
        if (src->u.syment.n_type == 0
4998
2.95k
      && src->u.syment.n_value == 0
4999
2.95k
      && src->u.syment.n_scnum == 0)
5000
2.95k
    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
0
      case C_EXTDEF: /* External definition.  */
5008
0
      case C_ULABEL: /* Undefined label.  */
5009
0
      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
0
      case C_EXTLAB: /* External load time label.  */
5022
0
      default:
5023
0
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
0
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
0
     abfd, src->u.syment.n_sclass,
5027
0
     dst->symbol.section->name, dst->symbol.name);
5028
0
        ret = false;
5029
        /* Fall through.  */
5030
10
      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
10
        dst->symbol.flags = BSF_DEBUGGING;
5034
10
        dst->symbol.value = (src->u.syment.n_value);
5035
10
        break;
5036
4.60k
      }
5037
5038
4.60k
    dst->native = src;
5039
4.60k
    dst->symbol.udata.i = 0;
5040
4.60k
    dst->lineno = NULL;
5041
5042
4.60k
    this_index += (src->u.syment.n_numaux) + 1;
5043
4.60k
    dst++;
5044
4.60k
    number_of_symbols++;
5045
4.60k
  }
5046
89
    }
5047
5048
89
  obj_symbols (abfd) = cached_area;
5049
89
  obj_raw_syments (abfd) = native_symbols;
5050
5051
89
  abfd->symcount = number_of_symbols;
5052
89
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
89
  {
5055
89
    asection *p;
5056
5057
89
    p = abfd->sections;
5058
180
    while (p)
5059
91
      {
5060
91
  if (! coff_slurp_line_table (abfd, p))
5061
0
    return false;
5062
91
  p = p->next;
5063
91
      }
5064
89
  }
5065
5066
89
  return ret;
5067
89
}
pei-loongarch64.c:coff_slurp_symbol_table
Line
Count
Source
4695
110
{
4696
110
  combined_entry_type *native_symbols;
4697
110
  coff_symbol_type *cached_area;
4698
110
  unsigned int *table_ptr;
4699
110
  unsigned int number_of_symbols = 0;
4700
110
  bool ret = true;
4701
110
  size_t amt;
4702
4703
110
  if (obj_symbols (abfd))
4704
55
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
55
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
0
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
55
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
55
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
55
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
55
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
55
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
55
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
55
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
55
  if (table_ptr == NULL)
4729
0
    return false;
4730
55
  else
4731
55
    {
4732
55
      coff_symbol_type *dst = cached_area;
4733
55
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
55
      unsigned int this_index = 0;
4735
4736
1.17k
      while (this_index < last_native_index)
4737
1.11k
  {
4738
1.11k
    combined_entry_type *src = native_symbols + this_index;
4739
1.11k
    table_ptr[this_index] = number_of_symbols;
4740
4741
1.11k
    dst->symbol.the_bfd = abfd;
4742
1.11k
    BFD_ASSERT (src->is_sym);
4743
1.11k
    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.11k
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
1.11k
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
1.11k
                 src->u.syment.n_scnum);
4748
1.11k
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
1.11k
    dst->symbol.value = 0;
4751
1.11k
    dst->done_lineno = false;
4752
4753
1.11k
    switch (src->u.syment.n_sclass)
4754
1.11k
      {
4755
80
      case C_EXT:
4756
98
      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
98
#ifdef C_SYSTEM
4768
98
      case C_SYSTEM: /* System Wide variable.  */
4769
98
#endif
4770
98
#ifdef COFF_WITH_PE
4771
      /* In PE, 0x68 (104) denotes a section symbol.  */
4772
103
      case C_SECTION:
4773
      /* In PE, 0x69 (105) denotes a weak external symbol.  */
4774
104
      case C_NT_WEAK:
4775
104
#endif
4776
104
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
104
    {
4778
72
    case COFF_SYMBOL_GLOBAL:
4779
72
      dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
4780
72
#if defined COFF_WITH_PE
4781
      /* PE sets the symbol to a value relative to the
4782
         start of the section.  */
4783
72
      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
72
      if (ISFCN ((src->u.syment.n_type)))
4789
        /* A function ext does not go at the end of a
4790
           file.  */
4791
6
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4792
72
      break;
4793
4794
13
    case COFF_SYMBOL_COMMON:
4795
13
      dst->symbol.section = bfd_com_section_ptr;
4796
13
      dst->symbol.value = src->u.syment.n_value;
4797
13
      break;
4798
4799
19
    case COFF_SYMBOL_UNDEFINED:
4800
19
      dst->symbol.section = bfd_und_section_ptr;
4801
19
      dst->symbol.value = 0;
4802
19
      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
104
    }
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
104
#ifdef COFF_WITH_PE
4831
104
        if (src->u.syment.n_sclass == C_NT_WEAK)
4832
1
    dst->symbol.flags |= BSF_WEAK;
4833
4834
104
        if (src->u.syment.n_sclass == C_SECTION
4835
104
      && src->u.syment.n_scnum > 0)
4836
0
    dst->symbol.flags = BSF_LOCAL;
4837
104
#endif
4838
104
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
#ifdef RS6000COFF_C
4840
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
#endif
4842
104
      )
4843
18
    dst->symbol.flags |= BSF_WEAK;
4844
4845
104
        break;
4846
4847
119
      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
136
      case C_LABEL:  /* Label.  */
4858
136
        if (src->u.syment.n_scnum == N_DEBUG)
4859
0
    dst->symbol.flags = BSF_DEBUGGING;
4860
136
        else
4861
136
    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
136
        if (dst->symbol.section)
4866
136
    {
4867
136
#if defined COFF_WITH_PE
4868
      /* PE sets the symbol to a value relative to the
4869
         start of the section.  */
4870
136
      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
136
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
136
        break;
4879
4880
20
      case C_FILE: /* File name.  */
4881
20
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
21
      case C_MOS:   /* Member of structure.  */
4884
21
      case C_EOS:   /* End of structure.  */
4885
22
      case C_REGPARM: /* Register parameter.  */
4886
36
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
56
      case C_TPDEF: /* Type definition.  */
4889
59
      case C_ARG:
4890
199
      case C_AUTO: /* Automatic variable.  */
4891
207
      case C_FIELD: /* Bit field.  */
4892
230
      case C_ENTAG: /* Enumeration tag.  */
4893
246
      case C_MOE:   /* Member of enumeration.  */
4894
252
      case C_MOU:   /* Member of union.  */
4895
262
      case C_UNTAG: /* Union tag.  */
4896
275
      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
275
        dst->symbol.flags |= BSF_DEBUGGING;
4914
275
        dst->symbol.value = (src->u.syment.n_value);
4915
275
        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
16
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
18
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
76
      case C_EFCN: /* Physical end of function.  */
4968
76
#if defined COFF_WITH_PE
4969
        /* PE sets the symbol to a value relative to the start
4970
     of the section.  */
4971
76
        dst->symbol.value = src->u.syment.n_value;
4972
76
        if (strcmp (dst->symbol.name, ".bf") != 0)
4973
76
    {
4974
      /* PE uses funny values for .ef and .lf; don't
4975
         relocate them.  */
4976
76
      dst->symbol.flags = BSF_DEBUGGING;
4977
76
    }
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
76
        break;
4988
4989
18
      case C_STATLAB: /* Static load time label.  */
4990
18
        dst->symbol.value = src->u.syment.n_value;
4991
18
        dst->symbol.flags = BSF_GLOBAL;
4992
18
        break;
4993
4994
499
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
499
        if (src->u.syment.n_type == 0
4998
499
      && src->u.syment.n_value == 0
4999
499
      && src->u.syment.n_scnum == 0)
5000
499
    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
0
      case C_EXTDEF: /* External definition.  */
5008
0
      case C_ULABEL: /* Undefined label.  */
5009
0
      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
0
      case C_EXTLAB: /* External load time label.  */
5022
0
      default:
5023
0
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
0
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
0
     abfd, src->u.syment.n_sclass,
5027
0
     dst->symbol.section->name, dst->symbol.name);
5028
0
        ret = false;
5029
        /* Fall through.  */
5030
9
      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
9
        dst->symbol.flags = BSF_DEBUGGING;
5034
9
        dst->symbol.value = (src->u.syment.n_value);
5035
9
        break;
5036
1.11k
      }
5037
5038
1.11k
    dst->native = src;
5039
1.11k
    dst->symbol.udata.i = 0;
5040
1.11k
    dst->lineno = NULL;
5041
5042
1.11k
    this_index += (src->u.syment.n_numaux) + 1;
5043
1.11k
    dst++;
5044
1.11k
    number_of_symbols++;
5045
1.11k
  }
5046
55
    }
5047
5048
55
  obj_symbols (abfd) = cached_area;
5049
55
  obj_raw_syments (abfd) = native_symbols;
5050
5051
55
  abfd->symcount = number_of_symbols;
5052
55
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
55
  {
5055
55
    asection *p;
5056
5057
55
    p = abfd->sections;
5058
345
    while (p)
5059
290
      {
5060
290
  if (! coff_slurp_line_table (abfd, p))
5061
0
    return false;
5062
290
  p = p->next;
5063
290
      }
5064
55
  }
5065
5066
55
  return ret;
5067
55
}
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
218
{
4696
218
  combined_entry_type *native_symbols;
4697
218
  coff_symbol_type *cached_area;
4698
218
  unsigned int *table_ptr;
4699
218
  unsigned int number_of_symbols = 0;
4700
218
  bool ret = true;
4701
218
  size_t amt;
4702
4703
218
  if (obj_symbols (abfd))
4704
109
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
109
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
0
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
109
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
109
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
109
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
109
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
109
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
109
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
109
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
109
  if (table_ptr == NULL)
4729
0
    return false;
4730
109
  else
4731
109
    {
4732
109
      coff_symbol_type *dst = cached_area;
4733
109
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
109
      unsigned int this_index = 0;
4735
4736
3.80k
      while (this_index < last_native_index)
4737
3.69k
  {
4738
3.69k
    combined_entry_type *src = native_symbols + this_index;
4739
3.69k
    table_ptr[this_index] = number_of_symbols;
4740
4741
3.69k
    dst->symbol.the_bfd = abfd;
4742
3.69k
    BFD_ASSERT (src->is_sym);
4743
3.69k
    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
3.69k
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
3.69k
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
3.69k
                 src->u.syment.n_scnum);
4748
3.69k
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
3.69k
    dst->symbol.value = 0;
4751
3.69k
    dst->done_lineno = false;
4752
4753
3.69k
    switch (src->u.syment.n_sclass)
4754
3.69k
      {
4755
843
      case C_EXT:
4756
844
      case C_WEAKEXT:
4757
#if defined ARM
4758
      case C_THUMBEXT:
4759
      case C_THUMBEXTFUNC:
4760
#endif
4761
844
#ifdef RS6000COFF_C
4762
847
      case C_HIDEXT:
4763
847
#ifndef AIX_WEAK_SUPPORT
4764
857
      case C_AIX_WEAKEXT:
4765
857
#endif
4766
857
#endif
4767
857
#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
835
    case COFF_SYMBOL_GLOBAL:
4779
835
      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
835
      dst->symbol.value = (src->u.syment.n_value
4786
835
               - dst->symbol.section->vma);
4787
835
#endif
4788
835
      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
835
      break;
4793
4794
20
    case COFF_SYMBOL_COMMON:
4795
20
      dst->symbol.section = bfd_com_section_ptr;
4796
20
      dst->symbol.value = src->u.syment.n_value;
4797
20
      break;
4798
4799
4
    case COFF_SYMBOL_UNDEFINED:
4800
4
      dst->symbol.section = bfd_und_section_ptr;
4801
4
      dst->symbol.value = 0;
4802
4
      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
3
    case COFF_SYMBOL_LOCAL:
4810
3
      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
3
      dst->symbol.value = (src->u.syment.n_value
4817
3
               - dst->symbol.section->vma);
4818
3
#endif
4819
3
      if (ISFCN ((src->u.syment.n_type)))
4820
2
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4821
3
      break;
4822
862
    }
4823
4824
862
#ifdef RS6000COFF_C
4825
        /* A symbol with a csect entry should not go at the end.  */
4826
862
        if (src->u.syment.n_numaux > 0)
4827
859
    dst->symbol.flags |= BSF_NOT_AT_END;
4828
862
#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
862
#ifdef RS6000COFF_C
4840
862
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
862
#endif
4842
862
      )
4843
11
    dst->symbol.flags |= BSF_WEAK;
4844
4845
862
        break;
4846
4847
169
      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
169
#ifdef RS6000COFF_C
4854
177
      case C_DWARF:  /* A label in a dwarf section.  */
4855
182
      case C_INFO:  /* A label in a comment section.  */
4856
182
#endif
4857
219
      case C_LABEL:  /* Label.  */
4858
219
        if (src->u.syment.n_scnum == N_DEBUG)
4859
0
    dst->symbol.flags = BSF_DEBUGGING;
4860
219
        else
4861
219
    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
219
        if (dst->symbol.section)
4866
219
    {
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
219
      dst->symbol.value = (src->u.syment.n_value
4873
219
               - dst->symbol.section->vma);
4874
219
#endif
4875
219
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
219
        break;
4879
4880
21
      case C_FILE: /* File name.  */
4881
21
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
88
      case C_MOS:   /* Member of structure.  */
4884
89
      case C_EOS:   /* End of structure.  */
4885
100
      case C_REGPARM: /* Register parameter.  */
4886
153
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
184
      case C_TPDEF: /* Type definition.  */
4889
187
      case C_ARG:
4890
228
      case C_AUTO: /* Automatic variable.  */
4891
242
      case C_FIELD: /* Bit field.  */
4892
247
      case C_ENTAG: /* Enumeration tag.  */
4893
259
      case C_MOE:   /* Member of enumeration.  */
4894
266
      case C_MOU:   /* Member of union.  */
4895
289
      case C_UNTAG: /* Union tag.  */
4896
289
      case C_STRTAG: /* Structure tag.  */
4897
289
#ifdef RS6000COFF_C
4898
290
      case C_GSYM:
4899
291
      case C_LSYM:
4900
292
      case C_PSYM:
4901
293
      case C_RSYM:
4902
295
      case C_RPSYM:
4903
296
      case C_STSYM:
4904
297
      case C_TCSYM:
4905
298
      case C_BCOMM:
4906
299
      case C_ECOML:
4907
300
      case C_ECOMM:
4908
301
      case C_DECL:
4909
301
      case C_ENTRY:
4910
302
      case C_FUN:
4911
303
      case C_ESTAT:
4912
303
#endif
4913
303
        dst->symbol.flags |= BSF_DEBUGGING;
4914
303
        dst->symbol.value = (src->u.syment.n_value);
4915
303
        break;
4916
4917
0
#ifdef RS6000COFF_C
4918
4
      case C_BINCL: /* Beginning of include file.  */
4919
31
      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
31
        {
4925
31
    asection *sec;
4926
4927
31
    dst->symbol.flags = BSF_DEBUGGING;
4928
1.30k
    for (sec = abfd->sections; sec != NULL; sec = sec->next)
4929
1.27k
      if (sec->line_filepos <= (file_ptr) src->u.syment.n_value
4930
1.27k
          && ((file_ptr) (sec->line_filepos
4931
890
              + sec->lineno_count * bfd_coff_linesz (abfd))
4932
890
        > (file_ptr) src->u.syment.n_value))
4933
1
        break;
4934
31
    if (sec == NULL)
4935
30
      dst->symbol.value = 0;
4936
1
    else
4937
1
      {
4938
1
        dst->symbol.section = sec;
4939
1
        dst->symbol.value = ((src->u.syment.n_value
4940
1
            - sec->line_filepos)
4941
1
           / bfd_coff_linesz (abfd));
4942
1
        src->fix_line = 1;
4943
1
      }
4944
31
        }
4945
31
        break;
4946
4947
2
      case C_BSTAT:
4948
2
        dst->symbol.flags = BSF_DEBUGGING;
4949
4950
2
        if (src->u.syment.n_value >= obj_raw_syment_count (abfd))
4951
1
    dst->symbol.value = 0;
4952
1
        else
4953
1
    {
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
1
      src->u.syment.n_value
4958
1
        = (uintptr_t) (native_symbols + src->u.syment.n_value);
4959
1
      dst->symbol.value = src->u.syment.n_value;
4960
1
      src->fix_value = 1;
4961
1
    }
4962
2
        break;
4963
0
#endif
4964
4965
4
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
7
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
13
      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
13
        dst->symbol.flags = BSF_LOCAL;
4984
13
        dst->symbol.value = (src->u.syment.n_value
4985
13
           - dst->symbol.section->vma);
4986
13
#endif
4987
13
        break;
4988
4989
10
      case C_STATLAB: /* Static load time label.  */
4990
10
        dst->symbol.value = src->u.syment.n_value;
4991
10
        dst->symbol.flags = BSF_GLOBAL;
4992
10
        break;
4993
4994
2.24k
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
2.24k
        if (src->u.syment.n_type == 0
4998
2.24k
      && src->u.syment.n_value == 0
4999
2.24k
      && src->u.syment.n_scnum == 0)
5000
2.24k
    break;
5001
1
#ifdef RS6000COFF_C
5002
        /* XCOFF specific: deleted entry.  */
5003
1
        if (src->u.syment.n_value == C_NULL_VALUE)
5004
1
    break;
5005
0
#endif
5006
        /* Fall through.  */
5007
0
      case C_EXTDEF: /* External definition.  */
5008
0
      case C_ULABEL: /* Undefined label.  */
5009
0
      case C_USTATIC: /* Undefined static.  */
5010
0
#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
0
      case C_LINE: /* line # reformatted as symbol table entry.  */
5014
        /* NT uses 0x67 for a weak symbol, not C_ALIAS.  */
5015
0
      case C_ALIAS: /* Duplicate tag.  */
5016
0
#endif
5017
        /* New storage classes for TI COFF.  */
5018
#ifdef TICOFF
5019
      case C_UEXT:  /* Tentative external definition.  */
5020
#endif
5021
0
      case C_EXTLAB: /* External load time label.  */
5022
0
      default:
5023
0
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
0
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
0
     abfd, src->u.syment.n_sclass,
5027
0
     dst->symbol.section->name, dst->symbol.name);
5028
0
        ret = false;
5029
        /* Fall through.  */
5030
4
      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
4
        dst->symbol.flags = BSF_DEBUGGING;
5034
4
        dst->symbol.value = (src->u.syment.n_value);
5035
4
        break;
5036
3.69k
      }
5037
5038
3.69k
    dst->native = src;
5039
3.69k
    dst->symbol.udata.i = 0;
5040
3.69k
    dst->lineno = NULL;
5041
5042
3.69k
    this_index += (src->u.syment.n_numaux) + 1;
5043
3.69k
    dst++;
5044
3.69k
    number_of_symbols++;
5045
3.69k
  }
5046
109
    }
5047
5048
109
  obj_symbols (abfd) = cached_area;
5049
109
  obj_raw_syments (abfd) = native_symbols;
5050
5051
109
  abfd->symcount = number_of_symbols;
5052
109
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
109
  {
5055
109
    asection *p;
5056
5057
109
    p = abfd->sections;
5058
8.31k
    while (p)
5059
8.20k
      {
5060
8.20k
  if (! coff_slurp_line_table (abfd, p))
5061
0
    return false;
5062
8.20k
  p = p->next;
5063
8.20k
      }
5064
109
  }
5065
5066
109
  return ret;
5067
109
}
coff-sh.c:coff_slurp_symbol_table
Line
Count
Source
4695
166
{
4696
166
  combined_entry_type *native_symbols;
4697
166
  coff_symbol_type *cached_area;
4698
166
  unsigned int *table_ptr;
4699
166
  unsigned int number_of_symbols = 0;
4700
166
  bool ret = true;
4701
166
  size_t amt;
4702
4703
166
  if (obj_symbols (abfd))
4704
83
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
83
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
0
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
83
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
83
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
83
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
83
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
83
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
83
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
83
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
83
  if (table_ptr == NULL)
4729
0
    return false;
4730
83
  else
4731
83
    {
4732
83
      coff_symbol_type *dst = cached_area;
4733
83
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
83
      unsigned int this_index = 0;
4735
4736
3.47k
      while (this_index < last_native_index)
4737
3.39k
  {
4738
3.39k
    combined_entry_type *src = native_symbols + this_index;
4739
3.39k
    table_ptr[this_index] = number_of_symbols;
4740
4741
3.39k
    dst->symbol.the_bfd = abfd;
4742
3.39k
    BFD_ASSERT (src->is_sym);
4743
3.39k
    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
3.39k
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
3.39k
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
3.39k
                 src->u.syment.n_scnum);
4748
3.39k
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
3.39k
    dst->symbol.value = 0;
4751
3.39k
    dst->done_lineno = false;
4752
4753
3.39k
    switch (src->u.syment.n_sclass)
4754
3.39k
      {
4755
97
      case C_EXT:
4756
146
      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
146
#ifdef C_SYSTEM
4768
166
      case C_SYSTEM: /* System Wide variable.  */
4769
166
#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
166
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
166
    {
4778
96
    case COFF_SYMBOL_GLOBAL:
4779
96
      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
96
      dst->symbol.value = (src->u.syment.n_value
4786
96
               - dst->symbol.section->vma);
4787
96
#endif
4788
96
      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
96
      break;
4793
4794
3
    case COFF_SYMBOL_COMMON:
4795
3
      dst->symbol.section = bfd_com_section_ptr;
4796
3
      dst->symbol.value = src->u.syment.n_value;
4797
3
      break;
4798
4799
67
    case COFF_SYMBOL_UNDEFINED:
4800
67
      dst->symbol.section = bfd_und_section_ptr;
4801
67
      dst->symbol.value = 0;
4802
67
      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
166
    }
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
166
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
#ifdef RS6000COFF_C
4840
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
#endif
4842
166
      )
4843
49
    dst->symbol.flags |= BSF_WEAK;
4844
4845
166
        break;
4846
4847
70
      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
87
      case C_LABEL:  /* Label.  */
4858
87
        if (src->u.syment.n_scnum == N_DEBUG)
4859
0
    dst->symbol.flags = BSF_DEBUGGING;
4860
87
        else
4861
87
    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
87
        if (dst->symbol.section)
4866
87
    {
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
87
      dst->symbol.value = (src->u.syment.n_value
4873
87
               - dst->symbol.section->vma);
4874
87
#endif
4875
87
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
87
        break;
4879
4880
22
      case C_FILE: /* File name.  */
4881
22
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
23
      case C_MOS:   /* Member of structure.  */
4884
26
      case C_EOS:   /* End of structure.  */
4885
26
      case C_REGPARM: /* Register parameter.  */
4886
47
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
104
      case C_TPDEF: /* Type definition.  */
4889
117
      case C_ARG:
4890
163
      case C_AUTO: /* Automatic variable.  */
4891
171
      case C_FIELD: /* Bit field.  */
4892
180
      case C_ENTAG: /* Enumeration tag.  */
4893
187
      case C_MOE:   /* Member of enumeration.  */
4894
188
      case C_MOU:   /* Member of union.  */
4895
204
      case C_UNTAG: /* Union tag.  */
4896
223
      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
223
        dst->symbol.flags |= BSF_DEBUGGING;
4914
223
        dst->symbol.value = (src->u.syment.n_value);
4915
223
        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
5
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
6
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
31
      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
31
        dst->symbol.flags = BSF_LOCAL;
4984
31
        dst->symbol.value = (src->u.syment.n_value
4985
31
           - dst->symbol.section->vma);
4986
31
#endif
4987
31
        break;
4988
4989
13
      case C_STATLAB: /* Static load time label.  */
4990
13
        dst->symbol.value = src->u.syment.n_value;
4991
13
        dst->symbol.flags = BSF_GLOBAL;
4992
13
        break;
4993
4994
2.86k
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
2.86k
        if (src->u.syment.n_type == 0
4998
2.86k
      && src->u.syment.n_value == 0
4999
2.86k
      && src->u.syment.n_scnum == 0)
5000
2.86k
    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
0
      case C_EXTDEF: /* External definition.  */
5008
0
      case C_ULABEL: /* Undefined label.  */
5009
0
      case C_USTATIC: /* Undefined static.  */
5010
0
#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
0
      case C_LINE: /* line # reformatted as symbol table entry.  */
5014
        /* NT uses 0x67 for a weak symbol, not C_ALIAS.  */
5015
0
      case C_ALIAS: /* Duplicate tag.  */
5016
0
#endif
5017
        /* New storage classes for TI COFF.  */
5018
#ifdef TICOFF
5019
      case C_UEXT:  /* Tentative external definition.  */
5020
#endif
5021
0
      case C_EXTLAB: /* External load time label.  */
5022
0
      default:
5023
0
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
0
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
0
     abfd, src->u.syment.n_sclass,
5027
0
     dst->symbol.section->name, dst->symbol.name);
5028
0
        ret = false;
5029
        /* Fall through.  */
5030
9
      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
9
        dst->symbol.flags = BSF_DEBUGGING;
5034
9
        dst->symbol.value = (src->u.syment.n_value);
5035
9
        break;
5036
3.39k
      }
5037
5038
3.39k
    dst->native = src;
5039
3.39k
    dst->symbol.udata.i = 0;
5040
3.39k
    dst->lineno = NULL;
5041
5042
3.39k
    this_index += (src->u.syment.n_numaux) + 1;
5043
3.39k
    dst++;
5044
3.39k
    number_of_symbols++;
5045
3.39k
  }
5046
83
    }
5047
5048
83
  obj_symbols (abfd) = cached_area;
5049
83
  obj_raw_syments (abfd) = native_symbols;
5050
5051
83
  abfd->symcount = number_of_symbols;
5052
83
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
83
  {
5055
83
    asection *p;
5056
5057
83
    p = abfd->sections;
5058
2.12k
    while (p)
5059
2.04k
      {
5060
2.04k
  if (! coff_slurp_line_table (abfd, p))
5061
0
    return false;
5062
2.04k
  p = p->next;
5063
2.04k
      }
5064
83
  }
5065
5066
83
  return ret;
5067
83
}
Unexecuted instantiation: coff-stgo32.c:coff_slurp_symbol_table
coff-tic30.c:coff_slurp_symbol_table
Line
Count
Source
4695
168
{
4696
168
  combined_entry_type *native_symbols;
4697
168
  coff_symbol_type *cached_area;
4698
168
  unsigned int *table_ptr;
4699
168
  unsigned int number_of_symbols = 0;
4700
168
  bool ret = true;
4701
168
  size_t amt;
4702
4703
168
  if (obj_symbols (abfd))
4704
84
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
84
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
0
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
84
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
84
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
84
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
84
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
84
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
84
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
84
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
84
  if (table_ptr == NULL)
4729
0
    return false;
4730
84
  else
4731
84
    {
4732
84
      coff_symbol_type *dst = cached_area;
4733
84
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
84
      unsigned int this_index = 0;
4735
4736
1.66k
      while (this_index < last_native_index)
4737
1.58k
  {
4738
1.58k
    combined_entry_type *src = native_symbols + this_index;
4739
1.58k
    table_ptr[this_index] = number_of_symbols;
4740
4741
1.58k
    dst->symbol.the_bfd = abfd;
4742
1.58k
    BFD_ASSERT (src->is_sym);
4743
1.58k
    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.58k
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
1.58k
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
1.58k
                 src->u.syment.n_scnum);
4748
1.58k
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
1.58k
    dst->symbol.value = 0;
4751
1.58k
    dst->done_lineno = false;
4752
4753
1.58k
    switch (src->u.syment.n_sclass)
4754
1.58k
      {
4755
155
      case C_EXT:
4756
173
      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
173
#ifdef C_SYSTEM
4768
180
      case C_SYSTEM: /* System Wide variable.  */
4769
180
#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
180
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
180
    {
4778
164
    case COFF_SYMBOL_GLOBAL:
4779
164
      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
164
      dst->symbol.value = (src->u.syment.n_value
4786
164
               - dst->symbol.section->vma);
4787
164
#endif
4788
164
      if (ISFCN ((src->u.syment.n_type)))
4789
        /* A function ext does not go at the end of a
4790
           file.  */
4791
16
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4792
164
      break;
4793
4794
4
    case COFF_SYMBOL_COMMON:
4795
4
      dst->symbol.section = bfd_com_section_ptr;
4796
4
      dst->symbol.value = src->u.syment.n_value;
4797
4
      break;
4798
4799
12
    case COFF_SYMBOL_UNDEFINED:
4800
12
      dst->symbol.section = bfd_und_section_ptr;
4801
12
      dst->symbol.value = 0;
4802
12
      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
180
    }
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
180
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
#ifdef RS6000COFF_C
4840
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
#endif
4842
180
      )
4843
18
    dst->symbol.flags |= BSF_WEAK;
4844
4845
180
        break;
4846
4847
39
      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
68
      case C_LABEL:  /* Label.  */
4858
68
        if (src->u.syment.n_scnum == N_DEBUG)
4859
0
    dst->symbol.flags = BSF_DEBUGGING;
4860
68
        else
4861
68
    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
68
        if (dst->symbol.section)
4866
68
    {
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
68
      dst->symbol.value = (src->u.syment.n_value
4873
68
               - dst->symbol.section->vma);
4874
68
#endif
4875
68
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
68
        break;
4879
4880
12
      case C_FILE: /* File name.  */
4881
12
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
46
      case C_MOS:   /* Member of structure.  */
4884
47
      case C_EOS:   /* End of structure.  */
4885
56
      case C_REGPARM: /* Register parameter.  */
4886
89
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
105
      case C_TPDEF: /* Type definition.  */
4889
137
      case C_ARG:
4890
475
      case C_AUTO: /* Automatic variable.  */
4891
507
      case C_FIELD: /* Bit field.  */
4892
510
      case C_ENTAG: /* Enumeration tag.  */
4893
514
      case C_MOE:   /* Member of enumeration.  */
4894
533
      case C_MOU:   /* Member of union.  */
4895
562
      case C_UNTAG: /* Union tag.  */
4896
590
      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
590
        dst->symbol.flags |= BSF_DEBUGGING;
4914
590
        dst->symbol.value = (src->u.syment.n_value);
4915
590
        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
9
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
42
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
52
      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
52
        dst->symbol.flags = BSF_LOCAL;
4984
52
        dst->symbol.value = (src->u.syment.n_value
4985
52
           - dst->symbol.section->vma);
4986
52
#endif
4987
52
        break;
4988
4989
9
      case C_STATLAB: /* Static load time label.  */
4990
9
        dst->symbol.value = src->u.syment.n_value;
4991
9
        dst->symbol.flags = BSF_GLOBAL;
4992
9
        break;
4993
4994
673
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
673
        if (src->u.syment.n_type == 0
4998
673
      && src->u.syment.n_value == 0
4999
673
      && src->u.syment.n_scnum == 0)
5000
673
    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
0
      case C_EXTDEF: /* External definition.  */
5008
0
      case C_ULABEL: /* Undefined label.  */
5009
0
      case C_USTATIC: /* Undefined static.  */
5010
0
#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
0
      case C_LINE: /* line # reformatted as symbol table entry.  */
5014
        /* NT uses 0x67 for a weak symbol, not C_ALIAS.  */
5015
0
      case C_ALIAS: /* Duplicate tag.  */
5016
0
#endif
5017
        /* New storage classes for TI COFF.  */
5018
#ifdef TICOFF
5019
      case C_UEXT:  /* Tentative external definition.  */
5020
#endif
5021
0
      case C_EXTLAB: /* External load time label.  */
5022
0
      default:
5023
0
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
0
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
0
     abfd, src->u.syment.n_sclass,
5027
0
     dst->symbol.section->name, dst->symbol.name);
5028
0
        ret = false;
5029
        /* Fall through.  */
5030
8
      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
8
        dst->symbol.flags = BSF_DEBUGGING;
5034
8
        dst->symbol.value = (src->u.syment.n_value);
5035
8
        break;
5036
1.58k
      }
5037
5038
1.58k
    dst->native = src;
5039
1.58k
    dst->symbol.udata.i = 0;
5040
1.58k
    dst->lineno = NULL;
5041
5042
1.58k
    this_index += (src->u.syment.n_numaux) + 1;
5043
1.58k
    dst++;
5044
1.58k
    number_of_symbols++;
5045
1.58k
  }
5046
84
    }
5047
5048
84
  obj_symbols (abfd) = cached_area;
5049
84
  obj_raw_syments (abfd) = native_symbols;
5050
5051
84
  abfd->symcount = number_of_symbols;
5052
84
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
84
  {
5055
84
    asection *p;
5056
5057
84
    p = abfd->sections;
5058
224
    while (p)
5059
140
      {
5060
140
  if (! coff_slurp_line_table (abfd, p))
5061
0
    return false;
5062
140
  p = p->next;
5063
140
      }
5064
84
  }
5065
5066
84
  return ret;
5067
84
}
Unexecuted instantiation: coff-tic4x.c:coff_slurp_symbol_table
coff-tic54x.c:coff_slurp_symbol_table
Line
Count
Source
4695
142
{
4696
142
  combined_entry_type *native_symbols;
4697
142
  coff_symbol_type *cached_area;
4698
142
  unsigned int *table_ptr;
4699
142
  unsigned int number_of_symbols = 0;
4700
142
  bool ret = true;
4701
142
  size_t amt;
4702
4703
142
  if (obj_symbols (abfd))
4704
71
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
71
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
0
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
71
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
71
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
71
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
71
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
71
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
71
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
71
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
71
  if (table_ptr == NULL)
4729
0
    return false;
4730
71
  else
4731
71
    {
4732
71
      coff_symbol_type *dst = cached_area;
4733
71
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
71
      unsigned int this_index = 0;
4735
4736
2.23k
      while (this_index < last_native_index)
4737
2.16k
  {
4738
2.16k
    combined_entry_type *src = native_symbols + this_index;
4739
2.16k
    table_ptr[this_index] = number_of_symbols;
4740
4741
2.16k
    dst->symbol.the_bfd = abfd;
4742
2.16k
    BFD_ASSERT (src->is_sym);
4743
2.16k
    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
2.16k
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
2.16k
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
2.16k
                 src->u.syment.n_scnum);
4748
2.16k
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
2.16k
    dst->symbol.value = 0;
4751
2.16k
    dst->done_lineno = false;
4752
4753
2.16k
    switch (src->u.syment.n_sclass)
4754
2.16k
      {
4755
410
      case C_EXT:
4756
435
      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
435
#ifdef C_SYSTEM
4768
440
      case C_SYSTEM: /* System Wide variable.  */
4769
440
#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
440
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
440
    {
4778
373
    case COFF_SYMBOL_GLOBAL:
4779
373
      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
373
      dst->symbol.value = (src->u.syment.n_value
4786
373
               - dst->symbol.section->vma);
4787
373
#endif
4788
373
      if (ISFCN ((src->u.syment.n_type)))
4789
        /* A function ext does not go at the end of a
4790
           file.  */
4791
10
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4792
373
      break;
4793
4794
26
    case COFF_SYMBOL_COMMON:
4795
26
      dst->symbol.section = bfd_com_section_ptr;
4796
26
      dst->symbol.value = src->u.syment.n_value;
4797
26
      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
#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
440
    }
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
440
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
#ifdef RS6000COFF_C
4840
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
#endif
4842
440
      )
4843
25
    dst->symbol.flags |= BSF_WEAK;
4844
4845
440
        break;
4846
4847
29
      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
59
      case C_LABEL:  /* Label.  */
4858
59
        if (src->u.syment.n_scnum == N_DEBUG)
4859
0
    dst->symbol.flags = BSF_DEBUGGING;
4860
59
        else
4861
59
    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
59
        if (dst->symbol.section)
4866
59
    {
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
59
      dst->symbol.value = (src->u.syment.n_value
4873
59
               - dst->symbol.section->vma);
4874
59
#endif
4875
59
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
59
        break;
4879
4880
20
      case C_FILE: /* File name.  */
4881
20
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
31
      case C_MOS:   /* Member of structure.  */
4884
33
      case C_EOS:   /* End of structure.  */
4885
34
      case C_REGPARM: /* Register parameter.  */
4886
45
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
67
      case C_TPDEF: /* Type definition.  */
4889
74
      case C_ARG:
4890
182
      case C_AUTO: /* Automatic variable.  */
4891
223
      case C_FIELD: /* Bit field.  */
4892
248
      case C_ENTAG: /* Enumeration tag.  */
4893
257
      case C_MOE:   /* Member of enumeration.  */
4894
329
      case C_MOU:   /* Member of union.  */
4895
347
      case C_UNTAG: /* Union tag.  */
4896
386
      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
386
        dst->symbol.flags |= BSF_DEBUGGING;
4914
386
        dst->symbol.value = (src->u.syment.n_value);
4915
386
        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
13
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
13
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
25
      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
25
        dst->symbol.flags = BSF_LOCAL;
4984
25
        dst->symbol.value = (src->u.syment.n_value
4985
25
           - dst->symbol.section->vma);
4986
25
#endif
4987
25
        break;
4988
4989
15
      case C_STATLAB: /* Static load time label.  */
4990
15
        dst->symbol.value = src->u.syment.n_value;
4991
15
        dst->symbol.flags = BSF_GLOBAL;
4992
15
        break;
4993
4994
1.24k
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
1.24k
        if (src->u.syment.n_type == 0
4998
1.24k
      && src->u.syment.n_value == 0
4999
1.24k
      && src->u.syment.n_scnum == 0)
5000
1.24k
    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
0
      case C_EXTDEF: /* External definition.  */
5008
0
      case C_ULABEL: /* Undefined label.  */
5009
0
      case C_USTATIC: /* Undefined static.  */
5010
0
#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
0
      case C_LINE: /* line # reformatted as symbol table entry.  */
5014
        /* NT uses 0x67 for a weak symbol, not C_ALIAS.  */
5015
0
      case C_ALIAS: /* Duplicate tag.  */
5016
0
#endif
5017
        /* New storage classes for TI COFF.  */
5018
0
#ifdef TICOFF
5019
0
      case C_UEXT: /* Tentative external definition.  */
5020
0
#endif
5021
0
      case C_EXTLAB: /* External load time label.  */
5022
0
      default:
5023
0
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
0
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
0
     abfd, src->u.syment.n_sclass,
5027
0
     dst->symbol.section->name, dst->symbol.name);
5028
0
        ret = false;
5029
        /* Fall through.  */
5030
3
      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
3
        dst->symbol.flags = BSF_DEBUGGING;
5034
3
        dst->symbol.value = (src->u.syment.n_value);
5035
3
        break;
5036
2.16k
      }
5037
5038
2.16k
    dst->native = src;
5039
2.16k
    dst->symbol.udata.i = 0;
5040
2.16k
    dst->lineno = NULL;
5041
5042
2.16k
    this_index += (src->u.syment.n_numaux) + 1;
5043
2.16k
    dst++;
5044
2.16k
    number_of_symbols++;
5045
2.16k
  }
5046
71
    }
5047
5048
71
  obj_symbols (abfd) = cached_area;
5049
71
  obj_raw_syments (abfd) = native_symbols;
5050
5051
71
  abfd->symcount = number_of_symbols;
5052
71
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
71
  {
5055
71
    asection *p;
5056
5057
71
    p = abfd->sections;
5058
737
    while (p)
5059
666
      {
5060
666
  if (! coff_slurp_line_table (abfd, p))
5061
0
    return false;
5062
666
  p = p->next;
5063
666
      }
5064
71
  }
5065
5066
71
  return ret;
5067
71
}
coff-z80.c:coff_slurp_symbol_table
Line
Count
Source
4695
154
{
4696
154
  combined_entry_type *native_symbols;
4697
154
  coff_symbol_type *cached_area;
4698
154
  unsigned int *table_ptr;
4699
154
  unsigned int number_of_symbols = 0;
4700
154
  bool ret = true;
4701
154
  size_t amt;
4702
4703
154
  if (obj_symbols (abfd))
4704
77
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
77
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
0
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
77
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
77
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
77
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
77
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
77
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
77
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
77
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
77
  if (table_ptr == NULL)
4729
0
    return false;
4730
77
  else
4731
77
    {
4732
77
      coff_symbol_type *dst = cached_area;
4733
77
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
77
      unsigned int this_index = 0;
4735
4736
2.60k
      while (this_index < last_native_index)
4737
2.53k
  {
4738
2.53k
    combined_entry_type *src = native_symbols + this_index;
4739
2.53k
    table_ptr[this_index] = number_of_symbols;
4740
4741
2.53k
    dst->symbol.the_bfd = abfd;
4742
2.53k
    BFD_ASSERT (src->is_sym);
4743
2.53k
    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
2.53k
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
2.53k
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
2.53k
                 src->u.syment.n_scnum);
4748
2.53k
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
2.53k
    dst->symbol.value = 0;
4751
2.53k
    dst->done_lineno = false;
4752
4753
2.53k
    switch (src->u.syment.n_sclass)
4754
2.53k
      {
4755
357
      case C_EXT:
4756
368
      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
368
#ifdef C_SYSTEM
4768
377
      case C_SYSTEM: /* System Wide variable.  */
4769
377
#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
377
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
377
    {
4778
349
    case COFF_SYMBOL_GLOBAL:
4779
349
      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
349
      dst->symbol.value = (src->u.syment.n_value
4786
349
               - dst->symbol.section->vma);
4787
349
#endif
4788
349
      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
349
      break;
4793
4794
10
    case COFF_SYMBOL_COMMON:
4795
10
      dst->symbol.section = bfd_com_section_ptr;
4796
10
      dst->symbol.value = src->u.syment.n_value;
4797
10
      break;
4798
4799
18
    case COFF_SYMBOL_UNDEFINED:
4800
18
      dst->symbol.section = bfd_und_section_ptr;
4801
18
      dst->symbol.value = 0;
4802
18
      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
377
    }
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
377
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
#ifdef RS6000COFF_C
4840
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
#endif
4842
377
      )
4843
11
    dst->symbol.flags |= BSF_WEAK;
4844
4845
377
        break;
4846
4847
67
      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
130
      case C_LABEL:  /* Label.  */
4858
130
        if (src->u.syment.n_scnum == N_DEBUG)
4859
0
    dst->symbol.flags = BSF_DEBUGGING;
4860
130
        else
4861
130
    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
130
        if (dst->symbol.section)
4866
130
    {
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
130
      dst->symbol.value = (src->u.syment.n_value
4873
130
               - dst->symbol.section->vma);
4874
130
#endif
4875
130
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
130
        break;
4879
4880
29
      case C_FILE: /* File name.  */
4881
29
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
57
      case C_MOS:   /* Member of structure.  */
4884
60
      case C_EOS:   /* End of structure.  */
4885
97
      case C_REGPARM: /* Register parameter.  */
4886
150
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
153
      case C_TPDEF: /* Type definition.  */
4889
181
      case C_ARG:
4890
977
      case C_AUTO: /* Automatic variable.  */
4891
980
      case C_FIELD: /* Bit field.  */
4892
994
      case C_ENTAG: /* Enumeration tag.  */
4893
1.01k
      case C_MOE:   /* Member of enumeration.  */
4894
1.05k
      case C_MOU:   /* Member of union.  */
4895
1.05k
      case C_UNTAG: /* Union tag.  */
4896
1.09k
      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.09k
        dst->symbol.flags |= BSF_DEBUGGING;
4914
1.09k
        dst->symbol.value = (src->u.syment.n_value);
4915
1.09k
        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
7
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
8
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
17
      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
17
        dst->symbol.flags = BSF_LOCAL;
4984
17
        dst->symbol.value = (src->u.syment.n_value
4985
17
           - dst->symbol.section->vma);
4986
17
#endif
4987
17
        break;
4988
4989
26
      case C_STATLAB: /* Static load time label.  */
4990
26
        dst->symbol.value = src->u.syment.n_value;
4991
26
        dst->symbol.flags = BSF_GLOBAL;
4992
26
        break;
4993
4994
873
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
873
        if (src->u.syment.n_type == 0
4998
873
      && src->u.syment.n_value == 0
4999
873
      && src->u.syment.n_scnum == 0)
5000
873
    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
0
      case C_EXTDEF: /* External definition.  */
5008
0
      case C_ULABEL: /* Undefined label.  */
5009
0
      case C_USTATIC: /* Undefined static.  */
5010
0
#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
0
      case C_LINE: /* line # reformatted as symbol table entry.  */
5014
        /* NT uses 0x67 for a weak symbol, not C_ALIAS.  */
5015
0
      case C_ALIAS: /* Duplicate tag.  */
5016
0
#endif
5017
        /* New storage classes for TI COFF.  */
5018
#ifdef TICOFF
5019
      case C_UEXT:  /* Tentative external definition.  */
5020
#endif
5021
0
      case C_EXTLAB: /* External load time label.  */
5022
0
      default:
5023
0
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
0
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
0
     abfd, src->u.syment.n_sclass,
5027
0
     dst->symbol.section->name, dst->symbol.name);
5028
0
        ret = false;
5029
        /* Fall through.  */
5030
11
      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
11
        dst->symbol.flags = BSF_DEBUGGING;
5034
11
        dst->symbol.value = (src->u.syment.n_value);
5035
11
        break;
5036
2.53k
      }
5037
5038
2.53k
    dst->native = src;
5039
2.53k
    dst->symbol.udata.i = 0;
5040
2.53k
    dst->lineno = NULL;
5041
5042
2.53k
    this_index += (src->u.syment.n_numaux) + 1;
5043
2.53k
    dst++;
5044
2.53k
    number_of_symbols++;
5045
2.53k
  }
5046
77
    }
5047
5048
77
  obj_symbols (abfd) = cached_area;
5049
77
  obj_raw_syments (abfd) = native_symbols;
5050
5051
77
  abfd->symcount = number_of_symbols;
5052
77
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
77
  {
5055
77
    asection *p;
5056
5057
77
    p = abfd->sections;
5058
362
    while (p)
5059
285
      {
5060
285
  if (! coff_slurp_line_table (abfd, p))
5061
0
    return false;
5062
285
  p = p->next;
5063
285
      }
5064
77
  }
5065
5066
77
  return ret;
5067
77
}
coff-z8k.c:coff_slurp_symbol_table
Line
Count
Source
4695
158
{
4696
158
  combined_entry_type *native_symbols;
4697
158
  coff_symbol_type *cached_area;
4698
158
  unsigned int *table_ptr;
4699
158
  unsigned int number_of_symbols = 0;
4700
158
  bool ret = true;
4701
158
  size_t amt;
4702
4703
158
  if (obj_symbols (abfd))
4704
79
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
79
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
0
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
79
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
79
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
79
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
79
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
79
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
79
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
79
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
79
  if (table_ptr == NULL)
4729
0
    return false;
4730
79
  else
4731
79
    {
4732
79
      coff_symbol_type *dst = cached_area;
4733
79
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
79
      unsigned int this_index = 0;
4735
4736
1.13k
      while (this_index < last_native_index)
4737
1.05k
  {
4738
1.05k
    combined_entry_type *src = native_symbols + this_index;
4739
1.05k
    table_ptr[this_index] = number_of_symbols;
4740
4741
1.05k
    dst->symbol.the_bfd = abfd;
4742
1.05k
    BFD_ASSERT (src->is_sym);
4743
1.05k
    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.05k
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
1.05k
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
1.05k
                 src->u.syment.n_scnum);
4748
1.05k
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
1.05k
    dst->symbol.value = 0;
4751
1.05k
    dst->done_lineno = false;
4752
4753
1.05k
    switch (src->u.syment.n_sclass)
4754
1.05k
      {
4755
24
      case C_EXT:
4756
38
      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
38
#ifdef C_SYSTEM
4768
70
      case C_SYSTEM: /* System Wide variable.  */
4769
70
#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
70
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
70
    {
4778
52
    case COFF_SYMBOL_GLOBAL:
4779
52
      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
52
      dst->symbol.value = (src->u.syment.n_value
4786
52
               - dst->symbol.section->vma);
4787
52
#endif
4788
52
      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
52
      break;
4793
4794
5
    case COFF_SYMBOL_COMMON:
4795
5
      dst->symbol.section = bfd_com_section_ptr;
4796
5
      dst->symbol.value = src->u.syment.n_value;
4797
5
      break;
4798
4799
13
    case COFF_SYMBOL_UNDEFINED:
4800
13
      dst->symbol.section = bfd_und_section_ptr;
4801
13
      dst->symbol.value = 0;
4802
13
      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
70
    }
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
70
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
#ifdef RS6000COFF_C
4840
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
#endif
4842
70
      )
4843
14
    dst->symbol.flags |= BSF_WEAK;
4844
4845
70
        break;
4846
4847
40
      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
72
      case C_LABEL:  /* Label.  */
4858
72
        if (src->u.syment.n_scnum == N_DEBUG)
4859
0
    dst->symbol.flags = BSF_DEBUGGING;
4860
72
        else
4861
72
    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
72
        if (dst->symbol.section)
4866
72
    {
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
72
      dst->symbol.value = (src->u.syment.n_value
4873
72
               - dst->symbol.section->vma);
4874
72
#endif
4875
72
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
72
        break;
4879
4880
27
      case C_FILE: /* File name.  */
4881
27
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
46
      case C_MOS:   /* Member of structure.  */
4884
48
      case C_EOS:   /* End of structure.  */
4885
51
      case C_REGPARM: /* Register parameter.  */
4886
82
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
101
      case C_TPDEF: /* Type definition.  */
4889
119
      case C_ARG:
4890
279
      case C_AUTO: /* Automatic variable.  */
4891
280
      case C_FIELD: /* Bit field.  */
4892
292
      case C_ENTAG: /* Enumeration tag.  */
4893
300
      case C_MOE:   /* Member of enumeration.  */
4894
301
      case C_MOU:   /* Member of union.  */
4895
314
      case C_UNTAG: /* Union tag.  */
4896
328
      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
328
        dst->symbol.flags |= BSF_DEBUGGING;
4914
328
        dst->symbol.value = (src->u.syment.n_value);
4915
328
        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
5
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
5
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
11
      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
11
        dst->symbol.flags = BSF_LOCAL;
4984
11
        dst->symbol.value = (src->u.syment.n_value
4985
11
           - dst->symbol.section->vma);
4986
11
#endif
4987
11
        break;
4988
4989
16
      case C_STATLAB: /* Static load time label.  */
4990
16
        dst->symbol.value = src->u.syment.n_value;
4991
16
        dst->symbol.flags = BSF_GLOBAL;
4992
16
        break;
4993
4994
549
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
549
        if (src->u.syment.n_type == 0
4998
549
      && src->u.syment.n_value == 0
4999
549
      && src->u.syment.n_scnum == 0)
5000
549
    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
0
      case C_EXTDEF: /* External definition.  */
5008
0
      case C_ULABEL: /* Undefined label.  */
5009
0
      case C_USTATIC: /* Undefined static.  */
5010
0
#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
0
      case C_LINE: /* line # reformatted as symbol table entry.  */
5014
        /* NT uses 0x67 for a weak symbol, not C_ALIAS.  */
5015
0
      case C_ALIAS: /* Duplicate tag.  */
5016
0
#endif
5017
        /* New storage classes for TI COFF.  */
5018
#ifdef TICOFF
5019
      case C_UEXT:  /* Tentative external definition.  */
5020
#endif
5021
0
      case C_EXTLAB: /* External load time label.  */
5022
0
      default:
5023
0
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
0
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
0
     abfd, src->u.syment.n_sclass,
5027
0
     dst->symbol.section->name, dst->symbol.name);
5028
0
        ret = false;
5029
        /* Fall through.  */
5030
9
      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
9
        dst->symbol.flags = BSF_DEBUGGING;
5034
9
        dst->symbol.value = (src->u.syment.n_value);
5035
9
        break;
5036
1.05k
      }
5037
5038
1.05k
    dst->native = src;
5039
1.05k
    dst->symbol.udata.i = 0;
5040
1.05k
    dst->lineno = NULL;
5041
5042
1.05k
    this_index += (src->u.syment.n_numaux) + 1;
5043
1.05k
    dst++;
5044
1.05k
    number_of_symbols++;
5045
1.05k
  }
5046
79
    }
5047
5048
79
  obj_symbols (abfd) = cached_area;
5049
79
  obj_raw_syments (abfd) = native_symbols;
5050
5051
79
  abfd->symcount = number_of_symbols;
5052
79
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
79
  {
5055
79
    asection *p;
5056
5057
79
    p = abfd->sections;
5058
554
    while (p)
5059
475
      {
5060
475
  if (! coff_slurp_line_table (abfd, p))
5061
0
    return false;
5062
475
  p = p->next;
5063
475
      }
5064
79
  }
5065
5066
79
  return ret;
5067
79
}
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
110
{
4696
110
  combined_entry_type *native_symbols;
4697
110
  coff_symbol_type *cached_area;
4698
110
  unsigned int *table_ptr;
4699
110
  unsigned int number_of_symbols = 0;
4700
110
  bool ret = true;
4701
110
  size_t amt;
4702
4703
110
  if (obj_symbols (abfd))
4704
55
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
55
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
0
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
55
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
55
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
55
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
55
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
55
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
55
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
55
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
55
  if (table_ptr == NULL)
4729
0
    return false;
4730
55
  else
4731
55
    {
4732
55
      coff_symbol_type *dst = cached_area;
4733
55
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
55
      unsigned int this_index = 0;
4735
4736
1.64k
      while (this_index < last_native_index)
4737
1.58k
  {
4738
1.58k
    combined_entry_type *src = native_symbols + this_index;
4739
1.58k
    table_ptr[this_index] = number_of_symbols;
4740
4741
1.58k
    dst->symbol.the_bfd = abfd;
4742
1.58k
    BFD_ASSERT (src->is_sym);
4743
1.58k
    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.58k
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
1.58k
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
1.58k
                 src->u.syment.n_scnum);
4748
1.58k
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
1.58k
    dst->symbol.value = 0;
4751
1.58k
    dst->done_lineno = false;
4752
4753
1.58k
    switch (src->u.syment.n_sclass)
4754
1.58k
      {
4755
146
      case C_EXT:
4756
150
      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
150
#ifdef C_SYSTEM
4768
156
      case C_SYSTEM: /* System Wide variable.  */
4769
156
#endif
4770
156
#ifdef COFF_WITH_PE
4771
      /* In PE, 0x68 (104) denotes a section symbol.  */
4772
159
      case C_SECTION:
4773
      /* In PE, 0x69 (105) denotes a weak external symbol.  */
4774
167
      case C_NT_WEAK:
4775
167
#endif
4776
167
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
167
    {
4778
133
    case COFF_SYMBOL_GLOBAL:
4779
133
      dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
4780
133
#if defined COFF_WITH_PE
4781
      /* PE sets the symbol to a value relative to the
4782
         start of the section.  */
4783
133
      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
133
      if (ISFCN ((src->u.syment.n_type)))
4789
        /* A function ext does not go at the end of a
4790
           file.  */
4791
12
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4792
133
      break;
4793
4794
18
    case COFF_SYMBOL_COMMON:
4795
18
      dst->symbol.section = bfd_com_section_ptr;
4796
18
      dst->symbol.value = src->u.syment.n_value;
4797
18
      break;
4798
4799
16
    case COFF_SYMBOL_UNDEFINED:
4800
16
      dst->symbol.section = bfd_und_section_ptr;
4801
16
      dst->symbol.value = 0;
4802
16
      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
167
    }
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
167
#ifdef COFF_WITH_PE
4831
167
        if (src->u.syment.n_sclass == C_NT_WEAK)
4832
8
    dst->symbol.flags |= BSF_WEAK;
4833
4834
167
        if (src->u.syment.n_sclass == C_SECTION
4835
167
      && src->u.syment.n_scnum > 0)
4836
0
    dst->symbol.flags = BSF_LOCAL;
4837
167
#endif
4838
167
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
#ifdef RS6000COFF_C
4840
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
#endif
4842
167
      )
4843
4
    dst->symbol.flags |= BSF_WEAK;
4844
4845
167
        break;
4846
4847
8
      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
50
      case C_LABEL:  /* Label.  */
4858
50
        if (src->u.syment.n_scnum == N_DEBUG)
4859
0
    dst->symbol.flags = BSF_DEBUGGING;
4860
50
        else
4861
50
    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
50
        if (dst->symbol.section)
4866
50
    {
4867
50
#if defined COFF_WITH_PE
4868
      /* PE sets the symbol to a value relative to the
4869
         start of the section.  */
4870
50
      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
50
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
50
        break;
4879
4880
13
      case C_FILE: /* File name.  */
4881
13
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
23
      case C_MOS:   /* Member of structure.  */
4884
24
      case C_EOS:   /* End of structure.  */
4885
30
      case C_REGPARM: /* Register parameter.  */
4886
42
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
49
      case C_TPDEF: /* Type definition.  */
4889
62
      case C_ARG:
4890
120
      case C_AUTO: /* Automatic variable.  */
4891
121
      case C_FIELD: /* Bit field.  */
4892
160
      case C_ENTAG: /* Enumeration tag.  */
4893
165
      case C_MOE:   /* Member of enumeration.  */
4894
175
      case C_MOU:   /* Member of union.  */
4895
184
      case C_UNTAG: /* Union tag.  */
4896
194
      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
194
        dst->symbol.flags |= BSF_DEBUGGING;
4914
194
        dst->symbol.value = (src->u.syment.n_value);
4915
194
        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
0
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
1
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
17
      case C_EFCN: /* Physical end of function.  */
4968
17
#if defined COFF_WITH_PE
4969
        /* PE sets the symbol to a value relative to the start
4970
     of the section.  */
4971
17
        dst->symbol.value = src->u.syment.n_value;
4972
17
        if (strcmp (dst->symbol.name, ".bf") != 0)
4973
17
    {
4974
      /* PE uses funny values for .ef and .lf; don't
4975
         relocate them.  */
4976
17
      dst->symbol.flags = BSF_DEBUGGING;
4977
17
    }
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
17
        break;
4988
4989
1
      case C_STATLAB: /* Static load time label.  */
4990
1
        dst->symbol.value = src->u.syment.n_value;
4991
1
        dst->symbol.flags = BSF_GLOBAL;
4992
1
        break;
4993
4994
1.15k
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
1.15k
        if (src->u.syment.n_type == 0
4998
1.15k
      && src->u.syment.n_value == 0
4999
1.15k
      && src->u.syment.n_scnum == 0)
5000
1.15k
    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
0
      case C_EXTDEF: /* External definition.  */
5008
0
      case C_ULABEL: /* Undefined label.  */
5009
0
      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
0
      case C_EXTLAB: /* External load time label.  */
5022
0
      default:
5023
0
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
0
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
0
     abfd, src->u.syment.n_sclass,
5027
0
     dst->symbol.section->name, dst->symbol.name);
5028
0
        ret = false;
5029
        /* Fall through.  */
5030
1
      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
1
        dst->symbol.flags = BSF_DEBUGGING;
5034
1
        dst->symbol.value = (src->u.syment.n_value);
5035
1
        break;
5036
1.58k
      }
5037
5038
1.58k
    dst->native = src;
5039
1.58k
    dst->symbol.udata.i = 0;
5040
1.58k
    dst->lineno = NULL;
5041
5042
1.58k
    this_index += (src->u.syment.n_numaux) + 1;
5043
1.58k
    dst++;
5044
1.58k
    number_of_symbols++;
5045
1.58k
  }
5046
55
    }
5047
5048
55
  obj_symbols (abfd) = cached_area;
5049
55
  obj_raw_syments (abfd) = native_symbols;
5050
5051
55
  abfd->symcount = number_of_symbols;
5052
55
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
55
  {
5055
55
    asection *p;
5056
5057
55
    p = abfd->sections;
5058
797
    while (p)
5059
742
      {
5060
742
  if (! coff_slurp_line_table (abfd, p))
5061
0
    return false;
5062
742
  p = p->next;
5063
742
      }
5064
55
  }
5065
5066
55
  return ret;
5067
55
}
pe-mcore.c:coff_slurp_symbol_table
Line
Count
Source
4695
148
{
4696
148
  combined_entry_type *native_symbols;
4697
148
  coff_symbol_type *cached_area;
4698
148
  unsigned int *table_ptr;
4699
148
  unsigned int number_of_symbols = 0;
4700
148
  bool ret = true;
4701
148
  size_t amt;
4702
4703
148
  if (obj_symbols (abfd))
4704
74
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
74
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
0
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
74
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
74
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
74
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
74
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
74
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
74
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
74
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
74
  if (table_ptr == NULL)
4729
0
    return false;
4730
74
  else
4731
74
    {
4732
74
      coff_symbol_type *dst = cached_area;
4733
74
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
74
      unsigned int this_index = 0;
4735
4736
17.3k
      while (this_index < last_native_index)
4737
17.3k
  {
4738
17.3k
    combined_entry_type *src = native_symbols + this_index;
4739
17.3k
    table_ptr[this_index] = number_of_symbols;
4740
4741
17.3k
    dst->symbol.the_bfd = abfd;
4742
17.3k
    BFD_ASSERT (src->is_sym);
4743
17.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
17.3k
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
17.3k
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
17.3k
                 src->u.syment.n_scnum);
4748
17.3k
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
17.3k
    dst->symbol.value = 0;
4751
17.3k
    dst->done_lineno = false;
4752
4753
17.3k
    switch (src->u.syment.n_sclass)
4754
17.3k
      {
4755
30
      case C_EXT:
4756
43
      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
43
#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
252
      case C_SECTION:
4773
      /* In PE, 0x69 (105) denotes a weak external symbol.  */
4774
319
      case C_NT_WEAK:
4775
319
#endif
4776
319
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
319
    {
4778
297
    case COFF_SYMBOL_GLOBAL:
4779
297
      dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
4780
297
#if defined COFF_WITH_PE
4781
      /* PE sets the symbol to a value relative to the
4782
         start of the section.  */
4783
297
      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
297
      if (ISFCN ((src->u.syment.n_type)))
4789
        /* A function ext does not go at the end of a
4790
           file.  */
4791
71
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4792
297
      break;
4793
4794
5
    case COFF_SYMBOL_COMMON:
4795
5
      dst->symbol.section = bfd_com_section_ptr;
4796
5
      dst->symbol.value = src->u.syment.n_value;
4797
5
      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
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
319
    }
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
319
#ifdef COFF_WITH_PE
4831
319
        if (src->u.syment.n_sclass == C_NT_WEAK)
4832
67
    dst->symbol.flags |= BSF_WEAK;
4833
4834
319
        if (src->u.syment.n_sclass == C_SECTION
4835
319
      && src->u.syment.n_scnum > 0)
4836
0
    dst->symbol.flags = BSF_LOCAL;
4837
319
#endif
4838
319
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
#ifdef RS6000COFF_C
4840
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
#endif
4842
319
      )
4843
13
    dst->symbol.flags |= BSF_WEAK;
4844
4845
319
        break;
4846
4847
79
      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.12k
      case C_LABEL:  /* Label.  */
4858
1.12k
        if (src->u.syment.n_scnum == N_DEBUG)
4859
0
    dst->symbol.flags = BSF_DEBUGGING;
4860
1.12k
        else
4861
1.12k
    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.12k
        if (dst->symbol.section)
4866
1.12k
    {
4867
1.12k
#if defined COFF_WITH_PE
4868
      /* PE sets the symbol to a value relative to the
4869
         start of the section.  */
4870
1.12k
      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.12k
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
1.12k
        break;
4879
4880
45
      case C_FILE: /* File name.  */
4881
45
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
98
      case C_MOS:   /* Member of structure.  */
4884
175
      case C_EOS:   /* End of structure.  */
4885
231
      case C_REGPARM: /* Register parameter.  */
4886
1.90k
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
2.04k
      case C_TPDEF: /* Type definition.  */
4889
2.11k
      case C_ARG:
4890
6.06k
      case C_AUTO: /* Automatic variable.  */
4891
6.07k
      case C_FIELD: /* Bit field.  */
4892
6.08k
      case C_ENTAG: /* Enumeration tag.  */
4893
6.13k
      case C_MOE:   /* Member of enumeration.  */
4894
7.24k
      case C_MOU:   /* Member of union.  */
4895
7.58k
      case C_UNTAG: /* Union tag.  */
4896
7.79k
      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.79k
        dst->symbol.flags |= BSF_DEBUGGING;
4914
7.79k
        dst->symbol.value = (src->u.syment.n_value);
4915
7.79k
        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
3
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
9
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
49
      case C_EFCN: /* Physical end of function.  */
4968
49
#if defined COFF_WITH_PE
4969
        /* PE sets the symbol to a value relative to the start
4970
     of the section.  */
4971
49
        dst->symbol.value = src->u.syment.n_value;
4972
49
        if (strcmp (dst->symbol.name, ".bf") != 0)
4973
49
    {
4974
      /* PE uses funny values for .ef and .lf; don't
4975
         relocate them.  */
4976
49
      dst->symbol.flags = BSF_DEBUGGING;
4977
49
    }
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
49
        break;
4988
4989
10
      case C_STATLAB: /* Static load time label.  */
4990
10
        dst->symbol.value = src->u.syment.n_value;
4991
10
        dst->symbol.flags = BSF_GLOBAL;
4992
10
        break;
4993
4994
8.00k
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
8.00k
        if (src->u.syment.n_type == 0
4998
8.00k
      && src->u.syment.n_value == 0
4999
8.00k
      && src->u.syment.n_scnum == 0)
5000
8.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
0
      case C_EXTDEF: /* External definition.  */
5008
0
      case C_ULABEL: /* Undefined label.  */
5009
0
      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
0
      case C_EXTLAB: /* External load time label.  */
5022
0
      default:
5023
0
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
0
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
0
     abfd, src->u.syment.n_sclass,
5027
0
     dst->symbol.section->name, dst->symbol.name);
5028
0
        ret = false;
5029
        /* Fall through.  */
5030
7
      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
7
        dst->symbol.flags = BSF_DEBUGGING;
5034
7
        dst->symbol.value = (src->u.syment.n_value);
5035
7
        break;
5036
17.3k
      }
5037
5038
17.3k
    dst->native = src;
5039
17.3k
    dst->symbol.udata.i = 0;
5040
17.3k
    dst->lineno = NULL;
5041
5042
17.3k
    this_index += (src->u.syment.n_numaux) + 1;
5043
17.3k
    dst++;
5044
17.3k
    number_of_symbols++;
5045
17.3k
  }
5046
74
    }
5047
5048
74
  obj_symbols (abfd) = cached_area;
5049
74
  obj_raw_syments (abfd) = native_symbols;
5050
5051
74
  abfd->symcount = number_of_symbols;
5052
74
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
74
  {
5055
74
    asection *p;
5056
5057
74
    p = abfd->sections;
5058
539
    while (p)
5059
465
      {
5060
465
  if (! coff_slurp_line_table (abfd, p))
5061
0
    return false;
5062
465
  p = p->next;
5063
465
      }
5064
74
  }
5065
5066
74
  return ret;
5067
74
}
pe-sh.c:coff_slurp_symbol_table
Line
Count
Source
4695
128
{
4696
128
  combined_entry_type *native_symbols;
4697
128
  coff_symbol_type *cached_area;
4698
128
  unsigned int *table_ptr;
4699
128
  unsigned int number_of_symbols = 0;
4700
128
  bool ret = true;
4701
128
  size_t amt;
4702
4703
128
  if (obj_symbols (abfd))
4704
64
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
64
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
0
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
64
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
64
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
64
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
64
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
64
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
64
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
64
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
64
  if (table_ptr == NULL)
4729
0
    return false;
4730
64
  else
4731
64
    {
4732
64
      coff_symbol_type *dst = cached_area;
4733
64
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
64
      unsigned int this_index = 0;
4735
4736
2.02k
      while (this_index < last_native_index)
4737
1.95k
  {
4738
1.95k
    combined_entry_type *src = native_symbols + this_index;
4739
1.95k
    table_ptr[this_index] = number_of_symbols;
4740
4741
1.95k
    dst->symbol.the_bfd = abfd;
4742
1.95k
    BFD_ASSERT (src->is_sym);
4743
1.95k
    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.95k
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
1.95k
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
1.95k
                 src->u.syment.n_scnum);
4748
1.95k
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
1.95k
    dst->symbol.value = 0;
4751
1.95k
    dst->done_lineno = false;
4752
4753
1.95k
    switch (src->u.syment.n_sclass)
4754
1.95k
      {
4755
348
      case C_EXT:
4756
357
      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
357
#ifdef C_SYSTEM
4768
360
      case C_SYSTEM: /* System Wide variable.  */
4769
360
#endif
4770
360
#ifdef COFF_WITH_PE
4771
      /* In PE, 0x68 (104) denotes a section symbol.  */
4772
360
      case C_SECTION:
4773
      /* In PE, 0x69 (105) denotes a weak external symbol.  */
4774
364
      case C_NT_WEAK:
4775
364
#endif
4776
364
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
364
    {
4778
334
    case COFF_SYMBOL_GLOBAL:
4779
334
      dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
4780
334
#if defined COFF_WITH_PE
4781
      /* PE sets the symbol to a value relative to the
4782
         start of the section.  */
4783
334
      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
334
      if (ISFCN ((src->u.syment.n_type)))
4789
        /* A function ext does not go at the end of a
4790
           file.  */
4791
11
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4792
334
      break;
4793
4794
8
    case COFF_SYMBOL_COMMON:
4795
8
      dst->symbol.section = bfd_com_section_ptr;
4796
8
      dst->symbol.value = src->u.syment.n_value;
4797
8
      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
364
    }
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
364
#ifdef COFF_WITH_PE
4831
364
        if (src->u.syment.n_sclass == C_NT_WEAK)
4832
4
    dst->symbol.flags |= BSF_WEAK;
4833
4834
364
        if (src->u.syment.n_sclass == C_SECTION
4835
364
      && src->u.syment.n_scnum > 0)
4836
0
    dst->symbol.flags = BSF_LOCAL;
4837
364
#endif
4838
364
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
#ifdef RS6000COFF_C
4840
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
#endif
4842
364
      )
4843
9
    dst->symbol.flags |= BSF_WEAK;
4844
4845
364
        break;
4846
4847
29
      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
45
      case C_LABEL:  /* Label.  */
4858
45
        if (src->u.syment.n_scnum == N_DEBUG)
4859
0
    dst->symbol.flags = BSF_DEBUGGING;
4860
45
        else
4861
45
    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
45
        if (dst->symbol.section)
4866
45
    {
4867
45
#if defined COFF_WITH_PE
4868
      /* PE sets the symbol to a value relative to the
4869
         start of the section.  */
4870
45
      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
45
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
45
        break;
4879
4880
15
      case C_FILE: /* File name.  */
4881
15
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
17
      case C_MOS:   /* Member of structure.  */
4884
18
      case C_EOS:   /* End of structure.  */
4885
26
      case C_REGPARM: /* Register parameter.  */
4886
26
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
50
      case C_TPDEF: /* Type definition.  */
4889
52
      case C_ARG:
4890
108
      case C_AUTO: /* Automatic variable.  */
4891
113
      case C_FIELD: /* Bit field.  */
4892
129
      case C_ENTAG: /* Enumeration tag.  */
4893
135
      case C_MOE:   /* Member of enumeration.  */
4894
142
      case C_MOU:   /* Member of union.  */
4895
146
      case C_UNTAG: /* Union tag.  */
4896
152
      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
152
        dst->symbol.flags |= BSF_DEBUGGING;
4914
152
        dst->symbol.value = (src->u.syment.n_value);
4915
152
        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
1
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
3
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
27
      case C_EFCN: /* Physical end of function.  */
4968
27
#if defined COFF_WITH_PE
4969
        /* PE sets the symbol to a value relative to the start
4970
     of the section.  */
4971
27
        dst->symbol.value = src->u.syment.n_value;
4972
27
        if (strcmp (dst->symbol.name, ".bf") != 0)
4973
27
    {
4974
      /* PE uses funny values for .ef and .lf; don't
4975
         relocate them.  */
4976
27
      dst->symbol.flags = BSF_DEBUGGING;
4977
27
    }
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
27
        break;
4988
4989
13
      case C_STATLAB: /* Static load time label.  */
4990
13
        dst->symbol.value = src->u.syment.n_value;
4991
13
        dst->symbol.flags = BSF_GLOBAL;
4992
13
        break;
4993
4994
1.34k
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
1.34k
        if (src->u.syment.n_type == 0
4998
1.34k
      && src->u.syment.n_value == 0
4999
1.34k
      && src->u.syment.n_scnum == 0)
5000
1.34k
    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
0
      case C_EXTDEF: /* External definition.  */
5008
0
      case C_ULABEL: /* Undefined label.  */
5009
0
      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
0
      case C_EXTLAB: /* External load time label.  */
5022
0
      default:
5023
0
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
0
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
0
     abfd, src->u.syment.n_sclass,
5027
0
     dst->symbol.section->name, dst->symbol.name);
5028
0
        ret = false;
5029
        /* Fall through.  */
5030
10
      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
10
        dst->symbol.flags = BSF_DEBUGGING;
5034
10
        dst->symbol.value = (src->u.syment.n_value);
5035
10
        break;
5036
1.95k
      }
5037
5038
1.95k
    dst->native = src;
5039
1.95k
    dst->symbol.udata.i = 0;
5040
1.95k
    dst->lineno = NULL;
5041
5042
1.95k
    this_index += (src->u.syment.n_numaux) + 1;
5043
1.95k
    dst++;
5044
1.95k
    number_of_symbols++;
5045
1.95k
  }
5046
64
    }
5047
5048
64
  obj_symbols (abfd) = cached_area;
5049
64
  obj_raw_syments (abfd) = native_symbols;
5050
5051
64
  abfd->symcount = number_of_symbols;
5052
64
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
64
  {
5055
64
    asection *p;
5056
5057
64
    p = abfd->sections;
5058
899
    while (p)
5059
835
      {
5060
835
  if (! coff_slurp_line_table (abfd, p))
5061
0
    return false;
5062
835
  p = p->next;
5063
835
      }
5064
64
  }
5065
5066
64
  return ret;
5067
64
}
pei-arm-wince.c:coff_slurp_symbol_table
Line
Count
Source
4695
56
{
4696
56
  combined_entry_type *native_symbols;
4697
56
  coff_symbol_type *cached_area;
4698
56
  unsigned int *table_ptr;
4699
56
  unsigned int number_of_symbols = 0;
4700
56
  bool ret = true;
4701
56
  size_t amt;
4702
4703
56
  if (obj_symbols (abfd))
4704
28
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
28
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
0
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
28
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
28
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
28
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
28
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
28
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
28
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
28
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
28
  if (table_ptr == NULL)
4729
0
    return false;
4730
28
  else
4731
28
    {
4732
28
      coff_symbol_type *dst = cached_area;
4733
28
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
28
      unsigned int this_index = 0;
4735
4736
64
      while (this_index < last_native_index)
4737
36
  {
4738
36
    combined_entry_type *src = native_symbols + this_index;
4739
36
    table_ptr[this_index] = number_of_symbols;
4740
4741
36
    dst->symbol.the_bfd = abfd;
4742
36
    BFD_ASSERT (src->is_sym);
4743
36
    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
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
36
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
36
                 src->u.syment.n_scnum);
4748
36
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
36
    dst->symbol.value = 0;
4751
36
    dst->done_lineno = false;
4752
4753
36
    switch (src->u.syment.n_sclass)
4754
36
      {
4755
3
      case C_EXT:
4756
7
      case C_WEAKEXT:
4757
7
#if defined ARM
4758
9
      case C_THUMBEXT:
4759
10
      case C_THUMBEXTFUNC:
4760
10
#endif
4761
#ifdef RS6000COFF_C
4762
      case C_HIDEXT:
4763
#ifndef AIX_WEAK_SUPPORT
4764
      case C_AIX_WEAKEXT:
4765
#endif
4766
#endif
4767
10
#ifdef C_SYSTEM
4768
10
      case C_SYSTEM: /* System Wide variable.  */
4769
10
#endif
4770
10
#ifdef COFF_WITH_PE
4771
      /* In PE, 0x68 (104) denotes a section symbol.  */
4772
12
      case C_SECTION:
4773
      /* In PE, 0x69 (105) denotes a weak external symbol.  */
4774
14
      case C_NT_WEAK:
4775
14
#endif
4776
14
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
14
    {
4778
10
    case COFF_SYMBOL_GLOBAL:
4779
10
      dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
4780
10
#if defined COFF_WITH_PE
4781
      /* PE sets the symbol to a value relative to the
4782
         start of the section.  */
4783
10
      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
10
      if (ISFCN ((src->u.syment.n_type)))
4789
        /* A function ext does not go at the end of a
4790
           file.  */
4791
5
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4792
10
      break;
4793
4794
2
    case COFF_SYMBOL_COMMON:
4795
2
      dst->symbol.section = bfd_com_section_ptr;
4796
2
      dst->symbol.value = src->u.syment.n_value;
4797
2
      break;
4798
4799
2
    case COFF_SYMBOL_UNDEFINED:
4800
2
      dst->symbol.section = bfd_und_section_ptr;
4801
2
      dst->symbol.value = 0;
4802
2
      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
14
    }
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
14
#ifdef COFF_WITH_PE
4831
14
        if (src->u.syment.n_sclass == C_NT_WEAK)
4832
2
    dst->symbol.flags |= BSF_WEAK;
4833
4834
14
        if (src->u.syment.n_sclass == C_SECTION
4835
14
      && src->u.syment.n_scnum > 0)
4836
0
    dst->symbol.flags = BSF_LOCAL;
4837
14
#endif
4838
14
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
#ifdef RS6000COFF_C
4840
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
#endif
4842
14
      )
4843
4
    dst->symbol.flags |= BSF_WEAK;
4844
4845
14
        break;
4846
4847
6
      case C_STAT:  /* Static.  */
4848
6
#if defined ARM
4849
7
      case C_THUMBSTAT:    /* Thumb static.  */
4850
7
      case C_THUMBLABEL:   /* Thumb label.  */
4851
7
      case C_THUMBSTATFUNC:/* Thumb static function.  */
4852
7
#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
8
      case C_LABEL:  /* Label.  */
4858
8
        if (src->u.syment.n_scnum == N_DEBUG)
4859
0
    dst->symbol.flags = BSF_DEBUGGING;
4860
8
        else
4861
8
    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
8
        if (dst->symbol.section)
4866
8
    {
4867
8
#if defined COFF_WITH_PE
4868
      /* PE sets the symbol to a value relative to the
4869
         start of the section.  */
4870
8
      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
8
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
8
        break;
4879
4880
0
      case C_FILE: /* File name.  */
4881
0
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
0
      case C_MOS:   /* Member of structure.  */
4884
1
      case C_EOS:   /* End of structure.  */
4885
2
      case C_REGPARM: /* Register parameter.  */
4886
3
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
3
      case C_TPDEF: /* Type definition.  */
4889
3
      case C_ARG:
4890
4
      case C_AUTO: /* Automatic variable.  */
4891
4
      case C_FIELD: /* Bit field.  */
4892
4
      case C_ENTAG: /* Enumeration tag.  */
4893
5
      case C_MOE:   /* Member of enumeration.  */
4894
6
      case C_MOU:   /* Member of union.  */
4895
6
      case C_UNTAG: /* Union tag.  */
4896
6
      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
        dst->symbol.flags |= BSF_DEBUGGING;
4914
6
        dst->symbol.value = (src->u.syment.n_value);
4915
6
        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
1
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
1
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
2
      case C_EFCN: /* Physical end of function.  */
4968
2
#if defined COFF_WITH_PE
4969
        /* PE sets the symbol to a value relative to the start
4970
     of the section.  */
4971
2
        dst->symbol.value = src->u.syment.n_value;
4972
2
        if (strcmp (dst->symbol.name, ".bf") != 0)
4973
2
    {
4974
      /* PE uses funny values for .ef and .lf; don't
4975
         relocate them.  */
4976
2
      dst->symbol.flags = BSF_DEBUGGING;
4977
2
    }
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
        break;
4988
4989
1
      case C_STATLAB: /* Static load time label.  */
4990
1
        dst->symbol.value = src->u.syment.n_value;
4991
1
        dst->symbol.flags = BSF_GLOBAL;
4992
1
        break;
4993
4994
3
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
3
        if (src->u.syment.n_type == 0
4998
3
      && src->u.syment.n_value == 0
4999
3
      && src->u.syment.n_scnum == 0)
5000
3
    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
0
      case C_EXTDEF: /* External definition.  */
5008
0
      case C_ULABEL: /* Undefined label.  */
5009
0
      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
0
      case C_EXTLAB: /* External load time label.  */
5022
0
      default:
5023
0
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
0
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
0
     abfd, src->u.syment.n_sclass,
5027
0
     dst->symbol.section->name, dst->symbol.name);
5028
0
        ret = false;
5029
        /* Fall through.  */
5030
2
      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
2
        dst->symbol.flags = BSF_DEBUGGING;
5034
2
        dst->symbol.value = (src->u.syment.n_value);
5035
2
        break;
5036
36
      }
5037
5038
36
    dst->native = src;
5039
36
    dst->symbol.udata.i = 0;
5040
36
    dst->lineno = NULL;
5041
5042
36
    this_index += (src->u.syment.n_numaux) + 1;
5043
36
    dst++;
5044
36
    number_of_symbols++;
5045
36
  }
5046
28
    }
5047
5048
28
  obj_symbols (abfd) = cached_area;
5049
28
  obj_raw_syments (abfd) = native_symbols;
5050
5051
28
  abfd->symcount = number_of_symbols;
5052
28
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
28
  {
5055
28
    asection *p;
5056
5057
28
    p = abfd->sections;
5058
47
    while (p)
5059
19
      {
5060
19
  if (! coff_slurp_line_table (abfd, p))
5061
0
    return false;
5062
19
  p = p->next;
5063
19
      }
5064
28
  }
5065
5066
28
  return ret;
5067
28
}
pei-arm.c:coff_slurp_symbol_table
Line
Count
Source
4695
108
{
4696
108
  combined_entry_type *native_symbols;
4697
108
  coff_symbol_type *cached_area;
4698
108
  unsigned int *table_ptr;
4699
108
  unsigned int number_of_symbols = 0;
4700
108
  bool ret = true;
4701
108
  size_t amt;
4702
4703
108
  if (obj_symbols (abfd))
4704
54
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
54
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
0
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
54
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
54
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
54
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
54
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
54
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
54
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
54
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
54
  if (table_ptr == NULL)
4729
0
    return false;
4730
54
  else
4731
54
    {
4732
54
      coff_symbol_type *dst = cached_area;
4733
54
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
54
      unsigned int this_index = 0;
4735
4736
257
      while (this_index < last_native_index)
4737
203
  {
4738
203
    combined_entry_type *src = native_symbols + this_index;
4739
203
    table_ptr[this_index] = number_of_symbols;
4740
4741
203
    dst->symbol.the_bfd = abfd;
4742
203
    BFD_ASSERT (src->is_sym);
4743
203
    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
203
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
203
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
203
                 src->u.syment.n_scnum);
4748
203
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
203
    dst->symbol.value = 0;
4751
203
    dst->done_lineno = false;
4752
4753
203
    switch (src->u.syment.n_sclass)
4754
203
      {
4755
3
      case C_EXT:
4756
6
      case C_WEAKEXT:
4757
6
#if defined ARM
4758
8
      case C_THUMBEXT:
4759
9
      case C_THUMBEXTFUNC:
4760
9
#endif
4761
#ifdef RS6000COFF_C
4762
      case C_HIDEXT:
4763
#ifndef AIX_WEAK_SUPPORT
4764
      case C_AIX_WEAKEXT:
4765
#endif
4766
#endif
4767
9
#ifdef C_SYSTEM
4768
9
      case C_SYSTEM: /* System Wide variable.  */
4769
9
#endif
4770
9
#ifdef COFF_WITH_PE
4771
      /* In PE, 0x68 (104) denotes a section symbol.  */
4772
10
      case C_SECTION:
4773
      /* In PE, 0x69 (105) denotes a weak external symbol.  */
4774
11
      case C_NT_WEAK:
4775
11
#endif
4776
11
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
11
    {
4778
6
    case COFF_SYMBOL_GLOBAL:
4779
6
      dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
4780
6
#if defined COFF_WITH_PE
4781
      /* PE sets the symbol to a value relative to the
4782
         start of the section.  */
4783
6
      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
6
      if (ISFCN ((src->u.syment.n_type)))
4789
        /* A function ext does not go at the end of a
4790
           file.  */
4791
3
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4792
6
      break;
4793
4794
3
    case COFF_SYMBOL_COMMON:
4795
3
      dst->symbol.section = bfd_com_section_ptr;
4796
3
      dst->symbol.value = src->u.syment.n_value;
4797
3
      break;
4798
4799
2
    case COFF_SYMBOL_UNDEFINED:
4800
2
      dst->symbol.section = bfd_und_section_ptr;
4801
2
      dst->symbol.value = 0;
4802
2
      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
11
    }
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
11
#ifdef COFF_WITH_PE
4831
11
        if (src->u.syment.n_sclass == C_NT_WEAK)
4832
1
    dst->symbol.flags |= BSF_WEAK;
4833
4834
11
        if (src->u.syment.n_sclass == C_SECTION
4835
11
      && src->u.syment.n_scnum > 0)
4836
0
    dst->symbol.flags = BSF_LOCAL;
4837
11
#endif
4838
11
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
#ifdef RS6000COFF_C
4840
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
#endif
4842
11
      )
4843
3
    dst->symbol.flags |= BSF_WEAK;
4844
4845
11
        break;
4846
4847
21
      case C_STAT:  /* Static.  */
4848
21
#if defined ARM
4849
22
      case C_THUMBSTAT:    /* Thumb static.  */
4850
22
      case C_THUMBLABEL:   /* Thumb label.  */
4851
22
      case C_THUMBSTATFUNC:/* Thumb static function.  */
4852
22
#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
23
      case C_LABEL:  /* Label.  */
4858
23
        if (src->u.syment.n_scnum == N_DEBUG)
4859
0
    dst->symbol.flags = BSF_DEBUGGING;
4860
23
        else
4861
23
    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
23
        if (dst->symbol.section)
4866
23
    {
4867
23
#if defined COFF_WITH_PE
4868
      /* PE sets the symbol to a value relative to the
4869
         start of the section.  */
4870
23
      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
23
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
23
        break;
4879
4880
1
      case C_FILE: /* File name.  */
4881
1
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
2
      case C_MOS:   /* Member of structure.  */
4884
3
      case C_EOS:   /* End of structure.  */
4885
4
      case C_REGPARM: /* Register parameter.  */
4886
12
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
13
      case C_TPDEF: /* Type definition.  */
4889
13
      case C_ARG:
4890
15
      case C_AUTO: /* Automatic variable.  */
4891
16
      case C_FIELD: /* Bit field.  */
4892
16
      case C_ENTAG: /* Enumeration tag.  */
4893
23
      case C_MOE:   /* Member of enumeration.  */
4894
24
      case C_MOU:   /* Member of union.  */
4895
24
      case C_UNTAG: /* Union tag.  */
4896
47
      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
47
        dst->symbol.flags |= BSF_DEBUGGING;
4914
47
        dst->symbol.value = (src->u.syment.n_value);
4915
47
        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
16
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
16
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
44
      case C_EFCN: /* Physical end of function.  */
4968
44
#if defined COFF_WITH_PE
4969
        /* PE sets the symbol to a value relative to the start
4970
     of the section.  */
4971
44
        dst->symbol.value = src->u.syment.n_value;
4972
44
        if (strcmp (dst->symbol.name, ".bf") != 0)
4973
44
    {
4974
      /* PE uses funny values for .ef and .lf; don't
4975
         relocate them.  */
4976
44
      dst->symbol.flags = BSF_DEBUGGING;
4977
44
    }
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
44
        break;
4988
4989
1
      case C_STATLAB: /* Static load time label.  */
4990
1
        dst->symbol.value = src->u.syment.n_value;
4991
1
        dst->symbol.flags = BSF_GLOBAL;
4992
1
        break;
4993
4994
76
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
76
        if (src->u.syment.n_type == 0
4998
76
      && src->u.syment.n_value == 0
4999
76
      && src->u.syment.n_scnum == 0)
5000
76
    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
0
      case C_EXTDEF: /* External definition.  */
5008
0
      case C_ULABEL: /* Undefined label.  */
5009
0
      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
0
      case C_EXTLAB: /* External load time label.  */
5022
0
      default:
5023
0
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
0
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
0
     abfd, src->u.syment.n_sclass,
5027
0
     dst->symbol.section->name, dst->symbol.name);
5028
0
        ret = false;
5029
        /* Fall through.  */
5030
1
      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
1
        dst->symbol.flags = BSF_DEBUGGING;
5034
1
        dst->symbol.value = (src->u.syment.n_value);
5035
1
        break;
5036
203
      }
5037
5038
203
    dst->native = src;
5039
203
    dst->symbol.udata.i = 0;
5040
203
    dst->lineno = NULL;
5041
5042
203
    this_index += (src->u.syment.n_numaux) + 1;
5043
203
    dst++;
5044
203
    number_of_symbols++;
5045
203
  }
5046
54
    }
5047
5048
54
  obj_symbols (abfd) = cached_area;
5049
54
  obj_raw_syments (abfd) = native_symbols;
5050
5051
54
  abfd->symcount = number_of_symbols;
5052
54
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
54
  {
5055
54
    asection *p;
5056
5057
54
    p = abfd->sections;
5058
283
    while (p)
5059
229
      {
5060
229
  if (! coff_slurp_line_table (abfd, p))
5061
0
    return false;
5062
229
  p = p->next;
5063
229
      }
5064
54
  }
5065
5066
54
  return ret;
5067
54
}
pei-mcore.c:coff_slurp_symbol_table
Line
Count
Source
4695
86
{
4696
86
  combined_entry_type *native_symbols;
4697
86
  coff_symbol_type *cached_area;
4698
86
  unsigned int *table_ptr;
4699
86
  unsigned int number_of_symbols = 0;
4700
86
  bool ret = true;
4701
86
  size_t amt;
4702
4703
86
  if (obj_symbols (abfd))
4704
43
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
43
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
0
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
43
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
43
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
43
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
43
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
43
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
43
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
43
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
43
  if (table_ptr == NULL)
4729
0
    return false;
4730
43
  else
4731
43
    {
4732
43
      coff_symbol_type *dst = cached_area;
4733
43
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
43
      unsigned int this_index = 0;
4735
4736
288
      while (this_index < last_native_index)
4737
245
  {
4738
245
    combined_entry_type *src = native_symbols + this_index;
4739
245
    table_ptr[this_index] = number_of_symbols;
4740
4741
245
    dst->symbol.the_bfd = abfd;
4742
245
    BFD_ASSERT (src->is_sym);
4743
245
    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
245
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
245
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
245
                 src->u.syment.n_scnum);
4748
245
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
245
    dst->symbol.value = 0;
4751
245
    dst->done_lineno = false;
4752
4753
245
    switch (src->u.syment.n_sclass)
4754
245
      {
4755
17
      case C_EXT:
4756
32
      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
32
#ifdef C_SYSTEM
4768
41
      case C_SYSTEM: /* System Wide variable.  */
4769
41
#endif
4770
41
#ifdef COFF_WITH_PE
4771
      /* In PE, 0x68 (104) denotes a section symbol.  */
4772
43
      case C_SECTION:
4773
      /* In PE, 0x69 (105) denotes a weak external symbol.  */
4774
45
      case C_NT_WEAK:
4775
45
#endif
4776
45
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
45
    {
4778
22
    case COFF_SYMBOL_GLOBAL:
4779
22
      dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
4780
22
#if defined COFF_WITH_PE
4781
      /* PE sets the symbol to a value relative to the
4782
         start of the section.  */
4783
22
      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
22
      if (ISFCN ((src->u.syment.n_type)))
4789
        /* A function ext does not go at the end of a
4790
           file.  */
4791
3
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4792
22
      break;
4793
4794
2
    case COFF_SYMBOL_COMMON:
4795
2
      dst->symbol.section = bfd_com_section_ptr;
4796
2
      dst->symbol.value = src->u.syment.n_value;
4797
2
      break;
4798
4799
21
    case COFF_SYMBOL_UNDEFINED:
4800
21
      dst->symbol.section = bfd_und_section_ptr;
4801
21
      dst->symbol.value = 0;
4802
21
      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
45
    }
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
45
#ifdef COFF_WITH_PE
4831
45
        if (src->u.syment.n_sclass == C_NT_WEAK)
4832
2
    dst->symbol.flags |= BSF_WEAK;
4833
4834
45
        if (src->u.syment.n_sclass == C_SECTION
4835
45
      && src->u.syment.n_scnum > 0)
4836
0
    dst->symbol.flags = BSF_LOCAL;
4837
45
#endif
4838
45
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
#ifdef RS6000COFF_C
4840
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
#endif
4842
45
      )
4843
15
    dst->symbol.flags |= BSF_WEAK;
4844
4845
45
        break;
4846
4847
11
      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
11
      case C_LABEL:  /* Label.  */
4858
11
        if (src->u.syment.n_scnum == N_DEBUG)
4859
2
    dst->symbol.flags = BSF_DEBUGGING;
4860
9
        else
4861
9
    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
11
        if (dst->symbol.section)
4866
11
    {
4867
11
#if defined COFF_WITH_PE
4868
      /* PE sets the symbol to a value relative to the
4869
         start of the section.  */
4870
11
      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
11
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
11
        break;
4879
4880
1
      case C_FILE: /* File name.  */
4881
1
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
1
      case C_MOS:   /* Member of structure.  */
4884
1
      case C_EOS:   /* End of structure.  */
4885
2
      case C_REGPARM: /* Register parameter.  */
4886
4
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
4
      case C_TPDEF: /* Type definition.  */
4889
6
      case C_ARG:
4890
7
      case C_AUTO: /* Automatic variable.  */
4891
8
      case C_FIELD: /* Bit field.  */
4892
9
      case C_ENTAG: /* Enumeration tag.  */
4893
15
      case C_MOE:   /* Member of enumeration.  */
4894
16
      case C_MOU:   /* Member of union.  */
4895
17
      case C_UNTAG: /* Union tag.  */
4896
24
      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
24
        dst->symbol.flags |= BSF_DEBUGGING;
4914
24
        dst->symbol.value = (src->u.syment.n_value);
4915
24
        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
2
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
4
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
25
      case C_EFCN: /* Physical end of function.  */
4968
25
#if defined COFF_WITH_PE
4969
        /* PE sets the symbol to a value relative to the start
4970
     of the section.  */
4971
25
        dst->symbol.value = src->u.syment.n_value;
4972
25
        if (strcmp (dst->symbol.name, ".bf") != 0)
4973
25
    {
4974
      /* PE uses funny values for .ef and .lf; don't
4975
         relocate them.  */
4976
25
      dst->symbol.flags = BSF_DEBUGGING;
4977
25
    }
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
25
        break;
4988
4989
4
      case C_STATLAB: /* Static load time label.  */
4990
4
        dst->symbol.value = src->u.syment.n_value;
4991
4
        dst->symbol.flags = BSF_GLOBAL;
4992
4
        break;
4993
4994
132
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
132
        if (src->u.syment.n_type == 0
4998
132
      && src->u.syment.n_value == 0
4999
132
      && src->u.syment.n_scnum == 0)
5000
132
    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
0
      case C_EXTDEF: /* External definition.  */
5008
0
      case C_ULABEL: /* Undefined label.  */
5009
0
      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
0
      case C_EXTLAB: /* External load time label.  */
5022
0
      default:
5023
0
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
0
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
0
     abfd, src->u.syment.n_sclass,
5027
0
     dst->symbol.section->name, dst->symbol.name);
5028
0
        ret = false;
5029
        /* Fall through.  */
5030
4
      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
4
        dst->symbol.flags = BSF_DEBUGGING;
5034
4
        dst->symbol.value = (src->u.syment.n_value);
5035
4
        break;
5036
245
      }
5037
5038
245
    dst->native = src;
5039
245
    dst->symbol.udata.i = 0;
5040
245
    dst->lineno = NULL;
5041
5042
245
    this_index += (src->u.syment.n_numaux) + 1;
5043
245
    dst++;
5044
245
    number_of_symbols++;
5045
245
  }
5046
43
    }
5047
5048
43
  obj_symbols (abfd) = cached_area;
5049
43
  obj_raw_syments (abfd) = native_symbols;
5050
5051
43
  abfd->symcount = number_of_symbols;
5052
43
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
43
  {
5055
43
    asection *p;
5056
5057
43
    p = abfd->sections;
5058
297
    while (p)
5059
254
      {
5060
254
  if (! coff_slurp_line_table (abfd, p))
5061
0
    return false;
5062
254
  p = p->next;
5063
254
      }
5064
43
  }
5065
5066
43
  return ret;
5067
43
}
pei-sh.c:coff_slurp_symbol_table
Line
Count
Source
4695
122
{
4696
122
  combined_entry_type *native_symbols;
4697
122
  coff_symbol_type *cached_area;
4698
122
  unsigned int *table_ptr;
4699
122
  unsigned int number_of_symbols = 0;
4700
122
  bool ret = true;
4701
122
  size_t amt;
4702
4703
122
  if (obj_symbols (abfd))
4704
61
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
61
  if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
4708
0
    return false;
4709
4710
  /* Allocate enough room for all the symbols in cached form.  */
4711
61
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
61
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
61
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
61
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
61
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
61
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
61
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
61
  if (table_ptr == NULL)
4729
0
    return false;
4730
61
  else
4731
61
    {
4732
61
      coff_symbol_type *dst = cached_area;
4733
61
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
61
      unsigned int this_index = 0;
4735
4736
1.06k
      while (this_index < last_native_index)
4737
1.00k
  {
4738
1.00k
    combined_entry_type *src = native_symbols + this_index;
4739
1.00k
    table_ptr[this_index] = number_of_symbols;
4740
4741
1.00k
    dst->symbol.the_bfd = abfd;
4742
1.00k
    BFD_ASSERT (src->is_sym);
4743
1.00k
    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.00k
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
1.00k
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
1.00k
                 src->u.syment.n_scnum);
4748
1.00k
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
1.00k
    dst->symbol.value = 0;
4751
1.00k
    dst->done_lineno = false;
4752
4753
1.00k
    switch (src->u.syment.n_sclass)
4754
1.00k
      {
4755
78
      case C_EXT:
4756
91
      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
91
#ifdef C_SYSTEM
4768
109
      case C_SYSTEM: /* System Wide variable.  */
4769
109
#endif
4770
109
#ifdef COFF_WITH_PE
4771
      /* In PE, 0x68 (104) denotes a section symbol.  */
4772
112
      case C_SECTION:
4773
      /* In PE, 0x69 (105) denotes a weak external symbol.  */
4774
118
      case C_NT_WEAK:
4775
118
#endif
4776
118
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
118
    {
4778
87
    case COFF_SYMBOL_GLOBAL:
4779
87
      dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
4780
87
#if defined COFF_WITH_PE
4781
      /* PE sets the symbol to a value relative to the
4782
         start of the section.  */
4783
87
      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
87
      if (ISFCN ((src->u.syment.n_type)))
4789
        /* A function ext does not go at the end of a
4790
           file.  */
4791
16
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4792
87
      break;
4793
4794
13
    case COFF_SYMBOL_COMMON:
4795
13
      dst->symbol.section = bfd_com_section_ptr;
4796
13
      dst->symbol.value = src->u.syment.n_value;
4797
13
      break;
4798
4799
18
    case COFF_SYMBOL_UNDEFINED:
4800
18
      dst->symbol.section = bfd_und_section_ptr;
4801
18
      dst->symbol.value = 0;
4802
18
      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
118
    }
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
118
#ifdef COFF_WITH_PE
4831
118
        if (src->u.syment.n_sclass == C_NT_WEAK)
4832
6
    dst->symbol.flags |= BSF_WEAK;
4833
4834
118
        if (src->u.syment.n_sclass == C_SECTION
4835
118
      && src->u.syment.n_scnum > 0)
4836
0
    dst->symbol.flags = BSF_LOCAL;
4837
118
#endif
4838
118
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
#ifdef RS6000COFF_C
4840
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
#endif
4842
118
      )
4843
13
    dst->symbol.flags |= BSF_WEAK;
4844
4845
118
        break;
4846
4847
37
      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
63
      case C_LABEL:  /* Label.  */
4858
63
        if (src->u.syment.n_scnum == N_DEBUG)
4859
0
    dst->symbol.flags = BSF_DEBUGGING;
4860
63
        else
4861
63
    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
63
        if (dst->symbol.section)
4866
63
    {
4867
63
#if defined COFF_WITH_PE
4868
      /* PE sets the symbol to a value relative to the
4869
         start of the section.  */
4870
63
      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
63
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
63
        break;
4879
4880
4
      case C_FILE: /* File name.  */
4881
4
        dst->symbol.flags = BSF_FILE;
4882
        /* Fall through.  */
4883
26
      case C_MOS:   /* Member of structure.  */
4884
27
      case C_EOS:   /* End of structure.  */
4885
32
      case C_REGPARM: /* Register parameter.  */
4886
52
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
57
      case C_TPDEF: /* Type definition.  */
4889
70
      case C_ARG:
4890
215
      case C_AUTO: /* Automatic variable.  */
4891
233
      case C_FIELD: /* Bit field.  */
4892
241
      case C_ENTAG: /* Enumeration tag.  */
4893
245
      case C_MOE:   /* Member of enumeration.  */
4894
254
      case C_MOU:   /* Member of union.  */
4895
261
      case C_UNTAG: /* Union tag.  */
4896
265
      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
265
        dst->symbol.flags |= BSF_DEBUGGING;
4914
265
        dst->symbol.value = (src->u.syment.n_value);
4915
265
        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
1
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
2
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
18
      case C_EFCN: /* Physical end of function.  */
4968
18
#if defined COFF_WITH_PE
4969
        /* PE sets the symbol to a value relative to the start
4970
     of the section.  */
4971
18
        dst->symbol.value = src->u.syment.n_value;
4972
18
        if (strcmp (dst->symbol.name, ".bf") != 0)
4973
18
    {
4974
      /* PE uses funny values for .ef and .lf; don't
4975
         relocate them.  */
4976
18
      dst->symbol.flags = BSF_DEBUGGING;
4977
18
    }
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
18
        break;
4988
4989
6
      case C_STATLAB: /* Static load time label.  */
4990
6
        dst->symbol.value = src->u.syment.n_value;
4991
6
        dst->symbol.flags = BSF_GLOBAL;
4992
6
        break;
4993
4994
532
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
532
        if (src->u.syment.n_type == 0
4998
532
      && src->u.syment.n_value == 0
4999
532
      && src->u.syment.n_scnum == 0)
5000
532
    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
0
      case C_EXTDEF: /* External definition.  */
5008
0
      case C_ULABEL: /* Undefined label.  */
5009
0
      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
0
      case C_EXTLAB: /* External load time label.  */
5022
0
      default:
5023
0
        _bfd_error_handler
5024
    /* xgettext:c-format */
5025
0
    (_("%pB: unrecognized storage class %d for %s symbol `%s'"),
5026
0
     abfd, src->u.syment.n_sclass,
5027
0
     dst->symbol.section->name, dst->symbol.name);
5028
0
        ret = false;
5029
        /* Fall through.  */
5030
4
      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
4
        dst->symbol.flags = BSF_DEBUGGING;
5034
4
        dst->symbol.value = (src->u.syment.n_value);
5035
4
        break;
5036
1.00k
      }
5037
5038
1.00k
    dst->native = src;
5039
1.00k
    dst->symbol.udata.i = 0;
5040
1.00k
    dst->lineno = NULL;
5041
5042
1.00k
    this_index += (src->u.syment.n_numaux) + 1;
5043
1.00k
    dst++;
5044
1.00k
    number_of_symbols++;
5045
1.00k
  }
5046
61
    }
5047
5048
61
  obj_symbols (abfd) = cached_area;
5049
61
  obj_raw_syments (abfd) = native_symbols;
5050
5051
61
  abfd->symcount = number_of_symbols;
5052
61
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
61
  {
5055
61
    asection *p;
5056
5057
61
    p = abfd->sections;
5058
265
    while (p)
5059
204
      {
5060
204
  if (! coff_slurp_line_table (abfd, p))
5061
0
    return false;
5062
204
  p = p->next;
5063
204
      }
5064
61
  }
5065
5066
61
  return ret;
5067
61
}
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
4.30k
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
4.30k
  switch (syment->n_sclass)
5080
4.30k
    {
5081
3.37k
    case C_EXT:
5082
3.65k
    case C_WEAKEXT:
5083
#ifdef ARM
5084
17
    case C_THUMBEXT:
5085
19
    case C_THUMBEXTFUNC:
5086
#endif
5087
#ifdef RS6000COFF_C
5088
920
    case C_HIDEXT:
5089
920
#ifndef AIX_WEAK_SUPPORT
5090
935
    case C_AIX_WEAKEXT:
5091
#endif
5092
#endif
5093
935
#ifdef C_SYSTEM
5094
4.11k
    case C_SYSTEM:
5095
4.11k
#endif
5096
#ifdef COFF_WITH_PE
5097
1.95k
    case C_NT_WEAK:
5098
#endif
5099
4.26k
      if (syment->n_scnum == 0)
5100
554
  {
5101
554
    if (syment->n_value == 0)
5102
355
      return COFF_SYMBOL_UNDEFINED;
5103
199
    else
5104
199
      return COFF_SYMBOL_COMMON;
5105
554
  }
5106
#ifdef RS6000COFF_C
5107
911
      if (syment->n_sclass == C_HIDEXT)
5108
19
  return COFF_SYMBOL_LOCAL;
5109
892
#endif
5110
3.69k
      return COFF_SYMBOL_GLOBAL;
5111
5112
36
    default:
5113
36
      break;
5114
4.30k
    }
5115
5116
#ifdef COFF_WITH_PE
5117
36
  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
36
  if (syment->n_sclass == C_SECTION)
5147
36
    {
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
36
      syment->n_value = 0;
5152
36
      if (syment->n_scnum == 0)
5153
36
  return COFF_SYMBOL_UNDEFINED;
5154
0
      return COFF_SYMBOL_PE_SECTION;
5155
36
    }
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
36
}
pei-i386.c:coff_classify_symbol
Line
Count
Source
5076
40
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
40
  switch (syment->n_sclass)
5080
40
    {
5081
21
    case C_EXT:
5082
32
    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
32
#ifdef C_SYSTEM
5094
33
    case C_SYSTEM:
5095
33
#endif
5096
33
#ifdef COFF_WITH_PE
5097
38
    case C_NT_WEAK:
5098
38
#endif
5099
38
      if (syment->n_scnum == 0)
5100
25
  {
5101
25
    if (syment->n_value == 0)
5102
12
      return COFF_SYMBOL_UNDEFINED;
5103
13
    else
5104
13
      return COFF_SYMBOL_COMMON;
5105
25
  }
5106
#ifdef RS6000COFF_C
5107
      if (syment->n_sclass == C_HIDEXT)
5108
  return COFF_SYMBOL_LOCAL;
5109
#endif
5110
13
      return COFF_SYMBOL_GLOBAL;
5111
5112
2
    default:
5113
2
      break;
5114
40
    }
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
100
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
100
  switch (syment->n_sclass)
5080
100
    {
5081
81
    case C_EXT:
5082
94
    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
94
#ifdef C_SYSTEM
5094
95
    case C_SYSTEM:
5095
95
#endif
5096
95
#ifdef COFF_WITH_PE
5097
96
    case C_NT_WEAK:
5098
96
#endif
5099
96
      if (syment->n_scnum == 0)
5100
21
  {
5101
21
    if (syment->n_value == 0)
5102
13
      return COFF_SYMBOL_UNDEFINED;
5103
8
    else
5104
8
      return COFF_SYMBOL_COMMON;
5105
21
  }
5106
#ifdef RS6000COFF_C
5107
      if (syment->n_sclass == C_HIDEXT)
5108
  return COFF_SYMBOL_LOCAL;
5109
#endif
5110
75
      return COFF_SYMBOL_GLOBAL;
5111
5112
4
    default:
5113
4
      break;
5114
100
    }
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-x86_64.c:coff_classify_symbol
Line
Count
Source
5076
138
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
138
  switch (syment->n_sclass)
5080
138
    {
5081
110
    case C_EXT:
5082
115
    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
115
#ifdef C_SYSTEM
5094
124
    case C_SYSTEM:
5095
124
#endif
5096
124
#ifdef COFF_WITH_PE
5097
136
    case C_NT_WEAK:
5098
136
#endif
5099
136
      if (syment->n_scnum == 0)
5100
29
  {
5101
29
    if (syment->n_value == 0)
5102
17
      return COFF_SYMBOL_UNDEFINED;
5103
12
    else
5104
12
      return COFF_SYMBOL_COMMON;
5105
29
  }
5106
#ifdef RS6000COFF_C
5107
      if (syment->n_sclass == C_HIDEXT)
5108
  return COFF_SYMBOL_LOCAL;
5109
#endif
5110
107
      return COFF_SYMBOL_GLOBAL;
5111
5112
2
    default:
5113
2
      break;
5114
138
    }
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
}
coff-x86_64.c:coff_classify_symbol
Line
Count
Source
5076
134
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
134
  switch (syment->n_sclass)
5080
134
    {
5081
100
    case C_EXT:
5082
118
    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
118
#ifdef C_SYSTEM
5094
134
    case C_SYSTEM:
5095
134
#endif
5096
#ifdef COFF_WITH_PE
5097
    case C_NT_WEAK:
5098
#endif
5099
134
      if (syment->n_scnum == 0)
5100
22
  {
5101
22
    if (syment->n_value == 0)
5102
14
      return COFF_SYMBOL_UNDEFINED;
5103
8
    else
5104
8
      return COFF_SYMBOL_COMMON;
5105
22
  }
5106
#ifdef RS6000COFF_C
5107
      if (syment->n_sclass == C_HIDEXT)
5108
  return COFF_SYMBOL_LOCAL;
5109
#endif
5110
112
      return COFF_SYMBOL_GLOBAL;
5111
5112
0
    default:
5113
0
      break;
5114
134
    }
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
134
}
coff64-rs6000.c:coff_classify_symbol
Line
Count
Source
5076
85
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
85
  switch (syment->n_sclass)
5080
85
    {
5081
54
    case C_EXT:
5082
57
    case C_WEAKEXT:
5083
#ifdef ARM
5084
    case C_THUMBEXT:
5085
    case C_THUMBEXTFUNC:
5086
#endif
5087
57
#ifdef RS6000COFF_C
5088
73
    case C_HIDEXT:
5089
73
#ifndef AIX_WEAK_SUPPORT
5090
78
    case C_AIX_WEAKEXT:
5091
78
#endif
5092
78
#endif
5093
78
#ifdef C_SYSTEM
5094
85
    case C_SYSTEM:
5095
85
#endif
5096
#ifdef COFF_WITH_PE
5097
    case C_NT_WEAK:
5098
#endif
5099
85
      if (syment->n_scnum == 0)
5100
12
  {
5101
12
    if (syment->n_value == 0)
5102
10
      return COFF_SYMBOL_UNDEFINED;
5103
2
    else
5104
2
      return COFF_SYMBOL_COMMON;
5105
12
  }
5106
73
#ifdef RS6000COFF_C
5107
73
      if (syment->n_sclass == C_HIDEXT)
5108
16
  return COFF_SYMBOL_LOCAL;
5109
57
#endif
5110
57
      return COFF_SYMBOL_GLOBAL;
5111
5112
0
    default:
5113
0
      break;
5114
85
    }
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
85
}
pe-aarch64.c:coff_classify_symbol
Line
Count
Source
5076
179
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
179
  switch (syment->n_sclass)
5080
179
    {
5081
104
    case C_EXT:
5082
123
    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
123
#ifdef C_SYSTEM
5094
173
    case C_SYSTEM:
5095
173
#endif
5096
173
#ifdef COFF_WITH_PE
5097
179
    case C_NT_WEAK:
5098
179
#endif
5099
179
      if (syment->n_scnum == 0)
5100
20
  {
5101
20
    if (syment->n_value == 0)
5102
14
      return COFF_SYMBOL_UNDEFINED;
5103
6
    else
5104
6
      return COFF_SYMBOL_COMMON;
5105
20
  }
5106
#ifdef RS6000COFF_C
5107
      if (syment->n_sclass == C_HIDEXT)
5108
  return COFF_SYMBOL_LOCAL;
5109
#endif
5110
159
      return COFF_SYMBOL_GLOBAL;
5111
5112
0
    default:
5113
0
      break;
5114
179
    }
5115
5116
0
#ifdef COFF_WITH_PE
5117
0
  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
0
  if (syment->n_sclass == C_SECTION)
5147
0
    {
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
0
      syment->n_value = 0;
5152
0
      if (syment->n_scnum == 0)
5153
0
  return COFF_SYMBOL_UNDEFINED;
5154
0
      return COFF_SYMBOL_PE_SECTION;
5155
0
    }
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
0
}
pei-aarch64.c:coff_classify_symbol
Line
Count
Source
5076
103
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
103
  switch (syment->n_sclass)
5080
103
    {
5081
93
    case C_EXT:
5082
97
    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
97
#ifdef C_SYSTEM
5094
98
    case C_SYSTEM:
5095
98
#endif
5096
98
#ifdef COFF_WITH_PE
5097
100
    case C_NT_WEAK:
5098
100
#endif
5099
100
      if (syment->n_scnum == 0)
5100
17
  {
5101
17
    if (syment->n_value == 0)
5102
15
      return COFF_SYMBOL_UNDEFINED;
5103
2
    else
5104
2
      return COFF_SYMBOL_COMMON;
5105
17
  }
5106
#ifdef RS6000COFF_C
5107
      if (syment->n_sclass == C_HIDEXT)
5108
  return COFF_SYMBOL_LOCAL;
5109
#endif
5110
83
      return COFF_SYMBOL_GLOBAL;
5111
5112
3
    default:
5113
3
      break;
5114
103
    }
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
}
pei-ia64.c:coff_classify_symbol
Line
Count
Source
5076
285
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
285
  switch (syment->n_sclass)
5080
285
    {
5081
217
    case C_EXT:
5082
235
    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
235
#ifdef C_SYSTEM
5094
248
    case C_SYSTEM:
5095
248
#endif
5096
248
#ifdef COFF_WITH_PE
5097
283
    case C_NT_WEAK:
5098
283
#endif
5099
283
      if (syment->n_scnum == 0)
5100
27
  {
5101
27
    if (syment->n_value == 0)
5102
11
      return COFF_SYMBOL_UNDEFINED;
5103
16
    else
5104
16
      return COFF_SYMBOL_COMMON;
5105
27
  }
5106
#ifdef RS6000COFF_C
5107
      if (syment->n_sclass == C_HIDEXT)
5108
  return COFF_SYMBOL_LOCAL;
5109
#endif
5110
256
      return COFF_SYMBOL_GLOBAL;
5111
5112
2
    default:
5113
2
      break;
5114
285
    }
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
}
pei-loongarch64.c:coff_classify_symbol
Line
Count
Source
5076
104
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
104
  switch (syment->n_sclass)
5080
104
    {
5081
80
    case C_EXT:
5082
98
    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
98
#ifdef C_SYSTEM
5094
98
    case C_SYSTEM:
5095
98
#endif
5096
98
#ifdef COFF_WITH_PE
5097
99
    case C_NT_WEAK:
5098
99
#endif
5099
99
      if (syment->n_scnum == 0)
5100
27
  {
5101
27
    if (syment->n_value == 0)
5102
14
      return COFF_SYMBOL_UNDEFINED;
5103
13
    else
5104
13
      return COFF_SYMBOL_COMMON;
5105
27
  }
5106
#ifdef RS6000COFF_C
5107
      if (syment->n_sclass == C_HIDEXT)
5108
  return COFF_SYMBOL_LOCAL;
5109
#endif
5110
72
      return COFF_SYMBOL_GLOBAL;
5111
5112
5
    default:
5113
5
      break;
5114
104
    }
5115
5116
5
#ifdef COFF_WITH_PE
5117
5
  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
5
  if (syment->n_sclass == C_SECTION)
5147
5
    {
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
5
      syment->n_value = 0;
5152
5
      if (syment->n_scnum == 0)
5153
5
  return COFF_SYMBOL_UNDEFINED;
5154
0
      return COFF_SYMBOL_PE_SECTION;
5155
5
    }
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
5
}
Unexecuted instantiation: cf-i386lynx.c:coff_classify_symbol
Unexecuted instantiation: coff-go32.c:coff_classify_symbol
Unexecuted instantiation: coff-i386.c:coff_classify_symbol
coff-rs6000.c:coff_classify_symbol
Line
Count
Source
5076
862
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
862
  switch (syment->n_sclass)
5080
862
    {
5081
843
    case C_EXT:
5082
844
    case C_WEAKEXT:
5083
#ifdef ARM
5084
    case C_THUMBEXT:
5085
    case C_THUMBEXTFUNC:
5086
#endif
5087
844
#ifdef RS6000COFF_C
5088
847
    case C_HIDEXT:
5089
847
#ifndef AIX_WEAK_SUPPORT
5090
857
    case C_AIX_WEAKEXT:
5091
857
#endif
5092
857
#endif
5093
857
#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
24
  {
5101
24
    if (syment->n_value == 0)
5102
4
      return COFF_SYMBOL_UNDEFINED;
5103
20
    else
5104
20
      return COFF_SYMBOL_COMMON;
5105
24
  }
5106
838
#ifdef RS6000COFF_C
5107
838
      if (syment->n_sclass == C_HIDEXT)
5108
3
  return COFF_SYMBOL_LOCAL;
5109
835
#endif
5110
835
      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
}
coff-sh.c:coff_classify_symbol
Line
Count
Source
5076
166
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
166
  switch (syment->n_sclass)
5080
166
    {
5081
97
    case C_EXT:
5082
146
    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
146
#ifdef C_SYSTEM
5094
166
    case C_SYSTEM:
5095
166
#endif
5096
#ifdef COFF_WITH_PE
5097
    case C_NT_WEAK:
5098
#endif
5099
166
      if (syment->n_scnum == 0)
5100
70
  {
5101
70
    if (syment->n_value == 0)
5102
67
      return COFF_SYMBOL_UNDEFINED;
5103
3
    else
5104
3
      return COFF_SYMBOL_COMMON;
5105
70
  }
5106
#ifdef RS6000COFF_C
5107
      if (syment->n_sclass == C_HIDEXT)
5108
  return COFF_SYMBOL_LOCAL;
5109
#endif
5110
96
      return COFF_SYMBOL_GLOBAL;
5111
5112
0
    default:
5113
0
      break;
5114
166
    }
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
166
}
Unexecuted instantiation: coff-stgo32.c:coff_classify_symbol
coff-tic30.c:coff_classify_symbol
Line
Count
Source
5076
180
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
180
  switch (syment->n_sclass)
5080
180
    {
5081
155
    case C_EXT:
5082
173
    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
173
#ifdef C_SYSTEM
5094
180
    case C_SYSTEM:
5095
180
#endif
5096
#ifdef COFF_WITH_PE
5097
    case C_NT_WEAK:
5098
#endif
5099
180
      if (syment->n_scnum == 0)
5100
16
  {
5101
16
    if (syment->n_value == 0)
5102
12
      return COFF_SYMBOL_UNDEFINED;
5103
4
    else
5104
4
      return COFF_SYMBOL_COMMON;
5105
16
  }
5106
#ifdef RS6000COFF_C
5107
      if (syment->n_sclass == C_HIDEXT)
5108
  return COFF_SYMBOL_LOCAL;
5109
#endif
5110
164
      return COFF_SYMBOL_GLOBAL;
5111
5112
0
    default:
5113
0
      break;
5114
180
    }
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
180
}
Unexecuted instantiation: coff-tic4x.c:coff_classify_symbol
coff-tic54x.c:coff_classify_symbol
Line
Count
Source
5076
440
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
440
  switch (syment->n_sclass)
5080
440
    {
5081
410
    case C_EXT:
5082
435
    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
435
#ifdef C_SYSTEM
5094
440
    case C_SYSTEM:
5095
440
#endif
5096
#ifdef COFF_WITH_PE
5097
    case C_NT_WEAK:
5098
#endif
5099
440
      if (syment->n_scnum == 0)
5100
67
  {
5101
67
    if (syment->n_value == 0)
5102
41
      return COFF_SYMBOL_UNDEFINED;
5103
26
    else
5104
26
      return COFF_SYMBOL_COMMON;
5105
67
  }
5106
#ifdef RS6000COFF_C
5107
      if (syment->n_sclass == C_HIDEXT)
5108
  return COFF_SYMBOL_LOCAL;
5109
#endif
5110
373
      return COFF_SYMBOL_GLOBAL;
5111
5112
0
    default:
5113
0
      break;
5114
440
    }
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
440
}
coff-z80.c:coff_classify_symbol
Line
Count
Source
5076
377
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
377
  switch (syment->n_sclass)
5080
377
    {
5081
357
    case C_EXT:
5082
368
    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
368
#ifdef C_SYSTEM
5094
377
    case C_SYSTEM:
5095
377
#endif
5096
#ifdef COFF_WITH_PE
5097
    case C_NT_WEAK:
5098
#endif
5099
377
      if (syment->n_scnum == 0)
5100
28
  {
5101
28
    if (syment->n_value == 0)
5102
18
      return COFF_SYMBOL_UNDEFINED;
5103
10
    else
5104
10
      return COFF_SYMBOL_COMMON;
5105
28
  }
5106
#ifdef RS6000COFF_C
5107
      if (syment->n_sclass == C_HIDEXT)
5108
  return COFF_SYMBOL_LOCAL;
5109
#endif
5110
349
      return COFF_SYMBOL_GLOBAL;
5111
5112
0
    default:
5113
0
      break;
5114
377
    }
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
377
}
coff-z8k.c:coff_classify_symbol
Line
Count
Source
5076
70
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
70
  switch (syment->n_sclass)
5080
70
    {
5081
24
    case C_EXT:
5082
38
    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
38
#ifdef C_SYSTEM
5094
70
    case C_SYSTEM:
5095
70
#endif
5096
#ifdef COFF_WITH_PE
5097
    case C_NT_WEAK:
5098
#endif
5099
70
      if (syment->n_scnum == 0)
5100
18
  {
5101
18
    if (syment->n_value == 0)
5102
13
      return COFF_SYMBOL_UNDEFINED;
5103
5
    else
5104
5
      return COFF_SYMBOL_COMMON;
5105
18
  }
5106
#ifdef RS6000COFF_C
5107
      if (syment->n_sclass == C_HIDEXT)
5108
  return COFF_SYMBOL_LOCAL;
5109
#endif
5110
52
      return COFF_SYMBOL_GLOBAL;
5111
5112
0
    default:
5113
0
      break;
5114
70
    }
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
70
}
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
167
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
167
  switch (syment->n_sclass)
5080
167
    {
5081
146
    case C_EXT:
5082
150
    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
150
#ifdef C_SYSTEM
5094
156
    case C_SYSTEM:
5095
156
#endif
5096
156
#ifdef COFF_WITH_PE
5097
164
    case C_NT_WEAK:
5098
164
#endif
5099
164
      if (syment->n_scnum == 0)
5100
31
  {
5101
31
    if (syment->n_value == 0)
5102
13
      return COFF_SYMBOL_UNDEFINED;
5103
18
    else
5104
18
      return COFF_SYMBOL_COMMON;
5105
31
  }
5106
#ifdef RS6000COFF_C
5107
      if (syment->n_sclass == C_HIDEXT)
5108
  return COFF_SYMBOL_LOCAL;
5109
#endif
5110
133
      return COFF_SYMBOL_GLOBAL;
5111
5112
3
    default:
5113
3
      break;
5114
167
    }
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
}
pe-mcore.c:coff_classify_symbol
Line
Count
Source
5076
319
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
319
  switch (syment->n_sclass)
5080
319
    {
5081
30
    case C_EXT:
5082
43
    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
43
#ifdef C_SYSTEM
5094
245
    case C_SYSTEM:
5095
245
#endif
5096
245
#ifdef COFF_WITH_PE
5097
312
    case C_NT_WEAK:
5098
312
#endif
5099
312
      if (syment->n_scnum == 0)
5100
15
  {
5101
15
    if (syment->n_value == 0)
5102
10
      return COFF_SYMBOL_UNDEFINED;
5103
5
    else
5104
5
      return COFF_SYMBOL_COMMON;
5105
15
  }
5106
#ifdef RS6000COFF_C
5107
      if (syment->n_sclass == C_HIDEXT)
5108
  return COFF_SYMBOL_LOCAL;
5109
#endif
5110
297
      return COFF_SYMBOL_GLOBAL;
5111
5112
7
    default:
5113
7
      break;
5114
319
    }
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
}
pe-sh.c:coff_classify_symbol
Line
Count
Source
5076
364
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
364
  switch (syment->n_sclass)
5080
364
    {
5081
348
    case C_EXT:
5082
357
    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
357
#ifdef C_SYSTEM
5094
360
    case C_SYSTEM:
5095
360
#endif
5096
360
#ifdef COFF_WITH_PE
5097
364
    case C_NT_WEAK:
5098
364
#endif
5099
364
      if (syment->n_scnum == 0)
5100
30
  {
5101
30
    if (syment->n_value == 0)
5102
22
      return COFF_SYMBOL_UNDEFINED;
5103
8
    else
5104
8
      return COFF_SYMBOL_COMMON;
5105
30
  }
5106
#ifdef RS6000COFF_C
5107
      if (syment->n_sclass == C_HIDEXT)
5108
  return COFF_SYMBOL_LOCAL;
5109
#endif
5110
334
      return COFF_SYMBOL_GLOBAL;
5111
5112
0
    default:
5113
0
      break;
5114
364
    }
5115
5116
0
#ifdef COFF_WITH_PE
5117
0
  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
0
  if (syment->n_sclass == C_SECTION)
5147
0
    {
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
0
      syment->n_value = 0;
5152
0
      if (syment->n_scnum == 0)
5153
0
  return COFF_SYMBOL_UNDEFINED;
5154
0
      return COFF_SYMBOL_PE_SECTION;
5155
0
    }
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
0
}
pei-arm-wince.c:coff_classify_symbol
Line
Count
Source
5076
14
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
14
  switch (syment->n_sclass)
5080
14
    {
5081
3
    case C_EXT:
5082
7
    case C_WEAKEXT:
5083
7
#ifdef ARM
5084
9
    case C_THUMBEXT:
5085
10
    case C_THUMBEXTFUNC:
5086
10
#endif
5087
#ifdef RS6000COFF_C
5088
    case C_HIDEXT:
5089
#ifndef AIX_WEAK_SUPPORT
5090
    case C_AIX_WEAKEXT:
5091
#endif
5092
#endif
5093
10
#ifdef C_SYSTEM
5094
10
    case C_SYSTEM:
5095
10
#endif
5096
10
#ifdef COFF_WITH_PE
5097
12
    case C_NT_WEAK:
5098
12
#endif
5099
12
      if (syment->n_scnum == 0)
5100
2
  {
5101
2
    if (syment->n_value == 0)
5102
0
      return COFF_SYMBOL_UNDEFINED;
5103
2
    else
5104
2
      return COFF_SYMBOL_COMMON;
5105
2
  }
5106
#ifdef RS6000COFF_C
5107
      if (syment->n_sclass == C_HIDEXT)
5108
  return COFF_SYMBOL_LOCAL;
5109
#endif
5110
10
      return COFF_SYMBOL_GLOBAL;
5111
5112
2
    default:
5113
2
      break;
5114
14
    }
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
}
pei-arm.c:coff_classify_symbol
Line
Count
Source
5076
11
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
11
  switch (syment->n_sclass)
5080
11
    {
5081
3
    case C_EXT:
5082
6
    case C_WEAKEXT:
5083
6
#ifdef ARM
5084
8
    case C_THUMBEXT:
5085
9
    case C_THUMBEXTFUNC:
5086
9
#endif
5087
#ifdef RS6000COFF_C
5088
    case C_HIDEXT:
5089
#ifndef AIX_WEAK_SUPPORT
5090
    case C_AIX_WEAKEXT:
5091
#endif
5092
#endif
5093
9
#ifdef C_SYSTEM
5094
9
    case C_SYSTEM:
5095
9
#endif
5096
9
#ifdef COFF_WITH_PE
5097
10
    case C_NT_WEAK:
5098
10
#endif
5099
10
      if (syment->n_scnum == 0)
5100
4
  {
5101
4
    if (syment->n_value == 0)
5102
1
      return COFF_SYMBOL_UNDEFINED;
5103
3
    else
5104
3
      return COFF_SYMBOL_COMMON;
5105
4
  }
5106
#ifdef RS6000COFF_C
5107
      if (syment->n_sclass == C_HIDEXT)
5108
  return COFF_SYMBOL_LOCAL;
5109
#endif
5110
6
      return COFF_SYMBOL_GLOBAL;
5111
5112
1
    default:
5113
1
      break;
5114
11
    }
5115
5116
1
#ifdef COFF_WITH_PE
5117
1
  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
1
  if (syment->n_sclass == C_SECTION)
5147
1
    {
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
1
      syment->n_value = 0;
5152
1
      if (syment->n_scnum == 0)
5153
1
  return COFF_SYMBOL_UNDEFINED;
5154
0
      return COFF_SYMBOL_PE_SECTION;
5155
1
    }
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
1
}
pei-mcore.c:coff_classify_symbol
Line
Count
Source
5076
45
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
45
  switch (syment->n_sclass)
5080
45
    {
5081
17
    case C_EXT:
5082
32
    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
32
#ifdef C_SYSTEM
5094
41
    case C_SYSTEM:
5095
41
#endif
5096
41
#ifdef COFF_WITH_PE
5097
43
    case C_NT_WEAK:
5098
43
#endif
5099
43
      if (syment->n_scnum == 0)
5100
21
  {
5101
21
    if (syment->n_value == 0)
5102
19
      return COFF_SYMBOL_UNDEFINED;
5103
2
    else
5104
2
      return COFF_SYMBOL_COMMON;
5105
21
  }
5106
#ifdef RS6000COFF_C
5107
      if (syment->n_sclass == C_HIDEXT)
5108
  return COFF_SYMBOL_LOCAL;
5109
#endif
5110
22
      return COFF_SYMBOL_GLOBAL;
5111
5112
2
    default:
5113
2
      break;
5114
45
    }
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
}
pei-sh.c:coff_classify_symbol
Line
Count
Source
5076
118
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
118
  switch (syment->n_sclass)
5080
118
    {
5081
78
    case C_EXT:
5082
91
    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
91
#ifdef C_SYSTEM
5094
109
    case C_SYSTEM:
5095
109
#endif
5096
109
#ifdef COFF_WITH_PE
5097
115
    case C_NT_WEAK:
5098
115
#endif
5099
115
      if (syment->n_scnum == 0)
5100
28
  {
5101
28
    if (syment->n_value == 0)
5102
15
      return COFF_SYMBOL_UNDEFINED;
5103
13
    else
5104
13
      return COFF_SYMBOL_COMMON;
5105
28
  }
5106
#ifdef RS6000COFF_C
5107
      if (syment->n_sclass == C_HIDEXT)
5108
  return COFF_SYMBOL_LOCAL;
5109
#endif
5110
87
      return COFF_SYMBOL_GLOBAL;
5111
5112
3
    default:
5113
3
      break;
5114
118
    }
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
}
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
0
#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
0
{
5238
0
  bfd_byte *native_relocs;
5239
0
  arelent *reloc_cache;
5240
0
  arelent *cache_ptr;
5241
0
  unsigned int idx;
5242
0
  size_t amt;
5243
5244
0
  if (asect->relocation)
5245
0
    return true;
5246
0
  if (asect->reloc_count == 0)
5247
0
    return true;
5248
0
  if (asect->flags & SEC_CONSTRUCTOR)
5249
0
    return true;
5250
0
  if (!coff_slurp_symbol_table (abfd))
5251
0
    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
#ifdef RELOC_PROCESSING
5286
0
      RELOC_PROCESSING (cache_ptr, &dst, symbols, abfd, asect);
5287
#else
5288
      cache_ptr->address = dst.r_vaddr;
5289
5290
0
      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
0
      else
5309
0
  {
5310
0
    cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
5311
0
    ptr = NULL;
5312
0
  }
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
0
      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
0
      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
}
Unexecuted instantiation: pei-i386.c:coff_slurp_reloc_table
Unexecuted instantiation: pe-x86_64.c:coff_slurp_reloc_table
Unexecuted instantiation: pei-x86_64.c:coff_slurp_reloc_table
Unexecuted instantiation: coff-x86_64.c:coff_slurp_reloc_table
Unexecuted instantiation: coff64-rs6000.c:coff_slurp_reloc_table
Unexecuted instantiation: 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
Unexecuted instantiation: coff-sh.c:coff_slurp_reloc_table
Unexecuted instantiation: coff-stgo32.c:coff_slurp_reloc_table
Unexecuted instantiation: coff-tic30.c:coff_slurp_reloc_table
Unexecuted instantiation: coff-tic4x.c:coff_slurp_reloc_table
Unexecuted instantiation: coff-tic54x.c:coff_slurp_reloc_table
Unexecuted instantiation: coff-z80.c:coff_slurp_reloc_table
Unexecuted instantiation: coff-z8k.c:coff_slurp_reloc_table
Unexecuted instantiation: pe-arm-wince.c:coff_slurp_reloc_table
Unexecuted instantiation: pe-arm.c:coff_slurp_reloc_table
Unexecuted instantiation: pe-i386.c:coff_slurp_reloc_table
Unexecuted instantiation: pe-mcore.c:coff_slurp_reloc_table
Unexecuted instantiation: pe-sh.c:coff_slurp_reloc_table
Unexecuted instantiation: pei-arm-wince.c:coff_slurp_reloc_table
Unexecuted instantiation: pei-arm.c:coff_slurp_reloc_table
Unexecuted instantiation: pei-mcore.c:coff_slurp_reloc_table
Unexecuted instantiation: pei-sh.c:coff_slurp_reloc_table
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
0
{
5388
0
  arelent *tblptr = section->relocation;
5389
0
  unsigned int count = 0;
5390
5391
0
  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
0
  else
5405
0
    {
5406
0
      if (! coff_slurp_reloc_table (abfd, section, symbols))
5407
0
  return -1;
5408
5409
0
      tblptr = section->relocation;
5410
5411
0
      for (; count++ < section->reloc_count;)
5412
0
  *relptr++ = tblptr++;
5413
0
    }
5414
0
  *relptr = 0;
5415
0
  return section->reloc_count;
5416
0
}
Unexecuted instantiation: pei-i386.c:coff_canonicalize_reloc
Unexecuted instantiation: pe-x86_64.c:coff_canonicalize_reloc
Unexecuted instantiation: pei-x86_64.c:coff_canonicalize_reloc
Unexecuted instantiation: coff-x86_64.c:coff_canonicalize_reloc
Unexecuted instantiation: coff64-rs6000.c:coff_canonicalize_reloc
Unexecuted instantiation: 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
Unexecuted instantiation: coff-sh.c:coff_canonicalize_reloc
Unexecuted instantiation: coff-stgo32.c:coff_canonicalize_reloc
Unexecuted instantiation: coff-tic30.c:coff_canonicalize_reloc
Unexecuted instantiation: coff-tic4x.c:coff_canonicalize_reloc
Unexecuted instantiation: coff-tic54x.c:coff_canonicalize_reloc
Unexecuted instantiation: coff-z80.c:coff_canonicalize_reloc
Unexecuted instantiation: coff-z8k.c:coff_canonicalize_reloc
Unexecuted instantiation: pe-arm-wince.c:coff_canonicalize_reloc
Unexecuted instantiation: pe-arm.c:coff_canonicalize_reloc
Unexecuted instantiation: pe-i386.c:coff_canonicalize_reloc
Unexecuted instantiation: pe-mcore.c:coff_canonicalize_reloc
Unexecuted instantiation: pe-sh.c:coff_canonicalize_reloc
Unexecuted instantiation: pei-arm-wince.c:coff_canonicalize_reloc
Unexecuted instantiation: pei-arm.c:coff_canonicalize_reloc
Unexecuted instantiation: pei-mcore.c:coff_canonicalize_reloc
Unexecuted instantiation: pei-sh.c:coff_canonicalize_reloc
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
224k
{
5706
224k
  struct external_ANON_OBJECT_HEADER_BIGOBJ *filehdr_src =
5707
224k
    (struct external_ANON_OBJECT_HEADER_BIGOBJ *) src;
5708
224k
  struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst;
5709
5710
224k
  filehdr_dst->f_magic  = H_GET_16 (abfd, filehdr_src->Machine);
5711
224k
  filehdr_dst->f_nscns  = H_GET_32 (abfd, filehdr_src->NumberOfSections);
5712
224k
  filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->TimeDateStamp);
5713
224k
  filehdr_dst->f_symptr =
5714
224k
    GET_FILEHDR_SYMPTR (abfd, filehdr_src->PointerToSymbolTable);
5715
224k
  filehdr_dst->f_nsyms  = H_GET_32 (abfd, filehdr_src->NumberOfSymbols);
5716
224k
  filehdr_dst->f_opthdr = 0;
5717
224k
  filehdr_dst->f_flags  = 0;
5718
5719
  /* Check other magic numbers.  */
5720
224k
  if (H_GET_16 (abfd, filehdr_src->Sig1) != IMAGE_FILE_MACHINE_UNKNOWN
5721
224k
      || H_GET_16 (abfd, filehdr_src->Sig2) != 0xffff
5722
224k
      || H_GET_16 (abfd, filehdr_src->Version) != 2
5723
224k
      || memcmp (filehdr_src->ClassID, header_bigobj_classid, 16) != 0)
5724
224k
    filehdr_dst->f_opthdr = 0xffff;
5725
5726
  /* Note that CLR metadata are ignored.  */
5727
224k
}
pe-x86_64.c:coff_bigobj_swap_filehdr_in
Line
Count
Source
5705
112k
{
5706
112k
  struct external_ANON_OBJECT_HEADER_BIGOBJ *filehdr_src =
5707
112k
    (struct external_ANON_OBJECT_HEADER_BIGOBJ *) src;
5708
112k
  struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst;
5709
5710
112k
  filehdr_dst->f_magic  = H_GET_16 (abfd, filehdr_src->Machine);
5711
112k
  filehdr_dst->f_nscns  = H_GET_32 (abfd, filehdr_src->NumberOfSections);
5712
112k
  filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->TimeDateStamp);
5713
112k
  filehdr_dst->f_symptr =
5714
112k
    GET_FILEHDR_SYMPTR (abfd, filehdr_src->PointerToSymbolTable);
5715
112k
  filehdr_dst->f_nsyms  = H_GET_32 (abfd, filehdr_src->NumberOfSymbols);
5716
112k
  filehdr_dst->f_opthdr = 0;
5717
112k
  filehdr_dst->f_flags  = 0;
5718
5719
  /* Check other magic numbers.  */
5720
112k
  if (H_GET_16 (abfd, filehdr_src->Sig1) != IMAGE_FILE_MACHINE_UNKNOWN
5721
112k
      || H_GET_16 (abfd, filehdr_src->Sig2) != 0xffff
5722
112k
      || H_GET_16 (abfd, filehdr_src->Version) != 2
5723
112k
      || memcmp (filehdr_src->ClassID, header_bigobj_classid, 16) != 0)
5724
112k
    filehdr_dst->f_opthdr = 0xffff;
5725
5726
  /* Note that CLR metadata are ignored.  */
5727
112k
}
pe-i386.c:coff_bigobj_swap_filehdr_in
Line
Count
Source
5705
112k
{
5706
112k
  struct external_ANON_OBJECT_HEADER_BIGOBJ *filehdr_src =
5707
112k
    (struct external_ANON_OBJECT_HEADER_BIGOBJ *) src;
5708
112k
  struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst;
5709
5710
112k
  filehdr_dst->f_magic  = H_GET_16 (abfd, filehdr_src->Machine);
5711
112k
  filehdr_dst->f_nscns  = H_GET_32 (abfd, filehdr_src->NumberOfSections);
5712
112k
  filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->TimeDateStamp);
5713
112k
  filehdr_dst->f_symptr =
5714
112k
    GET_FILEHDR_SYMPTR (abfd, filehdr_src->PointerToSymbolTable);
5715
112k
  filehdr_dst->f_nsyms  = H_GET_32 (abfd, filehdr_src->NumberOfSymbols);
5716
112k
  filehdr_dst->f_opthdr = 0;
5717
112k
  filehdr_dst->f_flags  = 0;
5718
5719
  /* Check other magic numbers.  */
5720
112k
  if (H_GET_16 (abfd, filehdr_src->Sig1) != IMAGE_FILE_MACHINE_UNKNOWN
5721
112k
      || H_GET_16 (abfd, filehdr_src->Sig2) != 0xffff
5722
112k
      || H_GET_16 (abfd, filehdr_src->Version) != 2
5723
112k
      || memcmp (filehdr_src->ClassID, header_bigobj_classid, 16) != 0)
5724
112k
    filehdr_dst->f_opthdr = 0xffff;
5725
5726
  /* Note that CLR metadata are ignored.  */
5727
112k
}
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
};